@power-plant/schema 0.0.2

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.
Files changed (81) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -0
  3. package/dist/bundle.cjs +1 -0
  4. package/dist/bundle.d.cts +18 -0
  5. package/dist/bundle.d.cts.map +1 -0
  6. package/dist/bundle.d.mts +18 -0
  7. package/dist/bundle.d.mts.map +1 -0
  8. package/dist/bundle.mjs +2 -0
  9. package/dist/bundle.mjs.map +1 -0
  10. package/dist/codegen.cjs +77 -0
  11. package/dist/codegen.d.cts +49 -0
  12. package/dist/codegen.d.cts.map +1 -0
  13. package/dist/codegen.d.mts +49 -0
  14. package/dist/codegen.d.mts.map +1 -0
  15. package/dist/codegen.mjs +78 -0
  16. package/dist/codegen.mjs.map +1 -0
  17. package/dist/constants-Cx9_Shfk.d.cts +32 -0
  18. package/dist/constants-Cx9_Shfk.d.cts.map +1 -0
  19. package/dist/constants-Cx9_Shfk.d.mts +32 -0
  20. package/dist/constants-Cx9_Shfk.d.mts.map +1 -0
  21. package/dist/constants.cjs +1 -0
  22. package/dist/constants.d.cts +2 -0
  23. package/dist/constants.d.mts +2 -0
  24. package/dist/constants.mjs +2 -0
  25. package/dist/constants.mjs.map +1 -0
  26. package/dist/extract.cjs +1 -0
  27. package/dist/extract.d.cts +130 -0
  28. package/dist/extract.d.cts.map +1 -0
  29. package/dist/extract.d.mts +130 -0
  30. package/dist/extract.d.mts.map +1 -0
  31. package/dist/extract.mjs +1 -0
  32. package/dist/helpers.cjs +1 -0
  33. package/dist/helpers.d.cts +123 -0
  34. package/dist/helpers.d.cts.map +1 -0
  35. package/dist/helpers.d.mts +123 -0
  36. package/dist/helpers.d.mts.map +1 -0
  37. package/dist/helpers.mjs +2 -0
  38. package/dist/helpers.mjs.map +1 -0
  39. package/dist/index.cjs +1 -0
  40. package/dist/index.d.cts +37 -0
  41. package/dist/index.d.cts.map +1 -0
  42. package/dist/index.d.mts +37 -0
  43. package/dist/index.d.mts.map +1 -0
  44. package/dist/index.mjs +1 -0
  45. package/dist/metadata.cjs +1 -0
  46. package/dist/metadata.d.cts +31 -0
  47. package/dist/metadata.d.cts.map +1 -0
  48. package/dist/metadata.d.mts +31 -0
  49. package/dist/metadata.d.mts.map +1 -0
  50. package/dist/metadata.mjs +2 -0
  51. package/dist/metadata.mjs.map +1 -0
  52. package/dist/persistence-B9pzElsC.mjs +2 -0
  53. package/dist/persistence-B9pzElsC.mjs.map +1 -0
  54. package/dist/persistence-CLni2zCP.cjs +1 -0
  55. package/dist/persistence.cjs +1 -0
  56. package/dist/persistence.d.cts +58 -0
  57. package/dist/persistence.d.cts.map +1 -0
  58. package/dist/persistence.d.mts +58 -0
  59. package/dist/persistence.d.mts.map +1 -0
  60. package/dist/persistence.mjs +1 -0
  61. package/dist/resolve.cjs +1 -0
  62. package/dist/resolve.d.cts +45 -0
  63. package/dist/resolve.d.cts.map +1 -0
  64. package/dist/resolve.d.mts +45 -0
  65. package/dist/resolve.d.mts.map +1 -0
  66. package/dist/resolve.mjs +2 -0
  67. package/dist/resolve.mjs.map +1 -0
  68. package/dist/type-checks.cjs +1 -0
  69. package/dist/type-checks.d.cts +324 -0
  70. package/dist/type-checks.d.cts.map +1 -0
  71. package/dist/type-checks.d.mts +324 -0
  72. package/dist/type-checks.d.mts.map +1 -0
  73. package/dist/type-checks.mjs +2 -0
  74. package/dist/type-checks.mjs.map +1 -0
  75. package/dist/types.cjs +0 -0
  76. package/dist/types.d.cts +1254 -0
  77. package/dist/types.d.cts.map +1 -0
  78. package/dist/types.d.mts +1254 -0
  79. package/dist/types.d.mts.map +1 -0
  80. package/dist/types.mjs +1 -0
  81. package/package.json +254 -0
