spice-couchbase 2.0.64 → 2.0.65
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.
- package/build/index.auto-optimize.test.js +122 -204
- package/build/index.count-query.test.js +27 -63
- package/build/index.index-management.test.js +283 -0
- package/build/index.js +486 -418
- package/build/index.multi_get.test.js +9 -56
- package/build/index.query-consistency.test.js +28 -72
- package/build/utility.js +182 -152
- package/build/utility.test.js +79 -59
- package/package.json +1 -1
- package/src/index.index-management.test.js +232 -0
- package/src/index.js +270 -8
- package/src/utility.js +78 -0
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function asyncGeneratorStep(
|
|
4
|
-
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
5
|
var assert = require("assert");
|
|
8
|
-
|
|
9
6
|
var Database = require("./index");
|
|
10
|
-
|
|
11
7
|
var passed = 0;
|
|
12
8
|
var failed = 0;
|
|
13
|
-
|
|
14
9
|
function createDb(_ref) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
get
|
|
18
|
-
} = _ref;
|
|
10
|
+
var lookupIn = _ref.lookupIn,
|
|
11
|
+
get = _ref.get;
|
|
19
12
|
var db = Object.create(Database.prototype);
|
|
20
13
|
var collection = {
|
|
21
14
|
lookupIn,
|
|
@@ -26,11 +19,9 @@ function createDb(_ref) {
|
|
|
26
19
|
db.connection = collection;
|
|
27
20
|
return db;
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
function test(_x, _x2) {
|
|
31
23
|
return _test.apply(this, arguments);
|
|
32
24
|
}
|
|
33
|
-
|
|
34
25
|
function _test() {
|
|
35
26
|
_test = _asyncToGenerator(function* (name, fn) {
|
|
36
27
|
try {
|
|
@@ -45,17 +36,13 @@ function _test() {
|
|
|
45
36
|
});
|
|
46
37
|
return _test.apply(this, arguments);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
function run() {
|
|
50
40
|
return _run.apply(this, arguments);
|
|
51
41
|
}
|
|
52
|
-
|
|
53
42
|
function _run() {
|
|
54
43
|
_run = _asyncToGenerator(function* () {
|
|
55
44
|
console.log("\n--- multi_get tests ---");
|
|
56
|
-
yield test("lookupIn success with dotted object path does not fallback to get",
|
|
57
|
-
/*#__PURE__*/
|
|
58
|
-
_asyncToGenerator(function* () {
|
|
45
|
+
yield test("lookupIn success with dotted object path does not fallback to get", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
59
46
|
var getCalls = 0;
|
|
60
47
|
var db = createDb({
|
|
61
48
|
lookupIn: function () {
|
|
@@ -67,11 +54,9 @@ function _run() {
|
|
|
67
54
|
}]
|
|
68
55
|
};
|
|
69
56
|
});
|
|
70
|
-
|
|
71
57
|
function lookupIn() {
|
|
72
58
|
return _lookupIn.apply(this, arguments);
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
return lookupIn;
|
|
76
61
|
}(),
|
|
77
62
|
get: function () {
|
|
@@ -85,11 +70,9 @@ function _run() {
|
|
|
85
70
|
}
|
|
86
71
|
};
|
|
87
72
|
});
|
|
88
|
-
|
|
89
73
|
function get() {
|
|
90
74
|
return _get.apply(this, arguments);
|
|
91
75
|
}
|
|
92
|
-
|
|
93
76
|
return get;
|
|
94
77
|
}()
|
|
95
78
|
});
|
|
@@ -102,9 +85,7 @@ function _run() {
|
|
|
102
85
|
}]);
|
|
103
86
|
assert.strictEqual(getCalls, 0);
|
|
104
87
|
}));
|
|
105
|
-
yield test("array-mapped dotted path falls back and returns mapped array values",
|
|
106
|
-
/*#__PURE__*/
|
|
107
|
-
_asyncToGenerator(function* () {
|
|
88
|
+
yield test("array-mapped dotted path falls back and returns mapped array values", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
108
89
|
var db = createDb({
|
|
109
90
|
lookupIn: function () {
|
|
110
91
|
var _lookupIn2 = _asyncToGenerator(function* () {
|
|
@@ -115,11 +96,9 @@ function _run() {
|
|
|
115
96
|
}]
|
|
116
97
|
};
|
|
117
98
|
});
|
|
118
|
-
|
|
119
99
|
function lookupIn() {
|
|
120
100
|
return _lookupIn2.apply(this, arguments);
|
|
121
101
|
}
|
|
122
|
-
|
|
123
102
|
return lookupIn;
|
|
124
103
|
}(),
|
|
125
104
|
get: function () {
|
|
@@ -134,11 +113,9 @@ function _run() {
|
|
|
134
113
|
}
|
|
135
114
|
};
|
|
136
115
|
});
|
|
137
|
-
|
|
138
116
|
function get() {
|
|
139
117
|
return _get2.apply(this, arguments);
|
|
140
118
|
}
|
|
141
|
-
|
|
142
119
|
return get;
|
|
143
120
|
}()
|
|
144
121
|
});
|
|
@@ -150,9 +127,7 @@ function _run() {
|
|
|
150
127
|
"tags.name": ["vip", "beta"]
|
|
151
128
|
}]);
|
|
152
129
|
}));
|
|
153
|
-
yield test("missing dotted fields return typed empties (object and array)",
|
|
154
|
-
/*#__PURE__*/
|
|
155
|
-
_asyncToGenerator(function* () {
|
|
130
|
+
yield test("missing dotted fields return typed empties (object and array)", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
156
131
|
var db = createDb({
|
|
157
132
|
lookupIn: function () {
|
|
158
133
|
var _lookupIn3 = _asyncToGenerator(function* () {
|
|
@@ -163,11 +138,9 @@ function _run() {
|
|
|
163
138
|
}]
|
|
164
139
|
};
|
|
165
140
|
});
|
|
166
|
-
|
|
167
141
|
function lookupIn() {
|
|
168
142
|
return _lookupIn3.apply(this, arguments);
|
|
169
143
|
}
|
|
170
|
-
|
|
171
144
|
return lookupIn;
|
|
172
145
|
}(),
|
|
173
146
|
get: function () {
|
|
@@ -179,11 +152,9 @@ function _run() {
|
|
|
179
152
|
}
|
|
180
153
|
};
|
|
181
154
|
});
|
|
182
|
-
|
|
183
155
|
function get() {
|
|
184
156
|
return _get3.apply(this, arguments);
|
|
185
157
|
}
|
|
186
|
-
|
|
187
158
|
return get;
|
|
188
159
|
}()
|
|
189
160
|
});
|
|
@@ -196,9 +167,7 @@ function _run() {
|
|
|
196
167
|
"tags.name": []
|
|
197
168
|
}]);
|
|
198
169
|
}));
|
|
199
|
-
yield test("mixed key outcomes keep order and omit missing docs",
|
|
200
|
-
/*#__PURE__*/
|
|
201
|
-
_asyncToGenerator(function* () {
|
|
170
|
+
yield test("mixed key outcomes keep order and omit missing docs", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
202
171
|
var db = createDb({
|
|
203
172
|
lookupIn: function () {
|
|
204
173
|
var _lookupIn4 = _asyncToGenerator(function* (key) {
|
|
@@ -210,7 +179,6 @@ function _run() {
|
|
|
210
179
|
}]
|
|
211
180
|
};
|
|
212
181
|
}
|
|
213
|
-
|
|
214
182
|
if (key === "b") {
|
|
215
183
|
return {
|
|
216
184
|
content: [{
|
|
@@ -219,14 +187,11 @@ function _run() {
|
|
|
219
187
|
}]
|
|
220
188
|
};
|
|
221
189
|
}
|
|
222
|
-
|
|
223
190
|
throw new Error("not found");
|
|
224
191
|
});
|
|
225
|
-
|
|
226
192
|
function lookupIn(_x3) {
|
|
227
193
|
return _lookupIn4.apply(this, arguments);
|
|
228
194
|
}
|
|
229
|
-
|
|
230
195
|
return lookupIn;
|
|
231
196
|
}(),
|
|
232
197
|
get: function () {
|
|
@@ -242,14 +207,11 @@ function _run() {
|
|
|
242
207
|
}
|
|
243
208
|
};
|
|
244
209
|
}
|
|
245
|
-
|
|
246
210
|
throw new Error("not found");
|
|
247
211
|
});
|
|
248
|
-
|
|
249
212
|
function get(_x4) {
|
|
250
213
|
return _get4.apply(this, arguments);
|
|
251
214
|
}
|
|
252
|
-
|
|
253
215
|
return get;
|
|
254
216
|
}()
|
|
255
217
|
});
|
|
@@ -264,19 +226,15 @@ function _run() {
|
|
|
264
226
|
"tags.name": ["vip", "beta"]
|
|
265
227
|
}]);
|
|
266
228
|
}));
|
|
267
|
-
yield test("non-column multi_get behavior remains unchanged",
|
|
268
|
-
/*#__PURE__*/
|
|
269
|
-
_asyncToGenerator(function* () {
|
|
229
|
+
yield test("non-column multi_get behavior remains unchanged", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
270
230
|
var db = createDb({
|
|
271
231
|
lookupIn: function () {
|
|
272
232
|
var _lookupIn5 = _asyncToGenerator(function* () {
|
|
273
233
|
throw new Error("should not be called");
|
|
274
234
|
});
|
|
275
|
-
|
|
276
235
|
function lookupIn() {
|
|
277
236
|
return _lookupIn5.apply(this, arguments);
|
|
278
237
|
}
|
|
279
|
-
|
|
280
238
|
return lookupIn;
|
|
281
239
|
}(),
|
|
282
240
|
get: function () {
|
|
@@ -284,7 +242,6 @@ function _run() {
|
|
|
284
242
|
if (key === "missing") {
|
|
285
243
|
throw new Error("not found");
|
|
286
244
|
}
|
|
287
|
-
|
|
288
245
|
return {
|
|
289
246
|
value: {
|
|
290
247
|
type: "user",
|
|
@@ -292,11 +249,9 @@ function _run() {
|
|
|
292
249
|
}
|
|
293
250
|
};
|
|
294
251
|
});
|
|
295
|
-
|
|
296
252
|
function get(_x5) {
|
|
297
253
|
return _get5.apply(this, arguments);
|
|
298
254
|
}
|
|
299
|
-
|
|
300
255
|
return get;
|
|
301
256
|
}()
|
|
302
257
|
});
|
|
@@ -313,14 +268,12 @@ function _run() {
|
|
|
313
268
|
}));
|
|
314
269
|
console.log("\nPassed: ".concat(passed));
|
|
315
270
|
console.log("Failed: ".concat(failed));
|
|
316
|
-
|
|
317
271
|
if (failed > 0) {
|
|
318
272
|
process.exitCode = 1;
|
|
319
273
|
}
|
|
320
274
|
});
|
|
321
275
|
return _run.apply(this, arguments);
|
|
322
276
|
}
|
|
323
|
-
|
|
324
277
|
run().catch(error => {
|
|
325
278
|
console.error(error);
|
|
326
279
|
process.exit(1);
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function asyncGeneratorStep(
|
|
4
|
-
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
5
|
var assert = require("assert");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
QueryScanConsistency
|
|
11
|
-
} = require("couchbase");
|
|
12
|
-
|
|
6
|
+
var _require = require("couchbase"),
|
|
7
|
+
QueryScanConsistency = _require.QueryScanConsistency;
|
|
13
8
|
var Database = require("./index");
|
|
14
|
-
|
|
15
9
|
var passed = 0;
|
|
16
10
|
var failed = 0;
|
|
17
|
-
|
|
18
11
|
function createQueryDb() {
|
|
19
12
|
var calls = [];
|
|
20
13
|
var db = Object.create(Database.prototype);
|
|
@@ -31,11 +24,9 @@ function createQueryDb() {
|
|
|
31
24
|
rows: []
|
|
32
25
|
};
|
|
33
26
|
});
|
|
34
|
-
|
|
35
27
|
function query(_x, _x2) {
|
|
36
28
|
return _query.apply(this, arguments);
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
return query;
|
|
40
31
|
}()
|
|
41
32
|
};
|
|
@@ -51,27 +42,21 @@ function createQueryDb() {
|
|
|
51
42
|
rows: []
|
|
52
43
|
};
|
|
53
44
|
});
|
|
54
|
-
|
|
55
45
|
function query(_x3, _x4) {
|
|
56
46
|
return _query2.apply(this, arguments);
|
|
57
47
|
}
|
|
58
|
-
|
|
59
48
|
return query;
|
|
60
49
|
}()
|
|
61
50
|
};
|
|
62
|
-
|
|
63
51
|
db.optimize = () => {};
|
|
64
|
-
|
|
65
52
|
return {
|
|
66
53
|
db,
|
|
67
54
|
calls
|
|
68
55
|
};
|
|
69
56
|
}
|
|
70
|
-
|
|
71
57
|
function test(_x5, _x6) {
|
|
72
58
|
return _test.apply(this, arguments);
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
function _test() {
|
|
76
61
|
_test = _asyncToGenerator(function* (name, fn) {
|
|
77
62
|
try {
|
|
@@ -86,32 +71,24 @@ function _test() {
|
|
|
86
71
|
});
|
|
87
72
|
return _test.apply(this, arguments);
|
|
88
73
|
}
|
|
89
|
-
|
|
90
74
|
function run() {
|
|
91
75
|
return _run.apply(this, arguments);
|
|
92
76
|
}
|
|
93
|
-
|
|
94
77
|
function _run() {
|
|
95
78
|
_run = _asyncToGenerator(function* () {
|
|
96
79
|
console.log("\n--- query consistency tests ---");
|
|
97
|
-
yield test("ordinary SQL++ queries default to not_bounded",
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
db,
|
|
102
|
-
calls
|
|
103
|
-
} = createQueryDb();
|
|
80
|
+
yield test("ordinary SQL++ queries default to not_bounded", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
81
|
+
var _createQueryDb = createQueryDb(),
|
|
82
|
+
db = _createQueryDb.db,
|
|
83
|
+
calls = _createQueryDb.calls;
|
|
104
84
|
yield db.query("SELECT 1");
|
|
105
85
|
assert.strictEqual(calls[0].target, "cluster");
|
|
106
86
|
assert.strictEqual(calls[0].options.scanConsistency, QueryScanConsistency.NotBounded);
|
|
107
87
|
}));
|
|
108
|
-
yield test("request_plus can be selected explicitly",
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
db,
|
|
113
|
-
calls
|
|
114
|
-
} = createQueryDb();
|
|
88
|
+
yield test("request_plus can be selected explicitly", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
89
|
+
var _createQueryDb2 = createQueryDb(),
|
|
90
|
+
db = _createQueryDb2.db,
|
|
91
|
+
calls = _createQueryDb2.calls;
|
|
115
92
|
yield db.query("SELECT 1", "scope", {
|
|
116
93
|
scan_consistency: "request_plus",
|
|
117
94
|
scan_wait: 2500
|
|
@@ -120,25 +97,19 @@ function _run() {
|
|
|
120
97
|
assert.strictEqual(calls[0].options.scanConsistency, QueryScanConsistency.RequestPlus);
|
|
121
98
|
assert.strictEqual(calls[0].options.scanWait, 2500);
|
|
122
99
|
}));
|
|
123
|
-
yield test("legacy boolean consistency values remain supported",
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
db,
|
|
128
|
-
calls
|
|
129
|
-
} = createQueryDb();
|
|
100
|
+
yield test("legacy boolean consistency values remain supported", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
101
|
+
var _createQueryDb3 = createQueryDb(),
|
|
102
|
+
db = _createQueryDb3.db,
|
|
103
|
+
calls = _createQueryDb3.calls;
|
|
130
104
|
yield db.query("SELECT 1", "cluster", {
|
|
131
105
|
scan_consistency: true
|
|
132
106
|
});
|
|
133
107
|
assert.strictEqual(calls[0].options.scanConsistency, QueryScanConsistency.RequestPlus);
|
|
134
108
|
}));
|
|
135
|
-
yield test("mutation state is forwarded without a conflicting scan mode",
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
db,
|
|
140
|
-
calls
|
|
141
|
-
} = createQueryDb();
|
|
109
|
+
yield test("mutation state is forwarded without a conflicting scan mode", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
110
|
+
var _createQueryDb4 = createQueryDb(),
|
|
111
|
+
db = _createQueryDb4.db,
|
|
112
|
+
calls = _createQueryDb4.calls;
|
|
142
113
|
var mutationState = {
|
|
143
114
|
token: "test-token"
|
|
144
115
|
};
|
|
@@ -150,19 +121,14 @@ function _run() {
|
|
|
150
121
|
assert.strictEqual(calls[0].options.scanConsistency, undefined);
|
|
151
122
|
assert.strictEqual(calls[0].options.scanWait, 1000);
|
|
152
123
|
}));
|
|
153
|
-
yield test("search keeps query scope separate from consistency",
|
|
154
|
-
/*#__PURE__*/
|
|
155
|
-
_asyncToGenerator(function* () {
|
|
124
|
+
yield test("search keeps query scope separate from consistency", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
156
125
|
var db = Object.create(Database.prototype);
|
|
157
126
|
var calls = [];
|
|
158
127
|
db.use_bucket_name = true;
|
|
159
128
|
db.bucket = "documents";
|
|
160
129
|
db.scope_name = "_default";
|
|
161
130
|
db.collection_name = "_default";
|
|
162
|
-
|
|
163
|
-
db.getData =
|
|
164
|
-
/*#__PURE__*/
|
|
165
|
-
function () {
|
|
131
|
+
db.getData = /*#__PURE__*/function () {
|
|
166
132
|
var _ref6 = _asyncToGenerator(function* (statement, scope, options) {
|
|
167
133
|
calls.push({
|
|
168
134
|
kind: "data",
|
|
@@ -172,15 +138,11 @@ function _run() {
|
|
|
172
138
|
});
|
|
173
139
|
return [];
|
|
174
140
|
});
|
|
175
|
-
|
|
176
141
|
return function (_x7, _x8, _x9) {
|
|
177
142
|
return _ref6.apply(this, arguments);
|
|
178
143
|
};
|
|
179
144
|
}();
|
|
180
|
-
|
|
181
|
-
db.getCount =
|
|
182
|
-
/*#__PURE__*/
|
|
183
|
-
function () {
|
|
145
|
+
db.getCount = /*#__PURE__*/function () {
|
|
184
146
|
var _ref7 = _asyncToGenerator(function* (statement, scope, options) {
|
|
185
147
|
calls.push({
|
|
186
148
|
kind: "count",
|
|
@@ -190,12 +152,10 @@ function _run() {
|
|
|
190
152
|
});
|
|
191
153
|
return 0;
|
|
192
154
|
});
|
|
193
|
-
|
|
194
|
-
return function (_x10, _x11, _x12) {
|
|
155
|
+
return function (_x0, _x1, _x10) {
|
|
195
156
|
return _ref7.apply(this, arguments);
|
|
196
157
|
};
|
|
197
158
|
}();
|
|
198
|
-
|
|
199
159
|
var options = {
|
|
200
160
|
scan_consistency: "request_plus"
|
|
201
161
|
};
|
|
@@ -204,13 +164,10 @@ function _run() {
|
|
|
204
164
|
assert.strictEqual(calls[0].options, options);
|
|
205
165
|
assert.strictEqual(calls[1].options, options);
|
|
206
166
|
}));
|
|
207
|
-
yield test("invalid consistency values fail before issuing a query",
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
db,
|
|
212
|
-
calls
|
|
213
|
-
} = createQueryDb();
|
|
167
|
+
yield test("invalid consistency values fail before issuing a query", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
168
|
+
var _createQueryDb5 = createQueryDb(),
|
|
169
|
+
db = _createQueryDb5.db,
|
|
170
|
+
calls = _createQueryDb5.calls;
|
|
214
171
|
yield assert.rejects(() => db.query("SELECT 1", "cluster", {
|
|
215
172
|
scan_consistency: "eventual"
|
|
216
173
|
}), /Unsupported query scan consistency/);
|
|
@@ -222,7 +179,6 @@ function _run() {
|
|
|
222
179
|
});
|
|
223
180
|
return _run.apply(this, arguments);
|
|
224
181
|
}
|
|
225
|
-
|
|
226
182
|
run().catch(error => {
|
|
227
183
|
console.error(error);
|
|
228
184
|
process.exit(1);
|