@overmap-ai/core 1.0.16-fix-misc-issues.7 → 1.0.16-fix-misc-issues.8
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
|
@@ -21,9 +21,6 @@ import ColorCls from "color";
|
|
|
21
21
|
import jwtDecode from "jwt-decode";
|
|
22
22
|
import { RESET_STATE } from "@redux-offline/redux-offline/lib/constants";
|
|
23
23
|
import { openDB } from "idb";
|
|
24
|
-
const debugLog = (...args) => {
|
|
25
|
-
console.trace(...args);
|
|
26
|
-
};
|
|
27
24
|
class OutboxCoordinator {
|
|
28
25
|
constructor() {
|
|
29
26
|
__publicField(this, "graph");
|
|
@@ -85,7 +82,6 @@ class OutboxCoordinator {
|
|
|
85
82
|
* dependency from the new request node to that node.
|
|
86
83
|
*/
|
|
87
84
|
addRequest(request2) {
|
|
88
|
-
debugLog("Adding request to outbox:", request2);
|
|
89
85
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
90
86
|
if (request2.payload.blockers.length === 0 || this.graph.size() === 1) {
|
|
91
87
|
return;
|
|
@@ -95,7 +91,6 @@ class OutboxCoordinator {
|
|
|
95
91
|
continue;
|
|
96
92
|
const details = this.graph.getNodeData(node);
|
|
97
93
|
if (request2.payload.blockers.some((blocker) => details.payload.blocks.includes(blocker))) {
|
|
98
|
-
debugLog("Adding dependency from", request2.payload.uuid, "to", node);
|
|
99
94
|
this._addDependency(request2.payload.uuid, node);
|
|
100
95
|
}
|
|
101
96
|
}
|
|
@@ -108,7 +103,6 @@ class OutboxCoordinator {
|
|
|
108
103
|
* @param request The request to insert at the beginning of the queue.
|
|
109
104
|
*/
|
|
110
105
|
insertRequest(request2) {
|
|
111
|
-
debugLog("Inserting request at the beginning of the queue:", request2);
|
|
112
106
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
113
107
|
for (const node of this.graph.overallOrder()) {
|
|
114
108
|
if (node === request2.payload.uuid)
|
|
@@ -124,7 +118,6 @@ class OutboxCoordinator {
|
|
|
124
118
|
* (from the offline store's outbox state) when the app is loaded.
|
|
125
119
|
*/
|
|
126
120
|
sneakRequest(request2) {
|
|
127
|
-
debugLog("Sneaking request into outbox:", request2);
|
|
128
121
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
129
122
|
}
|
|
130
123
|
/**
|
|
@@ -133,7 +126,7 @@ class OutboxCoordinator {
|
|
|
133
126
|
*/
|
|
134
127
|
_getNextNode() {
|
|
135
128
|
const leafNodes = this.graph.overallOrder(true);
|
|
136
|
-
let minAttempts =
|
|
129
|
+
let minAttempts = Number.MAX_SAFE_INTEGER;
|
|
137
130
|
let minAttemptsNode;
|
|
138
131
|
for (const node of leafNodes) {
|
|
139
132
|
const attempts = this.requestAttemptCounter[node] || 0;
|
|
@@ -142,7 +135,7 @@ class OutboxCoordinator {
|
|
|
142
135
|
minAttemptsNode = node;
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
|
-
|
|
138
|
+
console.debug("Next node with the least attempts:", minAttemptsNode, "with", minAttempts, "attempts");
|
|
146
139
|
return minAttemptsNode;
|
|
147
140
|
}
|
|
148
141
|
/**
|
|
@@ -151,11 +144,9 @@ class OutboxCoordinator {
|
|
|
151
144
|
peek() {
|
|
152
145
|
const nextNode = this._getNextNode();
|
|
153
146
|
if (!nextNode) {
|
|
154
|
-
debugLog("In peek: No next node; outbox is empty.");
|
|
155
147
|
return void 0;
|
|
156
148
|
}
|
|
157
149
|
const ret = this.graph.getNodeData(nextNode);
|
|
158
|
-
debugLog("Next node:", nextNode, "with data", ret);
|
|
159
150
|
return ret;
|
|
160
151
|
}
|
|
161
152
|
/**
|
|
@@ -163,7 +154,6 @@ class OutboxCoordinator {
|
|
|
163
154
|
* @param uuid The UUID of the request to remove.
|
|
164
155
|
*/
|
|
165
156
|
remove(uuid) {
|
|
166
|
-
debugLog("Removing request from outbox:", uuid);
|
|
167
157
|
this.graph.removeNode(uuid);
|
|
168
158
|
delete this.requestAttemptCounter[uuid];
|
|
169
159
|
}
|
|
@@ -175,7 +165,6 @@ class OutboxCoordinator {
|
|
|
175
165
|
if (nextRequestDetails) {
|
|
176
166
|
this.graph.removeNode(nextRequestDetails.payload.uuid);
|
|
177
167
|
}
|
|
178
|
-
debugLog("Popped request from outbox:", nextRequestDetails);
|
|
179
168
|
return nextRequestDetails;
|
|
180
169
|
}
|
|
181
170
|
/**
|
|
@@ -191,7 +180,6 @@ class OutboxCoordinator {
|
|
|
191
180
|
(request2) => request2.payload.uuid === nextRequestDetails.payload.uuid
|
|
192
181
|
);
|
|
193
182
|
if (nextRequestIndex !== -1) {
|
|
194
|
-
debugLog("In getQueue: Moving next request to the front of the queue");
|
|
195
183
|
ret.splice(nextRequestIndex, 1);
|
|
196
184
|
ret.unshift(nextRequestDetails);
|
|
197
185
|
}
|
|
@@ -212,12 +200,10 @@ class OutboxCoordinator {
|
|
|
212
200
|
const bAttempts = this.requestAttemptCounter[b.payload.uuid] || 0;
|
|
213
201
|
return aAttempts - bAttempts;
|
|
214
202
|
});
|
|
215
|
-
debugLog("In getReady: Ready requests:", ret);
|
|
216
203
|
return ret;
|
|
217
204
|
}
|
|
218
205
|
registerRetry(uuid) {
|
|
219
206
|
this.requestAttemptCounter[uuid] = (this.requestAttemptCounter[uuid] || 0) + 1;
|
|
220
|
-
debugLog("Registered retry for request:", uuid, "with", this.requestAttemptCounter[uuid], "attempts");
|
|
221
207
|
}
|
|
222
208
|
}
|
|
223
209
|
class APIError extends Error {
|
|
@@ -3319,7 +3305,6 @@ const defaultStore = configureStore({
|
|
|
3319
3305
|
});
|
|
3320
3306
|
async function performRequest(action, client) {
|
|
3321
3307
|
var _a2;
|
|
3322
|
-
debugLog("Inside performRequest. Action:", action);
|
|
3323
3308
|
async function checkToken() {
|
|
3324
3309
|
console.debug("CHECKING TOKEN");
|
|
3325
3310
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
@@ -3332,7 +3317,6 @@ async function performRequest(action, client) {
|
|
|
3332
3317
|
console.debug("A1");
|
|
3333
3318
|
const state = client.store.getState();
|
|
3334
3319
|
if (state.outboxReducer.deletedRequests.includes(action.payload.uuid)) {
|
|
3335
|
-
debugLog("Request was marked for deletion; throwing error.");
|
|
3336
3320
|
throw new Error("Request was marked for deletion");
|
|
3337
3321
|
}
|
|
3338
3322
|
await checkToken();
|
|
@@ -3352,12 +3336,10 @@ async function performRequest(action, client) {
|
|
|
3352
3336
|
const accessToken = selectAccessToken(state);
|
|
3353
3337
|
console.debug("A");
|
|
3354
3338
|
if (attachmentHash && !file) {
|
|
3355
|
-
debugLog("Cannot upload uncached attachment:", attachmentHash);
|
|
3356
3339
|
throw new Error(`Cannot upload file ${attachmentHash} because it's not cached.`);
|
|
3357
3340
|
}
|
|
3358
3341
|
console.debug("B");
|
|
3359
3342
|
if ((!isExternalUrl || false) && !url.startsWith("http")) {
|
|
3360
|
-
debugLog("Prepending base URL to relative URL:", url);
|
|
3361
3343
|
if (!url.startsWith("/") && !url.startsWith("blob:")) {
|
|
3362
3344
|
url = "/" + url;
|
|
3363
3345
|
}
|
|
@@ -3414,10 +3396,8 @@ async function performRequest(action, client) {
|
|
|
3414
3396
|
}
|
|
3415
3397
|
console.debug("D");
|
|
3416
3398
|
try {
|
|
3417
|
-
debugLog("Sending request:", requestDetails, "with params:", queryParams);
|
|
3418
3399
|
return await requestToSend.query(queryParams);
|
|
3419
3400
|
} catch (error) {
|
|
3420
|
-
debugLog("Request failed:", error);
|
|
3421
3401
|
console.error(error);
|
|
3422
3402
|
const originalError = error;
|
|
3423
3403
|
if (originalError.status === 401) {
|
|
@@ -3439,7 +3419,6 @@ async function performRequest(action, client) {
|
|
|
3439
3419
|
}
|
|
3440
3420
|
}
|
|
3441
3421
|
const apiErrorMessage = (_a2 = originalError.body) == null ? void 0 : _a2.error;
|
|
3442
|
-
debugLog("API error message:", apiErrorMessage);
|
|
3443
3422
|
throw new APIError(
|
|
3444
3423
|
typeof apiErrorMessage === "string" ? apiErrorMessage : (
|
|
3445
3424
|
// TODO: Error codes for all APIErrors.
|
|
@@ -5816,7 +5795,6 @@ export {
|
|
|
5816
5795
|
coordinatesToUrlText,
|
|
5817
5796
|
createOfflineAction,
|
|
5818
5797
|
createPointMarker,
|
|
5819
|
-
debugLog,
|
|
5820
5798
|
defaultBadgeColor,
|
|
5821
5799
|
defaultStore,
|
|
5822
5800
|
deleteComponentType,
|