mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-13 05:15:30 +00:00
24 lines
912 B
TypeScript
24 lines
912 B
TypeScript
import { SDKOfferDefinition } from "../../Contracts/DataModels";
|
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
import { client } from "../CosmosClient";
|
|
import { handleError, getErrorMessage } from "../ErrorHandlingUtils";
|
|
|
|
export const readOffers = async (): Promise<SDKOfferDefinition[]> => {
|
|
const clearMessage = logConsoleProgress(`Querying offers`);
|
|
|
|
try {
|
|
const response = await client().offers.readAll().fetchAll();
|
|
return response?.resources;
|
|
} catch (error) {
|
|
// This should be removed when we can correctly identify if an account is serverless when connected using connection string too.
|
|
if (getErrorMessage(error)?.includes("Reading or replacing offers is not supported for serverless accounts")) {
|
|
return [];
|
|
}
|
|
|
|
handleError(error, "ReadOffers", `Error while querying offers`);
|
|
throw error;
|
|
} finally {
|
|
clearMessage();
|
|
}
|
|
};
|