convex 1.34.0 → 1.35.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 +98 -43
- package/dist/browser.bundle.js +13 -10
- package/dist/browser.bundle.js.map +3 -3
- package/dist/cjs/browser/index-node.js +3 -1
- package/dist/cjs/browser/index.js +3 -1
- package/dist/cjs/browser/index.js.map +2 -2
- package/dist/cjs/browser/query_options.js.map +2 -2
- package/dist/cjs/browser/sync/authentication_manager.js +4 -1
- package/dist/cjs/browser/sync/authentication_manager.js.map +2 -2
- package/dist/cjs/browser/sync/web_socket_manager.js +1 -7
- package/dist/cjs/browser/sync/web_socket_manager.js.map +2 -2
- package/dist/cjs/cli/aiFiles.js +39 -20
- package/dist/cjs/cli/aiFiles.js.map +3 -3
- package/dist/cjs/cli/codegen_templates/readme.js +14 -1
- package/dist/cjs/cli/codegen_templates/readme.js.map +2 -2
- package/dist/cjs/cli/configure.js +34 -32
- package/dist/cjs/cli/configure.js.map +2 -2
- package/dist/cjs/cli/deploy.js +7 -8
- package/dist/cjs/cli/deploy.js.map +2 -2
- package/dist/cjs/cli/deploymentCreate.js +225 -40
- package/dist/cjs/cli/deploymentCreate.js.map +3 -3
- package/dist/cjs/cli/deploymentSelect.js +14 -13
- package/dist/cjs/cli/deploymentSelect.js.map +2 -2
- package/dist/cjs/cli/dev.js +30 -11
- package/dist/cjs/cli/dev.js.map +2 -2
- package/dist/cjs/cli/docs.js +1 -1
- package/dist/cjs/cli/docs.js.map +2 -2
- package/dist/cjs/cli/init.js +1 -1
- package/dist/cjs/cli/init.js.map +2 -2
- package/dist/cjs/cli/lib/aiFiles/agentsmd.js +73 -0
- package/dist/cjs/cli/lib/aiFiles/agentsmd.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/claudemd.js +73 -0
- package/dist/cjs/cli/lib/aiFiles/claudemd.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/cursorrules.js +48 -0
- package/dist/cjs/cli/lib/aiFiles/cursorrules.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/guidelinesmd.js +58 -0
- package/dist/cjs/cli/lib/aiFiles/guidelinesmd.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/index.js +215 -0
- package/dist/cjs/cli/lib/aiFiles/index.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/paths.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/skills.js +196 -0
- package/dist/cjs/cli/lib/aiFiles/skills.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/state.js +96 -0
- package/dist/cjs/cli/lib/aiFiles/state.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/status.js +198 -0
- package/dist/cjs/cli/lib/aiFiles/status.js.map +7 -0
- package/dist/cjs/cli/lib/aiFiles/utils.js +128 -0
- package/dist/cjs/cli/lib/aiFiles/utils.js.map +7 -0
- package/dist/cjs/cli/lib/api.js +70 -7
- package/dist/cjs/cli/lib/api.js.map +2 -2
- package/dist/cjs/cli/lib/command.js +10 -6
- package/dist/cjs/cli/lib/command.js.map +2 -2
- package/dist/cjs/cli/lib/config.js +43 -7
- package/dist/cjs/cli/lib/config.js.map +3 -3
- package/dist/cjs/cli/lib/deploy2.js +9 -26
- package/dist/cjs/cli/lib/deploy2.js.map +2 -2
- package/dist/cjs/cli/lib/deployApi/componentDefinition.js +4 -1
- package/dist/cjs/cli/lib/deployApi/componentDefinition.js.map +2 -2
- package/dist/cjs/cli/lib/deploymentSelection.js +45 -2
- package/dist/cjs/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/cjs/cli/lib/deploymentSelector.js +1 -0
- package/dist/cjs/cli/lib/deploymentSelector.js.map +2 -2
- package/dist/cjs/cli/lib/dev.js +162 -117
- package/dist/cjs/cli/lib/dev.js.map +2 -2
- package/dist/cjs/cli/lib/env.js +1 -13
- package/dist/cjs/cli/lib/env.js.map +2 -2
- package/dist/cjs/cli/lib/expiration.js +104 -0
- package/dist/cjs/cli/lib/expiration.js.map +7 -0
- package/dist/cjs/cli/lib/generatedFunctionLogsApi.js.map +1 -1
- package/dist/cjs/cli/lib/init.js +4 -3
- package/dist/cjs/cli/lib/init.js.map +2 -2
- package/dist/cjs/cli/lib/insights.js +1 -1
- package/dist/cjs/cli/lib/insights.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/anonymous.js +15 -8
- package/dist/cjs/cli/lib/localDeployment/anonymous.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/localDeployment.js +8 -10
- package/dist/cjs/cli/lib/localDeployment/localDeployment.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/run.js +1 -0
- package/dist/cjs/cli/lib/localDeployment/run.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/upgrade.js +2 -2
- package/dist/cjs/cli/lib/localDeployment/upgrade.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/utils.js +9 -0
- package/dist/cjs/cli/lib/localDeployment/utils.js.map +2 -2
- package/dist/cjs/cli/lib/mcp/tools/status.js +1 -1
- package/dist/cjs/cli/lib/mcp/tools/status.js.map +2 -2
- package/dist/cjs/cli/lib/updates.js +12 -13
- package/dist/cjs/cli/lib/updates.js.map +2 -2
- package/dist/cjs/cli/lib/usage.js +2 -1
- package/dist/cjs/cli/lib/usage.js.map +2 -2
- package/dist/cjs/cli/lib/utils/prompts.js +2 -1
- package/dist/cjs/cli/lib/utils/prompts.js.map +2 -2
- package/dist/cjs/cli/lib/utils/utils.js +46 -20
- package/dist/cjs/cli/lib/utils/utils.js.map +3 -3
- package/dist/cjs/cli/lib/versionApi.js +7 -4
- package/dist/cjs/cli/lib/versionApi.js.map +2 -2
- package/dist/cjs/cli/lib/workos/workos.js +4 -6
- package/dist/cjs/cli/lib/workos/workos.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/client.js +43 -6
- package/dist/cjs/react/client.js.map +2 -2
- package/dist/cjs/react/index.js +2 -0
- package/dist/cjs/react/index.js.map +2 -2
- package/dist/cjs/react-clerk/ConvexProviderWithClerk.js.map +1 -1
- package/dist/cjs/server/api.js.map +2 -2
- package/dist/cjs/server/components/definition.js.map +1 -1
- package/dist/cjs/server/components/index.js +40 -4
- package/dist/cjs/server/components/index.js.map +2 -2
- package/dist/cjs/server/data_model.js.map +1 -1
- package/dist/cjs/server/impl/meta_impl.js +78 -0
- package/dist/cjs/server/impl/meta_impl.js.map +7 -0
- package/dist/cjs/server/impl/registration_impl.js +16 -11
- package/dist/cjs/server/impl/registration_impl.js.map +2 -2
- package/dist/cjs/server/index.js.map +2 -2
- package/dist/cjs/server/meta.js +17 -0
- package/dist/cjs/server/meta.js.map +7 -0
- package/dist/cjs/server/registration.js.map +1 -1
- package/dist/cjs-types/browser/index.d.ts +1 -0
- package/dist/cjs-types/browser/index.d.ts.map +1 -1
- package/dist/cjs-types/browser/query_options.d.ts +12 -9
- package/dist/cjs-types/browser/query_options.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/authentication_manager.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/web_socket_manager.d.ts.map +1 -1
- package/dist/cjs-types/cli/aiFiles.d.ts.map +1 -1
- package/dist/cjs-types/cli/codegen_templates/readme.d.ts.map +1 -1
- package/dist/cjs-types/cli/configure.d.ts.map +1 -1
- package/dist/cjs-types/cli/configure.test.d.ts +2 -0
- package/dist/cjs-types/cli/configure.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentCreate.d.ts +1 -0
- package/dist/cjs-types/cli/deploymentCreate.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploymentSelect.d.ts +2 -1
- package/dist/cjs-types/cli/deploymentSelect.d.ts.map +1 -1
- package/dist/cjs-types/cli/dev.d.ts +3 -1
- package/dist/cjs-types/cli/dev.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/aiFiles/agentsmd.d.ts +19 -0
- package/dist/cjs-types/cli/lib/aiFiles/agentsmd.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/agentsmd.test.d.ts +2 -0
- package/dist/cjs-types/cli/lib/aiFiles/agentsmd.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/claudemd.d.ts +19 -0
- package/dist/cjs-types/cli/lib/aiFiles/claudemd.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/claudemd.test.d.ts +2 -0
- package/dist/cjs-types/cli/lib/aiFiles/claudemd.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/cursorrules.d.ts +10 -0
- package/dist/cjs-types/cli/lib/aiFiles/cursorrules.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.d.ts +12 -0
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.test.d.ts +2 -0
- package/dist/cjs-types/cli/lib/aiFiles/guidelinesmd.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/index.d.ts +42 -0
- package/dist/cjs-types/cli/lib/aiFiles/index.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/index.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/integration.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/{ai → aiFiles}/paths.d.ts +4 -0
- package/dist/cjs-types/cli/lib/aiFiles/paths.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/prompt.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/skills.d.ts +20 -0
- package/dist/cjs-types/cli/lib/aiFiles/skills.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/state.d.ts +38 -0
- package/dist/cjs-types/cli/lib/aiFiles/state.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/state.test.d.ts +2 -0
- package/dist/cjs-types/cli/lib/aiFiles/state.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/status.d.ts +6 -0
- package/dist/cjs-types/cli/lib/aiFiles/status.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/utils.d.ts +56 -0
- package/dist/cjs-types/cli/lib/aiFiles/utils.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/aiFiles/utils.test.d.ts +2 -0
- package/dist/cjs-types/cli/lib/aiFiles/utils.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/api.d.ts +3 -3
- package/dist/cjs-types/cli/lib/api.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/command.d.ts +2 -1
- package/dist/cjs-types/cli/lib/command.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/config.d.ts +18 -6
- package/dist/cjs-types/cli/lib/config.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploy2.d.ts +5 -2
- package/dist/cjs-types/cli/lib/deploy2.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployApi/componentDefinition.d.ts +27 -12
- package/dist/cjs-types/cli/lib/deployApi/componentDefinition.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deployApi/definitionConfig.d.ts +24 -24
- package/dist/cjs-types/cli/lib/deployApi/modules.d.ts +14 -14
- package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts +61 -52
- package/dist/cjs-types/cli/lib/deployApi/startPush.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/deploymentSelector.d.ts +2 -0
- package/dist/cjs-types/cli/lib/deploymentSelector.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/dev.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/env.d.ts +0 -4
- package/dist/cjs-types/cli/lib/env.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/expiration.d.ts +35 -0
- package/dist/cjs-types/cli/lib/expiration.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/expiration.test.d.ts +2 -0
- package/dist/cjs-types/cli/lib/expiration.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts +16 -1
- package/dist/cjs-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/init.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/anonymous.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/localDeployment.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/run.d.ts +15 -0
- package/dist/cjs-types/cli/lib/localDeployment/run.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts +7 -0
- package/dist/cjs-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/mcp/requestContext.d.ts +3 -3
- package/dist/cjs-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/cjs-types/cli/lib/updates.d.ts +4 -3
- package/dist/cjs-types/cli/lib/updates.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/usage.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/prompts.d.ts +1 -0
- package/dist/cjs-types/cli/lib/utils/prompts.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/utils.d.ts +16 -2
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/versionApi.d.ts +7 -1
- package/dist/cjs-types/cli/lib/versionApi.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/workos/workos.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/react/client.d.ts +54 -2
- package/dist/cjs-types/react/client.d.ts.map +1 -1
- package/dist/cjs-types/react/index.d.ts +7 -2
- package/dist/cjs-types/react/index.d.ts.map +1 -1
- package/dist/cjs-types/react/use_query_object_options.test.d.ts +5 -0
- package/dist/cjs-types/react/use_query_object_options.test.d.ts.map +1 -0
- package/dist/cjs-types/react/use_query_result.test.d.ts +5 -0
- package/dist/cjs-types/react/use_query_result.test.d.ts.map +1 -0
- package/dist/cjs-types/react-clerk/ConvexProviderWithClerk.d.ts +1 -1
- package/dist/cjs-types/server/api.d.ts +5 -1
- package/dist/cjs-types/server/api.d.ts.map +1 -1
- package/dist/cjs-types/server/components/definition.d.ts +1 -0
- package/dist/cjs-types/server/components/definition.d.ts.map +1 -1
- package/dist/cjs-types/server/components/index.d.ts +5 -1
- package/dist/cjs-types/server/components/index.d.ts.map +1 -1
- package/dist/cjs-types/server/data_model.d.ts +2 -1
- package/dist/cjs-types/server/data_model.d.ts.map +1 -1
- package/dist/cjs-types/server/impl/meta_impl.d.ts +5 -0
- package/dist/cjs-types/server/impl/meta_impl.d.ts.map +1 -0
- package/dist/cjs-types/server/impl/registration_impl.d.ts.map +1 -1
- package/dist/cjs-types/server/index.d.ts +1 -0
- package/dist/cjs-types/server/index.d.ts.map +1 -1
- package/dist/cjs-types/server/meta.d.ts +72 -0
- package/dist/cjs-types/server/meta.d.ts.map +1 -0
- package/dist/cjs-types/server/registration.d.ts.map +1 -1
- package/dist/cli.bundle.cjs +2446 -1933
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/browser/index-node.js +1 -0
- package/dist/esm/browser/index.js +1 -0
- package/dist/esm/browser/index.js.map +2 -2
- package/dist/esm/browser/query_options.js.map +2 -2
- package/dist/esm/browser/sync/authentication_manager.js +4 -1
- package/dist/esm/browser/sync/authentication_manager.js.map +2 -2
- package/dist/esm/browser/sync/web_socket_manager.js +1 -7
- package/dist/esm/browser/sync/web_socket_manager.js.map +2 -2
- package/dist/esm/cli/aiFiles.js +41 -23
- package/dist/esm/cli/aiFiles.js.map +2 -2
- package/dist/esm/cli/codegen_templates/readme.js +14 -1
- package/dist/esm/cli/codegen_templates/readme.js.map +2 -2
- package/dist/esm/cli/configure.js +35 -33
- package/dist/esm/cli/configure.js.map +2 -2
- package/dist/esm/cli/deploy.js +11 -10
- package/dist/esm/cli/deploy.js.map +2 -2
- package/dist/esm/cli/deploymentCreate.js +238 -42
- package/dist/esm/cli/deploymentCreate.js.map +2 -2
- package/dist/esm/cli/deploymentSelect.js +13 -12
- package/dist/esm/cli/deploymentSelect.js.map +2 -2
- package/dist/esm/cli/dev.js +34 -13
- package/dist/esm/cli/dev.js.map +2 -2
- package/dist/esm/cli/docs.js +1 -1
- package/dist/esm/cli/docs.js.map +2 -2
- package/dist/esm/cli/init.js +2 -2
- package/dist/esm/cli/init.js.map +2 -2
- package/dist/esm/cli/lib/aiFiles/agentsmd.js +56 -0
- package/dist/esm/cli/lib/aiFiles/agentsmd.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/claudemd.js +56 -0
- package/dist/esm/cli/lib/aiFiles/claudemd.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/cursorrules.js +16 -0
- package/dist/esm/cli/lib/aiFiles/cursorrules.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/guidelinesmd.js +35 -0
- package/dist/esm/cli/lib/aiFiles/guidelinesmd.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/index.js +193 -0
- package/dist/esm/cli/lib/aiFiles/index.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/paths.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/skills.js +163 -0
- package/dist/esm/cli/lib/aiFiles/skills.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/state.js +60 -0
- package/dist/esm/cli/lib/aiFiles/state.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/status.js +178 -0
- package/dist/esm/cli/lib/aiFiles/status.js.map +7 -0
- package/dist/esm/cli/lib/aiFiles/utils.js +97 -0
- package/dist/esm/cli/lib/aiFiles/utils.js.map +7 -0
- package/dist/esm/cli/lib/api.js +70 -7
- package/dist/esm/cli/lib/api.js.map +2 -2
- package/dist/esm/cli/lib/command.js +10 -6
- package/dist/esm/cli/lib/command.js.map +2 -2
- package/dist/esm/cli/lib/config.js +41 -6
- package/dist/esm/cli/lib/config.js.map +2 -2
- package/dist/esm/cli/lib/deploy2.js +13 -26
- package/dist/esm/cli/lib/deploy2.js.map +2 -2
- package/dist/esm/cli/lib/deployApi/componentDefinition.js +4 -1
- package/dist/esm/cli/lib/deployApi/componentDefinition.js.map +2 -2
- package/dist/esm/cli/lib/deploymentSelection.js +46 -2
- package/dist/esm/cli/lib/deploymentSelection.js.map +2 -2
- package/dist/esm/cli/lib/deploymentSelector.js +1 -0
- package/dist/esm/cli/lib/deploymentSelector.js.map +2 -2
- package/dist/esm/cli/lib/dev.js +162 -118
- package/dist/esm/cli/lib/dev.js.map +2 -2
- package/dist/esm/cli/lib/env.js +0 -11
- package/dist/esm/cli/lib/env.js.map +2 -2
- package/dist/esm/cli/lib/expiration.js +80 -0
- package/dist/esm/cli/lib/expiration.js.map +7 -0
- package/dist/esm/cli/lib/init.js +4 -3
- package/dist/esm/cli/lib/init.js.map +2 -2
- package/dist/esm/cli/lib/insights.js +1 -1
- package/dist/esm/cli/lib/insights.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/anonymous.js +16 -9
- package/dist/esm/cli/lib/localDeployment/anonymous.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/localDeployment.js +9 -11
- package/dist/esm/cli/lib/localDeployment/localDeployment.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/run.js +1 -1
- package/dist/esm/cli/lib/localDeployment/run.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/upgrade.js +2 -2
- package/dist/esm/cli/lib/localDeployment/upgrade.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/utils.js +8 -0
- package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
- package/dist/esm/cli/lib/mcp/tools/status.js +1 -1
- package/dist/esm/cli/lib/mcp/tools/status.js.map +2 -2
- package/dist/esm/cli/lib/updates.js +14 -12
- package/dist/esm/cli/lib/updates.js.map +2 -2
- package/dist/esm/cli/lib/usage.js +2 -1
- package/dist/esm/cli/lib/usage.js.map +2 -2
- package/dist/esm/cli/lib/utils/prompts.js +2 -1
- package/dist/esm/cli/lib/utils/prompts.js.map +2 -2
- package/dist/esm/cli/lib/utils/utils.js +45 -20
- package/dist/esm/cli/lib/utils/utils.js.map +3 -3
- package/dist/esm/cli/lib/versionApi.js +7 -4
- package/dist/esm/cli/lib/versionApi.js.map +2 -2
- package/dist/esm/cli/lib/workos/workos.js +4 -6
- package/dist/esm/cli/lib/workos/workos.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/client.js +43 -6
- package/dist/esm/react/client.js.map +2 -2
- package/dist/esm/react/index.js +1 -0
- package/dist/esm/react/index.js.map +2 -2
- package/dist/esm/react-clerk/ConvexProviderWithClerk.js.map +1 -1
- package/dist/esm/server/api.js.map +2 -2
- package/dist/esm/server/components/index.js +40 -4
- package/dist/esm/server/components/index.js.map +2 -2
- package/dist/esm/server/impl/meta_impl.js +54 -0
- package/dist/esm/server/impl/meta_impl.js.map +7 -0
- package/dist/esm/server/impl/registration_impl.js +20 -11
- package/dist/esm/server/impl/registration_impl.js.map +2 -2
- package/dist/esm/server/index.js.map +2 -2
- package/dist/esm/server/meta.js +2 -0
- package/dist/esm/server/meta.js.map +7 -0
- package/dist/esm-types/browser/index.d.ts +1 -0
- package/dist/esm-types/browser/index.d.ts.map +1 -1
- package/dist/esm-types/browser/query_options.d.ts +12 -9
- package/dist/esm-types/browser/query_options.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/authentication_manager.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/web_socket_manager.d.ts.map +1 -1
- package/dist/esm-types/cli/aiFiles.d.ts.map +1 -1
- package/dist/esm-types/cli/codegen_templates/readme.d.ts.map +1 -1
- package/dist/esm-types/cli/configure.d.ts.map +1 -1
- package/dist/esm-types/cli/configure.test.d.ts +2 -0
- package/dist/esm-types/cli/configure.test.d.ts.map +1 -0
- package/dist/esm-types/cli/deploy.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentCreate.d.ts +1 -0
- package/dist/esm-types/cli/deploymentCreate.d.ts.map +1 -1
- package/dist/esm-types/cli/deploymentSelect.d.ts +2 -1
- package/dist/esm-types/cli/deploymentSelect.d.ts.map +1 -1
- package/dist/esm-types/cli/dev.d.ts +3 -1
- package/dist/esm-types/cli/dev.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/aiFiles/agentsmd.d.ts +19 -0
- package/dist/esm-types/cli/lib/aiFiles/agentsmd.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/agentsmd.test.d.ts +2 -0
- package/dist/esm-types/cli/lib/aiFiles/agentsmd.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/claudemd.d.ts +19 -0
- package/dist/esm-types/cli/lib/aiFiles/claudemd.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/claudemd.test.d.ts +2 -0
- package/dist/esm-types/cli/lib/aiFiles/claudemd.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/cursorrules.d.ts +10 -0
- package/dist/esm-types/cli/lib/aiFiles/cursorrules.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.d.ts +12 -0
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.test.d.ts +2 -0
- package/dist/esm-types/cli/lib/aiFiles/guidelinesmd.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/index.d.ts +42 -0
- package/dist/esm-types/cli/lib/aiFiles/index.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/index.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/integration.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/{ai → aiFiles}/paths.d.ts +4 -0
- package/dist/esm-types/cli/lib/aiFiles/paths.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/prompt.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/skills.d.ts +20 -0
- package/dist/esm-types/cli/lib/aiFiles/skills.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/state.d.ts +38 -0
- package/dist/esm-types/cli/lib/aiFiles/state.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/state.test.d.ts +2 -0
- package/dist/esm-types/cli/lib/aiFiles/state.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/status.d.ts +6 -0
- package/dist/esm-types/cli/lib/aiFiles/status.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/utils.d.ts +56 -0
- package/dist/esm-types/cli/lib/aiFiles/utils.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/aiFiles/utils.test.d.ts +2 -0
- package/dist/esm-types/cli/lib/aiFiles/utils.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/api.d.ts +3 -3
- package/dist/esm-types/cli/lib/api.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/command.d.ts +2 -1
- package/dist/esm-types/cli/lib/command.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/config.d.ts +18 -6
- package/dist/esm-types/cli/lib/config.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploy2.d.ts +5 -2
- package/dist/esm-types/cli/lib/deploy2.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployApi/componentDefinition.d.ts +27 -12
- package/dist/esm-types/cli/lib/deployApi/componentDefinition.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deployApi/definitionConfig.d.ts +24 -24
- package/dist/esm-types/cli/lib/deployApi/modules.d.ts +14 -14
- package/dist/esm-types/cli/lib/deployApi/startPush.d.ts +61 -52
- package/dist/esm-types/cli/lib/deployApi/startPush.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploymentSelection.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/deploymentSelector.d.ts +2 -0
- package/dist/esm-types/cli/lib/deploymentSelector.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/dev.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/env.d.ts +0 -4
- package/dist/esm-types/cli/lib/env.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/expiration.d.ts +35 -0
- package/dist/esm-types/cli/lib/expiration.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/expiration.test.d.ts +2 -0
- package/dist/esm-types/cli/lib/expiration.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts +16 -1
- package/dist/esm-types/cli/lib/generatedFunctionLogsApi.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/init.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/anonymous.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/localDeployment.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/run.d.ts +15 -0
- package/dist/esm-types/cli/lib/localDeployment/run.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/upgrade.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/localDeployment/utils.d.ts +7 -0
- package/dist/esm-types/cli/lib/localDeployment/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/mcp/requestContext.d.ts +3 -3
- package/dist/esm-types/cli/lib/mcp/tools/insights.d.ts +2 -2
- package/dist/esm-types/cli/lib/updates.d.ts +4 -3
- package/dist/esm-types/cli/lib/updates.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/usage.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/prompts.d.ts +1 -0
- package/dist/esm-types/cli/lib/utils/prompts.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/utils.d.ts +16 -2
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/versionApi.d.ts +7 -1
- package/dist/esm-types/cli/lib/versionApi.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/workos/workos.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/react/client.d.ts +54 -2
- package/dist/esm-types/react/client.d.ts.map +1 -1
- package/dist/esm-types/react/index.d.ts +7 -2
- package/dist/esm-types/react/index.d.ts.map +1 -1
- package/dist/esm-types/react/use_query_object_options.test.d.ts +5 -0
- package/dist/esm-types/react/use_query_object_options.test.d.ts.map +1 -0
- package/dist/esm-types/react/use_query_result.test.d.ts +5 -0
- package/dist/esm-types/react/use_query_result.test.d.ts.map +1 -0
- package/dist/esm-types/react-clerk/ConvexProviderWithClerk.d.ts +1 -1
- package/dist/esm-types/server/api.d.ts +5 -1
- package/dist/esm-types/server/api.d.ts.map +1 -1
- package/dist/esm-types/server/components/definition.d.ts +1 -0
- package/dist/esm-types/server/components/definition.d.ts.map +1 -1
- package/dist/esm-types/server/components/index.d.ts +5 -1
- package/dist/esm-types/server/components/index.d.ts.map +1 -1
- package/dist/esm-types/server/data_model.d.ts +2 -1
- package/dist/esm-types/server/data_model.d.ts.map +1 -1
- package/dist/esm-types/server/impl/meta_impl.d.ts +5 -0
- package/dist/esm-types/server/impl/meta_impl.d.ts.map +1 -0
- package/dist/esm-types/server/impl/registration_impl.d.ts.map +1 -1
- package/dist/esm-types/server/index.d.ts +1 -0
- package/dist/esm-types/server/index.d.ts.map +1 -1
- package/dist/esm-types/server/meta.d.ts +72 -0
- package/dist/esm-types/server/meta.d.ts.map +1 -0
- package/dist/esm-types/server/registration.d.ts.map +1 -1
- package/dist/react.bundle.js +55 -15
- package/dist/react.bundle.js.map +3 -3
- package/package.json +11 -7
- package/schemas/convex.schema.json +22 -3
- package/src/browser/index.ts +3 -0
- package/src/browser/query_options.test.ts +0 -9
- package/src/browser/query_options.ts +36 -15
- package/src/browser/sync/authentication_manager.ts +9 -4
- package/src/browser/sync/client_node.test.ts +125 -0
- package/src/browser/sync/web_socket_manager.ts +1 -7
- package/src/cli/aiFiles.ts +56 -33
- package/src/cli/codegen_templates/readme.ts +14 -1
- package/src/cli/configure.test.ts +138 -0
- package/src/cli/configure.ts +62 -55
- package/src/cli/deploy.ts +12 -9
- package/src/cli/deploymentCreate.test.ts +349 -14
- package/src/cli/deploymentCreate.ts +268 -41
- package/src/cli/deploymentSelect.test.ts +136 -27
- package/src/cli/deploymentSelect.ts +50 -41
- package/src/cli/deploymentSelection.test.ts +399 -37
- package/src/cli/dev.ts +49 -14
- package/src/cli/docs.ts +1 -1
- package/src/cli/init.ts +2 -2
- package/src/cli/lib/{ai → aiFiles}/MANUAL_TESTING.md +6 -2
- package/src/cli/lib/aiFiles/agentsmd.test.ts +133 -0
- package/src/cli/lib/aiFiles/agentsmd.ts +81 -0
- package/src/cli/lib/aiFiles/claudemd.test.ts +92 -0
- package/src/cli/lib/aiFiles/claudemd.ts +81 -0
- package/src/cli/lib/aiFiles/cursorrules.ts +25 -0
- package/src/cli/lib/aiFiles/guidelinesmd.test.ts +50 -0
- package/src/cli/lib/aiFiles/guidelinesmd.ts +49 -0
- package/src/cli/lib/{ai → aiFiles}/index.test.ts +343 -516
- package/src/cli/lib/aiFiles/index.ts +297 -0
- package/src/cli/lib/{ai → aiFiles}/integration.test.ts +195 -158
- package/src/cli/lib/{ai → aiFiles}/paths.ts +5 -0
- package/src/cli/lib/{ai → aiFiles}/prompt.test.ts +79 -31
- package/src/cli/lib/aiFiles/skills.ts +243 -0
- package/src/cli/lib/aiFiles/state.test.ts +280 -0
- package/src/cli/lib/aiFiles/state.ts +82 -0
- package/src/cli/lib/aiFiles/status.ts +246 -0
- package/src/cli/lib/aiFiles/utils.test.ts +50 -0
- package/src/cli/lib/aiFiles/utils.ts +191 -0
- package/src/cli/lib/api.ts +88 -7
- package/src/cli/lib/command.ts +18 -8
- package/src/cli/lib/config.test.ts +185 -8
- package/src/cli/lib/config.ts +73 -12
- package/src/cli/lib/deploy2.ts +14 -27
- package/src/cli/lib/deployApi/componentDefinition.ts +4 -1
- package/src/cli/lib/deploymentSelection.ts +59 -6
- package/src/cli/lib/deploymentSelector.test.ts +6 -0
- package/src/cli/lib/deploymentSelector.ts +2 -0
- package/src/cli/lib/dev.ts +202 -153
- package/src/cli/lib/env.ts +0 -15
- package/src/cli/lib/expiration.test.ts +159 -0
- package/src/cli/lib/expiration.ts +124 -0
- package/src/cli/lib/generatedFunctionLogsApi.ts +16 -1
- package/src/cli/lib/init.ts +6 -2
- package/src/cli/lib/insights.ts +1 -1
- package/src/cli/lib/localDeployment/anonymous.ts +19 -9
- package/src/cli/lib/localDeployment/localDeployment.ts +9 -11
- package/src/cli/lib/localDeployment/run.ts +1 -1
- package/src/cli/lib/localDeployment/upgrade.ts +12 -10
- package/src/cli/lib/localDeployment/utils.ts +12 -0
- package/src/cli/lib/mcp/tools/status.ts +1 -1
- package/src/cli/lib/updates.test.ts +97 -60
- package/src/cli/lib/updates.ts +17 -15
- package/src/cli/lib/usage.ts +3 -1
- package/src/cli/lib/utils/prompts.ts +2 -0
- package/src/cli/lib/utils/utils.test.ts +6 -6
- package/src/cli/lib/utils/utils.ts +66 -27
- package/src/cli/lib/versionApi.test.ts +13 -10
- package/src/cli/lib/versionApi.ts +13 -5
- package/src/cli/lib/workos/workos.ts +4 -5
- package/src/index.ts +1 -1
- package/src/react/client.test.tsx +65 -0
- package/src/react/client.ts +129 -13
- package/src/react/index.ts +9 -1
- package/src/react/use_query_object_options.test.ts +50 -0
- package/src/react/use_query_result.test.ts +41 -0
- package/src/react-clerk/ConvexProviderWithClerk.test.tsx +1 -1
- package/src/react-clerk/ConvexProviderWithClerk.tsx +1 -1
- package/src/server/api.ts +5 -1
- package/src/server/components/definition.ts +3 -0
- package/src/server/components/index.ts +62 -5
- package/src/server/data_model.ts +2 -1
- package/src/server/impl/meta_impl.ts +74 -0
- package/src/server/impl/registration_impl.ts +21 -9
- package/src/server/index.ts +8 -0
- package/src/server/meta.ts +76 -0
- package/src/server/registration.ts +10 -0
- package/src/server/schema.test.ts +78 -1
- package/dist/cjs/cli/lib/ai/config.js +0 -144
- package/dist/cjs/cli/lib/ai/config.js.map +0 -7
- package/dist/cjs/cli/lib/ai/index.js +0 -704
- package/dist/cjs/cli/lib/ai/index.js.map +0 -7
- package/dist/cjs/cli/lib/ai/paths.js.map +0 -7
- package/dist/cjs-types/cli/lib/ai/config.d.ts +0 -50
- package/dist/cjs-types/cli/lib/ai/config.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/ai/config.test.d.ts +0 -2
- package/dist/cjs-types/cli/lib/ai/config.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/ai/index.d.ts +0 -56
- package/dist/cjs-types/cli/lib/ai/index.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/ai/index.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/ai/integration.test.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/ai/paths.d.ts.map +0 -1
- package/dist/cjs-types/cli/lib/ai/prompt.test.d.ts.map +0 -1
- package/dist/esm/cli/lib/ai/config.js +0 -109
- package/dist/esm/cli/lib/ai/config.js.map +0 -7
- package/dist/esm/cli/lib/ai/index.js +0 -684
- package/dist/esm/cli/lib/ai/index.js.map +0 -7
- package/dist/esm/cli/lib/ai/paths.js.map +0 -7
- package/dist/esm-types/cli/lib/ai/config.d.ts +0 -50
- package/dist/esm-types/cli/lib/ai/config.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/ai/config.test.d.ts +0 -2
- package/dist/esm-types/cli/lib/ai/config.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/ai/index.d.ts +0 -56
- package/dist/esm-types/cli/lib/ai/index.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/ai/index.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/ai/integration.test.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/ai/paths.d.ts.map +0 -1
- package/dist/esm-types/cli/lib/ai/prompt.test.d.ts.map +0 -1
- package/src/cli/lib/ai/config.test.ts +0 -338
- package/src/cli/lib/ai/config.ts +0 -159
- package/src/cli/lib/ai/index.ts +0 -1006
- /package/dist/cjs/cli/lib/{ai → aiFiles}/paths.js +0 -0
- /package/dist/cjs-types/cli/lib/{ai → aiFiles}/index.test.d.ts +0 -0
- /package/dist/cjs-types/cli/lib/{ai → aiFiles}/integration.test.d.ts +0 -0
- /package/dist/cjs-types/cli/lib/{ai → aiFiles}/prompt.test.d.ts +0 -0
- /package/dist/esm/cli/lib/{ai → aiFiles}/paths.js +0 -0
- /package/dist/esm-types/cli/lib/{ai → aiFiles}/index.test.d.ts +0 -0
- /package/dist/esm-types/cli/lib/{ai → aiFiles}/integration.test.d.ts +0 -0
- /package/dist/esm-types/cli/lib/{ai → aiFiles}/prompt.test.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/server/data_model.ts"],
|
|
4
|
-
"sourcesContent": ["import { Value } from \"../values/index.js\";\n\n// Document Types /////////////////////////////////////////////////////////////\n\n/**\n * A document stored in Convex.\n * @public\n */\nexport type GenericDocument = Record<string, Value>;\n\n/**\n * A type describing all of the document fields in a table.\n *\n * These can either be field names (like \"name\") or references to fields on\n * nested objects (like \"properties.name\").\n * @public\n */\nexport type GenericFieldPaths = string;\n\n// Index Types ///////////////////////////////////////////////////////////////\n\n/**\n * A type describing the ordered fields in an index.\n *\n * These can either be field names (like \"name\") or references to fields on\n * nested objects (like \"properties.name\").\n * @public\n */\nexport type GenericIndexFields = string[];\n\n/**\n * A type describing the indexes in a table.\n *\n * It's an object mapping each index name to the fields in the index.\n * @public\n */\nexport type GenericTableIndexes = Record<string, GenericIndexFields>;\n\n/**\n * A type describing the configuration of a search index.\n * @public\n */\nexport type GenericSearchIndexConfig = {\n searchField: string;\n filterFields: string;\n};\n\n/**\n * A type describing all of the search indexes in a table.\n *\n * This is an object mapping each index name to the config for the index.\n * @public\n */\nexport type GenericTableSearchIndexes = Record<\n string,\n GenericSearchIndexConfig\n>;\n\n/**\n * A type describing the configuration of a vector index.\n * @public\n */\nexport type GenericVectorIndexConfig = {\n vectorField: string;\n dimensions: number;\n filterFields: string;\n};\n\n/**\n * A type describing all of the vector indexes in a table.\n *\n * This is an object mapping each index name to the config for the index.\n * @public\n */\nexport type GenericTableVectorIndexes = Record<\n string,\n GenericVectorIndexConfig\n>;\n/**\n * If we have A | B | C, this finds A[Key] | B[Key] | C[Key], where we default to\n * `Default` if the Key isn't found.\n *\n * Conditional types apparently loop over the variants in a union, so the `T extends T`\n * is enough to force this behavior.\n * https://stackoverflow.com/questions/49401866/all-possible-keys-of-an-union-type\n */\n\ntype ValueFromUnion<T, Key, Default> = T extends T\n ? Key extends keyof T\n ? T[Key]\n : Default\n : never;\n\n/**\n * The type of a field in a document.\n *\n * Note that this supports both simple fields like \"name\" and nested fields like\n * \"properties.name\".\n *\n * If the field is not present in the document it is considered to be `undefined`.\n *\n * @public\n */\nexport type FieldTypeFromFieldPath<\n Document extends GenericDocument,\n FieldPath extends string,\n> =\n FieldTypeFromFieldPathInner<Document, FieldPath> extends Value | undefined\n ? FieldTypeFromFieldPathInner<Document, FieldPath>\n : Value | undefined;\n\n/**\n * The inner type of {@link FieldTypeFromFieldPath}.\n *\n * It's wrapped in a helper to coerce the type to `Value | undefined` since some\n * versions of TypeScript fail to infer this type correctly.\n *\n * @public\n */\nexport type FieldTypeFromFieldPathInner<\n Document extends GenericDocument,\n FieldPath extends string,\n> = FieldPath extends `${infer First}.${infer Second}`\n ? ValueFromUnion<\n Document,\n First,\n Record<never, never>\n > extends infer FieldValue\n ? // The fact that `extends infer` extracts the generic document out of a union of a\n // Value and record of Values (GenericDocument) is due to the feature\n // \"Distributive Conditional Types\" in the TypeScript Handbook:\n // https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n FieldValue extends GenericDocument\n ? FieldTypeFromFieldPath<FieldValue, Second>\n : undefined\n : undefined\n : ValueFromUnion<Document, FieldPath, undefined>;\n\n// Table Types /////////////////////////////////////////////////////////////////\n\n/**\n * A type describing the document type and indexes in a table.\n * @public\n */\nexport type GenericTableInfo = {\n document: GenericDocument;\n fieldPaths: GenericFieldPaths;\n indexes: GenericTableIndexes;\n searchIndexes: GenericTableSearchIndexes;\n vectorIndexes: GenericTableVectorIndexes;\n};\n\n/**\n * The type of a document in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type DocumentByInfo<TableInfo extends GenericTableInfo> =\n TableInfo[\"document\"];\n\n/**\n * The field paths in a table for a given {@link GenericTableInfo}.\n *\n * These can either be field names (like \"name\") or references to fields on\n * nested objects (like \"properties.name\").\n * @public\n */\nexport type FieldPaths<TableInfo extends GenericTableInfo> =\n TableInfo[\"fieldPaths\"];\n\n/**\n * The database indexes in a table for a given {@link GenericTableInfo}.\n *\n * This will be an object mapping index names to the fields in the index.\n * @public\n */\nexport type Indexes<TableInfo extends GenericTableInfo> = TableInfo[\"indexes\"];\n\n/**\n * The names of indexes in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type IndexNames<TableInfo extends GenericTableInfo> =\n keyof Indexes<TableInfo>;\n\n/**\n * Extract the fields of an index from a {@link GenericTableInfo} by name.\n * @public\n */\nexport type NamedIndex<\n TableInfo extends GenericTableInfo,\n IndexName extends IndexNames<TableInfo>,\n> = Indexes<TableInfo>[IndexName];\n\n/**\n * The search indexes in a table for a given {@link GenericTableInfo}.\n *\n * This will be an object mapping index names to the search index config.\n * @public\n */\nexport type SearchIndexes<TableInfo extends GenericTableInfo> =\n TableInfo[\"searchIndexes\"];\n\n/**\n * The names of search indexes in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type SearchIndexNames<TableInfo extends GenericTableInfo> =\n keyof SearchIndexes<TableInfo>;\n\n/**\n * Extract the config of a search index from a {@link GenericTableInfo} by name.\n * @public\n */\nexport type NamedSearchIndex<\n TableInfo extends GenericTableInfo,\n IndexName extends SearchIndexNames<TableInfo>,\n> = SearchIndexes<TableInfo>[IndexName];\n\n/**\n * The vector indexes in a table for a given {@link GenericTableInfo}.\n *\n * This will be an object mapping index names to the vector index config.\n * @public\n */\nexport type VectorIndexes<TableInfo extends GenericTableInfo> =\n TableInfo[\"vectorIndexes\"];\n\n/**\n * The names of vector indexes in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type VectorIndexNames<TableInfo extends GenericTableInfo> =\n keyof VectorIndexes<TableInfo>;\n\n/**\n * Extract the config of a vector index from a {@link GenericTableInfo} by name.\n * @public\n */\nexport type NamedVectorIndex<\n TableInfo extends GenericTableInfo,\n IndexName extends VectorIndexNames<TableInfo>,\n> = VectorIndexes<TableInfo>[IndexName];\n\n// Data Model Types ////////////////////////////////////////////////////////////\n\n/**\n * A type describing the tables in a Convex project.\n *\n * This is designed to be code generated with `npx convex dev`.\n * @public\n */\nexport type GenericDataModel = Record<string, GenericTableInfo>;\n\n/**\n * A {@link GenericDataModel} that considers documents to be `any` and does not\n * support indexes.\n *\n * This is the default before a schema is defined.\n * @public\n */\nexport type AnyDataModel = {\n [tableName: string]: {\n document: any;\n fieldPaths: GenericFieldPaths;\n indexes:
|
|
4
|
+
"sourcesContent": ["import { Value } from \"../values/index.js\";\nimport type { SystemIndexes } from \"./system_fields.js\";\n\n// Document Types /////////////////////////////////////////////////////////////\n\n/**\n * A document stored in Convex.\n * @public\n */\nexport type GenericDocument = Record<string, Value>;\n\n/**\n * A type describing all of the document fields in a table.\n *\n * These can either be field names (like \"name\") or references to fields on\n * nested objects (like \"properties.name\").\n * @public\n */\nexport type GenericFieldPaths = string;\n\n// Index Types ///////////////////////////////////////////////////////////////\n\n/**\n * A type describing the ordered fields in an index.\n *\n * These can either be field names (like \"name\") or references to fields on\n * nested objects (like \"properties.name\").\n * @public\n */\nexport type GenericIndexFields = string[];\n\n/**\n * A type describing the indexes in a table.\n *\n * It's an object mapping each index name to the fields in the index.\n * @public\n */\nexport type GenericTableIndexes = Record<string, GenericIndexFields>;\n\n/**\n * A type describing the configuration of a search index.\n * @public\n */\nexport type GenericSearchIndexConfig = {\n searchField: string;\n filterFields: string;\n};\n\n/**\n * A type describing all of the search indexes in a table.\n *\n * This is an object mapping each index name to the config for the index.\n * @public\n */\nexport type GenericTableSearchIndexes = Record<\n string,\n GenericSearchIndexConfig\n>;\n\n/**\n * A type describing the configuration of a vector index.\n * @public\n */\nexport type GenericVectorIndexConfig = {\n vectorField: string;\n dimensions: number;\n filterFields: string;\n};\n\n/**\n * A type describing all of the vector indexes in a table.\n *\n * This is an object mapping each index name to the config for the index.\n * @public\n */\nexport type GenericTableVectorIndexes = Record<\n string,\n GenericVectorIndexConfig\n>;\n/**\n * If we have A | B | C, this finds A[Key] | B[Key] | C[Key], where we default to\n * `Default` if the Key isn't found.\n *\n * Conditional types apparently loop over the variants in a union, so the `T extends T`\n * is enough to force this behavior.\n * https://stackoverflow.com/questions/49401866/all-possible-keys-of-an-union-type\n */\n\ntype ValueFromUnion<T, Key, Default> = T extends T\n ? Key extends keyof T\n ? T[Key]\n : Default\n : never;\n\n/**\n * The type of a field in a document.\n *\n * Note that this supports both simple fields like \"name\" and nested fields like\n * \"properties.name\".\n *\n * If the field is not present in the document it is considered to be `undefined`.\n *\n * @public\n */\nexport type FieldTypeFromFieldPath<\n Document extends GenericDocument,\n FieldPath extends string,\n> =\n FieldTypeFromFieldPathInner<Document, FieldPath> extends Value | undefined\n ? FieldTypeFromFieldPathInner<Document, FieldPath>\n : Value | undefined;\n\n/**\n * The inner type of {@link FieldTypeFromFieldPath}.\n *\n * It's wrapped in a helper to coerce the type to `Value | undefined` since some\n * versions of TypeScript fail to infer this type correctly.\n *\n * @public\n */\nexport type FieldTypeFromFieldPathInner<\n Document extends GenericDocument,\n FieldPath extends string,\n> = FieldPath extends `${infer First}.${infer Second}`\n ? ValueFromUnion<\n Document,\n First,\n Record<never, never>\n > extends infer FieldValue\n ? // The fact that `extends infer` extracts the generic document out of a union of a\n // Value and record of Values (GenericDocument) is due to the feature\n // \"Distributive Conditional Types\" in the TypeScript Handbook:\n // https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n FieldValue extends GenericDocument\n ? FieldTypeFromFieldPath<FieldValue, Second>\n : undefined\n : undefined\n : ValueFromUnion<Document, FieldPath, undefined>;\n\n// Table Types /////////////////////////////////////////////////////////////////\n\n/**\n * A type describing the document type and indexes in a table.\n * @public\n */\nexport type GenericTableInfo = {\n document: GenericDocument;\n fieldPaths: GenericFieldPaths;\n indexes: GenericTableIndexes;\n searchIndexes: GenericTableSearchIndexes;\n vectorIndexes: GenericTableVectorIndexes;\n};\n\n/**\n * The type of a document in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type DocumentByInfo<TableInfo extends GenericTableInfo> =\n TableInfo[\"document\"];\n\n/**\n * The field paths in a table for a given {@link GenericTableInfo}.\n *\n * These can either be field names (like \"name\") or references to fields on\n * nested objects (like \"properties.name\").\n * @public\n */\nexport type FieldPaths<TableInfo extends GenericTableInfo> =\n TableInfo[\"fieldPaths\"];\n\n/**\n * The database indexes in a table for a given {@link GenericTableInfo}.\n *\n * This will be an object mapping index names to the fields in the index.\n * @public\n */\nexport type Indexes<TableInfo extends GenericTableInfo> = TableInfo[\"indexes\"];\n\n/**\n * The names of indexes in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type IndexNames<TableInfo extends GenericTableInfo> =\n keyof Indexes<TableInfo>;\n\n/**\n * Extract the fields of an index from a {@link GenericTableInfo} by name.\n * @public\n */\nexport type NamedIndex<\n TableInfo extends GenericTableInfo,\n IndexName extends IndexNames<TableInfo>,\n> = Indexes<TableInfo>[IndexName];\n\n/**\n * The search indexes in a table for a given {@link GenericTableInfo}.\n *\n * This will be an object mapping index names to the search index config.\n * @public\n */\nexport type SearchIndexes<TableInfo extends GenericTableInfo> =\n TableInfo[\"searchIndexes\"];\n\n/**\n * The names of search indexes in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type SearchIndexNames<TableInfo extends GenericTableInfo> =\n keyof SearchIndexes<TableInfo>;\n\n/**\n * Extract the config of a search index from a {@link GenericTableInfo} by name.\n * @public\n */\nexport type NamedSearchIndex<\n TableInfo extends GenericTableInfo,\n IndexName extends SearchIndexNames<TableInfo>,\n> = SearchIndexes<TableInfo>[IndexName];\n\n/**\n * The vector indexes in a table for a given {@link GenericTableInfo}.\n *\n * This will be an object mapping index names to the vector index config.\n * @public\n */\nexport type VectorIndexes<TableInfo extends GenericTableInfo> =\n TableInfo[\"vectorIndexes\"];\n\n/**\n * The names of vector indexes in a table for a given {@link GenericTableInfo}.\n * @public\n */\nexport type VectorIndexNames<TableInfo extends GenericTableInfo> =\n keyof VectorIndexes<TableInfo>;\n\n/**\n * Extract the config of a vector index from a {@link GenericTableInfo} by name.\n * @public\n */\nexport type NamedVectorIndex<\n TableInfo extends GenericTableInfo,\n IndexName extends VectorIndexNames<TableInfo>,\n> = VectorIndexes<TableInfo>[IndexName];\n\n// Data Model Types ////////////////////////////////////////////////////////////\n\n/**\n * A type describing the tables in a Convex project.\n *\n * This is designed to be code generated with `npx convex dev`.\n * @public\n */\nexport type GenericDataModel = Record<string, GenericTableInfo>;\n\n/**\n * A {@link GenericDataModel} that considers documents to be `any` and does not\n * support indexes.\n *\n * This is the default before a schema is defined.\n * @public\n */\nexport type AnyDataModel = {\n [tableName: string]: {\n document: any;\n fieldPaths: GenericFieldPaths;\n indexes: SystemIndexes;\n searchIndexes: {};\n vectorIndexes: {};\n };\n};\n\n/**\n * A type of all of the table names defined in a {@link GenericDataModel}.\n * @public\n */\nexport type TableNamesInDataModel<DataModel extends GenericDataModel> =\n keyof DataModel & string;\n\n/**\n * Extract the `TableInfo` for a table in a {@link GenericDataModel} by table\n * name.\n *\n * @public\n */\nexport type NamedTableInfo<\n DataModel extends GenericDataModel,\n TableName extends keyof DataModel,\n> = DataModel[TableName];\n\n/**\n * The type of a document in a {@link GenericDataModel} by table name.\n * @public\n */\nexport type DocumentByName<\n DataModel extends GenericDataModel,\n TableName extends TableNamesInDataModel<DataModel>,\n> = DataModel[TableName][\"document\"];\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var meta_impl_exports = {};
|
|
20
|
+
__export(meta_impl_exports, {
|
|
21
|
+
setupActionMeta: () => setupActionMeta,
|
|
22
|
+
setupMutationMeta: () => setupMutationMeta,
|
|
23
|
+
setupQueryMeta: () => setupQueryMeta
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(meta_impl_exports);
|
|
26
|
+
var import_values = require("../../values/index.js");
|
|
27
|
+
var import_syscall = require("./syscall.js");
|
|
28
|
+
async function getTransactionMetrics() {
|
|
29
|
+
let syscallJSON;
|
|
30
|
+
try {
|
|
31
|
+
syscallJSON = await (0, import_syscall.performAsyncSyscall)("1.0/getTransactionMetrics", {});
|
|
32
|
+
} catch (e) {
|
|
33
|
+
if (e.message?.includes("Unknown async operation")) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
"getTransactionMetrics() can only be called from a query or mutation. It is not available in actions or outside of a Convex function."
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
return (0, import_values.jsonToConvex)(syscallJSON);
|
|
41
|
+
}
|
|
42
|
+
async function getFunctionMetadata() {
|
|
43
|
+
const { name, componentPath } = await (0, import_syscall.performAsyncSyscall)(
|
|
44
|
+
"1.0/getFunctionMetadata",
|
|
45
|
+
{}
|
|
46
|
+
);
|
|
47
|
+
return { name, componentPath };
|
|
48
|
+
}
|
|
49
|
+
function setupQueryMeta(visibility) {
|
|
50
|
+
return {
|
|
51
|
+
getFunctionMetadata: async () => ({
|
|
52
|
+
...await getFunctionMetadata(),
|
|
53
|
+
type: "query",
|
|
54
|
+
visibility
|
|
55
|
+
}),
|
|
56
|
+
getTransactionMetrics
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function setupMutationMeta(visibility) {
|
|
60
|
+
return {
|
|
61
|
+
getFunctionMetadata: async () => ({
|
|
62
|
+
...await getFunctionMetadata(),
|
|
63
|
+
type: "mutation",
|
|
64
|
+
visibility
|
|
65
|
+
}),
|
|
66
|
+
getTransactionMetrics
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function setupActionMeta(visibility) {
|
|
70
|
+
return {
|
|
71
|
+
getFunctionMetadata: async () => ({
|
|
72
|
+
...await getFunctionMetadata(),
|
|
73
|
+
type: "action",
|
|
74
|
+
visibility
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=meta_impl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/server/impl/meta_impl.ts"],
|
|
4
|
+
"sourcesContent": ["import { jsonToConvex } from \"../../values/index.js\";\nimport {\n ActionMeta,\n MutationMeta,\n QueryMeta,\n FunctionMetadata,\n TransactionMetrics,\n} from \"../meta.js\";\nimport { performAsyncSyscall } from \"./syscall.js\";\n\nasync function getTransactionMetrics(): Promise<TransactionMetrics> {\n let syscallJSON;\n try {\n syscallJSON = await performAsyncSyscall(\"1.0/getTransactionMetrics\", {});\n } catch (e: any) {\n if (e.message?.includes(\"Unknown async operation\")) {\n throw new Error(\n \"getTransactionMetrics() can only be called from a query or mutation. \" +\n \"It is not available in actions or outside of a Convex function.\",\n );\n }\n throw e;\n }\n return jsonToConvex(syscallJSON) as any;\n}\n\nasync function getFunctionMetadata(): Promise<{\n name: string;\n componentPath: string;\n}> {\n const { name, componentPath } = await performAsyncSyscall(\n \"1.0/getFunctionMetadata\",\n {},\n );\n return { name, componentPath };\n}\n\nexport function setupQueryMeta(\n visibility: FunctionMetadata[\"visibility\"],\n): QueryMeta {\n return {\n getFunctionMetadata: async () => ({\n ...(await getFunctionMetadata()),\n type: \"query\",\n visibility,\n }),\n getTransactionMetrics,\n };\n}\n\nexport function setupMutationMeta(\n visibility: FunctionMetadata[\"visibility\"],\n): MutationMeta {\n return {\n getFunctionMetadata: async () => ({\n ...(await getFunctionMetadata()),\n type: \"mutation\",\n visibility,\n }),\n getTransactionMetrics,\n };\n}\n\nexport function setupActionMeta(\n visibility: FunctionMetadata[\"visibility\"],\n): ActionMeta {\n return {\n getFunctionMetadata: async () => ({\n ...(await getFunctionMetadata()),\n type: \"action\",\n visibility,\n }),\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAQ7B,qBAAoC;AAEpC,eAAe,wBAAqD;AAClE,MAAI;AACJ,MAAI;AACF,kBAAc,UAAM,oCAAoB,6BAA6B,CAAC,CAAC;AAAA,EACzE,SAAS,GAAQ;AACf,QAAI,EAAE,SAAS,SAAS,yBAAyB,GAAG;AAClD,YAAM,IAAI;AAAA,QACR;AAAA,MAEF;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACA,aAAO,4BAAa,WAAW;AACjC;AAEA,eAAe,sBAGZ;AACD,QAAM,EAAE,MAAM,cAAc,IAAI,UAAM;AAAA,IACpC;AAAA,IACA,CAAC;AAAA,EACH;AACA,SAAO,EAAE,MAAM,cAAc;AAC/B;AAEO,SAAS,eACd,YACW;AACX,SAAO;AAAA,IACL,qBAAqB,aAAa;AAAA,MAChC,GAAI,MAAM,oBAAoB;AAAA,MAC9B,MAAM;AAAA,MACN;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,kBACd,YACc;AACd,SAAO;AAAA,IACL,qBAAqB,aAAa;AAAA,MAChC,GAAI,MAAM,oBAAoB;AAAA,MAC9B,MAAM;AAAA,MACN;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,gBACd,YACY;AACZ,SAAO;AAAA,IACL,qBAAqB,aAAa;AAAA,MAChC,GAAI,MAAM,oBAAoB;AAAA,MAC9B,MAAM;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -41,7 +41,8 @@ var import_common = require("../../common/index.js");
|
|
|
41
41
|
var import_syscall = require("./syscall.js");
|
|
42
42
|
var import_validator = require("../../values/validator.js");
|
|
43
43
|
var import_paths = require("../components/paths.js");
|
|
44
|
-
|
|
44
|
+
var import_meta_impl = require("./meta_impl.js");
|
|
45
|
+
async function invokeMutation(func, argsStr, visibility) {
|
|
45
46
|
const requestId = "";
|
|
46
47
|
const args = (0, import_values.jsonToConvex)(JSON.parse(argsStr));
|
|
47
48
|
const mutationCtx = {
|
|
@@ -49,6 +50,7 @@ async function invokeMutation(func, argsStr) {
|
|
|
49
50
|
auth: (0, import_authentication_impl.setupAuth)(requestId),
|
|
50
51
|
storage: (0, import_storage_impl.setupStorageWriter)(requestId),
|
|
51
52
|
scheduler: (0, import_scheduler_impl.setupMutationScheduler)(),
|
|
53
|
+
meta: (0, import_meta_impl.setupMutationMeta)(visibility),
|
|
52
54
|
runQuery: (reference, args2) => runUdf("query", reference, args2),
|
|
53
55
|
runMutation: (reference, args2) => runUdf("mutation", reference, args2)
|
|
54
56
|
};
|
|
@@ -135,7 +137,7 @@ const mutationGeneric = ((functionDefinition) => {
|
|
|
135
137
|
assertNotBrowser();
|
|
136
138
|
func.isMutation = true;
|
|
137
139
|
func.isPublic = true;
|
|
138
|
-
func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr);
|
|
140
|
+
func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr, "public");
|
|
139
141
|
func.exportArgs = exportArgs(functionDefinition);
|
|
140
142
|
func.exportReturns = exportReturns(functionDefinition);
|
|
141
143
|
func._handler = handler;
|
|
@@ -150,19 +152,20 @@ const internalMutationGeneric = ((functionDefinition) => {
|
|
|
150
152
|
assertNotBrowser();
|
|
151
153
|
func.isMutation = true;
|
|
152
154
|
func.isInternal = true;
|
|
153
|
-
func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr);
|
|
155
|
+
func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr, "internal");
|
|
154
156
|
func.exportArgs = exportArgs(functionDefinition);
|
|
155
157
|
func.exportReturns = exportReturns(functionDefinition);
|
|
156
158
|
func._handler = handler;
|
|
157
159
|
return func;
|
|
158
160
|
});
|
|
159
|
-
async function invokeQuery(func, argsStr) {
|
|
161
|
+
async function invokeQuery(func, argsStr, visibility) {
|
|
160
162
|
const requestId = "";
|
|
161
163
|
const args = (0, import_values.jsonToConvex)(JSON.parse(argsStr));
|
|
162
164
|
const queryCtx = {
|
|
163
165
|
db: (0, import_database_impl.setupReader)(),
|
|
164
166
|
auth: (0, import_authentication_impl.setupAuth)(requestId),
|
|
165
167
|
storage: (0, import_storage_impl.setupStorageReader)(requestId),
|
|
168
|
+
meta: (0, import_meta_impl.setupQueryMeta)(visibility),
|
|
166
169
|
runQuery: (reference, args2) => runUdf("query", reference, args2)
|
|
167
170
|
};
|
|
168
171
|
const result = await invokeFunction(func, queryCtx, args);
|
|
@@ -175,7 +178,7 @@ const queryGeneric = ((functionDefinition) => {
|
|
|
175
178
|
assertNotBrowser();
|
|
176
179
|
func.isQuery = true;
|
|
177
180
|
func.isPublic = true;
|
|
178
|
-
func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr);
|
|
181
|
+
func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr, "public");
|
|
179
182
|
func.exportArgs = exportArgs(functionDefinition);
|
|
180
183
|
func.exportReturns = exportReturns(functionDefinition);
|
|
181
184
|
func._handler = handler;
|
|
@@ -187,13 +190,13 @@ const internalQueryGeneric = ((functionDefinition) => {
|
|
|
187
190
|
assertNotBrowser();
|
|
188
191
|
func.isQuery = true;
|
|
189
192
|
func.isInternal = true;
|
|
190
|
-
func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr);
|
|
193
|
+
func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr, "internal");
|
|
191
194
|
func.exportArgs = exportArgs(functionDefinition);
|
|
192
195
|
func.exportReturns = exportReturns(functionDefinition);
|
|
193
196
|
func._handler = handler;
|
|
194
197
|
return func;
|
|
195
198
|
});
|
|
196
|
-
async function invokeAction(func, requestId, argsStr) {
|
|
199
|
+
async function invokeAction(func, requestId, argsStr, visibility) {
|
|
197
200
|
const args = (0, import_values.jsonToConvex)(JSON.parse(argsStr));
|
|
198
201
|
const calls = (0, import_actions_impl.setupActionCalls)(requestId);
|
|
199
202
|
const ctx = {
|
|
@@ -201,7 +204,8 @@ async function invokeAction(func, requestId, argsStr) {
|
|
|
201
204
|
auth: (0, import_authentication_impl.setupAuth)(requestId),
|
|
202
205
|
scheduler: (0, import_scheduler_impl.setupActionScheduler)(requestId),
|
|
203
206
|
storage: (0, import_storage_impl.setupStorageActionWriter)(requestId),
|
|
204
|
-
vectorSearch: (0, import_vector_search_impl.setupActionVectorSearch)(requestId)
|
|
207
|
+
vectorSearch: (0, import_vector_search_impl.setupActionVectorSearch)(requestId),
|
|
208
|
+
meta: (0, import_meta_impl.setupActionMeta)(visibility)
|
|
205
209
|
};
|
|
206
210
|
const result = await invokeFunction(func, ctx, args);
|
|
207
211
|
return JSON.stringify((0, import_values.convexToJson)(result === void 0 ? null : result));
|
|
@@ -212,7 +216,7 @@ const actionGeneric = ((functionDefinition) => {
|
|
|
212
216
|
assertNotBrowser();
|
|
213
217
|
func.isAction = true;
|
|
214
218
|
func.isPublic = true;
|
|
215
|
-
func.invokeAction = (requestId, argsStr) => invokeAction(handler, requestId, argsStr);
|
|
219
|
+
func.invokeAction = (requestId, argsStr) => invokeAction(handler, requestId, argsStr, "public");
|
|
216
220
|
func.exportArgs = exportArgs(functionDefinition);
|
|
217
221
|
func.exportReturns = exportReturns(functionDefinition);
|
|
218
222
|
func._handler = handler;
|
|
@@ -224,7 +228,7 @@ const internalActionGeneric = ((functionDefinition) => {
|
|
|
224
228
|
assertNotBrowser();
|
|
225
229
|
func.isAction = true;
|
|
226
230
|
func.isInternal = true;
|
|
227
|
-
func.invokeAction = (requestId, argsStr) => invokeAction(handler, requestId, argsStr);
|
|
231
|
+
func.invokeAction = (requestId, argsStr) => invokeAction(handler, requestId, argsStr, "internal");
|
|
228
232
|
func.exportArgs = exportArgs(functionDefinition);
|
|
229
233
|
func.exportReturns = exportReturns(functionDefinition);
|
|
230
234
|
func._handler = handler;
|
|
@@ -238,7 +242,8 @@ async function invokeHttpAction(func, request) {
|
|
|
238
242
|
auth: (0, import_authentication_impl.setupAuth)(requestId),
|
|
239
243
|
storage: (0, import_storage_impl.setupStorageActionWriter)(requestId),
|
|
240
244
|
scheduler: (0, import_scheduler_impl.setupActionScheduler)(requestId),
|
|
241
|
-
vectorSearch: (0, import_vector_search_impl.setupActionVectorSearch)(requestId)
|
|
245
|
+
vectorSearch: (0, import_vector_search_impl.setupActionVectorSearch)(requestId),
|
|
246
|
+
meta: (0, import_meta_impl.setupActionMeta)("public")
|
|
242
247
|
};
|
|
243
248
|
return await invokeFunction(func, ctx, [request]);
|
|
244
249
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/server/impl/registration_impl.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ConvexError,\n convexToJson,\n GenericValidator,\n jsonToConvex,\n v,\n Validator,\n Value,\n} from \"../../values/index.js\";\nimport { GenericDataModel } from \"../data_model.js\";\nimport {\n ActionBuilder,\n DefaultFunctionArgs,\n GenericActionCtx,\n GenericMutationCtx,\n GenericQueryCtx,\n MutationBuilder,\n PublicHttpAction,\n QueryBuilder,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n} from \"../registration.js\";\nimport { setupActionCalls } from \"./actions_impl.js\";\nimport { setupActionVectorSearch } from \"./vector_search_impl.js\";\nimport { setupAuth } from \"./authentication_impl.js\";\nimport { setupReader, setupWriter } from \"./database_impl.js\";\nimport { QueryImpl, QueryInitializerImpl } from \"./query_impl.js\";\nimport {\n setupActionScheduler,\n setupMutationScheduler,\n} from \"./scheduler_impl.js\";\nimport {\n setupStorageActionWriter,\n setupStorageReader,\n setupStorageWriter,\n} from \"./storage_impl.js\";\nimport { parseArgs } from \"../../common/index.js\";\nimport { performAsyncSyscall } from \"./syscall.js\";\nimport { asObjectValidator } from \"../../values/validator.js\";\nimport { getFunctionAddress } from \"../components/paths.js\";\n\nasync function invokeMutation<\n F extends (ctx: GenericMutationCtx<GenericDataModel>, ...args: any) => any,\n>(func: F, argsStr: string) {\n // TODO(presley): Change the function signature and propagate the requestId from Rust.\n // Ok, to mock it out for now, since queries are only running in V8.\n const requestId = \"\";\n const args = jsonToConvex(JSON.parse(argsStr));\n const mutationCtx = {\n db: setupWriter(),\n auth: setupAuth(requestId),\n storage: setupStorageWriter(requestId),\n scheduler: setupMutationScheduler(),\n\n runQuery: (reference: any, args?: any) => runUdf(\"query\", reference, args),\n runMutation: (reference: any, args?: any) =>\n runUdf(\"mutation\", reference, args),\n };\n const result = await invokeFunction(func, mutationCtx, args as any);\n validateReturnValue(result);\n return JSON.stringify(convexToJson(result === undefined ? null : result));\n}\n\nexport function validateReturnValue(v: any) {\n if (v instanceof QueryInitializerImpl || v instanceof QueryImpl) {\n throw new Error(\n \"Return value is a Query. Results must be retrieved with `.collect()`, `.take(n), `.unique()`, or `.first()`.\",\n );\n }\n}\n\nexport async function invokeFunction<\n Ctx,\n Args extends any[],\n F extends (ctx: Ctx, ...args: Args) => any,\n>(func: F, ctx: Ctx, args: Args) {\n let result;\n try {\n result = await Promise.resolve(func(ctx, ...args));\n } catch (thrown: unknown) {\n throw serializeConvexErrorData(thrown);\n }\n return result;\n}\n\nfunction dontCallDirectly(\n funcType: string,\n handler: (ctx: any, args: any) => any,\n): unknown {\n return (ctx: any, args: any) => {\n globalThis.console.warn(\n \"Convex functions should not directly call other Convex functions. Consider calling a helper function instead. \" +\n `e.g. \\`export const foo = ${funcType}(...); await foo(ctx);\\` is not supported. ` +\n \"See https://docs.convex.dev/production/best-practices/#use-helper-functions-to-write-shared-code\",\n );\n return handler(ctx, args);\n };\n}\n\n// Keep in sync with node executor\nfunction serializeConvexErrorData(thrown: unknown) {\n if (\n typeof thrown === \"object\" &&\n thrown !== null &&\n Symbol.for(\"ConvexError\") in thrown\n ) {\n const error = thrown as ConvexError<any>;\n error.data = JSON.stringify(\n convexToJson(error.data === undefined ? null : error.data),\n );\n (error as any).ConvexErrorSymbol = Symbol.for(\"ConvexError\");\n return error;\n } else {\n return thrown;\n }\n}\n\n/**\n * Guard against Convex functions accidentally getting included in a browser bundle.\n * Convex functions may include secret logic or credentials that should not be\n * send to untrusted clients (browsers).\n */\nfunction assertNotBrowser() {\n if (\n typeof window === \"undefined\" ||\n (window as any).__convexAllowFunctionsInBrowser\n ) {\n return;\n }\n // JSDom doesn't count, developers are allowed to use JSDom in Convex functions.\n const isRealBrowser =\n Object.getOwnPropertyDescriptor(globalThis, \"window\")\n ?.get?.toString()\n .includes(\"[native code]\") ?? false;\n if (isRealBrowser) {\n // eslint-disable-next-line no-console\n console.error(\n \"Convex functions should not be imported in the browser. This will throw an error in future versions of `convex`. If this is a false negative, please report it to Convex support.\",\n );\n }\n}\n\ntype FunctionDefinition =\n | ((ctx: any, args: DefaultFunctionArgs) => any)\n | {\n args?: GenericValidator | Record<string, GenericValidator>;\n returns?: GenericValidator | Record<string, GenericValidator>;\n handler: (ctx: any, args: DefaultFunctionArgs) => any;\n };\n\nfunction strictReplacer(key: string, value: any) {\n if (value === undefined) {\n throw new Error(\n `A validator is undefined for field \"${key}\". ` +\n `This is often caused by circular imports. ` +\n `See https://docs.convex.dev/error#undefined-validator for details.`,\n );\n }\n return value;\n}\nfunction exportArgs(functionDefinition: FunctionDefinition) {\n return () => {\n let args: GenericValidator = v.any();\n if (\n typeof functionDefinition === \"object\" &&\n functionDefinition.args !== undefined\n ) {\n args = asObjectValidator(functionDefinition.args);\n }\n return JSON.stringify(args.json, strictReplacer);\n };\n}\n\nfunction exportReturns(functionDefinition: FunctionDefinition) {\n return () => {\n let returns: Validator<any, any, any> | undefined;\n if (\n typeof functionDefinition === \"object\" &&\n functionDefinition.returns !== undefined\n ) {\n returns = asObjectValidator(functionDefinition.returns);\n }\n return JSON.stringify(returns ? returns.json : null, strictReplacer);\n };\n}\n\n/**\n * Define a mutation in this Convex app's public API.\n *\n * You should generally use the `mutation` function from\n * `\"./_generated/server\"`.\n *\n * Mutations can read from and write to the database, and are accessible from\n * the client. They run **transactionally**, all database reads and writes\n * within a single mutation are atomic and isolated from other mutations.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const createTask = mutation({\n * args: { text: v.string() },\n * returns: v.id(\"tasks\"),\n * handler: async (ctx, args) => {\n * const taskId = await ctx.db.insert(\"tasks\", {\n * text: args.text,\n * completed: false,\n * });\n * return taskId;\n * },\n * });\n * ```\n *\n * **Best practice:** Always include `args` and `returns` validators on all\n * mutations. If the function doesn't return a value, use `returns: v.null()`.\n * Argument validation is critical for security since public mutations are\n * exposed to the internet.\n *\n * **Common mistake:** Mutations cannot call third-party APIs or use `fetch`.\n * They must be deterministic. Use actions for external API calls.\n *\n * **Common mistake:** Do not use `mutation` for sensitive internal functions\n * that should not be called by clients. Use `internalMutation` instead.\n *\n * @param func - The mutation function. It receives a {@link GenericMutationCtx} as its first argument.\n * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/mutation-functions\n * @public\n */\nexport const mutationGeneric: MutationBuilder<any, \"public\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericMutationCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"mutation\", handler) as RegisteredMutation<\n \"public\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isMutation = true;\n func.isPublic = true;\n func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr);\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as MutationBuilder<any, \"public\">;\n\n/**\n * Define a mutation that is only accessible from other Convex functions (but not from the client).\n *\n * You should generally use the `internalMutation` function from\n * `\"./_generated/server\"`.\n *\n * Internal mutations can read from and write to the database but are **not**\n * exposed as part of your app's public API. They can only be called by other\n * Convex functions using `ctx.runMutation` or by the scheduler. Like public\n * mutations, they run transactionally.\n *\n * @example\n * ```typescript\n * import { internalMutation } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * // This mutation can only be called from other Convex functions:\n * export const markTaskCompleted = internalMutation({\n * args: { taskId: v.id(\"tasks\") },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * await ctx.db.patch(\"tasks\", args.taskId, { completed: true });\n * return null;\n * },\n * });\n * ```\n *\n * **Best practice:** Use `internalMutation` for any mutation that should not\n * be directly callable by clients, such as write-back functions from actions\n * or scheduled background work. Reference it via the `internal` object:\n * `await ctx.runMutation(internal.myModule.markTaskCompleted, { taskId })`.\n *\n * @param func - The mutation function. It receives a {@link GenericMutationCtx} as its first argument.\n * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/internal-functions\n * @public\n */\nexport const internalMutationGeneric: MutationBuilder<any, \"internal\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericMutationCtx<any>, args: any) => any;\n const func = dontCallDirectly(\n \"internalMutation\",\n handler,\n ) as RegisteredMutation<\"internal\", any, any>;\n\n assertNotBrowser();\n func.isMutation = true;\n func.isInternal = true;\n func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr);\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as MutationBuilder<any, \"internal\">;\n\nasync function invokeQuery<\n F extends (ctx: GenericQueryCtx<GenericDataModel>, ...args: any) => any,\n>(func: F, argsStr: string) {\n // TODO(presley): Change the function signature and propagate the requestId from Rust.\n // Ok, to mock it out for now, since queries are only running in V8.\n const requestId = \"\";\n const args = jsonToConvex(JSON.parse(argsStr));\n const queryCtx = {\n db: setupReader(),\n auth: setupAuth(requestId),\n storage: setupStorageReader(requestId),\n runQuery: (reference: any, args?: any) => runUdf(\"query\", reference, args),\n };\n const result = await invokeFunction(func, queryCtx, args as any);\n validateReturnValue(result);\n return JSON.stringify(convexToJson(result === undefined ? null : result));\n}\n\n/**\n * Define a query in this Convex app's public API.\n *\n * You should generally use the `query` function from\n * `\"./_generated/server\"`.\n *\n * Queries can read from the database and are accessible from the client. They\n * are **reactive**, when used with `useQuery` in React, the component\n * automatically re-renders whenever the underlying data changes. Queries\n * cannot modify the database.\n * Query results are automatically cached by the Convex client and kept\n * consistent via WebSocket subscriptions.\n *\n *\n * @example\n * ```typescript\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const listTasks = query({\n * args: { completed: v.optional(v.boolean()) },\n * returns: v.array(v.object({\n * _id: v.id(\"tasks\"),\n * _creationTime: v.number(),\n * text: v.string(),\n * completed: v.boolean(),\n * })),\n * handler: async (ctx, args) => {\n * if (args.completed !== undefined) {\n * return await ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_completed\", (q) => q.eq(\"completed\", args.completed))\n * .collect();\n * }\n * return await ctx.db.query(\"tasks\").collect();\n * },\n * });\n * ```\n *\n * **Best practice:** Always include `args` and `returns` validators. Use\n * `.withIndex()` instead of `.filter()` for efficient database queries.\n * Queries should be fast since they run on every relevant data change.\n *\n * **Common mistake:** Queries are pure reads, they cannot write to the\n * database, call external APIs, or schedule functions. Use actions for HTTP\n * calls and mutations for database writes and scheduling.\n *\n * @param func - The query function. It receives a {@link GenericQueryCtx} as its first argument.\n * @returns The wrapped query. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/query-functions\n * @public\n */\nexport const queryGeneric: QueryBuilder<any, \"public\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericQueryCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"query\", handler) as RegisteredQuery<\n \"public\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isQuery = true;\n func.isPublic = true;\n func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr);\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as QueryBuilder<any, \"public\">;\n\n/**\n * Define a query that is only accessible from other Convex functions (but not from the client).\n *\n * You should generally use the `internalQuery` function from\n * `\"./_generated/server\"`.\n *\n * Internal queries can read from the database but are **not** exposed as part\n * of your app's public API. They can only be called by other Convex functions\n * using `ctx.runQuery`. This is useful for loading data in actions or for\n * helper queries that shouldn't be client-facing.\n *\n * @example\n * ```typescript\n * import { internalQuery } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * // Only callable from other Convex functions:\n * export const getUser = internalQuery({\n * args: { userId: v.id(\"users\") },\n * returns: v.union(\n * v.object({\n * _id: v.id(\"users\"),\n * _creationTime: v.number(),\n * name: v.string(),\n * email: v.string(),\n * }),\n * v.null(),\n * ),\n * handler: async (ctx, args) => {\n * return await ctx.db.get(\"users\", args.userId);\n * },\n * });\n * ```\n *\n * **Best practice:** Use `internalQuery` for data-loading in actions via\n * `ctx.runQuery(internal.myModule.getUser, { userId })`.\n *\n * @param func - The query function. It receives a {@link GenericQueryCtx} as its first argument.\n * @returns The wrapped query. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/internal-functions\n * @public\n */\nexport const internalQueryGeneric: QueryBuilder<any, \"internal\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericQueryCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"internalQuery\", handler) as RegisteredQuery<\n \"internal\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isQuery = true;\n func.isInternal = true;\n func.invokeQuery = (argsStr) => invokeQuery(handler as any, argsStr);\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as QueryBuilder<any, \"internal\">;\n\nasync function invokeAction<\n F extends (ctx: GenericActionCtx<GenericDataModel>, ...args: any) => any,\n>(func: F, requestId: string, argsStr: string) {\n const args = jsonToConvex(JSON.parse(argsStr));\n const calls = setupActionCalls(requestId);\n const ctx = {\n ...calls,\n auth: setupAuth(requestId),\n scheduler: setupActionScheduler(requestId),\n storage: setupStorageActionWriter(requestId),\n vectorSearch: setupActionVectorSearch(requestId) as any,\n };\n const result = await invokeFunction(func, ctx, args as any);\n return JSON.stringify(convexToJson(result === undefined ? null : result));\n}\n\n/**\n * Define an action in this Convex app's public API.\n *\n * Actions can call third-party APIs, use Node.js libraries, and perform other\n * side effects. Unlike queries and mutations, actions do **not** have direct\n * database access (`ctx.db` is not available). Instead, use `ctx.runQuery`\n * and `ctx.runMutation` to read and write data.\n *\n * You should generally use the `action` function from\n * `\"./_generated/server\"`.\n *\n * Actions are accessible from the client and run outside of the database\n * transaction, so they are not atomic. They are best for integrating with\n * external services.\n *\n * @example\n * ```typescript\n * // Add \"use node\"; at the top of the file if using Node.js built-in modules.\n * import { action } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n * import { internal } from \"./_generated/api\";\n *\n * export const generateSummary = action({\n * args: { text: v.string() },\n * returns: v.string(),\n * handler: async (ctx, args) => {\n * // Call an external API:\n * const response = await fetch(\"https://api.example.com/summarize\", {\n * method: \"POST\",\n * body: JSON.stringify({ text: args.text }),\n * });\n * const { summary } = await response.json();\n *\n * // Write results back via a mutation:\n * await ctx.runMutation(internal.myModule.saveSummary, {\n * text: args.text,\n * summary,\n * });\n *\n * return summary;\n * },\n * });\n * ```\n *\n * **Best practice:** Minimize the number of `ctx.runQuery` and\n * `ctx.runMutation` calls from actions. Each call is a separate transaction,\n * so splitting logic across multiple calls introduces the risk of race\n * conditions. Try to batch reads/writes into single query/mutation calls.\n *\n * **`\"use node\"` runtime:** Actions run in Convex's default JavaScript\n * runtime, which supports `fetch` and most NPM packages. Only add\n * `\"use node\";` at the top of the file if a third-party library specifically\n * requires Node.js built-in APIs, it is a last resort, not the default.\n * Node.js actions have slower cold starts, and **only actions can be defined\n * in `\"use node\"` files** (no queries or mutations), so prefer the default\n * runtime whenever possible.\n *\n * **Common mistake:** Do not try to access `ctx.db` in an action, it is\n * not available. Use `ctx.runQuery` and `ctx.runMutation` instead.\n *\n * @param func - The function. It receives a {@link GenericActionCtx} as its first argument.\n * @returns The wrapped function. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/actions\n * @public\n */\nexport const actionGeneric: ActionBuilder<any, \"public\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericActionCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"action\", handler) as RegisteredAction<\n \"public\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isAction = true;\n func.isPublic = true;\n func.invokeAction = (requestId, argsStr) =>\n invokeAction(handler, requestId, argsStr);\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as ActionBuilder<any, \"public\">;\n\n/**\n * Define an action that is only accessible from other Convex functions (but not from the client).\n *\n * You should generally use the `internalAction` function from\n * `\"./_generated/server\"`.\n *\n * Internal actions behave like public actions (they can call external APIs and\n * use Node.js libraries) but are **not** exposed in your app's public API. They\n * can only be called by other Convex functions using `ctx.runAction` or via the\n * scheduler.\n *\n * @example\n * ```typescript\n * import { internalAction } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const sendEmail = internalAction({\n * args: { to: v.string(), subject: v.string(), body: v.string() },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * // Call an external email service (fetch works in the default runtime):\n * await fetch(\"https://api.email-service.com/send\", {\n * method: \"POST\",\n * headers: { \"Content-Type\": \"application/json\" },\n * body: JSON.stringify(args),\n * });\n * return null;\n * },\n * });\n * ```\n *\n * **Best practice:** Use `internalAction` for background work scheduled from\n * mutations: `await ctx.scheduler.runAfter(0, internal.myModule.sendEmail, { ... })`.\n * Only use `ctx.runAction` from another action if you need to cross runtimes\n * (e.g., default Convex runtime to Node.js). Otherwise, extract shared code\n * into a helper function.\n *\n * **`\"use node\"` runtime:** Only add `\"use node\";` at the top of the file\n * as a last resort when a third-party library requires Node.js APIs. Node.js\n * actions have slower cold starts, and **only actions can be defined in\n * `\"use node\"` files** (no queries or mutations).\n *\n * @param func - The function. It receives a {@link GenericActionCtx} as its first argument.\n * @returns The wrapped function. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/internal-functions\n * @public\n */\nexport const internalActionGeneric: ActionBuilder<any, \"internal\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericActionCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"internalAction\", handler) as RegisteredAction<\n \"internal\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isAction = true;\n func.isInternal = true;\n func.invokeAction = (requestId, argsStr) =>\n invokeAction(handler, requestId, argsStr);\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as ActionBuilder<any, \"internal\">;\n\nasync function invokeHttpAction<\n F extends (ctx: GenericActionCtx<GenericDataModel>, request: Request) => any,\n>(func: F, request: Request) {\n // TODO(presley): Change the function signature and propagate the requestId from Rust.\n // Ok, to mock it out for now, since http endpoints are only running in V8.\n const requestId = \"\";\n const calls = setupActionCalls(requestId);\n const ctx = {\n ...calls,\n auth: setupAuth(requestId),\n storage: setupStorageActionWriter(requestId),\n scheduler: setupActionScheduler(requestId),\n vectorSearch: setupActionVectorSearch(requestId) as any,\n };\n return await invokeFunction(func, ctx, [request]);\n}\n\n/**\n * Define a Convex HTTP action.\n *\n * HTTP actions handle raw HTTP requests and return HTTP responses. They are\n * registered by routing URL paths to them in `convex/http.ts` using\n * {@link HttpRouter}. Like regular actions, they can call external APIs and\n * use `ctx.runQuery` / `ctx.runMutation` but do not have direct `ctx.db` access.\n *\n * @example\n * ```typescript\n * // convex/http.ts\n * import { httpRouter } from \"convex/server\";\n * import { httpAction } from \"./_generated/server\";\n *\n * const http = httpRouter();\n *\n * http.route({\n * path: \"/api/webhook\",\n * method: \"POST\",\n * handler: httpAction(async (ctx, request) => {\n * const body = await request.json();\n * // Process the webhook payload...\n * return new Response(JSON.stringify({ ok: true }), {\n * status: 200,\n * headers: { \"Content-Type\": \"application/json\" },\n * });\n * }),\n * });\n *\n * export default http;\n * ```\n *\n * **Best practice:** HTTP actions are registered at the exact path specified.\n * For example, `path: \"/api/webhook\"` registers at `/api/webhook`.\n *\n * @param func - The function. It receives a {@link GenericActionCtx} as its first argument, and a `Request` object\n * as its second.\n * @returns The wrapped function. Route a URL path to this function in `convex/http.ts`.\n *\n * @see https://docs.convex.dev/functions/http-actions\n * @public\n */\nexport const httpActionGeneric = (\n func: (\n ctx: GenericActionCtx<GenericDataModel>,\n request: Request,\n ) => Promise<Response>,\n): PublicHttpAction => {\n const q = dontCallDirectly(\"httpAction\", func) as PublicHttpAction;\n assertNotBrowser();\n q.isHttp = true;\n q.invokeHttpAction = (request) => invokeHttpAction(func as any, request);\n q._handler = func;\n return q;\n};\n\nasync function runUdf(\n udfType: \"query\" | \"mutation\",\n f: any,\n args?: Record<string, Value>,\n): Promise<any> {\n const queryArgs = parseArgs(args);\n const syscallArgs = {\n udfType,\n args: convexToJson(queryArgs),\n ...getFunctionAddress(f),\n };\n const result = await performAsyncSyscall(\"1.0/runUdf\", syscallArgs);\n return jsonToConvex(result);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;
|
|
4
|
+
"sourcesContent": ["import {\n ConvexError,\n convexToJson,\n GenericValidator,\n jsonToConvex,\n v,\n Validator,\n Value,\n} from \"../../values/index.js\";\nimport { GenericDataModel } from \"../data_model.js\";\nimport {\n ActionBuilder,\n DefaultFunctionArgs,\n FunctionVisibility,\n GenericActionCtx,\n GenericMutationCtx,\n GenericQueryCtx,\n MutationBuilder,\n PublicHttpAction,\n QueryBuilder,\n RegisteredAction,\n RegisteredMutation,\n RegisteredQuery,\n} from \"../registration.js\";\nimport { setupActionCalls } from \"./actions_impl.js\";\nimport { setupActionVectorSearch } from \"./vector_search_impl.js\";\nimport { setupAuth } from \"./authentication_impl.js\";\nimport { setupReader, setupWriter } from \"./database_impl.js\";\nimport { QueryImpl, QueryInitializerImpl } from \"./query_impl.js\";\nimport {\n setupActionScheduler,\n setupMutationScheduler,\n} from \"./scheduler_impl.js\";\nimport {\n setupStorageActionWriter,\n setupStorageReader,\n setupStorageWriter,\n} from \"./storage_impl.js\";\nimport { parseArgs } from \"../../common/index.js\";\nimport { performAsyncSyscall } from \"./syscall.js\";\nimport { asObjectValidator } from \"../../values/validator.js\";\nimport { getFunctionAddress } from \"../components/paths.js\";\nimport {\n setupQueryMeta,\n setupMutationMeta,\n setupActionMeta,\n} from \"./meta_impl.js\";\n\nasync function invokeMutation<\n F extends (ctx: GenericMutationCtx<GenericDataModel>, ...args: any) => any,\n>(func: F, argsStr: string, visibility: FunctionVisibility) {\n // TODO(presley): Change the function signature and propagate the requestId from Rust.\n // Ok, to mock it out for now, since queries are only running in V8.\n const requestId = \"\";\n const args = jsonToConvex(JSON.parse(argsStr));\n const mutationCtx = {\n db: setupWriter(),\n auth: setupAuth(requestId),\n storage: setupStorageWriter(requestId),\n scheduler: setupMutationScheduler(),\n meta: setupMutationMeta(visibility),\n\n runQuery: (reference: any, args?: any) => runUdf(\"query\", reference, args),\n runMutation: (reference: any, args?: any) =>\n runUdf(\"mutation\", reference, args),\n };\n const result = await invokeFunction(func, mutationCtx, args as any);\n validateReturnValue(result);\n return JSON.stringify(convexToJson(result === undefined ? null : result));\n}\n\nexport function validateReturnValue(v: any) {\n if (v instanceof QueryInitializerImpl || v instanceof QueryImpl) {\n throw new Error(\n \"Return value is a Query. Results must be retrieved with `.collect()`, `.take(n), `.unique()`, or `.first()`.\",\n );\n }\n}\n\nexport async function invokeFunction<\n Ctx,\n Args extends any[],\n F extends (ctx: Ctx, ...args: Args) => any,\n>(func: F, ctx: Ctx, args: Args) {\n let result;\n try {\n result = await Promise.resolve(func(ctx, ...args));\n } catch (thrown: unknown) {\n throw serializeConvexErrorData(thrown);\n }\n return result;\n}\n\nfunction dontCallDirectly(\n funcType: string,\n handler: (ctx: any, args: any) => any,\n): unknown {\n return (ctx: any, args: any) => {\n globalThis.console.warn(\n \"Convex functions should not directly call other Convex functions. Consider calling a helper function instead. \" +\n `e.g. \\`export const foo = ${funcType}(...); await foo(ctx);\\` is not supported. ` +\n \"See https://docs.convex.dev/production/best-practices/#use-helper-functions-to-write-shared-code\",\n );\n return handler(ctx, args);\n };\n}\n\n// Keep in sync with node executor\nfunction serializeConvexErrorData(thrown: unknown) {\n if (\n typeof thrown === \"object\" &&\n thrown !== null &&\n Symbol.for(\"ConvexError\") in thrown\n ) {\n const error = thrown as ConvexError<any>;\n error.data = JSON.stringify(\n convexToJson(error.data === undefined ? null : error.data),\n );\n (error as any).ConvexErrorSymbol = Symbol.for(\"ConvexError\");\n return error;\n } else {\n return thrown;\n }\n}\n\n/**\n * Guard against Convex functions accidentally getting included in a browser bundle.\n * Convex functions may include secret logic or credentials that should not be\n * send to untrusted clients (browsers).\n */\nfunction assertNotBrowser() {\n if (\n typeof window === \"undefined\" ||\n (window as any).__convexAllowFunctionsInBrowser\n ) {\n return;\n }\n // JSDom doesn't count, developers are allowed to use JSDom in Convex functions.\n const isRealBrowser =\n Object.getOwnPropertyDescriptor(globalThis, \"window\")\n ?.get?.toString()\n .includes(\"[native code]\") ?? false;\n if (isRealBrowser) {\n // eslint-disable-next-line no-console\n console.error(\n \"Convex functions should not be imported in the browser. This will throw an error in future versions of `convex`. If this is a false negative, please report it to Convex support.\",\n );\n }\n}\n\ntype FunctionDefinition =\n | ((ctx: any, args: DefaultFunctionArgs) => any)\n | {\n args?: GenericValidator | Record<string, GenericValidator>;\n returns?: GenericValidator | Record<string, GenericValidator>;\n handler: (ctx: any, args: DefaultFunctionArgs) => any;\n };\n\nfunction strictReplacer(key: string, value: any) {\n if (value === undefined) {\n throw new Error(\n `A validator is undefined for field \"${key}\". ` +\n `This is often caused by circular imports. ` +\n `See https://docs.convex.dev/error#undefined-validator for details.`,\n );\n }\n return value;\n}\nfunction exportArgs(functionDefinition: FunctionDefinition) {\n return () => {\n let args: GenericValidator = v.any();\n if (\n typeof functionDefinition === \"object\" &&\n functionDefinition.args !== undefined\n ) {\n args = asObjectValidator(functionDefinition.args);\n }\n return JSON.stringify(args.json, strictReplacer);\n };\n}\n\nfunction exportReturns(functionDefinition: FunctionDefinition) {\n return () => {\n let returns: Validator<any, any, any> | undefined;\n if (\n typeof functionDefinition === \"object\" &&\n functionDefinition.returns !== undefined\n ) {\n returns = asObjectValidator(functionDefinition.returns);\n }\n return JSON.stringify(returns ? returns.json : null, strictReplacer);\n };\n}\n\n/**\n * Define a mutation in this Convex app's public API.\n *\n * You should generally use the `mutation` function from\n * `\"./_generated/server\"`.\n *\n * Mutations can read from and write to the database, and are accessible from\n * the client. They run **transactionally**, all database reads and writes\n * within a single mutation are atomic and isolated from other mutations.\n *\n * @example\n * ```typescript\n * import { mutation } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const createTask = mutation({\n * args: { text: v.string() },\n * returns: v.id(\"tasks\"),\n * handler: async (ctx, args) => {\n * const taskId = await ctx.db.insert(\"tasks\", {\n * text: args.text,\n * completed: false,\n * });\n * return taskId;\n * },\n * });\n * ```\n *\n * **Best practice:** Always include `args` and `returns` validators on all\n * mutations. If the function doesn't return a value, use `returns: v.null()`.\n * Argument validation is critical for security since public mutations are\n * exposed to the internet.\n *\n * **Common mistake:** Mutations cannot call third-party APIs or use `fetch`.\n * They must be deterministic. Use actions for external API calls.\n *\n * **Common mistake:** Do not use `mutation` for sensitive internal functions\n * that should not be called by clients. Use `internalMutation` instead.\n *\n * @param func - The mutation function. It receives a {@link GenericMutationCtx} as its first argument.\n * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/mutation-functions\n * @public\n */\nexport const mutationGeneric: MutationBuilder<any, \"public\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericMutationCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"mutation\", handler) as RegisteredMutation<\n \"public\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isMutation = true;\n func.isPublic = true;\n func.invokeMutation = (argsStr) => invokeMutation(handler, argsStr, \"public\");\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as MutationBuilder<any, \"public\">;\n\n/**\n * Define a mutation that is only accessible from other Convex functions (but not from the client).\n *\n * You should generally use the `internalMutation` function from\n * `\"./_generated/server\"`.\n *\n * Internal mutations can read from and write to the database but are **not**\n * exposed as part of your app's public API. They can only be called by other\n * Convex functions using `ctx.runMutation` or by the scheduler. Like public\n * mutations, they run transactionally.\n *\n * @example\n * ```typescript\n * import { internalMutation } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * // This mutation can only be called from other Convex functions:\n * export const markTaskCompleted = internalMutation({\n * args: { taskId: v.id(\"tasks\") },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * await ctx.db.patch(\"tasks\", args.taskId, { completed: true });\n * return null;\n * },\n * });\n * ```\n *\n * **Best practice:** Use `internalMutation` for any mutation that should not\n * be directly callable by clients, such as write-back functions from actions\n * or scheduled background work. Reference it via the `internal` object:\n * `await ctx.runMutation(internal.myModule.markTaskCompleted, { taskId })`.\n *\n * @param func - The mutation function. It receives a {@link GenericMutationCtx} as its first argument.\n * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/internal-functions\n * @public\n */\nexport const internalMutationGeneric: MutationBuilder<any, \"internal\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericMutationCtx<any>, args: any) => any;\n const func = dontCallDirectly(\n \"internalMutation\",\n handler,\n ) as RegisteredMutation<\"internal\", any, any>;\n\n assertNotBrowser();\n func.isMutation = true;\n func.isInternal = true;\n func.invokeMutation = (argsStr) =>\n invokeMutation(handler, argsStr, \"internal\");\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as MutationBuilder<any, \"internal\">;\n\nasync function invokeQuery<\n F extends (ctx: GenericQueryCtx<GenericDataModel>, ...args: any) => any,\n>(func: F, argsStr: string, visibility: FunctionVisibility) {\n // TODO(presley): Change the function signature and propagate the requestId from Rust.\n // Ok, to mock it out for now, since queries are only running in V8.\n const requestId = \"\";\n const args = jsonToConvex(JSON.parse(argsStr));\n const queryCtx = {\n db: setupReader(),\n auth: setupAuth(requestId),\n storage: setupStorageReader(requestId),\n meta: setupQueryMeta(visibility),\n runQuery: (reference: any, args?: any) => runUdf(\"query\", reference, args),\n };\n const result = await invokeFunction(func, queryCtx, args as any);\n validateReturnValue(result);\n return JSON.stringify(convexToJson(result === undefined ? null : result));\n}\n\n/**\n * Define a query in this Convex app's public API.\n *\n * You should generally use the `query` function from\n * `\"./_generated/server\"`.\n *\n * Queries can read from the database and are accessible from the client. They\n * are **reactive**, when used with `useQuery` in React, the component\n * automatically re-renders whenever the underlying data changes. Queries\n * cannot modify the database.\n * Query results are automatically cached by the Convex client and kept\n * consistent via WebSocket subscriptions.\n *\n *\n * @example\n * ```typescript\n * import { query } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const listTasks = query({\n * args: { completed: v.optional(v.boolean()) },\n * returns: v.array(v.object({\n * _id: v.id(\"tasks\"),\n * _creationTime: v.number(),\n * text: v.string(),\n * completed: v.boolean(),\n * })),\n * handler: async (ctx, args) => {\n * if (args.completed !== undefined) {\n * return await ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_completed\", (q) => q.eq(\"completed\", args.completed))\n * .collect();\n * }\n * return await ctx.db.query(\"tasks\").collect();\n * },\n * });\n * ```\n *\n * **Best practice:** Always include `args` and `returns` validators. Use\n * `.withIndex()` instead of `.filter()` for efficient database queries.\n * Queries should be fast since they run on every relevant data change.\n *\n * **Common mistake:** Queries are pure reads, they cannot write to the\n * database, call external APIs, or schedule functions. Use actions for HTTP\n * calls and mutations for database writes and scheduling.\n *\n * @param func - The query function. It receives a {@link GenericQueryCtx} as its first argument.\n * @returns The wrapped query. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/query-functions\n * @public\n */\nexport const queryGeneric: QueryBuilder<any, \"public\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericQueryCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"query\", handler) as RegisteredQuery<\n \"public\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isQuery = true;\n func.isPublic = true;\n func.invokeQuery = (argsStr) => invokeQuery(handler, argsStr, \"public\");\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as QueryBuilder<any, \"public\">;\n\n/**\n * Define a query that is only accessible from other Convex functions (but not from the client).\n *\n * You should generally use the `internalQuery` function from\n * `\"./_generated/server\"`.\n *\n * Internal queries can read from the database but are **not** exposed as part\n * of your app's public API. They can only be called by other Convex functions\n * using `ctx.runQuery`. This is useful for loading data in actions or for\n * helper queries that shouldn't be client-facing.\n *\n * @example\n * ```typescript\n * import { internalQuery } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * // Only callable from other Convex functions:\n * export const getUser = internalQuery({\n * args: { userId: v.id(\"users\") },\n * returns: v.union(\n * v.object({\n * _id: v.id(\"users\"),\n * _creationTime: v.number(),\n * name: v.string(),\n * email: v.string(),\n * }),\n * v.null(),\n * ),\n * handler: async (ctx, args) => {\n * return await ctx.db.get(\"users\", args.userId);\n * },\n * });\n * ```\n *\n * **Best practice:** Use `internalQuery` for data-loading in actions via\n * `ctx.runQuery(internal.myModule.getUser, { userId })`.\n *\n * @param func - The query function. It receives a {@link GenericQueryCtx} as its first argument.\n * @returns The wrapped query. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/internal-functions\n * @public\n */\nexport const internalQueryGeneric: QueryBuilder<any, \"internal\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericQueryCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"internalQuery\", handler) as RegisteredQuery<\n \"internal\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isQuery = true;\n func.isInternal = true;\n func.invokeQuery = (argsStr) =>\n invokeQuery(handler as any, argsStr, \"internal\");\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as QueryBuilder<any, \"internal\">;\n\nasync function invokeAction<\n F extends (ctx: GenericActionCtx<GenericDataModel>, ...args: any) => any,\n>(func: F, requestId: string, argsStr: string, visibility: FunctionVisibility) {\n const args = jsonToConvex(JSON.parse(argsStr));\n const calls = setupActionCalls(requestId);\n const ctx = {\n ...calls,\n auth: setupAuth(requestId),\n scheduler: setupActionScheduler(requestId),\n storage: setupStorageActionWriter(requestId),\n vectorSearch: setupActionVectorSearch(requestId) as any,\n meta: setupActionMeta(visibility),\n };\n const result = await invokeFunction(func, ctx, args as any);\n return JSON.stringify(convexToJson(result === undefined ? null : result));\n}\n\n/**\n * Define an action in this Convex app's public API.\n *\n * Actions can call third-party APIs, use Node.js libraries, and perform other\n * side effects. Unlike queries and mutations, actions do **not** have direct\n * database access (`ctx.db` is not available). Instead, use `ctx.runQuery`\n * and `ctx.runMutation` to read and write data.\n *\n * You should generally use the `action` function from\n * `\"./_generated/server\"`.\n *\n * Actions are accessible from the client and run outside of the database\n * transaction, so they are not atomic. They are best for integrating with\n * external services.\n *\n * @example\n * ```typescript\n * // Add \"use node\"; at the top of the file if using Node.js built-in modules.\n * import { action } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n * import { internal } from \"./_generated/api\";\n *\n * export const generateSummary = action({\n * args: { text: v.string() },\n * returns: v.string(),\n * handler: async (ctx, args) => {\n * // Call an external API:\n * const response = await fetch(\"https://api.example.com/summarize\", {\n * method: \"POST\",\n * body: JSON.stringify({ text: args.text }),\n * });\n * const { summary } = await response.json();\n *\n * // Write results back via a mutation:\n * await ctx.runMutation(internal.myModule.saveSummary, {\n * text: args.text,\n * summary,\n * });\n *\n * return summary;\n * },\n * });\n * ```\n *\n * **Best practice:** Minimize the number of `ctx.runQuery` and\n * `ctx.runMutation` calls from actions. Each call is a separate transaction,\n * so splitting logic across multiple calls introduces the risk of race\n * conditions. Try to batch reads/writes into single query/mutation calls.\n *\n * **`\"use node\"` runtime:** Actions run in Convex's default JavaScript\n * runtime, which supports `fetch` and most NPM packages. Only add\n * `\"use node\";` at the top of the file if a third-party library specifically\n * requires Node.js built-in APIs, it is a last resort, not the default.\n * Node.js actions have slower cold starts, and **only actions can be defined\n * in `\"use node\"` files** (no queries or mutations), so prefer the default\n * runtime whenever possible.\n *\n * **Common mistake:** Do not try to access `ctx.db` in an action, it is\n * not available. Use `ctx.runQuery` and `ctx.runMutation` instead.\n *\n * @param func - The function. It receives a {@link GenericActionCtx} as its first argument.\n * @returns The wrapped function. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/actions\n * @public\n */\nexport const actionGeneric: ActionBuilder<any, \"public\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericActionCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"action\", handler) as RegisteredAction<\n \"public\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isAction = true;\n func.isPublic = true;\n func.invokeAction = (requestId, argsStr) =>\n invokeAction(handler, requestId, argsStr, \"public\");\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as ActionBuilder<any, \"public\">;\n\n/**\n * Define an action that is only accessible from other Convex functions (but not from the client).\n *\n * You should generally use the `internalAction` function from\n * `\"./_generated/server\"`.\n *\n * Internal actions behave like public actions (they can call external APIs and\n * use Node.js libraries) but are **not** exposed in your app's public API. They\n * can only be called by other Convex functions using `ctx.runAction` or via the\n * scheduler.\n *\n * @example\n * ```typescript\n * import { internalAction } from \"./_generated/server\";\n * import { v } from \"convex/values\";\n *\n * export const sendEmail = internalAction({\n * args: { to: v.string(), subject: v.string(), body: v.string() },\n * returns: v.null(),\n * handler: async (ctx, args) => {\n * // Call an external email service (fetch works in the default runtime):\n * await fetch(\"https://api.email-service.com/send\", {\n * method: \"POST\",\n * headers: { \"Content-Type\": \"application/json\" },\n * body: JSON.stringify(args),\n * });\n * return null;\n * },\n * });\n * ```\n *\n * **Best practice:** Use `internalAction` for background work scheduled from\n * mutations: `await ctx.scheduler.runAfter(0, internal.myModule.sendEmail, { ... })`.\n * Only use `ctx.runAction` from another action if you need to cross runtimes\n * (e.g., default Convex runtime to Node.js). Otherwise, extract shared code\n * into a helper function.\n *\n * **`\"use node\"` runtime:** Only add `\"use node\";` at the top of the file\n * as a last resort when a third-party library requires Node.js APIs. Node.js\n * actions have slower cold starts, and **only actions can be defined in\n * `\"use node\"` files** (no queries or mutations).\n *\n * @param func - The function. It receives a {@link GenericActionCtx} as its first argument.\n * @returns The wrapped function. Include this as an `export` to name it and make it accessible.\n *\n * @see https://docs.convex.dev/functions/internal-functions\n * @public\n */\nexport const internalActionGeneric: ActionBuilder<any, \"internal\"> = ((\n functionDefinition: FunctionDefinition,\n) => {\n const handler = (\n typeof functionDefinition === \"function\"\n ? functionDefinition\n : functionDefinition.handler\n ) as (ctx: GenericActionCtx<any>, args: any) => any;\n const func = dontCallDirectly(\"internalAction\", handler) as RegisteredAction<\n \"internal\",\n any,\n any\n >;\n\n assertNotBrowser();\n func.isAction = true;\n func.isInternal = true;\n func.invokeAction = (requestId, argsStr) =>\n invokeAction(handler, requestId, argsStr, \"internal\");\n func.exportArgs = exportArgs(functionDefinition);\n func.exportReturns = exportReturns(functionDefinition);\n func._handler = handler;\n return func;\n}) as ActionBuilder<any, \"internal\">;\n\nasync function invokeHttpAction<\n F extends (ctx: GenericActionCtx<GenericDataModel>, request: Request) => any,\n>(func: F, request: Request) {\n // TODO(presley): Change the function signature and propagate the requestId from Rust.\n // Ok, to mock it out for now, since http endpoints are only running in V8.\n const requestId = \"\";\n const calls = setupActionCalls(requestId);\n const ctx = {\n ...calls,\n auth: setupAuth(requestId),\n storage: setupStorageActionWriter(requestId),\n scheduler: setupActionScheduler(requestId),\n vectorSearch: setupActionVectorSearch(requestId) as any,\n meta: setupActionMeta(\"public\"),\n };\n return await invokeFunction(func, ctx, [request]);\n}\n\n/**\n * Define a Convex HTTP action.\n *\n * HTTP actions handle raw HTTP requests and return HTTP responses. They are\n * registered by routing URL paths to them in `convex/http.ts` using\n * {@link HttpRouter}. Like regular actions, they can call external APIs and\n * use `ctx.runQuery` / `ctx.runMutation` but do not have direct `ctx.db` access.\n *\n * @example\n * ```typescript\n * // convex/http.ts\n * import { httpRouter } from \"convex/server\";\n * import { httpAction } from \"./_generated/server\";\n *\n * const http = httpRouter();\n *\n * http.route({\n * path: \"/api/webhook\",\n * method: \"POST\",\n * handler: httpAction(async (ctx, request) => {\n * const body = await request.json();\n * // Process the webhook payload...\n * return new Response(JSON.stringify({ ok: true }), {\n * status: 200,\n * headers: { \"Content-Type\": \"application/json\" },\n * });\n * }),\n * });\n *\n * export default http;\n * ```\n *\n * **Best practice:** HTTP actions are registered at the exact path specified.\n * For example, `path: \"/api/webhook\"` registers at `/api/webhook`.\n *\n * @param func - The function. It receives a {@link GenericActionCtx} as its first argument, and a `Request` object\n * as its second.\n * @returns The wrapped function. Route a URL path to this function in `convex/http.ts`.\n *\n * @see https://docs.convex.dev/functions/http-actions\n * @public\n */\nexport const httpActionGeneric = (\n func: (\n ctx: GenericActionCtx<GenericDataModel>,\n request: Request,\n ) => Promise<Response>,\n): PublicHttpAction => {\n const q = dontCallDirectly(\"httpAction\", func) as PublicHttpAction;\n assertNotBrowser();\n q.isHttp = true;\n q.invokeHttpAction = (request) => invokeHttpAction(func as any, request);\n q._handler = func;\n return q;\n};\n\nasync function runUdf(\n udfType: \"query\" | \"mutation\",\n f: any,\n args?: Record<string, Value>,\n): Promise<any> {\n const queryArgs = parseArgs(args);\n const syscallArgs = {\n udfType,\n args: convexToJson(queryArgs),\n ...getFunctionAddress(f),\n };\n const result = await performAsyncSyscall(\"1.0/runUdf\", syscallArgs);\n return jsonToConvex(result);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AAgBP,0BAAiC;AACjC,gCAAwC;AACxC,iCAA0B;AAC1B,2BAAyC;AACzC,wBAAgD;AAChD,4BAGO;AACP,0BAIO;AACP,oBAA0B;AAC1B,qBAAoC;AACpC,uBAAkC;AAClC,mBAAmC;AACnC,uBAIO;AAEP,eAAe,eAEb,MAAS,SAAiB,YAAgC;AAG1D,QAAM,YAAY;AAClB,QAAM,WAAO,4BAAa,KAAK,MAAM,OAAO,CAAC;AAC7C,QAAM,cAAc;AAAA,IAClB,QAAI,kCAAY;AAAA,IAChB,UAAM,sCAAU,SAAS;AAAA,IACzB,aAAS,wCAAmB,SAAS;AAAA,IACrC,eAAW,8CAAuB;AAAA,IAClC,UAAM,oCAAkB,UAAU;AAAA,IAElC,UAAU,CAAC,WAAgBA,UAAe,OAAO,SAAS,WAAWA,KAAI;AAAA,IACzE,aAAa,CAAC,WAAgBA,UAC5B,OAAO,YAAY,WAAWA,KAAI;AAAA,EACtC;AACA,QAAM,SAAS,MAAM,eAAe,MAAM,aAAa,IAAW;AAClE,sBAAoB,MAAM;AAC1B,SAAO,KAAK,cAAU,4BAAa,WAAW,SAAY,OAAO,MAAM,CAAC;AAC1E;AAEO,SAAS,oBAAoBC,IAAQ;AAC1C,MAAIA,cAAa,0CAAwBA,cAAa,6BAAW;AAC/D,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,eAIpB,MAAS,KAAU,MAAY;AAC/B,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,QAAQ,QAAQ,KAAK,KAAK,GAAG,IAAI,CAAC;AAAA,EACnD,SAAS,QAAiB;AACxB,UAAM,yBAAyB,MAAM;AAAA,EACvC;AACA,SAAO;AACT;AAEA,SAAS,iBACP,UACA,SACS;AACT,SAAO,CAAC,KAAU,SAAc;AAC9B,eAAW,QAAQ;AAAA,MACjB,2IAC+B,QAAQ;AAAA,IAEzC;AACA,WAAO,QAAQ,KAAK,IAAI;AAAA,EAC1B;AACF;AAGA,SAAS,yBAAyB,QAAiB;AACjD,MACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,IAAI,aAAa,KAAK,QAC7B;AACA,UAAM,QAAQ;AACd,UAAM,OAAO,KAAK;AAAA,UAChB,4BAAa,MAAM,SAAS,SAAY,OAAO,MAAM,IAAI;AAAA,IAC3D;AACA,IAAC,MAAc,oBAAoB,OAAO,IAAI,aAAa;AAC3D,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAOA,SAAS,mBAAmB;AAC1B,MACE,OAAO,WAAW,eACjB,OAAe,iCAChB;AACA;AAAA,EACF;AAEA,QAAM,gBACJ,OAAO,yBAAyB,YAAY,QAAQ,GAChD,KAAK,SAAS,EACf,SAAS,eAAe,KAAK;AAClC,MAAI,eAAe;AAEjB,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAUA,SAAS,eAAe,KAAa,OAAY;AAC/C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI;AAAA,MACR,uCAAuC,GAAG;AAAA,IAG5C;AAAA,EACF;AACA,SAAO;AACT;AACA,SAAS,WAAW,oBAAwC;AAC1D,SAAO,MAAM;AACX,QAAI,OAAyB,gBAAE,IAAI;AACnC,QACE,OAAO,uBAAuB,YAC9B,mBAAmB,SAAS,QAC5B;AACA,iBAAO,oCAAkB,mBAAmB,IAAI;AAAA,IAClD;AACA,WAAO,KAAK,UAAU,KAAK,MAAM,cAAc;AAAA,EACjD;AACF;AAEA,SAAS,cAAc,oBAAwC;AAC7D,SAAO,MAAM;AACX,QAAI;AACJ,QACE,OAAO,uBAAuB,YAC9B,mBAAmB,YAAY,QAC/B;AACA,oBAAU,oCAAkB,mBAAmB,OAAO;AAAA,IACxD;AACA,WAAO,KAAK,UAAU,UAAU,QAAQ,OAAO,MAAM,cAAc;AAAA,EACrE;AACF;AA+CO,MAAM,mBAAmD,CAC9D,uBACG;AACH,QAAM,UACJ,OAAO,uBAAuB,aAC1B,qBACA,mBAAmB;AAEzB,QAAM,OAAO,iBAAiB,YAAY,OAAO;AAMjD,mBAAiB;AACjB,OAAK,aAAa;AAClB,OAAK,WAAW;AAChB,OAAK,iBAAiB,CAAC,YAAY,eAAe,SAAS,SAAS,QAAQ;AAC5E,OAAK,aAAa,WAAW,kBAAkB;AAC/C,OAAK,gBAAgB,cAAc,kBAAkB;AACrD,OAAK,WAAW;AAChB,SAAO;AACT;AAwCO,MAAM,2BAA6D,CACxE,uBACG;AACH,QAAM,UACJ,OAAO,uBAAuB,aAC1B,qBACA,mBAAmB;AAEzB,QAAM,OAAO;AAAA,IACX;AAAA,IACA;AAAA,EACF;AAEA,mBAAiB;AACjB,OAAK,aAAa;AAClB,OAAK,aAAa;AAClB,OAAK,iBAAiB,CAAC,YACrB,eAAe,SAAS,SAAS,UAAU;AAC7C,OAAK,aAAa,WAAW,kBAAkB;AAC/C,OAAK,gBAAgB,cAAc,kBAAkB;AACrD,OAAK,WAAW;AAChB,SAAO;AACT;AAEA,eAAe,YAEb,MAAS,SAAiB,YAAgC;AAG1D,QAAM,YAAY;AAClB,QAAM,WAAO,4BAAa,KAAK,MAAM,OAAO,CAAC;AAC7C,QAAM,WAAW;AAAA,IACf,QAAI,kCAAY;AAAA,IAChB,UAAM,sCAAU,SAAS;AAAA,IACzB,aAAS,wCAAmB,SAAS;AAAA,IACrC,UAAM,iCAAe,UAAU;AAAA,IAC/B,UAAU,CAAC,WAAgBD,UAAe,OAAO,SAAS,WAAWA,KAAI;AAAA,EAC3E;AACA,QAAM,SAAS,MAAM,eAAe,MAAM,UAAU,IAAW;AAC/D,sBAAoB,MAAM;AAC1B,SAAO,KAAK,cAAU,4BAAa,WAAW,SAAY,OAAO,MAAM,CAAC;AAC1E;AAuDO,MAAM,gBAA6C,CACxD,uBACG;AACH,QAAM,UACJ,OAAO,uBAAuB,aAC1B,qBACA,mBAAmB;AAEzB,QAAM,OAAO,iBAAiB,SAAS,OAAO;AAM9C,mBAAiB;AACjB,OAAK,UAAU;AACf,OAAK,WAAW;AAChB,OAAK,cAAc,CAAC,YAAY,YAAY,SAAS,SAAS,QAAQ;AACtE,OAAK,aAAa,WAAW,kBAAkB;AAC/C,OAAK,gBAAgB,cAAc,kBAAkB;AACrD,OAAK,WAAW;AAChB,SAAO;AACT;AA6CO,MAAM,wBAAuD,CAClE,uBACG;AACH,QAAM,UACJ,OAAO,uBAAuB,aAC1B,qBACA,mBAAmB;AAEzB,QAAM,OAAO,iBAAiB,iBAAiB,OAAO;AAMtD,mBAAiB;AACjB,OAAK,UAAU;AACf,OAAK,aAAa;AAClB,OAAK,cAAc,CAAC,YAClB,YAAY,SAAgB,SAAS,UAAU;AACjD,OAAK,aAAa,WAAW,kBAAkB;AAC/C,OAAK,gBAAgB,cAAc,kBAAkB;AACrD,OAAK,WAAW;AAChB,SAAO;AACT;AAEA,eAAe,aAEb,MAAS,WAAmB,SAAiB,YAAgC;AAC7E,QAAM,WAAO,4BAAa,KAAK,MAAM,OAAO,CAAC;AAC7C,QAAM,YAAQ,sCAAiB,SAAS;AACxC,QAAM,MAAM;AAAA,IACV,GAAG;AAAA,IACH,UAAM,sCAAU,SAAS;AAAA,IACzB,eAAW,4CAAqB,SAAS;AAAA,IACzC,aAAS,8CAAyB,SAAS;AAAA,IAC3C,kBAAc,mDAAwB,SAAS;AAAA,IAC/C,UAAM,kCAAgB,UAAU;AAAA,EAClC;AACA,QAAM,SAAS,MAAM,eAAe,MAAM,KAAK,IAAW;AAC1D,SAAO,KAAK,cAAU,4BAAa,WAAW,SAAY,OAAO,MAAM,CAAC;AAC1E;AAoEO,MAAM,iBAA+C,CAC1D,uBACG;AACH,QAAM,UACJ,OAAO,uBAAuB,aAC1B,qBACA,mBAAmB;AAEzB,QAAM,OAAO,iBAAiB,UAAU,OAAO;AAM/C,mBAAiB;AACjB,OAAK,WAAW;AAChB,OAAK,WAAW;AAChB,OAAK,eAAe,CAAC,WAAW,YAC9B,aAAa,SAAS,WAAW,SAAS,QAAQ;AACpD,OAAK,aAAa,WAAW,kBAAkB;AAC/C,OAAK,gBAAgB,cAAc,kBAAkB;AACrD,OAAK,WAAW;AAChB,SAAO;AACT;AAkDO,MAAM,yBAAyD,CACpE,uBACG;AACH,QAAM,UACJ,OAAO,uBAAuB,aAC1B,qBACA,mBAAmB;AAEzB,QAAM,OAAO,iBAAiB,kBAAkB,OAAO;AAMvD,mBAAiB;AACjB,OAAK,WAAW;AAChB,OAAK,aAAa;AAClB,OAAK,eAAe,CAAC,WAAW,YAC9B,aAAa,SAAS,WAAW,SAAS,UAAU;AACtD,OAAK,aAAa,WAAW,kBAAkB;AAC/C,OAAK,gBAAgB,cAAc,kBAAkB;AACrD,OAAK,WAAW;AAChB,SAAO;AACT;AAEA,eAAe,iBAEb,MAAS,SAAkB;AAG3B,QAAM,YAAY;AAClB,QAAM,YAAQ,sCAAiB,SAAS;AACxC,QAAM,MAAM;AAAA,IACV,GAAG;AAAA,IACH,UAAM,sCAAU,SAAS;AAAA,IACzB,aAAS,8CAAyB,SAAS;AAAA,IAC3C,eAAW,4CAAqB,SAAS;AAAA,IACzC,kBAAc,mDAAwB,SAAS;AAAA,IAC/C,UAAM,kCAAgB,QAAQ;AAAA,EAChC;AACA,SAAO,MAAM,eAAe,MAAM,KAAK,CAAC,OAAO,CAAC;AAClD;AA4CO,MAAM,oBAAoB,CAC/B,SAIqB;AACrB,QAAM,IAAI,iBAAiB,cAAc,IAAI;AAC7C,mBAAiB;AACjB,IAAE,SAAS;AACX,IAAE,mBAAmB,CAAC,YAAY,iBAAiB,MAAa,OAAO;AACvE,IAAE,WAAW;AACb,SAAO;AACT;AAEA,eAAe,OACb,SACA,GACA,MACc;AACd,QAAM,gBAAY,yBAAU,IAAI;AAChC,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,UAAM,4BAAa,SAAS;AAAA,IAC5B,OAAG,iCAAmB,CAAC;AAAA,EACzB;AACA,QAAM,SAAS,UAAM,oCAAoB,cAAc,WAAW;AAClE,aAAO,4BAAa,MAAM;AAC5B;",
|
|
6
6
|
"names": ["args", "v"]
|
|
7
7
|
}
|
|
@@ -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 type { IndexRange, IndexRangeBuilder } from \"./index_range_builder.js\";\nexport * from \"./pagination.js\";\nexport type { OrderedQuery, Query, QueryInitializer } from \"./query.js\";\nexport type {\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 FilterApi,\n FunctionType,\n FunctionReference,\n FunctionArgs,\n OptionalRestArgs,\n PartialApi,\n ArgsAndOptions,\n FunctionReturnType,\n} from \"./api.js\";\nexport {\n defineApp,\n defineComponent,\n componentsGeneric,\n createFunctionHandle,\n type AnyChildComponents,\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 type {\n SearchIndexConfig,\n VectorIndexConfig,\n TableDefinition,\n SchemaDefinition,\n DefineSchemaOptions,\n GenericSchema,\n DataModelFromSchemaDefinition,\n SystemDataModel,\n SystemTableNames,\n} from \"./schema.js\";\nexport { defineTable, defineSchema } 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": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DA,2BAAc,0BA5Dd;AAgGA,+BAQO;
|
|
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 type {\n TransactionMetric,\n TransactionMetrics,\n FunctionMetadata,\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 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 FilterApi,\n FunctionType,\n FunctionReference,\n FunctionArgs,\n OptionalRestArgs,\n PartialApi,\n ArgsAndOptions,\n FunctionReturnType,\n} from \"./api.js\";\nexport {\n defineApp,\n defineComponent,\n componentsGeneric,\n createFunctionHandle,\n type AnyChildComponents,\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 type {\n SearchIndexConfig,\n VectorIndexConfig,\n TableDefinition,\n SchemaDefinition,\n DefineSchemaOptions,\n GenericSchema,\n DataModelFromSchemaDefinition,\n SystemDataModel,\n SystemTableNames,\n} from \"./schema.js\";\nexport { defineTable, defineSchema } 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": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DA,2BAAc,0BA5Dd;AAgGA,+BAQO;AAUP,2BAAc,4BAlHd;AA8IA,2BAAc,uCA9Id;AA+IA,2BAAc,yBA/Id;AAiJA,kBAAyB;AAUzB,oBAA8D;AAO9D,iBAKO;AAaP,wBAMO;AAIP,IAAAA,qBAA4C;AAC5C,IAAAA,qBAAmC;AAuBnC,oBAA0C;",
|
|
6
6
|
"names": ["import_components"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var meta_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(meta_exports);
|
|
17
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/server/meta.ts"],
|
|
4
|
+
"sourcesContent": ["import { FunctionType } from \"./api.js\";\nimport { FunctionVisibility } from \"./registration.js\";\n\n/**\n * Used and remaining amounts for a single transaction limit.\n *\n * @public\n */\nexport type TransactionMetric = {\n used: number;\n remaining: number;\n};\n\n/**\n * The remaining headroom for a transaction before hitting limits.\n *\n * See https://docs.convex.dev/production/state/limits\n *\n * @public\n */\nexport type TransactionMetrics = {\n bytesRead: TransactionMetric;\n bytesWritten: TransactionMetric;\n databaseQueries: TransactionMetric;\n documentsRead: TransactionMetric;\n documentsWritten: TransactionMetric;\n functionsScheduled: TransactionMetric;\n scheduledFunctionArgsBytes: TransactionMetric;\n};\n\n/**\n * Metadata about the currently executing Convex function.\n *\n * @public\n */\nexport type FunctionMetadata = {\n /**\n * The name of the function, in the format `\"path/to/module:functionName\"`\n */\n name: string;\n /**\n * The path of the component this function belongs to.\n * This is an empty string `\"\"` for the app.\n */\n componentPath: string;\n /** Whether it's a query, mutation, or action. */\n type: FunctionType;\n /** Whether the function is public or internal. */\n visibility: FunctionVisibility;\n};\n\n/**\n * Extra context available in Convex query functions.\n *\n * @public\n */\nexport interface QueryMeta {\n getFunctionMetadata(): Promise<FunctionMetadata>;\n getTransactionMetrics(): Promise<TransactionMetrics>;\n}\n\n/**\n * Extra context available in Convex mutation functions.\n *\n * @public\n */\nexport interface MutationMeta extends QueryMeta {}\n\n/**\n * Extra context available in Convex action functions.\n *\n * @public\n */\nexport interface ActionMeta {\n getFunctionMetadata(): Promise<FunctionMetadata>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|