@neo4j-labs/experimental-query-api-wrapper 0.0.1-alpha03 → 0.0.1-alpha05
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.
|
@@ -149,7 +149,7 @@ export default class HttpConnectionProvider extends ConnectionProvider {
|
|
|
149
149
|
*/
|
|
150
150
|
function run(connection, config) {
|
|
151
151
|
return new Promise((resolve, reject) => {
|
|
152
|
-
connection.run('
|
|
152
|
+
connection.run('CALL db.ping()', {}, {
|
|
153
153
|
database: config?.database, mode: config?.accessMode, fetchSize: 200, reactive: false, bookmarks: Bookmarks.empty(), highRecordWatermark: 10, lowRecordWatermark: 0, txConfig: TxConfig.empty()
|
|
154
154
|
})
|
|
155
155
|
.subscribe({
|
|
@@ -162,17 +162,45 @@ class QuerySuccessResponseCodec extends QueryResponseCodec {
|
|
|
162
162
|
}
|
|
163
163
|
_decodeTime(value) {
|
|
164
164
|
// 12:50:35.556+01:00
|
|
165
|
+
// 12:50:35+01:00
|
|
166
|
+
// 12:50:35Z
|
|
165
167
|
const [hourStr, minuteString, secondNanosecondAndOffsetString, offsetMinuteString] = value.split(':');
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
let [secondStr, nanosecondAndOffsetString] = secondNanosecondAndOffsetString.split('.');
|
|
169
|
+
let [nanosecondString, offsetHourString, isPositive, hasOffset] = ['0', '0', true, true];
|
|
170
|
+
if (nanosecondAndOffsetString !== undefined) {
|
|
171
|
+
if (nanosecondAndOffsetString.indexOf('+') >= 0) {
|
|
172
|
+
[nanosecondString, offsetHourString] = [...nanosecondAndOffsetString.split('+')];
|
|
173
|
+
}
|
|
174
|
+
else if (nanosecondAndOffsetString.indexOf('-') >= 0) {
|
|
175
|
+
[nanosecondString, offsetHourString] = [...nanosecondAndOffsetString.split('-')];
|
|
176
|
+
isPositive = false;
|
|
177
|
+
}
|
|
178
|
+
else if (nanosecondAndOffsetString.indexOf('Z') >= 0) {
|
|
179
|
+
[nanosecondString] = [...nanosecondAndOffsetString.split('Z')];
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
hasOffset = false;
|
|
183
|
+
if (nanosecondAndOffsetString.indexOf('[')) {
|
|
184
|
+
[nanosecondString] = [...nanosecondAndOffsetString.split('[')];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
if (secondStr.indexOf('+') >= 0) {
|
|
190
|
+
[secondStr, offsetHourString] = [...secondStr.split('+')];
|
|
191
|
+
}
|
|
192
|
+
else if (secondStr.indexOf('-') >= 0) {
|
|
193
|
+
[secondStr, offsetHourString] = [...secondStr.split('-')];
|
|
194
|
+
isPositive = false;
|
|
195
|
+
}
|
|
196
|
+
else if (secondStr.indexOf('Z') < 0) {
|
|
197
|
+
hasOffset = false;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
secondStr = secondStr.substring(0, 2);
|
|
201
|
+
const nanosecond = int(nanosecondString.padEnd(9, '0'));
|
|
202
|
+
if (hasOffset) {
|
|
203
|
+
const timeZoneOffsetInSeconds = int(offsetHourString).multiply(60).add(int(offsetMinuteString ?? '0')).multiply(60).multiply(isPositive ? 1 : -1);
|
|
176
204
|
return new Time(this._decodeInteger(hourStr), this._decodeInteger(minuteString), this._decodeInteger(secondStr), this._normalizeInteger(nanosecond), this._normalizeInteger(timeZoneOffsetInSeconds));
|
|
177
205
|
}
|
|
178
206
|
return new LocalTime(this._decodeInteger(hourStr), this._decodeInteger(minuteString), this._decodeInteger(secondStr), this._normalizeInteger(nanosecond));
|
|
@@ -217,17 +245,14 @@ class QuerySuccessResponseCodec extends QueryResponseCodec {
|
|
|
217
245
|
}
|
|
218
246
|
_decodeDuration(value) {
|
|
219
247
|
// P14DT16H12M
|
|
220
|
-
// Duration is PnW
|
|
221
248
|
const durationStringWithP = value.slice(1, value.length);
|
|
222
|
-
if (durationStringWithP.endsWith('W')) {
|
|
223
|
-
const weeksString = durationStringWithP.slice(0, durationStringWithP.length - 1);
|
|
224
|
-
const weeks = this._decodeInteger(weeksString);
|
|
225
|
-
throw newError('Duration in weeks are not supported yet', error.PROTOCOL_ERROR);
|
|
226
|
-
}
|
|
227
249
|
let month = '0';
|
|
250
|
+
let week = '0';
|
|
228
251
|
let day = '0';
|
|
229
252
|
let second = '0';
|
|
230
253
|
let nanosecond = '0';
|
|
254
|
+
let hour = '0';
|
|
255
|
+
let minute = '0';
|
|
231
256
|
let currentNumber = '';
|
|
232
257
|
let timePart = false;
|
|
233
258
|
for (const ch of durationStringWithP) {
|
|
@@ -237,35 +262,59 @@ class QuerySuccessResponseCodec extends QueryResponseCodec {
|
|
|
237
262
|
else {
|
|
238
263
|
switch (ch) {
|
|
239
264
|
case 'M':
|
|
265
|
+
// minutes
|
|
240
266
|
if (timePart) {
|
|
241
|
-
|
|
267
|
+
minute = currentNumber;
|
|
268
|
+
// months
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
month = currentNumber;
|
|
242
272
|
}
|
|
243
|
-
|
|
273
|
+
break;
|
|
274
|
+
case 'W':
|
|
275
|
+
if (timePart) {
|
|
276
|
+
throw newError(`Duration is not well formatted. Unexpected Duration component ${ch} in time part`, error.PROTOCOL_ERROR);
|
|
277
|
+
}
|
|
278
|
+
week = currentNumber;
|
|
244
279
|
break;
|
|
245
280
|
case 'D':
|
|
246
281
|
if (timePart) {
|
|
247
|
-
throw newError(`Unexpected Duration component ${ch} in time part`, error.PROTOCOL_ERROR);
|
|
282
|
+
throw newError(`Duration is not well formatted. Unexpected Duration component ${ch} in time part`, error.PROTOCOL_ERROR);
|
|
248
283
|
}
|
|
249
284
|
day = currentNumber;
|
|
250
285
|
break;
|
|
251
286
|
case 'S':
|
|
252
287
|
if (!timePart) {
|
|
253
|
-
throw newError(`Unexpected Duration component ${ch} in date part`, error.PROTOCOL_ERROR);
|
|
288
|
+
throw newError(`Duration is not well formatted. Unexpected Duration component ${ch} in date part`, error.PROTOCOL_ERROR);
|
|
254
289
|
}
|
|
255
290
|
const nanosecondSeparator = currentNumber.includes(',') ? ',' : '.';
|
|
256
291
|
[second, nanosecond] = currentNumber.split(nanosecondSeparator);
|
|
257
292
|
break;
|
|
293
|
+
case 'H':
|
|
294
|
+
if (!timePart) {
|
|
295
|
+
throw newError(`Duration is not well formatted. Unexpected Duration component ${ch} in date part`, error.PROTOCOL_ERROR);
|
|
296
|
+
}
|
|
297
|
+
hour = currentNumber;
|
|
298
|
+
break;
|
|
258
299
|
case 'T':
|
|
259
300
|
timePart = true;
|
|
260
301
|
break;
|
|
261
302
|
default:
|
|
262
|
-
throw newError(`Unexpected Duration component ${ch}`, error.PROTOCOL_ERROR);
|
|
303
|
+
throw newError(`Duration is not well formatted. Unexpected Duration component ${ch}`, error.PROTOCOL_ERROR);
|
|
263
304
|
}
|
|
264
305
|
currentNumber = '';
|
|
265
306
|
}
|
|
266
307
|
}
|
|
308
|
+
const secondsInt = int(hour)
|
|
309
|
+
.multiply(60)
|
|
310
|
+
.add(minute)
|
|
311
|
+
.multiply(60)
|
|
312
|
+
.add(second);
|
|
313
|
+
const dayInt = int(week)
|
|
314
|
+
.multiply(7)
|
|
315
|
+
.add(day);
|
|
267
316
|
const nanosecondString = nanosecond ?? '0';
|
|
268
|
-
return new Duration(this._decodeInteger(month), this.
|
|
317
|
+
return new Duration(this._decodeInteger(month), this._normalizeInteger(dayInt), this._normalizeInteger(secondsInt), this._decodeInteger(nanosecondString.padEnd(9, '0')));
|
|
269
318
|
}
|
|
270
319
|
_decodeMap(value) {
|
|
271
320
|
const result = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-labs/experimental-query-api-wrapper",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-alpha05",
|
|
4
4
|
"description": "Experimental wrapper library to access Neo4j Database using Query API with a neo4j-driver-like interface.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|