@power-plant/schema 0.0.4 → 0.0.6
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/README.md +2 -2
- package/dist/codegen.cjs +6 -6
- package/dist/codegen.d.cts +1 -1
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.mjs +4 -4
- package/dist/constants-CjTQhR-l.cjs +1 -0
- package/dist/{constants.mjs → constants-lk1mMbgx.mjs} +2 -2
- package/dist/constants-lk1mMbgx.mjs.map +1 -0
- package/dist/helpers-BIaA3COd.cjs +1 -0
- package/dist/helpers-kU9GDXDZ.mjs +2 -0
- package/dist/helpers-kU9GDXDZ.mjs.map +1 -0
- package/dist/index-1pJbUu8F.d.mts +38 -0
- package/dist/index-1pJbUu8F.d.mts.map +1 -0
- package/dist/index-M6wCzIr6.d.cts +38 -0
- package/dist/index-M6wCzIr6.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +628 -31
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +628 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -0
- package/dist/rolldown-runtime-CMqjfN_6.cjs +1 -0
- package/dist/storage/index.cjs +1 -0
- package/dist/storage/index.d.cts +2 -0
- package/dist/storage/index.d.mts +2 -0
- package/dist/storage/index.mjs +1 -0
- package/dist/storage-BccFP9xn.mjs +2 -0
- package/dist/storage-BccFP9xn.mjs.map +1 -0
- package/dist/storage-CgfRQlqS.cjs +1 -0
- package/dist/{types.d.cts → types-CCLUrmYp.d.cts} +86 -21
- package/dist/types-CCLUrmYp.d.cts.map +1 -0
- package/dist/{types.d.mts → types-J67fcIar.d.mts} +87 -22
- package/dist/types-J67fcIar.d.mts.map +1 -0
- package/dist/valibot.cjs +1 -0
- package/dist/valibot.d.cts +14 -0
- package/dist/valibot.d.cts.map +1 -0
- package/dist/valibot.d.mts +14 -0
- package/dist/valibot.d.mts.map +1 -0
- package/dist/valibot.mjs +2 -0
- package/dist/valibot.mjs.map +1 -0
- package/dist/zod.cjs +1 -0
- package/dist/zod.d.cts +23 -0
- package/dist/zod.d.cts.map +1 -0
- package/dist/zod.d.mts +23 -0
- package/dist/zod.d.mts.map +1 -0
- package/dist/zod.mjs +2 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +38 -88
- package/dist/constants-lihlIQu7.d.cts +0 -31
- package/dist/constants-lihlIQu7.d.cts.map +0 -1
- package/dist/constants-lihlIQu7.d.mts +0 -31
- package/dist/constants-lihlIQu7.d.mts.map +0 -1
- package/dist/constants.cjs +0 -1
- package/dist/constants.d.cts +0 -2
- package/dist/constants.d.mts +0 -2
- package/dist/constants.mjs.map +0 -1
- package/dist/extract.cjs +0 -1
- package/dist/extract.d.cts +0 -135
- package/dist/extract.d.cts.map +0 -1
- package/dist/extract.d.mts +0 -135
- package/dist/extract.d.mts.map +0 -1
- package/dist/extract.mjs +0 -2
- package/dist/extract.mjs.map +0 -1
- package/dist/helpers.cjs +0 -1
- package/dist/helpers.d.cts +0 -134
- package/dist/helpers.d.cts.map +0 -1
- package/dist/helpers.d.mts +0 -134
- package/dist/helpers.d.mts.map +0 -1
- package/dist/helpers.mjs +0 -2
- package/dist/helpers.mjs.map +0 -1
- package/dist/metadata.cjs +0 -1
- package/dist/metadata.d.cts +0 -31
- package/dist/metadata.d.cts.map +0 -1
- package/dist/metadata.d.mts +0 -31
- package/dist/metadata.d.mts.map +0 -1
- package/dist/metadata.mjs +0 -2
- package/dist/metadata.mjs.map +0 -1
- package/dist/type-checks.cjs +0 -1
- package/dist/type-checks.d.cts +0 -331
- package/dist/type-checks.d.cts.map +0 -1
- package/dist/type-checks.d.mts +0 -331
- package/dist/type-checks.d.mts.map +0 -1
- package/dist/type-checks.mjs +0 -2
- package/dist/type-checks.mjs.map +0 -1
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/types.mjs +0 -1
package/dist/extract.d.mts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { ExtractedSchemaEnvelope, InferExtractOptions, JsonSchema, SchemaEnvelopeOf, SchemaInput, SchemaInputVariant, SchemaSource, SchemaSourceInput, SchemaSourceVariant } from "./types.mjs";
|
|
2
|
-
import { InferLoadOptions } from "@stryke/resolve/types";
|
|
3
|
-
import { FileReferenceInput } from "@stryke/types";
|
|
4
|
-
|
|
5
|
-
//#region src/extract.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Bundles all external references in a JSON Schema into a single schema document by collecting all reference targets and rewriting the references to point to the bundled definitions. This ensures that the resulting schema is self-contained and can be used independently without relying on external documents.
|
|
8
|
-
*
|
|
9
|
-
* @param schema - The JSON Schema to bundle references for.
|
|
10
|
-
* @returns A new JSON Schema with all references bundled and rewritten to point to the bundled definitions.
|
|
11
|
-
*/
|
|
12
|
-
declare function bundleReferences(schema: JsonSchema): JsonSchema;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a hash string for a given schema definition input.
|
|
15
|
-
*/
|
|
16
|
-
declare function extractHash(variant: SchemaInputVariant, input: SchemaInput): string;
|
|
17
|
-
/**
|
|
18
|
-
* Extracts a JSON Schema from Zod, Standard Schema, Valibot, untyped, or JSON Schema inputs.
|
|
19
|
-
*
|
|
20
|
-
* @param schema - The schema input to extract a JSON Schema from.
|
|
21
|
-
* @returns The extracted JSON Schema, or `undefined` if the input is not a supported schema type.
|
|
22
|
-
*/
|
|
23
|
-
declare function extractJsonSchema(schema: unknown): JsonSchema | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Resolves the concrete source variant for a schema source input.
|
|
26
|
-
*
|
|
27
|
-
* @param input - The schema source input to inspect.
|
|
28
|
-
* @returns The resolved schema source variant.
|
|
29
|
-
* @throws Will throw an error when the input cannot be mapped to a supported source variant.
|
|
30
|
-
*/
|
|
31
|
-
declare function extractResolvedVariant(input: SchemaSourceInput): SchemaSourceVariant;
|
|
32
|
-
/**
|
|
33
|
-
* Determines the top-level input variant for schema extraction.
|
|
34
|
-
*
|
|
35
|
-
* @param input - The schema input to classify.
|
|
36
|
-
* @returns The resolved schema input variant.
|
|
37
|
-
*/
|
|
38
|
-
declare function extractVariant(input: SchemaInput): SchemaInputVariant;
|
|
39
|
-
/**
|
|
40
|
-
* Extracts and normalizes a JSON Schema from a concrete schema source input.
|
|
41
|
-
*
|
|
42
|
-
* @param input - The schema source input to extract from.
|
|
43
|
-
* @param variant - Optional source variant override. When omitted, the variant is inferred from the input.
|
|
44
|
-
* @returns A promise that resolves to a bundled JSON Schema.
|
|
45
|
-
* @throws Will throw an error if no valid JSON Schema can be extracted from the input.
|
|
46
|
-
*/
|
|
47
|
-
declare function extractSchema(input: SchemaSourceInput, variant?: SchemaInputVariant): Promise<JsonSchema>;
|
|
48
|
-
/**
|
|
49
|
-
* Builds source metadata for a schema input using a known source variant.
|
|
50
|
-
*
|
|
51
|
-
* @param variant - The schema source variant associated with the input.
|
|
52
|
-
* @param input - The schema source input to wrap.
|
|
53
|
-
* @returns The normalized schema source payload, including the source hash and variant.
|
|
54
|
-
* @throws Will throw an error if the provided variant is unsupported.
|
|
55
|
-
*/
|
|
56
|
-
declare function extractSource(variant: SchemaSourceVariant, input: SchemaSourceInput): SchemaSource;
|
|
57
|
-
/**
|
|
58
|
-
* Resolves a type definition to a JSON Schema. This function passes the provided file reference to ts-json-schema-generator, using the referenced export name as the target type when one is provided.
|
|
59
|
-
*
|
|
60
|
-
* @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
|
|
61
|
-
* @param options - Optional overrides reserved for API compatibility.
|
|
62
|
-
* @returns A promise that resolves to the generated JSON Schema.
|
|
63
|
-
*/
|
|
64
|
-
declare function extractTSType(input: FileReferenceInput, options?: InferLoadOptions<typeof input>): Promise<JsonSchema>;
|
|
65
|
-
/**
|
|
66
|
-
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](esbuild.github.io) using [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) to obtain the actual schema definition before extraction.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```ts
|
|
70
|
-
* Resolve a schema definition from a JSON schema file
|
|
71
|
-
* const schema1 = await extract(context, "./schemas/my-json-schema.json");
|
|
72
|
-
* // Resolve a schema definition from a TypeScript module export
|
|
73
|
-
* const schema2 = await extract(context, "./schemas.ts#MySchema");
|
|
74
|
-
* // Resolve a schema definition from a JSON Schema object
|
|
75
|
-
* const schema3 = await extract(context, schemaObject);
|
|
76
|
-
* // Resolve a schema definition from a Zod schema
|
|
77
|
-
* const schema4 = await extract(context, zodSchema);
|
|
78
|
-
* // Resolve a schema definition from a Valibot schema
|
|
79
|
-
* const schema5 = await extract(context, valibotSchema);
|
|
80
|
-
* // Resolve a schema definition from an untyped schema
|
|
81
|
-
* const schema6 = await extract(context, untypedSchema);
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @see https://zod.dev/
|
|
85
|
-
* @see https://valibot.dev/
|
|
86
|
-
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
87
|
-
* @see https://json-schema.org/
|
|
88
|
-
* @see https://ajv.js.org/json-type-definition.html
|
|
89
|
-
* @see https://github.com/vega/ts-json-schema-generator
|
|
90
|
-
* @see https://github.com/unjs/untyped
|
|
91
|
-
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
92
|
-
*
|
|
93
|
-
* @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options.
|
|
94
|
-
* @param options - Optional overrides for the configuration used during extraction.
|
|
95
|
-
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
96
|
-
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
97
|
-
*/
|
|
98
|
-
declare function extractSchemaWithSource<TSpec = any>(input: SchemaInput, options?: InferExtractOptions<typeof input>): Promise<ExtractedSchemaEnvelope<TSpec>>;
|
|
99
|
-
/**
|
|
100
|
-
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](esbuild.github.io) using [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) to obtain the actual schema definition before extraction.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* Resolve a schema definition from a JSON schema file
|
|
105
|
-
* const schema1 = await extract(context, "./schemas/my-json-schema.json");
|
|
106
|
-
* // Resolve a schema definition from a TypeScript module export
|
|
107
|
-
* const schema2 = await extract(context, "./schemas.ts#MySchema");
|
|
108
|
-
* // Resolve a schema definition from a JSON Schema object
|
|
109
|
-
* const schema3 = await extract(context, schemaObject);
|
|
110
|
-
* // Resolve a schema definition from a Zod schema
|
|
111
|
-
* const schema4 = await extract(context, zodSchema);
|
|
112
|
-
* // Resolve a schema definition from a Valibot schema
|
|
113
|
-
* const schema5 = await extract(context, valibotSchema);
|
|
114
|
-
* // Resolve a schema definition from an untyped schema
|
|
115
|
-
* const schema6 = await extract(context, untypedSchema);
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* @see https://zod.dev/
|
|
119
|
-
* @see https://valibot.dev/
|
|
120
|
-
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
121
|
-
* @see https://json-schema.org/
|
|
122
|
-
* @see https://ajv.js.org/json-type-definition.html
|
|
123
|
-
* @see https://github.com/vega/ts-json-schema-generator
|
|
124
|
-
* @see https://github.com/unjs/untyped
|
|
125
|
-
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
126
|
-
*
|
|
127
|
-
* @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options.
|
|
128
|
-
* @param options - Optional overrides for the configuration used during extraction.
|
|
129
|
-
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
130
|
-
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
131
|
-
*/
|
|
132
|
-
declare function extract<TSpec = any>(input: SchemaInput<TSpec>, options?: InferExtractOptions<typeof input>): Promise<SchemaEnvelopeOf<TSpec>>;
|
|
133
|
-
//#endregion
|
|
134
|
-
export { bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant };
|
|
135
|
-
//# sourceMappingURL=extract.d.mts.map
|
package/dist/extract.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.mts","names":[],"sources":["../src/extract.ts"],"mappings":""}
|
package/dist/extract.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{isFileReference as e,isJsonSchema as t,isJsonSchemaObject as n,isSchema as r,isSchemaOf as i,isSchemaWithSource as a,isUntypedInput as o,isUntypedInputStrict as s,isUntypedSchema as c,isUntypedSchemaStrict as l,isValibotSchema as u}from"./type-checks.mjs";import{isSetString as d}from"@stryke/type-checks";import{isSetObject as f}from"@stryke/type-checks/is-set-object";import{list as p}from"@stryke/string-format/list";import{findFileExtensionSafe as m}from"@stryke/path/find";import{VALID_OBJECT_SOURCE_EXTENSIONS as h}from"@stryke/resolve/constants";import{extractFileReference as g}from"@stryke/convert/extract-file-reference";import{murmurhash as _}from"@stryke/hash";import{deepClone as v}from"@stryke/helpers/deep-clone";import{isStandardJsonSchema as y}from"@stryke/json";import{loadSafe as b}from"@stryke/resolve/load";import{extractJsonSchema as x,isZod3Type as S}from"@stryke/zod";import{toJsonSchema as C}from"@valibot/to-json-schema";import{createGenerator as w}from"ts-json-schema-generator/dist/factory/generator.js";const T=`https://power-plant.invalid/`;function E(e){return!(!f(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e)}function D(e){return E(e)?e.schema:e}function O(e){return e.endsWith(`#`)?e.slice(0,-1):e}function k(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function A(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function j(e){return e.length===0?``:`/${e.map(e=>A(e)).join(`/`)}`}function M(e,t){try{return O(new URL(e,t).toString())}catch{return O(e)}}function N(e,t,n,r,i){if(!f(e))return;let a=e,o=j(t),s=d(a.$id)?M(a.$id,n):n,c=k(s);if(r.set(s,o),r.set(c,o),d(a.$anchor)&&r.set(`${c}#${a.$anchor}`,o),d(a.$dynamicAnchor)){let e=`${c}#${a.$dynamicAnchor}`;r.set(e,o),i.set(e,`#${a.$dynamicAnchor}`)}for(let[e,n]of Object.entries(a)){if(Array.isArray(n)){n.forEach((n,a)=>{N(n,[...t,e,String(a)],s,r,i)});continue}N(n,[...t,e],s,r,i)}}function P(e,t,n,r,i){if(!f(e))return;let a=e,o=d(a.$id)?M(a.$id,n):n;if(d(a.$ref)){let e=M(a.$ref,o),t=r.get(e)??r.get(k(e));t!==void 0&&(a.$ref=t.length>0?`#${t}`:`#`)}if(d(a.$dynamicRef)){let e=M(a.$dynamicRef,o),t=i.get(e);if(t)a.$dynamicRef=t;else{let t=r.get(e)??r.get(k(e));t!==void 0&&(a.$dynamicRef=t.length>0?`#${t}`:`#`)}}for(let[e,n]of Object.entries(a)){if(Array.isArray(n)){n.forEach((n,a)=>{P(n,[...t,e,String(a)],o,r,i)});continue}P(n,[...t,e],o,r,i)}}function F(e){if(!f(e))return e;let t=v(e),n=d(t.$id)?M(t.$id,T):T,r=new Map,i=new Map;return N(t,[],n,r,i),P(t,[],n,r,i),t}function I(e){if(c(e))return z(e);if(f(e)){if(o(e))return B(e);let t=e;if(`$schema`in t&&c(t.$schema))return z(t.$schema)}return e}function L(e){return Array.isArray(e)?e.map(e=>I(e)):e}function R(e){return C(e,{target:`draft-2020-12`})}function z(e){let t=e,n={};for(let[e,r]of Object.entries(t))if(!(e===`tsType`||e===`markdownType`||e===`tags`||e===`args`||e===`resolve`)){if(e===`id`&&d(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!f(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,I(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=I(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=L(r);continue}n[e]=r}return n}function B(e){let t=e,r=c(t.$schema)?z(t.$schema):{},i={};for(let[e,n]of Object.entries(t)){if(e.startsWith(`$`)||!f(n))continue;if(o(n)){i[e]=B(n);continue}let t=n;if(`$schema`in t&&c(t.$schema)){i[e]=z(t.$schema);continue}c(n)&&(i[e]=z(n))}if(!n(r))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let a={...f(r.properties)?r.properties:{},...i};return{...r,type:r.type??`object`,...Object.keys(a).length>0?{properties:a}:{}}}function V(e,n){let i=D(n);if(a(i)||r(i))return _({variant:e,input:i.schema});if(d(i)||typeof i==`boolean`)return _({variant:e,input:i});if(f(i)){if(S(i))return _({variant:e,input:i._def});if(y(i))return _({variant:e,input:i[`~standard`]});if(t(i))return _({variant:e,input:i});if(u(i))return _({variant:e,input:R(i)});if(o(i))return _({variant:e,input:B(i)});if(c(i))return _({variant:e,input:z(i)})}throw Error(`Failed to create an input hash for the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, or a reflected Deepkit Type object.`)}function H(e){if(f(e)){if(S(e))return x(e,{target:`draft-2020-12`});if(s(e))return B(e);if(l(e))return z(e);if(y(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(u(e))return R(e);if(t(e))return e}}function U(e){if(f(e)){if(S(e))return`zod3`;if(s(e)||l(e))return`untyped`;if(y(e))return`standard-schema`;if(t(e))return`json-schema`;if(u(e))return`valibot`}throw Error(`Failed to determine the variant of the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, a reflected Deepkit Type object, or an Untyped schema.`)}function W(t){let n=D(t);return a(n)||r(n)?n.variant:d(n)||e(n)?`file-reference`:U(n)}async function G(e,t){if(a(e))return e.schema;let n=t??U(e),r;if((n===`zod3`||n===`json-schema`||n===`standard-schema`||n===`untyped`||n===`valibot`)&&(r=H(e)),r)return F(r);throw Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, an untyped schema, or a reflected Deepkit Type object.`)}function K(e,t){if(e===`zod3`)return{hash:V(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:V(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:V(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:V(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:V(e,t),variant:`valibot`,schema:t};throw Error(`Failed to extract source information from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`)}async function q(e,t={}){let n=g(e);if(!n)throw Error(`Failed to extract a file reference from the provided input. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);let r=n.export??`*`;try{return w({path:n.file,type:r,expose:`export`,jsDoc:`extended`,...t}).createSchema(r)}catch(e){throw Error(`Failed to generate a JSON schema for "${n.file}" using the type "${r}". Error: ${e.message}`)}}async function J(e,t={}){let n=D(e);if(a(n))return n;if(r(n))return{...n,source:{hash:V(`json-schema`,n.schema),variant:`json-schema`,schema:n.schema}};let i,o=W(n),s=V(o,n);if(o===`file-reference`){let e=g(n);if(!e)throw Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(n)}". Please ensure that the input is correctly formatted as a file reference (e.g. "./schema.ts#MySchema") and that the file exists at the specified path.`);let o=m(e.file);if(o&&!h.includes(o))throw Error(`The provided schema file input "${e.file}" has an invalid file extension (.${o}). Please ensure that the file has one of the following extensions: ${p(h,{conjunction:`or`})}.`);let s=await b(n,t);s??=await q(n,t);let c=D(s);i=a(c)?c.source:r(c)?{hash:V(`json-schema`,c.schema),variant:`json-schema`,schema:c.schema}:K(U(c),c)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(o))i=K(o,n);else throw Error(`Invalid schema definition input "${o}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);return{variant:o,source:i,schema:await G(i.schema,i.variant),hash:s}}async function Y(e,t={}){let n=D(e);if(a(n)||i(n))return n;let r=await J(e,t);if(!r?.schema)throw Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);return r}export{F as bundleReferences,Y as extract,V as extractHash,H as extractJsonSchema,U as extractResolvedVariant,G as extractSchema,J as extractSchemaWithSource,K as extractSource,q as extractTSType,W as extractVariant};
|
|
2
|
-
//# sourceMappingURL=extract.mjs.map
|
package/dist/extract.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/helpers.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./constants.cjs"),l=require("./type-checks.cjs"),u=require("./metadata.cjs");let d=require("@stryke/type-checks"),f=require("@stryke/helpers/get-unique"),p=require("@stryke/path/find"),m=require("@stryke/resolve/constants"),h=require("defu");h=s(h,1);function g(e){let t=l.isSchema(e)?e.schema:e;if(!l.isJsonSchema(t))throw TypeError(`The provided input is not a valid JSON Schema`);return t}function _(e){let t=g(e);if(!l.isJsonSchemaObject(t))throw TypeError(`The provided input is not a valid JSON Schema object`);return t}function v(e){let t=_(e);return(0,d.isSetObject)(t.properties)?Object.entries(t.properties).reduce((e,[n,r])=>(r.name=n,r.required=!E(t,n),r.default=t.default?.[n]??r.default,e[n]=r,e),{}):{}}function y(e){return Object.values(v(e))}function b(e,t){let n=_(e);if(!(0,d.isSetObject)(n.properties))throw TypeError(`The provided schema does not have any properties`);let r=n.properties[t];if(!r)throw TypeError(`The provided schema does not have a property named "${t}"`);return{...r,name:t,required:!E(n,t),default:n.default?.[t]??r?.default}}function x(e,t,n){let r=_(e);r.properties??={},r.required??=[],n.name=t,r.properties[t]=n,r.required.includes(t)||r.required.push(t),r.required.length===0&&delete r.required}function S(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if(e===`required`)n[e]=(0,f.getUnique)([...Array.isArray(t)?t:[],...Array.isArray(r)?r:[]]);else if(c.SCHEMA_RECORD_KEYWORDS.has(e)&&(0,d.isSetObject)(t)&&(0,d.isSetObject)(r)){let i={...t};for(let[e,t]of Object.entries(r)){let n=i[e];i[e]=l.isJsonSchema(n)&&l.isJsonSchema(t)?S(n,t):t}n[e]=i}else c.SCHEMA_ARRAY_CONCAT_KEYWORDS.has(e)&&Array.isArray(t)&&Array.isArray(r)?n[e]=[...t,...r]:c.SCHEMA_SINGLE_KEYWORDS.has(e)&&l.isJsonSchema(t)&&l.isJsonSchema(r)?n[e]=S(t,r):n[e]=r}return n}function C(...e){let t=e.map(e=>g(e));return t.length===0?{}:t.reduce((e,t)=>{let n=e.type,r=t.type;return n&&r&&n!==r?t:S(e,t)})}function w(e,t){return(0,h.default)(e,Object.fromEntries(c.JSON_SCHEMA_METADATA_KEYS.filter(e=>t[e]!==void 0).map(e=>[e,t[e]])))}function T(e){return(0,d.isSetObject)(e)?e.nullable===!0?!0:u.readSchemaTypes(e).includes(`null`):!1}function E(e,t){if(!e.properties?.[t])throw Error(`The property "${t}" does not exist in the parent schema.`);return!(e.required??[]).includes(t)}function D(e){return m.VALID_OBJECT_SOURCE_EXTENSIONS.includes((0,p.findFileExtensionSafe)(e))}exports.addProperty=x,exports.getJsonSchema=g,exports.getJsonSchemaObject=_,exports.getProperties=v,exports.getPropertiesList=y,exports.getProperty=b,exports.isPropertyOptional=E,exports.isSchemaNullable=T,exports.isValidSchemaInputFile=D,exports.merge=C,exports.mergeMetadata=w;
|
package/dist/helpers.d.cts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaObject, JsonSchemaOf, SchemaEnvelope } from "./types.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers.d.ts
|
|
4
|
-
type GetPropertyResult = JsonSchema & {
|
|
5
|
-
name: string;
|
|
6
|
-
required: boolean;
|
|
7
|
-
default?: unknown;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Retrieves the JSON Schema from a Schema wrapper or returns the input if it's already a JSON Schema.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
|
|
14
|
-
*
|
|
15
|
-
* @param input - The input which can be either a Schema wrapper or a JSON Schema object.
|
|
16
|
-
* @returns The JSON Schema object.
|
|
17
|
-
* @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
|
|
18
|
-
*/
|
|
19
|
-
declare function getJsonSchema(input: SchemaEnvelope | JsonSchema): JsonSchema;
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves the JSON Schema in Object form from a Schema wrapper or returns the input if it's already a JSON Schema.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema object, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
|
|
25
|
-
*
|
|
26
|
-
* @param input - The input which can be either a Schema wrapper or a JSON Schema object.
|
|
27
|
-
* @returns The JSON Schema object.
|
|
28
|
-
* @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
|
|
29
|
-
*/
|
|
30
|
-
declare function getJsonSchemaObject(input: SchemaEnvelope | JsonSchema): JsonSchemaObject;
|
|
31
|
-
/**
|
|
32
|
-
* Extracts object properties from a JSON Schema object form.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* This function returns an empty object if the schema is not an object form or if it has no properties.
|
|
36
|
-
*
|
|
37
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
38
|
-
* @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.
|
|
39
|
-
*/
|
|
40
|
-
declare function getProperties(obj: SchemaEnvelope | JsonSchemaObject): Record<string, GetPropertyResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Returns object properties as an array.
|
|
43
|
-
*
|
|
44
|
-
* @remarks
|
|
45
|
-
* This is a convenience function that extracts properties using `getProperties` and returns them as an array.
|
|
46
|
-
*
|
|
47
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
48
|
-
* @returns An array of JSON Schema fragments representing the properties, each including metadata.
|
|
49
|
-
*/
|
|
50
|
-
declare function getPropertiesList(obj: SchemaEnvelope | JsonSchemaObject): GetPropertyResult[];
|
|
51
|
-
/**
|
|
52
|
-
* Extracts object properties from a JSON Schema object form.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* This function returns an empty object if the schema is not an object form or if it has no properties.
|
|
56
|
-
*
|
|
57
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
58
|
-
* @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.
|
|
59
|
-
*/
|
|
60
|
-
declare function getProperty<TSchema extends JsonSchemaObject>(obj: SchemaEnvelope<TSchema> | TSchema, name: keyof TSchema["properties"] & string): GetPropertyResult;
|
|
61
|
-
/**
|
|
62
|
-
* Adds a property to a JSON Schema object form.
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
65
|
-
* This function modifies the provided schema in place by adding a new property with the specified name and schema. It also updates the `required` array based on the `optional` flag of the property. If the property is marked as optional, it will be removed from the `required` array; otherwise, it will be added to it.
|
|
66
|
-
*
|
|
67
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to which the property should be added.
|
|
68
|
-
* @param name - The name of the property to add.
|
|
69
|
-
* @param property - The JSON Schema fragment representing the property's schema, including metadata.
|
|
70
|
-
* @throws Will throw an error if the provided schema is not an object form.
|
|
71
|
-
*/
|
|
72
|
-
declare function addProperty(obj: SchemaEnvelope | JsonSchemaObject, name: string, property: JsonSchema): void;
|
|
73
|
-
/**
|
|
74
|
-
* Merges multiple JSON Schemas into one.
|
|
75
|
-
*
|
|
76
|
-
* @remarks
|
|
77
|
-
* This function takes multiple JSON Schemas or Schema wrappers and merges them
|
|
78
|
-
* into a single JSON Schema object. Later schemas in the argument list take
|
|
79
|
-
* precedence over earlier ones for scalar conflicts.
|
|
80
|
-
*
|
|
81
|
-
* Structured keywords are merged recursively:
|
|
82
|
-
* - Named child schemas (`properties`, `$defs`, etc.) are merged
|
|
83
|
-
* per-property via recursive calls to `merge`.
|
|
84
|
-
* - Composition arrays (`allOf`, `anyOf`, `oneOf`) are concatenated.
|
|
85
|
-
* - Single-schema keywords (`if`, `then`, `else`, `not`, `items`, etc.)
|
|
86
|
-
* are merged recursively when both sides define them.
|
|
87
|
-
* - `required` arrays are union'ed and deduplicated.
|
|
88
|
-
*
|
|
89
|
-
* @param schemas - An array of JSON Schemas or Schema wrappers to merge.
|
|
90
|
-
* @returns A new JSON Schema that is the result of merging all input schemas.
|
|
91
|
-
*/
|
|
92
|
-
declare function merge(...schemas: (JsonSchema | SchemaEnvelope)[]): JsonSchema;
|
|
93
|
-
/**
|
|
94
|
-
* Merges metadata into a JSON Schema fragment.
|
|
95
|
-
*
|
|
96
|
-
* @remarks
|
|
97
|
-
* This function takes a JSON Schema fragment and a metadata object, and merges the metadata into the schema. Only the keys defined in {@link JSON_SCHEMA_METADATA_KEYS} are considered for merging. The resulting schema will include the original schema properties along with the provided metadata.
|
|
98
|
-
*
|
|
99
|
-
* @param schema - The JSON Schema fragment to merge metadata into.
|
|
100
|
-
* @param metadata - The metadata to merge into the schema.
|
|
101
|
-
* @returns A new JSON Schema fragment that includes the merged metadata.
|
|
102
|
-
*/
|
|
103
|
-
declare function mergeMetadata<TSpec>(schema: JsonSchemaOf<TSpec>, metadata: JsonSchemaMetadataKeywords): JsonSchemaOf<TSpec>;
|
|
104
|
-
/**
|
|
105
|
-
* Returns whether a JSON Schema fragment accepts `null`.
|
|
106
|
-
*
|
|
107
|
-
* @remarks
|
|
108
|
-
* This is true if the schema has `nullable: true` or if its `type` includes `"null"`.
|
|
109
|
-
*
|
|
110
|
-
* @param schema - The JSON Schema fragment to check.
|
|
111
|
-
* @returns `true` if the schema accepts `null`, otherwise `false`.
|
|
112
|
-
*/
|
|
113
|
-
declare function isSchemaNullable(schema?: JsonSchema): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Returns whether an object property is optional (not listed in `required`).
|
|
116
|
-
*
|
|
117
|
-
* @remarks
|
|
118
|
-
* In JSON Schema, object properties are optional by default unless they are listed in the `required` array of the parent schema. This function checks whether a given property name is not included in the `required` array of its parent schema, indicating that it is optional.
|
|
119
|
-
*
|
|
120
|
-
* @param parent - The parent JSON Schema object containing the property.
|
|
121
|
-
* @param propertyName - The name of the property to check for optionality.
|
|
122
|
-
* @returns `true` if the property is optional, otherwise `false`.
|
|
123
|
-
*/
|
|
124
|
-
declare function isPropertyOptional(parent: JsonSchemaObject, propertyName: string): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Checks if a given file name has a valid schema input file extension.
|
|
127
|
-
*
|
|
128
|
-
* @param fileName - The file name to check for a valid schema input extension.
|
|
129
|
-
* @returns `true` if the file name has a valid schema input extension, otherwise `false`.
|
|
130
|
-
*/
|
|
131
|
-
declare function isValidSchemaInputFile(fileName: string): boolean;
|
|
132
|
-
//#endregion
|
|
133
|
-
export { GetPropertyResult, addProperty, getJsonSchema, getJsonSchemaObject, getProperties, getPropertiesList, getProperty, isPropertyOptional, isSchemaNullable, isValidSchemaInputFile, merge, mergeMetadata };
|
|
134
|
-
//# sourceMappingURL=helpers.d.cts.map
|
package/dist/helpers.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.cts","names":[],"sources":["../src/helpers.ts"],"mappings":";;;KAwCY,iBAAA,GAAoB,UAAU;EACxC,IAAA;EACA,QAAA;EACA,OAAA;AAAA;;;;;;;AAAO;AAaT;;;iBAAgB,aAAA,CAAc,KAAA,EAAO,cAAA,GAAiB,UAAA,GAAa,UAAA;;;;;;;;;;AAAU;iBAmB7D,mBAAA,CACd,KAAA,EAAO,cAAA,GAAiB,UAAA,GACvB,gBAAA;;;;;;;;;;iBAkBa,aAAA,CACd,GAAA,EAAK,cAAA,GAAiB,gBAAA,GACrB,MAAA,SAAe,iBAAA;;;AApBC;AAkBnB;;;;;;iBA+BgB,iBAAA,CAAkB,GAAA,EAAK,cAAA,GAAiB,gBAAA,GAAgB,iBAAA;;;;;;;;;AA7BrC;iBA0CnB,WAAA,iBAA4B,gBAAA,EAC1C,GAAA,EAAK,cAAA,CAAe,OAAA,IAAW,OAAA,EAC/B,IAAA,QAAY,OAAA,0BACX,iBAAA;;;;;;;;;;;;iBAgCa,WAAA,CACd,GAAA,EAAK,cAAA,GAAiB,gBAAA,EACtB,IAAA,UACA,QAAA,EAAU,UAAA;AAnD4D;AAaxE;;;;;;;;;;;;;;;;;;AAbwE,iBA4JxD,KAAA,IAAS,OAAA,GAAU,UAAA,GAAa,cAAA,MAAoB,UAAA;;;AA5IhD;AAgCpB;;;;;;;iBAyIgB,aAAA,QACd,MAAA,EAAQ,YAAA,CAAa,KAAA,GACrB,QAAA,EAAU,0BAAA,GACT,YAAA,CAAa,KAAA;;;;;;;;AAzIM;AAyGtB;iBAoDgB,gBAAA,CAAiB,MAAmB,GAAV,UAAU;;;;;;;;;;;iBAsBpC,kBAAA,CACd,MAAA,EAAQ,gBAAgB,EACxB,YAAA;AA5E4E;AA6B9E;;;;;AA7B8E,iBA6F9D,sBAAA,CAAuB,QAAgB"}
|
package/dist/helpers.d.mts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaObject, JsonSchemaOf, SchemaEnvelope } from "./types.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers.d.ts
|
|
4
|
-
type GetPropertyResult = JsonSchema & {
|
|
5
|
-
name: string;
|
|
6
|
-
required: boolean;
|
|
7
|
-
default?: unknown;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Retrieves the JSON Schema from a Schema wrapper or returns the input if it's already a JSON Schema.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
|
|
14
|
-
*
|
|
15
|
-
* @param input - The input which can be either a Schema wrapper or a JSON Schema object.
|
|
16
|
-
* @returns The JSON Schema object.
|
|
17
|
-
* @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
|
|
18
|
-
*/
|
|
19
|
-
declare function getJsonSchema(input: SchemaEnvelope | JsonSchema): JsonSchema;
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves the JSON Schema in Object form from a Schema wrapper or returns the input if it's already a JSON Schema.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema object, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
|
|
25
|
-
*
|
|
26
|
-
* @param input - The input which can be either a Schema wrapper or a JSON Schema object.
|
|
27
|
-
* @returns The JSON Schema object.
|
|
28
|
-
* @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
|
|
29
|
-
*/
|
|
30
|
-
declare function getJsonSchemaObject(input: SchemaEnvelope | JsonSchema): JsonSchemaObject;
|
|
31
|
-
/**
|
|
32
|
-
* Extracts object properties from a JSON Schema object form.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* This function returns an empty object if the schema is not an object form or if it has no properties.
|
|
36
|
-
*
|
|
37
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
38
|
-
* @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.
|
|
39
|
-
*/
|
|
40
|
-
declare function getProperties(obj: SchemaEnvelope | JsonSchemaObject): Record<string, GetPropertyResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Returns object properties as an array.
|
|
43
|
-
*
|
|
44
|
-
* @remarks
|
|
45
|
-
* This is a convenience function that extracts properties using `getProperties` and returns them as an array.
|
|
46
|
-
*
|
|
47
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
48
|
-
* @returns An array of JSON Schema fragments representing the properties, each including metadata.
|
|
49
|
-
*/
|
|
50
|
-
declare function getPropertiesList(obj: SchemaEnvelope | JsonSchemaObject): GetPropertyResult[];
|
|
51
|
-
/**
|
|
52
|
-
* Extracts object properties from a JSON Schema object form.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* This function returns an empty object if the schema is not an object form or if it has no properties.
|
|
56
|
-
*
|
|
57
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
58
|
-
* @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.
|
|
59
|
-
*/
|
|
60
|
-
declare function getProperty<TSchema extends JsonSchemaObject>(obj: SchemaEnvelope<TSchema> | TSchema, name: keyof TSchema["properties"] & string): GetPropertyResult;
|
|
61
|
-
/**
|
|
62
|
-
* Adds a property to a JSON Schema object form.
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
65
|
-
* This function modifies the provided schema in place by adding a new property with the specified name and schema. It also updates the `required` array based on the `optional` flag of the property. If the property is marked as optional, it will be removed from the `required` array; otherwise, it will be added to it.
|
|
66
|
-
*
|
|
67
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to which the property should be added.
|
|
68
|
-
* @param name - The name of the property to add.
|
|
69
|
-
* @param property - The JSON Schema fragment representing the property's schema, including metadata.
|
|
70
|
-
* @throws Will throw an error if the provided schema is not an object form.
|
|
71
|
-
*/
|
|
72
|
-
declare function addProperty(obj: SchemaEnvelope | JsonSchemaObject, name: string, property: JsonSchema): void;
|
|
73
|
-
/**
|
|
74
|
-
* Merges multiple JSON Schemas into one.
|
|
75
|
-
*
|
|
76
|
-
* @remarks
|
|
77
|
-
* This function takes multiple JSON Schemas or Schema wrappers and merges them
|
|
78
|
-
* into a single JSON Schema object. Later schemas in the argument list take
|
|
79
|
-
* precedence over earlier ones for scalar conflicts.
|
|
80
|
-
*
|
|
81
|
-
* Structured keywords are merged recursively:
|
|
82
|
-
* - Named child schemas (`properties`, `$defs`, etc.) are merged
|
|
83
|
-
* per-property via recursive calls to `merge`.
|
|
84
|
-
* - Composition arrays (`allOf`, `anyOf`, `oneOf`) are concatenated.
|
|
85
|
-
* - Single-schema keywords (`if`, `then`, `else`, `not`, `items`, etc.)
|
|
86
|
-
* are merged recursively when both sides define them.
|
|
87
|
-
* - `required` arrays are union'ed and deduplicated.
|
|
88
|
-
*
|
|
89
|
-
* @param schemas - An array of JSON Schemas or Schema wrappers to merge.
|
|
90
|
-
* @returns A new JSON Schema that is the result of merging all input schemas.
|
|
91
|
-
*/
|
|
92
|
-
declare function merge(...schemas: (JsonSchema | SchemaEnvelope)[]): JsonSchema;
|
|
93
|
-
/**
|
|
94
|
-
* Merges metadata into a JSON Schema fragment.
|
|
95
|
-
*
|
|
96
|
-
* @remarks
|
|
97
|
-
* This function takes a JSON Schema fragment and a metadata object, and merges the metadata into the schema. Only the keys defined in {@link JSON_SCHEMA_METADATA_KEYS} are considered for merging. The resulting schema will include the original schema properties along with the provided metadata.
|
|
98
|
-
*
|
|
99
|
-
* @param schema - The JSON Schema fragment to merge metadata into.
|
|
100
|
-
* @param metadata - The metadata to merge into the schema.
|
|
101
|
-
* @returns A new JSON Schema fragment that includes the merged metadata.
|
|
102
|
-
*/
|
|
103
|
-
declare function mergeMetadata<TSpec>(schema: JsonSchemaOf<TSpec>, metadata: JsonSchemaMetadataKeywords): JsonSchemaOf<TSpec>;
|
|
104
|
-
/**
|
|
105
|
-
* Returns whether a JSON Schema fragment accepts `null`.
|
|
106
|
-
*
|
|
107
|
-
* @remarks
|
|
108
|
-
* This is true if the schema has `nullable: true` or if its `type` includes `"null"`.
|
|
109
|
-
*
|
|
110
|
-
* @param schema - The JSON Schema fragment to check.
|
|
111
|
-
* @returns `true` if the schema accepts `null`, otherwise `false`.
|
|
112
|
-
*/
|
|
113
|
-
declare function isSchemaNullable(schema?: JsonSchema): boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Returns whether an object property is optional (not listed in `required`).
|
|
116
|
-
*
|
|
117
|
-
* @remarks
|
|
118
|
-
* In JSON Schema, object properties are optional by default unless they are listed in the `required` array of the parent schema. This function checks whether a given property name is not included in the `required` array of its parent schema, indicating that it is optional.
|
|
119
|
-
*
|
|
120
|
-
* @param parent - The parent JSON Schema object containing the property.
|
|
121
|
-
* @param propertyName - The name of the property to check for optionality.
|
|
122
|
-
* @returns `true` if the property is optional, otherwise `false`.
|
|
123
|
-
*/
|
|
124
|
-
declare function isPropertyOptional(parent: JsonSchemaObject, propertyName: string): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Checks if a given file name has a valid schema input file extension.
|
|
127
|
-
*
|
|
128
|
-
* @param fileName - The file name to check for a valid schema input extension.
|
|
129
|
-
* @returns `true` if the file name has a valid schema input extension, otherwise `false`.
|
|
130
|
-
*/
|
|
131
|
-
declare function isValidSchemaInputFile(fileName: string): boolean;
|
|
132
|
-
//#endregion
|
|
133
|
-
export { GetPropertyResult, addProperty, getJsonSchema, getJsonSchemaObject, getProperties, getPropertiesList, getProperty, isPropertyOptional, isSchemaNullable, isValidSchemaInputFile, merge, mergeMetadata };
|
|
134
|
-
//# sourceMappingURL=helpers.d.mts.map
|
package/dist/helpers.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/helpers.ts"],"mappings":""}
|
package/dist/helpers.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{JSON_SCHEMA_METADATA_KEYS as e,SCHEMA_ARRAY_CONCAT_KEYWORDS as t,SCHEMA_RECORD_KEYWORDS as n,SCHEMA_SINGLE_KEYWORDS as r}from"./constants.mjs";import{isJsonSchema as i,isJsonSchemaObject as a,isSchema as o}from"./type-checks.mjs";import{readSchemaTypes as s}from"./metadata.mjs";import{isSetObject as c}from"@stryke/type-checks";import{getUnique as l}from"@stryke/helpers/get-unique";import{findFileExtensionSafe as u}from"@stryke/path/find";import{VALID_OBJECT_SOURCE_EXTENSIONS as d}from"@stryke/resolve/constants";import f from"defu";function p(e){let t=o(e)?e.schema:e;if(!i(t))throw TypeError(`The provided input is not a valid JSON Schema`);return t}function m(e){let t=p(e);if(!a(t))throw TypeError(`The provided input is not a valid JSON Schema object`);return t}function h(e){let t=m(e);return c(t.properties)?Object.entries(t.properties).reduce((e,[n,r])=>(r.name=n,r.required=!C(t,n),r.default=t.default?.[n]??r.default,e[n]=r,e),{}):{}}function g(e){return Object.values(h(e))}function _(e,t){let n=m(e);if(!c(n.properties))throw TypeError(`The provided schema does not have any properties`);let r=n.properties[t];if(!r)throw TypeError(`The provided schema does not have a property named "${t}"`);return{...r,name:t,required:!C(n,t),default:n.default?.[t]??r?.default}}function v(e,t,n){let r=m(e);r.properties??={},r.required??=[],n.name=t,r.properties[t]=n,r.required.includes(t)||r.required.push(t),r.required.length===0&&delete r.required}function y(e,a){let o={...e};for(let[e,s]of Object.entries(a)){let a=o[e];if(e===`required`)o[e]=l([...Array.isArray(a)?a:[],...Array.isArray(s)?s:[]]);else if(n.has(e)&&c(a)&&c(s)){let t={...a};for(let[e,n]of Object.entries(s)){let r=t[e];t[e]=i(r)&&i(n)?y(r,n):n}o[e]=t}else t.has(e)&&Array.isArray(a)&&Array.isArray(s)?o[e]=[...a,...s]:r.has(e)&&i(a)&&i(s)?o[e]=y(a,s):o[e]=s}return o}function b(...e){let t=e.map(e=>p(e));return t.length===0?{}:t.reduce((e,t)=>{let n=e.type,r=t.type;return n&&r&&n!==r?t:y(e,t)})}function x(t,n){return f(t,Object.fromEntries(e.filter(e=>n[e]!==void 0).map(e=>[e,n[e]])))}function S(e){return c(e)?e.nullable===!0?!0:s(e).includes(`null`):!1}function C(e,t){if(!e.properties?.[t])throw Error(`The property "${t}" does not exist in the parent schema.`);return!(e.required??[]).includes(t)}function w(e){return d.includes(u(e))}export{v as addProperty,p as getJsonSchema,m as getJsonSchemaObject,h as getProperties,g as getPropertiesList,_ as getProperty,C as isPropertyOptional,S as isSchemaNullable,w as isValidSchemaInputFile,b as merge,x as mergeMetadata};
|
|
2
|
-
//# sourceMappingURL=helpers.mjs.map
|
package/dist/helpers.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/metadata.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants.cjs");let t=require("@stryke/type-checks/is-set-object"),n=require("@stryke/type-checks/is-set-string");function r(n,r){if(!r||!(0,t.isSetObject)(n))return n;let i={...n},a=i;for(let t of e.JSON_SCHEMA_METADATA_KEYS){let e=r[t];e!=null&&(a[t]=e)}return i}function i(e){if(!(0,t.isSetObject)(e))return[];let r=e;return Array.isArray(r.type)?r.type.filter(e=>(0,n.isSetString)(e)):(0,n.isSetString)(r.type)&&r.type!==`object`&&r.type!==`array`?[r.type]:[]}function a(e){if((0,t.isSetObject)(e))return i(e).find(e=>e!==`null`)}exports.applyJsonSchemaMetadata=r,exports.getPrimarySchemaType=a,exports.readSchemaTypes=i;
|
package/dist/metadata.d.cts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaPrimitiveType } from "./types.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/metadata.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
6
|
-
*
|
|
7
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
8
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
9
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
10
|
-
*/
|
|
11
|
-
declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
|
|
12
|
-
/**
|
|
13
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
17
|
-
*
|
|
18
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
19
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
20
|
-
*/
|
|
21
|
-
declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
|
|
22
|
-
/**
|
|
23
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
24
|
-
*
|
|
25
|
-
* @param schema - The JSON Schema fragment to check.
|
|
26
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
27
|
-
*/
|
|
28
|
-
declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
|
|
31
|
-
//# sourceMappingURL=metadata.d.cts.map
|
package/dist/metadata.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.cts","names":[],"sources":["../src/metadata.ts"],"mappings":";;;;;AAuCA;;;;;iBAAgB,uBAAA,CACd,MAAA,EAAQ,UAAA,EACR,QAAA,EAAU,0BAAA,eACT,UAAA;;;;;;;;;AAAU;iBA0BG,eAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB;;;;;;;iBA6BV,oBAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB"}
|
package/dist/metadata.d.mts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaPrimitiveType } from "./types.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/metadata.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
6
|
-
*
|
|
7
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
8
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
9
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
10
|
-
*/
|
|
11
|
-
declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
|
|
12
|
-
/**
|
|
13
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
17
|
-
*
|
|
18
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
19
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
20
|
-
*/
|
|
21
|
-
declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
|
|
22
|
-
/**
|
|
23
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
24
|
-
*
|
|
25
|
-
* @param schema - The JSON Schema fragment to check.
|
|
26
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
27
|
-
*/
|
|
28
|
-
declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
|
|
31
|
-
//# sourceMappingURL=metadata.d.mts.map
|
package/dist/metadata.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.mts","names":[],"sources":["../src/metadata.ts"],"mappings":""}
|
package/dist/metadata.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{JSON_SCHEMA_METADATA_KEYS as e}from"./constants.mjs";import{isSetObject as t}from"@stryke/type-checks/is-set-object";import{isSetString as n}from"@stryke/type-checks/is-set-string";function r(n,r){if(!r||!t(n))return n;let i={...n},a=i;for(let t of e){let e=r[t];e!=null&&(a[t]=e)}return i}function i(e){if(!t(e))return[];let r=e;return Array.isArray(r.type)?r.type.filter(e=>n(e)):n(r.type)&&r.type!==`object`&&r.type!==`array`?[r.type]:[]}function a(e){if(t(e))return i(e).find(e=>e!==`null`)}export{r as applyJsonSchemaMetadata,a as getPrimarySchemaType,i as readSchemaTypes};
|
|
2
|
-
//# sourceMappingURL=metadata.mjs.map
|
package/dist/metadata.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/type-checks.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants.cjs");let t=require("@stryke/type-checks");function n(e){return!(0,t.isString)(e)&&e.file!==void 0}const r=e=>typeof e==`number`&&Number.isFinite(e),i=e=>(0,t.isSetObject)(e)||(0,t.isBoolean)(e),a=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>i(e)),o=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>(0,t.isBoolean)(e)),s=e=>Array.isArray(e)&&e.every(e=>(0,t.isSetString)(e)),ee=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>s(e)),c=new Set(e.JSON_SCHEMA_PRIMITIVE_TYPES),l=new Set(e.JSON_SCHEMA_TYPES);function te(e){return(0,t.isSetString)(e)&&c.has(e)}function u(e){return(0,t.isSetString)(e)&&l.has(e)}const ne=new Set([`date`,`time`,`date-time`,`iso-time`,`iso-date-time`,`unix-time`]),d=e=>typeof e==`bigint`,re=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`function`,`object`,`any`,`array`]),f=e=>(0,t.isSetString)(e)&&re.has(e),p=e=>{if(!(0,t.isSetObject)(e))return!1;let n=e;return!(n.type!==void 0&&!((0,t.isSetString)(n.type)&&f(n.type)||Array.isArray(n.type)&&n.type.every(e=>f(e)))||n.tsType!==void 0&&!(0,t.isSetString)(n.tsType)||n.markdownType!==void 0&&!(0,t.isSetString)(n.markdownType)||n.items!==void 0&&!(p(n.items)||Array.isArray(n.items)&&n.items.every(e=>p(e))))},ie=e=>{if(!p(e))return!1;let n=e;return n.name!==void 0&&!(0,t.isSetString)(n.name)?!1:n.optional===void 0||typeof n.optional==`boolean`},ae=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>Z(e)),m=(e,t)=>Array.isArray(e)&&e.every(e=>t(e)),oe=(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),h=(e,n=!1)=>e===void 0||(0,t.isString)(e)&&(n||e.length>0),g=e=>e===void 0||(0,t.isBoolean)(e),_=e=>e===void 0||r(e),v=e=>e===void 0||d(e),y=e=>e===void 0||X(e),b=e=>e===void 0||m(e,X),se=e=>e===void 0||Array.isArray(e)&&e.every(e=>(0,t.isSetString)(e)&&c.has(e)),ce=e=>e===void 0||Array.isArray(e)&&e.every(e=>(0,t.isSetString)(e)&&l.has(e)),x=e=>!(!h(e.$id)||!h(e.$schema)||e.$vocabulary!==void 0&&!o(e.$vocabulary)||!h(e.$comment,!0)||!h(e.$anchor)||e.$defs!==void 0&&!a(e.$defs)||!h(e.$dynamicRef)||!h(e.$dynamicAnchor)||!h(e.name)||!h(e.title,!0)||!h(e.description,!0)||!h(e.docs,!0)||e.examples!==void 0&&!Array.isArray(e.examples)||e.alias!==void 0&&!s(e.alias)||e.tags!==void 0&&!s(e.tags)||!g(e.deprecated)||!g(e.hidden)||!g(e.ignore)||!g(e.internal)||!g(e.runtime)||!g(e.readOnly)||!g(e.writeOnly)||!b(e.allOf)||!b(e.anyOf)||!b(e.oneOf)||!y(e.not)||!y(e.if)||!y(e.then)||!y(e.else));function le(e){return(0,t.isSetObject)(e)?x(e):!1}function S(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&h(n.$ref)}function C(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||n.type!==`array`?!1:b(n.prefixItems)&&y(n.items)&&y(n.contains)&&_(n.minItems)&&_(n.maxItems)&&g(n.uniqueItems)&&_(n.minContains)&&_(n.maxContains)&&(n.unevaluatedItems===void 0||(0,t.isBoolean)(n.unevaluatedItems)||X(n.unevaluatedItems))}function w(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||n.type!==`integer`||n.format!==`int64`?!1:v(n.minimum)&&v(n.exclusiveMinimum)&&v(n.maximum)&&v(n.exclusiveMaximum)&&v(n.multipleOf)&&v(n.default)&&(n.enum===void 0||m(n.enum,d))}function T(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`boolean`&&g(n.default)}function E(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)?n.anyOf===void 0?n.type!==`integer`&&n.type!==`string`||!(0,t.isSetString)(n.format)||!ne.has(n.format)?!1:_(n.minimum)&&_(n.maximum)&&(n.default===void 0||(0,t.isSetString)(n.default)||r(n.default)):m(n.anyOf,E):!1}function D(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!x(n)||!(0,t.isSetString)(n.type)||!c.has(n.type)||!Array.isArray(n.enum))return!1;let i=n.type,a=n.enum,o=n.default;return i===`string`?a.every(e=>(0,t.isSetString)(e))&&(o===void 0||(0,t.isSetString)(o)):i===`number`||i===`integer`?a.every(e=>r(e))&&(o===void 0||r(o)):i===`boolean`?a.every(e=>(0,t.isBoolean)(e))&&(o===void 0||(0,t.isBoolean)(o)):i===`null`&&a.every(e=>e===null)&&o==null}function O(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||!m(n.allOf,X)?!1:n.unevaluatedProperties===void 0||(0,t.isBoolean)(n.unevaluatedProperties)||X(n.unevaluatedProperties)}function k(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||!(`const`in n)?!1:n.type===void 0||(0,t.isSetString)(n.type)&&u(n.type)||ce(n.type)}function A(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!x(n)||n.type!==`array`||n.maxItems!==125||!(0,t.isSetObject)(n.items))return!1;let r=n.items;return r.type===`array`&&oe(r.prefixItems,X,X)&&(r.items===void 0||r.items===!1)&&r.minItems===2&&r.maxItems===2}function j(e){if(!(0,t.isSetObject)(e))return!1;let n=e,i=n.type===`string`||n.type===`number`||Array.isArray(n.type)&&n.type.length===2&&n.type[0]===`string`&&n.type[1]===`number`;return x(n)&&i&&Array.isArray(n.enum)&&n.enum.every(e=>(0,t.isSetString)(e)||r(e))}function M(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&S(n.not)}function N(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`null`&&(n.const===void 0||n.const===null)&&(n.enum===void 0||Array.isArray(n.enum)&&n.enum.every(e=>e===null))&&(n.default===void 0||n.default===null)}function P(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!x(n))return!1;let r=n.anyOf!==void 0&&Array.isArray(n.anyOf)&&n.anyOf.length===2&&X(n.anyOf[0])&&N(n.anyOf[1]),i=Array.isArray(n.type)&&n.type.length===2&&(n.type[0]===`null`&&(0,t.isSetString)(n.type[1])&&n.type[1]!==`null`&&l.has(n.type[1])||n.type[1]===`null`&&(0,t.isSetString)(n.type[0])&&n.type[0]!==`null`&&l.has(n.type[0]));return r||i}function F(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||n.type!==`number`&&n.type!==`integer`?!1:h(n.format)&&_(n.minimum)&&_(n.exclusiveMinimum)&&_(n.maximum)&&_(n.exclusiveMaximum)&&_(n.multipleOf)&&_(n.default)&&(n.enum===void 0||m(n.enum,r))}function I(e){return F(e)&&e.type===`integer`}function L(e){return F(e)&&e.type===`number`}function R(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`object`&&(n.properties===void 0||a(n.properties))&&(n.patternProperties===void 0||a(n.patternProperties))&&(n.additionalProperties===void 0||(0,t.isBoolean)(n.additionalProperties)||X(n.additionalProperties))&&(n.required===void 0||s(n.required))&&(n.unevaluatedProperties===void 0||(0,t.isBoolean)(n.unevaluatedProperties)||X(n.unevaluatedProperties))&&(n.dependencies===void 0||(0,t.isSetObject)(n.dependencies)&&Object.values(n.dependencies).every(e=>s(e)||X(e)))&&(n.dependentRequired===void 0||ee(n.dependentRequired))&&(n.dependentSchemas===void 0||a(n.dependentSchemas))&&_(n.minProperties)&&_(n.maxProperties)&&(n.primaryKey===void 0||s(n.primaryKey))&&h(n.databaseSchema)}function z(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`string`&&_(n.minLength)&&_(n.maxLength)&&h(n.pattern)&&h(n.format)&&h(n.default)&&(n.enum===void 0||m(n.enum,t.isSetString))&&h(n.contentMediaType)&&h(n.contentEncoding)&&h(n.contentSchema)}function B(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`array`&&n.uniqueItems===!0&&b(n.prefixItems)&&y(n.items)&&y(n.contains)&&_(n.minItems)&&_(n.maxItems)&&_(n.minContains)&&_(n.maxContains)&&(n.unevaluatedItems===void 0||(0,t.isBoolean)(n.unevaluatedItems)||X(n.unevaluatedItems))}function V(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`object`&&(n.patternProperties===void 0||a(n.patternProperties))&&(n.additionalProperties===void 0||(0,t.isBoolean)(n.additionalProperties)||X(n.additionalProperties))&&y(n.propertyNames)}function H(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`array`&&m(n.prefixItems,X)&&_(n.minItems)&&_(n.maxItems)&&y(n.items)&&y(n.contains)&&g(n.uniqueItems)&&_(n.minContains)&&_(n.maxContains)&&(n.unevaluatedItems===void 0||(0,t.isBoolean)(n.unevaluatedItems)||X(n.unevaluatedItems))}function U(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&S(n.not)&&(n.default===void 0||n.default===void 0)}function W(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)?(0,t.isSetString)(n.type)&&c.has(n.type)?n.enum===void 0?!0:Array.isArray(n.enum)?n.type===`string`?n.enum.every(e=>(0,t.isSetString)(e))&&(n.default===void 0||(0,t.isSetString)(n.default)):n.type===`number`?n.enum.every(e=>r(e))&&(n.default===void 0||r(n.default)):n.type===`boolean`?n.enum.every(e=>(0,t.isBoolean)(e))&&(n.default===void 0||(0,t.isBoolean)(n.default)):n.type===`integer`?n.format===`int64`?n.enum.every(e=>d(e))&&(n.default===void 0||d(n.default)):!1:n.type===`null`&&n.enum.every(e=>e===null)&&(n.default===void 0||n.default===null):!1:se(n.type)&&n.type!==void 0:!1}function G(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&(W(n)||q(n))}function K(e){return S(e)}function q(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&m(n.anyOf,X)}function J(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&(0,t.isSetString)(n.$ref)}function Y(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!(0,t.isSetObject)(n[`~standard`]))return!1;let r=n[`~standard`];return r.version===1&&(0,t.isFunction)(r.validate)}function ue(e){if(!(0,t.isSetObject)(e)||!Y(e))return!1;let n=e;return n.kind===`schema`&&(0,t.isSetString)(n.type)&&(0,t.isBoolean)(n.async)&&(0,t.isFunction)(n.reference)&&(0,t.isSetString)(n.expects)&&(0,t.isFunction)(n[`~run`])}function X(e){return z(e)||I(e)||L(e)||w(e)||T(e)||E(e)||D(e)||k(e)||j(e)||N(e)||C(e)||R(e)||V(e)||H(e)||G(e)||U(e)||J(e)||M(e)||A(e)||S(e)||P(e)||O(e)||K(e)||B(e)}function de(e){return N(e)}function Z(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!(!p(n)||`id`in n&&!(0,t.isSetString)(n.id)||`resolve`in n&&!(0,t.isFunction)(n.resolve)||`properties`in n&&!ae(n.properties)||`required`in n&&!s(n.required)||`title`in n&&!(0,t.isSetString)(n.title)||`description`in n&&!(0,t.isSetString)(n.description)||`$schema`in n&&!(0,t.isSetString)(n.$schema)||`tags`in n&&!s(n.tags)||`args`in n&&(!Array.isArray(n.args)||!n.args.every(e=>ie(e)))||`returns`in n&&!p(n.returns))}function Q(e){return Z(e)&&!X(e)}function fe(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!(`$schema`in n&&!Z(n.$schema)||`$resolve`in n&&!(0,t.isFunction)(n.$resolve))}function pe(e){if(!fe(e)||X(e))return!1;let t=e;return!(`$schema`in t&&t.$schema!==void 0&&!Q(t.$schema))}function $(e){return(0,t.isSetObject)(e)&&`schema`in e&&X(e.schema)&&`variant`in e&&(0,t.isSetString)(e.variant)&&`hash`in e&&(0,t.isSetString)(e.hash)}function me(e){return $(e)}function he(e){return $(e)&&`source`in e&&(0,t.isSetObject)(e.source)&&`schema`in e.source&&`variant`in e.source&&(0,t.isSetString)(e.source.variant)}function ge(e){return $(e)&&R(e.schema)}exports.isFileReference=n,exports.isJsonSchema=X,exports.isJsonSchemaAllOf=O,exports.isJsonSchemaAny=S,exports.isJsonSchemaAnyOf=q,exports.isJsonSchemaArray=C,exports.isJsonSchemaBigint=w,exports.isJsonSchemaBoolean=T,exports.isJsonSchemaDate=E,exports.isJsonSchemaDecimal=L,exports.isJsonSchemaEnum=D,exports.isJsonSchemaInteger=I,exports.isJsonSchemaKeywords=le,exports.isJsonSchemaLiteral=k,exports.isJsonSchemaMap=A,exports.isJsonSchemaNativeEnum=j,exports.isJsonSchemaNever=M,exports.isJsonSchemaNull=N,exports.isJsonSchemaNullable=P,exports.isJsonSchemaNumber=F,exports.isJsonSchemaObject=R,exports.isJsonSchemaPrimitiveType=te,exports.isJsonSchemaPrimitiveUnion=W,exports.isJsonSchemaRecord=V,exports.isJsonSchemaRef=J,exports.isJsonSchemaSet=B,exports.isJsonSchemaString=z,exports.isJsonSchemaTuple=H,exports.isJsonSchemaType=u,exports.isJsonSchemaUndefined=U,exports.isJsonSchemaUnion=G,exports.isJsonSchemaUnknown=K,exports.isNullOnlyJsonSchema=de,exports.isSchema=$,exports.isSchemaObject=ge,exports.isSchemaOf=me,exports.isSchemaWithSource=he,exports.isStandardSchema=Y,exports.isUntypedInput=fe,exports.isUntypedInputStrict=pe,exports.isUntypedSchema=Z,exports.isUntypedSchemaStrict=Q,exports.isValibotSchema=ue;
|