@domorium/validator 1.4.0 → 1.6.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 +55 -0
- package/README.md +17 -0
- package/dist/document/gedcomDocument.d.ts +13 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +331 -222
- package/dist/types/errors.d.ts +6 -0
- package/dist/validator/validate.d.ts +5 -1
- package/dist/validator/versionRegistry.d.ts +30 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@domorium/validator` are documented here.
|
|
4
4
|
|
|
5
|
+
## 1.6.0 - 2026-08-12
|
|
6
|
+
|
|
7
|
+
- **A fragment can be checked without being told it is not a file.** Text that is
|
|
8
|
+
part of a document rather than one of its own — a block pasted into a note, an
|
|
9
|
+
example in documentation, a selection — was judged as a whole file, so the one
|
|
10
|
+
thing certainly not the author's mistake was the first thing reported, and
|
|
11
|
+
nothing after it was read at all. `createDocument(text, { fragment: true,
|
|
12
|
+
dialect })` reads the lines and goes quiet only about what the boundary caused:
|
|
13
|
+
the missing header and trailer, a pointer leaving the text, an extension tag
|
|
14
|
+
with no `HEAD.SCHMA` to declare it in. An unknown tag, a payload of the wrong
|
|
15
|
+
type and a level that cannot follow the line above are still reported.
|
|
16
|
+
- `dialect` is named by the caller because a fragment carries no
|
|
17
|
+
`HEAD.GEDC.VERS`; without one there are still no rules to read it by.
|
|
18
|
+
|
|
19
|
+
## 1.5.0 - 2026-08-10
|
|
20
|
+
|
|
21
|
+
- **The GEDCOM version is resolved against a table by longest match, and a
|
|
22
|
+
version we hold no schema for no longer validates against the newest one.**
|
|
23
|
+
`2 VERS 4.0`, a garbage version and a document with no `VERS` line were all
|
|
24
|
+
checked against GEDCOM 7 and reported clean, because nothing they were checked
|
|
25
|
+
against applied to them. Three codes replace that silence: `VAL011` for a
|
|
26
|
+
version no schema describes, `VAL012` for a document whose version cannot be
|
|
27
|
+
read, `VAL013` for one checked against another version's schema. The first two
|
|
28
|
+
suppress every schema-derived diagnostic, while lexing, tree assembly and
|
|
29
|
+
level validation still run — a 4.0 file with a level that cannot follow the
|
|
30
|
+
line above it still says so. `5.5`, `5.5.5` and `5.5 EL` are checked against
|
|
31
|
+
the 5.5.1 schema with a warning naming the substitution; `5.6`, `5.4`, `5.3`,
|
|
32
|
+
`5.0` and `4` are not, because the difference runs the wrong way and the
|
|
33
|
+
substitution would report false errors on correct lines.
|
|
34
|
+
- **A structure the specification gives no substructures accepted any child.**
|
|
35
|
+
`getRules` answered `undefined` both for a leaf and for a type it could not
|
|
36
|
+
resolve, and the permissive reading of the two won: 57 structures in GEDCOM 7
|
|
37
|
+
and 89 in 5.5.1 accepted anything at all, `TRLR` among them in 5.5.1. So
|
|
38
|
+
|
|
39
|
+
0 @S1@ SOUR
|
|
40
|
+
1 TITL Open Archieven
|
|
41
|
+
2 BOGUS whatever
|
|
42
|
+
|
|
43
|
+
reported nothing. A child of a leaf structure is now an unknown tag.
|
|
44
|
+
|
|
45
|
+
- `2 VERS 5.5.1`, with more than one space after the tag, selected the GEDCOM 7
|
|
46
|
+
schema and the file came back clean. The delimiter after a tag belongs to the
|
|
47
|
+
payload, so the version is trimmed before it selects anything. Present since
|
|
48
|
+
1.2.0.
|
|
49
|
+
- The inline form of a 5.5.1 multimedia link was unreachable, so `1 OBJE` with
|
|
50
|
+
`FILE` and `TITL` written beneath it reported `FILE` as an unknown tag. Both
|
|
51
|
+
shapes now resolve. One type serves both, so a pointer carrying children and an
|
|
52
|
+
inline form with only a `TITL` are accepted where the specification allows
|
|
53
|
+
neither; telling them apart needs a schema that can offer two types for one
|
|
54
|
+
tag.
|
|
55
|
+
- New on `GedcomDocument`: `getVersionResolution()` returns the outcome above
|
|
56
|
+
without parsing a message, and `getDialect()` names the version whose rules
|
|
57
|
+
apply — or nothing, for a version we cannot judge. `VersionResolution` and
|
|
58
|
+
`GedcomDialect` are exported alongside them.
|
|
59
|
+
|
|
5
60
|
## 1.4.0 - 2026-08-09
|
|
6
61
|
|
|
7
62
|
- Read a `HEAD.SCHMA` tag whose URI is a standard one as the structure it names.
|
package/README.md
CHANGED
|
@@ -25,6 +25,23 @@ const document = new GedcomDocument().createDocument(gedcomString);
|
|
|
25
25
|
const errors = document.getErrors();
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Fragments
|
|
29
|
+
|
|
30
|
+
A fenced block in a note, an example in documentation, a selection: text that is
|
|
31
|
+
part of a document rather than one of its own.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const block = new GedcomDocument().createDocument(text, {
|
|
35
|
+
fragment: true,
|
|
36
|
+
dialect: "7.0",
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
What goes quiet is what the boundary caused — the header and trailer, a pointer
|
|
41
|
+
leaving the text, an extension tag with no `HEAD.SCHMA` to declare it in.
|
|
42
|
+
Everything else is still read. `dialect` is needed because a fragment carries no
|
|
43
|
+
`HEAD.GEDC.VERS`.
|
|
44
|
+
|
|
28
45
|
## Diagnostics
|
|
29
46
|
|
|
30
47
|
`getErrors()` returns `GedcomError[]`:
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { GedcomError } from "../types/errors";
|
|
2
2
|
import { ASTNode, ASTToken } from "../parser";
|
|
3
|
+
import { type GedcomDialect, type VersionResolution } from "../validator/versionRegistry";
|
|
3
4
|
import { type GedcomCompletion } from "../completion/completion";
|
|
4
5
|
import type { Position } from "../types/position";
|
|
6
|
+
export interface CreateDocumentOptions {
|
|
7
|
+
/** Text that is part of a document rather than one of its own. */
|
|
8
|
+
fragment?: boolean;
|
|
9
|
+
/** A fragment carries no header, so the rules are named rather than read. */
|
|
10
|
+
dialect?: GedcomDialect;
|
|
11
|
+
}
|
|
5
12
|
export declare class GedcomDocument {
|
|
6
13
|
private nodes;
|
|
7
14
|
pointers: Map<string, ASTNode[]>;
|
|
8
15
|
xRefs: Map<string, ASTToken[]>;
|
|
9
16
|
private errors;
|
|
10
17
|
private scheme;
|
|
18
|
+
private resolution;
|
|
19
|
+
private requiresSchmaDeclaration;
|
|
11
20
|
private extensions;
|
|
12
21
|
private parseGedcom;
|
|
13
|
-
createDocument(text: string): GedcomDocument;
|
|
22
|
+
createDocument(text: string, options?: CreateDocumentOptions): GedcomDocument;
|
|
23
|
+
private applyScheme;
|
|
14
24
|
private validateLevels;
|
|
15
25
|
getLabel(node: ASTNode): string | undefined;
|
|
16
26
|
getPointerTargetTag(node: ASTNode): string | undefined;
|
|
17
27
|
isRecordDeclaration(node: ASTNode): boolean;
|
|
18
28
|
getVersion(): string | undefined;
|
|
29
|
+
getVersionResolution(): VersionResolution | undefined;
|
|
30
|
+
getDialect(): GedcomDialect | undefined;
|
|
19
31
|
getCompletions(position: Position, lineText: string): GedcomCompletion[];
|
|
20
32
|
updateDocument(_text: string, _range: Range): GedcomDocument;
|
|
21
33
|
getErrors(_lang?: string): GedcomError[];
|