@domorium/validator 1.8.2 → 2.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,123 @@
2
2
 
3
3
  All notable changes to `@domorium/validator` are documented here.
4
4
 
5
+ ## 2.0.0 - 2026-08-20
6
+
7
+ Removes three members of `GedcomDocument` that no consumer read, which is what
8
+ makes this a major: `updateDocument`, which returned `this` and did nothing;
9
+ `xRefs`, a parse product nothing outside the package looked at; and the public
10
+ `pointers`, now private because writing to it poisoned the pointer-target cache
11
+ keyed on it. `getErrors` and `getNodes` lose parameters they never read — a
12
+ change to their types only, since JavaScript discards a surplus argument.
13
+
14
+ - **A 5.5.1 multimedia format is read without regard to case.** `2 FORM JPG` was
15
+ reported against a set the specification writes in lower case, so a file holding
16
+ the right value in the wrong spelling read as one holding a format 5.5.1 does not
17
+ have — and `FORM` is required under every `OBJE`.`FILE`, so an export writing
18
+ extensions in upper case earned an error per photograph. That set is now compared
19
+ without regard to case; `png` and `pdf`, which the specification has no spelling
20
+ for, are still reported. The LDS status sets, which 5.5.1 writes in upper case,
21
+ are unchanged: the case matters differently per set, so the set is named rather
22
+ than the comparison.
23
+ - **A tag typed in lower case is completed.** The lexer reads `1 sex` as the SEX
24
+ tag and the validator names the mistake — a tag is written in upper case, SEX —
25
+ but completion, which is the way out of it, matched upper case only: `1 se`
26
+ offered nothing where `1 SE` offered 62 tags, and a payload typed after `1 sex`
27
+ was offered nothing where after `1 SEX` it was offered the four values of the
28
+ enumeration. The typed tag is now read as the lexer reads it, and the schema is
29
+ asked about the tag it names rather than about the letters as they were typed.
30
+ - **A completion on a large document is answered in under a millisecond.** Every
31
+ request rebuilt the flattened node array and then filtered it, so a 300k-line
32
+ file paid 69 ms per keystroke — for a tree the last parse built and nothing has
33
+ touched since, where parsing and validating that whole file takes 492 ms once.
34
+ The walk is now cached against the array a parse replaces, and the line the
35
+ cursor sits on is found by halving the nodes rather than by reading the range of
36
+ every one before it: 6 ms for the first completion after a parse, 0.1 ms for
37
+ each one after that.
38
+ - **A second `createDocument` on one instance answers for the file it was given.**
39
+ A header naming a system before `GEDC`, a version no schema describes, and a
40
+ header naming no version at all each return before a schema is chosen, and the
41
+ schema, the extension tags and the GEDCOM 7 flag of the document read before
42
+ them stayed where they were: an instance that had read a 7.0 file offered
43
+ `SCHMA` while completing the header of a Personal Ancestral File, and labelled
44
+ a tag with a URI declared by a `HEAD`.`SCHMA` in another file. Parsing now
45
+ clears all three, so every call answers for its own text.
46
+ - **`GedcomDocument` no longer carries members nothing reads.** `updateDocument`
47
+ returned `this` and did nothing; `getErrors` took a language it never read and
48
+ `getNodes` a range it never read — and that `Range` was the DOM's, ambient
49
+ because the package pinned no `lib`, so `getNodes(new Range())` compiled in a
50
+ package that must also run in Node. `pointers` and `xRefs` were mutable parse
51
+ products no consumer outside the package read, and assigning to `pointers`
52
+ poisoned the pointer-target cache keyed on it. `getErrors()` and `getNodes()`
53
+ take no arguments, `pointers` is private and `updateDocument` and `xRefs` are
54
+ gone; the package compiles against `ES2023` alone, so a DOM global cannot be
55
+ named by accident again.
56
+ - **A 5.5.1 multimedia format and the four LDS ordinance statuses are read against
57
+ the value sets the specification spells out.** `3 FORM exe` beneath a FILE, and
58
+ `2 STAT nonsense` beneath BAPL, CONL, ENDL, SLGC or SLGS, were accepted: 5.5.1
59
+ states these closed sets in its primitive definitions rather than in an
60
+ enumeration vocabulary, so the scheme recorded only a type URI and the payload
61
+ was checked for one thing, that it was not empty. A multimedia FORM is now one
62
+ of `[bmp, gif, jpg, ole, pcx, tif, wav]` — 5.5 spelled two of those `jpeg` and
63
+ `tiff` — and each ordinance status one of the seven or eight the specification
64
+ lists for it. Their values are upper case where `PEDI` and `RESN` are lower, and
65
+ a file that mixes the two is now told so. Completion offers these values as well.
66
+ - **A payload type the validator does not describe is left alone, rather than
67
+ required to be a non-empty string.** Every payload type either schema declares is
68
+ now named, and a test over both says so. A type new to an upstream release used to
69
+ reach the same check as free text and report a missing value on every structure
70
+ that legitimately omits it; it now fails that test instead, where a person can see
71
+ it.
72
+ - **A 5.5.1 date is read against the calendar its escape names, and completion
73
+ offers one.** The twelve month tags lived in four places — the 5.5.1 date grammar,
74
+ the day-length table, the 7.0 `calendar` section and the completion reader's own
75
+ list — and 5.5.1, whose `calendar` section was empty, could use none of them. That
76
+ section now describes all six calendars 5.5.1 names, `validator/calendars.ts` is
77
+ the only reader of it, and the lengths stay in code with a test binding them to the
78
+ months both schemes name. `@#DHEBREW@ 45 XXX 5760` is reported rather than waved
79
+ through on a non-empty check, `@#DJULIAN@ 12 JAN 2000` is checked as a date rather
80
+ than accepted for being non-empty, and a date under `@#DROMAN@` or `@#DUNKNOWN@` —
81
+ calendars 5.5.1 names and gives no month — is still accepted, because an empty
82
+ month table says nothing rather than forbidding everything. Completion in a 5.5.1
83
+ file went from 8 candidates with the cursor after `2 DATE` to 26, the escapes and
84
+ the Gregorian months joining the modifiers; from none after `2 DATE 12` to 14; and
85
+ from none after `2 DATE 12 JAN 2000` to the two epoch spellings 5.5.1 writes.
86
+ Neither conformance corpus moved: 8 diagnostics over 23 official files, 14 795
87
+ over 14 vendor exports. See docs/adr/0012.
88
+
89
+ - **A document with more than about 125k diagnostics reports all of them instead of
90
+ none.** Diagnostics were gathered by spreading each level's array into its
91
+ parent's `push`, and a spread is one argument per element: V8 refuses somewhere
92
+ past 125k, so `createDocument` threw a `RangeError` for exceeding the call stack
93
+ and the caller got an exception where it had asked a question — not a truncated
94
+ list, none. A file of 130 000 records each carrying one tag the schema does not
95
+ define there now reports its 130 000 warnings. One array is carried down the walk
96
+ and pushed into, so nothing is capped and no array is allocated per node.
97
+ - **A line below one carrying a pointer but no tag answers nothing instead of
98
+ throwing.** `0 @I1@`, what a truncated export leaves behind, still becomes a node
99
+ and adopts the lines indented under it, so the walk from a node to the root met a
100
+ step with no tag and threw `TypeError: Cannot read properties of undefined`. Asking
101
+ for the type, the label or the pointer target of such a node — hovering
102
+ `1 NAME John /Doe/` is one way in — now gives the same empty answer already given
103
+ for a path the schema does not resolve.
104
+ - **A year followed by an extension epoch is a date.** `2 DATE 2000 _MYEPOCH` was
105
+ reported as an invalid date value. An extension tag is admissible as a month and
106
+ as an epoch alike, and the reader took the pair for a day and a month — leaving
107
+ the date with no year, which every date must have. A month is now read only when
108
+ the year it must precede follows it, so the epoch reading is the one left. The
109
+ same value under an extension calendar, `2 DATE _MYCAL 1900 _MYEPOCH`, was
110
+ rejected for the same reason and is now read too.
111
+
112
+ - **An unresolved pointer names the xref that failed, and lists nothing.** A `FAMC`
113
+ pointing at a family the file does not declare was reported as "Value for FAMC
114
+ should be in set [@F70@, @F75@, … 2853 more]" — the vocabulary of a closed set,
115
+ spent on ten families that were not the problem, ending in an admission that it
116
+ gave up. A pointer's set is the population of the document, so the diagnostic now
117
+ states the fact about the line: "No FAM record carries @F1450@". An enumeration
118
+ still lists its values, because for `SEX` the four of them are the whole answer.
119
+ Where the payload is not a pointer at all the message is unchanged — there the
120
+ shape is what is wrong, not the identifier.
121
+
5
122
  ## 1.8.2 - 2026-08-18