@@ -0,0 +1,37 @@
1
+ import { BundleOptions, bundle } from "./bundle.cjs";
2
+ import { a as SCHEMA_ARRAY_CONCAT_KEYWORDS, c as VALID_SOURCE_FILE_EXTENSIONS, i as JsonSchemaTypeNames, n as JSON_SCHEMA_PRIMITIVE_TYPES, o as SCHEMA_RECORD_KEYWORDS, r as JSON_SCHEMA_TYPES, s as SCHEMA_SINGLE_KEYWORDS, t as JSON_SCHEMA_METADATA_KEYS } from "./constants-Cx9_Shfk.cjs";
3
+ import { BaseSchemaSource, ExtractedSchema, JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBigint, JsonSchemaBoolean, JsonSchemaConditionalKeywords, JsonSchemaDate, JsonSchemaDecimal, JsonSchemaDecimalFormat, JsonSchemaEnum, JsonSchemaInteger, JsonSchemaIntegerFormat, JsonSchemaKeywords, JsonSchemaLike, JsonSchemaLiteral, JsonSchemaLogicKeywords, JsonSchemaMap, JsonSchemaMetadataKeywords, JsonSchemaNativeEnum, JsonSchemaNever, JsonSchemaNull, JsonSchemaNullable, JsonSchemaNumber, JsonSchemaNumberFormat, JsonSchemaObject, JsonSchemaOf, JsonSchemaPrimitiveType, JsonSchemaPrimitiveUnion, JsonSchemaRecord, JsonSchemaRecordPropertyNames, JsonSchemaRef, JsonSchemaSchemaSource, JsonSchemaSet, JsonSchemaString, JsonSchemaStringFormat, JsonSchemaTuple, JsonSchemaType, JsonSchemaUndefined, JsonSchemaUnion, JsonSchemaUnknown, Schema, SchemaInput, SchemaInputVariant, SchemaInputWithMeta, SchemaMeta, SchemaOf, SchemaSource, SchemaSourceInput, SchemaSourceVariant, SpecOf, StandardSchemaSchemaSource, UntypedInputObject, UntypedSchema, UntypedSchemaSource, ValibotSchema, ValibotSchemaSource, Zod3SchemaSource } from "./types.cjs";
4
+ import { GenerateParserCodeOptions, generateParserCode, getJsonSchemaType, stringifyType, stringifyValue } from "./codegen.cjs";
5
+ import { ExtractOptions, bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant } from "./extract.cjs";
6
+ import { GetPropertyResult, addProperty, getJsonSchema, getJsonSchemaObject, getProperties, getPropertiesList, getProperty, isPropertyOptional, isSchemaNullable, isValidSchemaInputFile, merge } from "./helpers.cjs";
7
+ import { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes } from "./metadata.cjs";
8
+ import { PersistenceContext, getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema } from "./persistence.cjs";
9
+ import { ResolveOptions, resolve, resolveModule, resolveSafe, resolveTSType } from "./resolve.cjs";
10
+ import { 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, isSchema, isSchemaObject, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema } from "./type-checks.cjs";
11
+
12
+ //#region src/index.d.ts
13
+ declare module "zod" {
14
+ interface GlobalMeta {
15
+ id?: string;
16
+ title?: string;
17
+ description?: string;
18
+ docs?: string;
19
+ alias?: string[];
20
+ tags?: string[];
21
+ deprecated?: boolean;
22
+ hidden?: boolean;
23
+ ignore?: boolean;
24
+ internal?: boolean;
25
+ runtime?: boolean;
26
+ examples?: unknown[];
27
+ readOnly?: boolean;
28
+ writeOnly?: boolean;
29
+ contentEncoding?: string;
30
+ contentMediaType?: string;
31
+ contentSchema?: string;
32
+ [keyword: string]: unknown;
33
+ }
34
+ }
35
+ //#endregion
36
+ export { BaseSchemaSource, BundleOptions, ExtractOptions, ExtractedSchema, GenerateParserCodeOptions, GetPropertyResult, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBigint, JsonSchemaBoolean, JsonSchemaConditionalKeywords, JsonSchemaDate, JsonSchemaDecimal, JsonSchemaDecimalFormat, JsonSchemaEnum, JsonSchemaInteger, JsonSchemaIntegerFormat, JsonSchemaKeywords, JsonSchemaLike, JsonSchemaLiteral, JsonSchemaLogicKeywords, JsonSchemaMap, JsonSchemaMetadataKeywords, JsonSchemaNativeEnum, JsonSchemaNever, JsonSchemaNull, JsonSchemaNullable, JsonSchemaNumber, JsonSchemaNumberFormat, JsonSchemaObject, JsonSchemaOf, JsonSchemaPrimitiveType, JsonSchemaPrimitiveUnion, JsonSchemaRecord, JsonSchemaRecordPropertyNames, JsonSchemaRef, JsonSchemaSchemaSource, JsonSchemaSet, JsonSchemaString, JsonSchemaStringFormat, JsonSchemaTuple, JsonSchemaType, JsonSchemaTypeNames, JsonSchemaUndefined, JsonSchemaUnion, JsonSchemaUnknown, PersistenceContext, ResolveOptions, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, Schema, SchemaInput, SchemaInputVariant, SchemaInputWithMeta, SchemaMeta, SchemaOf, SchemaSource, SchemaSourceInput, SchemaSourceVariant, SpecOf, StandardSchemaSchemaSource, UntypedInputObject, UntypedSchema, UntypedSchemaSource, VALID_SOURCE_FILE_EXTENSIONS, ValibotSchema, ValibotSchemaSource, Zod3SchemaSource, addProperty, applyJsonSchemaMetadata, bundle, bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant, generateParserCode, getCacheDirectory, getCacheFilePath, getJsonSchema, getJsonSchemaObject, getJsonSchemaType, 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, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaInputFile, merge, readSchema, readSchemaSafe, readSchemaTypes, resolve, resolveModule, resolveSafe, resolveTSType, stringifyType, stringifyValue, writeSchema };
37
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;YAmBY,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;IACA,QAAA;IACA,SAAA;IACA,eAAA;IACA,gBAAA;IACA,aAAA;IAAA,CACC,OAAA;EAAA;AAAA"}
@@ -0,0 +1,37 @@
1
+ import { BundleOptions, bundle } from "./bundle.mjs";
2
+ import { a as SCHEMA_ARRAY_CONCAT_KEYWORDS, c as VALID_SOURCE_FILE_EXTENSIONS, i as JsonSchemaTypeNames, n as JSON_SCHEMA_PRIMITIVE_TYPES, o as SCHEMA_RECORD_KEYWORDS, r as JSON_SCHEMA_TYPES, s as SCHEMA_SINGLE_KEYWORDS, t as JSON_SCHEMA_METADATA_KEYS } from "./constants-Cx9_Shfk.mjs";
3
+ import { BaseSchemaSource, ExtractedSchema, JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBigint, JsonSchemaBoolean, JsonSchemaConditionalKeywords, JsonSchemaDate, JsonSchemaDecimal, JsonSchemaDecimalFormat, JsonSchemaEnum, JsonSchemaInteger, JsonSchemaIntegerFormat, JsonSchemaKeywords, JsonSchemaLike, JsonSchemaLiteral, JsonSchemaLogicKeywords, JsonSchemaMap, JsonSchemaMetadataKeywords, JsonSchemaNativeEnum, JsonSchemaNever, JsonSchemaNull, JsonSchemaNullable, JsonSchemaNumber, JsonSchemaNumberFormat, JsonSchemaObject, JsonSchemaOf, JsonSchemaPrimitiveType, JsonSchemaPrimitiveUnion, JsonSchemaRecord, JsonSchemaRecordPropertyNames, JsonSchemaRef, JsonSchemaSchemaSource, JsonSchemaSet, JsonSchemaString, JsonSchemaStringFormat, JsonSchemaTuple, JsonSchemaType, JsonSchemaUndefined, JsonSchemaUnion, JsonSchemaUnknown, Schema, SchemaInput, SchemaInputVariant, SchemaInputWithMeta, SchemaMeta, SchemaOf, SchemaSource, SchemaSourceInput, SchemaSourceVariant, SpecOf, StandardSchemaSchemaSource, UntypedInputObject, UntypedSchema, UntypedSchemaSource, ValibotSchema, ValibotSchemaSource, Zod3SchemaSource } from "./types.mjs";
4
+ import { GenerateParserCodeOptions, generateParserCode, getJsonSchemaType, stringifyType, stringifyValue } from "./codegen.mjs";
5
+ import { ExtractOptions, bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant } from "./extract.mjs";
6
+ import { GetPropertyResult, addProperty, getJsonSchema, getJsonSchemaObject, getProperties, getPropertiesList, getProperty, isPropertyOptional, isSchemaNullable, isValidSchemaInputFile, merge } from "./helpers.mjs";
7
+ import { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes } from "./metadata.mjs";
8
+ import { PersistenceContext, getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema } from "./persistence.mjs";
9
+ import { ResolveOptions, resolve, resolveModule, resolveSafe, resolveTSType } from "./resolve.mjs";
10
+ import { 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, isSchema, isSchemaObject, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema } from "./type-checks.mjs";
11
+
12
+ //#region src/index.d.ts
13
+ declare module "zod" {
14
+ interface GlobalMeta {
15
+ id?: string;
16
+ title?: string;
17
+ description?: string;
18
+ docs?: string;
19
+ alias?: string[];
20
+ tags?: string[];
21
+ deprecated?: boolean;
22
+ hidden?: boolean;
23
+ ignore?: boolean;
24
+ internal?: boolean;
25
+ runtime?: boolean;
26
+ examples?: unknown[];
27
+ readOnly?: boolean;
28
+ writeOnly?: boolean;
29
+ contentEncoding?: string;
30
+ contentMediaType?: string;
31
+ contentSchema?: string;
32
+ [keyword: string]: unknown;
33
+ }
34
+ }
35
+ //#endregion
36
+ export { BaseSchemaSource, BundleOptions, ExtractOptions, ExtractedSchema, GenerateParserCodeOptions, GetPropertyResult, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBigint, JsonSchemaBoolean, JsonSchemaConditionalKeywords, JsonSchemaDate, JsonSchemaDecimal, JsonSchemaDecimalFormat, JsonSchemaEnum, JsonSchemaInteger, JsonSchemaIntegerFormat, JsonSchemaKeywords, JsonSchemaLike, JsonSchemaLiteral, JsonSchemaLogicKeywords, JsonSchemaMap, JsonSchemaMetadataKeywords, JsonSchemaNativeEnum, JsonSchemaNever, JsonSchemaNull, JsonSchemaNullable, JsonSchemaNumber, JsonSchemaNumberFormat, JsonSchemaObject, JsonSchemaOf, JsonSchemaPrimitiveType, JsonSchemaPrimitiveUnion, JsonSchemaRecord, JsonSchemaRecordPropertyNames, JsonSchemaRef, JsonSchemaSchemaSource, JsonSchemaSet, JsonSchemaString, JsonSchemaStringFormat, JsonSchemaTuple, JsonSchemaType, JsonSchemaTypeNames, JsonSchemaUndefined, JsonSchemaUnion, JsonSchemaUnknown, PersistenceContext, ResolveOptions, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, Schema, SchemaInput, SchemaInputVariant, SchemaInputWithMeta, SchemaMeta, SchemaOf, SchemaSource, SchemaSourceInput, SchemaSourceVariant, SpecOf, StandardSchemaSchemaSource, UntypedInputObject, UntypedSchema, UntypedSchemaSource, VALID_SOURCE_FILE_EXTENSIONS, ValibotSchema, ValibotSchemaSource, Zod3SchemaSource, addProperty, applyJsonSchemaMetadata, bundle, bundleReferences, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant, generateParserCode, getCacheDirectory, getCacheFilePath, getJsonSchema, getJsonSchemaObject, getJsonSchemaType, 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, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaInputFile, merge, readSchema, readSchemaSafe, readSchemaTypes, resolve, resolveModule, resolveSafe, resolveTSType, stringifyType, stringifyValue, writeSchema };
37
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":""}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
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,VALID_SOURCE_FILE_EXTENSIONS as s}from"./constants.mjs";import{isFileReference as c,isJsonSchema as l,isJsonSchemaAllOf as u,isJsonSchemaAny as d,isJsonSchemaAnyOf as f,isJsonSchemaArray as p,isJsonSchemaBigint as m,isJsonSchemaBoolean as h,isJsonSchemaDate as g,isJsonSchemaDecimal as _,isJsonSchemaEnum as v,isJsonSchemaInteger as y,isJsonSchemaKeywords as b,isJsonSchemaLiteral as x,isJsonSchemaMap as S,isJsonSchemaNativeEnum as C,isJsonSchemaNever as w,isJsonSchemaNull as T,isJsonSchemaNullable as E,isJsonSchemaNumber as D,isJsonSchemaObject as O,isJsonSchemaPrimitiveType as k,isJsonSchemaPrimitiveUnion as A,isJsonSchemaRecord as j,isJsonSchemaRef as M,isJsonSchemaSet as N,isJsonSchemaString as P,isJsonSchemaTuple as F,isJsonSchemaType as I,isJsonSchemaUndefined as L,isJsonSchemaUnion as R,isJsonSchemaUnknown as z,isNullOnlyJsonSchema as B,isSchema as V,isSchemaObject 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{bundle as X}from"./bundle.mjs";import{resolve as Z,resolveModule as Q,resolveSafe as $,resolveTSType as ee}from"./resolve.mjs";import{a as te,c as ne,d as re,f as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as fe,t as pe,u as me}from"./persistence-B9pzElsC.mjs";import{applyJsonSchemaMetadata as he,getPrimarySchemaType as ge,readSchemaTypes as _e}from"./metadata.mjs";import{addProperty as ve,getJsonSchema as ye,getJsonSchemaObject as be,getProperties as xe,getPropertiesList as Se,getProperty as Ce,isPropertyOptional as we,isSchemaNullable as Te,isValidSchemaInputFile as Ee,merge as De}from"./helpers.mjs";import{generateParserCode as Oe,getJsonSchemaType as ke,stringifyType as Ae,stringifyValue as je}from"./codegen.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,s as VALID_SOURCE_FILE_EXTENSIONS,ve as addProperty,he as applyJsonSchemaMetadata,X as bundle,le as bundleReferences,fe as extract,ne as extractHash,oe as extractJsonSchema,me as extractResolvedVariant,re as extractSchema,ie as extractSchemaWithSource,ue as extractSource,se as extractVariant,Oe as generateParserCode,pe as getCacheDirectory,ce as getCacheFilePath,ye as getJsonSchema,be as getJsonSchemaObject,ke as getJsonSchemaType,ge as getPrimarySchemaType,xe as getProperties,Se as getPropertiesList,Ce as getProperty,c as isFileReference,l as isJsonSchema,u as isJsonSchemaAllOf,d as isJsonSchemaAny,f as isJsonSchemaAnyOf,p as isJsonSchemaArray,m as isJsonSchemaBigint,h as isJsonSchemaBoolean,g as isJsonSchemaDate,_ as isJsonSchemaDecimal,v as isJsonSchemaEnum,y as isJsonSchemaInteger,b as isJsonSchemaKeywords,x as isJsonSchemaLiteral,S as isJsonSchemaMap,C as isJsonSchemaNativeEnum,w as isJsonSchemaNever,T as isJsonSchemaNull,E as isJsonSchemaNullable,D as isJsonSchemaNumber,O as isJsonSchemaObject,k as isJsonSchemaPrimitiveType,A as isJsonSchemaPrimitiveUnion,j as isJsonSchemaRecord,M as isJsonSchemaRef,N as isJsonSchemaSet,P as isJsonSchemaString,F as isJsonSchemaTuple,I as isJsonSchemaType,L as isJsonSchemaUndefined,R as isJsonSchemaUnion,z as isJsonSchemaUnknown,B as isNullOnlyJsonSchema,we as isPropertyOptional,V as isSchema,Te as isSchemaNullable,H as isSchemaObject,U as isSchemaWithSource,W as isStandardSchema,G as isUntypedInput,K as isUntypedInputStrict,q as isUntypedSchema,J as isUntypedSchemaStrict,Y as isValibotSchema,Ee as isValidSchemaInputFile,De as merge,de as readSchema,ae as readSchemaSafe,_e as readSchemaTypes,Z as resolve,Q as resolveModule,$ as resolveSafe,ee as resolveTSType,Ae as stringifyType,je as stringifyValue,te as writeSchema};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants.cjs");let t=require("@stryke/type-checks/is-set-string"),n=require("@stryke/type-checks/is-set-object");function r(t,r){if(!r||!(0,n.isSetObject)(t))return t;let i={...t},a=i;for(let t of e.JSON_SCHEMA_METADATA_KEYS){let e=r[t];e!=null&&(a[t]=e)}return i}function i(e){if(!(0,n.isSetObject)(e))return[];let r=e;return Array.isArray(r.type)?r.type.filter(e=>(0,t.isSetString)(e)):(0,t.isSetString)(r.type)&&r.type!==`object`&&r.type!==`array`?[r.type]:[]}function a(e){if((0,n.isSetObject)(e))return i(e).find(e=>e!==`null`)}exports.applyJsonSchemaMetadata=r,exports.getPrimarySchemaType=a,exports.readSchemaTypes=i;
@@ -0,0 +1,31 @@
1
+ import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaPrimitiveType } from "./types.cjs";
2
+
3
+ //#region src/metadata.d.ts
4
+ /**
5
+ * Applies Powerlines schema metadata onto a JSON Schema fragment.
6
+ *
7
+ * @param schema - The JSON Schema fragment to apply metadata to.
8
+ * @param metadata - The Powerlines schema metadata to apply.
9
+ * @returns A new JSON Schema fragment with the metadata applied.
10
+ */
11
+ declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
12
+ /**
13
+ * Normalizes the JSON Schema `type` keyword to a string array.
14
+ *
15
+ * @remarks
16
+ * This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
17
+ *
18
+ * @param schema - The JSON Schema fragment to read types from.
19
+ * @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
20
+ */
21
+ declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
22
+ /**
23
+ * Returns the primary non-null JSON Schema type name for a fragment.
24
+ *
25
+ * @param schema - The JSON Schema fragment to check.
26
+ * @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
27
+ */
28
+ declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
29
+ //#endregion
30
+ export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
31
+ //# sourceMappingURL=metadata.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.cts","names":[],"sources":["../src/metadata.ts"],"mappings":";;;;;AAuCA;;;;;iBAAgB,uBAAA,CACd,MAAA,EAAQ,UAAA,EACR,QAAA,EAAU,0BAAA,eACT,UAAA;;;;;;;;;AAAU;iBA0BG,eAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB;;;;;;;iBA6BV,oBAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB"}
@@ -0,0 +1,31 @@
1
+ import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaPrimitiveType } from "./types.mjs";
2
+
3
+ //#region src/metadata.d.ts
4
+ /**
5
+ * Applies Powerlines schema metadata onto a JSON Schema fragment.
6
+ *
7
+ * @param schema - The JSON Schema fragment to apply metadata to.
8
+ * @param metadata - The Powerlines schema metadata to apply.
9
+ * @returns A new JSON Schema fragment with the metadata applied.
10
+ */
11
+ declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
12
+ /**
13
+ * Normalizes the JSON Schema `type` keyword to a string array.
14
+ *
15
+ * @remarks
16
+ * This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
17
+ *
18
+ * @param schema - The JSON Schema fragment to read types from.
19
+ * @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
20
+ */
21
+ declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
22
+ /**
23
+ * Returns the primary non-null JSON Schema type name for a fragment.
24
+ *
25
+ * @param schema - The JSON Schema fragment to check.
26
+ * @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
27
+ */
28
+ declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
29
+ //#endregion
30
+ export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
31
+ //# sourceMappingURL=metadata.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.mts","names":[],"sources":["../src/metadata.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{JSON_SCHEMA_METADATA_KEYS as e}from"./constants.mjs";import{isSetString as t}from"@stryke/type-checks/is-set-string";import{isSetObject as n}from"@stryke/type-checks/is-set-object";function r(t,r){if(!r||!n(t))return t;let i={...t},a=i;for(let t of e){let e=r[t];e!=null&&(a[t]=e)}return i}function i(e){if(!n(e))return[];let r=e;return Array.isArray(r.type)?r.type.filter(e=>t(e)):t(r.type)&&r.type!==`object`&&r.type!==`array`?[r.type]:[]}function a(e){if(n(e))return i(e).find(e=>e!==`null`)}export{r as applyJsonSchemaMetadata,a as getPrimarySchemaType,i as readSchemaTypes};
2
+ //# sourceMappingURL=metadata.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.mjs","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{VALID_SOURCE_FILE_EXTENSIONS as e}from"./constants.mjs";import{isFileReference as t,isJsonSchema as n,isJsonSchemaObject as r,isSchema as i,isSchemaWithSource as a,isUntypedInput as o,isUntypedInputStrict as s,isUntypedSchema as c,isUntypedSchemaStrict as l,isValibotSchema as u}from"./type-checks.mjs";import{resolveSafe as d,resolveTSType as f}from"./resolve.mjs";import{isSetString as p}from"@stryke/type-checks";import{extractFileReference as m}from"@stryke/convert/extract-file-reference";import{findFileExtensionSafe as h}from"@stryke/path/find";import{mkdir as g,readFile as _,writeFile as v}from"node:fs/promises";import{existsSync as y}from"node:fs";import{joinPaths as b}from"@stryke/path/join";import{getEnvPaths as ee}from"@stryke/env/get-env-paths";import{murmurhash as x}from"@stryke/hash";import{deepClone as S}from"@stryke/helpers/deep-clone";import{isStandardJsonSchema as C}from"@stryke/json";import{list as te}from"@stryke/string-format/list";import{isSetObject as w}from"@stryke/type-checks/is-set-object";import{extractJsonSchema as T,isZod3Type as E}from"@stryke/zod";import{toJsonSchema as D}from"@valibot/to-json-schema";const O=`https://powerlines.invalid/`;function ne(e){return!w(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e?!1:Object.keys(e).every(e=>e===`schema`||e===`meta`)}function k(e){return ne(e)?{input:e.schema,meta:e.meta}:{input:e}}function A(e){return e.endsWith(`#`)?e.slice(0,-1):e}function j(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function M(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function N(e){return e.length===0?``:`/${e.map(e=>M(e)).join(`/`)}`}function P(e,t){try{return A(new URL(e,t).toString())}catch{return A(e)}}function F(e,t,n,r,i){if(!w(e))return;let a=e,o=N(t),s=p(a.$id)?P(a.$id,n):n,c=j(s);if(r.set(s,o),r.set(c,o),p(a.$anchor)&&r.set(`${c}#${a.$anchor}`,o),p(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)=>{F(n,[...t,e,String(a)],s,r,i)});continue}F(n,[...t,e],s,r,i)}}function I(e,t,n,r,i){if(!w(e))return;let a=e,o=p(a.$id)?P(a.$id,n):n;if(p(a.$ref)){let e=P(a.$ref,o),t=r.get(e)??r.get(j(e));t!==void 0&&(a.$ref=t.length>0?`#${t}`:`#`)}if(p(a.$dynamicRef)){let e=P(a.$dynamicRef,o),t=i.get(e);if(t)a.$dynamicRef=t;else{let t=r.get(e)??r.get(j(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)=>{I(n,[...t,e,String(a)],o,r,i)});continue}I(n,[...t,e],o,r,i)}}function L(e){if(!w(e))return e;let t=S(e),n=p(t.$id)?P(t.$id,O):O,r=new Map,i=new Map;return F(t,[],n,r,i),I(t,[],n,r,i),t}function R(e){if(c(e))return V(e);if(w(e)){if(o(e))return H(e);let t=e;if(`$schema`in t&&c(t.$schema))return V(t.$schema)}return e}function z(e){return Array.isArray(e)?e.map(e=>R(e)):e}function B(e){return D(e,{target:`draft-2020-12`})}function V(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`&&p(r)){n.$id=r;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!w(r)){n[e]=r;continue}n[e]=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,R(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=R(r);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=z(r);continue}n[e]=r}return n}function H(e){let t=e,n=c(t.$schema)?V(t.$schema):{},i={};for(let[e,n]of Object.entries(t)){if(e.startsWith(`$`)||!w(n))continue;if(o(n)){i[e]=H(n);continue}let t=n;if(`$schema`in t&&c(t.$schema)){i[e]=V(t.$schema);continue}c(n)&&(i[e]=V(n))}if(!r(n))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let a={...w(n.properties)?n.properties:{},...i};return{...n,type:n.type??`object`,...Object.keys(a).length>0?{properties:a}:{}}}function U(e,t){let{input:r}=k(t);if(a(r)||i(r))return x({variant:e,input:r.schema});if(p(r)||typeof r==`boolean`)return x({variant:e,input:r});if(w(r)){if(E(r))return x({variant:e,input:r._def});if(C(r))return x({variant:e,input:r[`~standard`]});if(n(r))return x({variant:e,input:r});if(u(r))return x({variant:e,input:B(r)});if(o(r))return x({variant:e,input:H(r)});if(c(r))return x({variant:e,input:V(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 W(e){if(w(e)){if(E(e))return T(e,{target:`draft-2020-12`});if(s(e))return H(e);if(l(e))return V(e);if(C(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(u(e))return B(e);if(n(e))return e}}function G(e){if(w(e)){if(E(e))return`zod3`;if(s(e)||l(e))return`untyped`;if(C(e))return`standard-schema`;if(n(e))return`json-schema`;if(u(e))return`valibot`}throw Error(`Failed to determine the variant of the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a Valibot BaseSchema, a reflected Deepkit Type object, or an Untyped schema.`)}function K(e){let{input:n}=k(e);return a(n)||i(n)?n.variant:p(n)||t(n)?`file-reference`:G(n)}async function q(e,t){if(a(e))return e.schema;let n=t??G(e),r;if((n===`zod3`||n===`json-schema`||n===`standard-schema`||n===`untyped`||n===`valibot`)&&(r=W(e)),r)return L(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 J(e,t){if(e===`zod3`)return{hash:U(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:U(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:U(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:U(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:U(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 Y(t,n={}){let{input:r,meta:o}=k(t);if(a(r))return o===void 0?r:{...r,meta:o};if(i(r))return{...r,...o===void 0?{}:{meta:o},source:{hash:U(`json-schema`,r.schema),variant:`json-schema`,schema:r.schema}};let s,c=K(r),l=U(c,r),u=o;if(c===`file-reference`){let t=m(r);if(!t)throw Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(r)}". Please ensure that the input is correctly formatted as a file reference (e.g. "./schema.ts#MySchema") and that the file exists at the specified path.`);let o=h(t.file);if(o&&!e.includes(o))throw Error(`The provided schema file input "${t.file}" has an invalid file extension (.${o}). Please ensure that the file has one of the following extensions: ${te(e,{conjunction:`or`})}.`);let c=await d(r,n);c??=await f(r,n);let{input:l,meta:p}=k(c);u===void 0&&p!==void 0&&(u=p),s=a(l)?l.source:i(l)?{hash:U(`json-schema`,l.schema),variant:`json-schema`,schema:l.schema}:J(G(l),l)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(c))s=J(c,r);else throw Error(`Invalid schema definition input "${c}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);let p={variant:c,source:s,schema:await q(s.schema,s.variant),hash:l};return u!==void 0&&(p.meta=u),p}async function re(e,t={}){let{input:n,meta:r}=k(e);if(a(n)||i(n))return r===void 0?n:{...n,meta:r};let o,s=K(n),c=U(s,n),l=t.cachePath??ee().cache,u={cachePath:l},d=b(X(u),`${c}.json`);if(t.skipCache!==!0&&y(d)){let e=await _(d,`utf8`);if(e){let t={variant:s,hash:c,schema:JSON.parse(e)};r!==void 0&&(t.meta=r),o=t}}if(o??=await Y(e,{...t,cachePath:l}),r!==void 0&&o&&(o.meta=r),!o?.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 t.skipCache!==!0&&await Q(u,o),o}function X(e){return b(e.cachePath,`schemas`)}function Z(e,t){let n=U(K(t),t);return b(X(e),`${n}.json`)}async function Q(e,t){if(!i(t))throw Error(`The provided input is not a valid schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);let n=X(e),r=e.fs?.mkdir??g,a=e.fs?.write??v;!y(n)&&!e.fs?.mkdir?await g(n,{recursive:!0}):e.fs?.mkdir&&await r(n,{recursive:!0}),await a(Z(e,t),JSON.stringify(t.schema))}async function $(e,t){let n=Z(e,t),r=e.fs?.exists??(async e=>Promise.resolve(y(e))),a=e.fs?.read??_;if(!await r(n))return;let o=await a(n);if(!o)return;let s=JSON.parse(typeof o==`string`?o:o.toString());if(i(s))return s}async function ie(e,t){let n=await $(e,t);if(!n){let e=K(t),n=U(e,t);throw Error(`The ${e} schema with hash "${n}" does not exist in the cache. This may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. Please ensure that the schema is properly written to the cache before attempting to read it.`)}return n}export{Q as a,U as c,q as d,Y as f,$ as i,W as l,K as m,Z as n,L as o,J as p,ie as r,re as s,X as t,G as u};
2
+ //# sourceMappingURL=persistence-B9pzElsC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence-B9pzElsC.mjs","names":[],"sources":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const e=require("./constants.cjs"),t=require("./type-checks.cjs"),n=require("./resolve.cjs");let r=require("@stryke/type-checks"),i=require("@stryke/convert/extract-file-reference"),a=require("@stryke/path/find"),o=require("node:fs/promises"),s=require("node:fs"),c=require("@stryke/path/join"),l=require("@stryke/env/get-env-paths"),u=require("@stryke/hash"),d=require("@stryke/helpers/deep-clone"),f=require("@stryke/json"),p=require("@stryke/string-format/list"),m=require("@stryke/type-checks/is-set-object"),h=require("@stryke/zod"),g=require("@valibot/to-json-schema");const _=`https://powerlines.invalid/`;function v(e){return!(0,m.isSetObject)(e)||!(`schema`in e)||`hash`in e||`variant`in e||`source`in e?!1:Object.keys(e).every(e=>e===`schema`||e===`meta`)}function y(e){return v(e)?{input:e.schema,meta:e.meta}:{input:e}}function b(e){return e.endsWith(`#`)?e.slice(0,-1):e}function x(e){let t=e.indexOf(`#`);return t>=0?e.slice(0,t):e}function S(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function C(e){return e.length===0?``:`/${e.map(e=>S(e)).join(`/`)}`}function w(e,t){try{return b(new URL(e,t).toString())}catch{return b(e)}}function T(e,t,n,i,a){if(!(0,m.isSetObject)(e))return;let o=e,s=C(t),c=(0,r.isSetString)(o.$id)?w(o.$id,n):n,l=x(c);if(i.set(c,s),i.set(l,s),(0,r.isSetString)(o.$anchor)&&i.set(`${l}#${o.$anchor}`,s),(0,r.isSetString)(o.$dynamicAnchor)){let e=`${l}#${o.$dynamicAnchor}`;i.set(e,s),a.set(e,`#${o.$dynamicAnchor}`)}for(let[e,n]of Object.entries(o)){if(Array.isArray(n)){n.forEach((n,r)=>{T(n,[...t,e,String(r)],c,i,a)});continue}T(n,[...t,e],c,i,a)}}function E(e,t,n,i,a){if(!(0,m.isSetObject)(e))return;let o=e,s=(0,r.isSetString)(o.$id)?w(o.$id,n):n;if((0,r.isSetString)(o.$ref)){let e=w(o.$ref,s),t=i.get(e)??i.get(x(e));t!==void 0&&(o.$ref=t.length>0?`#${t}`:`#`)}if((0,r.isSetString)(o.$dynamicRef)){let e=w(o.$dynamicRef,s),t=a.get(e);if(t)o.$dynamicRef=t;else{let t=i.get(e)??i.get(x(e));t!==void 0&&(o.$dynamicRef=t.length>0?`#${t}`:`#`)}}for(let[e,n]of Object.entries(o)){if(Array.isArray(n)){n.forEach((n,r)=>{E(n,[...t,e,String(r)],s,i,a)});continue}E(n,[...t,e],s,i,a)}}function D(e){if(!(0,m.isSetObject)(e))return e;let t=(0,d.deepClone)(e),n=(0,r.isSetString)(t.$id)?w(t.$id,_):_,i=new Map,a=new Map;return T(t,[],n,i,a),E(t,[],n,i,a),t}function O(e){if(t.isUntypedSchema(e))return j(e);if((0,m.isSetObject)(e)){if(t.isUntypedInput(e))return M(e);let n=e;if(`$schema`in n&&t.isUntypedSchema(n.$schema))return j(n.$schema)}return e}function k(e){return Array.isArray(e)?e.map(e=>O(e)):e}function A(e){return(0,g.toJsonSchema)(e,{target:`draft-2020-12`})}function j(e){let t=e,n={};for(let[e,i]of Object.entries(t))if(!(e===`tsType`||e===`markdownType`||e===`tags`||e===`args`||e===`resolve`)){if(e===`id`&&(0,r.isSetString)(i)){n.$id=i;continue}if(e===`properties`||e===`patternProperties`||e===`dependentSchemas`||e===`$defs`||e===`definitions`){if(!(0,m.isSetObject)(i)){n[e]=i;continue}n[e]=Object.fromEntries(Object.entries(i).map(([e,t])=>[e,O(t)]));continue}if(e===`items`||e===`contains`||e===`if`||e===`then`||e===`else`||e===`not`||e===`propertyNames`||e===`additionalProperties`||e===`unevaluatedProperties`){n[e]=O(i);continue}if(e===`oneOf`||e===`anyOf`||e===`allOf`){n[e]=k(i);continue}n[e]=i}return n}function M(e){let n=e,r=t.isUntypedSchema(n.$schema)?j(n.$schema):{},i={};for(let[e,r]of Object.entries(n)){if(e.startsWith(`$`)||!(0,m.isSetObject)(r))continue;if(t.isUntypedInput(r)){i[e]=M(r);continue}let n=r;if(`$schema`in n&&t.isUntypedSchema(n.$schema)){i[e]=j(n.$schema);continue}t.isUntypedSchema(r)&&(i[e]=j(r))}if(!t.isJsonSchemaObject(r))throw Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);let a={...(0,m.isSetObject)(r.properties)?r.properties:{},...i};return{...r,type:r.type??`object`,...Object.keys(a).length>0?{properties:a}:{}}}function N(e,n){let{input:i}=y(n);if(t.isSchemaWithSource(i)||t.isSchema(i))return(0,u.murmurhash)({variant:e,input:i.schema});if((0,r.isSetString)(i)||typeof i==`boolean`)return(0,u.murmurhash)({variant:e,input:i});if((0,m.isSetObject)(i)){if((0,h.isZod3Type)(i))return(0,u.murmurhash)({variant:e,input:i._def});if((0,f.isStandardJsonSchema)(i))return(0,u.murmurhash)({variant:e,input:i[`~standard`]});if(t.isJsonSchema(i))return(0,u.murmurhash)({variant:e,input:i});if(t.isValibotSchema(i))return(0,u.murmurhash)({variant:e,input:A(i)});if(t.isUntypedInput(i))return(0,u.murmurhash)({variant:e,input:M(i)});if(t.isUntypedSchema(i))return(0,u.murmurhash)({variant:e,input:j(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 P(e){if((0,m.isSetObject)(e)){if((0,h.isZod3Type)(e))return(0,h.extractJsonSchema)(e,{target:`draft-2020-12`});if(t.isUntypedInputStrict(e))return M(e);if(t.isUntypedSchemaStrict(e))return j(e);if((0,f.isStandardJsonSchema)(e))return e[`~standard`].jsonSchema.input({target:`draft-2020-12`});if(t.isValibotSchema(e))return A(e);if(t.isJsonSchema(e))return e}}function F(e){if((0,m.isSetObject)(e)){if((0,h.isZod3Type)(e))return`zod3`;if(t.isUntypedInputStrict(e)||t.isUntypedSchemaStrict(e))return`untyped`;if((0,f.isStandardJsonSchema)(e))return`standard-schema`;if(t.isJsonSchema(e))return`json-schema`;if(t.isValibotSchema(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 I(e){let{input:n}=y(e);return t.isSchemaWithSource(n)||t.isSchema(n)?n.variant:(0,r.isSetString)(n)||t.isFileReference(n)?`file-reference`:F(n)}async function L(e,n){if(t.isSchemaWithSource(e))return e.schema;let r=n??F(e),i;if((r===`zod3`||r===`json-schema`||r===`standard-schema`||r===`untyped`||r===`valibot`)&&(i=P(e)),i)return D(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 R(e,t){if(e===`zod3`)return{hash:N(e,t),variant:`zod3`,schema:t};if(e===`untyped`)return{hash:N(e,t),variant:`untyped`,schema:t};if(e===`standard-schema`)return{hash:N(e,t),variant:`standard-schema`,schema:t};if(e===`json-schema`)return{hash:N(e,t),variant:`json-schema`,schema:t};if(e===`valibot`)return{hash:N(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 z(r,o={}){let{input:s,meta:c}=y(r);if(t.isSchemaWithSource(s))return c===void 0?s:{...s,meta:c};if(t.isSchema(s))return{...s,...c===void 0?{}:{meta:c},source:{hash:N(`json-schema`,s.schema),variant:`json-schema`,schema:s.schema}};let l,u=I(s),d=N(u,s),f=c;if(u===`file-reference`){let r=(0,i.extractFileReference)(s);if(!r)throw Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(s)}". 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 c=(0,a.findFileExtensionSafe)(r.file);if(c&&!e.VALID_SOURCE_FILE_EXTENSIONS.includes(c))throw Error(`The provided schema file input "${r.file}" has an invalid file extension (.${c}). Please ensure that the file has one of the following extensions: ${(0,p.list)(e.VALID_SOURCE_FILE_EXTENSIONS,{conjunction:`or`})}.`);let u=await n.resolveSafe(s,o);u??=await n.resolveTSType(s,o);let{input:d,meta:m}=y(u);f===void 0&&m!==void 0&&(f=m),l=t.isSchemaWithSource(d)?d.source:t.isSchema(d)?{hash:N(`json-schema`,d.schema),variant:`json-schema`,schema:d.schema}:R(F(d),d)}else if([`json-schema`,`standard-schema`,`zod3`,`untyped`,`valibot`,`reflection`].includes(u))l=R(u,s);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".`);let m={variant:u,source:l,schema:await L(l.schema,l.variant),hash:d};return f!==void 0&&(m.meta=f),m}async function B(e,n={}){let{input:r,meta:i}=y(e);if(t.isSchemaWithSource(r)||t.isSchema(r))return i===void 0?r:{...r,meta:i};let a,u=I(r),d=N(u,r),f=n.cachePath??(0,l.getEnvPaths)().cache,p={cachePath:f},m=(0,c.joinPaths)(V(p),`${d}.json`);if(n.skipCache!==!0&&(0,s.existsSync)(m)){let e=await(0,o.readFile)(m,`utf8`);if(e){let t={variant:u,hash:d,schema:JSON.parse(e)};i!==void 0&&(t.meta=i),a=t}}if(a??=await z(e,{...n,cachePath:f}),i!==void 0&&a&&(a.meta=i),!a?.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 n.skipCache!==!0&&await U(p,a),a}function V(e){return(0,c.joinPaths)(e.cachePath,`schemas`)}function H(e,t){let n=N(I(t),t);return(0,c.joinPaths)(V(e),`${n}.json`)}async function U(e,n){if(!t.isSchema(n))throw Error(`The provided input is not a valid schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);let r=V(e),i=e.fs?.mkdir??o.mkdir,a=e.fs?.write??o.writeFile;!(0,s.existsSync)(r)&&!e.fs?.mkdir?await(0,o.mkdir)(r,{recursive:!0}):e.fs?.mkdir&&await i(r,{recursive:!0}),await a(H(e,n),JSON.stringify(n.schema))}async function W(e,n){let r=H(e,n),i=e.fs?.exists??(async e=>Promise.resolve((0,s.existsSync)(e))),a=e.fs?.read??o.readFile;if(!await i(r))return;let c=await a(r);if(!c)return;let l=JSON.parse(typeof c==`string`?c:c.toString());if(t.isSchema(l))return l}async function G(e,t){let n=await W(e,t);if(!n){let e=I(t),n=N(e,t);throw Error(`The ${e} schema with hash "${n}" does not exist in the cache. This may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. Please ensure that the schema is properly written to the cache before attempting to read it.`)}return n}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return F}});
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("./type-checks.cjs");const e=require("./persistence-CLni2zCP.cjs");exports.getCacheDirectory=e.t,exports.getCacheFilePath=e.n,exports.readSchema=e.r,exports.readSchemaSafe=e.i,exports.writeSchema=e.a;
@@ -0,0 +1,58 @@
1
+ import { Schema, SchemaInput } from "./types.cjs";
2
+ import { Buffer } from "node:buffer";
3
+
4
+ //#region src/persistence.d.ts
5
+ interface PersistenceContext {
6
+ cachePath: string;
7
+ fs?: {
8
+ exists?: (path: string) => Promise<boolean>;
9
+ read?: (path: string) => Promise<string | Buffer>;
10
+ write?: (path: string, data: string | Buffer) => Promise<void>;
11
+ mkdir?: (path: string, options: {
12
+ recursive: boolean;
13
+ }) => Promise<void>;
14
+ };
15
+ }
16
+ /**
17
+ * A helper function to get the cache directory path for storing schemas. This function takes a cache path as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the provided cache path with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
18
+ *
19
+ * @param context - The context object containing the cache path.
20
+ * @returns The path to the cache directory for storing schemas, constructed by joining the provided cache path with the "schemas" subdirectory.
21
+ */
22
+ declare function getCacheDirectory(context: PersistenceContext): string;
23
+ /**
24
+ * A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
25
+ *
26
+ * @param context - The context object containing the cache path.
27
+ * @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
28
+ * @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
29
+ */
30
+ declare function getCacheFilePath(context: PersistenceContext, input: SchemaInput): string;
31
+ /**
32
+ * Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
33
+ *
34
+ * @param context - The context object containing the cache path and file system utilities.
35
+ * @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
36
+ * @throws Will throw an error if the provided input is not a valid schema.
37
+ */
38
+ declare function writeSchema(context: PersistenceContext, schema: Schema): Promise<void>;
39
+ /**
40
+ * A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the context provided and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
41
+ *
42
+ * @param context - The context object containing the cache path and file system utilities.
43
+ * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
44
+ * @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
45
+ */
46
+ declare function readSchemaSafe(context: PersistenceContext, input: SchemaInput): Promise<Schema | undefined>;
47
+ /**
48
+ * Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
49
+ *
50
+ * @param context - The context object containing the cache path and file system utilities.
51
+ * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
52
+ * @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
53
+ * @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
54
+ */
55
+ declare function readSchema(context: PersistenceContext, input: SchemaInput): Promise<Schema>;
56
+ //#endregion
57
+ export { PersistenceContext, getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema };
58
+ //# sourceMappingURL=persistence.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence.d.cts","names":[],"sources":["../src/persistence.ts"],"mappings":";;;;UA0BiB,kBAAA;EACf,SAAA;EACA,EAAA;IACE,MAAA,IAAU,IAAA,aAAiB,OAAA;IAC3B,IAAA,IAAQ,IAAA,aAAiB,OAAA,UAAiB,MAAA;IAC1C,KAAA,IAAS,IAAA,UAAc,IAAA,WAAe,MAAA,KAAW,OAAA;IACjD,KAAA,IAAS,IAAA,UAAc,OAAA;MAAW,SAAA;IAAA,MAAyB,OAAA;EAAA;AAAA;;;;;;;iBAU/C,iBAAA,CAAkB,OAA2B,EAAlB,kBAAkB;;;;;;;;iBAW7C,gBAAA,CACd,OAAA,EAAS,kBAAA,EACT,KAAA,EAAO,WAAW;;;;;;;;iBAeE,WAAA,CAAY,OAAA,EAAS,kBAAA,EAAoB,MAAA,EAAQ,MAAA,GAAM,OAAA;AA5B7E;;;;AAA6D;AAW7D;;AAXA,iBA0DsB,cAAA,CACpB,OAAA,EAAS,kBAAA,EACT,KAAA,EAAO,WAAA,GACN,OAAA,CAAQ,MAAA;;;;;;;AAhDS;AAepB;iBAkEsB,UAAA,CACpB,OAAA,EAAS,kBAAA,EACT,KAAA,EAAO,WAAA,GACN,OAAA,CAAQ,MAAA"}
@@ -0,0 +1,58 @@
1
+ import { Schema, SchemaInput } from "./types.mjs";
2
+ import { Buffer } from "node:buffer";
3
+
4
+ //#region src/persistence.d.ts
5
+ interface PersistenceContext {
6
+ cachePath: string;
7
+ fs?: {
8
+ exists?: (path: string) => Promise<boolean>;
9
+ read?: (path: string) => Promise<string | Buffer>;
10
+ write?: (path: string, data: string | Buffer) => Promise<void>;
11
+ mkdir?: (path: string, options: {
12
+ recursive: boolean;
13
+ }) => Promise<void>;
14
+ };
15
+ }
16
+ /**
17
+ * A helper function to get the cache directory path for storing schemas. This function takes a cache path as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the provided cache path with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
18
+ *
19
+ * @param context - The context object containing the cache path.
20
+ * @returns The path to the cache directory for storing schemas, constructed by joining the provided cache path with the "schemas" subdirectory.
21
+ */
22
+ declare function getCacheDirectory(context: PersistenceContext): string;
23
+ /**
24
+ * A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
25
+ *
26
+ * @param context - The context object containing the cache path.
27
+ * @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
28
+ * @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
29
+ */
30
+ declare function getCacheFilePath(context: PersistenceContext, input: SchemaInput): string;
31
+ /**
32
+ * Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
33
+ *
34
+ * @param context - The context object containing the cache path and file system utilities.
35
+ * @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
36
+ * @throws Will throw an error if the provided input is not a valid schema.
37
+ */
38
+ declare function writeSchema(context: PersistenceContext, schema: Schema): Promise<void>;
39
+ /**
40
+ * A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the context provided and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
41
+ *
42
+ * @param context - The context object containing the cache path and file system utilities.
43
+ * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
44
+ * @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
45
+ */
46
+ declare function readSchemaSafe(context: PersistenceContext, input: SchemaInput): Promise<Schema | undefined>;
47
+ /**
48
+ * Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
49
+ *
50
+ * @param context - The context object containing the cache path and file system utilities.
51
+ * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
52
+ * @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
53
+ * @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
54
+ */
55
+ declare function readSchema(context: PersistenceContext, input: SchemaInput): Promise<Schema>;
56
+ //#endregion
57
+ export { PersistenceContext, getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema };
58
+ //# sourceMappingURL=persistence.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence.d.mts","names":[],"sources":["../src/persistence.ts"],"mappings":""}
@@ -0,0 +1 @@
1
+ import"./type-checks.mjs";import{a as e,i as t,n,r,t as i}from"./persistence-B9pzElsC.mjs";export{i as getCacheDirectory,n as getCacheFilePath,r as readSchema,t as readSchemaSafe,e as writeSchema};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./bundle.cjs");let t=require("@stryke/convert/extract-file-reference"),n=require("@stryke/path/find"),r=require("@stryke/type-checks/is-set-string"),i=require("@stryke/url/helpers"),a=require("jiti"),o=require("node:fs/promises"),s=require("node:path"),c=require("smol-toml"),l=require("ts-json-schema-generator/dist/factory/generator.js"),u=require("yaml");async function d(r,i={}){let o=(0,t.extractFileReference)(r);if(!o)throw Error(`Failed to extract a file reference from the provided input ${JSON.stringify(r)}. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);let c=await e.bundle(o.file,i),l;try{let e=c.path===`<stdout>`?(0,s.resolve)(process.cwd(),`${o.file}.bundled${(0,s.extname)(o.file)||`.mjs`}`):c.path;l=await(0,a.createJiti)(i?.cwd??process.cwd()).evalModule(c.text,{filename:e,ext:(0,n.findFileDotExtension)(e)})}catch(e){throw Error(`Failed to evaluate the bundled module for "${o.file}". Error: ${e.message}${i.debug?`\n\nBundle output for module: \n${c.text&&c.text.length>5e4?`${c.text.slice(0,5e4)}\n... [truncated]`:c.text}`:``}`)}return l}async function f(e,n={}){let r=(0,t.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,l.createGenerator)({path:r.file,type:i,expose:`export`,jsDoc:`extended`,...n}).createSchema(i)}catch(e){throw Error(`Failed to generate a JSON schema for "${r.file}" using the type "${i}". Error: ${e.message}`)}}async function p(e,a){if((0,r.isSetString)(e)&&(0,i.isValidURL)(e)&&!e.startsWith(`file://`))try{let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch the JSON file from the URL "${e}". HTTP status: ${t.status} ${t.statusText}`);return await t.json()}catch(t){throw Error(`Failed to fetch or parse the JSON file from the URL "${e}". Error: ${t.message}`)}let s=(0,t.extractFileReference)(e);if(!s)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 l=(0,n.findFileExtensionSafe)(s.file);if(l.startsWith(`json`))try{let e=await(0,o.readFile)(s.file,`utf8`);if(!(0,r.isSetString)(e))throw Error(`The file at "${s.file}" could not be read as a string. Please ensure the file exists and contains valid JSON.`);return JSON.parse(e)}catch(e){throw Error(`Failed to read or parse the JSON file at "${s.file}". Please ensure the file exists and contains valid JSON. Error: ${e.message}`)}else if(l===`yaml`||l===`yml`)try{let e=await(0,o.readFile)(s.file,`utf8`);if(!(0,r.isSetString)(e))throw Error(`The file at "${s.file}" could not be read as a string. Please ensure the file exists and contains valid YAML.`);return(0,u.parse)(e)}catch(e){throw Error(`Failed to read or parse the YAML file at "${s.file}". Please ensure the file exists and contains valid YAML. Error: ${e.message}`)}else if(l===`toml`)try{let e=await(0,o.readFile)(s.file,`utf8`);if(!(0,r.isSetString)(e))throw Error(`The file at "${s.file}" could not be read as a string. Please ensure the file exists and contains valid TOML.`);return(0,c.parse)(e)}catch(e){throw Error(`Failed to read or parse the TOML file at "${s.file}". Please ensure the file exists and contains valid TOML. Error: ${e.message}`)}let f=await d(s,a),p=s.export;p||=`default`;let m=f[p]??f[`__Ω${p}`];if(m===void 0)throw Error(`The export "${p}" could not be resolved in the "${s.file}" module. ${Object.keys(f).length===0?`After bundling, no exports were found in the module. Please ensure that the "${s.file}" module has a "${p}" export with the desired value.`:`After bundling, the available exports were: ${Object.keys(f).join(`, `)}. Please ensure that the export exists and is correctly named.`}`);return m}async function m(e,t){try{return await p(e,t)}catch{return}}exports.resolve=p,exports.resolveModule=d,exports.resolveSafe=m,exports.resolveTSType=f;
@@ -0,0 +1,45 @@
1
+ import { BundleOptions } from "./bundle.cjs";
2
+ import { JsonSchema } from "./types.cjs";
3
+ import { FileReferenceInput } from "@stryke/types/configuration";
4
+ import { Config } from "ts-json-schema-generator/dist/src/Config.js";
5
+
6
+ //#region src/resolve.d.ts
7
+ interface ResolveOptions extends BundleOptions, Partial<Config> {
8
+ cwd?: string;
9
+ tsconfig?: string;
10
+ }
11
+ /**
12
+ * Compiles a type definition to a module and returns the module.
13
+ *
14
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
15
+ * @param options - Optional overrides for the ESBuild configuration.
16
+ * @returns A promise that resolves to the compiled module.
17
+ */
18
+ declare function resolveModule<TResult>(input: FileReferenceInput, options?: ResolveOptions): Promise<TResult>;
19
+ /**
20
+ * Resolves a type definition to a JSON Schema. This function passes the provided file reference to ts-json-schema-generator, using the referenced export name as the target type when one is provided.
21
+ *
22
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
23
+ * @param options - Optional overrides reserved for API compatibility.
24
+ * @returns A promise that resolves to the generated JSON Schema.
25
+ */
26
+ declare function resolveTSType(input: FileReferenceInput, options?: ResolveOptions): Promise<JsonSchema>;
27
+ /**
28
+ * Compiles a type definition to a module and returns the specified export from the module.
29
+ *
30
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
31
+ * @param options - Optional overrides for the ESBuild configuration.
32
+ * @returns A promise that resolves to the compiled module.
33
+ */
34
+ declare function resolve<TResult>(input: FileReferenceInput, options?: ResolveOptions): Promise<TResult>;
35
+ /**
36
+ * Safely compiles a type definition to a module and returns the specified export from the module.
37
+ *
38
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
39
+ * @param options - Optional overrides for the ESBuild configuration.
40
+ * @returns A promise that resolves to the compiled module.
41
+ */
42
+ declare function resolveSafe<TResult>(input: FileReferenceInput, options?: ResolveOptions): Promise<TResult | undefined>;
43
+ //#endregion
44
+ export { ResolveOptions, resolve, resolveModule, resolveSafe, resolveTSType };
45
+ //# sourceMappingURL=resolve.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.cts","names":[],"sources":["../src/resolve.ts"],"mappings":";;;;;;UAkCiB,cAAA,SACP,aAAA,EAAe,OAAA,CAAQ,MAAA;EAC/B,GAAA;EACA,QAAA;AAAA;;;;;;;;iBAUoB,aAAA,UACpB,KAAA,EAAO,kBAAA,EACP,OAAA,GAAS,cAAA,GACR,OAAA,CAAQ,OAAA;;;;;AAbD;AAUV;;iBA0DsB,aAAA,CACpB,KAAA,EAAO,kBAAA,EACP,OAAA,GAAS,cAAA,GACR,OAAA,CAAQ,UAAA;;;;;;;;iBAoCW,OAAA,UACpB,KAAA,EAAO,kBAAA,EACP,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,OAAA;;;;;;;AAjGO;iBAsNI,WAAA,UACpB,KAAA,EAAO,kBAAA,EACP,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,OAAA"}
@@ -0,0 +1,45 @@
1
+ import { BundleOptions } from "./bundle.mjs";
2
+ import { JsonSchema } from "./types.mjs";
3
+ import { FileReferenceInput } from "@stryke/types/configuration";
4
+ import { Config } from "ts-json-schema-generator/dist/src/Config.js";
5
+
6
+ //#region src/resolve.d.ts
7
+ interface ResolveOptions extends BundleOptions, Partial<Config> {
8
+ cwd?: string;
9
+ tsconfig?: string;
10
+ }
11
+ /**
12
+ * Compiles a type definition to a module and returns the module.
13
+ *
14
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
15
+ * @param options - Optional overrides for the ESBuild configuration.
16
+ * @returns A promise that resolves to the compiled module.
17
+ */
18
+ declare function resolveModule<TResult>(input: FileReferenceInput, options?: ResolveOptions): Promise<TResult>;
19
+ /**
20
+ * Resolves a type definition to a JSON Schema. This function passes the provided file reference to ts-json-schema-generator, using the referenced export name as the target type when one is provided.
21
+ *
22
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
23
+ * @param options - Optional overrides reserved for API compatibility.
24
+ * @returns A promise that resolves to the generated JSON Schema.
25
+ */
26
+ declare function resolveTSType(input: FileReferenceInput, options?: ResolveOptions): Promise<JsonSchema>;
27
+ /**
28
+ * Compiles a type definition to a module and returns the specified export from the module.
29
+ *
30
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
31
+ * @param options - Optional overrides for the ESBuild configuration.
32
+ * @returns A promise that resolves to the compiled module.
33
+ */
34
+ declare function resolve<TResult>(input: FileReferenceInput, options?: ResolveOptions): Promise<TResult>;
35
+ /**
36
+ * Safely compiles a type definition to a module and returns the specified export from the module.
37
+ *
38
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
39
+ * @param options - Optional overrides for the ESBuild configuration.
40
+ * @returns A promise that resolves to the compiled module.
41
+ */
42
+ declare function resolveSafe<TResult>(input: FileReferenceInput, options?: ResolveOptions): Promise<TResult | undefined>;
43
+ //#endregion
44
+ export { ResolveOptions, resolve, resolveModule, resolveSafe, resolveTSType };
45
+ //# sourceMappingURL=resolve.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.mts","names":[],"sources":["../src/resolve.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{bundle as e}from"./bundle.mjs";import{extractFileReference as t}from"@stryke/convert/extract-file-reference";import{findFileDotExtension as n,findFileExtensionSafe as r}from"@stryke/path/find";import{isSetString as i}from"@stryke/type-checks/is-set-string";import{isValidURL as a}from"@stryke/url/helpers";import{createJiti as o}from"jiti";import{readFile as s}from"node:fs/promises";import{extname as c,resolve as l}from"node:path";import{parse as u}from"smol-toml";import{createGenerator as d}from"ts-json-schema-generator/dist/factory/generator.js";import{parse as f}from"yaml";async function p(r,i={}){let a=t(r);if(!a)throw Error(`Failed to extract a file reference from the provided input ${JSON.stringify(r)}. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);let s=await e(a.file,i),u;try{let e=s.path===`<stdout>`?l(process.cwd(),`${a.file}.bundled${c(a.file)||`.mjs`}`):s.path;u=await o(i?.cwd??process.cwd()).evalModule(s.text,{filename:e,ext:n(e)})}catch(e){throw Error(`Failed to evaluate the bundled module for "${a.file}". Error: ${e.message}${i.debug?`\n\nBundle output for module: \n${s.text&&s.text.length>5e4?`${s.text.slice(0,5e4)}\n... [truncated]`:s.text}`:``}`)}return u}async function m(e,n={}){let r=t(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 d({path:r.file,type:i,expose:`export`,jsDoc:`extended`,...n}).createSchema(i)}catch(e){throw Error(`Failed to generate a JSON schema for "${r.file}" using the type "${i}". Error: ${e.message}`)}}async function h(e,n){if(i(e)&&a(e)&&!e.startsWith(`file://`))try{let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch the JSON file from the URL "${e}". HTTP status: ${t.status} ${t.statusText}`);return await t.json()}catch(t){throw Error(`Failed to fetch or parse the JSON file from the URL "${e}". Error: ${t.message}`)}let o=t(e);if(!o)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 c=r(o.file);if(c.startsWith(`json`))try{let e=await s(o.file,`utf8`);if(!i(e))throw Error(`The file at "${o.file}" could not be read as a string. Please ensure the file exists and contains valid JSON.`);return JSON.parse(e)}catch(e){throw Error(`Failed to read or parse the JSON file at "${o.file}". Please ensure the file exists and contains valid JSON. Error: ${e.message}`)}else if(c===`yaml`||c===`yml`)try{let e=await s(o.file,`utf8`);if(!i(e))throw Error(`The file at "${o.file}" could not be read as a string. Please ensure the file exists and contains valid YAML.`);return f(e)}catch(e){throw Error(`Failed to read or parse the YAML file at "${o.file}". Please ensure the file exists and contains valid YAML. Error: ${e.message}`)}else if(c===`toml`)try{let e=await s(o.file,`utf8`);if(!i(e))throw Error(`The file at "${o.file}" could not be read as a string. Please ensure the file exists and contains valid TOML.`);return u(e)}catch(e){throw Error(`Failed to read or parse the TOML file at "${o.file}". Please ensure the file exists and contains valid TOML. Error: ${e.message}`)}let l=await p(o,n),d=o.export;d||=`default`;let m=l[d]??l[`__Ω${d}`];if(m===void 0)throw Error(`The export "${d}" could not be resolved in the "${o.file}" module. ${Object.keys(l).length===0?`After bundling, no exports were found in the module. Please ensure that the "${o.file}" module has a "${d}" export with the desired value.`:`After bundling, the available exports were: ${Object.keys(l).join(`, `)}. Please ensure that the export exists and is correctly named.`}`);return m}async function g(e,t){try{return await h(e,t)}catch{return}}export{h as resolve,p as resolveModule,g as resolveSafe,m as resolveTSType};
2
+ //# sourceMappingURL=resolve.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.mjs","names":[],"sources":[],"mappings":""}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants.cjs");let t=require("@stryke/type-checks");function n(e){return!(0,t.isString)(e)&&e.file!==void 0}const r=e=>typeof e==`number`&&Number.isFinite(e),i=e=>(0,t.isSetObject)(e)||(0,t.isBoolean)(e),a=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>i(e)),o=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>(0,t.isBoolean)(e)),s=e=>Array.isArray(e)&&e.every(e=>(0,t.isSetString)(e)),ee=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>s(e)),c=new Set(e.JSON_SCHEMA_PRIMITIVE_TYPES),l=new Set(e.JSON_SCHEMA_TYPES);function te(e){return(0,t.isSetString)(e)&&c.has(e)}function u(e){return(0,t.isSetString)(e)&&l.has(e)}const ne=new Set([`date`,`time`,`date-time`,`iso-time`,`iso-date-time`,`unix-time`]),d=e=>typeof e==`bigint`,re=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`function`,`object`,`any`,`array`]),f=e=>(0,t.isSetString)(e)&&re.has(e),p=e=>{if(!(0,t.isSetObject)(e))return!1;let n=e;return!(n.type!==void 0&&!((0,t.isSetString)(n.type)&&f(n.type)||Array.isArray(n.type)&&n.type.every(e=>f(e)))||n.tsType!==void 0&&!(0,t.isSetString)(n.tsType)||n.markdownType!==void 0&&!(0,t.isSetString)(n.markdownType)||n.items!==void 0&&!(p(n.items)||Array.isArray(n.items)&&n.items.every(e=>p(e))))},ie=e=>{if(!p(e))return!1;let n=e;return n.name!==void 0&&!(0,t.isSetString)(n.name)?!1:n.optional===void 0||typeof n.optional==`boolean`},ae=e=>(0,t.isSetObject)(e)&&Object.values(e).every(e=>X(e)),m=(e,t)=>Array.isArray(e)&&e.every(e=>t(e)),oe=(e,t,n)=>Array.isArray(e)&&e.length===2&&t(e[0])&&n(e[1]),h=(e,n=!1)=>e===void 0||(0,t.isString)(e)&&(n||e.length>0),g=e=>e===void 0||(0,t.isBoolean)(e),_=e=>e===void 0||r(e),v=e=>e===void 0||d(e),y=e=>e===void 0||Y(e),b=e=>e===void 0||m(e,Y),se=e=>e===void 0||Array.isArray(e)&&e.every(e=>(0,t.isSetString)(e)&&c.has(e)),ce=e=>e===void 0||Array.isArray(e)&&e.every(e=>(0,t.isSetString)(e)&&l.has(e)),x=e=>!(!h(e.$id)||!h(e.$schema)||e.$vocabulary!==void 0&&!o(e.$vocabulary)||!h(e.$comment,!0)||!h(e.$anchor)||e.$defs!==void 0&&!a(e.$defs)||!h(e.$dynamicRef)||!h(e.$dynamicAnchor)||!h(e.name)||!h(e.title,!0)||!h(e.description,!0)||!h(e.docs,!0)||e.examples!==void 0&&!Array.isArray(e.examples)||e.alias!==void 0&&!s(e.alias)||e.tags!==void 0&&!s(e.tags)||!g(e.deprecated)||!g(e.hidden)||!g(e.ignore)||!g(e.internal)||!g(e.runtime)||!g(e.readOnly)||!g(e.writeOnly)||!b(e.allOf)||!b(e.anyOf)||!b(e.oneOf)||!y(e.not)||!y(e.if)||!y(e.then)||!y(e.else));function le(e){return(0,t.isSetObject)(e)?x(e):!1}function S(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&h(n.$ref)}function C(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||n.type!==`array`?!1:b(n.prefixItems)&&y(n.items)&&y(n.contains)&&_(n.minItems)&&_(n.maxItems)&&g(n.uniqueItems)&&_(n.minContains)&&_(n.maxContains)&&(n.unevaluatedItems===void 0||(0,t.isBoolean)(n.unevaluatedItems)||Y(n.unevaluatedItems))}function w(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||n.type!==`integer`||n.format!==`int64`?!1:v(n.minimum)&&v(n.exclusiveMinimum)&&v(n.maximum)&&v(n.exclusiveMaximum)&&v(n.multipleOf)&&v(n.default)&&(n.enum===void 0||m(n.enum,d))}function T(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`boolean`&&g(n.default)}function E(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)?n.anyOf===void 0?n.type!==`integer`&&n.type!==`string`||!(0,t.isSetString)(n.format)||!ne.has(n.format)?!1:_(n.minimum)&&_(n.maximum)&&(n.default===void 0||(0,t.isSetString)(n.default)||r(n.default)):m(n.anyOf,E):!1}function D(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!x(n)||!(0,t.isSetString)(n.type)||!c.has(n.type)||!Array.isArray(n.enum))return!1;let i=n.type,a=n.enum,o=n.default;return i===`string`?a.every(e=>(0,t.isSetString)(e))&&(o===void 0||(0,t.isSetString)(o)):i===`number`||i===`integer`?a.every(e=>r(e))&&(o===void 0||r(o)):i===`boolean`?a.every(e=>(0,t.isBoolean)(e))&&(o===void 0||(0,t.isBoolean)(o)):i===`null`&&a.every(e=>e===null)&&o==null}function O(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||!m(n.allOf,Y)?!1:n.unevaluatedProperties===void 0||(0,t.isBoolean)(n.unevaluatedProperties)||Y(n.unevaluatedProperties)}function k(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||!(`const`in n)?!1:n.type===void 0||(0,t.isSetString)(n.type)&&u(n.type)||ce(n.type)}function A(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!x(n)||n.type!==`array`||n.maxItems!==125||!(0,t.isSetObject)(n.items))return!1;let r=n.items;return r.type===`array`&&oe(r.prefixItems,Y,Y)&&(r.items===void 0||r.items===!1)&&r.minItems===2&&r.maxItems===2}function j(e){if(!(0,t.isSetObject)(e))return!1;let n=e,i=n.type===`string`||n.type===`number`||Array.isArray(n.type)&&n.type.length===2&&n.type[0]===`string`&&n.type[1]===`number`;return x(n)&&i&&Array.isArray(n.enum)&&n.enum.every(e=>(0,t.isSetString)(e)||r(e))}function M(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&S(n.not)}function N(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`null`&&(n.const===void 0||n.const===null)&&(n.enum===void 0||Array.isArray(n.enum)&&n.enum.every(e=>e===null))&&(n.default===void 0||n.default===null)}function P(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!x(n))return!1;let r=n.anyOf!==void 0&&Array.isArray(n.anyOf)&&n.anyOf.length===2&&Y(n.anyOf[0])&&N(n.anyOf[1]),i=Array.isArray(n.type)&&n.type.length===2&&(n.type[0]===`null`&&(0,t.isSetString)(n.type[1])&&n.type[1]!==`null`&&l.has(n.type[1])||n.type[1]===`null`&&(0,t.isSetString)(n.type[0])&&n.type[0]!==`null`&&l.has(n.type[0]));return r||i}function F(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!x(n)||n.type!==`number`&&n.type!==`integer`?!1:h(n.format)&&_(n.minimum)&&_(n.exclusiveMinimum)&&_(n.maximum)&&_(n.exclusiveMaximum)&&_(n.multipleOf)&&_(n.default)&&(n.enum===void 0||m(n.enum,r))}function I(e){return F(e)&&e.type===`integer`}function L(e){return F(e)&&e.type===`number`}function R(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`object`&&(n.properties===void 0||a(n.properties))&&(n.patternProperties===void 0||a(n.patternProperties))&&(n.additionalProperties===void 0||(0,t.isBoolean)(n.additionalProperties)||Y(n.additionalProperties))&&(n.required===void 0||s(n.required))&&(n.unevaluatedProperties===void 0||(0,t.isBoolean)(n.unevaluatedProperties)||Y(n.unevaluatedProperties))&&(n.dependencies===void 0||(0,t.isSetObject)(n.dependencies)&&Object.values(n.dependencies).every(e=>s(e)||Y(e)))&&(n.dependentRequired===void 0||ee(n.dependentRequired))&&(n.dependentSchemas===void 0||a(n.dependentSchemas))&&_(n.minProperties)&&_(n.maxProperties)&&(n.primaryKey===void 0||s(n.primaryKey))&&h(n.databaseSchema)}function ue(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`string`&&_(n.minLength)&&_(n.maxLength)&&h(n.pattern)&&h(n.format)&&h(n.default)&&(n.enum===void 0||m(n.enum,t.isSetString))&&h(n.contentMediaType)&&h(n.contentEncoding)&&h(n.contentSchema)}function z(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`array`&&n.uniqueItems===!0&&b(n.prefixItems)&&y(n.items)&&y(n.contains)&&_(n.minItems)&&_(n.maxItems)&&_(n.minContains)&&_(n.maxContains)&&(n.unevaluatedItems===void 0||(0,t.isBoolean)(n.unevaluatedItems)||Y(n.unevaluatedItems))}function B(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`object`&&(n.patternProperties===void 0||a(n.patternProperties))&&(n.additionalProperties===void 0||(0,t.isBoolean)(n.additionalProperties)||Y(n.additionalProperties))&&y(n.propertyNames)}function V(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&n.type===`array`&&m(n.prefixItems,Y)&&_(n.minItems)&&_(n.maxItems)&&y(n.items)&&y(n.contains)&&g(n.uniqueItems)&&_(n.minContains)&&_(n.maxContains)&&(n.unevaluatedItems===void 0||(0,t.isBoolean)(n.unevaluatedItems)||Y(n.unevaluatedItems))}function H(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&S(n.not)&&(n.default===void 0||n.default===void 0)}function U(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)?(0,t.isSetString)(n.type)&&c.has(n.type)?n.enum===void 0?!0:Array.isArray(n.enum)?n.type===`string`?n.enum.every(e=>(0,t.isSetString)(e))&&(n.default===void 0||(0,t.isSetString)(n.default)):n.type===`number`?n.enum.every(e=>r(e))&&(n.default===void 0||r(n.default)):n.type===`boolean`?n.enum.every(e=>(0,t.isBoolean)(e))&&(n.default===void 0||(0,t.isBoolean)(n.default)):n.type===`integer`?n.format===`int64`?n.enum.every(e=>d(e))&&(n.default===void 0||d(n.default)):!1:n.type===`null`&&n.enum.every(e=>e===null)&&(n.default===void 0||n.default===null):!1:se(n.type)&&n.type!==void 0:!1}function W(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&(U(n)||K(n))}function G(e){return S(e)}function K(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&m(n.anyOf,Y)}function q(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return x(n)&&(0,t.isSetString)(n.$ref)}function J(e){if(!(0,t.isSetObject)(e))return!1;let n=e;if(!(0,t.isSetObject)(n[`~standard`]))return!1;let r=n[`~standard`];return r.version===1&&(0,t.isFunction)(r.validate)}function de(e){if(!(0,t.isSetObject)(e)||!J(e))return!1;let n=e;return n.kind===`schema`&&(0,t.isSetString)(n.type)&&(0,t.isBoolean)(n.async)&&(0,t.isFunction)(n.reference)&&(0,t.isSetString)(n.expects)&&(0,t.isFunction)(n[`~run`])}function Y(e){return ue(e)||I(e)||L(e)||w(e)||T(e)||E(e)||D(e)||k(e)||j(e)||N(e)||C(e)||R(e)||B(e)||V(e)||W(e)||H(e)||q(e)||M(e)||A(e)||S(e)||P(e)||O(e)||G(e)||z(e)}function fe(e){return N(e)}function X(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!(!p(n)||`id`in n&&!(0,t.isSetString)(n.id)||`resolve`in n&&!(0,t.isFunction)(n.resolve)||`properties`in n&&!ae(n.properties)||`required`in n&&!s(n.required)||`title`in n&&!(0,t.isSetString)(n.title)||`description`in n&&!(0,t.isSetString)(n.description)||`$schema`in n&&!(0,t.isSetString)(n.$schema)||`tags`in n&&!s(n.tags)||`args`in n&&(!Array.isArray(n.args)||!n.args.every(e=>ie(e)))||`returns`in n&&!p(n.returns))}function Z(e){return X(e)&&!Y(e)}function Q(e){if(!(0,t.isSetObject)(e))return!1;let n=e;return!(`$schema`in n&&!X(n.$schema)||`$resolve`in n&&!(0,t.isFunction)(n.$resolve))}function pe(e){if(!Q(e)||Y(e))return!1;let t=e;return!(`$schema`in t&&t.$schema!==void 0&&!Z(t.$schema))}function $(e){return(0,t.isSetObject)(e)&&`schema`in e&&Y(e.schema)&&`variant`in e&&(0,t.isSetString)(e.variant)&&`hash`in e&&(0,t.isSetString)(e.hash)}function me(e){return $(e)&&`source`in e&&(0,t.isSetObject)(e.source)&&`schema`in e.source&&`variant`in e.source&&(0,t.isSetString)(e.source.variant)}function he(e){return $(e)&&R(e.schema)}exports.isFileReference=n,exports.isJsonSchema=Y,exports.isJsonSchemaAllOf=O,exports.isJsonSchemaAny=S,exports.isJsonSchemaAnyOf=K,exports.isJsonSchemaArray=C,exports.isJsonSchemaBigint=w,exports.isJsonSchemaBoolean=T,exports.isJsonSchemaDate=E,exports.isJsonSchemaDecimal=L,exports.isJsonSchemaEnum=D,exports.isJsonSchemaInteger=I,exports.isJsonSchemaKeywords=le,exports.isJsonSchemaLiteral=k,exports.isJsonSchemaMap=A,exports.isJsonSchemaNativeEnum=j,exports.isJsonSchemaNever=M,exports.isJsonSchemaNull=N,exports.isJsonSchemaNullable=P,exports.isJsonSchemaNumber=F,exports.isJsonSchemaObject=R,exports.isJsonSchemaPrimitiveType=te,exports.isJsonSchemaPrimitiveUnion=U,exports.isJsonSchemaRecord=B,exports.isJsonSchemaRef=q,exports.isJsonSchemaSet=z,exports.isJsonSchemaString=ue,exports.isJsonSchemaTuple=V,exports.isJsonSchemaType=u,exports.isJsonSchemaUndefined=H,exports.isJsonSchemaUnion=W,exports.isJsonSchemaUnknown=G,exports.isNullOnlyJsonSchema=fe,exports.isSchema=$,exports.isSchemaObject=he,exports.isSchemaWithSource=me,exports.isStandardSchema=J,exports.isUntypedInput=Q,exports.isUntypedInputStrict=pe,exports.isUntypedSchema=X,exports.isUntypedSchemaStrict=Z,exports.isValibotSchema=de;