couchbase 3.2.2 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. package/binding.gyp +5 -0
  2. package/deps/lcb/CMakeLists.txt +1 -1
  3. package/deps/lcb/CONTRIBUTING.md +1 -1
  4. package/deps/lcb/README.markdown +2 -2
  5. package/deps/lcb/RELEASE_NOTES.markdown +84 -17
  6. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  7. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  8. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -6
  9. package/deps/lcb/doc/Doxyfile +1 -1
  10. package/deps/lcb/example/minimal/query.c +9 -7
  11. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  12. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  13. package/deps/lcb/include/libcouchbase/couchbase.h +55 -1
  14. package/deps/lcb/include/libcouchbase/error.h +6 -1
  15. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  16. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  17. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  18. package/deps/lcb/libcouchbase.gyp +353 -349
  19. package/deps/lcb/packaging/deb/control +1 -1
  20. package/deps/lcb/src/analytics/analytics_handle.cc +7 -5
  21. package/deps/lcb/src/analytics/analytics_handle.hh +28 -0
  22. package/deps/lcb/src/capi/cmd_counter.hh +18 -0
  23. package/deps/lcb/src/capi/cmd_exists.hh +18 -0
  24. package/deps/lcb/src/capi/cmd_get.hh +17 -0
  25. package/deps/lcb/src/capi/cmd_get_replica.hh +20 -1
  26. package/deps/lcb/src/capi/cmd_query.cc +13 -0
  27. package/deps/lcb/src/capi/cmd_query.hh +22 -14
  28. package/deps/lcb/src/capi/cmd_remove.hh +18 -0
  29. package/deps/lcb/src/capi/cmd_search.hh +6 -0
  30. package/deps/lcb/src/capi/cmd_store.hh +28 -21
  31. package/deps/lcb/src/capi/cmd_subdoc.hh +30 -0
  32. package/deps/lcb/src/capi/cmd_touch.hh +18 -0
  33. package/deps/lcb/src/capi/cmd_unlock.hh +18 -0
  34. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  35. package/deps/lcb/src/capi/collection_qualifier.hh +6 -8
  36. package/deps/lcb/src/cntl.cc +42 -8
  37. package/deps/lcb/src/dns-srv.cc +5 -3
  38. package/deps/lcb/src/errmap.cc +5 -9
  39. package/deps/lcb/src/errmap.h +7 -3
  40. package/deps/lcb/src/handler.cc +24 -18
  41. package/deps/lcb/src/internal.h +2 -1
  42. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  43. package/deps/lcb/src/mcserver/mcserver.cc +8 -5
  44. package/deps/lcb/src/mcserver/negotiate.cc +42 -17
  45. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  46. package/deps/lcb/src/n1ql/n1ql.cc +5 -1
  47. package/deps/lcb/src/n1ql/query_handle.cc +80 -44
  48. package/deps/lcb/src/n1ql/query_handle.hh +41 -3
  49. package/deps/lcb/src/operations/counter.cc +13 -1
  50. package/deps/lcb/src/operations/exists.cc +14 -2
  51. package/deps/lcb/src/operations/get.cc +14 -2
  52. package/deps/lcb/src/operations/get_replica.cc +18 -6
  53. package/deps/lcb/src/operations/observe.cc +1 -1
  54. package/deps/lcb/src/operations/remove.cc +13 -1
  55. package/deps/lcb/src/operations/store.cc +13 -1
  56. package/deps/lcb/src/operations/subdoc.cc +13 -2
  57. package/deps/lcb/src/operations/touch.cc +14 -2
  58. package/deps/lcb/src/operations/unlock.cc +14 -2
  59. package/deps/lcb/src/search/search_handle.cc +26 -8
  60. package/deps/lcb/src/search/search_handle.hh +29 -0
  61. package/deps/lcb/src/ssl/ssl_common.c +7 -8
  62. package/deps/lcb/src/tracing/span.cc +43 -10
  63. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  64. package/deps/lcb/src/utilities.cc +21 -0
  65. package/deps/lcb/src/utilities.h +3 -0
  66. package/deps/lcb/src/views/view_handle.cc +13 -5
  67. package/deps/lcb/src/views/view_handle.hh +29 -0
  68. package/deps/lcb/tests/CMakeLists.txt +21 -0
  69. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  70. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  71. package/deps/lcb/tests/iotests/mock-environment.cc +25 -1
  72. package/deps/lcb/tests/iotests/mock-environment.h +49 -1
  73. package/deps/lcb/tests/iotests/mock-unit-test.cc +96 -5
  74. package/deps/lcb/tests/iotests/mock-unit-test.h +32 -0
  75. package/deps/lcb/tests/iotests/serverparams.h +7 -2
  76. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  77. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  78. package/deps/lcb/tests/iotests/t_get.cc +14 -4
  79. package/deps/lcb/tests/iotests/t_n1ql.cc +17 -1
  80. package/deps/lcb/tests/iotests/t_ratelimit.cc +729 -0
  81. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  82. package/deps/lcb/tests/iotests/testutil.cc +342 -0
  83. package/deps/lcb/tests/iotests/testutil.h +164 -0
  84. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  85. package/deps/lcb/tests/mocksupport/server.c +0 -1
  86. package/deps/lcb/tools/cbc.cc +7 -0
  87. package/dist/analyticsexecutor.js +2 -2
  88. package/dist/analyticsindexmanager.js +512 -524
  89. package/dist/binarycollection.d.ts +17 -0
  90. package/dist/binding.d.ts +2 -0
  91. package/dist/binding.js +1 -1
  92. package/dist/bindingutilities.js +9 -1
  93. package/dist/bucketmanager.d.ts +32 -23
  94. package/dist/bucketmanager.js +197 -189
  95. package/dist/cluster.js +37 -36
  96. package/dist/collection.js +17 -23
  97. package/dist/collectionmanager.js +181 -200
  98. package/dist/connection.js +6 -3
  99. package/dist/connspec.js +5 -1
  100. package/dist/couchbase.js +7 -14
  101. package/dist/datastructures.js +239 -310
  102. package/dist/diagnosticsexecutor.js +70 -85
  103. package/dist/errors.d.ts +18 -0
  104. package/dist/errors.js +26 -2
  105. package/dist/eventingfunctionmanager.js +267 -294
  106. package/dist/httpexecutor.js +31 -38
  107. package/dist/logging.js +1 -1
  108. package/dist/queryexecutor.js +3 -3
  109. package/dist/queryindexmanager.js +236 -263
  110. package/dist/scope.js +8 -2
  111. package/dist/searchexecutor.js +3 -0
  112. package/dist/searchindexmanager.js +240 -271
  113. package/dist/searchquery.d.ts +17 -0
  114. package/dist/searchquery.js +22 -1
  115. package/dist/searchtypes.d.ts +7 -2
  116. package/dist/searchtypes.js +2 -2
  117. package/dist/usermanager.js +250 -263
  118. package/dist/utilities.d.ts +3 -2
  119. package/dist/utilities.js +16 -4
  120. package/dist/viewexecutor.js +1 -1
  121. package/dist/viewindexmanager.js +131 -150
  122. package/package.json +1 -1
  123. package/src/connection.cpp +2 -0
  124. package/src/constants.cpp +2 -0
  125. package/src/instance.cpp +8 -1
  126. package/src/instance.h +1 -0
  127. package/src/uv-plugin-all.cpp +1 -0
  128. package/dist/cas.d.ts +0 -0
  129. package/dist/cas.js +0 -1
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.CouchbaseSet = exports.CouchbaseQueue = exports.CouchbaseMap = exports.CouchbaseList = void 0;
13
4
  const errors_1 = require("./errors");
