convex 1.43.0 → 1.44.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 (90) hide show
  1. package/CHANGELOG.md +130 -113
  2. package/dist/browser.bundle.js +1 -1
  3. package/dist/browser.bundle.js.map +1 -1
  4. package/dist/cjs/cli/codegen_templates/component_server.js +4 -3
  5. package/dist/cjs/cli/codegen_templates/component_server.js.map +2 -2
  6. package/dist/cjs/cli/codegen_templates/server.js +24 -12
  7. package/dist/cjs/cli/codegen_templates/server.js.map +2 -2
  8. package/dist/cjs/cli/lib/login.js +12 -8
  9. package/dist/cjs/cli/lib/login.js.map +2 -2
  10. package/dist/cjs/cli/login.js +52 -7
  11. package/dist/cjs/cli/login.js.map +2 -2
  12. package/dist/cjs/index.js +1 -1
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/react/ConvexAuthState.js +30 -32
  15. package/dist/cjs/react/ConvexAuthState.js.map +2 -2
  16. package/dist/cjs/server/impl/actions_impl.js +12 -0
  17. package/dist/cjs/server/impl/actions_impl.js.map +2 -2
  18. package/dist/cjs/server/index.js +3 -0
  19. package/dist/cjs/server/index.js.map +2 -2
  20. package/dist/cjs/server/schema.js +69 -1
  21. package/dist/cjs/server/schema.js.map +2 -2
  22. package/dist/cjs-types/cli/codegen_templates/component_server.d.ts.map +1 -1
  23. package/dist/cjs-types/cli/codegen_templates/server.d.ts +1 -0
  24. package/dist/cjs-types/cli/codegen_templates/server.d.ts.map +1 -1
  25. package/dist/cjs-types/cli/lib/login.d.ts +5 -0
  26. package/dist/cjs-types/cli/lib/login.d.ts.map +1 -1
  27. package/dist/cjs-types/cli/login.d.ts.map +1 -1
  28. package/dist/cjs-types/cli/login.test.d.ts +2 -0
  29. package/dist/cjs-types/cli/login.test.d.ts.map +1 -0
  30. package/dist/cjs-types/index.d.ts +1 -1
  31. package/dist/cjs-types/react/ConvexAuthState.d.ts.map +1 -1
  32. package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
  33. package/dist/cjs-types/server/impl/actions_impl.test.d.ts +2 -0
  34. package/dist/cjs-types/server/impl/actions_impl.test.d.ts.map +1 -0
  35. package/dist/cjs-types/server/index.d.ts +2 -2
  36. package/dist/cjs-types/server/index.d.ts.map +1 -1
  37. package/dist/cjs-types/server/schema.d.ts +83 -5
  38. package/dist/cjs-types/server/schema.d.ts.map +1 -1
  39. package/dist/cli.bundle.cjs +1277 -570
  40. package/dist/cli.bundle.cjs.map +4 -4
  41. package/dist/esm/cli/codegen_templates/component_server.js +8 -4
  42. package/dist/esm/cli/codegen_templates/component_server.js.map +2 -2
  43. package/dist/esm/cli/codegen_templates/server.js +22 -11
  44. package/dist/esm/cli/codegen_templates/server.js.map +2 -2
  45. package/dist/esm/cli/lib/login.js +11 -8
  46. package/dist/esm/cli/lib/login.js.map +2 -2
  47. package/dist/esm/cli/login.js +54 -10
  48. package/dist/esm/cli/login.js.map +2 -2
  49. package/dist/esm/index.js +1 -1
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/esm/react/ConvexAuthState.js +31 -32
  52. package/dist/esm/react/ConvexAuthState.js.map +2 -2
  53. package/dist/esm/server/impl/actions_impl.js +11 -0
  54. package/dist/esm/server/impl/actions_impl.js.map +2 -2
  55. package/dist/esm/server/index.js +2 -1
  56. package/dist/esm/server/index.js.map +2 -2
  57. package/dist/esm/server/schema.js +67 -0
  58. package/dist/esm/server/schema.js.map +2 -2
  59. package/dist/esm-types/cli/codegen_templates/component_server.d.ts.map +1 -1
  60. package/dist/esm-types/cli/codegen_templates/server.d.ts +1 -0
  61. package/dist/esm-types/cli/codegen_templates/server.d.ts.map +1 -1
  62. package/dist/esm-types/cli/lib/login.d.ts +5 -0
  63. package/dist/esm-types/cli/lib/login.d.ts.map +1 -1
  64. package/dist/esm-types/cli/login.d.ts.map +1 -1
  65. package/dist/esm-types/cli/login.test.d.ts +2 -0
  66. package/dist/esm-types/cli/login.test.d.ts.map +1 -0
  67. package/dist/esm-types/index.d.ts +1 -1
  68. package/dist/esm-types/react/ConvexAuthState.d.ts.map +1 -1
  69. package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
  70. package/dist/esm-types/server/impl/actions_impl.test.d.ts +2 -0
  71. package/dist/esm-types/server/impl/actions_impl.test.d.ts.map +1 -0
  72. package/dist/esm-types/server/index.d.ts +2 -2
  73. package/dist/esm-types/server/index.d.ts.map +1 -1
  74. package/dist/esm-types/server/schema.d.ts +83 -5
  75. package/dist/esm-types/server/schema.d.ts.map +1 -1
  76. package/dist/react.bundle.js +31 -33
  77. package/dist/react.bundle.js.map +2 -2
  78. package/package.json +3 -4
  79. package/src/cli/codegen_templates/component_server.ts +12 -6
  80. package/src/cli/codegen_templates/server.ts +36 -19
  81. package/src/cli/lib/login.ts +20 -9
  82. package/src/cli/login.test.ts +261 -0
  83. package/src/cli/login.ts +88 -13
  84. package/src/index.ts +1 -1
  85. package/src/react/ConvexAuthState.tsx +15 -7
  86. package/src/server/impl/actions_impl.test.ts +59 -0
  87. package/src/server/impl/actions_impl.ts +23 -0
  88. package/src/server/index.ts +7 -1
  89. package/src/server/schema.test.ts +98 -0
  90. package/src/server/schema.ts +178 -1
