@mailwoman/geographic-model 0.0.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.
Files changed (51) hide show
  1. package/README.md +155 -0
  2. package/artifact.ts +198 -0
  3. package/compile.ts +350 -0
  4. package/data/geographic-model.json +172 -0
  5. package/data/model/concepts.json +114 -0
  6. package/data/model/mappings.json +18 -0
  7. package/data/model/model.json +3 -0
  8. package/data/model/relations.json +14 -0
  9. package/index.ts +51 -0
  10. package/load.ts +396 -0
  11. package/lookup.ts +129 -0
  12. package/out/artifact.d.ts +106 -0
  13. package/out/artifact.d.ts.map +1 -0
  14. package/out/artifact.js +135 -0
  15. package/out/artifact.js.map +1 -0
  16. package/out/compile.d.ts +84 -0
  17. package/out/compile.d.ts.map +1 -0
  18. package/out/compile.js +259 -0
  19. package/out/compile.js.map +1 -0
  20. package/out/index.d.ts +51 -0
  21. package/out/index.d.ts.map +1 -0
  22. package/out/index.js +51 -0
  23. package/out/index.js.map +1 -0
  24. package/out/load.d.ts +122 -0
  25. package/out/load.d.ts.map +1 -0
  26. package/out/load.js +269 -0
  27. package/out/load.js.map +1 -0
  28. package/out/lookup.d.ts +64 -0
  29. package/out/lookup.d.ts.map +1 -0
  30. package/out/lookup.js +68 -0
  31. package/out/lookup.js.map +1 -0
  32. package/out/schema.d.ts +366 -0
  33. package/out/schema.d.ts.map +1 -0
  34. package/out/schema.js +166 -0
  35. package/out/schema.js.map +1 -0
  36. package/out/scripts/build-artifact.d.ts +51 -0
  37. package/out/scripts/build-artifact.d.ts.map +1 -0
  38. package/out/scripts/build-artifact.js +78 -0
  39. package/out/scripts/build-artifact.js.map +1 -0
  40. package/out/validate.d.ts +67 -0
  41. package/out/validate.d.ts.map +1 -0
  42. package/out/validate.js +465 -0
  43. package/out/validate.js.map +1 -0
  44. package/out/validation-issues.d.ts +84 -0
  45. package/out/validation-issues.d.ts.map +1 -0
  46. package/out/validation-issues.js +190 -0
  47. package/out/validation-issues.js.map +1 -0
  48. package/package.json +120 -0
  49. package/schema.ts +399 -0
  50. package/validate.ts +845 -0
  51. package/validation-issues.ts +305 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-artifact.js","sourceRoot":"","sources":["../../scripts/build-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAgC,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AACnH,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACvC,4HAA4H,CAAA;AAE7H;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB;IACjC,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAA;IACxG,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;IAEhG,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,2DAA2D,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpG,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,uBAAuB,CAAC,EAAE,CAAA;AAC9F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B;IAC7C,OAAO,sBAAsB,CAAC,4BAA4B,CAAC,kBAAkB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACzF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAEhE,8GAA8G;IAC9G,0FAA0F;IAC1F,2EAA2E;IAC3E,OAAO,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,IAAI;IACZ,MAAM,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAA;IACzC,MAAM,KAAK,GAAG,8BAA8B,EAAE,CAAA;IAE9C,aAAa,CAAC,QAAQ,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAA;IAEtD,OAAO,CAAC,GAAG,CACV,SAAS,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC,MAAM,cAAc,KAAK,CAAC,SAAS,CAAC,MAAM,eAAe,KAAK,CAAC,QAAQ,CAAC,MAAM,cAAc,KAAK,CAAC,YAAY,CAAC,MAAM,kBAAkB,KAAK,CAAC,YAAY,CAAC,MAAM,yBAAyB,KAAK,CAAC,YAAY,GAAG,CACnP,CAAA;AACF,CAAC;AAED,+GAA+G;AAC/G,8DAA8D;AAC9D,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACtB,IAAI,EAAE,CAAA;AACP,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Deterministic validation of a {@link GeographicModelDocument}. Plain TypeScript: no reasoner, no