@@ -29,26 +20,22 @@ class CouchbaseList {
29
20
  this._coll = collection;
30
21
  this._key = key;
31
22
  }
32
- _get() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const doc = yield this._coll.get(this._key);
35
- if (!(doc.content instanceof Array)) {
36
- throw new errors_1.CouchbaseError('expected document of array type');
37
- }
38
- return doc.content;
39
- });
23
+ async _get() {
24
+ const doc = await this._coll.get(this._key);
25
+ if (!(doc.content instanceof Array)) {
26
+ throw new errors_1.CouchbaseError('expected document of array type');
27
+ }
28
+ return doc.content;
40
29
  }
41
30
  /**
42
31
  * Returns the entire list of items in this list.
43
32
  *
44
33
  * @param callback A node-style callback to be invoked after execution.
45
34
  */
46
- getAll(callback) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
49
- return yield this._get();
50
- }), callback);
51
- });
35
+ async getAll(callback) {
36
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
37
+ return await this._get();
38
+ }, callback);
52
39
  }
53
40
  /**
54
41
  * Iterates each item in the list.
@@ -56,36 +43,32 @@ class CouchbaseList {
56
43
  * @param rowCallback A callback invoked for each item in the list.
57
44
  * @param callback A node-style callback to be invoked after execution.
58
45
  */
