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
|
@@ -2,7 +2,10 @@ import { convexToJson, jsonToConvex, Value } from "../../values/index.js";
|
|
|
2
2
|
import { version } from "../../index.js";
|
|
3
3
|
import { performAsyncSyscall } from "./syscall.js";
|
|
4
4
|
import { parseArgs } from "../../common/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
FunctionReference,
|
|
7
|
+
FunctionReference_future,
|
|
8
|
+
} from "../../server/api.js";
|
|
6
9
|
import { getFunctionAddress } from "../components/paths.js";
|
|
7
10
|
import { validateArg } from "./validate.js";
|
|
8
11
|
|
|
@@ -23,7 +26,9 @@ function syscallArgs(
|
|
|
23
26
|
export function setupActionCalls(requestId: string) {
|
|
24
27
|
return {
|
|
25
28
|
runQuery: async (
|
|
26
|
-
query:
|
|
29
|
+
query:
|
|
30
|
+
| FunctionReference<"query", "public" | "internal">
|
|
31
|
+
| FunctionReference_future<"query", "public" | "internal">,
|
|
27
32
|
args?: Record<string, Value>,
|
|
28
33
|
): Promise<any> => {
|
|
29
34
|
const result = await performAsyncSyscall(
|
|
@@ -33,7 +38,9 @@ export function setupActionCalls(requestId: string) {
|
|
|
33
38
|
return jsonToConvex(result);
|
|
34
39
|
},
|
|
35
40
|
runMutation: async (
|
|
36
|
-
mutation:
|
|
41
|
+
mutation:
|
|
42
|
+
| FunctionReference<"mutation", "public" | "internal">
|
|
43
|
+
| FunctionReference_future<"mutation", "public" | "internal">,
|
|
37
44
|
args?: Record<string, Value>,
|
|
38
45
|
): Promise<any> => {
|
|
39
46
|
const result = await performAsyncSyscall(
|
|
@@ -43,7 +50,9 @@ export function setupActionCalls(requestId: string) {
|
|
|
43
50
|
return jsonToConvex(result);
|
|
44
51
|
},
|
|
45
52
|
runAction: async (
|
|
46
|
-
action:
|
|
53
|
+
action:
|
|
54
|
+
| FunctionReference<"action", "public" | "internal">
|
|
55
|
+
| FunctionReference_future<"action", "public" | "internal">,
|
|
47
56
|
args?: Record<string, Value>,
|
|
48
57
|
): Promise<any> => {
|
|
49
58
|
const result = await performAsyncSyscall(
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
TransactionMetrics,
|
|
9
9
|
DeploymentMetadata,
|
|
10
10
|
} from "../meta.js";
|
|
11
|
-
import { performAsyncSyscall } from "./syscall.js";
|
|
11
|
+
import { performAsyncSyscall, performSyscall } from "./syscall.js";
|
|
12
12
|
|
|
13
13
|
async function getTransactionMetrics(): Promise<TransactionMetrics> {
|
|
14
14
|
let syscallJSON;
|
|
@@ -53,6 +53,11 @@ async function getDeploymentMetadata(): Promise<DeploymentMetadata> {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function getSnapshotTs(): bigint {
|
|
57
|
+
const syscallJSON = performSyscall("1.0/getSnapshotTs", {});
|
|
58
|
+
return jsonToConvex(syscallJSON) as bigint;
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
async function getRequestMetadata(): Promise<RequestMetadata> {
|
|
57
62
|
const { ip, userAgent, requestId, scheduledFunctionId, authToken } =
|
|
58
63
|
await performAsyncSyscall("1.0/getRequestMetadata", {});
|
|
@@ -70,6 +75,7 @@ export function setupQueryMeta(
|
|
|
70
75
|
}),
|
|
71
76
|
getTransactionMetrics,
|
|
72
77
|
getDeploymentMetadata,
|
|
78
|
+
getSnapshotTs,
|
|
73
79
|
};
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -85,6 +91,7 @@ export function setupMutationMeta(
|
|
|
85
91
|
getTransactionMetrics,
|
|
86
92
|
getDeploymentMetadata,
|
|
87
93
|
getRequestMetadata,
|
|
94
|
+
getSnapshotTs,
|
|
88
95
|
};
|
|
89
96
|
}
|
|
90
97
|
|
|
@@ -3,15 +3,22 @@ import { version } from "../../index.js";
|
|
|
3
3
|
import { performAsyncSyscall } from "./syscall.js";
|
|
4
4
|
import { parseArgs } from "../../common/index.js";
|
|
5
5
|
import { SchedulableFunctionReference, Scheduler } from "../scheduler.js";
|
|
6
|
+
import { FunctionReference_future } from "../api.js";
|
|
6
7
|
import { Id } from "../../values/value.js";
|
|
7
8
|
import { validateArg } from "./validate.js";
|
|
8
9
|
import { getFunctionAddress } from "../components/paths.js";
|
|
9
10
|
|
|
11
|
+
// Mirrors the constraint on `Scheduler.runAfter` and `Scheduler.runAt`, which
|
|
12
|
+
// is module-local to `scheduler.ts`.
|
|
13
|
+
type SchedulableFunctionReferenceCompat =
|
|
14
|
+
| SchedulableFunctionReference
|
|
15
|
+
| FunctionReference_future<"mutation" | "action", "public" | "internal">;
|
|
16
|
+
|
|
10
17
|
export function setupMutationScheduler(): Scheduler {
|
|
11
18
|
return {
|
|
12
19
|
runAfter: async (
|
|
13
20
|
delayMs: number,
|
|
14
|
-
functionReference:
|
|
21
|
+
functionReference: SchedulableFunctionReferenceCompat,
|
|
15
22
|
args?: Record<string, Value>,
|
|
16
23
|
) => {
|
|
17
24
|
const syscallArgs = runAfterSyscallArgs(delayMs, functionReference, args);
|
|
@@ -19,7 +26,7 @@ export function setupMutationScheduler(): Scheduler {
|
|
|
19
26
|
},
|
|
20
27
|
runAt: async (
|
|
21
28
|
ms_since_epoch_or_date: number | Date,
|
|
22
|
-
functionReference:
|
|
29
|
+
functionReference: SchedulableFunctionReferenceCompat,
|
|
23
30
|
args?: Record<string, Value>,
|
|
24
31
|
) => {
|
|
25
32
|
const syscallArgs = runAtSyscallArgs(
|
|
@@ -41,7 +48,7 @@ export function setupActionScheduler(requestId: string): Scheduler {
|
|
|
41
48
|
return {
|
|
42
49
|
runAfter: async (
|
|
43
50
|
delayMs: number,
|
|
44
|
-
functionReference:
|
|
51
|
+
functionReference: SchedulableFunctionReferenceCompat,
|
|
45
52
|
args?: Record<string, Value>,
|
|
46
53
|
) => {
|
|
47
54
|
const syscallArgs = {
|
|
@@ -52,7 +59,7 @@ export function setupActionScheduler(requestId: string): Scheduler {
|
|
|
52
59
|
},
|
|
53
60
|
runAt: async (
|
|
54
61
|
ms_since_epoch_or_date: number | Date,
|
|
55
|
-
functionReference:
|
|
62
|
+
functionReference: SchedulableFunctionReferenceCompat,
|
|
56
63
|
args?: Record<string, Value>,
|
|
57
64
|
) => {
|
|
58
65
|
const syscallArgs = {
|
|
@@ -74,7 +81,7 @@ export function setupActionScheduler(requestId: string): Scheduler {
|
|
|
74
81
|
|
|
75
82
|
function runAfterSyscallArgs(
|
|
76
83
|
delayMs: number,
|
|
77
|
-
functionReference:
|
|
84
|
+
functionReference: SchedulableFunctionReferenceCompat,
|
|
78
85
|
args?: Record<string, Value>,
|
|
79
86
|
) {
|
|
80
87
|
if (typeof delayMs !== "number") {
|
|
@@ -100,7 +107,7 @@ function runAfterSyscallArgs(
|
|
|
100
107
|
|
|
101
108
|
function runAtSyscallArgs(
|
|
102
109
|
ms_since_epoch_or_date: number | Date,
|
|
103
|
-
functionReference:
|
|
110
|
+
functionReference: SchedulableFunctionReferenceCompat,
|
|
104
111
|
args?: Record<string, Value>,
|
|
105
112
|
) {
|
|
106
113
|
let ts;
|
package/src/server/index.ts
CHANGED
package/src/server/meta.ts
CHANGED
|
@@ -133,6 +133,31 @@ export interface QueryMeta {
|
|
|
133
133
|
getFunctionMetadata(): Promise<FunctionMetadata>;
|
|
134
134
|
getTransactionMetrics(): Promise<TransactionMetrics>;
|
|
135
135
|
getDeploymentMetadata(): Promise<DeploymentMetadata>;
|
|
136
|
+
/**
|
|
137
|
+
* @internal
|
|
138
|
+
* Returns the timestamp of the database snapshot this transaction reads
|
|
139
|
+
* from, in nanoseconds.
|
|
140
|
+
*
|
|
141
|
+
* All commits at or before this timestamp are observable within the
|
|
142
|
+
* transaction, and no later commits are. The value is fixed for the
|
|
143
|
+
* lifetime of the transaction and shared with all nested `runMutation` and
|
|
144
|
+
* `runQuery` calls.
|
|
145
|
+
*
|
|
146
|
+
* It is on the same clock as `db.vars.commitTs`: documents observable in
|
|
147
|
+
* this transaction have `commitTs` values at or before this timestamp, and
|
|
148
|
+
* no new documents will be written with a `commitTs` at or below this,
|
|
149
|
+
* including from the current transaction. When reading documents with an
|
|
150
|
+
* index in commitTs order, you can use this as an upper bound to prevent
|
|
151
|
+
* conflicting with racing inserts.
|
|
152
|
+
*
|
|
153
|
+
* Since the timestamp differs on every execution, calling this in a query
|
|
154
|
+
* limits caching of the query's result the same way `Date.now()` does.
|
|
155
|
+
*
|
|
156
|
+
* Note: this should not be compared to `_creationTime` or `Date.now()`, as
|
|
157
|
+
* those are based on wall-clock time rather than the database clock, and
|
|
158
|
+
* aren't guaranteed to follow commit order.
|
|
159
|
+
*/
|
|
160
|
+
getSnapshotTs(): bigint;
|
|
136
161
|
}
|
|
137
162
|
|
|
138
163
|
/**
|
|
@@ -16,10 +16,11 @@ import {
|
|
|
16
16
|
} from "./meta.js";
|
|
17
17
|
import {
|
|
18
18
|
ArgsAndOptions,
|
|
19
|
-
FunctionReference,
|
|
20
19
|
FunctionReturnType,
|
|
21
20
|
OptionalRestArgs,
|
|
22
21
|
ValidatorTypeToReturnType,
|
|
22
|
+
FunctionReference,
|
|
23
|
+
FunctionReference_future,
|
|
23
24
|
} from "../server/api.js";
|
|
24
25
|
import {
|
|
25
26
|
GenericValidator,
|
|
@@ -133,7 +134,11 @@ export interface GenericMutationCtx<DataModel extends GenericDataModel> {
|
|
|
133
134
|
* const user = await ctx.runQuery(internal.users.getUser, { userId });
|
|
134
135
|
* ```
|
|
135
136
|
*/
|
|
136
|
-
runQuery: <
|
|
137
|
+
runQuery: <
|
|
138
|
+
Query extends
|
|
139
|
+
| FunctionReference<"query", "public" | "internal">
|
|
140
|
+
| FunctionReference_future<"query", "public" | "internal">,
|
|
141
|
+
>(
|
|
137
142
|
query: Query,
|
|
138
143
|
...args: ArgsAndOptions<Query, AdvancedRunQueryOptions>
|
|
139
144
|
) => Promise<FunctionReturnType<Query>>;
|
|
@@ -149,7 +154,9 @@ export interface GenericMutationCtx<DataModel extends GenericDataModel> {
|
|
|
149
154
|
* validation, and creating a new isolated JS context.
|
|
150
155
|
*/
|
|
151
156
|
runMutation: <
|
|
152
|
-
Mutation extends
|
|
157
|
+
Mutation extends
|
|
158
|
+
| FunctionReference<"mutation", "public" | "internal">
|
|
159
|
+
| FunctionReference_future<"mutation", "public" | "internal">,
|
|
153
160
|
>(
|
|
154
161
|
mutation: Mutation,
|
|
155
162
|
...args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>
|
|
@@ -243,7 +250,11 @@ export interface GenericQueryCtx<DataModel extends GenericDataModel> {
|
|
|
243
250
|
* `runQuery` incurs overhead of running argument and return value validation,
|
|
244
251
|
* and creating a new isolated JS context.
|
|
245
252
|
*/
|
|
246
|
-
runQuery: <
|
|
253
|
+
runQuery: <
|
|
254
|
+
Query extends
|
|
255
|
+
| FunctionReference<"query", "public" | "internal">
|
|
256
|
+
| FunctionReference_future<"query", "public" | "internal">,
|
|
257
|
+
>(
|
|
247
258
|
query: Query,
|
|
248
259
|
...args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>
|
|
249
260
|
) => Promise<FunctionReturnType<Query>>;
|
|
@@ -326,7 +337,11 @@ export interface GenericActionCtx<DataModel extends GenericDataModel> {
|
|
|
326
337
|
* @param args - The arguments to the query function.
|
|
327
338
|
* @returns A promise of the query's result.
|
|
328
339
|
*/
|
|
329
|
-
runQuery<
|
|
340
|
+
runQuery<
|
|
341
|
+
Query extends
|
|
342
|
+
| FunctionReference<"query", "public" | "internal">
|
|
343
|
+
| FunctionReference_future<"query", "public" | "internal">,
|
|
344
|
+
>(
|
|
330
345
|
query: Query,
|
|
331
346
|
...args: OptionalRestArgs<Query>
|
|
332
347
|
): Promise<FunctionReturnType<Query>>;
|
|
@@ -347,7 +362,9 @@ export interface GenericActionCtx<DataModel extends GenericDataModel> {
|
|
|
347
362
|
* @returns A promise of the mutation's result.
|
|
348
363
|
*/
|
|
349
364
|
runMutation<
|
|
350
|
-
Mutation extends
|
|
365
|
+
Mutation extends
|
|
366
|
+
| FunctionReference<"mutation", "public" | "internal">
|
|
367
|
+
| FunctionReference_future<"mutation", "public" | "internal">,
|
|
351
368
|
>(
|
|
352
369
|
mutation: Mutation,
|
|
353
370
|
...args: OptionalRestArgs<Mutation>
|
|
@@ -369,7 +386,11 @@ export interface GenericActionCtx<DataModel extends GenericDataModel> {
|
|
|
369
386
|
* @param args - The arguments to the action function.
|
|
370
387
|
* @returns A promise of the action's result.
|
|
371
388
|
*/
|
|
372
|
-
runAction<
|
|
389
|
+
runAction<
|
|
390
|
+
Action extends
|
|
391
|
+
| FunctionReference<"action", "public" | "internal">
|
|
392
|
+
| FunctionReference_future<"action", "public" | "internal">,
|
|
393
|
+
>(
|
|
373
394
|
action: Action,
|
|
374
395
|
...args: OptionalRestArgs<Action>
|
|
375
396
|
): Promise<FunctionReturnType<Action>>;
|
package/src/server/scheduler.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FunctionReference,
|
|
3
|
+
FunctionReference_future,
|
|
4
|
+
OptionalRestArgs,
|
|
5
|
+
} from "../server/api.js";
|
|
2
6
|
import { Id } from "../values/value.js";
|
|
3
7
|
|
|
4
8
|
/**
|
|
@@ -13,6 +17,17 @@ export type SchedulableFunctionReference = FunctionReference<
|
|
|
13
17
|
"public" | "internal"
|
|
14
18
|
>;
|
|
15
19
|
|
|
20
|
+
// What the scheduling methods accept. This is kept separate from the exported
|
|
21
|
+
// `SchedulableFunctionReference` so that alias keeps describing a plain
|
|
22
|
+
// reference. Existing code depending on it can still forward it to anything
|
|
23
|
+
// typed with `FunctionReference` or read its `_args`. This alias is
|
|
24
|
+
// module-local so that a consumer's declaration file inlines it instead of
|
|
25
|
+
// importing it from a path that is not part of the package's public entry
|
|
26
|
+
// points.
|
|
27
|
+
type SchedulableFunctionReferenceCompat =
|
|
28
|
+
| SchedulableFunctionReference
|
|
29
|
+
| FunctionReference_future<"mutation" | "action", "public" | "internal">;
|
|
30
|
+
|
|
16
31
|
/**
|
|
17
32
|
* An interface to schedule Convex functions to run in the future.
|
|
18
33
|
*
|
|
@@ -78,13 +93,13 @@ export interface Scheduler {
|
|
|
78
93
|
* @param delayMs - Delay in milliseconds. Must be non-negative. If the delay
|
|
79
94
|
* is zero, the scheduled function will be due to execute immediately after the
|
|
80
95
|
* scheduling one completes.
|
|
81
|
-
* @param functionReference - A {@link FunctionReference}
|
|
82
|
-
* to schedule.
|
|
96
|
+
* @param functionReference - A {@link FunctionReference} or
|
|
97
|
+
* {@link FunctionReference_future} for the function to schedule.
|
|
83
98
|
* @param args - Arguments to call the scheduled functions with.
|
|
84
99
|
* @returns The ID of the scheduled function in the `_scheduled_functions`
|
|
85
100
|
* system table. Use this to cancel it later if needed.
|
|
86
101
|
**/
|
|
87
|
-
runAfter<FuncRef extends
|
|
102
|
+
runAfter<FuncRef extends SchedulableFunctionReferenceCompat>(
|
|
88
103
|
delayMs: number,
|
|
89
104
|
functionReference: FuncRef,
|
|
90
105
|
...args: OptionalRestArgs<FuncRef>
|
|
@@ -110,13 +125,13 @@ export interface Scheduler {
|
|
|
110
125
|
* If the timestamp is in the past, the scheduled function will be due to
|
|
111
126
|
* execute immediately after the scheduling one completes. The timestamp can't
|
|
112
127
|
* be more than five years in the past or more than five years in the future.
|
|
113
|
-
* @param functionReference - A {@link FunctionReference}
|
|
114
|
-
* to schedule.
|
|
128
|
+
* @param functionReference - A {@link FunctionReference} or
|
|
129
|
+
* {@link FunctionReference_future} for the function to schedule.
|
|
115
130
|
* @param args - Arguments to call the scheduled functions with.
|
|
116
131
|
* @returns The ID of the scheduled function in the `_scheduled_functions`
|
|
117
132
|
* system table.
|
|
118
133
|
**/
|
|
119
|
-
runAt<FuncRef extends
|
|
134
|
+
runAt<FuncRef extends SchedulableFunctionReferenceCompat>(
|
|
120
135
|
timestamp: number | Date,
|
|
121
136
|
functionReference: FuncRef,
|
|
122
137
|
...args: OptionalRestArgs<FuncRef>
|
package/src/server/schema.ts
CHANGED
|
@@ -204,6 +204,9 @@ export class TableDefinition<
|
|
|
204
204
|
private stagedVectorIndexes: VectorIndex[];
|
|
205
205
|
// The type of documents stored in this table.
|
|
206
206
|
validator: DocumentType;
|
|
207
|
+
// The proposed next validator for this table, validated against existing
|
|
208
|
+
// documents in the background while `validator` remains enforced.
|
|
209
|
+
private stagedValidator: Validator<any, any, any> | undefined;
|
|
207
210
|
|
|
208
211
|
/**
|
|
209
212
|
* @internal
|
|
@@ -557,6 +560,45 @@ export class TableDefinition<
|
|
|
557
560
|
return this;
|
|
558
561
|
}
|
|
559
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Stage a new document validator for this table.
|
|
565
|
+
*
|
|
566
|
+
* Convex validates the staged validator against the table's existing
|
|
567
|
+
* documents in the background, while the validator passed to
|
|
568
|
+
* {@link defineTable} remains the one enforced on reads and writes. Once
|
|
569
|
+
* the background validation succeeds, make the staged validator the
|
|
570
|
+
* table's validator and remove `.staged()`.
|
|
571
|
+
*
|
|
572
|
+
* ```ts
|
|
573
|
+
* defineTable({
|
|
574
|
+
* author: v.string(),
|
|
575
|
+
* }).staged({
|
|
576
|
+
* author: v.array(v.string()),
|
|
577
|
+
* })
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* TODO: link a worked staged-schema example from the docs once one exists.
|
|
581
|
+
*
|
|
582
|
+
* @param documentSchema - The proposed next type of documents stored in
|
|
583
|
+
* this table, as an object of field validators or a schema validator.
|
|
584
|
+
* @returns A {@link TableDefinition} with the staged validator attached.
|
|
585
|
+
*
|
|
586
|
+
* @internal
|
|
587
|
+
*/
|
|
588
|
+
staged(
|
|
589
|
+
documentSchema:
|
|
590
|
+
| Validator<Record<string, any>, "required", any>
|
|
591
|
+
| Record<string, GenericValidator>,
|
|
592
|
+
): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {
|
|
593
|
+
if (this.stagedValidator !== undefined) {
|
|
594
|
+
throw new Error("Table cannot have more than one staged validator.");
|
|
595
|
+
}
|
|
596
|
+
this.stagedValidator = isValidator(documentSchema)
|
|
597
|
+
? documentSchema
|
|
598
|
+
: v.object(documentSchema);
|
|
599
|
+
return this.self();
|
|
600
|
+
}
|
|
601
|
+
|
|
560
602
|
/**
|
|
561
603
|
* Work around for https://github.com/microsoft/TypeScript/issues/57035
|
|
562
604
|
*/
|
|
@@ -582,6 +624,16 @@ export class TableDefinition<
|
|
|
582
624
|
);
|
|
583
625
|
}
|
|
584
626
|
|
|
627
|
+
let stagedDocumentType = undefined;
|
|
628
|
+
if (this.stagedValidator !== undefined) {
|
|
629
|
+
stagedDocumentType = this.stagedValidator.json;
|
|
630
|
+
if (typeof stagedDocumentType !== "object") {
|
|
631
|
+
throw new Error(
|
|
632
|
+
"Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)",
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
585
637
|
return {
|
|
586
638
|
indexes: this.indexes,
|
|
587
639
|
stagedDbIndexes: this.stagedDbIndexes,
|
|
@@ -590,6 +642,7 @@ export class TableDefinition<
|
|
|
590
642
|
vectorIndexes: this.vectorIndexes,
|
|
591
643
|
stagedVectorIndexes: this.stagedVectorIndexes,
|
|
592
644
|
documentType,
|
|
645
|
+
stagedDocumentType,
|
|
593
646
|
};
|
|
594
647
|
}
|
|
595
648
|
}
|
|
@@ -884,6 +937,7 @@ export class SchemaDefinition<
|
|
|
884
937
|
vectorIndexes,
|
|
885
938
|
stagedVectorIndexes,
|
|
886
939
|
documentType,
|
|
940
|
+
stagedDocumentType,
|
|
887
941
|
} = definition.export();
|
|
888
942
|
return {
|
|
889
943
|
tableName,
|
|
@@ -894,6 +948,7 @@ export class SchemaDefinition<
|
|
|
894
948
|
vectorIndexes,
|
|
895
949
|
stagedVectorIndexes,
|
|
896
950
|
documentType,
|
|
951
|
+
stagedDocumentType,
|
|
897
952
|
};
|
|
898
953
|
}),
|
|
899
954
|
schemaValidation: this.schemaValidation,
|
package/src/values/validator.ts
CHANGED
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
export type GenericValidator = Validator<any, any, any>;
|
|
29
29
|
|
|
30
30
|
export function isValidator(v: any): v is GenericValidator {
|
|
31
|
-
|
|
31
|
+
// Check for the literal `true` marker: a field map can contain a field
|
|
32
|
+
// *named* `isConvexValidator` whose value is a (truthy) validator object.
|
|
33
|
+
return v?.isConvexValidator === true;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
/**
|