xsschema 0.5.0-beta.5 → 0.5.0-beta.7
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/dist/index.d.ts +42 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,47 @@ declare namespace StandardSchemaV1 {
|
|
|
74
74
|
/** Infers the output type of a Standard. */
|
|
75
75
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
76
|
}
|
|
77
|
+
/** The Standard JSON Schema interface. */
|
|
78
|
+
interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
|
|
79
|
+
/** The Standard JSON Schema properties. */
|
|
80
|
+
readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
|
|
81
|
+
}
|
|
82
|
+
declare namespace StandardJSONSchemaV1 {
|
|
83
|
+
/** The Standard JSON Schema properties interface. */
|
|
84
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
85
|
+
/** Methods for generating the input/output JSON Schema. */
|
|
86
|
+
readonly jsonSchema: StandardJSONSchemaV1.Converter;
|
|
87
|
+
}
|
|
88
|
+
/** The Standard JSON Schema converter interface. */
|
|
89
|
+
interface Converter {
|
|
90
|
+
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
|
|
91
|
+
readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
|
92
|
+
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
|
|
93
|
+
readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The target version of the generated JSON Schema.
|
|
97
|
+
*
|
|
98
|
+
* 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.
|
|
99
|
+
*
|
|
100
|
+
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
|
|
101
|
+
*/
|
|
102
|
+
type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
|
|
103
|
+
/** The options for the input/output methods. */
|
|
104
|
+
interface Options {
|
|
105
|
+
/** 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. */
|
|
106
|
+
readonly target: Target;
|
|
107
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
108
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
109
|
+
}
|
|
110
|
+
/** The Standard types interface. */
|
|
111
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
|
|
112
|
+
}
|
|
113
|
+
/** Infers the input type of a Standard. */
|
|
114
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
115
|
+
/** Infers the output type of a Standard. */
|
|
116
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
117
|
+
}
|
|
77
118
|
|
|
78
119
|
// ==================================================================================================
|
|
79
120
|
// JSON Schema Draft 07
|
|
@@ -260,5 +301,5 @@ declare const toJsonSchema: (schema: StandardSchemaV1) => Promise<JSONSchema7>;
|
|
|
260
301
|
/** @see {@link https://github.com/standard-schema/standard-schema#how-do-i-accept-standard-schemas-in-my-library} */
|
|
261
302
|
declare const validate: <T extends StandardSchemaV1>(schema: T, input: StandardSchemaV1.InferInput<T>) => Promise<StandardSchemaV1.InferOutput<T>>;
|
|
262
303
|
|
|
263
|
-
export { StandardSchemaV1 as Schema, jsonSchema, strictJsonSchema, toJsonSchema, validate };
|
|
304
|
+
export { StandardSchemaV1 as Schema, StandardJSONSchemaV1 as SchemaWithJson, jsonSchema, strictJsonSchema, toJsonSchema, validate };
|
|
264
305
|
export type { Infer, InferIn, JSONSchema7 as JsonSchema };
|