59
- forEach(rowCallback, callback) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
62
- const values = yield this._get();
63
- for (let i = 0; i < values.length; ++i) {
64
- rowCallback(values[i], i, this);
65
- }
66
- }), callback);
67
- });
46
+ async forEach(rowCallback, callback) {
47
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
48
+ const values = await this._get();
49
+ for (let i = 0; i < values.length; ++i) {
50
+ rowCallback(values[i], i, this);
51
+ }
52
+ }, callback);
68
53
  }
69
54
  /**
70
55
  * Provides the ability to async-for loop this object.
71
56
  */
72
57
  [Symbol.asyncIterator]() {
73
- const getNext = () => __awaiter(this, void 0, void 0, function* () { return this._get(); });
58
+ const getNext = async () => this._get();
74
59
  return {
75
60
  data: null,
76
61
  index: -1,
77
- next() {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- if (this.index < 0) {
80
- this.data = yield getNext();
81
- this.index = 0;
82
- }
83
- const data = this.data;
84
- if (this.index < data.length) {
85
- return { done: false, value: data[this.index++] };
86
- }
87
- return { done: true };
88
- });
62
+ async next() {
63
+ if (this.index < 0) {
64
+ this.data = await getNext();
65
+ this.index = 0;
66
+ }
67
+ const data = this.data;
68
+ if (this.index < data.length) {
69
+ return { done: false, value: data[this.index++] };
70
+ }
71
+ return { done: true };
89
72
  },
90
73
  };
91
74
  }
@@ -95,19 +78,17 @@ class CouchbaseList {
95
78
  * @param index The index to retrieve.
96
79
  * @param callback A node-style callback to be invoked after execution.
97
80
  */
98
- getAt(index, callback) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
101
- const res = yield this._coll.lookupIn(this._key, [
102
- sdspecs_1.LookupInSpec.get('[' + index + ']'),
103
- ]);
104
- const itemRes = res.content[0];
105
- if (itemRes.error) {
106
- throw itemRes.error;
107
- }
108
- return itemRes.value;
109
- }), callback);
110
- });
81
+ async getAt(index, callback) {
82
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
83
+ const res = await this._coll.lookupIn(this._key, [
84
+ sdspecs_1.LookupInSpec.get('[' + index + ']'),
85
+ ]);
86
+ const itemRes = res.content[0];
87
+ if (itemRes.error) {
88
+ throw itemRes.error;
89
+ }
90
+ return itemRes.value;
91
+ }, callback);
111
92
  }
112
93
  /**
113
94
  * Removes an item at a specific index from the list.
@@ -115,14 +96,12 @@ class CouchbaseList {
115
96
  * @param index The index to remove.
116
97
  * @param callback A node-style callback to be invoked after execution.
117
98
  */
118
- removeAt(index, callback) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
121
- yield this._coll.mutateIn(this._key, [
122
- sdspecs_1.MutateInSpec.remove('[' + index + ']'),
123
- ]);
124
- }), callback);
125
- });
99
+ async removeAt(index, callback) {
100
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
101
+ await this._coll.mutateIn(this._key, [
102
+ sdspecs_1.MutateInSpec.remove('[' + index + ']'),
103
+ ]);
104
+ }, callback);
126
105
  }
