@power-plant/schema 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/codegen.cjs +6 -6
- package/dist/codegen.d.cts +1 -1
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.mjs +4 -4
- package/dist/constants-CjTQhR-l.cjs +1 -0
- package/dist/{constants.mjs → constants-lk1mMbgx.mjs} +2 -2
- package/dist/constants-lk1mMbgx.mjs.map +1 -0
- package/dist/helpers-BIaA3COd.cjs +1 -0
- package/dist/helpers-kU9GDXDZ.mjs +2 -0
- package/dist/helpers-kU9GDXDZ.mjs.map +1 -0
- package/dist/index-1pJbUu8F.d.mts +38 -0
- package/dist/index-1pJbUu8F.d.mts.map +1 -0
- package/dist/index-M6wCzIr6.d.cts +38 -0
- package/dist/index-M6wCzIr6.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +628 -31
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +628 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -0
- package/dist/rolldown-runtime-CMqjfN_6.cjs +1 -0
- package/dist/storage/index.cjs +1 -0
- package/dist/storage/index.d.cts +2 -0
- package/dist/storage/index.d.mts +2 -0
- package/dist/storage/index.mjs +1 -0
- package/dist/storage-BccFP9xn.mjs +2 -0
- package/dist/storage-BccFP9xn.mjs.map +1 -0
- package/dist/storage-CgfRQlqS.cjs +1 -0
- package/dist/{types.d.cts → types-CCLUrmYp.d.cts} +86 -21
- package/dist/types-CCLUrmYp.d.cts.map +1 -0
- package/dist/{types.d.mts → types-J67fcIar.d.mts} +87 -22
- package/dist/types-J67fcIar.d.mts.map +1 -0
- package/dist/valibot.cjs +1 -0
- package/dist/valibot.d.cts +14 -0
- package/dist/valibot.d.cts.map +1 -0
- package/dist/valibot.d.mts +14 -0
- package/dist/valibot.d.mts.map +1 -0
- package/dist/valibot.mjs +2 -0
- package/dist/valibot.mjs.map +1 -0
- package/dist/zod.cjs +1 -0
- package/dist/zod.d.cts +23 -0
- package/dist/zod.d.cts.map +1 -0
- package/dist/zod.d.mts +23 -0
- package/dist/zod.d.mts.map +1 -0
- package/dist/zod.mjs +2 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +38 -88
- package/dist/constants-lihlIQu7.d.cts +0 -31
- package/dist/constants-lihlIQu7.d.cts.map +0 -1
- package/dist/constants-lihlIQu7.d.mts +0 -31
- package/dist/constants-lihlIQu7.d.mts.map +0 -1
- package/dist/constants.cjs +0 -1
- package/dist/constants.d.cts +0 -2
- package/dist/constants.d.mts +0 -2
- package/dist/constants.mjs.map +0 -1
- package/dist/extract.cjs +0 -1
- package/dist/extract.d.cts +0 -135
- package/dist/extract.d.cts.map +0 -1
- package/dist/extract.d.mts +0 -135
- package/dist/extract.d.mts.map +0 -1
- package/dist/extract.mjs +0 -2
- package/dist/extract.mjs.map +0 -1
- package/dist/helpers.cjs +0 -1
- package/dist/helpers.d.cts +0 -134
- package/dist/helpers.d.cts.map +0 -1
- package/dist/helpers.d.mts +0 -134
- package/dist/helpers.d.mts.map +0 -1
- package/dist/helpers.mjs +0 -2
- package/dist/helpers.mjs.map +0 -1
- package/dist/metadata.cjs +0 -1
- package/dist/metadata.d.cts +0 -31
- package/dist/metadata.d.cts.map +0 -1
- package/dist/metadata.d.mts +0 -31
- package/dist/metadata.d.mts.map +0 -1
- package/dist/metadata.mjs +0 -2
- package/dist/metadata.mjs.map +0 -1
- package/dist/type-checks.cjs +0 -1
- package/dist/type-checks.d.cts +0 -331
- package/dist/type-checks.d.cts.map +0 -1
- package/dist/type-checks.d.mts +0 -331
- package/dist/type-checks.d.mts.map +0 -1
- package/dist/type-checks.mjs +0 -2
- package/dist/type-checks.mjs.map +0 -1
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/types.mjs +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/extract.ts","../src/helpers.ts","../src/metadata.ts","../src/type-checks.ts"],"mappings":""}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import"./types.mjs";import{JSON_SCHEMA_METADATA_KEYS as e,JSON_SCHEMA_PRIMITIVE_TYPES as t,JSON_SCHEMA_TYPES as n,JsonSchemaTypeNames as r,SCHEMA_ARRAY_CONCAT_KEYWORDS as i,SCHEMA_RECORD_KEYWORDS as a,SCHEMA_SINGLE_KEYWORDS as o}from"./constants.mjs";import{isFileReference as s,isJsonSchema as c,isJsonSchemaAllOf as l,isJsonSchemaAny as u,isJsonSchemaAnyOf as d,isJsonSchemaArray as f,isJsonSchemaBigint as p,isJsonSchemaBoolean as m,isJsonSchemaDate as h,isJsonSchemaDecimal as g,isJsonSchemaEnum as _,isJsonSchemaInteger as v,isJsonSchemaKeywords as y,isJsonSchemaLiteral as b,isJsonSchemaMap as x,isJsonSchemaNativeEnum as S,isJsonSchemaNever as C,isJsonSchemaNull as w,isJsonSchemaNullable as T,isJsonSchemaNumber as E,isJsonSchemaObject as D,isJsonSchemaPrimitiveType as O,isJsonSchemaPrimitiveUnion as k,isJsonSchemaRecord as A,isJsonSchemaRef as j,isJsonSchemaSet as M,isJsonSchemaString as N,isJsonSchemaTuple as P,isJsonSchemaType as F,isJsonSchemaUndefined as I,isJsonSchemaUnion as L,isJsonSchemaUnknown as R,isNullOnlyJsonSchema as z,isSchema as B,isSchemaObject as V,isSchemaOf as H,isSchemaWithSource as U,isStandardSchema as W,isUntypedInput as G,isUntypedInputStrict as K,isUntypedSchema as q,isUntypedSchemaStrict as J,isValibotSchema as Y}from"./type-checks.mjs";import{applyJsonSchemaMetadata as X,getPrimarySchemaType as Z,readSchemaTypes as Q}from"./metadata.mjs";import{addProperty as $,getJsonSchema as ee,getJsonSchemaObject as te,getProperties as ne,getPropertiesList as re,getProperty as ie,isPropertyOptional as ae,isSchemaNullable as oe,isValidSchemaInputFile as se,merge as ce,mergeMetadata as le}from"./helpers.mjs";import{generateParserCode as ue,getJsonSchemaType as de,stringifyType as fe,stringifyValue as pe}from"./codegen.mjs";import{bundleReferences as me,extract as he,extractHash as ge,extractJsonSchema as _e,extractResolvedVariant as ve,extractSchema as ye,extractSchemaWithSource as be,extractSource as xe,extractTSType as Se,extractVariant as Ce}from"./extract.mjs";export{e as JSON_SCHEMA_METADATA_KEYS,t as JSON_SCHEMA_PRIMITIVE_TYPES,n as JSON_SCHEMA_TYPES,r as JsonSchemaTypeNames,i as SCHEMA_ARRAY_CONCAT_KEYWORDS,a as SCHEMA_RECORD_KEYWORDS,o as SCHEMA_SINGLE_KEYWORDS,$ as addProperty,X as applyJsonSchemaMetadata,me as bundleReferences,he as extract,ge as extractHash,_e as extractJsonSchema,ve as extractResolvedVariant,ye as extractSchema,be as extractSchemaWithSource,xe as extractSource,Se as extractTSType,Ce as extractVariant,ue as generateParserCode,ee as getJsonSchema,te as getJsonSchemaObject,de as getJsonSchemaType,Z as getPrimarySchemaType,ne as getProperties,re as getPropertiesList,ie as getProperty,s as isFileReference,c as isJsonSchema,l as isJsonSchemaAllOf,u as isJsonSchemaAny,d as isJsonSchemaAnyOf,f as isJsonSchemaArray,p as isJsonSchemaBigint,m as isJsonSchemaBoolean,h as isJsonSchemaDate,g as isJsonSchemaDecimal,_ as isJsonSchemaEnum,v as isJsonSchemaInteger,y as isJsonSchemaKeywords,b as isJsonSchemaLiteral,x as isJsonSchemaMap,S as isJsonSchemaNativeEnum,C as isJsonSchemaNever,w as isJsonSchemaNull,T as isJsonSchemaNullable,E as isJsonSchemaNumber,D as isJsonSchemaObject,O as isJsonSchemaPrimitiveType,k as isJsonSchemaPrimitiveUnion,A as isJsonSchemaRecord,j as isJsonSchemaRef,M as isJsonSchemaSet,N as isJsonSchemaString,P as isJsonSchemaTuple,F as isJsonSchemaType,I as isJsonSchemaUndefined,L as isJsonSchemaUnion,R as isJsonSchemaUnknown,z as isNullOnlyJsonSchema,ae as isPropertyOptional,B as isSchema,oe as isSchemaNullable,V as isSchemaObject,H as isSchemaOf,U as isSchemaWithSource,W as isStandardSchema,G as isUntypedInput,K as isUntypedInputStrict,q as isUntypedSchema,J as isUntypedSchemaStrict,Y as isValibotSchema,se as isValidSchemaInputFile,ce as merge,le as mergeMetadata,Q as readSchemaTypes,fe as stringifyType,pe as stringifyValue};
|
|
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
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"../storage-BccFP9xn.mjs";export{e as createStoragePromises,n as mapStorageToFileSystem,t as normalizeKey};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EventEmitter as e}from"node:events";import*as t from"node:fs";import{Stats as n,constants as r}from"node:fs";import{callbackify as i}from"node:util";import{Buffer as a}from"node:buffer";import{MessageChannel as o,receiveMessageOnPort as s}from"node:worker_threads";import{Readable as c,Writable as l}from"node:stream";function u(e){return e instanceof URL?decodeURIComponent(e.pathname):a.isBuffer(e)?e.toString():e}function d(e){let t=u(e).replace(/\\/g,`/`);for(;t.startsWith(`./`);)t=t.slice(2);return t=t.replace(/^\/+/,``),t=t.replace(/\/+/g,`/`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function f(...e){let t=[];for(let n of e)for(let e of d(n).split(`/`))if(!(!e||e===`.`)){if(e===`..`){t.pop();continue}t.push(e)}return t.join(`/`)}function p(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function m(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function h(e){return e.endsWith(`$`)}function g(e){return e?`${e}/`:``}function _(e,t){let n=g(e),r=new Set;for(let e of t){if(h(e))continue;let t=n?e.startsWith(n)?e.slice(n.length):``:e;if(!t||t===e)continue;let i=t.indexOf(`/`);r.add(i===-1?t:t.slice(0,i))}return[...r].sort()}function v(e,t,n,r){let i=n?` '${n}'`:``,a=Error(r??`${e}: ${t}${i}`);return a.code=e,a.syscall=t,n&&(a.path=n),a}function y(e){let{port1:t,port2:n}=new o;e().then(e=>{t.postMessage({ok:!0,value:e})},e=>{t.postMessage({ok:!1,error:e})});let r=s(n);if(t.close(),n.close(),!r)throw Error(`Storage operation did not complete.`);if(!r.message.ok)throw r.message.error;return r.message.value}function b(e){return e==null?a.alloc(0):a.isBuffer(e)?e:(e instanceof Uint8Array,a.from(e))}function x(e){if(typeof e==`string`)return e;if(e!=null)return e.encoding??void 0}function S(e){let t=x(e);return t==null||t===`buffer`}function C(e,t){let n=b(typeof e==`string`||a.isBuffer(e)||e instanceof Uint8Array?e:e==null?``:JSON.stringify(e));return t==null||t===`buffer`?n:n.toString(t)}function w(e){return typeof e==`string`?e:b(a.from(e.buffer,e.byteOffset,e.byteLength))}function T(e,t,r=0){let i=Date.now(),a=t?.atime instanceof Date?t.atime:new Date(i),o=t?.mtime instanceof Date?t.mtime:new Date(i),s=e===`directory`?16877:e===`symlink`?41471:33188,c=Object.create(n.prototype);return Object.assign(c,{dev:0,ino:0,mode:s,nlink:1,uid:typeof t?.uid==`number`?t.uid:0,gid:typeof t?.gid==`number`?t.gid:0,rdev:0,size:r,blksize:4096,blocks:Math.ceil(r/512),atimeMs:a.getTime(),mtimeMs:o.getTime(),ctimeMs:o.getTime(),birthtimeMs:o.getTime(),atime:a,mtime:o,ctime:o,birthtime:o}),c}function E(e,t){return RegExp(`^${e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`.*`).replace(/\*/g,`[^/]*`).replace(/\?/g,`.`)}$`).test(t)}function D(e=6){return Array.from({length:e},()=>`abcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*36))).join(``)}const O=`symlinkTarget`;function k(e){let t=new Map,i=3;async function o(t){try{return await e.getMeta(t)??null}catch{return null}}async function s(t,n=!0){let r=d(t);if(!r&&t!==`.`&&t!==`/`)return null;let i=await o(r);return i?.[O]&&typeof i[O]==`string`?n?s(i[O],!0):{key:r,type:`symlink`,meta:i}:await e.hasItem(r)?{key:r,type:`file`,meta:i}:_(r,(await e.getKeys(r)).filter(e=>e!==r&&!h(e))).length>0?{key:r,type:`directory`,meta:i}:null}async function u(e,t=!0){let n=await s(e,t);if(!n)throw v(`ENOENT`,`stat`,d(e));return n}async function k(t){let n=await o(t);if(typeof n?.size==`number`)return n.size;if(S()){let n=await e.getItemRaw(t);return n==null?0:b(n).byteLength}let r=await e.getItem(t);return r==null?0:b(String(r)).byteLength}async function A(t,n){let r=d(t);if((await u(r,!0)).type!==`file`)throw v(`EISDIR`,`read`,r,`EISDIR: illegal operation on a directory, read`);let i=x(n),a=S(n)?await e.getItemRaw(r):await e.getItem(r);if(a==null)throw v(`ENOENT`,`open`,r);return C(a,i)}async function j(t,n,r){let i=d(t),a=x(r),o=typeof n==`string`?n:a&&a!==`buffer`?b(w(n)).toString(a):w(n);await e.setItem(i,o),await e.setMeta(i,{mtime:new Date,atime:new Date,size:b(o).byteLength})}async function M(t,n){let r=d(t),i=await s(r,!1);if(!i){if(typeof n==`object`&&n&&`recursive`in n&&n.recursive)return;throw v(`ENOENT`,`unlink`,r)}if(i.type===`directory`){let t=n===!0||(typeof n==`object`&&n&&`recursive`in n?!!n.recursive:!1),i=(await e.getKeys(r)).filter(e=>e!==r&&!h(e)&&e.startsWith(g(r)));if(!t&&i.length>0)throw v(`ENOTEMPTY`,`rmdir`,r);await Promise.all(i.map(async t=>e.removeItem(t))),await e.hasItem(r)&&await e.removeItem(r);return}await e.removeItem(r)}async function N(t,n,r=!1){if((await u(t,!0)).type===`directory`){if(!r)throw v(`EISDIR`,`copy`,t,`EISDIR: illegal operation on a directory, copy`);let i=await e.getKeys(t);for(let e of i)h(e)||e===t||await N(e,f(n,e.slice(t.length).replace(/^\//,``)),!0);return}let i=await A(t);await j(n,typeof i==`string`?i:b(i));let a=await o(t);a&&await e.setMeta(d(n),a)}async function P(e,t=!0){let n=await u(e,t),r=n.type===`file`?await k(n.key):4096;return T(n.type,n.meta,r)}async function F(t,n){let r=d(t);await u(r,!0),await e.setMeta(r,{mode:n})}async function I(t,n,r){let i=d(t);await u(i,!0),await e.setMeta(i,{uid:n,gid:r})}async function L(e,t){let n=d(e),r=typeof t==`object`&&t?!!t.recursive:!1;if(!n)return;let i=p(n);if(i){let e=await s(i,!0);if(!e&&!r)throw v(`ENOENT`,`mkdir`,n);!e&&r&&await L(i,{recursive:!0})}if((await s(n,!0))?.type===`file`)throw v(`EEXIST`,`mkdir`,n)}async function R(e,t){let n=`${d(e)}${D()}`;return await L(n,{recursive:!0}),t?.encoding===`buffer`?a.from(n):n}function z(t,n){let r=d(t),i=[],o=!1,s=0,c=!1,l=async()=>{if(o)return;await u(r,!0);let t=await e.getKeys(r);i=_(r,t.filter(e=>!h(e))),o=!0},f=e=>({name:e,isFile:()=>!0,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1});return{path:r,async read(){if(c)throw v(`EBADF`,`readdir`,r);if(await l(),s>=i.length)return null;let e=i[s++];return n?.encoding===`buffer`?a.from(e):f(e)},async close(){c=!0},async*[Symbol.asyncIterator](){for(;;){let e=await this.read();if(!e)break;yield e}}}}function B(e,t){let n=d(e),r=t?.start??0,i=t?.end;return c.from((async function*(){let e=b(await A(n));if(r>0&&(e=e.subarray(r)),i!=null){yield e.subarray(0,Math.max(0,i-r+1));return}yield e})())}function V(e,t){let n=d(e),r=[];return new l({write(e,t,n){r.push(b(e)),n()},final:e=>{let i=a.concat(r),o=t?.encoding&&t.encoding!==`buffer`?i.toString(t.encoding):i;j(n,o,t).then(()=>e()).catch(t=>e(t))}})}function H(n,r){let i=()=>{let e=t.get(n);if(!e)throw v(`EBADF`,`read`,r);return e};return{fd:n,async appendFile(e,t){let n=await A(r).catch(()=>a.alloc(0));await j(r,a.concat([b(n),b(typeof e==`string`?e:w(e))]),t)},async chmod(e){},async chown(e,t){},async close(){t.delete(n)},createReadStream(e){return B(r,e)},createWriteStream(e){return V(r,e)},async datasync(){},async read(e,t,n,a){let o=i(),s=b(await A(r,{encoding:void 0})),c=a??o.position,l=t??0,u=n??e.length-l,d=s.copy(e,l,c,c+u);return a??(o.position+=d),{bytesRead:d,buffer:e}},async readFile(e){return A(r,e)},async stat(e){return P(r)},async sync(){},async truncate(e=0){await j(r,b(await A(r)).subarray(0,e))},async utimes(t,n){await e.setMeta(r,{atime:new Date(t),mtime:new Date(n)})},async write(e,t,n,a){let o=i(),s=b(await A(r).catch(()=>``)),c=t??0,l=n??e.length-c,u=a??o.position;return e.copy(s,u,c,c+l),await j(r,s),a??(o.position+=l),{bytesWritten:l,buffer:e}},async writeFile(e,t){await j(r,typeof e==`string`?e:w(e),t)}}}let U={async access(e,t=r.F_OK){let n=await s(e,!0);if(!n)throw v(`ENOENT`,`access`,d(e));if(t&r.W_OK&&n.type===`directory`)throw v(`EISDIR`,`access`,d(e))},async appendFile(e,t,n){let r=d(e),i=await A(r).catch(()=>``);await j(r,a.concat([b(i),b(typeof t==`string`?t:w(t))]),n)},async chmod(t,n){let r=d(t);await u(r,!0),await e.setMeta(r,{mode:n})},async chown(t,n,r){let i=d(t);await u(i,!0),await e.setMeta(i,{uid:n,gid:r})},async copyFile(e,t,n){await N(d(e),d(t),!1)},async cp(e,t,n){await N(d(e),d(t),!!n?.recursive)},async glob(t,n){let r=d(n?.cwd??`.`),i=(await e.getKeys(r)).filter(e=>!h(e)).filter(e=>E(String(t),e));async function*a(){for(let e of i)if(n&&`withFileTypes`in n&&n.withFileTypes){let t=await s(e,!0);yield{name:m(e),relative:e.slice(r.length).replace(/^\//,``),absolute:e,isFile:()=>t?.type===`file`,isDirectory:()=>t?.type===`directory`,isSymbolicLink:()=>t?.type===`symlink`}}else yield e}return a()},async lchmod(e,t){await F(e,t)},async lchown(e,t,n){await I(e,t,n)},async lutimes(t,n,r){let i=d(t);await u(i,!1),await e.setMeta(i,{atime:new Date(n),mtime:new Date(r)})},async link(e,t){let n=d(e),r=d(t),i=await A(n);await j(r,typeof i==`string`?i:b(i))},async lstat(e,t){return P(e,!1)},async mkdir(e,t){return L(e,t)},async mkdtemp(e,t){return R(e,t)},async mkdtempDisposable(e,t){let n=await R(e,t);return{path:n,async[Symbol.asyncDispose](){await M(n,{recursive:!0,force:!0})},[Symbol.dispose](){y(async()=>M(n,{recursive:!0,force:!0}))}}},async open(e,n,r){let a=d(e);await u(a,!0).catch(async e=>{if(e.code===`ENOENT`){await j(a,``);return}throw e});let o=i++;return t.set(o,{key:a,position:0}),H(o,a)},async opendir(e,t){return z(e,t)},async readdir(t,n){let r=d(t);await u(r,!0);let i=await e.getKeys(r),o=_(r,i.filter(e=>!h(e)));return n&&typeof n==`object`&&`recursive`in n&&n.recursive&&(o=i.filter(e=>!h(e)).map(e=>e.slice(r.length).replace(/^\//,``)).filter(Boolean)),n&&typeof n==`object`&&`withFileTypes`in n&&n.withFileTypes?await Promise.all(o.map(async e=>{let t=await s(f(r,e),!0);return{name:e,isFile:()=>t?.type===`file`,isDirectory:()=>t?.type===`directory`,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>t?.type===`symlink`,isFIFO:()=>!1,isSocket:()=>!1}})):n&&typeof n==`object`&&`encoding`in n&&n.encoding===`buffer`?o.map(e=>a.from(e)):o},async readFile(e,t){return A(e,t)},async readlink(e,t){let n=d(e),r=await u(n,!1);if(r.type!==`symlink`)throw v(`EINVAL`,`readlink`,n);let i=r.meta?.[O];if(typeof i!=`string`)throw v(`EINVAL`,`readlink`,n);return t&&typeof t==`object`&&t.encoding===`buffer`?a.from(i):i},async realpath(e,t){let n=f(e);if(!await s(n,!0))throw v(`ENOENT`,`realpath`,n);return t&&typeof t==`object`&&t.encoding===`buffer`?a.from(n):n},async rename(t,n){let r=d(t),i=d(n);if((await u(r,!0)).type===`directory`){let t=await e.getKeys(r);for(let n of t){if(h(n))continue;let t=n===r?``:n.slice(r.length).replace(/^\//,``),a=t?f(i,t):i;if(n===r&&await e.hasItem(n)){let t=await e.getItem(n);t!=null&&await e.setItem(a,t)}else if(n!==r){let t=await e.getItem(n);t!=null&&await e.setItem(a,t);let r=await o(n);r&&await e.setMeta(a,r),await e.removeItem(n)}}await e.hasItem(r)&&await e.removeItem(r);return}let a=await e.getItem(r);a!=null&&await e.setItem(i,a);let s=await o(r);s&&await e.setMeta(i,s),await e.removeItem(r)},async rm(e,t){await M(e,t)},async rmdir(e,t){await M(e,t)},async stat(e,t){return P(e)},async statfs(t,r){let i=await e.getKeys(d(t)),a=Object.create(n.prototype);return Object.assign(a,{type:0,bsize:4096,blocks:i.length,bfree:0,bavail:0,files:i.length,ffree:0}),a},async symlink(t,n,r){let i=d(n);await e.setMeta(i,{[O]:d(t),mtime:new Date,atime:new Date})},async truncate(e,t=0){let n=d(e);await j(n,b(await A(n)).subarray(0,t))},async unlink(t){let n=d(t),r=await s(n,!1);if(!r)throw v(`ENOENT`,`unlink`,n);if(r.type===`directory`)throw v(`EISDIR`,`unlink`,n);await e.removeItem(n)},async utimes(t,n,r){let i=d(t);await u(i,!0),await e.setMeta(i,{atime:new Date(n),mtime:new Date(r)})},async watch(t,n){let r=d(t),i=await e.watch((e,t)=>{(t===r||t.startsWith(g(r)))&&(typeof n==`function`?n:n.listener)?.(e,t)});return{async close(){await i()},[Symbol.asyncDispose]:async()=>{await i()}}},async writeFile(e,t,n){await j(e,t,n)}};async function W(e,t,n){return(await U.open(e,t,n)).fd}async function G(e){if(!t.has(e))throw v(`EBADF`,`close`);t.delete(e)}async function K(e,n){let r=t.get(e);if(!r)throw v(`EBADF`,`fstat`);return P(r.key)}async function q(e,n,r,i,a){let o=t.get(e);if(!o)throw v(`EBADF`,`read`);return H(e,o.key).read(n,r,i,a)}async function J(e,n,r,i,a){let o=t.get(e);if(!o)throw v(`EBADF`,`write`);return H(e,o.key).write(n,r,i,a)}async function Y(e,n=0){let r=t.get(e);if(!r)throw v(`EBADF`,`ftruncate`);await U.truncate(r.key,n)}async function X(e,n,r){let i=t.get(e);if(!i)throw v(`EBADF`,`futimes`);await U.utimes(i.key,n,r)}async function Z(e,n,r){let i=0,o=r??t.get(e)?.position??0;for(let t of n){let n=a.from(t.buffer,t.byteOffset,t.byteLength),r=await q(e,n,0,n.length,o);i+=r.bytesRead,o+=r.bytesRead}return{bytesRead:i,buffers:n}}async function Q(e,n,r){let i=a.concat(n.map(e=>a.from(e.buffer,e.byteOffset,e.byteLength))),o=t.get(e);if(!o)throw v(`EBADF`,`writev`);let s=r??o.position,c=b(await A(o.key).catch(()=>``));return i.copy(c,s),await j(o.key,c),r??(o.position+=i.byteLength),{bytesWritten:i.byteLength,buffers:n}}return{promises:U,createReadStream:B,createWriteStream:V,openFd:W,closeFd:G,fstatFd:K,readFd:q,writeFd:J,ftruncateFd:Y,futimesFd:X,readvFd:Z,writevFd:Q}}function A(e){let t=i(e);return t.__promisify__=e,t}function j(){return async()=>void 0}function M(){return()=>void 0}function N(n){let r=k(n),{promises:i}=r,a=async(...e)=>{let t=i.glob(...e),n=[];for await(let e of t)n.push(typeof e==`string`?e:`absolute`in e?String(e.absolute):String(e));return n},o=t=>{let r=new e;return n.watch((e,n)=>{let i=d(t);(n===i||n.startsWith(`${i}/`))&&r.emit(`change`,e,n)}).then(e=>{r.on(`close`,()=>{e()})}),r};return{promises:i,access:A(i.access),appendFile:A(i.appendFile),chmod:A(i.chmod),chown:A(i.chown),close:A(r.closeFd),copyFile:A(i.copyFile),cp:A(i.cp),createReadStream:r.createReadStream,createWriteStream:r.createWriteStream,exists:((e,t)=>{i.access(e).then(()=>t(!0)).catch(()=>t(!1))}),fchmod:A(j()),fchown:A(j()),fdatasync:A(j()),fstat:A(r.fstatFd),fsync:A(j()),ftruncate:A(r.ftruncateFd),futimes:A(r.futimesFd),glob:A(a),lchmod:A(i.lchmod),lchown:A(i.lchown),lutimes:A(i.lutimes),link:A(i.link),lstat:A(i.lstat),mkdir:A(i.mkdir),mkdtemp:A(i.mkdtemp),open:A(r.openFd),openAsBlob:A(async e=>{let t=await i.readFile(e);return new Blob([t])}),opendir:A(i.opendir),read:A(r.readFd),readdir:A(i.readdir),readFile:A(i.readFile),readlink:A(i.readlink),readv:A(r.readvFd),realpath:A(i.realpath),rename:A(i.rename),rmdir:A(i.rmdir),rm:A(i.rm),stat:A(i.stat),statfs:A(i.statfs),symlink:A(i.symlink),truncate:A(i.truncate),unlink:A(i.unlink),unwatchFile:t.unwatchFile,utimes:A(i.utimes),watch:((e,t,n)=>{let r=o(e),i=e=>{r.on(`change`,e)};return typeof t==`function`?(i(t),r):(typeof n==`function`?i(n):t&&typeof t==`object`&&`listener`in t&&typeof t.listener==`function`&&i(t.listener),r)}),watchFile:t.watchFile,write:A(r.writeFd),writeFile:A(i.writeFile),writev:A(r.writevFd),accessSync:((e,t)=>y(async()=>i.access(e,t))),appendFileSync:((e,t,n)=>y(async()=>i.appendFile(e,t,n))),chmodSync:((e,t)=>y(async()=>i.chmod(e,t))),chownSync:((e,t,n)=>y(async()=>i.chown(e,t,n))),closeSync:(e=>y(async()=>r.closeFd(e))),copyFileSync:((e,t,n)=>y(async()=>i.copyFile(e,t,n))),cpSync:((e,t,n)=>y(async()=>i.cp(e,t,n))),existsSync:(e=>{try{return y(async()=>i.access(e)),!0}catch{return!1}}),fchmodSync:M(),fchownSync:M(),fdatasyncSync:M(),fstatSync:((e,t)=>y(async()=>r.fstatFd(e,t))),fsyncSync:M(),ftruncateSync:((e,t)=>y(async()=>r.ftruncateFd(e,t))),futimesSync:((e,t,n)=>y(async()=>r.futimesFd(e,t,n))),globSync:((e,t)=>y(async()=>a(e,t))),lchmodSync:((e,t)=>y(async()=>i.lchmod(e,t))),lchownSync:((e,t,n)=>y(async()=>i.lchown(e,t,n))),lutimesSync:((e,t,n)=>y(async()=>i.lutimes(e,t,n))),linkSync:((e,t)=>y(async()=>i.link(e,t))),lstatSync:((e,t)=>y(async()=>i.lstat(e,t))),mkdirSync:((e,t)=>y(async()=>i.mkdir(e,t))),mkdtempSync:((e,t)=>y(async()=>i.mkdtemp(e,t))),openSync:((e,t,n)=>y(async()=>r.openFd(e,t,n??void 0))),opendirSync:((e,t)=>y(async()=>i.opendir(e,t))),readdirSync:((e,t)=>y(async()=>i.readdir(e,t))),readFileSync:((e,t)=>y(async()=>i.readFile(e,t))),readlinkSync:((e,t)=>y(async()=>i.readlink(e,t))),readSync:((e,t,n,i,a)=>y(async()=>r.readFd(e,t,n??0,i??t.byteLength,a==null?null:Number(a))).bytesRead),readvSync:((e,t,n)=>y(async()=>r.readvFd(e,[...t],n)).bytesRead),realpathSync:((e,t)=>y(async()=>i.realpath(e,t))),renameSync:((e,t)=>y(async()=>i.rename(e,t))),rmdirSync:(e=>y(async()=>i.rm(e,{recursive:!1}))),rmSync:((e,t)=>y(async()=>i.rm(e,t))),statSync:((e,t)=>y(async()=>i.stat(e,t))),statfsSync:((e,t)=>y(async()=>i.statfs(e,t))),symlinkSync:((e,t,n)=>y(async()=>i.symlink(e,t,n))),truncateSync:((e,t)=>y(async()=>i.truncate(e,t))),unlinkSync:(e=>y(async()=>i.unlink(e))),utimesSync:((e,t,n)=>y(async()=>i.utimes(e,t,n))),writeFileSync:((e,t,n)=>y(async()=>i.writeFile(e,t,n))),writeSync:((e,t,n,i,a)=>y(async()=>r.writeFd(e,t,n??0,i??t.byteLength,a==null?null:Number(a))).bytesWritten),writevSync:((e,t,n)=>y(async()=>r.writevFd(e,[...t],n)).bytesWritten)}}export{k as n,d as r,N as t};
|
|
2
|
+
//# sourceMappingURL=storage-BccFP9xn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-BccFP9xn.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-CMqjfN_6.cjs");let t=require("node:events"),n=require("node:fs");n=e.t(n,1);let r=require("node:util"),i=require("node:buffer"),a=require("node:worker_threads"),o=require("node:stream");function s(e){return e instanceof URL?decodeURIComponent(e.pathname):i.Buffer.isBuffer(e)?e.toString():e}function c(e){let t=s(e).replace(/\\/g,`/`);for(;t.startsWith(`./`);)t=t.slice(2);return t=t.replace(/^\/+/,``),t=t.replace(/\/+/g,`/`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function l(...e){let t=[];for(let n of e)for(let e of c(n).split(`/`))if(!(!e||e===`.`)){if(e===`..`){t.pop();continue}t.push(e)}return t.join(`/`)}function u(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function d(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function f(e){return e.endsWith(`$`)}function p(e){return e?`${e}/`:``}function m(e,t){let n=p(e),r=new Set;for(let e of t){if(f(e))continue;let t=n?e.startsWith(n)?e.slice(n.length):``:e;if(!t||t===e)continue;let i=t.indexOf(`/`);r.add(i===-1?t:t.slice(0,i))}return[...r].sort()}function h(e,t,n,r){let i=n?` '${n}'`:``,a=Error(r??`${e}: ${t}${i}`);return a.code=e,a.syscall=t,n&&(a.path=n),a}function g(e){let{port1:t,port2:n}=new a.MessageChannel;e().then(e=>{t.postMessage({ok:!0,value:e})},e=>{t.postMessage({ok:!1,error:e})});let r=(0,a.receiveMessageOnPort)(n);if(t.close(),n.close(),!r)throw Error(`Storage operation did not complete.`);if(!r.message.ok)throw r.message.error;return r.message.value}function _(e){return e==null?i.Buffer.alloc(0):i.Buffer.isBuffer(e)?e:(e instanceof Uint8Array,i.Buffer.from(e))}function v(e){if(typeof e==`string`)return e;if(e!=null)return e.encoding??void 0}function y(e){let t=v(e);return t==null||t===`buffer`}function b(e,t){let n=_(typeof e==`string`||i.Buffer.isBuffer(e)||e instanceof Uint8Array?e:e==null?``:JSON.stringify(e));return t==null||t===`buffer`?n:n.toString(t)}function x(e){return typeof e==`string`?e:_(i.Buffer.from(e.buffer,e.byteOffset,e.byteLength))}function S(e,t,r=0){let i=Date.now(),a=t?.atime instanceof Date?t.atime:new Date(i),o=t?.mtime instanceof Date?t.mtime:new Date(i),s=e===`directory`?16877:e===`symlink`?41471:33188,c=Object.create(n.Stats.prototype);return Object.assign(c,{dev:0,ino:0,mode:s,nlink:1,uid:typeof t?.uid==`number`?t.uid:0,gid:typeof t?.gid==`number`?t.gid:0,rdev:0,size:r,blksize:4096,blocks:Math.ceil(r/512),atimeMs:a.getTime(),mtimeMs:o.getTime(),ctimeMs:o.getTime(),birthtimeMs:o.getTime(),atime:a,mtime:o,ctime:o,birthtime:o}),c}function C(e,t){return RegExp(`^${e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`.*`).replace(/\*/g,`[^/]*`).replace(/\?/g,`.`)}$`).test(t)}function w(e=6){return Array.from({length:e},()=>`abcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*36))).join(``)}const T=`symlinkTarget`;function E(e){let t=new Map,r=3;async function a(t){try{return await e.getMeta(t)??null}catch{return null}}async function s(t,n=!0){let r=c(t);if(!r&&t!==`.`&&t!==`/`)return null;let i=await a(r);return i?.[T]&&typeof i[T]==`string`?n?s(i[T],!0):{key:r,type:`symlink`,meta:i}:await e.hasItem(r)?{key:r,type:`file`,meta:i}:m(r,(await e.getKeys(r)).filter(e=>e!==r&&!f(e))).length>0?{key:r,type:`directory`,meta:i}:null}async function E(e,t=!0){let n=await s(e,t);if(!n)throw h(`ENOENT`,`stat`,c(e));return n}async function D(t){let n=await a(t);if(typeof n?.size==`number`)return n.size;if(y()){let n=await e.getItemRaw(t);return n==null?0:_(n).byteLength}let r=await e.getItem(t);return r==null?0:_(String(r)).byteLength}async function O(t,n){let r=c(t);if((await E(r,!0)).type!==`file`)throw h(`EISDIR`,`read`,r,`EISDIR: illegal operation on a directory, read`);let i=v(n),a=y(n)?await e.getItemRaw(r):await e.getItem(r);if(a==null)throw h(`ENOENT`,`open`,r);return b(a,i)}async function k(t,n,r){let i=c(t),a=v(r),o=typeof n==`string`?n:a&&a!==`buffer`?_(x(n)).toString(a):x(n);await e.setItem(i,o),await e.setMeta(i,{mtime:new Date,atime:new Date,size:_(o).byteLength})}async function A(t,n){let r=c(t),i=await s(r,!1);if(!i){if(typeof n==`object`&&n&&`recursive`in n&&n.recursive)return;throw h(`ENOENT`,`unlink`,r)}if(i.type===`directory`){let t=n===!0||(typeof n==`object`&&n&&`recursive`in n?!!n.recursive:!1),i=(await e.getKeys(r)).filter(e=>e!==r&&!f(e)&&e.startsWith(p(r)));if(!t&&i.length>0)throw h(`ENOTEMPTY`,`rmdir`,r);await Promise.all(i.map(async t=>e.removeItem(t))),await e.hasItem(r)&&await e.removeItem(r);return}await e.removeItem(r)}async function j(t,n,r=!1){if((await E(t,!0)).type===`directory`){if(!r)throw h(`EISDIR`,`copy`,t,`EISDIR: illegal operation on a directory, copy`);let i=await e.getKeys(t);for(let e of i)f(e)||e===t||await j(e,l(n,e.slice(t.length).replace(/^\//,``)),!0);return}let i=await O(t);await k(n,typeof i==`string`?i:_(i));let o=await a(t);o&&await e.setMeta(c(n),o)}async function M(e,t=!0){let n=await E(e,t),r=n.type===`file`?await D(n.key):4096;return S(n.type,n.meta,r)}async function N(t,n){let r=c(t);await E(r,!0),await e.setMeta(r,{mode:n})}async function P(t,n,r){let i=c(t);await E(i,!0),await e.setMeta(i,{uid:n,gid:r})}async function F(e,t){let n=c(e),r=typeof t==`object`&&t?!!t.recursive:!1;if(!n)return;let i=u(n);if(i){let e=await s(i,!0);if(!e&&!r)throw h(`ENOENT`,`mkdir`,n);!e&&r&&await F(i,{recursive:!0})}if((await s(n,!0))?.type===`file`)throw h(`EEXIST`,`mkdir`,n)}async function I(e,t){let n=`${c(e)}${w()}`;return await F(n,{recursive:!0}),t?.encoding===`buffer`?i.Buffer.from(n):n}function L(t,n){let r=c(t),a=[],o=!1,s=0,l=!1,u=async()=>{if(o)return;await E(r,!0);let t=await e.getKeys(r);a=m(r,t.filter(e=>!f(e))),o=!0},d=e=>({name:e,isFile:()=>!0,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1});return{path:r,async read(){if(l)throw h(`EBADF`,`readdir`,r);if(await u(),s>=a.length)return null;let e=a[s++];return n?.encoding===`buffer`?i.Buffer.from(e):d(e)},async close(){l=!0},async*[Symbol.asyncIterator](){for(;;){let e=await this.read();if(!e)break;yield e}}}}function R(e,t){let n=c(e),r=t?.start??0,i=t?.end;return o.Readable.from((async function*(){let e=_(await O(n));if(r>0&&(e=e.subarray(r)),i!=null){yield e.subarray(0,Math.max(0,i-r+1));return}yield e})())}function z(e,t){let n=c(e),r=[];return new o.Writable({write(e,t,n){r.push(_(e)),n()},final:e=>{let a=i.Buffer.concat(r),o=t?.encoding&&t.encoding!==`buffer`?a.toString(t.encoding):a;k(n,o,t).then(()=>e()).catch(t=>e(t))}})}function B(n,r){let a=()=>{let e=t.get(n);if(!e)throw h(`EBADF`,`read`,r);return e};return{fd:n,async appendFile(e,t){let n=await O(r).catch(()=>i.Buffer.alloc(0));await k(r,i.Buffer.concat([_(n),_(typeof e==`string`?e:x(e))]),t)},async chmod(e){},async chown(e,t){},async close(){t.delete(n)},createReadStream(e){return R(r,e)},createWriteStream(e){return z(r,e)},async datasync(){},async read(e,t,n,i){let o=a(),s=_(await O(r,{encoding:void 0})),c=i??o.position,l=t??0,u=n??e.length-l,d=s.copy(e,l,c,c+u);return i??(o.position+=d),{bytesRead:d,buffer:e}},async readFile(e){return O(r,e)},async stat(e){return M(r)},async sync(){},async truncate(e=0){await k(r,_(await O(r)).subarray(0,e))},async utimes(t,n){await e.setMeta(r,{atime:new Date(t),mtime:new Date(n)})},async write(e,t,n,i){let o=a(),s=_(await O(r).catch(()=>``)),c=t??0,l=n??e.length-c,u=i??o.position;return e.copy(s,u,c,c+l),await k(r,s),i??(o.position+=l),{bytesWritten:l,buffer:e}},async writeFile(e,t){await k(r,typeof e==`string`?e:x(e),t)}}}let V={async access(e,t=n.constants.F_OK){let r=await s(e,!0);if(!r)throw h(`ENOENT`,`access`,c(e));if(t&n.constants.W_OK&&r.type===`directory`)throw h(`EISDIR`,`access`,c(e))},async appendFile(e,t,n){let r=c(e),a=await O(r).catch(()=>``);await k(r,i.Buffer.concat([_(a),_(typeof t==`string`?t:x(t))]),n)},async chmod(t,n){let r=c(t);await E(r,!0),await e.setMeta(r,{mode:n})},async chown(t,n,r){let i=c(t);await E(i,!0),await e.setMeta(i,{uid:n,gid:r})},async copyFile(e,t,n){await j(c(e),c(t),!1)},async cp(e,t,n){await j(c(e),c(t),!!n?.recursive)},async glob(t,n){let r=c(n?.cwd??`.`),i=(await e.getKeys(r)).filter(e=>!f(e)).filter(e=>C(String(t),e));async function*a(){for(let e of i)if(n&&`withFileTypes`in n&&n.withFileTypes){let t=await s(e,!0);yield{name:d(e),relative:e.slice(r.length).replace(/^\//,``),absolute:e,isFile:()=>t?.type===`file`,isDirectory:()=>t?.type===`directory`,isSymbolicLink:()=>t?.type===`symlink`}}else yield e}return a()},async lchmod(e,t){await N(e,t)},async lchown(e,t,n){await P(e,t,n)},async lutimes(t,n,r){let i=c(t);await E(i,!1),await e.setMeta(i,{atime:new Date(n),mtime:new Date(r)})},async link(e,t){let n=c(e),r=c(t),i=await O(n);await k(r,typeof i==`string`?i:_(i))},async lstat(e,t){return M(e,!1)},async mkdir(e,t){return F(e,t)},async mkdtemp(e,t){return I(e,t)},async mkdtempDisposable(e,t){let n=await I(e,t);return{path:n,async[Symbol.asyncDispose](){await A(n,{recursive:!0,force:!0})},[Symbol.dispose](){g(async()=>A(n,{recursive:!0,force:!0}))}}},async open(e,n,i){let a=c(e);await E(a,!0).catch(async e=>{if(e.code===`ENOENT`){await k(a,``);return}throw e});let o=r++;return t.set(o,{key:a,position:0}),B(o,a)},async opendir(e,t){return L(e,t)},async readdir(t,n){let r=c(t);await E(r,!0);let a=await e.getKeys(r),o=m(r,a.filter(e=>!f(e)));return n&&typeof n==`object`&&`recursive`in n&&n.recursive&&(o=a.filter(e=>!f(e)).map(e=>e.slice(r.length).replace(/^\//,``)).filter(Boolean)),n&&typeof n==`object`&&`withFileTypes`in n&&n.withFileTypes?await Promise.all(o.map(async e=>{let t=await s(l(r,e),!0);return{name:e,isFile:()=>t?.type===`file`,isDirectory:()=>t?.type===`directory`,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>t?.type===`symlink`,isFIFO:()=>!1,isSocket:()=>!1}})):n&&typeof n==`object`&&`encoding`in n&&n.encoding===`buffer`?o.map(e=>i.Buffer.from(e)):o},async readFile(e,t){return O(e,t)},async readlink(e,t){let n=c(e),r=await E(n,!1);if(r.type!==`symlink`)throw h(`EINVAL`,`readlink`,n);let a=r.meta?.[T];if(typeof a!=`string`)throw h(`EINVAL`,`readlink`,n);return t&&typeof t==`object`&&t.encoding===`buffer`?i.Buffer.from(a):a},async realpath(e,t){let n=l(e);if(!await s(n,!0))throw h(`ENOENT`,`realpath`,n);return t&&typeof t==`object`&&t.encoding===`buffer`?i.Buffer.from(n):n},async rename(t,n){let r=c(t),i=c(n);if((await E(r,!0)).type===`directory`){let t=await e.getKeys(r);for(let n of t){if(f(n))continue;let t=n===r?``:n.slice(r.length).replace(/^\//,``),o=t?l(i,t):i;if(n===r&&await e.hasItem(n)){let t=await e.getItem(n);t!=null&&await e.setItem(o,t)}else if(n!==r){let t=await e.getItem(n);t!=null&&await e.setItem(o,t);let r=await a(n);r&&await e.setMeta(o,r),await e.removeItem(n)}}await e.hasItem(r)&&await e.removeItem(r);return}let o=await e.getItem(r);o!=null&&await e.setItem(i,o);let s=await a(r);s&&await e.setMeta(i,s),await e.removeItem(r)},async rm(e,t){await A(e,t)},async rmdir(e,t){await A(e,t)},async stat(e,t){return M(e)},async statfs(t,r){let i=await e.getKeys(c(t)),a=Object.create(n.Stats.prototype);return Object.assign(a,{type:0,bsize:4096,blocks:i.length,bfree:0,bavail:0,files:i.length,ffree:0}),a},async symlink(t,n,r){let i=c(n);await e.setMeta(i,{[T]:c(t),mtime:new Date,atime:new Date})},async truncate(e,t=0){let n=c(e);await k(n,_(await O(n)).subarray(0,t))},async unlink(t){let n=c(t),r=await s(n,!1);if(!r)throw h(`ENOENT`,`unlink`,n);if(r.type===`directory`)throw h(`EISDIR`,`unlink`,n);await e.removeItem(n)},async utimes(t,n,r){let i=c(t);await E(i,!0),await e.setMeta(i,{atime:new Date(n),mtime:new Date(r)})},async watch(t,n){let r=c(t),i=await e.watch((e,t)=>{(t===r||t.startsWith(p(r)))&&(typeof n==`function`?n:n.listener)?.(e,t)});return{async close(){await i()},[Symbol.asyncDispose]:async()=>{await i()}}},async writeFile(e,t,n){await k(e,t,n)}};async function H(e,t,n){return(await V.open(e,t,n)).fd}async function U(e){if(!t.has(e))throw h(`EBADF`,`close`);t.delete(e)}async function W(e,n){let r=t.get(e);if(!r)throw h(`EBADF`,`fstat`);return M(r.key)}async function G(e,n,r,i,a){let o=t.get(e);if(!o)throw h(`EBADF`,`read`);return B(e,o.key).read(n,r,i,a)}async function K(e,n,r,i,a){let o=t.get(e);if(!o)throw h(`EBADF`,`write`);return B(e,o.key).write(n,r,i,a)}async function q(e,n=0){let r=t.get(e);if(!r)throw h(`EBADF`,`ftruncate`);await V.truncate(r.key,n)}async function J(e,n,r){let i=t.get(e);if(!i)throw h(`EBADF`,`futimes`);await V.utimes(i.key,n,r)}async function Y(e,n,r){let a=0,o=r??t.get(e)?.position??0;for(let t of n){let n=i.Buffer.from(t.buffer,t.byteOffset,t.byteLength),r=await G(e,n,0,n.length,o);a+=r.bytesRead,o+=r.bytesRead}return{bytesRead:a,buffers:n}}async function X(e,n,r){let a=i.Buffer.concat(n.map(e=>i.Buffer.from(e.buffer,e.byteOffset,e.byteLength))),o=t.get(e);if(!o)throw h(`EBADF`,`writev`);let s=r??o.position,c=_(await O(o.key).catch(()=>``));return a.copy(c,s),await k(o.key,c),r??(o.position+=a.byteLength),{bytesWritten:a.byteLength,buffers:n}}return{promises:V,createReadStream:R,createWriteStream:z,openFd:H,closeFd:U,fstatFd:W,readFd:G,writeFd:K,ftruncateFd:q,futimesFd:J,readvFd:Y,writevFd:X}}function D(e){let t=(0,r.callbackify)(e);return t.__promisify__=e,t}function O(){return async()=>void 0}function k(){return()=>void 0}function A(e){let r=E(e),{promises:i}=r,a=async(...e)=>{let t=i.glob(...e),n=[];for await(let e of t)n.push(typeof e==`string`?e:`absolute`in e?String(e.absolute):String(e));return n},o=n=>{let r=new t.EventEmitter;return e.watch((e,t)=>{let i=c(n);(t===i||t.startsWith(`${i}/`))&&r.emit(`change`,e,t)}).then(e=>{r.on(`close`,()=>{e()})}),r};return{promises:i,access:D(i.access),appendFile:D(i.appendFile),chmod:D(i.chmod),chown:D(i.chown),close:D(r.closeFd),copyFile:D(i.copyFile),cp:D(i.cp),createReadStream:r.createReadStream,createWriteStream:r.createWriteStream,exists:((e,t)=>{i.access(e).then(()=>t(!0)).catch(()=>t(!1))}),fchmod:D(O()),fchown:D(O()),fdatasync:D(O()),fstat:D(r.fstatFd),fsync:D(O()),ftruncate:D(r.ftruncateFd),futimes:D(r.futimesFd),glob:D(a),lchmod:D(i.lchmod),lchown:D(i.lchown),lutimes:D(i.lutimes),link:D(i.link),lstat:D(i.lstat),mkdir:D(i.mkdir),mkdtemp:D(i.mkdtemp),open:D(r.openFd),openAsBlob:D(async e=>{let t=await i.readFile(e);return new Blob([t])}),opendir:D(i.opendir),read:D(r.readFd),readdir:D(i.readdir),readFile:D(i.readFile),readlink:D(i.readlink),readv:D(r.readvFd),realpath:D(i.realpath),rename:D(i.rename),rmdir:D(i.rmdir),rm:D(i.rm),stat:D(i.stat),statfs:D(i.statfs),symlink:D(i.symlink),truncate:D(i.truncate),unlink:D(i.unlink),unwatchFile:n.unwatchFile,utimes:D(i.utimes),watch:((e,t,n)=>{let r=o(e),i=e=>{r.on(`change`,e)};return typeof t==`function`?(i(t),r):(typeof n==`function`?i(n):t&&typeof t==`object`&&`listener`in t&&typeof t.listener==`function`&&i(t.listener),r)}),watchFile:n.watchFile,write:D(r.writeFd),writeFile:D(i.writeFile),writev:D(r.writevFd),accessSync:((e,t)=>g(async()=>i.access(e,t))),appendFileSync:((e,t,n)=>g(async()=>i.appendFile(e,t,n))),chmodSync:((e,t)=>g(async()=>i.chmod(e,t))),chownSync:((e,t,n)=>g(async()=>i.chown(e,t,n))),closeSync:(e=>g(async()=>r.closeFd(e))),copyFileSync:((e,t,n)=>g(async()=>i.copyFile(e,t,n))),cpSync:((e,t,n)=>g(async()=>i.cp(e,t,n))),existsSync:(e=>{try{return g(async()=>i.access(e)),!0}catch{return!1}}),fchmodSync:k(),fchownSync:k(),fdatasyncSync:k(),fstatSync:((e,t)=>g(async()=>r.fstatFd(e,t))),fsyncSync:k(),ftruncateSync:((e,t)=>g(async()=>r.ftruncateFd(e,t))),futimesSync:((e,t,n)=>g(async()=>r.futimesFd(e,t,n))),globSync:((e,t)=>g(async()=>a(e,t))),lchmodSync:((e,t)=>g(async()=>i.lchmod(e,t))),lchownSync:((e,t,n)=>g(async()=>i.lchown(e,t,n))),lutimesSync:((e,t,n)=>g(async()=>i.lutimes(e,t,n))),linkSync:((e,t)=>g(async()=>i.link(e,t))),lstatSync:((e,t)=>g(async()=>i.lstat(e,t))),mkdirSync:((e,t)=>g(async()=>i.mkdir(e,t))),mkdtempSync:((e,t)=>g(async()=>i.mkdtemp(e,t))),openSync:((e,t,n)=>g(async()=>r.openFd(e,t,n??void 0))),opendirSync:((e,t)=>g(async()=>i.opendir(e,t))),readdirSync:((e,t)=>g(async()=>i.readdir(e,t))),readFileSync:((e,t)=>g(async()=>i.readFile(e,t))),readlinkSync:((e,t)=>g(async()=>i.readlink(e,t))),readSync:((e,t,n,i,a)=>g(async()=>r.readFd(e,t,n??0,i??t.byteLength,a==null?null:Number(a))).bytesRead),readvSync:((e,t,n)=>g(async()=>r.readvFd(e,[...t],n)).bytesRead),realpathSync:((e,t)=>g(async()=>i.realpath(e,t))),renameSync:((e,t)=>g(async()=>i.rename(e,t))),rmdirSync:(e=>g(async()=>i.rm(e,{recursive:!1}))),rmSync:((e,t)=>g(async()=>i.rm(e,t))),statSync:((e,t)=>g(async()=>i.stat(e,t))),statfsSync:((e,t)=>g(async()=>i.statfs(e,t))),symlinkSync:((e,t,n)=>g(async()=>i.symlink(e,t,n))),truncateSync:((e,t)=>g(async()=>i.truncate(e,t))),unlinkSync:(e=>g(async()=>i.unlink(e))),utimesSync:((e,t,n)=>g(async()=>i.utimes(e,t,n))),writeFileSync:((e,t,n)=>g(async()=>i.writeFile(e,t,n))),writeSync:((e,t,n,i,a)=>g(async()=>r.writeFd(e,t,n??0,i??t.byteLength,a==null?null:Number(a))).bytesWritten),writevSync:((e,t,n)=>g(async()=>r.writevFd(e,[...t],n)).bytesWritten)}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}});
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
import { n as JSON_SCHEMA_PRIMITIVE_TYPES, r as JSON_SCHEMA_TYPES } from "./constants-lihlIQu7.cjs";
|
|
2
1
|
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
import { InferLoadOptions,
|
|
2
|
+
import { InferLoadOptions, LoadReference } from "@stryke/resolve/types";
|
|
3
|
+
import { Storage } from "unstorage";
|
|
4
4
|
import { InputObject, Schema } from "untyped";
|
|
5
5
|
import { BaseIssue, BaseSchema } from "valibot";
|
|
6
6
|
import * as z3 from "zod/v3";
|
|
7
7
|
|
|
8
|
+
//#region src/constants.d.ts
|
|
9
|
+
declare const JsonSchemaTypeNames: {
|
|
10
|
+
readonly STRING: "string";
|
|
11
|
+
readonly NUMBER: "number";
|
|
12
|
+
readonly INTEGER: "integer";
|
|
13
|
+
readonly BOOLEAN: "boolean";
|
|
14
|
+
readonly NULL: "null";
|
|
15
|
+
readonly OBJECT: "object";
|
|
16
|
+
readonly ARRAY: "array";
|
|
17
|
+
};
|
|
18
|
+
declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
|
|
19
|
+
declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
|
|
20
|
+
declare const JSON_SCHEMA_METADATA_KEYS: ("$id" | "$schema" | "$vocabulary" | "$comment" | "$anchor" | "$defs" | "$dynamicRef" | "$dynamicAnchor" | "name" | "version" | "title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
|
|
21
|
+
/**
|
|
22
|
+
* Keywords whose values are a flat record of named JSON Schema fragments.
|
|
23
|
+
* Each child schema is merged recursively with its counterpart.
|
|
24
|
+
*/
|
|
25
|
+
declare const SCHEMA_RECORD_KEYWORDS: Set<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Keywords whose value is a single JSON Schema fragment that should be
|
|
28
|
+
* recursively merged when both sides define it.
|
|
29
|
+
*/
|
|
30
|
+
declare const SCHEMA_SINGLE_KEYWORDS: Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Keywords whose values are arrays of JSON Schema fragments that should be
|
|
33
|
+
* concatenated (rather than overridden) during a merge.
|
|
34
|
+
*/
|
|
35
|
+
declare const SCHEMA_ARRAY_CONCAT_KEYWORDS: Set<string>;
|
|
36
|
+
//#endregion
|
|
8
37
|
//#region src/types.d.ts
|
|
9
38
|
/**
|
|
10
39
|
* Primitive JSON Schema `type` keyword values.
|
|
@@ -53,7 +82,7 @@ interface JsonSchemaMetadataKeywords {
|
|
|
53
82
|
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.1
|
|
54
83
|
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
|
|
55
84
|
*/
|
|
56
|
-
$schema?:
|
|
85
|
+
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
|
57
86
|
/**
|
|
58
87
|
* A keyword that is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema.
|
|
59
88
|
*
|
|
@@ -255,14 +284,19 @@ type JsonSchemaKeywords = JsonSchemaMetadataKeywords & JsonSchemaLogicKeywords &
|
|
|
255
284
|
/**
|
|
256
285
|
* A schema that can point to another schema via `$ref`.
|
|
257
286
|
*/
|
|
258
|
-
|
|
287
|
+
type JsonSchemaAny = JsonSchemaKeywords & ({
|
|
259
288
|
/**
|
|
260
289
|
* A URI reference to another schema.
|
|
261
290
|
*
|
|
262
291
|
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3.1
|
|
263
292
|
*/
|
|
264
293
|
$ref?: string;
|
|
265
|
-
}
|
|
294
|
+
} | {
|
|
295
|
+
/**
|
|
296
|
+
* Declares the primitive type of the schema.
|
|
297
|
+
*/
|
|
298
|
+
type: typeof JSON_SCHEMA_PRIMITIVE_TYPES;
|
|
299
|
+
});
|
|
266
300
|
/**
|
|
267
301
|
* JSON Schema keywords for array validation.
|
|
268
302
|
*
|
|
@@ -961,7 +995,7 @@ type JsonSchema = JsonSchemaString | JsonSchemaInteger | JsonSchemaDecimal | Jso
|
|
|
961
995
|
*/
|
|
962
996
|
interface JsonSchemaLike extends JsonSchemaKeywords {
|
|
963
997
|
$id?: string;
|
|
964
|
-
$schema?:
|
|
998
|
+
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
|
965
999
|
$vocabulary?: Record<string, boolean>;
|
|
966
1000
|
$comment?: string;
|
|
967
1001
|
$anchor?: string;
|
|
@@ -1127,11 +1161,11 @@ type SchemaSourceVariant = "standard-schema" | "json-schema" | "zod3" | "untyped
|
|
|
1127
1161
|
/**
|
|
1128
1162
|
* Accepted schema input variants, including raw type definitions.
|
|
1129
1163
|
*/
|
|
1130
|
-
type
|
|
1164
|
+
type SchemaConfigVariant = SchemaSourceVariant | "file-reference";
|
|
1131
1165
|
/**
|
|
1132
1166
|
* Alias for the Untyped object-input schema shape.
|
|
1133
1167
|
*/
|
|
1134
|
-
type
|
|
1168
|
+
type UntypedConfigObject = InputObject;
|
|
1135
1169
|
/**
|
|
1136
1170
|
* Alias for the Untyped schema document shape.
|
|
1137
1171
|
*/
|
|
@@ -1139,7 +1173,7 @@ type UntypedSchema = Schema;
|
|
|
1139
1173
|
/**
|
|
1140
1174
|
* A Valibot schema instance.
|
|
1141
1175
|
*
|
|
1142
|
-
* @template
|
|
1176
|
+
* @template TConfig - The raw input type accepted by the schema.
|
|
1143
1177
|
* @template TOutput - The parsed output type produced by the schema.
|
|
1144
1178
|
* @template TIssue - The issue type emitted for validation errors.
|
|
1145
1179
|
*/
|
|
@@ -1147,12 +1181,12 @@ type ValibotSchema<TInput = unknown, TOutput = unknown, TIssue extends BaseIssue
|
|
|
1147
1181
|
/**
|
|
1148
1182
|
* Raw schema source input union before normalization.
|
|
1149
1183
|
*/
|
|
1150
|
-
type
|
|
1184
|
+
type SchemaSourceConfig<TSpec = any> = StandardJSONSchemaV1<TSpec> | JsonSchemaOf<TSpec> | z3.ZodType<TSpec, any, any> | UntypedConfigObject | UntypedSchema | ValibotSchema<TSpec>;
|
|
1151
1185
|
/**
|
|
1152
1186
|
* Any accepted schema input, including normalized schemas and references.
|
|
1153
1187
|
*
|
|
1154
1188
|
* @remarks
|
|
1155
|
-
* The `
|
|
1189
|
+
* The `SchemaConfig` type can be one of the following variants:
|
|
1156
1190
|
* - A file path string (for example: `"./src/types.ts"`).
|
|
1157
1191
|
* - A URL string (for example: `"https://example.com/config.json"`).
|
|
1158
1192
|
* - A {@link GitHubReference | GitHub repository reference string}, starting with either `"github:"` or `"gh:"`, an optional branch or tag, and optionally including a specific file path within the repository (for example: `"github:main:storm-software/stryke/packages/resolve/src/types.ts"`). It is also valid to provide the branch or tag after the file path (for example: `"github:storm-software/stryke/packages/resolve/src/types.ts@main"`).
|
|
@@ -1161,16 +1195,21 @@ type SchemaSourceInput<TSpec = any> = StandardJSONSchemaV1<TSpec> | JsonSchemaOf
|
|
|
1161
1195
|
* - A file reference string (this value can include both a path to the TypeScript module and the name of the module export separated by a ":", "#", or ";" character - for example: `"./src/types.ts#ExampleExport"`).
|
|
1162
1196
|
* - A {@link FileReference} object, which contains information about a file reference.
|
|
1163
1197
|
* - A {@link URL} object, which represents a URL to fetch the file from.
|
|
1164
|
-
* - A {@link
|
|
1198
|
+
* - A {@link SchemaSourceConfig} object, which represents a raw schema input in one of the supported formats (Standard Schema, JSON Schema, Zod v3, Untyped, or Valibot).
|
|
1165
1199
|
*
|
|
1166
1200
|
* @template TSpec - The original TypeScript type for which the schema is being extracted. This type parameter is used to derive the appropriate JSON Schema representation based on the structure and constraints of `T`.
|
|
1167
1201
|
*
|
|
1168
|
-
* @see {@link
|
|
1202
|
+
* @see {@link SchemaSourceConfig}
|
|
1169
1203
|
* @see {@link SchemaEnvelope}
|
|
1170
|
-
* @see {@link
|
|
1204
|
+
* @see {@link SchemaConfigWithMeta}
|
|
1171
1205
|
*/
|
|
1172
|
-
type
|
|
1173
|
-
type InferExtractOptions<T extends
|
|
1206
|
+
type SchemaConfig<TSpec = any> = LoadReference | SchemaSourceConfig<TSpec> | SchemaEnvelope<JsonSchemaOf<TSpec>>;
|
|
1207
|
+
type InferExtractOptions<T extends SchemaConfig> = (T extends LoadReference ? Omit<InferLoadOptions<T>, "fs"> : {}) & {
|
|
1208
|
+
/**
|
|
1209
|
+
* An optional storage instance to use for caching schema extraction results. If provided, the storage instance will be used to store and retrieve cached schema extraction results, which can improve performance by avoiding redundant schema extraction operations. If not provided, the default storage mechanism will be used.
|
|
1210
|
+
*/
|
|
1211
|
+
storage?: Storage;
|
|
1212
|
+
};
|
|
1174
1213
|
/**
|
|
1175
1214
|
* A schema envelope that contains the normalized schema and its source variant.
|
|
1176
1215
|
*/
|
|
@@ -1182,7 +1221,7 @@ interface SchemaEnvelope<TJsonSchema extends JsonSchema = JsonSchema> {
|
|
|
1182
1221
|
/**
|
|
1183
1222
|
* The source variant used to derive the normalized {@link JsonSchema}.
|
|
1184
1223
|
*/
|
|
1185
|
-
variant:
|
|
1224
|
+
variant: SchemaConfigVariant;
|
|
1186
1225
|
/**
|
|
1187
1226
|
* The normalized schema definition.
|
|
1188
1227
|
*/
|
|
@@ -1205,7 +1244,7 @@ interface BaseSchemaSource<TSpec = any> {
|
|
|
1205
1244
|
/** The specific source format used for the schema input. */
|
|
1206
1245
|
variant: SchemaSourceVariant;
|
|
1207
1246
|
/** The original schema input captured before normalization. */
|
|
1208
|
-
schema:
|
|
1247
|
+
schema: SchemaSourceConfig<TSpec>;
|
|
1209
1248
|
}
|
|
1210
1249
|
/**
|
|
1211
1250
|
* Source descriptor for schemas that already use JSON Schema.
|
|
@@ -1241,7 +1280,7 @@ interface UntypedSchemaSource<TSpec = any> extends BaseSchemaSource<TSpec> {
|
|
|
1241
1280
|
/** Indicates the source input comes from the Untyped schema model. */
|
|
1242
1281
|
variant: "untyped";
|
|
1243
1282
|
/** The original Untyped schema input. */
|
|
1244
|
-
schema:
|
|
1283
|
+
schema: UntypedConfigObject | UntypedSchema;
|
|
1245
1284
|
}
|
|
1246
1285
|
/**
|
|
1247
1286
|
* Source descriptor for Valibot schema inputs.
|
|
@@ -1265,6 +1304,32 @@ interface ExtractedSchemaEnvelope<TSpec = any> extends SchemaEnvelopeOf<TSpec> {
|
|
|
1265
1304
|
*/
|
|
1266
1305
|
source: SchemaSource<TSpec>;
|
|
1267
1306
|
}
|
|
1307
|
+
declare module "zod" {
|
|
1308
|
+
interface GlobalMeta {
|
|
1309
|
+
id?: string;
|
|
1310
|
+
title?: string;
|
|
1311
|
+
description?: string;
|
|
1312
|
+
docs?: string;
|
|
1313
|
+
alias?: string[];
|
|
1314
|
+
tags?: string[];
|
|
1315
|
+
deprecated?: boolean;
|
|
1316
|
+
hidden?: boolean;
|
|
1317
|
+
ignore?: boolean;
|
|
1318
|
+
internal?: boolean;
|
|
1319
|
+
runtime?: boolean;
|
|
1320
|
+
examples?: unknown | {
|
|
1321
|
+
name?: string;
|
|
1322
|
+
description?: string;
|
|
1323
|
+
value: unknown;
|
|
1324
|
+
}[];
|
|
1325
|
+
readOnly?: boolean;
|
|
1326
|
+
writeOnly?: boolean;
|
|
1327
|
+
contentEncoding?: string;
|
|
1328
|
+
contentMediaType?: string;
|
|
1329
|
+
contentSchema?: string;
|
|
1330
|
+
[keyword: string]: unknown;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1268
1333
|
//#endregion
|
|
1269
|
-
export {
|
|
1270
|
-
//# sourceMappingURL=types.d.cts.map
|
|
1334
|
+
export { SpecOf as $, JsonSchemaObject as A, JsonSchemaStringFormat as B, JsonSchemaMetadataKeywords as C, JsonSchemaNullable as D, JsonSchemaNull as E, JsonSchemaRecordPropertyNames as F, JsonSchemaUnknown as G, JsonSchemaType as H, JsonSchemaRef as I, SchemaEnvelope as J, SchemaConfig as K, JsonSchemaSchemaSource as L, JsonSchemaPrimitiveType as M, JsonSchemaPrimitiveUnion as N, JsonSchemaNumber as O, JsonSchemaRecord as P, SchemaSourceVariant as Q, JsonSchemaSet as R, JsonSchemaMap as S, JsonSchemaNever as T, JsonSchemaUndefined as U, JsonSchemaTuple as V, JsonSchemaUnion as W, SchemaSource as X, SchemaEnvelopeOf as Y, SchemaSourceConfig as Z, JsonSchemaIntegerFormat as _, JsonSchemaAllOf as a, ValibotSchemaSource as at, JsonSchemaLiteral as b, JsonSchemaArray as c, JSON_SCHEMA_PRIMITIVE_TYPES as ct, JsonSchemaConditionalKeywords as d, SCHEMA_ARRAY_CONCAT_KEYWORDS as dt, StandardSchemaSchemaSource as et, JsonSchemaDate as f, SCHEMA_RECORD_KEYWORDS as ft, JsonSchemaInteger as g, JsonSchemaEnum as h, JsonSchema as i, ValibotSchema as it, JsonSchemaOf as j, JsonSchemaNumberFormat as k, JsonSchemaBigint as l, JSON_SCHEMA_TYPES as lt, JsonSchemaDecimalFormat as m, ExtractedSchemaEnvelope as n, UntypedSchema as nt, JsonSchemaAny as o, Zod3SchemaSource as ot, JsonSchemaDecimal as p, SCHEMA_SINGLE_KEYWORDS as pt, SchemaConfigVariant as q, InferExtractOptions as r, UntypedSchemaSource as rt, JsonSchemaAnyOf as s, JSON_SCHEMA_METADATA_KEYS as st, BaseSchemaSource as t, UntypedConfigObject as tt, JsonSchemaBoolean as u, JsonSchemaTypeNames as ut, JsonSchemaKeywords as v, JsonSchemaNativeEnum as w, JsonSchemaLogicKeywords as x, JsonSchemaLike as y, JsonSchemaString as z };
|
|
1335
|
+
//# sourceMappingURL=types-CCLUrmYp.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CCLUrmYp.d.cts","names":[],"sources":["../src/constants.ts","../src/types.ts"],"mappings":";;;;;;;;cAoBa,mBAAA;EAAA;;;;;;;;cAUA,2BAAA;AAAA,cAQA,iBAAA;AAAA,cAMA,yBAAA;;;;;cA8BA,sBAAA,EAAsB,GAAA;;;;;cAYtB,sBAAA,EAAsB,GAAA;;;;AAlDzB;cAmEG,4BAAA,EAA4B,GAAA;;;;AAnFzC;;;;KCgBY,uBAAA,WACF,2BAA2B;;;;;;KAOzB,cAAA,WAAyB,iBAAiB;;;ADdtD;KCmBY,uBAAA;;;ADbF;KC0BE,uBAAA;;;;KAKA,sBAAA,GACV,uBAAA,GAA0B,uBAAuB;ADxBnD;;;AAAA,KC6BY,sBAAA;ADL+C;AAM3D;;;;AAN2D,UCkC1C,0BAAA;EDhBJ;;;;AAAsB;AAiBnC;ECME,GAAA;;;ADNuC;;;;ECcvC,OAAA;EAjFiC;;;AACE;AAOrC;;EAoFE,WAAA,GAAc,MAAA;EApFsC;AAAA;AAKtD;;;;EAuFE,QAAA;EA1EU;;;;AAAuB;EAiFjC,OAAA;EA5EgC;;;AACiB;AAKnD;;;;EAgFE,KAAA,GAAQ,MAAA,SAAe,UAAA;EAnDR;;;;;;;EA4Df,WAAA;EArDA;;;;;;EA6DA,cAAA;EAjBQ;;;EAsBR,IAAA;EAAA;;;EAKA,OAAA;EAeA;;;EAVA,KAAA;EAgBmD;;;EAXnD,WAAA;EA8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AAA,sBAEP,gBAAA,CAAiB,KAAA;EAzTpB;EA2TL,OAAA;EA3TwB;EA8TxB,MAAA,EAAQ,aAAA,CAAc,KAAA;AAAA;;;;KAMZ,YAAA,gBACR,sBAAA,CAAuB,KAAA,IACvB,0BAAA,CAA2B,KAAA,IAC3B,gBAAA,CAAiB,KAAA,IACjB,mBAAA,CAAoB,KAAA,IACpB,mBAAA,CAAoB,KAAA;;;;UAKP,uBAAA,sBAEP,gBAAA,CAAiB,KAAA;EA1UD;AAAA;;EA8UxB,MAAA,EAAQ,YAAA,CAAa,KAAA;AAAA;AAAA;EAAA,UAIX,UAAA;IACR,EAAA;IACA,KAAA;IACA,WAAA;IACA,IAAA;IACA,KAAA;IACA,IAAA;IACA,UAAA;IACA,MAAA;IACA,MAAA;IACA,QAAA;IACA,OAAA;IACA,QAAA;MACc,IAAA;MAAe,WAAA;MAAsB,KAAA;IAAA;IACnD,QAAA;IACA,SAAA;IACA,eAAA;IACA,gBAAA;IACA,aAAA;IAAA,CACC,OAAA;EAAA;AAAA"}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseIssue, BaseSchema } from "valibot";
|
|
2
2
|
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
import { InferLoadOptions,
|
|
3
|
+
import { InferLoadOptions, LoadReference } from "@stryke/resolve/types";
|
|
4
|
+
import { Storage } from "unstorage";
|
|
4
5
|
import { InputObject, Schema } from "untyped";
|
|
5
|
-
import { BaseIssue, BaseSchema } from "valibot";
|
|
6
6
|
import * as z3 from "zod/v3";
|
|
7
7
|
|
|
8
|
+
//#region src/constants.d.ts
|
|
9
|
+
declare const JsonSchemaTypeNames: {
|
|
10
|
+
readonly STRING: "string";
|
|
11
|
+
readonly NUMBER: "number";
|
|
12
|
+
readonly INTEGER: "integer";
|
|
13
|
+
readonly BOOLEAN: "boolean";
|
|
14
|
+
readonly NULL: "null";
|
|
15
|
+
readonly OBJECT: "object";
|
|
16
|
+
readonly ARRAY: "array";
|
|
17
|
+
};
|
|
18
|
+
declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
|
|
19
|
+
declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
|
|
20
|
+
declare const JSON_SCHEMA_METADATA_KEYS: ("$id" | "$schema" | "$vocabulary" | "$comment" | "$anchor" | "$defs" | "$dynamicRef" | "$dynamicAnchor" | "name" | "version" | "title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
|
|
21
|
+
/**
|
|
22
|
+
* Keywords whose values are a flat record of named JSON Schema fragments.
|
|
23
|
+
* Each child schema is merged recursively with its counterpart.
|
|
24
|
+
*/
|
|
25
|
+
declare const SCHEMA_RECORD_KEYWORDS: Set<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Keywords whose value is a single JSON Schema fragment that should be
|
|
28
|
+
* recursively merged when both sides define it.
|
|
29
|
+
*/
|
|
30
|
+
declare const SCHEMA_SINGLE_KEYWORDS: Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Keywords whose values are arrays of JSON Schema fragments that should be
|
|
33
|
+
* concatenated (rather than overridden) during a merge.
|
|
34
|
+
*/
|
|
35
|
+
declare const SCHEMA_ARRAY_CONCAT_KEYWORDS: Set<string>;
|
|
36
|
+
//#endregion
|
|
8
37
|
//#region src/types.d.ts
|
|
9
38
|
/**
|
|
10
39
|
* Primitive JSON Schema `type` keyword values.
|
|
@@ -53,7 +82,7 @@ interface JsonSchemaMetadataKeywords {
|
|
|
53
82
|
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.1
|
|
54
83
|
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
|
|
55
84
|
*/
|
|
56
|
-
$schema?:
|
|
85
|
+
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
|
57
86
|
/**
|
|
58
87
|
* A keyword that is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema.
|
|
59
88
|
*
|
|
@@ -255,14 +284,19 @@ type JsonSchemaKeywords = JsonSchemaMetadataKeywords & JsonSchemaLogicKeywords &
|
|
|
255
284
|
/**
|
|
256
285
|
* A schema that can point to another schema via `$ref`.
|
|
257
286
|
*/
|
|
258
|
-
|
|
287
|
+
type JsonSchemaAny = JsonSchemaKeywords & ({
|
|
259
288
|
/**
|
|
260
289
|
* A URI reference to another schema.
|
|
261
290
|
*
|
|
262
291
|
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3.1
|
|
263
292
|
*/
|
|
264
293
|
$ref?: string;
|
|
265
|
-
}
|
|
294
|
+
} | {
|
|
295
|
+
/**
|
|
296
|
+
* Declares the primitive type of the schema.
|
|
297
|
+
*/
|
|
298
|
+
type: typeof JSON_SCHEMA_PRIMITIVE_TYPES;
|
|
299
|
+
});
|
|
266
300
|
/**
|
|
267
301
|
* JSON Schema keywords for array validation.
|
|
268
302
|
*
|
|
@@ -961,7 +995,7 @@ type JsonSchema = JsonSchemaString | JsonSchemaInteger | JsonSchemaDecimal | Jso
|
|
|
961
995
|
*/
|
|
962
996
|
interface JsonSchemaLike extends JsonSchemaKeywords {
|
|
963
997
|
$id?: string;
|
|
964
|
-
$schema?:
|
|
998
|
+
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
|
965
999
|
$vocabulary?: Record<string, boolean>;
|
|
966
1000
|
$comment?: string;
|
|
967
1001
|
$anchor?: string;
|
|
@@ -1127,11 +1161,11 @@ type SchemaSourceVariant = "standard-schema" | "json-schema" | "zod3" | "untyped
|
|
|
1127
1161
|
/**
|
|
1128
1162
|
* Accepted schema input variants, including raw type definitions.
|
|
1129
1163
|
*/
|
|
1130
|
-
type
|
|
1164
|
+
type SchemaConfigVariant = SchemaSourceVariant | "file-reference";
|
|
1131
1165
|
/**
|
|
1132
1166
|
* Alias for the Untyped object-input schema shape.
|
|
1133
1167
|
*/
|
|
1134
|
-
type
|
|
1168
|
+
type UntypedConfigObject = InputObject;
|
|
1135
1169
|
/**
|
|
1136
1170
|
* Alias for the Untyped schema document shape.
|
|
1137
1171
|
*/
|
|
@@ -1139,7 +1173,7 @@ type UntypedSchema = Schema;
|
|
|
1139
1173
|
/**
|
|
1140
1174
|
* A Valibot schema instance.
|
|
1141
1175
|
*
|
|
1142
|
-
* @template
|
|
1176
|
+
* @template TConfig - The raw input type accepted by the schema.
|
|
1143
1177
|
* @template TOutput - The parsed output type produced by the schema.
|
|
1144
1178
|
* @template TIssue - The issue type emitted for validation errors.
|
|
1145
1179
|
*/
|
|
@@ -1147,12 +1181,12 @@ type ValibotSchema<TInput = unknown, TOutput = unknown, TIssue extends BaseIssue
|
|
|
1147
1181
|
/**
|
|
1148
1182
|
* Raw schema source input union before normalization.
|
|
1149
1183
|
*/
|
|
1150
|
-
type
|
|
1184
|
+
type SchemaSourceConfig<TSpec = any> = StandardJSONSchemaV1<TSpec> | JsonSchemaOf<TSpec> | z3.ZodType<TSpec, any, any> | UntypedConfigObject | UntypedSchema | ValibotSchema<TSpec>;
|
|
1151
1185
|
/**
|
|
1152
1186
|
* Any accepted schema input, including normalized schemas and references.
|
|
1153
1187
|
*
|
|
1154
1188
|
* @remarks
|
|
1155
|
-
* The `
|
|
1189
|
+
* The `SchemaConfig` type can be one of the following variants:
|
|
1156
1190
|
* - A file path string (for example: `"./src/types.ts"`).
|
|
1157
1191
|
* - A URL string (for example: `"https://example.com/config.json"`).
|
|
1158
1192
|
* - A {@link GitHubReference | GitHub repository reference string}, starting with either `"github:"` or `"gh:"`, an optional branch or tag, and optionally including a specific file path within the repository (for example: `"github:main:storm-software/stryke/packages/resolve/src/types.ts"`). It is also valid to provide the branch or tag after the file path (for example: `"github:storm-software/stryke/packages/resolve/src/types.ts@main"`).
|
|
@@ -1161,16 +1195,21 @@ type SchemaSourceInput<TSpec = any> = StandardJSONSchemaV1<TSpec> | JsonSchemaOf
|
|
|
1161
1195
|
* - A file reference string (this value can include both a path to the TypeScript module and the name of the module export separated by a ":", "#", or ";" character - for example: `"./src/types.ts#ExampleExport"`).
|
|
1162
1196
|
* - A {@link FileReference} object, which contains information about a file reference.
|
|
1163
1197
|
* - A {@link URL} object, which represents a URL to fetch the file from.
|
|
1164
|
-
* - A {@link
|
|
1198
|
+
* - A {@link SchemaSourceConfig} object, which represents a raw schema input in one of the supported formats (Standard Schema, JSON Schema, Zod v3, Untyped, or Valibot).
|
|
1165
1199
|
*
|
|
1166
1200
|
* @template TSpec - The original TypeScript type for which the schema is being extracted. This type parameter is used to derive the appropriate JSON Schema representation based on the structure and constraints of `T`.
|
|
1167
1201
|
*
|
|
1168
|
-
* @see {@link
|
|
1202
|
+
* @see {@link SchemaSourceConfig}
|
|
1169
1203
|
* @see {@link SchemaEnvelope}
|
|
1170
|
-
* @see {@link
|
|
1204
|
+
* @see {@link SchemaConfigWithMeta}
|
|
1171
1205
|
*/
|
|
1172
|
-
type
|
|
1173
|
-
type InferExtractOptions<T extends
|
|
1206
|
+
type SchemaConfig<TSpec = any> = LoadReference | SchemaSourceConfig<TSpec> | SchemaEnvelope<JsonSchemaOf<TSpec>>;
|
|
1207
|
+
type InferExtractOptions<T extends SchemaConfig> = (T extends LoadReference ? Omit<InferLoadOptions<T>, "fs"> : {}) & {
|
|
1208
|
+
/**
|
|
1209
|
+
* An optional storage instance to use for caching schema extraction results. If provided, the storage instance will be used to store and retrieve cached schema extraction results, which can improve performance by avoiding redundant schema extraction operations. If not provided, the default storage mechanism will be used.
|
|
1210
|
+
*/
|
|
1211
|
+
storage?: Storage;
|
|
1212
|
+
};
|
|
1174
1213
|
/**
|
|
1175
1214
|
* A schema envelope that contains the normalized schema and its source variant.
|
|
1176
1215
|
*/
|
|
@@ -1182,7 +1221,7 @@ interface SchemaEnvelope<TJsonSchema extends JsonSchema = JsonSchema> {
|
|
|
1182
1221
|
/**
|
|
1183
1222
|
* The source variant used to derive the normalized {@link JsonSchema}.
|
|
1184
1223
|
*/
|
|
1185
|
-
variant:
|
|
1224
|
+
variant: SchemaConfigVariant;
|
|
1186
1225
|
/**
|
|
1187
1226
|
* The normalized schema definition.
|
|
1188
1227
|
*/
|
|
@@ -1205,7 +1244,7 @@ interface BaseSchemaSource<TSpec = any> {
|
|
|
1205
1244
|
/** The specific source format used for the schema input. */
|
|
1206
1245
|
variant: SchemaSourceVariant;
|
|
1207
1246
|
/** The original schema input captured before normalization. */
|
|
1208
|
-
schema:
|
|
1247
|
+
schema: SchemaSourceConfig<TSpec>;
|
|
1209
1248
|
}
|
|
1210
1249
|
/**
|
|
1211
1250
|
* Source descriptor for schemas that already use JSON Schema.
|
|
@@ -1241,7 +1280,7 @@ interface UntypedSchemaSource<TSpec = any> extends BaseSchemaSource<TSpec> {
|
|
|
1241
1280
|
/** Indicates the source input comes from the Untyped schema model. */
|
|
1242
1281
|
variant: "untyped";
|
|
1243
1282
|
/** The original Untyped schema input. */
|
|
1244
|
-
schema:
|
|
1283
|
+
schema: UntypedConfigObject | UntypedSchema;
|
|
1245
1284
|
}
|
|
1246
1285
|
/**
|
|
1247
1286
|
* Source descriptor for Valibot schema inputs.
|
|
@@ -1265,6 +1304,32 @@ interface ExtractedSchemaEnvelope<TSpec = any> extends SchemaEnvelopeOf<TSpec> {
|
|
|
1265
1304
|
*/
|
|
1266
1305
|
source: SchemaSource<TSpec>;
|
|
1267
1306
|
}
|
|
1307
|
+
declare module "zod" {
|
|
1308
|
+
interface GlobalMeta {
|
|
1309
|
+
id?: string;
|
|
1310
|
+
title?: string;
|
|
1311
|
+
description?: string;
|
|
1312
|
+
docs?: string;
|
|
1313
|
+
alias?: string[];
|
|
1314
|
+
tags?: string[];
|
|
1315
|
+
deprecated?: boolean;
|
|
1316
|
+
hidden?: boolean;
|
|
1317
|
+
ignore?: boolean;
|
|
1318
|
+
internal?: boolean;
|
|
1319
|
+
runtime?: boolean;
|
|
1320
|
+
examples?: unknown | {
|
|
1321
|
+
name?: string;
|
|
1322
|
+
description?: string;
|
|
1323
|
+
value: unknown;
|
|
1324
|
+
}[];
|
|
1325
|
+
readOnly?: boolean;
|
|
1326
|
+
writeOnly?: boolean;
|
|
1327
|
+
contentEncoding?: string;
|
|
1328
|
+
contentMediaType?: string;
|
|
1329
|
+
contentSchema?: string;
|
|
1330
|
+
[keyword: string]: unknown;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1268
1333
|
//#endregion
|
|
1269
|
-
export {
|
|
1270
|
-
//# sourceMappingURL=types.d.mts.map
|
|
1334
|
+
export { SpecOf as $, JsonSchemaObject as A, JsonSchemaStringFormat as B, JsonSchemaMetadataKeywords as C, JsonSchemaNullable as D, JsonSchemaNull as E, JsonSchemaRecordPropertyNames as F, JsonSchemaUnknown as G, JsonSchemaType as H, JsonSchemaRef as I, SchemaEnvelope as J, SchemaConfig as K, JsonSchemaSchemaSource as L, JsonSchemaPrimitiveType as M, JsonSchemaPrimitiveUnion as N, JsonSchemaNumber as O, JsonSchemaRecord as P, SchemaSourceVariant as Q, JsonSchemaSet as R, JsonSchemaMap as S, JsonSchemaNever as T, JsonSchemaUndefined as U, JsonSchemaTuple as V, JsonSchemaUnion as W, SchemaSource as X, SchemaEnvelopeOf as Y, SchemaSourceConfig as Z, JsonSchemaIntegerFormat as _, JsonSchemaAllOf as a, ValibotSchemaSource as at, JsonSchemaLiteral as b, JsonSchemaArray as c, JSON_SCHEMA_PRIMITIVE_TYPES as ct, JsonSchemaConditionalKeywords as d, SCHEMA_ARRAY_CONCAT_KEYWORDS as dt, StandardSchemaSchemaSource as et, JsonSchemaDate as f, SCHEMA_RECORD_KEYWORDS as ft, JsonSchemaInteger as g, JsonSchemaEnum as h, JsonSchema as i, ValibotSchema as it, JsonSchemaOf as j, JsonSchemaNumberFormat as k, JsonSchemaBigint as l, JSON_SCHEMA_TYPES as lt, JsonSchemaDecimalFormat as m, ExtractedSchemaEnvelope as n, UntypedSchema as nt, JsonSchemaAny as o, Zod3SchemaSource as ot, JsonSchemaDecimal as p, SCHEMA_SINGLE_KEYWORDS as pt, SchemaConfigVariant as q, InferExtractOptions as r, UntypedSchemaSource as rt, JsonSchemaAnyOf as s, JSON_SCHEMA_METADATA_KEYS as st, BaseSchemaSource as t, UntypedConfigObject as tt, JsonSchemaBoolean as u, JsonSchemaTypeNames as ut, JsonSchemaKeywords as v, JsonSchemaNativeEnum as w, JsonSchemaLogicKeywords as x, JsonSchemaLike as y, JsonSchemaString as z };
|
|
1335
|
+
//# sourceMappingURL=types-J67fcIar.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-J67fcIar.d.mts","names":[],"sources":["../src/constants.ts","../src/types.ts"],"mappings":""}
|