@vielzeug/spell 26.11.9 → 26.11.10

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 (236) hide show
  1. package/README.md +1 -1
  2. package/dist/_dev.cjs.map +1 -1
  3. package/dist/_dev.js.map +1 -1
  4. package/dist/_object.cjs +2 -0
  5. package/dist/_object.cjs.map +1 -0
  6. package/dist/_object.d.ts +9 -0
  7. package/dist/_object.d.ts.map +1 -0
  8. package/dist/_object.js +2 -0
  9. package/dist/_object.js.map +1 -0
  10. package/dist/_parse.cjs +2 -0
  11. package/dist/_parse.cjs.map +1 -0
  12. package/dist/_parse.d.ts +38 -0
  13. package/dist/_parse.d.ts.map +1 -0
  14. package/dist/_parse.js +2 -0
  15. package/dist/_parse.js.map +1 -0
  16. package/dist/errors.cjs +2 -2
  17. package/dist/errors.cjs.map +1 -1
  18. package/dist/errors.d.ts +15 -26
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/errors.js +2 -2
  21. package/dist/errors.js.map +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.ts +4 -4
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/json.cjs +2 -1
  27. package/dist/json.cjs.map +1 -0
  28. package/dist/json.d.ts +8 -1
  29. package/dist/json.d.ts.map +1 -1
  30. package/dist/json.js +2 -1
  31. package/dist/json.js.map +1 -0
  32. package/dist/messages.cjs +1 -1
  33. package/dist/messages.cjs.map +1 -1
  34. package/dist/messages.d.ts +7 -6
  35. package/dist/messages.d.ts.map +1 -1
  36. package/dist/messages.js +1 -1
  37. package/dist/messages.js.map +1 -1
  38. package/dist/predicates.cjs +2 -1
  39. package/dist/predicates.cjs.map +1 -0
  40. package/dist/predicates.d.ts +41 -2
  41. package/dist/predicates.d.ts.map +1 -1
  42. package/dist/predicates.js +2 -1
  43. package/dist/predicates.js.map +1 -0
  44. package/dist/s.cjs +1 -1
  45. package/dist/s.cjs.map +1 -1
  46. package/dist/s.d.ts +21 -22
  47. package/dist/s.d.ts.map +1 -1
  48. package/dist/s.js +1 -1
  49. package/dist/s.js.map +1 -1
  50. package/dist/schema.cjs +2 -0
  51. package/dist/schema.cjs.map +1 -0
  52. package/dist/schema.d.ts +93 -0
  53. package/dist/schema.d.ts.map +1 -0
  54. package/dist/schema.js +2 -0
  55. package/dist/schema.js.map +1 -0
  56. package/dist/schemas/array.cjs +1 -1
  57. package/dist/schemas/array.cjs.map +1 -1
  58. package/dist/schemas/array.d.ts +22 -32
  59. package/dist/schemas/array.d.ts.map +1 -1
  60. package/dist/schemas/array.js +1 -1
  61. package/dist/schemas/array.js.map +1 -1
  62. package/dist/schemas/bigint.cjs +1 -1
  63. package/dist/schemas/bigint.cjs.map +1 -1
  64. package/dist/schemas/bigint.d.ts +14 -18
  65. package/dist/schemas/bigint.d.ts.map +1 -1
  66. package/dist/schemas/bigint.js +1 -1
  67. package/dist/schemas/bigint.js.map +1 -1
  68. package/dist/schemas/date.cjs +1 -1
  69. package/dist/schemas/date.cjs.map +1 -1
  70. package/dist/schemas/date.d.ts +7 -6
  71. package/dist/schemas/date.d.ts.map +1 -1
  72. package/dist/schemas/date.js +1 -1
  73. package/dist/schemas/date.js.map +1 -1
  74. package/dist/schemas/discriminated-union.cjs +2 -0
  75. package/dist/schemas/discriminated-union.cjs.map +1 -0
  76. package/dist/schemas/discriminated-union.d.ts +39 -0
  77. package/dist/schemas/discriminated-union.d.ts.map +1 -0
  78. package/dist/schemas/discriminated-union.js +2 -0
  79. package/dist/schemas/discriminated-union.js.map +1 -0
  80. package/dist/schemas/intersect.cjs +1 -1
  81. package/dist/schemas/intersect.cjs.map +1 -1
  82. package/dist/schemas/intersect.d.ts +10 -9
  83. package/dist/schemas/intersect.d.ts.map +1 -1
  84. package/dist/schemas/intersect.js +1 -1
  85. package/dist/schemas/intersect.js.map +1 -1
  86. package/dist/schemas/lazy.cjs +1 -1
  87. package/dist/schemas/lazy.cjs.map +1 -1
  88. package/dist/schemas/lazy.d.ts +10 -10
  89. package/dist/schemas/lazy.d.ts.map +1 -1
  90. package/dist/schemas/lazy.js +1 -1
  91. package/dist/schemas/lazy.js.map +1 -1
  92. package/dist/schemas/map.cjs +1 -1
  93. package/dist/schemas/map.cjs.map +1 -1
  94. package/dist/schemas/map.d.ts +8 -7
  95. package/dist/schemas/map.d.ts.map +1 -1
  96. package/dist/schemas/map.js +1 -1
  97. package/dist/schemas/map.js.map +1 -1
  98. package/dist/schemas/number.cjs +1 -1
  99. package/dist/schemas/number.cjs.map +1 -1
  100. package/dist/schemas/number.d.ts +20 -27
  101. package/dist/schemas/number.d.ts.map +1 -1
  102. package/dist/schemas/number.js +1 -1
  103. package/dist/schemas/number.js.map +1 -1
  104. package/dist/schemas/object.cjs +1 -1
  105. package/dist/schemas/object.cjs.map +1 -1
  106. package/dist/schemas/object.d.ts +40 -88
  107. package/dist/schemas/object.d.ts.map +1 -1
  108. package/dist/schemas/object.js +1 -1
  109. package/dist/schemas/object.js.map +1 -1
  110. package/dist/schemas/primitives.cjs +2 -0
  111. package/dist/schemas/primitives.cjs.map +1 -0
  112. package/dist/schemas/primitives.d.ts +38 -0
  113. package/dist/schemas/primitives.d.ts.map +1 -0
  114. package/dist/schemas/primitives.js +2 -0
  115. package/dist/schemas/primitives.js.map +1 -0
  116. package/dist/schemas/record.cjs +1 -1
  117. package/dist/schemas/record.cjs.map +1 -1
  118. package/dist/schemas/record.d.ts +7 -8
  119. package/dist/schemas/record.d.ts.map +1 -1
  120. package/dist/schemas/record.js +1 -1
  121. package/dist/schemas/record.js.map +1 -1
  122. package/dist/schemas/set.cjs +1 -1
  123. package/dist/schemas/set.cjs.map +1 -1
  124. package/dist/schemas/set.d.ts +8 -7
  125. package/dist/schemas/set.d.ts.map +1 -1
  126. package/dist/schemas/set.js +1 -1
  127. package/dist/schemas/set.js.map +1 -1
  128. package/dist/schemas/string.cjs +1 -1
  129. package/dist/schemas/string.cjs.map +1 -1
  130. package/dist/schemas/string.d.ts +42 -98
  131. package/dist/schemas/string.d.ts.map +1 -1
  132. package/dist/schemas/string.js +1 -1
  133. package/dist/schemas/string.js.map +1 -1
  134. package/dist/schemas/tuple.cjs +1 -1
  135. package/dist/schemas/tuple.cjs.map +1 -1
  136. package/dist/schemas/tuple.d.ts +9 -9
  137. package/dist/schemas/tuple.d.ts.map +1 -1
  138. package/dist/schemas/tuple.js +1 -1
  139. package/dist/schemas/tuple.js.map +1 -1
  140. package/dist/schemas/union.cjs +1 -1
  141. package/dist/schemas/union.cjs.map +1 -1
  142. package/dist/schemas/union.d.ts +9 -7
  143. package/dist/schemas/union.d.ts.map +1 -1
  144. package/dist/schemas/union.js +1 -1
  145. package/dist/schemas/union.js.map +1 -1
  146. package/dist/spell.cjs +2 -2
  147. package/dist/spell.cjs.map +1 -1
  148. package/dist/spell.iife.js +2 -2
  149. package/dist/spell.iife.js.map +1 -1
  150. package/dist/spell.js +842 -1601
  151. package/dist/spell.js.map +1 -1
  152. package/dist/types.cjs +1 -1
  153. package/dist/types.cjs.map +1 -1
  154. package/dist/types.d.ts +151 -265
  155. package/dist/types.d.ts.map +1 -1
  156. package/dist/types.js +1 -1
  157. package/dist/types.js.map +1 -1
  158. package/package.json +2 -2
  159. package/dist/core.cjs +0 -2
  160. package/dist/core.cjs.map +0 -1
  161. package/dist/core.d.ts +0 -101
  162. package/dist/core.d.ts.map +0 -1
  163. package/dist/core.js +0 -2
  164. package/dist/core.js.map +0 -1
  165. package/dist/formats.cjs +0 -2
  166. package/dist/formats.cjs.map +0 -1
  167. package/dist/formats.d.ts +0 -41
  168. package/dist/formats.d.ts.map +0 -1
  169. package/dist/formats.js +0 -2
  170. package/dist/formats.js.map +0 -1
  171. package/dist/json-schema.cjs +0 -2
  172. package/dist/json-schema.cjs.map +0 -1
  173. package/dist/json-schema.d.ts +0 -5
  174. package/dist/json-schema.d.ts.map +0 -1
  175. package/dist/json-schema.js +0 -2
  176. package/dist/json-schema.js.map +0 -1
  177. package/dist/safe-object.cjs +0 -2
  178. package/dist/safe-object.cjs.map +0 -1
  179. package/dist/safe-object.d.ts +0 -6
  180. package/dist/safe-object.d.ts.map +0 -1
  181. package/dist/safe-object.js +0 -2
  182. package/dist/safe-object.js.map +0 -1
  183. package/dist/schemas/boolean.cjs +0 -2
  184. package/dist/schemas/boolean.cjs.map +0 -1
  185. package/dist/schemas/boolean.d.ts +0 -9
  186. package/dist/schemas/boolean.d.ts.map +0 -1
  187. package/dist/schemas/boolean.js +0 -2
  188. package/dist/schemas/boolean.js.map +0 -1
  189. package/dist/schemas/enum.cjs +0 -2
  190. package/dist/schemas/enum.cjs.map +0 -1
  191. package/dist/schemas/enum.d.ts +0 -12
  192. package/dist/schemas/enum.d.ts.map +0 -1
  193. package/dist/schemas/enum.js +0 -2
  194. package/dist/schemas/enum.js.map +0 -1
  195. package/dist/schemas/instanceof.cjs +0 -2
  196. package/dist/schemas/instanceof.cjs.map +0 -1
  197. package/dist/schemas/instanceof.d.ts +0 -9
  198. package/dist/schemas/instanceof.d.ts.map +0 -1
  199. package/dist/schemas/instanceof.js +0 -2
  200. package/dist/schemas/instanceof.js.map +0 -1
  201. package/dist/schemas/literal.cjs +0 -2
  202. package/dist/schemas/literal.cjs.map +0 -1
  203. package/dist/schemas/literal.d.ts +0 -9
  204. package/dist/schemas/literal.d.ts.map +0 -1
  205. package/dist/schemas/literal.js +0 -2
  206. package/dist/schemas/literal.js.map +0 -1
  207. package/dist/schemas/never.cjs +0 -2
  208. package/dist/schemas/never.cjs.map +0 -1
  209. package/dist/schemas/never.d.ts +0 -8
  210. package/dist/schemas/never.d.ts.map +0 -1
  211. package/dist/schemas/never.js +0 -2
  212. package/dist/schemas/never.js.map +0 -1
  213. package/dist/schemas/raw-or.cjs +0 -2
  214. package/dist/schemas/raw-or.cjs.map +0 -1
  215. package/dist/schemas/raw-or.d.ts +0 -17
  216. package/dist/schemas/raw-or.d.ts.map +0 -1
  217. package/dist/schemas/raw-or.js +0 -2
  218. package/dist/schemas/raw-or.js.map +0 -1
  219. package/dist/schemas/variant.cjs +0 -2
  220. package/dist/schemas/variant.cjs.map +0 -1
  221. package/dist/schemas/variant.d.ts +0 -37
  222. package/dist/schemas/variant.d.ts.map +0 -1
  223. package/dist/schemas/variant.js +0 -2
  224. package/dist/schemas/variant.js.map +0 -1
  225. package/dist/tolerate.cjs +0 -2
  226. package/dist/tolerate.cjs.map +0 -1
  227. package/dist/tolerate.d.ts +0 -10
  228. package/dist/tolerate.d.ts.map +0 -1
  229. package/dist/tolerate.js +0 -2
  230. package/dist/tolerate.js.map +0 -1
  231. package/dist/validators.cjs +0 -2
  232. package/dist/validators.cjs.map +0 -1
  233. package/dist/validators.d.ts +0 -20
  234. package/dist/validators.d.ts.map +0 -1
  235. package/dist/validators.js +0 -2
  236. package/dist/validators.js.map +0 -1
