1 | // Copyright (c) Microsoft Corporation.
|
2 | // Licensed under the MIT license.
|
3 | import { Constants } from "./common";
|
4 | /**
|
5 | * A single response page from the Azure Cosmos DB Change Feed
|
6 | */
|
7 | export class ChangeFeedResponse {
|
8 | /**
|
9 | * @internal
|
10 | */
|
11 | constructor(
|
12 | /**
|
13 | * Gets the items returned in the response from Azure Cosmos DB
|
14 | */
|
15 | result,
|
16 | /**
|
17 | * Gets the number of items returned in the response from Azure Cosmos DB
|
18 | */
|
19 | count,
|
20 | /**
|
21 | * Gets the status code of the response from Azure Cosmos DB
|
22 | */
|
23 | statusCode, headers) {
|
24 | this.result = result;
|
25 | this.count = count;
|
26 | this.statusCode = statusCode;
|
27 | this.headers = Object.freeze(headers);
|
28 | }
|
29 | /**
|
30 | * Gets the request charge for this request from the Azure Cosmos DB service.
|
31 | */
|
32 | get requestCharge() {
|
33 | const rus = this.headers[Constants.HttpHeaders.RequestCharge];
|
34 | return rus ? parseInt(rus, 10) : null;
|
35 | }
|
36 | /**
|
37 | * Gets the activity ID for the request from the Azure Cosmos DB service.
|
38 | */
|
39 | get activityId() {
|
40 | return this.headers[Constants.HttpHeaders.ActivityId];
|
41 | }
|
42 | /**
|
43 | * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.
|
44 | *
|
45 | * This is equivalent to the `etag` property.
|
46 | */
|
47 | get continuation() {
|
48 | return this.etag;
|
49 | }
|
50 | /**
|
51 | * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.
|
52 | */
|
53 | get sessionToken() {
|
54 | return this.headers[Constants.HttpHeaders.SessionToken];
|
55 | }
|
56 | /**
|
57 | * Gets the entity tag associated with last transaction in the Azure Cosmos DB service,
|
58 | * which can be used as If-Non-Match Access condition for ReadFeed REST request or
|
59 | * `continuation` property of `ChangeFeedOptions` parameter for
|
60 | * `Items.changeFeed()`
|
61 | * to get feed changes since the transaction specified by this entity tag.
|
62 | *
|
63 | * This is equivalent to the `continuation` property.
|
64 | */
|
65 | get etag() {
|
66 | return this.headers[Constants.HttpHeaders.ETag];
|
67 | }
|
68 | }
|
69 | //# sourceMappingURL=ChangeFeedResponse.js.map |
\ | No newline at end of file |