127
106
  /**
128
107
  * Returns the index of a specific value from the list.
@@ -130,31 +109,27 @@ class CouchbaseList {
130
109
  * @param value The value to search for.
131
110
  * @param callback A node-style callback to be invoked after execution.
132
111
  */
133
- indexOf(value, callback) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
136
- const items = yield this._get();
137
- for (let i = 0; i < items.length; ++i) {
138
- if (items[i] === value) {
139
- return i;
140
- }
112
+ async indexOf(value, callback) {
113
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
114
+ const items = await this._get();
115
+ for (let i = 0; i < items.length; ++i) {
116
+ if (items[i] === value) {
117
+ return i;
141
118
  }
142
- return -1;
143
- }), callback);
144
- });
119
+ }
120
+ return -1;
121
+ }, callback);
145
122
  }
146
123
  /**
147
124
  * Returns the number of items in the list.
148
125
  *
149
126
  * @param callback A node-style callback to be invoked after execution.
150
127
  */
151
- size(callback) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
154
- const res = yield this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
155
- return res.content[0].value;
156
- }), callback);
157
- });
128
+ async size(callback) {
129
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
130
+ const res = await this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
131
+ return res.content[0].value;
132
+ }, callback);
158
133
  }
159
134
  /**
160
135
  * Adds a new item to the end of the list.
@@ -162,14 +137,12 @@ class CouchbaseList {
162
137
  * @param value The value to add.
163
138
  * @param callback A node-style callback to be invoked after execution.
164
139
  */
165
- push(value, callback) {
166
- return __awaiter(this, void 0, void 0, function* () {
167
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
168
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayAppend('', value)], {
169
- storeSemantics: generaltypes_1.StoreSemantics.Upsert,
170
- });
171
- }), callback);
172
- });
140
+ async push(value, callback) {
141
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
142
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayAppend('', value)], {
143
+ storeSemantics: generaltypes_1.StoreSemantics.Upsert,
144
+ });
145
+ }, callback);
173
146
  }
174
147
  /**
175
148
  * Adds a new item to the beginning of the list.
@@ -177,14 +150,12 @@ class CouchbaseList {
177
150
  * @param value The value to add.
178
151
  * @param callback A node-style callback to be invoked after execution.
179
152
  */
180
- unshift(value, callback) {
181
- return __awaiter(this, void 0, void 0, function* () {
182
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
183
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayPrepend('', value)], {
184
- storeSemantics: generaltypes_1.StoreSemantics.Upsert,
185
- });
186
- }), callback);
187
- });
153
+ async unshift(value, callback) {
154
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
155
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayPrepend('', value)], {
156
+ storeSemantics: generaltypes_1.StoreSemantics.Upsert,
157
+ });
158
+ }, callback);
188
159
  }
189
160
  }
190
161
  exports.CouchbaseList = CouchbaseList;
@@ -203,26 +174,22 @@ class CouchbaseMap {
203
174
  this._coll = collection;
204
175
  this._key = key;
205
176
  }
206
- _get() {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- const doc = yield this._coll.get(this._key);
209
- if (!(doc.content instanceof Object)) {
210
- throw new errors_1.CouchbaseError('expected document of object type');
211
- }
212
- return doc.content;
213
- });
177
+ async _get() {
178
+ const doc = await this._coll.get(this._key);
179
+ if (!(doc.content instanceof Object)) {
180
+ throw new errors_1.CouchbaseError('expected document of object type');
181
+ }
182
+ return doc.content;
214
183
  }
215
184
  /**
216
185
  * Returns an object representing all items in the map.
217
186
  *
218
187
  * @param callback A node-style callback to be invoked after execution.
219
188
  */
220
- getAll(callback) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
223
- return yield this._get();
224
- }), callback);
225
- });
189
+ async getAll(callback) {
190
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
191
+ return await this._get();
192
+ }, callback);
226
193
  }
227
194
  /**
228
195
  * Iterates through every item in the map.
@@ -230,40 +197,36 @@ class CouchbaseMap {
230
197
  * @param rowCallback A callback invoked for each item in the list.
231
198
  * @param callback A node-style callback to be invoked after execution.
232
199
  */
