convex 1.13.0-alpha.1 → 1.13.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 (106) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/bin/main-dev +2 -2
  3. package/dist/browser.bundle.js +1 -1
  4. package/dist/browser.bundle.js.map +1 -1
  5. package/dist/cjs/browser/logging.js.map +1 -1
  6. package/dist/cjs/bundler/context.js +5 -1
  7. package/dist/cjs/bundler/context.js.map +2 -2
  8. package/dist/cjs/cli/codegen_templates/tsconfig.js +3 -2
  9. package/dist/cjs/cli/codegen_templates/tsconfig.js.map +2 -2
  10. package/dist/cjs/cli/convexImport.js +54 -3
  11. package/dist/cjs/cli/convexImport.js.map +2 -2
  12. package/dist/cjs/cli/dashboard.js +1 -1
  13. package/dist/cjs/cli/dashboard.js.map +2 -2
  14. package/dist/cjs/cli/lib/utils.js +3 -2
  15. package/dist/cjs/cli/lib/utils.js.map +2 -2
  16. package/dist/cjs/index.js +1 -1
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/server/components/index.js.map +1 -1
  19. package/dist/cjs/server/pagination.js.map +1 -1
  20. package/dist/cjs/server/registration.js.map +1 -1
  21. package/dist/cjs/values/validator.js +1 -1
  22. package/dist/cjs/values/validator.js.map +2 -2
  23. package/dist/cjs/values/validators.js +69 -64
  24. package/dist/cjs/values/validators.js.map +2 -2
  25. package/dist/cjs-types/browser/logging.d.ts +1 -1
  26. package/dist/cjs-types/browser/logging.d.ts.map +1 -1
  27. package/dist/cjs-types/bundler/context.d.ts.map +1 -1
  28. package/dist/cjs-types/cli/codegen_templates/tsconfig.d.ts.map +1 -1
  29. package/dist/cjs-types/cli/convexImport.d.ts.map +1 -1
  30. package/dist/cjs-types/cli/dashboard.d.ts +1 -1
  31. package/dist/cjs-types/cli/dashboard.d.ts.map +1 -1
  32. package/dist/cjs-types/cli/lib/utils.d.ts +1 -1
  33. package/dist/cjs-types/cli/lib/utils.d.ts.map +1 -1
  34. package/dist/cjs-types/index.d.ts +1 -1
  35. package/dist/cjs-types/index.d.ts.map +1 -1
  36. package/dist/cjs-types/server/pagination.d.ts +5 -5
  37. package/dist/cjs-types/server/registration.d.ts +73 -0
  38. package/dist/cjs-types/server/registration.d.ts.map +1 -1
  39. package/dist/cjs-types/server/schema.d.ts +2 -2
  40. package/dist/cjs-types/values/validator.d.ts +2 -2
  41. package/dist/cjs-types/values/validator.d.ts.map +1 -1
  42. package/dist/cjs-types/values/validators.d.ts +32 -88
  43. package/dist/cjs-types/values/validators.d.ts.map +1 -1
  44. package/dist/cli.bundle.cjs +64 -10
  45. package/dist/cli.bundle.cjs.map +2 -2
  46. package/dist/esm/browser/logging.js.map +1 -1
  47. package/dist/esm/bundler/context.js +5 -1
  48. package/dist/esm/bundler/context.js.map +2 -2
  49. package/dist/esm/cli/codegen_templates/tsconfig.js +3 -2
  50. package/dist/esm/cli/codegen_templates/tsconfig.js.map +2 -2
  51. package/dist/esm/cli/convexImport.js +54 -3
  52. package/dist/esm/cli/convexImport.js.map +2 -2
  53. package/dist/esm/cli/dashboard.js +1 -1
  54. package/dist/esm/cli/dashboard.js.map +2 -2
  55. package/dist/esm/cli/lib/utils.js +3 -2
  56. package/dist/esm/cli/lib/utils.js.map +2 -2
  57. package/dist/esm/index.js +1 -1
  58. package/dist/esm/index.js.map +1 -1
  59. package/dist/esm/server/components/index.js.map +1 -1
  60. package/dist/esm/server/pagination.js.map +1 -1
  61. package/dist/esm/values/validator.js +1 -1
  62. package/dist/esm/values/validator.js.map +2 -2
  63. package/dist/esm/values/validators.js +69 -64
  64. package/dist/esm/values/validators.js.map +2 -2
  65. package/dist/esm-types/browser/logging.d.ts +1 -1
  66. package/dist/esm-types/browser/logging.d.ts.map +1 -1
  67. package/dist/esm-types/bundler/context.d.ts.map +1 -1
  68. package/dist/esm-types/cli/codegen_templates/tsconfig.d.ts.map +1 -1
  69. package/dist/esm-types/cli/convexImport.d.ts.map +1 -1
  70. package/dist/esm-types/cli/dashboard.d.ts +1 -1
  71. package/dist/esm-types/cli/dashboard.d.ts.map +1 -1
  72. package/dist/esm-types/cli/lib/utils.d.ts +1 -1
  73. package/dist/esm-types/cli/lib/utils.d.ts.map +1 -1
  74. package/dist/esm-types/index.d.ts +1 -1
  75. package/dist/esm-types/index.d.ts.map +1 -1
  76. package/dist/esm-types/server/pagination.d.ts +5 -5
  77. package/dist/esm-types/server/registration.d.ts +73 -0
  78. package/dist/esm-types/server/registration.d.ts.map +1 -1
  79. package/dist/esm-types/server/schema.d.ts +2 -2
  80. package/dist/esm-types/values/validator.d.ts +2 -2
  81. package/dist/esm-types/values/validator.d.ts.map +1 -1
  82. package/dist/esm-types/values/validators.d.ts +32 -88
  83. package/dist/esm-types/values/validators.d.ts.map +1 -1
  84. package/dist/react.bundle.js +1 -1
  85. package/dist/react.bundle.js.map +1 -1
  86. package/package.json +11 -12
  87. package/src/browser/logging.ts +1 -1
  88. package/src/bundler/context.ts +4 -0
  89. package/src/cli/codegen_templates/tsconfig.ts +3 -2
  90. package/src/cli/convexImport.ts +62 -4
  91. package/src/cli/dashboard.ts +2 -2
  92. package/src/cli/lib/utils.ts +3 -1
  93. package/src/index.ts +1 -1
  94. package/src/server/components/index.ts +1 -1
  95. package/src/server/pagination.ts +1 -1
  96. package/src/server/registration.ts +73 -0
  97. package/src/values/validator.ts +10 -2
  98. package/src/values/validators.ts +104 -142
  99. package/vitest.config.js +11 -0
  100. package/browser/node_modules/.modules.yaml +0 -19
  101. package/react/node_modules/.modules.yaml +0 -19
  102. package/react-auth0/node_modules/.modules.yaml +0 -19
  103. package/react-clerk/node_modules/.modules.yaml +0 -19
  104. package/server/node_modules/.modules.yaml +0 -19
  105. package/src/environment/index.d.ts +0 -28
  106. package/values/node_modules/.modules.yaml +0 -19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.13.0-alpha.1
