convex 1.46.0 → 1.48.0-alpha.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 +58 -1
- package/dist/browser.bundle.js +7 -1
- package/dist/browser.bundle.js.map +2 -2
- package/dist/cjs/bundler/context.js +7 -5
- package/dist/cjs/bundler/context.js.map +2 -2
- package/dist/cjs/bundler/fs.js +47 -6
- package/dist/cjs/bundler/fs.js.map +2 -2
- package/dist/cjs/bundler/index.js +5 -4
- package/dist/cjs/bundler/index.js.map +2 -2
- package/dist/cjs/cli/account.js +237 -0
- package/dist/cjs/cli/account.js.map +7 -0
- package/dist/cjs/cli/codegen.js +0 -4
- package/dist/cjs/cli/codegen.js.map +2 -2
- package/dist/cjs/cli/configure.js +28 -6
- package/dist/cjs/cli/configure.js.map +2 -2
- package/dist/cjs/cli/deploy.js +27 -2
- package/dist/cjs/cli/deploy.js.map +2 -2
- package/dist/cjs/cli/deploymentSelect.js +2 -2
- package/dist/cjs/cli/deploymentSelect.js.map +2 -2
- package/dist/cjs/cli/dev.js +6 -0
- package/dist/cjs/cli/dev.js.map +2 -2
- package/dist/cjs/cli/env.js +10 -5
- package/dist/cjs/cli/env.js.map +2 -2
- package/dist/cjs/cli/envDefault.js +7 -2
- package/dist/cjs/cli/envDefault.js.map +2 -2
- package/dist/cjs/cli/generatedApi.js.map +1 -1
- package/dist/cjs/cli/lib/api.js +2 -0
- package/dist/cjs/cli/lib/api.js.map +2 -2
- package/dist/cjs/cli/lib/checkForLargeIndexBackfill.js +113 -0
- package/dist/cjs/cli/lib/checkForLargeIndexBackfill.js.map +7 -0
- package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +36 -47
- package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
- package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js +58 -39
- package/dist/cjs/cli/lib/checkForSlowSchemaValidation.js.map +2 -2
- package/dist/cjs/cli/lib/checkForStagedValidatorDeletion.js +90 -0
- package/dist/cjs/cli/lib/checkForStagedValidatorDeletion.js.map +7 -0
- package/dist/cjs/cli/lib/codegen.js.map +2 -2
- package/dist/cjs/cli/lib/command.js +2 -1
- package/dist/cjs/cli/lib/command.js.map +2 -2
- package/dist/cjs/cli/lib/components/definition/bundle.js +37 -11
- package/dist/cjs/cli/lib/components/definition/bundle.js.map +2 -2
- package/dist/cjs/cli/lib/components.js +48 -5
- package/dist/cjs/cli/lib/components.js.map +2 -2
- package/dist/cjs/cli/lib/config.js +56 -17
- package/dist/cjs/cli/lib/config.js.map +2 -2
- package/dist/cjs/cli/lib/deploy2.js +3 -1
- package/dist/cjs/cli/lib/deploy2.js.map +2 -2
- package/dist/cjs/cli/lib/deployApi/evaluateSchema.js +30 -2
- package/dist/cjs/cli/lib/deployApi/evaluateSchema.js.map +2 -2
- package/dist/cjs/cli/lib/deployKeyWarning.js +43 -0
- package/dist/cjs/cli/lib/deployKeyWarning.js.map +7 -0
- package/dist/cjs/cli/lib/deployment.js +2 -0
- package/dist/cjs/cli/lib/deployment.js.map +2 -2
- package/dist/cjs/cli/lib/deploymentSelection.js +27 -18
- package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/cjs/cli/lib/dev.js +5 -0
- package/dist/cjs/cli/lib/dev.js.map +2 -2
- package/dist/cjs/cli/lib/envvars.js +32 -0
- package/dist/cjs/cli/lib/envvars.js.map +2 -2
- package/dist/cjs/cli/lib/formatValidationProgress.js +47 -0
- package/dist/cjs/cli/lib/formatValidationProgress.js.map +7 -0
- 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/indexes.js.map +1 -1
- package/dist/cjs/cli/lib/login.js +28 -4
- package/dist/cjs/cli/lib/login.js.map +2 -2
- package/dist/cjs/cli/lib/mcp/requestContext.js +5 -1
- package/dist/cjs/cli/lib/mcp/requestContext.js.map +2 -2
- package/dist/cjs/cli/lib/mcp/tools/env.js +10 -3
- package/dist/cjs/cli/lib/mcp/tools/env.js.map +2 -2
- package/dist/cjs/cli/lib/profileManagement.js +196 -0
- package/dist/cjs/cli/lib/profileManagement.js.map +7 -0
- package/dist/cjs/cli/lib/profiles.js +333 -0
- package/dist/cjs/cli/lib/profiles.js.map +7 -0
- package/dist/cjs/cli/lib/run.js +4 -0
- package/dist/cjs/cli/lib/run.js.map +2 -2
- package/dist/cjs/cli/lib/schemaEvaluation.js +62 -0
- package/dist/cjs/cli/lib/schemaEvaluation.js.map +7 -0
- package/dist/cjs/cli/lib/usageLimits.js +4 -2
- package/dist/cjs/cli/lib/usageLimits.js.map +2 -2
- package/dist/cjs/cli/lib/utils/mutex.js +9 -24
- package/dist/cjs/cli/lib/utils/mutex.js.map +2 -2
- package/dist/cjs/cli/lib/utils/utils.js +66 -27
- package/dist/cjs/cli/lib/utils/utils.js.map +2 -2
- package/dist/cjs/cli/login.js +213 -114
- package/dist/cjs/cli/login.js.map +3 -3
- package/dist/cjs/cli/logout.js +113 -12
- package/dist/cjs/cli/logout.js.map +3 -3
- package/dist/cjs/cli/mcp.js +43 -10
- package/dist/cjs/cli/mcp.js.map +3 -3
- package/dist/cjs/cli/program.js +2 -1
- package/dist/cjs/cli/program.js.map +2 -2
- package/dist/cjs/cli/projectCreate.js +1 -1
- package/dist/cjs/cli/projectCreate.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/impl/actions_impl.js +8 -3
- package/dist/cjs/server/impl/actions_impl.js.map +2 -2
- package/dist/cjs/server/impl/storage_impl.js +29 -0
- package/dist/cjs/server/impl/storage_impl.js.map +2 -2
- package/dist/cjs/server/index.js +1 -0
- 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 +34 -12
- package/dist/cjs/server/schema.js.map +2 -2
- package/dist/cjs/server/storage.js.map +1 -1
- package/dist/cjs/values/validators.js +1 -1
- package/dist/cjs/values/validators.js.map +2 -2
- package/dist/cjs/values/value.js +6 -0
- package/dist/cjs/values/value.js.map +2 -2
- package/dist/cjs-types/bundler/context.d.ts +5 -0
- package/dist/cjs-types/bundler/context.d.ts.map +1 -1
- package/dist/cjs-types/bundler/fs.d.ts +7 -2
- package/dist/cjs-types/bundler/fs.d.ts.map +1 -1
- package/dist/cjs-types/bundler/index.d.ts +9 -2
- package/dist/cjs-types/bundler/index.d.ts.map +1 -1
- package/dist/cjs-types/cli/account.d.ts +6 -0
- package/dist/cjs-types/cli/account.d.ts.map +1 -0
- package/dist/cjs-types/cli/codegen.d.ts.map +1 -1
- package/dist/cjs-types/cli/configure.d.ts +6 -0
- package/dist/cjs-types/cli/configure.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploy.d.ts +2 -0
- package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentCreate.d.ts +6 -6
- package/dist/cjs-types/cli/deploymentSelect.d.ts.map +1 -1
- package/dist/cjs-types/cli/dev.d.ts +1 -0
- package/dist/cjs-types/cli/dev.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/generatedApi.d.ts +1 -1
- package/dist/cjs-types/cli/generatedApi.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/api.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/checkForLargeIndexBackfill.d.ts +30 -0
- package/dist/cjs-types/cli/lib/checkForLargeIndexBackfill.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts +5 -7
- package/dist/cjs-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts +4 -10
- package/dist/cjs-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/checkForStagedValidatorDeletion.d.ts +17 -0
- package/dist/cjs-types/cli/lib/checkForStagedValidatorDeletion.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/codegen.d.ts +0 -3
- package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/command.d.ts +2 -0
- package/dist/cjs-types/cli/lib/command.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts +13 -0
- package/dist/cjs-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/components.d.ts +4 -0
- package/dist/cjs-types/cli/lib/components.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/config.d.ts +2 -1
- package/dist/cjs-types/cli/lib/config.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploy2.d.ts +2 -0
- package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts +460 -16
- package/dist/cjs-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployKeyWarning.d.ts +3 -0
- package/dist/cjs-types/cli/lib/deployKeyWarning.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/deployment.d.ts +2 -0
- package/dist/cjs-types/cli/lib/deployment.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts +2 -1
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/dev.d.ts +1 -0
- package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/envvars.d.ts +6 -0
- package/dist/cjs-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/formatValidationProgress.d.ts +8 -0
- package/dist/cjs-types/cli/lib/formatValidationProgress.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/fsUtils.d.ts +1 -0
- package/dist/cjs-types/cli/lib/fsUtils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/login.d.ts +3 -1
- 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/env.d.ts +8 -5
- package/dist/cjs-types/cli/lib/mcp/tools/env.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/cjs-types/cli/lib/profileManagement.d.ts +10 -0
- package/dist/cjs-types/cli/lib/profileManagement.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/profiles.d.ts +59 -0
- package/dist/cjs-types/cli/lib/profiles.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/run.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/schemaEvaluation.d.ts +33 -0
- package/dist/cjs-types/cli/lib/schemaEvaluation.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/usageLimits.d.ts +1 -1
- package/dist/cjs-types/cli/lib/usageLimits.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/mutex.d.ts +1 -3
- package/dist/cjs-types/cli/lib/utils/mutex.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/utils.d.ts +15 -2
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/login.d.ts +21 -0
- package/dist/cjs-types/cli/login.d.ts.map +1 -1
- package/dist/cjs-types/cli/logout.d.ts +8 -1
- 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/impl/actions_impl.d.ts +18 -3
- package/dist/cjs-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/storage_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/index.d.ts +1 -1
- package/dist/cjs-types/server/index.d.ts.map +1 -1
- package/dist/cjs-types/server/meta.d.ts +63 -0
- package/dist/cjs-types/server/meta.d.ts.map +1 -1
- package/dist/cjs-types/server/registration.d.ts +10 -0
- package/dist/cjs-types/server/registration.d.ts.map +1 -1
- package/dist/cjs-types/server/schema.d.ts +33 -0
- package/dist/cjs-types/server/schema.d.ts.map +1 -1
- package/dist/cjs-types/server/storage.d.ts.map +1 -1
- package/dist/cjs-types/values/value.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +4889 -2980
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/bundler/context.js +7 -5
- package/dist/esm/bundler/context.js.map +2 -2
- package/dist/esm/bundler/fs.js +47 -6
- package/dist/esm/bundler/fs.js.map +2 -2
- package/dist/esm/bundler/index.js +5 -4
- package/dist/esm/bundler/index.js.map +2 -2
- package/dist/esm/cli/account.js +221 -0
- package/dist/esm/cli/account.js.map +7 -0
- package/dist/esm/cli/codegen.js +0 -4
- package/dist/esm/cli/codegen.js.map +2 -2
- package/dist/esm/cli/configure.js +27 -6
- package/dist/esm/cli/configure.js.map +2 -2
- package/dist/esm/cli/deploy.js +27 -2
- package/dist/esm/cli/deploy.js.map +2 -2
- package/dist/esm/cli/deploymentSelect.js +6 -3
- package/dist/esm/cli/deploymentSelect.js.map +2 -2
- package/dist/esm/cli/dev.js +6 -0
- package/dist/esm/cli/dev.js.map +2 -2
- package/dist/esm/cli/env.js +11 -6
- package/dist/esm/cli/env.js.map +2 -2
- package/dist/esm/cli/envDefault.js +7 -2
- package/dist/esm/cli/envDefault.js.map +2 -2
- package/dist/esm/cli/lib/api.js +2 -0
- package/dist/esm/cli/lib/api.js.map +2 -2
- package/dist/esm/cli/lib/checkForLargeIndexBackfill.js +95 -0
- package/dist/esm/cli/lib/checkForLargeIndexBackfill.js.map +7 -0
- package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +37 -48
- package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
- package/dist/esm/cli/lib/checkForSlowSchemaValidation.js +63 -41
- package/dist/esm/cli/lib/checkForSlowSchemaValidation.js.map +2 -2
- package/dist/esm/cli/lib/checkForStagedValidatorDeletion.js +68 -0
- package/dist/esm/cli/lib/checkForStagedValidatorDeletion.js.map +7 -0
- package/dist/esm/cli/lib/codegen.js.map +2 -2
- package/dist/esm/cli/lib/command.js +2 -1
- package/dist/esm/cli/lib/command.js.map +2 -2
- package/dist/esm/cli/lib/components/definition/bundle.js +37 -11
- package/dist/esm/cli/lib/components/definition/bundle.js.map +2 -2
- package/dist/esm/cli/lib/components.js +55 -5
- package/dist/esm/cli/lib/components.js.map +2 -2
- package/dist/esm/cli/lib/config.js +55 -17
- package/dist/esm/cli/lib/config.js.map +2 -2
- package/dist/esm/cli/lib/deploy2.js +3 -1
- package/dist/esm/cli/lib/deploy2.js.map +2 -2
- package/dist/esm/cli/lib/deployApi/evaluateSchema.js +28 -2
- package/dist/esm/cli/lib/deployApi/evaluateSchema.js.map +2 -2
- package/dist/esm/cli/lib/deployKeyWarning.js +27 -0
- package/dist/esm/cli/lib/deployKeyWarning.js.map +7 -0
- 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 +35 -20
- package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/esm/cli/lib/dev.js +5 -0
- package/dist/esm/cli/lib/dev.js.map +2 -2
- package/dist/esm/cli/lib/envvars.js +35 -1
- package/dist/esm/cli/lib/envvars.js.map +2 -2
- package/dist/esm/cli/lib/formatValidationProgress.js +24 -0
- package/dist/esm/cli/lib/formatValidationProgress.js.map +7 -0
- 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/indexes.js.map +1 -1
- package/dist/esm/cli/lib/login.js +36 -4
- package/dist/esm/cli/lib/login.js.map +2 -2
- package/dist/esm/cli/lib/mcp/requestContext.js +5 -1
- package/dist/esm/cli/lib/mcp/requestContext.js.map +2 -2
- package/dist/esm/cli/lib/mcp/tools/env.js +10 -3
- package/dist/esm/cli/lib/mcp/tools/env.js.map +2 -2
- package/dist/esm/cli/lib/profileManagement.js +179 -0
- package/dist/esm/cli/lib/profileManagement.js.map +7 -0
- package/dist/esm/cli/lib/profiles.js +288 -0
- package/dist/esm/cli/lib/profiles.js.map +7 -0
- package/dist/esm/cli/lib/run.js +4 -0
- package/dist/esm/cli/lib/run.js.map +2 -2
- package/dist/esm/cli/lib/schemaEvaluation.js +39 -0
- package/dist/esm/cli/lib/schemaEvaluation.js.map +7 -0
- package/dist/esm/cli/lib/usageLimits.js +4 -2
- package/dist/esm/cli/lib/usageLimits.js.map +2 -2
- package/dist/esm/cli/lib/utils/mutex.js +9 -24
- package/dist/esm/cli/lib/utils/mutex.js.map +2 -2
- package/dist/esm/cli/lib/utils/utils.js +63 -27
- package/dist/esm/cli/lib/utils/utils.js.map +2 -2
- package/dist/esm/cli/login.js +225 -112
- package/dist/esm/cli/login.js.map +3 -3
- package/dist/esm/cli/logout.js +110 -13
- package/dist/esm/cli/logout.js.map +2 -2
- package/dist/esm/cli/mcp.js +34 -10
- package/dist/esm/cli/mcp.js.map +2 -2
- package/dist/esm/cli/program.js +2 -1
- package/dist/esm/cli/program.js.map +2 -2
- package/dist/esm/cli/projectCreate.js +1 -1
- package/dist/esm/cli/projectCreate.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/impl/actions_impl.js +7 -3
- package/dist/esm/server/impl/actions_impl.js.map +2 -2
- package/dist/esm/server/impl/storage_impl.js +29 -0
- package/dist/esm/server/impl/storage_impl.js.map +2 -2
- package/dist/esm/server/index.js +4 -1
- package/dist/esm/server/index.js.map +2 -2
- package/dist/esm/server/schema.js +34 -12
- package/dist/esm/server/schema.js.map +2 -2
- package/dist/esm/values/validators.js +1 -1
- package/dist/esm/values/validators.js.map +2 -2
- package/dist/esm/values/value.js +6 -0
- package/dist/esm/values/value.js.map +2 -2
- package/dist/esm-types/bundler/context.d.ts +5 -0
- package/dist/esm-types/bundler/context.d.ts.map +1 -1
- package/dist/esm-types/bundler/fs.d.ts +7 -2
- package/dist/esm-types/bundler/fs.d.ts.map +1 -1
- package/dist/esm-types/bundler/index.d.ts +9 -2
- package/dist/esm-types/bundler/index.d.ts.map +1 -1
- package/dist/esm-types/cli/account.d.ts +6 -0
- package/dist/esm-types/cli/account.d.ts.map +1 -0
- package/dist/esm-types/cli/codegen.d.ts.map +1 -1
- package/dist/esm-types/cli/configure.d.ts +6 -0
- package/dist/esm-types/cli/configure.d.ts.map +1 -1
- package/dist/esm-types/cli/deploy.d.ts +2 -0
- package/dist/esm-types/cli/deploy.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentCreate.d.ts +6 -6
- package/dist/esm-types/cli/deploymentSelect.d.ts.map +1 -1
- package/dist/esm-types/cli/dev.d.ts +1 -0
- package/dist/esm-types/cli/dev.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/generatedApi.d.ts +1 -1
- package/dist/esm-types/cli/generatedApi.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/api.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/checkForLargeIndexBackfill.d.ts +30 -0
- package/dist/esm-types/cli/lib/checkForLargeIndexBackfill.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts +5 -7
- package/dist/esm-types/cli/lib/checkForLargeIndexDeletion.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts +4 -10
- package/dist/esm-types/cli/lib/checkForSlowSchemaValidation.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/checkForStagedValidatorDeletion.d.ts +17 -0
- package/dist/esm-types/cli/lib/checkForStagedValidatorDeletion.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/codegen.d.ts +0 -3
- package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/command.d.ts +2 -0
- package/dist/esm-types/cli/lib/command.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/components/definition/bundle.d.ts +13 -0
- package/dist/esm-types/cli/lib/components/definition/bundle.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/components.d.ts +4 -0
- package/dist/esm-types/cli/lib/components.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/config.d.ts +2 -1
- package/dist/esm-types/cli/lib/config.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploy2.d.ts +2 -0
- package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts +460 -16
- package/dist/esm-types/cli/lib/deployApi/evaluateSchema.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployKeyWarning.d.ts +3 -0
- package/dist/esm-types/cli/lib/deployKeyWarning.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/deployment.d.ts +2 -0
- package/dist/esm-types/cli/lib/deployment.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts +2 -1
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/dev.d.ts +1 -0
- package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/envvars.d.ts +6 -0
- package/dist/esm-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/formatValidationProgress.d.ts +8 -0
- package/dist/esm-types/cli/lib/formatValidationProgress.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/fsUtils.d.ts +1 -0
- package/dist/esm-types/cli/lib/fsUtils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/login.d.ts +3 -1
- 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/env.d.ts +8 -5
- package/dist/esm-types/cli/lib/mcp/tools/env.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/esm-types/cli/lib/profileManagement.d.ts +10 -0
- package/dist/esm-types/cli/lib/profileManagement.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/profiles.d.ts +59 -0
- package/dist/esm-types/cli/lib/profiles.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/run.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/schemaEvaluation.d.ts +33 -0
- package/dist/esm-types/cli/lib/schemaEvaluation.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/usageLimits.d.ts +1 -1
- package/dist/esm-types/cli/lib/usageLimits.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/mutex.d.ts +1 -3
- package/dist/esm-types/cli/lib/utils/mutex.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/utils.d.ts +15 -2
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/login.d.ts +21 -0
- package/dist/esm-types/cli/login.d.ts.map +1 -1
- package/dist/esm-types/cli/logout.d.ts +8 -1
- 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/impl/actions_impl.d.ts +18 -3
- package/dist/esm-types/server/impl/actions_impl.d.ts.map +1 -1
- package/dist/esm-types/server/impl/storage_impl.d.ts.map +1 -1
- package/dist/esm-types/server/index.d.ts +1 -1
- package/dist/esm-types/server/index.d.ts.map +1 -1
- package/dist/esm-types/server/meta.d.ts +63 -0
- package/dist/esm-types/server/meta.d.ts.map +1 -1
- package/dist/esm-types/server/registration.d.ts +10 -0
- package/dist/esm-types/server/registration.d.ts.map +1 -1
- package/dist/esm-types/server/schema.d.ts +33 -0
- package/dist/esm-types/server/schema.d.ts.map +1 -1
- package/dist/esm-types/server/storage.d.ts.map +1 -1
- package/dist/esm-types/values/value.d.ts.map +1 -1
- package/dist/react.bundle.js +7 -1
- package/dist/react.bundle.js.map +2 -2
- package/package.json +5 -5
- package/schemas/convex.schema.json +5 -5
- package/src/bundler/context.ts +9 -5
- package/src/bundler/fs.ts +54 -5
- package/src/bundler/index.ts +9 -4
- package/src/cli/account.ts +320 -0
- package/src/cli/codegen.ts +0 -2
- package/src/cli/configure.ts +45 -9
- package/src/cli/deploy.ts +36 -5
- package/src/cli/deploymentSelect.ts +7 -4
- package/src/cli/dev.ts +9 -0
- package/src/cli/env.ts +12 -6
- package/src/cli/envDefault.ts +8 -2
- package/src/cli/generatedApi.ts +1 -1
- package/src/cli/lib/api.ts +5 -1
- package/src/cli/lib/checkForLargeIndexBackfill.ts +173 -0
- package/src/cli/lib/checkForLargeIndexDeletion.ts +45 -58
- package/src/cli/lib/checkForSlowSchemaValidation.ts +76 -65
- package/src/cli/lib/checkForStagedValidatorDeletion.ts +104 -0
- package/src/cli/lib/codegen.ts +0 -3
- package/src/cli/lib/command.ts +3 -0
- package/src/cli/lib/components/definition/bundle.ts +68 -14
- package/src/cli/lib/components.ts +71 -4
- package/src/cli/lib/config.ts +85 -18
- package/src/cli/lib/deploy2.ts +10 -1
- package/src/cli/lib/deployApi/evaluateSchema.ts +35 -0
- package/src/cli/lib/deployKeyWarning.ts +43 -0
- package/src/cli/lib/deployment.ts +2 -2
- package/src/cli/lib/deploymentSelection.ts +37 -18
- package/src/cli/lib/dev.ts +14 -0
- package/src/cli/lib/envvars.ts +43 -1
- package/src/cli/lib/formatValidationProgress.ts +35 -0
- package/src/cli/lib/fsUtils.ts +5 -2
- package/src/cli/lib/generateDocs.ts +1 -1
- package/src/cli/lib/indexes.ts +1 -1
- package/src/cli/lib/login.ts +47 -3
- package/src/cli/lib/mcp/requestContext.ts +7 -1
- package/src/cli/lib/mcp/tools/env.ts +17 -3
- package/src/cli/lib/profileManagement.ts +262 -0
- package/src/cli/lib/profiles.ts +398 -0
- package/src/cli/lib/run.ts +2 -0
- package/src/cli/lib/schemaEvaluation.ts +88 -0
- package/src/cli/lib/usageLimits.ts +2 -0
- package/src/cli/lib/utils/mutex.ts +9 -27
- package/src/cli/lib/utils/utils.ts +83 -36
- package/src/cli/login.ts +293 -168
- package/src/cli/logout.ts +142 -17
- package/src/cli/mcp.ts +48 -11
- package/src/cli/program.ts +2 -0
- package/src/cli/projectCreate.ts +1 -1
- package/src/index.ts +1 -1
- package/src/server/impl/actions_impl.ts +26 -6
- package/src/server/impl/storage_impl.ts +30 -0
- package/src/server/index.ts +5 -1
- package/src/server/meta.ts +56 -2
- package/src/server/registration.ts +10 -0
- package/src/server/schema.ts +37 -15
- package/src/server/storage.ts +17 -0
- package/src/values/validators.ts +1 -1
- package/src/values/value.ts +9 -5
package/src/cli/logout.ts
CHANGED
|
@@ -1,24 +1,149 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
2
|
import { oneoffContext } from "../bundler/context.js";
|
|
3
|
-
import { logFinishedStep } from "../bundler/log.js";
|
|
3
|
+
import { logFinishedStep, logMessage, logWarning } from "../bundler/log.js";
|
|
4
4
|
import { recursivelyDelete } from "./lib/fsUtils.js";
|
|
5
5
|
import { globalConfigPath } from "./lib/utils/globalConfig.js";
|
|
6
|
+
import {
|
|
7
|
+
getProfileSelection,
|
|
8
|
+
profileConfigPath,
|
|
9
|
+
readProfileToken,
|
|
10
|
+
readProfileSettings,
|
|
11
|
+
updateProfileSettings,
|
|
12
|
+
savedProfileNames,
|
|
13
|
+
} from "./lib/profiles.js";
|
|
14
|
+
import path from "path";
|
|
15
|
+
import { rootDirectory } from "./lib/utils/utils.js";
|
|
16
|
+
import { promptOptions } from "./lib/utils/prompts.js";
|
|
6
17
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
export function createLogoutCommand() {
|
|
19
|
+
return new Command("logout")
|
|
20
|
+
.description(
|
|
21
|
+
"Log out of the selected account. Directory selections are preserved.",
|
|
22
|
+
)
|
|
23
|
+
.option("--account <name>", "Remove only this account's saved credentials")
|
|
24
|
+
.option(
|
|
25
|
+
"--all",
|
|
26
|
+
"Remove all saved account credentials, preserving account selections",
|
|
27
|
+
)
|
|
28
|
+
.allowExcessArguments(false)
|
|
29
|
+
.action(async (options, cmd) => {
|
|
30
|
+
if (options.all && options.account !== undefined)
|
|
31
|
+
cmd.error("Pass either --account or --all, not both.");
|
|
32
|
+
const ctx = await oneoffContext({
|
|
33
|
+
url: undefined,
|
|
34
|
+
adminKey: undefined,
|
|
35
|
+
envFile: undefined,
|
|
36
|
+
skipAuth: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
let all = !!options.all;
|
|
40
|
+
let profile = all
|
|
41
|
+
? null
|
|
42
|
+
: await getProfileSelection(ctx, { name: options.account });
|
|
43
|
+
if (
|
|
44
|
+
!all &&
|
|
45
|
+
options.account === undefined &&
|
|
46
|
+
process.stdin.isTTY &&
|
|
47
|
+
profile !== null
|
|
48
|
+
) {
|
|
49
|
+
const token = readProfileToken(ctx, profile.name);
|
|
50
|
+
const settings = await readProfileSettings(ctx);
|
|
51
|
+
const selectedName = profile.name;
|
|
52
|
+
// A matching compatibility token is another copy of this account's login.
|
|
53
|
+
const hasOtherLogins =
|
|
54
|
+
savedProfileNames(ctx).some((name) => name !== selectedName) ||
|
|
55
|
+
(typeof settings.accessToken === "string" &&
|
|
56
|
+
settings.accessToken.length > 0 &&
|
|
57
|
+
settings.accessToken !== token);
|
|
58
|
+
if (hasOtherLogins) {
|
|
59
|
+
const scope = await promptOptions(ctx, {
|
|
60
|
+
message: "Which saved logins would you like to log out of?",
|
|
61
|
+
choices: [
|
|
62
|
+
{ name: `Only account "${profile.name}"`, value: "profile" },
|
|
63
|
+
{ name: "All saved logins on this device", value: "all" },
|
|
64
|
+
],
|
|
65
|
+
default: "profile",
|
|
66
|
+
});
|
|
67
|
+
if (scope === "all") {
|
|
68
|
+
profile = null;
|
|
69
|
+
all = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
16
73
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
74
|
+
let warnAboutLegacyCredentials = false;
|
|
75
|
+
if (profile !== null) {
|
|
76
|
+
const selectedName = profile.name;
|
|
77
|
+
await updateProfileSettings(
|
|
78
|
+
ctx,
|
|
79
|
+
(settings) => {
|
|
80
|
+
const token = readProfileToken(ctx, selectedName);
|
|
81
|
+
// A migrated account can share its token with old CLI versions.
|
|
82
|
+
if (token !== null && settings.accessToken === token) {
|
|
83
|
+
delete settings.accessToken;
|
|
84
|
+
} else if (
|
|
85
|
+
settings.defaultProfile === selectedName &&
|
|
86
|
+
typeof settings.accessToken === "string" &&
|
|
87
|
+
settings.accessToken.length > 0
|
|
88
|
+
) {
|
|
89
|
+
// Editing the default or logging in with an older CLI can leave this
|
|
90
|
+
// token belonging to a different account.
|
|
91
|
+
warnAboutLegacyCredentials = true;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
() => {
|
|
95
|
+
const configPath = profileConfigPath(selectedName);
|
|
96
|
+
recursivelyDelete(ctx, configPath, {
|
|
97
|
+
force: true,
|
|
98
|
+
followSymlinks: false,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
} else {
|
|
103
|
+
await updateProfileSettings(
|
|
104
|
+
ctx,
|
|
105
|
+
async (settings) => {
|
|
106
|
+
if (
|
|
107
|
+
!all &&
|
|
108
|
+
savedProfileNames(ctx).length > 0 &&
|
|
109
|
+
settings.accessToken === undefined
|
|
110
|
+
) {
|
|
111
|
+
return await ctx.crash({
|
|
112
|
+
exitCode: 1,
|
|
113
|
+
errorType: "fatal",
|
|
114
|
+
printedMessage:
|
|
115
|
+
"No account is selected. Use `npx convex logout --account <name>` or `npx convex logout --all`.",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
delete settings.accessToken;
|
|
119
|
+
},
|
|
120
|
+
() => {
|
|
121
|
+
const profilesDir = path.join(rootDirectory(), "profiles");
|
|
122
|
+
if (all)
|
|
123
|
+
recursivelyDelete(ctx, profilesDir, {
|
|
124
|
+
force: true,
|
|
125
|
+
followSymlinks: false,
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
logFinishedStep(
|
|
132
|
+
profile !== null
|
|
133
|
+
? `Removed credentials for account "${profile.name}".\n Run \`npx convex login --account ${profile.name}\` to log in.`
|
|
134
|
+
: `${all ? "Removed all saved Convex account credentials." : "Removed your saved Convex login credentials."}\n Run \`npx convex login\` to log in.`,
|
|
135
|
+
);
|
|
136
|
+
if (warnAboutLegacyCredentials) {
|
|
137
|
+
logWarning(
|
|
138
|
+
`Saved credentials remain in ${globalConfigPath()} for older CLI versions. To remove all saved account credentials, run \`npx convex logout --all\`.`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
if (process.env.CONVEX_OVERRIDE_ACCESS_TOKEN) {
|
|
142
|
+
logMessage(
|
|
143
|
+
"CONVEX_OVERRIDE_ACCESS_TOKEN still supplies credentials. Unset it to stop using that token.",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
20
148
|
|
|
21
|
-
|
|
22
|
-
"You have been logged out of Convex.\n Run `npx convex dev` to log in.",
|
|
23
|
-
);
|
|
24
|
-
});
|
|
149
|
+
export const logout = createLogoutCommand();
|
package/src/cli/mcp.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
3
|
import { oneoffContext } from "../bundler/context.js";
|
|
3
4
|
import { logError } from "../bundler/log.js";
|
|
@@ -6,6 +7,7 @@ import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
|
6
7
|
import { actionDescription } from "./lib/command.js";
|
|
7
8
|
import { checkAuthorization } from "./lib/login.js";
|
|
8
9
|
import {
|
|
10
|
+
encodeDeploymentSelector,
|
|
9
11
|
McpOptions,
|
|
10
12
|
RequestContext,
|
|
11
13
|
RequestCrash,
|
|
@@ -115,6 +117,14 @@ function enabledTools(
|
|
|
115
117
|
export function makeServer(options: McpOptions) {
|
|
116
118
|
const enabledToolsByName = enabledTools(options);
|
|
117
119
|
const mutex = new Mutex();
|
|
120
|
+
const serverDirectory = process.cwd();
|
|
121
|
+
options = {
|
|
122
|
+
...options,
|
|
123
|
+
envFile:
|
|
124
|
+
options.envFile === undefined
|
|
125
|
+
? undefined
|
|
126
|
+
: path.resolve(serverDirectory, options.envFile),
|
|
127
|
+
};
|
|
118
128
|
const server = new Server(
|
|
119
129
|
{
|
|
120
130
|
name: "Convex MCP Server",
|
|
@@ -128,17 +138,7 @@ export function makeServer(options: McpOptions) {
|
|
|
128
138
|
);
|
|
129
139
|
server.setRequestHandler("tools/call", async (request: CallToolRequest) => {
|
|
130
140
|
const ctx = new RequestContext(options);
|
|
131
|
-
await initializeBigBrainAuth(ctx, options);
|
|
132
141
|
try {
|
|
133
|
-
const authorized = await checkAuthorization(ctx, false);
|
|
134
|
-
if (!authorized) {
|
|
135
|
-
await ctx.crash({
|
|
136
|
-
exitCode: 1,
|
|
137
|
-
errorType: "fatal",
|
|
138
|
-
printedMessage:
|
|
139
|
-
"Not Authorized: Run `npx convex dev` to login to your Convex project.",
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
142
|
if (!request.params.arguments) {
|
|
143
143
|
await ctx.crash({
|
|
144
144
|
exitCode: 1,
|
|
@@ -158,7 +158,44 @@ export function makeServer(options: McpOptions) {
|
|
|
158
158
|
|
|
159
159
|
// Serialize tool handlers since they're mutating the current working directory.
|
|
160
160
|
const result = await mutex.runExclusive(async () => {
|
|
161
|
-
|
|
161
|
+
const projectDir =
|
|
162
|
+
"deploymentSelector" in input
|
|
163
|
+
? ctx.decodeDeploymentSelectorUnchecked(input.deploymentSelector)
|
|
164
|
+
.projectDir
|
|
165
|
+
: (("projectDir" in input ? input.projectDir : undefined) ??
|
|
166
|
+
options.projectDir);
|
|
167
|
+
const previousDirectory = process.cwd();
|
|
168
|
+
try {
|
|
169
|
+
if (projectDir !== undefined)
|
|
170
|
+
process.chdir(path.resolve(serverDirectory, projectDir));
|
|
171
|
+
await initializeBigBrainAuth(ctx, options);
|
|
172
|
+
if (!(await checkAuthorization(ctx, false))) {
|
|
173
|
+
await ctx.crash({
|
|
174
|
+
exitCode: 1,
|
|
175
|
+
errorType: "fatal",
|
|
176
|
+
printedMessage:
|
|
177
|
+
"Not Authorized: Run `npx convex dev` to login to your Convex project.",
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const absoluteDirectory = process.cwd();
|
|
181
|
+
const resolvedInput =
|
|
182
|
+
"deploymentSelector" in input
|
|
183
|
+
? {
|
|
184
|
+
...input,
|
|
185
|
+
deploymentSelector: encodeDeploymentSelector(
|
|
186
|
+
absoluteDirectory,
|
|
187
|
+
ctx.decodeDeploymentSelectorUnchecked(
|
|
188
|
+
input.deploymentSelector,
|
|
189
|
+
).deployment,
|
|
190
|
+
),
|
|
191
|
+
}
|
|
192
|
+
: projectDir === undefined
|
|
193
|
+
? input
|
|
194
|
+
: { ...input, projectDir: absoluteDirectory };
|
|
195
|
+
return await convexTool.handler(ctx, resolvedInput);
|
|
196
|
+
} finally {
|
|
197
|
+
process.chdir(previousDirectory);
|
|
198
|
+
}
|
|
162
199
|
});
|
|
163
200
|
return {
|
|
164
201
|
content: [
|
package/src/cli/program.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { logout } from "./logout.js";
|
|
|
21
21
|
import { logs } from "./logs.js";
|
|
22
22
|
import { mcp } from "./mcp.js";
|
|
23
23
|
import { networkTest } from "./network_test.js";
|
|
24
|
+
import { account } from "./account.js";
|
|
24
25
|
import { project } from "./project.js";
|
|
25
26
|
import { reinit } from "./reinit.js";
|
|
26
27
|
import { run } from "./run.js";
|
|
@@ -56,6 +57,7 @@ export function buildProgram() {
|
|
|
56
57
|
.addCommand(codegen)
|
|
57
58
|
.addCommand(update)
|
|
58
59
|
.addCommand(logout)
|
|
60
|
+
.addCommand(account)
|
|
59
61
|
.addCommand(networkTest, { hidden: true })
|
|
60
62
|
.addCommand(integration, { hidden: true })
|
|
61
63
|
.addCommand(functionSpec)
|
package/src/cli/projectCreate.ts
CHANGED
|
@@ -64,7 +64,7 @@ async function runProjectCreate(
|
|
|
64
64
|
logMessage(
|
|
65
65
|
chalkStderr.gray(
|
|
66
66
|
`Next, add a deployment with ` +
|
|
67
|
-
`\`npx convex deployment create ${team.slug}:${projectSlug}:dev --type dev\` ` +
|
|
67
|
+
`\`npx convex deployment create ${team.slug}:${projectSlug}:dev/my-feature --type dev --select\` ` +
|
|
68
68
|
`(pass \`--region us\` to choose a region).`,
|
|
69
69
|
),
|
|
70
70
|
);
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "1.
|
|
1
|
+
export const version = "1.48.0-alpha.0";
|
|
@@ -64,26 +64,46 @@ export function setupActionCalls(requestId: string) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* A Convex-managed service. The backend decides which names it accepts; this
|
|
69
|
+
* type lists the ones the current release knows about.
|
|
70
|
+
*/
|
|
71
|
+
export type ServiceName = "ai-gateway";
|
|
72
|
+
|
|
67
73
|
/**
|
|
68
74
|
* Get a short-lived credential for calling a Convex-managed service.
|
|
69
75
|
*
|
|
70
76
|
* This function can only be called while an action is running. The credential
|
|
71
77
|
* is scoped to the current deployment and should be sent as a bearer token.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
78
|
+
* The action runtime caches and refreshes credentials as needed, so call
|
|
79
|
+
* this function whenever making a service request.
|
|
74
80
|
*
|
|
75
81
|
* @param service - The service the credential may access.
|
|
76
82
|
* @returns A JWT to send as `Authorization: Bearer <token>`. Keep it inside
|
|
77
83
|
* the action: don't return it to clients or store it in environment
|
|
78
84
|
* variables.
|
|
79
85
|
*/
|
|
80
|
-
export async function getServiceToken(service:
|
|
86
|
+
export async function getServiceToken(service: ServiceName): Promise<string> {
|
|
81
87
|
validateArg(service, 1, "getServiceToken", "service");
|
|
82
|
-
if (service !== "ai-gateway") {
|
|
83
|
-
throw new Error(`Unsupported service "${String(service)}"`);
|
|
84
|
-
}
|
|
85
88
|
return await performAsyncSyscall("1.0/createServiceToken", {
|
|
86
89
|
service,
|
|
87
90
|
version,
|
|
88
91
|
});
|
|
89
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get the base URL of a Convex-managed service.
|
|
96
|
+
*
|
|
97
|
+
* This function can only be called while an action is running. Pair it with
|
|
98
|
+
* {@link getServiceToken} to reach the service.
|
|
99
|
+
*
|
|
100
|
+
* @param service - The service to address.
|
|
101
|
+
* @returns The service's origin, without a trailing slash.
|
|
102
|
+
*/
|
|
103
|
+
export async function getServiceUrl(service: ServiceName): Promise<string> {
|
|
104
|
+
validateArg(service, 1, "getServiceUrl", "service");
|
|
105
|
+
return await performAsyncSyscall("1.0/getServiceUrl", {
|
|
106
|
+
service,
|
|
107
|
+
version,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
StorageWriter,
|
|
7
7
|
} from "../storage.js";
|
|
8
8
|
import { version } from "../../index.js";
|
|
9
|
+
import { fromByteArray, toByteArray } from "../../values/base64.js";
|
|
9
10
|
import { performAsyncSyscall, performJsSyscall } from "./syscall.js";
|
|
10
11
|
import { validateArg } from "./validate.js";
|
|
11
12
|
|
|
@@ -45,6 +46,35 @@ export function setupStorageWriter(requestId: string): StorageWriter {
|
|
|
45
46
|
storageId,
|
|
46
47
|
});
|
|
47
48
|
},
|
|
49
|
+
store: async (blob: Blob, options?: { sha256?: string }) => {
|
|
50
|
+
if (!(blob instanceof Blob)) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
"store() expects a Blob. If you are trying to store a Request, `await request.blob()` will give you the correct input.",
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
56
|
+
return await performAsyncSyscall("1.0/storageStore", {
|
|
57
|
+
requestId,
|
|
58
|
+
version,
|
|
59
|
+
blob: fromByteArray(bytes),
|
|
60
|
+
contentType: blob.type,
|
|
61
|
+
sha256: options?.sha256,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
get: async (storageId: FileStorageId) => {
|
|
65
|
+
const result: { blob: string; contentType: string | null } | null =
|
|
66
|
+
await performAsyncSyscall("1.0/storageGet", {
|
|
67
|
+
requestId,
|
|
68
|
+
version,
|
|
69
|
+
storageId,
|
|
70
|
+
});
|
|
71
|
+
if (result === null) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return new Blob([toByteArray(result.blob)], {
|
|
75
|
+
type: result.contentType ?? "",
|
|
76
|
+
});
|
|
77
|
+
},
|
|
48
78
|
getUrl: reader.getUrl,
|
|
49
79
|
getMetadata: reader.getMetadata,
|
|
50
80
|
};
|
package/src/server/index.ts
CHANGED
|
@@ -103,7 +103,11 @@ export {
|
|
|
103
103
|
internalMutationGeneric,
|
|
104
104
|
internalQueryGeneric,
|
|
105
105
|
} from "./impl/registration_impl.js";
|
|
106
|
-
export {
|
|
106
|
+
export {
|
|
107
|
+
getServiceToken,
|
|
108
|
+
getServiceUrl,
|
|
109
|
+
type ServiceName,
|
|
110
|
+
} from "./impl/actions_impl.js";
|
|
107
111
|
export type {
|
|
108
112
|
TransactionMetric,
|
|
109
113
|
TransactionMetrics,
|
package/src/server/meta.ts
CHANGED
|
@@ -26,6 +26,14 @@ export type TransactionMetrics = {
|
|
|
26
26
|
documentsWritten: TransactionMetric;
|
|
27
27
|
functionsScheduled: TransactionMetric;
|
|
28
28
|
scheduledFunctionArgsBytes: TransactionMetric;
|
|
29
|
+
/** @internal */
|
|
30
|
+
filesWritten: TransactionMetric;
|
|
31
|
+
/** @internal */
|
|
32
|
+
fileWriteBytes: TransactionMetric;
|
|
33
|
+
/** @internal */
|
|
34
|
+
filesRead: TransactionMetric;
|
|
35
|
+
/** @internal */
|
|
36
|
+
fileReadBytes: TransactionMetric;
|
|
29
37
|
};
|
|
30
38
|
|
|
31
39
|
/**
|
|
@@ -43,6 +51,14 @@ export interface TransactionLimits {
|
|
|
43
51
|
documentsWritten?: number;
|
|
44
52
|
functionsScheduled?: number;
|
|
45
53
|
scheduledFunctionArgsBytes?: number;
|
|
54
|
+
/** @internal */
|
|
55
|
+
filesWritten?: number;
|
|
56
|
+
/** @internal */
|
|
57
|
+
fileWriteBytes?: number;
|
|
58
|
+
/** @internal */
|
|
59
|
+
filesRead?: number;
|
|
60
|
+
/** @internal */
|
|
61
|
+
fileReadBytes?: number;
|
|
46
62
|
}
|
|
47
63
|
|
|
48
64
|
/**
|
|
@@ -130,18 +146,30 @@ export type RequestMetadata = {
|
|
|
130
146
|
* @public
|
|
131
147
|
*/
|
|
132
148
|
export interface QueryMeta {
|
|
149
|
+
/**
|
|
150
|
+
* Metadata about the currently executing Convex function.
|
|
151
|
+
*/
|
|
133
152
|
getFunctionMetadata(): Promise<FunctionMetadata>;
|
|
153
|
+
/**
|
|
154
|
+
* The remaining headroom for a transaction before hitting limits.
|
|
155
|
+
*
|
|
156
|
+
* See https://docs.convex.dev/production/state/limits
|
|
157
|
+
*/
|
|
134
158
|
getTransactionMetrics(): Promise<TransactionMetrics>;
|
|
159
|
+
/**
|
|
160
|
+
* Metadata about the deployment this function is running on.
|
|
161
|
+
*/
|
|
135
162
|
getDeploymentMetadata(): Promise<DeploymentMetadata>;
|
|
136
163
|
/**
|
|
137
|
-
* @internal
|
|
138
164
|
* Returns the timestamp of the database snapshot this transaction reads
|
|
139
165
|
* from, in nanoseconds.
|
|
140
166
|
*
|
|
141
167
|
* All commits at or before this timestamp are observable within the
|
|
142
168
|
* transaction, and no later commits are. The value is fixed for the
|
|
143
169
|
* lifetime of the transaction and shared with all nested `runMutation` and
|
|
144
|
-
* `runQuery` calls.
|
|
170
|
+
* non-stale `runQuery` calls. If a nested query is called with
|
|
171
|
+
* `useStaleSnapshot: true`, then the nested query may in a future backend
|
|
172
|
+
* version choose an older snapshotTs.
|
|
145
173
|
*
|
|
146
174
|
* It is on the same clock as `db.vars.commitTs`: documents observable in
|
|
147
175
|
* this transaction have `commitTs` values at or before this timestamp, and
|
|
@@ -156,6 +184,8 @@ export interface QueryMeta {
|
|
|
156
184
|
* Note: this should not be compared to `_creationTime` or `Date.now()`, as
|
|
157
185
|
* those are based on wall-clock time rather than the database clock, and
|
|
158
186
|
* aren't guaranteed to follow commit order.
|
|
187
|
+
*
|
|
188
|
+
* Docs: https://docs.convex.dev/database/advanced/commit-timestamp
|
|
159
189
|
*/
|
|
160
190
|
getSnapshotTs(): bigint;
|
|
161
191
|
}
|
|
@@ -166,6 +196,15 @@ export interface QueryMeta {
|
|
|
166
196
|
* @public
|
|
167
197
|
*/
|
|
168
198
|
export interface MutationMeta extends QueryMeta {
|
|
199
|
+
/**
|
|
200
|
+
* Metadata about the HTTP request that triggered the current function execution.
|
|
201
|
+
*
|
|
202
|
+
* `ip` and `userAgent` are `null` when the function was not triggered by an
|
|
203
|
+
* HTTP request (e.g. scheduled jobs or cron jobs).
|
|
204
|
+
*
|
|
205
|
+
* Functions called from within a function (i.e. using `runMutation`) will have
|
|
206
|
+
* the same request metadata as the parent function.
|
|
207
|
+
*/
|
|
169
208
|
getRequestMetadata(): Promise<RequestMetadata>;
|
|
170
209
|
}
|
|
171
210
|
|
|
@@ -175,7 +214,22 @@ export interface MutationMeta extends QueryMeta {
|
|
|
175
214
|
* @public
|
|
176
215
|
*/
|
|
177
216
|
export interface ActionMeta {
|
|
217
|
+
/**
|
|
218
|
+
* Metadata about the currently executing Convex function.
|
|
219
|
+
*/
|
|
178
220
|
getFunctionMetadata(): Promise<FunctionMetadata>;
|
|
221
|
+
/**
|
|
222
|
+
* Metadata about the deployment this function is running on.
|
|
223
|
+
*/
|
|
179
224
|
getDeploymentMetadata(): Promise<DeploymentMetadata>;
|
|
225
|
+
/**
|
|
226
|
+
* Metadata about the HTTP request that triggered the current function execution.
|
|
227
|
+
*
|
|
228
|
+
* `ip` and `userAgent` are `null` when the function was not triggered by an
|
|
229
|
+
* HTTP request (e.g. scheduled jobs or cron jobs).
|
|
230
|
+
*
|
|
231
|
+
* Functions called from within a function (i.e. using `runMutation` or
|
|
232
|
+
* `runAction`) will have the same request metadata as the parent function.
|
|
233
|
+
*/
|
|
180
234
|
getRequestMetadata(): Promise<RequestMetadata>;
|
|
181
235
|
}
|
|
@@ -1234,6 +1234,11 @@ export type HttpActionBuilder = (
|
|
|
1234
1234
|
) => PublicHttpAction;
|
|
1235
1235
|
|
|
1236
1236
|
export interface AdvancedRunQueryOptions {
|
|
1237
|
+
/**
|
|
1238
|
+
* Custom limits for a nested transaction. Each field specifies the absolute
|
|
1239
|
+
* maximum allowed for the nested function call. Values are capped at the
|
|
1240
|
+
* global transaction limits, so they can only lower limits, never raise them.
|
|
1241
|
+
*/
|
|
1237
1242
|
transactionLimits?: TransactionLimits;
|
|
1238
1243
|
/**
|
|
1239
1244
|
* Run a query on a recent snapshot of the database that is not guaranteed
|
|
@@ -1244,6 +1249,11 @@ export interface AdvancedRunQueryOptions {
|
|
|
1244
1249
|
* database read conflicts are expected, e.g. reading from an append-only
|
|
1245
1250
|
* table with immutable records where the only read conflicts are from
|
|
1246
1251
|
* concurrent appends.
|
|
1252
|
+
*
|
|
1253
|
+
* To determine the snapshot of the nested query, you can call
|
|
1254
|
+
* `ctx.meta.getSnapshotTs()` from within the stale snapshot query. To
|
|
1255
|
+
* compare to the parent mutation's snapshot timestamp, you can return that
|
|
1256
|
+
* value from the query and call `ctx.meta.getSnapshotTs()` from the parent.
|
|
1247
1257
|
*/
|
|
1248
1258
|
useStaleSnapshot?: boolean;
|
|
1249
1259
|
}
|
package/src/server/schema.ts
CHANGED
|
@@ -561,41 +561,63 @@ export class TableDefinition<
|
|
|
561
561
|
}
|
|
562
562
|
|
|
563
563
|
/**
|
|
564
|
-
* Stage
|
|
564
|
+
* Stage changes to this table's document validator.
|
|
565
565
|
*
|
|
566
566
|
* Convex validates the staged validator against the table's existing
|
|
567
567
|
* documents in the background, while the validator passed to
|
|
568
|
-
* {@link defineTable} remains the one enforced on
|
|
569
|
-
* the background validation succeeds,
|
|
570
|
-
*
|
|
568
|
+
* {@link defineTable} remains the one enforced on writes. Once
|
|
569
|
+
* the background validation succeeds, apply the staged changes
|
|
570
|
+
* and remove `.staged()`.
|
|
571
|
+
*
|
|
572
|
+
* For an object validator, pass only the fields to add or replace. Fields
|
|
573
|
+
* omitted from the changes keep their enforced validators.
|
|
574
|
+
* Set a field to `undefined` to remove it from the staged validator.
|
|
575
|
+
* For nested objects, you must specify the full object validator.
|
|
571
576
|
*
|
|
572
577
|
* ```ts
|
|
573
578
|
* defineTable({
|
|
574
|
-
*
|
|
579
|
+
* apple: v.string(),
|
|
580
|
+
* banana: v.number(),
|
|
581
|
+
* legacy: v.optional(v.string()),
|
|
575
582
|
* }).staged({
|
|
576
|
-
*
|
|
583
|
+
* banana: v.union(v.string(), v.number()),
|
|
584
|
+
* legacy: undefined,
|
|
577
585
|
* })
|
|
578
586
|
* ```
|
|
579
587
|
*
|
|
580
|
-
*
|
|
588
|
+
* See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).
|
|
581
589
|
*
|
|
582
|
-
* @param documentSchema -
|
|
583
|
-
*
|
|
590
|
+
* @param documentSchema - Field changes for a table defined as an object or
|
|
591
|
+
* `v.any()`, or a full schema validator specifying the proposed next document
|
|
592
|
+
* type. Use a full schema validator for a table defined as a union.
|
|
584
593
|
* @returns A {@link TableDefinition} with the staged validator attached.
|
|
585
|
-
*
|
|
586
|
-
* @internal
|
|
587
594
|
*/
|
|
588
595
|
staged(
|
|
589
596
|
documentSchema:
|
|
590
597
|
| Validator<Record<string, any>, "required", any>
|
|
591
|
-
| Record<string, GenericValidator>,
|
|
598
|
+
| Record<string, GenericValidator | undefined>,
|
|
592
599
|
): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes> {
|
|
593
600
|
if (this.stagedValidator !== undefined) {
|
|
594
601
|
throw new Error("Table cannot have more than one staged validator.");
|
|
595
602
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
603
|
+
if (isValidator(documentSchema)) {
|
|
604
|
+
this.stagedValidator = documentSchema;
|
|
605
|
+
} else {
|
|
606
|
+
if (this.validator.kind !== "object" && this.validator.kind !== "any") {
|
|
607
|
+
throw new Error(
|
|
608
|
+
"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.",
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
const enforcedFields =
|
|
612
|
+
this.validator.kind === "object" ? this.validator.fields : {};
|
|
613
|
+
const fields: Record<string, GenericValidator> = Object.fromEntries(
|
|
614
|
+
Object.entries({ ...enforcedFields, ...documentSchema }).filter(
|
|
615
|
+
(entry): entry is [string, GenericValidator] =>
|
|
616
|
+
entry[1] !== undefined,
|
|
617
|
+
),
|
|
618
|
+
);
|
|
619
|
+
this.stagedValidator = v.object(fields);
|
|
620
|
+
}
|
|
599
621
|
return this.self();
|
|
600
622
|
}
|
|
601
623
|
|
package/src/server/storage.ts
CHANGED
|
@@ -194,6 +194,23 @@ export interface StorageWriter extends StorageReader {
|
|
|
194
194
|
delete<T extends StorageId>(
|
|
195
195
|
storageId: T extends { __tableName: any } ? never : T,
|
|
196
196
|
): Promise<void>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
// TODO: move `store` from StorageActionWriter to StorageWriter when mutation
|
|
202
|
+
// file storage access is ready for release
|
|
203
|
+
store(
|
|
204
|
+
blob: Blob,
|
|
205
|
+
options?: { sha256?: string },
|
|
206
|
+
): Promise<GenericId<"_storage">>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
// TODO: move `get` from StorageActionWriter to StorageWriter when mutation
|
|
212
|
+
// file storage access is ready for release
|
|
213
|
+
get(storageId: GenericId<"_storage">): Promise<Blob | null>;
|
|
197
214
|
}
|
|
198
215
|
|
|
199
216
|
/**
|
package/src/values/validators.ts
CHANGED
|
@@ -641,7 +641,7 @@ export class VRecord<
|
|
|
641
641
|
throw new Error("Record validator cannot have optional values");
|
|
642
642
|
}
|
|
643
643
|
if (!key.isConvexValidator || !value.isConvexValidator) {
|
|
644
|
-
throw new Error("Key and value of v.record()
|
|
644
|
+
throw new Error("Key and value of v.record() must be validators");
|
|
645
645
|
}
|
|
646
646
|
this.key = key;
|
|
647
647
|
this.value = value;
|
package/src/values/value.ts
CHANGED
|
@@ -311,13 +311,17 @@ const MAX_VALUE_FOR_ERROR_LEN = 16384;
|
|
|
311
311
|
export function stringifyValueForError(value: any) {
|
|
312
312
|
const str = JSON.stringify(value, (_key, value) => {
|
|
313
313
|
if (value === undefined) {
|
|
314
|
-
//
|
|
315
|
-
//
|
|
316
|
-
// We deal with `undefined` specifically because it's the most common.
|
|
317
|
-
// Ideally we'd use a pretty-printing library that prints `undefined`
|
|
318
|
-
// (no quotes), but it might not be worth the bundle size cost.
|
|
314
|
+
// JSON.stringify omits undefined object properties and converts undefined
|
|
315
|
+
// array elements to null. Preserve them in error messages.
|
|
319
316
|
return "undefined";
|
|
320
317
|
}
|
|
318
|
+
if (typeof value === "function") {
|
|
319
|
+
// A fixed placeholder also works for functions with custom string coercion.
|
|
320
|
+
return "[Function]";
|
|
321
|
+
}
|
|
322
|
+
if (typeof value === "symbol") {
|
|
323
|
+
return String(value);
|
|
324
|
+
}
|
|
321
325
|
if (typeof value === "bigint") {
|
|
322
326
|
// `JSON.stringify` throws on bigints by default.
|
|
323
327
|
return `${value.toString()}n`;
|