233
- forEach(rowCallback, callback) {
234
- return __awaiter(this, void 0, void 0, function* () {
235
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
236
- const values = yield this._get();
237
- for (const i in values) {
238
- rowCallback(values[i], i, this);
239
- }
240
- }), callback);
241
- });
200
+ async forEach(rowCallback, callback) {
201
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
202
+ const values = await this._get();
203
+ for (const i in values) {
204
+ rowCallback(values[i], i, this);
205
+ }
206
+ }, callback);
242
207
  }
243
208
  /**
244
209
  * Provides the ability to async-for loop this object.
245
210
  */
246
211
  [Symbol.asyncIterator]() {
247
- const getNext = () => __awaiter(this, void 0, void 0, function* () { return this._get(); });
212
+ const getNext = async () => this._get();
248
213
  return {
249
214
  data: null,
250
215
  keys: null,
251
216
  index: -1,
252
- next() {
253
- return __awaiter(this, void 0, void 0, function* () {
254
- if (this.index < 0) {
255
- this.data = yield getNext();
256
- this.keys = Object.keys(this.data);
257
- this.index = 0;
258
- }
259
- const keys = this.keys;
260
- const data = this.data;
261
- if (this.index < keys.length) {
262
- const key = keys[this.index++];
263
- return { done: false, value: [data[key], key] };
264
- }
265
- return { done: true, value: undefined };
266
- });
217
+ async next() {
218
+ if (this.index < 0) {
219
+ this.data = await getNext();
220
+ this.keys = Object.keys(this.data);
221
+ this.index = 0;
222
+ }
223
+ const keys = this.keys;
224
+ const data = this.data;
225
+ if (this.index < keys.length) {
226
+ const key = keys[this.index++];
227
+ return { done: false, value: [data[key], key] };
228
+ }
229
+ return { done: true, value: undefined };
267
230
  },
268
231
  };
269
232
  }
@@ -274,14 +237,12 @@ class CouchbaseMap {
274
237
  * @param value The new value to set.
275
238
  * @param callback A node-style callback to be invoked after execution.
276
239
  */
277
- set(item, value, callback) {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
280
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.upsert(item, value)], {
281
- storeSemantics: generaltypes_1.StoreSemantics.Upsert,
282
- });
283
- }), callback);
284
- });
240
+ async set(item, value, callback) {
241
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
242
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.upsert(item, value)], {
243
+ storeSemantics: generaltypes_1.StoreSemantics.Upsert,
244
+ });
245
+ }, callback);
285
246
  }
286
247
  /**
287
248
  * Fetches a specific key from the map.
@@ -289,17 +250,15 @@ class CouchbaseMap {
289
250
  * @param item The key in the map to retrieve.
290
251
  * @param callback A node-style callback to be invoked after execution.
291
252
  */
292
- get(item, callback) {
293
- return __awaiter(this, void 0, void 0, function* () {
294
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
295
- const res = yield this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.get(item)]);
296
- const itemRes = res.content[0];
297
- if (itemRes.error) {
298
- throw itemRes.error;
299
- }
300
- return itemRes.value;
301
- }), callback);
302
- });
253
+ async get(item, callback) {
254
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
255
+ const res = await this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.get(item)]);
256
+ const itemRes = res.content[0];
257
+ if (itemRes.error) {
258
+ throw itemRes.error;
259
+ }
260
+ return itemRes.value;
261
+ }, callback);
303
262
  }
304
263
  /**
305
264
  * Removes a specific key from the map.
@@ -307,12 +266,10 @@ class CouchbaseMap {
307
266
  * @param item The key in the map to remove.
308
267
  * @param callback A node-style callback to be invoked after execution.
309
268
  */
310
- remove(item, callback) {
311
- return __awaiter(this, void 0, void 0, function* () {
312
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
313
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.remove(item)]);
314
- }), callback);
315
- });
269
+ async remove(item, callback) {
270
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
271
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.remove(item)]);
272
+ }, callback);
316
273
  }