6
123
 
7
124
  - **A tag written in mixed case is read as written, and the message says which tag
package/README.md CHANGED
@@ -73,22 +73,27 @@ const unresolved = errors.filter(
73
73
  );
74
74
  ```
75
75
 
76
- | Code | Member | Reported when |
77
- | ----------------- | ---------------------- | ----------------------------------------------------------- |
78
- | `VAL001` | `UnknownTag` | a tag the schema does not define in this position |
79
- | `VAL002` | `MissingTag` | a structure the schema requires is absent |
80
- | `VAL003` | `MissingValue` | the payload is absent where one is required |
81
- | `VAL004` | `IncorrectValue` | the payload does not match its data type |
82
- | `VAL005` | `ShouldBeSetValue` | the payload is not one of the permitted values |
83
- | `VAL006` | `MissingRef` | a pointer payload that is not written as a pointer |
84
- | `VAL007` | `ManyOccurrences` | more occurrences than the cardinality allows |
85
- | `VAL008` | `UndocumentedTag` | a GEDCOM 7 extension tag with no `HEAD`.`SCHMA` declaration |
86
- | `VAL009` | `DuplicateDeclaration` | a tag declared more than once in `HEAD`.`SCHMA` |
87
- | `VAL010` | `EmptyEvent` | an event with neither a payload nor substructures |
88
- | `unresolved-xref` | `UnresolvedXref` | an xref naming no record of the required type |
89
- | `invalid-level` | `InvalidLevel` | a level that cannot follow the line above it |
90
- | `LEXER` | `Lexer` | the text could not be tokenized |
91
- | `PARSER` | `Parser` | the tokens could not be assembled into a tree |
76
+ | Code | Member | Reported when |
77
+ | ----------------- | ----------------------- | ------------------------------------------------------------------------------ |
78
+ | `VAL001` | `UnknownTag` | a tag the schema does not define in this position |
79
+ | `VAL002` | `MissingTag` | a structure the schema requires is absent |
80
+ | `VAL003` | `MissingValue` | the payload is absent where one is required |
81
+ | `VAL004` | `IncorrectValue` | the payload does not match its data type |
82
+ | `VAL005` | `ShouldBeSetValue` | the payload is not one of the permitted values |
83
+ | `VAL006` | `MissingRef` | a pointer payload that is not written as a pointer |
84
+ | `VAL007` | `ManyOccurrences` | more occurrences than the cardinality allows |
85
+ | `VAL008` | `UndocumentedTag` | a GEDCOM 7 extension tag with no `HEAD`.`SCHMA` declaration |
86
+ | `VAL009` | `DuplicateDeclaration` | a tag declared more than once in `HEAD`.`SCHMA` |
87
+ | `VAL010` | `EmptyEvent` | an event with neither a payload nor substructures |
88
+ | `VAL011` | `UnsupportedVersion` | the version is one no schema in this package describes |
89
+ | `VAL012` | `UndeterminedVersion` | no version could be read from `HEAD`.`GEDC`.`VERS` |
90
+ | `VAL013` | `SubstitutedVersion` | a version checked against a different version's schema |
91
+ | `VAL014` | `ImpossibleDay` | a date naming a day its calendar does not have, such as `31 FEB` |
92
+ | `VAL015` | `PersonalAncestralFile` | a header naming `SYST` before `GEDC`, so the file is a Personal Ancestral File |
93
+ | `unresolved-xref` | `UnresolvedXref` | an xref naming no record of the required type |
94
+ | `invalid-level` | `InvalidLevel` | a level that cannot follow the line above it |
95
+ | `LEXER` | `Lexer` | the text could not be tokenized |
96
+ | `PARSER` | `Parser` | the tokens could not be assembled into a tree |
92
97
 
93
98
  ## Scripts
94
99
 
@@ -3,6 +3,7 @@
3
3
  * nothing here: the months worth offering depend on the calendar named a few
4
4
  * tokens earlier, and the keywords depend on what the value opened with.
5
5
  */
6
+ import { GedcomScheme } from "../schemes/schema-types";
6
7
  export type DateGrammar = "value" | "period" | "exact";
7
8
  export interface DateSlot {
8
9
  /** A calendar may be named here. */
@@ -14,4 +15,4 @@ export interface DateSlot {
14
15
  /** Bare words the grammar allows here. */
15
16
  keywords: string[];
16
17
  }
17
- export declare function dateSlot(typed: string, grammar: DateGrammar): DateSlot;
18
+ export declare function dateSlot(scheme: GedcomScheme, typed: string, grammar: DateGrammar): DateSlot;
@@ -1,5 +1,5 @@
1
1
  import { GedcomError } from "../types/errors";
2
- import { ASTNode, ASTToken } from "../parser";
2
+ import { ASTNode } from "../parser";
3
3
  import { type GedcomDialect, type VersionResolution } from "../validator/versionRegistry";
4
4
  import { type GedcomCompletion } from "../completion/completion";
5
5
  import type { Position } from "../types/position";
@@ -11,8 +11,7 @@ export interface CreateDocumentOptions {
11
11
  }
12
12
  export declare class GedcomDocument {
13
13
  private nodes;
14
- pointers: Map<string, ASTNode[]>;
15
- xRefs: Map<string, ASTToken[]>;
14
+ private pointers;
16
15
  private errors;
17
16
  private scheme;
18
17
  private resolution;
@@ -29,7 +28,6 @@ export declare class GedcomDocument {
29
28
  getVersionResolution(): VersionResolution | undefined;
30
29
  getDialect(): GedcomDialect | undefined;
31
30
  getCompletions(position: Position, lineText: string): GedcomCompletion[];
32
- updateDocument(_text: string, _range: Range): GedcomDocument;
33
- getErrors(_lang?: string): GedcomError[];
34
- getNodes(_range?: Range): ASTNode[];
31
+ getErrors(): GedcomError[];
32
+ getNodes(): ASTNode[];
35
33
  }