convex 1.48.0-alpha.0 → 1.48.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 +28 -4
- package/README.md +1 -1
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +1 -1
- package/dist/cjs/bundler/context.js +5 -7
- package/dist/cjs/bundler/context.js.map +2 -2
- package/dist/cjs/bundler/fs.js +6 -47
- package/dist/cjs/bundler/fs.js.map +2 -2
- package/dist/cjs/cli/aiFiles.js +26 -4
- package/dist/cjs/cli/aiFiles.js.map +2 -2
- package/dist/cjs/cli/configure.js +2 -15
- package/dist/cjs/cli/configure.js.map +2 -2
- package/dist/cjs/cli/env.js +6 -3
- package/dist/cjs/cli/env.js.map +2 -2
- package/dist/cjs/cli/envDefault.js +5 -2
- package/dist/cjs/cli/envDefault.js.map +2 -2
- package/dist/cjs/cli/lib/aiFiles/guidelinesmd.js +2 -1
- package/dist/cjs/cli/lib/aiFiles/guidelinesmd.js.map +2 -2
- package/dist/cjs/cli/lib/aiFiles/index.js +13 -2
- package/dist/cjs/cli/lib/aiFiles/index.js.map +2 -2
- package/dist/cjs/cli/lib/aiFiles/skills.js +6 -5
- package/dist/cjs/cli/lib/aiFiles/skills.js.map +2 -2
- package/dist/cjs/cli/lib/aiFiles/state.js +1 -1
- package/dist/cjs/cli/lib/aiFiles/state.js.map +1 -1
- package/dist/cjs/cli/lib/components.js +12 -2
- package/dist/cjs/cli/lib/components.js.map +2 -2
- package/dist/cjs/cli/lib/deployApi/startPush.js +42 -1
- package/dist/cjs/cli/lib/deployApi/startPush.js.map +2 -2
- package/dist/cjs/cli/lib/deployment.js +0 -2
- package/dist/cjs/cli/lib/deployment.js.map +2 -2
- package/dist/cjs/cli/lib/deploymentSelection.js +18 -27
- package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/cjs/cli/lib/env.js +9 -1
- package/dist/cjs/cli/lib/env.js.map +2 -2
- package/dist/cjs/cli/lib/envvars.js +0 -32
- package/dist/cjs/cli/lib/envvars.js.map +2 -2
- package/dist/cjs/cli/lib/fsUtils.js +1 -1
- package/dist/cjs/cli/lib/fsUtils.js.map +2 -2
- package/dist/cjs/cli/lib/generateDocs.js +1 -1
- package/dist/cjs/cli/lib/generateDocs.js.map +1 -1
- package/dist/cjs/cli/lib/localDeployment/dashboard.js +11 -1
- package/dist/cjs/cli/lib/localDeployment/dashboard.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/download.js +16 -1
- package/dist/cjs/cli/lib/localDeployment/download.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/utils.js +4 -0
- package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
- package/dist/cjs/cli/lib/login.js +4 -28
- package/dist/cjs/cli/lib/login.js.map +2 -2
- package/dist/cjs/cli/lib/mcp/requestContext.js +1 -5
- package/dist/cjs/cli/lib/mcp/requestContext.js.map +2 -2
- package/dist/cjs/cli/lib/utils/aiAgent.js +32 -0
- package/dist/cjs/cli/lib/utils/aiAgent.js.map +7 -0
- package/dist/cjs/cli/lib/utils/utils.js +9 -18
- package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
- package/dist/cjs/cli/login.js +114 -213
- package/dist/cjs/cli/login.js.map +3 -3
- package/dist/cjs/cli/logout.js +12 -113
- package/dist/cjs/cli/logout.js.map +3 -3
- package/dist/cjs/cli/mcp.js +10 -43
- package/dist/cjs/cli/mcp.js.map +3 -3
- package/dist/cjs/cli/program.js +1 -2
- package/dist/cjs/cli/program.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/authentication.js.map +1 -1
- package/dist/cjs/server/components/index.js.map +2 -2
- package/dist/cjs/server/impl/authentication_impl.js +15 -1
- package/dist/cjs/server/impl/authentication_impl.js.map +2 -2
- package/dist/cjs/server/impl/registration_impl.js +1 -1
- package/dist/cjs/server/impl/registration_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/schema.js +0 -2
- package/dist/cjs/server/schema.js.map +2 -2
- package/dist/cjs/server/storage.js.map +1 -1
- package/dist/cjs-types/bundler/context.d.ts +0 -5
- package/dist/cjs-types/bundler/context.d.ts.map +1 -1
- package/dist/cjs-types/bundler/fs.d.ts +2 -7
- package/dist/cjs-types/bundler/fs.d.ts.map +1 -1
- package/dist/cjs-types/cli/aiFiles.d.ts.map +1 -1
- package/dist/cjs-types/cli/configure.d.ts.map +1 -1
- package/dist/cjs-types/cli/env.d.ts.map +1 -1
- package/dist/cjs-types/cli/envDefault.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.d.ts +3 -1
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/aiFiles/index.d.ts +11 -1
- package/dist/cjs-types/cli/lib/aiFiles/index.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/aiFiles/skills.d.ts +4 -1
- package/dist/cjs-types/cli/lib/aiFiles/skills.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts +13 -0
- package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployment.d.ts +0 -2
- package/dist/cjs-types/cli/lib/deployment.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts +1 -2
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/env.d.ts +1 -0
- package/dist/cjs-types/cli/lib/env.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/envvars.d.ts +0 -6
- package/dist/cjs-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/fsUtils.d.ts +0 -1
- package/dist/cjs-types/cli/lib/fsUtils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/dashboard.d.ts +6 -0
- package/dist/cjs-types/cli/lib/localDeployment/dashboard.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/download.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/login.d.ts +1 -3
- package/dist/cjs-types/cli/lib/login.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/requestContext.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/cjs-types/cli/lib/utils/aiAgent.d.ts +8 -0
- package/dist/cjs-types/cli/lib/utils/aiAgent.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/utils/utils.d.ts +0 -5
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/login.d.ts +0 -21
- package/dist/cjs-types/cli/login.d.ts.map +1 -1
- package/dist/cjs-types/cli/logout.d.ts +1 -8
- package/dist/cjs-types/cli/logout.d.ts.map +1 -1
- package/dist/cjs-types/cli/mcp.d.ts.map +1 -1
- package/dist/cjs-types/cli/program.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/index.d.ts.map +1 -1
- package/dist/cjs-types/server/authentication.d.ts +65 -0
- package/dist/cjs-types/server/authentication.d.ts.map +1 -1
- package/dist/cjs-types/server/components/index.d.ts +6 -0
- package/dist/cjs-types/server/components/index.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/authentication_impl.d.ts +2 -1
- package/dist/cjs-types/server/impl/authentication_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/index.d.ts +2 -2
- package/dist/cjs-types/server/index.d.ts.map +1 -1
- package/dist/cjs-types/server/meta.d.ts +8 -0
- package/dist/cjs-types/server/meta.d.ts.map +1 -1
- package/dist/cjs-types/server/registration.d.ts +5 -3
- package/dist/cjs-types/server/registration.d.ts.map +1 -1
- package/dist/cjs-types/server/schema.d.ts +0 -2
- package/dist/cjs-types/server/schema.d.ts.map +1 -1
- package/dist/cjs-types/server/storage.d.ts +28 -25
- package/dist/cjs-types/server/storage.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +1379 -2142
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/bundler/context.js +5 -7
- package/dist/esm/bundler/context.js.map +2 -2
- package/dist/esm/bundler/fs.js +6 -47
- package/dist/esm/bundler/fs.js.map +2 -2
- package/dist/esm/cli/aiFiles.js +26 -4
- package/dist/esm/cli/aiFiles.js.map +2 -2
- package/dist/esm/cli/configure.js +2 -15
- package/dist/esm/cli/configure.js.map +2 -2
- package/dist/esm/cli/env.js +6 -3
- package/dist/esm/cli/env.js.map +2 -2
- package/dist/esm/cli/envDefault.js +5 -2
- package/dist/esm/cli/envDefault.js.map +2 -2
- package/dist/esm/cli/lib/aiFiles/guidelinesmd.js +2 -1
- package/dist/esm/cli/lib/aiFiles/guidelinesmd.js.map +2 -2
- package/dist/esm/cli/lib/aiFiles/index.js +13 -2
- package/dist/esm/cli/lib/aiFiles/index.js.map +2 -2
- package/dist/esm/cli/lib/aiFiles/skills.js +6 -5
- package/dist/esm/cli/lib/aiFiles/skills.js.map +2 -2
- package/dist/esm/cli/lib/aiFiles/state.js +1 -1
- package/dist/esm/cli/lib/aiFiles/state.js.map +1 -1
- package/dist/esm/cli/lib/components.js +15 -2
- package/dist/esm/cli/lib/components.js.map +2 -2
- package/dist/esm/cli/lib/deployApi/startPush.js +39 -0
- package/dist/esm/cli/lib/deployApi/startPush.js.map +2 -2
- package/dist/esm/cli/lib/deployment.js +2 -2
- package/dist/esm/cli/lib/deployment.js.map +2 -2
- package/dist/esm/cli/lib/deploymentSelection.js +20 -35
- package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/esm/cli/lib/env.js +9 -1
- package/dist/esm/cli/lib/env.js.map +2 -2
- package/dist/esm/cli/lib/envvars.js +1 -35
- package/dist/esm/cli/lib/envvars.js.map +2 -2
- package/dist/esm/cli/lib/fsUtils.js +1 -1
- package/dist/esm/cli/lib/fsUtils.js.map +2 -2
- package/dist/esm/cli/lib/generateDocs.js +1 -1
- package/dist/esm/cli/lib/generateDocs.js.map +1 -1
- package/dist/esm/cli/lib/localDeployment/dashboard.js +9 -0
- package/dist/esm/cli/lib/localDeployment/dashboard.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/download.js +16 -1
- package/dist/esm/cli/lib/localDeployment/download.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/login.js +4 -36
- package/dist/esm/cli/lib/login.js.map +2 -2
- package/dist/esm/cli/lib/mcp/requestContext.js +1 -5
- package/dist/esm/cli/lib/mcp/requestContext.js.map +2 -2
- package/dist/esm/cli/lib/utils/aiAgent.js +10 -0
- package/dist/esm/cli/lib/utils/aiAgent.js.map +7 -0
- package/dist/esm/cli/lib/utils/utils.js +9 -16
- package/dist/esm/cli/lib/utils/utils.js.map +2 -2
- package/dist/esm/cli/login.js +112 -225
- package/dist/esm/cli/login.js.map +3 -3
- package/dist/esm/cli/logout.js +13 -110
- package/dist/esm/cli/logout.js.map +2 -2
- package/dist/esm/cli/mcp.js +10 -34
- package/dist/esm/cli/mcp.js.map +2 -2
- package/dist/esm/cli/program.js +1 -2
- package/dist/esm/cli/program.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/components/index.js.map +2 -2
- package/dist/esm/server/impl/authentication_impl.js +13 -0
- package/dist/esm/server/impl/authentication_impl.js.map +2 -2
- package/dist/esm/server/impl/registration_impl.js +2 -2
- package/dist/esm/server/impl/registration_impl.js.map +2 -2
- package/dist/esm/server/index.js.map +2 -2
- package/dist/esm/server/schema.js +0 -2
- package/dist/esm/server/schema.js.map +2 -2
- package/dist/esm-types/bundler/context.d.ts +0 -5
- package/dist/esm-types/bundler/context.d.ts.map +1 -1
- package/dist/esm-types/bundler/fs.d.ts +2 -7
- package/dist/esm-types/bundler/fs.d.ts.map +1 -1
- package/dist/esm-types/cli/aiFiles.d.ts.map +1 -1
- package/dist/esm-types/cli/configure.d.ts.map +1 -1
- package/dist/esm-types/cli/env.d.ts.map +1 -1
- package/dist/esm-types/cli/envDefault.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.d.ts +3 -1
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/aiFiles/index.d.ts +11 -1
- package/dist/esm-types/cli/lib/aiFiles/index.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/aiFiles/skills.d.ts +4 -1
- package/dist/esm-types/cli/lib/aiFiles/skills.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployApi/startPush.d.ts +13 -0
- package/dist/esm-types/cli/lib/deployApi/startPush.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployment.d.ts +0 -2
- package/dist/esm-types/cli/lib/deployment.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts +1 -2
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/env.d.ts +1 -0
- package/dist/esm-types/cli/lib/env.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/envvars.d.ts +0 -6
- package/dist/esm-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/fsUtils.d.ts +0 -1
- package/dist/esm-types/cli/lib/fsUtils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/dashboard.d.ts +6 -0
- package/dist/esm-types/cli/lib/localDeployment/dashboard.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/download.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/login.d.ts +1 -3
- package/dist/esm-types/cli/lib/login.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/requestContext.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/esm-types/cli/lib/utils/aiAgent.d.ts +8 -0
- package/dist/esm-types/cli/lib/utils/aiAgent.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/utils/utils.d.ts +0 -5
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/login.d.ts +0 -21
- package/dist/esm-types/cli/login.d.ts.map +1 -1
- package/dist/esm-types/cli/logout.d.ts +1 -8
- package/dist/esm-types/cli/logout.d.ts.map +1 -1
- package/dist/esm-types/cli/mcp.d.ts.map +1 -1
- package/dist/esm-types/cli/program.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/index.d.ts.map +1 -1
- package/dist/esm-types/server/authentication.d.ts +65 -0
- package/dist/esm-types/server/authentication.d.ts.map +1 -1
- package/dist/esm-types/server/components/index.d.ts +6 -0
- package/dist/esm-types/server/components/index.d.ts.map +1 -1
- package/dist/esm-types/server/impl/authentication_impl.d.ts +2 -1
- package/dist/esm-types/server/impl/authentication_impl.d.ts.map +1 -1
- package/dist/esm-types/server/index.d.ts +2 -2
- package/dist/esm-types/server/index.d.ts.map +1 -1
- package/dist/esm-types/server/meta.d.ts +8 -0
- package/dist/esm-types/server/meta.d.ts.map +1 -1
- package/dist/esm-types/server/registration.d.ts +5 -3
- package/dist/esm-types/server/registration.d.ts.map +1 -1
- package/dist/esm-types/server/schema.d.ts +0 -2
- package/dist/esm-types/server/schema.d.ts.map +1 -1
- package/dist/esm-types/server/storage.d.ts +28 -25
- package/dist/esm-types/server/storage.d.ts.map +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +1 -1
- package/package.json +3 -2
- package/schemas/convex.schema.json +1 -2
- package/src/bundler/context.ts +5 -9
- package/src/bundler/fs.ts +5 -54
- package/src/cli/aiFiles.ts +30 -4
- package/src/cli/configure.ts +2 -18
- package/src/cli/env.ts +4 -1
- package/src/cli/envDefault.ts +4 -1
- package/src/cli/lib/aiFiles/guidelinesmd.ts +7 -2
- package/src/cli/lib/aiFiles/index.ts +23 -3
- package/src/cli/lib/aiFiles/skills.ts +11 -7
- package/src/cli/lib/aiFiles/state.ts +1 -1
- package/src/cli/lib/components.ts +18 -3
- package/src/cli/lib/deployApi/startPush.ts +64 -0
- package/src/cli/lib/deployment.ts +2 -2
- package/src/cli/lib/deploymentSelection.ts +18 -37
- package/src/cli/lib/env.ts +13 -2
- package/src/cli/lib/envvars.ts +1 -43
- package/src/cli/lib/fsUtils.ts +2 -5
- package/src/cli/lib/generateDocs.ts +1 -1
- package/src/cli/lib/localDeployment/dashboard.ts +19 -0
- package/src/cli/lib/localDeployment/download.ts +17 -1
- package/src/cli/lib/localDeployment/utils.ts +4 -0
- package/src/cli/lib/login.ts +3 -47
- package/src/cli/lib/mcp/requestContext.ts +1 -7
- package/src/cli/lib/utils/aiAgent.ts +15 -0
- package/src/cli/lib/utils/utils.ts +15 -19
- package/src/cli/login.ts +168 -293
- package/src/cli/logout.ts +17 -142
- package/src/cli/mcp.ts +11 -48
- package/src/cli/program.ts +0 -2
- package/src/index.ts +1 -1
- package/src/server/authentication.ts +79 -0
- package/src/server/components/index.ts +11 -0
- package/src/server/impl/authentication_impl.ts +15 -1
- package/src/server/impl/registration_impl.ts +2 -2
- package/src/server/index.ts +6 -0
- package/src/server/meta.ts +0 -8
- package/src/server/registration.ts +5 -2
- package/src/server/schema.ts +0 -2
- package/src/server/storage.ts +29 -42
- package/dist/cjs/cli/account.js +0 -237
- package/dist/cjs/cli/account.js.map +0 -7
- package/dist/cjs/cli/lib/deployKeyWarning.js +0 -43
- package/dist/cjs/cli/lib/deployKeyWarning.js.map +0 -7
- package/dist/cjs/cli/lib/profileManagement.js +0 -196
- package/dist/cjs/cli/lib/profileManagement.js.map +0 -7
- package/dist/cjs/cli/lib/profiles.js +0 -333
- package/dist/cjs/cli/lib/profiles.js.map +0 -7
- package/dist/cjs-types/cli/account.d.ts +0 -6
- package/dist/cjs-types/cli/account.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/deployKeyWarning.d.ts +0 -3
- package/dist/cjs-types/cli/lib/deployKeyWarning.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/profileManagement.d.ts +0 -10
- package/dist/cjs-types/cli/lib/profileManagement.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/profiles.d.ts +0 -59
- package/dist/cjs-types/cli/lib/profiles.d.ts.map +0 -1
- package/dist/esm/cli/account.js +0 -221
- package/dist/esm/cli/account.js.map +0 -7
- package/dist/esm/cli/lib/deployKeyWarning.js +0 -27
- package/dist/esm/cli/lib/deployKeyWarning.js.map +0 -7
- package/dist/esm/cli/lib/profileManagement.js +0 -179
- package/dist/esm/cli/lib/profileManagement.js.map +0 -7
- package/dist/esm/cli/lib/profiles.js +0 -288
- package/dist/esm/cli/lib/profiles.js.map +0 -7
- package/dist/esm-types/cli/account.d.ts +0 -6
- package/dist/esm-types/cli/account.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/deployKeyWarning.d.ts +0 -3
- package/dist/esm-types/cli/lib/deployKeyWarning.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/profileManagement.d.ts +0 -10
- package/dist/esm-types/cli/lib/profileManagement.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/profiles.d.ts +0 -59
- package/dist/esm-types/cli/lib/profiles.d.ts.map +0 -1
- package/src/cli/account.ts +0 -320
- package/src/cli/lib/deployKeyWarning.ts +0 -43
- package/src/cli/lib/profileManagement.ts +0 -262
- package/src/cli/lib/profiles.ts +0 -398
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/registration.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n Auth,\n GenericDatabaseReader,\n GenericDatabaseReaderWithTable,\n GenericDatabaseWriter,\n GenericDatabaseWriterWithTable,\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./index.js\";\nimport {\n ActionMeta,\n MutationMeta,\n QueryMeta,\n TransactionLimits,\n} from \"./meta.js\";\nimport {\n ArgsAndOptions,\n FunctionReturnType,\n OptionalRestArgs,\n ValidatorTypeToReturnType,\n FunctionReference,\n FunctionReference_future,\n} from \"../server/api.js\";\nimport {\n GenericValidator,\n Infer,\n ObjectType,\n PropertyValidators,\n} from \"../values/validator.js\";\nimport { Id } from \"../values/value.js\";\nimport {\n GenericDataModel,\n NamedTableInfo,\n TableNamesInDataModel,\n VectorIndexNames,\n} from \"./data_model.js\";\nimport { Scheduler } from \"./scheduler.js\";\nimport { VectorSearchQuery } from \"./vector_search.js\";\nimport { Expand } from \"../type_utils.js\";\nimport { Validator } from \"../values/validators.js\";\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server. Mutations run **transactionally**, all reads\n * and writes within a single mutation are atomic and isolated.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const createTask = mutation({\n * args: { text: v.string() },\n * returns: v.id(\"tasks\"),\n * handler: async (ctx, args) => {\n * // ctx.db: read and write documents\n * const taskId = await ctx.db.insert(\"tasks\", { text: args.text, completed: false });\n *\n * // ctx.auth: check the authenticated user\n * const identity = await ctx.auth.getUserIdentity();\n *\n * // ctx.scheduler: schedule functions for later\n * await ctx.scheduler.runAfter(0, internal.notifications.send, { taskId });\n *\n * return taskId;\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericMutationCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading and writing data in the database.\n *\n * Use `ctx.db.insert()`, `ctx.db.patch()`, `ctx.db.replace()`, and\n * `ctx.db.delete()` to write data. Use `ctx.db.get()` and `ctx.db.query()`\n * to read data. All operations within a mutation are atomic.\n */\n db: GenericDatabaseWriter<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n *\n * Use `ctx.storage.generateUploadUrl()` to create an upload URL for clients,\n * `ctx.storage.getUrl(storageId)` to get a URL for a stored file,\n * or `ctx.storage.delete(storageId)` to remove one.\n */\n storage: StorageWriter;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n *\n * @example\n * ```typescript\n * // Schedule an action to run immediately after this mutation commits:\n * await ctx.scheduler.runAfter(0, internal.emails.sendWelcome, { userId });\n *\n * // Schedule a cleanup to run in 24 hours:\n * await ctx.scheduler.runAfter(24 * 60 * 60 * 1000, internal.tasks.cleanup, {});\n * ```\n */\n scheduler: Scheduler;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same transaction as the calling mutation,\n * seeing a consistent snapshot of the database. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.getUser, { userId });\n * ```\n */\n runQuery: <\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: ArgsAndOptions<Query, AdvancedRunQueryOptions>\n ) => Promise<FunctionReturnType<Query>>;\n\n /**\n * Call a mutation function within the same transaction.\n *\n * The mutation runs in a sub-transaction, so if it throws an error, all of\n * its writes will be rolled back. Requires a {@link FunctionReference}.\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runMutation` incurs overhead of running argument and return value\n * validation, and creating a new isolated JS context.\n */\n runMutation: <\n Mutation extends\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Mutation>>;\n\n meta: MutationMeta;\n}\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @public\n */\nexport type GenericMutationCtxWithTable<DataModel extends GenericDataModel> =\n Omit<GenericMutationCtx<DataModel>, \"db\"> & {\n db: GenericDatabaseWriterWithTable<DataModel>;\n };\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server. Queries are **read-only**, they can read from\n * the database but cannot write. They are also **reactive**, when used with\n * `useQuery` on the client, the result automatically updates when data changes.\n *\n * You should generally use the `QueryCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const listTasks = query({\n * args: {},\n * returns: v.array(v.object({\n * _id: v.id(\"tasks\"),\n * _creationTime: v.number(),\n * text: v.string(),\n * completed: v.boolean(),\n * })),\n * handler: async (ctx, args) => {\n * // ctx.db: read-only database access\n * return await ctx.db.query(\"tasks\").order(\"desc\").take(100);\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericQueryCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading data in the database.\n *\n * Use `ctx.db.get(table, id)` to fetch a single document by ID, or\n * `ctx.db.query(\"tableName\")` to query multiple documents with filtering\n * and ordering. Queries are read-only, no write methods are available.\n */\n db: GenericDatabaseReader<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading files in storage.\n *\n * Use `ctx.storage.getUrl(storageId)` to get a URL for a stored file.\n */\n storage: StorageReader;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same read snapshot. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n */\n runQuery: <\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Query>>;\n\n meta: QueryMeta;\n}\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server.\n *\n * This differs from the {@link MutationCtx} because all of the services are\n * read-only.\n *\n *\n * @public\n */\nexport type GenericQueryCtxWithTable<DataModel extends GenericDataModel> = Omit<\n GenericQueryCtx<DataModel>,\n \"db\"\n> & {\n db: GenericDatabaseReaderWithTable<DataModel>;\n};\n\n/**\n * A set of services for use within Convex action functions.\n *\n * The action context is passed as the first argument to any Convex action\n * run on the server. Actions can call external APIs and use Node.js libraries,\n * but do **not** have direct database access (`ctx.db` is not available).\n * Use `ctx.runQuery` and `ctx.runMutation` to interact with the database.\n *\n * You should generally use the `ActionCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { action } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const processPayment = action({\n * args: { orderId: v.id(\"orders\"), amount: v.number() },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * // Read data via ctx.runQuery:\n * const order = await ctx.runQuery(internal.orders.get, { id: args.orderId });\n *\n * // Call external API:\n * const result = await fetch(\"https://api.stripe.com/v1/charges\", { ... });\n *\n * // Write results back via ctx.runMutation:\n * await ctx.runMutation(internal.orders.markPaid, { id: args.orderId });\n *\n * return null;\n * },\n * });\n * ```\n *\n * **Common mistake:** `ctx.db` is not available in actions. Do not try to\n * access it, use `ctx.runQuery` and `ctx.runMutation` instead.\n *\n * @public\n */\nexport interface GenericActionCtx<DataModel extends GenericDataModel> {\n /**\n * Run the Convex query with the given name and arguments.\n *\n * Each `runQuery` call is a separate read transaction. Consider using an\n * {@link internalQuery} to prevent users from calling the query directly.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.get, { userId });\n * ```\n *\n * @param query - A {@link FunctionReference} for the query to run.\n * @param args - The arguments to the query function.\n * @returns A promise of the query's result.\n */\n runQuery<\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: OptionalRestArgs<Query>\n ): Promise<FunctionReturnType<Query>>;\n\n /**\n * Run the Convex mutation with the given name and arguments.\n *\n * Each `runMutation` call is a separate write transaction. Consider using\n * an {@link internalMutation} to prevent users from calling it directly.\n *\n * @example\n * ```typescript\n * await ctx.runMutation(internal.orders.markPaid, { id: orderId });\n * ```\n *\n * @param mutation - A {@link FunctionReference} for the mutation to run.\n * @param args - The arguments to the mutation function.\n * @returns A promise of the mutation's result.\n */\n runMutation<\n Mutation extends\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: OptionalRestArgs<Mutation>\n ): Promise<FunctionReturnType<Mutation>>;\n\n /**\n * Run the Convex action with the given name and arguments.\n *\n * **Important:** Only use `runAction` when you need to cross runtimes\n * (e.g., calling a `\"use node\"` action from the default Convex runtime).\n * For code in the same runtime, extract shared logic into a plain\n * TypeScript helper function instead, `runAction` has significant\n * overhead (separate function call, separate resource allocation).\n *\n * Consider using an {@link internalAction} to prevent users from calling the\n * action directly.\n *\n * @param action - A {@link FunctionReference} for the action to run.\n * @param args - The arguments to the action function.\n * @returns A promise of the action's result.\n */\n runAction<\n Action extends\n | FunctionReference<\"action\", \"public\" | \"internal\">\n | FunctionReference_future<\"action\", \"public\" | \"internal\">,\n >(\n action: Action,\n ...args: OptionalRestArgs<Action>\n ): Promise<FunctionReturnType<Action>>;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n */\n scheduler: Scheduler;\n\n /**\n * Information about the currently authenticated user.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n */\n storage: StorageActionWriter;\n\n /**\n * Run a vector search on the given table and index.\n *\n * @param tableName - The name of the table to query.\n * @param indexName - The name of the vector index on the table to query.\n * @param query - A {@link VectorSearchQuery} containing the vector to query,\n * the number of results to return, and any filters.\n * @returns A promise of IDs and scores for the documents with the nearest\n * vectors\n */\n vectorSearch<\n TableName extends TableNamesInDataModel<DataModel>,\n IndexName extends VectorIndexNames<NamedTableInfo<DataModel, TableName>>,\n >(\n tableName: TableName,\n indexName: IndexName,\n query: Expand<\n VectorSearchQuery<NamedTableInfo<DataModel, TableName>, IndexName>\n >,\n ): Promise<Array<{ _id: Id<TableName>; _score: number }>>;\n\n meta: ActionMeta;\n}\n\n/**\n * The default arguments type for a Convex query, mutation, or action function.\n *\n * Convex functions always take an arguments object that maps the argument\n * names to their values.\n *\n * @public\n */\nexport type DefaultFunctionArgs = Record<string, unknown>;\n\n/**\n * The arguments array for a function that takes arguments.\n *\n * This is an array of a single {@link DefaultFunctionArgs} element.\n */\ntype OneArgArray<ArgsObject extends DefaultFunctionArgs = DefaultFunctionArgs> =\n [ArgsObject];\n\n/**\n * The arguments to a function that takes no arguments (just an empty array).\n */\ntype NoArgsArray = [];\n\n/**\n * An array of arguments to a Convex function.\n *\n * Convex functions can take either a single {@link DefaultFunctionArgs} object or no\n * args at all.\n *\n * @public\n */\nexport type ArgsArray = OneArgArray | NoArgsArray;\n\n/**\n * A type for the empty object `{}`.\n *\n * Note that we don't use `type EmptyObject = {}` because that matches every object.\n */\nexport type EmptyObject = Record<string, never>;\n\n/**\n * Convert an {@link ArgsArray} into a single object type.\n *\n * Empty arguments arrays are converted to {@link EmptyObject}.\n * @public\n */\nexport type ArgsArrayToObject<Args extends ArgsArray> =\n Args extends OneArgArray<infer ArgsObject> ? ArgsObject : EmptyObject;\n\n/**\n * A type representing the visibility of a Convex function.\n *\n * @public\n */\nexport type FunctionVisibility = \"public\" | \"internal\";\n\n/**\n * Given a {@link FunctionVisibility}, should this function have `isPublic: true`\n * or `isInternal: true`?\n */\ntype VisibilityProperties<Visiblity extends FunctionVisibility> = {\n /** Phantom type marker; not present at runtime. */\n _visibility: Visiblity;\n} & (Visiblity extends \"public\"\n ? {\n isPublic: true;\n }\n : {\n isInternal: true;\n });\n\n/**\n * A mutation function that is part of this app.\n *\n * You can create a mutation by wrapping your function in\n * {@link mutationGeneric} or {@link internalMutationGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredMutation<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isMutation: true;\n\n /** @internal */\n invokeMutation(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericMutationCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * A query function that is part of this app.\n *\n * You can create a query by wrapping your function in\n * {@link queryGeneric} or {@link internalQueryGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredQuery<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isQuery: true;\n\n /** @internal */\n invokeQuery(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericQueryCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An action that is part of this app.\n *\n * You can create an action by wrapping your function in\n * {@link actionGeneric} or {@link internalActionGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredAction<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isAction: true;\n\n /** @internal */\n invokeAction(requestId: string, argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An HTTP action that is part of this app's public API.\n *\n * You can create public HTTP actions by wrapping your function in\n * {@link httpActionGeneric} and exporting it.\n *\n * @public\n */\nexport type PublicHttpAction = {\n isHttp: true;\n\n /** @internal */\n invokeHttpAction(request: Request): Promise<Response>;\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>;\n};\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function without\n * argument validation.\n *\n * Convex functions always take a context object as their first argument\n * and an (optional) args object as their second argument.\n *\n * This can be written as a function like:\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query(({ db }, { arg }) => {...});\n * ```\n * or as an object like:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query({\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n * See {@link ValidatedFunction} to add argument validation.\n *\n * @public\n */\nexport type UnvalidatedFunction<Ctx, Args extends ArgsArray, Returns> =\n | ((ctx: Ctx, ...args: Args) => Returns)\n | {\n handler: (ctx: Ctx, ...args: Args) => Returns;\n };\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function with argument\n * validation.\n *\n * Argument validation allows you to assert that the arguments to this function\n * are the expected type.\n *\n * Example:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const func = query({\n * args: {\n * arg: v.string()\n * },\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n *\n * **For security, argument validation should be added to all public functions in\n * production apps.**\n *\n * See {@link UnvalidatedFunction} for functions without argument validation.\n * @public\n */\nexport interface ValidatedFunction<\n Ctx,\n ArgsValidator extends PropertyValidators,\n Returns,\n> {\n /**\n * A validator for the arguments of this function.\n *\n * This is an object mapping argument names to validators constructed with\n * {@link values.v}.\n *\n * ```js\n * import { v } from \"convex/values\";\n *\n * const args = {\n * stringArg: v.string(),\n * optionalNumberArg: v.optional(v.number()),\n * }\n * ```\n */\n args: ArgsValidator;\n\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator.\n * @returns\n */\n handler: (ctx: Ctx, args: ObjectType<ArgsValidator>) => Returns;\n}\n\n/**\n * There are multiple syntaxes for defining a Convex function:\n * ```\n * - query(async (ctx, args) => {...})\n * - query({ handler: async (ctx, args) => {...} })\n * - query({ args: { a: v.string }, handler: async (ctx, args) => {...} } })\n * - query({ args: { a: v.string }, returns: v.string(), handler: async (ctx, args) => {...} } })\n *```\n *\n * In each of these, we want to correctly infer the type for the arguments and\n * return value, preferring the type derived from a validator if it's provided.\n *\n * To avoid having a separate overload for each, which would show up in error messages,\n * we use the type params -- ArgsValidator, ReturnsValidator, ReturnValue, OneOrZeroArgs.\n *\n * The type for ReturnValue and OneOrZeroArgs are constrained by the type or ArgsValidator and\n * ReturnsValidator if they're present, and inferred from any explicit type annotations to the\n * arguments or return value of the function.\n *\n * Below are a few utility types to get the appropriate type constraints based on\n * an optional validator.\n *\n * Additional tricks:\n * - We use Validator | void instead of Validator | undefined because the latter does\n * not work with `strictNullChecks` since it's equivalent to just `Validator`.\n * - We use a tuple type of length 1 to avoid distribution over the union\n * https://github.com/microsoft/TypeScript/issues/29368#issuecomment-453529532\n */\n\nexport type ReturnValueForOptionalValidator<\n ReturnsValidator extends Validator<any, any, any> | PropertyValidators | void,\n> = [ReturnsValidator] extends [Validator<any, any, any>]\n ? ValidatorTypeToReturnType<Infer<ReturnsValidator>>\n : [ReturnsValidator] extends [PropertyValidators]\n ? ValidatorTypeToReturnType<ObjectType<ReturnsValidator>>\n : any;\n\nexport type ArgsArrayForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? OneArgArray<Infer<ArgsValidator>>\n : [ArgsValidator] extends [PropertyValidators]\n ? OneArgArray<ObjectType<ArgsValidator>>\n : ArgsArray;\n\nexport type DefaultArgsForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? [Infer<ArgsValidator>]\n : [ArgsValidator] extends [PropertyValidators]\n ? [ObjectType<ArgsValidator>]\n : OneArgArray;\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link actionGeneric} a type specific to your data model.\n * @public\n */\nexport type ActionBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n func:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n *\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredAction<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link httpActionGeneric} a type specific to your data model\n * and functions.\n * @public\n */\nexport type HttpActionBuilder = (\n func: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>,\n) => PublicHttpAction;\n\nexport interface AdvancedRunQueryOptions {\n /**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n */\n transactionLimits?: TransactionLimits;\n /**\n * Run a query on a recent snapshot of the database that is not guaranteed\n * to be up-to-date when this transaction commits.\n *\n * This is an advanced feature which can introduce subtle race conditions,\n * so its use is generally discouraged except for specific use-cases where\n * database read conflicts are expected, e.g. reading from an append-only\n * table with immutable records where the only read conflicts are from\n * concurrent appends.\n *\n * To determine the snapshot of the nested query, you can call\n * `ctx.meta.getSnapshotTs()` from within the stale snapshot query. To\n * compare to the parent mutation's snapshot timestamp, you can return that\n * value from the query and call `ctx.meta.getSnapshotTs()` from the parent.\n */\n useStaleSnapshot?: boolean;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import {\n Auth,\n MutationAuth,\n GenericDatabaseReader,\n GenericDatabaseReaderWithTable,\n GenericDatabaseWriter,\n GenericDatabaseWriterWithTable,\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./index.js\";\nimport {\n ActionMeta,\n MutationMeta,\n QueryMeta,\n TransactionLimits,\n} from \"./meta.js\";\nimport {\n ArgsAndOptions,\n FunctionReturnType,\n OptionalRestArgs,\n ValidatorTypeToReturnType,\n FunctionReference,\n FunctionReference_future,\n} from \"../server/api.js\";\nimport {\n GenericValidator,\n Infer,\n ObjectType,\n PropertyValidators,\n} from \"../values/validator.js\";\nimport { Id } from \"../values/value.js\";\nimport {\n GenericDataModel,\n NamedTableInfo,\n TableNamesInDataModel,\n VectorIndexNames,\n} from \"./data_model.js\";\nimport { Scheduler } from \"./scheduler.js\";\nimport { VectorSearchQuery } from \"./vector_search.js\";\nimport { Expand } from \"../type_utils.js\";\nimport { Validator } from \"../values/validators.js\";\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server. Mutations run **transactionally**, all reads\n * and writes within a single mutation are atomic and isolated.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const createTask = mutation({\n * args: { text: v.string() },\n * returns: v.id(\"tasks\"),\n * handler: async (ctx, args) => {\n * // ctx.db: read and write documents\n * const taskId = await ctx.db.insert(\"tasks\", { text: args.text, completed: false });\n *\n * // ctx.auth: check the authenticated user\n * const identity = await ctx.auth.getUserIdentity();\n *\n * // ctx.scheduler: schedule functions for later\n * await ctx.scheduler.runAfter(0, internal.notifications.send, { taskId });\n *\n * return taskId;\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericMutationCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading and writing data in the database.\n *\n * Use `ctx.db.insert()`, `ctx.db.patch()`, `ctx.db.replace()`, and\n * `ctx.db.delete()` to write data. Use `ctx.db.get()` and `ctx.db.query()`\n * to read data. All operations within a mutation are atomic.\n */\n db: GenericDatabaseWriter<DataModel>;\n\n /**\n * Auth functionality for mutations.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n *\n * `ctx.auth.signJwt` is available for creating deployment issued JWTs.\n */\n auth: MutationAuth;\n\n /**\n * A utility for reading and writing files in storage.\n *\n * Use `ctx.storage.generateUploadUrl()` to create an upload URL for clients,\n * `ctx.storage.getUrl(storageId)` to get a URL for a stored file,\n * or `ctx.storage.delete(storageId)` to remove one.\n */\n storage: StorageWriter;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n *\n * @example\n * ```typescript\n * // Schedule an action to run immediately after this mutation commits:\n * await ctx.scheduler.runAfter(0, internal.emails.sendWelcome, { userId });\n *\n * // Schedule a cleanup to run in 24 hours:\n * await ctx.scheduler.runAfter(24 * 60 * 60 * 1000, internal.tasks.cleanup, {});\n * ```\n */\n scheduler: Scheduler;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same transaction as the calling mutation,\n * seeing a consistent snapshot of the database. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.getUser, { userId });\n * ```\n */\n runQuery: <\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: ArgsAndOptions<Query, AdvancedRunQueryOptions>\n ) => Promise<FunctionReturnType<Query>>;\n\n /**\n * Call a mutation function within the same transaction.\n *\n * The mutation runs in a sub-transaction, so if it throws an error, all of\n * its writes will be rolled back. Requires a {@link FunctionReference}.\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runMutation` incurs overhead of running argument and return value\n * validation, and creating a new isolated JS context.\n */\n runMutation: <\n Mutation extends\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: ArgsAndOptions<Mutation, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Mutation>>;\n\n meta: MutationMeta;\n}\n\n/**\n * A set of services for use within Convex mutation functions.\n *\n * The mutation context is passed as the first argument to any Convex mutation\n * function run on the server.\n *\n * You should generally use the `MutationCtx` type from\n * `\"./_generated/server\"`.\n *\n * @public\n */\nexport type GenericMutationCtxWithTable<DataModel extends GenericDataModel> =\n Omit<GenericMutationCtx<DataModel>, \"db\"> & {\n db: GenericDatabaseWriterWithTable<DataModel>;\n };\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server. Queries are **read-only**, they can read from\n * the database but cannot write. They are also **reactive**, when used with\n * `useQuery` on the client, the result automatically updates when data changes.\n *\n * You should generally use the `QueryCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const listTasks = query({\n * args: {},\n * returns: v.array(v.object({\n * _id: v.id(\"tasks\"),\n * _creationTime: v.number(),\n * text: v.string(),\n * completed: v.boolean(),\n * })),\n * handler: async (ctx, args) => {\n * // ctx.db: read-only database access\n * return await ctx.db.query(\"tasks\").order(\"desc\").take(100);\n * },\n * });\n * ```\n *\n * @public\n */\nexport interface GenericQueryCtx<DataModel extends GenericDataModel> {\n /**\n * A utility for reading data in the database.\n *\n * Use `ctx.db.get(table, id)` to fetch a single document by ID, or\n * `ctx.db.query(\"tableName\")` to query multiple documents with filtering\n * and ordering. Queries are read-only, no write methods are available.\n */\n db: GenericDatabaseReader<DataModel>;\n\n /**\n * Information about the currently authenticated user.\n *\n * Call `await ctx.auth.getUserIdentity()` to get the current user's identity,\n * or `null` if the user is not authenticated.\n */\n auth: Auth;\n\n /**\n * A utility for reading files in storage.\n *\n * Use `ctx.storage.getUrl(storageId)` to get a URL for a stored file.\n */\n storage: StorageReader;\n\n /**\n * Call a query function within the same transaction.\n *\n * The query runs within the same read snapshot. Requires a\n * {@link FunctionReference} (e.g., `api.myModule.myQuery` or\n * `internal.myModule.myQuery`).\n *\n * NOTE: Often you can extract shared logic into a helper function instead.\n * `runQuery` incurs overhead of running argument and return value validation,\n * and creating a new isolated JS context.\n */\n runQuery: <\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>\n ) => Promise<FunctionReturnType<Query>>;\n\n meta: QueryMeta;\n}\n\n/**\n * A set of services for use within Convex query functions.\n *\n * The query context is passed as the first argument to any Convex query\n * function run on the server.\n *\n * This differs from the {@link MutationCtx} because all of the services are\n * read-only.\n *\n *\n * @public\n */\nexport type GenericQueryCtxWithTable<DataModel extends GenericDataModel> = Omit<\n GenericQueryCtx<DataModel>,\n \"db\"\n> & {\n db: GenericDatabaseReaderWithTable<DataModel>;\n};\n\n/**\n * A set of services for use within Convex action functions.\n *\n * The action context is passed as the first argument to any Convex action\n * run on the server. Actions can call external APIs and use Node.js libraries,\n * but do **not** have direct database access (`ctx.db` is not available).\n * Use `ctx.runQuery` and `ctx.runMutation` to interact with the database.\n *\n * You should generally use the `ActionCtx` type from\n * `\"./_generated/server\"`.\n *\n * @example\n * ```typescript\n * import { action } from \"./_generated/server\";\n * import { internal } from \"./_generated/api\";\n * import { v } from \"convex/values\";\n *\n * export const processPayment = action({\n * args: { orderId: v.id(\"orders\"), amount: v.number() },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * // Read data via ctx.runQuery:\n * const order = await ctx.runQuery(internal.orders.get, { id: args.orderId });\n *\n * // Call external API:\n * const result = await fetch(\"https://api.stripe.com/v1/charges\", { ... });\n *\n * // Write results back via ctx.runMutation:\n * await ctx.runMutation(internal.orders.markPaid, { id: args.orderId });\n *\n * return null;\n * },\n * });\n * ```\n *\n * **Common mistake:** `ctx.db` is not available in actions. Do not try to\n * access it, use `ctx.runQuery` and `ctx.runMutation` instead.\n *\n * @public\n */\nexport interface GenericActionCtx<DataModel extends GenericDataModel> {\n /**\n * Run the Convex query with the given name and arguments.\n *\n * Each `runQuery` call is a separate read transaction. Consider using an\n * {@link internalQuery} to prevent users from calling the query directly.\n *\n * @example\n * ```typescript\n * const user = await ctx.runQuery(internal.users.get, { userId });\n * ```\n *\n * @param query - A {@link FunctionReference} for the query to run.\n * @param args - The arguments to the query function.\n * @returns A promise of the query's result.\n */\n runQuery<\n Query extends\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n >(\n query: Query,\n ...args: OptionalRestArgs<Query>\n ): Promise<FunctionReturnType<Query>>;\n\n /**\n * Run the Convex mutation with the given name and arguments.\n *\n * Each `runMutation` call is a separate write transaction. Consider using\n * an {@link internalMutation} to prevent users from calling it directly.\n *\n * @example\n * ```typescript\n * await ctx.runMutation(internal.orders.markPaid, { id: orderId });\n * ```\n *\n * @param mutation - A {@link FunctionReference} for the mutation to run.\n * @param args - The arguments to the mutation function.\n * @returns A promise of the mutation's result.\n */\n runMutation<\n Mutation extends\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n >(\n mutation: Mutation,\n ...args: OptionalRestArgs<Mutation>\n ): Promise<FunctionReturnType<Mutation>>;\n\n /**\n * Run the Convex action with the given name and arguments.\n *\n * **Important:** Only use `runAction` when you need to cross runtimes\n * (e.g., calling a `\"use node\"` action from the default Convex runtime).\n * For code in the same runtime, extract shared logic into a plain\n * TypeScript helper function instead, `runAction` has significant\n * overhead (separate function call, separate resource allocation).\n *\n * Consider using an {@link internalAction} to prevent users from calling the\n * action directly.\n *\n * @param action - A {@link FunctionReference} for the action to run.\n * @param args - The arguments to the action function.\n * @returns A promise of the action's result.\n */\n runAction<\n Action extends\n | FunctionReference<\"action\", \"public\" | \"internal\">\n | FunctionReference_future<\"action\", \"public\" | \"internal\">,\n >(\n action: Action,\n ...args: OptionalRestArgs<Action>\n ): Promise<FunctionReturnType<Action>>;\n\n /**\n * A utility for scheduling Convex functions to run in the future.\n */\n scheduler: Scheduler;\n\n /**\n * Information about the currently authenticated user.\n */\n auth: Auth;\n\n /**\n * A utility for reading and writing files in storage.\n */\n storage: StorageActionWriter;\n\n /**\n * Run a vector search on the given table and index.\n *\n * @param tableName - The name of the table to query.\n * @param indexName - The name of the vector index on the table to query.\n * @param query - A {@link VectorSearchQuery} containing the vector to query,\n * the number of results to return, and any filters.\n * @returns A promise of IDs and scores for the documents with the nearest\n * vectors\n */\n vectorSearch<\n TableName extends TableNamesInDataModel<DataModel>,\n IndexName extends VectorIndexNames<NamedTableInfo<DataModel, TableName>>,\n >(\n tableName: TableName,\n indexName: IndexName,\n query: Expand<\n VectorSearchQuery<NamedTableInfo<DataModel, TableName>, IndexName>\n >,\n ): Promise<Array<{ _id: Id<TableName>; _score: number }>>;\n\n meta: ActionMeta;\n}\n\n/**\n * The default arguments type for a Convex query, mutation, or action function.\n *\n * Convex functions always take an arguments object that maps the argument\n * names to their values.\n *\n * @public\n */\nexport type DefaultFunctionArgs = Record<string, unknown>;\n\n/**\n * The arguments array for a function that takes arguments.\n *\n * This is an array of a single {@link DefaultFunctionArgs} element.\n */\ntype OneArgArray<ArgsObject extends DefaultFunctionArgs = DefaultFunctionArgs> =\n [ArgsObject];\n\n/**\n * The arguments to a function that takes no arguments (just an empty array).\n */\ntype NoArgsArray = [];\n\n/**\n * An array of arguments to a Convex function.\n *\n * Convex functions can take either a single {@link DefaultFunctionArgs} object or no\n * args at all.\n *\n * @public\n */\nexport type ArgsArray = OneArgArray | NoArgsArray;\n\n/**\n * A type for the empty object `{}`.\n *\n * Note that we don't use `type EmptyObject = {}` because that matches every object.\n */\nexport type EmptyObject = Record<string, never>;\n\n/**\n * Convert an {@link ArgsArray} into a single object type.\n *\n * Empty arguments arrays are converted to {@link EmptyObject}.\n * @public\n */\nexport type ArgsArrayToObject<Args extends ArgsArray> =\n Args extends OneArgArray<infer ArgsObject> ? ArgsObject : EmptyObject;\n\n/**\n * A type representing the visibility of a Convex function.\n *\n * @public\n */\nexport type FunctionVisibility = \"public\" | \"internal\";\n\n/**\n * Given a {@link FunctionVisibility}, should this function have `isPublic: true`\n * or `isInternal: true`?\n */\ntype VisibilityProperties<Visiblity extends FunctionVisibility> = {\n /** Phantom type marker; not present at runtime. */\n _visibility: Visiblity;\n} & (Visiblity extends \"public\"\n ? {\n isPublic: true;\n }\n : {\n isInternal: true;\n });\n\n/**\n * A mutation function that is part of this app.\n *\n * You can create a mutation by wrapping your function in\n * {@link mutationGeneric} or {@link internalMutationGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredMutation<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isMutation: true;\n\n /** @internal */\n invokeMutation(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericMutationCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * A query function that is part of this app.\n *\n * You can create a query by wrapping your function in\n * {@link queryGeneric} or {@link internalQueryGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredQuery<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isQuery: true;\n\n /** @internal */\n invokeQuery(argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericQueryCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An action that is part of this app.\n *\n * You can create an action by wrapping your function in\n * {@link actionGeneric} or {@link internalActionGeneric} and exporting it.\n *\n * @public\n */\nexport type RegisteredAction<\n Visibility extends FunctionVisibility,\n Args extends DefaultFunctionArgs,\n Returns,\n> = {\n isConvexFunction: true;\n isAction: true;\n\n /** @internal */\n invokeAction(requestId: string, argsStr: string): Promise<string>;\n\n /** @internal */\n exportArgs(): string;\n\n /** @internal */\n exportReturns(): string;\n\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, args: Args) => Returns;\n} & VisibilityProperties<Visibility>;\n\n/**\n * An HTTP action that is part of this app's public API.\n *\n * You can create public HTTP actions by wrapping your function in\n * {@link httpActionGeneric} and exporting it.\n *\n * @public\n */\nexport type PublicHttpAction = {\n isHttp: true;\n\n /** @internal */\n invokeHttpAction(request: Request): Promise<Response>;\n /** @internal */\n _handler: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>;\n};\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function without\n * argument validation.\n *\n * Convex functions always take a context object as their first argument\n * and an (optional) args object as their second argument.\n *\n * This can be written as a function like:\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query(({ db }, { arg }) => {...});\n * ```\n * or as an object like:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export const func = query({\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n * See {@link ValidatedFunction} to add argument validation.\n *\n * @public\n */\nexport type UnvalidatedFunction<Ctx, Args extends ArgsArray, Returns> =\n | ((ctx: Ctx, ...args: Args) => Returns)\n | {\n handler: (ctx: Ctx, ...args: Args) => Returns;\n };\n\n/**\n * @deprecated -- See the type definition for `MutationBuilder` or similar for\n * the types used for defining Convex functions.\n *\n * The definition of a Convex query, mutation, or action function with argument\n * validation.\n *\n * Argument validation allows you to assert that the arguments to this function\n * are the expected type.\n *\n * Example:\n *\n * ```js\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const func = query({\n * args: {\n * arg: v.string()\n * },\n * handler: ({ db }, { arg }) => {...},\n * });\n * ```\n *\n * **For security, argument validation should be added to all public functions in\n * production apps.**\n *\n * See {@link UnvalidatedFunction} for functions without argument validation.\n * @public\n */\nexport interface ValidatedFunction<\n Ctx,\n ArgsValidator extends PropertyValidators,\n Returns,\n> {\n /**\n * A validator for the arguments of this function.\n *\n * This is an object mapping argument names to validators constructed with\n * {@link values.v}.\n *\n * ```js\n * import { v } from \"convex/values\";\n *\n * const args = {\n * stringArg: v.string(),\n * optionalNumberArg: v.optional(v.number()),\n * }\n * ```\n */\n args: ArgsValidator;\n\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator.\n * @returns\n */\n handler: (ctx: Ctx, args: ObjectType<ArgsValidator>) => Returns;\n}\n\n/**\n * There are multiple syntaxes for defining a Convex function:\n * ```\n * - query(async (ctx, args) => {...})\n * - query({ handler: async (ctx, args) => {...} })\n * - query({ args: { a: v.string }, handler: async (ctx, args) => {...} } })\n * - query({ args: { a: v.string }, returns: v.string(), handler: async (ctx, args) => {...} } })\n *```\n *\n * In each of these, we want to correctly infer the type for the arguments and\n * return value, preferring the type derived from a validator if it's provided.\n *\n * To avoid having a separate overload for each, which would show up in error messages,\n * we use the type params -- ArgsValidator, ReturnsValidator, ReturnValue, OneOrZeroArgs.\n *\n * The type for ReturnValue and OneOrZeroArgs are constrained by the type or ArgsValidator and\n * ReturnsValidator if they're present, and inferred from any explicit type annotations to the\n * arguments or return value of the function.\n *\n * Below are a few utility types to get the appropriate type constraints based on\n * an optional validator.\n *\n * Additional tricks:\n * - We use Validator | void instead of Validator | undefined because the latter does\n * not work with `strictNullChecks` since it's equivalent to just `Validator`.\n * - We use a tuple type of length 1 to avoid distribution over the union\n * https://github.com/microsoft/TypeScript/issues/29368#issuecomment-453529532\n */\n\nexport type ReturnValueForOptionalValidator<\n ReturnsValidator extends Validator<any, any, any> | PropertyValidators | void,\n> = [ReturnsValidator] extends [Validator<any, any, any>]\n ? ValidatorTypeToReturnType<Infer<ReturnsValidator>>\n : [ReturnsValidator] extends [PropertyValidators]\n ? ValidatorTypeToReturnType<ObjectType<ReturnsValidator>>\n : any;\n\nexport type ArgsArrayForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? OneArgArray<Infer<ArgsValidator>>\n : [ArgsValidator] extends [PropertyValidators]\n ? OneArgArray<ObjectType<ArgsValidator>>\n : ArgsArray;\n\nexport type DefaultArgsForOptionalValidator<\n ArgsValidator extends GenericValidator | PropertyValidators | void,\n> = [ArgsValidator] extends [Validator<any, any, any>]\n ? [Infer<ArgsValidator>]\n : [ArgsValidator] extends [PropertyValidators]\n ? [ObjectType<ArgsValidator>]\n : OneArgArray;\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link mutationGeneric} a type specific to your data model.\n * @public\n */\nexport type MutationBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n mutation:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericMutationCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredMutation<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link queryGeneric} a type specific to your data model.\n * @public\n */\nexport type QueryBuilderWithTable<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n query:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericQueryCtxWithTable<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredQuery<Visibility, ArgsArrayToObject<OneOrZeroArgs>, ReturnValue>;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link actionGeneric} a type specific to your data model.\n * @public\n */\nexport type ActionBuilder<\n DataModel extends GenericDataModel,\n Visibility extends FunctionVisibility,\n> = {\n <\n ArgsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnsValidator extends\n | PropertyValidators\n | Validator<any, \"required\", any>\n | void,\n ReturnValue extends ReturnValueForOptionalValidator<ReturnsValidator> = any,\n OneOrZeroArgs extends ArgsArrayForOptionalValidator<ArgsValidator> =\n DefaultArgsForOptionalValidator<ArgsValidator>,\n >(\n func:\n | {\n /**\n * Argument validation.\n *\n * Examples:\n *\n * ```\n * args: {}\n * args: { input: v.optional(v.number()) }\n * args: { message: v.string(), author: v.id(\"authors\") }\n * args: { messages: v.array(v.string()) }\n * ```\n *\n */\n args?: ArgsValidator;\n /**\n * The return value validator.\n *\n * Examples:\n *\n * ```\n * returns: v.null()\n * returns: v.string()\n * returns: { message: v.string(), author: v.id(\"authors\") }\n * returns: v.array(v.string())\n * ```\n */\n returns?: ReturnsValidator;\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n handler: (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ) => ReturnValue;\n }\n | {\n /**\n * The implementation of this function.\n *\n * This is a function that takes in the appropriate context and arguments\n * and produces some result.\n *\n * @param ctx - The context object. This is one of {@link QueryCtx},\n * {@link MutationCtx}, or {@link ActionCtx} depending on the function type.\n * @param args - The arguments object for this function. This will match\n * the type defined by the argument validator if provided.\n * @returns\n */\n (\n ctx: GenericActionCtx<DataModel>,\n ...args: OneOrZeroArgs\n ): ReturnValue;\n },\n ): RegisteredAction<\n Visibility,\n ArgsArrayToObject<OneOrZeroArgs>,\n ReturnValue\n >;\n};\n\n/**\n * Internal type helper used by Convex code generation.\n *\n * Used to give {@link httpActionGeneric} a type specific to your data model\n * and functions.\n * @public\n */\nexport type HttpActionBuilder = (\n func: (ctx: GenericActionCtx<any>, request: Request) => Promise<Response>,\n) => PublicHttpAction;\n\nexport interface AdvancedRunQueryOptions {\n /**\n * Custom limits for a nested transaction. Each field specifies the absolute\n * maximum allowed for the nested function call. Values are capped at the\n * global transaction limits, so they can only lower limits, never raise them.\n */\n transactionLimits?: TransactionLimits;\n /**\n * Run a query on a recent snapshot of the database that is not guaranteed\n * to be up-to-date when this transaction commits.\n *\n * This is an advanced feature which can introduce subtle race conditions,\n * so its use is generally discouraged except for specific use-cases where\n * database read conflicts are expected, e.g. reading from an append-only\n * table with immutable records where the only read conflicts are from\n * concurrent appends.\n *\n * To determine the snapshot of the nested query, you can call\n * `ctx.meta.getSnapshotTs()` from within the stale snapshot query. To\n * compare to the parent mutation's snapshot timestamp, you can return that\n * value from the query and call `ctx.meta.getSnapshotTs()` from the parent.\n */\n useStaleSnapshot?: boolean;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -57,8 +57,6 @@ class TableDefinition {
|
|
|
57
57
|
*
|
|
58
58
|
* Returns indexes defined on this table.
|
|
59
59
|
* Intended for the advanced use cases of dynamically deciding which index to use for a query.
|
|
60
|
-
* If you think you need this, please chime in on ths issue in the Convex JS GitHub repo.
|
|
61
|
-
* https://github.com/get-convex/convex-js/issues/49
|
|
62
60
|
*/
|
|
63
61
|
" indexes"() {
|
|
64
62
|
return this.indexes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/schema.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Utilities for defining the schema of your Convex project.\n *\n * ## Usage\n *\n * Schemas should be placed in a `schema.ts` file in your `convex/` directory.\n *\n * Schema definitions should be built using {@link defineSchema},\n * {@link defineTable}, and {@link values.v}. Make sure to export the schema as the\n * default export.\n *\n * ```ts\n * import { defineSchema, defineTable } from \"convex/server\";\n * import { v } from \"convex/values\";\n *\n * export default defineSchema({\n * messages: defineTable({\n * body: v.string(),\n * user: v.id(\"users\"),\n * }),\n * users: defineTable({\n * name: v.string(),\n * }),\n * });\n * ```\n *\n * To learn more about schemas, see [Defining a Schema](https://docs.convex.dev/using/schemas).\n * @module\n */\nimport {\n AnyDataModel,\n GenericDataModel,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n TableNamesInDataModel,\n} from \"../server/data_model.js\";\nimport {\n IdField,\n IndexTiebreakerField,\n SystemFields,\n SystemIndexes,\n} from \"../server/system_fields.js\";\nimport { Expand } from \"../type_utils.js\";\nimport { GenericId } from \"../values/index.js\";\nimport {\n GenericValidator,\n ObjectType,\n isValidator,\n v,\n} from \"../values/validator.js\";\nimport {\n VFloat64,\n VId,\n VObject,\n VUnion,\n Validator,\n} from \"../values/validators.js\";\n\n/**\n * Extract all of the index field paths within a {@link Validator}.\n *\n * This is used within {@link defineTable}.\n * @public\n */\ntype ExtractFieldPaths<T extends Validator<any, any, any>> =\n // Add in the system fields available in index definitions.\n // This should be everything except for `_id` because thats added to indexes\n // automatically.\n T[\"fieldPaths\"] | keyof SystemFields;\n\n/**\n * Extract the {@link GenericDocument} within a {@link Validator} and\n * add on the system fields.\n *\n * This is used within {@link defineTable}.\n * @public\n */\ntype ExtractDocument<T extends Validator<any, any, any>> =\n // Add the system fields to `Value` (except `_id` because it depends on\n //the table name) and trick TypeScript into expanding them.\n Expand<SystemFields & T[\"type\"]>;\n\nexport interface DbIndexConfig<\n FirstFieldPath extends string,\n RestFieldPaths extends string[],\n> {\n /**\n * The fields to index, in order. Must specify at least one field.\n */\n fields: [FirstFieldPath, ...RestFieldPaths];\n}\n\n/**\n * The configuration for a full text search index.\n *\n * @public\n */\nexport interface SearchIndexConfig<\n SearchField extends string,\n FilterFields extends string,\n> {\n /**\n * The field to index for full text search.\n *\n * This must be a field of type `string`.\n */\n searchField: SearchField;\n\n /**\n * Additional fields to index for fast filtering when running search queries.\n */\n filterFields?: FilterFields[];\n}\n\n/**\n * The configuration for a vector index.\n *\n * @public\n */\nexport interface VectorIndexConfig<\n VectorField extends string,\n FilterFields extends string,\n> {\n /**\n * The field to index for vector search.\n *\n * This must be a field of type `v.array(v.float64())` (or a union)\n */\n vectorField: VectorField;\n /**\n * The length of the vectors indexed. This must be between 2 and 2048 inclusive.\n */\n dimensions: number;\n /**\n * Additional fields to index for fast filtering when running vector searches.\n */\n filterFields?: FilterFields[];\n}\n\n/**\n * @internal\n */\nexport type VectorIndex = {\n indexDescriptor: string;\n vectorField: string;\n dimensions: number;\n filterFields: string[];\n};\n\n/**\n * @internal\n */\nexport type Index = {\n indexDescriptor: string;\n fields: string[];\n};\n\n/**\n * @internal\n */\nexport type SearchIndex = {\n indexDescriptor: string;\n searchField: string;\n filterFields: string[];\n};\n\n/**\n * Options for defining an index.\n *\n * @public\n */\nexport interface IndexOptions {\n /**\n * Whether the index should be staged.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n */\n staged?: boolean;\n}\n\n/**\n * The definition of a table within a schema.\n *\n * This should be produced by using {@link defineTable}.\n * @public\n */\nexport class TableDefinition<\n DocumentType extends Validator<any, any, any> = Validator<any, any, any>,\n Indexes extends GenericTableIndexes = {},\n SearchIndexes extends GenericTableSearchIndexes = {},\n VectorIndexes extends GenericTableVectorIndexes = {},\n> {\n private indexes: Index[];\n private stagedDbIndexes: Index[];\n private searchIndexes: SearchIndex[];\n private stagedSearchIndexes: SearchIndex[];\n private vectorIndexes: VectorIndex[];\n private stagedVectorIndexes: VectorIndex[];\n // The type of documents stored in this table.\n validator: DocumentType;\n // The proposed next validator for this table, validated against existing\n // documents in the background while `validator` remains enforced.\n private stagedValidator: Validator<any, any, any> | undefined;\n\n /**\n * @internal\n */\n constructor(documentType: DocumentType) {\n this.indexes = [];\n this.stagedDbIndexes = [];\n this.searchIndexes = [];\n this.stagedSearchIndexes = [];\n this.vectorIndexes = [];\n this.stagedVectorIndexes = [];\n this.validator = documentType;\n }\n\n /**\n * This API is experimental: it may change or disappear.\n *\n * Returns indexes defined on this table.\n * Intended for the advanced use cases of dynamically deciding which index to use for a query.\n * If you think you need this, please chime in on ths issue in the Convex JS GitHub repo.\n * https://github.com/get-convex/convex-js/issues/49\n */\n \" indexes\"(): { indexDescriptor: string; fields: string[] }[] {\n return this.indexes;\n }\n\n /**\n * Define an index on this table.\n *\n * Indexes speed up queries by allowing efficient lookups on specific fields.\n * Use `.withIndex()` in your queries to leverage them.\n *\n * Index fields must be queried in the same order they are defined. If you\n * need to query by `field2` then `field1`, create a separate index with\n * that field order.\n *\n * @example\n * ```ts\n * defineTable({\n * userId: v.id(\"users\"),\n * status: v.string(),\n * updatedAt: v.number(),\n * })\n * // Name indexes after their fields:\n * .index(\"by_userId\", [\"userId\"])\n * .index(\"by_status_updatedAt\", [\"status\", \"updatedAt\"])\n * ```\n *\n * **Best practice:** Always include all index fields in the index name\n * (e.g., `\"by_field1_and_field2\"`).\n *\n * @param name - The name of the index.\n * @param indexConfig - The index configuration object.\n * @returns A {@link TableDefinition} with this index included.\n *\n * @see https://docs.convex.dev/database/reading-data/indexes\n */\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n indexConfig: Expand<\n DbIndexConfig<FirstFieldPath, RestFieldPaths> &\n IndexOptions & { staged?: false }\n >,\n ): TableDefinition<\n DocumentType,\n Expand<\n Indexes &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes,\n VectorIndexes\n >;\n\n /**\n * Define an index on this table.\n *\n * To learn about indexes, see [Defining Indexes](https://docs.convex.dev/database/reading-data/indexes).\n *\n * @param name - The name of the index.\n * @param fields - The fields to index, in order. Must specify at least one\n * field.\n * @returns A {@link TableDefinition} with this index included.\n */\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n fields: [FirstFieldPath, ...RestFieldPaths],\n ): TableDefinition<\n DocumentType,\n Expand<\n Indexes &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes,\n VectorIndexes\n >;\n\n /**\n * Define a staged index on this table.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n *\n * To learn about indexes, see [Defining Indexes](https://docs.convex.dev/using/indexes).\n *\n * @param name - The name of the index.\n * @param indexConfig - The index configuration object.\n * @returns A {@link TableDefinition} with this index included.\n */\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n indexConfig: Expand<\n DbIndexConfig<FirstFieldPath, RestFieldPaths> &\n IndexOptions & { staged: true }\n >,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>;\n\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n indexConfig:\n | Expand<DbIndexConfig<FirstFieldPath, RestFieldPaths> & IndexOptions>\n | [FirstFieldPath, ...RestFieldPaths],\n ) {\n if (Array.isArray(indexConfig)) {\n // indexConfig is [FirstFieldPath, ...RestFieldPaths]\n this.indexes.push({\n indexDescriptor: name,\n fields: indexConfig,\n });\n } else if (indexConfig.staged) {\n // indexConfig is object with fields and staged: true\n this.stagedDbIndexes.push({\n indexDescriptor: name,\n fields: indexConfig.fields,\n });\n } else {\n // indexConfig is object with fields (and maybe staged: false/undefined)\n this.indexes.push({\n indexDescriptor: name,\n fields: indexConfig.fields,\n });\n }\n return this;\n }\n\n /**\n * Define a search index on this table.\n *\n * To learn about search indexes, see [Search](https://docs.convex.dev/text-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The search index configuration object.\n * @returns A {@link TableDefinition} with this search index included.\n */\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n SearchIndexConfig<SearchField, FilterFields> &\n IndexOptions & { staged?: false }\n >,\n ): TableDefinition<\n DocumentType,\n Indexes,\n // Update `SearchIndexes` to include the new index and use `Expand` to make\n // the types look pretty in editors.\n Expand<\n SearchIndexes &\n Record<\n IndexName,\n {\n searchField: SearchField;\n filterFields: FilterFields;\n }\n >\n >,\n VectorIndexes\n >;\n\n /**\n * Define a staged search index on this table.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n *\n * To learn about search indexes, see [Search](https://docs.convex.dev/text-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The search index configuration object.\n * @returns A {@link TableDefinition} with this search index included.\n */\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n SearchIndexConfig<SearchField, FilterFields> &\n IndexOptions & { staged: true }\n >,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>;\n\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n SearchIndexConfig<SearchField, FilterFields> & IndexOptions\n >,\n ) {\n if (indexConfig.staged) {\n this.stagedSearchIndexes.push({\n indexDescriptor: name,\n searchField: indexConfig.searchField,\n filterFields: indexConfig.filterFields || [],\n });\n } else {\n this.searchIndexes.push({\n indexDescriptor: name,\n searchField: indexConfig.searchField,\n filterFields: indexConfig.filterFields || [],\n });\n }\n return this;\n }\n\n /**\n * Define a vector index on this table.\n *\n * To learn about vector indexes, see [Vector Search](https://docs.convex.dev/vector-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The vector index configuration object.\n * @returns A {@link TableDefinition} with this vector index included.\n */\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n VectorIndexConfig<VectorField, FilterFields> &\n IndexOptions & { staged?: false }\n >,\n ): TableDefinition<\n DocumentType,\n Indexes,\n SearchIndexes,\n Expand<\n VectorIndexes &\n Record<\n IndexName,\n {\n vectorField: VectorField;\n dimensions: number;\n filterFields: FilterFields;\n }\n >\n >\n >;\n\n /**\n * Define a staged vector index on this table.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n *\n * To learn about vector indexes, see [Vector Search](https://docs.convex.dev/vector-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The vector index configuration object.\n * @returns A {@link TableDefinition} with this vector index included.\n */\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n VectorIndexConfig<VectorField, FilterFields> &\n IndexOptions & { staged: true }\n >,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>;\n\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n VectorIndexConfig<VectorField, FilterFields> & IndexOptions\n >,\n ) {\n if (indexConfig.staged) {\n this.stagedVectorIndexes.push({\n indexDescriptor: name,\n vectorField: indexConfig.vectorField,\n dimensions: indexConfig.dimensions,\n filterFields: indexConfig.filterFields || [],\n });\n } else {\n this.vectorIndexes.push({\n indexDescriptor: name,\n vectorField: indexConfig.vectorField,\n dimensions: indexConfig.dimensions,\n filterFields: indexConfig.filterFields || [],\n });\n }\n return this;\n }\n\n /**\n * Stage changes to this table's document validator.\n *\n * Convex validates the staged validator against the table's existing\n * documents in the background, while the validator passed to\n * {@link defineTable} remains the one enforced on writes. Once\n * the background validation succeeds, apply the staged changes\n * and remove `.staged()`.\n *\n * For an object validator, pass only the fields to add or replace. Fields\n * omitted from the changes keep their enforced validators.\n * Set a field to `undefined` to remove it from the staged validator.\n * For nested objects, you must specify the full object validator.\n *\n * ```ts\n * defineTable({\n * apple: v.string(),\n * banana: v.number(),\n * legacy: v.optional(v.string()),\n * }).staged({\n * banana: v.union(v.string(), v.number()),\n * legacy: undefined,\n * })\n * ```\n *\n * See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).\n *\n * @param documentSchema - Field changes for a table defined as an object or\n * `v.any()`, or a full schema validator specifying the proposed next document\n * type. Use a full schema validator for a table defined as a union.\n * @returns A {@link TableDefinition} with the staged validator attached.\n */\n staged(\n documentSchema:\n | Validator<Record<string, any>, \"required\", any>\n | Record<string, GenericValidator | undefined>,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {\n if (this.stagedValidator !== undefined) {\n throw new Error(\"Table cannot have more than one staged validator.\");\n }\n if (isValidator(documentSchema)) {\n this.stagedValidator = documentSchema;\n } else {\n if (this.validator.kind !== \"object\" && this.validator.kind !== \"any\") {\n throw new Error(\n \"Specifying top-level field changes is only supported for simple table definitions. For a table defined with a union or record validator, you must stage a fully defined object or union validator.\",\n );\n }\n const enforcedFields =\n this.validator.kind === \"object\" ? this.validator.fields : {};\n const fields: Record<string, GenericValidator> = Object.fromEntries(\n Object.entries({ ...enforcedFields, ...documentSchema }).filter(\n (entry): entry is [string, GenericValidator] =>\n entry[1] !== undefined,\n ),\n );\n this.stagedValidator = v.object(fields);\n }\n return this.self();\n }\n\n /**\n * Work around for https://github.com/microsoft/TypeScript/issues/57035\n */\n protected self(): TableDefinition<\n DocumentType,\n Indexes,\n SearchIndexes,\n VectorIndexes\n > {\n return this;\n }\n /**\n * Export the contents of this definition.\n *\n * This is called internally by the Convex framework.\n * @internal\n */\n export() {\n const documentType = this.validator.json;\n if (typeof documentType !== \"object\") {\n throw new Error(\n \"Invalid validator: please make sure that the parameter of `defineTable` is valid (see https://docs.convex.dev/database/schemas)\",\n );\n }\n\n let stagedDocumentType = undefined;\n if (this.stagedValidator !== undefined) {\n stagedDocumentType = this.stagedValidator.json;\n if (typeof stagedDocumentType !== \"object\") {\n throw new Error(\n \"Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)\",\n );\n }\n }\n\n return {\n indexes: this.indexes,\n stagedDbIndexes: this.stagedDbIndexes,\n searchIndexes: this.searchIndexes,\n stagedSearchIndexes: this.stagedSearchIndexes,\n vectorIndexes: this.vectorIndexes,\n stagedVectorIndexes: this.stagedVectorIndexes,\n documentType,\n stagedDocumentType,\n };\n }\n}\n\n/**\n * Define a table in a schema.\n *\n * You can either specify the schema of your documents as an object like\n * ```ts\n * defineTable({\n * field: v.string()\n * });\n * ```\n *\n * or as a schema type like\n * ```ts\n * defineTable(\n * v.union(\n * v.object({...}),\n * v.object({...})\n * )\n * );\n * ```\n *\n * @param documentSchema - The type of documents stored in this table.\n * @returns A {@link TableDefinition} for the table.\n *\n * @public\n */\nexport function defineTable<\n DocumentSchema extends Validator<Record<string, any>, \"required\", any>,\n>(documentSchema: DocumentSchema): TableDefinition<DocumentSchema>;\n/**\n * Define a table in a schema.\n *\n * You can either specify the schema of your documents as an object like\n * ```ts\n * defineTable({\n * field: v.string()\n * });\n * ```\n *\n * or as a schema type like\n * ```ts\n * defineTable(\n * v.union(\n * v.object({...}),\n * v.object({...})\n * )\n * );\n * ```\n *\n * @param documentSchema - The type of documents stored in this table.\n * @returns A {@link TableDefinition} for the table.\n *\n * @public\n */\nexport function defineTable<\n DocumentSchema extends Record<string, GenericValidator>,\n>(\n documentSchema: DocumentSchema,\n): TableDefinition<VObject<ObjectType<DocumentSchema>, DocumentSchema>>;\nexport function defineTable<\n DocumentSchema extends\n | Validator<Record<string, any>, \"required\", any>\n | Record<string, GenericValidator>,\n>(documentSchema: DocumentSchema): TableDefinition<any, any, any> {\n if (isValidator(documentSchema)) {\n return new TableDefinition(documentSchema);\n } else {\n return new TableDefinition(v.object(documentSchema));\n }\n}\n\n/**\n * The validators for the system fields Convex adds to every document.\n *\n * @public\n */\nexport type SystemFieldValidators<TableName extends string> = {\n _id: VId<GenericId<TableName>>;\n _creationTime: VFloat64<number>;\n};\n\n/**\n * Add the system field validators to an object validator, leaving any other\n * validator untouched.\n */\ntype WithSystemFieldValidators<\n TableName extends string,\n DocumentType extends Validator<any, any, any>,\n> =\n DocumentType extends VObject<infer Type, infer Fields, any, any>\n ? VObject<\n Expand<IdField<TableName> & SystemFields & Type>,\n Expand<SystemFieldValidators<TableName> & Fields>\n >\n : DocumentType;\n\n/**\n * The validator for whole documents of a table: the table's own validator with\n * the `_id` and `_creationTime` system fields added.\n *\n * For a table defined with a union, the system fields are added to each member\n * of the union.\n *\n * @public\n */\nexport type DocValidator<\n TableName extends string,\n DocumentType extends Validator<any, any, any>,\n> =\n DocumentType extends VUnion<any, infer Members, any, any>\n ? {\n [Index in keyof Members]: WithSystemFieldValidators<\n TableName,\n Members[Index]\n >;\n } extends infer NewMembers extends Validator<any, \"required\", any>[]\n ? VUnion<\n WithSystemFieldValidators<TableName, Members[number]>[\"type\"],\n NewMembers\n >\n : never\n : WithSystemFieldValidators<TableName, DocumentType>;\n\nfunction addSystemFields(\n tableName: string,\n validator: GenericValidator,\n): GenericValidator {\n switch (validator.kind) {\n case \"object\":\n return validator.extend({\n _id: v.id(tableName),\n _creationTime: v.number(),\n });\n case \"union\":\n return v.union(\n ...validator.members.map((member) =>\n addSystemFields(tableName, member),\n ),\n );\n // `v.any()` already permits the system fields.\n case \"any\":\n return validator;\n default:\n throw new Error(\n `Invalid validator for table \"${tableName}\": a table's documents must be objects, or a union of objects (see https://docs.convex.dev/database/schemas)`,\n );\n }\n}\n\n/**\n * Build the validator for whole documents of a table, by adding the `_id` and\n * `_creationTime` system fields to the table's own validator.\n *\n * Prefer {@link SchemaDefinition.doc} when you have the schema in hand: it\n * checks the table name against the schema.\n *\n * @example\n * ```ts\n * const messageDoc = docValidator(\"messages\", schema.tables.messages);\n *\n * export const get = query({\n * args: { id: v.id(\"messages\") },\n * returns: v.union(messageDoc, v.null()),\n * handler: (ctx, args) => ctx.db.get(args.id),\n * });\n * ```\n *\n * @param tableName - The name of the table, used for the `_id` validator.\n * @param table - The {@link TableDefinition} for that table.\n * @returns A validator matching documents of the table.\n *\n * @public\n */\nexport function docValidator<\n TableName extends string,\n Table extends TableDefinition<any, any, any, any>,\n>(\n tableName: TableName,\n table: Table,\n): DocValidator<TableName, Table[\"validator\"]> {\n return addSystemFields(tableName, table.validator) as DocValidator<\n TableName,\n Table[\"validator\"]\n >;\n}\n\n/**\n * A type describing the schema of a Convex project.\n *\n * This should be constructed using {@link defineSchema}, {@link defineTable},\n * and {@link v}.\n * @public\n */\nexport type GenericSchema = Record<string, TableDefinition>;\n\nfunction tableInSchema<\n Schema extends GenericSchema,\n TableName extends keyof Schema & string,\n>(\n schema: SchemaDefinition<Schema, boolean>,\n tableName: TableName,\n): Schema[TableName] {\n const table = schema.tables[tableName];\n if (table === undefined) {\n throw new Error(\n `Table \"${tableName}\" is not in this schema. Tables in this schema: ${Object.keys(\n schema.tables,\n ).join(\", \")}`,\n );\n }\n return table;\n}\n\n/**\n *\n * The definition of a Convex project schema.\n *\n * This should be produced by using {@link defineSchema}.\n * @public\n */\nexport class SchemaDefinition<\n Schema extends GenericSchema,\n StrictTableTypes extends boolean,\n> {\n public tables: Schema;\n public strictTableNameTypes!: StrictTableTypes;\n public readonly schemaValidation: boolean;\n\n /**\n * @internal\n */\n constructor(tables: Schema, options?: DefineSchemaOptions<StrictTableTypes>) {\n this.tables = tables;\n this.schemaValidation =\n options?.schemaValidation === undefined ? true : options.schemaValidation;\n }\n\n /**\n * The validator for whole documents of a table in this schema: the table's\n * own validator with the `_id` and `_creationTime` system fields added.\n *\n * @example\n * ```ts\n * export const get = query({\n * args: { id: schema.id(\"messages\") },\n * returns: v.union(schema.doc(\"messages\"), v.null()),\n * handler: (ctx, args) => ctx.db.get(args.id),\n * });\n * ```\n *\n * @param tableName - The name of a table in this schema.\n * @returns A validator matching documents of that table.\n */\n doc<TableName extends keyof Schema & string>(\n tableName: TableName,\n ): DocValidator<TableName, Schema[TableName][\"validator\"]> {\n return docValidator(tableName, tableInSchema(this, tableName));\n }\n\n /**\n * The validator for IDs of a table in this schema.\n *\n * Same as `v.id(tableName)`, but only accepts tables in this schema.\n *\n * @param tableName - The name of a table in this schema.\n * @returns A validator matching IDs of that table.\n */\n id<TableName extends keyof Schema & string>(\n tableName: TableName,\n ): VId<GenericId<TableName>> {\n tableInSchema(this, tableName);\n return v.id(tableName);\n }\n\n /**\n * Export the contents of this definition.\n *\n * This is called internally by the Convex framework.\n * @internal\n */\n export(): string {\n return JSON.stringify({\n tables: Object.entries(this.tables).map(([tableName, definition]) => {\n const {\n indexes,\n stagedDbIndexes,\n searchIndexes,\n stagedSearchIndexes,\n vectorIndexes,\n stagedVectorIndexes,\n documentType,\n stagedDocumentType,\n } = definition.export();\n return {\n tableName,\n indexes,\n stagedDbIndexes,\n searchIndexes,\n stagedSearchIndexes,\n vectorIndexes,\n stagedVectorIndexes,\n documentType,\n stagedDocumentType,\n };\n }),\n schemaValidation: this.schemaValidation,\n });\n }\n}\n\n/**\n * Options for {@link defineSchema}.\n *\n * @public\n */\nexport interface DefineSchemaOptions<StrictTableNameTypes extends boolean> {\n /**\n * Whether Convex should validate at runtime that all documents match\n * your schema.\n *\n * If `schemaValidation` is `true`, Convex will:\n * 1. Check that all existing documents match your schema when your schema\n * is pushed.\n * 2. Check that all insertions and updates match your schema during mutations.\n *\n * If `schemaValidation` is `false`, Convex will not validate that new or\n * existing documents match your schema. You'll still get schema-specific\n * TypeScript types, but there will be no validation at runtime that your\n * documents match those types.\n *\n * By default, `schemaValidation` is `true`.\n */\n schemaValidation?: boolean;\n\n /**\n * Whether the TypeScript types should allow accessing tables not in the schema.\n *\n * If `strictTableNameTypes` is `true`, using tables not listed in the schema\n * will generate a TypeScript compilation error.\n *\n * If `strictTableNameTypes` is `false`, you'll be able to access tables not\n * listed in the schema and their document type will be `any`.\n *\n * `strictTableNameTypes: false` is useful for rapid prototyping.\n *\n * Regardless of the value of `strictTableNameTypes`, your schema will only\n * validate documents in the tables listed in the schema. You can still create\n * and modify other tables on the dashboard or in JavaScript mutations.\n *\n * By default, `strictTableNameTypes` is `true`.\n */\n strictTableNameTypes?: StrictTableNameTypes;\n}\n\n/**\n * Define the schema of this Convex project.\n *\n * This should be exported as the default export from a `schema.ts` file in\n * your `convex/` directory. The schema enables runtime validation of documents\n * and provides end-to-end TypeScript type safety.\n *\n * Every document in Convex automatically has two system fields:\n * - `_id` - a unique document ID with validator `v.id(\"tableName\")`\n * - `_creationTime` - a creation timestamp with validator `v.number()`\n *\n * You do not need to include these in your schema definition, they are added\n * automatically.\n *\n * @example\n * ```ts\n * // convex/schema.ts\n * import { defineSchema, defineTable } from \"convex/server\";\n * import { v } from \"convex/values\";\n *\n * export default defineSchema({\n * users: defineTable({\n * name: v.string(),\n * email: v.string(),\n * }).index(\"by_email\", [\"email\"]),\n *\n * messages: defineTable({\n * body: v.string(),\n * userId: v.id(\"users\"),\n * channelId: v.id(\"channels\"),\n * }).index(\"by_channel\", [\"channelId\"]),\n *\n * channels: defineTable({\n * name: v.string(),\n * }),\n *\n * // Discriminated union table:\n * results: defineTable(\n * v.union(\n * v.object({ kind: v.literal(\"error\"), message: v.string() }),\n * v.object({ kind: v.literal(\"success\"), value: v.number() }),\n * )\n * ),\n * });\n * ```\n *\n * **Best practice:** Always include all index fields in the index name. For\n * example, an index on `[\"field1\", \"field2\"]` should be named\n * `\"by_field1_field2\"`.\n *\n * @param schema - A map from table name to {@link TableDefinition} for all of\n * the tables in this project.\n * @param options - Optional configuration. See {@link DefineSchemaOptions} for\n * a full description.\n * @returns The schema.\n *\n * @see https://docs.convex.dev/database/schemas\n * @public\n */\nexport function defineSchema<\n Schema extends GenericSchema,\n StrictTableNameTypes extends boolean = true,\n>(\n schema: Schema,\n options?: DefineSchemaOptions<StrictTableNameTypes>,\n): SchemaDefinition<Schema, StrictTableNameTypes> {\n return new SchemaDefinition(schema, options);\n}\n\n/**\n * Internal type used in Convex code generation!\n *\n * Convert a {@link SchemaDefinition} into a {@link server.GenericDataModel}.\n *\n * @public\n */\nexport type DataModelFromSchemaDefinition<\n SchemaDef extends SchemaDefinition<any, boolean>,\n> = MaybeMakeLooseDataModel<\n {\n [TableName in keyof SchemaDef[\"tables\"] &\n string]: SchemaDef[\"tables\"][TableName] extends TableDefinition<\n infer DocumentType,\n infer Indexes,\n infer SearchIndexes,\n infer VectorIndexes\n >\n ? {\n // We've already added all of the system fields except for `_id`.\n // Add that here.\n document: Expand<IdField<TableName> & ExtractDocument<DocumentType>>;\n fieldPaths:\n | keyof IdField<TableName>\n | ExtractFieldPaths<DocumentType>;\n indexes: Expand<Indexes & SystemIndexes>;\n searchIndexes: SearchIndexes;\n vectorIndexes: VectorIndexes;\n }\n : never;\n },\n SchemaDef[\"strictTableNameTypes\"]\n>;\n\ntype MaybeMakeLooseDataModel<\n DataModel extends GenericDataModel,\n StrictTableNameTypes extends boolean,\n> = StrictTableNameTypes extends true\n ? DataModel\n : Expand<DataModel & AnyDataModel>;\n\nconst _systemSchema = defineSchema({\n _scheduled_functions: defineTable({\n name: v.string(),\n args: v.array(v.any()),\n scheduledTime: v.float64(),\n completedTime: v.optional(v.float64()),\n state: v.union(\n v.object({ kind: v.literal(\"pending\") }),\n v.object({ kind: v.literal(\"inProgress\") }),\n v.object({ kind: v.literal(\"success\") }),\n v.object({ kind: v.literal(\"failed\"), error: v.string() }),\n v.object({ kind: v.literal(\"canceled\") }),\n ),\n }),\n _storage: defineTable({\n sha256: v.string(),\n size: v.float64(),\n contentType: v.optional(v.string()),\n }),\n});\n\nexport interface SystemDataModel extends DataModelFromSchemaDefinition<\n typeof _systemSchema\n> {}\n\nexport type SystemTableNames = TableNamesInDataModel<SystemDataModel>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6CA,uBAKO;AA8IA,MAAM,gBAKX;AAAA;AAAA;AAAA;AAAA,EAgBA,YAAY,cAA4B;AAfxC,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AAER;AAAA;AAGA;AAAA;AAAA,wBAAQ;AAMN,SAAK,UAAU,CAAC;AAChB,SAAK,kBAAkB,CAAC;AACxB,SAAK,gBAAgB,CAAC;AACtB,SAAK,sBAAsB,CAAC;AAC5B,SAAK,gBAAgB,CAAC;AACtB,SAAK,sBAAsB,CAAC;AAC5B,SAAK,YAAY;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * Utilities for defining the schema of your Convex project.\n *\n * ## Usage\n *\n * Schemas should be placed in a `schema.ts` file in your `convex/` directory.\n *\n * Schema definitions should be built using {@link defineSchema},\n * {@link defineTable}, and {@link values.v}. Make sure to export the schema as the\n * default export.\n *\n * ```ts\n * import { defineSchema, defineTable } from \"convex/server\";\n * import { v } from \"convex/values\";\n *\n * export default defineSchema({\n * messages: defineTable({\n * body: v.string(),\n * user: v.id(\"users\"),\n * }),\n * users: defineTable({\n * name: v.string(),\n * }),\n * });\n * ```\n *\n * To learn more about schemas, see [Defining a Schema](https://docs.convex.dev/using/schemas).\n * @module\n */\nimport {\n AnyDataModel,\n GenericDataModel,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n TableNamesInDataModel,\n} from \"../server/data_model.js\";\nimport {\n IdField,\n IndexTiebreakerField,\n SystemFields,\n SystemIndexes,\n} from \"../server/system_fields.js\";\nimport { Expand } from \"../type_utils.js\";\nimport { GenericId } from \"../values/index.js\";\nimport {\n GenericValidator,\n ObjectType,\n isValidator,\n v,\n} from \"../values/validator.js\";\nimport {\n VFloat64,\n VId,\n VObject,\n VUnion,\n Validator,\n} from \"../values/validators.js\";\n\n/**\n * Extract all of the index field paths within a {@link Validator}.\n *\n * This is used within {@link defineTable}.\n * @public\n */\ntype ExtractFieldPaths<T extends Validator<any, any, any>> =\n // Add in the system fields available in index definitions.\n // This should be everything except for `_id` because thats added to indexes\n // automatically.\n T[\"fieldPaths\"] | keyof SystemFields;\n\n/**\n * Extract the {@link GenericDocument} within a {@link Validator} and\n * add on the system fields.\n *\n * This is used within {@link defineTable}.\n * @public\n */\ntype ExtractDocument<T extends Validator<any, any, any>> =\n // Add the system fields to `Value` (except `_id` because it depends on\n //the table name) and trick TypeScript into expanding them.\n Expand<SystemFields & T[\"type\"]>;\n\nexport interface DbIndexConfig<\n FirstFieldPath extends string,\n RestFieldPaths extends string[],\n> {\n /**\n * The fields to index, in order. Must specify at least one field.\n */\n fields: [FirstFieldPath, ...RestFieldPaths];\n}\n\n/**\n * The configuration for a full text search index.\n *\n * @public\n */\nexport interface SearchIndexConfig<\n SearchField extends string,\n FilterFields extends string,\n> {\n /**\n * The field to index for full text search.\n *\n * This must be a field of type `string`.\n */\n searchField: SearchField;\n\n /**\n * Additional fields to index for fast filtering when running search queries.\n */\n filterFields?: FilterFields[];\n}\n\n/**\n * The configuration for a vector index.\n *\n * @public\n */\nexport interface VectorIndexConfig<\n VectorField extends string,\n FilterFields extends string,\n> {\n /**\n * The field to index for vector search.\n *\n * This must be a field of type `v.array(v.float64())` (or a union)\n */\n vectorField: VectorField;\n /**\n * The length of the vectors indexed. This must be between 2 and 2048 inclusive.\n */\n dimensions: number;\n /**\n * Additional fields to index for fast filtering when running vector searches.\n */\n filterFields?: FilterFields[];\n}\n\n/**\n * @internal\n */\nexport type VectorIndex = {\n indexDescriptor: string;\n vectorField: string;\n dimensions: number;\n filterFields: string[];\n};\n\n/**\n * @internal\n */\nexport type Index = {\n indexDescriptor: string;\n fields: string[];\n};\n\n/**\n * @internal\n */\nexport type SearchIndex = {\n indexDescriptor: string;\n searchField: string;\n filterFields: string[];\n};\n\n/**\n * Options for defining an index.\n *\n * @public\n */\nexport interface IndexOptions {\n /**\n * Whether the index should be staged.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n */\n staged?: boolean;\n}\n\n/**\n * The definition of a table within a schema.\n *\n * This should be produced by using {@link defineTable}.\n * @public\n */\nexport class TableDefinition<\n DocumentType extends Validator<any, any, any> = Validator<any, any, any>,\n Indexes extends GenericTableIndexes = {},\n SearchIndexes extends GenericTableSearchIndexes = {},\n VectorIndexes extends GenericTableVectorIndexes = {},\n> {\n private indexes: Index[];\n private stagedDbIndexes: Index[];\n private searchIndexes: SearchIndex[];\n private stagedSearchIndexes: SearchIndex[];\n private vectorIndexes: VectorIndex[];\n private stagedVectorIndexes: VectorIndex[];\n // The type of documents stored in this table.\n validator: DocumentType;\n // The proposed next validator for this table, validated against existing\n // documents in the background while `validator` remains enforced.\n private stagedValidator: Validator<any, any, any> | undefined;\n\n /**\n * @internal\n */\n constructor(documentType: DocumentType) {\n this.indexes = [];\n this.stagedDbIndexes = [];\n this.searchIndexes = [];\n this.stagedSearchIndexes = [];\n this.vectorIndexes = [];\n this.stagedVectorIndexes = [];\n this.validator = documentType;\n }\n\n /**\n * This API is experimental: it may change or disappear.\n *\n * Returns indexes defined on this table.\n * Intended for the advanced use cases of dynamically deciding which index to use for a query.\n */\n \" indexes\"(): { indexDescriptor: string; fields: string[] }[] {\n return this.indexes;\n }\n\n /**\n * Define an index on this table.\n *\n * Indexes speed up queries by allowing efficient lookups on specific fields.\n * Use `.withIndex()` in your queries to leverage them.\n *\n * Index fields must be queried in the same order they are defined. If you\n * need to query by `field2` then `field1`, create a separate index with\n * that field order.\n *\n * @example\n * ```ts\n * defineTable({\n * userId: v.id(\"users\"),\n * status: v.string(),\n * updatedAt: v.number(),\n * })\n * // Name indexes after their fields:\n * .index(\"by_userId\", [\"userId\"])\n * .index(\"by_status_updatedAt\", [\"status\", \"updatedAt\"])\n * ```\n *\n * **Best practice:** Always include all index fields in the index name\n * (e.g., `\"by_field1_and_field2\"`).\n *\n * @param name - The name of the index.\n * @param indexConfig - The index configuration object.\n * @returns A {@link TableDefinition} with this index included.\n *\n * @see https://docs.convex.dev/database/reading-data/indexes\n */\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n indexConfig: Expand<\n DbIndexConfig<FirstFieldPath, RestFieldPaths> &\n IndexOptions & { staged?: false }\n >,\n ): TableDefinition<\n DocumentType,\n Expand<\n Indexes &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes,\n VectorIndexes\n >;\n\n /**\n * Define an index on this table.\n *\n * To learn about indexes, see [Defining Indexes](https://docs.convex.dev/database/reading-data/indexes).\n *\n * @param name - The name of the index.\n * @param fields - The fields to index, in order. Must specify at least one\n * field.\n * @returns A {@link TableDefinition} with this index included.\n */\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n fields: [FirstFieldPath, ...RestFieldPaths],\n ): TableDefinition<\n DocumentType,\n Expand<\n Indexes &\n Record<\n IndexName,\n [FirstFieldPath, ...RestFieldPaths, IndexTiebreakerField]\n >\n >,\n SearchIndexes,\n VectorIndexes\n >;\n\n /**\n * Define a staged index on this table.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n *\n * To learn about indexes, see [Defining Indexes](https://docs.convex.dev/using/indexes).\n *\n * @param name - The name of the index.\n * @param indexConfig - The index configuration object.\n * @returns A {@link TableDefinition} with this index included.\n */\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n indexConfig: Expand<\n DbIndexConfig<FirstFieldPath, RestFieldPaths> &\n IndexOptions & { staged: true }\n >,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>;\n\n index<\n IndexName extends string,\n FirstFieldPath extends ExtractFieldPaths<DocumentType>,\n RestFieldPaths extends ExtractFieldPaths<DocumentType>[],\n >(\n name: IndexName,\n indexConfig:\n | Expand<DbIndexConfig<FirstFieldPath, RestFieldPaths> & IndexOptions>\n | [FirstFieldPath, ...RestFieldPaths],\n ) {\n if (Array.isArray(indexConfig)) {\n // indexConfig is [FirstFieldPath, ...RestFieldPaths]\n this.indexes.push({\n indexDescriptor: name,\n fields: indexConfig,\n });\n } else if (indexConfig.staged) {\n // indexConfig is object with fields and staged: true\n this.stagedDbIndexes.push({\n indexDescriptor: name,\n fields: indexConfig.fields,\n });\n } else {\n // indexConfig is object with fields (and maybe staged: false/undefined)\n this.indexes.push({\n indexDescriptor: name,\n fields: indexConfig.fields,\n });\n }\n return this;\n }\n\n /**\n * Define a search index on this table.\n *\n * To learn about search indexes, see [Search](https://docs.convex.dev/text-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The search index configuration object.\n * @returns A {@link TableDefinition} with this search index included.\n */\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n SearchIndexConfig<SearchField, FilterFields> &\n IndexOptions & { staged?: false }\n >,\n ): TableDefinition<\n DocumentType,\n Indexes,\n // Update `SearchIndexes` to include the new index and use `Expand` to make\n // the types look pretty in editors.\n Expand<\n SearchIndexes &\n Record<\n IndexName,\n {\n searchField: SearchField;\n filterFields: FilterFields;\n }\n >\n >,\n VectorIndexes\n >;\n\n /**\n * Define a staged search index on this table.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n *\n * To learn about search indexes, see [Search](https://docs.convex.dev/text-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The search index configuration object.\n * @returns A {@link TableDefinition} with this search index included.\n */\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n SearchIndexConfig<SearchField, FilterFields> &\n IndexOptions & { staged: true }\n >,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>;\n\n searchIndex<\n IndexName extends string,\n SearchField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n SearchIndexConfig<SearchField, FilterFields> & IndexOptions\n >,\n ) {\n if (indexConfig.staged) {\n this.stagedSearchIndexes.push({\n indexDescriptor: name,\n searchField: indexConfig.searchField,\n filterFields: indexConfig.filterFields || [],\n });\n } else {\n this.searchIndexes.push({\n indexDescriptor: name,\n searchField: indexConfig.searchField,\n filterFields: indexConfig.filterFields || [],\n });\n }\n return this;\n }\n\n /**\n * Define a vector index on this table.\n *\n * To learn about vector indexes, see [Vector Search](https://docs.convex.dev/vector-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The vector index configuration object.\n * @returns A {@link TableDefinition} with this vector index included.\n */\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n VectorIndexConfig<VectorField, FilterFields> &\n IndexOptions & { staged?: false }\n >,\n ): TableDefinition<\n DocumentType,\n Indexes,\n SearchIndexes,\n Expand<\n VectorIndexes &\n Record<\n IndexName,\n {\n vectorField: VectorField;\n dimensions: number;\n filterFields: FilterFields;\n }\n >\n >\n >;\n\n /**\n * Define a staged vector index on this table.\n *\n * For large tables, index backfill can be slow. Staging an index allows you\n * to push the schema and enable the index later.\n *\n * If `staged` is `true`, the index will be staged and will not be enabled\n * until the staged flag is removed. Staged indexes do not block push\n * completion. Staged indexes cannot be used in queries.\n *\n * To learn about vector indexes, see [Vector Search](https://docs.convex.dev/vector-search).\n *\n * @param name - The name of the index.\n * @param indexConfig - The vector index configuration object.\n * @returns A {@link TableDefinition} with this vector index included.\n */\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n VectorIndexConfig<VectorField, FilterFields> &\n IndexOptions & { staged: true }\n >,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>;\n\n vectorIndex<\n IndexName extends string,\n VectorField extends ExtractFieldPaths<DocumentType>,\n FilterFields extends ExtractFieldPaths<DocumentType> = never,\n >(\n name: IndexName,\n indexConfig: Expand<\n VectorIndexConfig<VectorField, FilterFields> & IndexOptions\n >,\n ) {\n if (indexConfig.staged) {\n this.stagedVectorIndexes.push({\n indexDescriptor: name,\n vectorField: indexConfig.vectorField,\n dimensions: indexConfig.dimensions,\n filterFields: indexConfig.filterFields || [],\n });\n } else {\n this.vectorIndexes.push({\n indexDescriptor: name,\n vectorField: indexConfig.vectorField,\n dimensions: indexConfig.dimensions,\n filterFields: indexConfig.filterFields || [],\n });\n }\n return this;\n }\n\n /**\n * Stage changes to this table's document validator.\n *\n * Convex validates the staged validator against the table's existing\n * documents in the background, while the validator passed to\n * {@link defineTable} remains the one enforced on writes. Once\n * the background validation succeeds, apply the staged changes\n * and remove `.staged()`.\n *\n * For an object validator, pass only the fields to add or replace. Fields\n * omitted from the changes keep their enforced validators.\n * Set a field to `undefined` to remove it from the staged validator.\n * For nested objects, you must specify the full object validator.\n *\n * ```ts\n * defineTable({\n * apple: v.string(),\n * banana: v.number(),\n * legacy: v.optional(v.string()),\n * }).staged({\n * banana: v.union(v.string(), v.number()),\n * legacy: undefined,\n * })\n * ```\n *\n * See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).\n *\n * @param documentSchema - Field changes for a table defined as an object or\n * `v.any()`, or a full schema validator specifying the proposed next document\n * type. Use a full schema validator for a table defined as a union.\n * @returns A {@link TableDefinition} with the staged validator attached.\n */\n staged(\n documentSchema:\n | Validator<Record<string, any>, \"required\", any>\n | Record<string, GenericValidator | undefined>,\n ): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {\n if (this.stagedValidator !== undefined) {\n throw new Error(\"Table cannot have more than one staged validator.\");\n }\n if (isValidator(documentSchema)) {\n this.stagedValidator = documentSchema;\n } else {\n if (this.validator.kind !== \"object\" && this.validator.kind !== \"any\") {\n throw new Error(\n \"Specifying top-level field changes is only supported for simple table definitions. For a table defined with a union or record validator, you must stage a fully defined object or union validator.\",\n );\n }\n const enforcedFields =\n this.validator.kind === \"object\" ? this.validator.fields : {};\n const fields: Record<string, GenericValidator> = Object.fromEntries(\n Object.entries({ ...enforcedFields, ...documentSchema }).filter(\n (entry): entry is [string, GenericValidator] =>\n entry[1] !== undefined,\n ),\n );\n this.stagedValidator = v.object(fields);\n }\n return this.self();\n }\n\n /**\n * Work around for https://github.com/microsoft/TypeScript/issues/57035\n */\n protected self(): TableDefinition<\n DocumentType,\n Indexes,\n SearchIndexes,\n VectorIndexes\n > {\n return this;\n }\n /**\n * Export the contents of this definition.\n *\n * This is called internally by the Convex framework.\n * @internal\n */\n export() {\n const documentType = this.validator.json;\n if (typeof documentType !== \"object\") {\n throw new Error(\n \"Invalid validator: please make sure that the parameter of `defineTable` is valid (see https://docs.convex.dev/database/schemas)\",\n );\n }\n\n let stagedDocumentType = undefined;\n if (this.stagedValidator !== undefined) {\n stagedDocumentType = this.stagedValidator.json;\n if (typeof stagedDocumentType !== \"object\") {\n throw new Error(\n \"Invalid staged validator: please make sure that the parameter of `.staged()` is valid (see https://docs.convex.dev/database/schemas)\",\n );\n }\n }\n\n return {\n indexes: this.indexes,\n stagedDbIndexes: this.stagedDbIndexes,\n searchIndexes: this.searchIndexes,\n stagedSearchIndexes: this.stagedSearchIndexes,\n vectorIndexes: this.vectorIndexes,\n stagedVectorIndexes: this.stagedVectorIndexes,\n documentType,\n stagedDocumentType,\n };\n }\n}\n\n/**\n * Define a table in a schema.\n *\n * You can either specify the schema of your documents as an object like\n * ```ts\n * defineTable({\n * field: v.string()\n * });\n * ```\n *\n * or as a schema type like\n * ```ts\n * defineTable(\n * v.union(\n * v.object({...}),\n * v.object({...})\n * )\n * );\n * ```\n *\n * @param documentSchema - The type of documents stored in this table.\n * @returns A {@link TableDefinition} for the table.\n *\n * @public\n */\nexport function defineTable<\n DocumentSchema extends Validator<Record<string, any>, \"required\", any>,\n>(documentSchema: DocumentSchema): TableDefinition<DocumentSchema>;\n/**\n * Define a table in a schema.\n *\n * You can either specify the schema of your documents as an object like\n * ```ts\n * defineTable({\n * field: v.string()\n * });\n * ```\n *\n * or as a schema type like\n * ```ts\n * defineTable(\n * v.union(\n * v.object({...}),\n * v.object({...})\n * )\n * );\n * ```\n *\n * @param documentSchema - The type of documents stored in this table.\n * @returns A {@link TableDefinition} for the table.\n *\n * @public\n */\nexport function defineTable<\n DocumentSchema extends Record<string, GenericValidator>,\n>(\n documentSchema: DocumentSchema,\n): TableDefinition<VObject<ObjectType<DocumentSchema>, DocumentSchema>>;\nexport function defineTable<\n DocumentSchema extends\n | Validator<Record<string, any>, \"required\", any>\n | Record<string, GenericValidator>,\n>(documentSchema: DocumentSchema): TableDefinition<any, any, any> {\n if (isValidator(documentSchema)) {\n return new TableDefinition(documentSchema);\n } else {\n return new TableDefinition(v.object(documentSchema));\n }\n}\n\n/**\n * The validators for the system fields Convex adds to every document.\n *\n * @public\n */\nexport type SystemFieldValidators<TableName extends string> = {\n _id: VId<GenericId<TableName>>;\n _creationTime: VFloat64<number>;\n};\n\n/**\n * Add the system field validators to an object validator, leaving any other\n * validator untouched.\n */\ntype WithSystemFieldValidators<\n TableName extends string,\n DocumentType extends Validator<any, any, any>,\n> =\n DocumentType extends VObject<infer Type, infer Fields, any, any>\n ? VObject<\n Expand<IdField<TableName> & SystemFields & Type>,\n Expand<SystemFieldValidators<TableName> & Fields>\n >\n : DocumentType;\n\n/**\n * The validator for whole documents of a table: the table's own validator with\n * the `_id` and `_creationTime` system fields added.\n *\n * For a table defined with a union, the system fields are added to each member\n * of the union.\n *\n * @public\n */\nexport type DocValidator<\n TableName extends string,\n DocumentType extends Validator<any, any, any>,\n> =\n DocumentType extends VUnion<any, infer Members, any, any>\n ? {\n [Index in keyof Members]: WithSystemFieldValidators<\n TableName,\n Members[Index]\n >;\n } extends infer NewMembers extends Validator<any, \"required\", any>[]\n ? VUnion<\n WithSystemFieldValidators<TableName, Members[number]>[\"type\"],\n NewMembers\n >\n : never\n : WithSystemFieldValidators<TableName, DocumentType>;\n\nfunction addSystemFields(\n tableName: string,\n validator: GenericValidator,\n): GenericValidator {\n switch (validator.kind) {\n case \"object\":\n return validator.extend({\n _id: v.id(tableName),\n _creationTime: v.number(),\n });\n case \"union\":\n return v.union(\n ...validator.members.map((member) =>\n addSystemFields(tableName, member),\n ),\n );\n // `v.any()` already permits the system fields.\n case \"any\":\n return validator;\n default:\n throw new Error(\n `Invalid validator for table \"${tableName}\": a table's documents must be objects, or a union of objects (see https://docs.convex.dev/database/schemas)`,\n );\n }\n}\n\n/**\n * Build the validator for whole documents of a table, by adding the `_id` and\n * `_creationTime` system fields to the table's own validator.\n *\n * Prefer {@link SchemaDefinition.doc} when you have the schema in hand: it\n * checks the table name against the schema.\n *\n * @example\n * ```ts\n * const messageDoc = docValidator(\"messages\", schema.tables.messages);\n *\n * export const get = query({\n * args: { id: v.id(\"messages\") },\n * returns: v.union(messageDoc, v.null()),\n * handler: (ctx, args) => ctx.db.get(args.id),\n * });\n * ```\n *\n * @param tableName - The name of the table, used for the `_id` validator.\n * @param table - The {@link TableDefinition} for that table.\n * @returns A validator matching documents of the table.\n *\n * @public\n */\nexport function docValidator<\n TableName extends string,\n Table extends TableDefinition<any, any, any, any>,\n>(\n tableName: TableName,\n table: Table,\n): DocValidator<TableName, Table[\"validator\"]> {\n return addSystemFields(tableName, table.validator) as DocValidator<\n TableName,\n Table[\"validator\"]\n >;\n}\n\n/**\n * A type describing the schema of a Convex project.\n *\n * This should be constructed using {@link defineSchema}, {@link defineTable},\n * and {@link v}.\n * @public\n */\nexport type GenericSchema = Record<string, TableDefinition>;\n\nfunction tableInSchema<\n Schema extends GenericSchema,\n TableName extends keyof Schema & string,\n>(\n schema: SchemaDefinition<Schema, boolean>,\n tableName: TableName,\n): Schema[TableName] {\n const table = schema.tables[tableName];\n if (table === undefined) {\n throw new Error(\n `Table \"${tableName}\" is not in this schema. Tables in this schema: ${Object.keys(\n schema.tables,\n ).join(\", \")}`,\n );\n }\n return table;\n}\n\n/**\n *\n * The definition of a Convex project schema.\n *\n * This should be produced by using {@link defineSchema}.\n * @public\n */\nexport class SchemaDefinition<\n Schema extends GenericSchema,\n StrictTableTypes extends boolean,\n> {\n public tables: Schema;\n public strictTableNameTypes!: StrictTableTypes;\n public readonly schemaValidation: boolean;\n\n /**\n * @internal\n */\n constructor(tables: Schema, options?: DefineSchemaOptions<StrictTableTypes>) {\n this.tables = tables;\n this.schemaValidation =\n options?.schemaValidation === undefined ? true : options.schemaValidation;\n }\n\n /**\n * The validator for whole documents of a table in this schema: the table's\n * own validator with the `_id` and `_creationTime` system fields added.\n *\n * @example\n * ```ts\n * export const get = query({\n * args: { id: schema.id(\"messages\") },\n * returns: v.union(schema.doc(\"messages\"), v.null()),\n * handler: (ctx, args) => ctx.db.get(args.id),\n * });\n * ```\n *\n * @param tableName - The name of a table in this schema.\n * @returns A validator matching documents of that table.\n */\n doc<TableName extends keyof Schema & string>(\n tableName: TableName,\n ): DocValidator<TableName, Schema[TableName][\"validator\"]> {\n return docValidator(tableName, tableInSchema(this, tableName));\n }\n\n /**\n * The validator for IDs of a table in this schema.\n *\n * Same as `v.id(tableName)`, but only accepts tables in this schema.\n *\n * @param tableName - The name of a table in this schema.\n * @returns A validator matching IDs of that table.\n */\n id<TableName extends keyof Schema & string>(\n tableName: TableName,\n ): VId<GenericId<TableName>> {\n tableInSchema(this, tableName);\n return v.id(tableName);\n }\n\n /**\n * Export the contents of this definition.\n *\n * This is called internally by the Convex framework.\n * @internal\n */\n export(): string {\n return JSON.stringify({\n tables: Object.entries(this.tables).map(([tableName, definition]) => {\n const {\n indexes,\n stagedDbIndexes,\n searchIndexes,\n stagedSearchIndexes,\n vectorIndexes,\n stagedVectorIndexes,\n documentType,\n stagedDocumentType,\n } = definition.export();\n return {\n tableName,\n indexes,\n stagedDbIndexes,\n searchIndexes,\n stagedSearchIndexes,\n vectorIndexes,\n stagedVectorIndexes,\n documentType,\n stagedDocumentType,\n };\n }),\n schemaValidation: this.schemaValidation,\n });\n }\n}\n\n/**\n * Options for {@link defineSchema}.\n *\n * @public\n */\nexport interface DefineSchemaOptions<StrictTableNameTypes extends boolean> {\n /**\n * Whether Convex should validate at runtime that all documents match\n * your schema.\n *\n * If `schemaValidation` is `true`, Convex will:\n * 1. Check that all existing documents match your schema when your schema\n * is pushed.\n * 2. Check that all insertions and updates match your schema during mutations.\n *\n * If `schemaValidation` is `false`, Convex will not validate that new or\n * existing documents match your schema. You'll still get schema-specific\n * TypeScript types, but there will be no validation at runtime that your\n * documents match those types.\n *\n * By default, `schemaValidation` is `true`.\n */\n schemaValidation?: boolean;\n\n /**\n * Whether the TypeScript types should allow accessing tables not in the schema.\n *\n * If `strictTableNameTypes` is `true`, using tables not listed in the schema\n * will generate a TypeScript compilation error.\n *\n * If `strictTableNameTypes` is `false`, you'll be able to access tables not\n * listed in the schema and their document type will be `any`.\n *\n * `strictTableNameTypes: false` is useful for rapid prototyping.\n *\n * Regardless of the value of `strictTableNameTypes`, your schema will only\n * validate documents in the tables listed in the schema. You can still create\n * and modify other tables on the dashboard or in JavaScript mutations.\n *\n * By default, `strictTableNameTypes` is `true`.\n */\n strictTableNameTypes?: StrictTableNameTypes;\n}\n\n/**\n * Define the schema of this Convex project.\n *\n * This should be exported as the default export from a `schema.ts` file in\n * your `convex/` directory. The schema enables runtime validation of documents\n * and provides end-to-end TypeScript type safety.\n *\n * Every document in Convex automatically has two system fields:\n * - `_id` - a unique document ID with validator `v.id(\"tableName\")`\n * - `_creationTime` - a creation timestamp with validator `v.number()`\n *\n * You do not need to include these in your schema definition, they are added\n * automatically.\n *\n * @example\n * ```ts\n * // convex/schema.ts\n * import { defineSchema, defineTable } from \"convex/server\";\n * import { v } from \"convex/values\";\n *\n * export default defineSchema({\n * users: defineTable({\n * name: v.string(),\n * email: v.string(),\n * }).index(\"by_email\", [\"email\"]),\n *\n * messages: defineTable({\n * body: v.string(),\n * userId: v.id(\"users\"),\n * channelId: v.id(\"channels\"),\n * }).index(\"by_channel\", [\"channelId\"]),\n *\n * channels: defineTable({\n * name: v.string(),\n * }),\n *\n * // Discriminated union table:\n * results: defineTable(\n * v.union(\n * v.object({ kind: v.literal(\"error\"), message: v.string() }),\n * v.object({ kind: v.literal(\"success\"), value: v.number() }),\n * )\n * ),\n * });\n * ```\n *\n * **Best practice:** Always include all index fields in the index name. For\n * example, an index on `[\"field1\", \"field2\"]` should be named\n * `\"by_field1_field2\"`.\n *\n * @param schema - A map from table name to {@link TableDefinition} for all of\n * the tables in this project.\n * @param options - Optional configuration. See {@link DefineSchemaOptions} for\n * a full description.\n * @returns The schema.\n *\n * @see https://docs.convex.dev/database/schemas\n * @public\n */\nexport function defineSchema<\n Schema extends GenericSchema,\n StrictTableNameTypes extends boolean = true,\n>(\n schema: Schema,\n options?: DefineSchemaOptions<StrictTableNameTypes>,\n): SchemaDefinition<Schema, StrictTableNameTypes> {\n return new SchemaDefinition(schema, options);\n}\n\n/**\n * Internal type used in Convex code generation!\n *\n * Convert a {@link SchemaDefinition} into a {@link server.GenericDataModel}.\n *\n * @public\n */\nexport type DataModelFromSchemaDefinition<\n SchemaDef extends SchemaDefinition<any, boolean>,\n> = MaybeMakeLooseDataModel<\n {\n [TableName in keyof SchemaDef[\"tables\"] &\n string]: SchemaDef[\"tables\"][TableName] extends TableDefinition<\n infer DocumentType,\n infer Indexes,\n infer SearchIndexes,\n infer VectorIndexes\n >\n ? {\n // We've already added all of the system fields except for `_id`.\n // Add that here.\n document: Expand<IdField<TableName> & ExtractDocument<DocumentType>>;\n fieldPaths:\n | keyof IdField<TableName>\n | ExtractFieldPaths<DocumentType>;\n indexes: Expand<Indexes & SystemIndexes>;\n searchIndexes: SearchIndexes;\n vectorIndexes: VectorIndexes;\n }\n : never;\n },\n SchemaDef[\"strictTableNameTypes\"]\n>;\n\ntype MaybeMakeLooseDataModel<\n DataModel extends GenericDataModel,\n StrictTableNameTypes extends boolean,\n> = StrictTableNameTypes extends true\n ? DataModel\n : Expand<DataModel & AnyDataModel>;\n\nconst _systemSchema = defineSchema({\n _scheduled_functions: defineTable({\n name: v.string(),\n args: v.array(v.any()),\n scheduledTime: v.float64(),\n completedTime: v.optional(v.float64()),\n state: v.union(\n v.object({ kind: v.literal(\"pending\") }),\n v.object({ kind: v.literal(\"inProgress\") }),\n v.object({ kind: v.literal(\"success\") }),\n v.object({ kind: v.literal(\"failed\"), error: v.string() }),\n v.object({ kind: v.literal(\"canceled\") }),\n ),\n }),\n _storage: defineTable({\n sha256: v.string(),\n size: v.float64(),\n contentType: v.optional(v.string()),\n }),\n});\n\nexport interface SystemDataModel extends DataModelFromSchemaDefinition<\n typeof _systemSchema\n> {}\n\nexport type SystemTableNames = TableNamesInDataModel<SystemDataModel>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6CA,uBAKO;AA8IA,MAAM,gBAKX;AAAA;AAAA;AAAA;AAAA,EAgBA,YAAY,cAA4B;AAfxC,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AAER;AAAA;AAGA;AAAA;AAAA,wBAAQ;AAMN,SAAK,UAAU,CAAC;AAChB,SAAK,kBAAkB,CAAC;AACxB,SAAK,gBAAgB,CAAC;AACtB,SAAK,sBAAsB,CAAC;AAC5B,SAAK,gBAAgB,CAAC;AACtB,SAAK,sBAAsB,CAAC;AAC5B,SAAK,YAAY;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,aAA8D;AAC5D,WAAO,KAAK;AAAA,EACd;AAAA,EAkHA,MAKE,MACA,aAGA;AACA,QAAI,MAAM,QAAQ,WAAW,GAAG;AAE9B,WAAK,QAAQ,KAAK;AAAA,QAChB,iBAAiB;AAAA,QACjB,QAAQ;AAAA,MACV,CAAC;AAAA,IACH,WAAW,YAAY,QAAQ;AAE7B,WAAK,gBAAgB,KAAK;AAAA,QACxB,iBAAiB;AAAA,QACjB,QAAQ,YAAY;AAAA,MACtB,CAAC;AAAA,IACH,OAAO;AAEL,WAAK,QAAQ,KAAK;AAAA,QAChB,iBAAiB;AAAA,QACjB,QAAQ,YAAY;AAAA,MACtB,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAAA,EAmEA,YAKE,MACA,aAGA;AACA,QAAI,YAAY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AAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/storage.ts"],
|
|
4
|
-
"sourcesContent": ["import { GenericId } from \"../values/index.js\";\n\n/**\n * @deprecated This ID format is no longer returned by stable file storage APIs. Use `Id<\"_storage\">` instead.\n *\n * The old ID format used by Convex file storage.\n *\n * \u26A0\uFE0F Security warning: Anyone that has knows to this ID can download the underlying file\n * from `https://<deployment>.convex.cloud/api/storage/<storageId>`.\n * (Note that it\u2019s safe to share the new ID format, `Id<\"_storage\">`, to anyone).\n *\n * @public\n */\nexport type StorageId = string;\n\n/**\n * @deprecated This type is only necessary for backwards compatibility with Convex versions that\n * pre-date `convex@1.6.0`. Use `Id<\"_storage\">` instead.\n */\nexport type FileStorageId = GenericId<\"_storage\"> | StorageId;\n\n/**\n * @deprecated This type is only returned by {@link StorageReader.getUrl | storage.getUrl}.\n * To get the details of a document, use `ctx.db.system.get(\"_storage\", storageId)` instead.\n *\n * Metadata for a single file as returned by {@link StorageReader.getMetadata | storage.getMetadata}.\n *\n * @public\n */\nexport type FileMetadata = {\n /**\n * ID for referencing the file (eg. via {@link StorageReader.getUrl | storage.getUrl})\n *\n * This is an older ID format that is no longer returned by stable file storage APIs.\n * Consider using `Id<\"_storage\">` instead.\n *\n * \u26A0\uFE0F Security warning: Anyone that has knows to this ID can download the underlying file\n * from `https://<deployment>.convex.cloud/api/storage/<storageId>`.\n * (Note that it\u2019s safe to share the new ID format, `Id<\"_storage\">`, to anyone).\n */\n storageId: StorageId;\n /**\n * Hex encoded sha256 checksum of file contents\n */\n sha256: string;\n /**\n * Size of the file in bytes\n */\n size: number;\n /**\n * ContentType of the file if it was provided on upload\n */\n contentType: string | null;\n};\n\n/**\n * An interface to read files from storage within Convex query functions.\n *\n * Available as `ctx.storage` in queries (read-only), mutations, and actions.\n *\n * @example\n * ```typescript\n * // Get a URL for a stored file:\n * const url = await ctx.storage.getUrl(storageId);\n * if (url) {\n * // Use the URL (e.g., return it to the client)\n * }\n *\n * // Get file metadata via the system table (preferred over deprecated getMetadata):\n * const metadata = await ctx.db.system.get(\"_storage\", storageId);\n * // metadata: { _id, _creationTime, sha256, size, contentType? }\n * ```\n *\n * @see https://docs.convex.dev/file-storage\n * @public\n */\nexport interface StorageReader {\n /**\n * Get the URL for a file in storage by its `Id<\"_storage\">`.\n *\n * The GET response includes a standard HTTP Digest header with a sha256 checksum.\n *\n * @example\n * ```typescript\n * const url = await ctx.storage.getUrl(storageId);\n * ```\n *\n * @param storageId - The `Id<\"_storage\">` of the file to fetch from Convex storage.\n * @returns - A URL which fetches the file via an HTTP GET, or `null` if the file no longer exists.\n */\n getUrl(storageId: GenericId<\"_storage\">): Promise<string | null>;\n\n /**\n * @deprecated Passing a string is deprecated, use `storage.getUrl(Id<\"_storage\">)` instead.\n *\n * Get the URL for a file in storage by its {@link StorageId}.\n *\n * The GET response includes a standard HTTP Digest header with a sha256 checksum.\n *\n * @param storageId - The {@link StorageId} of the file to fetch from Convex storage.\n * @returns - A url which fetches the file via an HTTP GET, or `null` if it no longer exists.\n */\n getUrl<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<string | null>;\n\n /**\n * @deprecated Use `ctx.db.system.get(\"_storage\", storageId)` instead, which returns\n * equivalent metadata from the `_storage` system table (with a slightly different shape):\n * ```typescript\n * const metadata = await ctx.db.system.get(\"_storage\", storageId);\n * // { _id, _creationTime, sha256, size, contentType? }\n * ```\n *\n * Get metadata for a file.\n *\n * @param storageId - The `Id<\"_storage\">` of the file.\n * @returns - A {@link FileMetadata} object if found or `null` if not found.\n */\n getMetadata(storageId: GenericId<\"_storage\">): Promise<FileMetadata | null>;\n\n /**\n * @deprecated Use `ctx.db.system.get(\"_storage\", storageId)` instead.\n *\n * Get metadata for a file.\n *\n * @param storageId - The {@link StorageId} of the file.\n * @returns - A {@link FileMetadata} object if found or `null` if not found.\n */\n getMetadata<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<FileMetadata | null>;\n}\n\n/**\n * An interface to write files to storage within Convex mutation functions.\n *\n * Available as `ctx.storage` in mutations.\n *\n * @see https://docs.convex.dev/file-storage\n * @public\n */\nexport interface StorageWriter extends StorageReader {\n /**\n * Generate a short-lived URL for uploading a file into storage.\n *\n * The client should make a POST request to this URL with the file as the\n * body. The response will be a JSON object containing a newly allocated\n * `Id<\"_storage\">` (`{ storageId: \"...\" }`).\n *\n * @example\n * ```typescript\n * // In a mutation, generate the upload URL:\n * export const generateUploadUrl = mutation({\n * args: {},\n * returns: v.string(),\n * handler: async (ctx) => {\n * return await ctx.storage.generateUploadUrl();\n * },\n * });\n *\n * // On the client, upload the file:\n * // const uploadUrl = await generateUploadUrl();\n * // const result = await fetch(uploadUrl, { method: \"POST\", body: file });\n * // const { storageId } = await result.json();\n * ```\n *\n * @returns - A short-lived URL for uploading a file via HTTP POST.\n */\n generateUploadUrl(): Promise<string>;\n /**\n * Delete a file from Convex storage.\n *\n * Once a file is deleted, any URLs previously generated by {@link StorageReader.getUrl} will return 404s.\n *\n * @example\n * ```typescript\n * await ctx.storage.delete(storageId);\n * ```\n *\n * @param storageId - The `Id<\"_storage\">` of the file to delete from Convex storage.\n */\n delete(storageId: GenericId<\"_storage\">): Promise<void>;\n\n /**\n * @deprecated Passing a string is deprecated, use `storage.delete(Id<\"_storage\">)` instead.\n *\n * Delete a file from Convex storage.\n *\n * Once a file is deleted, any URLs previously generated by {@link StorageReader.getUrl} will return 404s.\n *\n * @param storageId - The {@link StorageId} of the file to delete from Convex storage.\n */\n delete<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<void>;\n\n /**\n *
|
|
4
|
+
"sourcesContent": ["import { GenericId } from \"../values/index.js\";\n\n/**\n * @deprecated This ID format is no longer returned by stable file storage APIs. Use `Id<\"_storage\">` instead.\n *\n * The old ID format used by Convex file storage.\n *\n * \u26A0\uFE0F Security warning: Anyone that has knows to this ID can download the underlying file\n * from `https://<deployment>.convex.cloud/api/storage/<storageId>`.\n * (Note that it\u2019s safe to share the new ID format, `Id<\"_storage\">`, to anyone).\n *\n * @public\n */\nexport type StorageId = string;\n\n/**\n * @deprecated This type is only necessary for backwards compatibility with Convex versions that\n * pre-date `convex@1.6.0`. Use `Id<\"_storage\">` instead.\n */\nexport type FileStorageId = GenericId<\"_storage\"> | StorageId;\n\n/**\n * @deprecated This type is only returned by {@link StorageReader.getUrl | storage.getUrl}.\n * To get the details of a document, use `ctx.db.system.get(\"_storage\", storageId)` instead.\n *\n * Metadata for a single file as returned by {@link StorageReader.getMetadata | storage.getMetadata}.\n *\n * @public\n */\nexport type FileMetadata = {\n /**\n * ID for referencing the file (eg. via {@link StorageReader.getUrl | storage.getUrl})\n *\n * This is an older ID format that is no longer returned by stable file storage APIs.\n * Consider using `Id<\"_storage\">` instead.\n *\n * \u26A0\uFE0F Security warning: Anyone that has knows to this ID can download the underlying file\n * from `https://<deployment>.convex.cloud/api/storage/<storageId>`.\n * (Note that it\u2019s safe to share the new ID format, `Id<\"_storage\">`, to anyone).\n */\n storageId: StorageId;\n /**\n * Hex encoded sha256 checksum of file contents\n */\n sha256: string;\n /**\n * Size of the file in bytes\n */\n size: number;\n /**\n * ContentType of the file if it was provided on upload\n */\n contentType: string | null;\n};\n\n/**\n * An interface to read files from storage within Convex query functions.\n *\n * Available as `ctx.storage` in queries (read-only), mutations, and actions.\n *\n * @example\n * ```typescript\n * // Get a URL for a stored file:\n * const url = await ctx.storage.getUrl(storageId);\n * if (url) {\n * // Use the URL (e.g., return it to the client)\n * }\n *\n * // Get file metadata via the system table (preferred over deprecated getMetadata):\n * const metadata = await ctx.db.system.get(\"_storage\", storageId);\n * // metadata: { _id, _creationTime, sha256, size, contentType? }\n * ```\n *\n * @see https://docs.convex.dev/file-storage\n * @public\n */\nexport interface StorageReader {\n /**\n * Get the URL for a file in storage by its `Id<\"_storage\">`.\n *\n * The GET response includes a standard HTTP Digest header with a sha256 checksum.\n *\n * @example\n * ```typescript\n * const url = await ctx.storage.getUrl(storageId);\n * ```\n *\n * @param storageId - The `Id<\"_storage\">` of the file to fetch from Convex storage.\n * @returns - A URL which fetches the file via an HTTP GET, or `null` if the file no longer exists.\n */\n getUrl(storageId: GenericId<\"_storage\">): Promise<string | null>;\n\n /**\n * @deprecated Passing a string is deprecated, use `storage.getUrl(Id<\"_storage\">)` instead.\n *\n * Get the URL for a file in storage by its {@link StorageId}.\n *\n * The GET response includes a standard HTTP Digest header with a sha256 checksum.\n *\n * @param storageId - The {@link StorageId} of the file to fetch from Convex storage.\n * @returns - A url which fetches the file via an HTTP GET, or `null` if it no longer exists.\n */\n getUrl<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<string | null>;\n\n /**\n * @deprecated Use `ctx.db.system.get(\"_storage\", storageId)` instead, which returns\n * equivalent metadata from the `_storage` system table (with a slightly different shape):\n * ```typescript\n * const metadata = await ctx.db.system.get(\"_storage\", storageId);\n * // { _id, _creationTime, sha256, size, contentType? }\n * ```\n *\n * Get metadata for a file.\n *\n * @param storageId - The `Id<\"_storage\">` of the file.\n * @returns - A {@link FileMetadata} object if found or `null` if not found.\n */\n getMetadata(storageId: GenericId<\"_storage\">): Promise<FileMetadata | null>;\n\n /**\n * @deprecated Use `ctx.db.system.get(\"_storage\", storageId)` instead.\n *\n * Get metadata for a file.\n *\n * @param storageId - The {@link StorageId} of the file.\n * @returns - A {@link FileMetadata} object if found or `null` if not found.\n */\n getMetadata<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<FileMetadata | null>;\n}\n\n/**\n * An interface to read and write files to storage within Convex mutation functions.\n *\n * Available as `ctx.storage` in mutations, actions, and HTTP actions.\n *\n * @see https://docs.convex.dev/file-storage\n * @public\n */\nexport interface StorageWriter extends StorageReader {\n /**\n * Generate a short-lived URL for uploading a file into storage.\n *\n * The client should make a POST request to this URL with the file as the\n * body. The response will be a JSON object containing a newly allocated\n * `Id<\"_storage\">` (`{ storageId: \"...\" }`).\n *\n * @example\n * ```typescript\n * // In a mutation, generate the upload URL:\n * export const generateUploadUrl = mutation({\n * args: {},\n * returns: v.string(),\n * handler: async (ctx) => {\n * return await ctx.storage.generateUploadUrl();\n * },\n * });\n *\n * // On the client, upload the file:\n * // const uploadUrl = await generateUploadUrl();\n * // const result = await fetch(uploadUrl, { method: \"POST\", body: file });\n * // const { storageId } = await result.json();\n * ```\n *\n * @returns - A short-lived URL for uploading a file via HTTP POST.\n */\n generateUploadUrl(): Promise<string>;\n /**\n * Delete a file from Convex storage.\n *\n * Once a file is deleted, any URLs previously generated by {@link StorageReader.getUrl} will return 404s.\n *\n * @example\n * ```typescript\n * await ctx.storage.delete(storageId);\n * ```\n *\n * @param storageId - The `Id<\"_storage\">` of the file to delete from Convex storage.\n */\n delete(storageId: GenericId<\"_storage\">): Promise<void>;\n\n /**\n * @deprecated Passing a string is deprecated, use `storage.delete(Id<\"_storage\">)` instead.\n *\n * Delete a file from Convex storage.\n *\n * Once a file is deleted, any URLs previously generated by {@link StorageReader.getUrl} will return 404s.\n *\n * @param storageId - The {@link StorageId} of the file to delete from Convex storage.\n */\n delete<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<void>;\n\n /**\n * Download a file from storage as a Blob.\n *\n * In mutations, files read count toward the transaction's `filesRead` and\n * `fileReadBytes` limits. Use\n * `ctx.meta.getTransactionMetrics()` to check the remaining headroom.\n *\n * @param storageId - The `Id<\"_storage\">` of the file.\n * @returns A Blob containing the file contents, or `null` if the file doesn't exist.\n */\n get(storageId: GenericId<\"_storage\">): Promise<Blob | null>;\n\n /**\n * @deprecated Passing a string is deprecated, use `storage.get(Id<\"_storage\">)` instead.\n *\n * Get a Blob containing the file associated with the provided {@link StorageId}, or `null` if there is no file.\n */\n get<T extends StorageId>(\n storageId: T extends { __tableName: any } ? never : T,\n ): Promise<Blob | null>;\n\n /**\n * Upload a Blob directly to storage.\n *\n * To upload files from a client, use {@link StorageWriter.generateUploadUrl}\n * instead.\n *\n * In mutations, files stored count toward the transaction's `filesWritten`\n * and `fileWriteBytes` limits. Use\n * `ctx.meta.getTransactionMetrics()` to check the remaining headroom.\n *\n * @example\n * ```typescript\n * const storageId = await ctx.storage.store(blob);\n * // If in an action, save storageId to the database via ctx.runMutation\n * ```\n *\n * @param blob - The Blob to store.\n * @param options - Optional settings. Pass `sha256` to verify the file integrity.\n * @returns The `Id<\"_storage\">` of the newly stored file.\n */\n store(\n blob: Blob,\n options?: { sha256?: string },\n ): Promise<GenericId<\"_storage\">>;\n}\n\n/**\n * An interface to read and write files to storage within Convex actions and HTTP actions.\n *\n * @example\n * ```typescript\n * // In an action, download and re-upload a file:\n * const blob = await ctx.storage.get(storageId);\n * if (blob) {\n * const newStorageId = await ctx.storage.store(blob);\n * }\n * ```\n *\n * @public\n */\nexport interface StorageActionWriter extends StorageWriter {}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -19,10 +19,6 @@ export type BigBrainAuth = {
|
|
|
19
19
|
} | {
|
|
20
20
|
kind: "accessToken";
|
|
21
21
|
accessToken: string;
|
|
22
|
-
profile?: {
|
|
23
|
-
name: string;
|
|
24
|
-
source: string;
|
|
25
|
-
} | null;
|
|
26
22
|
});
|
|
27
23
|
export interface Context {
|
|
28
24
|
fs: Filesystem;
|
|
@@ -62,6 +58,5 @@ export declare const oneoffContext: (args: {
|
|
|
62
58
|
url?: string | undefined;
|
|
63
59
|
adminKey?: string | undefined;
|
|
64
60
|
envFile?: string | undefined;
|
|
65
|
-
skipAuth?: boolean;
|
|
66
61
|
}) => Promise<OneoffCtx>;
|
|
67
62
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/bundler/context.ts"],"names":[],"mappings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AC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,KAAK,OAAO,CAAC,SAAS,CAYtB,CAAC"}
|
|
@@ -7,7 +7,6 @@ export interface Filesystem {
|
|
|
7
7
|
listDir(dirPath: string): Dirent[];
|
|
8
8
|
exists(path: string): boolean;
|
|
9
9
|
stat(path: string): Stats;
|
|
10
|
-
lstat(path: string): Stats;
|
|
11
10
|
readUtf8File(path: string): string;
|
|
12
11
|
createReadStream(path: string, options: {
|
|
13
12
|
highWaterMark?: number;
|
|
@@ -38,7 +37,6 @@ export declare class NodeFs implements Filesystem {
|
|
|
38
37
|
listDir(dirPath: string): stdFs.Dirent<string>[];
|
|
39
38
|
exists(path: string): boolean;
|
|
40
39
|
stat(path: string): stdFs.Stats;
|
|
41
|
-
lstat(path: string): stdFs.Stats;
|
|
42
40
|
readUtf8File(path: string): string;
|
|
43
41
|
createReadStream(path: string, options: {
|
|
44
42
|
highWaterMark?: number;
|
|
@@ -60,12 +58,10 @@ export declare const nodeFs: NodeFs;
|
|
|
60
58
|
export declare class RecordingFs implements Filesystem {
|
|
61
59
|
private observedDirectories;
|
|
62
60
|
private observedFiles;
|
|
63
|
-
private observedLstats;
|
|
64
61
|
private invalidated;
|
|
65
62
|
private traceEvents;
|
|
66
63
|
constructor(traceEvents: boolean);
|
|
67
64
|
listDir(dirPath: string): Dirent[];
|
|
68
|
-
lstat(filePath: string): Stats;
|
|
69
65
|
exists(path: string): boolean;
|
|
70
66
|
stat(path: string): Stats;
|
|
71
67
|
readUtf8File(path: string): string;
|
|
@@ -85,7 +81,7 @@ export declare class RecordingFs implements Filesystem {
|
|
|
85
81
|
private updateOnDelete;
|
|
86
82
|
registerPath(p: string, st: Stats | null): void;
|
|
87
83
|
invalidate(): void;
|
|
88
|
-
registerNormalized(absPath: string, observed: Stats | null
|
|
84
|
+
registerNormalized(absPath: string, observed: Stats | null): void;
|
|
89
85
|
finalize(): Observations | "invalidated";
|
|
90
86
|
}
|
|
91
87
|
export type WatchEvent = {
|
|
@@ -93,10 +89,9 @@ export type WatchEvent = {
|
|
|
93
89
|
absPath: string;
|
|
94
90
|
};
|
|
95
91
|
export declare class Observations {
|
|
96
|
-
private lstats;
|
|
97
92
|
directories: Map<string, Set<string>>;
|
|
98
93
|
files: Map<string, Stats | null>;
|
|
99
|
-
constructor(directories: Map<string, Set<string>>, files: Map<string, Stats | null
|
|
94
|
+
constructor(directories: Map<string, Set<string>>, files: Map<string, Stats | null>);
|
|
100
95
|
paths(): string[];
|
|
101
96
|
overlaps({ absPath, }: WatchEvent): {
|
|
102
97
|
overlaps: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/bundler/fs.ts"],"names":[],"mappings":";;AAKA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAK5D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAgDpC,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAC1B,
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/bundler/fs.ts"],"names":[],"mappings":";;AAKA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAK5D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAgDpC,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEnC,M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,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,YAAY;IACvB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;gBAG/B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EACrC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IAMlC,KAAK,IAAI,MAAM,EAAE;IAWjB,QAAQ,CAAC,EACP,OAAO,GACR,EAAE,UAAU,GAAG;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CA2CzE;AAcD,wBAAgB,SAAS,CACvB,CAAC,EAAE,KAAK,GAAG,IAAI,EACf,CAAC,EAAE,KAAK,GAAG,IAAI,GACd;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAsDxD;AAGD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAOtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiFiles.d.ts","sourceRoot":"","sources":["../../../src/cli/aiFiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"aiFiles.d.ts","sourceRoot":"","sources":["../../../src/cli/aiFiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAiLtD,eAAO,MAAM,OAAO,qBAaI,CAAC"}
|