@atproto/lex-schema 0.0.11 → 0.0.13

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 (261) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/core/$type.d.ts +149 -0
  3. package/dist/core/$type.d.ts.map +1 -1
  4. package/dist/core/$type.js +44 -0
  5. package/dist/core/$type.js.map +1 -1
  6. package/dist/core/record-key.d.ts +44 -0
  7. package/dist/core/record-key.d.ts.map +1 -1
  8. package/dist/core/record-key.js +30 -0
  9. package/dist/core/record-key.js.map +1 -1
  10. package/dist/core/result.d.ts +85 -4
  11. package/dist/core/result.d.ts.map +1 -1
  12. package/dist/core/result.js +60 -4
  13. package/dist/core/result.js.map +1 -1
  14. package/dist/core/schema.d.ts +232 -5
  15. package/dist/core/schema.d.ts.map +1 -1
  16. package/dist/core/schema.js +197 -4
  17. package/dist/core/schema.js.map +1 -1
  18. package/dist/core/string-format.d.ts +244 -11
  19. package/dist/core/string-format.d.ts.map +1 -1
  20. package/dist/core/string-format.js +150 -0
  21. package/dist/core/string-format.js.map +1 -1
  22. package/dist/core/types.d.ts +90 -3
  23. package/dist/core/types.d.ts.map +1 -1
  24. package/dist/core/types.js.map +1 -1
  25. package/dist/core/validation-error.d.ts +60 -0
  26. package/dist/core/validation-error.d.ts.map +1 -1
  27. package/dist/core/validation-error.js +60 -0
  28. package/dist/core/validation-error.js.map +1 -1
  29. package/dist/core/validation-issue.d.ts +61 -0
  30. package/dist/core/validation-issue.d.ts.map +1 -1
  31. package/dist/core/validation-issue.js +54 -1
  32. package/dist/core/validation-issue.js.map +1 -1
  33. package/dist/core/validator.d.ts +356 -11
  34. package/dist/core/validator.d.ts.map +1 -1
  35. package/dist/core/validator.js +203 -4
  36. package/dist/core/validator.js.map +1 -1
  37. package/dist/helpers.d.ts +12 -28
  38. package/dist/helpers.d.ts.map +1 -1
  39. package/dist/helpers.js.map +1 -1
  40. package/dist/schema/array.d.ts +46 -0
  41. package/dist/schema/array.d.ts.map +1 -1
  42. package/dist/schema/array.js +16 -1
  43. package/dist/schema/array.js.map +1 -1
  44. package/dist/schema/blob.d.ts +50 -2
  45. package/dist/schema/blob.d.ts.map +1 -1
  46. package/dist/schema/blob.js +44 -2
  47. package/dist/schema/blob.js.map +1 -1
  48. package/dist/schema/boolean.d.ts +29 -0
  49. package/dist/schema/boolean.d.ts.map +1 -1
  50. package/dist/schema/boolean.js +30 -1
  51. package/dist/schema/boolean.js.map +1 -1
  52. package/dist/schema/bytes.d.ts +39 -0
  53. package/dist/schema/bytes.d.ts.map +1 -1
  54. package/dist/schema/bytes.js +34 -1
  55. package/dist/schema/bytes.js.map +1 -1
  56. package/dist/schema/cid.d.ts +39 -0
  57. package/dist/schema/cid.d.ts.map +1 -1
  58. package/dist/schema/cid.js +35 -1
  59. package/dist/schema/cid.js.map +1 -1
  60. package/dist/schema/custom.d.ts +67 -1
  61. package/dist/schema/custom.d.ts.map +1 -1
  62. package/dist/schema/custom.js +55 -0
  63. package/dist/schema/custom.js.map +1 -1
  64. package/dist/schema/dict.d.ts +45 -0
  65. package/dist/schema/dict.d.ts.map +1 -1
  66. package/dist/schema/dict.js +46 -1
  67. package/dist/schema/dict.js.map +1 -1
  68. package/dist/schema/discriminated-union.d.ts +59 -0
  69. package/dist/schema/discriminated-union.d.ts.map +1 -1
  70. package/dist/schema/discriminated-union.js +47 -1
  71. package/dist/schema/discriminated-union.js.map +1 -1
  72. package/dist/schema/enum.d.ts +49 -0
  73. package/dist/schema/enum.d.ts.map +1 -1
  74. package/dist/schema/enum.js +49 -0
  75. package/dist/schema/enum.js.map +1 -1
  76. package/dist/schema/integer.d.ts +43 -0
  77. package/dist/schema/integer.d.ts.map +1 -1
  78. package/dist/schema/integer.js +38 -1
  79. package/dist/schema/integer.js.map +1 -1
  80. package/dist/schema/intersection.d.ts +55 -0
  81. package/dist/schema/intersection.d.ts.map +1 -1
  82. package/dist/schema/intersection.js +50 -0
  83. package/dist/schema/intersection.js.map +1 -1
  84. package/dist/schema/lex-map.d.ts +37 -0
  85. package/dist/schema/lex-map.d.ts.map +1 -0
  86. package/dist/schema/lex-map.js +60 -0
  87. package/dist/schema/lex-map.js.map +1 -0
  88. package/dist/schema/lex-value.d.ts +35 -0
  89. package/dist/schema/lex-value.d.ts.map +1 -0
  90. package/dist/schema/lex-value.js +87 -0
  91. package/dist/schema/lex-value.js.map +1 -0
  92. package/dist/schema/literal.d.ts +45 -0
  93. package/dist/schema/literal.d.ts.map +1 -1
  94. package/dist/schema/literal.js +45 -0
  95. package/dist/schema/literal.js.map +1 -1
  96. package/dist/schema/never.d.ts +43 -0
  97. package/dist/schema/never.d.ts.map +1 -1
  98. package/dist/schema/never.js +44 -1
  99. package/dist/schema/never.js.map +1 -1
  100. package/dist/schema/null.d.ts +30 -0
  101. package/dist/schema/null.d.ts.map +1 -1
  102. package/dist/schema/null.js +31 -1
  103. package/dist/schema/null.js.map +1 -1
  104. package/dist/schema/nullable.d.ts +42 -0
  105. package/dist/schema/nullable.d.ts.map +1 -1
  106. package/dist/schema/nullable.js +42 -0
  107. package/dist/schema/nullable.js.map +1 -1
  108. package/dist/schema/object.d.ts +57 -0
  109. package/dist/schema/object.d.ts.map +1 -1
  110. package/dist/schema/object.js +53 -1
  111. package/dist/schema/object.js.map +1 -1
  112. package/dist/schema/optional.d.ts +43 -0
  113. package/dist/schema/optional.d.ts.map +1 -1
  114. package/dist/schema/optional.js +43 -0
  115. package/dist/schema/optional.js.map +1 -1
  116. package/dist/schema/params.d.ts +96 -12
  117. package/dist/schema/params.d.ts.map +1 -1
  118. package/dist/schema/params.js +155 -21
  119. package/dist/schema/params.js.map +1 -1
  120. package/dist/schema/payload.d.ts +111 -15
  121. package/dist/schema/payload.d.ts.map +1 -1
  122. package/dist/schema/payload.js +73 -3
  123. package/dist/schema/payload.js.map +1 -1
  124. package/dist/schema/permission-set.d.ts +58 -0
  125. package/dist/schema/permission-set.d.ts.map +1 -1
  126. package/dist/schema/permission-set.js +50 -0
  127. package/dist/schema/permission-set.js.map +1 -1
  128. package/dist/schema/permission.d.ts +42 -0
  129. package/dist/schema/permission.d.ts.map +1 -1
  130. package/dist/schema/permission.js +39 -0
  131. package/dist/schema/permission.js.map +1 -1
  132. package/dist/schema/procedure.d.ts +64 -0
  133. package/dist/schema/procedure.d.ts.map +1 -1
  134. package/dist/schema/procedure.js +64 -0
  135. package/dist/schema/procedure.js.map +1 -1
  136. package/dist/schema/query.d.ts +55 -0
  137. package/dist/schema/query.d.ts.map +1 -1
  138. package/dist/schema/query.js +55 -0
  139. package/dist/schema/query.js.map +1 -1
  140. package/dist/schema/record.d.ts +76 -25
  141. package/dist/schema/record.d.ts.map +1 -1
  142. package/dist/schema/record.js +21 -0
  143. package/dist/schema/record.js.map +1 -1
  144. package/dist/schema/ref.d.ts +51 -0
  145. package/dist/schema/ref.d.ts.map +1 -1
  146. package/dist/schema/ref.js +18 -0
  147. package/dist/schema/ref.js.map +1 -1
  148. package/dist/schema/refine.d.ts +58 -9
  149. package/dist/schema/refine.d.ts.map +1 -1
  150. package/dist/schema/refine.js.map +1 -1
  151. package/dist/schema/regexp.d.ts +45 -0
  152. package/dist/schema/regexp.d.ts.map +1 -1
  153. package/dist/schema/regexp.js +46 -1
  154. package/dist/schema/regexp.js.map +1 -1
  155. package/dist/schema/string.d.ts +72 -6
  156. package/dist/schema/string.d.ts.map +1 -1
  157. package/dist/schema/string.js +56 -8
  158. package/dist/schema/string.js.map +1 -1
  159. package/dist/schema/subscription.d.ts +72 -2
  160. package/dist/schema/subscription.d.ts.map +1 -1
  161. package/dist/schema/subscription.js +59 -0
  162. package/dist/schema/subscription.js.map +1 -1
  163. package/dist/schema/token.d.ts +48 -0
  164. package/dist/schema/token.d.ts.map +1 -1
  165. package/dist/schema/token.js +49 -1
  166. package/dist/schema/token.js.map +1 -1
  167. package/dist/schema/typed-object.d.ts +73 -23
  168. package/dist/schema/typed-object.d.ts.map +1 -1
  169. package/dist/schema/typed-object.js +20 -1
  170. package/dist/schema/typed-object.js.map +1 -1
  171. package/dist/schema/typed-ref.d.ts +54 -0
  172. package/dist/schema/typed-ref.d.ts.map +1 -1
  173. package/dist/schema/typed-ref.js +16 -0
  174. package/dist/schema/typed-ref.js.map +1 -1
  175. package/dist/schema/typed-union.d.ts +51 -1
  176. package/dist/schema/typed-union.d.ts.map +1 -1
  177. package/dist/schema/typed-union.js +52 -2
  178. package/dist/schema/typed-union.js.map +1 -1
  179. package/dist/schema/union.d.ts +46 -0
  180. package/dist/schema/union.d.ts.map +1 -1
  181. package/dist/schema/union.js +41 -0
  182. package/dist/schema/union.js.map +1 -1
  183. package/dist/schema/unknown.d.ts +34 -0
  184. package/dist/schema/unknown.d.ts.map +1 -1
  185. package/dist/schema/unknown.js +34 -0
  186. package/dist/schema/unknown.js.map +1 -1
  187. package/dist/schema/with-default.d.ts +45 -0
  188. package/dist/schema/with-default.d.ts.map +1 -1
  189. package/dist/schema/with-default.js +45 -0
  190. package/dist/schema/with-default.js.map +1 -1
  191. package/dist/schema.d.ts +2 -1
  192. package/dist/schema.d.ts.map +1 -1
  193. package/dist/schema.js +2 -1
  194. package/dist/schema.js.map +1 -1
  195. package/dist/util/if-any.d.ts +2 -0
  196. package/dist/util/if-any.d.ts.map +1 -0
  197. package/dist/util/if-any.js +3 -0
  198. package/dist/util/if-any.js.map +1 -0
  199. package/package.json +3 -3
  200. package/src/core/$type.ts +150 -18
  201. package/src/core/record-key.ts +44 -0
  202. package/src/core/result.ts +86 -4
  203. package/src/core/schema.ts +244 -9
  204. package/src/core/string-format.ts +259 -13
  205. package/src/core/types.ts +91 -3
  206. package/src/core/validation-error.ts +60 -0
  207. package/src/core/validation-issue.ts +68 -2
  208. package/src/core/validator.ts +373 -12
  209. package/src/helpers.test.ts +110 -29
  210. package/src/helpers.ts +54 -25
  211. package/src/schema/array.test.ts +94 -79
  212. package/src/schema/array.ts +48 -1
  213. package/src/schema/blob.ts +50 -1
  214. package/src/schema/boolean.ts +31 -1
  215. package/src/schema/bytes.ts +41 -1
  216. package/src/schema/cid.ts +41 -1
  217. package/src/schema/custom.ts +68 -1
  218. package/src/schema/dict.ts +47 -1
  219. package/src/schema/discriminated-union.ts +61 -1
  220. package/src/schema/enum.ts +50 -0
  221. package/src/schema/integer.ts +45 -1
  222. package/src/schema/intersection.ts +56 -0
  223. package/src/schema/{unknown-object.test.ts → lex-map.test.ts} +9 -9
  224. package/src/schema/lex-map.ts +63 -0
  225. package/src/schema/lex-value.test.ts +81 -0
  226. package/src/schema/lex-value.ts +86 -0
  227. package/src/schema/literal.ts +46 -0
  228. package/src/schema/never.ts +45 -1
  229. package/src/schema/null.ts +32 -1
  230. package/src/schema/nullable.ts +43 -0
  231. package/src/schema/object.ts +59 -1
  232. package/src/schema/optional.ts +44 -0
  233. package/src/schema/params.test.ts +133 -38
  234. package/src/schema/params.ts +237 -37
  235. package/src/schema/payload.test.ts +3 -3
  236. package/src/schema/payload.ts +145 -42
  237. package/src/schema/permission-set.ts +58 -0
  238. package/src/schema/permission.ts +42 -0
  239. package/src/schema/procedure.ts +64 -0
  240. package/src/schema/query.ts +55 -0
  241. package/src/schema/record.ts +82 -16
  242. package/src/schema/ref.ts +52 -0
  243. package/src/schema/refine.ts +58 -9
  244. package/src/schema/regexp.ts +47 -1
  245. package/src/schema/string.test.ts +99 -2
  246. package/src/schema/string.ts +108 -15
  247. package/src/schema/subscription.ts +72 -2
  248. package/src/schema/token.ts +50 -1
  249. package/src/schema/typed-object.ts +81 -16
  250. package/src/schema/typed-ref.ts +55 -0
  251. package/src/schema/typed-union.ts +58 -3
  252. package/src/schema/union.ts +47 -0
  253. package/src/schema/unknown.ts +35 -0
  254. package/src/schema/with-default.ts +46 -0
  255. package/src/schema.ts +2 -1
  256. package/src/util/if-any.ts +3 -0
  257. package/dist/schema/unknown-object.d.ts +0 -8
  258. package/dist/schema/unknown-object.d.ts.map +0 -1
  259. package/dist/schema/unknown-object.js +0 -19
  260. package/dist/schema/unknown-object.js.map +0 -1
  261. package/src/schema/unknown-object.ts +0 -19
