1 | import { CppTransactions, CppTransaction, CppTransactionLinks, CppTransactionGetMetaData } from './binding';
|
2 | import { Cluster } from './cluster';
|
3 | import { Collection } from './collection';
|
4 | import { DurabilityLevel } from './generaltypes';
|
5 | import { QueryMetaData, QueryProfileMode, QueryResult, QueryScanConsistency } from './querytypes';
|
6 | import { Scope } from './scope';
|
7 | import { Transcoder } from './transcoders';
|
8 | import { Cas } from './utilities';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare class DocumentId {
|
15 | constructor();
|
16 | /**
|
17 | * The name of the bucket containing the document.
|
18 | */
|
19 | bucket: string;
|
20 | /**
|
21 | * The name of the scope containing the document.
|
22 | */
|
23 | scope: string;
|
24 | /**
|
25 | * The name of the collection containing the document.
|
26 | */
|
27 | collection: string;
|
28 | /**
|
29 | * The key of the docuemnt.
|
30 | */
|
31 | key: string;
|
32 | }
|
33 | /**
|
34 | * Specifies the configuration options for a Transaction Keyspace.
|
35 | *
|
36 | * @category Transactions
|
37 | */
|
38 | export interface TransactionKeyspace {
|
39 | |
40 |
|
41 |
|
42 | bucket: string;
|
43 | |
44 |
|
45 |
|
46 | scope?: string;
|
47 | |
48 |
|
49 |
|
50 | collection?: string;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | export interface TransactionsCleanupConfig {
|
58 | |
59 |
|
60 |
|
61 | cleanupWindow?: number;
|
62 | |
63 |
|
64 |
|
65 | disableLostAttemptCleanup?: boolean;
|
66 | |
67 |
|
68 |
|
69 | disableClientAttemptCleanup?: boolean;
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | export interface TransactionsQueryConfig {
|
77 | |
78 |
|
79 |
|
80 | scanConsistency?: QueryScanConsistency;
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | export interface TransactionsConfig {
|
88 | |
89 |
|
90 |
|
91 | durabilityLevel?: DurabilityLevel;
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 | kvTimeout?: number;
|
98 | |
99 |
|
100 |
|
101 | timeout?: number;
|
102 | |
103 |
|
104 |
|
105 | queryConfig?: TransactionsQueryConfig;
|
106 | |
107 |
|
108 |
|
109 | cleanupConfig?: TransactionsCleanupConfig;
|
110 | |
111 |
|
112 |
|
113 | metadataCollection?: TransactionKeyspace;
|
114 | }
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | export interface TransactionOptions {
|
121 | |
122 |
|
123 |
|
124 | durabilityLevel?: DurabilityLevel;
|
125 | |
126 |
|
127 |
|
128 | timeout?: number;
|
129 | }
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | export declare class TransactionResult {
|
136 | |
137 |
|
138 |
|
139 | constructor(data: {
|
140 | transactionId: string;
|
141 | unstagingComplete: boolean;
|
142 | });
|
143 | /**
|
144 | * The ID of the completed transaction.
|
145 | */
|
146 | transactionId: string;
|
147 | /**
|
148 | * Whether all documents were successfully unstaged and are now available
|
149 | * for non-transactional operations to see.
|
150 | */
|
151 | unstagingComplete: boolean;
|
152 | }
|
153 | /**
|
154 | * Contains the results of a transactional Get operation.
|
155 | *
|
156 | * @category Transactions
|
157 | */
|
158 | export declare class TransactionGetResult {
|
159 | |
160 |
|
161 |
|
162 | constructor(data: TransactionGetResult);
|
163 | /**
|
164 | * The id of the document.
|
165 | */
|
166 | id: DocumentId;
|
167 | /**
|
168 | * The content of the document.
|
169 | */
|
170 | content: any;
|
171 | /**
|
172 | * The CAS of the document.
|
173 | */
|
174 | cas: Cas;
|
175 | /**
|
176 | * @internal
|
177 | */
|
178 | _links: CppTransactionLinks;
|
179 | /**
|
180 | * @internal
|
181 | */
|
182 | _metadata: CppTransactionGetMetaData;
|
183 | }
|
184 | /**
|
185 | * Contains the results of a transactional Query operation.
|
186 | *
|
187 | * @category Transactions
|
188 | */
|
189 | export declare class TransactionQueryResult<TRow = any> {
|
190 | |
191 |
|
192 |
|
193 | rows: TRow[];
|
194 | |
195 |
|
196 |
|
197 | meta: QueryMetaData;
|
198 | |
199 |
|
200 |
|
201 | constructor(data: QueryResult);
|
202 | }
|
203 | /**
|
204 | * @category Transactions
|
205 | */
|
206 | export interface TransactionQueryOptions {
|
207 | |
208 |
|
209 |
|
210 | parameters?: {
|
211 | [key: string]: any;
|
212 | } | any[];
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 | scanConsistency?: QueryScanConsistency;
|
219 | |
220 |
|
221 |
|
222 |
|
223 | adhoc?: boolean;
|
224 | |
225 |
|
226 |
|
227 | clientContextId?: string;
|
228 | |
229 |
|
230 |
|
231 |
|
232 | maxParallelism?: number;
|
233 | |
234 |
|
235 |
|
236 |
|
237 | pipelineBatch?: number;
|
238 | |
239 |
|
240 |
|
241 |
|
242 | pipelineCap?: number;
|
243 | |
244 |
|
245 |
|
246 |
|
247 |
|
248 | scanWait?: number;
|
249 | |
250 |
|
251 |
|
252 |
|
253 | scanCap?: number;
|
254 | |
255 |
|
256 |
|
257 |
|
258 | readOnly?: boolean;
|
259 | |
260 |
|
261 |
|
262 | profile?: QueryProfileMode;
|
263 | |
264 |
|
265 |
|
266 |
|
267 | metrics?: boolean;
|
268 | |
269 |
|
270 |
|
271 |
|
272 | raw?: {
|
273 | [key: string]: any;
|
274 | };
|
275 | |
276 |
|
277 |
|
278 | scope?: Scope;
|
279 | }
|
280 |
|
281 |
|
282 |
|
283 | export interface TransactionGetOptions {
|
284 | |
285 |
|
286 |
|
287 | transcoder?: Transcoder;
|
288 | }
|
289 |
|
290 |
|
291 |
|
292 | export interface TransactionInsertOptions {
|
293 | |
294 |
|
295 |
|
296 | transcoder?: Transcoder;
|
297 | }
|
298 |
|
299 |
|
300 |
|
301 | export interface TransactionReplaceOptions {
|
302 | |
303 |
|
304 |
|
305 | transcoder?: Transcoder;
|
306 | }
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | export declare class TransactionAttemptContext {
|
313 | private _impl;
|
314 | private _transcoder;
|
315 | |
316 |
|
317 |
|
318 | constructor(txns: Transactions, config?: TransactionOptions);
|
319 | /**
|
320 | @internal
|
321 | */
|
322 | get impl(): CppTransaction;
|
323 | /**
|
324 | * @internal
|
325 | */
|
326 | _newAttempt(): Promise<void>;
|
327 | /**
|
328 | * Retrieves the value of a document from the collection.
|
329 | *
|
330 | * @param collection The collection the document lives in.
|
331 | * @param key The document key to retrieve.
|
332 | * @param options Optional parameters for this operation.
|
333 | */
|
334 | get(collection: Collection, key: string, options?: TransactionGetOptions): Promise<TransactionGetResult>;
|
335 | /**
|
336 | * Inserts a new document to the collection, failing if the document already exists.
|
337 | *
|
338 | * @param collection The collection the document lives in.
|
339 | * @param key The document key to insert.
|
340 | * @param content The document content to insert.
|
341 | * @param options Optional parameters for this operation.
|
342 | */
|
343 | insert(collection: Collection, key: string, content: any, options?: TransactionInsertOptions): Promise<TransactionGetResult>;
|
344 | /**
|
345 | * Replaces a document in a collection.
|
346 | *
|
347 | * @param doc The document to replace.
|
348 | * @param content The document content to insert.
|
349 | * @param options Optional parameters for this operation.
|
350 | */
|
351 | replace(doc: TransactionGetResult, content: any, options?: TransactionReplaceOptions): Promise<TransactionGetResult>;
|
352 | /**
|
353 | * Removes a document from a collection.
|
354 | *
|
355 | * @param doc The document to remove.
|
356 | */
|
357 | remove(doc: TransactionGetResult): Promise<void>;
|
358 | /**
|
359 | * Executes a query in the context of this transaction.
|
360 | *
|
361 | * @param statement The statement to execute.
|
362 | * @param options Optional parameters for this operation.
|
363 | */
|
364 | query<TRow = any>(statement: string, options?: TransactionQueryOptions): Promise<TransactionQueryResult<TRow>>;
|
365 | /**
|
366 | * @internal
|
367 | */
|
368 | _commit(): Promise<TransactionResult>;
|
369 | /**
|
370 | * @internal
|
371 | */
|
372 | _rollback(): Promise<void>;
|
373 | }
|
374 | /**
|
375 | * Provides an interface to access transactions.
|
376 | *
|
377 | * @category Transactions
|
378 | */
|
379 | export declare class Transactions {
|
380 | private _cluster;
|
381 | private _impl;
|
382 | |
383 |
|
384 |
|
385 | constructor(cluster: Cluster, config?: TransactionsConfig);
|
386 | /**
|
387 | @internal
|
388 | */
|
389 | get impl(): CppTransactions;
|
390 | /**
|
391 | @internal
|
392 | */
|
393 | _close(): Promise<void>;
|
394 | /**
|
395 | * Executes a transaction.
|
396 | *
|
397 | * @param logicFn The transaction lambda to execute.
|
398 | * @param config Configuration operations for the transaction.
|
399 | */
|
400 | run(logicFn: (attempt: TransactionAttemptContext) => Promise<void>, config?: TransactionOptions): Promise<TransactionResult>;
|
401 | }
|