@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/dist/types/errors.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export declare enum GedcomErrorCode {
|
|
|
24
24
|
DuplicateDeclaration = "VAL009",
|
|
25
25
|
/** An event with neither a payload nor substructures asserts nothing. */
|
|
26
26
|
EmptyEvent = "VAL010",
|
|
27
|
+
/** The version is one no schema in this package describes. */
|
|
28
|
+
UnsupportedVersion = "VAL011",
|
|
29
|
+
/** No version could be read from HEAD.GEDC.VERS. */
|
|
30
|
+
UndeterminedVersion = "VAL012",
|
|
31
|
+
/** A version checked against a different version's schema. */
|
|
32
|
+
SubstitutedVersion = "VAL013",
|
|
27
33
|
/** A pointer whose xref names no record of the required type. */
|
|
28
34
|
UnresolvedXref = "unresolved-xref",
|
|
29
35
|
/** A line whose level cannot follow the line above it. */
|
|
@@ -6,7 +6,11 @@ export declare function schemeFor(nodes: ASTNode[]): GedcomScheme;
|
|
|
6
6
|
export declare class GedcomValidator {
|
|
7
7
|
private readonly pointers;
|
|
8
8
|
private readonly extensions;
|
|
9
|
-
|
|
9
|
+
/** A fragment is not a document, so nothing is required of its root. */
|
|
10
|
+
private readonly fragment;
|
|
11
|
+
constructor(pointers?: Map<string, ASTNode[]>, extensions?: ExtensionContext,
|
|
12
|
+
/** A fragment is not a document, so nothing is required of its root. */
|
|
13
|
+
fragment?: boolean);
|
|
10
14
|
setScheme(nodes: ASTNode[]): GedcomScheme;
|
|
11
15
|
validate(nodes: ASTNode[], parentType?: GedcomType, _scheme?: GedcomScheme): GedcomError[];
|
|
12
16
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ASTNode } from "../parser";
|
|
2
|
+
import { GedcomScheme } from "../schemes/schema-types";
|
|
3
|
+
import type { Range } from "../types/position";
|
|
4
|
+
export type GedcomDialect = "7.0" | "5.5.1";
|
|
5
|
+
interface SchemaChoice {
|
|
6
|
+
scheme: GedcomScheme;
|
|
7
|
+
dialect: GedcomDialect;
|
|
8
|
+
/** GEDCOM 7 onwards requires every extension tag to be declared in SCHMA. */
|
|
9
|
+
requiresSchmaDeclaration: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type VersionResolution = ({
|
|
12
|
+
kind: "supported";
|
|
13
|
+
version: string;
|
|
14
|
+
range: Range;
|
|
15
|
+
} & SchemaChoice) | ({
|
|
16
|
+
kind: "substituted";
|
|
17
|
+
version: string;
|
|
18
|
+
range: Range;
|
|
19
|
+
} & SchemaChoice) | {
|
|
20
|
+
kind: "unsupported";
|
|
21
|
+
version: string;
|
|
22
|
+
range: Range;
|
|
23
|
+
} | ({
|
|
24
|
+
kind: "undetermined";
|
|
25
|
+
range: Range;
|
|
26
|
+
} & SchemaChoice);
|
|
27
|
+
/** The schema a caller names outright, for text that carries no header. */
|
|
28
|
+
export declare function schemaForDialect(dialect: GedcomDialect): SchemaChoice;
|
|
29
|
+
export declare function resolveGedcomVersion(nodes: ASTNode[]): VersionResolution;
|
|
30
|
+
export {};
|