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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/logout.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from \"@commander-js/extra-typings\";\nimport { oneoffContext } from \"../bundler/context.js\";\nimport { logFinishedStep } from \"../bundler/log.js\";\nimport { recursivelyDelete } from \"./lib/fsUtils.js\";\nimport { globalConfigPath } from \"./lib/utils/globalConfig.js\";\n\nexport
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,
|
|
4
|
+
"sourcesContent": ["import { Command } from \"@commander-js/extra-typings\";\nimport { oneoffContext } from \"../bundler/context.js\";\nimport { logFinishedStep, logMessage, logWarning } from \"../bundler/log.js\";\nimport { recursivelyDelete } from \"./lib/fsUtils.js\";\nimport { globalConfigPath } from \"./lib/utils/globalConfig.js\";\nimport {\n getProfileSelection,\n profileConfigPath,\n readProfileToken,\n readProfileSettings,\n updateProfileSettings,\n savedProfileNames,\n} from \"./lib/profiles.js\";\nimport path from \"path\";\nimport { rootDirectory } from \"./lib/utils/utils.js\";\nimport { promptOptions } from \"./lib/utils/prompts.js\";\n\nexport function createLogoutCommand() {\n return new Command(\"logout\")\n .description(\n \"Log out of the selected account. Directory selections are preserved.\",\n )\n .option(\"--account <name>\", \"Remove only this account's saved credentials\")\n .option(\n \"--all\",\n \"Remove all saved account credentials, preserving account selections\",\n )\n .allowExcessArguments(false)\n .action(async (options, cmd) => {\n if (options.all && options.account !== undefined)\n cmd.error(\"Pass either --account or --all, not both.\");\n const ctx = await oneoffContext({\n url: undefined,\n adminKey: undefined,\n envFile: undefined,\n skipAuth: true,\n });\n\n let all = !!options.all;\n let profile = all\n ? null\n : await getProfileSelection(ctx, { name: options.account });\n if (\n !all &&\n options.account === undefined &&\n process.stdin.isTTY &&\n profile !== null\n ) {\n const token = readProfileToken(ctx, profile.name);\n const settings = await readProfileSettings(ctx);\n const selectedName = profile.name;\n // A matching compatibility token is another copy of this account's login.\n const hasOtherLogins =\n savedProfileNames(ctx).some((name) => name !== selectedName) ||\n (typeof settings.accessToken === \"string\" &&\n settings.accessToken.length > 0 &&\n settings.accessToken !== token);\n if (hasOtherLogins) {\n const scope = await promptOptions(ctx, {\n message: \"Which saved logins would you like to log out of?\",\n choices: [\n { name: `Only account \"${profile.name}\"`, value: \"profile\" },\n { name: \"All saved logins on this device\", value: \"all\" },\n ],\n default: \"profile\",\n });\n if (scope === \"all\") {\n profile = null;\n all = true;\n }\n }\n }\n\n let warnAboutLegacyCredentials = false;\n if (profile !== null) {\n const selectedName = profile.name;\n await updateProfileSettings(\n ctx,\n (settings) => {\n const token = readProfileToken(ctx, selectedName);\n // A migrated account can share its token with old CLI versions.\n if (token !== null && settings.accessToken === token) {\n delete settings.accessToken;\n } else if (\n settings.defaultProfile === selectedName &&\n typeof settings.accessToken === \"string\" &&\n settings.accessToken.length > 0\n ) {\n // Editing the default or logging in with an older CLI can leave this\n // token belonging to a different account.\n warnAboutLegacyCredentials = true;\n }\n },\n () => {\n const configPath = profileConfigPath(selectedName);\n recursivelyDelete(ctx, configPath, {\n force: true,\n followSymlinks: false,\n });\n },\n );\n } else {\n await updateProfileSettings(\n ctx,\n async (settings) => {\n if (\n !all &&\n savedProfileNames(ctx).length > 0 &&\n settings.accessToken === undefined\n ) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"No account is selected. Use `npx convex logout --account <name>` or `npx convex logout --all`.\",\n });\n }\n delete settings.accessToken;\n },\n () => {\n const profilesDir = path.join(rootDirectory(), \"profiles\");\n if (all)\n recursivelyDelete(ctx, profilesDir, {\n force: true,\n followSymlinks: false,\n });\n },\n );\n }\n\n logFinishedStep(\n profile !== null\n ? `Removed credentials for account \"${profile.name}\".\\n Run \\`npx convex login --account ${profile.name}\\` to log in.`\n : `${all ? \"Removed all saved Convex account credentials.\" : \"Removed your saved Convex login credentials.\"}\\n Run \\`npx convex login\\` to log in.`,\n );\n if (warnAboutLegacyCredentials) {\n logWarning(\n `Saved credentials remain in ${globalConfigPath()} for older CLI versions. To remove all saved account credentials, run \\`npx convex logout --all\\`.`,\n );\n }\n if (process.env.CONVEX_OVERRIDE_ACCESS_TOKEN) {\n logMessage(\n \"CONVEX_OVERRIDE_ACCESS_TOKEN still supplies credentials. Unset it to stop using that token.\",\n );\n }\n });\n}\n\nexport const logout = createLogoutCommand();\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB,YAAY,kBAAkB;AACxD,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA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AQ,IAAI,8BAA8B;AAC5C;AAAA,QACE;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACL;AAEO,aAAM,SAAS,oBAAoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/cli/mcp.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
import path from "path";
|
|
2
3
|
import { Command, Option } from "@commander-js/extra-typings";
|
|
3
4
|
import { oneoffContext } from "../bundler/context.js";
|
|
4
5
|
import { logError } from "../bundler/log.js";
|
|
@@ -7,6 +8,7 @@ import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
|
7
8
|
import { actionDescription } from "./lib/command.js";
|
|
8
9
|
import { checkAuthorization } from "./lib/login.js";
|
|
9
10
|
import {
|
|
11
|
+
encodeDeploymentSelector,
|
|
10
12
|
RequestContext,
|
|
11
13
|
RequestCrash
|
|
12
14
|
} from "./lib/mcp/requestContext.js";
|
|
@@ -79,6 +81,11 @@ function enabledTools(options) {
|
|
|
79
81
|
export function makeServer(options) {
|
|
80
82
|
const enabledToolsByName = enabledTools(options);
|
|
81
83
|
const mutex = new Mutex();
|
|
84
|
+
const serverDirectory = process.cwd();
|
|
85
|
+
options = {
|
|
86
|
+
...options,
|
|
87
|
+
envFile: options.envFile === void 0 ? void 0 : path.resolve(serverDirectory, options.envFile)
|
|
88
|
+
};
|
|
82
89
|
const server = new Server(
|
|
83
90
|
{
|
|
84
91
|
name: "Convex MCP Server",
|
|
@@ -92,16 +99,7 @@ export function makeServer(options) {
|
|
|
92
99
|
);
|
|
93
100
|
server.setRequestHandler("tools/call", async (request) => {
|
|
94
101
|
const ctx = new RequestContext(options);
|
|
95
|
-
await initializeBigBrainAuth(ctx, options);
|
|
96
102
|
try {
|
|
97
|
-
const authorized = await checkAuthorization(ctx, false);
|
|
98
|
-
if (!authorized) {
|
|
99
|
-
await ctx.crash({
|
|
100
|
-
exitCode: 1,
|
|
101
|
-
errorType: "fatal",
|
|
102
|
-
printedMessage: "Not Authorized: Run `npx convex dev` to login to your Convex project."
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
103
|
if (!request.params.arguments) {
|
|
106
104
|
await ctx.crash({
|
|
107
105
|
exitCode: 1,
|
|
@@ -119,7 +117,33 @@ export function makeServer(options) {
|
|
|
119
117
|
}
|
|
120
118
|
const input = convexTool.inputSchema.parse(request.params.arguments);
|
|
121
119
|
const result = await mutex.runExclusive(async () => {
|
|
122
|
-
|
|
120
|
+
const projectDir = "deploymentSelector" in input ? ctx.decodeDeploymentSelectorUnchecked(input.deploymentSelector).projectDir : ("projectDir" in input ? input.projectDir : void 0) ?? options.projectDir;
|
|
121
|
+
const previousDirectory = process.cwd();
|
|
122
|
+
try {
|
|
123
|
+
if (projectDir !== void 0)
|
|
124
|
+
process.chdir(path.resolve(serverDirectory, projectDir));
|
|
125
|
+
await initializeBigBrainAuth(ctx, options);
|
|
126
|
+
if (!await checkAuthorization(ctx, false)) {
|
|
127
|
+
await ctx.crash({
|
|
128
|
+
exitCode: 1,
|
|
129
|
+
errorType: "fatal",
|
|
130
|
+
printedMessage: "Not Authorized: Run `npx convex dev` to login to your Convex project."
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const absoluteDirectory = process.cwd();
|
|
134
|
+
const resolvedInput = "deploymentSelector" in input ? {
|
|
135
|
+
...input,
|
|
136
|
+
deploymentSelector: encodeDeploymentSelector(
|
|
137
|
+
absoluteDirectory,
|
|
138
|
+
ctx.decodeDeploymentSelectorUnchecked(
|
|
139
|
+
input.deploymentSelector
|
|
140
|
+
).deployment
|
|
141
|
+
)
|
|
142
|
+
} : projectDir === void 0 ? input : { ...input, projectDir: absoluteDirectory };
|
|
143
|
+
return await convexTool.handler(ctx, resolvedInput);
|
|
144
|
+
} finally {
|
|
145
|
+
process.chdir(previousDirectory);
|
|
146
|
+
}
|
|
123
147
|
});
|
|
124
148
|
return {
|
|
125
149
|
content: [
|
package/dist/esm/cli/mcp.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/mcp.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command, Option } from \"@commander-js/extra-typings\";\nimport { oneoffContext } from \"../bundler/context.js\";\nimport { logError } from \"../bundler/log.js\";\nimport { CallToolRequest, Server } from \"@modelcontextprotocol/server\";\nimport { serveStdio } from \"@modelcontextprotocol/server/stdio\";\nimport { actionDescription } from \"./lib/command.js\";\nimport { checkAuthorization } from \"./lib/login.js\";\nimport {\n McpOptions,\n RequestContext,\n RequestCrash,\n} from \"./lib/mcp/requestContext.js\";\nimport { mcpTool, convexTools, ConvexTool } from \"./lib/mcp/tools/index.js\";\nimport { Mutex } from \"./lib/utils/mutex.js\";\nimport { initializeBigBrainAuth } from \"./lib/deploymentSelection.js\";\n\nconst allToolNames = convexTools.map((t) => t.name).sort();\n\nexport const mcp = new Command(\"mcp\")\n .summary(\"Manage the Model Context Protocol server for Convex [BETA]\")\n .description(\n \"Commands to initialize and run a Model Context Protocol server for Convex that can be used with AI tools.\\n\" +\n \"This server exposes your Convex codebase to AI tools in a structured way.\",\n )\n .allowExcessArguments(false);\n\nmcp\n .command(\"start\")\n .summary(\"Start the MCP server\")\n .description(\n \"Start the Model Context Protocol server for Convex that can be used with AI tools.\",\n )\n .option(\n \"--project-dir <project-dir>\",\n \"Run the MCP server for a single project. By default, the MCP server can run for multiple projects, and each tool call specifies its project directory.\",\n )\n .option(\n \"--disable-tools <tool-names>\",\n `Comma separated list of tool names to disable (options: ${allToolNames.join(\", \")})`,\n )\n .option(\n \"--cautiously-allow-production-pii\",\n \"Allow read-only tools (data, logs, queries) on production deployments. These tools may expose PII. Defaults to false.\",\n false,\n )\n .option(\n \"--dangerously-enable-production-deployments\",\n \"DANGEROUSLY allow the MCP server to access production deployments, including mutating tools. Defaults to false.\",\n false,\n )\n // Deprecated option, we swapped the default. no-op.\n .addOption(\n new Option(\"--disable-production-deployments\")\n .conflicts(\"--dangerously-enable-production-deployments\")\n .hideHelp(),\n )\n .addDeploymentSelectionOptions(actionDescription(\"Run the MCP server on\"))\n .action(async (options) => {\n const ctx = await oneoffContext(options);\n try {\n // `serveStdio` only calls the factory once a client connects, and answers\n // a factory throw with an opaque `-32603`, so reject a bad\n // `--disable-tools` here instead.\n enabledTools(options);\n } catch (error: any) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n errForSentry: `Failed to start MCP server: ${error}`,\n printedMessage: `Failed to start MCP server: ${error}`,\n });\n }\n // The SDK picks the era from the client's opening message: a request\n // carrying the 2026-07-28 `_meta` envelope pins a stateless connection,\n // while an `initialize` is still served by the same factory over the legacy\n // protocol.\n // The returned handle's `close()` is intentionally never called: the\n // server lives until the client kills the process, and process exit tears\n // the transport down.\n serveStdio(() => makeServer(options), {\n legacy: \"serve\",\n // The only channel for out-of-band failures (transport errors, dropped\n // malformed notifications). stdout carries the protocol, so they go to\n // stderr.\n onerror: (error) => logError(`MCP server error: ${error.message}`),\n });\n // Keep the process running\n await new Promise(() => {});\n });\n\nfunction enabledTools(\n options: McpOptions,\n): Record<string, ConvexTool<any, any>> {\n const disabledToolNames = new Set<string>();\n for (const toolName of options.disableTools?.split(\",\") ?? []) {\n const name = toolName.trim();\n if (!allToolNames.includes(name)) {\n // eslint-disable-next-line no-restricted-syntax\n throw new Error(\n `Disabled tool ${name} not found (valid tools: ${allToolNames.join(\", \")})`,\n );\n }\n disabledToolNames.add(name);\n }\n\n const enabledToolsByName: Record<string, ConvexTool<any, any>> = {};\n for (const tool of convexTools) {\n if (!disabledToolNames.has(tool.name)) {\n enabledToolsByName[tool.name] = tool;\n }\n }\n return enabledToolsByName;\n}\n\nexport function makeServer(options: McpOptions) {\n const enabledToolsByName = enabledTools(options);\n const mutex = new Mutex();\n const server = new Server(\n {\n name: \"Convex MCP Server\",\n version: \"0.0.1\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n server.setRequestHandler(\"tools/call\", async (request: CallToolRequest) => {\n const ctx = new RequestContext(options);\n
|
|
5
|
-
"mappings": ";AAAA,SAAS,SAAS,cAAc;AAChC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAA0B,cAAc;AACxC,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC;AAAA,
|
|
4
|
+
"sourcesContent": ["import path from \"path\";\nimport { Command, Option } from \"@commander-js/extra-typings\";\nimport { oneoffContext } from \"../bundler/context.js\";\nimport { logError } from \"../bundler/log.js\";\nimport { CallToolRequest, Server } from \"@modelcontextprotocol/server\";\nimport { serveStdio } from \"@modelcontextprotocol/server/stdio\";\nimport { actionDescription } from \"./lib/command.js\";\nimport { checkAuthorization } from \"./lib/login.js\";\nimport {\n encodeDeploymentSelector,\n McpOptions,\n RequestContext,\n RequestCrash,\n} from \"./lib/mcp/requestContext.js\";\nimport { mcpTool, convexTools, ConvexTool } from \"./lib/mcp/tools/index.js\";\nimport { Mutex } from \"./lib/utils/mutex.js\";\nimport { initializeBigBrainAuth } from \"./lib/deploymentSelection.js\";\n\nconst allToolNames = convexTools.map((t) => t.name).sort();\n\nexport const mcp = new Command(\"mcp\")\n .summary(\"Manage the Model Context Protocol server for Convex [BETA]\")\n .description(\n \"Commands to initialize and run a Model Context Protocol server for Convex that can be used with AI tools.\\n\" +\n \"This server exposes your Convex codebase to AI tools in a structured way.\",\n )\n .allowExcessArguments(false);\n\nmcp\n .command(\"start\")\n .summary(\"Start the MCP server\")\n .description(\n \"Start the Model Context Protocol server for Convex that can be used with AI tools.\",\n )\n .option(\n \"--project-dir <project-dir>\",\n \"Run the MCP server for a single project. By default, the MCP server can run for multiple projects, and each tool call specifies its project directory.\",\n )\n .option(\n \"--disable-tools <tool-names>\",\n `Comma separated list of tool names to disable (options: ${allToolNames.join(\", \")})`,\n )\n .option(\n \"--cautiously-allow-production-pii\",\n \"Allow read-only tools (data, logs, queries) on production deployments. These tools may expose PII. Defaults to false.\",\n false,\n )\n .option(\n \"--dangerously-enable-production-deployments\",\n \"DANGEROUSLY allow the MCP server to access production deployments, including mutating tools. Defaults to false.\",\n false,\n )\n // Deprecated option, we swapped the default. no-op.\n .addOption(\n new Option(\"--disable-production-deployments\")\n .conflicts(\"--dangerously-enable-production-deployments\")\n .hideHelp(),\n )\n .addDeploymentSelectionOptions(actionDescription(\"Run the MCP server on\"))\n .action(async (options) => {\n const ctx = await oneoffContext(options);\n try {\n // `serveStdio` only calls the factory once a client connects, and answers\n // a factory throw with an opaque `-32603`, so reject a bad\n // `--disable-tools` here instead.\n enabledTools(options);\n } catch (error: any) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n errForSentry: `Failed to start MCP server: ${error}`,\n printedMessage: `Failed to start MCP server: ${error}`,\n });\n }\n // The SDK picks the era from the client's opening message: a request\n // carrying the 2026-07-28 `_meta` envelope pins a stateless connection,\n // while an `initialize` is still served by the same factory over the legacy\n // protocol.\n // The returned handle's `close()` is intentionally never called: the\n // server lives until the client kills the process, and process exit tears\n // the transport down.\n serveStdio(() => makeServer(options), {\n legacy: \"serve\",\n // The only channel for out-of-band failures (transport errors, dropped\n // malformed notifications). stdout carries the protocol, so they go to\n // stderr.\n onerror: (error) => logError(`MCP server error: ${error.message}`),\n });\n // Keep the process running\n await new Promise(() => {});\n });\n\nfunction enabledTools(\n options: McpOptions,\n): Record<string, ConvexTool<any, any>> {\n const disabledToolNames = new Set<string>();\n for (const toolName of options.disableTools?.split(\",\") ?? []) {\n const name = toolName.trim();\n if (!allToolNames.includes(name)) {\n // eslint-disable-next-line no-restricted-syntax\n throw new Error(\n `Disabled tool ${name} not found (valid tools: ${allToolNames.join(\", \")})`,\n );\n }\n disabledToolNames.add(name);\n }\n\n const enabledToolsByName: Record<string, ConvexTool<any, any>> = {};\n for (const tool of convexTools) {\n if (!disabledToolNames.has(tool.name)) {\n enabledToolsByName[tool.name] = tool;\n }\n }\n return enabledToolsByName;\n}\n\nexport function makeServer(options: McpOptions) {\n const enabledToolsByName = enabledTools(options);\n const mutex = new Mutex();\n const serverDirectory = process.cwd();\n options = {\n ...options,\n envFile:\n options.envFile === undefined\n ? undefined\n : path.resolve(serverDirectory, options.envFile),\n };\n const server = new Server(\n {\n name: \"Convex MCP Server\",\n version: \"0.0.1\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n server.setRequestHandler(\"tools/call\", async (request: CallToolRequest) => {\n const ctx = new RequestContext(options);\n try {\n if (!request.params.arguments) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: \"No arguments provided\",\n });\n }\n const convexTool = enabledToolsByName[request.params.name];\n if (!convexTool) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage: `Tool ${request.params.name} not found`,\n });\n }\n const input = convexTool.inputSchema.parse(request.params.arguments);\n\n // Serialize tool handlers since they're mutating the current working directory.\n const result = await mutex.runExclusive(async () => {\n const projectDir =\n \"deploymentSelector\" in input\n ? ctx.decodeDeploymentSelectorUnchecked(input.deploymentSelector)\n .projectDir\n : ((\"projectDir\" in input ? input.projectDir : undefined) ??\n options.projectDir);\n const previousDirectory = process.cwd();\n try {\n if (projectDir !== undefined)\n process.chdir(path.resolve(serverDirectory, projectDir));\n await initializeBigBrainAuth(ctx, options);\n if (!(await checkAuthorization(ctx, false))) {\n await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"Not Authorized: Run `npx convex dev` to login to your Convex project.\",\n });\n }\n const absoluteDirectory = process.cwd();\n const resolvedInput =\n \"deploymentSelector\" in input\n ? {\n ...input,\n deploymentSelector: encodeDeploymentSelector(\n absoluteDirectory,\n ctx.decodeDeploymentSelectorUnchecked(\n input.deploymentSelector,\n ).deployment,\n ),\n }\n : projectDir === undefined\n ? input\n : { ...input, projectDir: absoluteDirectory };\n return await convexTool.handler(ctx, resolvedInput);\n } finally {\n process.chdir(previousDirectory);\n }\n });\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result),\n },\n ],\n };\n } catch (error: any) {\n let message: string;\n if (error instanceof RequestCrash) {\n message = error.printedMessage;\n } else if (error instanceof Error) {\n message = error.message;\n } else {\n message = String(error);\n }\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify({ error: message }),\n },\n ],\n isError: true,\n };\n }\n });\n server.setRequestHandler(\"tools/list\", async () => {\n return {\n tools: Object.values(enabledToolsByName).map(mcpTool),\n };\n });\n return server;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,SAAS,cAAc;AAChC,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAA0B,cAAc;AACxC,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,mBAA+B;AACjD,SAAS,aAAa;AACtB,SAAS,8BAA8B;AAEvC,MAAM,eAAe,YAAY,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK;AAElD,aAAM,MAAM,IAAI,QAAQ,KAAK,EACjC,QAAQ,4DAA4D,EACpE;AAAA,EACC;AAEF,EACC,qBAAqB,KAAK;AAE7B,IACG,QAAQ,OAAO,EACf,QAAQ,sBAAsB,EAC9B;AAAA,EACC;AACF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA,2DAA2D,aAAa,KAAK,IAAI,CAAC;AACpF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACF,EACC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACF,EAEC;AAAA,EACC,IAAI,OAAO,kCAAkC,EAC1C,UAAU,6CAA6C,EACvD,SAAS;AACd,EACC,8BAA8B,kBAAkB,uBAAuB,CAAC,EACxE,OAAO,OAAO,YAAY;AACzB,QAAM,MAAM,MAAM,cAAc,OAAO;AACvC,MAAI;AAIF,iBAAa,OAAO;AAAA,EACtB,SAAS,OAA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YAAY,kBAAkB;AAClD,iBAAO,MAAM,WAAW,QAAQ,KAAK,aAAa;AAAA,QACpD,UAAE;AACA,kBAAQ,MAAM,iBAAiB;AAAA,QACjC;AAAA,MACF,CAAC;AACD,aAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,KAAK,UAAU,MAAM;AAAA,UAC7B;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAY;AACnB,UAAI;AACJ,UAAI,iBAAiB,cAAc;AACjC,kBAAU,MAAM;AAAA,MAClB,WAAW,iBAAiB,OAAO;AACjC,kBAAU,MAAM;AAAA,MAClB,OAAO;AACL,kBAAU,OAAO,KAAK;AAAA,MACxB;AACA,aAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,KAAK,UAAU,EAAE,OAAO,QAAQ,CAAC;AAAA,UACzC;AAAA,QACF;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AACD,SAAO,kBAAkB,cAAc,YAAY;AACjD,WAAO;AAAA,MACL,OAAO,OAAO,OAAO,kBAAkB,EAAE,IAAI,OAAO;AAAA,IACtD;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/cli/program.js
CHANGED
|
@@ -22,6 +22,7 @@ import { logout } from "./logout.js";
|
|
|
22
22
|
import { logs } from "./logs.js";
|
|
23
23
|
import { mcp } from "./mcp.js";
|
|
24
24
|
import { networkTest } from "./network_test.js";
|
|
25
|
+
import { account } from "./account.js";
|
|
25
26
|
import { project } from "./project.js";
|
|
26
27
|
import { reinit } from "./reinit.js";
|
|
27
28
|
import { run } from "./run.js";
|
|
@@ -30,6 +31,6 @@ import { update } from "./update.js";
|
|
|
30
31
|
import { version } from "./version.js";
|
|
31
32
|
export function buildProgram() {
|
|
32
33
|
const program = new Command();
|
|
33
|
-
return program.name("convex").usage("<command> [options]").description("Start developing with Convex by running `npx convex dev`.").addCommand(login, { hidden: true }).addCommand(init, { hidden: true }).addCommand(reinit, { hidden: true }).addCommand(dev).addCommand(deploy).addCommand(deployments, { hidden: true }).addCommand(run).addCommand(convexImport).addCommand(dashboard).addCommand(docs).addCommand(logs).addCommand(typecheck, { hidden: true }).addCommand(auth, { hidden: true }).addCommand(convexExport).addCommand(env).addCommand(data).addCommand(deployment).addCommand(project).addCommand(codegen).addCommand(update).addCommand(logout).addCommand(networkTest, { hidden: true }).addCommand(integration, { hidden: true }).addCommand(functionSpec).addCommand(insights).addCommand(mcp).addCommand(aiFiles).helpCommand("help <command>", "Show help for given <command>").version(version).configureHelp({ visibleOptions: () => [] }).showHelpAfterError();
|
|
34
|
+
return program.name("convex").usage("<command> [options]").description("Start developing with Convex by running `npx convex dev`.").addCommand(login, { hidden: true }).addCommand(init, { hidden: true }).addCommand(reinit, { hidden: true }).addCommand(dev).addCommand(deploy).addCommand(deployments, { hidden: true }).addCommand(run).addCommand(convexImport).addCommand(dashboard).addCommand(docs).addCommand(logs).addCommand(typecheck, { hidden: true }).addCommand(auth, { hidden: true }).addCommand(convexExport).addCommand(env).addCommand(data).addCommand(deployment).addCommand(project).addCommand(codegen).addCommand(update).addCommand(logout).addCommand(account).addCommand(networkTest, { hidden: true }).addCommand(integration, { hidden: true }).addCommand(functionSpec).addCommand(insights).addCommand(mcp).addCommand(aiFiles).helpCommand("help <command>", "Show help for given <command>").version(version).configureHelp({ visibleOptions: () => [] }).showHelpAfterError();
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=program.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/program.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from \"@commander-js/extra-typings\";\nimport { aiFiles } from \"./aiFiles.js\";\nimport { auth } from \"./auth.js\";\nimport { codegen } from \"./codegen.js\";\nimport { convexExport } from \"./convexExport.js\";\nimport { convexImport } from \"./convexImport.js\";\nimport { dashboard } from \"./dashboard.js\";\nimport { data } from \"./data.js\";\nimport { deploy } from \"./deploy.js\";\nimport { deployment } from \"./deployment.js\";\nimport { deployments } from \"./deployments.js\";\nimport { dev } from \"./dev.js\";\nimport { docs } from \"./docs.js\";\nimport { env } from \"./env.js\";\nimport { functionSpec } from \"./functionSpec.js\";\nimport { init } from \"./init.js\";\nimport { insights } from \"./insights.js\";\nimport { integration } from \"./integration.js\";\nimport { login } from \"./login.js\";\nimport { logout } from \"./logout.js\";\nimport { logs } from \"./logs.js\";\nimport { mcp } from \"./mcp.js\";\nimport { networkTest } from \"./network_test.js\";\nimport { project } from \"./project.js\";\nimport { reinit } from \"./reinit.js\";\nimport { run } from \"./run.js\";\nimport { typecheck } from \"./typecheck.js\";\nimport { update } from \"./update.js\";\nimport { version } from \"./version.js\";\n\nexport function buildProgram() {\n const program = new Command();\n return (\n program\n .name(\"convex\")\n .usage(\"<command> [options]\")\n .description(\"Start developing with Convex by running `npx convex dev`.\")\n .addCommand(login, { hidden: true })\n .addCommand(init, { hidden: true })\n .addCommand(reinit, { hidden: true })\n .addCommand(dev)\n .addCommand(deploy)\n .addCommand(deployments, { hidden: true })\n .addCommand(run)\n .addCommand(convexImport)\n .addCommand(dashboard)\n .addCommand(docs)\n .addCommand(logs)\n .addCommand(typecheck, { hidden: true })\n .addCommand(auth, { hidden: true })\n .addCommand(convexExport)\n .addCommand(env)\n .addCommand(data)\n .addCommand(deployment)\n .addCommand(project)\n .addCommand(codegen)\n .addCommand(update)\n .addCommand(logout)\n .addCommand(networkTest, { hidden: true })\n .addCommand(integration, { hidden: true })\n .addCommand(functionSpec)\n .addCommand(insights)\n .addCommand(mcp)\n .addCommand(aiFiles)\n .helpCommand(\"help <command>\", \"Show help for given <command>\")\n .version(version)\n // Hide version and help so they don't clutter\n // the list of commands.\n .configureHelp({ visibleOptions: () => [] })\n .showHelpAfterError()\n );\n}\n"],
|
|
5
|
-
"mappings": ";AA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Q,KAAK,CAAC,EACxC,WAAW,aAAa,EAAE,QAAQ,KAAK,CAAC,EACxC,WAAW,YAAY,EACvB,WAAW,QAAQ,EACnB,WAAW,GAAG,EACd,WAAW,OAAO,EAClB,YAAY,kBAAkB,+BAA+B,EAC7D,QAAQ,OAAO,EAGf,cAAc,EAAE,gBAAgB,MAAM,CAAC,EAAE,CAAC,EAC1C,mBAAmB;AAE1B;",
|
|
4
|
+
"sourcesContent": ["import { Command } from \"@commander-js/extra-typings\";\nimport { aiFiles } from \"./aiFiles.js\";\nimport { auth } from \"./auth.js\";\nimport { codegen } from \"./codegen.js\";\nimport { convexExport } from \"./convexExport.js\";\nimport { convexImport } from \"./convexImport.js\";\nimport { dashboard } from \"./dashboard.js\";\nimport { data } from \"./data.js\";\nimport { deploy } from \"./deploy.js\";\nimport { deployment } from \"./deployment.js\";\nimport { deployments } from \"./deployments.js\";\nimport { dev } from \"./dev.js\";\nimport { docs } from \"./docs.js\";\nimport { env } from \"./env.js\";\nimport { functionSpec } from \"./functionSpec.js\";\nimport { init } from \"./init.js\";\nimport { insights } from \"./insights.js\";\nimport { integration } from \"./integration.js\";\nimport { login } from \"./login.js\";\nimport { logout } from \"./logout.js\";\nimport { logs } from \"./logs.js\";\nimport { mcp } from \"./mcp.js\";\nimport { networkTest } from \"./network_test.js\";\nimport { account } from \"./account.js\";\nimport { project } from \"./project.js\";\nimport { reinit } from \"./reinit.js\";\nimport { run } from \"./run.js\";\nimport { typecheck } from \"./typecheck.js\";\nimport { update } from \"./update.js\";\nimport { version } from \"./version.js\";\n\nexport function buildProgram() {\n const program = new Command();\n return (\n program\n .name(\"convex\")\n .usage(\"<command> [options]\")\n .description(\"Start developing with Convex by running `npx convex dev`.\")\n .addCommand(login, { hidden: true })\n .addCommand(init, { hidden: true })\n .addCommand(reinit, { hidden: true })\n .addCommand(dev)\n .addCommand(deploy)\n .addCommand(deployments, { hidden: true })\n .addCommand(run)\n .addCommand(convexImport)\n .addCommand(dashboard)\n .addCommand(docs)\n .addCommand(logs)\n .addCommand(typecheck, { hidden: true })\n .addCommand(auth, { hidden: true })\n .addCommand(convexExport)\n .addCommand(env)\n .addCommand(data)\n .addCommand(deployment)\n .addCommand(project)\n .addCommand(codegen)\n .addCommand(update)\n .addCommand(logout)\n .addCommand(account)\n .addCommand(networkTest, { hidden: true })\n .addCommand(integration, { hidden: true })\n .addCommand(functionSpec)\n .addCommand(insights)\n .addCommand(mcp)\n .addCommand(aiFiles)\n .helpCommand(\"help <command>\", \"Show help for given <command>\")\n .version(version)\n // Hide version and help so they don't clutter\n // the list of commands.\n .configureHelp({ visibleOptions: () => [] })\n .showHelpAfterError()\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,WAAW;AACpB,SAAS,YAAY;AACrB,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,WAAW;AACpB,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,eAAe;AAEjB,gBAAS,eAAe;AAC7B,QAAM,UAAU,IAAI,QAAQ;AAC5B,SACE,QACG,KAAK,QAAQ,EACb,MAAM,qBAAqB,EAC3B,YAAY,2DAA2D,EACvE,WAAW,OAAO,EAAE,QAAQ,KAAK,CAAC,EAClC,WAAW,MAAM,EAAE,QAAQ,KAAK,CAAC,EACjC,WAAW,QAAQ,EAAE,QAAQ,KAAK,CAAC,EACnC,WAAW,GAAG,EACd,WAAW,MAAM,EACjB,WAAW,aAAa,EAAE,QAAQ,KAAK,CAAC,EACxC,WAAW,GAAG,EACd,WAAW,YAAY,EACvB,WAAW,SAAS,EACpB,WAAW,IAAI,EACf,WAAW,IAAI,EACf,WAAW,WAAW,EAAE,QAAQ,KAAK,CAAC,EACtC,WAAW,MAAM,EAAE,QAAQ,KAAK,CAAC,EACjC,WAAW,YAAY,EACvB,WAAW,GAAG,EACd,WAAW,IAAI,EACf,WAAW,UAAU,EACrB,WAAW,OAAO,EAClB,WAAW,OAAO,EAClB,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,WAAW,OAAO,EAClB,WAAW,aAAa,EAAE,QAAQ,KAAK,CAAC,EACxC,WAAW,aAAa,EAAE,QAAQ,KAAK,CAAC,EACxC,WAAW,YAAY,EACvB,WAAW,QAAQ,EACnB,WAAW,GAAG,EACd,WAAW,OAAO,EAClB,YAAY,kBAAkB,+BAA+B,EAC7D,QAAQ,OAAO,EAGf,cAAc,EAAE,gBAAgB,MAAM,CAAC,EAAE,CAAC,EAC1C,mBAAmB;AAE1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -42,7 +42,7 @@ async function runProjectCreate(nameArg, options) {
|
|
|
42
42
|
);
|
|
43
43
|
logMessage(
|
|
44
44
|
chalkStderr.gray(
|
|
45
|
-
`Next, add a deployment with \`npx convex deployment create ${team.slug}:${projectSlug}:dev --type dev\` (pass \`--region us\` to choose a region).`
|
|
45
|
+
`Next, add a deployment with \`npx convex deployment create ${team.slug}:${projectSlug}:dev/my-feature --type dev --select\` (pass \`--region us\` to choose a region).`
|
|
46
46
|
)
|
|
47
47
|
);
|
|
48
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/projectCreate.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command, Option } from \"@commander-js/extra-typings\";\nimport { oneoffContext } from \"../bundler/context.js\";\nimport { logFinishedStep, logMessage, showSpinner } from \"../bundler/log.js\";\nimport { chalkStderr } from \"chalk\";\nimport { createProject } from \"./lib/api.js\";\nimport { ensureAuthCanCreateDeployment } from \"./lib/deploymentSelection.js\";\nimport { validateOrSelectTeam } from \"./lib/utils/utils.js\";\nimport { promptString } from \"./lib/utils/prompts.js\";\nimport { projectDashboardUrl } from \"./lib/dashboard.js\";\n\ntype ProjectCreateOptions = {\n team?: string | undefined;\n};\n\nasync function runProjectCreate(\n nameArg: string | undefined,\n options: ProjectCreateOptions,\n): Promise<void> {\n const ctx = await oneoffContext({\n url: undefined,\n adminKey: undefined,\n envFile: undefined,\n });\n\n // Creating a project goes through the platform API, which accepts personal\n // access tokens and project keys but not deployment/preview deploy keys.\n // Fail fast (and clearly) for the unsupported keys rather than surfacing an\n // opaque error later.\n await ensureAuthCanCreateDeployment(ctx);\n\n const { team } = await validateOrSelectTeam(ctx, options.team, \"Team:\");\n\n let projectName = nameArg;\n if (!projectName) {\n if (!process.stdin.isTTY) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"Specify a project name:\\n\" + \" `npx convex project create my-app`\",\n });\n }\n projectName = await promptString(ctx, {\n message: \"Project name:\",\n });\n }\n\n showSpinner(`Creating project ${projectName}...`);\n // `project create` only creates the project. Provisioning a deployment is a\n // separate, explicit step (`npx convex deployment create`) so this command\n // doesn't have to mirror every deployment setting (region, class, ...).\n const { projectSlug } = await createProject(ctx, {\n teamId: team.id,\n projectName,\n deploymentToProvision: null,\n });\n\n logFinishedStep(\n `Created project ${chalkStderr.bold(projectSlug)} in team ` +\n `${chalkStderr.bold(team.slug)}, manage it at ${chalkStderr.bold(\n projectDashboardUrl(team.slug, projectSlug),\n )}`,\n );\n logMessage(\n chalkStderr.gray(\n `Next, add a deployment with ` +\n `\\`npx convex deployment create ${team.slug}:${projectSlug}:dev --type dev\\` ` +\n `(pass \\`--region us\\` to choose a region).`,\n ),\n );\n}\n\nexport const projectCreate = new Command(\"create\")\n .summary(\"Create a new project\")\n .description(\n [\n \"Create a new project.\",\n \"\",\n \"Provisioning a deployment is a separate step \u2014 after creating the\",\n \"project, run `npx convex deployment create` to add one.\",\n \"\",\n \"\u2022 Create a project in your only team: `npx convex project create my-app`\",\n \"\u2022 Pick the team: `npx convex project create my-app --team my-team`\",\n ].join(\"\\n\"),\n )\n .allowExcessArguments(false)\n .argument(\n \"[name]\",\n \"The name of the new project. Prompted for when omitted in an \" +\n \"interactive terminal; required otherwise.\",\n )\n .addOption(\n new Option(\n \"--team <team_slug>\",\n \"The team to create the project in. Defaults to your only team, or \" +\n \"prompts when you belong to several.\",\n ),\n )\n .action(runProjectCreate);\n"],
|
|
4
|
+
"sourcesContent": ["import { Command, Option } from \"@commander-js/extra-typings\";\nimport { oneoffContext } from \"../bundler/context.js\";\nimport { logFinishedStep, logMessage, showSpinner } from \"../bundler/log.js\";\nimport { chalkStderr } from \"chalk\";\nimport { createProject } from \"./lib/api.js\";\nimport { ensureAuthCanCreateDeployment } from \"./lib/deploymentSelection.js\";\nimport { validateOrSelectTeam } from \"./lib/utils/utils.js\";\nimport { promptString } from \"./lib/utils/prompts.js\";\nimport { projectDashboardUrl } from \"./lib/dashboard.js\";\n\ntype ProjectCreateOptions = {\n team?: string | undefined;\n};\n\nasync function runProjectCreate(\n nameArg: string | undefined,\n options: ProjectCreateOptions,\n): Promise<void> {\n const ctx = await oneoffContext({\n url: undefined,\n adminKey: undefined,\n envFile: undefined,\n });\n\n // Creating a project goes through the platform API, which accepts personal\n // access tokens and project keys but not deployment/preview deploy keys.\n // Fail fast (and clearly) for the unsupported keys rather than surfacing an\n // opaque error later.\n await ensureAuthCanCreateDeployment(ctx);\n\n const { team } = await validateOrSelectTeam(ctx, options.team, \"Team:\");\n\n let projectName = nameArg;\n if (!projectName) {\n if (!process.stdin.isTTY) {\n return await ctx.crash({\n exitCode: 1,\n errorType: \"fatal\",\n printedMessage:\n \"Specify a project name:\\n\" + \" `npx convex project create my-app`\",\n });\n }\n projectName = await promptString(ctx, {\n message: \"Project name:\",\n });\n }\n\n showSpinner(`Creating project ${projectName}...`);\n // `project create` only creates the project. Provisioning a deployment is a\n // separate, explicit step (`npx convex deployment create`) so this command\n // doesn't have to mirror every deployment setting (region, class, ...).\n const { projectSlug } = await createProject(ctx, {\n teamId: team.id,\n projectName,\n deploymentToProvision: null,\n });\n\n logFinishedStep(\n `Created project ${chalkStderr.bold(projectSlug)} in team ` +\n `${chalkStderr.bold(team.slug)}, manage it at ${chalkStderr.bold(\n projectDashboardUrl(team.slug, projectSlug),\n )}`,\n );\n logMessage(\n chalkStderr.gray(\n `Next, add a deployment with ` +\n `\\`npx convex deployment create ${team.slug}:${projectSlug}:dev/my-feature --type dev --select\\` ` +\n `(pass \\`--region us\\` to choose a region).`,\n ),\n );\n}\n\nexport const projectCreate = new Command(\"create\")\n .summary(\"Create a new project\")\n .description(\n [\n \"Create a new project.\",\n \"\",\n \"Provisioning a deployment is a separate step \u2014 after creating the\",\n \"project, run `npx convex deployment create` to add one.\",\n \"\",\n \"\u2022 Create a project in your only team: `npx convex project create my-app`\",\n \"\u2022 Pick the team: `npx convex project create my-app --team my-team`\",\n ].join(\"\\n\"),\n )\n .allowExcessArguments(false)\n .argument(\n \"[name]\",\n \"The name of the new project. Prompted for when omitted in an \" +\n \"interactive terminal; required otherwise.\",\n )\n .addOption(\n new Option(\n \"--team <team_slug>\",\n \"The team to create the project in. Defaults to your only team, or \" +\n \"prompts when you belong to several.\",\n ),\n )\n .action(runProjectCreate);\n"],
|
|
5
5
|
"mappings": ";AAAA,SAAS,SAAS,cAAc;AAChC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB,YAAY,mBAAmB;AACzD,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,qCAAqC;AAC9C,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B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AgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -41,12 +41,16 @@ export function setupActionCalls(requestId) {
|
|
|
41
41
|
}
|
|
42
42
|
export async function getServiceToken(service) {
|
|
43
43
|
validateArg(service, 1, "getServiceToken", "service");
|
|
44
|
-
if (service !== "ai-gateway") {
|
|
45
|
-
throw new Error(`Unsupported service "${String(service)}"`);
|
|
46
|
-
}
|
|
47
44
|
return await performAsyncSyscall("1.0/createServiceToken", {
|
|
48
45
|
service,
|
|
49
46
|
version
|
|
50
47
|
});
|
|
51
48
|
}
|
|
49
|
+
export async function getServiceUrl(service) {
|
|
50
|
+
validateArg(service, 1, "getServiceUrl", "service");
|
|
51
|
+
return await performAsyncSyscall("1.0/getServiceUrl", {
|
|
52
|
+
service,
|
|
53
|
+
version
|
|
54
|
+
});
|
|
55
|
+
}
|
|
52
56
|
//# sourceMappingURL=actions_impl.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/server/impl/actions_impl.ts"],
|
|
4
|
-
"sourcesContent": ["import { convexToJson, jsonToConvex, Value } from \"../../values/index.js\";\nimport { version } from \"../../index.js\";\nimport { performAsyncSyscall } from \"./syscall.js\";\nimport { parseArgs } from \"../../common/index.js\";\nimport {\n FunctionReference,\n FunctionReference_future,\n} from \"../../server/api.js\";\nimport { getFunctionAddress } from \"../components/paths.js\";\nimport { validateArg } from \"./validate.js\";\n\nfunction syscallArgs(\n requestId: string,\n functionReference: any,\n args?: Record<string, Value>,\n) {\n const address = getFunctionAddress(functionReference);\n return {\n ...address,\n args: convexToJson(parseArgs(args)),\n version,\n requestId,\n };\n}\n\nexport function setupActionCalls(requestId: string) {\n return {\n runQuery: async (\n query:\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n args?: Record<string, Value>,\n ): Promise<any> => {\n const result = await performAsyncSyscall(\n \"1.0/actions/query\",\n syscallArgs(requestId, query, args),\n );\n return jsonToConvex(result);\n },\n runMutation: async (\n mutation:\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n args?: Record<string, Value>,\n ): Promise<any> => {\n const result = await performAsyncSyscall(\n \"1.0/actions/mutation\",\n syscallArgs(requestId, mutation, args),\n );\n return jsonToConvex(result);\n },\n runAction: async (\n action:\n | FunctionReference<\"action\", \"public\" | \"internal\">\n | FunctionReference_future<\"action\", \"public\" | \"internal\">,\n args?: Record<string, Value>,\n ): Promise<any> => {\n const result = await performAsyncSyscall(\n \"1.0/actions/action\",\n syscallArgs(requestId, action, args),\n );\n return jsonToConvex(result);\n },\n };\n}\n\n/**\n * Get a short-lived credential for calling a Convex-managed service.\n *\n * This function can only be called while an action is running. The credential\n * is scoped to the current deployment and should be sent as a bearer token.\n *
|
|
5
|
-
"mappings": ";AAAA,SAAS,cAAc,oBAA2B;AAClD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,SAAS,iBAAiB;AAK1B,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAE5B,SAAS,YACP,WACA,mBACA,MACA;AACA,QAAM,UAAU,mBAAmB,iBAAiB;AACpD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,aAAa,UAAU,IAAI,CAAC;AAAA,IAClC;AAAA,IACA;AAAA,EACF;AACF;AAEO,gBAAS,iBAAiB,WAAmB;AAClD,SAAO;AAAA,IACL,UAAU,OACR,OAGA,SACiB;AACjB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,QACA,YAAY,WAAW,OAAO,IAAI;AAAA,MACpC;AACA,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,aAAa,OACX,UAGA,SACiB;AACjB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,QACA,YAAY,WAAW,UAAU,IAAI;AAAA,MACvC;AACA,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,WAAW,OACT,QAGA,SACiB;AACjB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,QACA,YAAY,WAAW,QAAQ,IAAI;AAAA,MACrC;AACA,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,EACF;AACF;
|
|
4
|
+
"sourcesContent": ["import { convexToJson, jsonToConvex, Value } from \"../../values/index.js\";\nimport { version } from \"../../index.js\";\nimport { performAsyncSyscall } from \"./syscall.js\";\nimport { parseArgs } from \"../../common/index.js\";\nimport {\n FunctionReference,\n FunctionReference_future,\n} from \"../../server/api.js\";\nimport { getFunctionAddress } from \"../components/paths.js\";\nimport { validateArg } from \"./validate.js\";\n\nfunction syscallArgs(\n requestId: string,\n functionReference: any,\n args?: Record<string, Value>,\n) {\n const address = getFunctionAddress(functionReference);\n return {\n ...address,\n args: convexToJson(parseArgs(args)),\n version,\n requestId,\n };\n}\n\nexport function setupActionCalls(requestId: string) {\n return {\n runQuery: async (\n query:\n | FunctionReference<\"query\", \"public\" | \"internal\">\n | FunctionReference_future<\"query\", \"public\" | \"internal\">,\n args?: Record<string, Value>,\n ): Promise<any> => {\n const result = await performAsyncSyscall(\n \"1.0/actions/query\",\n syscallArgs(requestId, query, args),\n );\n return jsonToConvex(result);\n },\n runMutation: async (\n mutation:\n | FunctionReference<\"mutation\", \"public\" | \"internal\">\n | FunctionReference_future<\"mutation\", \"public\" | \"internal\">,\n args?: Record<string, Value>,\n ): Promise<any> => {\n const result = await performAsyncSyscall(\n \"1.0/actions/mutation\",\n syscallArgs(requestId, mutation, args),\n );\n return jsonToConvex(result);\n },\n runAction: async (\n action:\n | FunctionReference<\"action\", \"public\" | \"internal\">\n | FunctionReference_future<\"action\", \"public\" | \"internal\">,\n args?: Record<string, Value>,\n ): Promise<any> => {\n const result = await performAsyncSyscall(\n \"1.0/actions/action\",\n syscallArgs(requestId, action, args),\n );\n return jsonToConvex(result);\n },\n };\n}\n\n/**\n * A Convex-managed service. The backend decides which names it accepts; this\n * type lists the ones the current release knows about.\n */\nexport type ServiceName = \"ai-gateway\";\n\n/**\n * Get a short-lived credential for calling a Convex-managed service.\n *\n * This function can only be called while an action is running. The credential\n * is scoped to the current deployment and should be sent as a bearer token.\n * The action runtime caches and refreshes credentials as needed, so call\n * this function whenever making a service request.\n *\n * @param service - The service the credential may access.\n * @returns A JWT to send as `Authorization: Bearer <token>`. Keep it inside\n * the action: don't return it to clients or store it in environment\n * variables.\n */\nexport async function getServiceToken(service: ServiceName): Promise<string> {\n validateArg(service, 1, \"getServiceToken\", \"service\");\n return await performAsyncSyscall(\"1.0/createServiceToken\", {\n service,\n version,\n });\n}\n\n/**\n * Get the base URL of a Convex-managed service.\n *\n * This function can only be called while an action is running. Pair it with\n * {@link getServiceToken} to reach the service.\n *\n * @param service - The service to address.\n * @returns The service's origin, without a trailing slash.\n */\nexport async function getServiceUrl(service: ServiceName): Promise<string> {\n validateArg(service, 1, \"getServiceUrl\", \"service\");\n return await performAsyncSyscall(\"1.0/getServiceUrl\", {\n service,\n version,\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,cAAc,oBAA2B;AAClD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,SAAS,iBAAiB;AAK1B,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAE5B,SAAS,YACP,WACA,mBACA,MACA;AACA,QAAM,UAAU,mBAAmB,iBAAiB;AACpD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,aAAa,UAAU,IAAI,CAAC;AAAA,IAClC;AAAA,IACA;AAAA,EACF;AACF;AAEO,gBAAS,iBAAiB,WAAmB;AAClD,SAAO;AAAA,IACL,UAAU,OACR,OAGA,SACiB;AACjB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,QACA,YAAY,WAAW,OAAO,IAAI;AAAA,MACpC;AACA,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,aAAa,OACX,UAGA,SACiB;AACjB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,QACA,YAAY,WAAW,UAAU,IAAI;AAAA,MACvC;AACA,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,WAAW,OACT,QAGA,SACiB;AACjB,YAAM,SAAS,MAAM;AAAA,QACnB;AAAA,QACA,YAAY,WAAW,QAAQ,IAAI;AAAA,MACrC;AACA,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,EACF;AACF;AAqBA,sBAAsB,gBAAgB,SAAuC;AAC3E,cAAY,SAAS,GAAG,mBAAmB,SAAS;AACpD,SAAO,MAAM,oBAAoB,0BAA0B;AAAA,IACzD;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAWA,sBAAsB,cAAc,SAAuC;AACzE,cAAY,SAAS,GAAG,iBAAiB,SAAS;AAClD,SAAO,MAAM,oBAAoB,qBAAqB;AAAA,IACpD;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { version } from "../../index.js";
|
|
3
|
+
import { fromByteArray, toByteArray } from "../../values/base64.js";
|
|
3
4
|
import { performAsyncSyscall, performJsSyscall } from "./syscall.js";
|
|
4
5
|
import { validateArg } from "./validate.js";
|
|
5
6
|
export function setupStorageReader(requestId) {
|
|
@@ -37,6 +38,34 @@ export function setupStorageWriter(requestId) {
|
|
|
37
38
|
storageId
|
|
38
39
|
});
|
|
39
40
|
},
|
|
41
|
+
store: async (blob, options) => {
|
|
42
|
+
if (!(blob instanceof Blob)) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"store() expects a Blob. If you are trying to store a Request, `await request.blob()` will give you the correct input."
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
48
|
+
return await performAsyncSyscall("1.0/storageStore", {
|
|
49
|
+
requestId,
|
|
50
|
+
version,
|
|
51
|
+
blob: fromByteArray(bytes),
|
|
52
|
+
contentType: blob.type,
|
|
53
|
+
sha256: options?.sha256
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
get: async (storageId) => {
|
|
57
|
+
const result = await performAsyncSyscall("1.0/storageGet", {
|
|
58
|
+
requestId,
|
|
59
|
+
version,
|
|
60
|
+
storageId
|
|
61
|
+
});
|
|
62
|
+
if (result === null) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return new Blob([toByteArray(result.blob)], {
|
|
66
|
+
type: result.contentType ?? ""
|
|
67
|
+
});
|
|
68
|
+
},
|
|
40
69
|
getUrl: reader.getUrl,
|
|
41
70
|
getMetadata: reader.getMetadata
|
|
42
71
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/server/impl/storage_impl.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n FileMetadata,\n StorageActionWriter,\n FileStorageId,\n StorageReader,\n StorageWriter,\n} from \"../storage.js\";\nimport { version } from \"../../index.js\";\nimport { performAsyncSyscall, performJsSyscall } from \"./syscall.js\";\nimport { validateArg } from \"./validate.js\";\n\nexport function setupStorageReader(requestId: string): StorageReader {\n return {\n getUrl: async (storageId: FileStorageId) => {\n validateArg(storageId, 1, \"getUrl\", \"storageId\");\n return await performAsyncSyscall(\"1.0/storageGetUrl\", {\n requestId,\n version,\n storageId,\n });\n },\n getMetadata: async (storageId: FileStorageId): Promise<FileMetadata> => {\n return await performAsyncSyscall(\"1.0/storageGetMetadata\", {\n requestId,\n version,\n storageId,\n });\n },\n };\n}\n\nexport function setupStorageWriter(requestId: string): StorageWriter {\n const reader = setupStorageReader(requestId);\n return {\n generateUploadUrl: async () => {\n return await performAsyncSyscall(\"1.0/storageGenerateUploadUrl\", {\n requestId,\n version,\n });\n },\n delete: async (storageId: FileStorageId) => {\n await performAsyncSyscall(\"1.0/storageDelete\", {\n requestId,\n version,\n storageId,\n });\n },\n getUrl: reader.getUrl,\n getMetadata: reader.getMetadata,\n };\n}\n\nexport function setupStorageActionWriter(\n requestId: string,\n): StorageActionWriter {\n const writer = setupStorageWriter(requestId);\n return {\n ...writer,\n store: async (blob: Blob, options?: { sha256?: string }) => {\n return await performJsSyscall(\"storage/storeBlob\", {\n requestId,\n version,\n blob,\n options,\n });\n },\n get: async (storageId: FileStorageId) => {\n return await performJsSyscall(\"storage/getBlob\", {\n requestId,\n version,\n storageId,\n });\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,eAAe;AACxB,SAAS,qBAAqB,wBAAwB;AACtD,SAAS,mBAAmB;AAErB,gBAAS,mBAAmB,WAAkC;AACnE,SAAO;AAAA,IACL,QAAQ,OAAO,cAA6B;AAC1C,kBAAY,WAAW,GAAG,UAAU,WAAW;AAC/C,aAAO,MAAM,oBAAoB,qBAAqB;AAAA,QACpD;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,aAAa,OAAO,cAAoD;AACtE,aAAO,MAAM,oBAAoB,0BAA0B;AAAA,QACzD;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,gBAAS,mBAAmB,WAAkC;AACnE,QAAM,SAAS,mBAAmB,SAAS;AAC3C,SAAO;AAAA,IACL,mBAAmB,YAAY;AAC7B,aAAO,MAAM,oBAAoB,gCAAgC;AAAA,QAC/D;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,QAAQ,OAAO,cAA6B;AAC1C,YAAM,oBAAoB,qBAAqB;AAAA,QAC7C;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,QAAQ,OAAO;AAAA,IACf,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,gBAAS,yBACd,WACqB;AACrB,QAAM,SAAS,mBAAmB,SAAS;AAC3C,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,OAAO,MAAY,YAAkC;AAC1D,aAAO,MAAM,iBAAiB,qBAAqB;AAAA,QACjD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,KAAK,OAAO,cAA6B;AACvC,aAAO,MAAM,iBAAiB,mBAAmB;AAAA,QAC/C;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import {\n FileMetadata,\n StorageActionWriter,\n FileStorageId,\n StorageReader,\n StorageWriter,\n} from \"../storage.js\";\nimport { version } from \"../../index.js\";\nimport { fromByteArray, toByteArray } from \"../../values/base64.js\";\nimport { performAsyncSyscall, performJsSyscall } from \"./syscall.js\";\nimport { validateArg } from \"./validate.js\";\n\nexport function setupStorageReader(requestId: string): StorageReader {\n return {\n getUrl: async (storageId: FileStorageId) => {\n validateArg(storageId, 1, \"getUrl\", \"storageId\");\n return await performAsyncSyscall(\"1.0/storageGetUrl\", {\n requestId,\n version,\n storageId,\n });\n },\n getMetadata: async (storageId: FileStorageId): Promise<FileMetadata> => {\n return await performAsyncSyscall(\"1.0/storageGetMetadata\", {\n requestId,\n version,\n storageId,\n });\n },\n };\n}\n\nexport function setupStorageWriter(requestId: string): StorageWriter {\n const reader = setupStorageReader(requestId);\n return {\n generateUploadUrl: async () => {\n return await performAsyncSyscall(\"1.0/storageGenerateUploadUrl\", {\n requestId,\n version,\n });\n },\n delete: async (storageId: FileStorageId) => {\n await performAsyncSyscall(\"1.0/storageDelete\", {\n requestId,\n version,\n storageId,\n });\n },\n store: async (blob: Blob, options?: { sha256?: string }) => {\n if (!(blob instanceof Blob)) {\n throw new Error(\n \"store() expects a Blob. If you are trying to store a Request, `await request.blob()` will give you the correct input.\",\n );\n }\n const bytes = new Uint8Array(await blob.arrayBuffer());\n return await performAsyncSyscall(\"1.0/storageStore\", {\n requestId,\n version,\n blob: fromByteArray(bytes),\n contentType: blob.type,\n sha256: options?.sha256,\n });\n },\n get: async (storageId: FileStorageId) => {\n const result: { blob: string; contentType: string | null } | null =\n await performAsyncSyscall(\"1.0/storageGet\", {\n requestId,\n version,\n storageId,\n });\n if (result === null) {\n return null;\n }\n return new Blob([toByteArray(result.blob)], {\n type: result.contentType ?? \"\",\n });\n },\n getUrl: reader.getUrl,\n getMetadata: reader.getMetadata,\n };\n}\n\nexport function setupStorageActionWriter(\n requestId: string,\n): StorageActionWriter {\n const writer = setupStorageWriter(requestId);\n return {\n ...writer,\n store: async (blob: Blob, options?: { sha256?: string }) => {\n return await performJsSyscall(\"storage/storeBlob\", {\n requestId,\n version,\n blob,\n options,\n });\n },\n get: async (storageId: FileStorageId) => {\n return await performJsSyscall(\"storage/getBlob\", {\n requestId,\n version,\n storageId,\n });\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,eAAe;AACxB,SAAS,eAAe,mBAAmB;AAC3C,SAAS,qBAAqB,wBAAwB;AACtD,SAAS,mBAAmB;AAErB,gBAAS,mBAAmB,WAAkC;AACnE,SAAO;AAAA,IACL,QAAQ,OAAO,cAA6B;AAC1C,kBAAY,WAAW,GAAG,UAAU,WAAW;AAC/C,aAAO,MAAM,oBAAoB,qBAAqB;AAAA,QACpD;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,aAAa,OAAO,cAAoD;AACtE,aAAO,MAAM,oBAAoB,0BAA0B;AAAA,QACzD;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,gBAAS,mBAAmB,WAAkC;AACnE,QAAM,SAAS,mBAAmB,SAAS;AAC3C,SAAO;AAAA,IACL,mBAAmB,YAAY;AAC7B,aAAO,MAAM,oBAAoB,gCAAgC;AAAA,QAC/D;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,QAAQ,OAAO,cAA6B;AAC1C,YAAM,oBAAoB,qBAAqB;AAAA,QAC7C;AAAA,Q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10
|
internalQueryGeneric
|
|
11
11
|
} from "./impl/registration_impl.js";
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
getServiceToken,
|
|
14
|
+
getServiceUrl
|
|
15
|
+
} from "./impl/actions_impl.js";
|
|
13
16
|
export * from "./pagination.js";
|
|
14
17
|
export * from "./search_filter_builder.js";
|
|
15
18
|
export * from "./storage.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Utilities for implementing server-side Convex query and mutation functions.\n *\n * ## Usage\n *\n * ### Code Generation\n *\n * This module is typically used alongside generated server code.\n *\n * To generate the server code, run `npx convex dev` in your Convex project.\n * This will create a `convex/_generated/server.js` file with the following\n * functions, typed for your schema:\n * - [query](https://docs.convex.dev/generated-api/server#query)\n * - [mutation](https://docs.convex.dev/generated-api/server#mutation)\n *\n * If you aren't using TypeScript and code generation, you can use these untyped\n * functions instead:\n * - {@link queryGeneric}\n * - {@link mutationGeneric}\n *\n * ### Example\n *\n * Convex functions are defined by using either the `query` or\n * `mutation` wrappers.\n *\n * Queries receive a `db` that implements the {@link GenericDatabaseReader} interface.\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export default query({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your (read-only) code here!\n * },\n * });\n * ```\n *\n * If your function needs to write to the database, such as inserting, updating,\n * or deleting documents, use `mutation` instead which provides a `db` that\n * implements the {@link GenericDatabaseWriter} interface.\n *\n * ```js\n * import { mutation } from \"./_generated/server\";\n *\n * export default mutation({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your mutation code here!\n * },\n * });\n * ```\n * @module\n */\n\nexport type {\n Auth,\n AuthConfig,\n AuthProvider,\n UserIdentity,\n UserIdentityAttributes,\n} from \"./authentication.js\";\nexport * from \"./database.js\";\nexport type {\n GenericDocument,\n GenericFieldPaths,\n GenericIndexFields,\n GenericTableIndexes,\n GenericSearchIndexConfig,\n GenericTableSearchIndexes,\n GenericVectorIndexConfig,\n GenericTableVectorIndexes,\n FieldTypeFromFieldPath,\n FieldTypeFromFieldPathInner,\n GenericTableInfo,\n DocumentByInfo,\n FieldPaths,\n Indexes,\n IndexNames,\n NamedIndex,\n SearchIndexes,\n SearchIndexNames,\n NamedSearchIndex,\n VectorIndexes,\n VectorIndexNames,\n NamedVectorIndex,\n GenericDataModel,\n AnyDataModel,\n TableNamesInDataModel,\n NamedTableInfo,\n DocumentByName,\n} from \"./data_model.js\";\n\nexport type {\n Expression,\n ExpressionOrValue,\n FilterBuilder,\n} from \"./filter_builder.js\";\nexport {\n actionGeneric,\n httpActionGeneric,\n mutationGeneric,\n queryGeneric,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n} from \"./impl/registration_impl.js\";\nexport {
|
|
5
|
-
"mappings": ";AA4DA,cAAc;AAoCd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,
|
|
4
|
+
"sourcesContent": ["/**\n * Utilities for implementing server-side Convex query and mutation functions.\n *\n * ## Usage\n *\n * ### Code Generation\n *\n * This module is typically used alongside generated server code.\n *\n * To generate the server code, run `npx convex dev` in your Convex project.\n * This will create a `convex/_generated/server.js` file with the following\n * functions, typed for your schema:\n * - [query](https://docs.convex.dev/generated-api/server#query)\n * - [mutation](https://docs.convex.dev/generated-api/server#mutation)\n *\n * If you aren't using TypeScript and code generation, you can use these untyped\n * functions instead:\n * - {@link queryGeneric}\n * - {@link mutationGeneric}\n *\n * ### Example\n *\n * Convex functions are defined by using either the `query` or\n * `mutation` wrappers.\n *\n * Queries receive a `db` that implements the {@link GenericDatabaseReader} interface.\n *\n * ```js\n * import { query } from \"./_generated/server\";\n *\n * export default query({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your (read-only) code here!\n * },\n * });\n * ```\n *\n * If your function needs to write to the database, such as inserting, updating,\n * or deleting documents, use `mutation` instead which provides a `db` that\n * implements the {@link GenericDatabaseWriter} interface.\n *\n * ```js\n * import { mutation } from \"./_generated/server\";\n *\n * export default mutation({\n * handler: async ({ db }, { arg1, arg2 }) => {\n * // Your mutation code here!\n * },\n * });\n * ```\n * @module\n */\n\nexport type {\n Auth,\n AuthConfig,\n AuthProvider,\n UserIdentity,\n UserIdentityAttributes,\n} from \"./authentication.js\";\nexport * from \"./database.js\";\nexport type {\n GenericDocument,\n GenericFieldPaths,\n GenericIndexFields,\n GenericTableIndexes,\n GenericSearchIndexConfig,\n GenericTableSearchIndexes,\n GenericVectorIndexConfig,\n GenericTableVectorIndexes,\n FieldTypeFromFieldPath,\n FieldTypeFromFieldPathInner,\n GenericTableInfo,\n DocumentByInfo,\n FieldPaths,\n Indexes,\n IndexNames,\n NamedIndex,\n SearchIndexes,\n SearchIndexNames,\n NamedSearchIndex,\n VectorIndexes,\n VectorIndexNames,\n NamedVectorIndex,\n GenericDataModel,\n AnyDataModel,\n TableNamesInDataModel,\n NamedTableInfo,\n DocumentByName,\n} from \"./data_model.js\";\n\nexport type {\n Expression,\n ExpressionOrValue,\n FilterBuilder,\n} from \"./filter_builder.js\";\nexport {\n actionGeneric,\n httpActionGeneric,\n mutationGeneric,\n queryGeneric,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n} from \"./impl/registration_impl.js\";\nexport {\n getServiceToken,\n getServiceUrl,\n type ServiceName,\n} from \"./impl/actions_impl.js\";\nexport type {\n TransactionMetric,\n TransactionMetrics,\n TransactionLimits,\n FunctionMetadata,\n DeploymentMetadata,\n RequestMetadata,\n QueryMeta,\n MutationMeta,\n ActionMeta,\n} from \"./meta.js\";\nexport type { IndexRange, IndexRangeBuilder } from \"./index_range_builder.js\";\nexport * from \"./pagination.js\";\nexport type { OrderedQuery, Query, QueryInitializer } from \"./query.js\";\nexport type {\n AdvancedRunQueryOptions,\n ArgsArray,\n DefaultFunctionArgs,\n FunctionVisibility,\n ActionBuilder,\n MutationBuilder,\n MutationBuilderWithTable,\n QueryBuilder,\n QueryBuilderWithTable,\n HttpActionBuilder,\n GenericActionCtx,\n GenericMutationCtx,\n GenericMutationCtxWithTable,\n GenericQueryCtx,\n GenericQueryCtxWithTable,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n PublicHttpAction,\n UnvalidatedFunction,\n ValidatedFunction,\n ReturnValueForOptionalValidator,\n ArgsArrayForOptionalValidator,\n ArgsArrayToObject,\n DefaultArgsForOptionalValidator,\n} from \"./registration.js\";\nexport * from \"./search_filter_builder.js\";\nexport * from \"./storage.js\";\nexport type { Scheduler, SchedulableFunctionReference } from \"./scheduler.js\";\nexport { cronJobs } from \"./cron.js\";\nexport type { CronJob, Crons } from \"./cron.js\";\nexport type {\n SystemFields,\n IdField,\n WithoutSystemFields,\n WithOptionalSystemFields,\n SystemIndexes,\n IndexTiebreakerField,\n} from \"./system_fields.js\";\nexport { httpRouter, HttpRouter, ROUTABLE_HTTP_METHODS } from \"./router.js\";\nexport type {\n RoutableMethod,\n RouteSpec,\n RouteSpecWithPath,\n RouteSpecWithPathPrefix,\n} from \"./router.js\";\nexport {\n anyApi,\n getFunctionName,\n makeFunctionReference,\n filterApi,\n} from \"./api.js\";\nexport type {\n ApiFromModules,\n AnyApi,\n FunctionReference_future,\n FilterApi,\n FunctionType,\n FunctionReference,\n FunctionArgs,\n OptionalRestArgs,\n PartialApi,\n ArgsAndOptions,\n FunctionReturnType,\n ValidatorTypeToReturnType,\n} from \"./api.js\";\nexport {\n defineApp,\n defineComponent,\n componentsGeneric,\n createFunctionHandle,\n type AnyChildComponents,\n type EnvDefinition,\n type EnvFromDefinition,\n type EnvFromAppDefinition,\n type AppDefinition,\n} from \"./components/index.js\";\n/**\n * @internal\n */\nexport { currentSystemUdfInComponent } from \"./components/index.js\";\nexport { getFunctionAddress } from \"./components/index.js\";\nexport type {\n ComponentDefinition,\n AnyComponents,\n FunctionHandle,\n} from \"./components/index.js\";\n\n/**\n * @internal\n */\nexport type { Index, SearchIndex, VectorIndex } from \"./schema.js\";\n\nexport { log } from \"./log.js\";\nexport type { AuditLogBody, AuditLogValue } from \"./audit_logging.js\";\n\nexport type {\n SearchIndexConfig,\n VectorIndexConfig,\n TableDefinition,\n SchemaDefinition,\n DefineSchemaOptions,\n GenericSchema,\n DataModelFromSchemaDefinition,\n SystemDataModel,\n SystemTableNames,\n DocValidator,\n SystemFieldValidators,\n} from \"./schema.js\";\nexport { defineTable, defineSchema, docValidator } from \"./schema.js\";\n\nexport type {\n VectorSearch,\n VectorSearchQuery,\n VectorFilterBuilder,\n FilterExpression,\n} from \"./vector_search.js\";\n\n/**\n * @public\n */\nexport type { BetterOmit, Expand } from \"../type_utils.js\";\n"],
|
|
5
|
+
"mappings": ";AA4DA,cAAc;AAoCd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAaP,cAAc;AA6Bd,cAAc;AACd,cAAc;AAEd,SAAS,gBAAgB;AAUzB,SAAS,YAAY,YAAY,6BAA6B;AAO9D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAIP,SAAS,mCAAmC;AAC5C,SAAS,0BAA0B;AAYnC,SAAS,WAAW;AAgBpB,SAAS,aAAa,cAAc,oBAAoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -95,35 +95,57 @@ export class TableDefinition {
|
|
|
95
95
|
return this;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
|
-
* Stage
|
|
98
|
+
* Stage changes to this table's document validator.
|
|
99
99
|
*
|
|
100
100
|
* Convex validates the staged validator against the table's existing
|
|
101
101
|
* documents in the background, while the validator passed to
|
|
102
|
-
* {@link defineTable} remains the one enforced on
|
|
103
|
-
* the background validation succeeds,
|
|
104
|
-
*
|
|
102
|
+
* {@link defineTable} remains the one enforced on writes. Once
|
|
103
|
+
* the background validation succeeds, apply the staged changes
|
|
104
|
+
* and remove `.staged()`.
|
|
105
|
+
*
|
|
106
|
+
* For an object validator, pass only the fields to add or replace. Fields
|
|
107
|
+
* omitted from the changes keep their enforced validators.
|
|
108
|
+
* Set a field to `undefined` to remove it from the staged validator.
|
|
109
|
+
* For nested objects, you must specify the full object validator.
|
|
105
110
|
*
|
|
106
111
|
* ```ts
|
|
107
112
|
* defineTable({
|
|
108
|
-
*
|
|
113
|
+
* apple: v.string(),
|
|
114
|
+
* banana: v.number(),
|
|
115
|
+
* legacy: v.optional(v.string()),
|
|
109
116
|
* }).staged({
|
|
110
|
-
*
|
|
117
|
+
* banana: v.union(v.string(), v.number()),
|
|
118
|
+
* legacy: undefined,
|
|
111
119
|
* })
|
|
112
120
|
* ```
|
|
113
121
|
*
|
|
114
|
-
*
|
|
122
|
+
* See [Staged validators](https://docs.convex.dev/database/schemas#staged-validators).
|
|
115
123
|
*
|
|
116
|
-
* @param documentSchema -
|
|
117
|
-
*
|
|
124
|
+
* @param documentSchema - Field changes for a table defined as an object or
|
|
125
|
+
* `v.any()`, or a full schema validator specifying the proposed next document
|
|
126
|
+
* type. Use a full schema validator for a table defined as a union.
|
|
118
127
|
* @returns A {@link TableDefinition} with the staged validator attached.
|
|
119
|
-
*
|
|
120
|
-
* @internal
|
|
121
128
|
*/
|
|
122
129
|
staged(documentSchema) {
|
|
123
130
|
if (this.stagedValidator !== void 0) {
|
|
124
131
|
throw new Error("Table cannot have more than one staged validator.");
|
|
125
132
|
}
|
|
126
|
-
|
|
133
|
+
if (isValidator(documentSchema)) {
|
|
134
|
+
this.stagedValidator = documentSchema;
|
|
135
|
+
} else {
|
|
136
|
+
if (this.validator.kind !== "object" && this.validator.kind !== "any") {
|
|
137
|
+
throw new Error(
|
|
138
|
+
"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."
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const enforcedFields = this.validator.kind === "object" ? this.validator.fields : {};
|
|
142
|
+
const fields = Object.fromEntries(
|
|
143
|
+
Object.entries({ ...enforcedFields, ...documentSchema }).filter(
|
|
144
|
+
(entry) => entry[1] !== void 0
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
this.stagedValidator = v.object(fields);
|
|
148
|
+
}
|
|
127
149
|
return this.self();
|
|
128
150
|
}
|
|
129
151
|
/**
|