api-def 0.9.0 → 0.9.2

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 (121) hide show
  1. package/cjs/Api.d.ts +35 -35
  2. package/cjs/Api.js +140 -144
  3. package/cjs/ApiConstants.d.ts +58 -58
  4. package/cjs/ApiConstants.js +55 -55
  5. package/cjs/ApiTypes.d.ts +103 -103
  6. package/cjs/ApiTypes.js +4 -4
  7. package/cjs/ApiUtils.d.ts +6 -6
  8. package/cjs/ApiUtils.js +51 -53
  9. package/cjs/Endpoint.d.ts +52 -52
  10. package/cjs/Endpoint.js +104 -108
  11. package/cjs/EndpointBuilder.d.ts +14 -14
  12. package/cjs/EndpointBuilder.js +46 -46
  13. package/cjs/MockingTypes.d.ts +30 -30
  14. package/cjs/MockingTypes.js +2 -2
  15. package/cjs/QueryHandling.d.ts +3 -3
  16. package/cjs/QueryHandling.js +24 -24
  17. package/cjs/RequestConfig.d.ts +2 -2
  18. package/cjs/RequestConfig.js +74 -74
  19. package/cjs/RequestContext.d.ts +48 -48
  20. package/cjs/RequestContext.js +235 -238
  21. package/cjs/RequestError.d.ts +30 -30
  22. package/cjs/RequestError.js +47 -47
  23. package/cjs/Requester.d.ts +3 -3
  24. package/cjs/Requester.js +335 -336
  25. package/cjs/TextDecoding.d.ts +1 -1
  26. package/cjs/TextDecoding.js +152 -139
  27. package/cjs/UtilTypes.d.ts +5 -5
  28. package/cjs/UtilTypes.js +2 -2
  29. package/cjs/Utils.d.ts +15 -15
  30. package/cjs/Utils.js +79 -77
  31. package/cjs/Validation.d.ts +8 -8
  32. package/cjs/Validation.js +2 -2
  33. package/cjs/backend/AxiosRequestBackend.d.ts +13 -13
  34. package/cjs/backend/AxiosRequestBackend.js +99 -99
  35. package/cjs/backend/FetchRequestBackend.d.ts +15 -15
  36. package/cjs/backend/FetchRequestBackend.js +202 -197
  37. package/cjs/backend/MockRequestBackend.d.ts +11 -11
  38. package/cjs/backend/MockRequestBackend.js +164 -164
  39. package/cjs/backend/RequestBackend.d.ts +19 -19
  40. package/cjs/backend/RequestBackend.js +2 -2
  41. package/cjs/cache/CacheBackend.d.ts +6 -6
  42. package/cjs/cache/CacheBackend.js +2 -2
  43. package/cjs/cache/Caching.d.ts +10 -10
  44. package/cjs/cache/Caching.js +88 -88
  45. package/cjs/cache/LocalForageCacheBackend.d.ts +9 -9
  46. package/cjs/cache/LocalForageCacheBackend.js +24 -24
  47. package/cjs/cache/LocalStorageCacheBackend.d.ts +7 -7
  48. package/cjs/cache/LocalStorageCacheBackend.js +77 -77
  49. package/cjs/index.d.ts +13 -13
  50. package/cjs/index.js +41 -41
  51. package/cjs/middleware/CacheMiddleware.d.ts +7 -7
  52. package/cjs/middleware/CacheMiddleware.js +107 -107
  53. package/cjs/middleware/LoggingMiddleware.d.ts +6 -6
  54. package/cjs/middleware/LoggingMiddleware.js +82 -88
  55. package/cjs/util/retry/index.d.ts +3 -3
  56. package/cjs/util/retry/index.js +52 -52
  57. package/cjs/util/retry/lib/retry.d.ts +3 -3
  58. package/cjs/util/retry/lib/retry.js +50 -54
  59. package/cjs/util/retry/lib/retryOperation.d.ts +27 -27
  60. package/cjs/util/retry/lib/retryOperation.js +130 -134
  61. package/esm/Api.d.ts +35 -35
  62. package/esm/Api.js +92 -98
  63. package/esm/ApiConstants.d.ts +58 -58
  64. package/esm/ApiConstants.js +52 -52
  65. package/esm/ApiTypes.d.ts +103 -103
  66. package/esm/ApiTypes.js +1 -1
  67. package/esm/ApiUtils.d.ts +6 -6
  68. package/esm/ApiUtils.js +43 -45
  69. package/esm/Endpoint.d.ts +52 -52
  70. package/esm/Endpoint.js +66 -70
  71. package/esm/EndpointBuilder.d.ts +14 -14
  72. package/esm/EndpointBuilder.js +31 -31
  73. package/esm/MockingTypes.d.ts +30 -30
  74. package/esm/MockingTypes.js +1 -1
  75. package/esm/QueryHandling.d.ts +3 -3
  76. package/esm/QueryHandling.js +19 -19
  77. package/esm/RequestConfig.d.ts +2 -2
  78. package/esm/RequestConfig.js +56 -56
  79. package/esm/RequestContext.d.ts +48 -48
  80. package/esm/RequestContext.js +167 -170
  81. package/esm/RequestError.d.ts +30 -30
  82. package/esm/RequestError.js +42 -42
  83. package/esm/Requester.d.ts +3 -3
  84. package/esm/Requester.js +252 -253
  85. package/esm/TextDecoding.d.ts +1 -1
  86. package/esm/TextDecoding.js +148 -135
  87. package/esm/UtilTypes.d.ts +5 -5
  88. package/esm/UtilTypes.js +1 -1
  89. package/esm/Utils.d.ts +15 -15
  90. package/esm/Utils.js +66 -68
  91. package/esm/Validation.d.ts +8 -8
  92. package/esm/Validation.js +1 -1
  93. package/esm/backend/AxiosRequestBackend.d.ts +13 -13
  94. package/esm/backend/AxiosRequestBackend.js +62 -62
  95. package/esm/backend/FetchRequestBackend.d.ts +15 -15
  96. package/esm/backend/FetchRequestBackend.js +136 -126
  97. package/esm/backend/MockRequestBackend.d.ts +11 -11
  98. package/esm/backend/MockRequestBackend.js +116 -116
  99. package/esm/backend/RequestBackend.d.ts +19 -19
  100. package/esm/backend/RequestBackend.js +1 -1
  101. package/esm/cache/CacheBackend.d.ts +6 -6
  102. package/esm/cache/CacheBackend.js +1 -1
  103. package/esm/cache/Caching.d.ts +10 -10
  104. package/esm/cache/Caching.js +39 -39
  105. package/esm/cache/LocalForageCacheBackend.d.ts +9 -9
  106. package/esm/cache/LocalForageCacheBackend.js +20 -20
  107. package/esm/cache/LocalStorageCacheBackend.d.ts +7 -7
  108. package/esm/cache/LocalStorageCacheBackend.js +32 -32
  109. package/esm/index.d.ts +13 -13
  110. package/esm/index.js +14 -15
  111. package/esm/middleware/CacheMiddleware.d.ts +7 -7
  112. package/esm/middleware/CacheMiddleware.js +58 -58
  113. package/esm/middleware/LoggingMiddleware.d.ts +6 -6
  114. package/esm/middleware/LoggingMiddleware.js +77 -83
  115. package/esm/util/retry/index.d.ts +3 -3
  116. package/esm/util/retry/index.js +50 -50
  117. package/esm/util/retry/lib/retry.d.ts +3 -3
  118. package/esm/util/retry/lib/retry.js +35 -39
  119. package/esm/util/retry/lib/retryOperation.d.ts +27 -27
  120. package/esm/util/retry/lib/retryOperation.js +126 -132
  121. package/package.json +12 -32
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var LocalForageCacheBackend = /** @class */ (function () {
4
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5
- function LocalForageCacheBackend(localforage) {
6
- this.store = localforage.createInstance({
7
- name: "requestCache",
8
- });
9
- }
10
- LocalForageCacheBackend.prototype.clear = function () {
11
- return this.store.clear();
12
- };
13
- LocalForageCacheBackend.prototype.getItem = function (key) {
14
- return this.store.getItem(key);
15
- };
16
- LocalForageCacheBackend.prototype.removeItem = function (key) {
17
- return this.store.removeItem(key);
18
- };
19
- LocalForageCacheBackend.prototype.setItem = function (key, value) {
20
- return this.store.setItem(key, value);
21
- };
22
- return LocalForageCacheBackend;
23
- }());
24
- exports.default = LocalForageCacheBackend;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var LocalForageCacheBackend = /** @class */ (function () {
4
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5
+ function LocalForageCacheBackend(localforage) {
6
+ this.store = localforage.createInstance({
7
+ name: "requestCache",
8
+ });
9
+ }
10
+ LocalForageCacheBackend.prototype.clear = function () {
11
+ return this.store.clear();
12
+ };
13
+ LocalForageCacheBackend.prototype.getItem = function (key) {
14
+ return this.store.getItem(key);
15
+ };
16
+ LocalForageCacheBackend.prototype.removeItem = function (key) {
17
+ return this.store.removeItem(key);
18
+ };
19
+ LocalForageCacheBackend.prototype.setItem = function (key, value) {
20
+ return this.store.setItem(key, value);
21
+ };
22
+ return LocalForageCacheBackend;
23
+ }());
24
+ exports.default = LocalForageCacheBackend;
@@ -1,7 +1,7 @@
1
- import { CacheBackend } from "./CacheBackend";
2
- export default class LocalStorageCacheBackend implements CacheBackend {
3
- clear(): Promise<void>;
4
- getItem<T>(key: string): Promise<T | null>;
5
- removeItem(key: string): Promise<void>;
6
- setItem<T>(key: string, value: T): Promise<void>;
7
- }
1
+ import { CacheBackend } from "./CacheBackend";
2
+ export default class LocalStorageCacheBackend implements CacheBackend {
3
+ clear(): Promise<void>;
4
+ getItem<T>(key: string): Promise<T | null>;
5
+ removeItem(key: string): Promise<void>;
6
+ setItem<T>(key: string, value: T): Promise<void>;
7
+ }
@@ -1,77 +1,77 @@
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
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var LocalStorageCacheBackend = /** @class */ (function () {
40
- function LocalStorageCacheBackend() {
41
- }
42
- LocalStorageCacheBackend.prototype.clear = function () {
43
- return __awaiter(this, void 0, void 0, function () {
44
- return __generator(this, function (_a) {
45
- localStorage.clear();
46
- return [2 /*return*/];
47
- });
48
- });
49
- };
50
- LocalStorageCacheBackend.prototype.getItem = function (key) {
51
- return __awaiter(this, void 0, void 0, function () {
52
- var value;
53
- return __generator(this, function (_a) {
54
- value = localStorage.getItem(key);
55
- return [2 /*return*/, value ? JSON.parse(value) : null];
56
- });
57
- });
58
- };
59
- LocalStorageCacheBackend.prototype.removeItem = function (key) {
60
- return __awaiter(this, void 0, void 0, function () {
61
- return __generator(this, function (_a) {
62
- localStorage.removeItem(key);
63
- return [2 /*return*/];
64
- });
65
- });
66
- };
67
- LocalStorageCacheBackend.prototype.setItem = function (key, value) {
68
- return __awaiter(this, void 0, void 0, function () {
69
- return __generator(this, function (_a) {
70
- localStorage.setItem(key, JSON.stringify(value));
71
- return [2 /*return*/];
72
- });
73
- });
74
- };
75
- return LocalStorageCacheBackend;
76
- }());
77
- exports.default = LocalStorageCacheBackend;
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var LocalStorageCacheBackend = /** @class */ (function () {
40
+ function LocalStorageCacheBackend() {
41
+ }
42
+ LocalStorageCacheBackend.prototype.clear = function () {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ return __generator(this, function (_a) {
45
+ localStorage.clear();
46
+ return [2 /*return*/];
47
+ });
48
+ });
49
+ };
50
+ LocalStorageCacheBackend.prototype.getItem = function (key) {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ var value;
53
+ return __generator(this, function (_a) {
54
+ value = localStorage.getItem(key);
55
+ return [2 /*return*/, value ? JSON.parse(value) : null];
56
+ });
57
+ });
58
+ };
59
+ LocalStorageCacheBackend.prototype.removeItem = function (key) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ return __generator(this, function (_a) {
62
+ localStorage.removeItem(key);
63
+ return [2 /*return*/];
64
+ });
65
+ });
66
+ };
67
+ LocalStorageCacheBackend.prototype.setItem = function (key, value) {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ return __generator(this, function (_a) {
70
+ localStorage.setItem(key, JSON.stringify(value));
71
+ return [2 /*return*/];
72
+ });
73
+ });
74
+ };
75
+ return LocalStorageCacheBackend;
76
+ }());
77
+ exports.default = LocalStorageCacheBackend;
package/cjs/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export * from "./Api";
2
- export * from "./ApiTypes";
3
- export * from "./UtilTypes";
4
- export * from "./ApiConstants";
5
- export { isRequestError } from "./RequestError";
6
- export { default as Endpoint, EndpointConfig } from "./Endpoint";
7
- export { clearCache, setCacheBackend } from "./cache/Caching";
8
- export { default as LocalStorageCacheBackend } from "./cache/LocalStorageCacheBackend";
9
- export { default as LocaleForageCacheBackend } from "./cache/LocalForageCacheBackend";
10
- export { default as AxiosRequestBackend } from "./backend/AxiosRequestBackend";
11
- export { default as FetchRequestBackend } from "./backend/FetchRequestBackend";
12
- export { default as CacheMiddleware } from "./middleware/CacheMiddleware";
13
- export { default as LoggingMiddleware } from "./middleware/LoggingMiddleware";
1
+ export * from "./Api";
2
+ export * from "./ApiTypes";
3
+ export * from "./UtilTypes";
4
+ export * from "./ApiConstants";
5
+ export { isRequestError } from "./RequestError";
6
+ export { default as Endpoint, EndpointConfig } from "./Endpoint";
7
+ export { clearCache, setCacheBackend } from "./cache/Caching";
8
+ export { default as LocalStorageCacheBackend } from "./cache/LocalStorageCacheBackend";
9
+ export { default as LocaleForageCacheBackend } from "./cache/LocalForageCacheBackend";
10
+ export { default as AxiosRequestBackend } from "./backend/AxiosRequestBackend";
11
+ export { default as FetchRequestBackend } from "./backend/FetchRequestBackend";
12
+ export { default as CacheMiddleware } from "./middleware/CacheMiddleware";
13
+ export { default as LoggingMiddleware } from "./middleware/LoggingMiddleware";
package/cjs/index.js CHANGED
@@ -1,41 +1,41 @@
1
- /// <reference types="typescript" />
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.LoggingMiddleware = exports.CacheMiddleware = exports.FetchRequestBackend = exports.AxiosRequestBackend = exports.LocaleForageCacheBackend = exports.LocalStorageCacheBackend = exports.setCacheBackend = exports.clearCache = exports.Endpoint = exports.isRequestError = void 0;
19
- __exportStar(require("./Api"), exports);
20
- __exportStar(require("./ApiTypes"), exports);
21
- __exportStar(require("./UtilTypes"), exports);
22
- __exportStar(require("./ApiConstants"), exports);
23
- var RequestError_1 = require("./RequestError");
24
- Object.defineProperty(exports, "isRequestError", { enumerable: true, get: function () { return RequestError_1.isRequestError; } });
25
- var Endpoint_1 = require("./Endpoint");
26
- Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return Endpoint_1.default; } });
27
- var Caching_1 = require("./cache/Caching");
28
- Object.defineProperty(exports, "clearCache", { enumerable: true, get: function () { return Caching_1.clearCache; } });
29
- Object.defineProperty(exports, "setCacheBackend", { enumerable: true, get: function () { return Caching_1.setCacheBackend; } });
30
- var LocalStorageCacheBackend_1 = require("./cache/LocalStorageCacheBackend");
31
- Object.defineProperty(exports, "LocalStorageCacheBackend", { enumerable: true, get: function () { return LocalStorageCacheBackend_1.default; } });
32
- var LocalForageCacheBackend_1 = require("./cache/LocalForageCacheBackend");
33
- Object.defineProperty(exports, "LocaleForageCacheBackend", { enumerable: true, get: function () { return LocalForageCacheBackend_1.default; } });
34
- var AxiosRequestBackend_1 = require("./backend/AxiosRequestBackend");
35
- Object.defineProperty(exports, "AxiosRequestBackend", { enumerable: true, get: function () { return AxiosRequestBackend_1.default; } });
36
- var FetchRequestBackend_1 = require("./backend/FetchRequestBackend");
37
- Object.defineProperty(exports, "FetchRequestBackend", { enumerable: true, get: function () { return FetchRequestBackend_1.default; } });
38
- var CacheMiddleware_1 = require("./middleware/CacheMiddleware");
39
- Object.defineProperty(exports, "CacheMiddleware", { enumerable: true, get: function () { return CacheMiddleware_1.default; } });
40
- var LoggingMiddleware_1 = require("./middleware/LoggingMiddleware");
41
- Object.defineProperty(exports, "LoggingMiddleware", { enumerable: true, get: function () { return LoggingMiddleware_1.default; } });
1
+ "use strict";
2
+ /// <reference types="typescript" />
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.LoggingMiddleware = exports.CacheMiddleware = exports.FetchRequestBackend = exports.AxiosRequestBackend = exports.LocaleForageCacheBackend = exports.LocalStorageCacheBackend = exports.setCacheBackend = exports.clearCache = exports.Endpoint = exports.isRequestError = void 0;
19
+ __exportStar(require("./Api"), exports);
20
+ __exportStar(require("./ApiTypes"), exports);
21
+ __exportStar(require("./UtilTypes"), exports);
22
+ __exportStar(require("./ApiConstants"), exports);
23
+ var RequestError_1 = require("./RequestError");
24
+ Object.defineProperty(exports, "isRequestError", { enumerable: true, get: function () { return RequestError_1.isRequestError; } });
25
+ var Endpoint_1 = require("./Endpoint");
26
+ Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return Endpoint_1.default; } });
27
+ var Caching_1 = require("./cache/Caching");
28
+ Object.defineProperty(exports, "clearCache", { enumerable: true, get: function () { return Caching_1.clearCache; } });
29
+ Object.defineProperty(exports, "setCacheBackend", { enumerable: true, get: function () { return Caching_1.setCacheBackend; } });
30
+ var LocalStorageCacheBackend_1 = require("./cache/LocalStorageCacheBackend");
31
+ Object.defineProperty(exports, "LocalStorageCacheBackend", { enumerable: true, get: function () { return LocalStorageCacheBackend_1.default; } });
32
+ var LocalForageCacheBackend_1 = require("./cache/LocalForageCacheBackend");
33
+ Object.defineProperty(exports, "LocaleForageCacheBackend", { enumerable: true, get: function () { return LocalForageCacheBackend_1.default; } });
34
+ var AxiosRequestBackend_1 = require("./backend/AxiosRequestBackend");
35
+ Object.defineProperty(exports, "AxiosRequestBackend", { enumerable: true, get: function () { return AxiosRequestBackend_1.default; } });
36
+ var FetchRequestBackend_1 = require("./backend/FetchRequestBackend");
37
+ Object.defineProperty(exports, "FetchRequestBackend", { enumerable: true, get: function () { return FetchRequestBackend_1.default; } });
38
+ var CacheMiddleware_1 = require("./middleware/CacheMiddleware");
39
+ Object.defineProperty(exports, "CacheMiddleware", { enumerable: true, get: function () { return CacheMiddleware_1.default; } });
40
+ var LoggingMiddleware_1 = require("./middleware/LoggingMiddleware");
41
+ Object.defineProperty(exports, "LoggingMiddleware", { enumerable: true, get: function () { return LoggingMiddleware_1.default; } });
@@ -1,7 +1,7 @@
1
- import { RequestMiddleware } from "../ApiTypes";
2
- export interface CacheMiddlewareOptions {
3
- defaultExpiry?: number;
4
- predicate?: () => boolean;
5
- }
6
- declare const CacheMiddleware: (options?: CacheMiddlewareOptions) => RequestMiddleware;
7
- export default CacheMiddleware;
1
+ import { RequestMiddleware } from "../ApiTypes";
2
+ export interface CacheMiddlewareOptions {
3
+ defaultExpiry?: number;
4
+ predicate?: () => boolean;
5
+ }
6
+ declare const CacheMiddleware: (options?: CacheMiddlewareOptions) => RequestMiddleware;
7
+ export default CacheMiddleware;
@@ -1,107 +1,107 @@
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
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var Caching = require("../cache/Caching");
40
- var ApiConstants_1 = require("../ApiConstants");
41
- var CacheMiddleware = function (options) {
42
- var _a;
43
- if (options === void 0) { options = {}; }
44
- return _a = {},
45
- _a[ApiConstants_1.RequestEvent.Success] = function (context) { return __awaiter(void 0, void 0, void 0, function () {
46
- var cache, shouldCache, expiry;
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0:
50
- if (context.method !== ApiConstants_1.RequestMethod.Get)
51
- return [2 /*return*/];
52
- cache = (context.computedConfig || {}).cache;
53
- shouldCache = !options.predicate || options.predicate();
54
- if (!(cache && shouldCache)) return [3 /*break*/, 2];
55
- expiry = typeof cache === "number" ? cache : (options.defaultExpiry || Caching.DEFAULT_CACHE_EXPIRY);
56
- return [4 /*yield*/, Caching.setCachedItem(context.key, context.response, expiry)];
57
- case 1:
58
- _a.sent();
59
- _a.label = 2;
60
- case 2: return [2 /*return*/];
61
- }
62
- });
63
- }); },
64
- _a[ApiConstants_1.RequestEvent.BeforeSend] = function (context) { return __awaiter(void 0, void 0, void 0, function () {
65
- var cache, shouldCache, cachedValue;
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0:
69
- if (context.method !== ApiConstants_1.RequestMethod.Get)
70
- return [2 /*return*/];
71
- cache = (context.computedConfig || {}).cache;
72
- shouldCache = !options.predicate || options.predicate();
73
- if (!(cache && shouldCache)) return [3 /*break*/, 2];
74
- if (!cache) return [3 /*break*/, 2];
75
- return [4 /*yield*/, Caching.getCachedItem(context.key)];
76
- case 1:
77
- cachedValue = _a.sent();
78
- if (cachedValue) {
79
- context.stats.cached = {
80
- is: true,
81
- by: ApiConstants_1.CacheSource.Local,
82
- };
83
- context.cacheInfo.source = ApiConstants_1.CacheSource.Local;
84
- context.cacheInfo.cached = true;
85
- return [2 /*return*/, {
86
- type: ApiConstants_1.EventResultType.Respond,
87
- response: cachedValue,
88
- }];
89
- }
90
- _a.label = 2;
91
- case 2:
92
- if (cache === false) {
93
- context.updateQuery({
94
- _bust: Math.floor(Math.random() * 9000) + 1000,
95
- });
96
- context.updateHeaders({
97
- Pragma: "no-cache, no-store, must-revalidate",
98
- "Cache-Control": "no-cache, no-store, must-revalidate",
99
- });
100
- }
101
- return [2 /*return*/];
102
- }
103
- });
104
- }); },
105
- _a;
106
- };
107
- exports.default = CacheMiddleware;
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var ApiConstants_1 = require("../ApiConstants");
40
+ var Caching = require("../cache/Caching");
41
+ var CacheMiddleware = function (options) {
42
+ var _a;
43
+ if (options === void 0) { options = {}; }
44
+ return _a = {},
45
+ _a[ApiConstants_1.RequestEvent.Success] = function (context) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var cache, shouldCache, expiry;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ if (context.method !== ApiConstants_1.RequestMethod.Get)
51
+ return [2 /*return*/];
52
+ cache = (context.computedConfig || {}).cache;
53
+ shouldCache = !options.predicate || options.predicate();
54
+ if (!(cache && shouldCache)) return [3 /*break*/, 2];
55
+ expiry = typeof cache === "number" ? cache : options.defaultExpiry || Caching.DEFAULT_CACHE_EXPIRY;
56
+ return [4 /*yield*/, Caching.setCachedItem(context.key, context.response, expiry)];
57
+ case 1:
58
+ _a.sent();
59
+ _a.label = 2;
60
+ case 2: return [2 /*return*/];
61
+ }
62
+ });
63
+ }); },
64
+ _a[ApiConstants_1.RequestEvent.BeforeSend] = function (context) { return __awaiter(void 0, void 0, void 0, function () {
65
+ var cache, shouldCache, cachedValue;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ if (context.method !== ApiConstants_1.RequestMethod.Get)
70
+ return [2 /*return*/];
71
+ cache = (context.computedConfig || {}).cache;
72
+ shouldCache = !options.predicate || options.predicate();
73
+ if (!(cache && shouldCache)) return [3 /*break*/, 2];
74
+ if (!cache) return [3 /*break*/, 2];
75
+ return [4 /*yield*/, Caching.getCachedItem(context.key)];
76
+ case 1:
77
+ cachedValue = _a.sent();
78
+ if (cachedValue) {
79
+ context.stats.cached = {
80
+ is: true,
81
+ by: ApiConstants_1.CacheSource.Local,
82
+ };
83
+ context.cacheInfo.source = ApiConstants_1.CacheSource.Local;
84
+ context.cacheInfo.cached = true;
85
+ return [2 /*return*/, {
86
+ type: ApiConstants_1.EventResultType.Respond,
87
+ response: cachedValue,
88
+ }];
89
+ }
90
+ _a.label = 2;
91
+ case 2:
92
+ if (cache === false) {
93
+ context.updateQuery({
94
+ _bust: Math.floor(Math.random() * 9000) + 1000,
95
+ });
96
+ context.updateHeaders({
97
+ Pragma: "no-cache, no-store, must-revalidate",
98
+ "Cache-Control": "no-cache, no-store, must-revalidate",
99
+ });
100
+ }
101
+ return [2 /*return*/];
102
+ }
103
+ });
104
+ }); },
105
+ _a;
106
+ };
107
+ exports.default = CacheMiddleware;
@@ -1,6 +1,6 @@
1
- import { RequestMiddleware } from "../ApiTypes";
2
- export interface LoggingMiddlewareOptions {
3
- predicate?: () => boolean;
4
- }
5
- declare const LoggingMiddleware: (config?: LoggingMiddlewareOptions) => RequestMiddleware;
6
- export default LoggingMiddleware;
1
+ import { RequestMiddleware } from "../ApiTypes";
2
+ export interface LoggingMiddlewareOptions {
3
+ predicate?: () => boolean;
4
+ }
5
+ declare const LoggingMiddleware: (config?: LoggingMiddlewareOptions) => RequestMiddleware;
6
+ export default LoggingMiddleware;