@@ -1,6 +0,0 @@
1
- export declare const UNSAFE_OBJECT_KEYS: Set<string>;
2
- export declare function isUnsafeObjectKey(key: string): boolean;
3
- export declare function defineOwnProperty<T>(target: Record<string, T>, key: string, value: T): void;
4
- export declare function objectFromEntries<T>(entries: Iterable<readonly [string, T]>): Record<string, T>;
5
- export declare function cloneRecord<T>(source: Record<string, T>): Record<string, T>;
6
- //# sourceMappingURL=safe-object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-object.d.ts","sourceRoot":"","sources":["../src/safe-object.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,aAAqD,CAAC;AAErF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAO3F;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM/F;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAE3E"}
@@ -1,2 +0,0 @@
1
- var e=/* @__PURE__ */ new Set([`__proto__`,`constructor`,`prototype`]);function t(t){return e.has(t)}function n(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function r(e){let t={};for(let[r,i]of e)n(t,r,i);return t}function i(e){return r(Object.entries(e))}export{e as UNSAFE_OBJECT_KEYS,i as cloneRecord,n as defineOwnProperty,t as isUnsafeObjectKey,r as objectFromEntries};
2
- //# sourceMappingURL=safe-object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-object.js","names":["UNSAFE_OBJECT_KEYS","isUnsafeObjectKey","key","defineOwnProperty","target","objectFromEntries","out","value","entries","cloneRecord","source"],"sources":["../src/safe-object.ts"],"sourcesContent":["export const UNSAFE_OBJECT_KEYS = new Set(['__proto__', 'constructor', 'prototype']);\n\nexport function isUnsafeObjectKey(key: string): boolean {\n return UNSAFE_OBJECT_KEYS.has(key);\n}\n\nexport function defineOwnProperty<T>(target: Record<string, T>, key: string, value: T): void {\n Object.defineProperty(target, key, {\n configurable: true,\n enumerable: true,\n value,\n writable: true,\n });\n}\n\nexport function objectFromEntries<T>(entries: Iterable<readonly [string, T]>): Record<string, T> {\n const out: Record<string, T> = {};\n\n for (const [key, value] of entries) defineOwnProperty(out, key, value);\n\n return out;\n}\n\nexport function cloneRecord<T>(source: Record<string, T>): Record<string, T> {\n return objectFromEntries(Object.entries(source));\n}\n"],"mappings":"AAAA,IAAaA,kBAAqB,IAAI,IAAI,CAAC,YAAa,cAAe,WAAW,CAAC,EAEnF,SAAgBC,EAAkB,EAAsB,CACtD,OAAOD,EAAmB,IAAIE,CAAG,CACnC,CAEA,SAAgBC,EAAqB,EAA2B,EAAa,EAAgB,CAC3F,OAAO,eAAeC,EAAQF,EAAK,CACjC,aAAc,GACd,WAAY,GACZ,QACA,SAAU,EACZ,CAAC,CACH,CAEA,SAAgBG,EAAqB,EAA4D,CAC/F,IAAMC,EAAyB,CAAC,EAEhC,IAAK,GAAM,CAACJ,EAAKK,KAAUC,EAASL,EAAkBG,EAAKJ,EAAKK,CAAK,EAErE,OAAOD,CACT,CAEA,SAAgBG,EAAe,EAA8C,CAC3E,OAAOJ,EAAkB,OAAO,QAAQK,CAAM,CAAC,CACjD,C"}
@@ -1,2 +0,0 @@
1
- const e=require("../types.cjs"),t=require("../core.cjs");var n=class n extends t.Schema{get _kind(){return`boolean`}constructor(){super((t,n)=>typeof t==`boolean`?null:[{code:e.ErrorCode.invalid_type,message:n.messages.boolean.type(),path:[]}])}_toDescriptorImpl(){return{...this._describeBase(),kind:`boolean`}}static coerce(){return new n().preprocess(e=>typeof e==`boolean`?e:e===`true`||e===`1`||e===1?!0:e===`false`||e===`0`||e===0?!1:e)}};exports.BooleanSchema=n;
2
- //# sourceMappingURL=boolean.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"boolean.cjs","names":["Schema","ErrorCode","require_types","require_core","BooleanSchema","value","ctx","v"],"sources":["../../src/schemas/boolean.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class BooleanSchema<Input = boolean> extends Schema<boolean, Input> {\n protected override get _kind(): string {\n return 'boolean';\n }\n\n constructor() {\n super((value, ctx) =>\n typeof value === 'boolean'\n ? null\n : [{ code: ErrorCode.invalid_type, message: ctx!.messages.boolean.type(), path: [] }],\n );\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'boolean' };\n }\n\n static coerce(): BooleanSchema<unknown> {\n return new BooleanSchema().preprocess((v: unknown) => {\n if (typeof v === 'boolean') return v;\n\n if (v === 'true' || v === '1' || v === 1) return true;\n\n if (v === 'false' || v === '0' || v === 0) return false;\n\n return v;\n });\n }\n}\n"],"mappings":"A,yDAIA,IAAaI,EAAb,MAAaA,UAAuCJ,EAAAA,MAAuB,CACzE,IAAuB,OAAgB,CACrC,MAAO,SACT,CAEA,aAAc,CACZ,OAAO,EAAO,IACZ,OAAOK,GAAU,UACb,KACA,CAAC,CAAE,KAAMJ,EAAAA,UAAU,aAAc,QAASK,EAAK,SAAS,QAAQ,KAAK,EAAG,KAAM,CAAC,CAAE,CAAC,CACxF,CACF,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,SAAU,CACpD,CAEA,OAAO,QAAiC,CACtC,OAAO,IAAIF,EAAc,CAAC,CAAC,WAAY,GACjC,OAAOG,GAAM,UAAkBA,EAE/BA,IAAM,QAAUA,IAAM,KAAOA,IAAM,EAAU,GAE7CA,IAAM,SAAWA,IAAM,KAAOA,IAAM,EAAU,GAE3CA,CACR,CACH,CACF,E"}
@@ -1,9 +0,0 @@
1
- import type { SchemaDescriptor } from '../core';
2
- import { Schema } from '../core';
3
- export declare class BooleanSchema<Input = boolean> extends Schema<boolean, Input> {
4
- protected get _kind(): string;
5
- constructor();
6
- protected _toDescriptorImpl(): SchemaDescriptor;
7
- static coerce(): BooleanSchema<unknown>;
8
- }
9
- //# sourceMappingURL=boolean.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/schemas/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAa,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,aAAa,CAAC,KAAK,GAAG,OAAO,CAAE,SAAQ,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;IACxE,cAAuB,KAAK,IAAI,MAAM,CAErC;;cAUkB,iBAAiB,IAAI,gBAAgB;IAIxD,MAAM,CAAC,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC;CAWxC"}
@@ -1,2 +0,0 @@
1
- import{ErrorCode as e}from"../types.js";import{Schema as t}from"../core.js";var n=class n extends t{get _kind(){return`boolean`}constructor(){super((t,n)=>typeof t==`boolean`?null:[{code:e.invalid_type,message:n.messages.boolean.type(),path:[]}])}_toDescriptorImpl(){return{...this._describeBase(),kind:`boolean`}}static coerce(){return new n().preprocess(e=>typeof e==`boolean`?e:e===`true`||e===`1`||e===1?!0:e===`false`||e===`0`||e===0?!1:e)}};export{n as BooleanSchema};
2
- //# sourceMappingURL=boolean.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"boolean.js","names":["BooleanSchema","Schema","value","ErrorCode","ctx","v"],"sources":["../../src/schemas/boolean.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class BooleanSchema<Input = boolean> extends Schema<boolean, Input> {\n protected override get _kind(): string {\n return 'boolean';\n }\n\n constructor() {\n super((value, ctx) =>\n typeof value === 'boolean'\n ? null\n : [{ code: ErrorCode.invalid_type, message: ctx!.messages.boolean.type(), path: [] }],\n );\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'boolean' };\n }\n\n static coerce(): BooleanSchema<unknown> {\n return new BooleanSchema().preprocess((v: unknown) => {\n if (typeof v === 'boolean') return v;\n\n if (v === 'true' || v === '1' || v === 1) return true;\n\n if (v === 'false' || v === '0' || v === 0) return false;\n\n return v;\n });\n }\n}\n"],"mappings":"A,4EAIA,IAAaA,EAAb,MAAaA,UAAuCC,CAAuB,CACzE,IAAuB,OAAgB,CACrC,MAAO,SACT,CAEA,aAAc,CACZ,OAAO,EAAO,IACZ,OAAOC,GAAU,UACb,KACA,CAAC,CAAE,KAAMC,EAAU,aAAc,QAASC,EAAK,SAAS,QAAQ,KAAK,EAAG,KAAM,CAAC,CAAE,CAAC,CACxF,CACF,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,SAAU,CACpD,CAEA,OAAO,QAAiC,CACtC,OAAO,IAAIJ,EAAc,CAAC,CAAC,WAAY,GACjC,OAAOK,GAAM,UAAkBA,EAE/BA,IAAM,QAAUA,IAAM,KAAOA,IAAM,EAAU,GAE7CA,IAAM,SAAWA,IAAM,KAAOA,IAAM,EAAU,GAE3CA,CACR,CACH,CACF,E"}
@@ -1,2 +0,0 @@
1
- const e=require("../types.cjs"),t=require("../core.cjs");function n(t){let n=new Set(t);return(r,i)=>n.has(r)?null:[{code:e.ErrorCode.invalid_enum,message:i.messages.enum.invalid({values:t}),params:{values:t},path:[]}]}var r=class extends t.Schema{values;get _kind(){return`enum`}constructor(e){super(n(e)),this.values=e}_toDescriptorImpl(){return{...this._describeBase(),kind:`enum`,values:this.values}}};exports.EnumSchema=r;
2
- //# sourceMappingURL=enum.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum.cjs","names":["ErrorCode","Schema","require_types","require_core","buildEnumValidator","set","values","value","ctx","EnumSchema"],"sources":["../../src/schemas/enum.ts"],"sourcesContent":["import type { SchemaDescriptor, ValidateFn } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport type EnumValues = readonly [string | number, ...(string | number)[]];\ntype EnumType<T extends EnumValues> = T[number];\n\nfunction buildEnumValidator(values: readonly unknown[]): ValidateFn {\n const set = new Set<unknown>(values);\n\n return (value, ctx) =>\n set.has(value)\n ? null\n : [\n {\n code: ErrorCode.invalid_enum,\n message: ctx!.messages.enum.invalid({ values }),\n params: { values },\n path: [],\n },\n ];\n}\n\nexport class EnumSchema<T extends EnumValues> extends Schema<EnumType<T>, EnumType<T>> {\n readonly values: T;\n\n protected override get _kind(): string {\n return 'enum';\n }\n\n constructor(values: T) {\n super(buildEnumValidator(values));\n this.values = values;\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'enum', values: this.values };\n }\n}\n"],"mappings":"A,yDAOA,SAASI,EAAmB,EAAwC,CAClE,IAAMC,EAAM,IAAI,IAAaC,CAAM,EAEnC,OAAQ,EAAO,IACbD,EAAI,IAAIE,CAAK,EACT,KACA,CACE,CACE,KAAMP,EAAAA,UAAU,aAChB,QAASQ,EAAK,SAAS,KAAK,QAAQ,CAAE,QAAO,CAAC,EAC9C,OAAQ,CAAE,QAAO,EACjB,KAAM,CAAC,CACT,CACF,CACR,CAEA,IAAaC,EAAb,cAAsDR,EAAAA,MAAiC,CACrF,OAEA,IAAuB,OAAgB,CACrC,MAAO,MACT,CAEA,YAAY,EAAW,CACrB,MAAMG,EAAmBE,CAAM,CAAC,EAChC,KAAK,OAASA,CAChB,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,OAAQ,OAAQ,KAAK,MAAO,CACtE,CACF,E"}
@@ -1,12 +0,0 @@
1
- import type { SchemaDescriptor } from '../core';
2
- import { Schema } from '../core';
3
- export type EnumValues = readonly [string | number, ...(string | number)[]];
4
- type EnumType<T extends EnumValues> = T[number];
5
- export declare class EnumSchema<T extends EnumValues> extends Schema<EnumType<T>, EnumType<T>> {
6
- readonly values: T;
7
- protected get _kind(): string;
8
- constructor(values: T);
9
- protected _toDescriptorImpl(): SchemaDescriptor;
10
- }
11
- export {};
12
- //# sourceMappingURL=enum.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/schemas/enum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,SAAS,CAAC;AAE5D,OAAO,EAAa,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAC5E,KAAK,QAAQ,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAkBhD,qBAAa,UAAU,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpF,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnB,cAAuB,KAAK,IAAI,MAAM,CAErC;gBAEW,MAAM,EAAE,CAAC;cAKF,iBAAiB,IAAI,gBAAgB;CAGzD"}
@@ -1,2 +0,0 @@
1
- import{ErrorCode as e}from"../types.js";import{Schema as t}from"../core.js";function n(t){let n=new Set(t);return(r,i)=>n.has(r)?null:[{code:e.invalid_enum,message:i.messages.enum.invalid({values:t}),params:{values:t},path:[]}]}var r=class extends t{values;get _kind(){return`enum`}constructor(e){super(n(e)),this.values=e}_toDescriptorImpl(){return{...this._describeBase(),kind:`enum`,values:this.values}}};export{r as EnumSchema};
2
- //# sourceMappingURL=enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum.js","names":["buildEnumValidator","set","values","value","ErrorCode","ctx","EnumSchema","Schema"],"sources":["../../src/schemas/enum.ts"],"sourcesContent":["import type { SchemaDescriptor, ValidateFn } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport type EnumValues = readonly [string | number, ...(string | number)[]];\ntype EnumType<T extends EnumValues> = T[number];\n\nfunction buildEnumValidator(values: readonly unknown[]): ValidateFn {\n const set = new Set<unknown>(values);\n\n return (value, ctx) =>\n set.has(value)\n ? null\n : [\n {\n code: ErrorCode.invalid_enum,\n message: ctx!.messages.enum.invalid({ values }),\n params: { values },\n path: [],\n },\n ];\n}\n\nexport class EnumSchema<T extends EnumValues> extends Schema<EnumType<T>, EnumType<T>> {\n readonly values: T;\n\n protected override get _kind(): string {\n return 'enum';\n }\n\n constructor(values: T) {\n super(buildEnumValidator(values));\n this.values = values;\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'enum', values: this.values };\n }\n}\n"],"mappings":"A,4EAOA,SAASA,EAAmB,EAAwC,CAClE,IAAMC,EAAM,IAAI,IAAaC,CAAM,EAEnC,OAAQ,EAAO,IACbD,EAAI,IAAIE,CAAK,EACT,KACA,CACE,CACE,KAAMC,EAAU,aAChB,QAASC,EAAK,SAAS,KAAK,QAAQ,CAAE,QAAO,CAAC,EAC9C,OAAQ,CAAE,QAAO,EACjB,KAAM,CAAC,CACT,CACF,CACR,CAEA,IAAaC,EAAb,cAAsDC,CAAiC,CACrF,OAEA,IAAuB,OAAgB,CACrC,MAAO,MACT,CAEA,YAAY,EAAW,CACrB,MAAMP,EAAmBE,CAAM,CAAC,EAChC,KAAK,OAASA,CAChB,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,OAAQ,OAAQ,KAAK,MAAO,CACtE,CACF,E"}
@@ -1,2 +0,0 @@
1
- const e=require("../types.cjs"),t=require("../core.cjs");var n=class extends t.Schema{cls;get _kind(){return`instanceof`}constructor(t){super((n,r)=>n instanceof t?null:[{code:e.ErrorCode.invalid_type,message:r.messages.instanceof.type({className:t.name}),path:[]}]),this.cls=t}_toDescriptorImpl(){return{...this._describeBase(),className:this.cls.name,kind:`instanceof`}}};exports.InstanceOfSchema=n;
2
- //# sourceMappingURL=instanceof.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instanceof.cjs","names":["Schema","ErrorCode","require_types","require_core","InstanceOfSchema","value","cls","ctx"],"sources":["../../src/schemas/instanceof.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class InstanceOfSchema<T> extends Schema<T, T> {\n readonly cls: new (\n ...args: never[]\n ) => T;\n\n protected override get _kind(): string {\n return 'instanceof';\n }\n\n constructor(cls: new (...args: never[]) => T) {\n super((value, ctx) =>\n value instanceof cls\n ? null\n : [\n {\n code: ErrorCode.invalid_type,\n message: ctx!.messages.instanceof.type({ className: cls.name }),\n path: [],\n },\n ],\n );\n this.cls = cls;\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), className: this.cls.name, kind: 'instanceof' };\n }\n}\n"],"mappings":"A,yDAIA,IAAaI,EAAb,cAAyCJ,EAAAA,MAAa,CACpD,IAIA,IAAuB,OAAgB,CACrC,MAAO,YACT,CAEA,YAAY,EAAkC,CAC5C,OAAO,EAAO,IACZK,aAAiBC,EACb,KACA,CACE,CACE,KAAML,EAAAA,UAAU,aAChB,QAASM,EAAK,SAAS,WAAW,KAAK,CAAE,UAAWD,EAAI,IAAK,CAAC,EAC9D,KAAM,CAAC,CACT,CACF,CACN,EACA,KAAK,IAAMA,CACb,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,UAAW,KAAK,IAAI,KAAM,KAAM,YAAa,CACjF,CACF,E"}
@@ -1,9 +0,0 @@
1
- import type { SchemaDescriptor } from '../core';
2
- import { Schema } from '../core';
3
- export declare class InstanceOfSchema<T> extends Schema<T, T> {
4
- readonly cls: new (...args: never[]) => T;
5
- protected get _kind(): string;
6
- constructor(cls: new (...args: never[]) => T);
7
- protected _toDescriptorImpl(): SchemaDescriptor;
8
- }
9
- //# sourceMappingURL=instanceof.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instanceof.d.ts","sourceRoot":"","sources":["../../src/schemas/instanceof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAa,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACnD,QAAQ,CAAC,GAAG,EAAE,KACZ,GAAG,IAAI,EAAE,KAAK,EAAE,KACb,CAAC,CAAC;IAEP,cAAuB,KAAK,IAAI,MAAM,CAErC;gBAEW,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;cAezB,iBAAiB,IAAI,gBAAgB;CAGzD"}
@@ -1,2 +0,0 @@
1
- import{ErrorCode as e}from"../types.js";import{Schema as t}from"../core.js";var n=class extends t{cls;get _kind(){return`instanceof`}constructor(t){super((n,r)=>n instanceof t?null:[{code:e.invalid_type,message:r.messages.instanceof.type({className:t.name}),path:[]}]),this.cls=t}_toDescriptorImpl(){return{...this._describeBase(),className:this.cls.name,kind:`instanceof`}}};export{n as InstanceOfSchema};
2
- //# sourceMappingURL=instanceof.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instanceof.js","names":["InstanceOfSchema","Schema","value","cls","ErrorCode","ctx"],"sources":["../../src/schemas/instanceof.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class InstanceOfSchema<T> extends Schema<T, T> {\n readonly cls: new (\n ...args: never[]\n ) => T;\n\n protected override get _kind(): string {\n return 'instanceof';\n }\n\n constructor(cls: new (...args: never[]) => T) {\n super((value, ctx) =>\n value instanceof cls\n ? null\n : [\n {\n code: ErrorCode.invalid_type,\n message: ctx!.messages.instanceof.type({ className: cls.name }),\n path: [],\n },\n ],\n );\n this.cls = cls;\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), className: this.cls.name, kind: 'instanceof' };\n }\n}\n"],"mappings":"A,4EAIA,IAAaA,EAAb,cAAyCC,CAAa,CACpD,IAIA,IAAuB,OAAgB,CACrC,MAAO,YACT,CAEA,YAAY,EAAkC,CAC5C,OAAO,EAAO,IACZC,aAAiBC,EACb,KACA,CACE,CACE,KAAMC,EAAU,aAChB,QAASC,EAAK,SAAS,WAAW,KAAK,CAAE,UAAWF,EAAI,IAAK,CAAC,EAC9D,KAAM,CAAC,CACT,CACF,CACN,EACA,KAAK,IAAMA,CACb,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,UAAW,KAAK,IAAI,KAAM,KAAM,YAAa,CACjF,CACF,E"}
@@ -1,2 +0,0 @@
1
- const e=require("../types.cjs"),t=require("../core.cjs");var n=class extends t.Schema{value;get _kind(){return`literal`}constructor(t){super((n,r)=>n===t?null:[{code:e.ErrorCode.invalid_literal,message:r.messages.literal.expected({expected:t}),params:{expected:t},path:[]}]),this.value=t}_toDescriptorImpl(){return{...this._describeBase(),kind:`literal`,value:this.value}}};exports.LiteralSchema=n;
2
- //# sourceMappingURL=literal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"literal.cjs","names":["Schema","ErrorCode","require_types","require_core","LiteralSchema","val","value","ctx"],"sources":["../../src/schemas/literal.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class LiteralSchema<T extends string | number | boolean | null | undefined> extends Schema<T, T> {\n readonly value: T;\n\n protected override get _kind(): string {\n return 'literal';\n }\n\n constructor(value: T) {\n super((val, ctx) =>\n val === value\n ? null\n : [\n {\n code: ErrorCode.invalid_literal,\n message: ctx!.messages.literal.expected({ expected: value }),\n params: { expected: value },\n path: [],\n },\n ],\n );\n this.value = value;\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'literal', value: this.value };\n }\n}\n"],"mappings":"A,yDAIA,IAAaI,EAAb,cAA2FJ,EAAAA,MAAa,CACtG,MAEA,IAAuB,OAAgB,CACrC,MAAO,SACT,CAEA,YAAY,EAAU,CACpB,OAAO,EAAK,IACVK,IAAQC,EACJ,KACA,CACE,CACE,KAAML,EAAAA,UAAU,gBAChB,QAASM,EAAK,SAAS,QAAQ,SAAS,CAAE,SAAUD,CAAM,CAAC,EAC3D,OAAQ,CAAE,SAAUA,CAAM,EAC1B,KAAM,CAAC,CACT,CACF,CACN,EACA,KAAK,MAAQA,CACf,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,UAAW,MAAO,KAAK,KAAM,CACvE,CACF,E"}
@@ -1,9 +0,0 @@
1
- import type { SchemaDescriptor } from '../core';
2
- import { Schema } from '../core';
3
- export declare class LiteralSchema<T extends string | number | boolean | null | undefined> extends Schema<T, T> {
4
- readonly value: T;
5
- protected get _kind(): string;
6
- constructor(value: T);
7
- protected _toDescriptorImpl(): SchemaDescriptor;
8
- }
9
- //# sourceMappingURL=literal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../src/schemas/literal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAa,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAE,SAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACrG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAElB,cAAuB,KAAK,IAAI,MAAM,CAErC;gBAEW,KAAK,EAAE,CAAC;cAgBD,iBAAiB,IAAI,gBAAgB;CAGzD"}
@@ -1,2 +0,0 @@
1
- import{ErrorCode as e}from"../types.js";import{Schema as t}from"../core.js";var n=class extends t{value;get _kind(){return`literal`}constructor(t){super((n,r)=>n===t?null:[{code:e.invalid_literal,message:r.messages.literal.expected({expected:t}),params:{expected:t},path:[]}]),this.value=t}_toDescriptorImpl(){return{...this._describeBase(),kind:`literal`,value:this.value}}};export{n as LiteralSchema};
2
- //# sourceMappingURL=literal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"literal.js","names":["LiteralSchema","Schema","val","value","ErrorCode","ctx"],"sources":["../../src/schemas/literal.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class LiteralSchema<T extends string | number | boolean | null | undefined> extends Schema<T, T> {\n readonly value: T;\n\n protected override get _kind(): string {\n return 'literal';\n }\n\n constructor(value: T) {\n super((val, ctx) =>\n val === value\n ? null\n : [\n {\n code: ErrorCode.invalid_literal,\n message: ctx!.messages.literal.expected({ expected: value }),\n params: { expected: value },\n path: [],\n },\n ],\n );\n this.value = value;\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'literal', value: this.value };\n }\n}\n"],"mappings":"A,4EAIA,IAAaA,EAAb,cAA2FC,CAAa,CACtG,MAEA,IAAuB,OAAgB,CACrC,MAAO,SACT,CAEA,YAAY,EAAU,CACpB,OAAO,EAAK,IACVC,IAAQC,EACJ,KACA,CACE,CACE,KAAMC,EAAU,gBAChB,QAASC,EAAK,SAAS,QAAQ,SAAS,CAAE,SAAUF,CAAM,CAAC,EAC3D,OAAQ,CAAE,SAAUA,CAAM,EAC1B,KAAM,CAAC,CACT,CACF,CACN,EACA,KAAK,MAAQA,CACf,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,UAAW,MAAO,KAAK,KAAM,CACvE,CACF,E"}
@@ -1,2 +0,0 @@
1
- const e=require("../types.cjs"),t=require("../core.cjs");var n=class extends t.Schema{get _kind(){return`never`}constructor(){super((t,n)=>[{code:e.ErrorCode.invalid_type,message:n.messages.never.invalid(),path:[]}])}_toDescriptorImpl(){return{...this._describeBase(),kind:`never`}}};exports.NeverSchema=n;
2
- //# sourceMappingURL=never.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"never.cjs","names":["Schema","ErrorCode","require_types","require_core","NeverSchema","ctx"],"sources":["../../src/schemas/never.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class NeverSchema extends Schema<never, never> {\n protected override get _kind(): string {\n return 'never';\n }\n\n constructor() {\n super((_value, ctx) => [{ code: ErrorCode.invalid_type, message: ctx!.messages.never.invalid(), path: [] }]);\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'never' };\n }\n}\n"],"mappings":"A,yDAIA,IAAaI,EAAb,cAAiCJ,EAAAA,MAAqB,CACpD,IAAuB,OAAgB,CACrC,MAAO,OACT,CAEA,aAAc,CACZ,OAAO,EAAQ,IAAQ,CAAC,CAAE,KAAMC,EAAAA,UAAU,aAAc,QAASI,EAAK,SAAS,MAAM,QAAQ,EAAG,KAAM,CAAC,CAAE,CAAC,CAAC,CAC7G,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,OAAQ,CAClD,CACF,E"}
@@ -1,8 +0,0 @@
1
- import type { SchemaDescriptor } from '../core';
2
- import { Schema } from '../core';
3
- export declare class NeverSchema extends Schema<never, never> {
4
- protected get _kind(): string;
5
- constructor();
6
- protected _toDescriptorImpl(): SchemaDescriptor;
7
- }
8
- //# sourceMappingURL=never.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"never.d.ts","sourceRoot":"","sources":["../../src/schemas/never.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAa,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,WAAY,SAAQ,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC;IACnD,cAAuB,KAAK,IAAI,MAAM,CAErC;;cAMkB,iBAAiB,IAAI,gBAAgB;CAGzD"}
@@ -1,2 +0,0 @@
1
- import{ErrorCode as e}from"../types.js";import{Schema as t}from"../core.js";var n=class extends t{get _kind(){return`never`}constructor(){super((t,n)=>[{code:e.invalid_type,message:n.messages.never.invalid(),path:[]}])}_toDescriptorImpl(){return{...this._describeBase(),kind:`never`}}};export{n as NeverSchema};
2
- //# sourceMappingURL=never.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"never.js","names":["NeverSchema","Schema","ErrorCode","ctx"],"sources":["../../src/schemas/never.ts"],"sourcesContent":["import type { SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\n\nexport class NeverSchema extends Schema<never, never> {\n protected override get _kind(): string {\n return 'never';\n }\n\n constructor() {\n super((_value, ctx) => [{ code: ErrorCode.invalid_type, message: ctx!.messages.never.invalid(), path: [] }]);\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n return { ...this._describeBase(), kind: 'never' };\n }\n}\n"],"mappings":"A,4EAIA,IAAaA,EAAb,cAAiCC,CAAqB,CACpD,IAAuB,OAAgB,CACrC,MAAO,OACT,CAEA,aAAc,CACZ,OAAO,EAAQ,IAAQ,CAAC,CAAE,KAAMC,EAAU,aAAc,QAASC,EAAK,SAAS,MAAM,QAAQ,EAAG,KAAM,CAAC,CAAE,CAAC,CAAC,CAC7G,CAEA,mBAAyD,CACvD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,KAAM,OAAQ,CAClD,CACF,E"}
@@ -1,2 +0,0 @@
1
- const e=require("../core.cjs"),t=require("./literal.cjs");function n(n){return n.map(n=>n instanceof e.Schema?n:new t.LiteralSchema(n))}exports.normalizeToSchemas=n;
2
- //# sourceMappingURL=raw-or.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"raw-or.cjs","names":["Schema","LiteralSchema","require_core","require_literal","normalizeToSchemas","items","item"],"sources":["../../src/schemas/raw-or.ts"],"sourcesContent":["/**\n * Helpers for accepting raw literal values alongside schema instances in\n * sUnion() and sIntersect() arguments.\n *\n * Moved out of literal.ts: this infrastructure belongs to the combinator\n * entry points (s.ts), not to LiteralSchema.\n */\n\nimport type { AnySchema } from '../core';\n\nimport { Schema } from '../core';\nimport { LiteralSchema } from './literal';\n\nexport type LiteralValue = string | number | boolean | null | undefined;\nexport type RawOrSchema = AnySchema | LiteralValue;\nexport type NormalizeItem<T> = T extends AnySchema ? T : T extends LiteralValue ? LiteralSchema<T> : never;\nexport type NormalizeItems<T extends readonly RawOrSchema[]> = { readonly [K in keyof T]: NormalizeItem<T[K]> };\n\nexport function normalizeToSchemas<T extends readonly RawOrSchema[]>(items: T): NormalizeItems<T> {\n return items.map((item) =>\n item instanceof Schema ? item : new LiteralSchema(item as LiteralValue),\n ) as unknown as NormalizeItems<T>;\n}\n"],"mappings":"A,0DAkBA,SAAgBI,EAAqD,EAA6B,CAChG,OAAOC,EAAM,IAAK,GAChBC,aAAgBN,EAAAA,OAASM,EAAO,IAAIL,EAAAA,cAAcK,CAAoB,CACxE,CACF,C"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Helpers for accepting raw literal values alongside schema instances in
3
- * sUnion() and sIntersect() arguments.
4
- *
5
- * Moved out of literal.ts: this infrastructure belongs to the combinator
6
- * entry points (s.ts), not to LiteralSchema.
7
- */
8
- import type { AnySchema } from '../core';
9
- import { LiteralSchema } from './literal';
10
- export type LiteralValue = string | number | boolean | null | undefined;
11
- export type RawOrSchema = AnySchema | LiteralValue;
12
- export type NormalizeItem<T> = T extends AnySchema ? T : T extends LiteralValue ? LiteralSchema<T> : never;
13
- export type NormalizeItems<T extends readonly RawOrSchema[]> = {
14
- readonly [K in keyof T]: NormalizeItem<T[K]>;
15
- };
16
- export declare function normalizeToSchemas<T extends readonly RawOrSchema[]>(items: T): NormalizeItems<T>;
17
- //# sourceMappingURL=raw-or.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"raw-or.d.ts","sourceRoot":"","sources":["../../src/schemas/raw-or.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;AACnD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,CAAC,SAAS,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAC3G,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEhH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAIhG"}
@@ -1,2 +0,0 @@
1
- import{Schema as e}from"../core.js";import{LiteralSchema as t}from"./literal.js";function n(n){return n.map(n=>n instanceof e?n:new t(n))}export{n as normalizeToSchemas};
2
- //# sourceMappingURL=raw-or.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"raw-or.js","names":["normalizeToSchemas","items","item","Schema","LiteralSchema"],"sources":["../../src/schemas/raw-or.ts"],"sourcesContent":["/**\n * Helpers for accepting raw literal values alongside schema instances in\n * sUnion() and sIntersect() arguments.\n *\n * Moved out of literal.ts: this infrastructure belongs to the combinator\n * entry points (s.ts), not to LiteralSchema.\n */\n\nimport type { AnySchema } from '../core';\n\nimport { Schema } from '../core';\nimport { LiteralSchema } from './literal';\n\nexport type LiteralValue = string | number | boolean | null | undefined;\nexport type RawOrSchema = AnySchema | LiteralValue;\nexport type NormalizeItem<T> = T extends AnySchema ? T : T extends LiteralValue ? LiteralSchema<T> : never;\nexport type NormalizeItems<T extends readonly RawOrSchema[]> = { readonly [K in keyof T]: NormalizeItem<T[K]> };\n\nexport function normalizeToSchemas<T extends readonly RawOrSchema[]>(items: T): NormalizeItems<T> {\n return items.map((item) =>\n item instanceof Schema ? item : new LiteralSchema(item as LiteralValue),\n ) as unknown as NormalizeItems<T>;\n}\n"],"mappings":"A,iFAkBA,SAAgBA,EAAqD,EAA6B,CAChG,OAAOC,EAAM,IAAK,GAChBC,aAAgBC,EAASD,EAAO,IAAIE,EAAcF,CAAoB,CACxE,CACF,C"}
@@ -1,2 +0,0 @@
1
- const e=require("../core.cjs"),t=require("../errors.cjs"),n=require("../types.cjs"),r=require("../safe-object.cjs"),i=require("./literal.cjs");var a=class extends e.Schema{_map;_discriminator;get _kind(){return`variant`}constructor(e,n){let r=new Map;for(let[a,o]of Object.entries(n)){let n=new i.LiteralSchema(a),s=o.shape[e];if(s&&(!(s instanceof i.LiteralSchema)||s.value!==a))throw new t.SpellError(`s.discriminatedUnion(): branch "${a}" defines a conflicting discriminator schema for "${e}".`);let c={[e]:n};r.set(a,s?o:o.extend(c))}super(),this._discriminator=e,this._map=r}get discriminator(){return this._discriminator}get variantMap(){return new Map(this._map)}_resolveVariant(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return{issues:[{code:n.ErrorCode.invalid_type,message:t.messages.variant.type(),path:[]}]};let r=e,i=r[this._discriminator],a=this._map.get(i);if(!a){let e=[...this._map.keys()];return{issues:[{code:n.ErrorCode.invalid_variant,message:t.messages.variant.invalidDiscriminator({discriminator:this._discriminator,expected:e}),params:{discriminator:this._discriminator,expected:e},path:[]}]}}return{matched:a,obj:r}}_parse(e,t){let n=this._resolveVariant(e,t);if(`issues`in n)return{data:e,issues:n.issues,typeOk:!1};let r=n.matched._parseFullSync(e,t);return r.issues.length===0?{data:r.data,issues:[],typeOk:!0}:{data:e,issues:r.issues,typeOk:!0}}async _parseAsync(e,t){let n=this._resolveVariant(e,t);if(`issues`in n)return{data:e,issues:n.issues,typeOk:!1};let r=await n.matched._parseFullAsync(e,t);return r.issues.length===0?{data:r.data,issues:[],typeOk:!0}:{data:e,issues:r.issues,typeOk:!0}}_toDescriptorImpl(){let e={};for(let[t,n]of this._map.entries())r.defineOwnProperty(e,t,n.definition());return{...this._describeBase(),branches:e,discriminator:this._discriminator,kind:`variant`}}};exports.VariantSchema=a;
2
- //# sourceMappingURL=variant.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variant.cjs","names":["Schema","LiteralSchema","SpellError","ErrorCode","require_core","require_errors","require_types","require_safe_object","require_literal","VariantSchema","map","tag","schema","variantMap","discriminatorSchema","existingDiscriminator","discriminator","discriminatorShape","value","ctx","obj","discValue","matched","expected","resolved","result","branches","key"],"sources":["../../src/schemas/variant.ts"],"sourcesContent":["import type { AnySchema, Issue, ParseContext, ParseValue, SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\nimport { SpellError } from '../errors';\nimport { defineOwnProperty } from '../safe-object';\nimport { LiteralSchema } from './literal';\nimport type { InferObject, InferObjectInput, ObjectSchema, ObjectShape } from './object';\n\ntype VariantMap = Record<string, ObjectSchema<any>>;\ntype Simplify<T> = { [P in keyof T]: T[P] };\ntype InferVariantMap<K extends string, M extends VariantMap> = {\n [Tag in keyof M & string]: M[Tag] extends { shape: infer S extends ObjectShape }\n ? InferObject<S> & { [P in K]: Tag }\n : never;\n}[keyof M & string];\ntype InferVariantInputMap<K extends string, M extends VariantMap> = {\n [Tag in keyof M & string]: M[Tag] extends { shape: infer S extends ObjectShape }\n ? Simplify<InferObjectInput<S> & { [P in K]: Tag }>\n : never;\n}[keyof M & string];\n\nexport class VariantSchema<K extends string, M extends VariantMap> extends Schema<\n InferVariantMap<K, M>,\n InferVariantInputMap<K, M>\n> {\n private readonly _map: Map<string, VariantMap[string]>;\n private readonly _discriminator: K;\n\n protected override get _kind(): string {\n return 'variant';\n }\n\n constructor(discriminator: K, variantMap: M) {\n const map = new Map<string, VariantMap[string]>();\n\n for (const [tag, schema] of Object.entries(variantMap)) {\n const discriminatorSchema = new LiteralSchema(tag);\n const existingDiscriminator = schema.shape[discriminator];\n\n if (\n existingDiscriminator &&\n (!(existingDiscriminator instanceof LiteralSchema) || existingDiscriminator.value !== tag)\n ) {\n throw new SpellError(\n `s.discriminatedUnion(): branch \"${tag}\" defines a conflicting discriminator schema for \"${discriminator}\".`,\n );\n }\n\n const discriminatorShape = {\n [discriminator]: discriminatorSchema,\n } as unknown as Record<K, AnySchema>;\n\n map.set(tag, existingDiscriminator ? schema : schema.extend(discriminatorShape));\n }\n\n super();\n this._discriminator = discriminator;\n this._map = map;\n }\n\n /** The discriminator field key used to select the matching variant. */\n get discriminator(): K {\n return this._discriminator;\n }\n\n /** Map from discriminator tag value to the extended ObjectSchema for that variant. */\n get variantMap(): ReadonlyMap<string, VariantMap[string]> {\n return new Map(this._map);\n }\n\n private _resolveVariant(\n value: unknown,\n ctx: ParseContext,\n ): { matched: VariantMap[string]; obj: Record<string, unknown> } | { issues: Issue[] } {\n if (value == null || typeof value !== 'object' || Array.isArray(value)) {\n return {\n issues: [{ code: ErrorCode.invalid_type, message: ctx.messages.variant.type(), path: [] }],\n };\n }\n\n const obj = value as Record<string, unknown>;\n const discValue = obj[this._discriminator] as string;\n const matched = this._map.get(discValue);\n\n if (!matched) {\n const expected = [...this._map.keys()];\n\n return {\n issues: [\n {\n code: ErrorCode.invalid_variant,\n message: ctx.messages.variant.invalidDiscriminator({\n discriminator: this._discriminator,\n expected,\n }),\n params: { discriminator: this._discriminator, expected },\n path: [],\n },\n ],\n };\n }\n\n return { matched, obj };\n }\n\n protected override _parse(value: unknown, ctx: ParseContext): ParseValue {\n const resolved = this._resolveVariant(value, ctx);\n\n if ('issues' in resolved) return { data: value, issues: resolved.issues, typeOk: false };\n\n const result = resolved.matched._parseFullSync(value, ctx);\n\n return result.issues.length === 0\n ? { data: result.data, issues: [], typeOk: true }\n : { data: value, issues: result.issues, typeOk: true };\n }\n\n protected override async _parseAsync(value: unknown, ctx: ParseContext): Promise<ParseValue> {\n const resolved = this._resolveVariant(value, ctx);\n\n if ('issues' in resolved) return { data: value, issues: resolved.issues, typeOk: false };\n\n const result = await resolved.matched._parseFullAsync(value, ctx);\n\n return result.issues.length === 0\n ? { data: result.data, issues: [], typeOk: true }\n : { data: value, issues: result.issues, typeOk: true };\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n const branches: Record<string, SchemaDescriptor> = {};\n\n for (const [key, schema] of this._map.entries()) {\n defineOwnProperty(branches, key, schema.definition());\n }\n\n return { ...this._describeBase(), branches, discriminator: this._discriminator, kind: 'variant' };\n }\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, InferObjectInput, ObjectSchema, ObjectShape } from './object';
4
- type VariantMap = Record<string, ObjectSchema<any>>;
5
- type Simplify<T> = {
6
- [P in keyof T]: T[P];
7
- };
8
- type InferVariantMap<K extends string, M extends VariantMap> = {
9
- [Tag in keyof M & string]: M[Tag] extends {
10
- shape: infer S extends ObjectShape;
11
- } ? InferObject<S> & {
12
- [P in K]: Tag;
13
- } : never;
14
- }[keyof M & string];
15
- type InferVariantInputMap<K extends string, M extends VariantMap> = {
16
- [Tag in keyof M & string]: M[Tag] extends {
17
- shape: infer S extends ObjectShape;
18
- } ? Simplify<InferObjectInput<S> & {
19
- [P in K]: Tag;
20
- }> : never;
21
- }[keyof M & string];
22
- export declare class VariantSchema<K extends string, M extends VariantMap> extends Schema<InferVariantMap<K, M>, InferVariantInputMap<K, M>> {
23
- private readonly _map;
24
- private readonly _discriminator;
25
- protected get _kind(): string;
26
- constructor(discriminator: K, variantMap: M);
27
- /** The discriminator field key used to select the matching variant. */
28
- get discriminator(): K;
29
- /** Map from discriminator tag value to the extended ObjectSchema for that variant. */
30
- get variantMap(): ReadonlyMap<string, VariantMap[string]>;
31
- private _resolveVariant;
32
- protected _parse(value: unknown, ctx: ParseContext): ParseValue;
33
- protected _parseAsync(value: unknown, ctx: ParseContext): Promise<ParseValue>;
34
- protected _toDescriptorImpl(): SchemaDescriptor;
35
- }
36
- export {};
37
- //# sourceMappingURL=variant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/schemas/variant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5F,OAAO,EAAa,MAAM,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzF,KAAK,UAAU,GAAG,MAAM,CAAC,MAA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uEAAuE;IACvE,IAAI,aAAa,IAAI,CAAC,CAErB;IAED,sFAAsF;IACtF,IAAI,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAExD;IAED,OAAO,CAAC,eAAe;cAmCJ,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,UAAU;cAY/C,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;cAYzE,iBAAiB,IAAI,gBAAgB;CASzD"}
@@ -1,2 +0,0 @@
1
- import{Schema as e}from"../core.js";import{SpellError as t}from"../errors.js";import{ErrorCode as n}from"../types.js";import{defineOwnProperty as r}from"../safe-object.js";import{LiteralSchema as i}from"./literal.js";var a=class extends e{_map;_discriminator;get _kind(){return`variant`}constructor(e,n){let r=/* @__PURE__ */ new Map;for(let[a,o]of Object.entries(n)){let n=new i(a),s=o.shape[e];if(s&&(!(s instanceof i)||s.value!==a))throw new t(`s.discriminatedUnion(): branch "${a}" defines a conflicting discriminator schema for "${e}".`);let c={[e]:n};r.set(a,s?o:o.extend(c))}super(),this._discriminator=e,this._map=r}get discriminator(){return this._discriminator}get variantMap(){return new Map(this._map)}_resolveVariant(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return{issues:[{code:n.invalid_type,message:t.messages.variant.type(),path:[]}]};let r=e,i=r[this._discriminator],a=this._map.get(i);if(!a){let e=[...this._map.keys()];return{issues:[{code:n.invalid_variant,message:t.messages.variant.invalidDiscriminator({discriminator:this._discriminator,expected:e}),params:{discriminator:this._discriminator,expected:e},path:[]}]}}return{matched:a,obj:r}}_parse(e,t){let n=this._resolveVariant(e,t);if(`issues`in n)return{data:e,issues:n.issues,typeOk:!1};let r=n.matched._parseFullSync(e,t);return r.issues.length===0?{data:r.data,issues:[],typeOk:!0}:{data:e,issues:r.issues,typeOk:!0}}async _parseAsync(e,t){let n=this._resolveVariant(e,t);if(`issues`in n)return{data:e,issues:n.issues,typeOk:!1};let r=await n.matched._parseFullAsync(e,t);return r.issues.length===0?{data:r.data,issues:[],typeOk:!0}:{data:e,issues:r.issues,typeOk:!0}}_toDescriptorImpl(){let e={};for(let[t,n]of this._map.entries())r(e,t,n.definition());return{...this._describeBase(),branches:e,discriminator:this._discriminator,kind:`variant`}}};export{a as VariantSchema};
2
- //# sourceMappingURL=variant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variant.js","names":["VariantSchema","Schema","map","tag","schema","variantMap","discriminatorSchema","LiteralSchema","existingDiscriminator","discriminator","SpellError","discriminatorShape","value","ErrorCode","ctx","obj","discValue","matched","expected","resolved","result","branches","key","defineOwnProperty"],"sources":["../../src/schemas/variant.ts"],"sourcesContent":["import type { AnySchema, Issue, ParseContext, ParseValue, SchemaDescriptor } from '../core';\n\nimport { ErrorCode, Schema } from '../core';\nimport { SpellError } from '../errors';\nimport { defineOwnProperty } from '../safe-object';\nimport { LiteralSchema } from './literal';\nimport type { InferObject, InferObjectInput, ObjectSchema, ObjectShape } from './object';\n\ntype VariantMap = Record<string, ObjectSchema<any>>;\ntype Simplify<T> = { [P in keyof T]: T[P] };\ntype InferVariantMap<K extends string, M extends VariantMap> = {\n [Tag in keyof M & string]: M[Tag] extends { shape: infer S extends ObjectShape }\n ? InferObject<S> & { [P in K]: Tag }\n : never;\n}[keyof M & string];\ntype InferVariantInputMap<K extends string, M extends VariantMap> = {\n [Tag in keyof M & string]: M[Tag] extends { shape: infer S extends ObjectShape }\n ? Simplify<InferObjectInput<S> & { [P in K]: Tag }>\n : never;\n}[keyof M & string];\n\nexport class VariantSchema<K extends string, M extends VariantMap> extends Schema<\n InferVariantMap<K, M>,\n InferVariantInputMap<K, M>\n> {\n private readonly _map: Map<string, VariantMap[string]>;\n private readonly _discriminator: K;\n\n protected override get _kind(): string {\n return 'variant';\n }\n\n constructor(discriminator: K, variantMap: M) {\n const map = new Map<string, VariantMap[string]>();\n\n for (const [tag, schema] of Object.entries(variantMap)) {\n const discriminatorSchema = new LiteralSchema(tag);\n const existingDiscriminator = schema.shape[discriminator];\n\n if (\n existingDiscriminator &&\n (!(existingDiscriminator instanceof LiteralSchema) || existingDiscriminator.value !== tag)\n ) {\n throw new SpellError(\n `s.discriminatedUnion(): branch \"${tag}\" defines a conflicting discriminator schema for \"${discriminator}\".`,\n );\n }\n\n const discriminatorShape = {\n [discriminator]: discriminatorSchema,\n } as unknown as Record<K, AnySchema>;\n\n map.set(tag, existingDiscriminator ? schema : schema.extend(discriminatorShape));\n }\n\n super();\n this._discriminator = discriminator;\n this._map = map;\n }\n\n /** The discriminator field key used to select the matching variant. */\n get discriminator(): K {\n return this._discriminator;\n }\n\n /** Map from discriminator tag value to the extended ObjectSchema for that variant. */\n get variantMap(): ReadonlyMap<string, VariantMap[string]> {\n return new Map(this._map);\n }\n\n private _resolveVariant(\n value: unknown,\n ctx: ParseContext,\n ): { matched: VariantMap[string]; obj: Record<string, unknown> } | { issues: Issue[] } {\n if (value == null || typeof value !== 'object' || Array.isArray(value)) {\n return {\n issues: [{ code: ErrorCode.invalid_type, message: ctx.messages.variant.type(), path: [] }],\n };\n }\n\n const obj = value as Record<string, unknown>;\n const discValue = obj[this._discriminator] as string;\n const matched = this._map.get(discValue);\n\n if (!matched) {\n const expected = [...this._map.keys()];\n\n return {\n issues: [\n {\n code: ErrorCode.invalid_variant,\n message: ctx.messages.variant.invalidDiscriminator({\n discriminator: this._discriminator,\n expected,\n }),\n params: { discriminator: this._discriminator, expected },\n path: [],\n },\n ],\n };\n }\n\n return { matched, obj };\n }\n\n protected override _parse(value: unknown, ctx: ParseContext): ParseValue {\n const resolved = this._resolveVariant(value, ctx);\n\n if ('issues' in resolved) return { data: value, issues: resolved.issues, typeOk: false };\n\n const result = resolved.matched._parseFullSync(value, ctx);\n\n return result.issues.length === 0\n ? { data: result.data, issues: [], typeOk: true }\n : { data: value, issues: result.issues, typeOk: true };\n }\n\n protected override async _parseAsync(value: unknown, ctx: ParseContext): Promise<ParseValue> {\n const resolved = this._resolveVariant(value, ctx);\n\n if ('issues' in resolved) return { data: value, issues: resolved.issues, typeOk: false };\n\n const result = await resolved.matched._parseFullAsync(value, ctx);\n\n return result.issues.length === 0\n ? { data: result.data, issues: [], typeOk: true }\n : { data: value, issues: result.issues, typeOk: true };\n }\n\n protected override _toDescriptorImpl(): SchemaDescriptor {\n const branches: Record<string, SchemaDescriptor> = {};\n\n for (const [key, schema] of this._map.entries()) {\n defineOwnProperty(branches, key, schema.definition());\n }\n\n return { ...this._describeBase(), branches, discriminator: this._discriminator, kind: 'variant' };\n }\n}\n"],"mappings":"A,yNAqBA,IAAaA,EAAb,cAA2EC,CAGzE,CACA,KACA,eAEA,IAAuB,OAAgB,CACrC,MAAO,SACT,CAEA,YAAY,EAAkB,EAAe,CAC3C,IAAMC,kBAAM,IAAI,IAEhB,IAAK,GAAM,CAACC,EAAKC,KAAW,OAAO,QAAQC,CAAU,EAAG,CACtD,IAAMC,EAAsB,IAAIC,EAAcJ,CAAG,EAC3CK,EAAwBJ,EAAO,MAAMK,GAE3C,GACED,IACC,EAAEA,aAAiCD,IAAkBC,EAAsB,QAAUL,GAEtF,MAAM,IAAIO,EACR,mCAAmCP,EAAI,oDAAoDM,EAAc,GAC3G,EAGF,IAAME,EAAqB,EACxBF,GAAgBH,CACnB,EAEAJ,EAAI,IAAIC,EAAKK,EAAwBJ,EAASA,EAAO,OAAOO,CAAkB,CAAC,CACjF,CAEA,MAAM,EACN,KAAK,eAAiBF,EACtB,KAAK,KAAOP,CACd,CAGA,IAAI,eAAmB,CACrB,OAAO,KAAK,cACd,CAGA,IAAI,YAAsD,CACxD,OAAO,IAAI,IAAI,KAAK,IAAI,CAC1B,CAEA,gBACE,EACA,EACqF,CACrF,GAAqB,OAAOU,GAAU,WAAlCA,GAA8C,MAAM,QAAQA,CAAK,EACnE,MAAO,CACL,OAAQ,CAAC,CAAE,KAAMC,EAAU,aAAc,QAASC,EAAI,SAAS,QAAQ,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AAyD,CACvD,IAAMC,EAA6C,CAAC,EAEpD,IAAK,GAAM,CAACC,EAAKlB,KAAW,KAAK,KAAK,QAAQ,EAC5CmB,EAAkBF,EAAUC,EAAKlB,EAAO,WAAW,CAAC,EAGtD,MAAO,CAAE,GAAG,KAAK,cAAc,EAAG,WAAU,cAAe,KAAK,eAAgB,KAAM,SAAU,CAClG,CACF,E"}
package/dist/tolerate.cjs DELETED
@@ -1,2 +0,0 @@
1
- function e(e,...t){let n=new Set(t);return e.preprocess(e=>{if(typeof e!=`object`||!e)return e;let t=!1;for(let r of Object.keys(e))if(n.has(r)){t=!0;break}if(!t)return e;let r={};for(let[t,i]of Object.entries(e))n.has(t)||(r[t]=i);return r})}exports.tolerate=e;
2
- //# sourceMappingURL=tolerate.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tolerate.cjs","names":["tolerate","keys","tolerated","schema","value","stripped","key","next","entry"],"sources":["../src/tolerate.ts"],"sourcesContent":["import type { Schema } from './core';\n\n/**\n * Accepts and drops named keys a record carries from an older schema version, instead of failing\n * `invalid_keys`. One call per removed field: the parsed output never sees the tolerated keys.\n *\n * @example\n * const hunter = tolerate(s.object({ name: s.string() }), 'woundCount');\n */\nexport function tolerate<Output extends object, Input>(\n schema: Schema<Output, Input>,\n ...keys: string[]\n): Schema<Output, Input> {\n const tolerated = new Set(keys);\n return schema.preprocess((value) => {\n if (typeof value !== 'object' || value === null) return value;\n let stripped = false;\n for (const key of Object.keys(value)) {\n if (tolerated.has(key)) {\n stripped = true;\n break;\n }\n }\n if (!stripped) return value;\n const next: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (!tolerated.has(key)) next[key] = entry;\n }\n return next;\n });\n}\n"],"mappings":"AASA,SAAgBA,EACd,EACA,GAAGC,EACoB,CACvB,IAAMC,EAAY,IAAI,IAAID,CAAI,EAC9B,OAAOE,EAAO,WAAY,GAAU,CAClC,GAAI,OAAOC,GAAU,WAAYA,EAAgB,OAAOA,EACxD,IAAIC,EAAW,GACf,IAAK,IAAMC,KAAO,OAAO,KAAKF,CAAK,EACjC,GAAIF,EAAU,IAAII,CAAG,EAAG,CACtB,EAAW,GACX,KACF,CAEF,GAAI,CAACD,EAAU,OAAOD,EACtB,IAAMG,EAAgC,CAAC,EACvC,IAAK,GAAM,CAACD,EAAKE,KAAU,OAAO,QAAQJ,CAAK,EACxCF,EAAU,IAAII,CAAG,IAAG,EAAKA,GAAOE,GAEvC,OAAOD,CACT,CAAC,CACH,C"}
@@ -1,10 +0,0 @@
1
- import type { Schema } from './core';
2
- /**
3
- * Accepts and drops named keys a record carries from an older schema version, instead of failing
4
- * `invalid_keys`. One call per removed field: the parsed output never sees the tolerated keys.
5
- *
6
- * @example
7
- * const hunter = tolerate(s.object({ name: s.string() }), 'woundCount');
8
- */
9
- export declare function tolerate<Output extends object, Input>(schema: Schema<Output, Input>, ...keys: string[]): Schema<Output, Input>;
10
- //# sourceMappingURL=tolerate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tolerate.d.ts","sourceRoot":"","sources":["../src/tolerate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EACnD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC7B,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAkBvB"}
package/dist/tolerate.js DELETED
@@ -1,2 +0,0 @@
1
- function e(e,...t){let n=new Set(t);return e.preprocess(e=>{if(typeof e!=`object`||!e)return e;let t=!1;for(let r of Object.keys(e))if(n.has(r)){t=!0;break}if(!t)return e;let r={};for(let[t,i]of Object.entries(e))n.has(t)||(r[t]=i);return r})}export{e as tolerate};
2
- //# sourceMappingURL=tolerate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tolerate.js","names":["tolerate","keys","tolerated","schema","value","stripped","key","next","entry"],"sources":["../src/tolerate.ts"],"sourcesContent":["import type { Schema } from './core';\n\n/**\n * Accepts and drops named keys a record carries from an older schema version, instead of failing\n * `invalid_keys`. One call per removed field: the parsed output never sees the tolerated keys.\n *\n * @example\n * const hunter = tolerate(s.object({ name: s.string() }), 'woundCount');\n */\nexport function tolerate<Output extends object, Input>(\n schema: Schema<Output, Input>,\n ...keys: string[]\n): Schema<Output, Input> {\n const tolerated = new Set(keys);\n return schema.preprocess((value) => {\n if (typeof value !== 'object' || value === null) return value;\n let stripped = false;\n for (const key of Object.keys(value)) {\n if (tolerated.has(key)) {\n stripped = true;\n break;\n }\n }\n if (!stripped) return value;\n const next: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (!tolerated.has(key)) next[key] = entry;\n }\n return next;\n });\n}\n"],"mappings":"AASA,SAAgBA,EACd,EACA,GAAGC,EACoB,CACvB,IAAMC,EAAY,IAAI,IAAID,CAAI,EAC9B,OAAOE,EAAO,WAAY,GAAU,CAClC,GAAI,OAAOC,GAAU,WAAYA,EAAgB,OAAOA,EACxD,IAAIC,EAAW,GACf,IAAK,IAAMC,KAAO,OAAO,KAAKF,CAAK,EACjC,GAAIF,EAAU,IAAII,CAAG,EAAG,CACtB,EAAW,GACX,KACF,CAEF,GAAI,CAACD,EAAU,OAAOD,EACtB,IAAMG,EAAgC,CAAC,EACvC,IAAK,GAAM,CAACD,EAAKE,KAAU,OAAO,QAAQJ,CAAK,EACxCF,EAAU,IAAII,CAAG,IAAG,EAAKA,GAAOE,GAEvC,OAAOD,CACT,CAAC,CACH,C"}
@@ -1,2 +0,0 @@
1
- var e=(e,t)=>e.length>=t,t=(e,t)=>e.length<=t,n=(e,t,n)=>e>=t&&e<=n,r=e=>Number.isInteger(e),i=e=>e>0,a=e=>e>=0,o=e=>e<0,s=(e,t)=>e%t===0,c=e=>typeof e==`string`,l=e=>typeof e==`number`&&!Number.isNaN(e),u=e=>typeof e==`boolean`,d=e=>e==null,f=e=>e instanceof Date&&!Number.isNaN(e.getTime()),p=e=>Array.isArray(e);exports.hasMaxLength=t,exports.hasMinLength=e,exports.isArray=p,exports.isBoolean=u,exports.isDate=f,exports.isInRange=n,exports.isInteger=r,exports.isMultipleOf=s,exports.isNegative=o,exports.isNonNegative=a,exports.isNullOrUndefined=d,exports.isNumber=l,exports.isPositive=i,exports.isString=c;
2
- //# sourceMappingURL=validators.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validators.cjs","names":["hasMinLength","value","min","hasMaxLength","max","isInRange","isInteger","isPositive","isNonNegative","isNegative","isMultipleOf","step","isString","isNumber","isBoolean","isNullOrUndefined","isDate","isArray"],"sources":["../src/validators.ts"],"sourcesContent":["/**\n * Standalone validator functions: zero-dep, tree-shakeable helpers that return\n * a simple `boolean` (or a typed predicate) without constructing a Schema.\n * Useful in non-schema contexts such as conditional rendering, guards, etc.\n */\n\n/* -------------------- Generic range validators -------------------- */\n\nexport const hasMinLength = (value: string | unknown[], min: number): boolean => value.length >= min;\nexport const hasMaxLength = (value: string | unknown[], max: number): boolean => value.length <= max;\nexport const isInRange = (value: number, min: number, max: number): boolean => value >= min && value <= max;\nexport const isInteger = (value: number): boolean => Number.isInteger(value);\nexport const isPositive = (value: number): boolean => value > 0;\nexport const isNonNegative = (value: number): boolean => value >= 0;\nexport const isNegative = (value: number): boolean => value < 0;\nexport const isMultipleOf = (value: number, step: number): boolean => value % step === 0;\n\n/* -------------------- Type guards -------------------- */\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\nexport const isNumber = (value: unknown): value is number => typeof value === 'number' && !Number.isNaN(value);\nexport const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';\nexport const isNullOrUndefined = (value: unknown): value is null | undefined => value == null;\nexport const isDate = (value: unknown): value is Date => value instanceof Date && !Number.isNaN(value.getTime());\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n"],"mappings":"AAQA,IAAaA,GAAgB,EAA2B,IAAyBC,EAAM,QAAUC,EACpFC,GAAgB,EAA2B,IAAyBF,EAAM,QAAUG,EACpFC,GAAa,EAAe,EAAa,IAAyBJ,GAASC,GAAOD,GAASG,EAC3FE,EAAa,GAA2B,OAAO,UAAUL,CAAK,EAC9DM,EAAc,GAA2BN,EAAQ,EACjDO,EAAiB,GAA2BP,GAAS,EACrDQ,EAAc,GAA2BR,EAAQ,EACjDS,GAAgB,EAAe,IAA0BT,EAAQU,IAAS,EAI1EC,EAAY,GAAoC,OAAOX,GAAU,SACjEY,EAAY,GAAoC,OAAOZ,GAAU,UAAY,CAAC,OAAO,MAAMA,CAAK,EAChGa,EAAa,GAAqC,OAAOb,GAAU,UACnEc,EAAqB,GAA8Cd,GAAS,KAC5Ee,EAAU,GAAkCf,aAAiB,MAAQ,CAAC,OAAO,MAAMA,EAAM,QAAQ,CAAC,EAClGgB,EAAW,GAAuC,MAAM,QAAQhB,CAAK,E"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Standalone validator functions: zero-dep, tree-shakeable helpers that return
3
- * a simple `boolean` (or a typed predicate) without constructing a Schema.
4
- * Useful in non-schema contexts such as conditional rendering, guards, etc.
5
- */
6
- export declare const hasMinLength: (value: string | unknown[], min: number) => boolean;
7
- export declare const hasMaxLength: (value: string | unknown[], max: number) => boolean;
8
- export declare const isInRange: (value: number, min: number, max: number) => boolean;
9
- export declare const isInteger: (value: number) => boolean;
10
- export declare const isPositive: (value: number) => boolean;
11
- export declare const isNonNegative: (value: number) => boolean;
12
- export declare const isNegative: (value: number) => boolean;
13
- export declare const isMultipleOf: (value: number, step: number) => boolean;
14
- export declare const isString: (value: unknown) => value is string;
15
- export declare const isNumber: (value: unknown) => value is number;
16
- export declare const isBoolean: (value: unknown) => value is boolean;
17
- export declare const isNullOrUndefined: (value: unknown) => value is null | undefined;
18
- export declare const isDate: (value: unknown) => value is Date;
19
- export declare const isArray: (value: unknown) => value is unknown[];
20
- //# sourceMappingURL=validators.d.ts.map
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t=(e,t)=>e.length<=t,n=(e,t,n)=>e>=t&&e<=n,r=e=>Number.isInteger(e),i=e=>e>0,a=e=>e>=0,o=e=>e<0,s=(e,t)=>e%t===0,c=e=>typeof e==`string`,l=e=>typeof e==`number`&&!Number.isNaN(e),u=e=>typeof e==`boolean`,d=e=>e==null,f=e=>e instanceof Date&&!Number.isNaN(e.getTime()),p=e=>Array.isArray(e);export{t as hasMaxLength,e as hasMinLength,p as isArray,u as isBoolean,f as isDate,n as isInRange,r as isInteger,s as isMultipleOf,o as isNegative,a as isNonNegative,d as isNullOrUndefined,l as isNumber,i as isPositive,c as isString};
2
- //# sourceMappingURL=validators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validators.js","names":["hasMinLength","value","min","hasMaxLength","max","isInRange","isInteger","isPositive","isNonNegative","isNegative","isMultipleOf","step","isString","isNumber","isBoolean","isNullOrUndefined","isDate","isArray"],"sources":["../src/validators.ts"],"sourcesContent":["/**\n * Standalone validator functions: zero-dep, tree-shakeable helpers that return\n * a simple `boolean` (or a typed predicate) without constructing a Schema.\n * Useful in non-schema contexts such as conditional rendering, guards, etc.\n */\n\n/* -------------------- Generic range validators -------------------- */\n\nexport const hasMinLength = (value: string | unknown[], min: number): boolean => value.length >= min;\nexport const hasMaxLength = (value: string | unknown[], max: number): boolean => value.length <= max;\nexport const isInRange = (value: number, min: number, max: number): boolean => value >= min && value <= max;\nexport const isInteger = (value: number): boolean => Number.isInteger(value);\nexport const isPositive = (value: number): boolean => value > 0;\nexport const isNonNegative = (value: number): boolean => value >= 0;\nexport const isNegative = (value: number): boolean => value < 0;\nexport const isMultipleOf = (value: number, step: number): boolean => value % step === 0;\n\n/* -------------------- Type guards -------------------- */\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\nexport const isNumber = (value: unknown): value is number => typeof value === 'number' && !Number.isNaN(value);\nexport const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';\nexport const isNullOrUndefined = (value: unknown): value is null | undefined => value == null;\nexport const isDate = (value: unknown): value is Date => value instanceof Date && !Number.isNaN(value.getTime());\nexport const isArray = (value: unknown): value is unknown[] => Array.isArray(value);\n"],"mappings":"AAQA,IAAaA,GAAgB,EAA2B,IAAyBC,EAAM,QAAUC,EACpFC,GAAgB,EAA2B,IAAyBF,EAAM,QAAUG,EACpFC,GAAa,EAAe,EAAa,IAAyBJ,GAASC,GAAOD,GAASG,EAC3FE,EAAa,GAA2B,OAAO,UAAUL,CAAK,EAC9DM,EAAc,GAA2BN,EAAQ,EACjDO,EAAiB,GAA2BP,GAAS,EACrDQ,EAAc,GAA2BR,EAAQ,EACjDS,GAAgB,EAAe,IAA0BT,EAAQU,IAAS,EAI1EC,EAAY,GAAoC,OAAOX,GAAU,SACjEY,EAAY,GAAoC,OAAOZ,GAAU,UAAY,CAAC,OAAO,MAAMA,CAAK,EAChGa,EAAa,GAAqC,OAAOb,GAAU,UACnEc,EAAqB,GAA8Cd,GAAS,KAC5Ee,EAAU,GAAkCf,aAAiB,MAAQ,CAAC,OAAO,MAAMA,EAAM,QAAQ,CAAC,EAClGgB,EAAW,GAAuC,MAAM,QAAQhB,CAAK,E"}