@mailwoman/geographic-model 10.0.0 → 10.2.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 (62) hide show
  1. package/README.md +32 -32
  2. package/data/geographic-model.json +5 -5
  3. package/data/model/concepts.json +5 -5
  4. package/lib/artifact.ts +37 -65
  5. package/lib/compile.ts +55 -70
  6. package/lib/index.ts +22 -35
  7. package/lib/load.ts +60 -72
  8. package/lib/lookup.ts +12 -28
  9. package/lib/packaged.ts +50 -0
  10. package/lib/schema.ts +104 -97
  11. package/lib/validate.ts +32 -56
  12. package/lib/validation/issues.ts +32 -36
  13. package/lib/validation/references.ts +24 -27
  14. package/out/artifact.d.ts +28 -45
  15. package/out/artifact.d.ts.map +1 -1
  16. package/out/artifact.js +25 -52
  17. package/out/artifact.js.map +1 -1
  18. package/out/compile.d.ts +27 -41
  19. package/out/compile.d.ts.map +1 -1
  20. package/out/compile.js +42 -64
  21. package/out/compile.js.map +1 -1
  22. package/out/index.d.ts +22 -35
  23. package/out/index.d.ts.map +1 -1
  24. package/out/index.js +22 -35
  25. package/out/index.js.map +1 -1
  26. package/out/load.d.ts +30 -39
  27. package/out/load.d.ts.map +1 -1
  28. package/out/load.js +42 -56
  29. package/out/load.js.map +1 -1
  30. package/out/lookup.d.ts +12 -28
  31. package/out/lookup.d.ts.map +1 -1
  32. package/out/lookup.js +4 -16
  33. package/out/lookup.js.map +1 -1
  34. package/out/packaged.d.ts +24 -0
  35. package/out/packaged.d.ts.map +1 -0
  36. package/out/packaged.js +42 -0
  37. package/out/packaged.js.map +1 -0
  38. package/out/schema.d.ts +104 -97
  39. package/out/schema.d.ts.map +1 -1
  40. package/out/schema.js +37 -52
  41. package/out/schema.js.map +1 -1
  42. package/out/tools/build-artifact.d.ts +27 -0
  43. package/out/tools/build-artifact.d.ts.map +1 -0
  44. package/out/tools/build-artifact.js +44 -0
  45. package/out/tools/build-artifact.js.map +1 -0
  46. package/out/validate.d.ts +29 -50
  47. package/out/validate.d.ts.map +1 -1
  48. package/out/validate.js +12 -35
  49. package/out/validate.js.map +1 -1
  50. package/out/validation/issues.d.ts +17 -20
  51. package/out/validation/issues.d.ts.map +1 -1
  52. package/out/validation/issues.js +25 -29
  53. package/out/validation/issues.js.map +1 -1
  54. package/out/validation/references.d.ts.map +1 -1
  55. package/out/validation/references.js +20 -23
  56. package/out/validation/references.js.map +1 -1
  57. package/package.json +35 -76
  58. package/tools/build-artifact.ts +56 -0
  59. package/out/scripts/build-artifact.d.ts +0 -51
  60. package/out/scripts/build-artifact.d.ts.map +0 -1
  61. package/out/scripts/build-artifact.js +0 -85
  62. package/out/scripts/build-artifact.js.map +0 -1
package/out/load.d.ts CHANGED
@@ -3,36 +3,26 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The authoring loader: a directory of JSON files in, one {@link GeographicModelDocument} out.
6
+ * Loads a directory of JSON files into one {@link GeographicModelDocument}.
7
7
  *
8
- * **The filesystem layout is authoring convenience and carries no meaning.** A concept means the
9
- * same thing whichever file it was written in, and a file may hold any subset of the tables. What a
10
- * directory does carry is one manifest — `model.json`, holding the document's `version` — because a
11
- * version assembled from whichever fragment happened to declare one is a version nobody chose.
8
+ * File layout does not assign meaning to a file. Any file may hold any subset of the tables.
9
+ * Only `model.json` may declare the document's `version`.
12
10
  *
