@overmap-ai/core 1.0.16-fix-misc-issues.2 → 1.0.16-fix-misc-issues.3
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/overmap-core.js
CHANGED
|
@@ -22,6 +22,7 @@ import jwtDecode from "jwt-decode";
|
|
|
22
22
|
import { RESET_STATE } from "@redux-offline/redux-offline/lib/constants";
|
|
23
23
|
import { openDB } from "idb";
|
|
24
24
|
const debugLog = (...args) => {
|
|
25
|
+
console.trace(...args);
|
|
25
26
|
};
|
|
26
27
|
class OutboxCoordinator {
|
|
27
28
|
constructor() {
|
|
@@ -84,8 +85,10 @@ class OutboxCoordinator {
|
|
|
84
85
|
* dependency from the new request node to that node.
|
|
85
86
|
*/
|
|
86
87
|
addRequest(request2) {
|
|
88
|
+
debugLog("Adding request to outbox:", request2);
|
|
87
89
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
88
90
|
if (request2.payload.blockers.length === 0 || this.graph.size() === 1) {
|
|
91
|
+
debugLog("Request has no dependencies, or there are no other nodes in the graph");
|
|
89
92
|
return;
|
|
90
93
|
}
|
|
91
94
|
for (const node of this.graph.overallOrder()) {
|
|
@@ -106,6 +109,7 @@ class OutboxCoordinator {
|
|
|
106
109
|
* @param request The request to insert at the beginning of the queue.
|
|
107
110
|
*/
|
|
108
111
|
insertRequest(request2) {
|
|
112
|
+
debugLog("Inserting request at the beginning of the queue:", request2);
|
|
109
113
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
110
114
|
for (const node of this.graph.overallOrder()) {
|
|
111
115
|
if (node === request2.payload.uuid)
|
|
@@ -121,6 +125,7 @@ class OutboxCoordinator {
|
|
|
121
125
|
* (from the offline store's outbox state) when the app is loaded.
|
|
122
126
|
*/
|
|
123
127
|
sneakRequest(request2) {
|
|
128
|
+
debugLog("Sneaking request into outbox:", request2);
|
|
124
129
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
@@ -138,6 +143,7 @@ class OutboxCoordinator {
|
|
|
138
143
|
minAttemptsNode = node;
|
|
139
144
|
}
|
|
140
145
|
}
|
|
146
|
+
debugLog("Next node:", minAttemptsNode, "with", minAttempts, "attempts");
|
|
141
147
|
return minAttemptsNode;
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
@@ -146,9 +152,11 @@ class OutboxCoordinator {
|
|
|
146
152
|
peek() {
|
|
147
153
|
const nextNode = this._getNextNode();
|
|
148
154
|
if (!nextNode) {
|
|
155
|
+
debugLog("In peek: No next node; outbox is empty.");
|
|
149
156
|
return void 0;
|
|
150
157
|
}
|
|
151
158
|
const ret = this.graph.getNodeData(nextNode);
|
|
159
|
+
debugLog("Next node:", nextNode, "with data", ret);
|
|
152
160
|
return ret;
|
|
153
161
|
}
|
|
154
162
|
/**
|
|
@@ -156,6 +164,7 @@ class OutboxCoordinator {
|
|
|
156
164
|
* @param uuid The UUID of the request to remove.
|
|
157
165
|
*/
|
|
158
166
|
remove(uuid) {
|
|
167
|
+
debugLog("Removing request from outbox:", uuid);
|
|
159
168
|
this.graph.removeNode(uuid);
|
|
160
169
|
delete this.requestAttemptCounter[uuid];
|
|
161
170
|
}
|
|
@@ -167,6 +176,7 @@ class OutboxCoordinator {
|
|
|
167
176
|
if (nextRequestDetails) {
|
|
168
177
|
this.graph.removeNode(nextRequestDetails.payload.uuid);
|
|
169
178
|
}
|
|
179
|
+
debugLog("Popped request from outbox:", nextRequestDetails);
|
|
170
180
|
return nextRequestDetails;
|
|
171
181
|
}
|
|
172
182
|
/**
|
|
@@ -176,16 +186,20 @@ class OutboxCoordinator {
|
|
|
176
186
|
getQueue() {
|
|
177
187
|
const ret = this.graph.overallOrder().map((nodeName) => this.graph.getNodeData(nodeName));
|
|
178
188
|
const nextNode = this._getNextNode();
|
|
189
|
+
debugLog("In getQueue: Next node:", nextNode);
|
|
179
190
|
if (nextNode) {
|
|
180
191
|
const nextRequestDetails = this.graph.getNodeData(nextNode);
|
|
181
192
|
const nextRequestIndex = ret.findIndex(
|
|
182
193
|
(request2) => request2.payload.uuid === nextRequestDetails.payload.uuid
|
|
183
194
|
);
|
|
195
|
+
debugLog("In getQueue: Next request index:", nextRequestIndex, "with data", nextRequestDetails);
|
|
184
196
|
if (nextRequestIndex !== -1) {
|
|
197
|
+
debugLog("In getQueue: Moving next request to the front of the queue");
|
|
185
198
|
ret.splice(nextRequestIndex, 1);
|
|
186
199
|
ret.unshift(nextRequestDetails);
|
|
187
200
|
}
|
|
188
201
|
}
|
|
202
|
+
debugLog("In getQueue: Returning new queue:", ret);
|
|
189
203
|
return ret;
|
|
190
204
|
}
|
|
191
205
|
/**
|
|
@@ -202,6 +216,7 @@ class OutboxCoordinator {
|
|
|
202
216
|
const bAttempts = this.requestAttemptCounter[b.payload.uuid] || 0;
|
|
203
217
|
return aAttempts - bAttempts;
|
|
204
218
|
});
|
|
219
|
+
debugLog("In getReady: Ready requests:", ret);
|
|
205
220
|
return ret;
|
|
206
221
|
}
|
|
207
222
|
registerRetry(uuid) {
|
|
@@ -3308,6 +3323,7 @@ const defaultStore = configureStore({
|
|
|
3308
3323
|
});
|
|
3309
3324
|
async function performRequest(action, client) {
|
|
3310
3325
|
var _a2;
|
|
3326
|
+
debugLog("Inside performRequest. Action:", action);
|
|
3311
3327
|
async function checkToken() {
|
|
3312
3328
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
3313
3329
|
await client.auth.renewTokens();
|
|
@@ -3315,6 +3331,7 @@ async function performRequest(action, client) {
|
|
|
3315
3331
|
}
|
|
3316
3332
|
const state = client.store.getState();
|
|
3317
3333
|
if (state.outboxReducer.deletedRequests.includes(action.payload.uuid)) {
|
|
3334
|
+
debugLog("Request was marked for deletion; throwing error.");
|
|
3318
3335
|
throw new Error("Request was marked for deletion");
|
|
3319
3336
|
}
|
|
3320
3337
|
await checkToken();
|
|
@@ -3392,6 +3409,7 @@ async function performRequest(action, client) {
|
|
|
3392
3409
|
debugLog("Sending request:", requestDetails, "with params:", queryParams);
|
|
3393
3410
|
return await requestToSend.query(queryParams);
|
|
3394
3411
|
} catch (error) {
|
|
3412
|
+
debugLog("Request failed:", error);
|
|
3395
3413
|
console.error(error);
|
|
3396
3414
|
const originalError = error;
|
|
3397
3415
|
if (originalError.status === 401) {
|
|
@@ -3413,6 +3431,7 @@ async function performRequest(action, client) {
|
|
|
3413
3431
|
}
|
|
3414
3432
|
}
|
|
3415
3433
|
const apiErrorMessage = (_a2 = originalError.body) == null ? void 0 : _a2.error;
|
|
3434
|
+
debugLog("API error message:", apiErrorMessage);
|
|
3416
3435
|
throw new APIError(
|
|
3417
3436
|
typeof apiErrorMessage === "string" ? apiErrorMessage : (
|
|
3418
3437
|
// TODO: Error codes for all APIErrors.
|
|
@@ -3465,8 +3484,11 @@ class OfflineMiddleware {
|
|
|
3465
3484
|
} else {
|
|
3466
3485
|
console.debug(`All middleware finished with ${this.constructor.name}, performing request:`, action);
|
|
3467
3486
|
const baseUrl = action.meta.offline.effect.BASE_URL;
|
|
3487
|
+
debugLog("Base URL:", baseUrl);
|
|
3468
3488
|
if (!clientStore)
|
|
3469
3489
|
throw new Error("Client store not set");
|
|
3490
|
+
debugLog("Client store is set");
|
|
3491
|
+
debugLog("Performing request:", action);
|
|
3470
3492
|
return performRequest(action, makeClient(baseUrl, clientStore));
|
|
3471
3493
|
}
|
|
3472
3494
|
}
|