@cfworker/cosmos
Version:
Azure Cosmos DB client for Cloudflare Workers and service workers
61 lines (60 loc) • 1.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeedResponse = exports.ItemResponse = exports.CosmosResponse = void 0;
class CosmosResponse {
response;
constructor(response) {
this.response = response;
}
get status() {
return this.response.status;
}
get headers() {
return this.response.headers;
}
get body() {
return this.response.body;
}
get activityId() {
return this.response.headers.get('x-ms-activity-id');
}
get etag() {
return this.response.headers.get('etag');
}
get requestCharge() {
return parseInt(this.response.headers.get('x-ms-request-charge'));
}
get raw() {
return this.response;
}
}
exports.CosmosResponse = CosmosResponse;
class ItemResponse extends CosmosResponse {
constructor(response) {
super(response);
}
json() {
return this.response.json();
}
}
exports.ItemResponse = ItemResponse;
class FeedResponse extends CosmosResponse {
next;
itemsProperty;
constructor(response, next, itemsProperty) {
super(response);
this.next = next;
this.itemsProperty = itemsProperty;
}
get count() {
return parseInt(this.response.headers.get('x-ms-item-count'));
}
get hasNext() {
return this.response.headers.has('x-ms-continuation');
}
async json() {
const data = await this.response.json();
return data[this.itemsProperty];
}
}
exports.FeedResponse = FeedResponse;