13
- * Two properties make the loader safe to build an artifact from:
11
+ * The loader sorts files by path before reading them, so directory enumeration order never affects
12
+ * the output. It records the source file of every record and maps each validation issue back to that
13
+ * file. A duplicate-identifier issue also reports the file that used the identifier first.
14
14
  *
15
- * 1. **Enumeration order cannot reach the output.** {@link mergeGeographicModelFiles} sorts the
16
- * files it was handed before reading any of them, so the merged tables are a function of the file
17
- * NAMES and their contents. `readdir` order, and therefore the filesystem, is out of the answer.
18
- * 2. **Every issue names the file it came from.** The document validator addresses a record by its
19
- * position in the merged table (`$.concepts[7].kind`), which is the one thing an author cannot
20
- * see; the loader keeps a per-record origin and re-addresses each issue to its source file. A
21
- * duplicate identifier names both files — the one that claimed it and the one that claimed it
22
- * first — because "already used" is unactionable without the other half.
23
- *
24
- * Validation itself is delegated whole to `./validate.ts`. What the loader checks on its own is only
25
- * what the validator cannot see: whether a file parses, whether it is an object, and whether the
26
- * keys it uses are tables.
15
+ * `./validate.ts` performs document validation. The loader checks only that each file parses, holds
16
+ * an object and uses known table keys.
27
17
  */
28
18
  import type { GeographicModelDocument } from "#schema";
29
19
  /**
30
- * The manifest every model directory carries: the document's `version`, and nothing else.
20
+ * The manifest file that every model directory contains.
21
+ * It holds only the document's `version`.
31
22
  */
32
23
  export declare const MODEL_MANIFEST_FILENAME = "model.json";
33
24
  /**
34
- * Every way loading can fail. The document validator's whole vocabulary, plus the one failure only a loader meets: a
35
- * file that is not JSON at all.
25
+ * Load issue codes: every validation code plus `MalformedJSON`.
36
26
  */
