convex 1.24.3 → 1.24.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.24.4
4
+
5
+ - `ConvexClient.mutation()` now accepts a third `options` argument that can
6
+ contain an optimistic update.
7
+
8
+ - Log a warning when optimistic update handlers return a promise since they
9
+ should be sync.
10
+
3
11
  ## 1.24.3
4
12
 
5
13
  - Add `.url` property to ConvexReactClient.
@@ -28,7 +28,7 @@ var convex = (() => {
28
28
  });
29
29
 
30
30
  // src/index.ts
31
- var version = "1.24.3";
31
+ var version = "1.24.5";
32
32
 
33
33
  // src/values/base64.ts
34
34
  var base64_exports = {};
@@ -2804,7 +2804,15 @@ var convex = (() => {
2804
2804
  const optimisticUpdate = options.optimisticUpdate;
2805
2805
  if (optimisticUpdate !== void 0) {
2806
2806
  const wrappedUpdate = (localQueryStore) => {
2807
- optimisticUpdate(localQueryStore, mutationArgs);
2807
+ const result = optimisticUpdate(
2808
+ localQueryStore,
2809
+ mutationArgs
2810
+ );
2811
+ if (result instanceof Promise) {
2812
+ this.logger.warn(
2813
+ "Optimistic update handler returned a Promise. Optimistic updates should be synchronous."
2814
+ );
2815
+ }
2808
2816
  };
2809
2817
  const changedQueryTokens = this.optimisticQueryResults.applyOptimisticUpdate(
2810
2818
  wrappedUpdate,
@@ -3174,9 +3182,9 @@ var convex = (() => {
3174
3182
  * @param options - A {@link MutationOptions} options object for the mutation.
3175
3183
  * @returns A promise of the mutation's result.
3176
3184
  */
3177
- async mutation(mutation, args) {
3185
+ async mutation(mutation, args, options) {
3178
3186
  if (this.disabled) throw new Error("ConvexClient is disabled");
3179
- return await this.client.mutation(getFunctionName(mutation), args);
3187
+ return await this.client.mutation(getFunctionName(mutation), args, options);
3180
3188
  }
3181
3189
  /**
3182
3190
  * Execute an action function.