@power-plant/schema 0.0.5 → 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 +2 -2
- package/dist/codegen.d.cts +1 -1
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.mjs +3 -3
- package/dist/constants-CjTQhR-l.cjs +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 +14 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +14 -2
- package/dist/index.mjs +1 -1
- 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-BawP3FVI.d.mts → types-CCLUrmYp.d.cts} +18 -7
- package/dist/types-CCLUrmYp.d.cts.map +1 -0
- package/dist/{types-BmNamqlM.d.cts → types-J67fcIar.d.mts} +18 -7
- package/dist/types-J67fcIar.d.mts.map +1 -0
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.cts +1 -1
- package/dist/valibot.d.mts +1 -1
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.cts +11 -2
- package/dist/zod.d.cts.map +1 -1
- package/dist/zod.d.mts +11 -2
- package/dist/zod.mjs +1 -1
- package/package.json +33 -18
- package/dist/constants-CwyhgVEl.cjs +0 -1
- package/dist/helpers-B5sr5S3X.cjs +0 -1
- package/dist/helpers-Bh_V7xwV.mjs +0 -2
- package/dist/helpers-Bh_V7xwV.mjs.map +0 -1
- package/dist/types-BawP3FVI.d.mts.map +0 -1
- package/dist/types-BmNamqlM.d.cts.map +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<picture>
|
|
8
8
|
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/power-plant/media/banner-1280x640-dark.gif">
|
|
9
9
|
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/power-plant/media/banner-1280x640-light.gif">
|
|
10
|
-
<img src="https://public.storm-cdn.com/power-plant/media/banner-1280x640-dark.gif" width="100%" alt="
|
|
10
|
+
<img src="https://public.storm-cdn.com/power-plant/media/banner-1280x640-dark.gif" width="100%" alt="Power Plant" />
|
|
11
11
|
</picture>
|
|
12
12
|
</div>
|
|
13
13
|
<br />
|
|
@@ -33,7 +33,7 @@ The Power Plant monorepo is a collection of packages that are designed to work t
|
|
|
33
33
|
|
|
34
34
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
35
35
|
|
|
36
|
-
[](https://docs.stormsoftware.com/projects/power-plant) [](http://commitizen.github.io/cz-cli/)  
|
|
37
37
|
|
|
38
38
|
<!-- prettier-ignore-start -->
|
|
39
39
|
<!-- markdownlint-disable -->
|
package/dist/codegen.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-
|
|
2
|
-
`)} }`}}return n.oneOf||n.anyOf?(n.oneOf??n.anyOf??[]).map(e=>d(e)).join(` | `):n.allOf?`object`:`unknown`}function f(e){return(0,s.isNull)(e)?`null`:(0,o.isBoolean)(e)?`boolean`:(0,n.isInteger)(e)?`integer`:(0,c.isNumber)(e)?`number`:(0,n.isString)(e)?`string`:(0,n.isObject)(e)?`object`:Array.isArray(e)?`array`:void 0}function p(e){return/^#\/(?:definitions|\$defs)\/(.+)$/.exec(e)?.[1]}function m(e){let t=e.replace(/[^\w$]/gu,`_`);return`parse_${/^\d/u.test(t)?`_${t}`:t}`}function h(e){let t=e.type;return Array.isArray(t)?[...t]:t?[t]:[]}function g(e,t){return`${e} + ${JSON.stringify(t)}`}function _(i,o={}){let s=i,c=typeof s==`boolean`?{}:{...s.definitions,...s.$defs},l={};function u(e){let t=l[e]??0;return l[e]=t+1,`${e}${t>0?`${t}`:``}`}function f(t,n,i,s,l=`errors`){if(typeof t==`boolean`)return t?[`${s} = ${n};`]:[`${l}.push({ path: ${i}, failure: "No value is allowed at this location" });`,`${s} = ${n};`];if((0,r.isSetString)(t.$ref)){let e=p(t.$ref);return e&&e in c?[`${s} = ${m(e)}(${n}, ${i}, ${l});`]:[`${s} = ${n};`]}let d=u(t.name?`${(0,a.camelCase)(t.name)}Value`:`value`),f=u(t.name?`${(0,a.camelCase)(t.name)}Path`:`path`),h=[`const ${d} = ${n};`,`const ${f} = ${i};`];return!o.ignoreDefaults&&t.default!==void 0?(h.push(`if (${d} === undefined${t.type===`string`?` || ${d} === ""`:t.type===`number`||t.type===`integer`?` || Number.isNaN(${d})`:``}) {`,` ${s} = ${JSON.stringify(t.default)};`,`} else {`),e.c(t)?(h.push(` if (${d} === null) {`,` ${s} = null;`,` } else {`),h.push(..._(t,d,f,s,l)),h.push(` }`)):h.push(..._(t,d,f,s,l)),h.push(`}`),h):(h.push(`if (${d} === undefined) {`,` ${l}.push({ path: ${f}, failure: "A value is required" });`,` ${s} = ${d};`,`} else {`),e.c(t)?(h.push(` if (${d} === null) {`,` ${s} = null;`,` } else {`),h.push(..._(t,d,f,s,l)),h.push(` }`)):h.push(..._(t,d,f,s,l)),h.push(`}`),h)}function _(n,r,i,o,s){let c=[];if(n.const!==void 0){let e=JSON.stringify(n.const);return c.push(`if (${n.type===`string`?r:`JSON.stringify(${r})`} !== ${e}) { ${s}.push({ path: ${i}, failure: "Expected the constant value " + ${e} }); }`,`${o} = ${e};`),c}if(Array.isArray(n.enum)){let e=JSON.stringify(n.enum);return c.push(`if (!${e}.some(allowed => JSON.stringify(allowed) === JSON.stringify(${r}))) { ${s}.push({ path: ${i}, failure: \`Expected one of: ${(0,t.list)(n.enum.map(e=>JSON.stringify(e)),{conjunction:`or`})}, instead received: \${JSON.stringify(${r})}\` }); }`,`${o} = ${r};`),c}if(Array.isArray(n.oneOf)||Array.isArray(n.anyOf)){let e=n.oneOf??n.anyOf??[],t=u(n.name?`${(0,a.camelCase)(n.name)}Matched`:`matched`);c.push(`let ${t} = false;`);for(let s of e){let e=u(n.name?`${(0,a.camelCase)(n.name)}BranchErrors`:`branchErrors`),l=u(n.name?`${(0,a.camelCase)(n.name)}BranchResult`:`branchResult`);c.push(`if (!${t}) {`),c.push(` const ${e}: { path: string; failure: string }[] = [];`,` let ${l};`),c.push(...f(s,r,i,l,e)),c.push(` if (${e}.length === 0) {`,` ${o} = ${l};`,` ${t} = true;`,` }`,`}`)}return c.push(`if (!${t}) {`,` ${s}.push({ path: ${i}, failure: \`The provided value \${JSON.stringify(${r})} does not match the allowed schemas\` });`,` ${o} = ${r};`,`}`),c}if(Array.isArray(n.allOf)){let{allOf:t,...a}=n,l=e.u(a,...t);return c.push(...f(l,r,i,o,s)),c}let l=h(n);switch(e.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-BIaA3COd.cjs");let t=require("@stryke/string-format/list"),n=require("@stryke/type-checks"),r=require("@stryke/type-checks/is-set-string"),i=require("@stryke/convert/to-bool"),a=require("@stryke/string-format/camel-case"),o=require("@stryke/type-checks/is-boolean"),s=require("@stryke/type-checks/is-null"),c=require("@stryke/type-checks/is-number"),l=require("@stryke/type-checks/is-undefined");function u(e,t){return(0,l.isUndefined)(e)?`undefined`:(0,s.isNull)(e)?`null`:t===`boolean`||(0,o.isBoolean)(e)?String((0,i.toBool)(e)):t===`number`||(0,c.isNumber)(e)?Number.parseFloat(String(e)).toLocaleString(void 0,{maximumFractionDigits:20}):t===`integer`?Number.parseInt(String(e)).toLocaleString():t===`string`||t===`object`||t===`array`?JSON.stringify(e):String(e)}function d(t){if(!t)return`unknown`;if(typeof t==`boolean`)return t?`unknown`:`never`;if(e.I(t)&&(0,r.isSetString)(t.name))return t.name;let n=t;if((0,r.isSetString)(n.$ref))return/^#\/(?:definitions|\$defs)\/(.+)$/.exec(n.$ref)?.[1]??n.$ref;if(e.k(t)&&!(0,l.isUndefined)(t.const))return JSON.stringify((0,r.isSetString)(t.const)?t.const.replaceAll(/^['"`]|['"`]$/g,``):t.const);let i=e.m(t);if(i)return i===`integer`||i===`number`?`number`:i;if(n.type===`array`&&Array.isArray(n.enum))return n.enum.map(e=>JSON.stringify(e)).join(` | `);if(n.const!==void 0)return JSON.stringify(n.const);if(n.type===`array`||n.items)return`${d(Array.isArray(n.items)?n.items[0]:n.items)}[]`;if(n.type===`object`||n.properties||n.additionalProperties){if(e._(n.additionalProperties))return`{ [key: string]: ${d(n.additionalProperties)} }`;if(e.I(n)){let t=n.required??[];return`{ ${e.a(n).map(n=>{let r=!t.includes(n.name)||e.c(n)?`${t.includes(n.name)?``:`?`}${e.c(n)?` | null`:``}`:``;return`${n.name}${r}: ${d(n)}`}).join(`;
|
|
2
|
+
`)} }`}}return n.oneOf||n.anyOf?(n.oneOf??n.anyOf??[]).map(e=>d(e)).join(` | `):n.allOf?`object`:`unknown`}function f(e){return(0,s.isNull)(e)?`null`:(0,o.isBoolean)(e)?`boolean`:(0,n.isInteger)(e)?`integer`:(0,c.isNumber)(e)?`number`:(0,n.isString)(e)?`string`:(0,n.isObject)(e)?`object`:Array.isArray(e)?`array`:void 0}function p(e){return/^#\/(?:definitions|\$defs)\/(.+)$/.exec(e)?.[1]}function m(e){let t=e.replace(/[^\w$]/gu,`_`);return`parse_${/^\d/u.test(t)?`_${t}`:t}`}function h(e){let t=e.type;return Array.isArray(t)?[...t]:t?[t]:[]}function g(e,t){return`${e} + ${JSON.stringify(t)}`}function _(i,o={}){let s=i,c=typeof s==`boolean`?{}:{...s.definitions,...s.$defs},l={};function u(e){let t=l[e]??0;return l[e]=t+1,`${e}${t>0?`${t}`:``}`}function f(t,n,i,s,l=`errors`){if(typeof t==`boolean`)return t?[`${s} = ${n};`]:[`${l}.push({ path: ${i}, failure: "No value is allowed at this location" });`,`${s} = ${n};`];if((0,r.isSetString)(t.$ref)){let e=p(t.$ref);return e&&e in c?[`${s} = ${m(e)}(${n}, ${i}, ${l});`]:[`${s} = ${n};`]}let d=u(t.name?`${(0,a.camelCase)(t.name)}Value`:`value`),f=u(t.name?`${(0,a.camelCase)(t.name)}Path`:`path`),h=[`const ${d} = ${n};`,`const ${f} = ${i};`];return!o.ignoreDefaults&&t.default!==void 0?(h.push(`if (${d} === undefined${t.type===`string`?` || ${d} === ""`:t.type===`number`||t.type===`integer`?` || Number.isNaN(${d})`:``}) {`,` ${s} = ${JSON.stringify(t.default)};`,`} else {`),e.c(t)?(h.push(` if (${d} === null) {`,` ${s} = null;`,` } else {`),h.push(..._(t,d,f,s,l)),h.push(` }`)):h.push(..._(t,d,f,s,l)),h.push(`}`),h):(h.push(`if (${d} === undefined) {`,` ${l}.push({ path: ${f}, failure: "A value is required" });`,` ${s} = ${d};`,`} else {`),e.c(t)?(h.push(` if (${d} === null) {`,` ${s} = null;`,` } else {`),h.push(..._(t,d,f,s,l)),h.push(` }`)):h.push(..._(t,d,f,s,l)),h.push(`}`),h)}function _(n,r,i,o,s){let c=[];if(n.const!==void 0){let e=JSON.stringify(n.const);return c.push(`if (${n.type===`string`?r:`JSON.stringify(${r})`} !== ${e}) { ${s}.push({ path: ${i}, failure: "Expected the constant value " + ${e} }); }`,`${o} = ${e};`),c}if(Array.isArray(n.enum)){let e=JSON.stringify(n.enum);return c.push(`if (!${e}.some(allowed => JSON.stringify(allowed) === JSON.stringify(${r}))) { ${s}.push({ path: ${i}, failure: \`Expected one of: ${(0,t.list)(n.enum.map(e=>JSON.stringify(e)),{conjunction:`or`})}, instead received: \${JSON.stringify(${r})}\` }); }`,`${o} = ${r};`),c}if(Array.isArray(n.oneOf)||Array.isArray(n.anyOf)){let e=n.oneOf??n.anyOf??[],t=u(n.name?`${(0,a.camelCase)(n.name)}Matched`:`matched`);c.push(`let ${t} = false;`);for(let s of e){let e=u(n.name?`${(0,a.camelCase)(n.name)}BranchErrors`:`branchErrors`),l=u(n.name?`${(0,a.camelCase)(n.name)}BranchResult`:`branchResult`);c.push(`if (!${t}) {`),c.push(` const ${e}: { path: string; failure: string }[] = [];`,` let ${l};`),c.push(...f(s,r,i,l,e)),c.push(` if (${e}.length === 0) {`,` ${o} = ${l};`,` ${t} = true;`,` }`,`}`)}return c.push(`if (!${t}) {`,` ${s}.push({ path: ${i}, failure: \`The provided value \${JSON.stringify(${r})} does not match the allowed schemas\` });`,` ${o} = ${r};`,`}`),c}if(Array.isArray(n.allOf)){let{allOf:t,...a}=n,l=e.u(a,...t);return c.push(...f(l,r,i,o,s)),c}let l=h(n);switch(e.m(n)??l.find(e=>e!==`null`)??(n.properties?`object`:n.items?`array`:void 0)){case`object`:c.push(...v(n,r,i,o,s));break;case`array`:c.push(...y(n,r,i,o,s));break;case`string`:c.push(`if (typeof ${r} === "string") {`,` ${o} = ${r};`,`} else if (typeof ${r} === "number" || typeof ${r} === "boolean") {`,` ${o} = String(${r});`,`} else {`,` ${s}.push({ path: ${i}, failure: "Expected a string value" });`,` ${o} = ${r};`,`}`);break;case`integer`:c.push(`if (typeof ${r} === "number" && Number.isInteger(${r})) {`,` ${o} = ${r};`,`} else if (typeof ${r} === "string" && ${r}.trim() !== "" && Number.isInteger(Number(${r}))) {`,` ${o} = Number(${r});`,`} else if (typeof ${r} === "boolean") {`,` ${o} = ${r} ? 1 : 0;`,`} else {`,` ${s}.push({ path: ${i}, failure: "Expected an integer value" });`,` ${o} = ${r};`,`}`);break;case`number`:c.push(`if (typeof ${r} === "number") {`,` ${o} = ${r};`,`} else if (typeof ${r} === "string" && ${r}.trim() !== "" && !Number.isNaN(Number(${r}))) {`,` ${o} = Number(${r});`,`} else if (typeof ${r} === "boolean") {`,` ${o} = ${r} ? 1 : 0;`,`} else {`,` ${s}.push({ path: ${i}, failure: "Expected a number value" });`,` ${o} = ${r};`,`}`);break;case`boolean`:c.push(`if (typeof ${r} === "boolean") {`,` ${o} = ${r};`,`} else if ((typeof ${r} === "string" && (${r}.toLowerCase() === "true" || ${r}.toLowerCase() === "t" || ${r}.toLowerCase() === "yes" || ${r}.toLowerCase() === "y" || (!Number.isNaN(Number.parseInt(${r})) && Number.parseInt(${r}) > 0))) || (typeof ${r} === "number" && ${r} > 0)) {`,` ${o} = true;`,`} else if ((typeof ${r} === "string" && (${r}.toLowerCase() === "false" || ${r}.toLowerCase() === "f" || ${r}.toLowerCase() === "no" || ${r}.toLowerCase() === "n" || (!Number.isNaN(Number.parseInt(${r})) && Number.parseInt(${r}) <= 0))) || (typeof ${r} === "number" && ${r} <= 0)) {`,` ${o} = false;`,`} else {`,` ${s}.push({ path: ${i}, failure: "Expected a boolean value" });`,` ${o} = ${r};`,`}`);break;case`null`:c.push(`if (${r} === null) {`,` ${o} = null;`,`} else {`,` ${s}.push({ path: ${i}, failure: "Expected a null value" });`,` ${o} = ${r};`,`}`);break;case void 0:default:c.push(`${o} = ${r};`);break}return c}function v(t,r,i,o,s){let c=d(t),l=[`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) {`,` ${s}.push({ path: ${i}, failure: "Expected an object value" });`,` ${o} = ${r};`,`} else {`],p=u(c||t.name?`${(0,a.camelCase)(c||t.name)}Schema`:`schema`);if(l.push(`const ${p} = {} as Record<string, any>`),e.I(t)){let o=new Set;for(let c of e.a(t)){o.add(c.name);let t;(0,n.isSetArray)(c.alias)?(t=`(${c.alias.map(e=>`${r}[${JSON.stringify(e)}]`).join(` ${e.H(c)?`||`:`??`} `)} ${e.H(c)?`||`:`??`} ${r}[${JSON.stringify(c.name)}])`,c.alias.forEach(e=>o.add(e))):t=`${r}[${JSON.stringify(c.name)}]`;let d=g(i,`.${c.name}`),m=u(c.name?`${(0,a.camelCase)(c.name)}Property`:`property`),h=c.default===void 0?c.required?`${s}.push({ path: ${d}, failure: "Required property is missing" });`:``:`${p}[${JSON.stringify(c.name)}] = ${JSON.stringify(c.default)};`;l.push(` if (${t} !== undefined) {`,` let ${m};`),l.push(...f(c,t,d,m,s)),l.push(`${p}[${JSON.stringify(c.name)}] = ${m};`),h?l.push(`} else { ${h} }`):l.push(`}`)}let d=t.additionalProperties;if(e._(d)){let e=u(c||t.name?`${(0,a.camelCase)(c||t.name)}AdditionalProperties`:`additionalProperties`);l.push(` for (const key of Object.keys(${r})) {`,` if (${JSON.stringify([...o])}.includes(key)) { continue; }`,` let ${e};`),l.push(...f(d,`${r}[key]`,`${i} + "." + key`,e,s)),l.push(`${p}[key] = ${e};`,`}`)}else d!==!1&&l.push(` for (const key of Object.keys(${r})) {`,` if (${JSON.stringify([...o])}.includes(key)) { continue; }`,` ${p}[key] = ${r}[key];`,`}`)}return l.push(`${o} = ${p};`,`}`),l}function y(e,t,n,r,i){let o=[`if (!Array.isArray(${t})) {`,` ${i}.push({ path: ${n}, failure: "Expected an array value" });`,` ${r} = ${t};`,`} else {`],s=u(e.name?`${(0,a.camelCase)(e.name)}Array`:`array`);o.push(`const ${s}: unknown[] = [];`);let c=e.prefixItems??(Array.isArray(e.items)?e.items:void 0);if(c){let a=Array.isArray(e.items)?void 0:e.items;return o.push(` for (let index = 0; index < ${t}.length; index += 1) {`,` const item = ${t}[index];`,` let itemResult;`),c.forEach((e,t)=>{o.push(` ${t===0?`if`:`else if`} (index === ${t}) {`),o.push(...f(e,`item`,g(n,`[${t}]`),`itemResult`,i)),o.push(`}`)}),a?(o.push(`else {`),o.push(...f(a,`item`,`${n} + "[" + index + "]"`,`itemResult`,i)),o.push(`}`)):o.push(`else { itemResult = item; }`),o.push(` ${s}.push(itemResult);`,` }`,` ${r} = ${s};`,`}`),o}let l=e.items??!0;return o.push(` for (let index = 0; index < ${t}.length; index += 1) {`,` const item = ${t}[index];`,` let itemResult;`),o.push(...f(l,`item`,`${n} + "[" + index + "]"`,`itemResult`,i)),o.push(` ${s}.push(itemResult);`,` }`,` ${r} = ${s};`,`}`),o}return`/**
|
|
3
3
|
* Parser error constructor function.
|
|
4
4
|
*/
|
|
5
5
|
function ParserError(path, failure) {
|
package/dist/codegen.d.cts
CHANGED
package/dist/codegen.d.mts
CHANGED
package/dist/codegen.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)} }`}}return s.oneOf||s.anyOf?(s.oneOf??s.anyOf??[]).map(e=>x(e)).join(` | `):s.allOf?`object`:`unknown`}function S(e){return _(e)?`null`:g(e)?`boolean`:l(e)?`integer`:v(e)?`number`:f(e)?`string`:u(e)?`object`:Array.isArray(e)?`array`:void 0}function C(e){return/^#\/(?:definitions|\$defs)\/(.+)$/.exec(e)?.[1]}function w(e){let t=e.replace(/[^\w$]/gu,`_`);return`parse_${/^\d/u.test(t)?`_${t}`:t}`}function T(e){let t=e.type;return Array.isArray(t)?[...t]:t?[t]:[]}function E(e,t){return`${e} + ${JSON.stringify(t)}`}function D(
|
|
1
|
+
import{H as e,I as t,_ as n,a as r,c as i,k as a,m as o,u as s}from"./helpers-kU9GDXDZ.mjs";import{list as c}from"@stryke/string-format/list";import{isInteger as l,isObject as u,isSetArray as d,isString as f}from"@stryke/type-checks";import{isSetString as p}from"@stryke/type-checks/is-set-string";import{toBool as m}from"@stryke/convert/to-bool";import{camelCase as h}from"@stryke/string-format/camel-case";import{isBoolean as g}from"@stryke/type-checks/is-boolean";import{isNull as _}from"@stryke/type-checks/is-null";import{isNumber as v}from"@stryke/type-checks/is-number";import{isUndefined as y}from"@stryke/type-checks/is-undefined";function b(e,t){return y(e)?`undefined`:_(e)?`null`:t===`boolean`||g(e)?String(m(e)):t===`number`||v(e)?Number.parseFloat(String(e)).toLocaleString(void 0,{maximumFractionDigits:20}):t===`integer`?Number.parseInt(String(e)).toLocaleString():t===`string`||t===`object`||t===`array`?JSON.stringify(e):String(e)}function x(e){if(!e)return`unknown`;if(typeof e==`boolean`)return e?`unknown`:`never`;if(t(e)&&p(e.name))return e.name;let s=e;if(p(s.$ref))return/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref)?.[1]??s.$ref;if(a(e)&&!y(e.const))return JSON.stringify(p(e.const)?e.const.replaceAll(/^['"`]|['"`]$/g,``):e.const);let c=o(e);if(c)return c===`integer`||c===`number`?`number`:c;if(s.type===`array`&&Array.isArray(s.enum))return s.enum.map(e=>JSON.stringify(e)).join(` | `);if(s.const!==void 0)return JSON.stringify(s.const);if(s.type===`array`||s.items)return`${x(Array.isArray(s.items)?s.items[0]:s.items)}[]`;if(s.type===`object`||s.properties||s.additionalProperties){if(n(s.additionalProperties))return`{ [key: string]: ${x(s.additionalProperties)} }`;if(t(s)){let e=s.required??[];return`{ ${r(s).map(t=>{let n=!e.includes(t.name)||i(t)?`${e.includes(t.name)?``:`?`}${i(t)?` | null`:``}`:``;return`${t.name}${n}: ${x(t)}`}).join(`;
|
|
2
|
+
`)} }`}}return s.oneOf||s.anyOf?(s.oneOf??s.anyOf??[]).map(e=>x(e)).join(` | `):s.allOf?`object`:`unknown`}function S(e){return _(e)?`null`:g(e)?`boolean`:l(e)?`integer`:v(e)?`number`:f(e)?`string`:u(e)?`object`:Array.isArray(e)?`array`:void 0}function C(e){return/^#\/(?:definitions|\$defs)\/(.+)$/.exec(e)?.[1]}function w(e){let t=e.replace(/[^\w$]/gu,`_`);return`parse_${/^\d/u.test(t)?`_${t}`:t}`}function T(e){let t=e.type;return Array.isArray(t)?[...t]:t?[t]:[]}function E(e,t){return`${e} + ${JSON.stringify(t)}`}function D(a,l={}){let u=a,f=typeof u==`boolean`?{}:{...u.definitions,...u.$defs},m={};function g(e){let t=m[e]??0;return m[e]=t+1,`${e}${t>0?`${t}`:``}`}function _(e,t,n,r,a=`errors`){if(typeof e==`boolean`)return e?[`${r} = ${t};`]:[`${a}.push({ path: ${n}, failure: "No value is allowed at this location" });`,`${r} = ${t};`];if(p(e.$ref)){let i=C(e.$ref);return i&&i in f?[`${r} = ${w(i)}(${t}, ${n}, ${a});`]:[`${r} = ${t};`]}let o=g(e.name?`${h(e.name)}Value`:`value`),s=g(e.name?`${h(e.name)}Path`:`path`),c=[`const ${o} = ${t};`,`const ${s} = ${n};`];return!l.ignoreDefaults&&e.default!==void 0?(c.push(`if (${o} === undefined${e.type===`string`?` || ${o} === ""`:e.type===`number`||e.type===`integer`?` || Number.isNaN(${o})`:``}) {`,` ${r} = ${JSON.stringify(e.default)};`,`} else {`),i(e)?(c.push(` if (${o} === null) {`,` ${r} = null;`,` } else {`),c.push(...v(e,o,s,r,a)),c.push(` }`)):c.push(...v(e,o,s,r,a)),c.push(`}`),c):(c.push(`if (${o} === undefined) {`,` ${a}.push({ path: ${s}, failure: "A value is required" });`,` ${r} = ${o};`,`} else {`),i(e)?(c.push(` if (${o} === null) {`,` ${r} = null;`,` } else {`),c.push(...v(e,o,s,r,a)),c.push(` }`)):c.push(...v(e,o,s,r,a)),c.push(`}`),c)}function v(e,t,n,r,i){let a=[];if(e.const!==void 0){let o=JSON.stringify(e.const);return a.push(`if (${e.type===`string`?t:`JSON.stringify(${t})`} !== ${o}) { ${i}.push({ path: ${n}, failure: "Expected the constant value " + ${o} }); }`,`${r} = ${o};`),a}if(Array.isArray(e.enum)){let o=JSON.stringify(e.enum);return a.push(`if (!${o}.some(allowed => JSON.stringify(allowed) === JSON.stringify(${t}))) { ${i}.push({ path: ${n}, failure: \`Expected one of: ${c(e.enum.map(e=>JSON.stringify(e)),{conjunction:`or`})}, instead received: \${JSON.stringify(${t})}\` }); }`,`${r} = ${t};`),a}if(Array.isArray(e.oneOf)||Array.isArray(e.anyOf)){let o=e.oneOf??e.anyOf??[],s=g(e.name?`${h(e.name)}Matched`:`matched`);a.push(`let ${s} = false;`);for(let i of o){let o=g(e.name?`${h(e.name)}BranchErrors`:`branchErrors`),c=g(e.name?`${h(e.name)}BranchResult`:`branchResult`);a.push(`if (!${s}) {`),a.push(` const ${o}: { path: string; failure: string }[] = [];`,` let ${c};`),a.push(..._(i,t,n,c,o)),a.push(` if (${o}.length === 0) {`,` ${r} = ${c};`,` ${s} = true;`,` }`,`}`)}return a.push(`if (!${s}) {`,` ${i}.push({ path: ${n}, failure: \`The provided value \${JSON.stringify(${t})} does not match the allowed schemas\` });`,` ${r} = ${t};`,`}`),a}if(Array.isArray(e.allOf)){let{allOf:o,...c}=e,l=s(c,...o);return a.push(..._(l,t,n,r,i)),a}let l=T(e);switch(o(e)??l.find(e=>e!==`null`)??(e.properties?`object`:e.items?`array`:void 0)){case`object`:a.push(...y(e,t,n,r,i));break;case`array`:a.push(...b(e,t,n,r,i));break;case`string`:a.push(`if (typeof ${t} === "string") {`,` ${r} = ${t};`,`} else if (typeof ${t} === "number" || typeof ${t} === "boolean") {`,` ${r} = String(${t});`,`} else {`,` ${i}.push({ path: ${n}, failure: "Expected a string value" });`,` ${r} = ${t};`,`}`);break;case`integer`:a.push(`if (typeof ${t} === "number" && Number.isInteger(${t})) {`,` ${r} = ${t};`,`} else if (typeof ${t} === "string" && ${t}.trim() !== "" && Number.isInteger(Number(${t}))) {`,` ${r} = Number(${t});`,`} else if (typeof ${t} === "boolean") {`,` ${r} = ${t} ? 1 : 0;`,`} else {`,` ${i}.push({ path: ${n}, failure: "Expected an integer value" });`,` ${r} = ${t};`,`}`);break;case`number`:a.push(`if (typeof ${t} === "number") {`,` ${r} = ${t};`,`} else if (typeof ${t} === "string" && ${t}.trim() !== "" && !Number.isNaN(Number(${t}))) {`,` ${r} = Number(${t});`,`} else if (typeof ${t} === "boolean") {`,` ${r} = ${t} ? 1 : 0;`,`} else {`,` ${i}.push({ path: ${n}, failure: "Expected a number value" });`,` ${r} = ${t};`,`}`);break;case`boolean`:a.push(`if (typeof ${t} === "boolean") {`,` ${r} = ${t};`,`} else if ((typeof ${t} === "string" && (${t}.toLowerCase() === "true" || ${t}.toLowerCase() === "t" || ${t}.toLowerCase() === "yes" || ${t}.toLowerCase() === "y" || (!Number.isNaN(Number.parseInt(${t})) && Number.parseInt(${t}) > 0))) || (typeof ${t} === "number" && ${t} > 0)) {`,` ${r} = true;`,`} else if ((typeof ${t} === "string" && (${t}.toLowerCase() === "false" || ${t}.toLowerCase() === "f" || ${t}.toLowerCase() === "no" || ${t}.toLowerCase() === "n" || (!Number.isNaN(Number.parseInt(${t})) && Number.parseInt(${t}) <= 0))) || (typeof ${t} === "number" && ${t} <= 0)) {`,` ${r} = false;`,`} else {`,` ${i}.push({ path: ${n}, failure: "Expected a boolean value" });`,` ${r} = ${t};`,`}`);break;case`null`:a.push(`if (${t} === null) {`,` ${r} = null;`,`} else {`,` ${i}.push({ path: ${n}, failure: "Expected a null value" });`,` ${r} = ${t};`,`}`);break;case void 0:default:a.push(`${r} = ${t};`);break}return a}function y(i,a,o,s,c){let l=x(i),u=[`if (typeof ${a} !== "object" || ${a} === null || Array.isArray(${a})) {`,` ${c}.push({ path: ${o}, failure: "Expected an object value" });`,` ${s} = ${a};`,`} else {`],f=g(l||i.name?`${h(l||i.name)}Schema`:`schema`);if(u.push(`const ${f} = {} as Record<string, any>`),t(i)){let t=new Set;for(let n of r(i)){t.add(n.name);let r;d(n.alias)?(r=`(${n.alias.map(e=>`${a}[${JSON.stringify(e)}]`).join(` ${e(n)?`||`:`??`} `)} ${e(n)?`||`:`??`} ${a}[${JSON.stringify(n.name)}])`,n.alias.forEach(e=>t.add(e))):r=`${a}[${JSON.stringify(n.name)}]`;let i=E(o,`.${n.name}`),s=g(n.name?`${h(n.name)}Property`:`property`),l=n.default===void 0?n.required?`${c}.push({ path: ${i}, failure: "Required property is missing" });`:``:`${f}[${JSON.stringify(n.name)}] = ${JSON.stringify(n.default)};`;u.push(` if (${r} !== undefined) {`,` let ${s};`),u.push(..._(n,r,i,s,c)),u.push(`${f}[${JSON.stringify(n.name)}] = ${s};`),l?u.push(`} else { ${l} }`):u.push(`}`)}let s=i.additionalProperties;if(n(s)){let e=g(l||i.name?`${h(l||i.name)}AdditionalProperties`:`additionalProperties`);u.push(` for (const key of Object.keys(${a})) {`,` if (${JSON.stringify([...t])}.includes(key)) { continue; }`,` let ${e};`),u.push(..._(s,`${a}[key]`,`${o} + "." + key`,e,c)),u.push(`${f}[key] = ${e};`,`}`)}else s!==!1&&u.push(` for (const key of Object.keys(${a})) {`,` if (${JSON.stringify([...t])}.includes(key)) { continue; }`,` ${f}[key] = ${a}[key];`,`}`)}return u.push(`${s} = ${f};`,`}`),u}function b(e,t,n,r,i){let a=[`if (!Array.isArray(${t})) {`,` ${i}.push({ path: ${n}, failure: "Expected an array value" });`,` ${r} = ${t};`,`} else {`],o=g(e.name?`${h(e.name)}Array`:`array`);a.push(`const ${o}: unknown[] = [];`);let s=e.prefixItems??(Array.isArray(e.items)?e.items:void 0);if(s){let c=Array.isArray(e.items)?void 0:e.items;return a.push(` for (let index = 0; index < ${t}.length; index += 1) {`,` const item = ${t}[index];`,` let itemResult;`),s.forEach((e,t)=>{a.push(` ${t===0?`if`:`else if`} (index === ${t}) {`),a.push(..._(e,`item`,E(n,`[${t}]`),`itemResult`,i)),a.push(`}`)}),c?(a.push(`else {`),a.push(..._(c,`item`,`${n} + "[" + index + "]"`,`itemResult`,i)),a.push(`}`)):a.push(`else { itemResult = item; }`),a.push(` ${o}.push(itemResult);`,` }`,` ${r} = ${o};`,`}`),a}let c=e.items??!0;return a.push(` for (let index = 0; index < ${t}.length; index += 1) {`,` const item = ${t}[index];`,` let itemResult;`),a.push(..._(c,`item`,`${n} + "[" + index + "]"`,`itemResult`,i)),a.push(` ${o}.push(itemResult);`,` }`,` ${r} = ${o};`,`}`),a}return`/**
|
|
3
3
|
* Parser error constructor function.
|
|
4
4
|
*/
|
|
5
5
|
function ParserError(path, failure) {
|
|
@@ -47,7 +47,7 @@ export function parseSafe(inputValue) {
|
|
|
47
47
|
const errors = [];
|
|
48
48
|
|
|
49
49
|
let result;
|
|
50
|
-
${_(
|
|
50
|
+
${_(a,`inputValue`,`"$"`,`result`,`errors`).join(`
|
|
51
51
|
`)}
|
|
52
52
|
|
|
53
53
|
if (errors.length > 0) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={STRING:`string`,NUMBER:`number`,INTEGER:`integer`,BOOLEAN:`boolean`,NULL:`null`,OBJECT:`object`,ARRAY:`array`},t=[e.STRING,e.NUMBER,e.INTEGER,e.BOOLEAN,e.NULL],n=[...t,e.ARRAY,e.OBJECT],r=[`$id`,`$schema`,`$vocabulary`,`$comment`,`$anchor`,`$defs`,`$dynamicRef`,`$dynamicAnchor`,`alias`,`deprecated`,`description`,`title`,`docs`,`examples`,`hidden`,`ignore`,`internal`,`name`,`readOnly`,`runtime`,`tags`,`version`,`writeOnly`],i=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`]),a=new Set([`if`,`then`,`else`,`not`,`contains`,`items`,`additionalProperties`,`unevaluatedProperties`,`propertyNames`,`unevaluatedItems`]),o=new Set([`allOf`,`anyOf`,`oneOf`]);Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-CMqjfN_6.cjs"),t=require("./constants-CjTQhR-l.cjs");let n=require("@stryke/path/find"),r=require("@stryke/resolve/constants"),i=require("@stryke/type-checks"),a=require("@stryke/type-checks/is-set-object"),ee=require("@stryke/helpers/get-unique"),o=require("defu");o=e.t(o,1);let s=require("@stryke/type-checks/is-set-string");function te(e){return!(0,i.isString)(e)&&e.file!==void 0}const c=e=>typeof e==`number`&&Number.isFinite(e),ne=e=>(0,i.isSetObject)(e)||(0,i.isBoolean)(e),l=e=>(0,i.isSetObject)(e)&&Object.values(e).every(e=>ne(e)),re=e=>(0,i.isSetObject)(e)&&Object.values(e).every(e=>(0,i.isBoolean)(e)),u=e=>Array.isArray(e)&&e.every(e=>(0,i.isSetString)(e)),ie=e=>(0,i.isSetObject)(e)&&Object.values(e).every(e=>u(e)),d=new Set(t.n),f=new Set(t.r);function ae(e){return(0,i.isSetString)(e)&&d.has(e)}function oe(e){return(0,i.isSetString)(e)&&f.has(e)}const se=new Set([`date`,`time`,`date-time`,`iso-time`,`iso-date-time`,`unix-time`]),p=e=>typeof e==`bigint`,ce=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`function`,`object`,`any`,`array`]),m=e=>(0,i.isSetString)(e)&&ce.has(e),h=e=>{if(!(0,i.isSetObject)(e))return!1;let t=e;return!(t.type!==void 0&&!((0,i.isSetString)(t.type)&&m(t.type)||Array.isArray(t.type)&&t.type.every(e=>m(e)))||t.tsType!==void 0&&!(0,i.isSetString)(t.tsType)||t.markdownType!==void 0&&!(0,i.isSetString)(t.markdownType)||t.items!==void 0&&!(h(t.items)||Array.isArray(t.items)&&t.items.every(e=>h(e))))},le=e=>{if(!h(e))return!1;let t=e;return t.name!==void 0&&!(0,i.isSetString)(t.name)?!1:t.optional===void 0||typeof t.optional==`boolean`},ue=e=>(0,i.isSetObject)(e)&&Object.values(e).every(e=>q(e)),g=(e,t)=>Array.isArray(e)&&e.every(e=>t(e)),de=(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),_=(e,t=!1)=>e===void 0||(0,i.isString)(e)&&(t||e.length>0),v=e=>e===void 0||(0,i.isBoolean)(e),y=e=>e===void 0||c(e),b=e=>e===void 0||p(e),x=e=>e===void 0||K(e),S=e=>e===void 0||g(e,K),fe=e=>e===void 0||Array.isArray(e)&&e.every(e=>(0,i.isSetString)(e)&&d.has(e)),pe=e=>e===void 0||Array.isArray(e)&&e.every(e=>(0,i.isSetString)(e)&&f.has(e)),C=e=>!(!_(e.$id)||!_(e.$schema)||e.$vocabulary!==void 0&&!re(e.$vocabulary)||!_(e.$comment,!0)||!_(e.$anchor)||e.$defs!==void 0&&!l(e.$defs)||!_(e.$dynamicRef)||!_(e.$dynamicAnchor)||!_(e.name)||!_(e.title,!0)||!_(e.description,!0)||!_(e.docs,!0)||e.examples!==void 0&&!Array.isArray(e.examples)||e.alias!==void 0&&!u(e.alias)||e.tags!==void 0&&!u(e.tags)||!v(e.deprecated)||!v(e.hidden)||!v(e.ignore)||!v(e.internal)||!v(e.runtime)||!v(e.readOnly)||!v(e.writeOnly)||!S(e.allOf)||!S(e.anyOf)||!S(e.oneOf)||!x(e.not)||!x(e.if)||!x(e.then)||!x(e.else));function me(e){return(0,i.isSetObject)(e)?C(e):!1}function w(e){if(!(0,i.isSetObject)(e))return!1;let n=e;return C(n)&&_(n.$ref)&&(!n.type||Array.isArray(n.type)&&n.type.every(e=>t.n.includes(e)))}function T(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!C(t)||t.type!==`array`?!1:S(t.prefixItems)&&x(t.items)&&x(t.contains)&&y(t.minItems)&&y(t.maxItems)&&v(t.uniqueItems)&&y(t.minContains)&&y(t.maxContains)&&(t.unevaluatedItems===void 0||(0,i.isBoolean)(t.unevaluatedItems)||K(t.unevaluatedItems))}function E(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!C(t)||t.type!==`integer`||t.format!==`int64`?!1:b(t.minimum)&&b(t.exclusiveMinimum)&&b(t.maximum)&&b(t.exclusiveMaximum)&&b(t.multipleOf)&&b(t.default)&&(t.enum===void 0||g(t.enum,p))}function D(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`boolean`&&v(t.default)}function O(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)?t.anyOf===void 0?t.type!==`integer`&&t.type!==`string`||!(0,i.isSetString)(t.format)||!se.has(t.format)?!1:y(t.minimum)&&y(t.maximum)&&(t.default===void 0||(0,i.isSetString)(t.default)||c(t.default)):g(t.anyOf,O):!1}function k(e){if(!(0,i.isSetObject)(e))return!1;let t=e;if(!C(t)||!(0,i.isSetString)(t.type)||!d.has(t.type)||!Array.isArray(t.enum))return!1;let n=t.type,r=t.enum,a=t.default;return n===`string`?r.every(e=>(0,i.isSetString)(e))&&(a===void 0||(0,i.isSetString)(a)):n===`number`||n===`integer`?r.every(e=>c(e))&&(a===void 0||c(a)):n===`boolean`?r.every(e=>(0,i.isBoolean)(e))&&(a===void 0||(0,i.isBoolean)(a)):n===`null`&&r.every(e=>e===null)&&a==null}function A(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!C(t)||!g(t.allOf,K)?!1:t.unevaluatedProperties===void 0||(0,i.isBoolean)(t.unevaluatedProperties)||K(t.unevaluatedProperties)}function j(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!C(t)||!(`const`in t)?!1:t.type===void 0||(0,i.isSetString)(t.type)&&oe(t.type)||pe(t.type)}function M(e){if(!(0,i.isSetObject)(e))return!1;let t=e;if(!C(t)||t.type!==`array`||t.maxItems!==125||!(0,i.isSetObject)(t.items))return!1;let n=t.items;return n.type===`array`&&de(n.prefixItems,K,K)&&(n.items===void 0||n.items===!1)&&n.minItems===2&&n.maxItems===2}function N(e){if(!(0,i.isSetObject)(e))return!1;let t=e,n=t.type===`string`||t.type===`number`||Array.isArray(t.type)&&t.type.length===2&&t.type[0]===`string`&&t.type[1]===`number`;return C(t)&&n&&Array.isArray(t.enum)&&t.enum.every(e=>(0,i.isSetString)(e)||c(e))}function P(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&w(t.not)}function F(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`null`&&(t.const===void 0||t.const===null)&&(t.enum===void 0||Array.isArray(t.enum)&&t.enum.every(e=>e===null))&&(t.default===void 0||t.default===null)}function I(e){if(!(0,i.isSetObject)(e))return!1;let t=e;if(!C(t))return!1;let n=t.anyOf!==void 0&&Array.isArray(t.anyOf)&&t.anyOf.length===2&&K(t.anyOf[0])&&F(t.anyOf[1]),r=Array.isArray(t.type)&&t.type.length===2&&(t.type[0]===`null`&&(0,i.isSetString)(t.type[1])&&t.type[1]!==`null`&&f.has(t.type[1])||t.type[1]===`null`&&(0,i.isSetString)(t.type[0])&&t.type[0]!==`null`&&f.has(t.type[0]));return n||r}function L(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!C(t)||t.type!==`number`&&t.type!==`integer`?!1:_(t.format)&&y(t.minimum)&&y(t.exclusiveMinimum)&&y(t.maximum)&&y(t.exclusiveMaximum)&&y(t.multipleOf)&&y(t.default)&&(t.enum===void 0||g(t.enum,c))}function R(e){return L(e)&&e.type===`integer`}function z(e){return L(e)&&e.type===`number`}function B(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`object`&&(t.properties===void 0||l(t.properties))&&(t.patternProperties===void 0||l(t.patternProperties))&&(t.additionalProperties===void 0||(0,i.isBoolean)(t.additionalProperties)||K(t.additionalProperties))&&(t.required===void 0||u(t.required))&&(t.unevaluatedProperties===void 0||(0,i.isBoolean)(t.unevaluatedProperties)||K(t.unevaluatedProperties))&&(t.dependencies===void 0||(0,i.isSetObject)(t.dependencies)&&Object.values(t.dependencies).every(e=>u(e)||K(e)))&&(t.dependentRequired===void 0||ie(t.dependentRequired))&&(t.dependentSchemas===void 0||l(t.dependentSchemas))&&y(t.minProperties)&&y(t.maxProperties)&&(t.primaryKey===void 0||u(t.primaryKey))&&_(t.databaseSchema)}function V(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`string`&&y(t.minLength)&&y(t.maxLength)&&_(t.pattern)&&_(t.format)&&_(t.default)&&(t.enum===void 0||g(t.enum,i.isSetString))&&_(t.contentMediaType)&&_(t.contentEncoding)&&_(t.contentSchema)}function H(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`array`&&t.uniqueItems===!0&&S(t.prefixItems)&&x(t.items)&&x(t.contains)&&y(t.minItems)&&y(t.maxItems)&&y(t.minContains)&&y(t.maxContains)&&(t.unevaluatedItems===void 0||(0,i.isBoolean)(t.unevaluatedItems)||K(t.unevaluatedItems))}function U(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`object`&&(t.patternProperties===void 0||l(t.patternProperties))&&(t.additionalProperties===void 0||(0,i.isBoolean)(t.additionalProperties)||K(t.additionalProperties))&&x(t.propertyNames)}function W(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&t.type===`array`&&g(t.prefixItems,K)&&y(t.minItems)&&y(t.maxItems)&&x(t.items)&&x(t.contains)&&v(t.uniqueItems)&&y(t.minContains)&&y(t.maxContains)&&(t.unevaluatedItems===void 0||(0,i.isBoolean)(t.unevaluatedItems)||K(t.unevaluatedItems))}function G(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&w(t.not)&&(t.default===void 0||t.default===void 0)}function he(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)?(0,i.isSetString)(t.type)&&d.has(t.type)?t.enum===void 0?!0:Array.isArray(t.enum)?t.type===`string`?t.enum.every(e=>(0,i.isSetString)(e))&&(t.default===void 0||(0,i.isSetString)(t.default)):t.type===`number`?t.enum.every(e=>c(e))&&(t.default===void 0||c(t.default)):t.type===`boolean`?t.enum.every(e=>(0,i.isBoolean)(e))&&(t.default===void 0||(0,i.isBoolean)(t.default)):t.type===`integer`?t.format===`int64`?t.enum.every(e=>p(e))&&(t.default===void 0||p(t.default)):!1:t.type===`null`&&t.enum.every(e=>e===null)&&(t.default===void 0||t.default===null):!1:fe(t.type)&&t.type!==void 0:!1}function ge(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&(he(t)||ve(t))}function _e(e){return w(e)}function ve(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&g(t.anyOf,K)}function ye(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return C(t)&&(0,i.isSetString)(t.$ref)}function be(e){if(!(0,i.isSetObject)(e))return!1;let t=e;if(!(0,i.isSetObject)(t[`~standard`]))return!1;let n=t[`~standard`];return n.version===1&&(0,i.isFunction)(n.validate)}function xe(e){if(!(0,i.isSetObject)(e)||!be(e))return!1;let t=e;return t.kind===`schema`&&(0,i.isSetString)(t.type)&&(0,i.isBoolean)(t.async)&&(0,i.isFunction)(t.reference)&&(0,i.isSetString)(t.expects)&&(0,i.isFunction)(t[`~run`])}function K(e){return V(e)||R(e)||z(e)||E(e)||D(e)||O(e)||k(e)||j(e)||N(e)||F(e)||T(e)||B(e)||U(e)||W(e)||ge(e)||G(e)||ye(e)||P(e)||M(e)||w(e)||I(e)||A(e)||_e(e)||H(e)}function Se(e){return F(e)}function q(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!(!h(t)||`id`in t&&!(0,i.isSetString)(t.id)||`resolve`in t&&!(0,i.isFunction)(t.resolve)||`properties`in t&&!ue(t.properties)||`required`in t&&!u(t.required)||`title`in t&&!(0,i.isSetString)(t.title)||`description`in t&&!(0,i.isSetString)(t.description)||`$schema`in t&&!(0,i.isSetString)(t.$schema)||`tags`in t&&!u(t.tags)||`args`in t&&(!Array.isArray(t.args)||!t.args.every(e=>le(e)))||`returns`in t&&!h(t.returns))}function Ce(e){return q(e)&&!K(e)}function we(e){if(!(0,i.isSetObject)(e))return!1;let t=e;return!(`$schema`in t&&!q(t.$schema)||`$resolve`in t&&!(0,i.isFunction)(t.$resolve))}function Te(e){if(!we(e)||K(e))return!1;let t=e;return!(`$schema`in t&&t.$schema!==void 0&&!Ce(t.$schema))}function J(e){return(0,i.isSetObject)(e)&&`schema`in e&&K(e.schema)&&`variant`in e&&(0,i.isSetString)(e.variant)&&`hash`in e&&(0,i.isSetString)(e.hash)}function Ee(e){return J(e)}function De(e){return J(e)&&`source`in e&&(0,i.isSetObject)(e.source)&&`schema`in e.source&&`variant`in e.source&&(0,i.isSetString)(e.source.variant)}function Oe(e){return J(e)&&B(e.schema)}function ke(e,n){if(!n||!(0,a.isSetObject)(e))return e;let r={...e},i=r;for(let e of t.t){let t=n[e];t!=null&&(i[e]=t)}return r}function Y(e){if(!(0,a.isSetObject)(e))return[];let t=e;return Array.isArray(t.type)?t.type.filter(e=>(0,s.isSetString)(e)):(0,s.isSetString)(t.type)&&t.type!==`object`&&t.type!==`array`?[t.type]:[]}function Ae(e){if((0,a.isSetObject)(e))return Y(e).find(e=>e!==`null`)}function X(e){let t=J(e)?e.schema:e;if(!K(t))throw TypeError(`The provided input is not a valid JSON Schema`);return t}function Z(e){let t=X(e);if(!B(t))throw TypeError(`The provided input is not a valid JSON Schema object`);return t}function je(e){let t=Z(e);return(0,i.isSetObject)(t.properties)?Object.entries(t.properties).reduce((e,[n,r])=>(r.name=n,r.required=!$(t,n),r.default=t.default?.[n]??r.default,e[n]=r,e),{}):{}}function Me(e){return Object.values(je(e))}function Ne(e,t){let n=Z(e);if(!(0,i.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:!$(n,t),default:n.default?.[t]??r?.default}}function Pe(e,t,n){let r=Z(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 Q(e,n){let r={...e};for(let[e,a]of Object.entries(n)){let n=r[e];if(e===`required`)r[e]=(0,ee.getUnique)([...Array.isArray(n)?n:[],...Array.isArray(a)?a:[]]);else if(t.o.has(e)&&(0,i.isSetObject)(n)&&(0,i.isSetObject)(a)){let t={...n};for(let[e,n]of Object.entries(a)){let r=t[e];t[e]=K(r)&&K(n)?Q(r,n):n}r[e]=t}else t.a.has(e)&&Array.isArray(n)&&Array.isArray(a)?r[e]=[...n,...a]:t.s.has(e)&&K(n)&&K(a)?r[e]=Q(n,a):r[e]=a}return r}function Fe(...e){let t=e.map(e=>X(e));return t.length===0?{}:t.reduce((e,t)=>{let n=e.type,r=t.type;return n&&r&&n!==r?t:Q(e,t)})}function Ie(e,n){return(0,o.default)(e,Object.fromEntries(t.t.filter(e=>n[e]!==void 0).map(e=>[e,n[e]])))}function Le(e){return(0,i.isSetObject)(e)?e.nullable===!0?!0:Y(e).includes(`null`):!1}function $(e,t){if(!e.properties?.[t])throw Error(`The property "${t}" does not exist in the parent schema.`);return!(e.required??[]).includes(t)}function Re(e){return r.VALID_OBJECT_SOURCE_EXTENSIONS.includes((0,n.findFileExtensionSafe)(e))}function ze(e,t){let n=[];function r(e){let i=t(e);if(i!==void 0&&n.push(i),B(e))for(let t of Object.values(e.properties??{}))r(t);for(let t of[`allOf`,`anyOf`,`oneOf`,`not`,`if`,`then`,`else`,`$ref`,`items`,`additionalProperties`,`unevaluatedProperties`,`propertyNames`,`unevaluatedItems`,`contains`]){let n=e[t];if(Array.isArray(n))for(let e of n)K(e)&&r(e);else K(n)&&r(n)}}return r(e),n}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return U}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,n as t,o as n,r,s as i,t as a}from"./constants-lk1mMbgx.mjs";import{findFileExtensionSafe as o}from"@stryke/path/find";import{VALID_OBJECT_SOURCE_EXTENSIONS as ee}from"@stryke/resolve/constants";import{isBoolean as s,isFunction as c,isSetObject as l,isSetString as u,isString as te}from"@stryke/type-checks";import{isSetObject as d}from"@stryke/type-checks/is-set-object";import{getUnique as ne}from"@stryke/helpers/get-unique";import re from"defu";import{isSetString as f}from"@stryke/type-checks/is-set-string";function ie(e){return!te(e)&&e.file!==void 0}const p=e=>typeof e==`number`&&Number.isFinite(e),ae=e=>l(e)||s(e),m=e=>l(e)&&Object.values(e).every(e=>ae(e)),oe=e=>l(e)&&Object.values(e).every(e=>s(e)),h=e=>Array.isArray(e)&&e.every(e=>u(e)),se=e=>l(e)&&Object.values(e).every(e=>h(e)),g=new Set(t),_=new Set(r);function ce(e){return u(e)&&g.has(e)}function v(e){return u(e)&&_.has(e)}const le=new Set([`date`,`time`,`date-time`,`iso-time`,`iso-date-time`,`unix-time`]),y=e=>typeof e==`bigint`,ue=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`function`,`object`,`any`,`array`]),b=e=>u(e)&&ue.has(e),x=e=>{if(!l(e))return!1;let t=e;return!(t.type!==void 0&&!(u(t.type)&&b(t.type)||Array.isArray(t.type)&&t.type.every(e=>b(e)))||t.tsType!==void 0&&!u(t.tsType)||t.markdownType!==void 0&&!u(t.markdownType)||t.items!==void 0&&!(x(t.items)||Array.isArray(t.items)&&t.items.every(e=>x(e))))},de=e=>{if(!x(e))return!1;let t=e;return t.name!==void 0&&!u(t.name)?!1:t.optional===void 0||typeof t.optional==`boolean`},fe=e=>l(e)&&Object.values(e).every(e=>q(e)),S=(e,t)=>Array.isArray(e)&&e.every(e=>t(e)),pe=(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),C=(e,t=!1)=>e===void 0||te(e)&&(t||e.length>0),w=e=>e===void 0||s(e),T=e=>e===void 0||p(e),E=e=>e===void 0||y(e),D=e=>e===void 0||K(e),O=e=>e===void 0||S(e,K),me=e=>e===void 0||Array.isArray(e)&&e.every(e=>u(e)&&g.has(e)),he=e=>e===void 0||Array.isArray(e)&&e.every(e=>u(e)&&_.has(e)),k=e=>!(!C(e.$id)||!C(e.$schema)||e.$vocabulary!==void 0&&!oe(e.$vocabulary)||!C(e.$comment,!0)||!C(e.$anchor)||e.$defs!==void 0&&!m(e.$defs)||!C(e.$dynamicRef)||!C(e.$dynamicAnchor)||!C(e.name)||!C(e.title,!0)||!C(e.description,!0)||!C(e.docs,!0)||e.examples!==void 0&&!Array.isArray(e.examples)||e.alias!==void 0&&!h(e.alias)||e.tags!==void 0&&!h(e.tags)||!w(e.deprecated)||!w(e.hidden)||!w(e.ignore)||!w(e.internal)||!w(e.runtime)||!w(e.readOnly)||!w(e.writeOnly)||!O(e.allOf)||!O(e.anyOf)||!O(e.oneOf)||!D(e.not)||!D(e.if)||!D(e.then)||!D(e.else));function ge(e){return l(e)?k(e):!1}function A(e){if(!l(e))return!1;let n=e;return k(n)&&C(n.$ref)&&(!n.type||Array.isArray(n.type)&&n.type.every(e=>t.includes(e)))}function j(e){if(!l(e))return!1;let t=e;return!k(t)||t.type!==`array`?!1:O(t.prefixItems)&&D(t.items)&&D(t.contains)&&T(t.minItems)&&T(t.maxItems)&&w(t.uniqueItems)&&T(t.minContains)&&T(t.maxContains)&&(t.unevaluatedItems===void 0||s(t.unevaluatedItems)||K(t.unevaluatedItems))}function M(e){if(!l(e))return!1;let t=e;return!k(t)||t.type!==`integer`||t.format!==`int64`?!1:E(t.minimum)&&E(t.exclusiveMinimum)&&E(t.maximum)&&E(t.exclusiveMaximum)&&E(t.multipleOf)&&E(t.default)&&(t.enum===void 0||S(t.enum,y))}function N(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`boolean`&&w(t.default)}function P(e){if(!l(e))return!1;let t=e;return k(t)?t.anyOf===void 0?t.type!==`integer`&&t.type!==`string`||!u(t.format)||!le.has(t.format)?!1:T(t.minimum)&&T(t.maximum)&&(t.default===void 0||u(t.default)||p(t.default)):S(t.anyOf,P):!1}function F(e){if(!l(e))return!1;let t=e;if(!k(t)||!u(t.type)||!g.has(t.type)||!Array.isArray(t.enum))return!1;let n=t.type,r=t.enum,i=t.default;return n===`string`?r.every(e=>u(e))&&(i===void 0||u(i)):n===`number`||n===`integer`?r.every(e=>p(e))&&(i===void 0||p(i)):n===`boolean`?r.every(e=>s(e))&&(i===void 0||s(i)):n===`null`&&r.every(e=>e===null)&&i==null}function I(e){if(!l(e))return!1;let t=e;return!k(t)||!S(t.allOf,K)?!1:t.unevaluatedProperties===void 0||s(t.unevaluatedProperties)||K(t.unevaluatedProperties)}function L(e){if(!l(e))return!1;let t=e;return!k(t)||!(`const`in t)?!1:t.type===void 0||u(t.type)&&v(t.type)||he(t.type)}function R(e){if(!l(e))return!1;let t=e;if(!k(t)||t.type!==`array`||t.maxItems!==125||!l(t.items))return!1;let n=t.items;return n.type===`array`&&pe(n.prefixItems,K,K)&&(n.items===void 0||n.items===!1)&&n.minItems===2&&n.maxItems===2}function z(e){if(!l(e))return!1;let t=e,n=t.type===`string`||t.type===`number`||Array.isArray(t.type)&&t.type.length===2&&t.type[0]===`string`&&t.type[1]===`number`;return k(t)&&n&&Array.isArray(t.enum)&&t.enum.every(e=>u(e)||p(e))}function B(e){if(!l(e))return!1;let t=e;return k(t)&&A(t.not)}function V(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`null`&&(t.const===void 0||t.const===null)&&(t.enum===void 0||Array.isArray(t.enum)&&t.enum.every(e=>e===null))&&(t.default===void 0||t.default===null)}function H(e){if(!l(e))return!1;let t=e;if(!k(t))return!1;let n=t.anyOf!==void 0&&Array.isArray(t.anyOf)&&t.anyOf.length===2&&K(t.anyOf[0])&&V(t.anyOf[1]),r=Array.isArray(t.type)&&t.type.length===2&&(t.type[0]===`null`&&u(t.type[1])&&t.type[1]!==`null`&&_.has(t.type[1])||t.type[1]===`null`&&u(t.type[0])&&t.type[0]!==`null`&&_.has(t.type[0]));return n||r}function U(e){if(!l(e))return!1;let t=e;return!k(t)||t.type!==`number`&&t.type!==`integer`?!1:C(t.format)&&T(t.minimum)&&T(t.exclusiveMinimum)&&T(t.maximum)&&T(t.exclusiveMaximum)&&T(t.multipleOf)&&T(t.default)&&(t.enum===void 0||S(t.enum,p))}function W(e){return U(e)&&e.type===`integer`}function _e(e){return U(e)&&e.type===`number`}function G(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`object`&&(t.properties===void 0||m(t.properties))&&(t.patternProperties===void 0||m(t.patternProperties))&&(t.additionalProperties===void 0||s(t.additionalProperties)||K(t.additionalProperties))&&(t.required===void 0||h(t.required))&&(t.unevaluatedProperties===void 0||s(t.unevaluatedProperties)||K(t.unevaluatedProperties))&&(t.dependencies===void 0||l(t.dependencies)&&Object.values(t.dependencies).every(e=>h(e)||K(e)))&&(t.dependentRequired===void 0||se(t.dependentRequired))&&(t.dependentSchemas===void 0||m(t.dependentSchemas))&&T(t.minProperties)&&T(t.maxProperties)&&(t.primaryKey===void 0||h(t.primaryKey))&&C(t.databaseSchema)}function ve(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`string`&&T(t.minLength)&&T(t.maxLength)&&C(t.pattern)&&C(t.format)&&C(t.default)&&(t.enum===void 0||S(t.enum,u))&&C(t.contentMediaType)&&C(t.contentEncoding)&&C(t.contentSchema)}function ye(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`array`&&t.uniqueItems===!0&&O(t.prefixItems)&&D(t.items)&&D(t.contains)&&T(t.minItems)&&T(t.maxItems)&&T(t.minContains)&&T(t.maxContains)&&(t.unevaluatedItems===void 0||s(t.unevaluatedItems)||K(t.unevaluatedItems))}function be(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`object`&&(t.patternProperties===void 0||m(t.patternProperties))&&(t.additionalProperties===void 0||s(t.additionalProperties)||K(t.additionalProperties))&&D(t.propertyNames)}function xe(e){if(!l(e))return!1;let t=e;return k(t)&&t.type===`array`&&S(t.prefixItems,K)&&T(t.minItems)&&T(t.maxItems)&&D(t.items)&&D(t.contains)&&w(t.uniqueItems)&&T(t.minContains)&&T(t.maxContains)&&(t.unevaluatedItems===void 0||s(t.unevaluatedItems)||K(t.unevaluatedItems))}function Se(e){if(!l(e))return!1;let t=e;return k(t)&&A(t.not)&&(t.default===void 0||t.default===void 0)}function Ce(e){if(!l(e))return!1;let t=e;return k(t)?u(t.type)&&g.has(t.type)?t.enum===void 0?!0:Array.isArray(t.enum)?t.type===`string`?t.enum.every(e=>u(e))&&(t.default===void 0||u(t.default)):t.type===`number`?t.enum.every(e=>p(e))&&(t.default===void 0||p(t.default)):t.type===`boolean`?t.enum.every(e=>s(e))&&(t.default===void 0||s(t.default)):t.type===`integer`?t.format===`int64`?t.enum.every(e=>y(e))&&(t.default===void 0||y(t.default)):!1:t.type===`null`&&t.enum.every(e=>e===null)&&(t.default===void 0||t.default===null):!1:me(t.type)&&t.type!==void 0:!1}function we(e){if(!l(e))return!1;let t=e;return k(t)&&(Ce(t)||Ee(t))}function Te(e){return A(e)}function Ee(e){if(!l(e))return!1;let t=e;return k(t)&&S(t.anyOf,K)}function De(e){if(!l(e))return!1;let t=e;return k(t)&&u(t.$ref)}function Oe(e){if(!l(e))return!1;let t=e;if(!l(t[`~standard`]))return!1;let n=t[`~standard`];return n.version===1&&c(n.validate)}function ke(e){if(!l(e)||!Oe(e))return!1;let t=e;return t.kind===`schema`&&u(t.type)&&s(t.async)&&c(t.reference)&&u(t.expects)&&c(t[`~run`])}function K(e){return ve(e)||W(e)||_e(e)||M(e)||N(e)||P(e)||F(e)||L(e)||z(e)||V(e)||j(e)||G(e)||be(e)||xe(e)||we(e)||Se(e)||De(e)||B(e)||R(e)||A(e)||H(e)||I(e)||Te(e)||ye(e)}function Ae(e){return V(e)}function q(e){if(!l(e))return!1;let t=e;return!(!x(t)||`id`in t&&!u(t.id)||`resolve`in t&&!c(t.resolve)||`properties`in t&&!fe(t.properties)||`required`in t&&!h(t.required)||`title`in t&&!u(t.title)||`description`in t&&!u(t.description)||`$schema`in t&&!u(t.$schema)||`tags`in t&&!h(t.tags)||`args`in t&&(!Array.isArray(t.args)||!t.args.every(e=>de(e)))||`returns`in t&&!x(t.returns))}function je(e){return q(e)&&!K(e)}function Me(e){if(!l(e))return!1;let t=e;return!(`$schema`in t&&!q(t.$schema)||`$resolve`in t&&!c(t.$resolve))}function Ne(e){if(!Me(e)||K(e))return!1;let t=e;return!(`$schema`in t&&t.$schema!==void 0&&!je(t.$schema))}function J(e){return l(e)&&`schema`in e&&K(e.schema)&&`variant`in e&&u(e.variant)&&`hash`in e&&u(e.hash)}function Pe(e){return J(e)}function Fe(e){return J(e)&&`source`in e&&l(e.source)&&`schema`in e.source&&`variant`in e.source&&u(e.source.variant)}function Ie(e){return J(e)&&G(e.schema)}function Le(e,t){if(!t||!d(e))return e;let n={...e},r=n;for(let e of a){let n=t[e];n!=null&&(r[e]=n)}return n}function Y(e){if(!d(e))return[];let t=e;return Array.isArray(t.type)?t.type.filter(e=>f(e)):f(t.type)&&t.type!==`object`&&t.type!==`array`?[t.type]:[]}function Re(e){if(d(e))return Y(e).find(e=>e!==`null`)}function X(e){let t=J(e)?e.schema:e;if(!K(t))throw TypeError(`The provided input is not a valid JSON Schema`);return t}function Z(e){let t=X(e);if(!G(t))throw TypeError(`The provided input is not a valid JSON Schema object`);return t}function ze(e){let t=Z(e);return l(t.properties)?Object.entries(t.properties).reduce((e,[n,r])=>(r.name=n,r.required=!$(t,n),r.default=t.default?.[n]??r.default,e[n]=r,e),{}):{}}function Be(e){return Object.values(ze(e))}function Ve(e,t){let n=Z(e);if(!l(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:!$(n,t),default:n.default?.[t]??r?.default}}function He(e,t,n){let r=Z(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 Q(t,r){let a={...t};for(let[t,o]of Object.entries(r)){let r=a[t];if(t===`required`)a[t]=ne([...Array.isArray(r)?r:[],...Array.isArray(o)?o:[]]);else if(n.has(t)&&l(r)&&l(o)){let e={...r};for(let[t,n]of Object.entries(o)){let r=e[t];e[t]=K(r)&&K(n)?Q(r,n):n}a[t]=e}else e.has(t)&&Array.isArray(r)&&Array.isArray(o)?a[t]=[...r,...o]:i.has(t)&&K(r)&&K(o)?a[t]=Q(r,o):a[t]=o}return a}function Ue(...e){let t=e.map(e=>X(e));return t.length===0?{}:t.reduce((e,t)=>{let n=e.type,r=t.type;return n&&r&&n!==r?t:Q(e,t)})}function We(e,t){return re(e,Object.fromEntries(a.filter(e=>t[e]!==void 0).map(e=>[e,t[e]])))}function Ge(e){return l(e)?e.nullable===!0?!0:Y(e).includes(`null`):!1}function $(e,t){if(!e.properties?.[t])throw Error(`The property "${t}" does not exist in the parent schema.`);return!(e.required??[]).includes(t)}function Ke(e){return ee.includes(o(e))}function qe(e,t){let n=[];function r(e){let i=t(e);if(i!==void 0&&n.push(i),G(e))for(let t of Object.values(e.properties??{}))r(t);for(let t of[`allOf`,`anyOf`,`oneOf`,`not`,`if`,`then`,`else`,`$ref`,`items`,`additionalProperties`,`unevaluatedProperties`,`propertyNames`,`unevaluatedItems`,`contains`]){let n=e[t];if(Array.isArray(n))for(let e of n)K(e)&&r(e);else K(n)&&r(n)}}return r(e),n}export{Oe as $,R as A,De as B,N as C,W as D,F as E,U as F,Se as G,ve as H,G as I,Ae as J,we as K,ce as L,B as M,V as N,ge as O,H as P,Fe as Q,Ce as R,M as S,_e as T,xe as U,ye as V,v as W,Ie as X,J as Y,Pe as Z,K as _,Be as a,Ee as b,Ge as c,We as d,Me as et,qe as f,ie as g,Y as h,ze as i,ke as it,z as j,L as k,Ke as l,Re as m,X as n,q as nt,Ve as o,Le as p,Te as q,Z as r,je as rt,$ as s,He as t,Ne as tt,Ue as u,I as v,P as w,j as x,A as y,be as z};
|
|
2
|
+
//# sourceMappingURL=helpers-kU9GDXDZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-kU9GDXDZ.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Mode, OpenMode, PathLike, ReadStream, ReadStreamOptions, ReadVResult, StatOptions, Stats, TimeLike, WriteStream, WriteStreamOptions, WriteVResult } from "node:fs";
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
3
|
+
import { Storage } from "unstorage";
|
|
4
|
+
import { FileSystemInterface, PromisesFileSystemInterface } from "@stryke/types/fs";
|
|
5
|
+
|
|
6
|
+
//#region src/storage/helpers.d.ts
|
|
7
|
+
declare function normalizeKey(path: string | Buffer | URL): string;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/storage/promises.d.ts
|
|
10
|
+
interface StorageFileSystemCore {
|
|
11
|
+
promises: PromisesFileSystemInterface;
|
|
12
|
+
createReadStream: (path: PathLike, options?: ReadStreamOptions) => ReadStream;
|
|
13
|
+
createWriteStream: (path: PathLike, options?: WriteStreamOptions) => WriteStream;
|
|
14
|
+
openFd: (path: PathLike, flags?: OpenMode, mode?: Mode) => Promise<number>;
|
|
15
|
+
closeFd: (fd: number) => Promise<void>;
|
|
16
|
+
fstatFd: (fd: number, options?: StatOptions & {
|
|
17
|
+
bigint?: false | undefined;
|
|
18
|
+
}) => ReturnType<PromisesFileSystemInterface["stat"]>;
|
|
19
|
+
readFd: (fd: number, buffer: Buffer, offset: number, length: number, position: number | null) => Promise<{
|
|
20
|
+
bytesRead: number;
|
|
21
|
+
buffer: Buffer;
|
|
22
|
+
}>;
|
|
23
|
+
writeFd: (fd: number, buffer: Buffer, offset: number, length: number, position: number | null) => Promise<{
|
|
24
|
+
bytesWritten: number;
|
|
25
|
+
buffer: Buffer;
|
|
26
|
+
}>;
|
|
27
|
+
ftruncateFd: (fd: number, len?: number) => Promise<void>;
|
|
28
|
+
futimesFd: (fd: number, atime: TimeLike, mtime: TimeLike) => Promise<void>;
|
|
29
|
+
readvFd: (fd: number, buffers: NodeJS.ArrayBufferView[], position?: number) => Promise<ReadVResult>;
|
|
30
|
+
writevFd: (fd: number, buffers: NodeJS.ArrayBufferView[], position?: number) => Promise<WriteVResult>;
|
|
31
|
+
}
|
|
32
|
+
declare function createStoragePromises(storage: Storage): StorageFileSystemCore;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/storage/index.d.ts
|
|
35
|
+
declare function mapStorageToFileSystem(storage: Storage): FileSystemInterface;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { createStoragePromises as n, normalizeKey as r, mapStorageToFileSystem as t };
|
|
38
|
+
//# sourceMappingURL=index-1pJbUu8F.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-1pJbUu8F.d.mts","names":[],"sources":["../src/storage/helpers.ts","../src/storage/promises.ts","../src/storage/index.ts"],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Storage } from "unstorage";
|
|
2
|
+
import { FileSystemInterface, PromisesFileSystemInterface } from "@stryke/types/fs";
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
|
+
import { Mode, OpenMode, PathLike, ReadStream, ReadStreamOptions, ReadVResult, StatOptions, TimeLike, WriteStream, WriteStreamOptions, WriteVResult } from "node:fs";
|
|
5
|
+
|
|
6
|
+
//#region src/storage/helpers.d.ts
|
|
7
|
+
declare function normalizeKey(path: string | Buffer | URL): string;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/storage/promises.d.ts
|
|
10
|
+
interface StorageFileSystemCore {
|
|
11
|
+
promises: PromisesFileSystemInterface;
|
|
12
|
+
createReadStream: (path: PathLike, options?: ReadStreamOptions) => ReadStream;
|
|
13
|
+
createWriteStream: (path: PathLike, options?: WriteStreamOptions) => WriteStream;
|
|
14
|
+
openFd: (path: PathLike, flags?: OpenMode, mode?: Mode) => Promise<number>;
|
|
15
|
+
closeFd: (fd: number) => Promise<void>;
|
|
16
|
+
fstatFd: (fd: number, options?: StatOptions & {
|
|
17
|
+
bigint?: false | undefined;
|
|
18
|
+
}) => ReturnType<PromisesFileSystemInterface["stat"]>;
|
|
19
|
+
readFd: (fd: number, buffer: Buffer, offset: number, length: number, position: number | null) => Promise<{
|
|
20
|
+
bytesRead: number;
|
|
21
|
+
buffer: Buffer;
|
|
22
|
+
}>;
|
|
23
|
+
writeFd: (fd: number, buffer: Buffer, offset: number, length: number, position: number | null) => Promise<{
|
|
24
|
+
bytesWritten: number;
|
|
25
|
+
buffer: Buffer;
|
|
26
|
+
}>;
|
|
27
|
+
ftruncateFd: (fd: number, len?: number) => Promise<void>;
|
|
28
|
+
futimesFd: (fd: number, atime: TimeLike, mtime: TimeLike) => Promise<void>;
|
|
29
|
+
readvFd: (fd: number, buffers: NodeJS.ArrayBufferView[], position?: number) => Promise<ReadVResult>;
|
|
30
|
+
writevFd: (fd: number, buffers: NodeJS.ArrayBufferView[], position?: number) => Promise<WriteVResult>;
|
|
31
|
+
}
|
|
32
|
+
declare function createStoragePromises(storage: Storage): StorageFileSystemCore;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/storage/index.d.ts
|
|
35
|
+
declare function mapStorageToFileSystem(storage: Storage): FileSystemInterface;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { createStoragePromises as n, normalizeKey as r, mapStorageToFileSystem as t };
|
|
38
|
+
//# sourceMappingURL=index-M6wCzIr6.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-M6wCzIr6.d.cts","names":[],"sources":["../src/storage/helpers.ts","../src/storage/promises.ts","../src/storage/index.ts"],"mappings":";;;;;;iBAyCgB,YAAA,CAAa,IAAA,WAAe,MAAA,GAAS,GAAG;;;UCiDvC,qBAAA;EACf,QAAA,EAAU,2BAAA;EACV,gBAAA,GAAmB,IAAA,EAAM,QAAA,EAAU,OAAA,GAAU,iBAAA,KAAsB,UAAA;EACnE,iBAAA,GACE,IAAA,EAAM,QAAA,EACN,OAAA,GAAU,kBAAA,KACP,WAAA;EACL,MAAA,GAAS,IAAA,EAAM,QAAA,EAAU,KAAA,GAAQ,QAAA,EAAU,IAAA,GAAO,IAAA,KAAS,OAAA;EAC3D,OAAA,GAAU,EAAA,aAAe,OAAA;EACzB,OAAA,GACE,EAAA,UACA,OAAA,GAAU,WAAA;IAAgB,MAAA;EAAA,MACvB,UAAA,CAAW,2BAAA;EAChB,MAAA,GACE,EAAA,UACA,MAAA,EAAQ,MAAA,EACR,MAAA,UACA,MAAA,UACA,QAAA,oBACG,OAAA;IAAU,SAAA;IAAmB,MAAA,EAAQ,MAAA;EAAA;EAC1C,OAAA,GACE,EAAA,UACA,MAAA,EAAQ,MAAA,EACR,MAAA,UACA,MAAA,UACA,QAAA,oBACG,OAAA;IAAU,YAAA;IAAsB,MAAA,EAAQ,MAAA;EAAA;EAC7C,WAAA,GAAc,EAAA,UAAY,GAAA,cAAiB,OAAA;EAC3C,SAAA,GAAY,EAAA,UAAY,KAAA,EAAO,QAAA,EAAU,KAAA,EAAO,QAAA,KAAa,OAAA;EAC7D,OAAA,GACE,EAAA,UACA,OAAA,EAAS,MAAA,CAAO,eAAA,IAChB,QAAA,cACG,OAAA,CAAQ,WAAA;EACb,QAAA,GACE,EAAA,UACA,OAAA,EAAS,MAAA,CAAO,eAAA,IAChB,QAAA,cACG,OAAA,CAAQ,YAAA;AAAA;AAAA,iBAKC,qBAAA,CAAsB,OAAA,EAAS,OAAA,GAAU,qBAAqB;;;iBCrF9D,sBAAA,CAAuB,OAAA,EAAS,OAAA,GAAU,mBAAmB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-CwyhgVEl.cjs"),t=require("./helpers-B5sr5S3X.cjs");let n=require("@stryke/convert/extract-file-reference"),r=require("@stryke/hash"),i=require("@stryke/helpers/deep-clone"),a=require("@stryke/json"),o=require("@stryke/path/find"),s=require("@stryke/resolve/constants"),c=require("@stryke/resolve/load"),l=require("@stryke/string-format/list"),u=require("@stryke/type-checks"),d=require("@stryke/type-checks/is-set-object"),f=require("@stryke/zod"),p=require("@valibot/to-json-schema"),m=require("ts-json-schema-generator/dist/factory/generator.js");const h=`https://power-plant.invalid/`;function g(e){return!(!(0,d.isSetObject)(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e)}function _(e){return g(e)?e.schema:e}function v(e){return e.endsWith(`#`)?e.slice(0,-1):e}function y(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function b(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function x(e){return e.length===0?``:`/${e.map(e=>b(e)).join(`/`)}`}function S(e,t){try{return v(new URL(e,t).toString())}catch{return v(e)}}function C(e,t,n,r,i){if(!(0,d.isSetObject)(e))return;let a=e,o=x(t),s=(0,u.isSetString)(a.$id)?S(a.$id,n):n,c=y(s);if(r.set(s,o),r.set(c,o),(0,u.isSetString)(a.$anchor)&&r.set(`${c}#${a.$anchor}`,o),(0,u.isSetString)(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)=>{C(n,[...t,e,String(a)],s,r,i)});continue}C(n,[...t,e],s,r,i)}}function w(e,t,n,r,i){if(!(0,d.isSetObject)(e))return;let a=e,o=(0,u.isSetString)(a.$id)?S(a.$id,n):n;if((0,u.isSetString)(a.$ref)){let e=S(a.$ref,o),t=r.get(e)??r.get(y(e));t!==void 0&&(a.$ref=t.length>0?`#${t}`:`#`)}if((0,u.isSetString)(a.$dynamicRef)){let e=S(a.$dynamicRef,o),t=i.get(e);if(t)a.$dynamicRef=t;else{let t=r.get(e)??r.get(y(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)=>{w(n,[...t,e,String(a)],o,r,i)});continue}w(n,[...t,e],o,r,i)}}function T(e){if(!(0,d.isSetObject)(e))return e;let t=(0,i.deepClone)(e),n=(0,u.isSetString)(t.$id)?S(t.$id,h):h,r=new Map,a=new Map;return C(t,[],n,r,a),w(t,[],n,r,a),t}function E(e){if(t.tt(e))return k(e);if((0,d.isSetObject)(e)){if(t.$(e))return A(e);let n=e;if(`$schema`in n&&t.tt(n.$schema))return k(n.$schema)}return e}function D(e){return Array.isArray(e)?e.map(e=>E(e)):e}function O(e){return(0,p.toJsonSchema)(e,{target:`draft-2020-12`})}function k(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`&&(0,u.isSetString)(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!(0,d.isSetObject)(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,E(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=E(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=D(r);continue}n[e]=r}return n}function A(e){let n=e,r=t.tt(n.$schema)?k(n.$schema):{},i={};for(let[e,r]of Object.entries(n)){if(e.startsWith(`$`)||!(0,d.isSetObject)(r))continue;if(t.$(r)){i[e]=A(r);continue}let n=r;if(`$schema`in n&&t.tt(n.$schema)){i[e]=k(n.$schema);continue}t.tt(r)&&(i[e]=k(r))}if(!t.F(r))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let a={...(0,d.isSetObject)(r.properties)?r.properties:{},...i};return{...r,type:r.type??`object`,...Object.keys(a).length>0?{properties:a}:{}}}function j(e,n){let i=_(n);if(t.Z(i)||t.J(i))return(0,r.murmurhash)({variant:e,input:i.schema});if((0,u.isSetString)(i)||typeof i==`boolean`)return(0,r.murmurhash)({variant:e,input:i});if((0,d.isSetObject)(i)){if((0,f.isZod3Type)(i))return(0,r.murmurhash)({variant:e,input:i._def});if((0,a.isStandardJsonSchema)(i))return(0,r.murmurhash)({variant:e,input:i[`~standard`]});if(t.g(i))return(0,r.murmurhash)({variant:e,input:i});if(t.rt(i))return(0,r.murmurhash)({variant:e,input:O(i)});if(t.$(i))return(0,r.murmurhash)({variant:e,input:A(i)});if(t.tt(i))return(0,r.murmurhash)({variant:e,input:k(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 M(e){if((0,d.isSetObject)(e)){if((0,f.isZod3Type)(e))return(0,f.extractJsonSchema)(e,{target:`draft-2020-12`});if(t.et(e))return A(e);if(t.nt(e))return k(e);if((0,a.isStandardJsonSchema)(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(t.rt(e))return O(e);if(t.g(e))return e}}function N(e){if((0,d.isSetObject)(e)){if((0,f.isZod3Type)(e))return`zod3`;if(t.et(e)||t.nt(e))return`untyped`;if((0,a.isStandardJsonSchema)(e))return`standard-schema`;if(t.g(e))return`json-schema`;if(t.rt(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 P(e){let n=_(e);return t.Z(n)||t.J(n)?n.variant:(0,u.isSetString)(n)||t.h(n)?`file-reference`:N(n)}async function F(e,n){if(t.Z(e))return e.schema;let r=n??N(e),i;if((r===`zod3`||r===`json-schema`||r===`standard-schema`||r===`untyped`||r===`valibot`)&&(i=M(e)),i)return T(i);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 I(e,t){if(e===`zod3`)return{hash:j(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:j(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:j(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:j(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:j(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 L(e,t={}){let r=(0,n.extractFileReference)(e);if(!r)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 i=r.export??`*`;try{return(0,m.createGenerator)({path:r.file,type:i,expose:`export`,jsDoc:`extended`,...t}).createSchema(i)}catch(e){throw Error(`Failed to generate a JSON schema for "${r.file}" using the type "${i}". Error: ${e.message}`)}}async function R(e,r={}){let i=_(e);if(t.Z(i))return i;if(t.J(i))return{...i,source:{hash:j(`json-schema`,i.schema),variant:`json-schema`,schema:i.schema}};let a,u=P(i),d=j(u,i);if(u===`file-reference`){let e=(0,n.extractFileReference)(i);if(!e)throw Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(i)}". 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 u=(0,o.findFileExtensionSafe)(e.file);if(u&&!s.VALID_OBJECT_SOURCE_EXTENSIONS.includes(u))throw Error(`The provided schema file input "${e.file}" has an invalid file extension (.${u}). Please ensure that the file has one of the following extensions: ${(0,l.list)(s.VALID_OBJECT_SOURCE_EXTENSIONS,{conjunction:`or`})}.`);let d=await(0,c.loadSafe)(i,r);d??=await L(i,r);let f=_(d);a=t.Z(f)?f.source:t.J(f)?{hash:j(`json-schema`,f.schema),variant:`json-schema`,schema:f.schema}:I(N(f),f)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(u))a=I(u,i);else throw Error(`Invalid schema definition input "${u}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);return{variant:u,source:a,schema:await F(a.schema,a.variant),hash:d}}async function z(e,n={}){let r=_(e);if(t.Z(r)||t.X(r))return r;let i=await R(e,n);if(!i?.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 i}exports.JSON_SCHEMA_METADATA_KEYS=e.t,exports.JSON_SCHEMA_PRIMITIVE_TYPES=e.n,exports.JSON_SCHEMA_TYPES=e.r,exports.JsonSchemaTypeNames=e.i,exports.SCHEMA_ARRAY_CONCAT_KEYWORDS=e.a,exports.SCHEMA_RECORD_KEYWORDS=e.o,exports.SCHEMA_SINGLE_KEYWORDS=e.s,exports.addProperty=t.t,exports.applyJsonSchemaMetadata=t.f,exports.bundleReferences=T,exports.extract=z,exports.extractHash=j,exports.extractJsonSchema=M,exports.extractResolvedVariant=N,exports.extractSchema=F,exports.extractSchemaWithSource=R,exports.extractSource=I,exports.extractTSType=L,exports.extractVariant=P,exports.getJsonSchema=t.n,exports.getJsonSchemaObject=t.r,exports.getPrimarySchemaType=t.p,exports.getProperties=t.i,exports.getPropertiesList=t.a,exports.getProperty=t.o,exports.isFileReference=t.h,exports.isJsonSchema=t.g,exports.isJsonSchemaAllOf=t._,exports.isJsonSchemaAny=t.v,exports.isJsonSchemaAnyOf=t.y,exports.isJsonSchemaArray=t.b,exports.isJsonSchemaBigint=t.x,exports.isJsonSchemaBoolean=t.S,exports.isJsonSchemaDate=t.C,exports.isJsonSchemaDecimal=t.w,exports.isJsonSchemaEnum=t.T,exports.isJsonSchemaInteger=t.E,exports.isJsonSchemaKeywords=t.D,exports.isJsonSchemaLiteral=t.O,exports.isJsonSchemaMap=t.k,exports.isJsonSchemaNativeEnum=t.A,exports.isJsonSchemaNever=t.j,exports.isJsonSchemaNull=t.M,exports.isJsonSchemaNullable=t.N,exports.isJsonSchemaNumber=t.P,exports.isJsonSchemaObject=t.F,exports.isJsonSchemaPrimitiveType=t.I,exports.isJsonSchemaPrimitiveUnion=t.L,exports.isJsonSchemaRecord=t.R,exports.isJsonSchemaRef=t.z,exports.isJsonSchemaSet=t.B,exports.isJsonSchemaString=t.V,exports.isJsonSchemaTuple=t.H,exports.isJsonSchemaType=t.U,exports.isJsonSchemaUndefined=t.W,exports.isJsonSchemaUnion=t.G,exports.isJsonSchemaUnknown=t.K,exports.isNullOnlyJsonSchema=t.q,exports.isPropertyOptional=t.s,exports.isSchema=t.J,exports.isSchemaNullable=t.c,exports.isSchemaObject=t.Y,exports.isSchemaOf=t.X,exports.isSchemaWithSource=t.Z,exports.isStandardSchema=t.Q,exports.isUntypedConfig=t.$,exports.isUntypedConfigStrict=t.et,exports.isUntypedSchema=t.tt,exports.isUntypedSchemaStrict=t.nt,exports.isValibotSchema=t.rt,exports.isValidSchemaConfigFile=t.l,exports.merge=t.u,exports.mergeMetadata=t.d,exports.readSchemaTypes=t.m;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-CjTQhR-l.cjs"),t=require("./storage-CgfRQlqS.cjs"),n=require("./helpers-BIaA3COd.cjs");let r=require("@stryke/convert/extract-file-reference"),i=require("@stryke/hash"),a=require("@stryke/helpers/deep-clone"),o=require("@stryke/json"),s=require("@stryke/path/find"),c=require("@stryke/resolve/constants"),l=require("@stryke/resolve/load"),u=require("@stryke/string-format/list"),d=require("@stryke/type-checks"),f=require("@stryke/type-checks/is-set-object"),p=require("@stryke/zod"),m=require("@valibot/to-json-schema"),h=require("ts-json-schema-generator/dist/factory/generator.js");const g=`https://power-plant.invalid/`;function _(e){return!(!(0,f.isSetObject)(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e)}function v(e){return _(e)?e.schema:e}function y(e){return e.endsWith(`#`)?e.slice(0,-1):e}function b(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function x(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function S(e){return e.length===0?``:`/${e.map(e=>x(e)).join(`/`)}`}function C(e,t){try{return y(new URL(e,t).toString())}catch{return y(e)}}function w(e,t,n,r,i){if(!(0,f.isSetObject)(e))return;let a=e,o=S(t),s=(0,d.isSetString)(a.$id)?C(a.$id,n):n,c=b(s);if(r.set(s,o),r.set(c,o),(0,d.isSetString)(a.$anchor)&&r.set(`${c}#${a.$anchor}`,o),(0,d.isSetString)(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)=>{w(n,[...t,e,String(a)],s,r,i)});continue}w(n,[...t,e],s,r,i)}}function T(e,t,n,r,i){if(!(0,f.isSetObject)(e))return;let a=e,o=(0,d.isSetString)(a.$id)?C(a.$id,n):n;if((0,d.isSetString)(a.$ref)){let e=C(a.$ref,o),t=r.get(e)??r.get(b(e));t!==void 0&&(a.$ref=t.length>0?`#${t}`:`#`)}if((0,d.isSetString)(a.$dynamicRef)){let e=C(a.$dynamicRef,o),t=i.get(e);if(t)a.$dynamicRef=t;else{let t=r.get(e)??r.get(b(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)=>{T(n,[...t,e,String(a)],o,r,i)});continue}T(n,[...t,e],o,r,i)}}function E(e){if(!(0,f.isSetObject)(e))return e;let t=(0,a.deepClone)(e),n=(0,d.isSetString)(t.$id)?C(t.$id,g):g,r=new Map,i=new Map;return w(t,[],n,r,i),T(t,[],n,r,i),t}function D(e){if(n.nt(e))return A(e);if((0,f.isSetObject)(e)){if(n.et(e))return j(e);let t=e;if(`$schema`in t&&n.nt(t.$schema))return A(t.$schema)}return e}function O(e){return Array.isArray(e)?e.map(e=>D(e)):e}function k(e){return(0,m.toJsonSchema)(e,{target:`draft-2020-12`})}function A(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`&&(0,d.isSetString)(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!(0,f.isSetObject)(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,D(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=D(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=O(r);continue}n[e]=r}return n}function j(e){let t=e,r=n.nt(t.$schema)?A(t.$schema):{},i={};for(let[e,r]of Object.entries(t)){if(e.startsWith(`$`)||!(0,f.isSetObject)(r))continue;if(n.et(r)){i[e]=j(r);continue}let t=r;if(`$schema`in t&&n.nt(t.$schema)){i[e]=A(t.$schema);continue}n.nt(r)&&(i[e]=A(r))}if(!n.I(r))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let a={...(0,f.isSetObject)(r.properties)?r.properties:{},...i};return{...r,type:r.type??`object`,...Object.keys(a).length>0?{properties:a}:{}}}function M(e,t){let r=v(t);if(n.Q(r)||n.Y(r))return(0,i.murmurhash)({variant:e,input:r.schema});if((0,d.isSetString)(r)||typeof r==`boolean`)return(0,i.murmurhash)({variant:e,input:r});if((0,f.isSetObject)(r)){if((0,p.isZod3Type)(r))return(0,i.murmurhash)({variant:e,input:r._def});if((0,o.isStandardJsonSchema)(r))return(0,i.murmurhash)({variant:e,input:r[`~standard`]});if(n._(r))return(0,i.murmurhash)({variant:e,input:r});if(n.it(r))return(0,i.murmurhash)({variant:e,input:k(r)});if(n.et(r))return(0,i.murmurhash)({variant:e,input:j(r)});if(n.nt(r))return(0,i.murmurhash)({variant:e,input:A(r)})}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 N(e){if((0,f.isSetObject)(e)){if((0,p.isZod3Type)(e))return(0,p.extractJsonSchema)(e,{target:`draft-2020-12`});if(n.tt(e))return j(e);if(n.rt(e))return A(e);if((0,o.isStandardJsonSchema)(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(n.it(e))return k(e);if(n._(e))return e}}function P(e){if((0,f.isSetObject)(e)){if((0,p.isZod3Type)(e))return`zod3`;if(n.tt(e)||n.rt(e))return`untyped`;if((0,o.isStandardJsonSchema)(e))return`standard-schema`;if(n._(e))return`json-schema`;if(n.it(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 F(e){let t=v(e);return n.Q(t)||n.Y(t)?t.variant:(0,d.isSetString)(t)||n.g(t)?`file-reference`:P(t)}async function I(e,t){if(n.Q(e))return e.schema;let r=t??P(e),i;if((r===`zod3`||r===`json-schema`||r===`standard-schema`||r===`untyped`||r===`valibot`)&&(i=N(e)),i)return E(i);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 L(e,t){if(e===`zod3`)return{hash:M(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:M(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:M(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:M(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:M(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 R(e,t={}){let n=(0,r.extractFileReference)(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 i=n.export??`*`;try{return(0,h.createGenerator)({path:n.file,type:i,expose:`export`,jsDoc:`extended`,...t}).createSchema(i)}catch(e){throw Error(`Failed to generate a JSON schema for "${n.file}" using the type "${i}". Error: ${e.message}`)}}async function z(e,i={}){let a=v(e);if(n.Q(a))return a;if(n.Y(a))return{...a,source:{hash:M(`json-schema`,a.schema),variant:`json-schema`,schema:a.schema}};let o,d=F(a),f=M(d,a);if(d===`file-reference`){let e=(0,r.extractFileReference)(a);if(!e)throw Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(a)}". 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 d=(0,s.findFileExtensionSafe)(e.file);if(d&&!c.VALID_OBJECT_SOURCE_EXTENSIONS.includes(d))throw Error(`The provided schema file input "${e.file}" has an invalid file extension (.${d}). Please ensure that the file has one of the following extensions: ${(0,u.list)(c.VALID_OBJECT_SOURCE_EXTENSIONS,{conjunction:`or`})}.`);let f;i.storage&&(f=t.t(i.storage));let p=await(0,l.loadSafe)(a,{...i,fs:f});p??=await R(a,{...i,fs:f});let m=v(p);o=n.Q(m)?m.source:n.Y(m)?{hash:M(`json-schema`,m.schema),variant:`json-schema`,schema:m.schema}:L(P(m),m)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(d))o=L(d,a);else throw Error(`Invalid schema definition input "${d}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);return{variant:d,source:o,schema:await I(o.schema,o.variant),hash:f}}async function B(e,t={}){let r=v(e);if(n.Q(r)||n.Z(r))return r;let i=await z(e,t);if(!i?.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 i}exports.JSON_SCHEMA_METADATA_KEYS=e.t,exports.JSON_SCHEMA_PRIMITIVE_TYPES=e.n,exports.JSON_SCHEMA_TYPES=e.r,exports.JsonSchemaTypeNames=e.i,exports.SCHEMA_ARRAY_CONCAT_KEYWORDS=e.a,exports.SCHEMA_RECORD_KEYWORDS=e.o,exports.SCHEMA_SINGLE_KEYWORDS=e.s,exports.addProperty=n.t,exports.applyJsonSchemaMetadata=n.p,exports.bundleReferences=E,exports.createStoragePromises=t.n,exports.extract=B,exports.extractHash=M,exports.extractJsonSchema=N,exports.extractResolvedVariant=P,exports.extractSchema=I,exports.extractSchemaWithSource=z,exports.extractSource=L,exports.extractTSType=R,exports.extractVariant=F,exports.getJsonSchema=n.n,exports.getJsonSchemaObject=n.r,exports.getPrimarySchemaType=n.m,exports.getProperties=n.i,exports.getPropertiesList=n.a,exports.getProperty=n.o,exports.isFileReference=n.g,exports.isJsonSchema=n._,exports.isJsonSchemaAllOf=n.v,exports.isJsonSchemaAny=n.y,exports.isJsonSchemaAnyOf=n.b,exports.isJsonSchemaArray=n.x,exports.isJsonSchemaBigint=n.S,exports.isJsonSchemaBoolean=n.C,exports.isJsonSchemaDate=n.w,exports.isJsonSchemaDecimal=n.T,exports.isJsonSchemaEnum=n.E,exports.isJsonSchemaInteger=n.D,exports.isJsonSchemaKeywords=n.O,exports.isJsonSchemaLiteral=n.k,exports.isJsonSchemaMap=n.A,exports.isJsonSchemaNativeEnum=n.j,exports.isJsonSchemaNever=n.M,exports.isJsonSchemaNull=n.N,exports.isJsonSchemaNullable=n.P,exports.isJsonSchemaNumber=n.F,exports.isJsonSchemaObject=n.I,exports.isJsonSchemaPrimitiveType=n.L,exports.isJsonSchemaPrimitiveUnion=n.R,exports.isJsonSchemaRecord=n.z,exports.isJsonSchemaRef=n.B,exports.isJsonSchemaSet=n.V,exports.isJsonSchemaString=n.H,exports.isJsonSchemaTuple=n.U,exports.isJsonSchemaType=n.W,exports.isJsonSchemaUndefined=n.G,exports.isJsonSchemaUnion=n.K,exports.isJsonSchemaUnknown=n.q,exports.isNullOnlyJsonSchema=n.J,exports.isPropertyOptional=n.s,exports.isSchema=n.Y,exports.isSchemaNullable=n.c,exports.isSchemaObject=n.X,exports.isSchemaOf=n.Z,exports.isSchemaWithSource=n.Q,exports.isStandardSchema=n.$,exports.isUntypedConfig=n.et,exports.isUntypedConfigStrict=n.tt,exports.isUntypedSchema=n.nt,exports.isUntypedSchemaStrict=n.rt,exports.isValibotSchema=n.it,exports.isValidSchemaConfigFile=n.l,exports.mapStorageToFileSystem=t.t,exports.merge=n.u,exports.mergeMetadata=n.d,exports.normalizeKey=t.r,exports.readSchemaTypes=n.h,exports.traverseSchema=n.f;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { $ as SpecOf, A as JsonSchemaObject, B as JsonSchemaStringFormat, C as JsonSchemaMetadataKeywords, D as JsonSchemaNullable, E as JsonSchemaNull, F as JsonSchemaRecordPropertyNames, G as JsonSchemaUnknown, H as JsonSchemaType, I as JsonSchemaRef, J as SchemaEnvelope, K as SchemaConfig, L as JsonSchemaSchemaSource, M as JsonSchemaPrimitiveType, N as JsonSchemaPrimitiveUnion, O as JsonSchemaNumber, P as JsonSchemaRecord, Q as SchemaSourceVariant, R as JsonSchemaSet, S as JsonSchemaMap, T as JsonSchemaNever, U as JsonSchemaUndefined, V as JsonSchemaTuple, W as JsonSchemaUnion, X as SchemaSource, Y as SchemaEnvelopeOf, Z as SchemaSourceConfig, _ as JsonSchemaIntegerFormat, a as JsonSchemaAllOf, at as ValibotSchemaSource, b as JsonSchemaLiteral, c as JsonSchemaArray, ct as JSON_SCHEMA_PRIMITIVE_TYPES, d as JsonSchemaConditionalKeywords, dt as SCHEMA_ARRAY_CONCAT_KEYWORDS, et as StandardSchemaSchemaSource, f as JsonSchemaDate, ft as SCHEMA_RECORD_KEYWORDS, g as JsonSchemaInteger, h as JsonSchemaEnum, i as JsonSchema, it as ValibotSchema, j as JsonSchemaOf, k as JsonSchemaNumberFormat, l as JsonSchemaBigint, lt as JSON_SCHEMA_TYPES, m as JsonSchemaDecimalFormat, n as ExtractedSchemaEnvelope, nt as UntypedSchema, o as JsonSchemaAny, ot as Zod3SchemaSource, p as JsonSchemaDecimal, pt as SCHEMA_SINGLE_KEYWORDS, q as SchemaConfigVariant, r as InferExtractOptions, rt as UntypedSchemaSource, s as JsonSchemaAnyOf, st as JSON_SCHEMA_METADATA_KEYS, t as BaseSchemaSource, tt as UntypedConfigObject, u as JsonSchemaBoolean, ut as JsonSchemaTypeNames, v as JsonSchemaKeywords, w as JsonSchemaNativeEnum, x as JsonSchemaLogicKeywords, y as JsonSchemaLike, z as JsonSchemaString } from "./types-
|
|
1
|
+
import { $ as SpecOf, A as JsonSchemaObject, B as JsonSchemaStringFormat, C as JsonSchemaMetadataKeywords, D as JsonSchemaNullable, E as JsonSchemaNull, F as JsonSchemaRecordPropertyNames, G as JsonSchemaUnknown, H as JsonSchemaType, I as JsonSchemaRef, J as SchemaEnvelope, K as SchemaConfig, L as JsonSchemaSchemaSource, M as JsonSchemaPrimitiveType, N as JsonSchemaPrimitiveUnion, O as JsonSchemaNumber, P as JsonSchemaRecord, Q as SchemaSourceVariant, R as JsonSchemaSet, S as JsonSchemaMap, T as JsonSchemaNever, U as JsonSchemaUndefined, V as JsonSchemaTuple, W as JsonSchemaUnion, X as SchemaSource, Y as SchemaEnvelopeOf, Z as SchemaSourceConfig, _ as JsonSchemaIntegerFormat, a as JsonSchemaAllOf, at as ValibotSchemaSource, b as JsonSchemaLiteral, c as JsonSchemaArray, ct as JSON_SCHEMA_PRIMITIVE_TYPES, d as JsonSchemaConditionalKeywords, dt as SCHEMA_ARRAY_CONCAT_KEYWORDS, et as StandardSchemaSchemaSource, f as JsonSchemaDate, ft as SCHEMA_RECORD_KEYWORDS, g as JsonSchemaInteger, h as JsonSchemaEnum, i as JsonSchema, it as ValibotSchema, j as JsonSchemaOf, k as JsonSchemaNumberFormat, l as JsonSchemaBigint, lt as JSON_SCHEMA_TYPES, m as JsonSchemaDecimalFormat, n as ExtractedSchemaEnvelope, nt as UntypedSchema, o as JsonSchemaAny, ot as Zod3SchemaSource, p as JsonSchemaDecimal, pt as SCHEMA_SINGLE_KEYWORDS, q as SchemaConfigVariant, r as InferExtractOptions, rt as UntypedSchemaSource, s as JsonSchemaAnyOf, st as JSON_SCHEMA_METADATA_KEYS, t as BaseSchemaSource, tt as UntypedConfigObject, u as JsonSchemaBoolean, ut as JsonSchemaTypeNames, v as JsonSchemaKeywords, w as JsonSchemaNativeEnum, x as JsonSchemaLogicKeywords, y as JsonSchemaLike, z as JsonSchemaString } from "./types-CCLUrmYp.cjs";
|
|
2
|
+
import { n as createStoragePromises, r as normalizeKey, t as mapStorageToFileSystem } from "./index-M6wCzIr6.cjs";
|
|
2
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
4
|
import { InferLoadOptions } from "@stryke/resolve/types";
|
|
4
5
|
import { InputObject, Schema } from "untyped";
|
|
@@ -264,6 +265,17 @@ declare function isPropertyOptional(parent: JsonSchemaObject, propertyName: stri
|
|
|
264
265
|
* @returns `true` if the file name has a valid schema input extension, otherwise `false`.
|
|
265
266
|
*/
|
|
266
267
|
declare function isValidSchemaConfigFile(fileName: string): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Traverses a JSON Schema and applies a callback function to each schema fragment.
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* This function recursively traverses a JSON Schema, including nested schemas in properties, composition keywords (`allOf`, `anyOf`, `oneOf`), and other schema keywords. The provided callback function is invoked for each schema fragment encountered during the traversal. The results of the callback are collected and returned as an array.
|
|
273
|
+
*
|
|
274
|
+
* @param schema - The JSON Schema to traverse.
|
|
275
|
+
* @param callback - The callback function to apply to each schema fragment.
|
|
276
|
+
* @returns An array of results returned by the callback function.
|
|
277
|
+
*/
|
|
278
|
+
declare function traverseSchema<T>(schema: JsonSchema, callback: (schema: JsonSchema) => T | void): T[];
|
|
267
279
|
//#endregion
|
|
268
280
|
//#region src/metadata.d.ts
|
|
269
281
|
/**
|
|
@@ -615,5 +627,5 @@ declare function isSchemaWithSource(input: unknown): input is ExtractedSchemaEnv
|
|
|
615
627
|
*/
|
|
616
628
|
declare function isSchemaObject(input: unknown): input is SchemaEnvelope<JsonSchemaObject>;
|
|
617
629
|
//#endregion
|
|
618
|
-
export { type BaseSchemaSource, type ExtractedSchemaEnvelope, GetPropertyResult, type InferExtractOptions, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, type JsonSchema, type JsonSchemaAllOf, type JsonSchemaAny, type JsonSchemaAnyOf, type JsonSchemaArray, type JsonSchemaBigint, type JsonSchemaBoolean, type JsonSchemaConditionalKeywords, type JsonSchemaDate, type JsonSchemaDecimal, type JsonSchemaDecimalFormat, type JsonSchemaEnum, type JsonSchemaInteger, type JsonSchemaIntegerFormat, type JsonSchemaKeywords, type JsonSchemaLike, type JsonSchemaLiteral, type JsonSchemaLogicKeywords, type JsonSchemaMap, type JsonSchemaMetadataKeywords, type JsonSchemaNativeEnum, type JsonSchemaNever, type JsonSchemaNull, type JsonSchemaNullable, type JsonSchemaNumber, type JsonSchemaNumberFormat, type JsonSchemaObject, type JsonSchemaOf, type JsonSchemaPrimitiveType, type JsonSchemaPrimitiveUnion, type JsonSchemaRecord, type JsonSchemaRecordPropertyNames, type JsonSchemaRef, type JsonSchemaSchemaSource, type JsonSchemaSet, type JsonSchemaString, type JsonSchemaStringFormat, type JsonSchemaTuple, type JsonSchemaType, JsonSchemaTypeNames, type JsonSchemaUndefined, type JsonSchemaUnion, type JsonSchemaUnknown, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, type SchemaConfig, type SchemaConfigVariant, type SchemaEnvelope, type SchemaEnvelopeOf, type SchemaSource, type SchemaSourceConfig, type SchemaSourceVariant, type SpecOf, type StandardSchemaSchemaSource, type UntypedConfigObject, type UntypedSchema, type UntypedSchemaSource, type ValibotSchema, type ValibotSchemaSource, type Zod3SchemaSource, addProperty, applyJsonSchemaMetadata, bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant, getJsonSchema, getJsonSchemaObject, getPrimarySchemaType, getProperties, getPropertiesList, getProperty, isFileReference, isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isPropertyOptional, isSchema, isSchemaNullable, isSchemaObject, isSchemaOf, isSchemaWithSource, isStandardSchema, isUntypedConfig, isUntypedConfigStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaConfigFile, merge, mergeMetadata, readSchemaTypes };
|
|
630
|
+
export { type BaseSchemaSource, type ExtractedSchemaEnvelope, GetPropertyResult, type InferExtractOptions, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, type JsonSchema, type JsonSchemaAllOf, type JsonSchemaAny, type JsonSchemaAnyOf, type JsonSchemaArray, type JsonSchemaBigint, type JsonSchemaBoolean, type JsonSchemaConditionalKeywords, type JsonSchemaDate, type JsonSchemaDecimal, type JsonSchemaDecimalFormat, type JsonSchemaEnum, type JsonSchemaInteger, type JsonSchemaIntegerFormat, type JsonSchemaKeywords, type JsonSchemaLike, type JsonSchemaLiteral, type JsonSchemaLogicKeywords, type JsonSchemaMap, type JsonSchemaMetadataKeywords, type JsonSchemaNativeEnum, type JsonSchemaNever, type JsonSchemaNull, type JsonSchemaNullable, type JsonSchemaNumber, type JsonSchemaNumberFormat, type JsonSchemaObject, type JsonSchemaOf, type JsonSchemaPrimitiveType, type JsonSchemaPrimitiveUnion, type JsonSchemaRecord, type JsonSchemaRecordPropertyNames, type JsonSchemaRef, type JsonSchemaSchemaSource, type JsonSchemaSet, type JsonSchemaString, type JsonSchemaStringFormat, type JsonSchemaTuple, type JsonSchemaType, JsonSchemaTypeNames, type JsonSchemaUndefined, type JsonSchemaUnion, type JsonSchemaUnknown, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, type SchemaConfig, type SchemaConfigVariant, type SchemaEnvelope, type SchemaEnvelopeOf, type SchemaSource, type SchemaSourceConfig, type SchemaSourceVariant, type SpecOf, type StandardSchemaSchemaSource, type UntypedConfigObject, type UntypedSchema, type UntypedSchemaSource, type ValibotSchema, type ValibotSchemaSource, type Zod3SchemaSource, addProperty, applyJsonSchemaMetadata, bundleReferences, createStoragePromises, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant, getJsonSchema, getJsonSchemaObject, getPrimarySchemaType, getProperties, getPropertiesList, getProperty, isFileReference, isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isPropertyOptional, isSchema, isSchemaNullable, isSchemaObject, isSchemaOf, isSchemaWithSource, isStandardSchema, isUntypedConfig, isUntypedConfigStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaConfigFile, mapStorageToFileSystem, merge, mergeMetadata, normalizeKey, readSchemaTypes, traverseSchema };
|
|
619
631
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/extract.ts","../src/helpers.ts","../src/metadata.ts","../src/type-checks.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/extract.ts","../src/helpers.ts","../src/metadata.ts","../src/type-checks.ts"],"mappings":";;;;;;;;;;;;;;;;iBAmQgB,gBAAA,CAAiB,MAAA,EAAQ,UAAA,GAAa,UAAU;AAAhE;;;AAAA,iBAgMgB,WAAA,CACd,OAAA,EAAS,mBAAA,EACT,KAAA,EAAO,YAAY;;;;;AAlM2C;AAgMhE;iBAkDgB,iBAAA,CAAkB,MAAA,YAAkB,UAAU;;;;;;;;iBAoC9C,sBAAA,CACd,KAAA,EAAO,kBAAA,GACN,mBAAmB;AAtCtB;;;;AAA8D;AAoC9D;AApCA,iBAgEgB,cAAA,CAAe,KAAA,EAAO,YAAA,GAAe,mBAAmB;;;;;;;AA1BlD;AA0BtB;iBAsBsB,aAAA,CACpB,KAAA,EAAO,kBAAA,EACP,OAAA,GAAU,mBAAA,GACT,OAAA,CAAQ,UAAA;;;;;;;AAzB6D;AAsBxE;iBAsCgB,aAAA,CACd,OAAA,EAAS,mBAAA,EACT,KAAA,EAAO,kBAAA,GACN,YAAA;;;;;;;;iBA6CmB,aAAA,CACpB,KAAA,EAAO,kBAAA,EACP,OAAA,GAAS,gBAAA,QAAwB,KAAA,IAChC,OAAA,CAAQ,UAAA;;;;;;;AAtFU;AAmCrB;;;;;;;;;;;;;;AAGe;AA6Cf;;;;;;;;;;;iBAiEsB,uBAAA,cACpB,KAAA,EAAO,YAAA,EACP,OAAA,GAAS,mBAAA,QAA2B,KAAA,IACnC,OAAA,CAAQ,uBAAA,CAAwB,KAAA;;;;;;;AAjEd;AA8DrB;;;;;;;;;;;;;;;;;;;;;AAGwC;AA2IxC;;;;iBAAsB,OAAA,cACpB,KAAA,EAAO,YAAA,CAAa,KAAA,GACpB,OAAA,GAAS,mBAAA,QAA2B,KAAA,IACnC,OAAA,CAAQ,gBAAA,CAAiB,KAAA;;;KC30BhB,iBAAA,GAAoB,UAAU;EACxC,IAAA;EACA,QAAA;EACA,OAAA;AAAA;;;;;ADwNF;;;;;;iBC3MgB,aAAA,CAAc,KAAA,EAAO,cAAA,GAAiB,UAAA,GAAa,UAAA;;AD2MH;AAgMhE;;;;;;;;iBCxXgB,mBAAA,CACd,KAAA,EAAO,cAAA,GAAiB,UAAA,GACvB,gBAAA;ADwXkB;AAgDrB;;;;AAA8D;AAoC9D;;;AApFqB,iBCtWL,aAAA,CACd,GAAA,EAAK,cAAA,GAAiB,gBAAA,GACrB,MAAA,SAAe,iBAAA;;;;;AD0bI;AA0BtB;;;;iBCvbgB,iBAAA,CAAkB,GAAA,EAAK,cAAA,GAAiB,gBAAA,GAAgB,iBAAA;;;;ADubA;AAsBxE;;;;;iBChcgB,WAAA,iBAA4B,gBAAA,EAC1C,GAAA,EAAK,cAAA,CAAe,OAAA,IAAW,OAAA,EAC/B,IAAA,QAAY,OAAA,0BACX,iBAAA;;;;;;;;;;;ADgckB;iBChaL,WAAA,CACd,GAAA,EAAK,cAAA,GAAiB,gBAAA,EACtB,IAAA,UACA,QAAA,EAAU,UAAA;;;;;;;;;;;;;;ADmcG;AA6Cf;;;;;iBCvYgB,KAAA,IAAS,OAAA,GAAU,UAAA,GAAa,cAAA,MAAoB,UAAA;;;;;;;;;;;iBA6BpD,aAAA,QACd,MAAA,EAAQ,YAAA,CAAa,KAAA,GACrB,QAAA,EAAU,0BAAA,GACT,YAAA,CAAa,KAAA;;AD0WK;AA8DrB;;;;;;;iBCpZgB,gBAAA,CAAiB,MAAmB,GAAV,UAAU;;;;;;;;;;;iBAsBpC,kBAAA,CACd,MAAA,EAAQ,gBAAgB,EACxB,YAAA;;;AD+XsC;AA2IxC;;;iBCzfgB,uBAAA,CAAwB,QAAgB;;;;;;;;;;;iBAgBxC,cAAA,IACd,MAAA,EAAQ,UAAA,EACR,QAAA,GAAW,MAAA,EAAQ,UAAA,KAAe,CAAA,UACjC,CAAA;;;;;;;;;;iBCnWa,uBAAA,CACd,MAAA,EAAQ,UAAA,EACR,QAAA,EAAU,0BAAA,eACT,UAAA;;AFyNH;;;;;;;;iBE/LgB,eAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB;AF6X1B;;;;;;AAAA,iBEhWgB,oBAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB;;;;;;;;AF8J1B;iBGrLgB,eAAA,CAAgB,KAAA,QAAa,KAAA,IAAS,aAAa;;;;;;;iBAsCnD,yBAAA,CACd,KAAA,YACC,KAAA,IAAS,uBAAuB;AH6UnC;;;;;;AAAA,iBGhUgB,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,cAAc;;;AHkUpD;AAgDrB;;;iBGjGgB,oBAAA,CACd,KAAA,YACC,KAAA,IAAS,kBAAkB;AH+FgC;AAoC9D;;;;;AApC8D,iBGjF9C,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,aAAa;;;AHuHjD;AA0BtB;;;iBG3HgB,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe;;;;;AH2HH;AAsBxE;iBGlHgB,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,gBAAgB;;;;;;;iBA+B7D,mBAAA,CACd,KAAA,YACC,KAAA,IAAS,iBAAiB;;;;;;;iBAoBb,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,cAAc;AHgEpD;AAmCrB;;;;;AAnCqB,iBG3BL,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,cAAc;;;;;;;iBAuDzD,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe;;AHU5D;AA6Cf;;;;iBG7BgB,mBAAA,CACd,KAAA,YACC,KAAA,IAAS,iBAAiB;;;;;;;iBAuBb,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,aAAa;;;;;;;iBAgCvD,sBAAA,CACd,KAAA,YACC,KAAA,IAAS,oBAAoB;AHmChC;;;;;;AAAA,iBGPgB,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe;;;;;;;iBAgB3D,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,cAAc;;;;;;;iBAuBzD,oBAAA,CACd,KAAA,YACC,KAAA,IAAS,kBAAkB;AH/BU;AA2IxC;;;;;AA3IwC,iBGqExB,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,gBAAgB;;;;;;;iBA+B7D,mBAAA,CACd,KAAA,YACC,KAAA,IAAS,iBAAiB;;;;;;;iBAUb,mBAAA,CACd,KAAA,YACC,KAAA,IAAS,iBAAiB;;;;AH4BI;;;iBGlBjB,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,gBAAgB;AFzzB7E;;;;;;AAAA,iBEo2BgB,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,gBAAgB;;;AFj2BpE;AAaT;;;iBEg3BgB,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,aAAa;;;;;;;iBA8BvD,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,gBAAgB;;;AF94BA;AAmB7E;;;iBEo5BgB,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe;;;;;;;iBA8B3D,qBAAA,CACd,KAAA,YACC,KAAA,IAAS,mBAAmB;;;AFl7BZ;AAkBnB;;;iBEo7BgB,0BAAA,CACd,KAAA,YACC,KAAA,IAAS,wBAAwB;;;;;;;iBAsEpB,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe;;;;;AF1/BxC;AA6BnC;iBEg/BgB,mBAAA,CACd,KAAA,YACC,KAAA,IAAS,iBAAiB;;;;;;;iBAUb,iBAAA,CAAkB,KAAA,YAAiB,KAAA,IAAS,eAAe;;;;;AF5/BH;AAaxE;iBEigCgB,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,aAAa;;;;;;;iBAgBvD,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,gBAAgB;;;;;;;iBAqB3D,eAAA,CACd,KAAA,YACC,KAAA,IAAS,UAAU;;;;;;AFriCF;AAgCpB;;;iBE+hCgB,YAAA,CAAa,KAAA,YAAiB,KAAA,IAAS,UAAU;;;;;;;;;;iBAsCjD,oBAAA,CAAqB,KAAA,YAAiB,KAAA,IAAS,cAAc;;AFlkCvD;AAyGtB;;;;;;;iBEs+BgB,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,MAAa;;;;;;AFt+BO;AA6B9E;;;;iBEkgCgB,qBAAA,CAAsB,KAAA,YAAiB,KAAA,IAAS,MAAa;;;;;;;;;;iBAa7D,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,WAAmB;;;;;AF5gCxD;AAoBrB;;;;AAAoD;iBEkhCpC,qBAAA,CACd,KAAA,YACC,KAAA,IAAS,WAAmB;;;;;;;iBAuBf,QAAA,CAAS,KAAA,YAAiB,KAAA,IAAS,cAAc;AFnhC3C;AAiBtB;;;;AAAwD;AAjBlC,iBEqiCN,UAAA,QACd,KAAA,YACC,KAAA,IAAS,gBAAgB,CAAC,KAAA;;;;;;;iBAUb,kBAAA,CAAmB,KAAA,YAAiB,KAAA,IAAS,uBAAgB;;;;;;;iBAiB7D,cAAA,CACd,KAAA,YACC,KAAA,IAAS,cAAc,CAAC,gBAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { $ as SpecOf, A as JsonSchemaObject, B as JsonSchemaStringFormat, C as JsonSchemaMetadataKeywords, D as JsonSchemaNullable, E as JsonSchemaNull, F as JsonSchemaRecordPropertyNames, G as JsonSchemaUnknown, H as JsonSchemaType, I as JsonSchemaRef, J as SchemaEnvelope, K as SchemaConfig, L as JsonSchemaSchemaSource, M as JsonSchemaPrimitiveType, N as JsonSchemaPrimitiveUnion, O as JsonSchemaNumber, P as JsonSchemaRecord, Q as SchemaSourceVariant, R as JsonSchemaSet, S as JsonSchemaMap, T as JsonSchemaNever, U as JsonSchemaUndefined, V as JsonSchemaTuple, W as JsonSchemaUnion, X as SchemaSource, Y as SchemaEnvelopeOf, Z as SchemaSourceConfig, _ as JsonSchemaIntegerFormat, a as JsonSchemaAllOf, at as ValibotSchemaSource, b as JsonSchemaLiteral, c as JsonSchemaArray, ct as JSON_SCHEMA_PRIMITIVE_TYPES, d as JsonSchemaConditionalKeywords, dt as SCHEMA_ARRAY_CONCAT_KEYWORDS, et as StandardSchemaSchemaSource, f as JsonSchemaDate, ft as SCHEMA_RECORD_KEYWORDS, g as JsonSchemaInteger, h as JsonSchemaEnum, i as JsonSchema, it as ValibotSchema, j as JsonSchemaOf, k as JsonSchemaNumberFormat, l as JsonSchemaBigint, lt as JSON_SCHEMA_TYPES, m as JsonSchemaDecimalFormat, n as ExtractedSchemaEnvelope, nt as UntypedSchema, o as JsonSchemaAny, ot as Zod3SchemaSource, p as JsonSchemaDecimal, pt as SCHEMA_SINGLE_KEYWORDS, q as SchemaConfigVariant, r as InferExtractOptions, rt as UntypedSchemaSource, s as JsonSchemaAnyOf, st as JSON_SCHEMA_METADATA_KEYS, t as BaseSchemaSource, tt as UntypedConfigObject, u as JsonSchemaBoolean, ut as JsonSchemaTypeNames, v as JsonSchemaKeywords, w as JsonSchemaNativeEnum, x as JsonSchemaLogicKeywords, y as JsonSchemaLike, z as JsonSchemaString } from "./types-
|
|
1
|
+
import { $ as SpecOf, A as JsonSchemaObject, B as JsonSchemaStringFormat, C as JsonSchemaMetadataKeywords, D as JsonSchemaNullable, E as JsonSchemaNull, F as JsonSchemaRecordPropertyNames, G as JsonSchemaUnknown, H as JsonSchemaType, I as JsonSchemaRef, J as SchemaEnvelope, K as SchemaConfig, L as JsonSchemaSchemaSource, M as JsonSchemaPrimitiveType, N as JsonSchemaPrimitiveUnion, O as JsonSchemaNumber, P as JsonSchemaRecord, Q as SchemaSourceVariant, R as JsonSchemaSet, S as JsonSchemaMap, T as JsonSchemaNever, U as JsonSchemaUndefined, V as JsonSchemaTuple, W as JsonSchemaUnion, X as SchemaSource, Y as SchemaEnvelopeOf, Z as SchemaSourceConfig, _ as JsonSchemaIntegerFormat, a as JsonSchemaAllOf, at as ValibotSchemaSource, b as JsonSchemaLiteral, c as JsonSchemaArray, ct as JSON_SCHEMA_PRIMITIVE_TYPES, d as JsonSchemaConditionalKeywords, dt as SCHEMA_ARRAY_CONCAT_KEYWORDS, et as StandardSchemaSchemaSource, f as JsonSchemaDate, ft as SCHEMA_RECORD_KEYWORDS, g as JsonSchemaInteger, h as JsonSchemaEnum, i as JsonSchema, it as ValibotSchema, j as JsonSchemaOf, k as JsonSchemaNumberFormat, l as JsonSchemaBigint, lt as JSON_SCHEMA_TYPES, m as JsonSchemaDecimalFormat, n as ExtractedSchemaEnvelope, nt as UntypedSchema, o as JsonSchemaAny, ot as Zod3SchemaSource, p as JsonSchemaDecimal, pt as SCHEMA_SINGLE_KEYWORDS, q as SchemaConfigVariant, r as InferExtractOptions, rt as UntypedSchemaSource, s as JsonSchemaAnyOf, st as JSON_SCHEMA_METADATA_KEYS, t as BaseSchemaSource, tt as UntypedConfigObject, u as JsonSchemaBoolean, ut as JsonSchemaTypeNames, v as JsonSchemaKeywords, w as JsonSchemaNativeEnum, x as JsonSchemaLogicKeywords, y as JsonSchemaLike, z as JsonSchemaString } from "./types-J67fcIar.mjs";
|
|
2
|
+
import { n as createStoragePromises, r as normalizeKey, t as mapStorageToFileSystem } from "./index-1pJbUu8F.mjs";
|
|
2
3
|
import { BaseSchema } from "valibot";
|
|
3
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
5
|
import { InferLoadOptions } from "@stryke/resolve/types";
|
|
@@ -264,6 +265,17 @@ declare function isPropertyOptional(parent: JsonSchemaObject, propertyName: stri
|
|
|
264
265
|
* @returns `true` if the file name has a valid schema input extension, otherwise `false`.
|
|
265
266
|
*/
|
|
266
267
|
declare function isValidSchemaConfigFile(fileName: string): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Traverses a JSON Schema and applies a callback function to each schema fragment.
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* This function recursively traverses a JSON Schema, including nested schemas in properties, composition keywords (`allOf`, `anyOf`, `oneOf`), and other schema keywords. The provided callback function is invoked for each schema fragment encountered during the traversal. The results of the callback are collected and returned as an array.
|
|
273
|
+
*
|
|
274
|
+
* @param schema - The JSON Schema to traverse.
|
|
275
|
+
* @param callback - The callback function to apply to each schema fragment.
|
|
276
|
+
* @returns An array of results returned by the callback function.
|
|
277
|
+
*/
|
|
278
|
+
declare function traverseSchema<T>(schema: JsonSchema, callback: (schema: JsonSchema) => T | void): T[];
|
|
267
279
|
//#endregion
|
|
268
280
|
//#region src/metadata.d.ts
|
|
269
281
|
/**
|
|
@@ -615,5 +627,5 @@ declare function isSchemaWithSource(input: unknown): input is ExtractedSchemaEnv
|
|
|
615
627
|
*/
|
|
616
628
|
declare function isSchemaObject(input: unknown): input is SchemaEnvelope<JsonSchemaObject>;
|
|
617
629
|
//#endregion
|
|
618
|
-
export { type BaseSchemaSource, type ExtractedSchemaEnvelope, GetPropertyResult, type InferExtractOptions, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, type JsonSchema, type JsonSchemaAllOf, type JsonSchemaAny, type JsonSchemaAnyOf, type JsonSchemaArray, type JsonSchemaBigint, type JsonSchemaBoolean, type JsonSchemaConditionalKeywords, type JsonSchemaDate, type JsonSchemaDecimal, type JsonSchemaDecimalFormat, type JsonSchemaEnum, type JsonSchemaInteger, type JsonSchemaIntegerFormat, type JsonSchemaKeywords, type JsonSchemaLike, type JsonSchemaLiteral, type JsonSchemaLogicKeywords, type JsonSchemaMap, type JsonSchemaMetadataKeywords, type JsonSchemaNativeEnum, type JsonSchemaNever, type JsonSchemaNull, type JsonSchemaNullable, type JsonSchemaNumber, type JsonSchemaNumberFormat, type JsonSchemaObject, type JsonSchemaOf, type JsonSchemaPrimitiveType, type JsonSchemaPrimitiveUnion, type JsonSchemaRecord, type JsonSchemaRecordPropertyNames, type JsonSchemaRef, type JsonSchemaSchemaSource, type JsonSchemaSet, type JsonSchemaString, type JsonSchemaStringFormat, type JsonSchemaTuple, type JsonSchemaType, JsonSchemaTypeNames, type JsonSchemaUndefined, type JsonSchemaUnion, type JsonSchemaUnknown, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, type SchemaConfig, type SchemaConfigVariant, type SchemaEnvelope, type SchemaEnvelopeOf, type SchemaSource, type SchemaSourceConfig, type SchemaSourceVariant, type SpecOf, type StandardSchemaSchemaSource, type UntypedConfigObject, type UntypedSchema, type UntypedSchemaSource, type ValibotSchema, type ValibotSchemaSource, type Zod3SchemaSource, addProperty, applyJsonSchemaMetadata, bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant, getJsonSchema, getJsonSchemaObject, getPrimarySchemaType, getProperties, getPropertiesList, getProperty, isFileReference, isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isPropertyOptional, isSchema, isSchemaNullable, isSchemaObject, isSchemaOf, isSchemaWithSource, isStandardSchema, isUntypedConfig, isUntypedConfigStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaConfigFile, merge, mergeMetadata, readSchemaTypes };
|
|
630
|
+
export { type BaseSchemaSource, type ExtractedSchemaEnvelope, GetPropertyResult, type InferExtractOptions, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, type JsonSchema, type JsonSchemaAllOf, type JsonSchemaAny, type JsonSchemaAnyOf, type JsonSchemaArray, type JsonSchemaBigint, type JsonSchemaBoolean, type JsonSchemaConditionalKeywords, type JsonSchemaDate, type JsonSchemaDecimal, type JsonSchemaDecimalFormat, type JsonSchemaEnum, type JsonSchemaInteger, type JsonSchemaIntegerFormat, type JsonSchemaKeywords, type JsonSchemaLike, type JsonSchemaLiteral, type JsonSchemaLogicKeywords, type JsonSchemaMap, type JsonSchemaMetadataKeywords, type JsonSchemaNativeEnum, type JsonSchemaNever, type JsonSchemaNull, type JsonSchemaNullable, type JsonSchemaNumber, type JsonSchemaNumberFormat, type JsonSchemaObject, type JsonSchemaOf, type JsonSchemaPrimitiveType, type JsonSchemaPrimitiveUnion, type JsonSchemaRecord, type JsonSchemaRecordPropertyNames, type JsonSchemaRef, type JsonSchemaSchemaSource, type JsonSchemaSet, type JsonSchemaString, type JsonSchemaStringFormat, type JsonSchemaTuple, type JsonSchemaType, JsonSchemaTypeNames, type JsonSchemaUndefined, type JsonSchemaUnion, type JsonSchemaUnknown, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, type SchemaConfig, type SchemaConfigVariant, type SchemaEnvelope, type SchemaEnvelopeOf, type SchemaSource, type SchemaSourceConfig, type SchemaSourceVariant, type SpecOf, type StandardSchemaSchemaSource, type UntypedConfigObject, type UntypedSchema, type UntypedSchemaSource, type ValibotSchema, type ValibotSchemaSource, type Zod3SchemaSource, addProperty, applyJsonSchemaMetadata, bundleReferences, createStoragePromises, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant, getJsonSchema, getJsonSchemaObject, getPrimarySchemaType, getProperties, getPropertiesList, getProperty, isFileReference, isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isPropertyOptional, isSchema, isSchemaNullable, isSchemaObject, isSchemaOf, isSchemaWithSource, isStandardSchema, isUntypedConfig, isUntypedConfigStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaConfigFile, mapStorageToFileSystem, merge, mergeMetadata, normalizeKey, readSchemaTypes, traverseSchema };
|
|
619
631
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./constants-lk1mMbgx.mjs";import{$ as s,A as c,B as ee,C as te,D as ne,E as re,F as l,G as u,H as ie,I as ae,J as d,K as f,L as oe,M as se,N as ce,O as le,P as ue,Q as de,R as fe,S as pe,T as me,U as he,V as ge,W as _e,X as p,Y as ve,Z as m,_ as ye,a as be,b as h,c as xe,d as Se,et as g,f as Ce,g as _,h as v,i as we,j as Te,k as Ee,l as De,m as Oe,n as y,nt as b,o as x,p as S,q as C,r as w,rt as T,s as ke,t as Ae,tt as E,u as je,v as Me,w as Ne,x as Pe,y as Fe,z as Ie}from"./helpers-Bh_V7xwV.mjs";import{extractFileReference as D}from"@stryke/convert/extract-file-reference";import{murmurhash as O}from"@stryke/hash";import{deepClone as Le}from"@stryke/helpers/deep-clone";import{isStandardJsonSchema as k}from"@stryke/json";import{findFileExtensionSafe as Re}from"@stryke/path/find";import{VALID_OBJECT_SOURCE_EXTENSIONS as A}from"@stryke/resolve/constants";import{loadSafe as ze}from"@stryke/resolve/load";import{list as Be}from"@stryke/string-format/list";import{isSetString as j}from"@stryke/type-checks";import{isSetObject as M}from"@stryke/type-checks/is-set-object";import{extractJsonSchema as Ve,isZod3Type as N}from"@stryke/zod";import{toJsonSchema as He}from"@valibot/to-json-schema";import{createGenerator as Ue}from"ts-json-schema-generator/dist/factory/generator.js";const P=`https://power-plant.invalid/`;function We(e){return!(!M(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e)}function F(e){return We(e)?e.schema:e}function I(e){return e.endsWith(`#`)?e.slice(0,-1):e}function L(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function Ge(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function Ke(e){return e.length===0?``:`/${e.map(e=>Ge(e)).join(`/`)}`}function R(e,t){try{return I(new URL(e,t).toString())}catch{return I(e)}}function z(e,t,n,r,i){if(!M(e))return;let a=e,o=Ke(t),s=j(a.$id)?R(a.$id,n):n,c=L(s);if(r.set(s,o),r.set(c,o),j(a.$anchor)&&r.set(`${c}#${a.$anchor}`,o),j(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)=>{z(n,[...t,e,String(a)],s,r,i)});continue}z(n,[...t,e],s,r,i)}}function B(e,t,n,r,i){if(!M(e))return;let a=e,o=j(a.$id)?R(a.$id,n):n;if(j(a.$ref)){let e=R(a.$ref,o),t=r.get(e)??r.get(L(e));t!==void 0&&(a.$ref=t.length>0?`#${t}`:`#`)}if(j(a.$dynamicRef)){let e=R(a.$dynamicRef,o),t=i.get(e);if(t)a.$dynamicRef=t;else{let t=r.get(e)??r.get(L(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)=>{B(n,[...t,e,String(a)],o,r,i)});continue}B(n,[...t,e],o,r,i)}}function V(e){if(!M(e))return e;let t=Le(e),n=j(t.$id)?R(t.$id,P):P,r=new Map,i=new Map;return z(t,[],n,r,i),B(t,[],n,r,i),t}function H(e){if(E(e))return W(e);if(M(e)){if(s(e))return G(e);let t=e;if(`$schema`in t&&E(t.$schema))return W(t.$schema)}return e}function qe(e){return Array.isArray(e)?e.map(e=>H(e)):e}function U(e){return He(e,{target:`draft-2020-12`})}function W(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`&&j(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!M(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,H(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=H(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=qe(r);continue}n[e]=r}return n}function G(e){let t=e,n=E(t.$schema)?W(t.$schema):{},r={};for(let[e,n]of Object.entries(t)){if(e.startsWith(`$`)||!M(n))continue;if(s(n)){r[e]=G(n);continue}let t=n;if(`$schema`in t&&E(t.$schema)){r[e]=W(t.$schema);continue}E(n)&&(r[e]=W(n))}if(!l(n))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let i={...M(n.properties)?n.properties:{},...r};return{...n,type:n.type??`object`,...Object.keys(i).length>0?{properties:i}:{}}}function K(e,t){let n=F(t);if(m(n)||d(n))return O({variant:e,input:n.schema});if(j(n)||typeof n==`boolean`)return O({variant:e,input:n});if(M(n)){if(N(n))return O({variant:e,input:n._def});if(k(n))return O({variant:e,input:n[`~standard`]});if(_(n))return O({variant:e,input:n});if(T(n))return O({variant:e,input:U(n)});if(s(n))return O({variant:e,input:G(n)});if(E(n))return O({variant:e,input:W(n)})}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 q(e){if(M(e)){if(N(e))return Ve(e,{target:`draft-2020-12`});if(g(e))return G(e);if(b(e))return W(e);if(k(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(T(e))return U(e);if(_(e))return e}}function J(e){if(M(e)){if(N(e))return`zod3`;if(g(e)||b(e))return`untyped`;if(k(e))return`standard-schema`;if(_(e))return`json-schema`;if(T(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 Y(e){let t=F(e);return m(t)||d(t)?t.variant:j(t)||v(t)?`file-reference`:J(t)}async function X(e,t){if(m(e))return e.schema;let n=t??J(e),r;if((n===`zod3`||n===`json-schema`||n===`standard-schema`||n===`untyped`||n===`valibot`)&&(r=q(e)),r)return V(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 Z(e,t){if(e===`zod3`)return{hash:K(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:K(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:K(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:K(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:K(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=D(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 Ue({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 $(e,t={}){let n=F(e);if(m(n))return n;if(d(n))return{...n,source:{hash:K(`json-schema`,n.schema),variant:`json-schema`,schema:n.schema}};let r,i=Y(n),a=K(i,n);if(i===`file-reference`){let e=D(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 i=Re(e.file);if(i&&!A.includes(i))throw Error(`The provided schema file input "${e.file}" has an invalid file extension (.${i}). Please ensure that the file has one of the following extensions: ${Be(A,{conjunction:`or`})}.`);let a=await ze(n,t);a??=await Q(n,t);let o=F(a);r=m(o)?o.source:d(o)?{hash:K(`json-schema`,o.schema),variant:`json-schema`,schema:o.schema}:Z(J(o),o)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(i))r=Z(i,n);else throw Error(`Invalid schema definition input "${i}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);return{variant:i,source:r,schema:await X(r.schema,r.variant),hash:a}}async function Je(e,t={}){let n=F(e);if(m(n)||p(n))return n;let r=await $(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{o as JSON_SCHEMA_METADATA_KEYS,n as JSON_SCHEMA_PRIMITIVE_TYPES,i as JSON_SCHEMA_TYPES,t as JsonSchemaTypeNames,e as SCHEMA_ARRAY_CONCAT_KEYWORDS,r as SCHEMA_RECORD_KEYWORDS,a as SCHEMA_SINGLE_KEYWORDS,Ae as addProperty,Ce as applyJsonSchemaMetadata,V as bundleReferences,Je as extract,K as extractHash,q as extractJsonSchema,J as extractResolvedVariant,X as extractSchema,$ as extractSchemaWithSource,Z as extractSource,Q as extractTSType,Y as extractVariant,y as getJsonSchema,w as getJsonSchemaObject,S as getPrimarySchemaType,we as getProperties,be as getPropertiesList,x as getProperty,v as isFileReference,_ as isJsonSchema,ye as isJsonSchemaAllOf,Me as isJsonSchemaAny,Fe as isJsonSchemaAnyOf,h as isJsonSchemaArray,Pe as isJsonSchemaBigint,pe as isJsonSchemaBoolean,te as isJsonSchemaDate,Ne as isJsonSchemaDecimal,me as isJsonSchemaEnum,re as isJsonSchemaInteger,ne as isJsonSchemaKeywords,le as isJsonSchemaLiteral,Ee as isJsonSchemaMap,c as isJsonSchemaNativeEnum,Te as isJsonSchemaNever,se as isJsonSchemaNull,ce as isJsonSchemaNullable,ue as isJsonSchemaNumber,l as isJsonSchemaObject,ae as isJsonSchemaPrimitiveType,oe as isJsonSchemaPrimitiveUnion,fe as isJsonSchemaRecord,Ie as isJsonSchemaRef,ee as isJsonSchemaSet,ge as isJsonSchemaString,ie as isJsonSchemaTuple,he as isJsonSchemaType,_e as isJsonSchemaUndefined,u as isJsonSchemaUnion,f as isJsonSchemaUnknown,C as isNullOnlyJsonSchema,ke as isPropertyOptional,d as isSchema,xe as isSchemaNullable,ve as isSchemaObject,p as isSchemaOf,m as isSchemaWithSource,de as isStandardSchema,s as isUntypedConfig,g as isUntypedConfigStrict,E as isUntypedSchema,b as isUntypedSchemaStrict,T as isValibotSchema,De as isValidSchemaConfigFile,je as merge,Se as mergeMetadata,Oe as readSchemaTypes};
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./constants-lk1mMbgx.mjs";import{n as s,r as c,t as l}from"./storage-BccFP9xn.mjs";import{$ as ee,A as te,B as ne,C as re,D as u,E as d,F as ie,G as ae,H as oe,I as f,J as se,K as ce,L as le,M as ue,N as de,O as fe,P as pe,Q as p,R as me,S as he,T as ge,U as _e,V as ve,W as ye,X as be,Y as m,Z as h,_ as g,a as xe,b as Se,c as Ce,d as we,et as _,f as Te,g as v,h as Ee,i as De,it as y,j as Oe,k as ke,l as b,m as x,n as S,nt as C,o as w,p as Ae,q as je,r as Me,rt as T,s as Ne,t as Pe,tt as E,u as Fe,v as Ie,w as Le,x as Re,y as ze,z as Be}from"./helpers-kU9GDXDZ.mjs";import{extractFileReference as D}from"@stryke/convert/extract-file-reference";import{murmurhash as O}from"@stryke/hash";import{deepClone as Ve}from"@stryke/helpers/deep-clone";import{isStandardJsonSchema as k}from"@stryke/json";import{findFileExtensionSafe as He}from"@stryke/path/find";import{VALID_OBJECT_SOURCE_EXTENSIONS as A}from"@stryke/resolve/constants";import{loadSafe as Ue}from"@stryke/resolve/load";import{list as We}from"@stryke/string-format/list";import{isSetString as j}from"@stryke/type-checks";import{isSetObject as M}from"@stryke/type-checks/is-set-object";import{extractJsonSchema as Ge,isZod3Type as N}from"@stryke/zod";import{toJsonSchema as Ke}from"@valibot/to-json-schema";import{createGenerator as qe}from"ts-json-schema-generator/dist/factory/generator.js";const P=`https://power-plant.invalid/`;function Je(e){return!(!M(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e)}function F(e){return Je(e)?e.schema:e}function I(e){return e.endsWith(`#`)?e.slice(0,-1):e}function L(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function Ye(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function Xe(e){return e.length===0?``:`/${e.map(e=>Ye(e)).join(`/`)}`}function R(e,t){try{return I(new URL(e,t).toString())}catch{return I(e)}}function z(e,t,n,r,i){if(!M(e))return;let a=e,o=Xe(t),s=j(a.$id)?R(a.$id,n):n,c=L(s);if(r.set(s,o),r.set(c,o),j(a.$anchor)&&r.set(`${c}#${a.$anchor}`,o),j(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)=>{z(n,[...t,e,String(a)],s,r,i)});continue}z(n,[...t,e],s,r,i)}}function B(e,t,n,r,i){if(!M(e))return;let a=e,o=j(a.$id)?R(a.$id,n):n;if(j(a.$ref)){let e=R(a.$ref,o),t=r.get(e)??r.get(L(e));t!==void 0&&(a.$ref=t.length>0?`#${t}`:`#`)}if(j(a.$dynamicRef)){let e=R(a.$dynamicRef,o),t=i.get(e);if(t)a.$dynamicRef=t;else{let t=r.get(e)??r.get(L(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)=>{B(n,[...t,e,String(a)],o,r,i)});continue}B(n,[...t,e],o,r,i)}}function V(e){if(!M(e))return e;let t=Ve(e),n=j(t.$id)?R(t.$id,P):P,r=new Map,i=new Map;return z(t,[],n,r,i),B(t,[],n,r,i),t}function H(e){if(C(e))return W(e);if(M(e)){if(_(e))return G(e);let t=e;if(`$schema`in t&&C(t.$schema))return W(t.$schema)}return e}function Ze(e){return Array.isArray(e)?e.map(e=>H(e)):e}function U(e){return Ke(e,{target:`draft-2020-12`})}function W(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`&&j(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!M(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,H(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=H(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=Ze(r);continue}n[e]=r}return n}function G(e){let t=e,n=C(t.$schema)?W(t.$schema):{},r={};for(let[e,n]of Object.entries(t)){if(e.startsWith(`$`)||!M(n))continue;if(_(n)){r[e]=G(n);continue}let t=n;if(`$schema`in t&&C(t.$schema)){r[e]=W(t.$schema);continue}C(n)&&(r[e]=W(n))}if(!f(n))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let i={...M(n.properties)?n.properties:{},...r};return{...n,type:n.type??`object`,...Object.keys(i).length>0?{properties:i}:{}}}function K(e,t){let n=F(t);if(p(n)||m(n))return O({variant:e,input:n.schema});if(j(n)||typeof n==`boolean`)return O({variant:e,input:n});if(M(n)){if(N(n))return O({variant:e,input:n._def});if(k(n))return O({variant:e,input:n[`~standard`]});if(g(n))return O({variant:e,input:n});if(y(n))return O({variant:e,input:U(n)});if(_(n))return O({variant:e,input:G(n)});if(C(n))return O({variant:e,input:W(n)})}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 q(e){if(M(e)){if(N(e))return Ge(e,{target:`draft-2020-12`});if(E(e))return G(e);if(T(e))return W(e);if(k(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(y(e))return U(e);if(g(e))return e}}function J(e){if(M(e)){if(N(e))return`zod3`;if(E(e)||T(e))return`untyped`;if(k(e))return`standard-schema`;if(g(e))return`json-schema`;if(y(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 Y(e){let t=F(e);return p(t)||m(t)?t.variant:j(t)||v(t)?`file-reference`:J(t)}async function X(e,t){if(p(e))return e.schema;let n=t??J(e),r;if((n===`zod3`||n===`json-schema`||n===`standard-schema`||n===`untyped`||n===`valibot`)&&(r=q(e)),r)return V(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 Z(e,t){if(e===`zod3`)return{hash:K(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:K(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:K(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:K(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:K(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=D(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 qe({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 $(e,t={}){let n=F(e);if(p(n))return n;if(m(n))return{...n,source:{hash:K(`json-schema`,n.schema),variant:`json-schema`,schema:n.schema}};let r,i=Y(n),a=K(i,n);if(i===`file-reference`){let e=D(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 i=He(e.file);if(i&&!A.includes(i))throw Error(`The provided schema file input "${e.file}" has an invalid file extension (.${i}). Please ensure that the file has one of the following extensions: ${We(A,{conjunction:`or`})}.`);let a;t.storage&&(a=l(t.storage));let o=await Ue(n,{...t,fs:a});o??=await Q(n,{...t,fs:a});let s=F(o);r=p(s)?s.source:m(s)?{hash:K(`json-schema`,s.schema),variant:`json-schema`,schema:s.schema}:Z(J(s),s)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(i))r=Z(i,n);else throw Error(`Invalid schema definition input "${i}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);return{variant:i,source:r,schema:await X(r.schema,r.variant),hash:a}}async function Qe(e,t={}){let n=F(e);if(p(n)||h(n))return n;let r=await $(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{o as JSON_SCHEMA_METADATA_KEYS,n as JSON_SCHEMA_PRIMITIVE_TYPES,i as JSON_SCHEMA_TYPES,t as JsonSchemaTypeNames,e as SCHEMA_ARRAY_CONCAT_KEYWORDS,r as SCHEMA_RECORD_KEYWORDS,a as SCHEMA_SINGLE_KEYWORDS,Pe as addProperty,Ae as applyJsonSchemaMetadata,V as bundleReferences,s as createStoragePromises,Qe as extract,K as extractHash,q as extractJsonSchema,J as extractResolvedVariant,X as extractSchema,$ as extractSchemaWithSource,Z as extractSource,Q as extractTSType,Y as extractVariant,S as getJsonSchema,Me as getJsonSchemaObject,x as getPrimarySchemaType,De as getProperties,xe as getPropertiesList,w as getProperty,v as isFileReference,g as isJsonSchema,Ie as isJsonSchemaAllOf,ze as isJsonSchemaAny,Se as isJsonSchemaAnyOf,Re as isJsonSchemaArray,he as isJsonSchemaBigint,re as isJsonSchemaBoolean,Le as isJsonSchemaDate,ge as isJsonSchemaDecimal,d as isJsonSchemaEnum,u as isJsonSchemaInteger,fe as isJsonSchemaKeywords,ke as isJsonSchemaLiteral,te as isJsonSchemaMap,Oe as isJsonSchemaNativeEnum,ue as isJsonSchemaNever,de as isJsonSchemaNull,pe as isJsonSchemaNullable,ie as isJsonSchemaNumber,f as isJsonSchemaObject,le as isJsonSchemaPrimitiveType,me as isJsonSchemaPrimitiveUnion,Be as isJsonSchemaRecord,ne as isJsonSchemaRef,ve as isJsonSchemaSet,oe as isJsonSchemaString,_e as isJsonSchemaTuple,ye as isJsonSchemaType,ae as isJsonSchemaUndefined,ce as isJsonSchemaUnion,je as isJsonSchemaUnknown,se as isNullOnlyJsonSchema,Ne as isPropertyOptional,m as isSchema,Ce as isSchemaNullable,be as isSchemaObject,h as isSchemaOf,p as isSchemaWithSource,ee as isStandardSchema,_ as isUntypedConfig,E as isUntypedConfigStrict,C as isUntypedSchema,T as isUntypedSchemaStrict,y as isValibotSchema,b as isValidSchemaConfigFile,l as mapStorageToFileSystem,Fe as merge,we as mergeMetadata,c as normalizeKey,Ee as readSchemaTypes,Te as traverseSchema};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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));Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../storage-CgfRQlqS.cjs");exports.createStoragePromises=e.n,exports.mapStorageToFileSystem=e.t,exports.normalizeKey=e.r;
|