@opengeoweb/api 11.1.0 → 12.1.0
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/index.esm.js +39 -5
- package/package.json +3 -3
- package/src/fakeApi.d.ts +3 -0
- package/src/index.d.ts +1 -0
- package/src/utils.spec.d.ts +1 -0
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
2
2
|
export * from '@opengeoweb/authentication';
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { HttpResponse, delay } from 'msw';
|
|
4
5
|
|
|
5
6
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
6
7
|
try {
|
|
@@ -338,18 +339,27 @@ var getHeaders = function getHeaders(auth) {
|
|
|
338
339
|
};
|
|
339
340
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
340
341
|
var handleResponse = function handleResponse(response) {
|
|
341
|
-
if (response.
|
|
342
|
+
if (response.ok) {
|
|
342
343
|
return response.json().then(function (json) {
|
|
343
344
|
return json || response.headers;
|
|
345
|
+
})["catch"](function () {
|
|
346
|
+
// No JSON response
|
|
344
347
|
});
|
|
345
348
|
}
|
|
346
349
|
return response.json()["catch"](function () {
|
|
347
350
|
// Couldn't parse the JSON
|
|
348
351
|
throw new Error("" + response.status);
|
|
349
|
-
}).then(function (
|
|
350
|
-
var message = _ref.message;
|
|
352
|
+
}).then(function (json) {
|
|
351
353
|
// Got valid JSON with error response, use it
|
|
352
|
-
|
|
354
|
+
if (json) {
|
|
355
|
+
var message = json.message;
|
|
356
|
+
if (message) {
|
|
357
|
+
throw new Error(message);
|
|
358
|
+
}
|
|
359
|
+
var result = JSON.stringify(json);
|
|
360
|
+
throw new Error(result);
|
|
361
|
+
}
|
|
362
|
+
throw new Error("" + response.status);
|
|
353
363
|
});
|
|
354
364
|
};
|
|
355
365
|
var useAuthQuery = function useAuthQuery(queryKey, _queryFn, disabled, refetchInterval) {
|
|
@@ -415,6 +425,30 @@ var optimisticUpdate = function optimisticUpdate(updatedQueryKey, queryClient, _
|
|
|
415
425
|
};
|
|
416
426
|
};
|
|
417
427
|
|
|
428
|
+
var makeMockApiCall = function makeMockApiCall(response, responseInit, delayDuration) {
|
|
429
|
+
if (delayDuration === void 0) {
|
|
430
|
+
delayDuration = 0;
|
|
431
|
+
}
|
|
432
|
+
var result = HttpResponse.json(response, responseInit);
|
|
433
|
+
if (delayDuration) {
|
|
434
|
+
return jest.fn().mockImplementation( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
435
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
436
|
+
while (1) switch (_context.prev = _context.next) {
|
|
437
|
+
case 0:
|
|
438
|
+
_context.next = 2;
|
|
439
|
+
return delay(delayDuration);
|
|
440
|
+
case 2:
|
|
441
|
+
return _context.abrupt("return", result);
|
|
442
|
+
case 3:
|
|
443
|
+
case "end":
|
|
444
|
+
return _context.stop();
|
|
445
|
+
}
|
|
446
|
+
}, _callee);
|
|
447
|
+
})));
|
|
448
|
+
}
|
|
449
|
+
return jest.fn().mockResolvedValue(result);
|
|
450
|
+
};
|
|
451
|
+
|
|
418
452
|
/* *
|
|
419
453
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
420
454
|
* you may not use this file except in compliance with the License.
|
|
@@ -579,4 +613,4 @@ var VisibilityCause;
|
|
|
579
613
|
var API_NAMESPACE = 'api';
|
|
580
614
|
// Initialize and create provider if needed
|
|
581
615
|
|
|
582
|
-
export { API_NAMESPACE, AirmetPhenomena, CloudLevelUnits, Direction, LevelUnits, MovementUnit, ProductStatus, SigmetPhenomena, VisibilityCause, WindUnit, getHeaders, handleResponse, optimisticUpdate, useAuthQuery };
|
|
616
|
+
export { API_NAMESPACE, AirmetPhenomena, CloudLevelUnits, Direction, LevelUnits, MovementUnit, ProductStatus, SigmetPhenomena, VisibilityCause, WindUnit, getHeaders, handleResponse, makeMockApiCall, optimisticUpdate, useAuthQuery };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "GeoWeb API library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"url": "git@gitlab.com:opengeoweb/opengeoweb.git"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@opengeoweb/authentication": "
|
|
12
|
-
"@opengeoweb/store": "
|
|
11
|
+
"@opengeoweb/authentication": "12.1.0",
|
|
12
|
+
"@opengeoweb/store": "12.1.0",
|
|
13
13
|
"@tanstack/react-query": "^5.52.1"
|
|
14
14
|
},
|
|
15
15
|
"module": "./index.esm.js",
|
package/src/fakeApi.d.ts
ADDED
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|