api-def 0.9.1 → 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.
- package/cjs/Api.d.ts +35 -35
- package/cjs/Api.js +140 -144
- package/cjs/ApiConstants.d.ts +58 -58
- package/cjs/ApiConstants.js +55 -55
- package/cjs/ApiTypes.d.ts +103 -103
- package/cjs/ApiTypes.js +4 -4
- package/cjs/ApiUtils.d.ts +6 -6
- package/cjs/ApiUtils.js +51 -53
- package/cjs/Endpoint.d.ts +52 -52
- package/cjs/Endpoint.js +104 -108
- package/cjs/EndpointBuilder.d.ts +14 -14
- package/cjs/EndpointBuilder.js +46 -46
- package/cjs/MockingTypes.d.ts +30 -30
- package/cjs/MockingTypes.js +2 -2
- package/cjs/QueryHandling.d.ts +3 -3
- package/cjs/QueryHandling.js +24 -24
- package/cjs/RequestConfig.d.ts +2 -2
- package/cjs/RequestConfig.js +74 -74
- package/cjs/RequestContext.d.ts +48 -48
- package/cjs/RequestContext.js +235 -238
- package/cjs/RequestError.d.ts +30 -30
- package/cjs/RequestError.js +47 -47
- package/cjs/Requester.d.ts +3 -3
- package/cjs/Requester.js +335 -336
- package/cjs/TextDecoding.d.ts +1 -1
- package/cjs/TextDecoding.js +152 -139
- package/cjs/UtilTypes.d.ts +5 -5
- package/cjs/UtilTypes.js +2 -2
- package/cjs/Utils.d.ts +15 -15
- package/cjs/Utils.js +79 -77
- package/cjs/Validation.d.ts +8 -8
- package/cjs/Validation.js +2 -2
- package/cjs/backend/AxiosRequestBackend.d.ts +13 -13
- package/cjs/backend/AxiosRequestBackend.js +99 -99
- package/cjs/backend/FetchRequestBackend.d.ts +15 -15
- package/cjs/backend/FetchRequestBackend.js +202 -202
- package/cjs/backend/MockRequestBackend.d.ts +11 -11
- package/cjs/backend/MockRequestBackend.js +164 -164
- package/cjs/backend/RequestBackend.d.ts +19 -19
- package/cjs/backend/RequestBackend.js +2 -2
- package/cjs/cache/CacheBackend.d.ts +6 -6
- package/cjs/cache/CacheBackend.js +2 -2
- package/cjs/cache/Caching.d.ts +10 -10
- package/cjs/cache/Caching.js +88 -88
- package/cjs/cache/LocalForageCacheBackend.d.ts +9 -9
- package/cjs/cache/LocalForageCacheBackend.js +24 -24
- package/cjs/cache/LocalStorageCacheBackend.d.ts +7 -7
- package/cjs/cache/LocalStorageCacheBackend.js +77 -77
- package/cjs/index.d.ts +13 -13
- package/cjs/index.js +41 -41
- package/cjs/middleware/CacheMiddleware.d.ts +7 -7
- package/cjs/middleware/CacheMiddleware.js +107 -107
- package/cjs/middleware/LoggingMiddleware.d.ts +6 -6
- package/cjs/middleware/LoggingMiddleware.js +82 -88
- package/cjs/util/retry/index.d.ts +3 -3
- package/cjs/util/retry/index.js +52 -52
- package/cjs/util/retry/lib/retry.d.ts +3 -3
- package/cjs/util/retry/lib/retry.js +50 -54
- package/cjs/util/retry/lib/retryOperation.d.ts +27 -27
- package/cjs/util/retry/lib/retryOperation.js +130 -134
- package/esm/Api.d.ts +35 -35
- package/esm/Api.js +92 -98
- package/esm/ApiConstants.d.ts +58 -58
- package/esm/ApiConstants.js +52 -52
- package/esm/ApiTypes.d.ts +103 -103
- package/esm/ApiTypes.js +1 -1
- package/esm/ApiUtils.d.ts +6 -6
- package/esm/ApiUtils.js +43 -45
- package/esm/Endpoint.d.ts +52 -52
- package/esm/Endpoint.js +66 -70
- package/esm/EndpointBuilder.d.ts +14 -14
- package/esm/EndpointBuilder.js +31 -31
- package/esm/MockingTypes.d.ts +30 -30
- package/esm/MockingTypes.js +1 -1
- package/esm/QueryHandling.d.ts +3 -3
- package/esm/QueryHandling.js +19 -19
- package/esm/RequestConfig.d.ts +2 -2
- package/esm/RequestConfig.js +56 -56
- package/esm/RequestContext.d.ts +48 -48
- package/esm/RequestContext.js +167 -170
- package/esm/RequestError.d.ts +30 -30
- package/esm/RequestError.js +42 -42
- package/esm/Requester.d.ts +3 -3
- package/esm/Requester.js +252 -253
- package/esm/TextDecoding.d.ts +1 -1
- package/esm/TextDecoding.js +148 -135
- package/esm/UtilTypes.d.ts +5 -5
- package/esm/UtilTypes.js +1 -1
- package/esm/Utils.d.ts +15 -15
- package/esm/Utils.js +66 -68
- package/esm/Validation.d.ts +8 -8
- package/esm/Validation.js +1 -1
- package/esm/backend/AxiosRequestBackend.d.ts +13 -13
- package/esm/backend/AxiosRequestBackend.js +62 -62
- package/esm/backend/FetchRequestBackend.d.ts +15 -15
- package/esm/backend/FetchRequestBackend.js +136 -136
- package/esm/backend/MockRequestBackend.d.ts +11 -11
- package/esm/backend/MockRequestBackend.js +116 -116
- package/esm/backend/RequestBackend.d.ts +19 -19
- package/esm/backend/RequestBackend.js +1 -1
- package/esm/cache/CacheBackend.d.ts +6 -6
- package/esm/cache/CacheBackend.js +1 -1
- package/esm/cache/Caching.d.ts +10 -10
- package/esm/cache/Caching.js +39 -39
- package/esm/cache/LocalForageCacheBackend.d.ts +9 -9
- package/esm/cache/LocalForageCacheBackend.js +20 -20
- package/esm/cache/LocalStorageCacheBackend.d.ts +7 -7
- package/esm/cache/LocalStorageCacheBackend.js +32 -32
- package/esm/index.d.ts +13 -13
- package/esm/index.js +14 -15
- package/esm/middleware/CacheMiddleware.d.ts +7 -7
- package/esm/middleware/CacheMiddleware.js +58 -58
- package/esm/middleware/LoggingMiddleware.d.ts +6 -6
- package/esm/middleware/LoggingMiddleware.js +77 -83
- package/esm/util/retry/index.d.ts +3 -3
- package/esm/util/retry/index.js +50 -50
- package/esm/util/retry/lib/retry.d.ts +3 -3
- package/esm/util/retry/lib/retry.js +35 -39
- package/esm/util/retry/lib/retryOperation.d.ts +27 -27
- package/esm/util/retry/lib/retryOperation.js +126 -132
- 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
|
-
|
|
2
|
-
"
|
|
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
|
|
40
|
-
var
|
|
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 :
|
|
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;
|