317
274
  /**
318
275
  * Checks whether a specific key exists in the map.
@@ -320,55 +277,47 @@ class CouchbaseMap {
320
277
  * @param item The key in the map to search for.
321
278
  * @param callback A node-style callback to be invoked after execution.
322
279
  */
323
- exists(item, callback) {
324
- return __awaiter(this, void 0, void 0, function* () {
325
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
326
- const res = yield this._coll.lookupIn(this._key, [
327
- sdspecs_1.LookupInSpec.exists(item),
328
- ]);
329
- const itemRes = res.content[0];
330
- return itemRes.value;
331
- }), callback);
332
- });
280
+ async exists(item, callback) {
281
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
282
+ const res = await this._coll.lookupIn(this._key, [
283
+ sdspecs_1.LookupInSpec.exists(item),
284
+ ]);
285
+ const itemRes = res.content[0];
286
+ return itemRes.value;
287
+ }, callback);
333
288
  }
334
289
  /**
335
290
  * Returns a list of all the keys which exist in the map.
336
291
  *
337
292
  * @param callback A node-style callback to be invoked after execution.
338
293
  */
339
- keys(callback) {
340
- return __awaiter(this, void 0, void 0, function* () {
341
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
342
- const values = yield this._get();
343
- return Object.keys(values);
344
- }), callback);
345
- });
294
+ async keys(callback) {
295
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
296
+ const values = await this._get();
297
+ return Object.keys(values);
298
+ }, callback);
346
299
  }
347
300
  /**
348
301
  * Returns a list of all the values which exist in the map.
349
302
  *
350
303
  * @param callback A node-style callback to be invoked after execution.
351
304
  */
352
- values(callback) {
353
- return __awaiter(this, void 0, void 0, function* () {
354
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
355
- const values = yield this._get();
356
- return Object.values(values);
357
- }), callback);
358
- });
305
+ async values(callback) {
306
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
307
+ const values = await this._get();
308
+ return Object.values(values);
309
+ }, callback);
359
310
  }
360
311
  /**
361
312
  * Returns the number of items that exist in the map.
362
313
  *
363
314
  * @param callback A node-style callback to be invoked after execution.
364
315
  */
365
- size(callback) {
366
- return __awaiter(this, void 0, void 0, function* () {
367
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
368
- const res = yield this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
369
- return res.content[0].value;
370
- }), callback);
371
- });
316
+ async size(callback) {
317
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
318
+ const res = await this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
319
+ return res.content[0].value;
320
+ }, callback);
372
321
  }
373
322
  }
374
323
  exports.CouchbaseMap = CouchbaseMap;
@@ -387,27 +336,23 @@ class CouchbaseQueue {
387
336
  this._coll = collection;
388
337
  this._key = key;
389
338
  }
390
- _get() {
391
- return __awaiter(this, void 0, void 0, function* () {
392
- const doc = yield this._coll.get(this._key);
393
- if (!(doc.content instanceof Array)) {
394
- throw new errors_1.CouchbaseError('expected document of array type');
395
- }
396
- return doc.content;
397
- });
339
+ async _get() {
340
+ const doc = await this._coll.get(this._key);
341
+ if (!(doc.content instanceof Array)) {
342
+ throw new errors_1.CouchbaseError('expected document of array type');
343
+ }
344
+ return doc.content;
398
345
  }
399
346
  /**
400
347
  * Returns the number of items in the queue.
401
348
  *
402
349
  * @param callback A node-style callback to be invoked after execution.
403
350
  */
404
- size(callback) {
405
- return __awaiter(this, void 0, void 0, function* () {
406
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
407
- const res = yield this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
408
- return res.content[0].value;
409
- }), callback);
410
- });
351
+ async size(callback) {
352
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
353
+ const res = await this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
354
+ return res.content[0].value;
355
+ }, callback);
411
356
  }
412
357
  /**
413
358
  * Adds a new item to the back of the queue.
@@ -415,44 +360,40 @@ class CouchbaseQueue {
415
360
  * @param value The value to add.
416
361
  * @param callback A node-style callback to be invoked after execution.
417
362
  */
