UNPKG

@azure/cosmos

Version:
67 lines (66 loc) 3.72 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var QueryValidationHelper_exports = {}; __export(QueryValidationHelper_exports, { QueryTypes: () => QueryTypes, rejectContinuationTokenForUnsupportedQueries: () => rejectContinuationTokenForUnsupportedQueries }); module.exports = __toCommonJS(QueryValidationHelper_exports); var import_ErrorResponse = require("../request/ErrorResponse.js"); function rejectContinuationTokenForUnsupportedQueries(continuationToken, unsupportedQueryTypes) { if (!continuationToken) { return; } const conflictingQueryType = unsupportedQueryTypes.find((queryType) => queryType.isPresent); if (conflictingQueryType) { throw new import_ErrorResponse.ErrorResponse(conflictingQueryType.errorMessage); } } const QueryTypes = { nonStreamingOrderBy: (isPresent) => ({ name: "NonStreamingOrderBy", isPresent, errorMessage: "Continuation tokens are not supported for non-streaming ORDER BY queries. These queries must process all results to ensure correct ordering and cannot be resumed from an intermediate state. Consider removing the continuation token and using fetchAll() instead for complete results." }), groupBy: (isPresent) => ({ name: "GroupBy", isPresent, errorMessage: "Continuation tokens are not supported for GROUP BY queries. These queries must process all results to compute aggregations and cannot be resumed from an intermediate state. Consider removing the continuation token and using fetchAll() instead for complete results." }), unorderedDistinct: (isPresent) => ({ name: "UnorderedDistinct", isPresent, errorMessage: "Continuation tokens are not supported for unordered DISTINCT queries. These queries require tracking large amounts of duplicate data in continuation tokens which is not practical. Consider removing the continuation token and using fetchAll() instead, or use ordered DISTINCT queries which are supported." }), hybridSearch: (isPresent) => ({ name: "HybridSearch", isPresent, errorMessage: "Continuation tokens are not supported for hybrid search queries. Hybrid search queries require processing and ranking of all component query results to compute accurate Reciprocal Rank Fusion (RRF) scores and cannot be resumed from an intermediate state. Consider removing the continuation token and using fetchAll() instead for complete results." }), // Easy to add new unsupported query types here vectorSearch: (isPresent) => ({ name: "VectorSearch", isPresent, errorMessage: "Continuation tokens are not supported for vector search queries. Vector search queries require processing similarity calculations across all data and cannot be resumed from an intermediate state. Consider removing the continuation token and using fetchAll() instead for complete results." }) }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { QueryTypes, rejectContinuationTokenForUnsupportedQueries });