@atproto/lex-schema 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/core/property-key.d.ts.map +1 -0
  3. package/dist/core/property-key.js.map +1 -0
  4. package/dist/core/schema.d.ts.map +1 -0
  5. package/dist/core/schema.js.map +1 -0
  6. package/dist/core/validation-error.d.ts +19 -0
  7. package/dist/core/validation-error.d.ts.map +1 -0
  8. package/dist/{validation → core}/validation-error.js +12 -5
  9. package/dist/core/validation-error.js.map +1 -0
  10. package/dist/{validation → core}/validation-issue.d.ts +43 -0
  11. package/dist/core/validation-issue.d.ts.map +1 -0
  12. package/dist/{validation → core}/validation-issue.js +45 -0
  13. package/dist/core/validation-issue.js.map +1 -0
  14. package/dist/{validation → core}/validator.d.ts +1 -1
  15. package/dist/core/validator.d.ts.map +1 -0
  16. package/dist/{validation → core}/validator.js +4 -4
  17. package/dist/core/validator.js.map +1 -0
  18. package/dist/core.d.ts +5 -0
  19. package/dist/core.d.ts.map +1 -1
  20. package/dist/core.js +5 -0
  21. package/dist/core.js.map +1 -1
  22. package/dist/external.d.ts +15 -16
  23. package/dist/external.d.ts.map +1 -1
  24. package/dist/external.js +38 -55
  25. package/dist/external.js.map +1 -1
  26. package/dist/helpers.d.ts +7 -2
  27. package/dist/helpers.d.ts.map +1 -1
  28. package/dist/helpers.js +10 -0
  29. package/dist/helpers.js.map +1 -1
  30. package/dist/schema/_parameters.d.ts +1 -1
  31. package/dist/schema/_parameters.d.ts.map +1 -1
  32. package/dist/schema/_parameters.js.map +1 -1
  33. package/dist/schema/array.d.ts +1 -1
  34. package/dist/schema/array.d.ts.map +1 -1
  35. package/dist/schema/array.js +2 -2
  36. package/dist/schema/array.js.map +1 -1
  37. package/dist/schema/blob.d.ts +1 -1
  38. package/dist/schema/blob.d.ts.map +1 -1
  39. package/dist/schema/blob.js +2 -2
  40. package/dist/schema/blob.js.map +1 -1
  41. package/dist/schema/boolean.d.ts +1 -1
  42. package/dist/schema/boolean.d.ts.map +1 -1
  43. package/dist/schema/boolean.js +2 -2
  44. package/dist/schema/boolean.js.map +1 -1
  45. package/dist/schema/bytes.d.ts +1 -1
  46. package/dist/schema/bytes.d.ts.map +1 -1
  47. package/dist/schema/bytes.js +2 -2
  48. package/dist/schema/bytes.js.map +1 -1
  49. package/dist/schema/cid.d.ts +1 -1
  50. package/dist/schema/cid.d.ts.map +1 -1
  51. package/dist/schema/cid.js +2 -2
  52. package/dist/schema/cid.js.map +1 -1
  53. package/dist/schema/custom.d.ts +1 -1
  54. package/dist/schema/custom.d.ts.map +1 -1
  55. package/dist/schema/custom.js +3 -3
  56. package/dist/schema/custom.js.map +1 -1
  57. package/dist/schema/dict.d.ts +1 -1
  58. package/dist/schema/dict.d.ts.map +1 -1
  59. package/dist/schema/dict.js +2 -2
  60. package/dist/schema/dict.js.map +1 -1
  61. package/dist/schema/discriminated-union.d.ts +1 -1
  62. package/dist/schema/discriminated-union.d.ts.map +1 -1
  63. package/dist/schema/discriminated-union.js +2 -2
  64. package/dist/schema/discriminated-union.js.map +1 -1
  65. package/dist/schema/enum.d.ts +1 -1
  66. package/dist/schema/enum.d.ts.map +1 -1
  67. package/dist/schema/enum.js +2 -2
  68. package/dist/schema/enum.js.map +1 -1
  69. package/dist/schema/integer.d.ts +1 -1
  70. package/dist/schema/integer.d.ts.map +1 -1
  71. package/dist/schema/integer.js +4 -4
  72. package/dist/schema/integer.js.map +1 -1
  73. package/dist/schema/intersection.d.ts +1 -2
  74. package/dist/schema/intersection.d.ts.map +1 -1
  75. package/dist/schema/intersection.js +2 -2
  76. package/dist/schema/intersection.js.map +1 -1
  77. package/dist/schema/literal.d.ts +1 -1
  78. package/dist/schema/literal.d.ts.map +1 -1
  79. package/dist/schema/literal.js +2 -2
  80. package/dist/schema/literal.js.map +1 -1
  81. package/dist/schema/never.d.ts +1 -1
  82. package/dist/schema/never.d.ts.map +1 -1
  83. package/dist/schema/never.js +2 -2
  84. package/dist/schema/never.js.map +1 -1
  85. package/dist/schema/null.d.ts +1 -1
  86. package/dist/schema/null.d.ts.map +1 -1
  87. package/dist/schema/null.js +2 -2
  88. package/dist/schema/null.js.map +1 -1
  89. package/dist/schema/nullable.d.ts +1 -1
  90. package/dist/schema/nullable.d.ts.map +1 -1
  91. package/dist/schema/nullable.js +2 -2
  92. package/dist/schema/nullable.js.map +1 -1
  93. package/dist/schema/object.d.ts +1 -2
  94. package/dist/schema/object.d.ts.map +1 -1
  95. package/dist/schema/object.js +2 -2
  96. package/dist/schema/object.js.map +1 -1
  97. package/dist/schema/optional.d.ts +1 -1
  98. package/dist/schema/optional.d.ts.map +1 -1
  99. package/dist/schema/optional.js +2 -2
  100. package/dist/schema/optional.js.map +1 -1
  101. package/dist/schema/params.d.ts +1 -2
  102. package/dist/schema/params.d.ts.map +1 -1
  103. package/dist/schema/params.js +2 -2
  104. package/dist/schema/params.js.map +1 -1
  105. package/dist/schema/payload.d.ts +1 -1
  106. package/dist/schema/payload.d.ts.map +1 -1
  107. package/dist/schema/payload.js.map +1 -1
  108. package/dist/schema/record.d.ts +1 -2
  109. package/dist/schema/record.d.ts.map +1 -1
  110. package/dist/schema/record.js +2 -2
  111. package/dist/schema/record.js.map +1 -1
  112. package/dist/schema/ref.d.ts +1 -1
  113. package/dist/schema/ref.d.ts.map +1 -1
  114. package/dist/schema/ref.js +2 -2
  115. package/dist/schema/ref.js.map +1 -1
  116. package/dist/schema/refine.d.ts +18 -1
  117. package/dist/schema/refine.d.ts.map +1 -1
  118. package/dist/schema/refine.js +2 -2
  119. package/dist/schema/refine.js.map +1 -1
  120. package/dist/schema/regexp.d.ts +1 -1
  121. package/dist/schema/regexp.d.ts.map +1 -1
  122. package/dist/schema/regexp.js +2 -2
  123. package/dist/schema/regexp.js.map +1 -1
  124. package/dist/schema/string.d.ts +1 -2
  125. package/dist/schema/string.d.ts.map +1 -1
  126. package/dist/schema/string.js +1 -2
  127. package/dist/schema/string.js.map +1 -1
  128. package/dist/schema/subscription.d.ts +1 -2
  129. package/dist/schema/subscription.d.ts.map +1 -1
  130. package/dist/schema/subscription.js.map +1 -1
  131. package/dist/schema/token.d.ts +1 -1
  132. package/dist/schema/token.d.ts.map +1 -1
  133. package/dist/schema/token.js +2 -2
  134. package/dist/schema/token.js.map +1 -1
  135. package/dist/schema/typed-object.d.ts +1 -2
  136. package/dist/schema/typed-object.d.ts.map +1 -1
  137. package/dist/schema/typed-object.js +2 -2
  138. package/dist/schema/typed-object.js.map +1 -1
  139. package/dist/schema/typed-ref.d.ts +1 -1
  140. package/dist/schema/typed-ref.d.ts.map +1 -1
  141. package/dist/schema/typed-ref.js +2 -2
  142. package/dist/schema/typed-ref.js.map +1 -1
  143. package/dist/schema/typed-union.d.ts +2 -3
  144. package/dist/schema/typed-union.d.ts.map +1 -1
  145. package/dist/schema/typed-union.js +2 -2
  146. package/dist/schema/typed-union.js.map +1 -1
  147. package/dist/schema/union.d.ts +1 -1
  148. package/dist/schema/union.d.ts.map +1 -1
  149. package/dist/schema/union.js +3 -3
  150. package/dist/schema/union.js.map +1 -1
  151. package/dist/schema/unknown-object.d.ts +1 -2
  152. package/dist/schema/unknown-object.d.ts.map +1 -1
  153. package/dist/schema/unknown-object.js +2 -2
  154. package/dist/schema/unknown-object.js.map +1 -1
  155. package/dist/schema/unknown.d.ts +1 -1
  156. package/dist/schema/unknown.d.ts.map +1 -1
  157. package/dist/schema/unknown.js +2 -2
  158. package/dist/schema/unknown.js.map +1 -1
  159. package/dist/util/memoize.d.ts +3 -0
  160. package/dist/util/memoize.d.ts.map +1 -0
  161. package/dist/util/memoize.js +52 -0
  162. package/dist/util/memoize.js.map +1 -0
  163. package/package.json +6 -6
  164. package/src/{validation → core}/validation-error.ts +11 -3
  165. package/src/{validation → core}/validation-issue.ts +52 -0
  166. package/src/{validation → core}/validator.ts +1 -1
  167. package/src/core.ts +5 -0
  168. package/src/external.ts +67 -48
  169. package/src/helpers.test.ts +1 -0
  170. package/src/helpers.ts +16 -2
  171. package/src/schema/_parameters.test.ts +1 -0
  172. package/src/schema/_parameters.ts +1 -1
  173. package/src/schema/array.test.ts +1 -0
  174. package/src/schema/array.ts +1 -1
  175. package/src/schema/blob.test.ts +1 -0
  176. package/src/schema/blob.ts +1 -1
  177. package/src/schema/boolean.test.ts +1 -0
  178. package/src/schema/boolean.ts +1 -1
  179. package/src/schema/bytes.test.ts +1 -0
  180. package/src/schema/bytes.ts +1 -1
  181. package/src/schema/cid.test.ts +1 -0
  182. package/src/schema/cid.ts +1 -1
  183. package/src/schema/custom.test.ts +3 -2
  184. package/src/schema/custom.ts +1 -1
  185. package/src/schema/dict.test.ts +1 -0
  186. package/src/schema/dict.ts +1 -1
  187. package/src/schema/discriminated-union.test.ts +1 -0
  188. package/src/schema/discriminated-union.ts +1 -1
  189. package/src/schema/enum.test.ts +1 -0
  190. package/src/schema/enum.ts +1 -1
  191. package/src/schema/integer.test.ts +1 -0
  192. package/src/schema/integer.ts +3 -3
  193. package/src/schema/intersection.test.ts +1 -0
  194. package/src/schema/intersection.ts +2 -2
  195. package/src/schema/literal.test.ts +1 -0
  196. package/src/schema/literal.ts +1 -1
  197. package/src/schema/never.test.ts +1 -0
  198. package/src/schema/never.ts +1 -1
  199. package/src/schema/null.test.ts +1 -0
  200. package/src/schema/null.ts +1 -1
  201. package/src/schema/nullable.test.ts +1 -0
  202. package/src/schema/nullable.ts +1 -1
  203. package/src/schema/object.test.ts +1 -0
  204. package/src/schema/object.ts +3 -3
  205. package/src/schema/optional.test.ts +1 -0
  206. package/src/schema/optional.ts +1 -1
  207. package/src/schema/params.test.ts +1 -0
  208. package/src/schema/params.ts +3 -3
  209. package/src/schema/payload.test.ts +1 -0
  210. package/src/schema/payload.ts +1 -1
  211. package/src/schema/permission-set.test.ts +1 -0
  212. package/src/schema/permission.test.ts +1 -0
  213. package/src/schema/procedure.test.ts +1 -0
  214. package/src/schema/query.test.ts +1 -0
  215. package/src/schema/record.test.ts +1 -0
  216. package/src/schema/record.ts +5 -2
  217. package/src/schema/ref.test.ts +2 -1
  218. package/src/schema/ref.ts +1 -1
  219. package/src/schema/refine.test.ts +1 -0
  220. package/src/schema/refine.ts +18 -1
  221. package/src/schema/regexp.test.ts +1 -0
  222. package/src/schema/regexp.ts +1 -1
  223. package/src/schema/string.test.ts +1 -0
  224. package/src/schema/string.ts +8 -2
  225. package/src/schema/subscription.test.ts +1 -0
  226. package/src/schema/subscription.ts +1 -2
  227. package/src/schema/token.test.ts +1 -0
  228. package/src/schema/token.ts +1 -1
  229. package/src/schema/typed-object.test.ts +1 -0
  230. package/src/schema/typed-object.ts +3 -2
  231. package/src/schema/typed-ref.test.ts +1 -0
  232. package/src/schema/typed-ref.ts +1 -1
  233. package/src/schema/typed-union.test.ts +1 -0
  234. package/src/schema/typed-union.ts +4 -4
  235. package/src/schema/union.test.ts +1 -0
  236. package/src/schema/union.ts +1 -1
  237. package/src/schema/unknown-object.test.ts +1 -0
  238. package/src/schema/unknown-object.ts +1 -2
  239. package/src/schema/unknown.test.ts +1 -0
  240. package/src/schema/unknown.ts +1 -1
  241. package/src/util/array-agg.test.ts +1 -0
  242. package/src/util/memoize.ts +57 -0
  243. package/tsconfig.tests.json +1 -1
  244. package/dist/validation/property-key.d.ts.map +0 -1
  245. package/dist/validation/property-key.js.map +0 -1
  246. package/dist/validation/schema.d.ts.map +0 -1
  247. package/dist/validation/schema.js.map +0 -1
  248. package/dist/validation/validation-error.d.ts +0 -9
  249. package/dist/validation/validation-error.d.ts.map +0 -1
  250. package/dist/validation/validation-error.js.map +0 -1
  251. package/dist/validation/validation-issue.d.ts.map +0 -1
  252. package/dist/validation/validation-issue.js.map +0 -1
  253. package/dist/validation/validator.d.ts.map +0 -1
  254. package/dist/validation/validator.js.map +0 -1
  255. package/dist/validation.d.ts +0 -6
  256. package/dist/validation.d.ts.map +0 -1
  257. package/dist/validation.js +0 -9
  258. package/dist/validation.js.map +0 -1
  259. package/src/validation.ts +0 -5
  260. /package/dist/{validation → core}/property-key.d.ts +0 -0
  261. /package/dist/{validation → core}/property-key.js +0 -0
  262. /package/dist/{validation → core}/schema.d.ts +0 -0
  263. /package/dist/{validation → core}/schema.js +0 -0
  264. /package/src/{validation → core}/property-key.ts +0 -0
  265. /package/src/{validation → core}/schema.ts +0 -0
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnknownObjectSchema = void 0;
4
4
  const lex_data_1 = require("@atproto/lex-data");
