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