convex 1.45.0 → 1.46.0

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 (319) hide show
  1. package/CHANGELOG.md +48 -6
  2. package/dist/browser.bundle.js +1 -1
  3. package/dist/browser.bundle.js.map +2 -2
  4. package/dist/cjs/browser/http_client.js.map +2 -2
  5. package/dist/cjs/browser/query_options.js.map +2 -2
  6. package/dist/cjs/browser/simple_client.js.map +2 -2
  7. package/dist/cjs/browser/sync/optimistic_updates.js.map +1 -1
  8. package/dist/cjs/browser/sync/optimistic_updates_impl.js.map +2 -2
  9. package/dist/cjs/cli/codegen.js +2 -0
  10. package/dist/cjs/cli/codegen.js.map +2 -2
  11. package/dist/cjs/cli/deploy.js +1 -0
  12. package/dist/cjs/cli/deploy.js.map +2 -2
  13. package/dist/cjs/cli/docs.js +3 -36
  14. package/dist/cjs/cli/docs.js.map +2 -2
  15. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +101 -60
  16. package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  17. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +107 -0
  18. package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  19. package/dist/cjs/cli/lib/codegen.js.map +2 -2
  20. package/dist/cjs/cli/lib/components.js +12 -0
  21. package/dist/cjs/cli/lib/components.js.map +2 -2
  22. package/dist/cjs/cli/lib/deploy2.js +29 -2
  23. package/dist/cjs/cli/lib/deploy2.js.map +2 -2
  24. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +73 -0
  25. package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  26. package/dist/cjs/cli/lib/deployApi/finishPush.js +1 -0
  27. package/dist/cjs/cli/lib/deployApi/finishPush.js.map +2 -2
  28. package/dist/cjs/cli/lib/deployApi/startPush.js +1 -1
  29. package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
  30. package/dist/cjs/cli/lib/dev.js +1 -0
  31. package/dist/cjs/cli/lib/dev.js.map +2 -2
  32. package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
  33. package/dist/cjs/cli/lib/localDeployment/run.js +30 -1
  34. package/dist/cjs/cli/lib/localDeployment/run.js.map +2 -2
  35. package/dist/cjs/cli/lib/localDeployment/upgrade.js +6 -5
  36. package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +2 -2
  37. package/dist/cjs/cli/lib/localDeployment/utils.js +5 -1
  38. package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
  39. package/dist/cjs/cli/lib/run.js +1 -0
  40. package/dist/cjs/cli/lib/run.js.map +2 -2
  41. package/dist/cjs/cli/lib/utils/utils.js +36 -29
  42. package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
  43. package/dist/cjs/index.js +1 -1
  44. package/dist/cjs/index.js.map +1 -1
  45. package/dist/cjs/nextjs/index.js.map +2 -2
  46. package/dist/cjs/react/client.js.map +2 -2
  47. package/dist/cjs/react/hydration.js.map +2 -2
  48. package/dist/cjs/react/queries_observer.js.map +2 -2
  49. package/dist/cjs/react/use_paginated_query2.js.map +2 -2
  50. package/dist/cjs/react/use_queries.js.map +2 -2
  51. package/dist/cjs/server/api.js.map +2 -2
  52. package/dist/cjs/server/components/index.js.map +2 -2
  53. package/dist/cjs/server/cron.js +10 -10
  54. package/dist/cjs/server/cron.js.map +2 -2
  55. package/dist/cjs/server/impl/actions_impl.js.map +2 -2
  56. package/dist/cjs/server/impl/meta_impl.js +8 -2
  57. package/dist/cjs/server/impl/meta_impl.js.map +2 -2
  58. package/dist/cjs/server/impl/scheduler_impl.js.map +2 -2
  59. package/dist/cjs/server/index.js.map +2 -2
  60. package/dist/cjs/server/meta.js.map +1 -1
  61. package/dist/cjs/server/registration.js.map +1 -1
  62. package/dist/cjs/server/scheduler.js.map +1 -1
  63. package/dist/cjs/server/schema.js +50 -3
  64. package/dist/cjs/server/schema.js.map +2 -2
  65. package/dist/cjs/values/validator.js +1 -1
  66. package/dist/cjs/values/validator.js.map +2 -2
  67. package/dist/cjs/values/validators.js +81 -25
  68. package/dist/cjs/values/validators.js.map +2 -2
  69. package/dist/cjs-types/browser/http_client.d.ts +5 -5
  70. package/dist/cjs-types/browser/http_client.d.ts.map +1 -1
  71. package/dist/cjs-types/browser/query_options.d.ts +2 -2
  72. package/dist/cjs-types/browser/query_options.d.ts.map +1 -1
  73. package/dist/cjs-types/browser/simple_client.d.ts +6 -6
  74. package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
  75. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts +4 -4
  76. package/dist/cjs-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  77. package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  78. package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
  79. package/dist/cjs-types/cli/docs.d.ts.map +1 -1
  80. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
  81. package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  82. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
  83. package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  84. package/dist/cjs-types/cli/lib/codegen.d.ts +1 -0
  85. package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
  86. package/dist/cjs-types/cli/lib/components.d.ts +1 -0
  87. package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
  88. package/dist/cjs-types/cli/lib/deploy2.d.ts +6 -0
  89. package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
  90. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
  91. package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  92. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  93. package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  94. package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
  95. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  96. package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  97. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts +2 -0
  98. package/dist/cjs-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  99. package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  100. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +1 -0
  101. package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  102. package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
  103. package/dist/cjs-types/cli/lib/utils/utils.d.ts +5 -5
  104. package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
  105. package/dist/cjs-types/index.d.ts +1 -1
  106. package/dist/cjs-types/nextjs/index.d.ts +6 -6
  107. package/dist/cjs-types/nextjs/index.d.ts.map +1 -1
  108. package/dist/cjs-types/react/client.d.ts +15 -15
  109. package/dist/cjs-types/react/client.d.ts.map +1 -1
  110. package/dist/cjs-types/react/hydration.d.ts +3 -3
  111. package/dist/cjs-types/react/hydration.d.ts.map +1 -1
  112. package/dist/cjs-types/react/queries_observer.d.ts +9 -9
  113. package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
  114. package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -1
  115. package/dist/cjs-types/react/use_queries.d.ts +14 -6
  116. package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
  117. package/dist/cjs-types/server/api.d.ts +157 -7
  118. package/dist/cjs-types/server/api.d.ts.map +1 -1
  119. package/dist/cjs-types/server/components/index.d.ts +2 -2
  120. package/dist/cjs-types/server/components/index.d.ts.map +1 -1
  121. package/dist/cjs-types/server/cron.d.ts +21 -20
  122. package/dist/cjs-types/server/cron.d.ts.map +1 -1
  123. package/dist/cjs-types/server/impl/actions_impl.d.ts +4 -4
  124. package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
  125. package/dist/cjs-types/server/impl/meta_impl.d.ts.map +1 -1
  126. package/dist/cjs-types/server/impl/scheduler_impl.d.ts.map +1 -1
  127. package/dist/cjs-types/server/index.d.ts +1 -1
  128. package/dist/cjs-types/server/index.d.ts.map +1 -1
  129. package/dist/cjs-types/server/meta.d.ts.map +1 -1
  130. package/dist/cjs-types/server/registration.d.ts +7 -7
  131. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  132. package/dist/cjs-types/server/scheduler.d.ts +9 -7
  133. package/dist/cjs-types/server/scheduler.d.ts.map +1 -1
  134. package/dist/cjs-types/server/schema.d.ts +1 -0
  135. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  136. package/dist/cjs-types/values/validator.d.ts.map +1 -1
  137. package/dist/cjs-types/values/validators.d.ts +30 -0
  138. package/dist/cjs-types/values/validators.d.ts.map +1 -1
  139. package/dist/cli.bundle.cjs +347 -133
  140. package/dist/cli.bundle.cjs.map +4 -4
  141. package/dist/esm/browser/http_client.js.map +2 -2
  142. package/dist/esm/browser/query_options.js.map +2 -2
  143. package/dist/esm/browser/simple_client.js.map +2 -2
  144. package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
  145. package/dist/esm/cli/codegen.js +2 -0
  146. package/dist/esm/cli/codegen.js.map +2 -2
  147. package/dist/esm/cli/deploy.js +1 -0
  148. package/dist/esm/cli/deploy.js.map +2 -2
  149. package/dist/esm/cli/docs.js +3 -43
  150. package/dist/esm/cli/docs.js.map +2 -2
  151. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +100 -60
  152. package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
  153. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +85 -0
  154. package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
  155. package/dist/esm/cli/lib/codegen.js.map +2 -2
  156. package/dist/esm/cli/lib/components.js +12 -0
  157. package/dist/esm/cli/lib/components.js.map +2 -2
  158. package/dist/esm/cli/lib/deploy2.js +30 -2
  159. package/dist/esm/cli/lib/deploy2.js.map +2 -2
  160. package/dist/esm/cli/lib/deployApi/evaluateSchema.js +46 -0
  161. package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +7 -0
  162. package/dist/esm/cli/lib/deployApi/finishPush.js +1 -1
  163. package/dist/esm/cli/lib/deployApi/finishPush.js.map +2 -2
  164. package/dist/esm/cli/lib/deployApi/startPush.js +1 -1
  165. package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
  166. package/dist/esm/cli/lib/dev.js +1 -0
  167. package/dist/esm/cli/lib/dev.js.map +2 -2
  168. package/dist/esm/cli/lib/localDeployment/run.js +30 -2
  169. package/dist/esm/cli/lib/localDeployment/run.js.map +2 -2
  170. package/dist/esm/cli/lib/localDeployment/upgrade.js +4 -3
  171. package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
  172. package/dist/esm/cli/lib/localDeployment/utils.js +3 -0
  173. package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
  174. package/dist/esm/cli/lib/run.js +1 -0
  175. package/dist/esm/cli/lib/run.js.map +2 -2
  176. package/dist/esm/cli/lib/utils/utils.js +36 -30
  177. package/dist/esm/cli/lib/utils/utils.js.map +2 -2
  178. package/dist/esm/index.js +1 -1
  179. package/dist/esm/index.js.map +1 -1
  180. package/dist/esm/nextjs/index.js.map +2 -2
  181. package/dist/esm/react/client.js.map +2 -2
  182. package/dist/esm/react/hydration.js +3 -1
  183. package/dist/esm/react/hydration.js.map +2 -2
  184. package/dist/esm/react/queries_observer.js +3 -1
  185. package/dist/esm/react/queries_observer.js.map +2 -2
  186. package/dist/esm/react/use_paginated_query2.js +3 -1
  187. package/dist/esm/react/use_paginated_query2.js.map +2 -2
  188. package/dist/esm/react/use_queries.js.map +2 -2
  189. package/dist/esm/server/api.js.map +2 -2
  190. package/dist/esm/server/components/index.js.map +2 -2
  191. package/dist/esm/server/cron.js +13 -11
  192. package/dist/esm/server/cron.js.map +2 -2
  193. package/dist/esm/server/impl/actions_impl.js.map +2 -2
  194. package/dist/esm/server/impl/meta_impl.js +9 -3
  195. package/dist/esm/server/impl/meta_impl.js.map +2 -2
  196. package/dist/esm/server/impl/scheduler_impl.js.map +2 -2
  197. package/dist/esm/server/index.js.map +2 -2
  198. package/dist/esm/server/schema.js +50 -3
  199. package/dist/esm/server/schema.js.map +2 -2
  200. package/dist/esm/values/validator.js +1 -1
  201. package/dist/esm/values/validator.js.map +2 -2
  202. package/dist/esm/values/validators.js +81 -25
  203. package/dist/esm/values/validators.js.map +2 -2
  204. package/dist/esm-types/browser/http_client.d.ts +5 -5
  205. package/dist/esm-types/browser/http_client.d.ts.map +1 -1
  206. package/dist/esm-types/browser/query_options.d.ts +2 -2
  207. package/dist/esm-types/browser/query_options.d.ts.map +1 -1
  208. package/dist/esm-types/browser/simple_client.d.ts +6 -6
  209. package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
  210. package/dist/esm-types/browser/sync/optimistic_updates.d.ts +4 -4
  211. package/dist/esm-types/browser/sync/optimistic_updates.d.ts.map +1 -1
  212. package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
  213. package/dist/esm-types/cli/codegen.d.ts.map +1 -1
  214. package/dist/esm-types/cli/docs.d.ts.map +1 -1
  215. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
  216. package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
  217. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
  218. package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
  219. package/dist/esm-types/cli/lib/codegen.d.ts +1 -0
  220. package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
  221. package/dist/esm-types/cli/lib/components.d.ts +1 -0
  222. package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
  223. package/dist/esm-types/cli/lib/deploy2.d.ts +6 -0
  224. package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
  225. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
  226. package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
  227. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts +1 -2
  228. package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
  229. package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
  230. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
  231. package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
  232. package/dist/esm-types/cli/lib/localDeployment/run.d.ts +2 -0
  233. package/dist/esm-types/cli/lib/localDeployment/run.d.ts.map +1 -1
  234. package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
  235. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +1 -0
  236. package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
  237. package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
  238. package/dist/esm-types/cli/lib/utils/utils.d.ts +5 -5
  239. package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
  240. package/dist/esm-types/index.d.ts +1 -1
  241. package/dist/esm-types/nextjs/index.d.ts +6 -6
  242. package/dist/esm-types/nextjs/index.d.ts.map +1 -1
  243. package/dist/esm-types/react/client.d.ts +15 -15
  244. package/dist/esm-types/react/client.d.ts.map +1 -1
  245. package/dist/esm-types/react/hydration.d.ts +3 -3
  246. package/dist/esm-types/react/hydration.d.ts.map +1 -1
  247. package/dist/esm-types/react/queries_observer.d.ts +9 -9
  248. package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
  249. package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -1
  250. package/dist/esm-types/react/use_queries.d.ts +14 -6
  251. package/dist/esm-types/react/use_queries.d.ts.map +1 -1
  252. package/dist/esm-types/server/api.d.ts +157 -7
  253. package/dist/esm-types/server/api.d.ts.map +1 -1
  254. package/dist/esm-types/server/components/index.d.ts +2 -2
  255. package/dist/esm-types/server/components/index.d.ts.map +1 -1
  256. package/dist/esm-types/server/cron.d.ts +21 -20
  257. package/dist/esm-types/server/cron.d.ts.map +1 -1
  258. package/dist/esm-types/server/impl/actions_impl.d.ts +4 -4
  259. package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
  260. package/dist/esm-types/server/impl/meta_impl.d.ts.map +1 -1
  261. package/dist/esm-types/server/impl/scheduler_impl.d.ts.map +1 -1
  262. package/dist/esm-types/server/index.d.ts +1 -1
  263. package/dist/esm-types/server/index.d.ts.map +1 -1
  264. package/dist/esm-types/server/meta.d.ts.map +1 -1
  265. package/dist/esm-types/server/registration.d.ts +7 -7
  266. package/dist/esm-types/server/registration.d.ts.map +1 -1
  267. package/dist/esm-types/server/scheduler.d.ts +9 -7
  268. package/dist/esm-types/server/scheduler.d.ts.map +1 -1
  269. package/dist/esm-types/server/schema.d.ts +1 -0
  270. package/dist/esm-types/server/schema.d.ts.map +1 -1
  271. package/dist/esm-types/values/validator.d.ts.map +1 -1
  272. package/dist/esm-types/values/validators.d.ts +30 -0
  273. package/dist/esm-types/values/validators.d.ts.map +1 -1
  274. package/dist/react.bundle.js +1 -1
  275. package/dist/react.bundle.js.map +2 -2
  276. package/package.json +5 -5
  277. package/src/browser/http_client.ts +43 -10
  278. package/src/browser/query_options.ts +11 -5
  279. package/src/browser/simple_client.ts +35 -14
  280. package/src/browser/sync/optimistic_updates.ts +17 -4
  281. package/src/browser/sync/optimistic_updates_impl.ts +17 -4
  282. package/src/cli/codegen.ts +1 -0
  283. package/src/cli/deploy.ts +1 -0
  284. package/src/cli/docs.ts +3 -44
  285. package/src/cli/lib/checkForLargeIndexDeletion.ts +154 -82
  286. package/src/cli/lib/checkForSlowSchemaValidation.ts +130 -0
  287. package/src/cli/lib/codegen.ts +1 -0
  288. package/src/cli/lib/components.ts +17 -0
  289. package/src/cli/lib/deploy2.ts +56 -1
  290. package/src/cli/lib/deployApi/evaluateSchema.ts +62 -0
  291. package/src/cli/lib/deployApi/finishPush.ts +1 -1
  292. package/src/cli/lib/deployApi/startPush.ts +1 -1
  293. package/src/cli/lib/dev.ts +1 -0
  294. package/src/cli/lib/generatedFunctionLogsApi.ts +2 -0
  295. package/src/cli/lib/localDeployment/run.ts +44 -2
  296. package/src/cli/lib/localDeployment/upgrade.ts +4 -6
  297. package/src/cli/lib/localDeployment/utils.ts +6 -0
  298. package/src/cli/lib/run.ts +1 -0
  299. package/src/cli/lib/utils/utils.ts +63 -35
  300. package/src/index.ts +1 -1
  301. package/src/nextjs/index.ts +19 -8
  302. package/src/react/client.ts +73 -30
  303. package/src/react/hydration.tsx +14 -6
  304. package/src/react/queries_observer.ts +19 -16
  305. package/src/react/use_paginated_query2.ts +10 -6
  306. package/src/react/use_queries.ts +23 -7
  307. package/src/server/api.ts +220 -14
  308. package/src/server/components/index.ts +4 -6
  309. package/src/server/cron.ts +34 -24
  310. package/src/server/impl/actions_impl.ts +13 -4
  311. package/src/server/impl/meta_impl.ts +8 -1
  312. package/src/server/impl/scheduler_impl.ts +13 -6
  313. package/src/server/index.ts +1 -0
  314. package/src/server/meta.ts +25 -0
  315. package/src/server/registration.ts +28 -7
  316. package/src/server/scheduler.ts +22 -7
  317. package/src/server/schema.ts +55 -0
  318. package/src/values/validator.ts +3 -1
  319. package/src/values/validators.ts +84 -26
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/values/validator.ts"],
4
- "sourcesContent": ["import { Expand } from \"../type_utils.js\";\nimport { GenericId } from \"./index.js\";\nimport {\n OptionalProperty,\n VAny,\n VArray,\n VBoolean,\n VBytes,\n VFloat64,\n VId,\n VCommitTs,\n VInt64,\n VLiteral,\n VNull,\n VObject,\n VOptional,\n VRecord,\n VString,\n VUnion,\n Validator,\n} from \"./validators.js\";\n\n/**\n * The type that all validators must extend.\n *\n * @public\n */\nexport type GenericValidator = Validator<any, any, any>;\n\nexport function isValidator(v: any): v is GenericValidator {\n return !!v.isConvexValidator;\n}\n\n/**\n * Coerce an object with validators as properties to a validator.\n * If a validator is passed, return it.\n *\n * @public\n */\nexport function asObjectValidator<\n V extends Validator<any, any, any> | PropertyValidators,\n>(\n obj: V,\n): V extends Validator<any, any, any>\n ? V\n : V extends PropertyValidators\n ? Validator<ObjectType<V>>\n : never {\n if (isValidator(obj)) {\n return obj as any;\n } else {\n return v.object(obj as PropertyValidators) as any;\n }\n}\n\n/**\n * Coerce an object with validators as properties to a validator.\n * If a validator is passed, return it.\n *\n * @public\n */\nexport type AsObjectValidator<\n V extends Validator<any, any, any> | PropertyValidators,\n> =\n V extends Validator<any, any, any>\n ? V\n : V extends PropertyValidators\n ? Validator<ObjectType<V>>\n : never;\n\n/**\n * The validator builder.\n *\n * This builder allows you to build validators for Convex values. Validators\n * are used in two places:\n *\n * 1. **Schema definitions** - to define the shape of documents in your tables.\n * 2. **Function arguments and return values** - to validate inputs and outputs\n * of your Convex queries, mutations, and actions.\n *\n * Always include `args` and `returns` validators on all Convex functions. If a\n * function doesn't return a value, use `returns: v.null()`.\n *\n * **Convex type reference:**\n *\n * | Convex Type | JS/TS Type | Validator |\n * |-------------|---------------|--------------------------------|\n * | Id | `string` | `v.id(\"tableName\")` |\n * | Null | `null` | `v.null()` |\n * | Float64 | `number` | `v.number()` |\n * | Int64 | `bigint` | `v.int64()` |\n * | Boolean | `boolean` | `v.boolean()` |\n * | String | `string` | `v.string()` |\n * | Bytes | `ArrayBuffer` | `v.bytes()` |\n * | Array | `Array` | `v.array(element)` |\n * | Object | `Object` | `v.object({ field: value })` |\n * | Record | `Record` | `v.record(keys, values)` |\n *\n * **Modifiers and meta-types:**\n * - `v.union(member1, member2)` - a value matching at least one validator\n * - `v.literal(\"value\")` - a specific literal string, number, bigint, or boolean\n * - `v.optional(validator)` - makes a property optional in an object (`T | undefined`)\n *\n * **Important notes:**\n * - JavaScript's `undefined` is **not** a valid Convex value. Functions that\n * return `undefined` or have no return will return `null` to the client.\n * Objects with `undefined` values will strip those keys during serialization.\n * For arrays, use an explicit `null` instead.\n * - `v.bigint()` is deprecated, use `v.int64()` instead.\n * - `v.map()` and `v.set()` are not supported. Use `v.array()` of tuples or\n * `v.record()` as alternatives.\n *\n * @example\n * ```typescript\n * import { v } from \"convex/values\";\n *\n * // Use in function definition:\n * export const createUser = mutation({\n * args: {\n * name: v.string(),\n * email: v.string(),\n * age: v.optional(v.number()),\n * },\n * returns: v.id(\"users\"),\n * handler: async (ctx, args) => {\n * return await ctx.db.insert(\"users\", args);\n * },\n * });\n * ```\n *\n * @see https://docs.convex.dev/database/types\n * @see https://docs.convex.dev/functions/validation\n * @public\n */\nexport const v = {\n /**\n * Validates that the value is a document ID for the given table.\n *\n * IDs are strings at runtime but are typed as `Id<\"tableName\">` in\n * TypeScript for type safety.\n *\n * @example\n * ```typescript\n * args: { userId: v.id(\"users\") }\n * ```\n *\n * @param tableName The name of the table.\n */\n id: <TableName extends string>(tableName: TableName) => {\n return new VId<GenericId<TableName>>({\n isOptional: \"required\",\n tableName,\n });\n },\n\n /**\n * Validates that the value is `null`.\n *\n * Use `returns: v.null()` for functions that don't return a meaningful value.\n * JavaScript `undefined` is not a valid Convex value, it is automatically\n * converted to `null`.\n */\n null: () => {\n return new VNull({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a JavaScript `number` (Convex Float64).\n *\n * Supports all IEEE-754 double-precision floating point numbers including\n * NaN and Infinity.\n *\n * Alias for `v.float64()`.\n */\n number: () => {\n return new VFloat64({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a JavaScript `number` (Convex Float64).\n *\n * Supports all IEEE-754 double-precision floating point numbers.\n */\n float64: () => {\n return new VFloat64({ isOptional: \"required\" });\n },\n\n /**\n * @deprecated Use `v.int64()` instead.\n */\n bigint: () => {\n return new VInt64({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a JavaScript `bigint` (Convex Int64).\n *\n * Supports BigInts between -2^63 and 2^63-1.\n *\n * @example\n * ```typescript\n * args: { timestamp: v.int64() }\n * // Usage: createDoc({ timestamp: 1234567890n })\n * ```\n */\n int64: () => {\n return new VInt64({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a commit timestamp: an int64 (`bigint`)\n * assigned from the transaction's commit timestamp.\n *\n * An index on a field with this validator orders documents by commit order.\n * Accepts any int64 value; write `db.vars.commitTs` to have the field\n * resolve to the commit timestamp when the mutation commits.\n */\n commitTs: () => {\n return new VCommitTs({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a `boolean`.\n */\n boolean: () => {\n return new VBoolean({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a `string`.\n *\n * Strings are stored as UTF-8 and their storage size is calculated as their\n * UTF-8 encoded size.\n */\n string: () => {\n return new VString({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is an `ArrayBuffer` (Convex Bytes).\n *\n * Use for binary data.\n */\n bytes: () => {\n return new VBytes({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is exactly equal to the given literal.\n *\n * Useful for discriminated unions and enum-like patterns.\n *\n * @example\n * ```typescript\n * // Discriminated union pattern:\n * v.union(\n * v.object({ kind: v.literal(\"error\"), message: v.string() }),\n * v.object({ kind: v.literal(\"success\"), value: v.number() }),\n * )\n * ```\n *\n * @param literal The literal value to compare against.\n */\n literal: <T extends string | number | bigint | boolean>(literal: T) => {\n return new VLiteral<T>({ isOptional: \"required\", value: literal });\n },\n\n /**\n * Validates that the value is an `Array` where every element matches the\n * given validator.\n *\n * Arrays can have at most 8192 elements.\n *\n * @example\n * ```typescript\n * args: { tags: v.array(v.string()) }\n * args: { coordinates: v.array(v.number()) }\n * args: { items: v.array(v.object({ name: v.string(), qty: v.number() })) }\n * ```\n *\n * @param element The validator for the elements of the array.\n */\n array: <T extends Validator<any, \"required\", any>>(element: T) => {\n return new VArray<T[\"type\"][], T>({ isOptional: \"required\", element });\n },\n\n /**\n * Validates that the value is an `Object` with the specified properties.\n *\n * Objects can have at most 1024 entries. Field names must be non-empty and\n * must not start with `\"$\"` or `\"_\"` (`_` is reserved for system fields\n * like `_id` and `_creationTime`; `$` is reserved for Convex internal use).\n *\n * @example\n * ```typescript\n * args: {\n * user: v.object({\n * name: v.string(),\n * email: v.string(),\n * age: v.optional(v.number()),\n * })\n * }\n * ```\n *\n * @param fields An object mapping property names to their validators.\n */\n object: <T extends PropertyValidators>(fields: T) => {\n return new VObject<ObjectType<T>, T>({ isOptional: \"required\", fields });\n },\n\n /**\n * Validates that the value is a `Record` (object with dynamic keys).\n *\n * Records are objects at runtime but allow dynamic keys, unlike `v.object()`\n * which requires known property names. Keys must be ASCII characters only,\n * non-empty, and not start with `\"$\"` or `\"_\"`.\n *\n * @example\n * ```typescript\n * // Map of user IDs to scores:\n * args: { scores: v.record(v.id(\"users\"), v.number()) }\n *\n * // Map of string keys to string values:\n * args: { metadata: v.record(v.string(), v.string()) }\n * ```\n *\n * @param keys The validator for the keys of the record.\n * @param values The validator for the values of the record.\n */\n record: <\n Key extends Validator<string, \"required\", any>,\n Value extends Validator<any, \"required\", any>,\n >(\n keys: Key,\n values: Value,\n ) => {\n return new VRecord<Record<Infer<Key>, Value[\"type\"]>, Key, Value>({\n isOptional: \"required\",\n key: keys,\n value: values,\n });\n },\n\n /**\n * Validates that the value matches at least one of the given validators.\n *\n * @example\n * ```typescript\n * // Allow string or number:\n * args: { value: v.union(v.string(), v.number()) }\n *\n * // Discriminated union (recommended pattern):\n * v.union(\n * v.object({ kind: v.literal(\"text\"), body: v.string() }),\n * v.object({ kind: v.literal(\"image\"), url: v.string() }),\n * )\n *\n * // Nullable value:\n * returns: v.union(v.object({ ... }), v.null())\n * ```\n *\n * @param members The validators to match against.\n */\n union: <T extends Validator<any, \"required\", any>[]>(...members: T) => {\n return new VUnion<T[number][\"type\"], T>({\n isOptional: \"required\",\n members,\n });\n },\n\n /**\n * A validator that accepts any Convex value without validation.\n *\n * Prefer using specific validators when possible for better type safety\n * and runtime validation.\n */\n any: () => {\n return new VAny({ isOptional: \"required\" });\n },\n\n /**\n * Makes a property optional in an object validator.\n *\n * An optional property can be omitted entirely when creating a document or\n * calling a function. This is different from `v.nullable()` which requires\n * the property to be present but allows `null`.\n *\n * @example\n * ```typescript\n * v.object({\n * name: v.string(), // required\n * nickname: v.optional(v.string()), // can be omitted\n * })\n *\n * // Valid: { name: \"Alice\" }\n * // Valid: { name: \"Alice\", nickname: \"Ali\" }\n * // Invalid: { name: \"Alice\", nickname: null } - use v.nullable() for this\n * ```\n *\n * @param value The property value validator to make optional.\n */\n optional: <T extends GenericValidator>(value: T) => {\n return value.asOptional() as VOptional<T>;\n },\n\n /**\n * Allows a value to be either the given type or `null`.\n *\n * This is shorthand for `v.union(value, v.null())`. Unlike `v.optional()`,\n * the property must still be present, but may be `null`.\n *\n * @example\n * ```typescript\n * v.object({\n * name: v.string(),\n * deletedAt: v.nullable(v.number()), // must be present, can be null\n * })\n *\n * // Valid: { name: \"Alice\", deletedAt: null }\n * // Valid: { name: \"Alice\", deletedAt: 1234567890 }\n * // Invalid: { name: \"Alice\" } - deletedAt is required\n * ```\n */\n nullable: <T extends Validator<any, \"required\", any>>(value: T) => {\n return v.union(value, v.null());\n },\n};\n\n/**\n * Validators for each property of an object.\n *\n * This is represented as an object mapping the property name to its\n * {@link Validator}.\n *\n * @public\n */\nexport type PropertyValidators = Record<\n string,\n Validator<any, OptionalProperty, any>\n>;\n\n/**\n * Compute the type of an object from {@link PropertyValidators}.\n *\n * @public\n */\nexport type ObjectType<Fields extends PropertyValidators> = Expand<\n // Map each key to the corresponding property validator's type making\n // the optional ones optional.\n {\n // This `Exclude<..., undefined>` does nothing unless\n // the tsconfig.json option `\"exactOptionalPropertyTypes\": true,`\n // is used. When it is it results in a more accurate type.\n // When it is not the `Exclude` removes `undefined` but it is\n // added again by the optional property.\n [Property in OptionalKeys<Fields>]?: Exclude<\n Infer<Fields[Property]>,\n undefined\n >;\n } & {\n [Property in RequiredKeys<Fields>]: Infer<Fields[Property]>;\n }\n>;\n\ntype OptionalKeys<PropertyValidators extends Record<string, GenericValidator>> =\n {\n [Property in keyof PropertyValidators]: PropertyValidators[Property][\"isOptional\"] extends \"optional\"\n ? Property\n : never;\n }[keyof PropertyValidators];\n\ntype RequiredKeys<PropertyValidators extends Record<string, GenericValidator>> =\n Exclude<keyof PropertyValidators, OptionalKeys<PropertyValidators>>;\n\n/**\n * Extract a TypeScript type from a validator.\n *\n * Example usage:\n * ```ts\n * const objectSchema = v.object({\n * property: v.string(),\n * });\n * type MyObject = Infer<typeof objectSchema>; // { property: string }\n * ```\n * @typeParam V - The type of a {@link Validator} constructed with {@link v}.\n *\n * @public\n */\nexport type Infer<T extends Validator<any, OptionalProperty, any>> = T[\"type\"];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAkBO;AASA,SAAS,YAAYA,IAA+B;AACzD,SAAO,CAAC,CAACA,GAAE;AACb;AAQO,SAAS,kBAGd,KAKU;AACV,MAAI,YAAY,GAAG,GAAG;AACpB,WAAO;AAAA,EACT,OAAO;AACL,WAAO,EAAE,OAAO,GAAyB;AAAA,EAC3C;AACF;AAiFO,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcf,IAAI,CAA2B,cAAyB;AACtD,WAAO,IAAI,sBAA0B;AAAA,MACnC,YAAY;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,MAAM;AACV,WAAO,IAAI,wBAAM,EAAE,YAAY,WAAW,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAQ,MAAM;AACZ,WAAO,IAAI,2BAAS,EAAE,YAAY,WAAW,CAAC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E,KAAK,CAAC;AAAA,EAChC;AACF;",
4
+ "sourcesContent": ["import { Expand } from \"../type_utils.js\";\nimport { GenericId } from \"./index.js\";\nimport {\n OptionalProperty,\n VAny,\n VArray,\n VBoolean,\n VBytes,\n VFloat64,\n VId,\n VCommitTs,\n VInt64,\n VLiteral,\n VNull,\n VObject,\n VOptional,\n VRecord,\n VString,\n VUnion,\n Validator,\n} from \"./validators.js\";\n\n/**\n * The type that all validators must extend.\n *\n * @public\n */\nexport type GenericValidator = Validator<any, any, any>;\n\nexport function isValidator(v: any): v is GenericValidator {\n // Check for the literal `true` marker: a field map can contain a field\n // *named* `isConvexValidator` whose value is a (truthy) validator object.\n return v?.isConvexValidator === true;\n}\n\n/**\n * Coerce an object with validators as properties to a validator.\n * If a validator is passed, return it.\n *\n * @public\n */\nexport function asObjectValidator<\n V extends Validator<any, any, any> | PropertyValidators,\n>(\n obj: V,\n): V extends Validator<any, any, any>\n ? V\n : V extends PropertyValidators\n ? Validator<ObjectType<V>>\n : never {\n if (isValidator(obj)) {\n return obj as any;\n } else {\n return v.object(obj as PropertyValidators) as any;\n }\n}\n\n/**\n * Coerce an object with validators as properties to a validator.\n * If a validator is passed, return it.\n *\n * @public\n */\nexport type AsObjectValidator<\n V extends Validator<any, any, any> | PropertyValidators,\n> =\n V extends Validator<any, any, any>\n ? V\n : V extends PropertyValidators\n ? Validator<ObjectType<V>>\n : never;\n\n/**\n * The validator builder.\n *\n * This builder allows you to build validators for Convex values. Validators\n * are used in two places:\n *\n * 1. **Schema definitions** - to define the shape of documents in your tables.\n * 2. **Function arguments and return values** - to validate inputs and outputs\n * of your Convex queries, mutations, and actions.\n *\n * Always include `args` and `returns` validators on all Convex functions. If a\n * function doesn't return a value, use `returns: v.null()`.\n *\n * **Convex type reference:**\n *\n * | Convex Type | JS/TS Type | Validator |\n * |-------------|---------------|--------------------------------|\n * | Id | `string` | `v.id(\"tableName\")` |\n * | Null | `null` | `v.null()` |\n * | Float64 | `number` | `v.number()` |\n * | Int64 | `bigint` | `v.int64()` |\n * | Boolean | `boolean` | `v.boolean()` |\n * | String | `string` | `v.string()` |\n * | Bytes | `ArrayBuffer` | `v.bytes()` |\n * | Array | `Array` | `v.array(element)` |\n * | Object | `Object` | `v.object({ field: value })` |\n * | Record | `Record` | `v.record(keys, values)` |\n *\n * **Modifiers and meta-types:**\n * - `v.union(member1, member2)` - a value matching at least one validator\n * - `v.literal(\"value\")` - a specific literal string, number, bigint, or boolean\n * - `v.optional(validator)` - makes a property optional in an object (`T | undefined`)\n *\n * **Important notes:**\n * - JavaScript's `undefined` is **not** a valid Convex value. Functions that\n * return `undefined` or have no return will return `null` to the client.\n * Objects with `undefined` values will strip those keys during serialization.\n * For arrays, use an explicit `null` instead.\n * - `v.bigint()` is deprecated, use `v.int64()` instead.\n * - `v.map()` and `v.set()` are not supported. Use `v.array()` of tuples or\n * `v.record()` as alternatives.\n *\n * @example\n * ```typescript\n * import { v } from \"convex/values\";\n *\n * // Use in function definition:\n * export const createUser = mutation({\n * args: {\n * name: v.string(),\n * email: v.string(),\n * age: v.optional(v.number()),\n * },\n * returns: v.id(\"users\"),\n * handler: async (ctx, args) => {\n * return await ctx.db.insert(\"users\", args);\n * },\n * });\n * ```\n *\n * @see https://docs.convex.dev/database/types\n * @see https://docs.convex.dev/functions/validation\n * @public\n */\nexport const v = {\n /**\n * Validates that the value is a document ID for the given table.\n *\n * IDs are strings at runtime but are typed as `Id<\"tableName\">` in\n * TypeScript for type safety.\n *\n * @example\n * ```typescript\n * args: { userId: v.id(\"users\") }\n * ```\n *\n * @param tableName The name of the table.\n */\n id: <TableName extends string>(tableName: TableName) => {\n return new VId<GenericId<TableName>>({\n isOptional: \"required\",\n tableName,\n });\n },\n\n /**\n * Validates that the value is `null`.\n *\n * Use `returns: v.null()` for functions that don't return a meaningful value.\n * JavaScript `undefined` is not a valid Convex value, it is automatically\n * converted to `null`.\n */\n null: () => {\n return new VNull({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a JavaScript `number` (Convex Float64).\n *\n * Supports all IEEE-754 double-precision floating point numbers including\n * NaN and Infinity.\n *\n * Alias for `v.float64()`.\n */\n number: () => {\n return new VFloat64({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a JavaScript `number` (Convex Float64).\n *\n * Supports all IEEE-754 double-precision floating point numbers.\n */\n float64: () => {\n return new VFloat64({ isOptional: \"required\" });\n },\n\n /**\n * @deprecated Use `v.int64()` instead.\n */\n bigint: () => {\n return new VInt64({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a JavaScript `bigint` (Convex Int64).\n *\n * Supports BigInts between -2^63 and 2^63-1.\n *\n * @example\n * ```typescript\n * args: { timestamp: v.int64() }\n * // Usage: createDoc({ timestamp: 1234567890n })\n * ```\n */\n int64: () => {\n return new VInt64({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a commit timestamp: an int64 (`bigint`)\n * assigned from the transaction's commit timestamp.\n *\n * An index on a field with this validator orders documents by commit order.\n * Accepts any int64 value; write `db.vars.commitTs` to have the field\n * resolve to the commit timestamp when the mutation commits.\n */\n commitTs: () => {\n return new VCommitTs({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a `boolean`.\n */\n boolean: () => {\n return new VBoolean({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is a `string`.\n *\n * Strings are stored as UTF-8 and their storage size is calculated as their\n * UTF-8 encoded size.\n */\n string: () => {\n return new VString({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is an `ArrayBuffer` (Convex Bytes).\n *\n * Use for binary data.\n */\n bytes: () => {\n return new VBytes({ isOptional: \"required\" });\n },\n\n /**\n * Validates that the value is exactly equal to the given literal.\n *\n * Useful for discriminated unions and enum-like patterns.\n *\n * @example\n * ```typescript\n * // Discriminated union pattern:\n * v.union(\n * v.object({ kind: v.literal(\"error\"), message: v.string() }),\n * v.object({ kind: v.literal(\"success\"), value: v.number() }),\n * )\n * ```\n *\n * @param literal The literal value to compare against.\n */\n literal: <T extends string | number | bigint | boolean>(literal: T) => {\n return new VLiteral<T>({ isOptional: \"required\", value: literal });\n },\n\n /**\n * Validates that the value is an `Array` where every element matches the\n * given validator.\n *\n * Arrays can have at most 8192 elements.\n *\n * @example\n * ```typescript\n * args: { tags: v.array(v.string()) }\n * args: { coordinates: v.array(v.number()) }\n * args: { items: v.array(v.object({ name: v.string(), qty: v.number() })) }\n * ```\n *\n * @param element The validator for the elements of the array.\n */\n array: <T extends Validator<any, \"required\", any>>(element: T) => {\n return new VArray<T[\"type\"][], T>({ isOptional: \"required\", element });\n },\n\n /**\n * Validates that the value is an `Object` with the specified properties.\n *\n * Objects can have at most 1024 entries. Field names must be non-empty and\n * must not start with `\"$\"` or `\"_\"` (`_` is reserved for system fields\n * like `_id` and `_creationTime`; `$` is reserved for Convex internal use).\n *\n * @example\n * ```typescript\n * args: {\n * user: v.object({\n * name: v.string(),\n * email: v.string(),\n * age: v.optional(v.number()),\n * })\n * }\n * ```\n *\n * @param fields An object mapping property names to their validators.\n */\n object: <T extends PropertyValidators>(fields: T) => {\n return new VObject<ObjectType<T>, T>({ isOptional: \"required\", fields });\n },\n\n /**\n * Validates that the value is a `Record` (object with dynamic keys).\n *\n * Records are objects at runtime but allow dynamic keys, unlike `v.object()`\n * which requires known property names. Keys must be ASCII characters only,\n * non-empty, and not start with `\"$\"` or `\"_\"`.\n *\n * @example\n * ```typescript\n * // Map of user IDs to scores:\n * args: { scores: v.record(v.id(\"users\"), v.number()) }\n *\n * // Map of string keys to string values:\n * args: { metadata: v.record(v.string(), v.string()) }\n * ```\n *\n * @param keys The validator for the keys of the record.\n * @param values The validator for the values of the record.\n */\n record: <\n Key extends Validator<string, \"required\", any>,\n Value extends Validator<any, \"required\", any>,\n >(\n keys: Key,\n values: Value,\n ) => {\n return new VRecord<Record<Infer<Key>, Value[\"type\"]>, Key, Value>({\n isOptional: \"required\",\n key: keys,\n value: values,\n });\n },\n\n /**\n * Validates that the value matches at least one of the given validators.\n *\n * @example\n * ```typescript\n * // Allow string or number:\n * args: { value: v.union(v.string(), v.number()) }\n *\n * // Discriminated union (recommended pattern):\n * v.union(\n * v.object({ kind: v.literal(\"text\"), body: v.string() }),\n * v.object({ kind: v.literal(\"image\"), url: v.string() }),\n * )\n *\n * // Nullable value:\n * returns: v.union(v.object({ ... }), v.null())\n * ```\n *\n * @param members The validators to match against.\n */\n union: <T extends Validator<any, \"required\", any>[]>(...members: T) => {\n return new VUnion<T[number][\"type\"], T>({\n isOptional: \"required\",\n members,\n });\n },\n\n /**\n * A validator that accepts any Convex value without validation.\n *\n * Prefer using specific validators when possible for better type safety\n * and runtime validation.\n */\n any: () => {\n return new VAny({ isOptional: \"required\" });\n },\n\n /**\n * Makes a property optional in an object validator.\n *\n * An optional property can be omitted entirely when creating a document or\n * calling a function. This is different from `v.nullable()` which requires\n * the property to be present but allows `null`.\n *\n * @example\n * ```typescript\n * v.object({\n * name: v.string(), // required\n * nickname: v.optional(v.string()), // can be omitted\n * })\n *\n * // Valid: { name: \"Alice\" }\n * // Valid: { name: \"Alice\", nickname: \"Ali\" }\n * // Invalid: { name: \"Alice\", nickname: null } - use v.nullable() for this\n * ```\n *\n * @param value The property value validator to make optional.\n */\n optional: <T extends GenericValidator>(value: T) => {\n return value.asOptional() as VOptional<T>;\n },\n\n /**\n * Allows a value to be either the given type or `null`.\n *\n * This is shorthand for `v.union(value, v.null())`. Unlike `v.optional()`,\n * the property must still be present, but may be `null`.\n *\n * @example\n * ```typescript\n * v.object({\n * name: v.string(),\n * deletedAt: v.nullable(v.number()), // must be present, can be null\n * })\n *\n * // Valid: { name: \"Alice\", deletedAt: null }\n * // Valid: { name: \"Alice\", deletedAt: 1234567890 }\n * // Invalid: { name: \"Alice\" } - deletedAt is required\n * ```\n */\n nullable: <T extends Validator<any, \"required\", any>>(value: T) => {\n return v.union(value, v.null());\n },\n};\n\n/**\n * Validators for each property of an object.\n *\n * This is represented as an object mapping the property name to its\n * {@link Validator}.\n *\n * @public\n */\nexport type PropertyValidators = Record<\n string,\n Validator<any, OptionalProperty, any>\n>;\n\n/**\n * Compute the type of an object from {@link PropertyValidators}.\n *\n * @public\n */\nexport type ObjectType<Fields extends PropertyValidators> = Expand<\n // Map each key to the corresponding property validator's type making\n // the optional ones optional.\n {\n // This `Exclude<..., undefined>` does nothing unless\n // the tsconfig.json option `\"exactOptionalPropertyTypes\": true,`\n // is used. When it is it results in a more accurate type.\n // When it is not the `Exclude` removes `undefined` but it is\n // added again by the optional property.\n [Property in OptionalKeys<Fields>]?: Exclude<\n Infer<Fields[Property]>,\n undefined\n >;\n } & {\n [Property in RequiredKeys<Fields>]: Infer<Fields[Property]>;\n }\n>;\n\ntype OptionalKeys<PropertyValidators extends Record<string, GenericValidator>> =\n {\n [Property in keyof PropertyValidators]: PropertyValidators[Property][\"isOptional\"] extends \"optional\"\n ? Property\n : never;\n }[keyof PropertyValidators];\n\ntype RequiredKeys<PropertyValidators extends Record<string, GenericValidator>> =\n Exclude<keyof PropertyValidators, OptionalKeys<PropertyValidators>>;\n\n/**\n * Extract a TypeScript type from a validator.\n *\n * Example usage:\n * ```ts\n * const objectSchema = v.object({\n * property: v.string(),\n * });\n * type MyObject = Infer<typeof objectSchema>; // { property: string }\n * ```\n * @typeParam V - The type of a {@link Validator} constructed with {@link v}.\n *\n * @public\n */\nexport type Infer<T extends Validator<any, OptionalProperty, any>> = T[\"type\"];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAkBO;AASA,SAAS,YAAYA,IAA+B;AAGzD,SAAOA,IAAG,sBAAsB;AAClC;AAQO,SAAS,kBAGd,KAKU;AACV,MAAI,YAAY,GAAG,GAAG;AACpB,WAAO;AAAA,EACT,OAAO;AACL,WAAO,EAAE,OAAO,GAAyB;AAAA,EAC3C;AACF;AAiFO,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBA,UAAU,CAA6B,UAAa;AAClD,WAAO,MAAM,WAAW;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,UAAU,CAA4C,UAAa;AACjE,WAAO,EAAE,MAAM,OAAO,EAAE,KAAK,CAAC;AAAA,EAChC;AACF;",
6
6
  "names": ["v"]
7
7
  }
@@ -94,13 +94,17 @@ class VId extends BaseValidator {
94
94
  get json() {
95
95
  return { type: "id", tableName: this.tableName };
96
96
  }
97
- /** @internal */
98
- asOptional() {
97
+ /** Allow this field to be validated as absent. */
98
+ optional() {
99
99
  return new VId({
100
100
  isOptional: "optional",
101
101
  tableName: this.tableName
102
102
  });
103
103
  }
104
+ /** @internal */
105
+ asOptional() {
106
+ return this.optional();
107
+ }
104
108
  }
105
109
  class VFloat64 extends BaseValidator {
106
110
  constructor() {
@@ -114,12 +118,16 @@ class VFloat64 extends BaseValidator {
114
118
  get json() {
115
119
  return { type: "number" };
116
120
  }
117
- /** @internal */
118
- asOptional() {
121
+ /** Allow this field to be validated as absent. */
122
+ optional() {
119
123
  return new VFloat64({
120
124
  isOptional: "optional"
121
125
  });
122
126
  }
127
+ /** @internal */
128
+ asOptional() {
129
+ return this.optional();
130
+ }
123
131
  }
124
132
  class VInt64 extends BaseValidator {
125
133
  constructor() {
@@ -133,9 +141,13 @@ class VInt64 extends BaseValidator {
133
141
  get json() {
134
142
  return { type: "bigint" };
135
143
  }
144
+ /** Allow this validated field to be absent. */
145
+ optional() {
146
+ return new VInt64({ isOptional: "optional" });
147
+ }
136
148
  /** @internal */
137
149
  asOptional() {
138
- return new VInt64({ isOptional: "optional" });
150
+ return this.optional();
139
151
  }
140
152
  }
141
153
  class VCommitTs extends BaseValidator {
@@ -150,12 +162,16 @@ class VCommitTs extends BaseValidator {
150
162
  get json() {
151
163
  return { type: this.kind };
152
164
  }
153
- /** @internal */
154
- asOptional() {
165
+ /** Allow this validated field to be absent. */
166
+ optional() {
155
167
  return new VCommitTs({
156
168
  isOptional: "optional"
157
169
  });
158
170
  }
171
+ /** @internal */
172
+ asOptional() {
173
+ return this.optional();
174
+ }
159
175
  }
160
176
  class VBoolean extends BaseValidator {
161
177
  constructor() {
@@ -169,12 +185,16 @@ class VBoolean extends BaseValidator {
169
185
  get json() {
170
186
  return { type: this.kind };
171
187
  }
172
- /** @internal */
173
- asOptional() {
188
+ /** Allow this validated field to be absent. */
189
+ optional() {
174
190
  return new VBoolean({
175
191
  isOptional: "optional"
176
192
  });
177
193
  }
194
+ /** @internal */
195
+ asOptional() {
196
+ return this.optional();
197
+ }
178
198
  }
179
199
  class VBytes extends BaseValidator {
180
200
  constructor() {
@@ -188,9 +208,13 @@ class VBytes extends BaseValidator {
188
208
  get json() {
189
209
  return { type: this.kind };
190
210
  }
211
+ /** Allow this validated field to be absent. */
212
+ optional() {
213
+ return new VBytes({ isOptional: "optional" });
214
+ }
191
215
  /** @internal */
192
216
  asOptional() {
193
- return new VBytes({ isOptional: "optional" });
217
+ return this.optional();
194
218
  }
195
219
  }
196
220
  class VString extends BaseValidator {
@@ -205,12 +229,16 @@ class VString extends BaseValidator {
205
229
  get json() {
206
230
  return { type: this.kind };
207
231
  }
208
- /** @internal */
209
- asOptional() {
232
+ /** Allow this validated field to be absent. */
233
+ optional() {
210
234
  return new VString({
211
235
  isOptional: "optional"
212
236
  });
213
237
  }
238
+ /** @internal */
239
+ asOptional() {
240
+ return this.optional();
241
+ }
214
242
  }
215
243
  class VNull extends BaseValidator {
216
244
  constructor() {
@@ -224,9 +252,13 @@ class VNull extends BaseValidator {
224
252
  get json() {
225
253
  return { type: this.kind };
226
254
  }
255
+ /** Allow this validated field to be absent. */
256
+ optional() {
257
+ return new VNull({ isOptional: "optional" });
258
+ }
227
259
  /** @internal */
228
260
  asOptional() {
229
- return new VNull({ isOptional: "optional" });
261
+ return this.optional();
230
262
  }
231
263
  }
232
264
  class VAny extends BaseValidator {
@@ -243,12 +275,16 @@ class VAny extends BaseValidator {
243
275
  type: this.kind
244
276
  };
245
277
  }
246
- /** @internal */
247
- asOptional() {
278
+ /** Allow this validated field to be absent. */
279
+ optional() {
248
280
  return new VAny({
249
281
  isOptional: "optional"
250
282
  });
251
283
  }
284
+ /** @internal */
285
+ asOptional() {
286
+ return this.optional();
287
+ }
252
288
  }
253
289
  class VObject extends BaseValidator {
254
290
  /**
@@ -292,13 +328,17 @@ class VObject extends BaseValidator {
292
328
  )
293
329
  };
294
330
  }
295
- /** @internal */
296
- asOptional() {
331
+ /** Allow this validated field to be absent. */
332
+ optional() {
297
333
  return new VObject({
298
334
  isOptional: "optional",
299
335
  fields: this.fields
300
336
  });
301
337
  }
338
+ /** @internal */
339
+ asOptional() {
340
+ return this.optional();
341
+ }
302
342
  /**
303
343
  * Create a new VObject with the specified fields omitted.
304
344
  * @param fields The field names to omit from this VObject.
@@ -377,13 +417,17 @@ class VLiteral extends BaseValidator {
377
417
  value: (0, import_value.convexToJson)(this.value)
378
418
  };
379
419
  }
380
- /** @internal */
381
- asOptional() {
420
+ /** Allow this validated field to be absent. */
421
+ optional() {
382
422
  return new VLiteral({
383
423
  isOptional: "optional",
384
424
  value: this.value
385
425
  });
386
426
  }
427
+ /** @internal */
428
+ asOptional() {
429
+ return this.optional();
430
+ }
387
431
  }
388
432
  class VArray extends BaseValidator {
389
433
  /**
@@ -414,13 +458,17 @@ class VArray extends BaseValidator {
414
458
  value: this.element.json
415
459
  };
416
460
  }
417
- /** @internal */
418
- asOptional() {
461
+ /** Allow this validated field to be absent. */
462
+ optional() {
419
463
  return new VArray({
420
464
  isOptional: "optional",
421
465
  element: this.element
422
466
  });
423
467
  }
468
+ /** @internal */
469
+ asOptional() {
470
+ return this.optional();
471
+ }
424
472
  }
425
473
  class VRecord extends BaseValidator {
426
474
  /**
@@ -474,14 +522,18 @@ class VRecord extends BaseValidator {
474
522
  }
475
523
  };
476
524
  }
477
- /** @internal */
478
- asOptional() {
525
+ /** Allow this validated field to be absent. */
526
+ optional() {
479
527
  return new VRecord({
480
528
  isOptional: "optional",
481
529
  key: this.key,
482
530
  value: this.value
483
531
  });
484
532
  }
533
+ /** @internal */
534
+ asOptional() {
535
+ return this.optional();
536
+ }
485
537
  }
486
538
  class VUnion extends BaseValidator {
487
539
  /**
@@ -514,12 +566,16 @@ class VUnion extends BaseValidator {
514
566
  value: this.members.map((v) => v.json)
515
567
  };
516
568
  }
517
- /** @internal */
518
- asOptional() {
569
+ /** Allow this validated field to be absent. */
570
+ optional() {
519
571
  return new VUnion({
520
572
  isOptional: "optional",
521
573
  members: this.members
522
574
  });
523
575
  }
576
+ /** @internal */
577
+ asOptional() {
578
+ return this.optional();
579
+ }
524
580
  }
525
581
  //# sourceMappingURL=validators.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/values/validators.ts"],
4
- "sourcesContent": ["import { Expand } from \"../type_utils.js\";\nimport { GenericId } from \"./index.js\";\nimport { GenericValidator, ObjectType } from \"./validator.js\";\nimport { CommitTsPlaceholder, JSONValue, convexToJson } from \"./value.js\";\n\ntype TableNameFromType<T> =\n T extends GenericId<infer TableName> ? TableName : string;\n\nconst UNDEFINED_VALIDATOR_ERROR_URL =\n \"https://docs.convex.dev/error#undefined-validator\";\n\nfunction throwUndefinedValidatorError(\n context: string,\n fieldName?: string,\n): never {\n const fieldInfo = fieldName !== undefined ? ` for field \"${fieldName}\"` : \"\";\n throw new Error(\n `A validator is undefined${fieldInfo} in ${context}. ` +\n `This is often caused by circular imports. ` +\n `See ${UNDEFINED_VALIDATOR_ERROR_URL} for details.`,\n );\n}\n\n/**\n * Avoid using `instanceof BaseValidator`; this is inheritence for code reuse\n * not type heirarchy.\n */\nabstract class BaseValidator<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = never,\n> {\n /**\n * Only for TypeScript, the TS type of the JS values validated\n * by this validator.\n */\n readonly type!: Type;\n /**\n * Only for TypeScript, if this an Object validator, then\n * this is the TS type of its property names.\n */\n readonly fieldPaths!: FieldPaths;\n\n /**\n * Whether this is an optional Object property value validator.\n */\n readonly isOptional: IsOptional;\n\n /**\n * Always `\"true\"`.\n */\n readonly isConvexValidator: true;\n\n constructor({ isOptional }: { isOptional: IsOptional }) {\n this.isOptional = isOptional;\n this.isConvexValidator = true;\n }\n /** @internal */\n abstract get json(): ValidatorJSON;\n /** @internal */\n abstract asOptional(): Validator<Type | undefined, \"optional\", FieldPaths>;\n}\n\n/**\n * The type of the `v.id(tableName)` validator.\n */\nexport class VId<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The name of the table that the validated IDs must belong to.\n */\n readonly tableName: TableNameFromType<Type>;\n\n /**\n * The kind of validator, `\"id\"`.\n */\n readonly kind = \"id\" as const;\n\n /**\n * Usually you'd use `v.id(tableName)` instead.\n */\n constructor({\n isOptional,\n tableName,\n }: {\n isOptional: IsOptional;\n tableName: TableNameFromType<Type>;\n }) {\n super({ isOptional });\n if (typeof tableName !== \"string\") {\n throw new Error(\"v.id(tableName) requires a string\");\n }\n this.tableName = tableName;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return { type: \"id\", tableName: this.tableName };\n }\n /** @internal */\n asOptional() {\n return new VId<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n tableName: this.tableName,\n });\n }\n}\n\n/**\n * The type of the `v.float64()` validator.\n */\nexport class VFloat64<\n Type = number,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"float64\"`.\n */\n readonly kind = \"float64\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n // Server expects the old name `number` string instead of `float64`.\n return { type: \"number\" };\n }\n /** @internal */\n asOptional() {\n return new VFloat64<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n}\n\n/**\n * The type of the `v.int64()` validator.\n */\nexport class VInt64<\n Type = bigint,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"int64\"`.\n */\n readonly kind = \"int64\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n // Server expects the old name `bigint`.\n return { type: \"bigint\" };\n }\n /** @internal */\n asOptional() {\n return new VInt64<Type | undefined, \"optional\">({ isOptional: \"optional\" });\n }\n}\n\n/**\n * The type of the `v.commitTs()` validator.\n */\nexport class VCommitTs<\n Type = bigint | CommitTsPlaceholder,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"commitTs\"`.\n */\n readonly kind = \"commitTs\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** @internal */\n asOptional() {\n return new VCommitTs<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n}\n\n/**\n * The type of the `v.boolean()` validator.\n */\nexport class VBoolean<\n Type = boolean,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"boolean\"`.\n */\n readonly kind = \"boolean\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** @internal */\n asOptional() {\n return new VBoolean<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n}\n\n/**\n * The type of the `v.bytes()` validator.\n */\nexport class VBytes<\n Type = ArrayBuffer,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"bytes\"`.\n */\n readonly kind = \"bytes\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** @internal */\n asOptional() {\n return new VBytes<Type | undefined, \"optional\">({ isOptional: \"optional\" });\n }\n}\n\n/**\n * The type of the `v.string()` validator.\n */\nexport class VString<\n Type = string,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"string\"`.\n */\n readonly kind = \"string\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** @internal */\n asOptional() {\n return new VString<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n}\n\n/**\n * The type of the `v.null()` validator.\n */\nexport class VNull<\n Type = null,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"null\"`.\n */\n readonly kind = \"null\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** @internal */\n asOptional() {\n return new VNull<Type | undefined, \"optional\">({ isOptional: \"optional\" });\n }\n}\n\n/**\n * The type of the `v.any()` validator.\n */\nexport class VAny<\n Type = any,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = string,\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * The kind of validator, `\"any\"`.\n */\n readonly kind = \"any\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n };\n }\n /** @internal */\n asOptional() {\n return new VAny<Type | undefined, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n });\n }\n}\n\n/**\n * The type of the `v.object()` validator.\n */\nexport class VObject<\n Type,\n Fields extends Record<string, GenericValidator>,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = {\n [Property in keyof Fields]:\n | JoinFieldPaths<Property & string, Fields[Property][\"fieldPaths\"]>\n | Property;\n }[keyof Fields] &\n string,\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * An object with the validator for each property.\n */\n readonly fields: Fields;\n\n /**\n * The kind of validator, `\"object\"`.\n */\n readonly kind = \"object\" as const;\n\n /**\n * Usually you'd use `v.object({ ... })` instead.\n */\n constructor({\n isOptional,\n fields,\n }: {\n isOptional: IsOptional;\n fields: Fields;\n }) {\n super({ isOptional });\n globalThis.Object.entries(fields).forEach(([fieldName, validator]) => {\n if (validator === undefined) {\n throwUndefinedValidatorError(\"v.object()\", fieldName);\n }\n if (!validator.isConvexValidator) {\n throw new Error(\"v.object() entries must be validators\");\n }\n });\n this.fields = fields;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: globalThis.Object.fromEntries(\n globalThis.Object.entries(this.fields).map(([k, v]) => [\n k,\n {\n fieldType: v.json,\n optional: v.isOptional === \"optional\" ? true : false,\n },\n ]),\n ),\n };\n }\n /** @internal */\n asOptional() {\n return new VObject<Type | undefined, Fields, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n fields: this.fields,\n });\n }\n\n /**\n * Create a new VObject with the specified fields omitted.\n * @param fields The field names to omit from this VObject.\n */\n omit<K extends keyof Fields & string>(\n ...fields: K[]\n ): VObject<Expand<Omit<Type, K>>, Expand<Omit<Fields, K>>, IsOptional> {\n const newFields = { ...this.fields };\n for (const field of fields) {\n delete newFields[field];\n }\n return new VObject({\n isOptional: this.isOptional,\n fields: newFields as any,\n });\n }\n\n /**\n * Create a new VObject with only the specified fields.\n * @param fields The field names to pick from this VObject.\n */\n pick<K extends keyof Fields & string>(\n ...fields: K[]\n ): VObject<\n Expand<Pick<Type, Extract<keyof Type, K>>>,\n Expand<Pick<Fields, K>>,\n IsOptional\n > {\n const newFields: Record<string, GenericValidator> = {};\n for (const field of fields) {\n newFields[field] = this.fields[field];\n }\n return new VObject({\n isOptional: this.isOptional,\n fields: newFields as Expand<Pick<Fields, K>>,\n });\n }\n\n /**\n * Create a new VObject with all fields marked as optional.\n */\n partial(): VObject<\n { [K in keyof Type]?: Type[K] },\n { [K in keyof Fields]: VOptional<Fields[K]> },\n IsOptional\n > {\n const newFields: Record<string, GenericValidator> = {};\n for (const [key, validator] of globalThis.Object.entries(this.fields)) {\n newFields[key] = validator.asOptional();\n }\n return new VObject({\n isOptional: this.isOptional,\n fields: newFields as {\n [K in keyof Fields]: VOptional<Fields[K]>;\n },\n });\n }\n\n /**\n * Create a new VObject with additional fields merged in.\n * @param fields An object with additional validators to merge into this VObject.\n */\n extend<NewFields extends Record<string, GenericValidator>>(\n fields: NewFields,\n ): VObject<\n Expand<Type & ObjectType<NewFields>>,\n Expand<Fields & NewFields>,\n IsOptional\n > {\n return new VObject({\n isOptional: this.isOptional,\n fields: { ...this.fields, ...fields } as Expand<Fields & NewFields>,\n });\n }\n}\n\n/**\n * The type of the `v.literal()` validator.\n */\nexport class VLiteral<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The value that the validated values must be equal to.\n */\n readonly value: Type;\n\n /**\n * The kind of validator, `\"literal\"`.\n */\n readonly kind = \"literal\" as const;\n\n /**\n * Usually you'd use `v.literal(value)` instead.\n */\n constructor({ isOptional, value }: { isOptional: IsOptional; value: Type }) {\n super({ isOptional });\n if (\n typeof value !== \"string\" &&\n typeof value !== \"boolean\" &&\n typeof value !== \"number\" &&\n typeof value !== \"bigint\"\n ) {\n throw new Error(\"v.literal(value) must be a string, number, or boolean\");\n }\n this.value = value;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: convexToJson(this.value as string | boolean | number | bigint),\n };\n }\n /** @internal */\n asOptional() {\n return new VLiteral<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n value: this.value,\n });\n }\n}\n\n/**\n * The type of the `v.array()` validator.\n */\nexport class VArray<\n Type,\n Element extends Validator<any, \"required\", any>,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The validator for the elements of the array.\n */\n readonly element: Element;\n\n /**\n * The kind of validator, `\"array\"`.\n */\n readonly kind = \"array\" as const;\n\n /**\n * Usually you'd use `v.array(element)` instead.\n */\n constructor({\n isOptional,\n element,\n }: {\n isOptional: IsOptional;\n element: Element;\n }) {\n super({ isOptional });\n if (element === undefined) {\n throwUndefinedValidatorError(\"v.array()\");\n }\n this.element = element;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: this.element.json,\n };\n }\n /** @internal */\n asOptional() {\n return new VArray<Type | undefined, Element, \"optional\">({\n isOptional: \"optional\",\n element: this.element,\n });\n }\n}\n\n/**\n * The type of the `v.record()` validator.\n */\nexport class VRecord<\n Type,\n Key extends Validator<string, \"required\", any>,\n Value extends Validator<any, \"required\", any>,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = string,\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * The validator for the keys of the record.\n */\n readonly key: Key;\n\n /**\n * The validator for the values of the record.\n */\n readonly value: Value;\n\n /**\n * The kind of validator, `\"record\"`.\n */\n readonly kind = \"record\" as const;\n\n /**\n * Usually you'd use `v.record(key, value)` instead.\n */\n constructor({\n isOptional,\n key,\n value,\n }: {\n isOptional: IsOptional;\n key: Key;\n value: Value;\n }) {\n super({ isOptional });\n if (key === undefined) {\n throwUndefinedValidatorError(\"v.record()\", \"key\");\n }\n if (value === undefined) {\n throwUndefinedValidatorError(\"v.record()\", \"value\");\n }\n if ((key.isOptional as OptionalProperty) === \"optional\") {\n throw new Error(\"Record validator cannot have optional keys\");\n }\n if ((value.isOptional as OptionalProperty) === \"optional\") {\n throw new Error(\"Record validator cannot have optional values\");\n }\n if (!key.isConvexValidator || !value.isConvexValidator) {\n throw new Error(\"Key and value of v.record() but be validators\");\n }\n this.key = key;\n this.value = value;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n // This cast is needed because TypeScript thinks the key type is too wide\n keys: this.key.json as RecordKeyValidatorJSON,\n values: {\n fieldType: this.value.json,\n optional: false,\n },\n };\n }\n /** @internal */\n asOptional() {\n return new VRecord<Type | undefined, Key, Value, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n key: this.key,\n value: this.value,\n });\n }\n}\n\n/**\n * The type of the `v.union()` validator.\n */\nexport class VUnion<\n Type,\n T extends Validator<any, \"required\", any>[],\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = T[number][\"fieldPaths\"],\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * The array of validators, one of which must match the value.\n */\n readonly members: T;\n\n /**\n * The kind of validator, `\"union\"`.\n */\n readonly kind = \"union\" as const;\n\n /**\n * Usually you'd use `v.union(...members)` instead.\n */\n constructor({ isOptional, members }: { isOptional: IsOptional; members: T }) {\n super({ isOptional });\n members.forEach((member, index) => {\n if (member === undefined) {\n throwUndefinedValidatorError(\"v.union()\", `member at index ${index}`);\n }\n if (!member.isConvexValidator) {\n throw new Error(\"All members of v.union() must be validators\");\n }\n });\n this.members = members;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: this.members.map((v) => v.json),\n };\n }\n /** @internal */\n asOptional() {\n return new VUnion<Type | undefined, T, \"optional\">({\n isOptional: \"optional\",\n members: this.members,\n });\n }\n}\n\n// prettier-ignore\nexport type VOptional<T extends Validator<any, OptionalProperty, any>> =\n T extends VId<infer Type, OptionalProperty> ? VId<Type | undefined, \"optional\">\n : T extends VString<infer Type, OptionalProperty>\n ? VString<Type | undefined, \"optional\">\n : T extends VFloat64<infer Type, OptionalProperty>\n ? VFloat64<Type | undefined, \"optional\">\n : T extends VInt64<infer Type, OptionalProperty>\n ? VInt64<Type | undefined, \"optional\">\n : T extends VCommitTs<infer Type, OptionalProperty>\n ? VCommitTs<Type | undefined, \"optional\">\n : T extends VBoolean<infer Type, OptionalProperty>\n ? VBoolean<Type | undefined, \"optional\">\n : T extends VNull<infer Type, OptionalProperty>\n ? VNull<Type | undefined, \"optional\">\n : T extends VAny<infer Type, OptionalProperty>\n ? VAny<Type | undefined, \"optional\">\n : T extends VLiteral<infer Type, OptionalProperty>\n ? VLiteral<Type | undefined, \"optional\">\n : T extends VBytes<infer Type, OptionalProperty>\n ? VBytes<Type | undefined, \"optional\">\n : T extends VObject< infer Type, infer Fields, OptionalProperty, infer FieldPaths>\n ? VObject<Type | undefined, Fields, \"optional\", FieldPaths>\n : T extends VArray<infer Type, infer Element, OptionalProperty>\n ? VArray<Type | undefined, Element, \"optional\">\n : T extends VRecord< infer Type, infer Key, infer Value, OptionalProperty, infer FieldPaths>\n ? VRecord<Type | undefined, Key, Value, \"optional\", FieldPaths>\n : T extends VUnion<infer Type, infer Members, OptionalProperty, infer FieldPaths>\n ? VUnion<Type | undefined, Members, \"optional\", FieldPaths>\n : never\n\n/**\n * Type representing whether a property in an object is optional or required.\n *\n * @public\n */\nexport type OptionalProperty = \"optional\" | \"required\";\n\n/**\n * A validator for a Convex value.\n *\n * This should be constructed using the validator builder, {@link v}.\n *\n * A validator encapsulates:\n * - The TypeScript type of this value.\n * - Whether this field should be optional if it's included in an object.\n * - The TypeScript type for the set of index field paths that can be used to\n * build indexes on this value.\n * - A JSON representation of the validator.\n *\n * Specific types of validators contain additional information: for example\n * an `ArrayValidator` contains an `element` property with the validator\n * used to validate each element of the list. Use the shared 'kind' property\n * to identity the type of validator.\n *\n * More validators can be added in future releases so an exhaustive\n * switch statement on validator `kind` should be expected to break\n * in future releases of Convex.\n *\n * @public\n */\nexport type Validator<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = never,\n> =\n | VId<Type, IsOptional>\n | VString<Type, IsOptional>\n | VFloat64<Type, IsOptional>\n | VInt64<Type, IsOptional>\n | VCommitTs<Type, IsOptional>\n | VBoolean<Type, IsOptional>\n | VNull<Type, IsOptional>\n | VAny<Type, IsOptional>\n | VLiteral<Type, IsOptional>\n | VBytes<Type, IsOptional>\n | VObject<\n Type,\n Record<string, Validator<any, OptionalProperty, any>>,\n IsOptional,\n FieldPaths\n >\n | VArray<Type, Validator<any, \"required\", any>, IsOptional>\n | VRecord<\n Type,\n Validator<string, \"required\", any>,\n Validator<any, \"required\", any>,\n IsOptional,\n FieldPaths\n >\n | VUnion<Type, Validator<any, \"required\", any>[], IsOptional, FieldPaths>;\n\n/**\n * Join together two index field paths.\n *\n * This is used within the validator builder, {@link v}.\n * @public\n */\nexport type JoinFieldPaths<\n Start extends string,\n End extends string,\n> = `${Start}.${End}`;\n\nexport type ObjectFieldType = { fieldType: ValidatorJSON; optional: boolean };\n\nexport type ValidatorJSON =\n | { type: \"null\" }\n | { type: \"number\" }\n | { type: \"bigint\" }\n | { type: \"commitTs\" }\n | { type: \"boolean\" }\n | { type: \"string\" }\n | { type: \"bytes\" }\n | { type: \"any\" }\n | { type: \"literal\"; value: JSONValue }\n | { type: \"id\"; tableName: string }\n | { type: \"array\"; value: ValidatorJSON }\n | {\n type: \"record\";\n keys: RecordKeyValidatorJSON;\n values: RecordValueValidatorJSON;\n }\n | { type: \"object\"; value: Record<string, ObjectFieldType> }\n | { type: \"union\"; value: ValidatorJSON[] };\n\nexport type RecordKeyValidatorJSON =\n | { type: \"string\" }\n | { type: \"id\"; tableName: string }\n | { type: \"union\"; value: RecordKeyValidatorJSON[] };\n\nexport type RecordValueValidatorJSON = ObjectFieldType & { optional: false };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA6D;AAK7D,MAAM,gCACJ;AAEF,SAAS,6BACP,SACA,WACO;AACP,QAAM,YAAY,cAAc,SAAY,eAAe,SAAS,MAAM;AAC1E,QAAM,IAAI;AAAA,IACR,2BAA2B,SAAS,OAAO,OAAO,mDAEzC,6BAA6B;AAAA,EACxC;AACF;AAMA,MAAe,cAIb;AAAA,EAsBA,YAAY,EAAE,WAAW,GAA+B;AAjBxD;AAAA;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA,wBAAS;AAGP,SAAK,aAAa;AAClB,SA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ent": ["import { Expand } from \"../type_utils.js\";\nimport { GenericId } from \"./index.js\";\nimport { GenericValidator, ObjectType } from \"./validator.js\";\nimport { CommitTsPlaceholder, JSONValue, convexToJson } from \"./value.js\";\n\ntype TableNameFromType<T> =\n T extends GenericId<infer TableName> ? TableName : string;\n\nconst UNDEFINED_VALIDATOR_ERROR_URL =\n \"https://docs.convex.dev/error#undefined-validator\";\n\nfunction throwUndefinedValidatorError(\n context: string,\n fieldName?: string,\n): never {\n const fieldInfo = fieldName !== undefined ? ` for field \"${fieldName}\"` : \"\";\n throw new Error(\n `A validator is undefined${fieldInfo} in ${context}. ` +\n `This is often caused by circular imports. ` +\n `See ${UNDEFINED_VALIDATOR_ERROR_URL} for details.`,\n );\n}\n\n/**\n * Avoid using `instanceof BaseValidator`; this is inheritence for code reuse\n * not type heirarchy.\n */\nabstract class BaseValidator<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = never,\n> {\n /**\n * Only for TypeScript, the TS type of the JS values validated\n * by this validator.\n */\n readonly type!: Type;\n /**\n * Only for TypeScript, if this an Object validator, then\n * this is the TS type of its property names.\n */\n readonly fieldPaths!: FieldPaths;\n\n /**\n * Whether this is an optional Object property value validator.\n */\n readonly isOptional: IsOptional;\n\n /**\n * Always `\"true\"`.\n */\n readonly isConvexValidator: true;\n\n constructor({ isOptional }: { isOptional: IsOptional }) {\n this.isOptional = isOptional;\n this.isConvexValidator = true;\n }\n /** @internal */\n abstract get json(): ValidatorJSON;\n /** @internal */\n abstract asOptional(): Validator<Type | undefined, \"optional\", FieldPaths>;\n /** Allow this validated field to be absent. */\n abstract optional(): Validator<Type | undefined, \"optional\", FieldPaths>;\n}\n\n/**\n * The type of the `v.id(tableName)` validator.\n */\nexport class VId<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The name of the table that the validated IDs must belong to.\n */\n readonly tableName: TableNameFromType<Type>;\n\n /**\n * The kind of validator, `\"id\"`.\n */\n readonly kind = \"id\" as const;\n\n /**\n * Usually you'd use `v.id(tableName)` instead.\n */\n constructor({\n isOptional,\n tableName,\n }: {\n isOptional: IsOptional;\n tableName: TableNameFromType<Type>;\n }) {\n super({ isOptional });\n if (typeof tableName !== \"string\") {\n throw new Error(\"v.id(tableName) requires a string\");\n }\n this.tableName = tableName;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return { type: \"id\", tableName: this.tableName };\n }\n /** Allow this field to be validated as absent. */\n optional() {\n return new VId<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n tableName: this.tableName,\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.float64()` validator.\n */\nexport class VFloat64<\n Type = number,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"float64\"`.\n */\n readonly kind = \"float64\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n // Server expects the old name `number` string instead of `float64`.\n return { type: \"number\" };\n }\n /** Allow this field to be validated as absent. */\n optional() {\n return new VFloat64<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.int64()` validator.\n */\nexport class VInt64<\n Type = bigint,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"int64\"`.\n */\n readonly kind = \"int64\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n // Server expects the old name `bigint`.\n return { type: \"bigint\" };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VInt64<Type | undefined, \"optional\">({ isOptional: \"optional\" });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.commitTs()` validator.\n */\nexport class VCommitTs<\n Type = bigint | CommitTsPlaceholder,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"commitTs\"`.\n */\n readonly kind = \"commitTs\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VCommitTs<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.boolean()` validator.\n */\nexport class VBoolean<\n Type = boolean,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"boolean\"`.\n */\n readonly kind = \"boolean\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VBoolean<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.bytes()` validator.\n */\nexport class VBytes<\n Type = ArrayBuffer,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"bytes\"`.\n */\n readonly kind = \"bytes\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VBytes<Type | undefined, \"optional\">({ isOptional: \"optional\" });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.string()` validator.\n */\nexport class VString<\n Type = string,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"string\"`.\n */\n readonly kind = \"string\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VString<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.null()` validator.\n */\nexport class VNull<\n Type = null,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The kind of validator, `\"null\"`.\n */\n readonly kind = \"null\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return { type: this.kind };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VNull<Type | undefined, \"optional\">({ isOptional: \"optional\" });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.any()` validator.\n */\nexport class VAny<\n Type = any,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = string,\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * The kind of validator, `\"any\"`.\n */\n readonly kind = \"any\" as const;\n\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VAny<Type | undefined, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.object()` validator.\n */\nexport class VObject<\n Type,\n Fields extends Record<string, GenericValidator>,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = {\n [Property in keyof Fields]:\n | JoinFieldPaths<Property & string, Fields[Property][\"fieldPaths\"]>\n | Property;\n }[keyof Fields] &\n string,\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * An object with the validator for each property.\n */\n readonly fields: Fields;\n\n /**\n * The kind of validator, `\"object\"`.\n */\n readonly kind = \"object\" as const;\n\n /**\n * Usually you'd use `v.object({ ... })` instead.\n */\n constructor({\n isOptional,\n fields,\n }: {\n isOptional: IsOptional;\n fields: Fields;\n }) {\n super({ isOptional });\n globalThis.Object.entries(fields).forEach(([fieldName, validator]) => {\n if (validator === undefined) {\n throwUndefinedValidatorError(\"v.object()\", fieldName);\n }\n if (!validator.isConvexValidator) {\n throw new Error(\"v.object() entries must be validators\");\n }\n });\n this.fields = fields;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: globalThis.Object.fromEntries(\n globalThis.Object.entries(this.fields).map(([k, v]) => [\n k,\n {\n fieldType: v.json,\n optional: v.isOptional === \"optional\" ? true : false,\n },\n ]),\n ),\n };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VObject<Type | undefined, Fields, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n fields: this.fields,\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n\n /**\n * Create a new VObject with the specified fields omitted.\n * @param fields The field names to omit from this VObject.\n */\n omit<K extends keyof Fields & string>(\n ...fields: K[]\n ): VObject<Expand<Omit<Type, K>>, Expand<Omit<Fields, K>>, IsOptional> {\n const newFields = { ...this.fields };\n for (const field of fields) {\n delete newFields[field];\n }\n return new VObject({\n isOptional: this.isOptional,\n fields: newFields as any,\n });\n }\n\n /**\n * Create a new VObject with only the specified fields.\n * @param fields The field names to pick from this VObject.\n */\n pick<K extends keyof Fields & string>(\n ...fields: K[]\n ): VObject<\n Expand<Pick<Type, Extract<keyof Type, K>>>,\n Expand<Pick<Fields, K>>,\n IsOptional\n > {\n const newFields: Record<string, GenericValidator> = {};\n for (const field of fields) {\n newFields[field] = this.fields[field];\n }\n return new VObject({\n isOptional: this.isOptional,\n fields: newFields as Expand<Pick<Fields, K>>,\n });\n }\n\n /**\n * Create a new VObject with all fields marked as optional.\n */\n partial(): VObject<\n { [K in keyof Type]?: Type[K] },\n { [K in keyof Fields]: VOptional<Fields[K]> },\n IsOptional\n > {\n const newFields: Record<string, GenericValidator> = {};\n for (const [key, validator] of globalThis.Object.entries(this.fields)) {\n newFields[key] = validator.asOptional();\n }\n return new VObject({\n isOptional: this.isOptional,\n fields: newFields as {\n [K in keyof Fields]: VOptional<Fields[K]>;\n },\n });\n }\n\n /**\n * Create a new VObject with additional fields merged in.\n * @param fields An object with additional validators to merge into this VObject.\n */\n extend<NewFields extends Record<string, GenericValidator>>(\n fields: NewFields,\n ): VObject<\n Expand<Type & ObjectType<NewFields>>,\n Expand<Fields & NewFields>,\n IsOptional\n > {\n return new VObject({\n isOptional: this.isOptional,\n fields: { ...this.fields, ...fields } as Expand<Fields & NewFields>,\n });\n }\n}\n\n/**\n * The type of the `v.literal()` validator.\n */\nexport class VLiteral<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The value that the validated values must be equal to.\n */\n readonly value: Type;\n\n /**\n * The kind of validator, `\"literal\"`.\n */\n readonly kind = \"literal\" as const;\n\n /**\n * Usually you'd use `v.literal(value)` instead.\n */\n constructor({ isOptional, value }: { isOptional: IsOptional; value: Type }) {\n super({ isOptional });\n if (\n typeof value !== \"string\" &&\n typeof value !== \"boolean\" &&\n typeof value !== \"number\" &&\n typeof value !== \"bigint\"\n ) {\n throw new Error(\"v.literal(value) must be a string, number, or boolean\");\n }\n this.value = value;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: convexToJson(this.value as string | boolean | number | bigint),\n };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VLiteral<Type | undefined, \"optional\">({\n isOptional: \"optional\",\n value: this.value,\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.array()` validator.\n */\nexport class VArray<\n Type,\n Element extends Validator<any, \"required\", any>,\n IsOptional extends OptionalProperty = \"required\",\n> extends BaseValidator<Type, IsOptional> {\n /**\n * The validator for the elements of the array.\n */\n readonly element: Element;\n\n /**\n * The kind of validator, `\"array\"`.\n */\n readonly kind = \"array\" as const;\n\n /**\n * Usually you'd use `v.array(element)` instead.\n */\n constructor({\n isOptional,\n element,\n }: {\n isOptional: IsOptional;\n element: Element;\n }) {\n super({ isOptional });\n if (element === undefined) {\n throwUndefinedValidatorError(\"v.array()\");\n }\n this.element = element;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: this.element.json,\n };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VArray<Type | undefined, Element, \"optional\">({\n isOptional: \"optional\",\n element: this.element,\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.record()` validator.\n */\nexport class VRecord<\n Type,\n Key extends Validator<string, \"required\", any>,\n Value extends Validator<any, \"required\", any>,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = string,\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * The validator for the keys of the record.\n */\n readonly key: Key;\n\n /**\n * The validator for the values of the record.\n */\n readonly value: Value;\n\n /**\n * The kind of validator, `\"record\"`.\n */\n readonly kind = \"record\" as const;\n\n /**\n * Usually you'd use `v.record(key, value)` instead.\n */\n constructor({\n isOptional,\n key,\n value,\n }: {\n isOptional: IsOptional;\n key: Key;\n value: Value;\n }) {\n super({ isOptional });\n if (key === undefined) {\n throwUndefinedValidatorError(\"v.record()\", \"key\");\n }\n if (value === undefined) {\n throwUndefinedValidatorError(\"v.record()\", \"value\");\n }\n if ((key.isOptional as OptionalProperty) === \"optional\") {\n throw new Error(\"Record validator cannot have optional keys\");\n }\n if ((value.isOptional as OptionalProperty) === \"optional\") {\n throw new Error(\"Record validator cannot have optional values\");\n }\n if (!key.isConvexValidator || !value.isConvexValidator) {\n throw new Error(\"Key and value of v.record() but be validators\");\n }\n this.key = key;\n this.value = value;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n // This cast is needed because TypeScript thinks the key type is too wide\n keys: this.key.json as RecordKeyValidatorJSON,\n values: {\n fieldType: this.value.json,\n optional: false,\n },\n };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VRecord<Type | undefined, Key, Value, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n key: this.key,\n value: this.value,\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n/**\n * The type of the `v.union()` validator.\n */\nexport class VUnion<\n Type,\n T extends Validator<any, \"required\", any>[],\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = T[number][\"fieldPaths\"],\n> extends BaseValidator<Type, IsOptional, FieldPaths> {\n /**\n * The array of validators, one of which must match the value.\n */\n readonly members: T;\n\n /**\n * The kind of validator, `\"union\"`.\n */\n readonly kind = \"union\" as const;\n\n /**\n * Usually you'd use `v.union(...members)` instead.\n */\n constructor({ isOptional, members }: { isOptional: IsOptional; members: T }) {\n super({ isOptional });\n members.forEach((member, index) => {\n if (member === undefined) {\n throwUndefinedValidatorError(\"v.union()\", `member at index ${index}`);\n }\n if (!member.isConvexValidator) {\n throw new Error(\"All members of v.union() must be validators\");\n }\n });\n this.members = members;\n }\n /** @internal */\n get json(): ValidatorJSON {\n return {\n type: this.kind,\n value: this.members.map((v) => v.json),\n };\n }\n /** Allow this validated field to be absent. */\n optional() {\n return new VUnion<Type | undefined, T, \"optional\", FieldPaths>({\n isOptional: \"optional\",\n members: this.members,\n });\n }\n /** @internal */\n asOptional() {\n return this.optional();\n }\n}\n\n// prettier-ignore\nexport type VOptional<T extends Validator<any, OptionalProperty, any>> =\n T extends VId<infer Type, OptionalProperty> ? VId<Type | undefined, \"optional\">\n : T extends VString<infer Type, OptionalProperty>\n ? VString<Type | undefined, \"optional\">\n : T extends VFloat64<infer Type, OptionalProperty>\n ? VFloat64<Type | undefined, \"optional\">\n : T extends VInt64<infer Type, OptionalProperty>\n ? VInt64<Type | undefined, \"optional\">\n : T extends VCommitTs<infer Type, OptionalProperty>\n ? VCommitTs<Type | undefined, \"optional\">\n : T extends VBoolean<infer Type, OptionalProperty>\n ? VBoolean<Type | undefined, \"optional\">\n : T extends VNull<infer Type, OptionalProperty>\n ? VNull<Type | undefined, \"optional\">\n : T extends VAny<infer Type, OptionalProperty>\n ? VAny<Type | undefined, \"optional\">\n : T extends VLiteral<infer Type, OptionalProperty>\n ? VLiteral<Type | undefined, \"optional\">\n : T extends VBytes<infer Type, OptionalProperty>\n ? VBytes<Type | undefined, \"optional\">\n : T extends VObject< infer Type, infer Fields, OptionalProperty, infer FieldPaths>\n ? VObject<Type | undefined, Fields, \"optional\", FieldPaths>\n : T extends VArray<infer Type, infer Element, OptionalProperty>\n ? VArray<Type | undefined, Element, \"optional\">\n : T extends VRecord< infer Type, infer Key, infer Value, OptionalProperty, infer FieldPaths>\n ? VRecord<Type | undefined, Key, Value, \"optional\", FieldPaths>\n : T extends VUnion<infer Type, infer Members, OptionalProperty, infer FieldPaths>\n ? VUnion<Type | undefined, Members, \"optional\", FieldPaths>\n : never\n\n/**\n * Type representing whether a property in an object is optional or required.\n *\n * @public\n */\nexport type OptionalProperty = \"optional\" | \"required\";\n\n/**\n * A validator for a Convex value.\n *\n * This should be constructed using the validator builder, {@link v}.\n *\n * A validator encapsulates:\n * - The TypeScript type of this value.\n * - Whether this field should be optional if it's included in an object.\n * - The TypeScript type for the set of index field paths that can be used to\n * build indexes on this value.\n * - A JSON representation of the validator.\n *\n * Specific types of validators contain additional information: for example\n * an `ArrayValidator` contains an `element` property with the validator\n * used to validate each element of the list. Use the shared 'kind' property\n * to identity the type of validator.\n *\n * More validators can be added in future releases so an exhaustive\n * switch statement on validator `kind` should be expected to break\n * in future releases of Convex.\n *\n * @public\n */\nexport type Validator<\n Type,\n IsOptional extends OptionalProperty = \"required\",\n FieldPaths extends string = never,\n> =\n | VId<Type, IsOptional>\n | VString<Type, IsOptional>\n | VFloat64<Type, IsOptional>\n | VInt64<Type, IsOptional>\n | VCommitTs<Type, IsOptional>\n | VBoolean<Type, IsOptional>\n | VNull<Type, IsOptional>\n | VAny<Type, IsOptional>\n | VLiteral<Type, IsOptional>\n | VBytes<Type, IsOptional>\n | VObject<\n Type,\n Record<string, Validator<any, OptionalProperty, any>>,\n IsOptional,\n FieldPaths\n >\n | VArray<Type, Validator<any, \"required\", any>, IsOptional>\n | VRecord<\n Type,\n Validator<string, \"required\", any>,\n Validator<any, \"required\", any>,\n IsOptional,\n FieldPaths\n >\n | VUnion<Type, Validator<any, \"required\", any>[], IsOptional, FieldPaths>;\n\n/**\n * Join together two index field paths.\n *\n * This is used within the validator builder, {@link v}.\n * @public\n */\nexport type JoinFieldPaths<\n Start extends string,\n End extends string,\n> = `${Start}.${End}`;\n\nexport type ObjectFieldType = { fieldType: ValidatorJSON; optional: boolean };\n\nexport type ValidatorJSON =\n | { type: \"null\" }\n | { type: \"number\" }\n | { type: \"bigint\" }\n | { type: \"commitTs\" }\n | { type: \"boolean\" }\n | { type: \"string\" }\n | { type: \"bytes\" }\n | { type: \"any\" }\n | { type: \"literal\"; value: JSONValue }\n | { type: \"id\"; tableName: string }\n | { type: \"array\"; value: ValidatorJSON }\n | {\n type: \"record\";\n keys: RecordKeyValidatorJSON;\n values: RecordValueValidatorJSON;\n }\n | { type: \"object\"; value: Record<string, ObjectFieldType> }\n | { type: \"union\"; value: ValidatorJSON[] };\n\nexport type RecordKeyValidatorJSON =\n | { type: \"string\" }\n | { type: \"id\"; tableName: string }\n | { type: \"union\"; value: RecordKeyValidatorJSON[] };\n\nexport type RecordValueValidatorJSON = ObjectFieldType & { optional: false };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA6D;AAK7D,MAAM,gCACJ;AAEF,SAAS,6BACP,SACA,WACO;AACP,QAAM,YAAY,cAAc,SAAY,eAAe,SAAS,MAAM;AAC1E,QAAM,IAAI;AAAA,IACR,2BAA2B,SAAS,OAAO,OAAO,mDAEzC,6BAA6B;AAAA,EACxC;AACF;AAMA,MAAe,cAIb;AAAA,EAsBA,YAAY,EAAE,WAAW,GAA+B;AAjBxD;AAAA;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA,wBAAS;AAGP,SAAK,aAAa;AAClB,SAAK,oBAAoB;AAAA,EAC3B;AAOF;AAKO,MAAM,YAGH,cAAgC;AAAA;AAAA;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A4C;AAAA;AAAA;AAAA;AAAA,EAcpD,YAAY,EAAE,YAAY,QAAQ,GAA2C;AAC3E,UAAM,EAAE,WAAW,CAAC;AAXtB;AAAA;AAAA;AAAA,wBAAS;AAKT;AAAA;AAAA;AAAA,wBAAS,QAAO;AAOd,YAAQ,QAAQ,CAAC,QAAQ,UAAU;AACjC,UAAI,WAAW,QAAW;AACxB,qCAA6B,aAAa,mBAAmB,KAAK,EAAE;AAAA,MACtE;AACA,UAAI,CAAC,OAAO,mBAAmB;AAC7B,cAAM,IAAI,MAAM,6CAA6C;AAAA,MAC/D;AAAA,IACF,CAAC;AACD,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA,EAEA,IAAI,OAAsB;AACxB,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,IACvC;AAAA,EACF;AAAA;AAAA,EAEA,WAAW;AACT,WAAO,IAAI,OAAoD;AAAA,MAC7D,YAAY;AAAA,MACZ,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,EACH;AAAA;AAAA,EAEA,aAAa;AACX,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { FunctionReference, FunctionReturnType, OptionalRestArgs } from "../server/api.js";
1
+ import { FunctionReturnType, OptionalRestArgs, FunctionReference, FunctionReference_future } from "../server/api.js";
2
2
  import { Logger } from "./logging.js";
3
3
  import { ArgsAndOptions } from "../server/index.js";
4
4
  export declare const STATUS_CODE_OK = 200;
@@ -106,7 +106,7 @@ export declare class ConvexHttpClient {
106
106
  *
107
107
  * @deprecated This API is experimental: it may change or disappear.
108
108
  */
109
- consistentQuery<Query extends FunctionReference<"query">>(query: Query, ...args: OptionalRestArgs<Query>): Promise<FunctionReturnType<Query>>;
109
+ consistentQuery<Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(query: Query, ...args: OptionalRestArgs<Query>): Promise<FunctionReturnType<Query>>;
110
110
  private getTimestamp;
111
111
  private getTimestampInner;
112
112
  /**
@@ -117,7 +117,7 @@ export declare class ConvexHttpClient {
117
117
  * the arguments will be `{}`.
118
118
  * @returns A promise of the query's result.
119
119
  */
120
- query<Query extends FunctionReference<"query">>(query: Query, ...args: OptionalRestArgs<Query>): Promise<FunctionReturnType<Query>>;
120
+ query<Query extends FunctionReference<"query"> | FunctionReference_future<"query">>(query: Query, ...args: OptionalRestArgs<Query>): Promise<FunctionReturnType<Query>>;
121
121
  private queryInner;
122
122
  private mutationInner;
123
123
  private processMutationQueue;
@@ -131,7 +131,7 @@ export declare class ConvexHttpClient {
131
131
  * @param options - An optional object containing
132
132
  * @returns A promise of the mutation's result.
133
133
  */
134
- mutation<Mutation extends FunctionReference<"mutation">>(mutation: Mutation, ...args: ArgsAndOptions<Mutation, HttpMutationOptions>): Promise<FunctionReturnType<Mutation>>;
134
+ mutation<Mutation extends FunctionReference<"mutation"> | FunctionReference_future<"mutation">>(mutation: Mutation, ...args: ArgsAndOptions<Mutation, HttpMutationOptions>): Promise<FunctionReturnType<Mutation>>;
135
135
  /**
136
136
  * Execute a Convex action function. Actions are not queued.
137
137
  *
@@ -140,6 +140,6 @@ export declare class ConvexHttpClient {
140
140
  * the arguments will be `{}`.
141
141
  * @returns A promise of the action's result.
142
142
  */
143
- action<Action extends FunctionReference<"action">>(action: Action, ...args: OptionalRestArgs<Action>): Promise<FunctionReturnType<Action>>;
143
+ action<Action extends FunctionReference<"action"> | FunctionReference_future<"action">>(action: Action, ...args: OptionalRestArgs<Action>): Promise<FunctionReturnType<Action>>;
144
144
  }
145
145
  //# sourceMappingURL=http_client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../../src/browser/http_client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAIL,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B,CAAC,KAAK,CAAC,CAAC;YAOvB,YAAY;YAOZ,iBAAiB;IAmB/B;;;;;;;OAOG;IACG,KAAK,CACT,KAAK,SACD,iBAAiB,CAAC,OAAO,CAAC,GAC1B,wBAAwB,CAAC,OAAO,CAAC,EAErC,KAAK,EAAE,KAAK,EACZ,GAAG,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC/B,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAKvB,UAAU;YAoEV,aAAa;YAuDb,oBAAoB;IAkBlC,OAAO,CAAC,eAAe;IAcvB;;;;;;;;OAQG;IACG,QAAQ,CACZ,QAAQ,SACJ,iBAAiB,CAAC,UAAU,CAAC,GAC7B,wBAAwB,CAAC,UAAU,CAAC,EAExC,QAAQ,EAAE,QAAQ,EAClB,GAAG,IAAI,EAAE,cAAc,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GACrD,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAYxC;;;;;;;OAOG;IACG,MAAM,CACV,MAAM,SACF,iBAAiB,CAAC,QAAQ,CAAC,GAC3B,wBAAwB,CAAC,QAAQ,CAAC,EAEtC,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAChC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;CAuHvC"}
@@ -1,4 +1,4 @@
1
- import type { FunctionArgs, FunctionReference } from "../server/api.js";
1
+ import type { FunctionArgs, FunctionReference, FunctionReference_future } from "../server/api.js";
2
2
  /**
3
3
  * Options for a Convex query: the query function reference and its arguments.
4
4
  *
@@ -6,7 +6,7 @@ import type { FunctionArgs, FunctionReference } from "../server/api.js";
6
6
  *
7
7
  * @public
8
8
  */
9
- export type QueryOptions<Query extends FunctionReference<"query">> = {
9
+ export type QueryOptions<Query extends FunctionReference<"query"> | FunctionReference_future<"query">> = {
10
10
  /**
11
11
  * The query function to run.
12
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"query_options.d.ts","sourceRoot":"","sources":["../../../src/browser/query_options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,iBAAiB,CAAC,OAAO,CAAC,IAAI;IACnE;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;CAC3B,CAAC"}
1
+ {"version":3,"file":"query_options.d.ts","sourceRoot":"","sources":["../../../src/browser/query_options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CACtB,KAAK,SAAS,iBAAiB,CAAC,OAAO,CAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,IAC1E;IACF;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;CAC3B,CAAC"}