418
- push(value, callback) {
419
- return __awaiter(this, void 0, void 0, function* () {
420
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
421
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayPrepend('', value)], {
422
- storeSemantics: generaltypes_1.StoreSemantics.Upsert,
423
- });
424
- }), callback);
425
- });
363
+ async push(value, callback) {
364
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
365
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayPrepend('', value)], {
366
+ storeSemantics: generaltypes_1.StoreSemantics.Upsert,
367
+ });
368
+ }, callback);
426
369
  }
427
370
  /**
428
371
  * Removes an item from the front of the queue.
429
372
  *
430
373
  * @param callback A node-style callback to be invoked after execution.
431
374
  */
432
- pop(callback) {
433
- return __awaiter(this, void 0, void 0, function* () {
434
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
435
- for (let i = 0; i < 16; ++i) {
436
- try {
437
- const res = yield this._coll.lookupIn(this._key, [
438
- sdspecs_1.LookupInSpec.get('[-1]'),
439
- ]);
440
- const value = res.content[0].value;
441
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.remove('[-1]')], {
442
- cas: res.cas,
443
- });
444
- return value;
445
- }
446
- catch (e) {
447
- if (e instanceof errors_1.PathInvalidError) {
448
- throw new errors_1.CouchbaseError('no items available in list');
449
- }
450
- // continue and retry
375
+ async pop(callback) {
376
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
377
+ for (let i = 0; i < 16; ++i) {
378
+ try {
379
+ const res = await this._coll.lookupIn(this._key, [
380
+ sdspecs_1.LookupInSpec.get('[-1]'),
381
+ ]);
382
+ const value = res.content[0].value;
383
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.remove('[-1]')], {
384
+ cas: res.cas,
385
+ });
386
+ return value;
387
+ }
388
+ catch (e) {
389
+ if (e instanceof errors_1.PathInvalidError) {
390
+ throw new errors_1.CouchbaseError('no items available in list');
451
391
  }
392
+ // continue and retry
452
393
  }
453
- throw new errors_1.CouchbaseError('no items available to pop');
454
- }), callback);
455
- });
394
+ }
395
+ throw new errors_1.CouchbaseError('no items available to pop');
396
+ }, callback);
456
397
  }
457
398
  }
458
399
  exports.CouchbaseQueue = CouchbaseQueue;
@@ -471,14 +412,12 @@ class CouchbaseSet {
471
412
  this._coll = collection;
472
413
  this._key = key;
473
414
  }
474
- _get() {
475
- return __awaiter(this, void 0, void 0, function* () {
476
- const doc = yield this._coll.get(this._key);
477
- if (!(doc.content instanceof Array)) {
478
- throw new errors_1.CouchbaseError('expected document of array type');
479
- }
480
- return doc.content;
481
- });
415
+ async _get() {
416
+ const doc = await this._coll.get(this._key);
417
+ if (!(doc.content instanceof Array)) {
418
+ throw new errors_1.CouchbaseError('expected document of array type');
419
+ }
420
+ return doc.content;
482
421
  }
483
422
  /**
484
423
  * Adds a new item to the set. Returning whether the item already existed
@@ -487,23 +426,21 @@ class CouchbaseSet {
487
426
  * @param item The item to add.
488
427
  * @param callback A node-style callback to be invoked after execution.
489
428
  */
490
- add(item, callback) {
491
- return __awaiter(this, void 0, void 0, function* () {
492
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
493
- try {
494
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayAddUnique('', item)], {
495
- storeSemantics: generaltypes_1.StoreSemantics.Upsert,
496
- });
497
- }
498
- catch (e) {
499
- if (e instanceof errors_1.PathExistsError) {
500
- return false;
501
- }
502
- throw e;
429
+ async add(item, callback) {
430
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
431
+ try {
432
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.arrayAddUnique('', item)], {
433
+ storeSemantics: generaltypes_1.StoreSemantics.Upsert,
434
+ });
435
+ }
436
+ catch (e) {
437
+ if (e instanceof errors_1.PathExistsError) {
438
+ return false;
503
439
  }
504
- return true;
505
- }), callback);
506
- });
440
+ throw e;
441
+ }
442
+ return true;
443
+ }, callback);
507
444
  }