package/CHANGELOG.md CHANGED
@@ -1,63 +1,74 @@
1
1
  # Changelog
2
2
 
3
- ## 1.43.0 (unreleased)
4
- - Added new `npx convex deployment usage` and
5
- `npx convex deployment usage-limits` CLI commands to
6
- view a deployment’s current resource usage, and
7
- view or edit deployment usage limits.
8
- - When defining hourly cron jobs, you can now omit the
9
- `minuteUTC` parameter. When omitted, Convex will automatically
10
- choose a stable start time within the scheduled hour,
11
- avoiding concentrating jobs at the top of the hour.
3
+ ## 1.44.0
4
+
5
+ - `schema.doc(tableName)` returns the validator for whole documents of a table:
6
+ the table's own validator with the `_id` and `_creationTime` system fields
7
+ added (to each member, for tables defined with a union).
8
+ `schema.id(tableName)` is `v.id(tableName)` restricted to the table names in
9
+ the schema. `docValidator(tableName, tableDefinition)` from `convex/server`
10
+ does the same as `schema.doc` when you only have a table definition.
11
+ - The server-provided environment variables `CONVEX_SITE_URL` and
12
+ `CONVEX_CLOUD_URL` are now available on `env` by default in
13
+ `_generated/server.d.ts`, along with other environment variables specified in
14
+ `convex/convex.config.ts`.
15
+ - Fixed a bug where the context value provided by `ConvexProviderWithAuth` was
16
+ not referentially stable.
17
+ - Fixed a bug where `npx convex login status` would report misleading results
18
+ when the user is logged in but does not have access to the current project.
19
+
20
+ ## 1.43.0
21
+
22
+ - Added new `npx convex deployment usage` and
23
+ `npx convex deployment usage-limits` CLI commands to view a deployment’s
24
+ current resource usage, and view or edit deployment usage limits.
25
+ - When defining hourly cron jobs, you can now omit the `minuteUTC` parameter.
26
+ When omitted, Convex will automatically choose a stable start time within the
27
+ scheduled hour, avoiding concentrating jobs at the top of the hour.
12
28
  - Mutations can now reference their upcoming
