oatschema 0.0.1 → 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.
Files changed (56) hide show
  1. package/AUTHORS +4 -0
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +113 -13
  4. package/THIRD-PARTY-NOTICES +28 -0
  5. package/dist/ajv.d.ts +21 -0
  6. package/dist/ajv.js +28 -0
  7. package/dist/compiled/0.8.0/audio-transcription.js +4 -0
  8. package/dist/compiled/0.8.0/classification.js +4 -0
  9. package/dist/compiled/0.8.0/document-extraction.js +4 -0
  10. package/dist/compiled/0.8.0/embedding.js +4 -0
  11. package/dist/compiled/0.8.0/entity-extraction.js +4 -0
  12. package/dist/compiled/0.8.0/generic.js +4 -0
  13. package/dist/compiled/0.8.0/geolocation.js +4 -0
  14. package/dist/compiled/0.8.0/llm-output.js +4 -0
  15. package/dist/compiled/0.8.0/object-detection.js +4 -0
  16. package/dist/compiled/0.8.0/ranking.js +4 -0
  17. package/dist/compiled/0.8.0/regression.js +4 -0
  18. package/dist/compiled/0.8.0/temporal-segmentation.js +4 -0
  19. package/dist/compiled/index.js +30 -0
  20. package/dist/errors.d.ts +27 -0
  21. package/dist/errors.js +63 -0
  22. package/dist/formats.d.ts +13 -0
  23. package/dist/formats.js +106 -0
  24. package/dist/index.d.ts +6 -45
  25. package/dist/index.js +10 -56
  26. package/dist/names.d.ts +33 -0
  27. package/dist/names.js +33 -0
  28. package/dist/validate/audio-transcription.d.ts +27 -0
  29. package/dist/validate/audio-transcription.js +14 -0
  30. package/dist/validate/classification.d.ts +27 -0
  31. package/dist/validate/classification.js +14 -0
  32. package/dist/validate/document-extraction.d.ts +27 -0
  33. package/dist/validate/document-extraction.js +14 -0
  34. package/dist/validate/embedding.d.ts +27 -0
  35. package/dist/validate/embedding.js +14 -0
  36. package/dist/validate/entity-extraction.d.ts +27 -0
  37. package/dist/validate/entity-extraction.js +14 -0
  38. package/dist/validate/generic.d.ts +27 -0
  39. package/dist/validate/generic.js +14 -0
  40. package/dist/validate/geolocation.d.ts +27 -0
  41. package/dist/validate/geolocation.js +14 -0
  42. package/dist/validate/llm-output.d.ts +27 -0
  43. package/dist/validate/llm-output.js +14 -0
  44. package/dist/validate/object-detection.d.ts +27 -0
  45. package/dist/validate/object-detection.js +14 -0
  46. package/dist/validate/ranking.d.ts +27 -0
  47. package/dist/validate/ranking.js +14 -0
  48. package/dist/validate/regression.d.ts +27 -0
  49. package/dist/validate/regression.js +14 -0
  50. package/dist/validate/temporal-segmentation.d.ts +27 -0
  51. package/dist/validate/temporal-segmentation.js +14 -0
  52. package/dist/validate.d.ts +40 -0
  53. package/dist/validate.js +59 -0
  54. package/dist/validation.d.ts +74 -0
  55. package/dist/validation.js +328 -0
  56. package/package.json +24 -6
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `classification` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `classification` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `classification`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/classification.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("classification", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `document-extraction` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `document-extraction` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `document-extraction`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/document-extraction.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("document-extraction", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `embedding` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `embedding` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `embedding`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/embedding.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("embedding", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `entity-extraction` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `entity-extraction` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `entity-extraction`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/entity-extraction.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("entity-extraction", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `generic` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `generic` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `generic`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/generic.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("generic", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `geolocation` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `geolocation` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `geolocation`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/geolocation.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("geolocation", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `llm-output` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `llm-output` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `llm-output`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/llm-output.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("llm-output", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `object-detection` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `object-detection` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `object-detection`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/object-detection.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("object-detection", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `ranking` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `ranking` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `ranking`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/ranking.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("ranking", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `regression` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `regression` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `regression`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/regression.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("regression", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Validation of records against the `temporal-segmentation` OATS schema only, with precompiled validators.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import type { SchemaVersion } from "../names.js";
11
+ import type { ValidateOptions, Validator } from "../validation.js";
12
+
13
+ export { SchemaLookupError } from "../errors.js";
14
+ export { ValidationError, type ValidationErrorDetails, type ValidateOptions, type Validator } from "../validation.js";
15
+
16
+ /**
17
+ * Return a cached {@link Validator} for the `temporal-segmentation` schema in schema version `version`, or in
18
+ * `SCHEMA_VERSION` if `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param version An exact bundled version such as `"0.8.0"`.
23
+ * @param options Validation options.
24
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `temporal-segmentation`.
25
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
26
+ */
27
+ export declare function getValidator(version?: SchemaVersion, options?: ValidateOptions): Validator;
@@ -0,0 +1,14 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import v0 from "../compiled/0.8.0/temporal-segmentation.js";
5
+ import { versionValidator } from "../validation.js";
6
+
7
+ export { SchemaLookupError } from "../errors.js";
8
+ export { ValidationError } from "../validation.js";
9
+
10
+ const VERSIONS = new Map([["0.8.0", v0]]);
11
+
12
+ export function getValidator(version, options) {
13
+ return versionValidator("temporal-segmentation", VERSIONS, version, options);
14
+ }
@@ -0,0 +1,40 @@
1
+ import type { SchemaName, SchemaVersion } from "./names.ts";
2
+ import { type ValidateOptions, type ValidationError, type Validator } from "./validation.ts";
3
+ export { SchemaLookupError, UnknownSchemaError } from "./errors.ts";
4
+ export { type ValidateOptions, ValidationError, type ValidationErrorDetails, type Validator } from "./validation.ts";
5
+ /**
6
+ * Return a cached {@link Validator} for the schema `name` in schema version `version`, or in `SCHEMA_VERSION` if
7
+ * `version` is omitted.
8
+ *
9
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
10
+ *
11
+ * @param name The schema name, such as `"classification"`.
12
+ * @param version An exact bundled version such as `"0.8.0"`.
13
+ * @param options Validation options.
14
+ * @throws {UnknownSchemaError} `name` is not a schema in any bundled version.
15
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `name`.
16
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
17
+ */
18
+ export declare function getValidator(name: SchemaName, version?: SchemaVersion, options?: ValidateOptions): Validator;
19
+ /**
20
+ * Check `record` against the schema `name` in schema version `version`, or in `SCHEMA_VERSION` if `version` is
21
+ * omitted, and throw a {@link ValidationError} for the first error.
22
+ *
23
+ * Before OATS 1.0.0, a schema version may reject records that an older one accepted, so pass the version a record was
24
+ * written for. Arguments and other errors are as for {@link getValidator}; {@link iterErrors} returns every error.
25
+ *
26
+ * @throws {ValidationError} `record` does not conform.
27
+ */
28
+ export declare function validate(record: unknown, name: SchemaName, version?: SchemaVersion, options?: ValidateOptions): void;
29
+ /**
30
+ * Return whether `record` conforms to the schema `name` in schema version `version`.
31
+ *
32
+ * Arguments and errors are as for {@link validate}, except that a record that does not conform returns `false`.
33
+ */
34
+ export declare function isValid(record: unknown, name: SchemaName, version?: SchemaVersion, options?: ValidateOptions): boolean;
35
+ /**
36
+ * Return an iterator over every error in `record` against the schema `name` in schema version `version`.
37
+ *
38
+ * Arguments and errors are as for {@link validate}, except that each error is yielded rather than thrown.
39
+ */
40
+ export declare function iterErrors(record: unknown, name: SchemaName, version?: SchemaVersion, options?: ValidateOptions): IterableIterator<ValidationError>;
@@ -0,0 +1,59 @@
1
+ // SPDX-FileCopyrightText: 2026 The OATS Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * Validation of records against the bundled OATS schemas, with precompiled validators.
5
+ *
6
+ * The validators generate no code at run time and have no dependencies, so they run under a strict Content Security
7
+ * Policy and in a browser without a bundler. This module includes every schema; to load only one, import
8
+ * `oatschema/validate/<name>` instead.
9
+ *
10
+ * @module
11
+ */
12
+ import { COMPILED } from "./compiled/index.js";
13
+ import { tableValidator } from "./validation.js";
14
+ export { SchemaLookupError, UnknownSchemaError } from "./errors.js";
15
+ export { ValidationError } from "./validation.js";
16
+ /**
17
+ * Return a cached {@link Validator} for the schema `name` in schema version `version`, or in `SCHEMA_VERSION` if
18
+ * `version` is omitted.
19
+ *
20
+ * Formats (`date-time`, `uri`, …) are checked unless `options.checkFormats` is `false`.
21
+ *
22
+ * @param name The schema name, such as `"classification"`.
23
+ * @param version An exact bundled version such as `"0.8.0"`.
24
+ * @param options Validation options.
25
+ * @throws {UnknownSchemaError} `name` is not a schema in any bundled version.
26
+ * @throws {SchemaLookupError} `version` is not bundled, or does not contain `name`.
27
+ * @throws {TypeError} `options` is not an object, has an unknown key, or `checkFormats` is not a boolean.
28
+ */
29
+ export function getValidator(name, version, options) {
30
+ return tableValidator(COMPILED, name, version, options);
31
+ }
32
+ /**
33
+ * Check `record` against the schema `name` in schema version `version`, or in `SCHEMA_VERSION` if `version` is
34
+ * omitted, and throw a {@link ValidationError} for the first error.
35
+ *
36
+ * Before OATS 1.0.0, a schema version may reject records that an older one accepted, so pass the version a record was
37
+ * written for. Arguments and other errors are as for {@link getValidator}; {@link iterErrors} returns every error.
38
+ *
39
+ * @throws {ValidationError} `record` does not conform.
40
+ */
41
+ export function validate(record, name, version, options) {
42
+ tableValidator(COMPILED, name, version, options).validate(record);
43
+ }
44
+ /**
45
+ * Return whether `record` conforms to the schema `name` in schema version `version`.
46
+ *
47
+ * Arguments and errors are as for {@link validate}, except that a record that does not conform returns `false`.
48
+ */
49
+ export function isValid(record, name, version, options) {
50
+ return tableValidator(COMPILED, name, version, options).isValid(record);
51
+ }
52
+ /**
53
+ * Return an iterator over every error in `record` against the schema `name` in schema version `version`.
54
+ *
55
+ * Arguments and errors are as for {@link validate}, except that each error is yielded rather than thrown.
56
+ */
57
+ export function iterErrors(record, name, version, options) {
58
+ return tableValidator(COMPILED, name, version, options).iterErrors(record);
59
+ }
@@ -0,0 +1,74 @@
1
+ import { type SchemaName, type SchemaVersion } from "./names.ts";
2
+ /** Options for validation. */
3
+ export interface ValidateOptions {
4
+ /** Whether to check formats (`date-time`, `uri`, …). Defaults to `true`. */
5
+ readonly checkFormats?: boolean;
6
+ }
7
+ /** The details of a {@link ValidationError}. */
8
+ export interface ValidationErrorDetails {
9
+ /** The schema's name. */
10
+ readonly schemaName: SchemaName;
11
+ /** The exact schema version. */
12
+ readonly schemaVersion: SchemaVersion;
13
+ /** The location of the failing value within the record. */
14
+ readonly path?: readonly (string | number)[];
15
+ /** The location within the schema of the keyword that rejected it. */
16
+ readonly schemaPath?: readonly (string | number)[];
17
+ /** The JSON Schema keyword that rejected it, such as `"maxLength"` or `"required"`. */
18
+ readonly keyword?: string;
19
+ }
20
+ /**
21
+ * A record that does not conform to its schema.
22
+ *
23
+ * `path` locates the failing value within the record, `schemaPath` the schema location that rejected it,
24
+ * and `keyword` the JSON Schema keyword at the end of `schemaPath` (`"maxLength"`, `"required"`, …).
25
+ *
26
+ * `reason` shows each value from the record as `…`, quoting only property names, and is at most 1,000 characters.
27
+ * `message` adds the schema and the location, as in `classification 0.8.0 at /labels/0/score: … is greater than the
28
+ * maximum of 1`. Each string in `path` is at most 100 characters, and the location in `message` at most 1,000.
29
+ * The underlying validator's error is not kept.
30
+ */
31
+ export declare class ValidationError extends Error {
32
+ /** Why the value was rejected, without the schema or the location. */
33
+ readonly reason: string;
34
+ /** The schema's name. */
35
+ readonly schemaName: SchemaName;
36
+ /** The exact schema version. */
37
+ readonly schemaVersion: SchemaVersion;
38
+ /** The location of the failing value within the record. Array indices are numbers. */
39
+ readonly path: readonly (string | number)[];
40
+ /** The location within the schema of the keyword that rejected the value. */
41
+ readonly schemaPath: readonly (string | number)[];
42
+ /** The JSON Schema keyword that rejected the value. */
43
+ readonly keyword: string;
44
+ constructor(reason: string, details: ValidationErrorDetails);
45
+ }
46
+ /**
47
+ * A validator for one schema version, from `getValidator`.
48
+ *
49
+ * Formats (`date-time`, `uri`, …) are checked unless {@link Validator.checkFormats} is `false`.
50
+ * Records are JSON values, such as the result of `JSON.parse`.
51
+ */
52
+ export interface Validator {
53
+ /** The schema's name. */
54
+ readonly schemaName: SchemaName;
55
+ /** The exact schema version. */
56
+ readonly schemaVersion: SchemaVersion;
57
+ /** Whether formats (`date-time`, `uri`, …) are checked. */
58
+ readonly checkFormats: boolean;
59
+ /** Return whether `record` conforms. */
60
+ isValid(record: unknown): boolean;
61
+ /**
62
+ * Throw a {@link ValidationError} for the first error in `record`, if there is one.
63
+ *
64
+ * The first error is the first that {@link Validator.iterErrors} yields.
65
+ */
66
+ validate(record: unknown): void;
67
+ /**
68
+ * Return an iterator over every error in `record`, as {@link ValidationError}s.
69
+ *
70
+ * Every error is found before the first is yielded. The same record gives the same errors in the same order,
71
+ * but the order may change between releases.
72
+ */
73
+ iterErrors(record: unknown): IterableIterator<ValidationError>;
74
+ }