@overmap-ai/core 1.0.16-fix-misc-issues.2 → 1.0.16-fix-misc-issues.4
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
|
/**
|
|
@@ -182,6 +192,7 @@ class OutboxCoordinator {
|
|
|
182
192
|
(request2) => request2.payload.uuid === nextRequestDetails.payload.uuid
|
|
183
193
|
);
|
|
184
194
|
if (nextRequestIndex !== -1) {
|
|
195
|
+
debugLog("In getQueue: Moving next request to the front of the queue");
|
|
185
196
|
ret.splice(nextRequestIndex, 1);
|
|
186
197
|
ret.unshift(nextRequestDetails);
|
|
187
198
|
}
|
|
@@ -202,6 +213,7 @@ class OutboxCoordinator {
|
|
|
202
213
|
const bAttempts = this.requestAttemptCounter[b.payload.uuid] || 0;
|
|
203
214
|
return aAttempts - bAttempts;
|
|
204
215
|
});
|
|
216
|
+
debugLog("In getReady: Ready requests:", ret);
|
|
205
217
|
return ret;
|
|
206
218
|
}
|
|
207
219
|
registerRetry(uuid) {
|
|
@@ -3308,6 +3320,7 @@ const defaultStore = configureStore({
|
|
|
3308
3320
|
});
|
|
3309
3321
|
async function performRequest(action, client) {
|
|
3310
3322
|
var _a2;
|
|
3323
|
+
debugLog("Inside performRequest. Action:", action);
|
|
3311
3324
|
async function checkToken() {
|
|
3312
3325
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
3313
3326
|
await client.auth.renewTokens();
|
|
@@ -3315,6 +3328,7 @@ async function performRequest(action, client) {
|
|
|
3315
3328
|
}
|
|
3316
3329
|
const state = client.store.getState();
|
|
3317
3330
|
if (state.outboxReducer.deletedRequests.includes(action.payload.uuid)) {
|
|
3331
|
+
debugLog("Request was marked for deletion; throwing error.");
|
|
3318
3332
|
throw new Error("Request was marked for deletion");
|
|
3319
3333
|
}
|
|
3320
3334
|
await checkToken();
|
|
@@ -3332,9 +3346,11 @@ async function performRequest(action, client) {
|
|
|
3332
3346
|
const file = attachmentHash ? await client.files.fetchCache(attachmentHash) : void 0;
|
|
3333
3347
|
const accessToken = selectAccessToken(state);
|
|
3334
3348
|
if (attachmentHash && !file) {
|
|
3349
|
+
debugLog("Cannot upload uncached attachment:", attachmentHash);
|
|
3335
3350
|
throw new Error(`Cannot upload file ${attachmentHash} because it's not cached.`);
|
|
3336
3351
|
}
|
|
3337
3352
|
if ((!isExternalUrl || false) && !url.startsWith("http")) {
|
|
3353
|
+
debugLog("Prepending base URL to relative URL:", url);
|
|
3338
3354
|
if (!url.startsWith("/") && !url.startsWith("blob:")) {
|
|
3339
3355
|
url = "/" + url;
|
|
3340
3356
|
}
|
|
@@ -3392,6 +3408,7 @@ async function performRequest(action, client) {
|
|
|
3392
3408
|
debugLog("Sending request:", requestDetails, "with params:", queryParams);
|
|
3393
3409
|
return await requestToSend.query(queryParams);
|
|
3394
3410
|
} catch (error) {
|
|
3411
|
+
debugLog("Request failed:", error);
|
|
3395
3412
|
console.error(error);
|
|
3396
3413
|
const originalError = error;
|
|
3397
3414
|
if (originalError.status === 401) {
|
|
@@ -3413,6 +3430,7 @@ async function performRequest(action, client) {
|
|
|
3413
3430
|
}
|
|
3414
3431
|
}
|
|
3415
3432
|
const apiErrorMessage = (_a2 = originalError.body) == null ? void 0 : _a2.error;
|
|
3433
|
+
debugLog("API error message:", apiErrorMessage);
|
|
3416
3434
|
throw new APIError(
|
|
3417
3435
|
typeof apiErrorMessage === "string" ? apiErrorMessage : (
|
|
3418
3436
|
// TODO: Error codes for all APIErrors.
|
|
@@ -3465,8 +3483,11 @@ class OfflineMiddleware {
|
|
|
3465
3483
|
} else {
|
|
3466
3484
|
console.debug(`All middleware finished with ${this.constructor.name}, performing request:`, action);
|
|
3467
3485
|
const baseUrl = action.meta.offline.effect.BASE_URL;
|
|
3486
|
+
debugLog("Base URL:", baseUrl);
|
|
3468
3487
|
if (!clientStore)
|
|
3469
3488
|
throw new Error("Client store not set");
|
|
3489
|
+
debugLog("Client store is set");
|
|
3490
|
+
debugLog("Performing request:", action);
|
|
3470
3491
|
return performRequest(action, makeClient(baseUrl, clientStore));
|
|
3471
3492
|
}
|
|
3472
3493
|
}
|