@@ -1 +1 @@
1
- {"version":3,"file":"typed-ref.js","sourceRoot":"","sources":["../../src/schema/typed-ref.ts"],"names":[],"mappings":";;;AAkEA,4BAIC;AAtED,wCAOmB;AAYnB,MAAa,cAEX,SAAQ,gBAGT;IACC,OAAO,CAA4B;IAEnC,YAAY,MAAkC;QAC5C,uEAAuE;QACvE,sEAAsE;QAEtE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAClD,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,MAAM,CAAA;QAElC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,GAAG,CAAC,yBAAyB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QAC3E,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAnCD,wCAmCC;AAYD,SAAgB,QAAQ,CACtB,GAA+B;IAE/B,OAAO,IAAI,cAAc,CAAa,GAAG,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import {\n $Typed,\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n Validator,\n} from '../core.js'\n\nexport interface TypedObjectValidator<\n TInput extends { $type?: string } = { $type?: string },\n TOutput extends TInput = TInput,\n> extends Validator<TInput, TOutput> {\n $type: NonNullable<TOutput['$type']>\n}\n\nexport type TypedRefGetter<out TValidator extends TypedObjectValidator> =\n () => TValidator\n\nexport class TypedRefSchema<\n const TValidator extends TypedObjectValidator = TypedObjectValidator,\n> extends Schema<\n $Typed<InferInput<TValidator>>,\n $Typed<InferOutput<TValidator>>\n> {\n #getter: TypedRefGetter<TValidator>\n\n constructor(getter: TypedRefGetter<TValidator>) {\n // @NOTE In order to avoid circular dependency issues, we don't resolve\n // the schema here. Instead, we resolve it lazily when first accessed.\n\n super()\n\n this.#getter = getter\n }\n\n get validator(): TValidator {\n return this.#getter.call(null)\n }\n\n get $type(): TValidator['$type'] {\n return this.validator.$type\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n const result = ctx.validate(input, this.validator)\n if (!result.success) return result\n\n if (result.value.$type !== this.$type) {\n return ctx.issueInvalidPropertyValue(result.value, '$type', [this.$type])\n }\n\n return result\n }\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedRef<const TValidator extends TypedObjectValidator>(\n get: TypedRefGetter<TValidator>,\n): TypedRefSchema<TValidator>\nexport function typedRef<\n TInput extends { $type?: string },\n TOutput extends TInput = TInput,\n>(\n get: TypedRefGetter<TypedObjectValidator<TInput, TOutput>>,\n): TypedRefSchema<TypedObjectValidator<TInput, TOutput>>\nexport function typedRef<const TValidator extends TypedObjectValidator>(\n get: TypedRefGetter<TValidator>,\n): TypedRefSchema<TValidator> {\n return new TypedRefSchema<TValidator>(get)\n}\n"]}
1
+ {"version":3,"file":"typed-ref.js","sourceRoot":"","sources":["../../src/schema/typed-ref.ts"],"names":[],"mappings":";;;AAyHA,4BAIC;AA7HD,wCAOmB;AAyBnB;;;;;;;;;;;;;;GAcG;AACH,MAAa,cAEX,SAAQ,gBAGT;IACU,IAAI,GAAG,UAAmB,CAAA;IAEnC,OAAO,CAA4B;IAEnC,YAAY,MAAkC;QAC5C,uEAAuE;QACvE,sEAAsE;QAEtE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAClD,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,MAAM,CAAA;QAElC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,GAAG,CAAC,yBAAyB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QAC3E,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AArCD,wCAqCC;AAqCD,SAAgB,QAAQ,CACtB,GAA+B;IAE/B,OAAO,IAAI,cAAc,CAAa,GAAG,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import {\n $Typed,\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n Validator,\n} from '../core.js'\n\n/**\n * Interface for validators that have a $type property.\n *\n * Used by typed objects and records to identify their type in unions.\n *\n * @template TInput - The input type (with optional $type)\n * @template TOutput - The output type (with non-optional $type)\n */\nexport interface TypedObjectValidator<\n TInput extends { $type?: string } = { $type?: string },\n TOutput extends TInput = TInput,\n> extends Validator<TInput, TOutput> {\n $type: NonNullable<TOutput['$type']>\n}\n\n/**\n * Function type that returns a typed object validator, used for lazy resolution.\n *\n * @template TValidator - The typed object validator type\n */\nexport type TypedRefGetter<out TValidator extends TypedObjectValidator> =\n () => TValidator\n\n/**\n * Schema for referencing typed objects with lazy resolution.\n *\n * Used in typed unions to reference typed object schemas. Requires the\n * `$type` field to be present and match the referenced schema's type.\n * The referenced schema is resolved lazily to support circular references.\n *\n * @template TValidator - The referenced typed object validator type\n *\n * @example\n * ```ts\n * const ref = new TypedRefSchema(() => imageViewSchema)\n * // ref.$type === 'app.bsky.embed.images#view'\n * ```\n */\nexport class TypedRefSchema<\n const TValidator extends TypedObjectValidator = TypedObjectValidator,\n> extends Schema<\n $Typed<InferInput<TValidator>>,\n $Typed<InferOutput<TValidator>>\n> {\n readonly type = 'typedRef' as const\n\n #getter: TypedRefGetter<TValidator>\n\n constructor(getter: TypedRefGetter<TValidator>) {\n // @NOTE In order to avoid circular dependency issues, we don't resolve\n // the schema here. Instead, we resolve it lazily when first accessed.\n\n super()\n\n this.#getter = getter\n }\n\n get validator(): TValidator {\n return this.#getter.call(null)\n }\n\n get $type(): TValidator['$type'] {\n return this.validator.$type\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n const result = ctx.validate(input, this.validator)\n if (!result.success) return result\n\n if (result.value.$type !== this.$type) {\n return ctx.issueInvalidPropertyValue(result.value, '$type', [this.$type])\n }\n\n return result\n }\n}\n\n/**\n * Creates a reference to a typed object schema for use in typed unions.\n *\n * Unlike regular `ref()`, this requires the referenced schema to have a\n * `$type` property, and validates that the input's `$type` matches.\n *\n * @param get - Function that returns the typed object validator\n * @returns A new {@link TypedRefSchema} instance\n *\n * @example\n * ```ts\n * // Reference to image embed view\n * const imageRef = l.typedRef(() => imageViewSchema)\n *\n * // Use in a typed union\n * const embedUnion = l.typedUnion([\n * l.typedRef(() => imageViewSchema),\n * l.typedRef(() => videoViewSchema),\n * l.typedRef(() => externalViewSchema),\n * ], true) // closed union\n *\n * // The $type is accessible on the ref\n * console.log(imageRef.$type) // 'app.bsky.embed.images#view'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedRef<const TValidator extends TypedObjectValidator>(\n get: TypedRefGetter<TValidator>,\n): TypedRefSchema<TValidator>\nexport function typedRef<\n TInput extends { $type?: string },\n TOutput extends TInput = TInput,\n>(\n get: TypedRefGetter<TypedObjectValidator<TInput, TOutput>>,\n): TypedRefSchema<TypedObjectValidator<TInput, TOutput>>\nexport function typedRef<const TValidator extends TypedObjectValidator>(\n get: TypedRefGetter<TValidator>,\n): TypedRefSchema<TValidator> {\n return new TypedRefSchema<TValidator>(get)\n}\n"]}
@@ -1,12 +1,62 @@
1
1
  import { InferInput, InferOutput, Schema, Unknown$TypedObject, ValidationContext } from '../core.js';
