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