@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.
|
@@ -10,6 +10,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10
10
|
var _a;
|
|
11
11
|
"use strict";
|
|
12
12
|
const debugLog = (...args) => {
|
|
13
|
+
console.trace(...args);
|
|
13
14
|
};
|
|
14
15
|
class OutboxCoordinator {
|
|
15
16
|
constructor() {
|
|
@@ -72,8 +73,10 @@ var __publicField = (obj, key, value) => {
|
|
|
72
73
|
* dependency from the new request node to that node.
|
|
73
74
|
*/
|
|
74
75
|
addRequest(request2) {
|
|
76
|
+
debugLog("Adding request to outbox:", request2);
|
|
75
77
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
76
78
|
if (request2.payload.blockers.length === 0 || this.graph.size() === 1) {
|
|
79
|
+
debugLog("Request has no dependencies, or there are no other nodes in the graph");
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
82
|
for (const node of this.graph.overallOrder()) {
|
|
@@ -94,6 +97,7 @@ var __publicField = (obj, key, value) => {
|
|
|
94
97
|
* @param request The request to insert at the beginning of the queue.
|
|
95
98
|
*/
|
|
96
99
|
insertRequest(request2) {
|
|
100
|
+
debugLog("Inserting request at the beginning of the queue:", request2);
|
|
97
101
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
98
102
|
for (const node of this.graph.overallOrder()) {
|
|
99
103
|
if (node === request2.payload.uuid)
|
|
@@ -109,6 +113,7 @@ var __publicField = (obj, key, value) => {
|
|
|
109
113
|
* (from the offline store's outbox state) when the app is loaded.
|
|
110
114
|
*/
|
|
111
115
|
sneakRequest(request2) {
|
|
116
|
+
debugLog("Sneaking request into outbox:", request2);
|
|
112
117
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
113
118
|
}
|
|
114
119
|
/**
|
|
@@ -126,6 +131,7 @@ var __publicField = (obj, key, value) => {
|
|
|
126
131
|
minAttemptsNode = node;
|
|
127
132
|
}
|
|
128
133
|
}
|
|
134
|
+
debugLog("Next node:", minAttemptsNode, "with", minAttempts, "attempts");
|
|
129
135
|
return minAttemptsNode;
|
|
130
136
|
}
|
|
131
137
|
/**
|
|
@@ -134,9 +140,11 @@ var __publicField = (obj, key, value) => {
|
|
|
134
140
|
peek() {
|
|
135
141
|
const nextNode = this._getNextNode();
|
|
136
142
|
if (!nextNode) {
|
|
143
|
+
debugLog("In peek: No next node; outbox is empty.");
|
|
137
144
|
return void 0;
|
|
138
145
|
}
|
|
139
146
|
const ret = this.graph.getNodeData(nextNode);
|
|
147
|
+
debugLog("Next node:", nextNode, "with data", ret);
|
|
140
148
|
return ret;
|
|
141
149
|
}
|
|
142
150
|
/**
|
|
@@ -144,6 +152,7 @@ var __publicField = (obj, key, value) => {
|
|
|
144
152
|
* @param uuid The UUID of the request to remove.
|
|
145
153
|
*/
|
|
146
154
|
remove(uuid2) {
|
|
155
|
+
debugLog("Removing request from outbox:", uuid2);
|
|
147
156
|
this.graph.removeNode(uuid2);
|
|
148
157
|
delete this.requestAttemptCounter[uuid2];
|
|
149
158
|
}
|
|
@@ -155,6 +164,7 @@ var __publicField = (obj, key, value) => {
|
|
|
155
164
|
if (nextRequestDetails) {
|
|
156
165
|
this.graph.removeNode(nextRequestDetails.payload.uuid);
|
|
157
166
|
}
|
|
167
|
+
debugLog("Popped request from outbox:", nextRequestDetails);
|
|
158
168
|
return nextRequestDetails;
|
|
159
169
|
}
|
|
160
170
|
/**
|
|
@@ -164,16 +174,20 @@ var __publicField = (obj, key, value) => {
|
|
|
164
174
|
getQueue() {
|
|
165
175
|
const ret = this.graph.overallOrder().map((nodeName) => this.graph.getNodeData(nodeName));
|
|
166
176
|
const nextNode = this._getNextNode();
|
|
177
|
+
debugLog("In getQueue: Next node:", nextNode);
|
|
167
178
|
if (nextNode) {
|
|
168
179
|
const nextRequestDetails = this.graph.getNodeData(nextNode);
|
|
169
180
|
const nextRequestIndex = ret.findIndex(
|
|
170
181
|
(request2) => request2.payload.uuid === nextRequestDetails.payload.uuid
|
|
171
182
|
);
|
|
183
|
+
debugLog("In getQueue: Next request index:", nextRequestIndex, "with data", nextRequestDetails);
|
|
172
184
|
if (nextRequestIndex !== -1) {
|
|
185
|
+
debugLog("In getQueue: Moving next request to the front of the queue");
|
|
173
186
|
ret.splice(nextRequestIndex, 1);
|
|
174
187
|
ret.unshift(nextRequestDetails);
|
|
175
188
|
}
|
|
176
189
|
}
|
|
190
|
+
debugLog("In getQueue: Returning new queue:", ret);
|
|
177
191
|
return ret;
|
|
178
192
|
}
|
|
179
193
|
/**
|
|
@@ -190,6 +204,7 @@ var __publicField = (obj, key, value) => {
|
|
|
190
204
|
const bAttempts = this.requestAttemptCounter[b.payload.uuid] || 0;
|
|
191
205
|
return aAttempts - bAttempts;
|
|
192
206
|
});
|
|
207
|
+
debugLog("In getReady: Ready requests:", ret);
|
|
193
208
|
return ret;
|
|
194
209
|
}
|
|
195
210
|
registerRetry(uuid2) {
|
|
@@ -3296,6 +3311,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3296
3311
|
});
|
|
3297
3312
|
async function performRequest(action, client) {
|
|
3298
3313
|
var _a2;
|
|
3314
|
+
debugLog("Inside performRequest. Action:", action);
|
|
3299
3315
|
async function checkToken() {
|
|
3300
3316
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
3301
3317
|
await client.auth.renewTokens();
|
|
@@ -3303,6 +3319,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3303
3319
|
}
|
|
3304
3320
|
const state = client.store.getState();
|
|
3305
3321
|
if (state.outboxReducer.deletedRequests.includes(action.payload.uuid)) {
|
|
3322
|
+
debugLog("Request was marked for deletion; throwing error.");
|
|
3306
3323
|
throw new Error("Request was marked for deletion");
|
|
3307
3324
|
}
|
|
3308
3325
|
await checkToken();
|
|
@@ -3380,6 +3397,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3380
3397
|
debugLog("Sending request:", requestDetails, "with params:", queryParams);
|
|
3381
3398
|
return await requestToSend.query(queryParams);
|
|
3382
3399
|
} catch (error) {
|
|
3400
|
+
debugLog("Request failed:", error);
|
|
3383
3401
|
console.error(error);
|
|
3384
3402
|
const originalError = error;
|
|
3385
3403
|
if (originalError.status === 401) {
|
|
@@ -3401,6 +3419,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3401
3419
|
}
|
|
3402
3420
|
}
|
|
3403
3421
|
const apiErrorMessage = (_a2 = originalError.body) == null ? void 0 : _a2.error;
|
|
3422
|
+
debugLog("API error message:", apiErrorMessage);
|
|
3404
3423
|
throw new APIError(
|
|
3405
3424
|
typeof apiErrorMessage === "string" ? apiErrorMessage : (
|
|
3406
3425
|
// TODO: Error codes for all APIErrors.
|
|
@@ -3453,8 +3472,11 @@ var __publicField = (obj, key, value) => {
|
|
|
3453
3472
|
} else {
|
|
3454
3473
|
console.debug(`All middleware finished with ${this.constructor.name}, performing request:`, action);
|
|
3455
3474
|
const baseUrl = action.meta.offline.effect.BASE_URL;
|
|
3475
|
+
debugLog("Base URL:", baseUrl);
|
|
3456
3476
|
if (!exports2.clientStore)
|
|
3457
3477
|
throw new Error("Client store not set");
|
|
3478
|
+
debugLog("Client store is set");
|
|
3479
|
+
debugLog("Performing request:", action);
|
|
3458
3480
|
return performRequest(action, makeClient(baseUrl, exports2.clientStore));
|
|
3459
3481
|
}
|
|
3460
3482
|
}
|