4
+
5
+ - Convex queries, mutations, and actions now accept `returns:` property to
6
+ specify a return value validator.
7
+
8
+ Return value validators throw a runtime error (so will roll back the
9
+ transaction in a mutation) when the value returned from a query or mutation
10
+ does not match this validator. This is _stricter than TypeScript_ in that
11
+ extra properties will not be allowed.
12
+
13
+ - Validator fields are now exposed: the return value of `v.object({ ... })` now
14
+ has a `.fields` property with the validators for each property on it.
15
+
16
+ ```
17
+ const message = v.object({ user: v.string(), body: v.string() });
18
+ const imageMessage = v.object({ ...message.fields, })
19
+ ```
20
+
21
+ These validators are also exposed on the schema at
22
+ `schema.tables.messages.validator`
23
+
24
+ The `Validator` export is no longer a class. It is now a discriminated union
25
+ type of all validators where the `.kind` as the discriminator. The `Validator`
26
+ type still has three type parameters with only the first (the TypeScript type
27
+ enforced by the validator) required.
28
+
29
+ These are breaking changes if you're using the two optional type parameters of
30
+ `Validator` or doing `instanceof` checks with `Validator`! We apologize for
31
+ the inconvenience. The same users this affects should be the ones that most
32
+ benefit from the ability to work with validator types more directly.
33
+
34
+ - Argument validators now accept validators (object validators and union
35
+ validators) in addition to objects with validators as properties. Return value
36
+ validators similarly accept either validators or objects with validators as
37
+ properties, but unlike `args:` any validator is allowed.
38
+
39
+ Custom function wrappers (AKA middleware) should continue to work, but to
40
+ present the same API has the builtin Convex function wrappers `query`,
41
+ `internalQuery`, `mutation` etc. you'll need to update such code to accept
42
+ either a validator or an object of validators. You'll likely want to update
43
+ these anyway to support return value validators. The new `asValidator` helper
44
+ maybe useful here.
45
+
46
+ - The default tsconfig.json created in projects when first creating the
47
+ `convex/` directory now uses `"moduleResolution": "Bundler"`. This is just a
48
+ better default, you
49
+ [probably never want the previous default `"node"`/`"node10"`](https://www.typescriptlang.org/tsconfig/#moduleResolution).
50
+
3
51
  ## 1.12.1
4
52
 
5
53
  - Fix bug where `npx convex deploy` and `npx convex dev` would incorrectly skip
package/bin/main-dev CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  if [ "$(uname)" == "Darwin" ] || [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
5
5
  SCRIPTDIR="$(echo "$0" | python3 -c 'import os; print(os.path.dirname(os.path.realpath(input())))')"
6
- "exec" "$SCRIPTDIR/../node_modules/.bin/ts-node-esm" "--swc" "$SCRIPTDIR/../src/cli/index.ts" "$@"
6
+ CONVEX_RUNNING_LIVE_IN_MONOREPO=1 "exec" "$SCRIPTDIR/../node_modules/.bin/tsx" "$SCRIPTDIR/../src/cli/index.ts" "$@"
7
7
  else # it's probably Windows
8
8
  # This doesn't follow symlinks quite as correctly as the Mac/Linux solution above
9
9
  CONVEXDIR="$(dirname "$(dirname "$0")")"
10
- "exec" "$CONVEXDIR/node_modules/.bin/ts-node-esm" "--swc" "$CONVEXDIR/src/cli/index.ts" "$@"
10
+ CONVEX_RUNNING_LIVE_IN_MONOREPO=1 "exec" "$CONVEXDIR/node_modules/.bin/tsx" "$CONVEXDIR/src/cli/index.ts" "$@"
11
11
  fi
@@ -28,7 +28,7 @@ var convex = (() => {
28
28
  });
29
29
 
30
30
  // src/index.ts
31
- var version = "1.13.0-alpha.1";
31
+ var version = "1.13.0";
32
32
 
33
33
  // src/values/base64.ts
34
34
  var base64_exports = {};