5
- const validation_1 = require("../validation");
6
- class UnknownObjectSchema extends validation_1.Schema {
5
+ const core_js_1 = require("../core.js");
6
+ class UnknownObjectSchema extends core_js_1.Schema {
7
7
  validateInContext(input, ctx) {
8
8
  if ((0, lex_data_1.isLexMap)(input)) {
9
9
  return ctx.success(input);
@@ -1 +1 @@
1
- {"version":3,"file":"unknown-object.js","sourceRoot":"","sources":["../../src/schema/unknown-object.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,8CAA0E;AAK1E,MAAa,mBAAoB,SAAQ,mBAA2B;IAClE,iBAAiB,CACf,KAAc,EACd,GAAqB;QAErB,IAAI,IAAA,mBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAC/C,CAAC;CACF;AAXD,kDAWC","sourcesContent":["import { LexMap, isLexMap } from '@atproto/lex-data'\nimport { Schema, ValidationResult, ValidatorContext } from '../validation'\n\nexport type { LexMap }\nexport type UnknownObjectOutput = LexMap\n\nexport class UnknownObjectSchema extends Schema<UnknownObjectOutput> {\n validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<UnknownObjectOutput> {\n if (isLexMap(input)) {\n return ctx.success(input)\n }\n\n return ctx.issueInvalidType(input, 'unknown')\n }\n}\n"]}
1
+ {"version":3,"file":"unknown-object.js","sourceRoot":"","sources":["../../src/schema/unknown-object.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,wCAAuE;AAIvE,MAAa,mBAAoB,SAAQ,gBAA2B;IAClE,iBAAiB,CACf,KAAc,EACd,GAAqB;QAErB,IAAI,IAAA,mBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAC/C,CAAC;CACF;AAXD,kDAWC","sourcesContent":["import { LexMap, isLexMap } from '@atproto/lex-data'\nimport { Schema, ValidationResult, ValidatorContext } from '../core.js'\n\nexport type UnknownObjectOutput = LexMap\n\nexport class UnknownObjectSchema extends Schema<UnknownObjectOutput> {\n validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<UnknownObjectOutput> {\n if (isLexMap(input)) {\n return ctx.success(input)\n }\n\n return ctx.issueInvalidType(input, 'unknown')\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Schema, ValidationResult, ValidatorContext } from '../validation';
1
+ import { Schema, ValidationResult, ValidatorContext } from '../core.js';
2
2
  export declare class UnknownSchema extends Schema<unknown> {
3
3
  validateInContext(input: unknown, ctx: ValidatorContext): ValidationResult<unknown>;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAE1E,qBAAa,aAAc,SAAQ,MAAM,CAAC,OAAO,CAAC;IAChD,iBAAiB,CACf,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,OAAO,CAAC;CAG7B"}
1
+ {"version":3,"file":"unknown.d.ts","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEvE,qBAAa,aAAc,SAAQ,MAAM,CAAC,OAAO,CAAC;IAChD,iBAAiB,CACf,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,OAAO,CAAC;CAG7B"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnknownSchema = void 0;
4
- const validation_1 = require("../validation");
5
- class UnknownSchema extends validation_1.Schema {
4
+ const core_js_1 = require("../core.js");
5
+ class UnknownSchema extends core_js_1.Schema {
6
6
  validateInContext(input, ctx) {
7
7
  return ctx.success(input);
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":";;;AAAA,8CAA0E;AAE1E,MAAa,aAAc,SAAQ,mBAAe;IAChD,iBAAiB,CACf,KAAc,EACd,GAAqB;QAErB,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAPD,sCAOC","sourcesContent":["import { Schema, ValidationResult, ValidatorContext } from '../validation'\n\nexport class UnknownSchema extends Schema<unknown> {\n validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<unknown> {\n return ctx.success(input)\n }\n}\n"]}
1
+ {"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../src/schema/unknown.ts"],"names":[],"mappings":";;;AAAA,wCAAuE;AAEvE,MAAa,aAAc,SAAQ,gBAAe;IAChD,iBAAiB,CACf,KAAc,EACd,GAAqB;QAErB,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAPD,sCAOC","sourcesContent":["import { Schema, ValidationResult, ValidatorContext } from '../core.js'\n\nexport class UnknownSchema extends Schema<unknown> {\n validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<unknown> {\n return ctx.success(input)\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare function memoizedOptions<F extends (options?: NonNullable<unknown>) => any>(fn: F, keyFn?: (options: NonNullable<Parameters<F>[0]>) => string | number | boolean | null | void): F;
2
+ export declare function memoizedTransformer<F extends (arg: any) => any>(fn: F): F;
3
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/util/memoize.ts"],"names":[],"mappings":"AACA,wBAAgB,eAAe,CAC7B,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,GAAG,EAEjD,EAAE,EAAE,CAAC,EACL,KAAK,CAAC,EAAE,CACN,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KACnC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAC3C,CAAC,CAoCH;AAGD,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CASzE"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoizedOptions = memoizedOptions;
4
+ exports.memoizedTransformer = memoizedTransformer;
5
+ /*@__NO_SIDE_EFFECTS__*/
6
+ function memoizedOptions(fn, keyFn) {
7
+ let emptyOptionsValue;
8
+ if (keyFn) {
9
+ const cache = new Map();
10
+ const fromCache = (options) => {
11
+ const key = keyFn(options);
12
+ if (key !== undefined) {
13
+ const cached = cache.get(key);
14
+ if (cached)
15
+ return cached;
16
+ const result = fn(options);
17
+ cache.set(key, result);
18
+ return result;
19
+ }
20
+ return fn(options);
21
+ };
22
+ return ((options) => {
23
+ // Non-empty options case
24
+ if (options)
25
+ for (const _ in options)
26
+ return fromCache(options);
27
+ // Empty or missing options case
28
+ return (emptyOptionsValue ??= fn(options));
29
+ });
30
+ }
31
+ return ((options) => {
32
+ // Non-empty options case
33
+ if (options)
34
+ for (const _ in options)
35
+ return fn(options);
36
+ // Empty or missing options case
37
+ return (emptyOptionsValue ??= fn(options));
38
+ });
39
+ }
40
+ /*@__NO_SIDE_EFFECTS__*/
41
+ function memoizedTransformer(fn) {
42
+ const cache = new WeakMap();
43
+ return ((arg) => {
44
+ const cached = cache.get(arg);
45
+ if (cached)
46
+ return cached;
47
+ const result = fn(arg);
48
+ cache.set(arg, result);
49
+ return result;
50
+ });
51
+ }
52
+ //# sourceMappingURL=memoize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/util/memoize.ts"],"names":[],"mappings":";;AACA,0CA2CC;AAGD,kDASC;AAxDD,wBAAwB;AACxB,SAAgB,eAAe,CAG7B,EAAK,EACL,KAE4C;IAE5C,IAAI,iBAA4C,CAAA;IAEhD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmD,CAAA;QACxE,MAAM,SAAS,GAAG,CAChB,OAAsC,EACvB,EAAE;YACjB,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;YAC1B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBAC7B,IAAI,MAAM;oBAAE,OAAO,MAAM,CAAA;gBACzB,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAkB,CAAA;gBAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;gBACtB,OAAO,MAAM,CAAA;YACf,CAAC;YAED,OAAO,EAAE,CAAC,OAAO,CAAC,CAAA;QACpB,CAAC,CAAA;QAED,OAAO,CAAC,CAAC,OAAyB,EAAiB,EAAE;YACnD,yBAAyB;YACzB,IAAI,OAAO;gBAAE,KAAK,MAAM,CAAC,IAAI,OAAO;oBAAE,OAAO,SAAS,CAAC,OAAO,CAAC,CAAA;YAE/D,gCAAgC;YAChC,OAAO,CAAC,iBAAiB,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;QAC5C,CAAC,CAAM,CAAA;IACT,CAAC;IAED,OAAO,CAAC,CAAC,OAAyB,EAAiB,EAAE;QACnD,yBAAyB;QACzB,IAAI,OAAO;YAAE,KAAK,MAAM,CAAC,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC,OAAO,CAAC,CAAA;QAExD,gCAAgC;QAChC,OAAO,CAAC,iBAAiB,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5C,CAAC,CAAM,CAAA;AACT,CAAC;AAED,wBAAwB;AACxB,SAAgB,mBAAmB,CAA8B,EAAK;IACpE,MAAM,KAAK,GAAG,IAAI,OAAO,EAAyB,CAAA;IAClD,OAAO,CAAC,CAAC,GAAqB,EAAiB,EAAE;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,MAAM;YAAE,OAAO,MAAM,CAAA;QACzB,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAkB,CAAA;QACvC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACtB,OAAO,MAAM,CAAA;IACf,CAAC,CAAM,CAAA;AACT,CAAC","sourcesContent":["/*@__NO_SIDE_EFFECTS__*/\nexport function memoizedOptions<\n F extends (options?: NonNullable<unknown>) => any,\n>(\n fn: F,\n keyFn?: (\n options: NonNullable<Parameters<F>[0]>,\n ) => string | number | boolean | null | void,\n): F {\n let emptyOptionsValue: ReturnType<F> | undefined\n\n if (keyFn) {\n const cache = new Map<string | number | boolean | null, ReturnType<F>>()\n const fromCache = (\n options: NonNullable<Parameters<F>[0]>,\n ): ReturnType<F> => {\n const key = keyFn(options)\n if (key !== undefined) {\n const cached = cache.get(key)\n if (cached) return cached\n const result = fn(options) as ReturnType<F>\n cache.set(key, result)\n return result\n }\n\n return fn(options)\n }\n\n return ((options: Parameters<F>[0]): ReturnType<F> => {\n // Non-empty options case\n if (options) for (const _ in options) return fromCache(options)\n\n // Empty or missing options case\n return (emptyOptionsValue ??= fn(options))\n }) as F\n }\n\n return ((options: Parameters<F>[0]): ReturnType<F> => {\n // Non-empty options case\n if (options) for (const _ in options) return fn(options)\n\n // Empty or missing options case\n return (emptyOptionsValue ??= fn(options))\n }) as F\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function memoizedTransformer<F extends (arg: any) => any>(fn: F): F {\n const cache = new WeakMap<object, ReturnType<F>>()\n return ((arg: Parameters<F>[0]): ReturnType<F> => {\n const cached = cache.get(arg)\n if (cached) return cached\n const result = fn(arg) as ReturnType<F>\n cache.set(arg, result)\n return result\n }) as F\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/lex-schema",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "license": "MIT",
5
5
  "description": "Lexicon schema system for AT Lexicons",
6
6
  "keywords": [
@@ -28,22 +28,22 @@
28
28
  "types": "./dist/index.d.ts",
29
29
  "exports": {
30
30
  ".": {
31
+ "types": "./dist/index.d.ts",
31
32
  "browser": "./dist/index.js",
32
33
  "import": "./dist/index.js",
33
- "require": "./dist/index.js",
34
- "types": "./dist/index.d.ts"
34
+ "require": "./dist/index.js"
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
38
  "tslib": "^2.8.1",
39
39
  "@atproto/syntax": "0.4.2",
40
- "@atproto/lex-data": "0.0.4"
40
+ "@atproto/lex-data": "0.0.5"
41
41
  },
42
42
  "devDependencies": {
43
- "jest": "^28.1.2"
43
+ "vitest": "^4.0.16"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsc --build tsconfig.build.json",
47
- "test": "jest"
47
+ "test": "vitest run"
48
48
  }
49
49
  }
@@ -1,22 +1,30 @@
1
- import { ResultFailure, failureReason } from '../core.js'
1
+ import { LexError } from '@atproto/lex-data'
2
2
  import { arrayAgg } from '../util/array-agg.js'
3
+ import { ResultFailure, failureReason } from './result.js'
3
4
  import {
4
5
  Issue,
5
6
  IssueInvalidType,
6
7
  IssueInvalidValue,
7
8
  } from './validation-issue.js'
8
9
 
9
- export class ValidationError extends Error {
10
+ export class ValidationError extends LexError {
10
11
  name = 'ValidationError'
11
12
 
12
13
  readonly issues: Issue[]
13
14
 
14
15
  constructor(issues: Issue[], options?: ErrorOptions) {
15
16
  const issuesAgg = aggregateIssues(issues)
16
- super(issuesAgg.join(', '), options)
17
+ super('InvalidRequest', issuesAgg.join(', '), options)
17
18
  this.issues = issuesAgg
18
19
  }
19
20
 
21
+ toJSON() {
22
+ return {
23
+ ...super.toJSON(),
24
+ issues: this.issues.map((issue) => issue.toJSON()),
25
+ }
26
+ }
27
+
20
28
  static fromFailures(
21
29
  failures: ResultFailure<ValidationError>[],
22
30
  ): ValidationError {
@@ -9,6 +9,14 @@ export abstract class Issue {
9
9
  ) {}
10
10
 
11
11
  abstract toString(): string
12
+
13
+ toJSON() {
14
+ return {
15
+ code: this.code,
16
+ path: this.path,
17
+ message: this.toString(),
18
+ }
19
+ }
12
20
  }
13
21
 
14
22
  export class IssueCustom extends Issue {
@@ -39,6 +47,13 @@ export class IssueInvalidFormat extends Issue {
39
47
  return `Invalid ${this.formatDescription} format${this.message ? ` (${this.message})` : ''}${stringifyPath(this.path)} (got ${stringifyValue(this.input)})`
40
48
  }
41
49
 
50
+ toJSON() {
51
+ return {
52
+ ...super.toJSON(),
53
+ format: this.format,
54
+ }
55
+ }
56
+
42
57
  get formatDescription(): string {
43
58
  switch (this.format) {
44
59
  case 'at-identifier':
@@ -71,6 +86,13 @@ export class IssueInvalidType extends Issue {
71
86
  toString() {
72
87
  return `Expected ${oneOf(this.expected.map(stringifyExpectedType))} value type${stringifyPath(this.path)} (got ${stringifyType(this.input)})`
73
88
  }
89
+
90
+ toJSON() {
91
+ return {
92
+ ...super.toJSON(),
93
+ expected: this.expected,
94
+ }
95
+ }
74
96
  }
75
97
 
76
98
  export class IssueInvalidValue extends Issue {
@@ -85,6 +107,13 @@ export class IssueInvalidValue extends Issue {
85
107
  toString() {
86
108
  return `Expected ${oneOf(this.values.map(stringifyValue))}${stringifyPath(this.path)} (got ${stringifyValue(this.input)})`
87
109
  }
110
+
111
+ toJSON() {
112
+ return {
113
+ ...super.toJSON(),
114
+ values: this.values,
115
+ }
116
+ }
88
117
  }
89
118
 
90
119
  export class IssueRequiredKey extends Issue {
@@ -99,6 +128,13 @@ export class IssueRequiredKey extends Issue {
99
128
  toString() {
100
129
  return `Missing required key "${String(this.key)}"${stringifyPath(this.path)}`
101
130
  }
131
+
132
+ toJSON() {
133
+ return {
134
+ ...super.toJSON(),
135
+ key: this.key,
136
+ }
137
+ }
102
138
  }
103
139
 
104
140
  export type MeasurableType =
@@ -123,6 +159,14 @@ export class IssueTooBig extends Issue {
123
159
  toString() {
124
160
  return `${this.type} too big (maximum ${this.maximum})${stringifyPath(this.path)} (got ${this.actual})`
125
161
  }
162
+
163
+ toJSON() {
164
+ return {
165
+ ...super.toJSON(),
166
+ type: this.type,
167
+ maximum: this.maximum,
168
+ }
169
+ }
126
170
  }
127
171
 
128
172
  export class IssueTooSmall extends Issue {
@@ -139,6 +183,14 @@ export class IssueTooSmall extends Issue {
139
183
  toString() {
140
184
  return `${this.type} too small (minimum ${this.minimum})${stringifyPath(this.path)} (got ${this.actual})`
141
185
  }
186
+
187
+ toJSON() {
188
+ return {
189
+ ...super.toJSON(),
190
+ type: this.type,
191
+ minimum: this.minimum,
192
+ }
193
+ }
142
194
  }
143
195
 
144
196
  function stringifyExpectedType(expected: string): string {
@@ -1,5 +1,5 @@
1
- import { ResultFailure, ResultSuccess, failure, success } from '../core.js'
2
1
  import { PropertyKey } from './property-key.js'
2
+ import { ResultFailure, ResultSuccess, failure, success } from './result.js'
3
3
  import { ValidationError } from './validation-error.js'
4
4
  import {
5
5
  Issue,
package/src/core.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  export * from './core/$type.js'
2
+ export * from './core/property-key.js'
2
3
  export * from './core/record-key.js'
3
4
  export * from './core/result.js'
5
+ export * from './core/schema.js'
4
6
  export * from './core/string-format.js'
5
7
  export * from './core/types.js'
8
+ export * from './core/validation-error.js'
9
+ export * from './core/validation-issue.js'
10
+ export * from './core/validator.js'
package/src/external.ts CHANGED
@@ -1,4 +1,14 @@
1
- import { $Type, $TypeOf, $type, LexiconRecordKey, NsidString } from './core.js'
1
+ import {
2
+ $Type,
3
+ $TypeOf,
4
+ $type,
5
+ Infer,
6
+ LexiconRecordKey,
7
+ NsidString,
8
+ PropertyKey,
9
+ Schema,
10
+ Validator,
11
+ } from './core.js'
2
12
  import {
3
13
  ArraySchema,
4
14
  ArraySchemaOptions,
@@ -57,29 +67,25 @@ import {
57
67
  UnknownSchema,
58
68
  refine,
59
69
  } from './schema.js'
60
- import { Infer, PropertyKey, Schema, Validator } from './validation.js'
70
+ import { memoizedOptions, memoizedTransformer } from './util/memoize.js'
61
71
 
62
72
  export * from './core.js'
63
73
  export * from './helpers.js'
64
74
  export * from './schema.js'
65
- export * from './validation.js'
66
75
 
67
- /*@__NO_SIDE_EFFECTS__*/
68
- export function never() {
76
+ export { _null as null }
77
+
78
+ export const never = /*#__PURE__*/ memoizedOptions(function () {
69
79
  return new NeverSchema()
70
- }
80
+ })
71
81
 
72
- /*@__NO_SIDE_EFFECTS__*/
73
- export function unknown() {
82
+ export const unknown = /*#__PURE__*/ memoizedOptions(function () {
74
83
  return new UnknownSchema()
75
- }
84
+ })
76
85
 
77
- /*@__NO_SIDE_EFFECTS__*/
78
- export function _null() {
86
+ const _null = /*#__PURE__*/ memoizedOptions(function () {
79
87
  return new NullSchema()
80
- }
81
-
82
- export { _null as null }
88
+ })
83
89
 
84
90
  /*@__NO_SIDE_EFFECTS__*/
85
91
  export function literal<const V extends null | string | number | boolean>(
@@ -100,39 +106,45 @@ export function _enum<const V extends null | string | number | boolean>(
100
106
  // @NOTE "enum" is a reserved keyword in JS/TS
101
107
  export { _enum as enum }
102
108
 
103
- /*@__NO_SIDE_EFFECTS__*/
104
- export function boolean(options?: BooleanSchemaOptions) {
105
- return new BooleanSchema(options)
106
- }
107
-
108
- /*@__NO_SIDE_EFFECTS__*/
109
- export function integer(options?: IntegerSchemaOptions) {
109
+ export const boolean = /*#__PURE__*/ memoizedOptions(
110
+ function (options?: BooleanSchemaOptions) {
111
+ return new BooleanSchema(options)
112
+ },
113
+ (options) => {
114
+ const keys = Object.keys(options)
115
+ if (keys.length === 1 && keys[0] === 'default') return options.default!
116
+ },
117
+ )
118
+
119
+ export const integer = /*#__PURE__*/ memoizedOptions(function (
120
+ options?: IntegerSchemaOptions,
121
+ ) {
110
122
  return new IntegerSchema(options)
111
- }
123
+ })
112
124
 
113
- /*@__NO_SIDE_EFFECTS__*/
114
- export function cidLink(options?: CidSchemaOptions) {
125
+ export const cidLink = /*#__PURE__*/ memoizedOptions(function (
126
+ options?: CidSchemaOptions,
127
+ ) {
115
128
  return new CidSchema(options)
116
- }
129
+ })
117
130
 
118
- /*@__NO_SIDE_EFFECTS__*/
119
- export function bytes(options?: BytesSchemaOptions) {
131
+ export const bytes = /*#__PURE__*/ memoizedOptions(function (
132
+ options?: BytesSchemaOptions,
133
+ ) {
120
134
  return new BytesSchema(options)
121
- }
135
+ })
122
136
 
123
- /*@__NO_SIDE_EFFECTS__*/
124
- export function blob<O extends BlobSchemaOptions = NonNullable<unknown>>(
125
- options: O = {} as O,
126
- ) {
137
+ export const blob = /*#__PURE__*/ memoizedOptions(function <
138
+ O extends BlobSchemaOptions = NonNullable<unknown>,
139
+ >(options: O = {} as O) {
127
140
  return new BlobSchema(options)
128
- }
141
+ })
129
142
 
130
- /*@__NO_SIDE_EFFECTS__*/
131
- export function string<
143
+ export const string = /*#__PURE__*/ memoizedOptions(function <
132
144
  const O extends StringSchemaOptions = NonNullable<unknown>,
133
145
  >(options: StringSchemaOptions & O = {} as O) {
134
146
  return new StringSchema<O>(options)
135
- }
147
+ })
136
148
 
137
149
  /*@__NO_SIDE_EFFECTS__*/
138
150
  export function regexp<T extends string = string>(pattern: RegExp) {
@@ -171,10 +183,9 @@ export function dict<
171
183
  // Utility
172
184
  export type { UnknownObjectOutput as UnknownObject }
173
185
 
174
- /*@__NO_SIDE_EFFECTS__*/
175
- export function unknownObject() {
186
+ export const unknownObject = /*#__PURE__*/ memoizedOptions(function () {
176
187
  return new UnknownObjectSchema()
177
- }
188
+ })
178
189
 
179
190
  /*@__NO_SIDE_EFFECTS__*/
180
191
  export function ref<T>(get: RefSchemaGetter<T>) {
@@ -190,15 +201,17 @@ export function custom<T>(
190
201
  return new CustomSchema<T>(assertion, message, path)
191
202
  }
192
203
 
193
- /*@__NO_SIDE_EFFECTS__*/
194
- export function nullable<const S extends Validator>(schema: S) {
204
+ export const nullable = /*#__PURE__*/ memoizedTransformer(function <
205
+ const S extends Validator,
206
+ >(schema: S) {
195
207
  return new NullableSchema<Infer<S>>(schema)
196
- }
208
+ })
197
209
 
198
- /*@__NO_SIDE_EFFECTS__*/
199
- export function optional<const S extends Validator>(schema: S) {
210
+ export const optional = /*#__PURE__*/ memoizedTransformer(function <
211
+ const S extends Validator,
212
+ >(schema: S) {
200
213
  return new OptionalSchema<Infer<S>>(schema)
201
- }
214
+ })
202
215
 
203
216
  /*@__NO_SIDE_EFFECTS__*/
204
217
  export function union<const V extends UnionSchemaValidators>(validators: V) {
@@ -325,12 +338,11 @@ export function record<
325
338
  return new RecordSchema<K, T, S>(key, type, schema)
326
339
  }
327
340
 
328
- /*@__NO_SIDE_EFFECTS__*/
329
- export function params<
341
+ export const params = /*#__PURE__*/ memoizedOptions(function <
330
342
  const P extends ParamsSchemaShape = NonNullable<unknown>,
331
343
  >(properties: P = {} as P) {
332
344
  return new ParamsSchema<P>(properties)
333
- }
345
+ })
334
346
 
335
347
  /*@__NO_SIDE_EFFECTS__*/
336
348
  export function payload<
@@ -340,6 +352,13 @@ export function payload<
340
352
  return new Payload<E, S>(encoding, schema)
341
353
  }
342
354
 
355
+ /*@__NO_SIDE_EFFECTS__*/
356
+ export function jsonPayload<const P extends ObjectSchemaShape>(
357
+ properties: P,
358
+ ): Payload<'application/json', ObjectSchema<P>> {
359
+ return payload('application/json', object(properties))
360
+ }
361
+
343
362
  /*@__NO_SIDE_EFFECTS__*/
344
363
  export function query<
345
364
  const N extends NsidString,
@@ -1,3 +1,4 @@
1
+ import { describe, test } from 'vitest'
1
2
  import * as l from './external.js'
2
3
 
3
4
  class BinaryValue {
package/src/helpers.ts CHANGED
@@ -1,14 +1,23 @@
1
- import { Restricted } from './core.js'
1
+ import { LexErrorData } from '@atproto/lex-data'
2
+ import { Infer, Restricted, Schema } from './core.js'
2
3
  import {
3
4
  InferPayload,
4
5
  InferPayloadBody,
5
6
  InferPayloadEncoding,
7
+ ObjectSchema,
8
+ OptionalSchema,
6
9
  Payload,
7
10
  Procedure,
8
11
  Query,
12
+ StringSchema,
9
13
  Subscription,
10
14
  } from './schema.js'
11
- import { Infer, Schema } from './validation.js'
15
+
16
+ export type Main<T> = T | { main: T }
17
+
18
+ export function getMain<T extends object>(ns: Main<T>): T {
19
+ return 'main' in ns ? ns.main : ns
20
+ }
12
21
 
13
22
  /**
14
23
  * Every XRPC implementation should translate `application/json` and `text/*`
@@ -59,3 +68,8 @@ export type InferMethodMessage<
59
68
  //
60
69
  M extends Procedure | Query | Subscription,
61
70
  > = M extends { message: Schema } ? Infer<M['message']> : undefined
71
+
72
+ export const lexErrorData: Schema<LexErrorData> = new ObjectSchema({
73
+ error: new StringSchema({ minLength: 1 }),
74
+ message: new OptionalSchema(new StringSchema({})),
75
+ })
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest'
1
2
  import { paramSchema, paramsSchema } from './_parameters.js'
2
3
 
3
4
  describe('paramSchema', () => {
@@ -1,4 +1,4 @@
1
- import { Infer, Validator } from '../validation.js'
1
+ import { Infer, Validator } from '../core.js'
2
2
  import { ArraySchema } from './array.js'
3
3
  import { BooleanSchema } from './boolean.js'
4
4
  import { DictSchema } from './dict.js'
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest'
1
2
  import { ArraySchema } from './array.js'
2
3
  import { IntegerSchema } from './integer.js'
3
4
  import { ObjectSchema } from './object.js'
@@ -4,7 +4,7 @@ import {
4
4
  ValidationResult,
5
5
  Validator,
6
6
  ValidatorContext,
7
- } from '../validation.js'
7
+ } from '../core.js'
8
8
 
9
9
  export type ArraySchemaOptions = {
10
10
  minLength?: number
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest'
1
2
  import { parseCid } from '@atproto/lex-data'
2
3
  import { BlobSchema } from './blob.js'
3
4
 
@@ -4,7 +4,7 @@ import {
4
4
  isBlobRef,
5
5
  isLegacyBlobRef,
6
6
  } from '@atproto/lex-data'
7
- import { Schema, ValidationResult, ValidatorContext } from '../validation.js'
7
+ import { Schema, ValidationResult, ValidatorContext } from '../core.js'
8
8
 
9
9
  export type BlobSchemaOptions = {
10
10
  /**
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest'
1
2
  import { BooleanSchema } from './boolean.js'
2
3
 
3
4
  describe('BooleanSchema', () => {
@@ -1,4 +1,4 @@
1
- import { Schema, ValidationResult, ValidatorContext } from '../validation.js'
1
+ import { Schema, ValidationResult, ValidatorContext } from '../core.js'
2
2
 
3
3
  export type BooleanSchemaOptions = {
4
4
  default?: boolean
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest'
1
2
  import { BytesSchema } from './bytes.js'
2
3
 
3
4
  describe('BytesSchema', () => {
@@ -1,5 +1,5 @@
1
1
  import { asUint8Array } from '@atproto/lex-data'
2
- import { Schema, ValidationResult, ValidatorContext } from '../validation.js'
2
+ import { Schema, ValidationResult, ValidatorContext } from '../core.js'
3
3
 
4
4
  export type BytesSchemaOptions = {
5
5
  minLength?: number
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest'
1
2
  import { parseCid } from '@atproto/lex-data'
2
3
  import { CidSchema } from './cid.js'
3
4
 
package/src/schema/cid.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Cid, isCid } from '@atproto/lex-data'
2
- import { Schema, ValidationResult, ValidatorContext } from '../validation.js'
2
+ import { Schema, ValidationResult, ValidatorContext } from '../core.js'
3
3
 
4
4
  export type { Cid }
5
5
 
@@ -1,4 +1,5 @@
1
- import { IssueCustom } from '../validation.js'
1
+ import { describe, expect, it, vi } from 'vitest'
2
+ import { IssueCustom } from '../core.js'
2
3
  import { CustomSchema } from './custom.js'
3
4
 
4
5
  describe('CustomSchema', () => {
@@ -371,7 +372,7 @@ describe('CustomSchema', () => {
371
372
 
372
373
  describe('assertion context behavior', () => {
373
374
  it('calls assertion with null as this', () => {
374
- const assertion = jest.fn(function (
375
+ const assertion = vi.fn(function (
375
376
  this: unknown,
376
377
  input: unknown,
377
378
  ): input is string {
@@ -5,7 +5,7 @@ import {
5
5
  Schema,
6
6
  ValidationResult,
7
7
  ValidatorContext,
8
- } from '../validation.js'
8
+ } from '../core.js'
9
9
 
10
10
  export type CustomAssertionContext = {
11
11
  path: PropertyKey[]