This repository was archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocuments.js
289 lines (259 loc) · 13.9 KB
/
documents.js
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
//----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
var Base = require("./base");
//SCRIPT START
var AzureDocuments = Base.defineClass(null, null,
{
/**
* Represents a DatabaseAccount. A DatabaseAccount is the container for databases.
* @global
* @property {string} DatabasesLink - The self-link for Databases in the databaseAccount.
* @property {string} MediaLink - The self-link for Media in the databaseAccount.
* @property {number} MaxMediaStorageUsageInMB - Attachment content (media) storage quota in MBs ( Retrieved from gateway ).
* @property {number} CurrentMediaStorageUsageInMB - <p> Current attachment content (media) usage in MBs (Retrieved from gateway )<br>
Value is returned from cached information updated periodically and is not guaranteed to be real time. </p>
* @property {number} CapacityUnitsConsumed - The number is capacity units database account is currently consuming. <br>
Value is returned from cached information updated periodically and is not guaranteed to be real time. </p>
* @property {number} CapacityUnitsProvisioned - <p> The number of provisioned capacity units for the database account. <br>
Value is returned from cached information updated periodically and is not guaranteed to be real time. </p>
* @property {number} ConsumedDocumentStorageInMB - <p> The cumulative sum of current sizes of created collection in MB. <br>
Value is returned from cached information updated periodically and is not guaranteed to be real time. </p>
* @property {number} ReservedDocumentStorageInMB - <p> The cumulative sum of maximum sizes of created collection in MB. <br>
Value is returned from cached information updated periodically and is not guaranteed to be real time. </p>
* @property {number} ProvisionedDocumentStorageInMB - <p> The provisioned documented storage capacity for the database account. <br>
Value is returned from cached information updated periodically and is not guaranteed to be real time. </p>
* @property {object} ConsistencyPolicy - Gets the UserConsistencyPolicy settings.
* @property {string} ConsistencyPolicy.defaultConsistencyLevel - The default consistency level and it's of type {@link ConsistencyLevel}.
* @property {number} ConsistencyPolicy.maxStalenessPrefix - In bounded staleness consistency, the maximum allowed staleness in terms difference in sequence numbers (aka version).
* @property {number} ConsistencyPolicy.maxStalenessIntervalInSeconds - In bounded staleness consistency, the maximum allowed staleness in terms time interval.
*/
DatabaseAccount : Base.defineClass(function() {
Object.defineProperty(this, "DatabasesLink", {
value: "",
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "MediaLink", {
value: "",
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "MaxMediaStorageUsageInMB", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "CurrentMediaStorageUsageInMB", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "CapacityUnitsConsumed", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "CapacityUnitsProvisioned", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "ConsumedDocumentStorageInMB", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "ReservedDocumentStorageInMB", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "ProvisionedDocumentStorageInMB", {
value: 0,
writable: true,
configurable: true,
enumerable: true
});
Object.defineProperty(this, "ConsistencyPolicy", {
value: "",
writable: true,
configurable: true,
enumerable: true
});
}),
/**
* <p>Represents the consistency levels supported for DocumentDB client operations.<br>
* The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. Consistency levels.<br>
* Consistency levels by order of strength are Strong, BoundedStaleness, Session and Eventual.</p>
* @readonly
* @enum {string}
* @property Strong Strong Consistency guarantees that read operations always return the value that was last written.
* @property BoundedStaleness Bounded Staleness guarantees that reads are not too out-of-date. This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds).
* @property Session Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), monotonic writes (writes are ordered)
and read your writes (your writes are immediately visible to your reads) within any single session.
* @property Eventual Eventual Consistency guarantees that reads will return a subset of writes. All writes
will be eventually be available for reads.
*/
ConsistencyLevel : Object.freeze({
Strong: "Strong",
BoundedStaleness: "BoundedStaleness",
Session: "Session",
Eventual: "Eventual"
}),
/**
* Specifies the supported indexing modes.
* @readonly
* @enum {string}
* @property Consistent <p>Index is updated synchronously with a create or update operation. <br>
With consistent indexing, query behavior is the same as the default consistency level for the collection. The index is
always kept up to date with the data. </p>
* @property Lazy <p>Index is updated asynchronously with respect to a create or update operation. <br>
With lazy indexing, queries are eventually consistent. The index is updated when the collection is idle.</p>
*/
IndexingMode : Object.freeze({
Consistent: "consistent",
Lazy: "lazy",
}),
/**
* Specifies the supported Index types.
* @readonly
* @enum {string}
* @property Hash This is supplied for a path which has no sorting requirement.
* This kind of an index has better precision than corresponding range index.
*
* @property Range This is supplied for a path which requires sorting.
*/
IndexType : Object.freeze({
Hash: "Hash",
Range: "Range",
}),
Protocol : Object.freeze({
Tcp: 1,
Https: 2,
}),
ConnectionMode : Object.freeze({
Direct: 0,
Gateway: 1,
}),
/**
* Enum for media read mode values.
* @readonly
* @enum {sting}
* @property Buffered Content is buffered at the client and not directly streamed from the content store.
<p>Use Buffered to reduce the time taken to read and write media files.</p>
* @property Streamed Content is directly streamed from the content store without any buffering at the client.
<p>Use Streamed to reduce the client memory overhead of reading and writing media files. </p>
*/
MediaReadMode : Object.freeze({
Buffered: "Buffered",
Streamed: "Streamed"
}),
/**
* Enum for permission mode values.
* @readonly
* @enum {string}
* @property None Permission not valid.
* @property Read Permission applicable for read operations only.
* @property All Permission applicable for all operations.
*/
PermissionMode: Object.freeze({
None: "none",
Read: "read",
All: "all"
}),
/**
* Enum for trigger type values.
* Specifies the type of the trigger.
* @readonly
* @enum {string}
* @property Pre Trigger should be executed before the associated operation(s).
* @property Post Trigger should be executed after the associated operation(s).
*/
TriggerType: Object.freeze({
Pre: "pre",
Post: "post",
}),
/**
* Enum for trigger operation values.
* specifies the operations on which a trigger should be executed.
* @readonly
* @enum {string}
* @property All All operations.
* @property Create Create operations only.
* @property Update Update operations only.
* @property Delete Delete operations only.
* @property Replace Replace operations only.
*/
TriggerOperation: Object.freeze({
All: "all",
Create: "create",
Update: "update",
Delete: "delete",
Replace: "replace"
}),
/**
* Enum for udf type values.
* Specifies the types of user defined functions.
* @readonly
* @enum {string}
* @property Javascript Javascript type.
*/
UserDefinedFunctionType: Object.freeze({
Javascript: "Javascript"
}),
/**
* @global
* Represents the Connection policy assocated with a DocumentClient.
* @property {string} MediaReadMode - Attachment content (aka media) download mode. Should be one of the values of {@link MediaReadMode}
* @property {number} MediaRequestTimeout - Time to wait for response from network peer for attachment content (aka media) operations. Represented in milliseconds.
* @property {number} RequestTimeout - Request timeout (time to wait for response from network peer). Represented in milliseconds.
*/
ConnectionPolicy : Base.defineClass(function() {
Object.defineProperty(this, "_defaultMaxConnections", {
value: 20,
writable: true,
configurable: true,
enumerable: false // this is the default value, so it could be excluded during JSON.stringify
});
Object.defineProperty(this, "_defaultMaxConcurrentCallsPerConnection", {
value: 50,
writable: true,
configurable: true,
enumerable: false // this is the default value, so it could be excluded during JSON.stringify
});
Object.defineProperty(this, "_defaultRequestTimeout", {
value: 10000,
writable: true,
configurable: true,
enumerable: false // this is the default value, so it could be excluded during JSON.stringify
});
// defaultMediaRequestTimeout is based upon the blob client timeout and the retry policy.
Object.defineProperty(this, "_defaultMediaRequestTimeout", {
value: 300000,
writable: true,
configurable: true,
enumerable: false // this is the default value, so it could be excluded during JSON.stringify
});
this.ConnectionMode = AzureDocuments.ConnectionMode.Gateway;
this.ConnectionProtocol = AzureDocuments.Protocol.Https;
this.MediaReadMode = AzureDocuments.MediaReadMode.Buffered;
this.MediaRequestTimeout = this._defaultMediaRequestTimeout;
this.RequestTimeout = this._defaultRequestTimeout;
this.MaxCallsPerConnections = this._defaultMaxConcurrentCallsPerConnection; // for direct connectivity
this.MaxConnections = this._defaultMaxConnections; // for direct connectivity
})
}
);
//SCRIPT END
if (typeof exports !== "undefined") {
module.exports = AzureDocuments;
}