@driveflux/api-swr 4.0.88 → 4.0.89
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/dist/api-legacy/index.js +20 -12
- package/dist/fetcher.js +12 -4
- package/dist/index.js +22 -13
- package/dist/utils.js +3 -2
- package/package.json +17 -17
package/dist/api-legacy/index.js
CHANGED
|
@@ -138,9 +138,17 @@ function _ts_generator(thisArg, body) {
|
|
|
138
138
|
},
|
|
139
139
|
trys: [],
|
|
140
140
|
ops: []
|
|
141
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
142
|
-
return
|
|
143
|
-
|
|
141
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
142
|
+
return d(g, "next", {
|
|
143
|
+
value: verb(0)
|
|
144
|
+
}), d(g, "throw", {
|
|
145
|
+
value: verb(1)
|
|
146
|
+
}), d(g, "return", {
|
|
147
|
+
value: verb(2)
|
|
148
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
149
|
+
value: function() {
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
144
152
|
}), g;
|
|
145
153
|
function verb(n) {
|
|
146
154
|
return function(v) {
|
|
@@ -231,7 +239,7 @@ import useSWRInfinite from 'swr/infinite';
|
|
|
231
239
|
*
|
|
232
240
|
* @important instead of returning a result, this will always return Success or throw an error containing Error
|
|
233
241
|
* @important if the 3rd param provides an Authorization header, it will be ignored!
|
|
234
|
-
*/ export var fetchWithAuth = function(urlParams) {
|
|
242
|
+
*/ export var fetchWithAuth = function fetchWithAuth(urlParams) {
|
|
235
243
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
236
244
|
return _async_to_generator(function() {
|
|
237
245
|
var _result_metadata, _ref, url, accessToken, otherOptions, apiHost, finalUrl, correlationIdFromSessionStorage, result, correlationId, _result_metadata1;
|
|
@@ -274,10 +282,10 @@ import useSWRInfinite from 'swr/infinite';
|
|
|
274
282
|
});
|
|
275
283
|
})();
|
|
276
284
|
};
|
|
277
|
-
export var isStructuredResponse = function(obj) {
|
|
285
|
+
export var isStructuredResponse = function isStructuredResponse(obj) {
|
|
278
286
|
return obj && (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === 'object' && obj.metadata;
|
|
279
287
|
};
|
|
280
|
-
export var swrFetch = function(url) {
|
|
288
|
+
export var swrFetch = function swrFetch(url) {
|
|
281
289
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
282
290
|
return _async_to_generator(function() {
|
|
283
291
|
var _response_metadata, correlationIdFromSessionStorage, response, correlationId, _response_metadata1;
|
|
@@ -312,12 +320,12 @@ export var swrFetch = function(url) {
|
|
|
312
320
|
});
|
|
313
321
|
})();
|
|
314
322
|
};
|
|
315
|
-
export var useApi = function(key, config) {
|
|
323
|
+
export var useApi = function useApi(key, config) {
|
|
316
324
|
var result = useSWR(key, function(url) {
|
|
317
325
|
return swrFetch(url);
|
|
318
326
|
}, config);
|
|
319
327
|
return _object_spread_props(_object_spread({}, result), {
|
|
320
|
-
revalidate: function() {
|
|
328
|
+
revalidate: function revalidate() {
|
|
321
329
|
return _async_to_generator(function() {
|
|
322
330
|
return _ts_generator(this, function(_state) {
|
|
323
331
|
switch(_state.label){
|
|
@@ -337,7 +345,7 @@ export var useApi = function(key, config) {
|
|
|
337
345
|
}
|
|
338
346
|
});
|
|
339
347
|
};
|
|
340
|
-
export var useApiWithAuth = function(key, config) {
|
|
348
|
+
export var useApiWithAuth = function useApiWithAuth(key, config) {
|
|
341
349
|
// TODO
|
|
342
350
|
var accessToken = useAuth().accessToken;
|
|
343
351
|
var result = useSWR(key ? Array.isArray(key) ? key : [
|
|
@@ -348,7 +356,7 @@ export var useApiWithAuth = function(key, config) {
|
|
|
348
356
|
revalidate: result.mutate
|
|
349
357
|
});
|
|
350
358
|
};
|
|
351
|
-
export var usePaginationApiWithAuth = function(key, config) {
|
|
359
|
+
export var usePaginationApiWithAuth = function usePaginationApiWithAuth(key, config) {
|
|
352
360
|
// TODO
|
|
353
361
|
var accessToken = useAuth().accessToken;
|
|
354
362
|
var result = useSWRInfinite(function(i, p) {
|
|
@@ -375,7 +383,7 @@ export var usePaginationApiWithAuth = function(key, config) {
|
|
|
375
383
|
];
|
|
376
384
|
}, fetchWithAuth, config);
|
|
377
385
|
return _object_spread_props(_object_spread({}, result), {
|
|
378
|
-
revalidate: function() {
|
|
386
|
+
revalidate: function revalidate() {
|
|
379
387
|
return _async_to_generator(function() {
|
|
380
388
|
return _ts_generator(this, function(_state) {
|
|
381
389
|
switch(_state.label){
|
|
@@ -398,7 +406,7 @@ export var usePaginationApiWithAuth = function(key, config) {
|
|
|
398
406
|
/**
|
|
399
407
|
* TODO
|
|
400
408
|
* @deprecated
|
|
401
|
-
*/ export var useAuthenticatedFetch = function(url) {
|
|
409
|
+
*/ export var useAuthenticatedFetch = function useAuthenticatedFetch(url) {
|
|
402
410
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
403
411
|
var accessToken = useAuth().accessToken;
|
|
404
412
|
var headers = _object_spread({}, accessToken ? {
|
package/dist/fetcher.js
CHANGED
|
@@ -134,9 +134,17 @@ function _ts_generator(thisArg, body) {
|
|
|
134
134
|
},
|
|
135
135
|
trys: [],
|
|
136
136
|
ops: []
|
|
137
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
138
|
-
return
|
|
139
|
-
|
|
137
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
138
|
+
return d(g, "next", {
|
|
139
|
+
value: verb(0)
|
|
140
|
+
}), d(g, "throw", {
|
|
141
|
+
value: verb(1)
|
|
142
|
+
}), d(g, "return", {
|
|
143
|
+
value: verb(2)
|
|
144
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
145
|
+
value: function() {
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
140
148
|
}), g;
|
|
141
149
|
function verb(n) {
|
|
142
150
|
return function(v) {
|
|
@@ -224,7 +232,7 @@ import { enhancedFetch } from '@driveflux/fetch';
|
|
|
224
232
|
*
|
|
225
233
|
* @important instead of returning a result, this will always return Success or throw an error containing Error
|
|
226
234
|
* @important if the 3rd param provides an Authorization header, it will be ignored!
|
|
227
|
-
*/ export var fetchWithAuth = function(urlParams) {
|
|
235
|
+
*/ export var fetchWithAuth = function fetchWithAuth(urlParams) {
|
|
228
236
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
229
237
|
return _async_to_generator(function() {
|
|
230
238
|
var _result_metadata, _ref, url, accessToken, apiHost, finalUrl, correlationIdFromSessionStorage, result, correlationId, _result_metadata1;
|
package/dist/index.js
CHANGED
|
@@ -52,12 +52,22 @@ function _object_spread_props(target, source) {
|
|
|
52
52
|
}
|
|
53
53
|
function _object_without_properties(source, excluded) {
|
|
54
54
|
if (source == null) return {};
|
|
55
|
-
var target =
|
|
56
|
-
|
|
55
|
+
var target = {}, sourceKeys, key, i;
|
|
56
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
57
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
58
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
59
|
+
key = sourceKeys[i];
|
|
60
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
61
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
66
|
+
target = _object_without_properties_loose(source, excluded);
|
|
57
67
|
if (Object.getOwnPropertySymbols) {
|
|
58
|
-
|
|
59
|
-
for(i = 0; i <
|
|
60
|
-
key =
|
|
68
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
69
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
70
|
+
key = sourceKeys[i];
|
|
61
71
|
if (excluded.indexOf(key) >= 0) continue;
|
|
62
72
|
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
63
73
|
target[key] = source[key];
|
|
@@ -67,12 +77,11 @@ function _object_without_properties(source, excluded) {
|
|
|
67
77
|
}
|
|
68
78
|
function _object_without_properties_loose(source, excluded) {
|
|
69
79
|
if (source == null) return {};
|
|
70
|
-
var target = {};
|
|
71
|
-
var sourceKeys = Object.keys(source);
|
|
72
|
-
var key, i;
|
|
80
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
73
81
|
for(i = 0; i < sourceKeys.length; i++){
|
|
74
82
|
key = sourceKeys[i];
|
|
75
83
|
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
76
85
|
target[key] = source[key];
|
|
77
86
|
}
|
|
78
87
|
return target;
|
|
@@ -85,13 +94,13 @@ import useSWRInfinite from 'swr/infinite';
|
|
|
85
94
|
import { getApiUrl } from './api-models.js';
|
|
86
95
|
import { fetchWithAuth } from './fetcher.js';
|
|
87
96
|
import { makeQueryParams } from './utils.js';
|
|
88
|
-
var getKeyMaker = function(model, pageSize, query, accessToken) {
|
|
97
|
+
var getKeyMaker = function getKeyMaker(model, pageSize, query, accessToken) {
|
|
89
98
|
var resource = getApiUrl(model);
|
|
90
|
-
var loader = function(pageIndex, previousPageData) {
|
|
99
|
+
var loader = function loader(pageIndex, previousPageData) {
|
|
91
100
|
if (previousPageData && !previousPageData.next) {
|
|
92
101
|
return null;
|
|
93
102
|
}
|
|
94
|
-
var makeFinalQuery = function(index) {
|
|
103
|
+
var makeFinalQuery = function makeFinalQuery(index) {
|
|
95
104
|
var take = (previousPageData === null || previousPageData === void 0 ? void 0 : previousPageData.take) || pageSize;
|
|
96
105
|
return _object_spread_props(_object_spread({}, query), {
|
|
97
106
|
skip: (previousPageData === null || previousPageData === void 0 ? void 0 : previousPageData.skip) || (take ? index * take : undefined),
|
|
@@ -116,8 +125,8 @@ var getKeyMaker = function(model, pageSize, query, accessToken) {
|
|
|
116
125
|
};
|
|
117
126
|
return loader;
|
|
118
127
|
};
|
|
119
|
-
export var useApiPagination = function(model,
|
|
120
|
-
var pageSize =
|
|
128
|
+
export var useApiPagination = function useApiPagination(model, _1) {
|
|
129
|
+
var pageSize = _1.pageSize, query = _1.query, swrConfig = _object_without_properties(_1, [
|
|
121
130
|
"pageSize",
|
|
122
131
|
"query"
|
|
123
132
|
]);
|
package/dist/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ function _array_with_holes(arr) {
|
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
9
|
function _instanceof(left, right) {
|
|
10
|
+
"@swc/helpers - instanceof";
|
|
10
11
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
11
12
|
return !!right[Symbol.hasInstance](left);
|
|
12
13
|
} else {
|
|
@@ -51,7 +52,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
51
52
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
52
53
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
53
54
|
}
|
|
54
|
-
export var makeQueryParams = function(params) {
|
|
55
|
+
export var makeQueryParams = function makeQueryParams(params) {
|
|
55
56
|
if (_instanceof(params, URLSearchParams)) {
|
|
56
57
|
return params.toString();
|
|
57
58
|
}
|
|
@@ -78,7 +79,7 @@ export var makeQueryParams = function(params) {
|
|
|
78
79
|
}
|
|
79
80
|
return newParams.toString();
|
|
80
81
|
};
|
|
81
|
-
var appendParam = function(params, key, value) {
|
|
82
|
+
var appendParam = function appendParam1(params, key, value) {
|
|
82
83
|
if (Array.isArray(value)) {
|
|
83
84
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
84
85
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/api-swr",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.89",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -16,26 +16,26 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@driveflux/auth": "4.0.
|
|
20
|
-
"@driveflux/config": "3.0.
|
|
19
|
+
"@driveflux/auth": "4.0.88",
|
|
20
|
+
"@driveflux/config": "3.0.11",
|
|
21
21
|
"@driveflux/db": "4.1.19",
|
|
22
|
-
"@driveflux/fetch": "8.0.
|
|
23
|
-
"@driveflux/problem": "6.0.
|
|
24
|
-
"@driveflux/result": "6.0.
|
|
25
|
-
"lodash": "^4.
|
|
26
|
-
"swr": "^2.
|
|
22
|
+
"@driveflux/fetch": "8.0.2",
|
|
23
|
+
"@driveflux/problem": "6.0.2",
|
|
24
|
+
"@driveflux/result": "6.0.2",
|
|
25
|
+
"lodash": "^4.18.1",
|
|
26
|
+
"swr": "^2.4.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@driveflux/fab": "4.0.
|
|
30
|
-
"@driveflux/tsconfig": "3.0.
|
|
31
|
-
"@swc/cli": "^0.
|
|
32
|
-
"@swc/core": "^1.
|
|
33
|
-
"@types/lodash": "^4.17.
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"@types/react": "19.2.
|
|
29
|
+
"@driveflux/fab": "4.0.1",
|
|
30
|
+
"@driveflux/tsconfig": "3.0.1",
|
|
31
|
+
"@swc/cli": "^0.8.1",
|
|
32
|
+
"@swc/core": "^1.15.33",
|
|
33
|
+
"@types/lodash": "^4.17.24",
|
|
34
|
+
"@types/node": "^25.7.0",
|
|
35
|
+
"@types/react": "19.2.14",
|
|
36
36
|
"del-cli": "^7.0.0",
|
|
37
|
-
"react": "19.2.
|
|
38
|
-
"typescript": "^
|
|
37
|
+
"react": "19.2.6",
|
|
38
|
+
"typescript": "^6.0.3"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "fab",
|