13
- [_commit timestamp_](https://docs.convex.dev/database/advanced/commit-timestamp)
29
+ [commit timestamp](https://docs.convex.dev/database/advanced/commit-timestamp)
14
30
  with `ctx.db.vars.commitTs`. While the mutation is running,
15
- `ctx.db.vars.commitTs` is a placeholder symbol that is
16
- replaced with a Int64 value at commit time that is guaranteed
17
- to strictly follow commit order, unlike the `_creationTime` system field.
18
- This low-level primitive is helpful for advanced use cases such as implementing
19
- efficient FIFO queues.
20
- - Added a new `v.commitTs()` validator that accepts either the
21
- upcoming commit timestamp placeholder, or a Int64 commit timestamp.
22
- - The Convex CLI is now able to find the right TypeScript compiler
23
- when using side-by-side TypeScript 6 and 7 installation.
24
- (This setup is used in codebases that want to use the native TypeScript 7
25
- compiler but still need access to the TypeScript compiler JavaScript API.)
26
- - Deprecated the `typescriptCompiler` parameter in `convex.json`.
27
- This parameter was only necessary when using the TypeScript Native Preview
28
- (@typescript/native-preview). With TypeScript 7, Convex
29
- automatically picks the right binary.
30
- - When a component only uses environment variables that are all optional,
31
- it’s now possible to omit the `env` argument from `app.use(component, { })`.
32
- - Fixed a bug where `app.use()` failed to require
33
- a second argument when a component has required environment variables
34
- (e.g. `app.use(component, { env: { REQUIRED_VAR: "value" } })`).
35
- - Fixed a bug in `usePaginatedQuery_experimental`
36
- where page splits were handled incorrectly.
31
+ `ctx.db.vars.commitTs` is a placeholder symbol that is replaced with a Int64
32
+ value at commit time that is guaranteed to strictly follow commit order,
33
+ unlike the `_creationTime` system field. This low-level primitive is helpful
34
+ for advanced use cases such as implementing efficient FIFO queues.
35
+ - Added a new `v.commitTs()` validator that accepts either the upcoming commit
36
+ timestamp placeholder, or a Int64 commit timestamp.
37
+ - The Convex CLI is now able to find the right TypeScript compiler when using
38
+ side-by-side TypeScript 6 and 7 installation. (This setup is used in codebases
39
+ that want to use the native TypeScript 7 compiler but still need access to the
40
+ TypeScript compiler JavaScript API.)
41
+ - Deprecated the `typescriptCompiler` parameter in `convex.json`. This parameter
42
+ was only necessary when using the TypeScript Native Preview
43
+ (@typescript/native-preview). With TypeScript 7, Convex automatically picks
44
+ the right binary.
45
+ - When a component only uses environment variables that are all optional, it’s
46
+ now possible to omit the `env` argument from `app.use(component, { })`.
47
+ - Fixed a bug where `app.use()` failed to require a second argument when a
48
+ component has required environment variables (e.g.
49
+ `app.use(component, { env: { REQUIRED_VAR: "value" } })`).
50
+ - Fixed a bug in `usePaginatedQuery_experimental` where page splits were handled
51
+ incorrectly.
37
52
 
38
53
  ## 1.42.3
39
54
 
40
- - Fixed a bug where the codegen would not sort module paths in
41
- an order consistent with other platforms when running
42
- on Windows. This completes a fix that was only partially
43
- applied in 1.42.2.
55
+ - Fixed a bug where the codegen would not sort module paths in an order
56
+ consistent with other platforms when running on Windows. This completes a fix
57
+ that was only partially applied in 1.42.2.
44
58
 
45
59
  ## 1.42.2
46
- - Mutations and actions can now read the raw authentication
47
- token used in the request by accessing `authToken` in
48
- `ctx.meta.getRequestMetadata()`.
49
- - Fixed a circular import in `convex/browser` that caused issues
50
- when using the `ConvexHttpClient` in some JavaScript
51
- environments.
52
- - Fixed a bug in `ConvexProviderWithClerk` that caused
53
- the Convex client to ignore session changes in some situations.
54
- - Fixed a bug where the codegen would not sort module paths in
55
- an order consistent with other platforms when running
56
- on Windows.
57
- - When running `npx convex dev` outside a Convex project,
58
- the CLI now returns an error message immediately instead of
59
- first asking the user to select a project and then failing
60
- later.
60
+
61
+ - Mutations and actions can now read the raw authentication token used in the
62
+ request by accessing `authToken` in `ctx.meta.getRequestMetadata()`.
63
+ - Fixed a circular import in `convex/browser` that caused issues when using the
64
+ `ConvexHttpClient` in some JavaScript environments.
65
+ - Fixed a bug in `ConvexProviderWithClerk` that caused the Convex client to
66
+ ignore session changes in some situations.
67
+ - Fixed a bug where the codegen would not sort module paths in an order
68
+ consistent with other platforms when running on Windows.
69
+ - When running `npx convex dev` outside a Convex project, the CLI now returns an
70
+ error message immediately instead of first asking the user to select a project
71
+ and then failing later.
61
72
 
62
73
  ## 1.42.1
63
74
 
@@ -68,66 +79,67 @@
68
79
 
69
80
  ## 1.42.0
70
81
 
71
- - Added a new `npx convex project create` command that can be used
72
- to create new projects programmatically.
73
- - Added a new `--names-only` flag to `npx convex env list`
74
- (and `npx convex env default list`). This flag shows the names of
75
- the env vars that are set, without the values. It can be useful
76
- to let AI coding agents know the variables that are set on a deployment,
77
- without giving them the actual values.
78
- - Added a new `useStaleSnapshot` option to the arguments for `runQuery`.
79
- This is an advanced feature that can be used to allow mutations
80
- to avoid optimistic concurrency control (OCC) conflicts in some cases
81
- where they can commit even though they depend on conflicting reads.
82
- This change allows us to improve the performance of some of the
83
- official Convex components, including Workpool.
84
- - Improved the documentation of `db.*` methods to more clearly explain
85
- the difference between the old APIs without table names
86
- (e.g. `db.get(userId)`) and the new APIs with table names
87
- (e.g. `db.get("users", userId)`).
88
- - Fixed an issue where the CLI would not surface permission errors
89
- correctly when the user or token doesn’t have permission to do something.
82
+ - Added a new `npx convex project create` command that can be used to create new
83
+ projects programmatically.
84
+ - Added a new `--names-only` flag to `npx convex env list` (and
85
+ `npx convex env default list`). This flag shows the names of the env vars that
86
+ are set, without the values. It can be useful to let AI coding agents know the
87
+ variables that are set on a deployment, without giving them the actual values.
88
+ - Added a new `useStaleSnapshot` option to the arguments for `runQuery`. This is
89
+ an advanced feature that can be used to allow mutations to avoid optimistic
90
+ concurrency control (OCC) conflicts in some cases where they can commit even
91
+ though they depend on conflicting reads. This change allows us to improve the
92
+ performance of some of the official Convex components, including Workpool.
93
+ - Improved the documentation of `db.*` methods to more clearly explain the
94
+ difference between the old APIs without table names (e.g. `db.get(userId)`)
95
+ and the new APIs with table names (e.g. `db.get("users", userId)`).
96
+ - Fixed an issue where the CLI would not surface permission errors correctly
97
+ when the user or token doesn’t have permission to do something.
90
98
  - Exposes the current scheduled function's ID as `scheduledFunctionId` in
91
99
  `ctx.meta.getRequestMetadata()`.
92
- - `npx convex insights` has a new `--json` flag that makes the command
93
- output easier to parse programmatically.
94
- - File storage: marked a few TypeScript types in `convex/server` as `@deprecated`
95
- (`FileMetadata`, `FileStorageId`, `StorageId`). These types are used
96
- only by file storage APIs that were deprecated in `convex@1.6.0`,
97
- so we also marked them as `@deprecated` for clarity.
100
+ - `npx convex insights` has a new `--json` flag that makes the command output
101
+ easier to parse programmatically.
102
+ - File storage: marked a few TypeScript types in `convex/server` as
103
+ `@deprecated` (`FileMetadata`, `FileStorageId`, `StorageId`). These types are
104
+ used only by file storage APIs that were deprecated in `convex@1.6.0`, so we
105
+ also marked them as `@deprecated` for clarity.
98
106
  - Bumps the `ws` peer dependency to avoid a vulnerable range.
99
107
 
100
108
  ## 1.41.0
101
- - It is now possible to set limits on nested queries and mutations
102
- with the new `transactionLimits` option in `runQuery`/`runMutation`.
103
- - `npx convex ai-files` now installs skills with separate copies of
104
- each skill for each coding agent instead of using symlinks.
105
- We made this change to avoid known issues with symlinks on Windows.
109
+
110
+ - It is now possible to set limits on nested queries and mutations with the new
111
+ `transactionLimits` option in `runQuery`/`runMutation`.
112
+ - `npx convex ai-files` now installs skills with separate copies of each skill
113
+ for each coding agent instead of using symlinks. We made this change to avoid
114
+ known issues with symlinks on Windows.
106
115
  - When using Convex in anonymous mode (without a Convex account),
107
- `npx convex dev` now starts a different dashboard server for each
108
- deployment. This ensures the dashboard always connects to the
109
- right deployment when multiple deployments are running at the same time.
116
+ `npx convex dev` now starts a different dashboard server for each deployment.
117
+ This ensures the dashboard always connects to the right deployment when
118
+ multiple deployments are running at the same time.
110
119
 
111
120
  ## 1.40.0
121
+
112
122
  - You can now create a local deployment in a specific Convex cloud project with
113
123
  `npx convex deployment create team-slug:project-slug:local`.
114
- - You can now move a local deployment to another cloud project
115
- using `npx convex deployment select team-slug:project-slug:local`. This command warns
116
- when it moves the deployment to another project.
117
- - The CLI now shows more clearly which deployment is targeted when running commands
118
- such as `npx convex dev` and `npx convex deploy`.
119
- - Added a new `<AuthRefreshing />` helper component, used to show indicators when
120
- function calls are paused because the authentication token is refreshing.
121
- - Removed `--local` and `--cloud` flags from `npx convex dev`. The behavior of these flags
122
- was misleading when a deployment was already selected. Instead, use
123
- `npx convex deployment select local` to use a local deployment, and
124
+ - You can now move a local deployment to another cloud project using
125
+ `npx convex deployment select team-slug:project-slug:local`. This command
126
+ warns when it moves the deployment to another project.
127
+ - The CLI now shows more clearly which deployment is targeted when running
128
+ commands such as `npx convex dev` and `npx convex deploy`.
129
+ - Added a new `<AuthRefreshing />` helper component, used to show indicators
130
+ when function calls are paused because the authentication token is refreshing.
131
+ - Removed `--local` and `--cloud` flags from `npx convex dev`. The behavior of
132
+ these flags was misleading when a deployment was already selected. Instead,
133
+ use `npx convex deployment select local` to use a local deployment, and
124
134
  `npx convex deployment select dev` to use your personal cloud dev deployment.
125
- - The CLI now provides guidance when TypeScript type checking is taking too long.
135
+ - The CLI now provides guidance when TypeScript type checking is taking too
136
+ long.
126
137
  - Improved the CLI command documentation to include more details and examples.
127
- - `npx convex logs`: `--tail` is now accepted as an alias for the `--history` flag.
128
- - When creating a local deployment, the CLI now skips importing the default environment variables
129
- from the Convex cloud project if you don’t have permission to view the default environment
130
- variables instead of crashing.
138
+ - `npx convex logs`: `--tail` is now accepted as an alias for the `--history`
139
+ flag.
140
+ - When creating a local deployment, the CLI now skips importing the default
141
+ environment variables from the Convex cloud project if you don’t have
142
+ permission to view the default environment variables instead of crashing.
131
143
 
132
144
  ## 1.39.1
133
145
 
@@ -135,28 +147,31 @@
135
147
 
136
148
  ## 1.39.0
137
149
 
138
- - Apps and components may now declare typesafe env vars that they require. Both `defineApp`
139
- and `defineComponent` now accept an `env` object with string keys and validator values.
140
- Declared environment variables must be present and match the validators before deployment.
150
+ - Apps and components may now declare typesafe env vars that they require. Both
151
+ `defineApp` and `defineComponent` now accept an `env` object with string keys
152
+ and validator values. Declared environment variables must be present and match
153
+ the validators before deployment.
141
154
  - Allow `--local-cloud-port`, `--local-site-port`, `--local-backend-version` and
142
- `--local-force-upgrade` options to `npx convex dev` to be used whenever using a local deployment.
143
- - The `AsyncLocalStorage` and `AsyncResource` APIs from `node:async_hooks` are now available
144
- in the standard Convex runtime. Note that stored values will not be threaded through calls to
145
- `ctx.runQuery`/`ctx.runMutation`/`ctx.runAction`.
155
+ `--local-force-upgrade` options to `npx convex dev` to be used whenever using
156
+ a local deployment.
157
+ - The `AsyncLocalStorage` and `AsyncResource` APIs from `node:async_hooks` are
158
+ now available in the standard Convex runtime. Note that stored values will not
159
+ be threaded through calls to `ctx.runQuery`/`ctx.runMutation`/`ctx.runAction`.
146
160
 
147
161
  ## 1.38.0
148
162
 
149
- - Adds `ctx.meta.getRequestMetadata()` to access request metadata in mutations and actions:
150
- request ID, client IP, and client User-Agent.
163
+ - Adds `ctx.meta.getRequestMetadata()` to access request metadata in mutations
164
+ and actions: request ID, client IP, and client User-Agent.
151
165
  - Default env vars are now imported when creating a new local deployment.
152
- - Allows creating new local deployments using `npx convex deployment select local`.
153
- - Adds support for `--expiry` and `--expires` aliases for `--expiration` in `npx
154
- convex deployment create`.
166
+ - Allows creating new local deployments using
167
+ `npx convex deployment select local`.
168
+ - Adds support for `--expiry` and `--expires` aliases for `--expiration` in
169
+ `npx convex deployment create`.
155
170
  - Supports using `import "server-only"` to mark files as server-only.
156
171
  - Removes the `npx convex disable-local-deployments` command.
157
172
  - Fixes an issue where stdout/stderr would be truncated after exit in the CLI.
158
- - Updated `usePaginatedQuery_experimental` overload that has an object-based API similar
159
- to `useQuery_experimental`.
173
+ - Updated `usePaginatedQuery_experimental` overload that has an object-based API
174
+ similar to `useQuery_experimental`.
160
175
 
161
176
  ## 1.37.0
162
177
 
@@ -480,6 +495,8 @@
480
495
  confirmation before deleting large indexes. This change is helpful for
481
496
  avoiding situations where an index is accidentally deleted and backfilling it
482
497
  takes a long time.
498
+ - You can use `v.nullable` as a convenient alias for `v.union(v.null(), ...)`
499
+ when defining validators.
483
500
 
484
501
  ## 1.29.1
485
502
 
@@ -29,7 +29,7 @@ var convex = (() => {
29
29
  });
30
30
 
31
31
  // src/index.ts
32
- var version = "1.43.0";
32
+ var version = "1.44.0";
33
33
 
34
34
  // src/values/base64.ts
35
35
  var base64_exports = {};