7
+ * query engine, no schema library, and no I/O — the same input always produces the same issue list.
8
+ *
9
+ * The validator reports EVERY violation it finds. A record set is authored by hand and read by a
10
+ * compiler, so a validator that stops at the first problem hands its author one defect per run. It
11
+ * also never returns a partial document: either the input satisfies every rule and is returned
12
+ * whole, or nothing is returned and every issue is named with the path it was found at. There is no
13
+ * third answer in which some records were dropped quietly, because a dropped record is
14
+ * indistinguishable from a world that does not contain it.
15
+ *
16
+ * Two passes, in this order, and both always run:
17
+ *
18
+ * 1. **Shape.** Field presence, field types, closed-vocabulary membership, and unknown keys. An
19
+ * unknown key whose name announces ranking policy — a boost, a penalty, a weight, a rank, a
20
+ * score — is reported under its own code rather than as an anonymous stray field, because that
21
+ * is the one authoring mistake this package exists to refuse.
22
+ * 2. **Whole-table references.** Duplicate identifiers, `isA` self-reference and cycles, relation
23
+ * and concept resolution, relation domain and range kinds, inverse reciprocity, and derivation
24
+ * inputs. These are answerable only once every table has been read, which is why they are
25
+ * reported after the shape issues rather than interleaved with them.
26
+ *
27
+ * Consumed by #1926's compiler, which validates before it emits, and by #1927's authored document.
28
+ */
29
+ import { type GeographicModelDocument } from "./schema.ts";
30
+ import { type ValidationIssue } from "./validation-issues.ts";
31
+ export { type ValidationIssue, ValidationIssueCode } from "./validation-issues.ts";
32
+ /**
33
+ * The whole document, or every reason it is not one.
34
+ */
35
+ export type ValidationResult = {
36
+ ok: true;
37
+ document: GeographicModelDocument;
38
+ } | {
39
+ ok: false;
40
+ issues: ValidationIssue[];
41
+ };
42
+ /**
43
+ * Validate an authored geographic-model document.
44
+ *
45
+ * Returns the document whole, or every reason it is not one. Issues arrive in traversal order — shape issues per record
46
+ * in table order, then whole-table reference issues — so two runs over the same input produce the same list.
47
+ */
48
+ export declare function validateGeographicModelDocument(input: unknown): ValidationResult;
49
+ /**
50
+ * Render every issue as one line, `path: message [code]`, in the order the validator produced them.
51
+ */
52
+ export declare function formatValidationIssues(issues: readonly ValidationIssue[]): string;
53
+ /**
54
+ * Thrown by {@link parseGeographicModelDocument}. Carries the whole issue list, and states the whole issue list in its
55
+ * message, so a caller that only ever prints `error.message` still sees every violation.
56
+ */
57
+ export declare class GeographicModelValidationError extends Error {
58
+ readonly issues: readonly ValidationIssue[];
59
+ constructor(issues: readonly ValidationIssue[]);
60
+ }
61
+ /**
62
+ * Validate and return an authored document, throwing {@link GeographicModelValidationError} with every violation if it
63
+ * does not validate. The throwing form is for callers with no partial-result behavior to offer — a compiler, a build
64
+ * step, a test.
65
+ */
66
+ export declare function parseGeographicModelDocument(input: unknown): GeographicModelDocument;
67
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAKN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAA;AACpB,OAAO,EAWN,KAAK,eAAe,EAEpB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,KAAK,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAElF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACzB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC/C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAA;AA+tB3C;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAQhF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEjF;AAED;;;GAGG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IACxD,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;gBAE/B,MAAM,EAAE,SAAS,eAAe,EAAE;CAM9C;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAMpF"}
@@ -0,0 +1,465 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Deterministic validation of a {@link GeographicModelDocument}. Plain TypeScript: no reasoner, no
7
+ * query engine, no schema library, and no I/O — the same input always produces the same issue list.
8
+ *
9
+ * The validator reports EVERY violation it finds. A record set is authored by hand and read by a
10
+ * compiler, so a validator that stops at the first problem hands its author one defect per run. It
11
+ * also never returns a partial document: either the input satisfies every rule and is returned
12
+ * whole, or nothing is returned and every issue is named with the path it was found at. There is no
13
+ * third answer in which some records were dropped quietly, because a dropped record is
14
+ * indistinguishable from a world that does not contain it.
15
+ *
16
+ * Two passes, in this order, and both always run:
17
+ *
18
+ * 1. **Shape.** Field presence, field types, closed-vocabulary membership, and unknown keys. An
19
+ * unknown key whose name announces ranking policy — a boost, a penalty, a weight, a rank, a
20
+ * score — is reported under its own code rather than as an anonymous stray field, because that
21
+ * is the one authoring mistake this package exists to refuse.
22
+ * 2. **Whole-table references.** Duplicate identifiers, `isA` self-reference and cycles, relation
23
+ * and concept resolution, relation domain and range kinds, inverse reciprocity, and derivation
24
+ * inputs. These are answerable only once every table has been read, which is why they are
25
+ * reported after the shape issues rather than interleaved with them.
26
+ *
27
+ * Consumed by #1926's compiler, which validates before it emits, and by #1927's authored document.
28
+ */
29
+ import { ConceptKind, ConceptStatus, DerivationInputKind, ExternalVocabulary, Modality, RelationSemantics, } from "./schema.js";
30
+ import { add, checkFieldNames, isPlainObject, listVocabulary, readArray, readBoolean, readString, readStringArray, readVocabularyArray, readVocabularyValue, ValidationIssueCode, } from "./validation-issues.js";
31
+ export { ValidationIssueCode } from "./validation-issues.js";
32
+ const DOCUMENT_FIELDS = ["version", "relations", "concepts", "mappings", "observations", "derivedFacts"];
33
+ const PROVENANCE_FIELDS = ["source", "sourceVersion", "sourceRecord", "sourceURL", "authoredAt", "notes"];
34
+ const OPTIONAL_PROVENANCE_FIELDS = ["sourceVersion", "sourceRecord", "sourceURL", "authoredAt", "notes"];
35
+ const RELATION_FIELDS = [
36
+ "id",
37
+ "label",
38
+ "description",
39
+ "domainKinds",
40
+ "rangeKinds",
41
+ "transitive",
42
+ "symmetric",
43
+ "inverse",
44
+ "semantics",
45
+ ];
46
+ const ASSERTION_FIELDS = ["id", "relation", "target", "modality", "countries", "provenance"];
47
+ const CONCEPT_FIELDS = ["id", "label", "description", "kind", "isA", "assertions", "provenance", "status"];
48
+ const MAPPING_FIELDS = ["id", "concept", "vocabulary", "externalID", "provenance"];
49
+ const OBSERVATION_FIELDS = ["id", "subject", "relation", "object", "modality", "countries", "provenance"];
50
+ const DERIVED_FACT_FIELDS = [
51
+ "id",
52
+ "derivation",
53
+ "inputs",
54
+ "subject",
55
+ "relation",
56
+ "object",
57
+ "modality",
58
+ "countries",
59
+ ];
60
+ const DERIVATION_INPUT_FIELDS = ["kind", "id"];
61
+ /**
62
+ * ISO 3166-1 alpha-2, upper case. A lower-case or three-letter value is an authoring mistake that would otherwise scope
63
+ * a claim to a country nothing else in the system names.
64
+ */
65
+ const COUNTRY_PATTERN = /^[A-Z]{2}$/;
66
+ function readCountries(issues, path, container) {
67
+ const values = readStringArray(issues, path, container, "countries", false);
68
+ if (!values)
69
+ return;
70
+ for (const [index, value] of values.entries()) {
71
+ if (!COUNTRY_PATTERN.test(value)) {
72
+ add(issues, `${path}.countries[${index}]`, ValidationIssueCode.MalformedCountry, `\`${value}\` is not an upper-case ISO 3166-1 alpha-2 code`);
73
+ }
74
+ }
75
+ }
76
+ function readProvenance(issues, path, container) {
77
+ const value = container.provenance;
78
+ const fieldPath = `${path}.provenance`;
79
+ if (value === undefined) {
80
+ add(issues, fieldPath, ValidationIssueCode.MissingField, "`provenance` is required");
81
+ return;
82
+ }
83
+ if (!isPlainObject(value)) {
84
+ add(issues, fieldPath, ValidationIssueCode.WrongType, "`provenance` must be an object");
85
+ return;
86
+ }
87
+ checkFieldNames(issues, fieldPath, value, PROVENANCE_FIELDS);
88
+ readString(issues, fieldPath, value, "source", true);
89
+ for (const key of OPTIONAL_PROVENANCE_FIELDS) {
90
+ readString(issues, fieldPath, value, key, false);
91
+ }
92
+ }
93
+ /**
94
+ * Read the `label` and `description` an authored record carries.
95
+ */
96
+ function readNarration(issues, path, value) {
97
+ readString(issues, path, value, "label", true);
98
+ readString(issues, path, value, "description", true);
99
+ }
100
+ function readRelation(issues, path, value) {
101
+ const conceptKinds = Object.values(ConceptKind);
102
+ checkFieldNames(issues, path, value, RELATION_FIELDS);
103
+ const id = readString(issues, path, value, "id", true);
104
+ readNarration(issues, path, value);
105
+ const kindCode = ValidationIssueCode.UnknownConceptKind;
106
+ const domainKinds = readVocabularyArray(issues, path, value, "domainKinds", conceptKinds, kindCode);
107
+ const rangeKinds = readVocabularyArray(issues, path, value, "rangeKinds", conceptKinds, kindCode);
108
+ const transitive = readBoolean(issues, path, value, "transitive");
109
+ const symmetric = readBoolean(issues, path, value, "symmetric");
110
+ const inverse = readString(issues, path, value, "inverse", false);
111
+ readVocabularyValue(issues, path, value, "semantics", Object.values(RelationSemantics), ValidationIssueCode.UnknownRelationSemantics);
112
+ return { path, id, domainKinds, rangeKinds, transitive, symmetric, inverse };
113
+ }
114
+ function readAssertion(issues, path, value) {
115
+ checkFieldNames(issues, path, value, ASSERTION_FIELDS);
116
+ const id = readString(issues, path, value, "id", true);
117
+ const relation = readString(issues, path, value, "relation", true);
118
+ const target = readString(issues, path, value, "target", true);
119
+ readVocabularyValue(issues, path, value, "modality", Object.values(Modality), ValidationIssueCode.UnknownModality);
120
+ readCountries(issues, path, value);
121
+ readProvenance(issues, path, value);
122
+ return { path, id, relation, target };
123
+ }
124
+ function readConcept(issues, path, value) {
125
+ checkFieldNames(issues, path, value, CONCEPT_FIELDS);
126
+ const id = readString(issues, path, value, "id", true);
127
+ readNarration(issues, path, value);
128
+ const kind = readVocabularyValue(issues, path, value, "kind", Object.values(ConceptKind), ValidationIssueCode.UnknownConceptKind);
129
+ const isA = readStringArray(issues, path, value, "isA", true);
130
+ const assertions = [];
131
+ for (const [index, entry] of (readArray(issues, path, value, "assertions", true) ?? []).entries()) {
132
+ const entryPath = `${path}.assertions[${index}]`;
133
+ if (!isPlainObject(entry)) {
134
+ add(issues, entryPath, ValidationIssueCode.WrongType, "an assertion must be an object");
135
+ continue;
136
+ }
137
+ assertions.push(readAssertion(issues, entryPath, entry));
138
+ }
139
+ readProvenance(issues, path, value);
140
+ readVocabularyValue(issues, path, value, "status", Object.values(ConceptStatus), ValidationIssueCode.UnknownConceptStatus);
141
+ return { path, id, kind, isA, assertions };
142
+ }
143
+ function readMapping(issues, path, value) {
144
+ checkFieldNames(issues, path, value, MAPPING_FIELDS);
145
+ const id = readString(issues, path, value, "id", true);
146
+ const concept = readString(issues, path, value, "concept", true);
147
+ readVocabularyValue(issues, path, value, "vocabulary", Object.values(ExternalVocabulary), ValidationIssueCode.UnknownExternalVocabulary);
148
+ readString(issues, path, value, "externalID", true);
149
+ readProvenance(issues, path, value);
150
+ return { path, id, concept };
151
+ }
152
+ function readObservation(issues, path, value) {
153
+ checkFieldNames(issues, path, value, OBSERVATION_FIELDS);
154
+ const id = readString(issues, path, value, "id", true);
155
+ const subject = readString(issues, path, value, "subject", true);
156
+ const relation = readString(issues, path, value, "relation", true);
157
+ const object = readString(issues, path, value, "object", true);
158
+ readVocabularyValue(issues, path, value, "modality", Object.values(Modality), ValidationIssueCode.UnknownModality);
159
+ readCountries(issues, path, value);
160
+ readProvenance(issues, path, value);
161
+ return { path, id, subject, relation, object };
162
+ }
163
+ function readDerivationInput(issues, path, value) {
164
+ checkFieldNames(issues, path, value, DERIVATION_INPUT_FIELDS);
165
+ const kind = readVocabularyValue(issues, path, value, "kind", Object.values(DerivationInputKind), ValidationIssueCode.UnknownDerivationInputKind);
166
+ return { path, kind, id: readString(issues, path, value, "id", true) };
167
+ }
168
+ function readDerivedFact(issues, path, value) {
169
+ checkFieldNames(issues, path, value, DERIVED_FACT_FIELDS);
170
+ const id = readString(issues, path, value, "id", true);
171
+ readString(issues, path, value, "derivation", true);
172
+ const entries = readArray(issues, path, value, "inputs", true);
173
+ const inputs = [];
174
+ if (entries && !entries.length) {
175
+ add(issues, `${path}.inputs`, ValidationIssueCode.EmptyList, "a derived fact names the records its derivation read; an empty list is a fact with no provenance");
176
+ }
177
+ for (const [index, entry] of (entries ?? []).entries()) {
178
+ const entryPath = `${path}.inputs[${index}]`;
179
+ if (!isPlainObject(entry)) {
180
+ add(issues, entryPath, ValidationIssueCode.WrongType, "a derivation input must be an object");
181
+ continue;
182
+ }
183
+ inputs.push(readDerivationInput(issues, entryPath, entry));
184
+ }
185
+ const subject = readString(issues, path, value, "subject", true);
186
+ const relation = readString(issues, path, value, "relation", true);
187
+ const object = readString(issues, path, value, "object", true);
188
+ readVocabularyValue(issues, path, value, "modality", Object.values(Modality), ValidationIssueCode.UnknownModality);
189
+ readCountries(issues, path, value);
190
+ return { path, id, inputs, subject, relation, object };
191
+ }
192
+ function readTable(issues, document, key, label, read) {
193
+ const entries = readArray(issues, "$", document, key, true);
194
+ const records = [];
195
+ for (const [index, entry] of (entries ?? []).entries()) {
196
+ const entryPath = `$.${key}[${index}]`;
197
+ if (!isPlainObject(entry)) {
198
+ add(issues, entryPath, ValidationIssueCode.WrongType, `a ${label} must be an object`);
199
+ continue;
200
+ }
201
+ records.push(read(issues, entryPath, entry));
202
+ }
203
+ return records;
204
+ }
205
+ /**
206
+ * Index a table by identifier, reporting every record after the first that claims an identifier already taken. The
207
+ * first claimant keeps the identifier, so a duplicate never silently displaces the record other rows resolve against.
208
+ */
209
+ function indexByID(issues, records, label) {
210
+ const index = new Map();
211
+ for (const record of records) {
212
+ if (record.id === undefined)
213
+ continue;
214
+ if (index.has(record.id)) {
215
+ add(issues, `${record.path}.id`, ValidationIssueCode.DuplicateID, `\`${record.id}\` is already used by another ${label}`);
216
+ continue;
217
+ }
218
+ index.set(record.id, record);
219
+ }
220
+ return index;
221
+ }
222
+ /**
223
+ * Resolve one subject–relation–object edge and check it against the relation's declared domain and range kinds.
224
+ *
225
+ * Shared by authored assertions, source observations, and derived facts. The three differ in who stands behind them and
226
+ * in what provenance they carry, and the structural question asked of them is the same one.
227
+ */
228
+ function checkEdge(issues, edge, tables) {
229
+ const relation = edge.relationID === undefined ? undefined : tables.relations.get(edge.relationID);
230
+ if (edge.relationID !== undefined && !relation) {
231
+ add(issues, edge.relationPath, ValidationIssueCode.UnknownRelation, `\`${edge.relationID}\` is not a relation declared in this document`);
232
+ }
233
+ const object = edge.objectID === undefined ? undefined : tables.concepts.get(edge.objectID);
234
+ if (edge.objectID !== undefined && !object) {
235
+ add(issues, edge.objectPath, ValidationIssueCode.UnknownConcept, `\`${edge.objectID}\` is not a concept declared in this document`);
236
+ }
237
+ if (!relation)
238
+ return;
239
+ if (edge.subjectKind && relation.domainKinds && !relation.domainKinds.includes(edge.subjectKind)) {
240
+ add(issues, edge.subjectPath, ValidationIssueCode.DomainKindMismatch, `relation \`${relation.id}\` accepts ${listVocabulary(relation.domainKinds)} on the asserting side, not \`${edge.subjectKind}\``);
241
+ }
242
+ if (object?.kind && relation.rangeKinds && !relation.rangeKinds.includes(object.kind)) {
243
+ add(issues, edge.objectPath, ValidationIssueCode.RangeKindMismatch, `relation \`${relation.id}\` accepts ${listVocabulary(relation.rangeKinds)} on the target side, not \`${object.kind}\``);
244
+ }
245
+ }
246
+ function sameKinds(left, right) {
247
+ return left.length === right.length && left.every((kind) => right.includes(kind));
248
+ }
249
+ /**
250
+ * Check one relation's inverse and its transitivity against the kinds it declares.
251
+ */
252
+ function checkRelation(issues, relation, index) {
253
+ const inversePath = `${relation.path}.inverse`;
254
+ if (relation.transitive === true && relation.domainKinds && relation.rangeKinds) {
255
+ const chainable = relation.rangeKinds.some((kind) => relation.domainKinds?.includes(kind));
256
+ if (!chainable) {
257
+ add(issues, `${relation.path}.transitive`, ValidationIssueCode.TransitiveKindsDisjoint, "a transitive relation has to be able to chain, so its range kinds and its domain kinds must overlap");
258
+ }
259
+ }
260
+ if (relation.inverse === undefined)
261
+ return;
262
+ const inverse = index.get(relation.inverse);
263
+ if (!inverse) {
264
+ add(issues, inversePath, ValidationIssueCode.UnknownRelation, `\`${relation.inverse}\` is not a relation declared in this document`);
265
+ return;
266
+ }
267
+ if (relation.symmetric === true && inverse.id !== relation.id) {
268
+ add(issues, inversePath, ValidationIssueCode.InverseNotReciprocal, `\`${relation.id}\` is symmetric, so it is its own inverse; it names \`${relation.inverse}\``);
269
+ return;
270
+ }
271
+ if (inverse.inverse !== relation.id) {
272
+ add(issues, inversePath, ValidationIssueCode.InverseNotReciprocal, `\`${relation.inverse}\` does not name \`${relation.id}\` as its own inverse`);
273
+ }
274
+ if (inverse.id !== relation.id &&
275
+ relation.domainKinds &&
276
+ relation.rangeKinds &&
277
+ inverse.domainKinds &&
278
+ inverse.rangeKinds &&
279
+ !(sameKinds(relation.domainKinds, inverse.rangeKinds) && sameKinds(relation.rangeKinds, inverse.domainKinds))) {
280
+ add(issues, inversePath, ValidationIssueCode.InverseKindsMismatch, `an inverse reads the same edge backwards, so \`${relation.inverse}\` has to declare this relation's range kinds as its domain kinds, and the reverse`);
281
+ }
282
+ }
283
+ /**
284
+ * Follow `isA` upward from one concept and report the trail if it returns to where it started.
285
+ *
286
+ * The direct self-edge is left out of the walk: `checkIsA` already reports that as a self-reference, at the entry that
287
+ * carries it, and a second report saying the same concept cycles through itself tells its author nothing new.
288
+ */
289
+ function findIsACycle(start, concepts) {
290
+ if (start.id === undefined)
291
+ return undefined;
292
+ const startID = start.id;
293
+ const visited = new Set();
294
+ const frontier = (start.isA ?? [])
295
+ .filter((parent) => parent !== startID)
296
+ .map((parent) => ({ id: parent, trail: [startID, parent] }));
297
+ while (frontier.length) {
298
+ const step = frontier.pop();
299
+ if (!step)
300
+ break;
301
+ if (step.id === startID)
302
+ return step.trail;
303
+ if (visited.has(step.id))
304
+ continue;
305
+ visited.add(step.id);
306
+ for (const parent of concepts.get(step.id)?.isA ?? []) {
307
+ frontier.push({ id: parent, trail: [...step.trail, parent] });
308
+ }
309
+ }
310
+ return undefined;
311
+ }
312
+ function checkIsA(issues, concept, concepts) {
313
+ if (!concept.isA)
314
+ return;
315
+ for (const [index, parent] of concept.isA.entries()) {
316
+ const parentPath = `${concept.path}.isA[${index}]`;
317
+ if (parent === concept.id) {
318
+ add(issues, parentPath, ValidationIssueCode.SelfReference, "a concept is not a kind of itself");
319
+ continue;
320
+ }
321
+ if (!concepts.has(parent)) {
322
+ add(issues, parentPath, ValidationIssueCode.UnknownConcept, `\`${parent}\` is not a concept declared in this document`);
323
+ }
324
+ }
325
+ const cycle = findIsACycle(concept, concepts);
326
+ if (cycle) {
327
+ add(issues, `${concept.path}.isA`, ValidationIssueCode.CyclicIsA, `\`isA\` cycles through ${cycle.join(" → ")}`);
328
+ }
329
+ }
330
+ function checkDerivationInputs(issues, fact, tables) {
331
+ const byKind = {
332
+ [DerivationInputKind.Concept]: tables.concepts,
333
+ [DerivationInputKind.Relation]: tables.relations,
334
+ [DerivationInputKind.Assertion]: tables.assertions,
335
+ [DerivationInputKind.Mapping]: tables.mappings,
336
+ [DerivationInputKind.Observation]: tables.observations,
337
+ [DerivationInputKind.DerivedFact]: tables.derivedFacts,
338
+ };
339
+ for (const input of fact.inputs) {
340
+ if (input.kind === undefined || input.id === undefined)
341
+ continue;
342
+ if (input.kind === DerivationInputKind.DerivedFact && input.id === fact.id) {
343
+ add(issues, `${input.path}.id`, ValidationIssueCode.SelfReference, "a derived fact is not one of its own inputs");
344
+ continue;
345
+ }
346
+ if (!byKind[input.kind].has(input.id)) {
347
+ add(issues, `${input.path}.id`, ValidationIssueCode.UnknownDerivationInput, `no \`${input.kind}\` record in this document is identified by \`${input.id}\``);
348
+ }
349
+ }
350
+ }
351
+ function checkReferences(issues, view) {
352
+ const assertions = [];
353
+ for (const concept of view.concepts) {
354
+ assertions.push(...concept.assertions);
355
+ }
356
+ const relations = indexByID(issues, view.relations, "relation");
357
+ const concepts = indexByID(issues, view.concepts, "concept");
358
+ const tables = {
359
+ relations,
360
+ concepts,
361
+ assertions: indexByID(issues, assertions, "assertion"),
362
+ mappings: indexByID(issues, view.mappings, "mapping"),
363
+ observations: indexByID(issues, view.observations, "observation"),
364
+ derivedFacts: indexByID(issues, view.derivedFacts, "derived fact"),
365
+ };
366
+ for (const relation of view.relations) {
367
+ checkRelation(issues, relation, relations);
368
+ }
369
+ for (const concept of view.concepts) {
370
+ checkIsA(issues, concept, concepts);
371
+ for (const assertion of concept.assertions) {
372
+ checkEdge(issues, {
373
+ subjectKind: concept.kind,
374
+ subjectPath: `${assertion.path}.relation`,
375
+ relationID: assertion.relation,
376
+ relationPath: `${assertion.path}.relation`,
377
+ objectID: assertion.target,
378
+ objectPath: `${assertion.path}.target`,
379
+ }, tables);
380
+ }
381
+ }
382
+ for (const mapping of view.mappings) {
383
+ if (mapping.concept !== undefined && !concepts.has(mapping.concept)) {
384
+ add(issues, `${mapping.path}.concept`, ValidationIssueCode.UnknownConcept, `\`${mapping.concept}\` is not a concept declared in this document`);
385
+ }
386
+ }
387
+ for (const triple of [...view.observations, ...view.derivedFacts]) {
388
+ const subject = triple.subject === undefined ? undefined : concepts.get(triple.subject);
389
+ if (triple.subject !== undefined && !subject) {
390
+ add(issues, `${triple.path}.subject`, ValidationIssueCode.UnknownConcept, `\`${triple.subject}\` is not a concept declared in this document`);
391
+ }
392
+ checkEdge(issues, {
393
+ subjectKind: subject?.kind,
394
+ subjectPath: `${triple.path}.subject`,
395
+ relationID: triple.relation,
396
+ relationPath: `${triple.path}.relation`,
397
+ objectID: triple.object,
398
+ objectPath: `${triple.path}.object`,
399
+ }, tables);
400
+ }
401
+ for (const fact of view.derivedFacts) {
402
+ checkDerivationInputs(issues, fact, tables);
403
+ }
404
+ }
405
+ function collectIssues(input) {
406
+ const issues = [];
407
+ if (!isPlainObject(input)) {
408
+ add(issues, "$", ValidationIssueCode.WrongType, "a geographic-model document must be an object");
409
+ return issues;
410
+ }
411
+ checkFieldNames(issues, "$", input, DOCUMENT_FIELDS);
412
+ readString(issues, "$", input, "version", true);
413
+ checkReferences(issues, {
414
+ relations: readTable(issues, input, "relations", "relation", readRelation),
415
+ concepts: readTable(issues, input, "concepts", "concept", readConcept),
416
+ mappings: readTable(issues, input, "mappings", "mapping", readMapping),
417
+ observations: readTable(issues, input, "observations", "observation", readObservation),
418
+ derivedFacts: readTable(issues, input, "derivedFacts", "derived fact", readDerivedFact),
419
+ });
420
+ return issues;
421
+ }
422
+ /**
423
+ * Validate an authored geographic-model document.
424
+ *
425
+ * Returns the document whole, or every reason it is not one. Issues arrive in traversal order — shape issues per record
426
+ * in table order, then whole-table reference issues — so two runs over the same input produce the same list.
427
+ */
428
+ export function validateGeographicModelDocument(input) {
429
+ const issues = collectIssues(input);
430
+ if (issues.length)
431
+ return { ok: false, issues };
432
+ // A clean input IS the document — the validator reads, it never rewrites. Keeping the assertion in this function,
433
+ // where `input` is still `unknown`, is what makes it a single step rather than a cast through `unknown`.
434
+ return { ok: true, document: input };
435
+ }
436
+ /**
437
+ * Render every issue as one line, `path: message [code]`, in the order the validator produced them.
438
+ */
439
+ export function formatValidationIssues(issues) {
440
+ return issues.map((issue) => `${issue.path}: ${issue.message} [${issue.code}]`).join("\n");
441
+ }
442
+ /**
443
+ * Thrown by {@link parseGeographicModelDocument}. Carries the whole issue list, and states the whole issue list in its
444
+ * message, so a caller that only ever prints `error.message` still sees every violation.
445
+ */
446
+ export class GeographicModelValidationError extends Error {
447
+ issues;
448
+ constructor(issues) {
449
+ super(`geographic-model document is invalid (${issues.length} issues)\n${formatValidationIssues(issues)}`);
450
+ this.name = "GeographicModelValidationError";
451
+ this.issues = issues;
452
+ }
453
+ }
454
+ /**
455
+ * Validate and return an authored document, throwing {@link GeographicModelValidationError} with every violation if it
456
+ * does not validate. The throwing form is for callers with no partial-result behavior to offer — a compiler, a build
457
+ * step, a test.
458
+ */
459
+ export function parseGeographicModelDocument(input) {
460
+ const result = validateGeographicModelDocument(input);
461
+ if (!result.ok)
462
+ throw new GeographicModelValidationError(result.issues);
463
+ return result.document;
464
+ }
465
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACN,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAElB,QAAQ,EACR,iBAAiB,GACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,GAAG,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACd,SAAS,EACT,WAAW,EACX,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EAEnB,mBAAmB,GACnB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAwB,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AASlF,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,CAAU,CAAA;AACjH,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,CAAU,CAAA;AAClH,MAAM,0BAA0B,GAAG,CAAC,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,CAAU,CAAA;AAEjH,MAAM,eAAe,GAAG;IACvB,IAAI;IACJ,OAAO;IACP,aAAa;IACb,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,SAAS;IACT,WAAW;CACF,CAAA;AAEV,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,CAAU,CAAA;AACrG,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAA;AACnH,MAAM,cAAc,GAAG,CAAC,IAAI,E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