508
445
  /**
509
446
  * Returns whether a specific value already exists in the set.
@@ -511,18 +448,16 @@ class CouchbaseSet {
511
448
  * @param item The value to search for.
512
449
  * @param callback A node-style callback to be invoked after execution.
513
450
  */
514
- contains(item, callback) {
515
- return __awaiter(this, void 0, void 0, function* () {
516
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
517
- const values = yield this._get();
518
- for (let i = 0; i < values.length; ++i) {
519
- if (values[i] === item) {
520
- return true;
521
- }
451
+ async contains(item, callback) {
452
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
453
+ const values = await this._get();
454
+ for (let i = 0; i < values.length; ++i) {
455
+ if (values[i] === item) {
456
+ return true;
522
457
  }
523
- return false;
524
- }), callback);
525
- });
458
+ }
459
+ return false;
460
+ }, callback);
526
461
  }
527
462
  /**
528
463
  * Removes a specific value from the set.
@@ -530,56 +465,50 @@ class CouchbaseSet {
530
465
  * @param item The value to remove.
531
466
  * @param callback A node-style callback to be invoked after execution.
532
467
  */
533
- remove(item, callback) {
534
- return __awaiter(this, void 0, void 0, function* () {
535
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
536
- for (let i = 0; i < 16; ++i) {
537
- try {
538
- const res = yield this._coll.get(this._key);
539
- if (!(res.content instanceof Array)) {
540
- throw new errors_1.CouchbaseError('expected document of array type');
541
- }
542
- const itemIdx = res.content.indexOf(item);
543
- if (itemIdx === -1) {
544
- throw new Error('item was not found in set');
545
- }
546
- yield this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.remove('[' + itemIdx + ']')], {
547
- cas: res.cas,
548
- });
549
- return;
468
+ async remove(item, callback) {
469
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
470
+ for (let i = 0; i < 16; ++i) {
471
+ try {
472
+ const res = await this._coll.get(this._key);
473
+ if (!(res.content instanceof Array)) {
474
+ throw new errors_1.CouchbaseError('expected document of array type');
550
475
  }
551
- catch (e) {
552
- // continue and retry
476
+ const itemIdx = res.content.indexOf(item);
477
+ if (itemIdx === -1) {
478
+ throw new Error('item was not found in set');
553
479
  }
480
+ await this._coll.mutateIn(this._key, [sdspecs_1.MutateInSpec.remove('[' + itemIdx + ']')], {
481
+ cas: res.cas,
482
+ });
483
+ return;
554
484
  }
555
- throw new errors_1.CouchbaseError('no items available to pop');
556
- }), callback);
557
- });
485
+ catch (e) {
486
+ // continue and retry
487
+ }
488
+ }
489
+ throw new errors_1.CouchbaseError('no items available to pop');
490
+ }, callback);
558
491
  }
559
492
  /**
560
493
  * Returns a list of all values in the set.
561
494
  *
562
495
  * @param callback A node-style callback to be invoked after execution.
563
496
  */
564
- values(callback) {
565
- return __awaiter(this, void 0, void 0, function* () {
566
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
567
- return yield this._get();
568
- }), callback);
569
- });
497
+ async values(callback) {
498
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
499
+ return await this._get();
500
+ }, callback);
570
501
  }
571
502
  /**
572
503
  * Returns the number of elements in this set.
573
504
  *
574
505
  * @param callback A node-style callback to be invoked after execution.
575
506
  */
576
- size(callback) {
577
- return __awaiter(this, void 0, void 0, function* () {
578
- return utilities_1.PromiseHelper.wrapAsync(() => __awaiter(this, void 0, void 0, function* () {
579
- const res = yield this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
580
- return res.content[0].value;
581
- }), callback);
582
- });
507
+ async size(callback) {
508
+ return utilities_1.PromiseHelper.wrapAsync(async () => {
509
+ const res = await this._coll.lookupIn(this._key, [sdspecs_1.LookupInSpec.count('')]);
510
+ return res.content[0].value;
511
+ }, callback);
583
512
  }
584
513
  }
585
514
  exports.CouchbaseSet = CouchbaseSet;