typedriver 0.8.7 → 0.8.9

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.
@@ -1,5 +1,5 @@
1
1
  import Type from 'typebox';
2
- import { type StandardSchemaV1, type StandardJSONSchemaV1 } from './_standard/standard-schema.mjs';
2
+ import { type StandardSchemaV1, type StandardJSONSchemaV1 } from '@standard-schema/spec';
3
3
  import { Validator } from './validator.mjs';
4
4
  type TFromStandardSchema<Input extends StandardSchemaV1, Output extends unknown = StandardSchemaV1.InferInput<Input>, Result extends Validator = Validator<Input, Output>> = Result;
5
5
  type TFromStandardJsonSchema<Input extends StandardSchemaV1 & StandardJSONSchemaV1, Output extends unknown = StandardSchemaV1.InferInput<Input>, Result extends Validator = Validator<Input, Output>> = Result;
@@ -1,3 +1,3 @@
1
- import { StandardSchemaV1 } from '../_standard/standard-schema.mjs';
2
- import { TLocalizedValidationError } from 'typebox/error';
3
- export declare function errorToIssue(error: TLocalizedValidationError): StandardSchemaV1.Issue;
1
+ import type { TJsonSchemaError, TStandardSchemaError } from '../validator.mjs';
2
+ /** (Internal) Transform TJsonSchemaError to TStandardSchemaError */
3
+ export declare function errorToIssue(error: TJsonSchemaError): TStandardSchemaError;
@@ -8,6 +8,7 @@ function pathSegments(pointer) {
8
8
  return [];
9
9
  return pointer.slice(1).split('/').map((segment) => segment.replace(/~1/g, '/').replace(/~0/g, '~'));
10
10
  }
11
+ /** (Internal) Transform TJsonSchemaError to TStandardSchemaError */
11
12
  export function errorToIssue(error) {
12
13
  const path = pathSegments(error.instancePath);
13
14
  return { path, message: error.message };
@@ -1,4 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
+ // ------------------------------------------------------------------
3
+ // ParseError
4
+ // ------------------------------------------------------------------
2
5
  export class ParseError extends globalThis.Error {
3
6
  constructor(value, errors) {
4
7
  super('ParseError');
@@ -12,6 +15,9 @@ export class ParseError extends globalThis.Error {
12
15
  });
13
16
  }
14
17
  }
