1 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
2 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
3 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
4 | function verb(n) { return function (v) { return step([n, v]); }; }
|
5 | function step(op) {
|
6 | if (f) throw new TypeError("Generator is already executing.");
|
7 | while (_) try {
|
8 | 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;
|
9 | if (y = 0, t) op = [op[0] & 2, t.value];
|
10 | switch (op[0]) {
|
11 | case 0: case 1: t = op; break;
|
12 | case 4: _.label++; return { value: op[1], done: false };
|
13 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
14 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
15 | default:
|
16 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
17 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
18 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
19 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
20 | if (t[2]) _.ops.pop();
|
21 | _.trys.pop(); continue;
|
22 | }
|
23 | op = body.call(thisArg, _);
|
24 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
25 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
26 | }
|
27 | };
|
28 | var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
29 | for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
30 | to[j] = from[i];
|
31 | return to;
|
32 | };
|
33 | var __create = Object.create;
|
34 | var __defProp = Object.defineProperty;
|
35 | var __defProps = Object.defineProperties;
|
36 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
37 | var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
38 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
39 | var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
40 | var __getProtoOf = Object.getPrototypeOf;
|
41 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
42 | var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
43 | var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
|
44 | var __spreadValues = function (a, b) {
|
45 | for (var prop in b || (b = {}))
|
46 | if (__hasOwnProp.call(b, prop))
|
47 | __defNormalProp(a, prop, b[prop]);
|
48 | if (__getOwnPropSymbols)
|
49 | for (var _i = 0, _e = __getOwnPropSymbols(b); _i < _e.length; _i++) {
|
50 | var prop = _e[_i];
|
51 | if (__propIsEnum.call(b, prop))
|
52 | __defNormalProp(a, prop, b[prop]);
|
53 | }
|
54 | return a;
|
55 | };
|
56 | var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
|
57 | var __markAsModule = function (target) { return __defProp(target, "__esModule", { value: true }); };
|
58 | var __objRest = function (source, exclude) {
|
59 | var target = {};
|
60 | for (var prop in source)
|
61 | if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
62 | target[prop] = source[prop];
|
63 | if (source != null && __getOwnPropSymbols)
|
64 | for (var _i = 0, _e = __getOwnPropSymbols(source); _i < _e.length; _i++) {
|
65 | var prop = _e[_i];
|
66 | if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
67 | target[prop] = source[prop];
|
68 | }
|
69 | return target;
|
70 | };
|
71 | var __export = function (target, all) {
|
72 | for (var name in all)
|
73 | __defProp(target, name, { get: all[name], enumerable: true });
|
74 | };
|
75 | var __reExport = function (target, module2, desc) {
|
76 | if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
77 | var _loop_1 = function (key) {
|
78 | if (!__hasOwnProp.call(target, key) && key !== "default")
|
79 | __defProp(target, key, { get: function () { return module2[key]; }, enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
80 | };
|
81 | for (var _i = 0, _e = __getOwnPropNames(module2); _i < _e.length; _i++) {
|
82 | var key = _e[_i];
|
83 | _loop_1(key);
|
84 | }
|
85 | }
|
86 | return target;
|
87 | };
|
88 | var __toModule = function (module2) {
|
89 | return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: function () { return module2.default; }, enumerable: true } : { value: module2, enumerable: true })), module2);
|
90 | };
|
91 | var __async = function (__this, __arguments, generator) {
|
92 | return new Promise(function (resolve, reject) {
|
93 | var fulfilled = function (value) {
|
94 | try {
|
95 | step(generator.next(value));
|
96 | }
|
97 | catch (e) {
|
98 | reject(e);
|
99 | }
|
100 | };
|
101 | var rejected = function (value) {
|
102 | try {
|
103 | step(generator.throw(value));
|
104 | }
|
105 | catch (e) {
|
106 | reject(e);
|
107 | }
|
108 | };
|
109 | var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
|
110 | step((generator = generator.apply(__this, __arguments)).next());
|
111 | });
|
112 | };
|
113 |
|
114 | __markAsModule(exports);
|
115 | __export(exports, {
|
116 | QueryStatus: function () { return QueryStatus; },
|
117 | buildCreateApi: function () { return buildCreateApi; },
|
118 | copyWithStructuralSharing: function () { return copyWithStructuralSharing; },
|
119 | coreModule: function () { return coreModule; },
|
120 | createApi: function () { return createApi; },
|
121 | fakeBaseQuery: function () { return fakeBaseQuery; },
|
122 | fetchBaseQuery: function () { return fetchBaseQuery; },
|
123 | retry: function () { return retry; },
|
124 | setupListeners: function () { return setupListeners; },
|
125 | skipSelector: function () { return skipSelector; },
|
126 | skipToken: function () { return skipToken; }
|
127 | });
|
128 |
|
129 | var QueryStatus;
|
130 | (function (QueryStatus2) {
|
131 | QueryStatus2["uninitialized"] = "uninitialized";
|
132 | QueryStatus2["pending"] = "pending";
|
133 | QueryStatus2["fulfilled"] = "fulfilled";
|
134 | QueryStatus2["rejected"] = "rejected";
|
135 | })(QueryStatus || (QueryStatus = {}));
|
136 | function getRequestStatusFlags(status) {
|
137 | return {
|
138 | status: status,
|
139 | isUninitialized: status === QueryStatus.uninitialized,
|
140 | isLoading: status === QueryStatus.pending,
|
141 | isSuccess: status === QueryStatus.fulfilled,
|
142 | isError: status === QueryStatus.rejected
|
143 | };
|
144 | }
|
145 |
|
146 | function isAbsoluteUrl(url) {
|
147 | return new RegExp("(^|:)//").test(url);
|
148 | }
|
149 |
|
150 | var withoutTrailingSlash = function (url) { return url.replace(/\/$/, ""); };
|
151 | var withoutLeadingSlash = function (url) { return url.replace(/^\//, ""); };
|
152 | function joinUrls(base, url) {
|
153 | if (!base) {
|
154 | return url;
|
155 | }
|
156 | if (!url) {
|
157 | return base;
|
158 | }
|
159 | if (isAbsoluteUrl(url)) {
|
160 | return url;
|
161 | }
|
162 | base = withoutTrailingSlash(base);
|
163 | url = withoutLeadingSlash(url);
|
164 | return base + "/" + url;
|
165 | }
|
166 |
|
167 | var flatten = function (arr) { return [].concat.apply([], arr); };
|
168 |
|
169 | function isOnline() {
|
170 | return typeof navigator === "undefined" ? true : navigator.onLine === void 0 ? true : navigator.onLine;
|
171 | }
|
172 |
|
173 | function isDocumentVisible() {
|
174 | if (typeof document === "undefined") {
|
175 | return true;
|
176 | }
|
177 | return document.visibilityState !== "hidden";
|
178 | }
|
179 |
|
180 | var import_toolkit = __toModule(require("@reduxjs/toolkit"));
|
181 | var isPlainObject = import_toolkit.isPlainObject;
|
182 | function copyWithStructuralSharing(oldObj, newObj) {
|
183 | if (oldObj === newObj || !(isPlainObject(oldObj) && isPlainObject(newObj) || Array.isArray(oldObj) && Array.isArray(newObj))) {
|
184 | return newObj;
|
185 | }
|
186 | var newKeys = Object.keys(newObj);
|
187 | var oldKeys = Object.keys(oldObj);
|
188 | var isSameObject = newKeys.length === oldKeys.length;
|
189 | var mergeObj = Array.isArray(newObj) ? [] : {};
|
190 | for (var _i = 0, newKeys_1 = newKeys; _i < newKeys_1.length; _i++) {
|
191 | var key = newKeys_1[_i];
|
192 | mergeObj[key] = copyWithStructuralSharing(oldObj[key], newObj[key]);
|
193 | if (isSameObject)
|
194 | isSameObject = oldObj[key] === mergeObj[key];
|
195 | }
|
196 | return isSameObject ? oldObj : mergeObj;
|
197 | }
|
198 |
|
199 | var import_toolkit2 = __toModule(require("@reduxjs/toolkit"));
|
200 | var defaultFetchFn = function () {
|
201 | var args = [];
|
202 | for (var _i = 0; _i < arguments.length; _i++) {
|
203 | args[_i] = arguments[_i];
|
204 | }
|
205 | return fetch.apply(void 0, args);
|
206 | };
|
207 | var defaultValidateStatus = function (response) { return response.status >= 200 && response.status <= 299; };
|
208 | var isJsonContentType = function (headers) {
|
209 | var _a, _b;
|
210 | return (_b = (_a = headers.get("content-type")) == null ? void 0 : _a.trim()) == null ? void 0 : _b.startsWith("application/json");
|
211 | };
|
212 | var handleResponse = function (response, responseHandler) { return __async(void 0, null, function () {
|
213 | var text;
|
214 | return __generator(this, function (_e) {
|
215 | switch (_e.label) {
|
216 | case 0:
|
217 | if (typeof responseHandler === "function") {
|
218 | return [2 , responseHandler(response)];
|
219 | }
|
220 | if (responseHandler === "text") {
|
221 | return [2 , response.text()];
|
222 | }
|
223 | if (!(responseHandler === "json")) return [3 , 2];
|
224 | return [4 , response.text()];
|
225 | case 1:
|
226 | text = _e.sent();
|
227 | return [2 , text.length ? JSON.parse(text) : void 0];
|
228 | case 2: return [2 ];
|
229 | }
|
230 | });
|
231 | }); };
|
232 | function stripUndefined(obj) {
|
233 | if (!(0, import_toolkit2.isPlainObject)(obj)) {
|
234 | return obj;
|
235 | }
|
236 | var copy = __spreadValues({}, obj);
|
237 | for (var _i = 0, _e = Object.entries(copy); _i < _e.length; _i++) {
|
238 | var _f = _e[_i], k = _f[0], v = _f[1];
|
239 | if (typeof v === "undefined")
|
240 | delete copy[k];
|
241 | }
|
242 | return copy;
|
243 | }
|
244 | function fetchBaseQuery(_a) {
|
245 | var _this = this;
|
246 | if (_a === void 0) { _a = {}; }
|
247 | var _b = _a, baseUrl = _b.baseUrl, _e = _b.prepareHeaders, prepareHeaders = _e === void 0 ? function (x) { return x; } : _e, _f = _b.fetchFn, fetchFn = _f === void 0 ? defaultFetchFn : _f, baseFetchOptions = __objRest(_b, [
|
248 | "baseUrl",
|
249 | "prepareHeaders",
|
250 | "fetchFn"
|
251 | ]);
|
252 | if (typeof fetch === "undefined" && fetchFn === defaultFetchFn) {
|
253 | console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments.");
|
254 | }
|
255 | return function (_0, _1) { return __async(_this, [_0, _1], function (arg, _e) {
|
256 | var meta, _a2, url, _f, method, _g, headers, _h, body, _j, params, _k, responseHandler, _l, validateStatus, rest, config, _m, isJsonifiable, divider, query, request, requestClone, response, e_1, responseClone, resultData, responseText, handleResponseError_1, e_2;
|
257 | var signal = _e.signal, getState = _e.getState;
|
258 | return __generator(this, function (_o) {
|
259 | switch (_o.label) {
|
260 | case 0:
|
261 | _a2 = typeof arg == "string" ? { url: arg } : arg, url = _a2.url, _f = _a2.method, method = _f === void 0 ? "GET" : _f, _g = _a2.headers, headers = _g === void 0 ? new Headers({}) : _g, _h = _a2.body, body = _h === void 0 ? void 0 : _h, _j = _a2.params, params = _j === void 0 ? void 0 : _j, _k = _a2.responseHandler, responseHandler = _k === void 0 ? "json" : _k, _l = _a2.validateStatus, validateStatus = _l === void 0 ? defaultValidateStatus : _l, rest = __objRest(_a2, [
|
262 | "url",
|
263 | "method",
|
264 | "headers",
|
265 | "body",
|
266 | "params",
|
267 | "responseHandler",
|
268 | "validateStatus"
|
269 | ]);
|
270 | config = __spreadValues(__spreadProps(__spreadValues({}, baseFetchOptions), {
|
271 | method: method,
|
272 | signal: signal,
|
273 | body: body
|
274 | }), rest);
|
275 | _m = config;
|
276 | return [4 , prepareHeaders(new Headers(stripUndefined(headers)), { getState: getState })];
|
277 | case 1:
|
278 | _m.headers = _o.sent();
|
279 | isJsonifiable = function (body2) { return typeof body2 === "object" && ((0, import_toolkit2.isPlainObject)(body2) || Array.isArray(body2) || typeof body2.toJSON === "function"); };
|
280 | if (!config.headers.has("content-type") && isJsonifiable(body)) {
|
281 | config.headers.set("content-type", "application/json");
|
282 | }
|
283 | if (body && isJsonContentType(config.headers)) {
|
284 | config.body = JSON.stringify(body);
|
285 | }
|
286 | if (params) {
|
287 | divider = ~url.indexOf("?") ? "&" : "?";
|
288 | query = new URLSearchParams(stripUndefined(params));
|
289 | url += divider + query;
|
290 | }
|
291 | url = joinUrls(baseUrl, url);
|
292 | request = new Request(url, config);
|
293 | requestClone = request.clone();
|
294 | meta = { request: requestClone };
|
295 | _o.label = 2;
|
296 | case 2:
|
297 | _o.trys.push([2, 4, , 5]);
|
298 | return [4 , fetchFn(request)];
|
299 | case 3:
|
300 | response = _o.sent();
|
301 | return [3 , 5];
|
302 | case 4:
|
303 | e_1 = _o.sent();
|
304 | return [2 , { error: { status: "FETCH_ERROR", error: String(e_1) }, meta: meta }];
|
305 | case 5:
|
306 | responseClone = response.clone();
|
307 | meta.response = responseClone;
|
308 | responseText = "";
|
309 | _o.label = 6;
|
310 | case 6:
|
311 | _o.trys.push([6, 8, , 9]);
|
312 | return [4 , Promise.all([
|
313 | handleResponse(response, responseHandler).then(function (r) { return resultData = r; }, function (e) { return handleResponseError_1 = e; }),
|
314 | responseClone.text().then(function (r) { return responseText = r; }, function () {
|
315 | })
|
316 | ])];
|
317 | case 7:
|
318 | _o.sent();
|
319 | if (handleResponseError_1)
|
320 | throw handleResponseError_1;
|
321 | return [3 , 9];
|
322 | case 8:
|
323 | e_2 = _o.sent();
|
324 | return [2 , {
|
325 | error: {
|
326 | status: "PARSING_ERROR",
|
327 | originalStatus: response.status,
|
328 | data: responseText,
|
329 | error: String(e_2)
|
330 | },
|
331 | meta: meta
|
332 | }];
|
333 | case 9: return [2 , validateStatus(response, resultData) ? {
|
334 | data: resultData,
|
335 | meta: meta
|
336 | } : {
|
337 | error: {
|
338 | status: response.status,
|
339 | data: resultData
|
340 | },
|
341 | meta: meta
|
342 | }];
|
343 | }
|
344 | });
|
345 | }); };
|
346 | }
|
347 |
|
348 | var HandledError = (function () {
|
349 | function HandledError(value, meta) {
|
350 | if (meta === void 0) { meta = void 0; }
|
351 | this.value = value;
|
352 | this.meta = meta;
|
353 | }
|
354 | return HandledError;
|
355 | }());
|
356 |
|
357 | function defaultBackoff(attempt, maxRetries) {
|
358 | if (attempt === void 0) { attempt = 0; }
|
359 | if (maxRetries === void 0) { maxRetries = 5; }
|
360 | return __async(this, null, function () {
|
361 | var attempts, timeout;
|
362 | return __generator(this, function (_e) {
|
363 | switch (_e.label) {
|
364 | case 0:
|
365 | attempts = Math.min(attempt, maxRetries);
|
366 | timeout = ~~((Math.random() + 0.4) * (300 << attempts));
|
367 | return [4 , new Promise(function (resolve) { return setTimeout(function (res) { return resolve(res); }, timeout); })];
|
368 | case 1:
|
369 | _e.sent();
|
370 | return [2 ];
|
371 | }
|
372 | });
|
373 | });
|
374 | }
|
375 | function fail(e) {
|
376 | throw Object.assign(new HandledError({ error: e }), {
|
377 | throwImmediately: true
|
378 | });
|
379 | }
|
380 | var retryWithBackoff = function (baseQuery, defaultOptions) { return function (args, api, extraOptions) { return __async(void 0, null, function () {
|
381 | var options, retry2, result, e_3;
|
382 | return __generator(this, function (_e) {
|
383 | switch (_e.label) {
|
384 | case 0:
|
385 | options = __spreadValues(__spreadValues({
|
386 | maxRetries: 5,
|
387 | backoff: defaultBackoff
|
388 | }, defaultOptions), extraOptions);
|
389 | retry2 = 0;
|
390 | _e.label = 1;
|
391 | case 1:
|
392 | if (!true) return [3 , 7];
|
393 | _e.label = 2;
|
394 | case 2:
|
395 | _e.trys.push([2, 4, , 6]);
|
396 | return [4 , baseQuery(args, api, extraOptions)];
|
397 | case 3:
|
398 | result = _e.sent();
|
399 | if (result.error) {
|
400 | throw new HandledError(result);
|
401 | }
|
402 | return [2 , result];
|
403 | case 4:
|
404 | e_3 = _e.sent();
|
405 | retry2++;
|
406 | if (e_3.throwImmediately || retry2 > options.maxRetries) {
|
407 | if (e_3 instanceof HandledError) {
|
408 | return [2 , e_3.value];
|
409 | }
|
410 | throw e_3;
|
411 | }
|
412 | return [4 , options.backoff(retry2, options.maxRetries)];
|
413 | case 5:
|
414 | _e.sent();
|
415 | return [3 , 6];
|
416 | case 6: return [3 , 1];
|
417 | case 7: return [2 ];
|
418 | }
|
419 | });
|
420 | }); }; };
|
421 | var retry = Object.assign(retryWithBackoff, { fail: fail });
|
422 |
|
423 | var import_toolkit3 = __toModule(require("@reduxjs/toolkit"));
|
424 | var onFocus = (0, import_toolkit3.createAction)("__rtkq/focused");
|
425 | var onFocusLost = (0, import_toolkit3.createAction)("__rtkq/unfocused");
|
426 | var onOnline = (0, import_toolkit3.createAction)("__rtkq/online");
|
427 | var onOffline = (0, import_toolkit3.createAction)("__rtkq/offline");
|
428 | var initialized = false;
|
429 | function setupListeners(dispatch, customHandler) {
|
430 | function defaultHandler() {
|
431 | var handleFocus = function () { return dispatch(onFocus()); };
|
432 | var handleFocusLost = function () { return dispatch(onFocusLost()); };
|
433 | var handleOnline = function () { return dispatch(onOnline()); };
|
434 | var handleOffline = function () { return dispatch(onOffline()); };
|
435 | var handleVisibilityChange = function () {
|
436 | if (window.document.visibilityState === "visible") {
|
437 | handleFocus();
|
438 | }
|
439 | else {
|
440 | handleFocusLost();
|
441 | }
|
442 | };
|
443 | if (!initialized) {
|
444 | if (typeof window !== "undefined" && window.addEventListener) {
|
445 | window.addEventListener("visibilitychange", handleVisibilityChange, false);
|
446 | window.addEventListener("focus", handleFocus, false);
|
447 | window.addEventListener("online", handleOnline, false);
|
448 | window.addEventListener("offline", handleOffline, false);
|
449 | initialized = true;
|
450 | }
|
451 | }
|
452 | var unsubscribe = function () {
|
453 | window.removeEventListener("focus", handleFocus);
|
454 | window.removeEventListener("visibilitychange", handleVisibilityChange);
|
455 | window.removeEventListener("online", handleOnline);
|
456 | window.removeEventListener("offline", handleOffline);
|
457 | initialized = false;
|
458 | };
|
459 | return unsubscribe;
|
460 | }
|
461 | return customHandler ? customHandler(dispatch, { onFocus: onFocus, onFocusLost: onFocusLost, onOffline: onOffline, onOnline: onOnline }) : defaultHandler();
|
462 | }
|
463 |
|
464 | var import_toolkit4 = __toModule(require("@reduxjs/toolkit"));
|
465 | var skipToken = Symbol.for("RTKQ/skipToken");
|
466 | var skipSelector = skipToken;
|
467 | var initialSubState = {
|
468 | status: QueryStatus.uninitialized
|
469 | };
|
470 | var defaultQuerySubState = (0, import_toolkit4.createNextState)(initialSubState, function () {
|
471 | });
|
472 | var defaultMutationSubState = (0, import_toolkit4.createNextState)(initialSubState, function () {
|
473 | });
|
474 | function buildSelectors(_e) {
|
475 | var serializeQueryArgs = _e.serializeQueryArgs, reducerPath = _e.reducerPath;
|
476 | return { buildQuerySelector: buildQuerySelector, buildMutationSelector: buildMutationSelector };
|
477 | function withRequestFlags(substate) {
|
478 | return __spreadValues(__spreadValues({}, substate), getRequestStatusFlags(substate.status));
|
479 | }
|
480 | function selectInternalState(rootState) {
|
481 | var state = rootState[reducerPath];
|
482 | if (true) {
|
483 | if (!state) {
|
484 | if (selectInternalState.triggered)
|
485 | return state;
|
486 | selectInternalState.triggered = true;
|
487 | console.error("Error: No data found at `state." + reducerPath + "`. Did you forget to add the reducer to the store?");
|
488 | }
|
489 | }
|
490 | return state;
|
491 | }
|
492 | function buildQuerySelector(endpointName, endpointDefinition) {
|
493 | return function (queryArgs) {
|
494 | var selectQuerySubState = (0, import_toolkit4.createSelector)(selectInternalState, function (internalState) {
|
495 | var _a, _b;
|
496 | return (_b = queryArgs === skipToken ? void 0 : (_a = internalState == null ? void 0 : internalState.queries) == null ? void 0 : _a[serializeQueryArgs({
|
497 | queryArgs: queryArgs,
|
498 | endpointDefinition: endpointDefinition,
|
499 | endpointName: endpointName
|
500 | })]) != null ? _b : defaultQuerySubState;
|
501 | });
|
502 | return (0, import_toolkit4.createSelector)(selectQuerySubState, withRequestFlags);
|
503 | };
|
504 | }
|
505 | function buildMutationSelector() {
|
506 | return function (mutationId) {
|
507 | var selectMutationSubstate = (0, import_toolkit4.createSelector)(selectInternalState, function (internalState) {
|
508 | var _a, _b;
|
509 | return (_b = mutationId === skipToken ? void 0 : (_a = internalState == null ? void 0 : internalState.mutations) == null ? void 0 : _a[mutationId]) != null ? _b : defaultMutationSubState;
|
510 | });
|
511 | return (0, import_toolkit4.createSelector)(selectMutationSubstate, withRequestFlags);
|
512 | };
|
513 | }
|
514 | }
|
515 |
|
516 | var import_toolkit5 = __toModule(require("@reduxjs/toolkit"));
|
517 | var defaultSerializeQueryArgs = function (_e) {
|
518 | var endpointName = _e.endpointName, queryArgs = _e.queryArgs;
|
519 | return endpointName + "(" + JSON.stringify(queryArgs, function (key, value) { return (0, import_toolkit5.isPlainObject)(value) ? Object.keys(value).sort().reduce(function (acc, key2) {
|
520 | acc[key2] = value[key2];
|
521 | return acc;
|
522 | }, {}) : value; }) + ")";
|
523 | };
|
524 |
|
525 | var DefinitionType;
|
526 | (function (DefinitionType2) {
|
527 | DefinitionType2["query"] = "query";
|
528 | DefinitionType2["mutation"] = "mutation";
|
529 | })(DefinitionType || (DefinitionType = {}));
|
530 | function isQueryDefinition(e) {
|
531 | return e.type === DefinitionType.query;
|
532 | }
|
533 | function isMutationDefinition(e) {
|
534 | return e.type === DefinitionType.mutation;
|
535 | }
|
536 | function calculateProvidedBy(description, result, error, queryArg, assertTagTypes) {
|
537 | if (isFunction(description)) {
|
538 | return description(result, error, queryArg).map(expandTagDescription).map(assertTagTypes);
|
539 | }
|
540 | if (Array.isArray(description)) {
|
541 | return description.map(expandTagDescription).map(assertTagTypes);
|
542 | }
|
543 | return [];
|
544 | }
|
545 | function isFunction(t) {
|
546 | return typeof t === "function";
|
547 | }
|
548 | function expandTagDescription(description) {
|
549 | return typeof description === "string" ? { type: description } : description;
|
550 | }
|
551 |
|
552 | var import_toolkit6 = __toModule(require("@reduxjs/toolkit"));
|
553 | function buildCreateApi() {
|
554 | var modules = [];
|
555 | for (var _i = 0; _i < arguments.length; _i++) {
|
556 | modules[_i] = arguments[_i];
|
557 | }
|
558 | return function baseCreateApi(options) {
|
559 | var optionsWithDefaults = __spreadProps(__spreadValues({
|
560 | reducerPath: "api",
|
561 | serializeQueryArgs: defaultSerializeQueryArgs,
|
562 | keepUnusedDataFor: 60,
|
563 | refetchOnMountOrArgChange: false,
|
564 | refetchOnFocus: false,
|
565 | refetchOnReconnect: false
|
566 | }, options), {
|
567 | tagTypes: __spreadArray([], options.tagTypes || [])
|
568 | });
|
569 | var context = {
|
570 | endpointDefinitions: {},
|
571 | batch: function (fn) {
|
572 | fn();
|
573 | },
|
574 | apiUid: (0, import_toolkit6.nanoid)()
|
575 | };
|
576 | var api = {
|
577 | injectEndpoints: injectEndpoints,
|
578 | enhanceEndpoints: function (_e) {
|
579 | var addTagTypes = _e.addTagTypes, endpoints = _e.endpoints;
|
580 | if (addTagTypes) {
|
581 | for (var _i = 0, addTagTypes_1 = addTagTypes; _i < addTagTypes_1.length; _i++) {
|
582 | var eT = addTagTypes_1[_i];
|
583 | if (!optionsWithDefaults.tagTypes.includes(eT)) {
|
584 | optionsWithDefaults.tagTypes.push(eT);
|
585 | }
|
586 | }
|
587 | }
|
588 | if (endpoints) {
|
589 | for (var _f = 0, _g = Object.entries(endpoints); _f < _g.length; _f++) {
|
590 | var _h = _g[_f], endpointName = _h[0], partialDefinition = _h[1];
|
591 | if (typeof partialDefinition === "function") {
|
592 | partialDefinition(context.endpointDefinitions[endpointName]);
|
593 | }
|
594 | Object.assign(context.endpointDefinitions[endpointName] || {}, partialDefinition);
|
595 | }
|
596 | }
|
597 | return api;
|
598 | }
|
599 | };
|
600 | var initializedModules = modules.map(function (m) { return m.init(api, optionsWithDefaults, context); });
|
601 | function injectEndpoints(inject) {
|
602 | var evaluatedEndpoints = inject.endpoints({
|
603 | query: function (x) { return __spreadProps(__spreadValues({}, x), { type: DefinitionType.query }); },
|
604 | mutation: function (x) { return __spreadProps(__spreadValues({}, x), { type: DefinitionType.mutation }); }
|
605 | });
|
606 | for (var _i = 0, _e = Object.entries(evaluatedEndpoints); _i < _e.length; _i++) {
|
607 | var _f = _e[_i], endpointName = _f[0], definition = _f[1];
|
608 | if (!inject.overrideExisting && endpointName in context.endpointDefinitions) {
|
609 | if (typeof process !== "undefined" && true) {
|
610 | console.error("called `injectEndpoints` to override already-existing endpointName " + endpointName + " without specifying `overrideExisting: true`");
|
611 | }
|
612 | continue;
|
613 | }
|
614 | context.endpointDefinitions[endpointName] = definition;
|
615 | for (var _g = 0, initializedModules_1 = initializedModules; _g < initializedModules_1.length; _g++) {
|
616 | var m = initializedModules_1[_g];
|
617 | m.injectEndpoint(endpointName, definition);
|
618 | }
|
619 | }
|
620 | return api;
|
621 | }
|
622 | return api.injectEndpoints({ endpoints: options.endpoints });
|
623 | };
|
624 | }
|
625 |
|
626 | function fakeBaseQuery() {
|
627 | return function () {
|
628 | throw new Error("When using `fakeBaseQuery`, all queries & mutations must use the `queryFn` definition syntax.");
|
629 | };
|
630 | }
|
631 |
|
632 | var import_toolkit7 = __toModule(require("@reduxjs/toolkit"));
|
633 | var import_immer = __toModule(require("immer"));
|
634 | var import_toolkit8 = __toModule(require("@reduxjs/toolkit"));
|
635 | function defaultTransformResponse(baseQueryReturnValue) {
|
636 | return baseQueryReturnValue;
|
637 | }
|
638 | function buildThunks(_e) {
|
639 | var _this = this;
|
640 | var reducerPath = _e.reducerPath, baseQuery = _e.baseQuery, endpointDefinitions = _e.context.endpointDefinitions, serializeQueryArgs = _e.serializeQueryArgs, api = _e.api;
|
641 | var patchQueryData = function (endpointName, args, patches) { return function (dispatch) {
|
642 | var endpointDefinition = endpointDefinitions[endpointName];
|
643 | dispatch(api.internalActions.queryResultPatched({
|
644 | queryCacheKey: serializeQueryArgs({
|
645 | queryArgs: args,
|
646 | endpointDefinition: endpointDefinition,
|
647 | endpointName: endpointName
|
648 | }),
|
649 | patches: patches
|
650 | }));
|
651 | }; };
|
652 | var updateQueryData = function (endpointName, args, updateRecipe) { return function (dispatch, getState) {
|
653 | var _e, _f;
|
654 | var currentState = api.endpoints[endpointName].select(args)(getState());
|
655 | var ret = {
|
656 | patches: [],
|
657 | inversePatches: [],
|
658 | undo: function () { return dispatch(api.util.patchQueryData(endpointName, args, ret.inversePatches)); }
|
659 | };
|
660 | if (currentState.status === QueryStatus.uninitialized) {
|
661 | return ret;
|
662 | }
|
663 | if ("data" in currentState) {
|
664 | if ((0, import_immer.isDraftable)(currentState.data)) {
|
665 | var _g = (0, import_immer.produceWithPatches)(currentState.data, updateRecipe), patches = _g[1], inversePatches = _g[2];
|
666 | (_e = ret.patches).push.apply(_e, patches);
|
667 | (_f = ret.inversePatches).push.apply(_f, inversePatches);
|
668 | }
|
669 | else {
|
670 | var value = updateRecipe(currentState.data);
|
671 | ret.patches.push({ op: "replace", path: [], value: value });
|
672 | ret.inversePatches.push({
|
673 | op: "replace",
|
674 | path: [],
|
675 | value: currentState.data
|
676 | });
|
677 | }
|
678 | }
|
679 | dispatch(api.util.patchQueryData(endpointName, args, ret.patches));
|
680 | return ret;
|
681 | }; };
|
682 | var executeEndpoint = function (_0, _1) { return __async(_this, [_0, _1], function (arg, _e) {
|
683 | var endpointDefinition, transformResponse, result, baseQueryApi_1, _f, error_1;
|
684 | var signal = _e.signal, rejectWithValue = _e.rejectWithValue, fulfillWithValue = _e.fulfillWithValue, dispatch = _e.dispatch, getState = _e.getState, extra = _e.extra;
|
685 | return __generator(this, function (_g) {
|
686 | switch (_g.label) {
|
687 | case 0:
|
688 | endpointDefinition = endpointDefinitions[arg.endpointName];
|
689 | _g.label = 1;
|
690 | case 1:
|
691 | _g.trys.push([1, 7, , 8]);
|
692 | transformResponse = defaultTransformResponse;
|
693 | result = void 0;
|
694 | baseQueryApi_1 = {
|
695 | signal: signal,
|
696 | dispatch: dispatch,
|
697 | getState: getState,
|
698 | extra: extra
|
699 | };
|
700 | if (!endpointDefinition.query) return [3 , 3];
|
701 | return [4 , baseQuery(endpointDefinition.query(arg.originalArgs), baseQueryApi_1, endpointDefinition.extraOptions)];
|
702 | case 2:
|
703 | result = _g.sent();
|
704 | if (endpointDefinition.transformResponse) {
|
705 | transformResponse = endpointDefinition.transformResponse;
|
706 | }
|
707 | return [3 , 5];
|
708 | case 3: return [4 , endpointDefinition.queryFn(arg.originalArgs, baseQueryApi_1, endpointDefinition.extraOptions, function (arg2) { return baseQuery(arg2, baseQueryApi_1, endpointDefinition.extraOptions); })];
|
709 | case 4:
|
710 | result = _g.sent();
|
711 | _g.label = 5;
|
712 | case 5:
|
713 | if (result.error)
|
714 | throw new HandledError(result.error, result.meta);
|
715 | _f = fulfillWithValue;
|
716 | return [4 , transformResponse(result.data, result.meta)];
|
717 | case 6: return [2 , _f.apply(void 0, [_g.sent(), {
|
718 | fulfilledTimeStamp: Date.now(),
|
719 | baseQueryMeta: result.meta
|
720 | }])];
|
721 | case 7:
|
722 | error_1 = _g.sent();
|
723 | if (error_1 instanceof HandledError) {
|
724 | return [2 , rejectWithValue(error_1.value, { baseQueryMeta: error_1.meta })];
|
725 | }
|
726 | if (typeof process !== "undefined" && true) {
|
727 | console.error("An unhandled error occured processing a request for the endpoint \"" + arg.endpointName + "\".\nIn the case of an unhandled error, no tags will be \"provided\" or \"invalidated\".", error_1);
|
728 | }
|
729 | else {
|
730 | console.error(error_1);
|
731 | }
|
732 | throw error_1;
|
733 | case 8: return [2 ];
|
734 | }
|
735 | });
|
736 | }); };
|
737 | var queryThunk = (0, import_toolkit8.createAsyncThunk)(reducerPath + "/executeQuery", executeEndpoint, {
|
738 | getPendingMeta: function () {
|
739 | return { startedTimeStamp: Date.now() };
|
740 | },
|
741 | condition: function (arg, _e) {
|
742 | var getState = _e.getState;
|
743 | var _a, _b;
|
744 | var state = getState()[reducerPath];
|
745 | var requestState = (_a = state == null ? void 0 : state.queries) == null ? void 0 : _a[arg.queryCacheKey];
|
746 | var baseFetchOnMountOrArgChange = state.config.refetchOnMountOrArgChange;
|
747 | var fulfilledVal = requestState == null ? void 0 : requestState.fulfilledTimeStamp;
|
748 | var refetchVal = (_b = arg.forceRefetch) != null ? _b : arg.subscribe && baseFetchOnMountOrArgChange;
|
749 | if ((requestState == null ? void 0 : requestState.status) === "pending")
|
750 | return false;
|
751 | if (fulfilledVal) {
|
752 | if (refetchVal) {
|
753 | return refetchVal === true || (Number(new Date()) - Number(fulfilledVal)) / 1e3 >= refetchVal;
|
754 | }
|
755 | return false;
|
756 | }
|
757 | return true;
|
758 | },
|
759 | dispatchConditionRejection: true
|
760 | });
|
761 | var mutationThunk = (0, import_toolkit8.createAsyncThunk)(reducerPath + "/executeMutation", executeEndpoint, {
|
762 | getPendingMeta: function () {
|
763 | return { startedTimeStamp: Date.now() };
|
764 | }
|
765 | });
|
766 | var hasTheForce = function (options) { return "force" in options; };
|
767 | var hasMaxAge = function (options) { return "ifOlderThan" in options; };
|
768 | var prefetch = function (endpointName, arg, options) { return function (dispatch, getState) {
|
769 | var force = hasTheForce(options) && options.force;
|
770 | var maxAge = hasMaxAge(options) && options.ifOlderThan;
|
771 | var queryAction = function (force2) {
|
772 | if (force2 === void 0) { force2 = true; }
|
773 | return api.endpoints[endpointName].initiate(arg, { forceRefetch: force2 });
|
774 | };
|
775 | var latestStateValue = api.endpoints[endpointName].select(arg)(getState());
|
776 | if (force) {
|
777 | dispatch(queryAction());
|
778 | }
|
779 | else if (maxAge) {
|
780 | var lastFulfilledTs = latestStateValue == null ? void 0 : latestStateValue.fulfilledTimeStamp;
|
781 | if (!lastFulfilledTs) {
|
782 | dispatch(queryAction());
|
783 | return;
|
784 | }
|
785 | var shouldRetrigger = (Number(new Date()) - Number(new Date(lastFulfilledTs))) / 1e3 >= maxAge;
|
786 | if (shouldRetrigger) {
|
787 | dispatch(queryAction());
|
788 | }
|
789 | }
|
790 | else {
|
791 | dispatch(queryAction(false));
|
792 | }
|
793 | }; };
|
794 | function matchesEndpoint(endpointName) {
|
795 | return function (action) {
|
796 | var _a, _b;
|
797 | return ((_b = (_a = action == null ? void 0 : action.meta) == null ? void 0 : _a.arg) == null ? void 0 : _b.endpointName) === endpointName;
|
798 | };
|
799 | }
|
800 | function buildMatchThunkActions(thunk, endpointName) {
|
801 | return {
|
802 | matchPending: (0, import_toolkit7.isAllOf)((0, import_toolkit7.isPending)(thunk), matchesEndpoint(endpointName)),
|
803 | matchFulfilled: (0, import_toolkit7.isAllOf)((0, import_toolkit7.isFulfilled)(thunk), matchesEndpoint(endpointName)),
|
804 | matchRejected: (0, import_toolkit7.isAllOf)((0, import_toolkit7.isRejected)(thunk), matchesEndpoint(endpointName))
|
805 | };
|
806 | }
|
807 | return {
|
808 | queryThunk: queryThunk,
|
809 | mutationThunk: mutationThunk,
|
810 | prefetch: prefetch,
|
811 | updateQueryData: updateQueryData,
|
812 | patchQueryData: patchQueryData,
|
813 | buildMatchThunkActions: buildMatchThunkActions
|
814 | };
|
815 | }
|
816 | function calculateProvidedByThunk(action, type, endpointDefinitions, assertTagType) {
|
817 | return calculateProvidedBy(endpointDefinitions[action.meta.arg.endpointName][type], (0, import_toolkit7.isFulfilled)(action) ? action.payload : void 0, (0, import_toolkit7.isRejectedWithValue)(action) ? action.payload : void 0, action.meta.arg.originalArgs, assertTagType);
|
818 | }
|
819 |
|
820 | var import_toolkit9 = __toModule(require("@reduxjs/toolkit"));
|
821 | var import_immer2 = __toModule(require("immer"));
|
822 | function updateQuerySubstateIfExists(state, queryCacheKey, update) {
|
823 | var substate = state[queryCacheKey];
|
824 | if (substate) {
|
825 | update(substate);
|
826 | }
|
827 | }
|
828 | function updateMutationSubstateIfExists(state, _e, update) {
|
829 | var requestId = _e.requestId;
|
830 | var substate = state[requestId];
|
831 | if (substate) {
|
832 | update(substate);
|
833 | }
|
834 | }
|
835 | var initialState = {};
|
836 | function buildSlice(_e) {
|
837 | var reducerPath = _e.reducerPath, queryThunk = _e.queryThunk, mutationThunk = _e.mutationThunk, _f = _e.context, definitions = _f.endpointDefinitions, apiUid = _f.apiUid, assertTagType = _e.assertTagType, config = _e.config;
|
838 | var resetApiState = (0, import_toolkit9.createAction)(reducerPath + "/resetApiState");
|
839 | var querySlice = (0, import_toolkit9.createSlice)({
|
840 | name: reducerPath + "/queries",
|
841 | initialState: initialState,
|
842 | reducers: {
|
843 | removeQueryResult: function (draft, _e) {
|
844 | var queryCacheKey = _e.payload.queryCacheKey;
|
845 | delete draft[queryCacheKey];
|
846 | },
|
847 | queryResultPatched: function (draft, _e) {
|
848 | var _f = _e.payload, queryCacheKey = _f.queryCacheKey, patches = _f.patches;
|
849 | updateQuerySubstateIfExists(draft, queryCacheKey, function (substate) {
|
850 | substate.data = (0, import_immer2.applyPatches)(substate.data, patches.concat());
|
851 | });
|
852 | }
|
853 | },
|
854 | extraReducers: function (builder) {
|
855 | builder.addCase(queryThunk.pending, function (draft, _e) {
|
856 | var meta = _e.meta, arg = _e.meta.arg;
|
857 | var _a, _b;
|
858 | if (arg.subscribe) {
|
859 | (_b = draft[_a = arg.queryCacheKey]) != null ? _b : draft[_a] = {
|
860 | status: QueryStatus.uninitialized,
|
861 | endpointName: arg.endpointName
|
862 | };
|
863 | }
|
864 | updateQuerySubstateIfExists(draft, arg.queryCacheKey, function (substate) {
|
865 | substate.status = QueryStatus.pending;
|
866 | substate.requestId = meta.requestId;
|
867 | substate.originalArgs = arg.originalArgs;
|
868 | substate.startedTimeStamp = meta.startedTimeStamp;
|
869 | });
|
870 | }).addCase(queryThunk.fulfilled, function (draft, _e) {
|
871 | var meta = _e.meta, payload = _e.payload;
|
872 | updateQuerySubstateIfExists(draft, meta.arg.queryCacheKey, function (substate) {
|
873 | if (substate.requestId !== meta.requestId)
|
874 | return;
|
875 | substate.status = QueryStatus.fulfilled;
|
876 | substate.data = copyWithStructuralSharing(substate.data, payload);
|
877 | delete substate.error;
|
878 | substate.fulfilledTimeStamp = meta.fulfilledTimeStamp;
|
879 | });
|
880 | }).addCase(queryThunk.rejected, function (draft, _e) {
|
881 | var _f = _e.meta, condition = _f.condition, arg = _f.arg, requestId = _f.requestId, error = _e.error, payload = _e.payload;
|
882 | updateQuerySubstateIfExists(draft, arg.queryCacheKey, function (substate) {
|
883 | if (condition) {
|
884 | }
|
885 | else {
|
886 | if (substate.requestId !== requestId)
|
887 | return;
|
888 | substate.status = QueryStatus.rejected;
|
889 | substate.error = payload != null ? payload : error;
|
890 | }
|
891 | });
|
892 | });
|
893 | }
|
894 | });
|
895 | var mutationSlice = (0, import_toolkit9.createSlice)({
|
896 | name: reducerPath + "/mutations",
|
897 | initialState: initialState,
|
898 | reducers: {
|
899 | unsubscribeMutationResult: function (draft, action) {
|
900 | if (action.payload.requestId in draft) {
|
901 | delete draft[action.payload.requestId];
|
902 | }
|
903 | }
|
904 | },
|
905 | extraReducers: function (builder) {
|
906 | builder.addCase(mutationThunk.pending, function (draft, _e) {
|
907 | var _f = _e.meta, arg = _f.arg, requestId = _f.requestId, startedTimeStamp = _f.startedTimeStamp;
|
908 | if (!arg.track)
|
909 | return;
|
910 | draft[requestId] = {
|
911 | status: QueryStatus.pending,
|
912 | endpointName: arg.endpointName,
|
913 | startedTimeStamp: startedTimeStamp
|
914 | };
|
915 | }).addCase(mutationThunk.fulfilled, function (draft, _e) {
|
916 | var payload = _e.payload, meta = _e.meta, requestId = _e.meta.requestId;
|
917 | if (!meta.arg.track)
|
918 | return;
|
919 | updateMutationSubstateIfExists(draft, { requestId: requestId }, function (substate) {
|
920 | substate.status = QueryStatus.fulfilled;
|
921 | substate.data = payload;
|
922 | substate.fulfilledTimeStamp = meta.fulfilledTimeStamp;
|
923 | });
|
924 | }).addCase(mutationThunk.rejected, function (draft, _e) {
|
925 | var payload = _e.payload, error = _e.error, _f = _e.meta, requestId = _f.requestId, arg = _f.arg;
|
926 | if (!arg.track)
|
927 | return;
|
928 | updateMutationSubstateIfExists(draft, { requestId: requestId }, function (substate) {
|
929 | substate.status = QueryStatus.rejected;
|
930 | substate.error = payload != null ? payload : error;
|
931 | });
|
932 | });
|
933 | }
|
934 | });
|
935 | var invalidationSlice = (0, import_toolkit9.createSlice)({
|
936 | name: reducerPath + "/invalidation",
|
937 | initialState: initialState,
|
938 | reducers: {},
|
939 | extraReducers: function (builder) {
|
940 | builder.addCase(querySlice.actions.removeQueryResult, function (draft, _e) {
|
941 | var queryCacheKey = _e.payload.queryCacheKey;
|
942 | for (var _i = 0, _f = Object.values(draft); _i < _f.length; _i++) {
|
943 | var tagTypeSubscriptions = _f[_i];
|
944 | for (var _g = 0, _h = Object.values(tagTypeSubscriptions); _g < _h.length; _g++) {
|
945 | var idSubscriptions = _h[_g];
|
946 | var foundAt = idSubscriptions.indexOf(queryCacheKey);
|
947 | if (foundAt !== -1) {
|
948 | idSubscriptions.splice(foundAt, 1);
|
949 | }
|
950 | }
|
951 | }
|
952 | }).addMatcher((0, import_toolkit9.isAnyOf)((0, import_toolkit9.isFulfilled)(queryThunk), (0, import_toolkit9.isRejectedWithValue)(queryThunk)), function (draft, action) {
|
953 | var _a, _b, _c, _d;
|
954 | var providedTags = calculateProvidedByThunk(action, "providesTags", definitions, assertTagType);
|
955 | var queryCacheKey = action.meta.arg.queryCacheKey;
|
956 | for (var _i = 0, providedTags_1 = providedTags; _i < providedTags_1.length; _i++) {
|
957 | var _e = providedTags_1[_i], type = _e.type, id = _e.id;
|
958 | var subscribedQueries = (_d = (_b = (_a = draft[type]) != null ? _a : draft[type] = {})[_c = id || "__internal_without_id"]) != null ? _d : _b[_c] = [];
|
959 | var alreadySubscribed = subscribedQueries.includes(queryCacheKey);
|
960 | if (!alreadySubscribed) {
|
961 | subscribedQueries.push(queryCacheKey);
|
962 | }
|
963 | }
|
964 | });
|
965 | }
|
966 | });
|
967 | var subscriptionSlice = (0, import_toolkit9.createSlice)({
|
968 | name: reducerPath + "/subscriptions",
|
969 | initialState: initialState,
|
970 | reducers: {
|
971 | updateSubscriptionOptions: function (draft, _e) {
|
972 | var _f = _e.payload, queryCacheKey = _f.queryCacheKey, requestId = _f.requestId, options = _f.options;
|
973 | var _a;
|
974 | if ((_a = draft == null ? void 0 : draft[queryCacheKey]) == null ? void 0 : _a[requestId]) {
|
975 | draft[queryCacheKey][requestId] = options;
|
976 | }
|
977 | },
|
978 | unsubscribeQueryResult: function (draft, _e) {
|
979 | var _f = _e.payload, queryCacheKey = _f.queryCacheKey, requestId = _f.requestId;
|
980 | if (draft[queryCacheKey]) {
|
981 | delete draft[queryCacheKey][requestId];
|
982 | }
|
983 | }
|
984 | },
|
985 | extraReducers: function (builder) {
|
986 | builder.addCase(querySlice.actions.removeQueryResult, function (draft, _e) {
|
987 | var queryCacheKey = _e.payload.queryCacheKey;
|
988 | delete draft[queryCacheKey];
|
989 | }).addCase(queryThunk.pending, function (draft, _e) {
|
990 | var _f = _e.meta, arg = _f.arg, requestId = _f.requestId;
|
991 | var _a, _b, _c, _d;
|
992 | if (arg.subscribe) {
|
993 | var substate = (_b = draft[_a = arg.queryCacheKey]) != null ? _b : draft[_a] = {};
|
994 | substate[requestId] = (_d = (_c = arg.subscriptionOptions) != null ? _c : substate[requestId]) != null ? _d : {};
|
995 | }
|
996 | }).addCase(queryThunk.rejected, function (draft, _e) {
|
997 | var _f = _e.meta, condition = _f.condition, arg = _f.arg, requestId = _f.requestId, error = _e.error, payload = _e.payload;
|
998 | var _a, _b;
|
999 | var substate = draft[arg.queryCacheKey];
|
1000 | if (condition && arg.subscribe && substate) {
|
1001 | substate[requestId] = (_b = (_a = arg.subscriptionOptions) != null ? _a : substate[requestId]) != null ? _b : {};
|
1002 | }
|
1003 | });
|
1004 | }
|
1005 | });
|
1006 | var configSlice = (0, import_toolkit9.createSlice)({
|
1007 | name: reducerPath + "/config",
|
1008 | initialState: __spreadValues({
|
1009 | online: isOnline(),
|
1010 | focused: isDocumentVisible(),
|
1011 | middlewareRegistered: false
|
1012 | }, config),
|
1013 | reducers: {
|
1014 | middlewareRegistered: function (state, _e) {
|
1015 | var payload = _e.payload;
|
1016 | state.middlewareRegistered = state.middlewareRegistered === "conflict" || apiUid !== payload ? "conflict" : true;
|
1017 | }
|
1018 | },
|
1019 | extraReducers: function (builder) {
|
1020 | builder.addCase(onOnline, function (state) {
|
1021 | state.online = true;
|
1022 | }).addCase(onOffline, function (state) {
|
1023 | state.online = false;
|
1024 | }).addCase(onFocus, function (state) {
|
1025 | state.focused = true;
|
1026 | }).addCase(onFocusLost, function (state) {
|
1027 | state.focused = false;
|
1028 | });
|
1029 | }
|
1030 | });
|
1031 | var combinedReducer = (0, import_toolkit9.combineReducers)({
|
1032 | queries: querySlice.reducer,
|
1033 | mutations: mutationSlice.reducer,
|
1034 | provided: invalidationSlice.reducer,
|
1035 | subscriptions: subscriptionSlice.reducer,
|
1036 | config: configSlice.reducer
|
1037 | });
|
1038 | var reducer = function (state, action) { return combinedReducer(resetApiState.match(action) ? void 0 : state, action); };
|
1039 | var actions = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, configSlice.actions), querySlice.actions), subscriptionSlice.actions), mutationSlice.actions), {
|
1040 | resetApiState: resetApiState
|
1041 | });
|
1042 | return { reducer: reducer, actions: actions };
|
1043 | }
|
1044 |
|
1045 | var import_redux = __toModule(require("redux"));
|
1046 | var import_toolkit13 = __toModule(require("@reduxjs/toolkit"));
|
1047 |
|
1048 | var build = function (_e) {
|
1049 | var reducerPath = _e.reducerPath, api = _e.api, context = _e.context;
|
1050 | var _f = api.internalActions, removeQueryResult = _f.removeQueryResult, unsubscribeQueryResult = _f.unsubscribeQueryResult;
|
1051 | return function (mwApi) {
|
1052 | var currentRemovalTimeouts = {};
|
1053 | return function (next) { return function (action) {
|
1054 | var _a, _b;
|
1055 | var result = next(action);
|
1056 | if (unsubscribeQueryResult.match(action)) {
|
1057 | var state = mwApi.getState()[reducerPath];
|
1058 | var queryCacheKey = action.payload.queryCacheKey;
|
1059 | var endpointDefinition = context.endpointDefinitions[(_a = state.queries[queryCacheKey]) == null ? void 0 : _a.endpointName];
|
1060 | handleUnsubscribe(queryCacheKey, mwApi, (_b = endpointDefinition == null ? void 0 : endpointDefinition.keepUnusedDataFor) != null ? _b : state.config.keepUnusedDataFor);
|
1061 | }
|
1062 | if (api.util.resetApiState.match(action)) {
|
1063 | for (var _i = 0, _e = Object.entries(currentRemovalTimeouts); _i < _e.length; _i++) {
|
1064 | var _f = _e[_i], key = _f[0], timeout = _f[1];
|
1065 | if (timeout)
|
1066 | clearTimeout(timeout);
|
1067 | delete currentRemovalTimeouts[key];
|
1068 | }
|
1069 | }
|
1070 | return result;
|
1071 | }; };
|
1072 | function handleUnsubscribe(queryCacheKey, api2, keepUnusedDataFor) {
|
1073 | var currentTimeout = currentRemovalTimeouts[queryCacheKey];
|
1074 | if (currentTimeout) {
|
1075 | clearTimeout(currentTimeout);
|
1076 | }
|
1077 | currentRemovalTimeouts[queryCacheKey] = setTimeout(function () {
|
1078 | var subscriptions = api2.getState()[reducerPath].subscriptions[queryCacheKey];
|
1079 | if (!subscriptions || Object.keys(subscriptions).length === 0) {
|
1080 | api2.dispatch(removeQueryResult({ queryCacheKey: queryCacheKey }));
|
1081 | }
|
1082 | delete currentRemovalTimeouts[queryCacheKey];
|
1083 | }, keepUnusedDataFor * 1e3);
|
1084 | }
|
1085 | };
|
1086 | };
|
1087 |
|
1088 | var import_toolkit10 = __toModule(require("@reduxjs/toolkit"));
|
1089 | var build2 = function (_e) {
|
1090 | var reducerPath = _e.reducerPath, context = _e.context, endpointDefinitions = _e.context.endpointDefinitions, mutationThunk = _e.mutationThunk, api = _e.api, assertTagType = _e.assertTagType, refetchQuery = _e.refetchQuery;
|
1091 | var removeQueryResult = api.internalActions.removeQueryResult;
|
1092 | return function (mwApi) { return function (next) { return function (action) {
|
1093 | var result = next(action);
|
1094 | if ((0, import_toolkit10.isAnyOf)((0, import_toolkit10.isFulfilled)(mutationThunk), (0, import_toolkit10.isRejectedWithValue)(mutationThunk))(action)) {
|
1095 | invalidateTags(calculateProvidedByThunk(action, "invalidatesTags", endpointDefinitions, assertTagType), mwApi);
|
1096 | }
|
1097 | if (api.util.invalidateTags.match(action)) {
|
1098 | invalidateTags(calculateProvidedBy(action.payload, void 0, void 0, void 0, assertTagType), mwApi);
|
1099 | }
|
1100 | return result;
|
1101 | }; }; };
|
1102 | function invalidateTags(tags, api2) {
|
1103 | var _a;
|
1104 | var state = api2.getState()[reducerPath];
|
1105 | var toInvalidate = new Set();
|
1106 | for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
|
1107 | var tag = tags_1[_i];
|
1108 | var provided = state.provided[tag.type];
|
1109 | if (!provided) {
|
1110 | continue;
|
1111 | }
|
1112 | var invalidateSubscriptions = (_a = tag.id !== void 0 ? provided[tag.id] : flatten(Object.values(provided))) != null ? _a : [];
|
1113 | for (var _e = 0, invalidateSubscriptions_1 = invalidateSubscriptions; _e < invalidateSubscriptions_1.length; _e++) {
|
1114 | var invalidate = invalidateSubscriptions_1[_e];
|
1115 | toInvalidate.add(invalidate);
|
1116 | }
|
1117 | }
|
1118 | context.batch(function () {
|
1119 | var valuesArray = Array.from(toInvalidate.values());
|
1120 | for (var _i = 0, valuesArray_1 = valuesArray; _i < valuesArray_1.length; _i++) {
|
1121 | var queryCacheKey = valuesArray_1[_i];
|
1122 | var querySubState = state.queries[queryCacheKey];
|
1123 | var subscriptionSubState = state.subscriptions[queryCacheKey];
|
1124 | if (querySubState && subscriptionSubState) {
|
1125 | if (Object.keys(subscriptionSubState).length === 0) {
|
1126 | api2.dispatch(removeQueryResult({ queryCacheKey: queryCacheKey }));
|
1127 | }
|
1128 | else if (querySubState.status !== QueryStatus.uninitialized) {
|
1129 | api2.dispatch(refetchQuery(querySubState, queryCacheKey));
|
1130 | }
|
1131 | else {
|
1132 | }
|
1133 | }
|
1134 | }
|
1135 | });
|
1136 | }
|
1137 | };
|
1138 |
|
1139 | var build3 = function (_e) {
|
1140 | var reducerPath = _e.reducerPath, queryThunk = _e.queryThunk, api = _e.api, refetchQuery = _e.refetchQuery;
|
1141 | return function (mwApi) {
|
1142 | var currentPolls = {};
|
1143 | return function (next) { return function (action) {
|
1144 | var result = next(action);
|
1145 | if (api.internalActions.updateSubscriptionOptions.match(action)) {
|
1146 | updatePollingInterval(action.payload, mwApi);
|
1147 | }
|
1148 | if (queryThunk.pending.match(action) || queryThunk.rejected.match(action) && action.meta.condition) {
|
1149 | updatePollingInterval(action.meta.arg, mwApi);
|
1150 | }
|
1151 | if (queryThunk.fulfilled.match(action) || queryThunk.rejected.match(action) && !action.meta.condition) {
|
1152 | startNextPoll(action.meta.arg, mwApi);
|
1153 | }
|
1154 | if (api.util.resetApiState.match(action)) {
|
1155 | clearPolls();
|
1156 | }
|
1157 | return result;
|
1158 | }; };
|
1159 | function startNextPoll(_e, api2) {
|
1160 | var queryCacheKey = _e.queryCacheKey;
|
1161 | var state = api2.getState()[reducerPath];
|
1162 | var querySubState = state.queries[queryCacheKey];
|
1163 | var subscriptions = state.subscriptions[queryCacheKey];
|
1164 | if (!querySubState || querySubState.status === QueryStatus.uninitialized)
|
1165 | return;
|
1166 | var lowestPollingInterval = findLowestPollingInterval(subscriptions);
|
1167 | if (!Number.isFinite(lowestPollingInterval))
|
1168 | return;
|
1169 | var currentPoll = currentPolls[queryCacheKey];
|
1170 | if (currentPoll == null ? void 0 : currentPoll.timeout) {
|
1171 | clearTimeout(currentPoll.timeout);
|
1172 | currentPoll.timeout = void 0;
|
1173 | }
|
1174 | var nextPollTimestamp = Date.now() + lowestPollingInterval;
|
1175 | var currentInterval = currentPolls[queryCacheKey] = {
|
1176 | nextPollTimestamp: nextPollTimestamp,
|
1177 | pollingInterval: lowestPollingInterval,
|
1178 | timeout: setTimeout(function () {
|
1179 | currentInterval.timeout = void 0;
|
1180 | api2.dispatch(refetchQuery(querySubState, queryCacheKey));
|
1181 | }, lowestPollingInterval)
|
1182 | };
|
1183 | }
|
1184 | function updatePollingInterval(_e, api2) {
|
1185 | var queryCacheKey = _e.queryCacheKey;
|
1186 | var state = api2.getState()[reducerPath];
|
1187 | var querySubState = state.queries[queryCacheKey];
|
1188 | var subscriptions = state.subscriptions[queryCacheKey];
|
1189 | if (!querySubState || querySubState.status === QueryStatus.uninitialized) {
|
1190 | return;
|
1191 | }
|
1192 | var lowestPollingInterval = findLowestPollingInterval(subscriptions);
|
1193 | var currentPoll = currentPolls[queryCacheKey];
|
1194 | if (!Number.isFinite(lowestPollingInterval)) {
|
1195 | if (currentPoll == null ? void 0 : currentPoll.timeout) {
|
1196 | clearTimeout(currentPoll.timeout);
|
1197 | }
|
1198 | delete currentPolls[queryCacheKey];
|
1199 | return;
|
1200 | }
|
1201 | var nextPollTimestamp = Date.now() + lowestPollingInterval;
|
1202 | if (!currentPoll || nextPollTimestamp < currentPoll.nextPollTimestamp) {
|
1203 | startNextPoll({ queryCacheKey: queryCacheKey }, api2);
|
1204 | }
|
1205 | }
|
1206 | function clearPolls() {
|
1207 | for (var _i = 0, _e = Object.entries(currentPolls); _i < _e.length; _i++) {
|
1208 | var _f = _e[_i], key = _f[0], poll = _f[1];
|
1209 | if (poll == null ? void 0 : poll.timeout)
|
1210 | clearTimeout(poll.timeout);
|
1211 | delete currentPolls[key];
|
1212 | }
|
1213 | }
|
1214 | };
|
1215 | function findLowestPollingInterval(subscribers) {
|
1216 | if (subscribers === void 0) { subscribers = {}; }
|
1217 | var lowestPollingInterval = Number.POSITIVE_INFINITY;
|
1218 | for (var _i = 0, _e = Object.values(subscribers); _i < _e.length; _i++) {
|
1219 | var subscription = _e[_i];
|
1220 | if (!!subscription.pollingInterval)
|
1221 | lowestPollingInterval = Math.min(subscription.pollingInterval, lowestPollingInterval);
|
1222 | }
|
1223 | return lowestPollingInterval;
|
1224 | }
|
1225 | };
|
1226 |
|
1227 | var build4 = function (_e) {
|
1228 | var reducerPath = _e.reducerPath, context = _e.context, refetchQuery = _e.refetchQuery;
|
1229 | return function (mwApi) { return function (next) { return function (action) {
|
1230 | var result = next(action);
|
1231 | if (onFocus.match(action)) {
|
1232 | refetchValidQueries(mwApi, "refetchOnFocus");
|
1233 | }
|
1234 | if (onOnline.match(action)) {
|
1235 | refetchValidQueries(mwApi, "refetchOnReconnect");
|
1236 | }
|
1237 | return result;
|
1238 | }; }; };
|
1239 | function refetchValidQueries(api, type) {
|
1240 | var state = api.getState()[reducerPath];
|
1241 | var queries = state.queries;
|
1242 | var subscriptions = state.subscriptions;
|
1243 | context.batch(function () {
|
1244 | for (var _i = 0, _e = Object.keys(subscriptions); _i < _e.length; _i++) {
|
1245 | var queryCacheKey = _e[_i];
|
1246 | var querySubState = queries[queryCacheKey];
|
1247 | var subscriptionSubState = subscriptions[queryCacheKey];
|
1248 | if (!subscriptionSubState || !querySubState || querySubState.status === QueryStatus.uninitialized)
|
1249 | return;
|
1250 | var shouldRefetch = Object.values(subscriptionSubState).some(function (sub) { return sub[type] === true; }) || Object.values(subscriptionSubState).every(function (sub) { return sub[type] === void 0; }) && state.config[type];
|
1251 | if (shouldRefetch) {
|
1252 | api.dispatch(refetchQuery(querySubState, queryCacheKey));
|
1253 | }
|
1254 | }
|
1255 | });
|
1256 | }
|
1257 | };
|
1258 |
|
1259 | var import_toolkit11 = __toModule(require("@reduxjs/toolkit"));
|
1260 | var neverResolvedError = new Error("Promise never resolved before cacheEntryRemoved.");
|
1261 | var build5 = function (_e) {
|
1262 | var api = _e.api, reducerPath = _e.reducerPath, context = _e.context, queryThunk = _e.queryThunk, mutationThunk = _e.mutationThunk;
|
1263 | var isQueryThunk = (0, import_toolkit11.isAsyncThunkAction)(queryThunk);
|
1264 | var isMutationThunk = (0, import_toolkit11.isAsyncThunkAction)(mutationThunk);
|
1265 | var isFullfilledThunk = (0, import_toolkit11.isFulfilled)(queryThunk, mutationThunk);
|
1266 | return function (mwApi) {
|
1267 | var lifecycleMap = {};
|
1268 | return function (next) { return function (action) {
|
1269 | var stateBefore = mwApi.getState();
|
1270 | var result = next(action);
|
1271 | var cacheKey = getCacheKey(action);
|
1272 | if (queryThunk.pending.match(action)) {
|
1273 | var oldState = stateBefore[reducerPath].queries[cacheKey];
|
1274 | var state = mwApi.getState()[reducerPath].queries[cacheKey];
|
1275 | if (!oldState && state) {
|
1276 | handleNewKey(action.meta.arg.endpointName, action.meta.arg.originalArgs, cacheKey, mwApi, action.meta.requestId);
|
1277 | }
|
1278 | }
|
1279 | else if (mutationThunk.pending.match(action)) {
|
1280 | var state = mwApi.getState()[reducerPath].mutations[cacheKey];
|
1281 | if (state) {
|
1282 | handleNewKey(action.meta.arg.endpointName, action.meta.arg.originalArgs, cacheKey, mwApi, action.meta.requestId);
|
1283 | }
|
1284 | }
|
1285 | else if (isFullfilledThunk(action)) {
|
1286 | var lifecycle = lifecycleMap[cacheKey];
|
1287 | if (lifecycle == null ? void 0 : lifecycle.valueResolved) {
|
1288 | lifecycle.valueResolved({
|
1289 | data: action.payload,
|
1290 | meta: action.meta.baseQueryMeta
|
1291 | });
|
1292 | delete lifecycle.valueResolved;
|
1293 | }
|
1294 | }
|
1295 | else if (api.internalActions.removeQueryResult.match(action) || api.internalActions.unsubscribeMutationResult.match(action)) {
|
1296 | var lifecycle = lifecycleMap[cacheKey];
|
1297 | if (lifecycle) {
|
1298 | delete lifecycleMap[cacheKey];
|
1299 | lifecycle.cacheEntryRemoved();
|
1300 | }
|
1301 | }
|
1302 | else if (api.util.resetApiState.match(action)) {
|
1303 | for (var _i = 0, _e = Object.entries(lifecycleMap); _i < _e.length; _i++) {
|
1304 | var _f = _e[_i], cacheKey2 = _f[0], lifecycle = _f[1];
|
1305 | delete lifecycleMap[cacheKey2];
|
1306 | lifecycle.cacheEntryRemoved();
|
1307 | }
|
1308 | }
|
1309 | return result;
|
1310 | }; };
|
1311 | function getCacheKey(action) {
|
1312 | if (isQueryThunk(action))
|
1313 | return action.meta.arg.queryCacheKey;
|
1314 | if (isMutationThunk(action))
|
1315 | return action.meta.requestId;
|
1316 | if (api.internalActions.removeQueryResult.match(action))
|
1317 | return action.payload.queryCacheKey;
|
1318 | if (api.internalActions.unsubscribeMutationResult.match(action))
|
1319 | return action.payload.requestId;
|
1320 | return "";
|
1321 | }
|
1322 | function handleNewKey(endpointName, originalArgs, queryCacheKey, mwApi2, requestId) {
|
1323 | var endpointDefinition = context.endpointDefinitions[endpointName];
|
1324 | var onCacheEntryAdded = endpointDefinition == null ? void 0 : endpointDefinition.onCacheEntryAdded;
|
1325 | if (!onCacheEntryAdded)
|
1326 | return;
|
1327 | var lifecycle = {};
|
1328 | var cacheEntryRemoved = new Promise(function (resolve) {
|
1329 | lifecycle.cacheEntryRemoved = resolve;
|
1330 | });
|
1331 | var cacheDataLoaded = Promise.race([
|
1332 | new Promise(function (resolve) {
|
1333 | lifecycle.valueResolved = resolve;
|
1334 | }),
|
1335 | cacheEntryRemoved.then(function () {
|
1336 | throw neverResolvedError;
|
1337 | })
|
1338 | ]);
|
1339 | cacheDataLoaded.catch(function () {
|
1340 | });
|
1341 | lifecycleMap[queryCacheKey] = lifecycle;
|
1342 | var selector = api.endpoints[endpointName].select(endpointDefinition.type === DefinitionType.query ? originalArgs : queryCacheKey);
|
1343 | var extra = mwApi2.dispatch(function (_, __, extra2) { return extra2; });
|
1344 | var lifecycleApi = __spreadProps(__spreadValues({}, mwApi2), {
|
1345 | getCacheEntry: function () { return selector(mwApi2.getState()); },
|
1346 | requestId: requestId,
|
1347 | extra: extra,
|
1348 | updateCachedData: endpointDefinition.type === DefinitionType.query ? function (updateRecipe) { return mwApi2.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)); } : void 0,
|
1349 | cacheDataLoaded: cacheDataLoaded,
|
1350 | cacheEntryRemoved: cacheEntryRemoved
|
1351 | });
|
1352 | var runningHandler = onCacheEntryAdded(originalArgs, lifecycleApi);
|
1353 | Promise.resolve(runningHandler).catch(function (e) {
|
1354 | if (e === neverResolvedError)
|
1355 | return;
|
1356 | throw e;
|
1357 | });
|
1358 | }
|
1359 | };
|
1360 | };
|
1361 |
|
1362 | var import_toolkit12 = __toModule(require("@reduxjs/toolkit"));
|
1363 | var build6 = function (_e) {
|
1364 | var api = _e.api, context = _e.context, queryThunk = _e.queryThunk, mutationThunk = _e.mutationThunk;
|
1365 | var isPendingThunk = (0, import_toolkit12.isPending)(queryThunk, mutationThunk);
|
1366 | var isRejectedThunk = (0, import_toolkit12.isRejected)(queryThunk, mutationThunk);
|
1367 | var isFullfilledThunk = (0, import_toolkit12.isFulfilled)(queryThunk, mutationThunk);
|
1368 | return function (mwApi) {
|
1369 | var lifecycleMap = {};
|
1370 | return function (next) { return function (action) {
|
1371 | var _a, _b, _c;
|
1372 | var result = next(action);
|
1373 | if (isPendingThunk(action)) {
|
1374 | var _e = action.meta, requestId = _e.requestId, _f = _e.arg, endpointName_1 = _f.endpointName, originalArgs_1 = _f.originalArgs;
|
1375 | var endpointDefinition = context.endpointDefinitions[endpointName_1];
|
1376 | var onQueryStarted = endpointDefinition == null ? void 0 : endpointDefinition.onQueryStarted;
|
1377 | if (onQueryStarted) {
|
1378 | var lifecycle_1 = {};
|
1379 | var queryFulfilled = new Promise(function (resolve, reject) {
|
1380 | lifecycle_1.resolve = resolve;
|
1381 | lifecycle_1.reject = reject;
|
1382 | });
|
1383 | queryFulfilled.catch(function () {
|
1384 | });
|
1385 | lifecycleMap[requestId] = lifecycle_1;
|
1386 | var selector_1 = api.endpoints[endpointName_1].select(endpointDefinition.type === DefinitionType.query ? originalArgs_1 : requestId);
|
1387 | var extra = mwApi.dispatch(function (_, __, extra2) { return extra2; });
|
1388 | var lifecycleApi = __spreadProps(__spreadValues({}, mwApi), {
|
1389 | getCacheEntry: function () { return selector_1(mwApi.getState()); },
|
1390 | requestId: requestId,
|
1391 | extra: extra,
|
1392 | updateCachedData: endpointDefinition.type === DefinitionType.query ? function (updateRecipe) { return mwApi.dispatch(api.util.updateQueryData(endpointName_1, originalArgs_1, updateRecipe)); } : void 0,
|
1393 | queryFulfilled: queryFulfilled
|
1394 | });
|
1395 | onQueryStarted(originalArgs_1, lifecycleApi);
|
1396 | }
|
1397 | }
|
1398 | else if (isFullfilledThunk(action)) {
|
1399 | var _g = action.meta, requestId = _g.requestId, baseQueryMeta = _g.baseQueryMeta;
|
1400 | (_a = lifecycleMap[requestId]) == null ? void 0 : _a.resolve({
|
1401 | data: action.payload,
|
1402 | meta: baseQueryMeta
|
1403 | });
|
1404 | delete lifecycleMap[requestId];
|
1405 | }
|
1406 | else if (isRejectedThunk(action)) {
|
1407 | var _h = action.meta, requestId = _h.requestId, rejectedWithValue = _h.rejectedWithValue, baseQueryMeta = _h.baseQueryMeta;
|
1408 | (_c = lifecycleMap[requestId]) == null ? void 0 : _c.reject({
|
1409 | error: (_b = action.payload) != null ? _b : action.error,
|
1410 | isUnhandledError: !rejectedWithValue,
|
1411 | meta: baseQueryMeta
|
1412 | });
|
1413 | delete lifecycleMap[requestId];
|
1414 | }
|
1415 | return result;
|
1416 | }; };
|
1417 | };
|
1418 | };
|
1419 |
|
1420 | var build7 = function (_e) {
|
1421 | var api = _e.api, apiUid = _e.context.apiUid, reducerPath = _e.reducerPath;
|
1422 | return function (mwApi) {
|
1423 | var initialized2 = false;
|
1424 | return function (next) { return function (action) {
|
1425 | var _a, _b;
|
1426 | if (!initialized2) {
|
1427 | initialized2 = true;
|
1428 | mwApi.dispatch(api.internalActions.middlewareRegistered(apiUid));
|
1429 | }
|
1430 | var result = next(action);
|
1431 | if (api.util.resetApiState.match(action)) {
|
1432 | mwApi.dispatch(api.internalActions.middlewareRegistered(apiUid));
|
1433 | }
|
1434 | if (typeof process !== "undefined" && true) {
|
1435 | if (api.internalActions.middlewareRegistered.match(action) && action.payload === apiUid && ((_b = (_a = mwApi.getState()[reducerPath]) == null ? void 0 : _a.config) == null ? void 0 : _b.middlewareRegistered) === "conflict") {
|
1436 | console.warn("There is a mismatch between slice and middleware for the reducerPath \"" + reducerPath + "\".\nYou can only have one api per reducer path, this will lead to crashes in various situations!" + (reducerPath === "api" ? "\nIf you have multiple apis, you *have* to specify the reducerPath option when using createApi!" : ""));
|
1437 | }
|
1438 | }
|
1439 | return result;
|
1440 | }; };
|
1441 | };
|
1442 | };
|
1443 |
|
1444 | function buildMiddleware(input) {
|
1445 | var reducerPath = input.reducerPath, queryThunk = input.queryThunk;
|
1446 | var actions = {
|
1447 | invalidateTags: (0, import_toolkit13.createAction)(reducerPath + "/invalidateTags")
|
1448 | };
|
1449 | var middlewares = [
|
1450 | build7,
|
1451 | build,
|
1452 | build2,
|
1453 | build3,
|
1454 | build4,
|
1455 | build5,
|
1456 | build6
|
1457 | ].map(function (build8) { return build8(__spreadProps(__spreadValues({}, input), {
|
1458 | refetchQuery: refetchQuery
|
1459 | })); });
|
1460 | var middleware = function (mwApi) { return function (next) {
|
1461 | var applied = (0, import_redux.compose).apply(void 0, middlewares.map(function (middleware2) { return middleware2(mwApi); }))(next);
|
1462 | return function (action) {
|
1463 | if (mwApi.getState()[reducerPath]) {
|
1464 | return applied(action);
|
1465 | }
|
1466 | return next(action);
|
1467 | };
|
1468 | }; };
|
1469 | return { middleware: middleware, actions: actions };
|
1470 | function refetchQuery(querySubState, queryCacheKey, override) {
|
1471 | if (override === void 0) { override = {}; }
|
1472 | return queryThunk(__spreadValues({
|
1473 | endpointName: querySubState.endpointName,
|
1474 | originalArgs: querySubState.originalArgs,
|
1475 | subscribe: false,
|
1476 | forceRefetch: true,
|
1477 | queryCacheKey: queryCacheKey
|
1478 | }, override));
|
1479 | }
|
1480 | }
|
1481 |
|
1482 | function buildInitiate(_e) {
|
1483 | var serializeQueryArgs = _e.serializeQueryArgs, queryThunk = _e.queryThunk, mutationThunk = _e.mutationThunk, api = _e.api;
|
1484 | var _f = api.internalActions, unsubscribeQueryResult = _f.unsubscribeQueryResult, unsubscribeMutationResult = _f.unsubscribeMutationResult, updateSubscriptionOptions = _f.updateSubscriptionOptions;
|
1485 | return { buildInitiateQuery: buildInitiateQuery, buildInitiateMutation: buildInitiateMutation };
|
1486 | function middlewareWarning(getState) {
|
1487 | var _a, _b;
|
1488 | if (true) {
|
1489 | if (middlewareWarning.triggered)
|
1490 | return;
|
1491 | var registered = (_b = (_a = getState()[api.reducerPath]) == null ? void 0 : _a.config) == null ? void 0 : _b.middlewareRegistered;
|
1492 | if (registered !== void 0) {
|
1493 | ;
|
1494 | middlewareWarning.triggered = true;
|
1495 | }
|
1496 | if (registered === false) {
|
1497 | console.warn("Warning: Middleware for RTK-Query API at reducerPath \"" + api.reducerPath + "\" has not been added to the store.\nFeatures like automatic cache collection, automatic refetching etc. will not be available.");
|
1498 | }
|
1499 | }
|
1500 | }
|
1501 | function buildInitiateQuery(endpointName, endpointDefinition) {
|
1502 | var queryAction = function (arg, _e) {
|
1503 | var _f = _e === void 0 ? {} : _e, _g = _f.subscribe, subscribe = _g === void 0 ? true : _g, forceRefetch = _f.forceRefetch, subscriptionOptions = _f.subscriptionOptions;
|
1504 | return function (dispatch, getState) {
|
1505 | var queryCacheKey = serializeQueryArgs({
|
1506 | queryArgs: arg,
|
1507 | endpointDefinition: endpointDefinition,
|
1508 | endpointName: endpointName
|
1509 | });
|
1510 | var thunk = queryThunk({
|
1511 | subscribe: subscribe,
|
1512 | forceRefetch: forceRefetch,
|
1513 | subscriptionOptions: subscriptionOptions,
|
1514 | endpointName: endpointName,
|
1515 | originalArgs: arg,
|
1516 | queryCacheKey: queryCacheKey
|
1517 | });
|
1518 | var thunkResult = dispatch(thunk);
|
1519 | middlewareWarning(getState);
|
1520 | var requestId = thunkResult.requestId, abort = thunkResult.abort;
|
1521 | var statePromise = Object.assign(thunkResult.then(function () { return api.endpoints[endpointName].select(arg)(getState()); }), {
|
1522 | arg: arg,
|
1523 | requestId: requestId,
|
1524 | subscriptionOptions: subscriptionOptions,
|
1525 | abort: abort,
|
1526 | refetch: function () {
|
1527 | dispatch(queryAction(arg, { subscribe: false, forceRefetch: true }));
|
1528 | },
|
1529 | unsubscribe: function () {
|
1530 | if (subscribe)
|
1531 | dispatch(unsubscribeQueryResult({
|
1532 | queryCacheKey: queryCacheKey,
|
1533 | requestId: requestId
|
1534 | }));
|
1535 | },
|
1536 | updateSubscriptionOptions: function (options) {
|
1537 | statePromise.subscriptionOptions = options;
|
1538 | dispatch(updateSubscriptionOptions({
|
1539 | endpointName: endpointName,
|
1540 | requestId: requestId,
|
1541 | queryCacheKey: queryCacheKey,
|
1542 | options: options
|
1543 | }));
|
1544 | }
|
1545 | });
|
1546 | return statePromise;
|
1547 | };
|
1548 | };
|
1549 | return queryAction;
|
1550 | }
|
1551 | function buildInitiateMutation(endpointName, definition) {
|
1552 | return function (arg, _e) {
|
1553 | var _f = _e === void 0 ? {} : _e, _g = _f.track, track = _g === void 0 ? true : _g;
|
1554 | return function (dispatch, getState) {
|
1555 | var thunk = mutationThunk({
|
1556 | endpointName: endpointName,
|
1557 | originalArgs: arg,
|
1558 | track: track
|
1559 | });
|
1560 | var thunkResult = dispatch(thunk);
|
1561 | middlewareWarning(getState);
|
1562 | var requestId = thunkResult.requestId, abort = thunkResult.abort;
|
1563 | var returnValuePromise = thunkResult.unwrap().then(function (data) { return ({ data: data }); }).catch(function (error) { return ({ error: error }); });
|
1564 | return Object.assign(returnValuePromise, {
|
1565 | arg: thunkResult.arg,
|
1566 | requestId: requestId,
|
1567 | abort: abort,
|
1568 | unwrap: thunkResult.unwrap,
|
1569 | unsubscribe: function () {
|
1570 | if (track)
|
1571 | dispatch(unsubscribeMutationResult({ requestId: requestId }));
|
1572 | }
|
1573 | });
|
1574 | };
|
1575 | };
|
1576 | }
|
1577 | }
|
1578 |
|
1579 | function assertCast(v) {
|
1580 | }
|
1581 | function safeAssign(target) {
|
1582 | var args = [];
|
1583 | for (var _i = 1; _i < arguments.length; _i++) {
|
1584 | args[_i - 1] = arguments[_i];
|
1585 | }
|
1586 | Object.assign.apply(Object, __spreadArray([target], args));
|
1587 | }
|
1588 |
|
1589 | var import_immer3 = __toModule(require("immer"));
|
1590 | var coreModuleName = Symbol();
|
1591 | var coreModule = function () { return ({
|
1592 | name: coreModuleName,
|
1593 | init: function (api, _e, context) {
|
1594 | var baseQuery = _e.baseQuery, tagTypes = _e.tagTypes, reducerPath = _e.reducerPath, serializeQueryArgs = _e.serializeQueryArgs, keepUnusedDataFor = _e.keepUnusedDataFor, refetchOnMountOrArgChange = _e.refetchOnMountOrArgChange, refetchOnFocus = _e.refetchOnFocus, refetchOnReconnect = _e.refetchOnReconnect;
|
1595 | (0, import_immer3.enablePatches)();
|
1596 | assertCast(serializeQueryArgs);
|
1597 | var assertTagType = function (tag) {
|
1598 | if (typeof process !== "undefined" && true) {
|
1599 | if (!tagTypes.includes(tag.type)) {
|
1600 | console.error("Tag type '" + tag.type + "' was used, but not specified in `tagTypes`!");
|
1601 | }
|
1602 | }
|
1603 | return tag;
|
1604 | };
|
1605 | Object.assign(api, {
|
1606 | reducerPath: reducerPath,
|
1607 | endpoints: {},
|
1608 | internalActions: {
|
1609 | onOnline: onOnline,
|
1610 | onOffline: onOffline,
|
1611 | onFocus: onFocus,
|
1612 | onFocusLost: onFocusLost
|
1613 | },
|
1614 | util: {}
|
1615 | });
|
1616 | var _f = buildThunks({
|
1617 | baseQuery: baseQuery,
|
1618 | reducerPath: reducerPath,
|
1619 | context: context,
|
1620 | api: api,
|
1621 | serializeQueryArgs: serializeQueryArgs
|
1622 | }), queryThunk = _f.queryThunk, mutationThunk = _f.mutationThunk, patchQueryData = _f.patchQueryData, updateQueryData = _f.updateQueryData, prefetch = _f.prefetch, buildMatchThunkActions = _f.buildMatchThunkActions;
|
1623 | var _g = buildSlice({
|
1624 | context: context,
|
1625 | queryThunk: queryThunk,
|
1626 | mutationThunk: mutationThunk,
|
1627 | reducerPath: reducerPath,
|
1628 | assertTagType: assertTagType,
|
1629 | config: {
|
1630 | refetchOnFocus: refetchOnFocus,
|
1631 | refetchOnReconnect: refetchOnReconnect,
|
1632 | refetchOnMountOrArgChange: refetchOnMountOrArgChange,
|
1633 | keepUnusedDataFor: keepUnusedDataFor,
|
1634 | reducerPath: reducerPath
|
1635 | }
|
1636 | }), reducer = _g.reducer, sliceActions = _g.actions;
|
1637 | safeAssign(api.util, {
|
1638 | patchQueryData: patchQueryData,
|
1639 | updateQueryData: updateQueryData,
|
1640 | prefetch: prefetch,
|
1641 | resetApiState: sliceActions.resetApiState
|
1642 | });
|
1643 | safeAssign(api.internalActions, sliceActions);
|
1644 | Object.defineProperty(api.util, "updateQueryResult", {
|
1645 | get: function () {
|
1646 | if (typeof process !== "undefined" && true) {
|
1647 | console.warn("`api.util.updateQueryResult` has been renamed to `api.util.updateQueryData`, please change your code accordingly");
|
1648 | }
|
1649 | return api.util.updateQueryData;
|
1650 | }
|
1651 | });
|
1652 | Object.defineProperty(api.util, "patchQueryResult", {
|
1653 | get: function () {
|
1654 | if (typeof process !== "undefined" && true) {
|
1655 | console.warn("`api.util.patchQueryResult` has been renamed to `api.util.patchQueryData`, please change your code accordingly");
|
1656 | }
|
1657 | return api.util.patchQueryData;
|
1658 | }
|
1659 | });
|
1660 | var _h = buildMiddleware({
|
1661 | reducerPath: reducerPath,
|
1662 | context: context,
|
1663 | queryThunk: queryThunk,
|
1664 | mutationThunk: mutationThunk,
|
1665 | api: api,
|
1666 | assertTagType: assertTagType
|
1667 | }), middleware = _h.middleware, middlewareActions = _h.actions;
|
1668 | safeAssign(api.util, middlewareActions);
|
1669 | safeAssign(api, { reducer: reducer, middleware: middleware });
|
1670 | var _j = buildSelectors({
|
1671 | serializeQueryArgs: serializeQueryArgs,
|
1672 | reducerPath: reducerPath
|
1673 | }), buildQuerySelector = _j.buildQuerySelector, buildMutationSelector = _j.buildMutationSelector;
|
1674 | var _k = buildInitiate({
|
1675 | queryThunk: queryThunk,
|
1676 | mutationThunk: mutationThunk,
|
1677 | api: api,
|
1678 | serializeQueryArgs: serializeQueryArgs
|
1679 | }), buildInitiateQuery = _k.buildInitiateQuery, buildInitiateMutation = _k.buildInitiateMutation;
|
1680 | return {
|
1681 | name: coreModuleName,
|
1682 | injectEndpoint: function (endpointName, definition) {
|
1683 | var _a, _b;
|
1684 | var anyApi = api;
|
1685 | (_b = (_a = anyApi.endpoints)[endpointName]) != null ? _b : _a[endpointName] = {};
|
1686 | if (isQueryDefinition(definition)) {
|
1687 | safeAssign(anyApi.endpoints[endpointName], {
|
1688 | select: buildQuerySelector(endpointName, definition),
|
1689 | initiate: buildInitiateQuery(endpointName, definition)
|
1690 | }, buildMatchThunkActions(queryThunk, endpointName));
|
1691 | }
|
1692 | else if (isMutationDefinition(definition)) {
|
1693 | safeAssign(anyApi.endpoints[endpointName], {
|
1694 | select: buildMutationSelector(),
|
1695 | initiate: buildInitiateMutation(endpointName, definition)
|
1696 | }, buildMatchThunkActions(mutationThunk, endpointName));
|
1697 | }
|
1698 | }
|
1699 | };
|
1700 | }
|
1701 | }); };
|
1702 |
|
1703 | var createApi = buildCreateApi(coreModule());
|
1704 |
|
\ | No newline at end of file |