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.
- package/CHANGELOG.md +48 -6
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +2 -2
- package/dist/cjs/browser/http_client.js.map +2 -2
- package/dist/cjs/browser/query_options.js.map +2 -2
- package/dist/cjs/browser/simple_client.js.map +2 -2
- package/dist/cjs/browser/sync/optimistic_updates.js.map +1 -1
- package/dist/cjs/browser/sync/optimistic_updates_impl.js.map +2 -2
- package/dist/cjs/cli/codegen.js +2 -0
- package/dist/cjs/cli/codegen.js.map +2 -2
- package/dist/cjs/cli/deploy.js +1 -0
- package/dist/cjs/cli/deploy.js.map +2 -2
- package/dist/cjs/cli/docs.js +3 -36
- package/dist/cjs/cli/docs.js.map +2 -2
- package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +101 -60
- package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
- package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +107 -0
- package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
- package/dist/cjs/cli/lib/codegen.js.map +2 -2
- package/dist/cjs/cli/lib/components.js +12 -0
- package/dist/cjs/cli/lib/components.js.map +2 -2
- package/dist/cjs/cli/lib/deploy2.js +29 -2
- package/dist/cjs/cli/lib/deploy2.js.map +2 -2
- package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +73 -0
- package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +7 -0
- package/dist/cjs/cli/lib/deployApi/finishPush.js +1 -0
- package/dist/cjs/cli/lib/deployApi/finishPush.js.map +2 -2
- package/dist/cjs/cli/lib/deployApi/startPush.js +1 -1
- package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
- package/dist/cjs/cli/lib/dev.js +1 -0
- package/dist/cjs/cli/lib/dev.js.map +2 -2
- package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
- package/dist/cjs/cli/lib/localDeployment/run.js +30 -1
- package/dist/cjs/cli/lib/localDeployment/run.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/upgrade.js +6 -5
- package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/utils.js +5 -1
- package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
- package/dist/cjs/cli/lib/run.js +1 -0
- package/dist/cjs/cli/lib/run.js.map +2 -2
- package/dist/cjs/cli/lib/utils/utils.js +36 -29
- package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/nextjs/index.js.map +2 -2
- package/dist/cjs/react/client.js.map +2 -2
- package/dist/cjs/react/hydration.js.map +2 -2
- package/dist/cjs/react/queries_observer.js.map +2 -2
- package/dist/cjs/react/use_paginated_query2.js.map +2 -2
- package/dist/cjs/react/use_queries.js.map +2 -2
- package/dist/cjs/server/api.js.map +2 -2
- package/dist/cjs/server/components/index.js.map +2 -2
- package/dist/cjs/server/cron.js +10 -10
- package/dist/cjs/server/cron.js.map +2 -2
- package/dist/cjs/server/impl/actions_impl.js.map +2 -2
- package/dist/cjs/server/impl/meta_impl.js +8 -2
- package/dist/cjs/server/impl/meta_impl.js.map +2 -2
- package/dist/cjs/server/impl/scheduler_impl.js.map +2 -2
- package/dist/cjs/server/index.js.map +2 -2
- package/dist/cjs/server/meta.js.map +1 -1
- package/dist/cjs/server/registration.js.map +1 -1
- package/dist/cjs/server/scheduler.js.map +1 -1
- package/dist/cjs/server/schema.js +50 -3
- package/dist/cjs/server/schema.js.map +2 -2
- package/dist/cjs/values/validator.js +1 -1
- package/dist/cjs/values/validator.js.map +2 -2
- package/dist/cjs/values/validators.js +81 -25
- package/dist/cjs/values/validators.js.map +2 -2
- package/dist/cjs-types/browser/http_client.d.ts +5 -5
- package/dist/cjs-types/browser/http_client.d.ts.map +1 -1
- package/dist/cjs-types/browser/query_options.d.ts +2 -2
- package/dist/cjs-types/browser/query_options.d.ts.map +1 -1
- package/dist/cjs-types/browser/simple_client.d.ts +6 -6
- package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/optimistic_updates.d.ts +4 -4
- package/dist/cjs-types/browser/sync/optimistic_updates.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
- package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
- package/dist/cjs-types/cli/docs.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
- package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
- package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/codegen.d.ts +1 -0
- package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/components.d.ts +1 -0
- package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploy2.d.ts +6 -0
- package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
- package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts +1 -2
- package/dist/cjs-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
- package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/run.d.ts +2 -0
- package/dist/cjs-types/cli/lib/localDeployment/run.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +1 -0
- package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/utils.d.ts +5 -5
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/nextjs/index.d.ts +6 -6
- package/dist/cjs-types/nextjs/index.d.ts.map +1 -1
- package/dist/cjs-types/react/client.d.ts +15 -15
- package/dist/cjs-types/react/client.d.ts.map +1 -1
- package/dist/cjs-types/react/hydration.d.ts +3 -3
- package/dist/cjs-types/react/hydration.d.ts.map +1 -1
- package/dist/cjs-types/react/queries_observer.d.ts +9 -9
- package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
- package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -1
- package/dist/cjs-types/react/use_queries.d.ts +14 -6
- package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
- package/dist/cjs-types/server/api.d.ts +157 -7
- package/dist/cjs-types/server/api.d.ts.map +1 -1
- package/dist/cjs-types/server/components/index.d.ts +2 -2
- package/dist/cjs-types/server/components/index.d.ts.map +1 -1
- package/dist/cjs-types/server/cron.d.ts +21 -20
- package/dist/cjs-types/server/cron.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/actions_impl.d.ts +4 -4
- package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/meta_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/scheduler_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/index.d.ts +1 -1
- package/dist/cjs-types/server/index.d.ts.map +1 -1
- package/dist/cjs-types/server/meta.d.ts.map +1 -1
- package/dist/cjs-types/server/registration.d.ts +7 -7
- package/dist/cjs-types/server/registration.d.ts.map +1 -1
- package/dist/cjs-types/server/scheduler.d.ts +9 -7
- package/dist/cjs-types/server/scheduler.d.ts.map +1 -1
- package/dist/cjs-types/server/schema.d.ts +1 -0
- package/dist/cjs-types/server/schema.d.ts.map +1 -1
- package/dist/cjs-types/values/validator.d.ts.map +1 -1
- package/dist/cjs-types/values/validators.d.ts +30 -0
- package/dist/cjs-types/values/validators.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +347 -133
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/browser/http_client.js.map +2 -2
- package/dist/esm/browser/query_options.js.map +2 -2
- package/dist/esm/browser/simple_client.js.map +2 -2
- package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
- package/dist/esm/cli/codegen.js +2 -0
- package/dist/esm/cli/codegen.js.map +2 -2
- package/dist/esm/cli/deploy.js +1 -0
- package/dist/esm/cli/deploy.js.map +2 -2
- package/dist/esm/cli/docs.js +3 -43
- package/dist/esm/cli/docs.js.map +2 -2
- package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +100 -60
- package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
- package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +85 -0
- package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +7 -0
- package/dist/esm/cli/lib/codegen.js.map +2 -2
- package/dist/esm/cli/lib/components.js +12 -0
- package/dist/esm/cli/lib/components.js.map +2 -2
- package/dist/esm/cli/lib/deploy2.js +30 -2
- package/dist/esm/cli/lib/deploy2.js.map +2 -2
- package/dist/esm/cli/lib/deployApi/evaluateSchema.js +46 -0
- package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +7 -0
- package/dist/esm/cli/lib/deployApi/finishPush.js +1 -1
- package/dist/esm/cli/lib/deployApi/finishPush.js.map +2 -2
- package/dist/esm/cli/lib/deployApi/startPush.js +1 -1
- package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
- package/dist/esm/cli/lib/dev.js +1 -0
- package/dist/esm/cli/lib/dev.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/run.js +30 -2
- package/dist/esm/cli/lib/localDeployment/run.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/upgrade.js +4 -3
- package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/utils.js +3 -0
- package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
- package/dist/esm/cli/lib/run.js +1 -0
- package/dist/esm/cli/lib/run.js.map +2 -2
- package/dist/esm/cli/lib/utils/utils.js +36 -30
- package/dist/esm/cli/lib/utils/utils.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/nextjs/index.js.map +2 -2
- package/dist/esm/react/client.js.map +2 -2
- package/dist/esm/react/hydration.js +3 -1
- package/dist/esm/react/hydration.js.map +2 -2
- package/dist/esm/react/queries_observer.js +3 -1
- package/dist/esm/react/queries_observer.js.map +2 -2
- package/dist/esm/react/use_paginated_query2.js +3 -1
- package/dist/esm/react/use_paginated_query2.js.map +2 -2
- package/dist/esm/react/use_queries.js.map +2 -2
- package/dist/esm/server/api.js.map +2 -2
- package/dist/esm/server/components/index.js.map +2 -2
- package/dist/esm/server/cron.js +13 -11
- package/dist/esm/server/cron.js.map +2 -2
- package/dist/esm/server/impl/actions_impl.js.map +2 -2
- package/dist/esm/server/impl/meta_impl.js +9 -3
- package/dist/esm/server/impl/meta_impl.js.map +2 -2
- package/dist/esm/server/impl/scheduler_impl.js.map +2 -2
- package/dist/esm/server/index.js.map +2 -2
- package/dist/esm/server/schema.js +50 -3
- package/dist/esm/server/schema.js.map +2 -2
- package/dist/esm/values/validator.js +1 -1
- package/dist/esm/values/validator.js.map +2 -2
- package/dist/esm/values/validators.js +81 -25
- package/dist/esm/values/validators.js.map +2 -2
- package/dist/esm-types/browser/http_client.d.ts +5 -5
- package/dist/esm-types/browser/http_client.d.ts.map +1 -1
- package/dist/esm-types/browser/query_options.d.ts +2 -2
- package/dist/esm-types/browser/query_options.d.ts.map +1 -1
- package/dist/esm-types/browser/simple_client.d.ts +6 -6
- package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/optimistic_updates.d.ts +4 -4
- package/dist/esm-types/browser/sync/optimistic_updates.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
- package/dist/esm-types/cli/codegen.d.ts.map +1 -1
- package/dist/esm-types/cli/docs.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +26 -5
- package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +14 -0
- package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/codegen.d.ts +1 -0
- package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/components.d.ts +1 -0
- package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploy2.d.ts +6 -0
- package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +453 -0
- package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts +1 -2
- package/dist/esm-types/cli/lib/deployApi/finishPush.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +2 -0
- package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/run.d.ts +2 -0
- package/dist/esm-types/cli/lib/localDeployment/run.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +1 -0
- package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/utils.d.ts +5 -5
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/nextjs/index.d.ts +6 -6
- package/dist/esm-types/nextjs/index.d.ts.map +1 -1
- package/dist/esm-types/react/client.d.ts +15 -15
- package/dist/esm-types/react/client.d.ts.map +1 -1
- package/dist/esm-types/react/hydration.d.ts +3 -3
- package/dist/esm-types/react/hydration.d.ts.map +1 -1
- package/dist/esm-types/react/queries_observer.d.ts +9 -9
- package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
- package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -1
- package/dist/esm-types/react/use_queries.d.ts +14 -6
- package/dist/esm-types/react/use_queries.d.ts.map +1 -1
- package/dist/esm-types/server/api.d.ts +157 -7
- package/dist/esm-types/server/api.d.ts.map +1 -1
- package/dist/esm-types/server/components/index.d.ts +2 -2
- package/dist/esm-types/server/components/index.d.ts.map +1 -1
- package/dist/esm-types/server/cron.d.ts +21 -20
- package/dist/esm-types/server/cron.d.ts.map +1 -1
- package/dist/esm-types/server/impl/actions_impl.d.ts +4 -4
- package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/esm-types/server/impl/meta_impl.d.ts.map +1 -1
- package/dist/esm-types/server/impl/scheduler_impl.d.ts.map +1 -1
- package/dist/esm-types/server/index.d.ts +1 -1
- package/dist/esm-types/server/index.d.ts.map +1 -1
- package/dist/esm-types/server/meta.d.ts.map +1 -1
- package/dist/esm-types/server/registration.d.ts +7 -7
- package/dist/esm-types/server/registration.d.ts.map +1 -1
- package/dist/esm-types/server/scheduler.d.ts +9 -7
- package/dist/esm-types/server/scheduler.d.ts.map +1 -1
- package/dist/esm-types/server/schema.d.ts +1 -0
- package/dist/esm-types/server/schema.d.ts.map +1 -1
- package/dist/esm-types/values/validator.d.ts.map +1 -1
- package/dist/esm-types/values/validators.d.ts +30 -0
- package/dist/esm-types/values/validators.d.ts.map +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +2 -2
- package/package.json +5 -5
- package/src/browser/http_client.ts +43 -10
- package/src/browser/query_options.ts +11 -5
- package/src/browser/simple_client.ts +35 -14
- package/src/browser/sync/optimistic_updates.ts +17 -4
- package/src/browser/sync/optimistic_updates_impl.ts +17 -4
- package/src/cli/codegen.ts +1 -0
- package/src/cli/deploy.ts +1 -0
- package/src/cli/docs.ts +3 -44
- package/src/cli/lib/checkForLargeIndexDeletion.ts +154 -82
- package/src/cli/lib/checkForSlowSchemaValidation.ts +130 -0
- package/src/cli/lib/codegen.ts +1 -0
- package/src/cli/lib/components.ts +17 -0
- package/src/cli/lib/deploy2.ts +56 -1
- package/src/cli/lib/deployApi/evaluateSchema.ts +62 -0
- package/src/cli/lib/deployApi/finishPush.ts +1 -1
- package/src/cli/lib/deployApi/startPush.ts +1 -1
- package/src/cli/lib/dev.ts +1 -0
- package/src/cli/lib/generatedFunctionLogsApi.ts +2 -0
- package/src/cli/lib/localDeployment/run.ts +44 -2
- package/src/cli/lib/localDeployment/upgrade.ts +4 -6
- package/src/cli/lib/localDeployment/utils.ts +6 -0
- package/src/cli/lib/run.ts +1 -0
- package/src/cli/lib/utils/utils.ts +63 -35
- package/src/index.ts +1 -1
- package/src/nextjs/index.ts +19 -8
- package/src/react/client.ts +73 -30
- package/src/react/hydration.tsx +14 -6
- package/src/react/queries_observer.ts +19 -16
- package/src/react/use_paginated_query2.ts +10 -6
- package/src/react/use_queries.ts +23 -7
- package/src/server/api.ts +220 -14
- package/src/server/components/index.ts +4 -6
- package/src/server/cron.ts +34 -24
- package/src/server/impl/actions_impl.ts +13 -4
- package/src/server/impl/meta_impl.ts +8 -1
- package/src/server/impl/scheduler_impl.ts +13 -6
- package/src/server/index.ts +1 -0
- package/src/server/meta.ts +25 -0
- package/src/server/registration.ts +28 -7
- package/src/server/scheduler.ts +22 -7
- package/src/server/schema.ts +55 -0
- package/src/values/validator.ts +3 -1
- package/src/values/validators.ts +84 -26
|
@@ -13,10 +13,28 @@ import detect from "detect-port";
|
|
|
13
13
|
import { LOCAL_BACKEND_SENTRY_DSN } from "../utils/sentry.js";
|
|
14
14
|
import { createHash } from "crypto";
|
|
15
15
|
import { LocalDeploymentError } from "./errors.js";
|
|
16
|
-
import { LOCAL_BACKEND_INSTANCE_SECRET } from "./utils.js";
|
|
16
|
+
import { LOCAL_BACKEND_INSTANCE_SECRET, releaseDate } from "./utils.js";
|
|
17
17
|
import { DeploymentType, DetailedDeploymentCredentials } from "../api.js";
|
|
18
|
+
import { productionProvisionHost, provisionHost } from "../config.js";
|
|
18
19
|
|
|
19
20
|
const DEFAULT_STARTUP_TIMEOUT_SECS = 30;
|
|
21
|
+
const FIRST_CONTROL_PLANE_AUTH_BACKEND_VERSION =
|
|
22
|
+
"precompiled-2026-09-15-4e9b83a";
|
|
23
|
+
|
|
24
|
+
export function _backendSupportsControlPlaneAuth(version: string): boolean {
|
|
25
|
+
if (version === FIRST_CONTROL_PLANE_AUTH_BACKEND_VERSION) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const backendDate = releaseDate(version);
|
|
29
|
+
const firstSupportedDate = releaseDate(
|
|
30
|
+
FIRST_CONTROL_PLANE_AUTH_BACKEND_VERSION,
|
|
31
|
+
);
|
|
32
|
+
return (
|
|
33
|
+
backendDate !== null &&
|
|
34
|
+
firstSupportedDate !== null &&
|
|
35
|
+
backendDate > firstSupportedDate
|
|
36
|
+
);
|
|
37
|
+
}
|
|
20
38
|
|
|
21
39
|
async function parseStartupTimeoutSecs(ctx: Context): Promise<number> {
|
|
22
40
|
const raw = process.env.CONVEX_LOCAL_BACKEND_STARTUP_TIMEOUT_SECS;
|
|
@@ -44,6 +62,7 @@ export async function runLocalBackend(
|
|
|
44
62
|
deploymentKind: LocalDeploymentKind;
|
|
45
63
|
deploymentName: string;
|
|
46
64
|
binaryPath: string;
|
|
65
|
+
backendVersion: string;
|
|
47
66
|
instanceSecret: string;
|
|
48
67
|
isLatestVersion: boolean;
|
|
49
68
|
},
|
|
@@ -128,7 +147,29 @@ export async function runLocalBackend(
|
|
|
128
147
|
errForSentry: new LocalDeploymentError(message),
|
|
129
148
|
});
|
|
130
149
|
}
|
|
131
|
-
const
|
|
150
|
+
const supportsControlPlane = _backendSupportsControlPlaneAuth(
|
|
151
|
+
args.backendVersion,
|
|
152
|
+
);
|
|
153
|
+
if (supportsControlPlane && provisionHost !== productionProvisionHost) {
|
|
154
|
+
commandArgs.push("--control-plane-url", provisionHost);
|
|
155
|
+
}
|
|
156
|
+
const auth = ctx.bigBrainAuth();
|
|
157
|
+
if (
|
|
158
|
+
supportsControlPlane &&
|
|
159
|
+
args.deploymentKind === "local" &&
|
|
160
|
+
auth?.kind === "accessToken"
|
|
161
|
+
) {
|
|
162
|
+
commandArgs.push("--control-plane-access-token", auth.accessToken);
|
|
163
|
+
}
|
|
164
|
+
const displayArgs = commandArgs.map((arg, index) =>
|
|
165
|
+
index > 0 &&
|
|
166
|
+
["--instance-secret", "--control-plane-access-token"].includes(
|
|
167
|
+
commandArgs[index - 1],
|
|
168
|
+
)
|
|
169
|
+
? "[REDACTED]"
|
|
170
|
+
: arg,
|
|
171
|
+
);
|
|
172
|
+
const commandStr = `${args.binaryPath} ${displayArgs.join(" ")}`;
|
|
132
173
|
logVerbose(`Starting local backend: \`${commandStr}\``);
|
|
133
174
|
const p = child_process
|
|
134
175
|
.spawn(args.binaryPath, commandArgs, {
|
|
@@ -428,6 +469,7 @@ async function startEphemeralLocalBackend(
|
|
|
428
469
|
|
|
429
470
|
const { cleanupHandle } = await runLocalBackend(ctx, {
|
|
430
471
|
binaryPath,
|
|
472
|
+
backendVersion: config.backendVersion,
|
|
431
473
|
ports: config.ports,
|
|
432
474
|
deploymentKind,
|
|
433
475
|
deploymentName: args.deploymentName,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
saveDeploymentConfig,
|
|
11
11
|
} from "./filePaths.js";
|
|
12
12
|
import { runLocalBackend } from "./run.js";
|
|
13
|
+
import { releaseDate } from "./utils.js";
|
|
13
14
|
import { promptYesNo } from "../utils/prompts.js";
|
|
14
15
|
import { ensureBackendBinaryDownloaded } from "./download.js";
|
|
15
16
|
import {
|
|
@@ -66,6 +67,7 @@ export async function handlePotentialUpgradeAndStart(
|
|
|
66
67
|
);
|
|
67
68
|
const { cleanupHandle } = await runLocalBackend(ctx, {
|
|
68
69
|
binaryPath: args.newBinaryPath,
|
|
70
|
+
backendVersion: args.newVersion,
|
|
69
71
|
deploymentKind: args.deploymentKind,
|
|
70
72
|
deploymentName: args.deploymentName,
|
|
71
73
|
ports: args.ports,
|
|
@@ -99,6 +101,7 @@ export async function handlePotentialUpgradeAndStart(
|
|
|
99
101
|
});
|
|
100
102
|
const { cleanupHandle } = await runLocalBackend(ctx, {
|
|
101
103
|
binaryPath: oldBinaryPath,
|
|
104
|
+
backendVersion: args.oldVersion,
|
|
102
105
|
ports: args.ports,
|
|
103
106
|
deploymentKind: args.deploymentKind,
|
|
104
107
|
deploymentName: args.deploymentName,
|
|
@@ -155,6 +158,7 @@ async function handleUpgrade(
|
|
|
155
158
|
logVerbose(`Running backend on new version ${args.newVersion}`);
|
|
156
159
|
const { cleanupHandle } = await runLocalBackend(ctx, {
|
|
157
160
|
binaryPath: args.newBinaryPath,
|
|
161
|
+
backendVersion: args.newVersion,
|
|
158
162
|
ports: args.ports,
|
|
159
163
|
deploymentKind: args.deploymentKind,
|
|
160
164
|
deploymentName: args.deploymentName,
|
|
@@ -182,9 +186,3 @@ export function _isDowngrade(oldVersion: string, newVersion: string): boolean {
|
|
|
182
186
|
const newDate = releaseDate(newVersion);
|
|
183
187
|
return oldDate !== null && newDate !== null && newDate < oldDate;
|
|
184
188
|
}
|
|
185
|
-
|
|
186
|
-
// Backend releases are tagged `precompiled-YYYY-MM-DD-<commit>`, so the dates
|
|
187
|
-
// sort lexicographically.
|
|
188
|
-
function releaseDate(version: string): string | null {
|
|
189
|
-
return /^precompiled-(\d{4}-\d{2}-\d{2})-/.exec(version)?.[1] ?? null;
|
|
190
|
-
}
|
|
@@ -92,3 +92,9 @@ export function printLocalDeploymentWelcomeMessage() {
|
|
|
92
92
|
|
|
93
93
|
export const LOCAL_BACKEND_INSTANCE_SECRET =
|
|
94
94
|
"4361726e697461732c206c69746572616c6c79206d65616e696e6720226c6974";
|
|
95
|
+
|
|
96
|
+
// Backend releases are tagged `precompiled-YYYY-MM-DD-<commit>`, so the dates
|
|
97
|
+
// sort lexicographically.
|
|
98
|
+
export function releaseDate(version: string): string | null {
|
|
99
|
+
return /^precompiled-(\d{4}-\d{2}-\d{2})-/.exec(version)?.[1] ?? null;
|
|
100
|
+
}
|
package/src/cli/lib/run.ts
CHANGED
|
@@ -535,6 +535,7 @@ export async function pushToDeployment(
|
|
|
535
535
|
liveComponentSources: args.liveComponentSources,
|
|
536
536
|
pushAllModules: false,
|
|
537
537
|
largeIndexDeletionCheck: "no verification", // `convex run` can’t push to prod
|
|
538
|
+
warnOnSlowSchemaValidation: true,
|
|
538
539
|
message: null,
|
|
539
540
|
},
|
|
540
541
|
{
|
|
@@ -972,40 +972,28 @@ export function waitUntilCalled(): [Promise<unknown>, () => void] {
|
|
|
972
972
|
return [waitPromise, () => onCalled(null)];
|
|
973
973
|
}
|
|
974
974
|
|
|
975
|
-
const BYTE_UNITS
|
|
976
|
-
[1 << 30, "GiB"],
|
|
977
|
-
[1_000_000_000, "GB"],
|
|
978
|
-
[1 << 20, "MiB"],
|
|
979
|
-
[1_000_000, "MB"],
|
|
980
|
-
[1 << 10, "KiB"],
|
|
981
|
-
[1_000, "KB"],
|
|
982
|
-
];
|
|
975
|
+
const BYTE_UNITS = ["bytes", "KiB", "MiB", "GiB", "TiB", "PiB"];
|
|
983
976
|
|
|
984
977
|
/**
|
|
985
|
-
* Format a byte count into a human-friendly string
|
|
986
|
-
*
|
|
987
|
-
* Picks the unit (binary or decimal) that divides most cleanly.
|
|
988
|
-
* Shows one decimal place only when it divides exactly (e.g. "4.1 MiB").
|
|
989
|
-
* Falls back to raw bytes when no unit divides cleanly.
|
|
978
|
+
* Format a byte count into a human-friendly string, rounded to one decimal
|
|
979
|
+
* place (dropped when it would be ".0"), e.g. "4.1 MiB" or "128 MiB".
|
|
990
980
|
*/
|
|
991
981
|
export function formatSize(n: number): string {
|
|
992
|
-
|
|
993
|
-
|
|
982
|
+
let value = n;
|
|
983
|
+
let unitIndex = 0;
|
|
984
|
+
while (value >= 1024 && unitIndex < BYTE_UNITS.length - 1) {
|
|
985
|
+
value /= 1024;
|
|
986
|
+
unitIndex++;
|
|
994
987
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
if ((n * 10) % unitSize === 0) {
|
|
1003
|
-
const whole = Math.floor(n / unitSize);
|
|
1004
|
-
const frac = Math.floor((n * 10) / unitSize) % 10;
|
|
1005
|
-
return `${whole}.${frac} ${unitName}`;
|
|
1006
|
-
}
|
|
988
|
+
// Rounding to one decimal place can itself reach the next unit's
|
|
989
|
+
// boundary (e.g. 1023.999 KiB -> "1024.0 KiB" instead of "1.0 MiB").
|
|
990
|
+
const roundedValue = Number(value.toFixed(1));
|
|
991
|
+
if (roundedValue >= 1024 && unitIndex < BYTE_UNITS.length - 1) {
|
|
992
|
+
value /= 1024;
|
|
993
|
+
unitIndex++;
|
|
1007
994
|
}
|
|
1008
|
-
|
|
995
|
+
const formatted = value.toFixed(1).replace(/\.0$/, "");
|
|
996
|
+
return `${formatted} ${BYTE_UNITS[unitIndex]}`;
|
|
1009
997
|
}
|
|
1010
998
|
|
|
1011
999
|
export function formatDuration(ms: number): string {
|
|
@@ -1195,12 +1183,12 @@ export function spawnAsync(
|
|
|
1195
1183
|
|
|
1196
1184
|
const IDEMPOTENT_METHODS = ["GET", "HEAD", "PUT", "DELETE", "OPTIONS", "TRACE"];
|
|
1197
1185
|
|
|
1198
|
-
|
|
1186
|
+
// immediate, 1s delay, 2s delay, 4s delay, etc.
|
|
1187
|
+
export function retryDelay(
|
|
1199
1188
|
attempt: number,
|
|
1200
1189
|
_error: Error | null,
|
|
1201
1190
|
_response: Response | null,
|
|
1202
1191
|
): number {
|
|
1203
|
-
// immediate, 1s delay, 2s delay, 4s delay, etc.
|
|
1204
1192
|
const delay = attempt === 0 ? 1 : 2 ** (attempt - 1) * 1000;
|
|
1205
1193
|
const randomSum = delay * 0.2 * Math.random();
|
|
1206
1194
|
return delay + randomSum;
|
|
@@ -1209,8 +1197,13 @@ function retryDelay(
|
|
|
1209
1197
|
function deploymentFetchRetryOn(
|
|
1210
1198
|
onError?: (err: any, attempt: number) => void,
|
|
1211
1199
|
method?: string,
|
|
1200
|
+
maxRetries: number = MAX_RETRIES,
|
|
1201
|
+
shouldRetryOverride?: (
|
|
1202
|
+
error: Error | null,
|
|
1203
|
+
response: Response | null,
|
|
1204
|
+
) => boolean,
|
|
1212
1205
|
) {
|
|
1213
|
-
const
|
|
1206
|
+
const defaultShouldRetry = function (
|
|
1214
1207
|
_attempt: number,
|
|
1215
1208
|
error: Error | null,
|
|
1216
1209
|
response: Response | null,
|
|
@@ -1266,6 +1259,21 @@ function deploymentFetchRetryOn(
|
|
|
1266
1259
|
return { kind: "stop" };
|
|
1267
1260
|
};
|
|
1268
1261
|
|
|
1262
|
+
const shouldRetry = shouldRetryOverride
|
|
1263
|
+
? function (
|
|
1264
|
+
_attempt: number,
|
|
1265
|
+
error: Error | null,
|
|
1266
|
+
response: Response | null,
|
|
1267
|
+
): { kind: "retry"; error: any } | { kind: "stop" } {
|
|
1268
|
+
return shouldRetryOverride(error, response)
|
|
1269
|
+
? {
|
|
1270
|
+
kind: "retry",
|
|
1271
|
+
error:
|
|
1272
|
+
error ?? `Received response with status ${response?.status}`,
|
|
1273
|
+
}
|
|
1274
|
+
: { kind: "stop" };
|
|
1275
|
+
}
|
|
1276
|
+
: defaultShouldRetry;
|
|
1269
1277
|
return function (
|
|
1270
1278
|
attempt: number,
|
|
1271
1279
|
error: Error | null,
|
|
@@ -1275,7 +1283,7 @@ function deploymentFetchRetryOn(
|
|
|
1275
1283
|
if (result.kind === "retry") {
|
|
1276
1284
|
onError?.(result.error, attempt);
|
|
1277
1285
|
}
|
|
1278
|
-
if (attempt >=
|
|
1286
|
+
if (attempt >= maxRetries) {
|
|
1279
1287
|
// Stop retrying if we've exhausted all retries, but do this after we've
|
|
1280
1288
|
// called `onError` so that the caller can still log the error.
|
|
1281
1289
|
return false;
|
|
@@ -1334,15 +1342,30 @@ export function deploymentFetch(
|
|
|
1334
1342
|
deploymentUrl: string;
|
|
1335
1343
|
adminKey: string;
|
|
1336
1344
|
onError?: (err: any) => void;
|
|
1345
|
+
// Defaults to MAX_RETRIES. Lower this for best-effort requests (e.g.
|
|
1346
|
+
// advisory checks) where a slow retry loop against an unsupported or
|
|
1347
|
+
// unhealthy endpoint shouldn't hold up the surrounding command.
|
|
1348
|
+
maxRetries?: number | undefined;
|
|
1349
|
+
// Replaces the default retry policy (which is tuned for pushes: network
|
|
1350
|
+
// errors, 404s on fresh deployments, retries of idempotent methods).
|
|
1351
|
+
// Return true to retry the request. Backoff and retry logging are
|
|
1352
|
+
// shared either way.
|
|
1353
|
+
shouldRetry?: (error: Error | null, response: Response | null) => boolean;
|
|
1337
1354
|
},
|
|
1338
1355
|
): typeof fetch {
|
|
1339
|
-
const {
|
|
1356
|
+
const {
|
|
1357
|
+
deploymentUrl,
|
|
1358
|
+
adminKey,
|
|
1359
|
+
onError,
|
|
1360
|
+
maxRetries = MAX_RETRIES,
|
|
1361
|
+
shouldRetry,
|
|
1362
|
+
} = options;
|
|
1340
1363
|
const onErrorWithAttempt = (err: any, attempt: number) => {
|
|
1341
1364
|
onError?.(err);
|
|
1342
1365
|
if (attempt >= RETRY_LOG_THRESHOLD) {
|
|
1343
1366
|
logMessage(
|
|
1344
1367
|
chalkStderr.gray(
|
|
1345
|
-
`Retrying request (attempt ${attempt}/${
|
|
1368
|
+
`Retrying request (attempt ${attempt}/${maxRetries})...`,
|
|
1346
1369
|
),
|
|
1347
1370
|
);
|
|
1348
1371
|
}
|
|
@@ -1367,7 +1390,12 @@ export function deploymentFetch(
|
|
|
1367
1390
|
}
|
|
1368
1391
|
const func = throwingFetch(url, {
|
|
1369
1392
|
retryDelay,
|
|
1370
|
-
retryOn: deploymentFetchRetryOn(
|
|
1393
|
+
retryOn: deploymentFetchRetryOn(
|
|
1394
|
+
onErrorWithAttempt,
|
|
1395
|
+
options?.method,
|
|
1396
|
+
maxRetries,
|
|
1397
|
+
shouldRetry,
|
|
1398
|
+
),
|
|
1371
1399
|
...options,
|
|
1372
1400
|
headers,
|
|
1373
1401
|
});
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.46.0";
|
package/src/nextjs/index.ts
CHANGED
|
@@ -48,9 +48,10 @@ import { validateDeploymentUrl } from "../common/index.js";
|
|
|
48
48
|
import { Preloaded } from "../react/index.js";
|
|
49
49
|
import {
|
|
50
50
|
ArgsAndOptions,
|
|
51
|
-
FunctionReference,
|
|
52
51
|
FunctionReturnType,
|
|
53
52
|
getFunctionName,
|
|
53
|
+
FunctionReference,
|
|
54
|
+
FunctionReference_future,
|
|
54
55
|
} from "../server/index.js";
|
|
55
56
|
import { convexToJson, jsonToConvex } from "../values/index.js";
|
|
56
57
|
|
|
@@ -98,7 +99,9 @@ export type NextjsOptions = {
|
|
|
98
99
|
* @param options - A {@link NextjsOptions} options object for the query.
|
|
99
100
|
* @returns A promise of the `Preloaded` payload.
|
|
100
101
|
*/
|
|
101
|
-
export async function preloadQuery<
|
|
102
|
+
export async function preloadQuery<
|
|
103
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
104
|
+
>(
|
|
102
105
|
query: Query,
|
|
103
106
|
...args: ArgsAndOptions<Query, NextjsOptions>
|
|
104
107
|
): Promise<Preloaded<Query>> {
|
|
@@ -117,9 +120,9 @@ export async function preloadQuery<Query extends FunctionReference<"query">>(
|
|
|
117
120
|
* @param preloaded - The `Preloaded` payload returned by {@link preloadQuery}.
|
|
118
121
|
* @returns The query result.
|
|
119
122
|
*/
|
|
120
|
-
export function preloadedQueryResult<
|
|
121
|
-
|
|
122
|
-
): FunctionReturnType<Query> {
|
|
123
|
+
export function preloadedQueryResult<
|
|
124
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
125
|
+
>(preloaded: Preloaded<Query>): FunctionReturnType<Query> {
|
|
123
126
|
return jsonToConvex(preloaded._valueJSON);
|
|
124
127
|
}
|
|
125
128
|
|
|
@@ -133,7 +136,9 @@ export function preloadedQueryResult<Query extends FunctionReference<"query">>(
|
|
|
133
136
|
* @param options - A {@link NextjsOptions} options object for the query.
|
|
134
137
|
* @returns A promise of the query's result.
|
|
135
138
|
*/
|
|
136
|
-
export async function fetchQuery<
|
|
139
|
+
export async function fetchQuery<
|
|
140
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
141
|
+
>(
|
|
137
142
|
query: Query,
|
|
138
143
|
...args: ArgsAndOptions<Query, NextjsOptions>
|
|
139
144
|
): Promise<FunctionReturnType<Query>> {
|
|
@@ -153,7 +158,9 @@ export async function fetchQuery<Query extends FunctionReference<"query">>(
|
|
|
153
158
|
* @returns A promise of the mutation's result.
|
|
154
159
|
*/
|
|
155
160
|
export async function fetchMutation<
|
|
156
|
-
Mutation extends
|
|
161
|
+
Mutation extends
|
|
162
|
+
| FunctionReference<"mutation">
|
|
163
|
+
| FunctionReference_future<"mutation">,
|
|
157
164
|
>(
|
|
158
165
|
mutation: Mutation,
|
|
159
166
|
...args: ArgsAndOptions<Mutation, NextjsOptions>
|
|
@@ -173,7 +180,11 @@ export async function fetchMutation<
|
|
|
173
180
|
* @param options - A {@link NextjsOptions} options object for the action.
|
|
174
181
|
* @returns A promise of the action's result.
|
|
175
182
|
*/
|
|
176
|
-
export async function fetchAction<
|
|
183
|
+
export async function fetchAction<
|
|
184
|
+
Action extends
|
|
185
|
+
| FunctionReference<"action">
|
|
186
|
+
| FunctionReference_future<"action">,
|
|
187
|
+
>(
|
|
177
188
|
action: Action,
|
|
178
189
|
...args: ArgsAndOptions<Action, NextjsOptions>
|
|
179
190
|
): Promise<FunctionReturnType<Action>> {
|
package/src/react/client.ts
CHANGED
|
@@ -21,11 +21,12 @@ import { parseArgs } from "../common/index.js";
|
|
|
21
21
|
import {
|
|
22
22
|
ArgsAndOptions,
|
|
23
23
|
FunctionArgs,
|
|
24
|
-
FunctionReference,
|
|
25
24
|
FunctionReturnType,
|
|
26
25
|
OptionalRestArgs,
|
|
27
26
|
getFunctionName,
|
|
28
27
|
makeFunctionReference,
|
|
28
|
+
FunctionReference,
|
|
29
|
+
FunctionReference_future,
|
|
29
30
|
} from "../server/api.js";
|
|
30
31
|
import { EmptyObject } from "../server/registration.js";
|
|
31
32
|
import {
|
|
@@ -55,7 +56,11 @@ if (typeof React === "undefined") {
|
|
|
55
56
|
*
|
|
56
57
|
* @public
|
|
57
58
|
*/
|
|
58
|
-
export interface ReactMutation<
|
|
59
|
+
export interface ReactMutation<
|
|
60
|
+
Mutation extends
|
|
61
|
+
| FunctionReference<"mutation">
|
|
62
|
+
| FunctionReference_future<"mutation">,
|
|
63
|
+
> {
|
|
59
64
|
/**
|
|
60
65
|
* Execute the mutation on the server, returning a `Promise` of its return value.
|
|
61
66
|
*
|
|
@@ -95,7 +100,9 @@ export interface ReactMutation<Mutation extends FunctionReference<"mutation">> {
|
|
|
95
100
|
|
|
96
101
|
// Exported only for testing.
|
|
97
102
|
export function createMutation(
|
|
98
|
-
mutationReference:
|
|
103
|
+
mutationReference:
|
|
104
|
+
| FunctionReference<"mutation">
|
|
105
|
+
| FunctionReference_future<"mutation">,
|
|
99
106
|
client: ConvexReactClient,
|
|
100
107
|
update?: OptimisticUpdate<any>,
|
|
101
108
|
): ReactMutation<any> {
|
|
@@ -126,7 +133,11 @@ export function createMutation(
|
|
|
126
133
|
*
|
|
127
134
|
* @public
|
|
128
135
|
*/
|
|
129
|
-
export interface ReactAction<
|
|
136
|
+
export interface ReactAction<
|
|
137
|
+
Action extends
|
|
138
|
+
| FunctionReference<"action">
|
|
139
|
+
| FunctionReference_future<"action">,
|
|
140
|
+
> {
|
|
130
141
|
/**
|
|
131
142
|
* Execute the function on the server, returning a `Promise` of its return value.
|
|
132
143
|
*
|
|
@@ -138,7 +149,9 @@ export interface ReactAction<Action extends FunctionReference<"action">> {
|
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
function createAction(
|
|
141
|
-
actionReference:
|
|
152
|
+
actionReference:
|
|
153
|
+
| FunctionReference<"action">
|
|
154
|
+
| FunctionReference_future<"action">,
|
|
142
155
|
client: ConvexReactClient,
|
|
143
156
|
): ReactAction<any> {
|
|
144
157
|
return function (args?: Record<string, Value>): Promise<unknown> {
|
|
@@ -481,7 +494,11 @@ export class ConvexReactClient {
|
|
|
481
494
|
*
|
|
482
495
|
* @returns The {@link Watch} object.
|
|
483
496
|
*/
|
|
484
|
-
watchQuery<
|
|
497
|
+
watchQuery<
|
|
498
|
+
Query extends
|
|
499
|
+
| FunctionReference<"query">
|
|
500
|
+
| FunctionReference_future<"query">,
|
|
501
|
+
>(
|
|
485
502
|
query: Query,
|
|
486
503
|
...argsAndOptions: ArgsAndOptions<Query, WatchQueryOptions>
|
|
487
504
|
): Watch<FunctionReturnType<Query>> {
|
|
@@ -557,9 +574,11 @@ export class ConvexReactClient {
|
|
|
557
574
|
* @param queryOptions - A query (function reference from an api object) and its args, plus
|
|
558
575
|
* an optional extendSubscriptionFor for how long to subscribe to the query.
|
|
559
576
|
*/
|
|
560
|
-
prewarmQuery<
|
|
561
|
-
|
|
562
|
-
|
|
577
|
+
prewarmQuery<
|
|
578
|
+
Query extends
|
|
579
|
+
| FunctionReference<"query">
|
|
580
|
+
| FunctionReference_future<"query">,
|
|
581
|
+
>(queryOptions: QueryOptions<Query> & { extendSubscriptionFor?: number }) {
|
|
563
582
|
const extendSubscriptionFor =
|
|
564
583
|
queryOptions.extendSubscriptionFor ?? DEFAULT_EXTEND_SUBSCRIPTION_FOR;
|
|
565
584
|
const watch = this.watchQuery(queryOptions.query, queryOptions.args || {});
|
|
@@ -584,9 +603,13 @@ export class ConvexReactClient {
|
|
|
584
603
|
*
|
|
585
604
|
* @internal
|
|
586
605
|
*/
|
|
587
|
-
watchPaginatedQuery<
|
|
606
|
+
watchPaginatedQuery<
|
|
607
|
+
Query extends
|
|
608
|
+
| FunctionReference<"query">
|
|
609
|
+
| FunctionReference_future<"query">,
|
|
610
|
+
>(
|
|
588
611
|
query: Query,
|
|
589
|
-
args: Query
|
|
612
|
+
args: FunctionArgs<Query>,
|
|
590
613
|
options: WatchPaginatedQueryOptions,
|
|
591
614
|
): PaginatedWatch<FunctionReturnType<Query>> {
|
|
592
615
|
const name = getFunctionName(query);
|
|
@@ -634,7 +657,11 @@ export class ConvexReactClient {
|
|
|
634
657
|
* @param options - A {@link MutationOptions} options object for the mutation.
|
|
635
658
|
* @returns A promise of the mutation's result.
|
|
636
659
|
*/
|
|
637
|
-
mutation<
|
|
660
|
+
mutation<
|
|
661
|
+
Mutation extends
|
|
662
|
+
| FunctionReference<"mutation">
|
|
663
|
+
| FunctionReference_future<"mutation">,
|
|
664
|
+
>(
|
|
638
665
|
mutation: Mutation,
|
|
639
666
|
...argsAndOptions: ArgsAndOptions<
|
|
640
667
|
Mutation,
|
|
@@ -655,7 +682,11 @@ export class ConvexReactClient {
|
|
|
655
682
|
* the arguments will be `{}`.
|
|
656
683
|
* @returns A promise of the action's result.
|
|
657
684
|
*/
|
|
658
|
-
action<
|
|
685
|
+
action<
|
|
686
|
+
Action extends
|
|
687
|
+
| FunctionReference<"action">
|
|
688
|
+
| FunctionReference_future<"action">,
|
|
689
|
+
>(
|
|
659
690
|
action: Action,
|
|
660
691
|
...args: OptionalRestArgs<Action>
|
|
661
692
|
): Promise<FunctionReturnType<Action>> {
|
|
@@ -675,7 +706,11 @@ export class ConvexReactClient {
|
|
|
675
706
|
* the arguments will be `{}`.
|
|
676
707
|
* @returns A promise of the query's result.
|
|
677
708
|
*/
|
|
678
|
-
query<
|
|
709
|
+
query<
|
|
710
|
+
Query extends
|
|
711
|
+
| FunctionReference<"query">
|
|
712
|
+
| FunctionReference_future<"query">,
|
|
713
|
+
>(
|
|
679
714
|
query: Query,
|
|
680
715
|
...args: OptionalRestArgs<Query>
|
|
681
716
|
): Promise<FunctionReturnType<Query>> {
|
|
@@ -815,10 +850,12 @@ export const ConvexProvider: React.FC<{
|
|
|
815
850
|
);
|
|
816
851
|
};
|
|
817
852
|
|
|
818
|
-
export type OptionalRestArgsOrSkip<
|
|
819
|
-
FuncRef
|
|
853
|
+
export type OptionalRestArgsOrSkip<
|
|
854
|
+
FuncRef extends FunctionReference<any> | FunctionReference_future<any>,
|
|
855
|
+
> =
|
|
856
|
+
FunctionArgs<FuncRef> extends EmptyObject
|
|
820
857
|
? [args?: EmptyObject | "skip"]
|
|
821
|
-
: [args: FuncRef
|
|
858
|
+
: [args: FunctionArgs<FuncRef> | "skip"];
|
|
822
859
|
|
|
823
860
|
/**
|
|
824
861
|
* Result returned by object-form {@link useQuery_experimental}.
|
|
@@ -831,7 +868,7 @@ export type UseQueryResult<QueryResult, ThrowOnError extends boolean = false> =
|
|
|
831
868
|
| (ThrowOnError extends true ? never : { status: "error"; error: Error });
|
|
832
869
|
|
|
833
870
|
type UseQueryOptions<
|
|
834
|
-
Query extends FunctionReference<"query">,
|
|
871
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
835
872
|
ThrowOnError extends boolean,
|
|
836
873
|
> = {
|
|
837
874
|
query: Query;
|
|
@@ -882,10 +919,12 @@ type UseQueryOptions<
|
|
|
882
919
|
* @see https://docs.convex.dev/client/react#fetching-data
|
|
883
920
|
* @public
|
|
884
921
|
*/
|
|
885
|
-
export function useQuery<
|
|
922
|
+
export function useQuery<
|
|
923
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
924
|
+
>(
|
|
886
925
|
query: Query,
|
|
887
926
|
...args: OptionalRestArgsOrSkip<Query>
|
|
888
|
-
): Query
|
|
927
|
+
): FunctionReturnType<Query> | undefined {
|
|
889
928
|
const skip = args[0] === "skip";
|
|
890
929
|
const argsObject = args[0] === "skip" ? {} : parseArgs(args[0]);
|
|
891
930
|
const queryReference =
|
|
@@ -947,18 +986,18 @@ export function useQuery<Query extends FunctionReference<"query">>(
|
|
|
947
986
|
* @public
|
|
948
987
|
*/
|
|
949
988
|
export function useQuery_experimental<
|
|
950
|
-
Query extends FunctionReference<"query">,
|
|
989
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
951
990
|
ThrowOnError extends boolean = false,
|
|
952
991
|
>(
|
|
953
992
|
options: UseQueryOptions<Query, ThrowOnError>,
|
|
954
|
-
): UseQueryResult<Query
|
|
993
|
+
): UseQueryResult<FunctionReturnType<Query>, ThrowOnError>;
|
|
955
994
|
|
|
956
995
|
export function useQuery_experimental<
|
|
957
|
-
Query extends FunctionReference<"query">,
|
|
996
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
958
997
|
ThrowOnError extends boolean = false,
|
|
959
998
|
>(
|
|
960
999
|
options: UseQueryOptions<Query, ThrowOnError>,
|
|
961
|
-
): UseQueryResult<Query
|
|
1000
|
+
): UseQueryResult<FunctionReturnType<Query>, false> {
|
|
962
1001
|
const throwOnError = options.throwOnError ?? false;
|
|
963
1002
|
const queryReference =
|
|
964
1003
|
typeof options.query === "string"
|
|
@@ -1042,9 +1081,11 @@ export function useQuery_experimental<
|
|
|
1042
1081
|
* @see https://docs.convex.dev/client/react#editing-data
|
|
1043
1082
|
* @public
|
|
1044
1083
|
*/
|
|
1045
|
-
export function useMutation<
|
|
1046
|
-
|
|
1047
|
-
|
|
1084
|
+
export function useMutation<
|
|
1085
|
+
Mutation extends
|
|
1086
|
+
| FunctionReference<"mutation">
|
|
1087
|
+
| FunctionReference_future<"mutation">,
|
|
1088
|
+
>(mutation: Mutation): ReactMutation<Mutation> {
|
|
1048
1089
|
const mutationReference =
|
|
1049
1090
|
typeof mutation === "string"
|
|
1050
1091
|
? makeFunctionReference<"mutation", any, any>(mutation)
|
|
@@ -1111,9 +1152,11 @@ export function useMutation<Mutation extends FunctionReference<"mutation">>(
|
|
|
1111
1152
|
* @see https://docs.convex.dev/functions/actions#calling-actions-from-clients
|
|
1112
1153
|
* @public
|
|
1113
1154
|
*/
|
|
1114
|
-
export function useAction<
|
|
1115
|
-
|
|
1116
|
-
|
|
1155
|
+
export function useAction<
|
|
1156
|
+
Action extends
|
|
1157
|
+
| FunctionReference<"action">
|
|
1158
|
+
| FunctionReference_future<"action">,
|
|
1159
|
+
>(action: Action): ReactAction<Action> {
|
|
1117
1160
|
const convex = useContext(ConvexContext);
|
|
1118
1161
|
const actionReference =
|
|
1119
1162
|
typeof action === "string"
|
package/src/react/hydration.tsx
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useQuery } from "../react/client.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FunctionArgs,
|
|
5
|
+
FunctionReturnType,
|
|
6
|
+
makeFunctionReference,
|
|
7
|
+
FunctionReference,
|
|
8
|
+
FunctionReference_future,
|
|
9
|
+
} from "../server/api.js";
|
|
4
10
|
import { jsonToConvex } from "../values/index.js";
|
|
5
11
|
|
|
6
12
|
/**
|
|
@@ -9,7 +15,9 @@ import { jsonToConvex } from "../values/index.js";
|
|
|
9
15
|
*
|
|
10
16
|
* @public
|
|
11
17
|
*/
|
|
12
|
-
export type Preloaded<
|
|
18
|
+
export type Preloaded<
|
|
19
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
20
|
+
> = {
|
|
13
21
|
__type: Query;
|
|
14
22
|
_name: string;
|
|
15
23
|
_argsJSON: string;
|
|
@@ -31,13 +39,13 @@ export type Preloaded<Query extends FunctionReference<"query">> = {
|
|
|
31
39
|
*
|
|
32
40
|
* @public
|
|
33
41
|
*/
|
|
34
|
-
export function usePreloadedQuery<
|
|
35
|
-
|
|
36
|
-
): Query
|
|
42
|
+
export function usePreloadedQuery<
|
|
43
|
+
Query extends FunctionReference<"query"> | FunctionReference_future<"query">,
|
|
44
|
+
>(preloadedQuery: Preloaded<Query>): FunctionReturnType<Query> {
|
|
37
45
|
const args = useMemo(
|
|
38
46
|
() => jsonToConvex(preloadedQuery._argsJSON),
|
|
39
47
|
[preloadedQuery._argsJSON],
|
|
40
|
-
) as Query
|
|
48
|
+
) as FunctionArgs<Query>;
|
|
41
49
|
const preloadedResult = useMemo(
|
|
42
50
|
() => jsonToConvex(preloadedQuery._valueJSON),
|
|
43
51
|
[preloadedQuery._valueJSON],
|