couchbase 3.2.0 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +24 -18
  2. package/binding.gyp +88 -85
  3. package/deps/lcb/CMakeLists.txt +1 -1
  4. package/deps/lcb/CONTRIBUTING.md +1 -1
  5. package/deps/lcb/README.markdown +2 -2
  6. package/deps/lcb/RELEASE_NOTES.markdown +99 -14
  7. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  8. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  9. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
  10. package/deps/lcb/doc/Doxyfile +1 -1
  11. package/deps/lcb/example/CMakeLists.txt +4 -4
  12. package/deps/lcb/example/libuvdirect/main.c +39 -12
  13. package/deps/lcb/example/minimal/durability.cc +149 -0
  14. package/deps/lcb/example/minimal/query.c +11 -9
  15. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  16. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  17. package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
  18. package/deps/lcb/include/libcouchbase/error.h +2 -0
  19. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  20. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  21. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  22. package/deps/lcb/libcouchbase.gyp +347 -349
  23. package/deps/lcb/packaging/deb/control +1 -1
  24. package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
  25. package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
  26. package/deps/lcb/src/bootstrap.cc +6 -3
  27. package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
  28. package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
  29. package/deps/lcb/src/capi/cmd_counter.hh +23 -0
  30. package/deps/lcb/src/capi/cmd_exists.hh +24 -1
  31. package/deps/lcb/src/capi/cmd_get.hh +22 -0
  32. package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
  33. package/deps/lcb/src/capi/cmd_http.hh +7 -0
  34. package/deps/lcb/src/capi/cmd_query.cc +11 -1
  35. package/deps/lcb/src/capi/cmd_query.hh +31 -0
  36. package/deps/lcb/src/capi/cmd_remove.hh +23 -0
  37. package/deps/lcb/src/capi/cmd_search.cc +6 -0
  38. package/deps/lcb/src/capi/cmd_search.hh +23 -0
  39. package/deps/lcb/src/capi/cmd_store.hh +33 -21
  40. package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
  41. package/deps/lcb/src/capi/cmd_touch.hh +23 -0
  42. package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
  43. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  44. package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
  45. package/deps/lcb/src/cntl.cc +45 -11
  46. package/deps/lcb/src/crypto.cc +2 -2
  47. package/deps/lcb/src/dns-srv.cc +5 -3
  48. package/deps/lcb/src/errmap.cc +5 -9
  49. package/deps/lcb/src/errmap.h +7 -3
  50. package/deps/lcb/src/handler.cc +24 -18
  51. package/deps/lcb/src/hostlist.h +2 -2
  52. package/deps/lcb/src/http/http-priv.h +2 -2
  53. package/deps/lcb/src/http/http.cc +5 -2
  54. package/deps/lcb/src/instance.cc +20 -11
  55. package/deps/lcb/src/internal.h +9 -0
  56. package/deps/lcb/src/lcbio/connect.cc +14 -2
  57. package/deps/lcb/src/lcbio/connect.h +2 -2
  58. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  59. package/deps/lcb/src/lcbio/ioutils.cc +9 -10
  60. package/deps/lcb/src/lcbio/manager.cc +1 -1
  61. package/deps/lcb/src/mcserver/mcserver.cc +9 -6
  62. package/deps/lcb/src/mcserver/negotiate.cc +39 -17
  63. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  64. package/deps/lcb/src/n1ql/query_handle.cc +41 -19
  65. package/deps/lcb/src/n1ql/query_handle.hh +28 -1
  66. package/deps/lcb/src/operations/counter.cc +18 -5
  67. package/deps/lcb/src/operations/exists.cc +25 -4
  68. package/deps/lcb/src/operations/get.cc +39 -19
  69. package/deps/lcb/src/operations/get_replica.cc +28 -8
  70. package/deps/lcb/src/operations/observe.cc +1 -1
  71. package/deps/lcb/src/operations/ping.cc +8 -8
  72. package/deps/lcb/src/operations/pktfwd.cc +2 -1
  73. package/deps/lcb/src/operations/remove.cc +39 -22
  74. package/deps/lcb/src/operations/store.cc +18 -5
  75. package/deps/lcb/src/operations/subdoc.cc +18 -6
  76. package/deps/lcb/src/operations/touch.cc +34 -16
  77. package/deps/lcb/src/operations/unlock.cc +24 -5
  78. package/deps/lcb/src/packetutils.h +3 -2
  79. package/deps/lcb/src/retryq.cc +24 -5
  80. package/deps/lcb/src/search/search.cc +1 -0
  81. package/deps/lcb/src/search/search_handle.cc +30 -8
  82. package/deps/lcb/src/search/search_handle.hh +29 -0
  83. package/deps/lcb/src/settings.cc +1 -1
  84. package/deps/lcb/src/ssl/ssl_common.c +6 -7
  85. package/deps/lcb/src/tracing/span.cc +47 -14
  86. package/deps/lcb/src/tracing/tracer.cc +11 -2
  87. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  88. package/deps/lcb/src/utilities.cc +43 -0
  89. package/deps/lcb/src/utilities.h +53 -0
  90. package/deps/lcb/src/vbucket/vbucket.c +34 -33
  91. package/deps/lcb/src/views/view_handle.cc +13 -5
  92. package/deps/lcb/src/views/view_handle.hh +29 -0
  93. package/deps/lcb/tests/CMakeLists.txt +21 -0
  94. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  95. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  96. package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
  97. package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
  98. package/deps/lcb/tests/iotests/mock-environment.h +49 -0
  99. package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
  100. package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
  101. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  102. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  103. package/deps/lcb/tests/iotests/t_get.cc +109 -7
  104. package/deps/lcb/tests/iotests/t_http.cc +9 -4
  105. package/deps/lcb/tests/iotests/t_lock.cc +18 -0
  106. package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
  107. package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
  108. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  109. package/deps/lcb/tests/iotests/testutil.cc +168 -0
  110. package/deps/lcb/tests/iotests/testutil.h +116 -0
  111. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  112. package/deps/lcb/tests/mocksupport/server.c +0 -1
  113. package/deps/lcb/tests/mocksupport/timeout.c +2 -2
  114. package/deps/lcb/tools/cbc.cc +7 -0
  115. package/dist/analyticsindexmanager.js +512 -524
  116. package/dist/binding.d.ts +3 -0
  117. package/dist/bindingutilities.js +4 -0
  118. package/dist/bucket.js +1 -1
  119. package/dist/bucketmanager.d.ts +31 -1
  120. package/dist/bucketmanager.js +194 -186
  121. package/dist/cluster.d.ts +7 -0
  122. package/dist/cluster.js +48 -38
  123. package/dist/collection.js +11 -17
  124. package/dist/collectionmanager.js +181 -197
  125. package/dist/connection.d.ts +3 -1
  126. package/dist/connection.js +27 -16
  127. package/dist/couchbase.d.ts +1 -0
  128. package/dist/couchbase.js +3 -13
  129. package/dist/datastructures.js +239 -310
  130. package/dist/diagnosticsexecutor.js +70 -85
  131. package/dist/errors.d.ts +70 -0
  132. package/dist/errors.js +96 -2
  133. package/dist/eventingfunctionmanager.d.ts +804 -0
  134. package/dist/eventingfunctionmanager.js +993 -0
  135. package/dist/httpexecutor.d.ts +2 -1
  136. package/dist/httpexecutor.js +30 -37
  137. package/dist/queryindexmanager.js +240 -266
  138. package/dist/scope.js +10 -4
  139. package/dist/sdspecs.d.ts +1 -1
  140. package/dist/searchexecutor.js +3 -0
  141. package/dist/searchindexmanager.js +240 -271
  142. package/dist/searchquery.d.ts +17 -0
  143. package/dist/searchquery.js +22 -1
  144. package/dist/searchtypes.d.ts +7 -2
  145. package/dist/searchtypes.js +2 -2
  146. package/dist/usermanager.js +251 -264
  147. package/dist/utilities.d.ts +2 -0
  148. package/dist/utilities.js +7 -2
  149. package/dist/viewexecutor.js +1 -1
  150. package/dist/viewindexmanager.js +131 -150
  151. package/package.json +1 -1
  152. package/src/addondata.cpp +58 -0
  153. package/src/addondata.h +40 -0
  154. package/src/binding.cpp +3 -1
  155. package/src/cas.h +2 -2
  156. package/src/connection.cpp +25 -178
  157. package/src/connection.h +8 -65
  158. package/src/connection_ops.cpp +57 -34
  159. package/src/constants.cpp +3 -0
  160. package/src/instance.cpp +235 -0
  161. package/src/instance.h +102 -0
  162. package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
  163. package/src/logger.cpp +11 -1
  164. package/src/logger.h +3 -0
  165. package/src/metrics.cpp +10 -0
  166. package/src/metrics.h +3 -0
  167. package/src/mutationtoken.h +2 -2
  168. package/src/opbuilder.h +13 -15
  169. package/src/respreader.cpp +1 -0
  170. package/src/respreader.h +6 -4
  171. package/src/tracespan.h +11 -11
  172. package/src/tracing.cpp +11 -0
  173. package/src/tracing.h +3 -0
  174. package/src/valueparser.h +5 -0
  175. package/deps/lcb/example/observe/durability.c +0 -110
@@ -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;