2
+ import { TypedObjectSchema } from './typed-object.js';
2
3
  import { TypedRefSchema } from './typed-ref.js';
3
- export declare class TypedUnionSchema<const TValidators extends readonly TypedRefSchema[] = [], const TClosed extends boolean = boolean> extends Schema<TClosed extends true ? InferInput<TValidators[number]> : InferInput<TValidators[number]> | Unknown$TypedObject, TClosed extends true ? InferOutput<TValidators[number]> : InferOutput<TValidators[number]> | Unknown$TypedObject> {
4
+ /**
5
+ * Schema for Lexicon typed unions (unions discriminated by $type).
6
+ *
7
+ * Typed unions are collections of typed objects identified by their `$type`
8
+ * field. Can be "open" (accept unknown types) or "closed" (only accept
9
+ * known types).
10
+ *
11
+ * @template TValidators - Tuple of {@link TypedRefSchema} or {@link TypedObjectSchema} instances
12
+ * @template TClosed - Whether the union is closed (rejects unknown $types)
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const embedUnion = new TypedUnionSchema([
17
+ * l.typedRef(() => imageSchema),
18
+ * l.typedRef(() => videoSchema),
19
+ * ], true) // closed - only accepts images and videos
20
+ * ```
21
+ */
22
+ export declare class TypedUnionSchema<const TValidators extends readonly (TypedRefSchema | TypedObjectSchema)[] = [], const TClosed extends boolean = boolean> extends Schema<TClosed extends true ? InferInput<TValidators[number]> : InferInput<TValidators[number]> | Unknown$TypedObject, TClosed extends true ? InferOutput<TValidators[number]> : InferOutput<TValidators[number]> | Unknown$TypedObject> {
4
23
  protected readonly validators: TValidators;
5
24
  readonly closed: TClosed;
25
+ readonly type: "typedUnion";
6
26
  constructor(validators: TValidators, closed: TClosed);
7
27
  get validatorsMap(): Map<unknown, TValidators[number]>;
8
28
  get $types(): unknown[];
9
29
  validateInContext(input: unknown, ctx: ValidationContext): import("../core.js").ValidationFailure | import("../core.js").ValidationSuccess<Record<string, unknown>> | import("../core.js").ValidationSuccess<InferInput<TValidators[number]>>;
10
30
  }
31
+ /**
32
+ * Creates a typed union schema for Lexicon unions.
33
+ *
34
+ * Typed unions discriminate variants by their `$type` field. Can be open
35
+ * (accepts unknown types, useful for extensibility) or closed (strict).
36
+ *
37
+ * @param refs - Array of typed refs for the union variants
38
+ * @param closed - Whether to reject unknown $type values
39
+ * @returns A new {@link TypedUnionSchema} instance
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * // Closed union - only accepts known types
44
+ * const embedSchema = l.typedUnion([
45
+ * l.typedRef(() => imageViewSchema),
46
+ * l.typedRef(() => videoViewSchema),
47
+ * l.typedRef(() => externalViewSchema),
48
+ * ], true)
49
+ *
50
+ * // Open union - accepts unknown types for forward compatibility
51
+ * const feedItemSchema = l.typedUnion([
52
+ * l.typedRef(() => postSchema),
53
+ * l.typedRef(() => repostSchema),
54
+ * ], false) // unknown types pass through
55
+ *
56
+ * // Get all known $types
57
+ * console.log(embedSchema.$types)
58
+ * // ['app.bsky.embed.images#view', 'app.bsky.embed.video#view', ...]
59
+ * ```
60
+ */
11
61
  export declare function typedUnion<const R extends readonly TypedRefSchema[], const C extends boolean>(refs: R, closed: C): TypedUnionSchema<R, C>;
12
62
  //# sourceMappingURL=typed-union.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typed-union.d.ts","sourceRoot":"","sources":["../../src/schema/typed-union.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,qBAAa,gBAAgB,CAC3B,KAAK,CAAC,WAAW,SAAS,SAAS,cAAc,EAAE,GAAG,EAAE,EACxD,KAAK,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,CACvC,SAAQ,MAAM,CACd,OAAO,SAAS,IAAI,GAChB,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAC/B,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,EACzD,OAAO,SAAS,IAAI,GAChB,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAChC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAC3D;IAEG,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW;aAC1B,MAAM,EAAE,OAAO;gBADZ,UAAU,EAAE,WAAW,EAC1B,MAAM,EAAE,OAAO;IASjC,IAAI,aAAa,IAAI,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAKrD;IAED,IAAI,MAAM,cAET;IAED,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CAsBzD;AAGD,wBAAgB,UAAU,CACxB,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACzC,KAAK,CAAC,CAAC,SAAS,OAAO,EACvB,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,0BAEnB"}
1
+ {"version":3,"file":"typed-union.d.ts","sourceRoot":"","sources":["../../src/schema/typed-union.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,gBAAgB,CAC3B,KAAK,CAAC,WAAW,SAAS,SAAS,CAC/B,cAAc,GACd,iBAAiB,CACpB,EAAE,GAAG,EAAE,EACR,KAAK,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,CACvC,SAAQ,MAAM,CACd,OAAO,SAAS,IAAI,GAChB,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAC/B,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,EACzD,OAAO,SAAS,IAAI,GAChB,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAChC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAC3D;IAIG,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW;aAC1B,MAAM,EAAE,OAAO;IAJjC,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAS;gBAGhB,UAAU,EAAE,WAAW,EAC1B,MAAM,EAAE,OAAO;IAUjC,IAAI,aAAa,IAAI,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAKrD;IAED,IAAI,MAAM,cAET;IAED,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CAsBzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,wBAAgB,UAAU,CACxB,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACzC,KAAK,CAAC,CAAC,SAAS,OAAO,EACvB,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,0BAEnB"}
@@ -5,13 +5,33 @@ exports.typedUnion = typedUnion;
5
5
  const lex_data_1 = require("@atproto/lex-data");
6
6
  const core_js_1 = require("../core.js");
7
7
  const lazy_property_js_1 = require("../util/lazy-property.js");
8
+ /**
9
+ * Schema for Lexicon typed unions (unions discriminated by $type).
10
+ *
11
+ * Typed unions are collections of typed objects identified by their `$type`
12
+ * field. Can be "open" (accept unknown types) or "closed" (only accept
13
+ * known types).
14
+ *
15
+ * @template TValidators - Tuple of {@link TypedRefSchema} or {@link TypedObjectSchema} instances
16
+ * @template TClosed - Whether the union is closed (rejects unknown $types)
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const embedUnion = new TypedUnionSchema([
21
+ * l.typedRef(() => imageSchema),
22
+ * l.typedRef(() => videoSchema),
23
+ * ], true) // closed - only accepts images and videos
24
+ * ```
25
+ */
8
26
  class TypedUnionSchema extends core_js_1.Schema {
9
27
  validators;
10
28
  closed;
29
+ type = 'typedUnion';
11
30
  constructor(validators, closed) {
12
31
  // @NOTE In order to avoid circular dependency issues, we don't access the
13
32
  // refs's schema (or $type) here. Instead, we access them lazily when first
14
- // needed.
33
+ // needed. The biggest issue with this strategy is that we can't throw
34
+ // early if the refs contain multiple refs with the same $type.
15
35
  super();
16
36
  this.validators = validators;
17
37
  this.closed = closed;
@@ -27,7 +47,7 @@ class TypedUnionSchema extends core_js_1.Schema {
27
47
  }
28
48
  validateInContext(input, ctx) {
29
49
  if (!(0, lex_data_1.isPlainObject)(input) || !('$type' in input)) {
30
- return ctx.issueInvalidType(input, '$typed');
50
+ return ctx.issueUnexpectedType(input, '$typed');
31
51
  }
32
52
  const { $type } = input;
33
53
  const validator = this.validatorsMap.get($type);
@@ -44,6 +64,36 @@ class TypedUnionSchema extends core_js_1.Schema {
44
64
  }
45
65
  }
46
66
  exports.TypedUnionSchema = TypedUnionSchema;
67
+ /**
68
+ * Creates a typed union schema for Lexicon unions.
69
+ *
70
+ * Typed unions discriminate variants by their `$type` field. Can be open
71
+ * (accepts unknown types, useful for extensibility) or closed (strict).
72
+ *
73
+ * @param refs - Array of typed refs for the union variants
74
+ * @param closed - Whether to reject unknown $type values
75
+ * @returns A new {@link TypedUnionSchema} instance
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * // Closed union - only accepts known types
80
+ * const embedSchema = l.typedUnion([
81
+ * l.typedRef(() => imageViewSchema),
82
+ * l.typedRef(() => videoViewSchema),
83
+ * l.typedRef(() => externalViewSchema),
84
+ * ], true)
85
+ *
86
+ * // Open union - accepts unknown types for forward compatibility
87
+ * const feedItemSchema = l.typedUnion([
88
+ * l.typedRef(() => postSchema),
89
+ * l.typedRef(() => repostSchema),
90
+ * ], false) // unknown types pass through
91
+ *
92
+ * // Get all known $types
93
+ * console.log(embedSchema.$types)
94
+ * // ['app.bsky.embed.images#view', 'app.bsky.embed.video#view', ...]
95
+ * ```
96
+ */
47
97
  /*@__NO_SIDE_EFFECTS__*/
48
98
  function typedUnion(refs, closed) {
49
99
  return new TypedUnionSchema(refs, closed);
@@ -1 +1 @@
1
- {"version":3,"file":"typed-union.js","sourceRoot":"","sources":["../../src/schema/typed-union.ts"],"names":[],"mappings":";;;AAqEA,gCAKC;AA1ED,gDAAiD;AACjD,wCAMmB;AACnB,+DAAuD;AAGvD,MAAa,gBAGX,SAAQ,gBAOT;IAEsB;IACH;IAFlB,YACqB,UAAuB,EAC1B,MAAe;QAE/B,0EAA0E;QAC1E,2EAA2E;QAC3E,UAAU;QAEV,KAAK,EAAE,CAAA;QAPY,eAAU,GAAV,UAAU,CAAa;QAC1B,WAAM,GAAN,MAAM,CAAS;IAOjC,CAAC;IAED,IAAI,aAAa;QACf,MAAM,GAAG,GAAG,IAAI,GAAG,EAAgC,CAAA;QACnD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAE1D,OAAO,IAAA,+BAAY,EAAC,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,MAAM;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC9C,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;QAEvB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC/C,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACvC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,GAAG,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACnE,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,GAAG,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC/D,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAvDD,4CAuDC;AAED,wBAAwB;AACxB,SAAgB,UAAU,CAGxB,IAAO,EAAE,MAAS;IAClB,OAAO,IAAI,gBAAgB,CAAO,IAAI,EAAE,MAAM,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { isPlainObject } from '@atproto/lex-data'\nimport {\n InferInput,\n InferOutput,\n Schema,\n Unknown$TypedObject,\n ValidationContext,\n} from '../core.js'\nimport { lazyProperty } from '../util/lazy-property.js'\nimport { TypedRefSchema } from './typed-ref.js'\n\nexport class TypedUnionSchema<\n const TValidators extends readonly TypedRefSchema[] = [],\n const TClosed extends boolean = boolean,\n> extends Schema<\n TClosed extends true\n ? InferInput<TValidators[number]>\n : InferInput<TValidators[number]> | Unknown$TypedObject,\n TClosed extends true\n ? InferOutput<TValidators[number]>\n : InferOutput<TValidators[number]> | Unknown$TypedObject\n> {\n constructor(\n protected readonly validators: TValidators,\n public readonly closed: TClosed,\n ) {\n // @NOTE In order to avoid circular dependency issues, we don't access the\n // refs's schema (or $type) here. Instead, we access them lazily when first\n // needed.\n\n super()\n }\n\n get validatorsMap(): Map<unknown, TValidators[number]> {\n const map = new Map<unknown, TValidators[number]>()\n for (const ref of this.validators) map.set(ref.$type, ref)\n\n return lazyProperty(this, 'validatorsMap', map)\n }\n\n get $types() {\n return Array.from(this.validatorsMap.keys())\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (!isPlainObject(input) || !('$type' in input)) {\n return ctx.issueInvalidType(input, '$typed')\n }\n\n const { $type } = input\n\n const validator = this.validatorsMap.get($type)\n if (validator) {\n return ctx.validate(input, validator)\n }\n\n if (this.closed) {\n return ctx.issueInvalidPropertyValue(input, '$type', this.$types)\n }\n\n if (typeof $type !== 'string') {\n return ctx.issueInvalidPropertyType(input, '$type', 'string')\n }\n\n return ctx.success(input)\n }\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedUnion<\n const R extends readonly TypedRefSchema[],\n const C extends boolean,\n>(refs: R, closed: C) {\n return new TypedUnionSchema<R, C>(refs, closed)\n}\n"]}
1
+ {"version":3,"file":"typed-union.js","sourceRoot":"","sources":["../../src/schema/typed-union.ts"],"names":[],"mappings":";;;AA4HA,gCAKC;AAjID,gDAAiD;AACjD,wCAMmB;AACnB,+DAAuD;AAIvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,gBAMX,SAAQ,gBAOT;IAIsB;IACH;IAJT,IAAI,GAAG,YAAqB,CAAA;IAErC,YACqB,UAAuB,EAC1B,MAAe;QAE/B,0EAA0E;QAC1E,2EAA2E;QAC3E,sEAAsE;QACtE,+DAA+D;QAE/D,KAAK,EAAE,CAAA;QARY,eAAU,GAAV,UAAU,CAAa;QAC1B,WAAM,GAAN,MAAM,CAAS;IAQjC,CAAC;IAED,IAAI,aAAa;QACf,MAAM,GAAG,GAAG,IAAI,GAAG,EAAgC,CAAA;QACnD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAE1D,OAAO,IAAA,+BAAY,EAAC,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,MAAM;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,IAAI,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACjD,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;QAEvB,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC/C,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACvC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,GAAG,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACnE,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,GAAG,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC/D,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AA7DD,4CA6DC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAwB;AACxB,SAAgB,UAAU,CAGxB,IAAO,EAAE,MAAS;IAClB,OAAO,IAAI,gBAAgB,CAAO,IAAI,EAAE,MAAM,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { isPlainObject } from '@atproto/lex-data'\nimport {\n InferInput,\n InferOutput,\n Schema,\n Unknown$TypedObject,\n ValidationContext,\n} from '../core.js'\nimport { lazyProperty } from '../util/lazy-property.js'\nimport { TypedObjectSchema } from './typed-object.js'\nimport { TypedRefSchema } from './typed-ref.js'\n\n/**\n * Schema for Lexicon typed unions (unions discriminated by $type).\n *\n * Typed unions are collections of typed objects identified by their `$type`\n * field. Can be \"open\" (accept unknown types) or \"closed\" (only accept\n * known types).\n *\n * @template TValidators - Tuple of {@link TypedRefSchema} or {@link TypedObjectSchema} instances\n * @template TClosed - Whether the union is closed (rejects unknown $types)\n *\n * @example\n * ```ts\n * const embedUnion = new TypedUnionSchema([\n * l.typedRef(() => imageSchema),\n * l.typedRef(() => videoSchema),\n * ], true) // closed - only accepts images and videos\n * ```\n */\nexport class TypedUnionSchema<\n const TValidators extends readonly (\n | TypedRefSchema\n | TypedObjectSchema\n )[] = [],\n const TClosed extends boolean = boolean,\n> extends Schema<\n TClosed extends true\n ? InferInput<TValidators[number]>\n : InferInput<TValidators[number]> | Unknown$TypedObject,\n TClosed extends true\n ? InferOutput<TValidators[number]>\n : InferOutput<TValidators[number]> | Unknown$TypedObject\n> {\n readonly type = 'typedUnion' as const\n\n constructor(\n protected readonly validators: TValidators,\n public readonly closed: TClosed,\n ) {\n // @NOTE In order to avoid circular dependency issues, we don't access the\n // refs's schema (or $type) here. Instead, we access them lazily when first\n // needed. The biggest issue with this strategy is that we can't throw\n // early if the refs contain multiple refs with the same $type.\n\n super()\n }\n\n get validatorsMap(): Map<unknown, TValidators[number]> {\n const map = new Map<unknown, TValidators[number]>()\n for (const ref of this.validators) map.set(ref.$type, ref)\n\n return lazyProperty(this, 'validatorsMap', map)\n }\n\n get $types() {\n return Array.from(this.validatorsMap.keys())\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n if (!isPlainObject(input) || !('$type' in input)) {\n return ctx.issueUnexpectedType(input, '$typed')\n }\n\n const { $type } = input\n\n const validator = this.validatorsMap.get($type)\n if (validator) {\n return ctx.validate(input, validator)\n }\n\n if (this.closed) {\n return ctx.issueInvalidPropertyValue(input, '$type', this.$types)\n }\n\n if (typeof $type !== 'string') {\n return ctx.issueInvalidPropertyType(input, '$type', 'string')\n }\n\n return ctx.success(input)\n }\n}\n\n/**\n * Creates a typed union schema for Lexicon unions.\n *\n * Typed unions discriminate variants by their `$type` field. Can be open\n * (accepts unknown types, useful for extensibility) or closed (strict).\n *\n * @param refs - Array of typed refs for the union variants\n * @param closed - Whether to reject unknown $type values\n * @returns A new {@link TypedUnionSchema} instance\n *\n * @example\n * ```ts\n * // Closed union - only accepts known types\n * const embedSchema = l.typedUnion([\n * l.typedRef(() => imageViewSchema),\n * l.typedRef(() => videoViewSchema),\n * l.typedRef(() => externalViewSchema),\n * ], true)\n *\n * // Open union - accepts unknown types for forward compatibility\n * const feedItemSchema = l.typedUnion([\n * l.typedRef(() => postSchema),\n * l.typedRef(() => repostSchema),\n * ], false) // unknown types pass through\n *\n * // Get all known $types\n * console.log(embedSchema.$types)\n * // ['app.bsky.embed.images#view', 'app.bsky.embed.video#view', ...]\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedUnion<\n const R extends readonly TypedRefSchema[],\n const C extends boolean,\n>(refs: R, closed: C) {\n return new TypedUnionSchema<R, C>(refs, closed)\n}\n"]}
@@ -1,9 +1,55 @@
1
1
  import { InferInput, InferOutput, Schema, ValidationContext, ValidationFailure, Validator } from '../core.js';
2
+ /**
3
+ * Type representing a non-empty tuple of validators for union schemas.
4
+ *
5
+ * Requires at least one validator in the tuple.
6
+ */
2
7
  export type UnionSchemaValidators = readonly [Validator, ...Validator[]];
8
+ /**
9
+ * Schema for validating values that match one of several possible schemas.
10
+ *
11
+ * Tries each validator in order until one succeeds. If all validators fail,
12
+ * returns a combined error from all attempts.
13
+ *
14
+ * @template TValidators - Tuple type of the validators in the union
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const schema = new UnionSchema([l.string(), l.integer()])
19
+ * schema.validate('hello') // success
20
+ * schema.validate(42) // success
21
+ * schema.validate(true) // fails
22
+ * ```
23
+ */
3
24
  export declare class UnionSchema<const TValidators extends UnionSchemaValidators = any> extends Schema<InferInput<TValidators[number]>, InferOutput<TValidators[number]>> {
4
25
  protected readonly validators: TValidators;
26
+ readonly type: "union";
5
27
  constructor(validators: TValidators);
6
28
  validateInContext(input: unknown, ctx: ValidationContext): ValidationFailure | import("../core.js").ValidationSuccess<unknown>;
7
29
  }
30
+ /**
31
+ * Creates a union schema that accepts values matching any of the provided schemas.
32
+ *
33
+ * Validators are tried in order. Use `discriminatedUnion()` for better
34
+ * performance when discriminating on a known property.
35
+ *
36
+ * @param validators - Non-empty array of validators to try
37
+ * @returns A new {@link UnionSchema} instance
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * // String or number
42
+ * const stringOrNumber = l.union([l.string(), l.integer()])
43
+ *
44
+ * // Nullable value
45
+ * const nullableString = l.union([l.string(), l.null()])
46
+ *
47
+ * // Multiple object types
48
+ * const mediaSchema = l.union([
49
+ * l.object({ type: l.literal('image'), url: l.string() }),
50
+ * l.object({ type: l.literal('video'), url: l.string(), duration: l.integer() }),
51
+ * ])
52
+ * ```
53
+ */
8
54
  export declare function union<const TValidators extends UnionSchemaValidators>(validators: TValidators): UnionSchema<TValidators>;
9
55
  //# sourceMappingURL=union.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/schema/union.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EAEjB,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC,CAAA;AAExE,qBAAa,WAAW,CACtB,KAAK,CAAC,WAAW,SAAS,qBAAqB,GAAG,GAAG,CACrD,SAAQ,MAAM,CACd,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAC/B,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CACjC;IACa,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW;gBAAvB,UAAU,EAAE,WAAW;IAItD,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CAYzD;AAGD,wBAAgB,KAAK,CAAC,KAAK,CAAC,WAAW,SAAS,qBAAqB,EACnE,UAAU,EAAE,WAAW,4BAGxB"}
1
+ {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/schema/union.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EAEjB,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC,CAAA;AAExE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,WAAW,CACtB,KAAK,CAAC,WAAW,SAAS,qBAAqB,GAAG,GAAG,CACrD,SAAQ,MAAM,CACd,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAC/B,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CACjC;IAGa,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW;IAFtD,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAS;gBAED,UAAU,EAAE,WAAW;IAItD,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CAYzD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wBAAgB,KAAK,CAAC,KAAK,CAAC,WAAW,SAAS,qBAAqB,EACnE,UAAU,EAAE,WAAW,4BAGxB"}
@@ -3,8 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnionSchema = void 0;
4
4
  exports.union = union;
5
5
  const core_js_1 = require("../core.js");
6
+ /**
7
+ * Schema for validating values that match one of several possible schemas.
8
+ *
9
+ * Tries each validator in order until one succeeds. If all validators fail,
10
+ * returns a combined error from all attempts.
11
+ *
12
+ * @template TValidators - Tuple type of the validators in the union
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const schema = new UnionSchema([l.string(), l.integer()])
17
+ * schema.validate('hello') // success
18
+ * schema.validate(42) // success
19
+ * schema.validate(true) // fails
20
+ * ```
21
+ */
6
22
  class UnionSchema extends core_js_1.Schema {
7
23
  validators;
24
+ type = 'union';
8
25
  constructor(validators) {
9
26
  super();
10
27
  this.validators = validators;
@@ -21,6 +38,30 @@ class UnionSchema extends core_js_1.Schema {
21
38
  }
22
39
  }
23
40
  exports.UnionSchema = UnionSchema;
41
+ /**
42
+ * Creates a union schema that accepts values matching any of the provided schemas.
43
+ *
44
+ * Validators are tried in order. Use `discriminatedUnion()` for better
45
+ * performance when discriminating on a known property.
46
+ *
47
+ * @param validators - Non-empty array of validators to try
48
+ * @returns A new {@link UnionSchema} instance
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // String or number
53
+ * const stringOrNumber = l.union([l.string(), l.integer()])
54
+ *
55
+ * // Nullable value
56
+ * const nullableString = l.union([l.string(), l.null()])
57
+ *
58
+ * // Multiple object types
59
+ * const mediaSchema = l.union([
60
+ * l.object({ type: l.literal('image'), url: l.string() }),
61
+ * l.object({ type: l.literal('video'), url: l.string(), duration: l.integer() }),
62
+ * ])
63
+ * ```
64
+ */
24
65
  /*@__NO_SIDE_EFFECTS__*/
25
66
  function union(validators) {
26
67
  return new UnionSchema(validators);
@@ -1 +1 @@
1
- {"version":3,"file":"union.js","sourceRoot":"","sources":["../../src/schema/union.ts"],"names":[],"mappings":";;;AAqCA,sBAIC;AAzCD,wCAQmB;AAInB,MAAa,WAEX,SAAQ,gBAGT;IACgC;IAA/B,YAA+B,UAAuB;QACpD,KAAK,EAAE,CAAA;QADsB,eAAU,GAAV,UAAU,CAAa;IAEtD,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,MAAM,QAAQ,GAAwB,EAAE,CAAA;QAExC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;YAC7C,IAAI,MAAM,CAAC,OAAO;gBAAE,OAAO,MAAM,CAAA;YAEjC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACvB,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAtBD,kCAsBC;AAED,wBAAwB;AACxB,SAAgB,KAAK,CACnB,UAAuB;IAEvB,OAAO,IAAI,WAAW,CAAc,UAAU,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import {\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n ValidationError,\n ValidationFailure,\n Validator,\n} from '../core.js'\n\nexport type UnionSchemaValidators = readonly [Validator, ...Validator[]]\n\nexport class UnionSchema<\n const TValidators extends UnionSchemaValidators = any,\n> extends Schema<\n InferInput<TValidators[number]>,\n InferOutput<TValidators[number]>\n> {\n constructor(protected readonly validators: TValidators) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n const failures: ValidationFailure[] = []\n\n for (const validator of this.validators) {\n const result = ctx.validate(input, validator)\n if (result.success) return result\n\n failures.push(result)\n }\n\n return ctx.failure(ValidationError.fromFailures(failures))\n }\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function union<const TValidators extends UnionSchemaValidators>(\n validators: TValidators,\n) {\n return new UnionSchema<TValidators>(validators)\n}\n"]}
1
+ {"version":3,"file":"union.js","sourceRoot":"","sources":["../../src/schema/union.ts"],"names":[],"mappings":";;;AAoFA,sBAIC;AAxFD,wCAQmB;AASnB;;;;;;;;;;;;;;;GAeG;AACH,MAAa,WAEX,SAAQ,gBAGT;IAGgC;IAFtB,IAAI,GAAG,OAAgB,CAAA;IAEhC,YAA+B,UAAuB;QACpD,KAAK,EAAE,CAAA;QADsB,eAAU,GAAV,UAAU,CAAa;IAEtD,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,MAAM,QAAQ,GAAwB,EAAE,CAAA;QAExC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;YAC7C,IAAI,MAAM,CAAC,OAAO;gBAAE,OAAO,MAAM,CAAA;YAEjC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACvB,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,yBAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAxBD,kCAwBC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAwB;AACxB,SAAgB,KAAK,CACnB,UAAuB;IAEvB,OAAO,IAAI,WAAW,CAAc,UAAU,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import {\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n ValidationError,\n ValidationFailure,\n Validator,\n} from '../core.js'\n\n/**\n * Type representing a non-empty tuple of validators for union schemas.\n *\n * Requires at least one validator in the tuple.\n */\nexport type UnionSchemaValidators = readonly [Validator, ...Validator[]]\n\n/**\n * Schema for validating values that match one of several possible schemas.\n *\n * Tries each validator in order until one succeeds. If all validators fail,\n * returns a combined error from all attempts.\n *\n * @template TValidators - Tuple type of the validators in the union\n *\n * @example\n * ```ts\n * const schema = new UnionSchema([l.string(), l.integer()])\n * schema.validate('hello') // success\n * schema.validate(42) // success\n * schema.validate(true) // fails\n * ```\n */\nexport class UnionSchema<\n const TValidators extends UnionSchemaValidators = any,\n> extends Schema<\n InferInput<TValidators[number]>,\n InferOutput<TValidators[number]>\n> {\n readonly type = 'union' as const\n\n constructor(protected readonly validators: TValidators) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n const failures: ValidationFailure[] = []\n\n for (const validator of this.validators) {\n const result = ctx.validate(input, validator)\n if (result.success) return result\n\n failures.push(result)\n }\n\n return ctx.failure(ValidationError.fromFailures(failures))\n }\n}\n\n/**\n * Creates a union schema that accepts values matching any of the provided schemas.\n *\n * Validators are tried in order. Use `discriminatedUnion()` for better\n * performance when discriminating on a known property.\n *\n * @param validators - Non-empty array of validators to try\n * @returns A new {@link UnionSchema} instance\n *\n * @example\n * ```ts\n * // String or number\n * const stringOrNumber = l.union([l.string(), l.integer()])\n *\n * // Nullable value\n * const nullableString = l.union([l.string(), l.null()])\n *\n * // Multiple object types\n * const mediaSchema = l.union([\n * l.object({ type: l.literal('image'), url: l.string() }),\n * l.object({ type: l.literal('video'), url: l.string(), duration: l.integer() }),\n * ])\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function union<const TValidators extends UnionSchemaValidators>(\n validators: TValidators,\n) {\n return new UnionSchema<TValidators>(validators)\n}\n"]}
@@ -1,6 +1,40 @@
1
1
  import { Schema, ValidationContext } from '../core.js';
2
+ /**
3
+ * Schema that accepts any value without validation.
4
+ *
5
+ * Passes through any input unchanged. Use sparingly as it bypasses
6
+ * type safety. Useful for dynamic data or when the schema is not
7
+ * known at compile time.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const schema = new UnknownSchema()
12
+ * schema.validate(anything) // always succeeds
13
+ * ```
14
+ */
2
15
  export declare class UnknownSchema extends Schema<unknown> {
16
+ readonly type: "unknown";
3
17
  validateInContext(input: unknown, ctx: ValidationContext): import("../core.js").ValidationResult<unknown>;
4
18
  }
19
+ /**
20
+ * Creates an unknown schema that accepts any value.
21
+ *
22
+ * The value passes through without any validation or transformation.
23
+ * Use this when you need to accept arbitrary data.
24
+ *
25
+ * @returns A new {@link UnknownSchema} instance
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // Accept any value
30
+ * const anyDataSchema = l.unknown()
31
+ *
32
+ * // In an object with a dynamic field
33
+ * const flexibleSchema = l.object({
34
+ * type: l.string(),
35
+ * data: l.unknown(),
36
+ * })
37
+ * ```
38
+ */
5
39
  export declare const unknown: () => UnknownSchema;
6
40
  //# sourceMappingURL=unknown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGtD,qBAAa,aAAc,SAAQ,MAAM,CAAC,OAAO,CAAC;IAChD,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CAGzD;AAED,eAAO,MAAM,OAAO,qBAElB,CAAA"}
1
+ {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGtD;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,OAAO,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAS;IAElC,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CAGzD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,OAAO,qBAElB,CAAA"}
@@ -3,12 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.unknown = exports.UnknownSchema = void 0;
4
4
  const core_js_1 = require("../core.js");
5
5
  const memoize_js_1 = require("../util/memoize.js");
6
+ /**
7
+ * Schema that accepts any value without validation.
8
+ *
9
+ * Passes through any input unchanged. Use sparingly as it bypasses
10
+ * type safety. Useful for dynamic data or when the schema is not
11
+ * known at compile time.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const schema = new UnknownSchema()
16
+ * schema.validate(anything) // always succeeds
17
+ * ```
18
+ */
6
19
  class UnknownSchema extends core_js_1.Schema {
20
+ type = 'unknown';
7
21
  validateInContext(input, ctx) {
8
22
  return ctx.success(input);
9
23
  }
10
24
  }
11
25
  exports.UnknownSchema = UnknownSchema;
26
+ /**
27
+ * Creates an unknown schema that accepts any value.
28
+ *
29
+ * The value passes through without any validation or transformation.
30
+ * Use this when you need to accept arbitrary data.
31
+ *
32
+ * @returns A new {@link UnknownSchema} instance
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // Accept any value
37
+ * const anyDataSchema = l.unknown()
38
+ *
39
+ * // In an object with a dynamic field
40
+ * const flexibleSchema = l.object({
41
+ * type: l.string(),
42
+ * data: l.unknown(),
43
+ * })
44
+ * ```
45
+ */
12
46
  exports.unknown = (0, memoize_js_1.memoizedOptions)(function () {
13
47
  return new UnknownSchema();
14
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":";;;AAAA,wCAAsD;AACtD,mDAAoD;AAEpD,MAAa,aAAc,SAAQ,gBAAe;IAChD,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAJD,sCAIC;AAEY,QAAA,OAAO,GAAiB,IAAA,4BAAe,EAAC;IACnD,OAAO,IAAI,aAAa,EAAE,CAAA;AAC5B,CAAC,CAAC,CAAA","sourcesContent":["import { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\n\nexport class UnknownSchema extends Schema<unknown> {\n validateInContext(input: unknown, ctx: ValidationContext) {\n return ctx.success(input)\n }\n}\n\nexport const unknown = /*#__PURE__*/ memoizedOptions(function () {\n return new UnknownSchema()\n})\n"]}
1
+ {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":";;;AAAA,wCAAsD;AACtD,mDAAoD;AAEpD;;;;;;;;;;;;GAYG;AACH,MAAa,aAAc,SAAQ,gBAAe;IACvC,IAAI,GAAG,SAAkB,CAAA;IAElC,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAND,sCAMC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,OAAO,GAAiB,IAAA,4BAAe,EAAC;IACnD,OAAO,IAAI,aAAa,EAAE,CAAA;AAC5B,CAAC,CAAC,CAAA","sourcesContent":["import { Schema, ValidationContext } from '../core.js'\nimport { memoizedOptions } from '../util/memoize.js'\n\n/**\n * Schema that accepts any value without validation.\n *\n * Passes through any input unchanged. Use sparingly as it bypasses\n * type safety. Useful for dynamic data or when the schema is not\n * known at compile time.\n *\n * @example\n * ```ts\n * const schema = new UnknownSchema()\n * schema.validate(anything) // always succeeds\n * ```\n */\nexport class UnknownSchema extends Schema<unknown> {\n readonly type = 'unknown' as const\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n return ctx.success(input)\n }\n}\n\n/**\n * Creates an unknown schema that accepts any value.\n *\n * The value passes through without any validation or transformation.\n * Use this when you need to accept arbitrary data.\n *\n * @returns A new {@link UnknownSchema} instance\n *\n * @example\n * ```ts\n * // Accept any value\n * const anyDataSchema = l.unknown()\n *\n * // In an object with a dynamic field\n * const flexibleSchema = l.object({\n * type: l.string(),\n * data: l.unknown(),\n * })\n * ```\n */\nexport const unknown = /*#__PURE__*/ memoizedOptions(function () {\n return new UnknownSchema()\n})\n"]}
@@ -1,9 +1,54 @@
1
1
  import { InferInput, InferOutput, Schema, ValidationContext, Validator } from '../core.js';
2
+ /**
3
+ * Schema wrapper that provides a default value when the input is undefined.
4
+ *
5
+ * In parse mode, when the input is `undefined`, the default value is used
6
+ * instead. In validate mode, undefined values pass through unchanged (the
7
+ * default is not applied).
8
+ *
9
+ * @template TValidator - The wrapped validator type
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const schema = new WithDefaultSchema(l.integer(), 0)
14
+ * schema.parse(undefined) // 0
15
+ * schema.parse(42) // 42
16
+ * ```
17
+ */
2
18
  export declare class WithDefaultSchema<const TValidator extends Validator> extends Schema<InferInput<TValidator>, InferOutput<TValidator>> {
3
19
  readonly validator: TValidator;
4
20
  readonly defaultValue: InferInput<TValidator>;
21
+ readonly type: "withDefault";
5
22
  constructor(validator: TValidator, defaultValue: InferInput<TValidator>);
6
23
  validateInContext(input: unknown, ctx: ValidationContext): import("../core.js").ValidationResult<InferInput<TValidator>>;
7
24
  }
25
+ /**
26
+ * Creates a schema that applies a default value when the input is undefined.
27
+ *
28
+ * Commonly used with `optional()` to provide fallback values for missing
29
+ * properties. The default value is validated against the schema.
30
+ *
31
+ * @param validator - The validator for the value
32
+ * @param defaultValue - The default value to use when input is undefined
33
+ * @returns A new {@link WithDefaultSchema} instance
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * // Integer with default
38
+ * const countSchema = l.withDefault(l.integer(), 0)
39
+ * countSchema.parse(undefined) // 0
40
+ * countSchema.parse(5) // 5
41
+ *
42
+ * // Commonly combined with optional in objects
43
+ * const settingsSchema = l.object({
44
+ * theme: l.optional(l.withDefault(l.string(), 'light')),
45
+ * pageSize: l.optional(l.withDefault(l.integer(), 25)),
46
+ * })
47
+ * settingsSchema.parse({}) // { theme: 'light', pageSize: 25 }
48
+ *
49
+ * // Boolean with default
50
+ * const enabledSchema = l.withDefault(l.boolean(), false)
51
+ * ```
52
+ */
8
53
  export declare function withDefault<const TValidator extends Validator>(validator: TValidator, defaultValue: InferInput<TValidator>): WithDefaultSchema<TValidator>;
9
54
  //# sourceMappingURL=with-default.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-default.d.ts","sourceRoot":"","sources":["../../src/schema/with-default.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAA;AAEnB,qBAAa,iBAAiB,CAC5B,KAAK,CAAC,UAAU,SAAS,SAAS,CAClC,SAAQ,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAE7D,QAAQ,CAAC,SAAS,EAAE,UAAU;IAC9B,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC;gBADpC,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC;IAK/C,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CASzD;AAED,wBAAgB,WAAW,CAAC,KAAK,CAAC,UAAU,SAAS,SAAS,EAC5D,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC,iCAGrC"}
1
+ {"version":3,"file":"with-default.d.ts","sourceRoot":"","sources":["../../src/schema/with-default.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iBAAiB,CAC5B,KAAK,CAAC,UAAU,SAAS,SAAS,CAClC,SAAQ,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAI7D,QAAQ,CAAC,SAAS,EAAE,UAAU;IAC9B,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC;IAJ/C,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAS;gBAG3B,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC;IAK/C,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB;CASzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,UAAU,SAAS,SAAS,EAC5D,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC,iCAGrC"}
@@ -3,9 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WithDefaultSchema = void 0;
4
4
  exports.withDefault = withDefault;
5
5
  const core_js_1 = require("../core.js");
6
+ /**
7
+ * Schema wrapper that provides a default value when the input is undefined.
8
+ *
9
+ * In parse mode, when the input is `undefined`, the default value is used
10
+ * instead. In validate mode, undefined values pass through unchanged (the
11
+ * default is not applied).
12
+ *
13
+ * @template TValidator - The wrapped validator type
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const schema = new WithDefaultSchema(l.integer(), 0)
18
+ * schema.parse(undefined) // 0
19
+ * schema.parse(42) // 42
20
+ * ```
21
+ */
6
22
  class WithDefaultSchema extends core_js_1.Schema {
7
23
  validator;
8
24
  defaultValue;
25
+ type = 'withDefault';
9
26
  constructor(validator, defaultValue) {
10
27
  super();
11
28
  this.validator = validator;
@@ -21,6 +38,34 @@ class WithDefaultSchema extends core_js_1.Schema {
21
38
  }
22
39
  }
23
40
  exports.WithDefaultSchema = WithDefaultSchema;
41
+ /**
42
+ * Creates a schema that applies a default value when the input is undefined.
43
+ *
44
+ * Commonly used with `optional()` to provide fallback values for missing
45
+ * properties. The default value is validated against the schema.
46
+ *
47
+ * @param validator - The validator for the value
48
+ * @param defaultValue - The default value to use when input is undefined
49
+ * @returns A new {@link WithDefaultSchema} instance
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * // Integer with default
54
+ * const countSchema = l.withDefault(l.integer(), 0)
55
+ * countSchema.parse(undefined) // 0
56
+ * countSchema.parse(5) // 5
57
+ *
58
+ * // Commonly combined with optional in objects
59
+ * const settingsSchema = l.object({
60
+ * theme: l.optional(l.withDefault(l.string(), 'light')),
61
+ * pageSize: l.optional(l.withDefault(l.integer(), 25)),
62
+ * })
63
+ * settingsSchema.parse({}) // { theme: 'light', pageSize: 25 }
64
+ *
65
+ * // Boolean with default
66
+ * const enabledSchema = l.withDefault(l.boolean(), false)
67
+ * ```
68
+ */
24
69
  function withDefault(validator, defaultValue) {
25
70
  return new WithDefaultSchema(validator, defaultValue);
26
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"with-default.js","sourceRoot":"","sources":["../../src/schema/with-default.ts"],"names":[],"mappings":";;;AA6BA,kCAKC;AAlCD,wCAMmB;AAEnB,MAAa,iBAEX,SAAQ,gBAAuD;IAEpD;IACA;IAFX,YACW,SAAqB,EACrB,YAAoC;QAE7C,KAAK,EAAE,CAAA;QAHE,cAAS,GAAT,SAAS,CAAY;QACrB,iBAAY,GAAZ,YAAY,CAAwB;IAG/C,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,kEAAkE;QAClE,iCAAiC;QACjC,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC3D,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACxD,CAAC;QAED,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IAC5C,CAAC;CACF;AAnBD,8CAmBC;AAED,SAAgB,WAAW,CACzB,SAAqB,EACrB,YAAoC;IAEpC,OAAO,IAAI,iBAAiB,CAAa,SAAS,EAAE,YAAY,CAAC,CAAA;AACnE,CAAC","sourcesContent":["import {\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n Validator,\n} from '../core.js'\n\nexport class WithDefaultSchema<\n const TValidator extends Validator,\n> extends Schema<InferInput<TValidator>, InferOutput<TValidator>> {\n constructor(\n readonly validator: TValidator,\n readonly defaultValue: InferInput<TValidator>,\n ) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n // When in a validation context, the output should not be altered,\n // so we don't apply the default.\n if (input === undefined && ctx.options.mode !== 'validate') {\n return ctx.validate(this.defaultValue, this.validator)\n }\n\n return ctx.validate(input, this.validator)\n }\n}\n\nexport function withDefault<const TValidator extends Validator>(\n validator: TValidator,\n defaultValue: InferInput<TValidator>,\n) {\n return new WithDefaultSchema<TValidator>(validator, defaultValue)\n}\n"]}
1
+ {"version":3,"file":"with-default.js","sourceRoot":"","sources":["../../src/schema/with-default.ts"],"names":[],"mappings":";;;AA2EA,kCAKC;AAhFD,wCAMmB;AAEnB;;;;;;;;;;;;;;;GAeG;AACH,MAAa,iBAEX,SAAQ,gBAAuD;IAIpD;IACA;IAJF,IAAI,GAAG,aAAsB,CAAA;IAEtC,YACW,SAAqB,EACrB,YAAoC;QAE7C,KAAK,EAAE,CAAA;QAHE,cAAS,GAAT,SAAS,CAAY;QACrB,iBAAY,GAAZ,YAAY,CAAwB;IAG/C,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,GAAsB;QACtD,kEAAkE;QAClE,iCAAiC;QACjC,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC3D,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACxD,CAAC;QAED,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IAC5C,CAAC;CACF;AArBD,8CAqBC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,WAAW,CACzB,SAAqB,EACrB,YAAoC;IAEpC,OAAO,IAAI,iBAAiB,CAAa,SAAS,EAAE,YAAY,CAAC,CAAA;AACnE,CAAC","sourcesContent":["import {\n InferInput,\n InferOutput,\n Schema,\n ValidationContext,\n Validator,\n} from '../core.js'\n\n/**\n * Schema wrapper that provides a default value when the input is undefined.\n *\n * In parse mode, when the input is `undefined`, the default value is used\n * instead. In validate mode, undefined values pass through unchanged (the\n * default is not applied).\n *\n * @template TValidator - The wrapped validator type\n *\n * @example\n * ```ts\n * const schema = new WithDefaultSchema(l.integer(), 0)\n * schema.parse(undefined) // 0\n * schema.parse(42) // 42\n * ```\n */\nexport class WithDefaultSchema<\n const TValidator extends Validator,\n> extends Schema<InferInput<TValidator>, InferOutput<TValidator>> {\n readonly type = 'withDefault' as const\n\n constructor(\n readonly validator: TValidator,\n readonly defaultValue: InferInput<TValidator>,\n ) {\n super()\n }\n\n validateInContext(input: unknown, ctx: ValidationContext) {\n // When in a validation context, the output should not be altered,\n // so we don't apply the default.\n if (input === undefined && ctx.options.mode !== 'validate') {\n return ctx.validate(this.defaultValue, this.validator)\n }\n\n return ctx.validate(input, this.validator)\n }\n}\n\n/**\n * Creates a schema that applies a default value when the input is undefined.\n *\n * Commonly used with `optional()` to provide fallback values for missing\n * properties. The default value is validated against the schema.\n *\n * @param validator - The validator for the value\n * @param defaultValue - The default value to use when input is undefined\n * @returns A new {@link WithDefaultSchema} instance\n *\n * @example\n * ```ts\n * // Integer with default\n * const countSchema = l.withDefault(l.integer(), 0)\n * countSchema.parse(undefined) // 0\n * countSchema.parse(5) // 5\n *\n * // Commonly combined with optional in objects\n * const settingsSchema = l.object({\n * theme: l.optional(l.withDefault(l.string(), 'light')),\n * pageSize: l.optional(l.withDefault(l.integer(), 25)),\n * })\n * settingsSchema.parse({}) // { theme: 'light', pageSize: 25 }\n *\n * // Boolean with default\n * const enabledSchema = l.withDefault(l.boolean(), false)\n * ```\n */\nexport function withDefault<const TValidator extends Validator>(\n validator: TValidator,\n defaultValue: InferInput<TValidator>,\n) {\n return new WithDefaultSchema<TValidator>(validator, defaultValue)\n}\n"]}
package/dist/schema.d.ts CHANGED
@@ -6,13 +6,14 @@ export * from './schema/cid.js';
6
6
  export * from './schema/dict.js';
7
7
  export * from './schema/enum.js';
8
8
  export * from './schema/integer.js';
9
+ export * from './schema/lex-map.js';
10
+ export * from './schema/lex-value.js';
9
11
  export * from './schema/literal.js';
10
12
  export * from './schema/never.js';
11
13
  export * from './schema/null.js';
12
14
  export * from './schema/object.js';
13
15
  export * from './schema/regexp.js';
14
16
  export * from './schema/string.js';
15
- export * from './schema/unknown-object.js';
16
17
  export * from './schema/unknown.js';
17
18
  export * from './schema/custom.js';
18
19
  export * from './schema/discriminated-union.js';
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AAGnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AAGxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AAGnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AAGxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA"}
package/dist/schema.js CHANGED
@@ -10,13 +10,14 @@ tslib_1.__exportStar(require("./schema/cid.js"), exports);
10
10
  tslib_1.__exportStar(require("./schema/dict.js"), exports);
11
11
  tslib_1.__exportStar(require("./schema/enum.js"), exports);
12
12
  tslib_1.__exportStar(require("./schema/integer.js"), exports);
13
+ tslib_1.__exportStar(require("./schema/lex-map.js"), exports);
14
+ tslib_1.__exportStar(require("./schema/lex-value.js"), exports);
13
15
  tslib_1.__exportStar(require("./schema/literal.js"), exports);
14
16
  tslib_1.__exportStar(require("./schema/never.js"), exports);
15
17
  tslib_1.__exportStar(require("./schema/null.js"), exports);
16
18
  tslib_1.__exportStar(require("./schema/object.js"), exports);
17
19
  tslib_1.__exportStar(require("./schema/regexp.js"), exports);
18
20
  tslib_1.__exportStar(require("./schema/string.js"), exports);
19
- tslib_1.__exportStar(require("./schema/unknown-object.js"), exports);
20
21
  tslib_1.__exportStar(require("./schema/unknown.js"), exports);
21
22
  // Composite Types
22
23
  tslib_1.__exportStar(require("./schema/custom.js"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,4DAAiC;AACjC,2DAAgC;AAChC,8DAAmC;AACnC,4DAAiC;AACjC,0DAA+B;AAC/B,2DAAgC;AAChC,2DAAgC;AAChC,8DAAmC;AACnC,8DAAmC;AACnC,4DAAiC;AACjC,2DAAgC;AAChC,6DAAkC;AAClC,6DAAkC;AAClC,6DAAkC;AAClC,qEAA0C;AAC1C,8DAAmC;AAEnC,kBAAkB;AAClB,6DAAkC;AAClC,0EAA+C;AAC/C,mEAAwC;AACxC,+DAAoC;AACpC,+DAAoC;AACpC,0DAA+B;AAC/B,6DAAkC;AAClC,4DAAiC;AACjC,mEAAwC;AAExC,yBAAyB;AACzB,6DAAkC;AAClC,8DAAmC;AACnC,qEAA0C;AAC1C,iEAAsC;AACtC,gEAAqC;AACrC,4DAAiC;AACjC,6DAAkC;AAClC,mEAAwC;AACxC,4DAAiC;AACjC,mEAAwC;AACxC,gEAAqC;AACrC,kEAAuC","sourcesContent":["// Concrete Types\nexport * from './schema/array.js'\nexport * from './schema/blob.js'\nexport * from './schema/boolean.js'\nexport * from './schema/bytes.js'\nexport * from './schema/cid.js'\nexport * from './schema/dict.js'\nexport * from './schema/enum.js'\nexport * from './schema/integer.js'\nexport * from './schema/literal.js'\nexport * from './schema/never.js'\nexport * from './schema/null.js'\nexport * from './schema/object.js'\nexport * from './schema/regexp.js'\nexport * from './schema/string.js'\nexport * from './schema/unknown-object.js'\nexport * from './schema/unknown.js'\n\n// Composite Types\nexport * from './schema/custom.js'\nexport * from './schema/discriminated-union.js'\nexport * from './schema/intersection.js'\nexport * from './schema/nullable.js'\nexport * from './schema/optional.js'\nexport * from './schema/ref.js'\nexport * from './schema/refine.js'\nexport * from './schema/union.js'\nexport * from './schema/with-default.js'\n\n// Lexicon specific Types\nexport * from './schema/params.js'\nexport * from './schema/payload.js'\nexport * from './schema/permission-set.js'\nexport * from './schema/permission.js'\nexport * from './schema/procedure.js'\nexport * from './schema/query.js'\nexport * from './schema/record.js'\nexport * from './schema/subscription.js'\nexport * from './schema/token.js'\nexport * from './schema/typed-object.js'\nexport * from './schema/typed-ref.js'\nexport * from './schema/typed-union.js'\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,4DAAiC;AACjC,2DAAgC;AAChC,8DAAmC;AACnC,4DAAiC;AACjC,0DAA+B;AAC/B,2DAAgC;AAChC,2DAAgC;AAChC,8DAAmC;AACnC,8DAAmC;AACnC,gEAAqC;AACrC,8DAAmC;AACnC,4DAAiC;AACjC,2DAAgC;AAChC,6DAAkC;AAClC,6DAAkC;AAClC,6DAAkC;AAClC,8DAAmC;AAEnC,kBAAkB;AAClB,6DAAkC;AAClC,0EAA+C;AAC/C,mEAAwC;AACxC,+DAAoC;AACpC,+DAAoC;AACpC,0DAA+B;AAC/B,6DAAkC;AAClC,4DAAiC;AACjC,mEAAwC;AAExC,yBAAyB;AACzB,6DAAkC;AAClC,8DAAmC;AACnC,qEAA0C;AAC1C,iEAAsC;AACtC,gEAAqC;AACrC,4DAAiC;AACjC,6DAAkC;AAClC,mEAAwC;AACxC,4DAAiC;AACjC,mEAAwC;AACxC,gEAAqC;AACrC,kEAAuC","sourcesContent":["// Concrete Types\nexport * from './schema/array.js'\nexport * from './schema/blob.js'\nexport * from './schema/boolean.js'\nexport * from './schema/bytes.js'\nexport * from './schema/cid.js'\nexport * from './schema/dict.js'\nexport * from './schema/enum.js'\nexport * from './schema/integer.js'\nexport * from './schema/lex-map.js'\nexport * from './schema/lex-value.js'\nexport * from './schema/literal.js'\nexport * from './schema/never.js'\nexport * from './schema/null.js'\nexport * from './schema/object.js'\nexport * from './schema/regexp.js'\nexport * from './schema/string.js'\nexport * from './schema/unknown.js'\n\n// Composite Types\nexport * from './schema/custom.js'\nexport * from './schema/discriminated-union.js'\nexport * from './schema/intersection.js'\nexport * from './schema/nullable.js'\nexport * from './schema/optional.js'\nexport * from './schema/ref.js'\nexport * from './schema/refine.js'\nexport * from './schema/union.js'\nexport * from './schema/with-default.js'\n\n// Lexicon specific Types\nexport * from './schema/params.js'\nexport * from './schema/payload.js'\nexport * from './schema/permission-set.js'\nexport * from './schema/permission.js'\nexport * from './schema/procedure.js'\nexport * from './schema/query.js'\nexport * from './schema/record.js'\nexport * from './schema/subscription.js'\nexport * from './schema/token.js'\nexport * from './schema/typed-object.js'\nexport * from './schema/typed-ref.js'\nexport * from './schema/typed-union.js'\n"]}