18
+ // ------------------------------------------------------------------
19
+ // UnknownError
20
+ // ------------------------------------------------------------------
15
21
  export class UnknownError extends globalThis.Error {
16
22
  constructor(message) {
17
23
  super(`UnknownError: ${message}`);
@@ -1,3 +1,5 @@
1
1
  export * from './exceptions.mjs';
2
2
  export * from './error-to-issue.mjs';
3
3
  export * from './issue-to-error.mjs';
4
+ export * from './normal-error.mjs';
5
+ export * from './normal-issue.mjs';
@@ -2,3 +2,5 @@
2
2
  export * from './exceptions.mjs';
3
3
  export * from './error-to-issue.mjs';
4
4
  export * from './issue-to-error.mjs';
5
+ export * from './normal-error.mjs';
6
+ export * from './normal-issue.mjs';
@@ -1,3 +1,3 @@
1
- import { StandardSchemaV1 } from '../_standard/standard-schema.mjs';
2
- import { TLocalizedValidationError } from 'typebox/error';
3
- export declare function issueToError(issue: StandardSchemaV1.Issue): TLocalizedValidationError;
1
+ import type { TStandardSchemaError, TJsonSchemaError } from '../validator.mjs';
2
+ /** (Internal) Transform TStandardSchemaError to TJsonSchemaError */
3
+ export declare function issueToError(issue: TStandardSchemaError): TJsonSchemaError;
@@ -1,15 +1,23 @@
1
1
  // deno-fmt-ignore-file
2
- import { Guard } from 'typebox/guard';
3
2
  // ------------------------------------------------------------------
4
- // Issues
3
+ // Escape
5
4
  // ------------------------------------------------------------------
6
- function jsonPointer(segments) {
7
- return `#${segments.join('/')}`;
5
+ function escapeKey(segment) {
6
+ return `${segment}`.replace(/~/g, '~0').replace(/\//g, '~1');
8
7
  }
8
+ // ------------------------------------------------------------------
9
+ // Json Pointer
10
+ // ------------------------------------------------------------------
11
+ function pathToJsonPointer(path) {
12
+ const keys = path.map(escapeKey);
13
+ return `#/${keys.join('/')}`;
14
+ }
15
+ // ------------------------------------------------------------------
16
+ // IssueToError
17
+ // ------------------------------------------------------------------
18
+ /** (Internal) Transform TStandardSchemaError to TJsonSchemaError */
9
19
  export function issueToError(issue) {
10
- const instancePath = Guard.HasPropertyKey(issue, 'path') && Guard.IsArray(issue.path)
11
- ? jsonPointer(issue.path)
12
- : jsonPointer([]);
20
+ const instancePath = pathToJsonPointer(issue.path);
13
21
  return {
14
22
  instancePath,
15
23
  schemaPath: '#',
@@ -0,0 +1,4 @@
1
+ import type { TLocalizedValidationError } from 'typebox/error';
2
+ import type { TJsonSchemaError } from '../validator.mjs';
3
+ /** (Internal) Normalize a TLocalizedValidationError as TJsonSchemaError. */
4
+ export declare function normalError(error: TLocalizedValidationError): TJsonSchemaError;
@@ -0,0 +1,5 @@
1
+ // deno-fmt-ignore-file
2
+ /** (Internal) Normalize a TLocalizedValidationError as TJsonSchemaError. */
3
+ export function normalError(error) {
4
+ return error;
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import type { TStandardSchemaError } from '../validator.mjs';
3
+ /** (Internal) Normalize a StandardSchemaV1.Issue as TStandardSchemaError. */
4
+ export declare function normalIssue(issue: StandardSchemaV1.Issue): TStandardSchemaError;
@@ -0,0 +1,30 @@
1
+ // deno-fmt-ignore-file
2
+ import { Guard } from 'typebox/guard';
3
+ // ------------------------------------------------------------------
4
+ // Normal: Segments
5
+ // ------------------------------------------------------------------
6
+ function isSegmentObjectWithKey(segment) {
7
+ return Guard.IsObject(segment) && Guard.HasPropertyKey(segment, 'key') && (Guard.IsBigInt(segment.key)
8
+ || Guard.IsBoolean(segment.key)
9
+ || Guard.IsString(segment.key)
10
+ || Guard.IsNumber(segment.key));
11
+ }
12
+ function normalizeSegment(segment) {
13
+ return isSegmentObjectWithKey(segment) ? `${segment.key}` : `${segment}`;
14
+ }
15
+ function normalizeSegments(segments) {
16
+ return segments.map(normalizeSegment);
17
+ }
18
+ // ------------------------------------------------------------------
19
+ // Resolve
20
+ // ------------------------------------------------------------------
21
+ function resolveSegments(issue) {
22
+ return (Guard.HasPropertyKey(issue, 'path') && Guard.IsArray(issue.path)
23
+ ? issue.path
24
+ : []);
25
+ }
26
+ /** (Internal) Normalize a StandardSchemaV1.Issue as TStandardSchemaError. */
27
+ export function normalIssue(issue) {
28
+ const segments = resolveSegments(issue);
29
+ return ({ path: normalizeSegments(segments), message: issue.message });
30
+ }
@@ -1,2 +1,2 @@
1
- import { StandardSchemaV1, StandardJSONSchemaV1 } from '../_standard/standard-schema.mjs';
1
+ import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
2
2
  export declare function IsStandardJsonSchemaV1(value: unknown): value is StandardSchemaV1 & StandardJSONSchemaV1;
@@ -1,2 +1,2 @@
1
- import { StandardSchemaV1 } from '../_standard/standard-schema.mjs';
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  export declare function IsStandardSchemaV1(value: unknown): value is StandardSchemaV1;
@@ -1,4 +1,4 @@
1
- import { type StandardSchemaV1 } from './_standard/standard-schema.mjs';
1
+ import { type StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { type Validator } from './validator.mjs';
3
3
  import Type from 'typebox';
4
4
  type StaticValidator<_Input extends unknown, Output extends unknown> = (Output);
@@ -1,35 +1,27 @@
1
1
  import { System } from 'typebox/system';
2
- import { TLocalizedValidationError } from 'typebox/error';
3
- import { StandardSchemaV1 } from './_standard/standard-schema.mjs';
4
- export type TStandardSchemaError = StandardSchemaV1.Issue;
5
- export type TJsonSchemaError = TLocalizedValidationError;
6
2
  export type TErrorFormat = 'json-schema' | 'standard-schema';
3
+ export interface TJsonSchemaError {
4
+ keyword: string;
5
+ schemaPath: string;
6
+ instancePath: string;
7
+ params: object;
8
+ message: string;
9
+ }
10
+ export interface TStandardSchemaError {
11
+ path: string[];
12
+ message: string;
13
+ }
7
14
  declare const Locale: typeof System.Locale;
8
15
  export type TErrorLocale = (Exclude<keyof typeof Locale, 'Get' | 'Set' | 'Reset'> & ({} & string));
9
16
  /** Internal */
10
17
  export declare function resolveErrorOptions(options?: Partial<TErrorOptions>): TErrorOptions;
11
18
  export interface TErrorOptions {
12
- /**
13
- * Specifies the error message generation format.
14
- *
15
- * Supported values are `json-schema` and `standard-schema`.
16
- *
17
- * Default: `json-schema`
18
- */
19
+ /** Specifies the error format. Default: `json-schema` */
19
20
  format: TErrorFormat;
20
- /**
21
- * Specifies the locale used when generating error messages.
22
- *
23
- * This setting applies only when used with TypeScript, JSON Schema,
24
- * or implementations that follow the Standard JSON Schema specification.
25
- * When the compiled type is Standard Schema only, the error message
26
- * will be whatever is returned from that library.
27
- *
28
- * Default: `en_US`
29
- */
21
+ /** Specifies the error format. Default: `en_US` */
30
22
  locale: TErrorLocale;
31
23
  }
32
- export type TErrorResult<Options extends Partial<TErrorOptions>> = (Options['format'] extends 'standard-schema' ? StandardSchemaV1.Issue[] : TLocalizedValidationError[]);
24
+ export type TErrorResult<Options extends Partial<TErrorOptions>> = (Options['format'] extends 'standard-schema' ? TStandardSchemaError[] : TJsonSchemaError[]);
33
25
  /** Abstract Base for all Validator types. */
34
26
  export declare abstract class Validator<Input extends unknown = unknown, Output extends unknown = unknown> {
35
27
  /** Returns the schema used to construct this validator */
@@ -1,7 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { System } from 'typebox/system';
3
3
  import { Validator as TBValidator } from 'typebox/compile';
4
- import { ParseError, errorToIssue } from '../../errors/index.mjs';
4
+ import { ParseError, errorToIssue, normalError } from '../../errors/index.mjs';
5
5
  import { Validator, resolveErrorOptions } from '../../validator.mjs';
6
6
  export class JsonSchemaValidator extends Validator {
7
7
  constructor(input) {
@@ -46,7 +46,7 @@ export class JsonSchemaValidator extends Validator {
46
46
  System.Locale.Set(System.Locale[config.locale]);
47
47
  const errors = this.validator.Errors(value);
48
48
  return (config.format === 'standard-schema'
49
- ? errors.map(error => errorToIssue(error))
50
- : errors);
49
+ ? errors.map(error => errorToIssue(normalError(error)))
50
+ : errors.map(error => normalError(error)));
51
51
  }
52
52
  }
@@ -1,2 +1,3 @@
1
- import { StandardJSONSchemaV1 } from '../../_standard/standard-schema.mjs';
2
- export declare function ResolveJsonSchema(input: StandardJSONSchemaV1): Record<string, unknown>;
1
+ import { StandardJSONSchemaV1 } from '@standard-schema/spec';
2
+ /** (Internal) Resolves a JsonSchema representation (need discovery mechanism here) */
3
+ export declare function resolveJsonSchema(input: StandardJSONSchemaV1): Record<string, unknown>;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from 'typebox/guard';
3
- function AsOpenAPI3_0(input) {
3
+ function OpenAPI3_0(input) {
4
4
  try {
5
5
  return input['~standard'].jsonSchema.input({ target: 'openapi-3.0' });
6
6
  }
@@ -8,7 +8,7 @@ function AsOpenAPI3_0(input) {
8
8
  return undefined;
9
9
  }
10
10
  }
11
- function AsDraft7(input) {
11
+ function Draft7(input) {
12
12
  try {
13
13
  return input['~standard'].jsonSchema.input({ target: 'draft-07' });
14
14
  }
@@ -16,7 +16,7 @@ function AsDraft7(input) {
16
16
  return undefined;
17
17
  }
18
18
  }
19
- function AsDraft2020_12(input) {
19
+ function Draft2020_12(input) {
20
20
  try {
21
21
  return input['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
22
22
  }
@@ -24,9 +24,9 @@ function AsDraft2020_12(input) {
24
24
  return undefined;
25
25
  }
26
26
  }
27
- // Standard JSON Schema should provide mechanism to query supported specifications
28
- export function ResolveJsonSchema(input) {
29
- const jsonschema = AsDraft2020_12(input) ?? AsDraft7(input) ?? AsOpenAPI3_0(input);
27
+ /** (Internal) Resolves a JsonSchema representation (need discovery mechanism here) */
28
+ export function resolveJsonSchema(input) {
29
+ const jsonschema = Draft2020_12(input) ?? Draft7(input) ?? OpenAPI3_0(input);
30
30
  if (Guard.IsUndefined(jsonschema))
31
31
  throw Error(`Vendor '${input['~standard'].vendor}' advertised itself as a Standard JSON Schema but failed to produce a schematic. Submit an issue with the vendor.`);
32
32
  return jsonschema;
@@ -1,4 +1,4 @@
1
- import { StandardJSONSchemaV1, StandardSchemaV1 } from '../../_standard/standard-schema.mjs';
1
+ import { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Validator, type TErrorOptions, type TErrorResult } from '../../validator.mjs';
3
3
  export declare class StandardJsonSchemaValidator<Input extends StandardJSONSchemaV1 & StandardSchemaV1, Output extends unknown = StandardSchemaV1.InferOutput<Input>> extends Validator<Input, Output> {
4
4
  private readonly input;
@@ -1,14 +1,14 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { System } from 'typebox/system';
3
3
  import { Validator, resolveErrorOptions } from '../../validator.mjs';
4
- import { ParseError, errorToIssue } from '../../errors/index.mjs';
4
+ import { ParseError, errorToIssue, normalError } from '../../errors/index.mjs';
5
5
  import { Validator as TBValidator } from 'typebox/compile';
6
- import { ResolveJsonSchema } from './resolve.mjs';
6
+ import { resolveJsonSchema } from './resolve.mjs';
7
7
  export class StandardJsonSchemaValidator extends Validator {
8
8
  constructor(input) {
9
9
  super();
10
10
  this.input = input;
11
- const schema = ResolveJsonSchema(input);
11
+ const schema = resolveJsonSchema(input);
12
12
  this.validator = new TBValidator({}, schema);
13
13
  }
14
14
  // ----------------------------------------------------------------
@@ -48,7 +48,7 @@ export class StandardJsonSchemaValidator extends Validator {
48
48
  System.Locale.Set(System.Locale[config.locale]);
49
49
  const errors = this.validator.Errors(value);
50
50
  return (config.format === 'standard-schema'
51
- ? errors.map(error => errorToIssue(error))
52
- : errors);
51
+ ? errors.map(error => errorToIssue(normalError(error)))
52
+ : errors.map(error => normalError(error)));
53
53
  }
54
54
  }
@@ -1,4 +1,4 @@
1
- import { StandardSchemaV1 } from '../../_standard/standard-schema.mjs';
1
+ import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Validator, type TErrorOptions, type TErrorResult } from '../../validator.mjs';
3
3
  export declare class StandardSchemaValidator<Input extends StandardSchemaV1, Output extends unknown = StandardSchemaV1.InferOutput<Input>> extends Validator<Input, Output> {
4
4
  private readonly input;
@@ -1,5 +1,5 @@
1
1
  // deno-fmt-ignore-file
2
- import { ParseError, UnknownError, issueToError } from '../../errors/index.mjs';
2
+ import { ParseError, UnknownError, issueToError, normalIssue } from '../../errors/index.mjs';
3
3
  import { Validator, resolveErrorOptions } from '../../validator.mjs';
4
4
  export class StandardSchemaValidator extends Validator {
5
5
  constructor(input) {
@@ -47,7 +47,7 @@ export class StandardSchemaValidator extends Validator {
47
47
  const issues = (('issues' in result) ? result.issues : []);
48
48
  const config = resolveErrorOptions(options);
49
49
  return (config.format === 'json-schema'
50
- ? issues.map(issue => issueToError(issue))
51
- : issues.map(issue => ({ path: issue.path, message: issue.message })));
50
+ ? issues.map(issue => issueToError(normalIssue(issue)))
51
+ : issues.map(issue => normalIssue(issue)));
52
52
  }
53
53
  }
@@ -1,5 +1,5 @@
1
- import { Validator, type TErrorOptions, type TErrorResult } from '../../validator.mjs';
2
1
  import Type from 'typebox';
2
+ import { Validator, type TErrorOptions, type TErrorResult } from '../../validator.mjs';
3
3
  export declare class TypeScriptValidator<Input extends string, Schema extends Type.TSchema = Type.TScript<{}, Input>, Output extends unknown = Type.Static<Schema>> extends Validator<Input, Output> {
4
4
  private readonly validator;
5
5
  private readonly script;
@@ -1,9 +1,9 @@
1
1
  // deno-fmt-ignore-file
2
+ import Type from 'typebox';
2
3
  import { System } from 'typebox/system';
3
4
  import { Validator as TBValidator } from 'typebox/compile';
4
- import { ParseError, errorToIssue } from '../../errors/index.mjs';
5
+ import { ParseError, errorToIssue, normalError } from '../../errors/index.mjs';
5
6
  import { Validator, resolveErrorOptions } from '../../validator.mjs';
6
- import Type from 'typebox';
7
7
  export class TypeScriptValidator extends Validator {
8
8
  constructor(script) {
9
9
  super();
@@ -48,7 +48,7 @@ export class TypeScriptValidator extends Validator {
48
48
  System.Locale.Set(System.Locale[config.locale]);
49
49
  const errors = this.validator.Errors(value);
50
50
  return (config.format === 'standard-schema'
51
- ? errors.map(error => errorToIssue(error))
52
- : errors);
51
+ ? errors.map(error => errorToIssue(normalError(error)))
52
+ : errors.map(error => normalError(error)));
53
53
  }
54
54
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedriver",
3
3
  "description": "High Performance Driver for Runtime Type System Integration",
4
- "version": "0.8.7",
4
+ "version": "0.8.9",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "json-schema",
@@ -14,7 +14,8 @@
14
14
  "url": "https://github.com/sinclairzx81/typedriver"
15
15
  },
16
16
  "dependencies": {
17
- "typebox": "^1.0.61"
17
+ "@standard-schema/spec": "1.1.0",
18
+ "typebox": "^1.0.64"
18
19
  },
19
20
  "type": "module",
20
21
  "types": "./build/index.d.mts",
package/readme.md CHANGED
@@ -34,8 +34,6 @@ const Vector3 = compile(`{
34
34
  z: number
35
35
  }`)
36
36
 
37
- declare const value: unknown
38
-
39
37
  const position = Vector3.parse(value) // const position: {
40
38
  // x: number,
41
39
  // y: number,
@@ -65,7 +63,7 @@ License MIT
65
63
  - [Locales](#Locales)
66
64
  - [Static](#Static)
67
65
  - [Script](#Script)
68
- - [Reflect](#Schema)
66
+ - [Reflect](#Reflect)
69
67
  - [Extensions](#Extensions)
70
68
  - [Accelerate](#Accelerate)
71
69
  - [Compression](#Compression)
@@ -425,7 +423,7 @@ type T = Static<typeof T> // type T = number
425
423
 
426
424
  ## Accelerate
427
425
 
428
- TypeDriver provides acceleration support for libraries that implement the upcoming Standard JSON Schema specification. This is a new specification enables remote type libraries to be integrated directly into TypeBox validation infrastructure. This project tracks upstream implementations of this specification and maintains a benchmark measuring compariative performance with and without compile(...).
426
+ TypeDriver provides acceleration support for libraries that implement the Standard JSON Schema specification.
429
427
 
430
428
  ```bash
431
429
  $ deno task bench
@@ -442,20 +440,17 @@ const Vector3 = compile(`{
442
440
  Accelerated Indicates Support for Standard JSON Schema
443
441
 
444
442
  ```bash
445
- ┌────────────┬────────────┬─────────────┬──────────────┬──────────────┬─────────────────┐
446
- │ (idx) │ iterations │ accelerated │ default(...) │ compile(...) │ result
447
- ├────────────┼────────────┼─────────────┼──────────────┼──────────────┼─────────────────┤
448
- │ typescript │ 16000000 │ true │ " ------" │ " 30 ms" │ " ------"
449
- │ jsonschema │ 16000000 │ true │ " ------" │ " 29 ms" │ " ------"
450
- arktype │ 16000000 │ true │ " 537 ms" │ " 30 ms" │ "94.41% faster" │
451
- arri │ 16000000 │ false │ " 3086 ms" │ " 3049 ms" │ "1.20% faster"
452
- effect │ 16000000 │ false │ "24183 ms" │ "23886 ms" │ "1.23% faster"
453
- │ sury │ 16000000 │ false │ " 153 ms" │ " 166 ms" │ "8.33% slower" │
454
- │ valibot │ 16000000 │ false │ " 3632 ms" │ " 3515 ms" │ "3.21% faster" │
455
- zod │ 16000000 │ false │ " 575 ms" │ " 603 ms" │ "4.93% slower" │
456
- └────────────┴────────────┴─────────────┴──────────────┴──────────────┴─────────────────┘
457
-
458
- Last Run: Thu Dec 04 2025
443
+ ┌────────────┬────────────┬─────────────┬────────────────┬───────────────┬──────────────┐
444
+ │ (idx) │ iterations │ accelerated │ standard (...) │ compile (...) │ performance
445
+ ├────────────┼────────────┼─────────────┼────────────────┼───────────────┼──────────────┤
446
+ │ typescript │ 16000000 │ true │ " 30 ms" │ " 29 ms" │ " 1.02 ×"
447
+ │ jsonschema │ 16000000 │ true │ " 29 ms" │ " 29 ms" │ " 1.00 ×"
448
+ zod │ 16000000 │ true │ " 571 ms" │ " 28 ms" │ " 20.43 ×" │
449
+ arktype │ 16000000 │ true │ " 483 ms" │ " 30 ms" │ " 16.10 ×"
450
+ valibot │ 16000000 │ true │ " 3239 ms" │ " 28 ms" │ " 113.72 ×"
451
+ └────────────┴────────────┴─────────────┴────────────────┴───────────────┴──────────────┘
452
+
453
+ Last Run: Sat Dec 20 2025
459
454
  ```
460
455
 
461
456
  ## Compression
@@ -1,120 +0,0 @@
1
- /** The Standard Typed interface. This is a base type extended by other specs. */
2
- export interface StandardTypedV1<Input = unknown, Output = Input> {
3
- /** The Standard properties. */
4
- readonly '~standard': StandardTypedV1.Props<Input, Output>;
5
- }
6
- export declare namespace StandardTypedV1 {
7
- /** The Standard Typed properties interface. */
8
- export interface Props<Input = unknown, Output = Input> {
9
- /** The version number of the standard. */
10
- readonly version: 1;
11
- /** The vendor name of the schema library. */
12
- readonly vendor: string;
13
- /** Inferred types associated with the schema. */
14
- readonly types?: Types<Input, Output> | undefined;
15
- }
16
- /** The Standard Typed types interface. */
17
- export interface Types<Input = unknown, Output = Input> {
18
- /** The input type of the schema. */
19
- readonly input: Input;
20
- /** The output type of the schema. */
21
- readonly output: Output;
22
- }
23
- /** Infers the input type of a Standard Typed. */
24
- export type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['input'];
25
- /** Infers the output type of a Standard Typed. */
26
- export type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['output'];
27
- export {};
28
- }
29
- /** The Standard Schema interface. */
30
- export interface StandardSchemaV1<Input = unknown, Output = Input> {
31
- /** The Standard Schema properties. */
32
- readonly '~standard': StandardSchemaV1.Props<Input, Output>;
33
- }
34
- export declare namespace StandardSchemaV1 {
35
- /** The Standard Schema properties interface. */
36
- export interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
37
- /** Validates unknown input values. */
38
- readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
39
- }
40
- /** The result interface of the validate function. */
41
- export type Result<Output> = SuccessResult<Output> | FailureResult;
42
- /** The result interface if validation succeeds. */
43
- export interface SuccessResult<Output> {
44
- /** The typed output value. */
45
- readonly value: Output;
46
- /** A falsy value for `issues` indicates success. */
47
- readonly issues?: undefined;
48
- }
49
- export interface Options {
50
- /** Explicit support for additional vendor-specific parameters, if needed. */
51
- readonly libraryOptions?: Record<string, unknown> | undefined;
52
- }
53
- /** The result interface if validation fails. */
54
- export interface FailureResult {
55
- /** The issues of failed validation. */
56
- readonly issues: ReadonlyArray<Issue>;
57
- }
58
- /** The issue interface of the failure output. */
59
- export interface Issue {
60
- /** The error message of the issue. */
61
- readonly message: string;
62
- /** The path of the issue, if any. */
63
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
64
- }
65
- /** The path segment interface of the issue. */
66
- export interface PathSegment {
67
- /** The key representing a path segment. */
68
- readonly key: PropertyKey;
69
- }
70
- /** The Standard types interface. */
71
- export interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
72
- }
73
- /** Infers the input type of a Standard. */
74
- export type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
75
- /** Infers the output type of a Standard. */
76
- export type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
77
- export {};
78
- }
79
- /** The Standard JSON Schema interface. */
80
- export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
81
- /** The Standard JSON Schema properties. */
82
- readonly '~standard': StandardJSONSchemaV1.Props<Input, Output>;
83
- }
84
- export declare namespace StandardJSONSchemaV1 {
85
- /** The Standard JSON Schema properties interface. */
86
- export interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
87
- /** Methods for generating the input/output JSON Schema. */
88
- readonly jsonSchema: StandardJSONSchemaV1.Converter;
89
- }
90
- /** The Standard JSON Schema converter interface. */
91
- export interface Converter {
92
- /** Converts the input type to JSON Schema. May throw if conversion is not supported. */
93
- readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
94
- /** Converts the output type to JSON Schema. May throw if conversion is not supported. */
95
- readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
96
- }
97
- /**
98
- * The target version of the generated JSON Schema.
99
- *
100
- * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
101
- *
102
- * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
103
- */
104
- export type Target = 'draft-2020-12' | 'draft-07' | 'openapi-3.0' | ({} & string);
105
- /** The options for the input/output methods. */
106
- export interface Options {
107
- /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
108
- readonly target: Target;
109
- /** Explicit support for additional vendor-specific parameters, if needed. */
110
- readonly libraryOptions?: Record<string, unknown> | undefined;
111
- }
112
- /** The Standard types interface. */
113
- export interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
114
- }
115
- /** Infers the input type of a Standard. */
116
- export type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
117
- /** Infers the output type of a Standard. */
118
- export type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
119
- export {};
120
- }
@@ -1 +0,0 @@
1
- export {};