@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.
@@ -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
  /**
@@ -170,6 +180,7 @@ var __publicField = (obj, key, value) => {
170
180
  (request2) => request2.payload.uuid === nextRequestDetails.payload.uuid
171
181
  );
172
182
  if (nextRequestIndex !== -1) {
183
+ debugLog("In getQueue: Moving next request to the front of the queue");
173
184
  ret.splice(nextRequestIndex, 1);
174
185
  ret.unshift(nextRequestDetails);
175
186
  }
@@ -190,6 +201,7 @@ var __publicField = (obj, key, value) => {
190
201
  const bAttempts = this.requestAttemptCounter[b.payload.uuid] || 0;
191
202
  return aAttempts - bAttempts;
192
203
  });
204
+ debugLog("In getReady: Ready requests:", ret);
193
205
  return ret;
194
206
  }
195
207
  registerRetry(uuid2) {
@@ -3296,6 +3308,7 @@ var __publicField = (obj, key, value) => {
3296
3308
  });
3297
3309
  async function performRequest(action, client) {
3298
3310
  var _a2;
3311
+ debugLog("Inside performRequest. Action:", action);
3299
3312
  async function checkToken() {
3300
3313
  if (client.auth.tokenIsExpiringSoon()) {
3301
3314
  await client.auth.renewTokens();
@@ -3303,6 +3316,7 @@ var __publicField = (obj, key, value) => {
3303
3316
  }
3304
3317
  const state = client.store.getState();
3305
3318
  if (state.outboxReducer.deletedRequests.includes(action.payload.uuid)) {
3319
+ debugLog("Request was marked for deletion; throwing error.");
3306
3320
  throw new Error("Request was marked for deletion");
3307
3321
  }
3308
3322
  await checkToken();
@@ -3320,9 +3334,11 @@ var __publicField = (obj, key, value) => {
3320
3334
  const file = attachmentHash ? await client.files.fetchCache(attachmentHash) : void 0;
3321
3335
  const accessToken = selectAccessToken(state);
3322
3336
  if (attachmentHash && !file) {
3337
+ debugLog("Cannot upload uncached attachment:", attachmentHash);
3323
3338
  throw new Error(`Cannot upload file ${attachmentHash} because it's not cached.`);
3324
3339
  }
3325
3340
  if ((!isExternalUrl || false) && !url.startsWith("http")) {
3341
+ debugLog("Prepending base URL to relative URL:", url);
3326
3342
  if (!url.startsWith("/") && !url.startsWith("blob:")) {
3327
3343
  url = "/" + url;
3328
3344
  }
@@ -3380,6 +3396,7 @@ var __publicField = (obj, key, value) => {
3380
3396
  debugLog("Sending request:", requestDetails, "with params:", queryParams);
3381
3397
  return await requestToSend.query(queryParams);
3382
3398
  } catch (error) {
3399
+ debugLog("Request failed:", error);
3383
3400
  console.error(error);
3384
3401
  const originalError = error;
3385
3402
  if (originalError.status === 401) {
@@ -3401,6 +3418,7 @@ var __publicField = (obj, key, value) => {
3401
3418
  }
3402
3419
  }
3403
3420
  const apiErrorMessage = (_a2 = originalError.body) == null ? void 0 : _a2.error;
3421
+ debugLog("API error message:", apiErrorMessage);
3404
3422
  throw new APIError(
3405
3423
  typeof apiErrorMessage === "string" ? apiErrorMessage : (
3406
3424
  // TODO: Error codes for all APIErrors.
@@ -3453,8 +3471,11 @@ var __publicField = (obj, key, value) => {
3453
3471
  } else {
3454
3472
  console.debug(`All middleware finished with ${this.constructor.name}, performing request:`, action);
3455
3473
  const baseUrl = action.meta.offline.effect.BASE_URL;
3474
+ debugLog("Base URL:", baseUrl);
3456
3475
  if (!exports2.clientStore)
3457
3476
  throw new Error("Client store not set");
3477
+ debugLog("Client store is set");
3478
+ debugLog("Performing request:", action);
3458
3479
  return performRequest(action, makeClient(baseUrl, exports2.clientStore));
3459
3480
  }
3460
3481
  }