convex 1.29.3 → 1.30.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 +24 -1
- package/dist/browser.bundle.js +504 -19
- package/dist/browser.bundle.js.map +4 -4
- package/dist/cjs/browser/index.js.map +2 -2
- package/dist/cjs/browser/simple_client.js +120 -15
- package/dist/cjs/browser/simple_client.js.map +3 -3
- package/dist/cjs/browser/sync/client.js +2 -2
- package/dist/cjs/browser/sync/client.js.map +2 -2
- package/dist/cjs/browser/sync/local_state.js.map +2 -2
- package/dist/cjs/browser/sync/optimistic_updates_impl.js +8 -1
- package/dist/cjs/browser/sync/optimistic_updates_impl.js.map +2 -2
- package/dist/cjs/browser/sync/paginated_query_client.js +381 -0
- package/dist/cjs/browser/sync/paginated_query_client.js.map +7 -0
- package/dist/cjs/browser/sync/pagination.js +37 -0
- package/dist/cjs/browser/sync/pagination.js.map +7 -0
- package/dist/cjs/browser/sync/udf_path_utils.js +16 -1
- package/dist/cjs/browser/sync/udf_path_utils.js.map +2 -2
- package/dist/cjs/bundler/fs.js +5 -5
- package/dist/cjs/bundler/fs.js.map +3 -3
- package/dist/cjs/bundler/index.js +17 -15
- package/dist/cjs/bundler/index.js.map +3 -3
- package/dist/cjs/bundler/log.js +3 -3
- package/dist/cjs/bundler/log.js.map +3 -3
- package/dist/cjs/cli/configure.js +11 -13
- package/dist/cjs/cli/configure.js.map +3 -3
- package/dist/cjs/cli/convexExport.js +2 -12
- package/dist/cjs/cli/convexExport.js.map +3 -3
- package/dist/cjs/cli/convexImport.js +2 -12
- package/dist/cjs/cli/convexImport.js.map +3 -3
- package/dist/cjs/cli/dashboard.js +4 -4
- package/dist/cjs/cli/dashboard.js.map +3 -3
- package/dist/cjs/cli/data.js +2 -12
- package/dist/cjs/cli/data.js.map +3 -3
- package/dist/cjs/cli/deploy.js +13 -15
- package/dist/cjs/cli/deploy.js.map +3 -3
- package/dist/cjs/cli/docs.js +3 -3
- package/dist/cjs/cli/docs.js.map +3 -3
- package/dist/cjs/cli/env.js +2 -12
- package/dist/cjs/cli/env.js.map +3 -3
- package/dist/cjs/cli/index.js +9 -9
- package/dist/cjs/cli/index.js.map +3 -3
- package/dist/cjs/cli/integration.js +2 -12
- package/dist/cjs/cli/integration.js.map +3 -3
- package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js +7 -17
- package/dist/cjs/cli/lib/checkForLargeIndexDeletion.js.map +3 -3
- package/dist/cjs/cli/lib/codegen.js +5 -3
- package/dist/cjs/cli/lib/codegen.js.map +2 -2
- package/dist/cjs/cli/lib/components/definition/bundle.js +3 -3
- package/dist/cjs/cli/lib/components/definition/bundle.js.map +3 -3
- package/dist/cjs/cli/lib/components.js +2 -2
- package/dist/cjs/cli/lib/components.js.map +3 -3
- package/dist/cjs/cli/lib/config.js +13 -13
- package/dist/cjs/cli/lib/config.js.map +3 -3
- package/dist/cjs/cli/lib/convexExport.js +9 -7
- package/dist/cjs/cli/lib/convexExport.js.map +3 -3
- package/dist/cjs/cli/lib/convexImport.js +8 -8
- package/dist/cjs/cli/lib/convexImport.js.map +3 -3
- package/dist/cjs/cli/lib/cursorRules.js +2 -2
- package/dist/cjs/cli/lib/cursorRules.js.map +3 -3
- package/dist/cjs/cli/lib/data.js +3 -13
- package/dist/cjs/cli/lib/data.js.map +3 -3
- package/dist/cjs/cli/lib/deploy2.js +2 -2
- package/dist/cjs/cli/lib/deploy2.js.map +3 -3
- package/dist/cjs/cli/lib/dev.js +2 -2
- package/dist/cjs/cli/lib/dev.js.map +3 -3
- package/dist/cjs/cli/lib/env.js +4 -14
- package/dist/cjs/cli/lib/env.js.map +3 -3
- package/dist/cjs/cli/lib/envvars.js +5 -3
- package/dist/cjs/cli/lib/envvars.js.map +3 -3
- package/dist/cjs/cli/lib/functionSpec.js.map +2 -2
- package/dist/cjs/cli/lib/indexes.js +6 -16
- package/dist/cjs/cli/lib/indexes.js.map +3 -3
- package/dist/cjs/cli/lib/init.js +3 -13
- package/dist/cjs/cli/lib/init.js.map +3 -3
- package/dist/cjs/cli/lib/localDeployment/anonymous.js +1 -1
- package/dist/cjs/cli/lib/localDeployment/anonymous.js.map +2 -2
- package/dist/cjs/cli/lib/localDeployment/utils.js +4 -4
- package/dist/cjs/cli/lib/localDeployment/utils.js.map +3 -3
- package/dist/cjs/cli/lib/login.js +6 -4
- package/dist/cjs/cli/lib/login.js.map +3 -3
- package/dist/cjs/cli/lib/logs.js +19 -13
- package/dist/cjs/cli/lib/logs.js.map +2 -2
- package/dist/cjs/cli/lib/networkTest.js +11 -7
- package/dist/cjs/cli/lib/networkTest.js.map +3 -3
- package/dist/cjs/cli/lib/run.js +6 -6
- package/dist/cjs/cli/lib/run.js.map +3 -3
- package/dist/cjs/cli/lib/typecheck.js +7 -5
- package/dist/cjs/cli/lib/typecheck.js.map +3 -3
- package/dist/cjs/cli/lib/usage.js +4 -14
- package/dist/cjs/cli/lib/usage.js.map +3 -3
- package/dist/cjs/cli/lib/utils/globalConfig.js +4 -4
- package/dist/cjs/cli/lib/utils/globalConfig.js.map +3 -3
- package/dist/cjs/cli/lib/utils/utils.js +12 -8
- package/dist/cjs/cli/lib/utils/utils.js.map +3 -3
- package/dist/cjs/cli/typecheck.js +3 -13
- package/dist/cjs/cli/typecheck.js.map +3 -3
- package/dist/cjs/cli/update.js +2 -12
- package/dist/cjs/cli/update.js.map +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/client.js +82 -1
- package/dist/cjs/react/client.js.map +2 -2
- package/dist/cjs/react/index.js +4 -0
- package/dist/cjs/react/index.js.map +2 -2
- package/dist/cjs/react/queries_observer.js +36 -11
- package/dist/cjs/react/queries_observer.js.map +2 -2
- package/dist/cjs/react/use_paginated_query2.js +124 -0
- package/dist/cjs/react/use_paginated_query2.js.map +7 -0
- package/dist/cjs/react/use_queries.js +9 -2
- package/dist/cjs/react/use_queries.js.map +2 -2
- package/dist/cjs/values/validator.js.map +2 -2
- 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/simple_client.d.ts +22 -1
- package/dist/cjs-types/browser/simple_client.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/client.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/client_node_test_helpers.d.ts +5 -4
- package/dist/cjs-types/browser/sync/client_node_test_helpers.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/local_state.d.ts +12 -1
- package/dist/cjs-types/browser/sync/local_state.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
- package/dist/cjs-types/browser/sync/paginated_query_client.d.ts +71 -0
- package/dist/cjs-types/browser/sync/paginated_query_client.d.ts.map +1 -0
- package/dist/cjs-types/browser/sync/paginated_query_client.test.d.ts +2 -0
- package/dist/cjs-types/browser/sync/paginated_query_client.test.d.ts.map +1 -0
- package/dist/cjs-types/browser/sync/pagination.d.ts +23 -0
- package/dist/cjs-types/browser/sync/pagination.d.ts.map +1 -0
- package/dist/cjs-types/browser/sync/udf_path_utils.d.ts +20 -1
- package/dist/cjs-types/browser/sync/udf_path_utils.d.ts.map +1 -1
- package/dist/cjs-types/bundler/index.d.ts.map +1 -1
- package/dist/cjs-types/cli/configure.d.ts.map +1 -1
- package/dist/cjs-types/cli/deploy.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/codegen.d.ts +3 -1
- package/dist/cjs-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/convexExport.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/convexImport.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/functionSpec.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/login.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/logs.d.ts +2 -1
- package/dist/cjs-types/cli/lib/logs.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/networkTest.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/typecheck.d.ts.map +1 -1
- package/dist/cjs-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cjs-types/react/client.d.ts +37 -1
- package/dist/cjs-types/react/client.d.ts.map +1 -1
- package/dist/cjs-types/react/index.d.ts +2 -0
- package/dist/cjs-types/react/index.d.ts.map +1 -1
- package/dist/cjs-types/react/queries_observer.d.ts +12 -6
- package/dist/cjs-types/react/queries_observer.d.ts.map +1 -1
- package/dist/cjs-types/react/use_paginated_query2.d.ts +51 -0
- package/dist/cjs-types/react/use_paginated_query2.d.ts.map +1 -0
- package/dist/cjs-types/react/use_queries.d.ts.map +1 -1
- package/dist/cjs-types/values/validator.d.ts +1 -1
- package/dist/cli.bundle.cjs +201 -162
- package/dist/cli.bundle.cjs.map +2 -2
- package/dist/esm/browser/index.js.map +2 -2
- package/dist/esm/browser/simple_client.js +122 -15
- package/dist/esm/browser/simple_client.js.map +3 -3
- package/dist/esm/browser/sync/client.js +2 -2
- package/dist/esm/browser/sync/client.js.map +2 -2
- package/dist/esm/browser/sync/local_state.js.map +2 -2
- package/dist/esm/browser/sync/optimistic_updates_impl.js +8 -1
- package/dist/esm/browser/sync/optimistic_updates_impl.js.map +2 -2
- package/dist/esm/browser/sync/paginated_query_client.js +365 -0
- package/dist/esm/browser/sync/paginated_query_client.js.map +7 -0
- package/dist/esm/browser/sync/pagination.js +14 -0
- package/dist/esm/browser/sync/pagination.js.map +7 -0
- package/dist/esm/browser/sync/udf_path_utils.js +13 -0
- package/dist/esm/browser/sync/udf_path_utils.js.map +2 -2
- package/dist/esm/bundler/fs.js +5 -5
- package/dist/esm/bundler/fs.js.map +2 -2
- package/dist/esm/bundler/index.js +17 -15
- package/dist/esm/bundler/index.js.map +2 -2
- package/dist/esm/bundler/log.js +3 -3
- package/dist/esm/bundler/log.js.map +2 -2
- package/dist/esm/cli/configure.js +12 -14
- package/dist/esm/cli/configure.js.map +2 -2
- package/dist/esm/cli/convexExport.js +2 -2
- package/dist/esm/cli/convexExport.js.map +2 -2
- package/dist/esm/cli/convexImport.js +2 -2
- package/dist/esm/cli/convexImport.js.map +2 -2
- package/dist/esm/cli/dashboard.js +4 -4
- package/dist/esm/cli/dashboard.js.map +2 -2
- package/dist/esm/cli/data.js +2 -2
- package/dist/esm/cli/data.js.map +2 -2
- package/dist/esm/cli/deploy.js +13 -5
- package/dist/esm/cli/deploy.js.map +2 -2
- package/dist/esm/cli/docs.js +3 -3
- package/dist/esm/cli/docs.js.map +2 -2
- package/dist/esm/cli/env.js +2 -2
- package/dist/esm/cli/env.js.map +2 -2
- package/dist/esm/cli/index.js +9 -9
- package/dist/esm/cli/index.js.map +2 -2
- package/dist/esm/cli/integration.js +2 -2
- package/dist/esm/cli/integration.js.map +2 -2
- package/dist/esm/cli/lib/checkForLargeIndexDeletion.js +7 -7
- package/dist/esm/cli/lib/checkForLargeIndexDeletion.js.map +2 -2
- package/dist/esm/cli/lib/codegen.js +4 -2
- package/dist/esm/cli/lib/codegen.js.map +2 -2
- package/dist/esm/cli/lib/components/definition/bundle.js +3 -3
- package/dist/esm/cli/lib/components/definition/bundle.js.map +2 -2
- package/dist/esm/cli/lib/components.js +2 -2
- package/dist/esm/cli/lib/components.js.map +2 -2
- package/dist/esm/cli/lib/config.js +13 -13
- package/dist/esm/cli/lib/config.js.map +2 -2
- package/dist/esm/cli/lib/convexExport.js +9 -7
- package/dist/esm/cli/lib/convexExport.js.map +2 -2
- package/dist/esm/cli/lib/convexImport.js +8 -8
- package/dist/esm/cli/lib/convexImport.js.map +2 -2
- package/dist/esm/cli/lib/cursorRules.js +2 -2
- package/dist/esm/cli/lib/cursorRules.js.map +2 -2
- package/dist/esm/cli/lib/data.js +3 -3
- package/dist/esm/cli/lib/data.js.map +2 -2
- package/dist/esm/cli/lib/deploy2.js +2 -2
- package/dist/esm/cli/lib/deploy2.js.map +2 -2
- package/dist/esm/cli/lib/dev.js +2 -2
- package/dist/esm/cli/lib/dev.js.map +2 -2
- package/dist/esm/cli/lib/env.js +4 -4
- package/dist/esm/cli/lib/env.js.map +2 -2
- package/dist/esm/cli/lib/envvars.js +5 -3
- package/dist/esm/cli/lib/envvars.js.map +2 -2
- package/dist/esm/cli/lib/functionSpec.js.map +2 -2
- package/dist/esm/cli/lib/indexes.js +6 -6
- package/dist/esm/cli/lib/indexes.js.map +2 -2
- package/dist/esm/cli/lib/init.js +3 -3
- package/dist/esm/cli/lib/init.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/anonymous.js +2 -2
- package/dist/esm/cli/lib/localDeployment/anonymous.js.map +2 -2
- package/dist/esm/cli/lib/localDeployment/utils.js +4 -4
- package/dist/esm/cli/lib/localDeployment/utils.js.map +2 -2
- package/dist/esm/cli/lib/login.js +6 -4
- package/dist/esm/cli/lib/login.js.map +2 -2
- package/dist/esm/cli/lib/logs.js +20 -14
- package/dist/esm/cli/lib/logs.js.map +2 -2
- package/dist/esm/cli/lib/networkTest.js +11 -7
- package/dist/esm/cli/lib/networkTest.js.map +2 -2
- package/dist/esm/cli/lib/run.js +6 -6
- package/dist/esm/cli/lib/run.js.map +2 -2
- package/dist/esm/cli/lib/typecheck.js +7 -5
- package/dist/esm/cli/lib/typecheck.js.map +2 -2
- package/dist/esm/cli/lib/usage.js +4 -4
- package/dist/esm/cli/lib/usage.js.map +2 -2
- package/dist/esm/cli/lib/utils/globalConfig.js +4 -4
- package/dist/esm/cli/lib/utils/globalConfig.js.map +2 -2
- package/dist/esm/cli/lib/utils/utils.js +12 -8
- package/dist/esm/cli/lib/utils/utils.js.map +2 -2
- package/dist/esm/cli/typecheck.js +3 -3
- package/dist/esm/cli/typecheck.js.map +2 -2
- package/dist/esm/cli/update.js +2 -2
- package/dist/esm/cli/update.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 +84 -1
- package/dist/esm/react/client.js.map +2 -2
- package/dist/esm/react/index.js +2 -0
- package/dist/esm/react/index.js.map +2 -2
- package/dist/esm/react/queries_observer.js +36 -11
- package/dist/esm/react/queries_observer.js.map +2 -2
- package/dist/esm/react/use_paginated_query2.js +101 -0
- package/dist/esm/react/use_paginated_query2.js.map +7 -0
- package/dist/esm/react/use_queries.js +9 -2
- package/dist/esm/react/use_queries.js.map +2 -2
- package/dist/esm/values/validator.js.map +2 -2
- 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/simple_client.d.ts +22 -1
- package/dist/esm-types/browser/simple_client.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/client.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/client_node_test_helpers.d.ts +5 -4
- package/dist/esm-types/browser/sync/client_node_test_helpers.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/local_state.d.ts +12 -1
- package/dist/esm-types/browser/sync/local_state.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/optimistic_updates_impl.d.ts.map +1 -1
- package/dist/esm-types/browser/sync/paginated_query_client.d.ts +71 -0
- package/dist/esm-types/browser/sync/paginated_query_client.d.ts.map +1 -0
- package/dist/esm-types/browser/sync/paginated_query_client.test.d.ts +2 -0
- package/dist/esm-types/browser/sync/paginated_query_client.test.d.ts.map +1 -0
- package/dist/esm-types/browser/sync/pagination.d.ts +23 -0
- package/dist/esm-types/browser/sync/pagination.d.ts.map +1 -0
- package/dist/esm-types/browser/sync/udf_path_utils.d.ts +20 -1
- package/dist/esm-types/browser/sync/udf_path_utils.d.ts.map +1 -1
- package/dist/esm-types/bundler/index.d.ts.map +1 -1
- package/dist/esm-types/cli/configure.d.ts.map +1 -1
- package/dist/esm-types/cli/deploy.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/codegen.d.ts +3 -1
- package/dist/esm-types/cli/lib/codegen.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/convexExport.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/convexImport.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/envvars.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/functionSpec.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/login.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/logs.d.ts +2 -1
- package/dist/esm-types/cli/lib/logs.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/networkTest.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/typecheck.d.ts.map +1 -1
- package/dist/esm-types/cli/lib/utils/utils.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/esm-types/react/client.d.ts +37 -1
- package/dist/esm-types/react/client.d.ts.map +1 -1
- package/dist/esm-types/react/index.d.ts +2 -0
- package/dist/esm-types/react/index.d.ts.map +1 -1
- package/dist/esm-types/react/queries_observer.d.ts +12 -6
- package/dist/esm-types/react/queries_observer.d.ts.map +1 -1
- package/dist/esm-types/react/use_paginated_query2.d.ts +51 -0
- package/dist/esm-types/react/use_paginated_query2.d.ts.map +1 -0
- package/dist/esm-types/react/use_queries.d.ts.map +1 -1
- package/dist/esm-types/values/validator.d.ts +1 -1
- package/dist/react.bundle.js +620 -35
- package/dist/react.bundle.js.map +4 -4
- package/package.json +1 -1
- package/src/browser/index.ts +3 -0
- package/src/browser/simple_client.ts +164 -21
- package/src/browser/sync/client.ts +12 -3
- package/src/browser/sync/client_node_test_helpers.ts +29 -8
- package/src/browser/sync/local_state.ts +13 -1
- package/src/browser/sync/optimistic_updates_impl.ts +9 -2
- package/src/browser/sync/paginated_query_client.test.ts +389 -0
- package/src/browser/sync/paginated_query_client.ts +564 -0
- package/src/browser/sync/pagination.ts +50 -0
- package/src/browser/sync/udf_path_utils.ts +34 -2
- package/src/bundler/fs.ts +5 -5
- package/src/bundler/index.ts +17 -15
- package/src/bundler/log.ts +3 -3
- package/src/cli/configure.ts +13 -18
- package/src/cli/convexExport.ts +2 -2
- package/src/cli/convexImport.ts +2 -2
- package/src/cli/dashboard.ts +4 -4
- package/src/cli/data.ts +2 -2
- package/src/cli/deploy.ts +21 -5
- package/src/cli/docs.ts +3 -3
- package/src/cli/env.ts +2 -2
- package/src/cli/index.ts +9 -9
- package/src/cli/integration.ts +2 -2
- package/src/cli/lib/checkForLargeIndexDeletion.ts +7 -7
- package/src/cli/lib/codegen.ts +7 -2
- package/src/cli/lib/components/definition/bundle.ts +3 -3
- package/src/cli/lib/components.ts +2 -2
- package/src/cli/lib/config.ts +13 -13
- package/src/cli/lib/convexExport.ts +9 -7
- package/src/cli/lib/convexImport.ts +10 -8
- package/src/cli/lib/cursorRules.ts +2 -2
- package/src/cli/lib/data.ts +3 -3
- package/src/cli/lib/deploy2.ts +2 -2
- package/src/cli/lib/dev.ts +2 -2
- package/src/cli/lib/env.ts +4 -4
- package/src/cli/lib/envvars.ts +5 -3
- package/src/cli/lib/functionSpec.ts +1 -0
- package/src/cli/lib/indexes.test.ts +6 -6
- package/src/cli/lib/indexes.ts +8 -6
- package/src/cli/lib/init.ts +3 -3
- package/src/cli/lib/localDeployment/anonymous.ts +2 -2
- package/src/cli/lib/localDeployment/utils.ts +4 -4
- package/src/cli/lib/login.ts +6 -4
- package/src/cli/lib/logs.ts +21 -10
- package/src/cli/lib/networkTest.ts +11 -7
- package/src/cli/lib/run.ts +6 -6
- package/src/cli/lib/typecheck.ts +7 -5
- package/src/cli/lib/usage.ts +4 -4
- package/src/cli/lib/utils/globalConfig.ts +4 -4
- package/src/cli/lib/utils/utils.ts +12 -8
- package/src/cli/network_test.ts +2 -2
- package/src/cli/typecheck.ts +3 -3
- package/src/cli/update.ts +2 -2
- package/src/index.ts +1 -1
- package/src/react/client.ts +163 -4
- package/src/react/index.ts +2 -0
- package/src/react/queries_observer.test.ts +1 -1
- package/src/react/queries_observer.ts +75 -24
- package/src/react/use_paginated_query.test.tsx +963 -947
- package/src/react/use_paginated_query2.ts +234 -0
- package/src/react/use_queries.ts +15 -2
- package/src/values/validator.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.30.0
|
|
4
|
+
|
|
5
|
+
- The `--preview-create` parameter for `npx convex deploy` will now error if
|
|
6
|
+
used with a deploy key that is not a preview deploy key. Previously, the flag
|
|
7
|
+
would be ignored in this situation, and `npx convex deploy` would deploy to
|
|
8
|
+
the production deployment. If you were depending on this behavior, make sure
|
|
9
|
+
to remove the `--preview-create` flag when deploying to production.
|
|
10
|
+
|
|
11
|
+
## 1.29.3
|
|
12
|
+
|
|
13
|
+
- Revert ApiFromModules type changes introduced in 1.29.0 which sometimes caused
|
|
14
|
+
type mismatches due to `FunctionReference` sometimes missing properties.
|
|
15
|
+
|
|
16
|
+
- Don't warn when `"$schema"` is present in convex.json.
|
|
17
|
+
|
|
18
|
+
- Replace ProxyAgent with EnvHttpProxyAgent in the CLI so the `NO_PROXY`
|
|
19
|
+
environment variable is respected.
|
|
20
|
+
|
|
21
|
+
## 1.29.2
|
|
4
22
|
|
|
5
23
|
- When running `npx convex deploy`, the CLI will now ask for explicit
|
|
6
24
|
confirmation before deleting large indexes. This change is helpful for
|
|
7
25
|
avoiding situations where an index is accidentally deleted and backfilling it
|
|
8
26
|
takes a long time.
|
|
9
27
|
|
|
28
|
+
## 1.29.1
|
|
29
|
+
|
|
30
|
+
- Support for special error and no-op values of `CONVEX_DEPLOY_KEY` environment
|
|
31
|
+
variable used by the Convex Vercel integration.
|
|
32
|
+
|
|
10
33
|
## 1.29.0
|
|
11
34
|
|
|
12
35
|
- Code generation changes: modules and functions are sorted in more situations,
|
package/dist/browser.bundle.js
CHANGED
|
@@ -28,7 +28,7 @@ var convex = (() => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var version = "1.
|
|
31
|
+
var version = "1.30.0";
|
|
32
32
|
|
|
33
33
|
// src/values/base64.ts
|
|
34
34
|
var base64_exports = {};
|
|
@@ -624,6 +624,19 @@ var convex = (() => {
|
|
|
624
624
|
args: convexToJson(args)
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
|
+
function serializePaginatedPathAndArgs(udfPath, args, options) {
|
|
628
|
+
const { initialNumItems, id } = options;
|
|
629
|
+
const result = JSON.stringify({
|
|
630
|
+
type: "paginated",
|
|
631
|
+
udfPath: canonicalizeUdfPath(udfPath),
|
|
632
|
+
args: convexToJson(args),
|
|
633
|
+
options: convexToJson({ initialNumItems, id })
|
|
634
|
+
});
|
|
635
|
+
return result;
|
|
636
|
+
}
|
|
637
|
+
function serializedQueryTokenIsPaginated(token) {
|
|
638
|
+
return JSON.parse(token).type === "paginated";
|
|
639
|
+
}
|
|
627
640
|
|
|
628
641
|
// src/browser/sync/local_state.ts
|
|
629
642
|
var LocalSyncState = class {
|
|
@@ -1309,10 +1322,17 @@ var convex = (() => {
|
|
|
1309
1322
|
return localStore.modifiedQueries;
|
|
1310
1323
|
}
|
|
1311
1324
|
/**
|
|
1325
|
+
* "Raw" with respect to errors vs values, but query results still have
|
|
1326
|
+
* optimistic updates applied.
|
|
1327
|
+
*
|
|
1312
1328
|
* @internal
|
|
1313
1329
|
*/
|
|
1314
1330
|
rawQueryResult(queryToken) {
|
|
1315
|
-
|
|
1331
|
+
const query = this.queryResults.get(queryToken);
|
|
1332
|
+
if (query === void 0) {
|
|
1333
|
+
return void 0;
|
|
1334
|
+
}
|
|
1335
|
+
return query.result;
|
|
1316
1336
|
}
|
|
1317
1337
|
queryResult(queryToken) {
|
|
1318
1338
|
const query = this.queryResults.get(queryToken);
|
|
@@ -2825,7 +2845,7 @@ var convex = (() => {
|
|
|
2825
2845
|
token,
|
|
2826
2846
|
modification: {
|
|
2827
2847
|
kind: "Updated",
|
|
2828
|
-
result: optimisticResult
|
|
2848
|
+
result: optimisticResult
|
|
2829
2849
|
}
|
|
2830
2850
|
};
|
|
2831
2851
|
}),
|
|
@@ -2955,7 +2975,7 @@ var convex = (() => {
|
|
|
2955
2975
|
return this.optimisticQueryResults.queryResult(queryToken);
|
|
2956
2976
|
}
|
|
2957
2977
|
/**
|
|
2958
|
-
* Whether local query result is available for a
|
|
2978
|
+
* Whether local query result is available for a token.
|
|
2959
2979
|
*
|
|
2960
2980
|
* This method does not throw if the result is an error.
|
|
2961
2981
|
*
|
|
@@ -3256,11 +3276,374 @@ var convex = (() => {
|
|
|
3256
3276
|
}
|
|
3257
3277
|
};
|
|
3258
3278
|
|
|
3279
|
+
// src/browser/sync/pagination.ts
|
|
3280
|
+
function asPaginationResult(value) {
|
|
3281
|
+
if (typeof value !== "object" || value === null || !Array.isArray(value.page) || typeof value.isDone !== "boolean" || typeof value.continueCursor !== "string") {
|
|
3282
|
+
throw new Error(`Not a valid paginated query result: ${value?.toString()}`);
|
|
3283
|
+
}
|
|
3284
|
+
return value;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
// src/browser/sync/paginated_query_client.ts
|
|
3288
|
+
var PaginatedQueryClient = class {
|
|
3289
|
+
constructor(client, onTransition) {
|
|
3290
|
+
this.client = client;
|
|
3291
|
+
this.onTransition = onTransition;
|
|
3292
|
+
this.lastTransitionTs = Long.fromNumber(0);
|
|
3293
|
+
this.client.addOnTransitionHandler(
|
|
3294
|
+
(transition) => this.onBaseTransition(transition)
|
|
3295
|
+
);
|
|
3296
|
+
}
|
|
3297
|
+
paginatedQuerySet = /* @__PURE__ */ new Map();
|
|
3298
|
+
// hold onto a real Transition so we can construct synthetic ones with that timestamp
|
|
3299
|
+
lastTransitionTs;
|
|
3300
|
+
/**
|
|
3301
|
+
* Subscribe to a paginated query.
|
|
3302
|
+
*
|
|
3303
|
+
* @param name - The name of the paginated query function
|
|
3304
|
+
* @param args - Arguments for the query (excluding paginationOpts)
|
|
3305
|
+
* @param options - Pagination options including initialNumItems
|
|
3306
|
+
* @returns Object with paginatedQueryToken and unsubscribe function
|
|
3307
|
+
*/
|
|
3308
|
+
subscribe(name, args, options) {
|
|
3309
|
+
const canonicalizedUdfPath = canonicalizeUdfPath(name);
|
|
3310
|
+
const token = serializePaginatedPathAndArgs(
|
|
3311
|
+
canonicalizedUdfPath,
|
|
3312
|
+
args,
|
|
3313
|
+
options
|
|
3314
|
+
);
|
|
3315
|
+
const unsubscribe = () => this.removePaginatedQuerySubscriber(token);
|
|
3316
|
+
const existingEntry = this.paginatedQuerySet.get(token);
|
|
3317
|
+
if (existingEntry) {
|
|
3318
|
+
existingEntry.numSubscribers += 1;
|
|
3319
|
+
return {
|
|
3320
|
+
paginatedQueryToken: token,
|
|
3321
|
+
unsubscribe
|
|
3322
|
+
};
|
|
3323
|
+
}
|
|
3324
|
+
this.paginatedQuerySet.set(token, {
|
|
3325
|
+
token,
|
|
3326
|
+
canonicalizedUdfPath,
|
|
3327
|
+
args,
|
|
3328
|
+
numSubscribers: 1,
|
|
3329
|
+
options: { initialNumItems: options.initialNumItems },
|
|
3330
|
+
nextPageKey: 0,
|
|
3331
|
+
pageKeys: [],
|
|
3332
|
+
pageKeyToQuery: /* @__PURE__ */ new Map(),
|
|
3333
|
+
ongoingSplits: /* @__PURE__ */ new Map(),
|
|
3334
|
+
skip: false,
|
|
3335
|
+
id: options.id
|
|
3336
|
+
});
|
|
3337
|
+
this.addPageToPaginatedQuery(token, null, options.initialNumItems);
|
|
3338
|
+
return {
|
|
3339
|
+
paginatedQueryToken: token,
|
|
3340
|
+
unsubscribe
|
|
3341
|
+
};
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Get current results for a paginated query based on local state.
|
|
3345
|
+
*
|
|
3346
|
+
* Throws an error when one of the pages has errored.
|
|
3347
|
+
*/
|
|
3348
|
+
localQueryResult(name, args, options) {
|
|
3349
|
+
const canonicalizedUdfPath = canonicalizeUdfPath(name);
|
|
3350
|
+
const token = serializePaginatedPathAndArgs(
|
|
3351
|
+
canonicalizedUdfPath,
|
|
3352
|
+
args,
|
|
3353
|
+
options
|
|
3354
|
+
);
|
|
3355
|
+
return this.localQueryResultByToken(token);
|
|
3356
|
+
}
|
|
3357
|
+
/**
|
|
3358
|
+
* @internal
|
|
3359
|
+
*/
|
|
3360
|
+
localQueryResultByToken(token) {
|
|
3361
|
+
const paginatedQuery = this.paginatedQuerySet.get(token);
|
|
3362
|
+
if (!paginatedQuery) {
|
|
3363
|
+
return void 0;
|
|
3364
|
+
}
|
|
3365
|
+
const activePages = this.activePageQueryTokens(paginatedQuery);
|
|
3366
|
+
if (activePages.length === 0) {
|
|
3367
|
+
return {
|
|
3368
|
+
results: [],
|
|
3369
|
+
status: "LoadingFirstPage",
|
|
3370
|
+
loadMore: (numItems) => {
|
|
3371
|
+
return this.loadMoreOfPaginatedQuery(token, numItems);
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
let allResults = [];
|
|
3376
|
+
let hasUndefined = false;
|
|
3377
|
+
let isDone = false;
|
|
3378
|
+
for (const pageToken of activePages) {
|
|
3379
|
+
const result = this.client.localQueryResultByToken(pageToken);
|
|
3380
|
+
if (result === void 0) {
|
|
3381
|
+
hasUndefined = true;
|
|
3382
|
+
isDone = false;
|
|
3383
|
+
continue;
|
|
3384
|
+
}
|
|
3385
|
+
const paginationResult = asPaginationResult(result);
|
|
3386
|
+
allResults = allResults.concat(paginationResult.page);
|
|
3387
|
+
isDone = !!paginationResult.isDone;
|
|
3388
|
+
}
|
|
3389
|
+
let status;
|
|
3390
|
+
if (hasUndefined) {
|
|
3391
|
+
status = allResults.length === 0 ? "LoadingFirstPage" : "LoadingMore";
|
|
3392
|
+
} else if (isDone) {
|
|
3393
|
+
status = "Exhausted";
|
|
3394
|
+
} else {
|
|
3395
|
+
status = "CanLoadMore";
|
|
3396
|
+
}
|
|
3397
|
+
return {
|
|
3398
|
+
results: allResults,
|
|
3399
|
+
status,
|
|
3400
|
+
loadMore: (numItems) => {
|
|
3401
|
+
return this.loadMoreOfPaginatedQuery(token, numItems);
|
|
3402
|
+
}
|
|
3403
|
+
};
|
|
3404
|
+
}
|
|
3405
|
+
onBaseTransition(transition) {
|
|
3406
|
+
const changedBaseTokens = transition.queries.map((q) => q.token);
|
|
3407
|
+
const changed = this.queriesContainingTokens(changedBaseTokens);
|
|
3408
|
+
let paginatedQueries = [];
|
|
3409
|
+
if (changed.length > 0) {
|
|
3410
|
+
this.processPaginatedQuerySplits(
|
|
3411
|
+
changed,
|
|
3412
|
+
(token) => this.client.localQueryResultByToken(token)
|
|
3413
|
+
);
|
|
3414
|
+
paginatedQueries = changed.map((token) => ({
|
|
3415
|
+
token,
|
|
3416
|
+
modification: {
|
|
3417
|
+
kind: "Updated",
|
|
3418
|
+
result: this.localQueryResultByToken(token)
|
|
3419
|
+
}
|
|
3420
|
+
}));
|
|
3421
|
+
}
|
|
3422
|
+
const extendedTransition = {
|
|
3423
|
+
...transition,
|
|
3424
|
+
paginatedQueries
|
|
3425
|
+
};
|
|
3426
|
+
this.onTransition(extendedTransition);
|
|
3427
|
+
}
|
|
3428
|
+
/**
|
|
3429
|
+
* Load more items for a paginated query.
|
|
3430
|
+
*
|
|
3431
|
+
* This *always* causes a transition, the status of the query
|
|
3432
|
+
* has probably changed from "CanLoadMore" to "LoadingMore".
|
|
3433
|
+
* Data might have changed too: maybe a subscription to this page
|
|
3434
|
+
* query already exists (unlikely but possible) or this page query
|
|
3435
|
+
* has an optimistic update providing some initial data.
|
|
3436
|
+
*
|
|
3437
|
+
* @internal
|
|
3438
|
+
*/
|
|
3439
|
+
loadMoreOfPaginatedQuery(token, numItems) {
|
|
3440
|
+
this.mustGetPaginatedQuery(token);
|
|
3441
|
+
const lastPageToken = this.queryTokenForLastPageOfPaginatedQuery(token);
|
|
3442
|
+
const lastPageResult = this.client.localQueryResultByToken(lastPageToken);
|
|
3443
|
+
if (!lastPageResult) {
|
|
3444
|
+
return false;
|
|
3445
|
+
}
|
|
3446
|
+
const paginationResult = asPaginationResult(lastPageResult);
|
|
3447
|
+
if (paginationResult.isDone) {
|
|
3448
|
+
return false;
|
|
3449
|
+
}
|
|
3450
|
+
this.addPageToPaginatedQuery(
|
|
3451
|
+
token,
|
|
3452
|
+
paginationResult.continueCursor,
|
|
3453
|
+
numItems
|
|
3454
|
+
);
|
|
3455
|
+
const loadMoreTransition = {
|
|
3456
|
+
timestamp: this.lastTransitionTs,
|
|
3457
|
+
reflectedMutations: [],
|
|
3458
|
+
queries: [],
|
|
3459
|
+
paginatedQueries: [
|
|
3460
|
+
{
|
|
3461
|
+
token,
|
|
3462
|
+
modification: {
|
|
3463
|
+
kind: "Updated",
|
|
3464
|
+
result: this.localQueryResultByToken(token)
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
]
|
|
3468
|
+
};
|
|
3469
|
+
this.onTransition(loadMoreTransition);
|
|
3470
|
+
return true;
|
|
3471
|
+
}
|
|
3472
|
+
/**
|
|
3473
|
+
* @internal
|
|
3474
|
+
*/
|
|
3475
|
+
queriesContainingTokens(queryTokens) {
|
|
3476
|
+
if (queryTokens.length === 0) {
|
|
3477
|
+
return [];
|
|
3478
|
+
}
|
|
3479
|
+
const changed = [];
|
|
3480
|
+
const queryTokenSet = new Set(queryTokens);
|
|
3481
|
+
for (const [paginatedToken, paginatedQuery] of this.paginatedQuerySet) {
|
|
3482
|
+
for (const pageToken of this.allQueryTokens(paginatedQuery)) {
|
|
3483
|
+
if (queryTokenSet.has(pageToken)) {
|
|
3484
|
+
changed.push(paginatedToken);
|
|
3485
|
+
break;
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
return changed;
|
|
3490
|
+
}
|
|
3491
|
+
/**
|
|
3492
|
+
* @internal
|
|
3493
|
+
*/
|
|
3494
|
+
processPaginatedQuerySplits(changed, getResult) {
|
|
3495
|
+
for (const paginatedQueryToken of changed) {
|
|
3496
|
+
const paginatedQuery = this.mustGetPaginatedQuery(paginatedQueryToken);
|
|
3497
|
+
const { ongoingSplits, pageKeyToQuery, pageKeys } = paginatedQuery;
|
|
3498
|
+
for (const [pageKey, [splitKey1, splitKey2]] of ongoingSplits) {
|
|
3499
|
+
const bothNewPagesLoaded = getResult(pageKeyToQuery.get(splitKey1).queryToken) !== void 0 && getResult(pageKeyToQuery.get(splitKey2).queryToken) !== void 0;
|
|
3500
|
+
if (bothNewPagesLoaded) {
|
|
3501
|
+
this.completePaginatedQuerySplit(
|
|
3502
|
+
paginatedQuery,
|
|
3503
|
+
pageKey,
|
|
3504
|
+
splitKey1,
|
|
3505
|
+
splitKey2
|
|
3506
|
+
);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
for (const pageKey of pageKeys) {
|
|
3510
|
+
if (ongoingSplits.has(pageKey)) {
|
|
3511
|
+
continue;
|
|
3512
|
+
}
|
|
3513
|
+
const pageToken = pageKeyToQuery.get(pageKey).queryToken;
|
|
3514
|
+
const pageResult = getResult(pageToken);
|
|
3515
|
+
if (!pageResult) {
|
|
3516
|
+
continue;
|
|
3517
|
+
}
|
|
3518
|
+
const result = asPaginationResult(pageResult);
|
|
3519
|
+
const shouldSplit = result.splitCursor && (result.pageStatus === "SplitRecommended" || result.pageStatus === "SplitRequired" || // This client-driven page splitting condition will change in the future.
|
|
3520
|
+
result.page.length > paginatedQuery.options.initialNumItems * 2);
|
|
3521
|
+
if (shouldSplit) {
|
|
3522
|
+
this.splitPaginatedQueryPage(
|
|
3523
|
+
paginatedQuery,
|
|
3524
|
+
pageKey,
|
|
3525
|
+
result.splitCursor,
|
|
3526
|
+
// we just checked
|
|
3527
|
+
result.continueCursor
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
splitPaginatedQueryPage(paginatedQuery, pageKey, splitCursor, continueCursor) {
|
|
3534
|
+
const splitKey1 = paginatedQuery.nextPageKey++;
|
|
3535
|
+
const splitKey2 = paginatedQuery.nextPageKey++;
|
|
3536
|
+
const paginationOpts = {
|
|
3537
|
+
cursor: continueCursor,
|
|
3538
|
+
numItems: paginatedQuery.options.initialNumItems,
|
|
3539
|
+
id: paginatedQuery.id
|
|
3540
|
+
};
|
|
3541
|
+
const firstSubscription = this.client.subscribe(
|
|
3542
|
+
paginatedQuery.canonicalizedUdfPath,
|
|
3543
|
+
{
|
|
3544
|
+
...paginatedQuery.args,
|
|
3545
|
+
paginationOpts: {
|
|
3546
|
+
...paginationOpts,
|
|
3547
|
+
cursor: null,
|
|
3548
|
+
// Start from beginning for first split
|
|
3549
|
+
endCursor: splitCursor
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
);
|
|
3553
|
+
paginatedQuery.pageKeyToQuery.set(splitKey1, firstSubscription);
|
|
3554
|
+
const secondSubscription = this.client.subscribe(
|
|
3555
|
+
paginatedQuery.canonicalizedUdfPath,
|
|
3556
|
+
{
|
|
3557
|
+
...paginatedQuery.args,
|
|
3558
|
+
paginationOpts: {
|
|
3559
|
+
...paginationOpts,
|
|
3560
|
+
cursor: splitCursor,
|
|
3561
|
+
endCursor: continueCursor
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
);
|
|
3565
|
+
paginatedQuery.pageKeyToQuery.set(splitKey2, secondSubscription);
|
|
3566
|
+
paginatedQuery.ongoingSplits.set(pageKey, [splitKey1, splitKey2]);
|
|
3567
|
+
}
|
|
3568
|
+
/**
|
|
3569
|
+
* @internal
|
|
3570
|
+
*/
|
|
3571
|
+
addPageToPaginatedQuery(token, continueCursor, numItems) {
|
|
3572
|
+
const paginatedQuery = this.mustGetPaginatedQuery(token);
|
|
3573
|
+
const pageKey = paginatedQuery.nextPageKey++;
|
|
3574
|
+
const paginationOpts = {
|
|
3575
|
+
cursor: continueCursor,
|
|
3576
|
+
numItems,
|
|
3577
|
+
id: paginatedQuery.id
|
|
3578
|
+
};
|
|
3579
|
+
const pageArgs = {
|
|
3580
|
+
...paginatedQuery.args,
|
|
3581
|
+
paginationOpts
|
|
3582
|
+
};
|
|
3583
|
+
const subscription = this.client.subscribe(
|
|
3584
|
+
paginatedQuery.canonicalizedUdfPath,
|
|
3585
|
+
pageArgs
|
|
3586
|
+
);
|
|
3587
|
+
paginatedQuery.pageKeys.push(pageKey);
|
|
3588
|
+
paginatedQuery.pageKeyToQuery.set(pageKey, subscription);
|
|
3589
|
+
return subscription;
|
|
3590
|
+
}
|
|
3591
|
+
removePaginatedQuerySubscriber(token) {
|
|
3592
|
+
const paginatedQuery = this.paginatedQuerySet.get(token);
|
|
3593
|
+
if (!paginatedQuery) {
|
|
3594
|
+
return;
|
|
3595
|
+
}
|
|
3596
|
+
paginatedQuery.numSubscribers -= 1;
|
|
3597
|
+
if (paginatedQuery.numSubscribers > 0) {
|
|
3598
|
+
return;
|
|
3599
|
+
}
|
|
3600
|
+
for (const subscription of paginatedQuery.pageKeyToQuery.values()) {
|
|
3601
|
+
subscription.unsubscribe();
|
|
3602
|
+
}
|
|
3603
|
+
this.paginatedQuerySet.delete(token);
|
|
3604
|
+
}
|
|
3605
|
+
completePaginatedQuerySplit(paginatedQuery, pageKey, splitKey1, splitKey2) {
|
|
3606
|
+
const originalQuery = paginatedQuery.pageKeyToQuery.get(pageKey);
|
|
3607
|
+
paginatedQuery.pageKeyToQuery.delete(pageKey);
|
|
3608
|
+
const pageIndex = paginatedQuery.pageKeys.indexOf(pageKey);
|
|
3609
|
+
paginatedQuery.pageKeys.splice(pageIndex, 1, splitKey1, splitKey2);
|
|
3610
|
+
paginatedQuery.ongoingSplits.delete(pageKey);
|
|
3611
|
+
originalQuery.unsubscribe();
|
|
3612
|
+
}
|
|
3613
|
+
/** The query tokens for all active pages, in result order */
|
|
3614
|
+
activePageQueryTokens(paginatedQuery) {
|
|
3615
|
+
return paginatedQuery.pageKeys.map(
|
|
3616
|
+
(pageKey) => paginatedQuery.pageKeyToQuery.get(pageKey).queryToken
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3619
|
+
allQueryTokens(paginatedQuery) {
|
|
3620
|
+
return Array.from(paginatedQuery.pageKeyToQuery.values()).map(
|
|
3621
|
+
(sub) => sub.queryToken
|
|
3622
|
+
);
|
|
3623
|
+
}
|
|
3624
|
+
queryTokenForLastPageOfPaginatedQuery(token) {
|
|
3625
|
+
const paginatedQuery = this.mustGetPaginatedQuery(token);
|
|
3626
|
+
const lastPageKey = paginatedQuery.pageKeys[paginatedQuery.pageKeys.length - 1];
|
|
3627
|
+
if (lastPageKey === void 0) {
|
|
3628
|
+
throw new Error(`No pages for paginated query ${token}`);
|
|
3629
|
+
}
|
|
3630
|
+
return paginatedQuery.pageKeyToQuery.get(lastPageKey).queryToken;
|
|
3631
|
+
}
|
|
3632
|
+
mustGetPaginatedQuery(token) {
|
|
3633
|
+
const paginatedQuery = this.paginatedQuerySet.get(token);
|
|
3634
|
+
if (!paginatedQuery) {
|
|
3635
|
+
throw new Error("paginated query no longer exists for token " + token);
|
|
3636
|
+
}
|
|
3637
|
+
return paginatedQuery;
|
|
3638
|
+
}
|
|
3639
|
+
};
|
|
3640
|
+
|
|
3259
3641
|
// src/browser/simple_client.ts
|
|
3260
3642
|
var defaultWebSocketConstructor;
|
|
3261
3643
|
var ConvexClient = class {
|
|
3262
3644
|
listeners;
|
|
3263
3645
|
_client;
|
|
3646
|
+
_paginatedClient;
|
|
3264
3647
|
// A synthetic server event to run callbacks the first time
|
|
3265
3648
|
callNewListenersWithCurrentValuesTimer;
|
|
3266
3649
|
_closed;
|
|
@@ -3275,6 +3658,13 @@ var convex = (() => {
|
|
|
3275
3658
|
if (this._client) return this._client;
|
|
3276
3659
|
throw new Error("ConvexClient is disabled");
|
|
3277
3660
|
}
|
|
3661
|
+
/**
|
|
3662
|
+
* @internal
|
|
3663
|
+
*/
|
|
3664
|
+
get paginatedClient() {
|
|
3665
|
+
if (this._paginatedClient) return this._paginatedClient;
|
|
3666
|
+
throw new Error("ConvexClient is disabled");
|
|
3667
|
+
}
|
|
3278
3668
|
get disabled() {
|
|
3279
3669
|
return this._disabled;
|
|
3280
3670
|
}
|
|
@@ -3299,9 +3689,15 @@ var convex = (() => {
|
|
|
3299
3689
|
if (!this.disabled) {
|
|
3300
3690
|
this._client = new BaseConvexClient(
|
|
3301
3691
|
address,
|
|
3302
|
-
(
|
|
3692
|
+
() => {
|
|
3693
|
+
},
|
|
3694
|
+
// NOP, let the paginated query client do it all
|
|
3303
3695
|
baseOptions
|
|
3304
3696
|
);
|
|
3697
|
+
this._paginatedClient = new PaginatedQueryClient(
|
|
3698
|
+
this._client,
|
|
3699
|
+
(transition) => this._transition(transition)
|
|
3700
|
+
);
|
|
3305
3701
|
}
|
|
3306
3702
|
this.listeners = /* @__PURE__ */ new Set();
|
|
3307
3703
|
}
|
|
@@ -3339,15 +3735,7 @@ var convex = (() => {
|
|
|
3339
3735
|
*/
|
|
3340
3736
|
onUpdate(query, args, callback, onError) {
|
|
3341
3737
|
if (this.disabled) {
|
|
3342
|
-
|
|
3343
|
-
};
|
|
3344
|
-
const unsubscribeProps2 = {
|
|
3345
|
-
unsubscribe: disabledUnsubscribe,
|
|
3346
|
-
getCurrentValue: () => void 0,
|
|
3347
|
-
getQueryLogs: () => void 0
|
|
3348
|
-
};
|
|
3349
|
-
Object.assign(disabledUnsubscribe, unsubscribeProps2);
|
|
3350
|
-
return disabledUnsubscribe;
|
|
3738
|
+
return this.createDisabledUnsubscribe();
|
|
3351
3739
|
}
|
|
3352
3740
|
const { queryToken, unsubscribe } = this.client.subscribe(
|
|
3353
3741
|
getFunctionName(query),
|
|
@@ -3360,7 +3748,8 @@ var convex = (() => {
|
|
|
3360
3748
|
unsubscribe,
|
|
3361
3749
|
hasEverRun: false,
|
|
3362
3750
|
query,
|
|
3363
|
-
args
|
|
3751
|
+
args,
|
|
3752
|
+
paginationOptions: void 0
|
|
3364
3753
|
};
|
|
3365
3754
|
this.listeners.add(queryInfo);
|
|
3366
3755
|
if (this.queryResultReady(queryToken) && this.callNewListenersWithCurrentValuesTimer === void 0) {
|
|
@@ -3384,19 +3773,102 @@ var convex = (() => {
|
|
|
3384
3773
|
Object.assign(ret, unsubscribeProps);
|
|
3385
3774
|
return ret;
|
|
3386
3775
|
}
|
|
3776
|
+
/**
|
|
3777
|
+
* Call a callback whenever a new result for a paginated query is received.
|
|
3778
|
+
*
|
|
3779
|
+
* This is an experimental preview: the final API may change.
|
|
3780
|
+
* In particular, caching behavior, page splitting, and required paginated query options
|
|
3781
|
+
* may change.
|
|
3782
|
+
*
|
|
3783
|
+
* @param query - A {@link server.FunctionReference} for the public query to run.
|
|
3784
|
+
* @param args - The arguments to run the query with.
|
|
3785
|
+
* @param options - Options for the paginated query including initialNumItems and id.
|
|
3786
|
+
* @param callback - Function to call when the query result updates.
|
|
3787
|
+
* @param onError - Function to call when the query result updates with an error.
|
|
3788
|
+
*
|
|
3789
|
+
* @return an {@link Unsubscribe} function to stop calling the callback.
|
|
3790
|
+
*/
|
|
3791
|
+
onPaginatedUpdate_experimental(query, args, options, callback, onError) {
|
|
3792
|
+
if (this.disabled) {
|
|
3793
|
+
return this.createDisabledUnsubscribe();
|
|
3794
|
+
}
|
|
3795
|
+
const paginationOptions = {
|
|
3796
|
+
initialNumItems: options.initialNumItems,
|
|
3797
|
+
id: -1
|
|
3798
|
+
};
|
|
3799
|
+
const { paginatedQueryToken, unsubscribe } = this.paginatedClient.subscribe(
|
|
3800
|
+
getFunctionName(query),
|
|
3801
|
+
args,
|
|
3802
|
+
// Simple client doesn't use IDs, there's no expectation that these queries remain separate.
|
|
3803
|
+
paginationOptions
|
|
3804
|
+
);
|
|
3805
|
+
const queryInfo = {
|
|
3806
|
+
queryToken: paginatedQueryToken,
|
|
3807
|
+
callback,
|
|
3808
|
+
onError,
|
|
3809
|
+
unsubscribe,
|
|
3810
|
+
hasEverRun: false,
|
|
3811
|
+
query,
|
|
3812
|
+
args,
|
|
3813
|
+
paginationOptions
|
|
3814
|
+
};
|
|
3815
|
+
this.listeners.add(queryInfo);
|
|
3816
|
+
if (!!this.paginatedClient.localQueryResultByToken(paginatedQueryToken) && this.callNewListenersWithCurrentValuesTimer === void 0) {
|
|
3817
|
+
this.callNewListenersWithCurrentValuesTimer = setTimeout(
|
|
3818
|
+
() => this.callNewListenersWithCurrentValues(),
|
|
3819
|
+
0
|
|
3820
|
+
);
|
|
3821
|
+
}
|
|
3822
|
+
const unsubscribeProps = {
|
|
3823
|
+
unsubscribe: () => {
|
|
3824
|
+
if (this.closed) {
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3827
|
+
this.listeners.delete(queryInfo);
|
|
3828
|
+
unsubscribe();
|
|
3829
|
+
},
|
|
3830
|
+
getCurrentValue: () => {
|
|
3831
|
+
const result = this.paginatedClient.localQueryResult(
|
|
3832
|
+
getFunctionName(query),
|
|
3833
|
+
args,
|
|
3834
|
+
paginationOptions
|
|
3835
|
+
);
|
|
3836
|
+
return result;
|
|
3837
|
+
},
|
|
3838
|
+
getQueryLogs: () => []
|
|
3839
|
+
// Paginated queries don't aggregate their logs
|
|
3840
|
+
};
|
|
3841
|
+
const ret = unsubscribeProps.unsubscribe;
|
|
3842
|
+
Object.assign(ret, unsubscribeProps);
|
|
3843
|
+
return ret;
|
|
3844
|
+
}
|
|
3387
3845
|
// Run all callbacks that have never been run before if they have a query
|
|
3388
3846
|
// result available now.
|
|
3389
3847
|
callNewListenersWithCurrentValues() {
|
|
3390
3848
|
this.callNewListenersWithCurrentValuesTimer = void 0;
|
|
3391
|
-
this._transition([], true);
|
|
3849
|
+
this._transition({ queries: [], paginatedQueries: [] }, true);
|
|
3392
3850
|
}
|
|
3393
3851
|
queryResultReady(queryToken) {
|
|
3394
3852
|
return this.client.hasLocalQueryResultByToken(queryToken);
|
|
3395
3853
|
}
|
|
3854
|
+
createDisabledUnsubscribe() {
|
|
3855
|
+
const disabledUnsubscribe = () => {
|
|
3856
|
+
};
|
|
3857
|
+
const unsubscribeProps = {
|
|
3858
|
+
unsubscribe: disabledUnsubscribe,
|
|
3859
|
+
getCurrentValue: () => void 0,
|
|
3860
|
+
getQueryLogs: () => void 0
|
|
3861
|
+
};
|
|
3862
|
+
Object.assign(disabledUnsubscribe, unsubscribeProps);
|
|
3863
|
+
return disabledUnsubscribe;
|
|
3864
|
+
}
|
|
3396
3865
|
async close() {
|
|
3397
3866
|
if (this.disabled) return;
|
|
3398
3867
|
this.listeners.clear();
|
|
3399
3868
|
this._closed = true;
|
|
3869
|
+
if (this._paginatedClient) {
|
|
3870
|
+
this._paginatedClient = void 0;
|
|
3871
|
+
}
|
|
3400
3872
|
return this.client.close();
|
|
3401
3873
|
}
|
|
3402
3874
|
/**
|
|
@@ -3435,14 +3907,27 @@ var convex = (() => {
|
|
|
3435
3907
|
/**
|
|
3436
3908
|
* @internal
|
|
3437
3909
|
*/
|
|
3438
|
-
_transition(
|
|
3910
|
+
_transition({
|
|
3911
|
+
queries,
|
|
3912
|
+
paginatedQueries
|
|
3913
|
+
}, callNewListeners = false) {
|
|
3914
|
+
const updatedQueries = [
|
|
3915
|
+
...queries.map((q) => q.token),
|
|
3916
|
+
...paginatedQueries.map((q) => q.token)
|
|
3917
|
+
];
|
|
3439
3918
|
for (const queryInfo of this.listeners) {
|
|
3440
3919
|
const { callback, queryToken, onError, hasEverRun } = queryInfo;
|
|
3441
|
-
|
|
3920
|
+
const isPaginatedQuery = serializedQueryTokenIsPaginated(queryToken);
|
|
3921
|
+
const hasResultReady = isPaginatedQuery ? !!this.paginatedClient.localQueryResultByToken(queryToken) : this.client.hasLocalQueryResultByToken(queryToken);
|
|
3922
|
+
if (updatedQueries.includes(queryToken) || callNewListeners && !hasEverRun && hasResultReady) {
|
|
3442
3923
|
queryInfo.hasEverRun = true;
|
|
3443
3924
|
let newValue;
|
|
3444
3925
|
try {
|
|
3445
|
-
|
|
3926
|
+
if (isPaginatedQuery) {
|
|
3927
|
+
newValue = this.paginatedClient.localQueryResultByToken(queryToken);
|
|
3928
|
+
} else {
|
|
3929
|
+
newValue = this.client.localQueryResultByToken(queryToken);
|
|
3930
|
+
}
|
|
3446
3931
|
} catch (error) {
|
|
3447
3932
|
if (!(error instanceof Error)) throw error;
|
|
3448
3933
|
if (onError) {
|