37
27
  export declare const LoadIssueCode: {
38
28
  readonly MissingField: "missing_field";
@@ -60,63 +50,64 @@ export declare const LoadIssueCode: {
60
50
  readonly TransitiveKindsDisjoint: "transitive_kinds_disjoint";
61
51
  readonly MalformedCountry: "malformed_country";
62
52
  /**
63
- * A source file could not be parsed as JSON. Emitted by the loader alone; the document validator is handed values,
64
- * never text.
53
+ * A source file is not valid JSON.
65
54
  */
66
55
  readonly MalformedJSON: "malformed_json";
67
56
  };
57
+ /**
58
+ * A {@link LoadIssueCode} value.
59
+ */
68
60
  export type LoadIssueCode = (typeof LoadIssueCode)[keyof typeof LoadIssueCode];
69
61
  /**
70
- * One violation, addressed to the file an author can open.
62
+ * One load issue, attributed to its source file.
71
63
  */
72
64
  export interface SourcedIssue {
73
65
  /**
74
- * The source file, relative to the model directory, with `/` separators on every platform.
66
+ * The source file path relative to the model directory, with `/` separators on every platform.
75
67
  */
76
68
  file: string;
77
69
  /**
78
- * The JSONPath-style address into the MERGED document, kept so a reader can find the record in the table the
79
- * validator saw.
70
+ * The JSONPath-style location in the merged document.
80
71
  */
81
72
  path: string;
82
73
  code: LoadIssueCode;
83
74
  message: string;
84
75
  /**
85
- * For a duplicate identifier: the file that claimed it first.
76
+ * For a duplicate identifier, the file that used the identifier first.
86
77
  */
87
- otherFile?: string;
78
+ otherFile: string | null;
88
79
  }
89
80
  /**
90
- * One authoring file: its path relative to the model directory, and its text.
81
+ * A source file's path relative to the model directory, plus its text.
91
82
  */
92
83
  export interface GeographicModelSourceFile {
93
84
  path: string;
94
85
  text: string;
95
86
  }
96
87
  /**
97
- * Render every issue as one line, `file:path: message [code]`, in the order the loader produced them.
88
+ * Formats each issue as one `file:path: message [code]` line, in input order.
98
89
  */
99
90
  export declare function formatSourcedIssues(issues: readonly SourcedIssue[]): string;
100
91
  /**
101
- * Thrown when a model directory does not load. Carries every issue, and states them all in its message, so a caller
102
- * that only prints `error.message` still sees the whole list.
92
+ * The error thrown when a model directory does not load.
93
+ * Its message lists every issue.
103
94
  */
104
95
  export declare class GeographicModelLoadError extends Error {
105
96
  readonly issues: readonly SourcedIssue[];
106
97
  constructor(issues: readonly SourcedIssue[]);
107
98
  }
108
99
  /**
109
- * Merge authoring files into one document, and validate the result.
100
+ * Merges source files into one document and validates it.
101
+ *
102
+ * The function sorts files by path first, so the input order never affects the result.
110
103
  *
111
- * The files are sorted by path before anything is read, so any enumeration order produces the same tables in the same
112
- * order. Throws {@link GeographicModelLoadError} with every issue, each addressed to its source file; returns nothing
113
- * partial.
104
+ * @throws {GeographicModelLoadError} With every issue, each attributed to its source file.
114
105
  */
115
106
  export declare function mergeGeographicModelFiles(files: readonly GeographicModelSourceFile[]): GeographicModelDocument;
116
107
  /**
117
- * Load a model directory: read every `*.json` file under it, merge them, and validate the result.
108
+ * Reads every `*.json` file under `root`, merges the files and validates the merged document.
118
109
  *
119
- * Throws {@link GeographicModelLoadError} with every issue, each addressed to its source file.
110
+ * @throws {GeographicModelLoadError} With every issue, each attributed to its source file.
120
111
  */
121
112
  export declare function loadGeographicModelDirectory(root: string): Promise<GeographicModelDocument>;
122
113
  //# sourceM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CAAC,CASjG"}
package/out/load.js CHANGED
@@ -3,27 +3,17 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The authoring loader: a directory of JSON files in, one {@link GeographicModelDocument} out.
6
+ * Loads a directory of JSON files into one {@link GeographicModelDocument}.
7
7
  *
8
- * **The filesystem layout is authoring convenience and carries no meaning.** A concept means the
9
- * same thing whichever file it was written in, and a file may hold any subset of the tables. What a
10
- * directory does carry is one manifest — `model.json`, holding the document's `version` — because a
11
- * version assembled from whichever fragment happened to declare one is a version nobody chose.
8
+ * File layout does not assign meaning to a file. Any file may hold any subset of the tables.
9
+ * Only `model.json` may declare the document's `version`.
12
10
  *
13
- * Two properties make the loader safe to build an artifact from:
11
+ * The loader sorts files by path before reading them, so directory enumeration order never affects
12
+ * the output. It records the source file of every record and maps each validation issue back to that
13
+ * file. A duplicate-identifier issue also reports the file that used the identifier first.
14
14
  *
15
- * 1. **Enumeration order cannot reach the output.** {@link mergeGeographicModelFiles} sorts the
16
- * files it was handed before reading any of them, so the merged tables are a function of the file
17
- * NAMES and their contents. `readdir` order, and therefore the filesystem, is out of the answer.
18
- * 2. **Every issue names the file it came from.** The document validator addresses a record by its
19
- * position in the merged table (`$.concepts[7].kind`), which is the one thing an author cannot
20
- * see; the loader keeps a per-record origin and re-addresses each issue to its source file. A
21
- * duplicate identifier names both files — the one that claimed it and the one that claimed it
22
- * first — because "already used" is unactionable without the other half.
23
- *
24
- * Validation itself is delegated whole to `./validate.ts`. What the loader checks on its own is only
25
- * what the validator cannot see: whether a file parses, whether it is an object, and whether the
26
- * keys it uses are tables.
15
+ * `./validate.ts` performs document validation. The loader checks only that each file parses, holds
16
+ * an object and uses known table keys.
27
17
  */
28
18
  import { readLocalTextFile } from "@mailwoman/core/fs/readers";
29
19
  import { isPlainObject } from "@mailwoman/core/objects";
@@ -33,33 +23,32 @@ import { Globerator } from "spliterator/node/fs";
33
23
  import { validateGeographicModelDocument } from "#validate";
34
24
  import { add, checkFieldNames, readArray, readString, ValidationIssueCode, } from "#validation/issues";
35
25
  /**
36
- * The manifest every model directory carries: the document's `version`, and nothing else.
26
+ * The manifest file that every model directory contains.
27
+ * It holds only the document's `version`.
37
28
  */
38
29
  export const MODEL_MANIFEST_FILENAME = "model.json";
39
30
  /**
40
- * The keys a source file may use. They are the document's tables, minus the manifest's `version`.
31
+ * The table keys that a non-manifest source file may use.
41
32
  */
42
33
  const TABLE_FIELDS = ["relations", "concepts", "mappings", "observations", "derivedFacts"];
43
34
  const MANIFEST_FIELDS = ["version"];
44
35
  /**
45
- * The document path a record occupies, e.g. `$.concepts[7]` or `$.concepts[7].assertions[1]`. Group 3 is present only
46
- * for an assertion, which is the one record that nests.
36
+ * Matches a record's path in the merged document, such as `$.concepts[7]` or `$.concepts[7].assertions[1]`.
37
+ * Group 3 matches only for a nested assertion.
47
38
  */
48
39
  const RECORD_PATH_PATTERN = /^\$\.([A-Za-z]+)\[(\d+)\](?:\.assertions\[(\d+)\])?/u;
49
40
  /**
50
- * Every way loading can fail. The document validator's whole vocabulary, plus the one failure only a loader meets: a
51
- * file that is not JSON at all.
41
+ * Load issue codes: every validation code plus `MalformedJSON`.
52
42
  */
53
43
  export const LoadIssueCode = {
54
44
  ...ValidationIssueCode,
55
45
  /**
56
- * A source file could not be parsed as JSON. Emitted by the loader alone; the document validator is handed values,
57
- * never text.
46
+ * A source file is not valid JSON.
58
47
  */
59
48
  MalformedJSON: "malformed_json",
60
49
  };
61
50
  /**
62
- * Render every issue as one line, `file:path: message [code]`, in the order the loader produced them.
51
+ * Formats each issue as one `file:path: message [code]` line, in input order.
63
52
  */
64
53
  export function formatSourcedIssues(issues) {
65
54
  return issues
@@ -70,8 +59,8 @@ export function formatSourcedIssues(issues) {
70
59
  .join("\n");
71
60
  }
72
61
  /**
73
- * Thrown when a model directory does not load. Carries every issue, and states them all in its message, so a caller
74
- * that only prints `error.message` still sees the whole list.
62
+ * The error thrown when a model directory does not load.
63
+ * Its message lists every issue.
75
64
  */
76
65
  export class GeographicModelLoadError extends Error {
77
66
  issues;
@@ -82,14 +71,12 @@ export class GeographicModelLoadError extends Error {
82
71
  }
83
72
  }
84
73
  function sourced(file, issues) {
85
- return issues.map((issue) => ({ file, path: issue.path, code: issue.code, message: issue.message }));
74
+ return issues.map((issue) => ({ file, path: issue.path, code: issue.code, message: issue.message, otherFile: null }));
86
75
  }
87
76
  /**
88
- * Parse one source file, or report why it could not be parsed.
77
+ * Parses one source file, or records the parse failure and returns `undefined`.
89
78
  *
90
- * The house wrapper lives in `@mailwoman/core/objects`, and this package takes no dependency on `@mailwoman/core` — the
91
- * boundary record keeps world semantics out of core, and a build-time loader is not the reason to reverse it. The
92
- * parser's own message is also the useful half of the report here, which a wrapper returning a fallback discards.
79
+ * The loader calls `JSON.parse` directly because the report needs the parser's error message.
93
80
  */
94
81
  function readSourceJSON(file, issues) {
95
82
  try {
@@ -102,12 +89,13 @@ function readSourceJSON(file, issues) {
102
89
  path: "$",
103
90
  code: LoadIssueCode.MalformedJSON,
104
91
  message: error instanceof Error ? error.message : String(error),
92
+ otherFile: null,
105
93
  });
106
94
  return undefined;
107
95
  }
108
96
  }
109
97
  function claim(state, table, id, file) {
110
- if (id === undefined)
98
+ if (!id)
111
99
  return;
112
100
  const claims = state.firstClaims.get(table) ?? new Map();
113
101
  state.firstClaims.set(table, claims);
@@ -117,8 +105,8 @@ function claim(state, table, id, file) {
117
105
  }
118
106
  function recordID(entry) {
119
107
  if (!isPlainObject(entry))
120
- return undefined;
121
- return typeof entry.id === "string" ? entry.id : undefined;
108
+ return null;
109
+ return typeof entry.id === "string" ? entry.id : null;
122
110
  }
123
111
  function readManifestFile(state, file, value) {
124
112
  const issues = [];
@@ -132,7 +120,7 @@ function readManifestFile(state, file, value) {
132
120
  state.issues.push(...sourced(file.path, issues));
133
121
  }
134
122
  /**
135
- * Append one file's tables to the merged document, recording where every record came from.
123
+ * Appends one file's tables to the merged document and records each record's origin.
136
124
  */
137
125
  function readTableFile(state, file, value) {
138
126
  const issues = [];
@@ -141,8 +129,7 @@ function readTableFile(state, file, value) {
141
129
  state.issues.push(...sourced(file.path, issues));
142
130
  return;
143
131
  }
144
- // `version` is admitted to the field check and then refused on its own, so the report names where a version belongs
145
- // instead of only saying the field is unknown here.
132
+ // The field check allows `version` so that the specific error below can say where it belongs.
146
133
  checkFieldNames(issues, "$", value, [...TABLE_FIELDS, ...MANIFEST_FIELDS]);
147
134
  if ("version" in value) {
148
135
  add(issues, "$.version", ValidationIssueCode.UnknownField, `the document's \`version\` is authored in \`${MODEL_MANIFEST_FILENAME}\`, not in a table file`);
@@ -173,33 +160,32 @@ function readTableFile(state, file, value) {
173
160
  state.issues.push(...sourced(file.path, issues));
174
161
  }
175
162
  /**
176
- * Re-address one validation issue from its position in the merged document to the file the record was authored in.
163
+ * Attributes one validation issue to the file that contains the record.
177
164
  */
178
165
  function attribute(state, issue) {
179
166
  const match = RECORD_PATH_PATTERN.exec(issue.path);
180
167
  const nested = match?.[3];
181
168
  const key = match ? `${match[1]}[${match[2]}]${nested ? `.assertions[${nested}]` : ""}` : undefined;
182
169
  const origin = key ? state.origins.get(key) : undefined;
183
- // A document-level issue — `$.version`, or the root itself — is about the manifest, which is the only file that
184
- // contributes anything outside a table.
170
+ // Only the manifest contributes fields outside the tables, so it owns document-level issues.
185
171
  const file = origin?.file ?? MODEL_MANIFEST_FILENAME;
186
172
  const claimant = issue.code === ValidationIssueCode.DuplicateID && origin?.id
187
173
  ? state.firstClaims.get(origin.table)?.get(origin.id)
188
- : undefined;
174
+ : null;
189
175
  return {
190
176
  file,
191
177
  path: issue.path,
192
178
  code: issue.code,
193
179
  message: issue.message,
194
- ...(claimant ? { otherFile: claimant } : {}),
180
+ otherFile: claimant ?? null,
195
181
  };
196
182
  }
197
183
  /**
198
- * Merge authoring files into one document, and validate the result.
184
+ * Merges source files into one document and validates it.
185
+ *
186
+ * The function sorts files by path first, so the input order never affects the result.
199
187
  *
200
- * The files are sorted by path before anything is read, so any enumeration order produces the same tables in the same
201
- * order. Throws {@link GeographicModelLoadError} with every issue, each addressed to its source file; returns nothing
202
- * partial.
188
+ * @throws {GeographicModelLoadError} With every issue, each attributed to its source file.
203
189
  */
204
190
  export function mergeGeographicModelFiles(files) {
205
191
  const state = {
@@ -207,6 +193,7 @@ export function mergeGeographicModelFiles(files) {
207
193
  tables: { relations: [], concepts: [], mappings: [], observations: [], derivedFacts: [] },
208
194
  origins: new Map(),
209
195
  firstClaims: new Map(),
196
+ version: null,
210
197
  };
211
198
  const ordered = files.toSorted((left, right) => compareIdentifiers(left.path, right.path));
212
199
  const manifest = ordered.find((file) => file.path === MODEL_MANIFEST_FILENAME);
@@ -216,6 +203,7 @@ export function mergeGeographicModelFiles(files) {
216
203
  path: "$",
217
204
  code: LoadIssueCode.MissingField,
218
205
  message: `a model directory carries \`${MODEL_MANIFEST_FILENAME}\`, holding the document's \`version\``,
206
+ otherFile: null,
219
207
  });
220
208
  }
221
209
  for (const file of ordered) {
@@ -228,7 +216,7 @@ export function mergeGeographicModelFiles(files) {
228
216
  }
229
217
  readTableFile(state, file, value);
230
218
  }
231
- // A record issue cannot be addressed to a file that failed to parse, so the structural pass reports alone.
219
+ // Validation issues cannot be attributed reliably after a structural failure, so those failures stop here.
232
220
  if (state.issues.length)
233
221
  throw new GeographicModelLoadError(state.issues);
234
222
  const result = validateGeographicModelDocument({ version: state.version, ...state.tables });
@@ -238,11 +226,9 @@ export function mergeGeographicModelFiles(files) {
238
226
  return result.document;
239
227
  }
240
228
  /**
241
- * Every `*.json` file under `root`, relative to it, in code-point order.
229
+ * Lists every `*.json` file under `root` as a relative path, sorted by code point at each level.
242
230
  *
243
- * Directory entries are sorted at each level rather than taken as `readdir` returns them, so the list is a property of
244
- * the tree and not of the filesystem that stored it. Symbolic links are not followed: a model directory is source, and
245
- * a link out of it is a record whose home nobody can state.
231
+ * Symbolic links are skipped because only regular files and directories match.
246
232
  */
247
233
  async function listSourceFiles(root, prefix = "") {
248
234
  const entries = await Globerator.from("*", {
@@ -264,9 +250,9 @@ async function listSourceFiles(root, prefix = "") {
264
250
  return found;
265
251
  }
266
252
  /**
267
- * Load a model directory: read every `*.json` file under it, merge them, and validate the result.
253
+ * Reads every `*.json` file under `root`, merges the files and validates the merged document.
268
254
  *
269
- * Throws {@link GeographicModelLoadError} with every issue, each addressed to its source file.
255
+ * @throws {GeographicModelLoadError} With every issue, each attributed to its source file.
270
256
  */
271
257
  export async function loadGeographicModelDirectory(root) {
272
258
  const paths = await listSourceFiles(root);
package/out/load.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sourceRoot":"","sources":["../lib/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,kBAAkB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGhD,OAAO,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EACN,GAAG,EACH,eAAe,EACf,SAAS,EACT,UAAU,EAEV,mBAAmB,GACnB,MAAM,oBAAoB,CAAA;AAC3B;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAA;AAEnD;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,CAAU,CAAA;AAInG,MAAM,eAAe,GAAG,CAAC,SAAS,CAAU,CAAA;AAE5C;;;GAGG;AACH,MAAM,mBAAmB,GAAG,sDAAsD,CAAA;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,GAAG,mBAAmB;IACtB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,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;QAE5D,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;YAElD,SAAQ;QACT,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,IAAY;IAC9D,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;IACzC,MAAM,KAAK,GAAgC,EAAE,CAAA;IAE7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAA;IAC7E,CAAC;IAED,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC"}
package/out/lookup.d.ts CHANGED
@@ -3,62 +3,46 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The read surface over a compiled artifact: every question answered by one map probe, none by
7
- * walking the graph.
8
- *
9
- * The shape is deliberate. `@mailwoman/geographic-model` compiles authored records into an artifact
10
- * precisely so a runtime consumer never traverses anything — so the index exposes lookups
11
- * (`concept`, `ancestorsOf`, `derivedFactsAbout`, `conceptsForExternalID`) and no walk, no cursor,
12
- * and no query language.
13
- *
14
- * Two absences are distinguished everywhere, because they are different answers. A lookup for a
15
- * concept the artifact does not carry returns `undefined` — the model cannot speak to it. A lookup
16
- * for a concept it does carry, which nothing was derived about, returns an empty list — the model
17
- * carries it and states nothing. A reader that collapsed the two would report "no ancestors" for a
18
- * concept it had never heard of.
6
+ * Read-only lookups over a compiled artifact. Queries use prebuilt maps rather than traversing the graph.
7
+ * The lookup returns `undefined` for unknown concepts and an empty list for known concepts with no related facts.
19
8
  */
20
9
  import type { POICategoryID } from "@mailwoman/poi-taxonomy/types";
21
10
  import type { CompiledGeographicModel } from "#artifact";
22
11
  import type { ConceptID, ConceptRecord, DerivedFactRecord, ExternalVocabulary, RelationID, RelationRecord } from "#schema";
23
12
  /**
24
- * Lookups over one compiled artifact.
13
+ * Lookup methods for one compiled artifact.
25
14
  */
26
15
  export interface GeographicModelIndex {
27
16
  /**
28
- * The artifact these lookups read, so a consumer holding the index never has to carry both.
17
+ * Compiled artifact used by this index.
29
18
  */
30
19
  readonly model: CompiledGeographicModel;
31
20
  /**
32
- * One concept record, or `undefined` when the artifact does not carry it.
21
+ * Concept record, or `undefined` if absent.
33
22
  */
34
23
  concept(id: ConceptID): ConceptRecord | undefined;
35
24
  /**
36
- * One relation definition, or `undefined` when the artifact does not carry it.
25
+ * Relation definition, or `undefined` if absent.
37
26
  */
38
27
  relation(id: RelationID): RelationRecord | undefined;
39
28
  /**
40
- * Every concept this one is a kind of, transitively, in code-point order. Empty for a concept that is a kind of
41
- * nothing; `undefined` for a concept the artifact does not carry.
29
+ * Transitive ancestors in code-point order; `undefined` if the concept is absent.
42
30
  */
43
31
  ancestorsOf(id: ConceptID): readonly ConceptID[] | undefined;
44
32
  /**
45
- * Every derived fact whose subject is this concept, in artifact order. Empty for a concept nothing was derived about;
46
- * `undefined` for a concept the artifact does not carry.
33
+ * Derived facts in artifact order; `undefined` if the concept is absent.
47
34
  */
48
35
  derivedFactsAbout(id: ConceptID): readonly DerivedFactRecord[] | undefined;
49
36
  /**
50
- * The concepts a mapping translates this external identifier into, in code-point order.
51
- *
52
- * An empty list is a true negative rather than an unread answer: the artifact carries every mapping the document
53
- * authored, so nothing having declared this identifier is the whole of what there is to know about it.
37
+ * Concepts mapped from this external ID, in code-point order.
38
+ * An empty list means no mapping is recorded.
54
39
  */
55
40
  conceptsForExternalID(vocabulary: ExternalVocabulary, externalID: POICategoryID): readonly ConceptID[];
56
41
  }
57
42
  /**
58
- * Index a compiled artifact for reading.
43
+ * Build lookup maps over a compiled artifact.
59
44
  *
60
- * Every table is walked once here so that no table is ever walked again. Nothing is copied — the records handed back
61
- * are the artifact's own.
45
+ * Return references to the artifact's records without copying them.
62
46
  */
63
47
  export declare function createGeographicModelIndex(model: CompiledGeographicModel): GeographicModelIndex;
64
48
  //# sourceMappingURL=lookup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lib/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAElE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,KAAK,EACX,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,MAAM,SAAS,CAAA;AAEhB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,uBAAuB,CAAA;IACvC;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS,CAAA;IACjD;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,cAAc,GAAG,SAAS,CAAA;IACpD;;;OAGG;IACH,WAAW,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE,GAAG,SAAS,CAAA;IAC5D;;;OAGG;IACH,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,i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,17 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The read surface over a compiled artifact: every question answered by one map probe, none by
7
- * walking the graph.
8
- *
9
- * The shape is deliberate. `@mailwoman/geographic-model` compiles authored records into an artifact
10
- * precisely so a runtime consumer never traverses anything — so the index exposes lookups
11
- * (`concept`, `ancestorsOf`, `derivedFactsAbout`, `conceptsForExternalID`) and no walk, no cursor,
12
- * and no query language.
13
- *
14
- * Two absences are distinguished everywhere, because they are different answers. A lookup for a
15
- * concept the artifact does not carry returns `undefined` — the model cannot speak to it. A lookup
16
- * for a concept it does carry, which nothing was derived about, returns an empty list — the model
17
- * carries it and states nothing. A reader that collapsed the two would report "no ancestors" for a
18
- * concept it had never heard of.
6
+ * Read-only lookups over a compiled artifact. Queries use prebuilt maps rather than traversing the graph.
7
+ * The lookup returns `undefined` for unknown concepts and an empty list for known concepts with no related facts.
19
8
  */
20
9
  import { compareByCodePoint as compareIdentifiers } from "@mailwoman/core/strings/compare";
21
10
  function externalKey(vocabulary, externalID) {
22
11
  return `${vocabulary}\u0000${externalID}`;
23
12
  }
24
13
  /**
25
- * Index a compiled artifact for reading.
14
+ * Build lookup maps over a compiled artifact.
26
15
  *
27
- * Every table is walked once here so that no table is ever walked again. Nothing is copied — the records handed back
28
- * are the artifact's own.
16
+ * Return references to the artifact's records without copying them.
29
17
  */
30
18
  export function createGeographicModelIndex(model) {
31
19
  const concepts = new Map(model.concepts.map((concept) => [String(concept.id), concept]));
package/out/lookup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lib/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,kBAAkB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAgD1F,SAAS,WAAW,CAAC,UAA8B,EAAE,UAAkB;IACtE,OAAO,GAAG,UAAU,SAAS,UAAU,EAAE,CAAA;AAC1C,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AC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACjG,qBAAqB,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE;YACjD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;YAEzE,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAC3D,CAAC;KACD,CAAA;AACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Reads the compiled model this package ships in `data/geographic-model.json`.
6
+ */
7
+ import { type CompiledGeographicModel } from "#artifact";
8
+ /**
9
+ * The authoring directory and the artifact it compiles to.
10
+ *
11
+ * Probes for `model/model.json`, so a genuinely missing `data/` throws naming the path.
12
+ */
13
+ export declare function packagedModelPaths(): Promise<{
14
+ source: string;
15
+ artifact: string;
16
+ }>;
17
+ /**
18
+ * Read the committed artifact.
19
+ *
20
+ * The reader checks the format version.
21
+ * It trusts the records because the loader validated them on input.
22
+ */
23
+ export declare function readCompiledGeographicModel(): Promise<CompiledGeographicModel>;
24
+ //# sourceMappingURL=packaged.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packaged.d.ts","sourceRoot":"","sources":["../lib/packaged.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAE,KAAK,uBAAuB,EAAgC,MAAM,WAAW,CAAA;AAEtF;;;;GAIG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAexF;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAOpF"}