@domorium/validator 0.1.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 +10 -0
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/completion/completion.d.ts +18 -0
- package/dist/document/gedcomDocument.d.ts +18 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +713 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/lexer.d.ts +30 -0
- package/dist/parser/parser.d.ts +7 -0
- package/dist/parser/visitor.d.ts +43 -0
- package/dist/schemes/schema-types.d.ts +41 -0
- package/dist/types/errors.d.ts +8 -0
- package/dist/types/position.d.ts +8 -0
- package/dist/validator/getGedcomVersion.d.ts +2 -0
- package/dist/validator/index.d.ts +1 -0
- package/dist/validator/rule-node.d.ts +26 -0
- package/dist/validator/validate.d.ts +9 -0
- package/package.json +62 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@domorium/validator` are documented here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 - 2026-07-21
|
|
6
|
+
|
|
7
|
+
- Initial public release.
|
|
8
|
+
- Parse GEDCOM 5.5.1 and GEDCOM 7 documents into an AST.
|
|
9
|
+
- Validate structure, cardinality, payloads, and references.
|
|
10
|
+
- Provide completion data for GEDCOM-aware editors.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lavich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @domorium/validator
|
|
2
|
+
|
|
3
|
+
GEDCOM 5.5.1 and 7.0 parser and validator. Parses `.ged` files into an AST and validates structure, cardinality, and payload types against the official GEDCOM specification schemas.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @domorium/validator
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { GedcomDocument } from "@domorium/validator";
|
|
15
|
+
|
|
16
|
+
const document = new GedcomDocument().createDocument(gedcomString);
|
|
17
|
+
const errors = document.getErrors();
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Scripts
|
|
21
|
+
|
|
22
|
+
| Command | Description |
|
|
23
|
+
| ------------------- | -------------------------------------------------------- |
|
|
24
|
+
| `npm run build` | Build library (CJS + ESM + types) |
|
|
25
|
+
| `npm run watch` | Build in watch mode |
|
|
26
|
+
| `npm test` | Run tests |
|
|
27
|
+
| `npm run typecheck` | Type-check without emitting |
|
|
28
|
+
| `npm run generate` | Regenerate `g7validation.json` from upstream GEDCOM spec |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ASTNode } from "../parser";
|
|
2
|
+
import type { Position } from "../types/position";
|
|
3
|
+
import { type GedcomScheme } from "../schemes/schema-types";
|
|
4
|
+
export interface GedcomCompletion {
|
|
5
|
+
label: string;
|
|
6
|
+
kind: "tag" | "enum" | "pointer";
|
|
7
|
+
detail?: string;
|
|
8
|
+
}
|
|
9
|
+
interface CompletionContext {
|
|
10
|
+
nodes: ASTNode[];
|
|
11
|
+
pointers: Map<string, ASTNode[]>;
|
|
12
|
+
scheme: GedcomScheme;
|
|
13
|
+
isGedcom7: boolean;
|
|
14
|
+
position: Position;
|
|
15
|
+
lineText: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function getGedcomCompletions(context: CompletionContext): GedcomCompletion[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GedcomError } from "../types/errors";
|
|
2
|
+
import { ASTNode, ASTToken } from "../parser";
|
|
3
|
+
import { type GedcomCompletion } from "../completion/completion";
|
|
4
|
+
import type { Position } from "../types/position";
|
|
5
|
+
export declare class GedcomDocument {
|
|
6
|
+
private nodes;
|
|
7
|
+
pointers: Map<string, ASTNode[]>;
|
|
8
|
+
xRefs: Map<string, ASTToken[]>;
|
|
9
|
+
private errors;
|
|
10
|
+
private scheme;
|
|
11
|
+
private parseGedcom;
|
|
12
|
+
createDocument(text: string): GedcomDocument;
|
|
13
|
+
getLabel(node: ASTNode): string | undefined;
|
|
14
|
+
getCompletions(position: Position, lineText: string): GedcomCompletion[];
|
|
15
|
+
updateDocument(_text: string, _range: Range): GedcomDocument;
|
|
16
|
+
getErrors(_lang?: string): GedcomError[];
|
|
17
|
+
getNodes(_range?: Range): ASTNode[];
|
|
18
|
+
}
|