@overmap-ai/core 1.0.71-fields.14 → 1.0.71-fields.15
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/constants/defaults.d.ts +2 -1
- package/dist/constants/index.d.ts +3 -3
- package/dist/enums/index.d.ts +5 -5
- package/dist/index.d.ts +6 -6
- package/dist/overmap-core.js +113 -227
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +120 -233
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/base.d.ts +8 -6
- package/dist/sdk/classes/OutboxCoordinator.d.ts +4 -4
- package/dist/sdk/classes/index.d.ts +1 -1
- package/dist/sdk/errors.d.ts +3 -1
- package/dist/sdk/globals.d.ts +7 -5
- package/dist/sdk/index.d.ts +6 -6
- package/dist/sdk/sdk.d.ts +6 -5
- package/dist/sdk/services/AgentService.d.ts +4 -3
- package/dist/sdk/services/AssetAttachmentService.d.ts +18 -19
- package/dist/sdk/services/AssetService.d.ts +5 -4
- package/dist/sdk/services/AssetStageCompletionService.d.ts +5 -4
- package/dist/sdk/services/AssetStageService.d.ts +5 -4
- package/dist/sdk/services/AssetTypeAttachmentService.d.ts +17 -18
- package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +4 -3
- package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +6 -5
- package/dist/sdk/services/AssetTypeFieldsAttachmentService.d.ts +5 -4
- package/dist/sdk/services/AssetTypeFieldsService.d.ts +5 -4
- package/dist/sdk/services/AssetTypeService.d.ts +5 -4
- package/dist/sdk/services/BaseApiService.d.ts +5 -4
- package/dist/sdk/services/BaseAttachmentService.d.ts +8 -7
- package/dist/sdk/services/BaseAuthService.d.ts +5 -4
- package/dist/sdk/services/BaseService.d.ts +7 -5
- package/dist/sdk/services/BaseUploadService.d.ts +5 -4
- package/dist/sdk/services/CategoryService.d.ts +5 -4
- package/dist/sdk/services/DocumentAttachmentService.d.ts +17 -18
- package/dist/sdk/services/DocumentService.d.ts +5 -4
- package/dist/sdk/services/EmailDomainsService.d.ts +4 -3
- package/dist/sdk/services/EmailVerificationService.d.ts +4 -3
- package/dist/sdk/services/FileService.d.ts +5 -4
- package/dist/sdk/services/FormRevisionAttachmentService.d.ts +5 -4
- package/dist/sdk/services/FormRevisionService.d.ts +5 -4
- package/dist/sdk/services/FormService.d.ts +5 -4
- package/dist/sdk/services/FormSubmissionAttachmentService.d.ts +5 -4
- package/dist/sdk/services/FormSubmissionService.d.ts +6 -5
- package/dist/sdk/services/GeoImageService.d.ts +5 -4
- package/dist/sdk/services/IssueAssociationService.d.ts +5 -4
- package/dist/sdk/services/IssueAttachmentService.d.ts +17 -18
- package/dist/sdk/services/IssueCommentService.d.ts +5 -4
- package/dist/sdk/services/IssueService.d.ts +5 -4
- package/dist/sdk/services/IssueTypeFieldValuesAttachmentService.d.ts +5 -4
- package/dist/sdk/services/IssueTypeFieldValuesService.d.ts +5 -4
- package/dist/sdk/services/IssueTypeFieldsAttachmentService.d.ts +5 -4
- package/dist/sdk/services/IssueTypeFieldsService.d.ts +5 -4
- package/dist/sdk/services/IssueTypeService.d.ts +5 -4
- package/dist/sdk/services/IssueUpdateService.d.ts +4 -3
- package/dist/sdk/services/JWTAuthService.d.ts +7 -6
- package/dist/sdk/services/LicenseService.d.ts +4 -3
- package/dist/sdk/services/OrganizationAccessService.d.ts +4 -3
- package/dist/sdk/services/OrganizationService.d.ts +4 -3
- package/dist/sdk/services/ProjectAccessService.d.ts +4 -3
- package/dist/sdk/services/ProjectAttachmentService.d.ts +17 -18
- package/dist/sdk/services/ProjectFileService.d.ts +5 -4
- package/dist/sdk/services/ProjectService.d.ts +4 -3
- package/dist/sdk/services/TeamService.d.ts +5 -4
- package/dist/sdk/services/UserService.d.ts +4 -3
- package/dist/sdk/services/WorkspaceService.d.ts +5 -4
- package/dist/sdk/services/index.d.ts +45 -45
- package/dist/sdk/typings.d.ts +9 -8
- package/dist/store/adapter.d.ts +12 -11
- package/dist/store/index.d.ts +2 -2
- package/dist/store/migrations.d.ts +2 -1
- package/dist/store/slices/agentsSlice.d.ts +11 -10
- package/dist/store/slices/assetAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/assetSlice.d.ts +35 -24
- package/dist/store/slices/assetStageCompletionSlice.d.ts +33 -22
- package/dist/store/slices/assetStageSlice.d.ts +36 -25
- package/dist/store/slices/assetTypeAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +35 -24
- package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +35 -24
- package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +35 -24
- package/dist/store/slices/assetTypeFieldsSlice.d.ts +43 -32
- package/dist/store/slices/assetTypeSlice.d.ts +16 -21
- package/dist/store/slices/authSlice.d.ts +10 -9
- package/dist/store/slices/categorySlice.d.ts +30 -16
- package/dist/store/slices/documentAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/documentSlice.d.ts +30 -13
- package/dist/store/slices/emailDomainsSlice.d.ts +29 -15
- package/dist/store/slices/fileSlice.d.ts +7 -6
- package/dist/store/slices/formRevisionAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/formRevisionSlice.d.ts +37 -26
- package/dist/store/slices/formSlice.d.ts +35 -21
- package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/formSubmissionSlice.d.ts +16 -21
- package/dist/store/slices/geoImageSlice.d.ts +16 -21
- package/dist/store/slices/index.d.ts +46 -46
- package/dist/store/slices/issueAssociationSlice.d.ts +35 -24
- package/dist/store/slices/issueAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/issueCommentSlice.d.ts +13 -18
- package/dist/store/slices/issueSlice.d.ts +13 -18
- package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +35 -24
- package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +35 -24
- package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +35 -24
- package/dist/store/slices/issueTypeFieldsSlice.d.ts +43 -32
- package/dist/store/slices/issueTypeSlice.d.ts +12 -14
- package/dist/store/slices/issueUpdateSlice.d.ts +13 -18
- package/dist/store/slices/licenseSlice.d.ts +10 -9
- package/dist/store/slices/organizationAccessSlice.d.ts +11 -13
- package/dist/store/slices/organizationSlice.d.ts +27 -10
- package/dist/store/slices/outboxSlice.d.ts +15 -15
- package/dist/store/slices/projectAccessSlice.d.ts +11 -16
- package/dist/store/slices/projectAttachmentSlice.d.ts +16 -21
- package/dist/store/slices/projectFileSlice.d.ts +33 -16
- package/dist/store/slices/projectSlice.d.ts +10 -9
- package/dist/store/slices/rehydratedSlice.d.ts +7 -6
- package/dist/store/slices/teamSlice.d.ts +12 -14
- package/dist/store/slices/userSlice.d.ts +14 -13
- package/dist/store/slices/versioningSlice.d.ts +3 -2
- package/dist/store/slices/workspaceSlice.d.ts +31 -17
- package/dist/store/store.d.ts +7 -7
- package/dist/typings/index.d.ts +6 -6
- package/dist/typings/models/access.d.ts +3 -2
- package/dist/typings/models/agents.d.ts +3 -2
- package/dist/typings/models/assets.d.ts +5 -4
- package/dist/typings/models/attachments.d.ts +3 -2
- package/dist/typings/models/base.d.ts +3 -2
- package/dist/typings/models/categories.d.ts +3 -2
- package/dist/typings/models/documents.d.ts +2 -1
- package/dist/typings/models/emailDomain.d.ts +2 -1
- package/dist/typings/models/emailVerification.d.ts +3 -2
- package/dist/typings/models/fields.d.ts +3 -2
- package/dist/typings/models/forms.d.ts +4 -3
- package/dist/typings/models/geoImages.d.ts +4 -3
- package/dist/typings/models/index.d.ts +22 -22
- package/dist/typings/models/issueTypes.d.ts +3 -2
- package/dist/typings/models/issues.d.ts +9 -8
- package/dist/typings/models/license.d.ts +3 -2
- package/dist/typings/models/organizations.d.ts +2 -1
- package/dist/typings/models/projects.d.ts +4 -3
- package/dist/typings/models/store.d.ts +3 -3
- package/dist/typings/models/teams.d.ts +4 -3
- package/dist/typings/models/users.d.ts +2 -1
- package/dist/typings/models/workspace.d.ts +2 -1
- package/dist/typings/search.d.ts +1 -1
- package/dist/typings/store.d.ts +2 -1
- package/dist/utils/async/DeferredPromise.d.ts +1 -1
- package/dist/utils/colors.d.ts +2 -1
- package/dist/utils/coordinates.d.ts +3 -2
- package/dist/utils/file.d.ts +2 -1
- package/dist/utils/forms.d.ts +2 -1
- package/dist/utils/index.d.ts +10 -10
- package/dist/utils/offline.d.ts +2 -1
- package/dist/utils/utils.d.ts +2 -1
- package/package.json +18 -20
package/dist/overmap-core.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
var _a;
|
|
8
5
|
import { DepGraph } from "dependency-graph";
|
|
9
6
|
import { v4 } from "uuid";
|
|
10
7
|
import { saveAs } from "file-saver";
|
|
11
8
|
import ColorCls from "color";
|
|
12
|
-
import {
|
|
9
|
+
import { sky, mint, lime, grass, jade, cyan, blue, indigo, iris, violet, purple, plum, pink, crimson, red, orange, amber, yellow, brown, gold, gray } from "@radix-ui/colors";
|
|
10
|
+
import { createSlice, createSelector, combineReducers, compose } from "@reduxjs/toolkit";
|
|
13
11
|
import { offline as offline$1 } from "@redux-offline/redux-offline";
|
|
14
12
|
import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
|
|
15
13
|
import localforage from "localforage";
|
|
16
14
|
import createMigration from "redux-persist-migrate";
|
|
17
|
-
import { createSlice, createSelector, combineReducers } from "@reduxjs/toolkit";
|
|
18
15
|
import request from "superagent";
|
|
19
16
|
import { RESET_STATE } from "@redux-offline/redux-offline/lib/constants";
|
|
20
17
|
import jwtDecode from "jwt-decode";
|
|
21
18
|
import { openDB } from "idb";
|
|
22
|
-
import { unsafeShowToast } from "@overmap-ai/blocks";
|
|
23
19
|
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
24
20
|
HttpMethod2["GET"] = "GET";
|
|
25
21
|
HttpMethod2["POST"] = "POST";
|
|
@@ -153,8 +149,7 @@ class OutboxCoordinator {
|
|
|
153
149
|
return;
|
|
154
150
|
}
|
|
155
151
|
for (const node of this.graph.overallOrder()) {
|
|
156
|
-
if (node === request2.payload.uuid)
|
|
157
|
-
continue;
|
|
152
|
+
if (node === request2.payload.uuid) continue;
|
|
158
153
|
const details = this.graph.getNodeData(node);
|
|
159
154
|
if (request2.payload.blockers.some((blocker) => details.payload.blocks.includes(blocker))) {
|
|
160
155
|
this._addDependency(request2.payload.uuid, node);
|
|
@@ -171,8 +166,7 @@ class OutboxCoordinator {
|
|
|
171
166
|
insertRequest(request2) {
|
|
172
167
|
this.graph.addNode(request2.payload.uuid, request2);
|
|
173
168
|
for (const node of this.graph.overallOrder()) {
|
|
174
|
-
if (node === request2.payload.uuid)
|
|
175
|
-
continue;
|
|
169
|
+
if (node === request2.payload.uuid) continue;
|
|
176
170
|
const details = this.graph.getNodeData(node);
|
|
177
171
|
if (details.payload.blockers.some((blocker) => request2.payload.blocks.includes(blocker))) {
|
|
178
172
|
this._addDependency(node, request2.payload.uuid);
|
|
@@ -208,8 +202,7 @@ class OutboxCoordinator {
|
|
|
208
202
|
*/
|
|
209
203
|
peek() {
|
|
210
204
|
const nextNode = this._getNextNode();
|
|
211
|
-
if (!nextNode)
|
|
212
|
-
return void 0;
|
|
205
|
+
if (!nextNode) return void 0;
|
|
213
206
|
return this.graph.getNodeData(nextNode);
|
|
214
207
|
}
|
|
215
208
|
/**
|
|
@@ -281,17 +274,15 @@ function extractErrorMessage(errorRes, err) {
|
|
|
281
274
|
ret = responseBody.error;
|
|
282
275
|
} else if (typeof responseBody.message === "string") {
|
|
283
276
|
ret = responseBody.message;
|
|
284
|
-
} else
|
|
277
|
+
} else {
|
|
285
278
|
try {
|
|
286
|
-
ret = Object.entries(responseBody
|
|
279
|
+
ret = Object.entries(responseBody).map(([key, value]) => {
|
|
287
280
|
if (typeof value === "string") {
|
|
288
|
-
if (_SPECIAL_KEYS.includes(key))
|
|
289
|
-
return value;
|
|
281
|
+
if (_SPECIAL_KEYS.includes(key)) return value;
|
|
290
282
|
return `${key}: ${value}`;
|
|
291
283
|
}
|
|
292
284
|
if (Array.isArray(value)) {
|
|
293
|
-
if (_SPECIAL_KEYS.includes(key))
|
|
294
|
-
return value.join("\n");
|
|
285
|
+
if (_SPECIAL_KEYS.includes(key)) return value.join("\n");
|
|
295
286
|
return value.map((v) => `${key}: ${v}`).join("\n");
|
|
296
287
|
}
|
|
297
288
|
return `${key}: ${JSON.stringify(value)}`;
|
|
@@ -359,11 +350,9 @@ const coordinatesAreEqual = (a, b) => {
|
|
|
359
350
|
return a[0] === b[0] && a[1] === b[1];
|
|
360
351
|
};
|
|
361
352
|
const coordinatesToText = (coordinates, decimalPlaces) => {
|
|
362
|
-
if (!coordinates)
|
|
363
|
-
return "(No Location)";
|
|
353
|
+
if (!coordinates) return "(No Location)";
|
|
364
354
|
const { lat, lng } = coordinatesToLiteral(coordinates);
|
|
365
|
-
if (decimalPlaces)
|
|
366
|
-
return `${lat.toFixed(decimalPlaces)}, ${lng.toFixed(decimalPlaces)}`;
|
|
355
|
+
if (decimalPlaces) return `${lat.toFixed(decimalPlaces)}, ${lng.toFixed(decimalPlaces)}`;
|
|
367
356
|
return `${lat}, ${lng}`;
|
|
368
357
|
};
|
|
369
358
|
const coordinatesToUrlText = (coordinates) => {
|
|
@@ -416,7 +405,7 @@ function hashFile(file) {
|
|
|
416
405
|
reader.onload = () => {
|
|
417
406
|
const fileResult = reader.result;
|
|
418
407
|
if (!fileResult) {
|
|
419
|
-
reject();
|
|
408
|
+
reject(new Error("FileReader did not return a valid ArrayBuffer."));
|
|
420
409
|
return;
|
|
421
410
|
}
|
|
422
411
|
void crypto.subtle.digest("SHA-1", fileResult).then((hash) => {
|
|
@@ -430,8 +419,7 @@ function hashFile(file) {
|
|
|
430
419
|
function getFileIdentifier(file) {
|
|
431
420
|
if (!file.name || !file.type || !file.size) {
|
|
432
421
|
const message = "File has no name, type, and/or size";
|
|
433
|
-
|
|
434
|
-
throw new Error(`${message}.`);
|
|
422
|
+
throw new Error(message);
|
|
435
423
|
}
|
|
436
424
|
return `${file.name}&${file.type}${file.size}`;
|
|
437
425
|
}
|
|
@@ -553,21 +541,19 @@ const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
|
|
|
553
541
|
const OUTBOX_RETRY_DELAY = 6e4;
|
|
554
542
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
555
543
|
let debug = false;
|
|
556
|
-
const REACT_APP_DEBUG_MEMOIZATION =
|
|
544
|
+
const REACT_APP_DEBUG_MEMOIZATION = "";
|
|
557
545
|
if (["true", "1"].includes(REACT_APP_DEBUG_MEMOIZATION.toLowerCase())) {
|
|
558
546
|
debug = true;
|
|
559
547
|
}
|
|
560
548
|
function shallowEqual(objA, objB) {
|
|
561
|
-
if (objA === objB)
|
|
562
|
-
return true;
|
|
549
|
+
if (objA === objB) return true;
|
|
563
550
|
if (typeof objA !== typeof objB) {
|
|
564
551
|
return false;
|
|
565
552
|
}
|
|
566
553
|
const keysA = Object.keys(objA);
|
|
567
554
|
const keysB = Object.keys(objB);
|
|
568
555
|
const keysALength = keysA.length;
|
|
569
|
-
if (keysALength !== keysB.length)
|
|
570
|
-
return false;
|
|
556
|
+
if (keysALength !== keysB.length) return false;
|
|
571
557
|
for (let i = 0; i < keysALength; i++) {
|
|
572
558
|
const key = keysA[i];
|
|
573
559
|
if (!Object.prototype.hasOwnProperty.call(objB, key) || objA[key] !== objB[key]) {
|
|
@@ -594,11 +580,9 @@ function memoize(func) {
|
|
|
594
580
|
};
|
|
595
581
|
}
|
|
596
582
|
function areArraysEqual(first, second) {
|
|
597
|
-
if (first.length !== second.length)
|
|
598
|
-
return false;
|
|
583
|
+
if (first.length !== second.length) return false;
|
|
599
584
|
for (let i = 0; i < first.length; i++) {
|
|
600
|
-
if (first[i] !== second[i])
|
|
601
|
-
return false;
|
|
585
|
+
if (first[i] !== second[i]) return false;
|
|
602
586
|
}
|
|
603
587
|
return true;
|
|
604
588
|
}
|
|
@@ -643,13 +627,11 @@ const generateBadgeColors = (rawColor) => {
|
|
|
643
627
|
return { backgroundColor, textColor };
|
|
644
628
|
};
|
|
645
629
|
const getLocalDateString = memoize((date) => {
|
|
646
|
-
if (!date)
|
|
647
|
-
return "";
|
|
630
|
+
if (!date) return "";
|
|
648
631
|
const asDate = new Date(date);
|
|
649
632
|
const isThisYear = asDate.getFullYear() === today.getFullYear();
|
|
650
633
|
const options = { day: "numeric", month: "short" };
|
|
651
|
-
if (!isThisYear)
|
|
652
|
-
options.year = "numeric";
|
|
634
|
+
if (!isThisYear) options.year = "numeric";
|
|
653
635
|
return asDate.toLocaleDateString([], options);
|
|
654
636
|
});
|
|
655
637
|
const relative = new Intl.RelativeTimeFormat([], { style: "long", numeric: "auto" });
|
|
@@ -660,10 +642,10 @@ const isToday = (date) => {
|
|
|
660
642
|
};
|
|
661
643
|
const getLocalRelativeDateString = memoize((date, min, max) => {
|
|
662
644
|
const days = Math.round((new Date(date).getTime() - today.getTime()) / msInDay);
|
|
663
|
-
if (days < min || days > max)
|
|
664
|
-
return getLocalDateString(date);
|
|
645
|
+
if (days < min || days > max) return getLocalDateString(date);
|
|
665
646
|
return relative.format(days, "days");
|
|
666
647
|
});
|
|
648
|
+
_a = Symbol.toStringTag;
|
|
667
649
|
class DeferredPromise {
|
|
668
650
|
constructor() {
|
|
669
651
|
__publicField(this, _a, "Promise");
|
|
@@ -688,14 +670,12 @@ class DeferredPromise {
|
|
|
688
670
|
return this._promise.catch(onRejected);
|
|
689
671
|
}
|
|
690
672
|
resolve(value) {
|
|
691
|
-
if (!this._resolve)
|
|
692
|
-
throw new Error("No resolve callback");
|
|
673
|
+
if (!this._resolve) throw new Error("No resolve callback");
|
|
693
674
|
this._resolve(value);
|
|
694
675
|
this._state = "fulfilled";
|
|
695
676
|
}
|
|
696
677
|
reject(reason) {
|
|
697
|
-
if (!this._reject)
|
|
698
|
-
throw reason;
|
|
678
|
+
if (!this._reject) throw reason;
|
|
699
679
|
this._reject(reason);
|
|
700
680
|
this._state = "rejected";
|
|
701
681
|
}
|
|
@@ -703,35 +683,6 @@ class DeferredPromise {
|
|
|
703
683
|
throw new Error("`finally` not implemented");
|
|
704
684
|
}
|
|
705
685
|
}
|
|
706
|
-
_a = Symbol.toStringTag;
|
|
707
|
-
var randomString = function randomString2() {
|
|
708
|
-
return Math.random().toString(36).substring(7).split("").join(".");
|
|
709
|
-
};
|
|
710
|
-
({
|
|
711
|
-
INIT: "@@redux/INIT" + randomString(),
|
|
712
|
-
REPLACE: "@@redux/REPLACE" + randomString(),
|
|
713
|
-
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
|
714
|
-
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
function compose() {
|
|
718
|
-
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
719
|
-
funcs[_key] = arguments[_key];
|
|
720
|
-
}
|
|
721
|
-
if (funcs.length === 0) {
|
|
722
|
-
return function(arg) {
|
|
723
|
-
return arg;
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
if (funcs.length === 1) {
|
|
727
|
-
return funcs[0];
|
|
728
|
-
}
|
|
729
|
-
return funcs.reduce(function(a, b) {
|
|
730
|
-
return function() {
|
|
731
|
-
return a(b.apply(void 0, arguments));
|
|
732
|
-
};
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
686
|
const VERSION_REDUCER_KEY$1 = "versioning";
|
|
736
687
|
const latestVersion = () => migrations.length - 1;
|
|
737
688
|
const initialVersioning = (state) => {
|
|
@@ -752,8 +703,7 @@ const wrapMigration = (migrator) => (state) => {
|
|
|
752
703
|
if (state === void 0) {
|
|
753
704
|
state = {};
|
|
754
705
|
}
|
|
755
|
-
if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
|
|
756
|
-
return state;
|
|
706
|
+
if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion()) return state;
|
|
757
707
|
return migrator(state);
|
|
758
708
|
};
|
|
759
709
|
const migrations = [initialVersioning, signOut, signOut, createOutboxState];
|
|
@@ -947,8 +897,7 @@ const selectAssetsByIds = restructureCreateSelectorWithArgs(
|
|
|
947
897
|
const assets = [];
|
|
948
898
|
for (const assetId of assetIds) {
|
|
949
899
|
const asset = assetsMapping[assetId];
|
|
950
|
-
if (asset)
|
|
951
|
-
assets.push(asset);
|
|
900
|
+
if (asset) assets.push(asset);
|
|
952
901
|
}
|
|
953
902
|
return fallbackToEmptyArray(assets);
|
|
954
903
|
})
|
|
@@ -1009,11 +958,11 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
|
|
|
1009
958
|
const attachmentsOfAsset = attachments.filter(({ asset }) => assetId === asset);
|
|
1010
959
|
const fileAttachments = attachmentsOfAsset.filter(
|
|
1011
960
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1012
|
-
({ file_type }) => !file_type
|
|
961
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
1013
962
|
);
|
|
1014
963
|
const imageAttachments = attachmentsOfAsset.filter(
|
|
1015
964
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1016
|
-
({ file_type }) => file_type
|
|
965
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
1017
966
|
);
|
|
1018
967
|
return { fileAttachments, imageAttachments };
|
|
1019
968
|
}
|
|
@@ -1056,8 +1005,7 @@ const selectCompletedStagesByAsset = createSelector(
|
|
|
1056
1005
|
const completedStagesByAsset = {};
|
|
1057
1006
|
for (const stageCompletion of Object.values(completedStagesMapping)) {
|
|
1058
1007
|
const { asset, stage, submitted_at } = stageCompletion;
|
|
1059
|
-
if (!completedStagesByAsset[asset])
|
|
1060
|
-
completedStagesByAsset[asset] = {};
|
|
1008
|
+
if (!completedStagesByAsset[asset]) completedStagesByAsset[asset] = {};
|
|
1061
1009
|
completedStagesByAsset[asset][stage] = submitted_at;
|
|
1062
1010
|
}
|
|
1063
1011
|
return completedStagesByAsset;
|
|
@@ -1281,11 +1229,11 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
|
|
|
1281
1229
|
const attachmentsOfAssetType = attachments.filter(({ asset_type }) => asset_type === assetTypeId);
|
|
1282
1230
|
const fileAttachments = attachmentsOfAssetType.filter(
|
|
1283
1231
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1284
|
-
({ file_type }) => !file_type
|
|
1232
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
1285
1233
|
);
|
|
1286
1234
|
const imageAttachments = attachmentsOfAssetType.filter(
|
|
1287
1235
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1288
|
-
({ file_type }) => file_type
|
|
1236
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
1289
1237
|
);
|
|
1290
1238
|
return { fileAttachments, imageAttachments };
|
|
1291
1239
|
}
|
|
@@ -1422,8 +1370,7 @@ const selectUploadUrl = (sha1) => (state) => {
|
|
|
1422
1370
|
}
|
|
1423
1371
|
const today2 = (/* @__PURE__ */ new Date()).getTime();
|
|
1424
1372
|
const expiringWithinAnHour = (url.exp ?? today2) - today2 < msPerHour;
|
|
1425
|
-
if (expiringWithinAnHour)
|
|
1426
|
-
return void 0;
|
|
1373
|
+
if (expiringWithinAnHour) return void 0;
|
|
1427
1374
|
return url;
|
|
1428
1375
|
};
|
|
1429
1376
|
const fileReducer = fileSlice.reducer;
|
|
@@ -1452,8 +1399,7 @@ const userSlice = createSlice({
|
|
|
1452
1399
|
state.currentUser = action.payload;
|
|
1453
1400
|
},
|
|
1454
1401
|
setProfilePicture: (state, action) => {
|
|
1455
|
-
if (!state.currentUser)
|
|
1456
|
-
return;
|
|
1402
|
+
if (!state.currentUser) return;
|
|
1457
1403
|
state.currentUser.profile.file = action.payload.file ?? null;
|
|
1458
1404
|
state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
|
|
1459
1405
|
const currentUser = state.users[state.currentUser.id];
|
|
@@ -1789,8 +1735,7 @@ const outboxSlice = createSlice({
|
|
|
1789
1735
|
},
|
|
1790
1736
|
markAsDeleted(state, action) {
|
|
1791
1737
|
const index = state.deletedRequests.indexOf(action.payload);
|
|
1792
|
-
if (index !== -1)
|
|
1793
|
-
state.deletedRequests.splice(index, 1);
|
|
1738
|
+
if (index !== -1) state.deletedRequests.splice(index, 1);
|
|
1794
1739
|
},
|
|
1795
1740
|
_setLatestRetryTime: (state, action) => {
|
|
1796
1741
|
state.latestRetryTime = action.payload;
|
|
@@ -1939,11 +1884,11 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
|
|
|
1939
1884
|
const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
|
|
1940
1885
|
const fileAttachments = attachmentsOfProject.filter(
|
|
1941
1886
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1942
|
-
({ file_type }) => !file_type
|
|
1887
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
1943
1888
|
);
|
|
1944
1889
|
const imageAttachments = attachmentsOfProject.filter(
|
|
1945
1890
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1946
|
-
({ file_type }) => file_type
|
|
1891
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
1947
1892
|
);
|
|
1948
1893
|
return { fileAttachments, imageAttachments };
|
|
1949
1894
|
}
|
|
@@ -2027,8 +1972,7 @@ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
|
|
|
2027
1972
|
[selectFormRevisionMapping, (_state, formId) => formId],
|
|
2028
1973
|
(revisions, formId) => {
|
|
2029
1974
|
const revisionsOfForm = Object.values(revisions).filter((revision) => revision.form === formId);
|
|
2030
|
-
if (revisionsOfForm.length === 0)
|
|
2031
|
-
return void 0;
|
|
1975
|
+
if (revisionsOfForm.length === 0) return void 0;
|
|
2032
1976
|
const sortedRevisions = revisionsOfForm.sort(formRevisionSortFn);
|
|
2033
1977
|
const latestRevision = sortedRevisions[revisionsOfForm.length - 1];
|
|
2034
1978
|
return revisions[latestRevision.offline_id];
|
|
@@ -2092,7 +2036,7 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
2092
2036
|
return [...regularMatches.slice(0, maxResults)];
|
|
2093
2037
|
},
|
|
2094
2038
|
// as the argument is an object, we check the first level of properties for equality
|
|
2095
|
-
{ memoizeOptions: {
|
|
2039
|
+
{ memoizeOptions: { resultEqualityCheck: shallowEqual } }
|
|
2096
2040
|
)
|
|
2097
2041
|
);
|
|
2098
2042
|
const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
|
|
@@ -2146,8 +2090,7 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
2146
2090
|
(submissionsMapping, revisionMapping, formId) => {
|
|
2147
2091
|
const revisionIds = /* @__PURE__ */ new Set();
|
|
2148
2092
|
for (const revision of Object.values(revisionMapping)) {
|
|
2149
|
-
if (revision.form !== formId)
|
|
2150
|
-
continue;
|
|
2093
|
+
if (revision.form !== formId) continue;
|
|
2151
2094
|
revisionIds.add(revision.offline_id);
|
|
2152
2095
|
}
|
|
2153
2096
|
return Object.values(submissionsMapping).filter(
|
|
@@ -2519,8 +2462,7 @@ const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
|
|
|
2519
2462
|
createSelector([selectDocumentsMapping, (_state, documentId) => documentId], (mapping, documentId) => {
|
|
2520
2463
|
const listOfAncestors = [];
|
|
2521
2464
|
const document2 = mapping[documentId];
|
|
2522
|
-
if (!document2 || !document2.parent_document)
|
|
2523
|
-
return listOfAncestors;
|
|
2465
|
+
if (!document2 || !document2.parent_document) return listOfAncestors;
|
|
2524
2466
|
let currentAncestor = mapping[document2.parent_document];
|
|
2525
2467
|
while (currentAncestor) {
|
|
2526
2468
|
listOfAncestors.push(currentAncestor.offline_id);
|
|
@@ -2586,11 +2528,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
|
|
|
2586
2528
|
const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
|
|
2587
2529
|
const fileAttachments = attachmentsOfProject.filter(
|
|
2588
2530
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2589
|
-
({ file_type }) => !file_type
|
|
2531
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
2590
2532
|
);
|
|
2591
2533
|
const imageAttachments = attachmentsOfProject.filter(
|
|
2592
2534
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2593
|
-
({ file_type }) => file_type
|
|
2535
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
2594
2536
|
);
|
|
2595
2537
|
return { fileAttachments, imageAttachments };
|
|
2596
2538
|
}
|
|
@@ -2796,11 +2738,11 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
|
|
|
2796
2738
|
const attachmentsOfIssue = attachments.filter(({ issue }) => issue === issueId);
|
|
2797
2739
|
const fileAttachments = attachmentsOfIssue.filter(
|
|
2798
2740
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2799
|
-
({ file_type }) => !file_type
|
|
2741
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
2800
2742
|
);
|
|
2801
2743
|
const imageAttachments = attachmentsOfIssue.filter(
|
|
2802
2744
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2803
|
-
({ file_type }) => file_type
|
|
2745
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
2804
2746
|
);
|
|
2805
2747
|
return { fileAttachments, imageAttachments };
|
|
2806
2748
|
}
|
|
@@ -3369,6 +3311,7 @@ class BaseService {
|
|
|
3369
3311
|
async enqueueRequest(requestDetails) {
|
|
3370
3312
|
return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
|
|
3371
3313
|
}
|
|
3314
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3372
3315
|
dispatch(action) {
|
|
3373
3316
|
this.client.store.dispatch(action);
|
|
3374
3317
|
}
|
|
@@ -3446,9 +3389,8 @@ function getOutboxCoordinator() {
|
|
|
3446
3389
|
__OUTBOX_COORDINATOR = coordinator;
|
|
3447
3390
|
return coordinator;
|
|
3448
3391
|
}
|
|
3449
|
-
const persistCallback = (
|
|
3450
|
-
if (
|
|
3451
|
-
throw err;
|
|
3392
|
+
const persistCallback = (e) => {
|
|
3393
|
+
if (e) throw e;
|
|
3452
3394
|
const clientStore2 = getClientStore();
|
|
3453
3395
|
if (clientStore2) {
|
|
3454
3396
|
clientStore2.dispatch({ type: "rehydrated/setRehydrated", payload: true });
|
|
@@ -3512,14 +3454,11 @@ function extractResponseFromError(error) {
|
|
|
3512
3454
|
const knownKeys = ["ok", "redirect", "clientError", "serverError", "error"];
|
|
3513
3455
|
return typeof response === "object" && response !== null && knownKeys.every((key) => key in response);
|
|
3514
3456
|
}
|
|
3515
|
-
if (isResponse(error))
|
|
3516
|
-
return error;
|
|
3457
|
+
if (isResponse(error)) return error;
|
|
3517
3458
|
if (typeof error === "object" && error !== null) {
|
|
3518
3459
|
const typedError = error;
|
|
3519
|
-
if (isResponse(typedError.response))
|
|
3520
|
-
|
|
3521
|
-
if (typedError.response && isResponse(typedError.response.response))
|
|
3522
|
-
return typedError.response.response;
|
|
3460
|
+
if (isResponse(typedError.response)) return typedError.response;
|
|
3461
|
+
if (typedError.response && isResponse(typedError.response.response)) return typedError.response.response;
|
|
3523
3462
|
}
|
|
3524
3463
|
return void 0;
|
|
3525
3464
|
}
|
|
@@ -3560,15 +3499,11 @@ async function performRequest(action, client) {
|
|
|
3560
3499
|
const addPayload = (req) => {
|
|
3561
3500
|
if (attachmentHash) {
|
|
3562
3501
|
const s3url = requestDetails.s3url;
|
|
3563
|
-
if (!s3url)
|
|
3564
|
-
|
|
3565
|
-
if (
|
|
3566
|
-
throw new Error(`S3 URL warning for file ${attachmentHash}`);
|
|
3567
|
-
if (!file)
|
|
3568
|
-
throw new Error(`No file for file ${attachmentHash}`);
|
|
3502
|
+
if (!s3url) throw new Error(`No S3 URL for file ${attachmentHash}`);
|
|
3503
|
+
if ("warning" in s3url) throw new Error(`S3 URL warning for file ${attachmentHash}`);
|
|
3504
|
+
if (!file) throw new Error(`No file for file ${attachmentHash}`);
|
|
3569
3505
|
const s3Sha1Checksum = s3url.fields["x-amz-checksum-sha1"];
|
|
3570
|
-
if (!s3Sha1Checksum)
|
|
3571
|
-
throw new Error(`No checksum for file ${attachmentHash}`);
|
|
3506
|
+
if (!s3Sha1Checksum) throw new Error(`No checksum for file ${attachmentHash}`);
|
|
3572
3507
|
return req.set("x-amz-checksum-sha1", s3Sha1Checksum).field({ ...payload, ...s3url.fields }).attach("file", file);
|
|
3573
3508
|
}
|
|
3574
3509
|
return req.send(payload);
|
|
@@ -3628,8 +3563,7 @@ class MiddlewareChainerPrivate {
|
|
|
3628
3563
|
this.compile = this.compile.bind(this);
|
|
3629
3564
|
}
|
|
3630
3565
|
then(next) {
|
|
3631
|
-
if (this._previous)
|
|
3632
|
-
this._previous.next = next;
|
|
3566
|
+
if (this._previous) this._previous.next = next;
|
|
3633
3567
|
this._all.push(next);
|
|
3634
3568
|
this._previous = next;
|
|
3635
3569
|
return {
|
|
@@ -3657,11 +3591,9 @@ class OfflineMiddleware {
|
|
|
3657
3591
|
} else {
|
|
3658
3592
|
console.debug("Middleware finished. Performing request:", action);
|
|
3659
3593
|
const clientStore2 = getClientStore();
|
|
3660
|
-
if (!clientStore2)
|
|
3661
|
-
throw new Error("Client store not set");
|
|
3594
|
+
if (!clientStore2) throw new Error("Client store not set");
|
|
3662
3595
|
const clientSDK2 = getClientSDK();
|
|
3663
|
-
if (!clientSDK2)
|
|
3664
|
-
throw new Error("Client SDK not set");
|
|
3596
|
+
if (!clientSDK2) throw new Error("Client SDK not set");
|
|
3665
3597
|
return performRequest(action, clientSDK2);
|
|
3666
3598
|
}
|
|
3667
3599
|
}
|
|
@@ -3682,20 +3614,6 @@ function runMiddleware(action) {
|
|
|
3682
3614
|
return (_a2 = allMiddleware[0]) == null ? void 0 : _a2.run(action);
|
|
3683
3615
|
}
|
|
3684
3616
|
const discardStatuses = [400, 409, 403, 404, 405, 500];
|
|
3685
|
-
const statusMessages = {
|
|
3686
|
-
403: { title: "Forbidden", description: "You are not authorized to perform this action.", accentColor: "red" },
|
|
3687
|
-
404: { title: "Not found", description: "The requested resource was not found.", accentColor: "red" },
|
|
3688
|
-
405: {
|
|
3689
|
-
title: "Not supported",
|
|
3690
|
-
description: "It's not you. It's us. Sorry for the inconvenience.",
|
|
3691
|
-
accentColor: "red"
|
|
3692
|
-
},
|
|
3693
|
-
500: {
|
|
3694
|
-
title: "Server error",
|
|
3695
|
-
description: "Our server seems to be experiencing problems at the moment. We have been alerted and will fix the problem as soon as possible.",
|
|
3696
|
-
accentColor: "red"
|
|
3697
|
-
}
|
|
3698
|
-
};
|
|
3699
3617
|
function discard(reason, action, retries = 0) {
|
|
3700
3618
|
var _a2;
|
|
3701
3619
|
console.debug(
|
|
@@ -3748,14 +3666,6 @@ function discard(reason, action, retries = 0) {
|
|
|
3748
3666
|
}
|
|
3749
3667
|
if (status !== void 0 && discardStatuses.includes(status)) {
|
|
3750
3668
|
console.warn("Discarding request due to error:", reason, "\nAction:", action);
|
|
3751
|
-
const message = statusMessages[status];
|
|
3752
|
-
if (message) {
|
|
3753
|
-
if (unsafeShowToast) {
|
|
3754
|
-
unsafeShowToast(message);
|
|
3755
|
-
} else {
|
|
3756
|
-
console.error(`Could not display toast for status ${status} because there is no toast handle.`);
|
|
3757
|
-
}
|
|
3758
|
-
}
|
|
3759
3669
|
const coordinator2 = getOutboxCoordinator();
|
|
3760
3670
|
if (!coordinator2) {
|
|
3761
3671
|
throw new Error("Outbox coordinator not set");
|
|
@@ -3783,6 +3693,7 @@ function retry(_action, _retries) {
|
|
|
3783
3693
|
}
|
|
3784
3694
|
class BaseSDK {
|
|
3785
3695
|
constructor(store) {
|
|
3696
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3786
3697
|
__publicField(this, "store");
|
|
3787
3698
|
this.store = store;
|
|
3788
3699
|
}
|
|
@@ -3818,9 +3729,13 @@ class BaseSDK {
|
|
|
3818
3729
|
};
|
|
3819
3730
|
performRequest(fullOfflineAction, this).then((result) => {
|
|
3820
3731
|
promise.resolve(result.body);
|
|
3821
|
-
}).catch((
|
|
3822
|
-
discard(
|
|
3823
|
-
|
|
3732
|
+
}).catch((e) => {
|
|
3733
|
+
discard(e, fullOfflineAction);
|
|
3734
|
+
if (e instanceof Error) {
|
|
3735
|
+
promise.reject(e);
|
|
3736
|
+
} else {
|
|
3737
|
+
promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
|
|
3738
|
+
}
|
|
3824
3739
|
});
|
|
3825
3740
|
} else {
|
|
3826
3741
|
const innerPromise = this.store.dispatch(
|
|
@@ -3874,10 +3789,8 @@ class BaseAuthService extends BaseService {
|
|
|
3874
3789
|
}
|
|
3875
3790
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
3876
3791
|
function parseTokens(response) {
|
|
3877
|
-
if (!response.access)
|
|
3878
|
-
|
|
3879
|
-
if (!response.refresh)
|
|
3880
|
-
throw new Error("Missing refresh token");
|
|
3792
|
+
if (!response.access) throw new Error("Missing access token");
|
|
3793
|
+
if (!response.refresh) throw new Error("Missing refresh token");
|
|
3881
3794
|
return { accessToken: response.access, refreshToken: response.refresh };
|
|
3882
3795
|
}
|
|
3883
3796
|
class JWTService extends BaseAuthService {
|
|
@@ -3914,8 +3827,7 @@ class JWTService extends BaseAuthService {
|
|
|
3914
3827
|
this.clearAuth();
|
|
3915
3828
|
return void 0;
|
|
3916
3829
|
}
|
|
3917
|
-
if (!response.access)
|
|
3918
|
-
throw new Error("Missing access token");
|
|
3830
|
+
if (!response.access) throw new Error("Missing access token");
|
|
3919
3831
|
return { accessToken: response.access, refreshToken: response.refresh ?? this.getRefreshToken() };
|
|
3920
3832
|
});
|
|
3921
3833
|
}
|
|
@@ -3971,8 +3883,7 @@ class JWTService extends BaseAuthService {
|
|
|
3971
3883
|
return `Bearer ${accessToken}`;
|
|
3972
3884
|
}
|
|
3973
3885
|
async prepareAuth() {
|
|
3974
|
-
if (!this.tokenIsExpiringSoon())
|
|
3975
|
-
return;
|
|
3886
|
+
if (!this.tokenIsExpiringSoon()) return;
|
|
3976
3887
|
console.debug(this.constructor.name, "preparing auth");
|
|
3977
3888
|
try {
|
|
3978
3889
|
await this.renewTokens();
|
|
@@ -3980,7 +3891,11 @@ class JWTService extends BaseAuthService {
|
|
|
3980
3891
|
if (e instanceof APIError) {
|
|
3981
3892
|
this.clearAuth();
|
|
3982
3893
|
}
|
|
3983
|
-
|
|
3894
|
+
if (e instanceof Error) {
|
|
3895
|
+
return Promise.reject(e);
|
|
3896
|
+
} else {
|
|
3897
|
+
return Promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
|
|
3898
|
+
}
|
|
3984
3899
|
}
|
|
3985
3900
|
}
|
|
3986
3901
|
/* if not successfull in gracefully handling an unauthorized response, throw and APIError */
|
|
@@ -4011,7 +3926,7 @@ class JWTService extends BaseAuthService {
|
|
|
4011
3926
|
async initAuth(payload) {
|
|
4012
3927
|
const uuid = v4();
|
|
4013
3928
|
console.debug(this.constructor.name, "Initiating auth");
|
|
4014
|
-
|
|
3929
|
+
return this.enqueueRequest({
|
|
4015
3930
|
uuid,
|
|
4016
3931
|
description: "Get token pair",
|
|
4017
3932
|
method: HttpMethod.POST,
|
|
@@ -4019,25 +3934,12 @@ class JWTService extends BaseAuthService {
|
|
|
4019
3934
|
payload,
|
|
4020
3935
|
isAuthNeeded: false,
|
|
4021
3936
|
checkAuth: false,
|
|
3937
|
+
immediate: true,
|
|
4022
3938
|
blockers: [],
|
|
4023
3939
|
blocks: []
|
|
4024
|
-
}).then(
|
|
4025
|
-
|
|
4026
|
-
let timedOut = false;
|
|
4027
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
4028
|
-
setTimeout(() => {
|
|
4029
|
-
timedOut = true;
|
|
4030
|
-
this.dispatch(markForDeletion(uuid));
|
|
4031
|
-
reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
|
|
4032
|
-
}, timeout * 1e3);
|
|
4033
|
-
});
|
|
4034
|
-
const successPromise = promise.then((tokens) => {
|
|
4035
|
-
if (timedOut) {
|
|
4036
|
-
return void 0;
|
|
4037
|
-
}
|
|
4038
|
-
this.setTokens(tokens);
|
|
3940
|
+
}).then((tokens) => {
|
|
3941
|
+
this.setTokens(parseTokens(tokens));
|
|
4039
3942
|
});
|
|
4040
|
-
return Promise.race([timeoutPromise, successPromise]);
|
|
4041
3943
|
}
|
|
4042
3944
|
}
|
|
4043
3945
|
class BaseApiService extends BaseService {
|
|
@@ -4197,8 +4099,7 @@ class AssetService extends BaseApiService {
|
|
|
4197
4099
|
const { store } = this.client;
|
|
4198
4100
|
const state = store.getState();
|
|
4199
4101
|
const assetToBeDeleted = selectAssetById(id)(state);
|
|
4200
|
-
if (!assetToBeDeleted)
|
|
4201
|
-
throw new Error(`No asset with id ${id} found in the store`);
|
|
4102
|
+
if (!assetToBeDeleted) throw new Error(`No asset with id ${id} found in the store`);
|
|
4202
4103
|
const attachmentsOfAssets = selectAttachmentsOfAsset(id)(state);
|
|
4203
4104
|
const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(id)(state);
|
|
4204
4105
|
const issueAssociations = selectIssueAssociationsOfAsset(id)(state);
|
|
@@ -4221,12 +4122,12 @@ class AssetService extends BaseApiService {
|
|
|
4221
4122
|
url: `/assets/${id}/`,
|
|
4222
4123
|
blockers: [id],
|
|
4223
4124
|
blocks: []
|
|
4224
|
-
}).catch((
|
|
4125
|
+
}).catch((e) => {
|
|
4225
4126
|
this.dispatch(addAsset(assetToBeDeleted));
|
|
4226
4127
|
this.dispatch(addAssetAttachments(attachmentsOfAssets));
|
|
4227
4128
|
this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
|
|
4228
4129
|
this.dispatch(addIssueAssociations(issueAssociations));
|
|
4229
|
-
throw
|
|
4130
|
+
throw e;
|
|
4230
4131
|
});
|
|
4231
4132
|
}
|
|
4232
4133
|
bulkAdd(payloads, assetTypeId, batchSize) {
|
|
@@ -4250,8 +4151,7 @@ class AssetService extends BaseApiService {
|
|
|
4250
4151
|
const { batchId, payload } = assetBatch;
|
|
4251
4152
|
const batchAssetOfflineIds = payload.assets.map((c) => c.offline_id);
|
|
4252
4153
|
const blockers = [assetTypeId];
|
|
4253
|
-
if (prevBatchId)
|
|
4254
|
-
blockers.push(prevBatchId);
|
|
4154
|
+
if (prevBatchId) blockers.push(prevBatchId);
|
|
4255
4155
|
const blocks = batchAssetOfflineIds;
|
|
4256
4156
|
blocks.push(batchId);
|
|
4257
4157
|
const promise = this.enqueueRequest({
|
|
@@ -4471,8 +4371,7 @@ class AssetStageService extends BaseApiService {
|
|
|
4471
4371
|
update(payload) {
|
|
4472
4372
|
const { store } = this.client;
|
|
4473
4373
|
const assetStage = selectAssetStageById(payload.offline_id)(store.getState());
|
|
4474
|
-
if (!assetStage)
|
|
4475
|
-
throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
|
|
4374
|
+
if (!assetStage) throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
|
|
4476
4375
|
const updatedAssetStage = {
|
|
4477
4376
|
...assetStage,
|
|
4478
4377
|
...payload
|
|
@@ -4628,8 +4527,7 @@ class BaseAttachmentService extends BaseUploadService {
|
|
|
4628
4527
|
for (const payload of payloads) {
|
|
4629
4528
|
const { modelId, file } = payload;
|
|
4630
4529
|
const filePayload = await this.getFilePayload(file);
|
|
4631
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
4632
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
4530
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
4633
4531
|
const offlineAttachment = this.buildOfflineAttachment({
|
|
4634
4532
|
file,
|
|
4635
4533
|
file_sha1: filePayload.sha1,
|
|
@@ -5093,7 +4991,18 @@ class IssueService extends BaseApiService {
|
|
|
5093
4991
|
]) {
|
|
5094
4992
|
if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
|
|
5095
4993
|
switch (issueUpdateChange) {
|
|
5096
|
-
case
|
|
4994
|
+
case IssueUpdateChange.PRIORITY:
|
|
4995
|
+
case IssueUpdateChange.STATUS: {
|
|
4996
|
+
const val = payload[issueUpdateChange];
|
|
4997
|
+
changes[issueUpdateChange] = val !== void 0 ? Number(val) : null;
|
|
4998
|
+
break;
|
|
4999
|
+
}
|
|
5000
|
+
case IssueUpdateChange.DUE_DATE:
|
|
5001
|
+
case IssueUpdateChange.DESCRIPTION:
|
|
5002
|
+
case IssueUpdateChange.TITLE:
|
|
5003
|
+
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
5004
|
+
break;
|
|
5005
|
+
case IssueUpdateChange.CATEGORY: {
|
|
5097
5006
|
let categoryOrNull = null;
|
|
5098
5007
|
const categoryIdOrNull = payload[issueUpdateChange];
|
|
5099
5008
|
if (categoryIdOrNull) {
|
|
@@ -5110,7 +5019,7 @@ class IssueService extends BaseApiService {
|
|
|
5110
5019
|
} : null;
|
|
5111
5020
|
break;
|
|
5112
5021
|
}
|
|
5113
|
-
case
|
|
5022
|
+
case IssueUpdateChange.ASSIGNED_TO: {
|
|
5114
5023
|
let userOrNull = null;
|
|
5115
5024
|
const userIdOrNull = payload[issueUpdateChange];
|
|
5116
5025
|
if (userIdOrNull) {
|
|
@@ -5126,20 +5035,6 @@ class IssueService extends BaseApiService {
|
|
|
5126
5035
|
} : null;
|
|
5127
5036
|
break;
|
|
5128
5037
|
}
|
|
5129
|
-
case "description":
|
|
5130
|
-
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
5131
|
-
break;
|
|
5132
|
-
case "title":
|
|
5133
|
-
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
5134
|
-
break;
|
|
5135
|
-
case "priority":
|
|
5136
|
-
changes[issueUpdateChange] = payload[issueUpdateChange];
|
|
5137
|
-
break;
|
|
5138
|
-
case "status":
|
|
5139
|
-
changes[issueUpdateChange] = payload[issueUpdateChange];
|
|
5140
|
-
break;
|
|
5141
|
-
case "due_date":
|
|
5142
|
-
changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
|
|
5143
5038
|
}
|
|
5144
5039
|
}
|
|
5145
5040
|
}
|
|
@@ -5915,9 +5810,9 @@ class WorkspaceService extends BaseApiService {
|
|
|
5915
5810
|
blockers: [id],
|
|
5916
5811
|
blocks: []
|
|
5917
5812
|
});
|
|
5918
|
-
void promise.catch((
|
|
5813
|
+
void promise.catch((e) => {
|
|
5919
5814
|
this.dispatch(addWorkspace(originalWorkspace));
|
|
5920
|
-
throw
|
|
5815
|
+
throw e;
|
|
5921
5816
|
});
|
|
5922
5817
|
return promise;
|
|
5923
5818
|
}
|
|
@@ -5978,7 +5873,7 @@ const summarizeEvery = 20;
|
|
|
5978
5873
|
class FileService extends BaseApiService {
|
|
5979
5874
|
constructor() {
|
|
5980
5875
|
super(...arguments);
|
|
5981
|
-
__publicField(this, "host"
|
|
5876
|
+
__publicField(this, "host");
|
|
5982
5877
|
// NOTE: If you alter the schema (of the IndexedDB database) in any way, you must increment the version in order to
|
|
5983
5878
|
// migrate the store. This allows idb to automatically migrate the user's existing data to the new schema.
|
|
5984
5879
|
__publicField(this, "_dbPromise", openDB("fileCache", 1, {
|
|
@@ -5989,8 +5884,7 @@ class FileService extends BaseApiService {
|
|
|
5989
5884
|
}
|
|
5990
5885
|
async renewUploadUrl(sha1) {
|
|
5991
5886
|
const file = await this.fetchCache(sha1);
|
|
5992
|
-
if (!file)
|
|
5993
|
-
throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
5887
|
+
if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
5994
5888
|
const key = await getFileS3Key(file, sha1);
|
|
5995
5889
|
const s3UploadUrl = await this.enqueueRequest({
|
|
5996
5890
|
description: "Get S3 URL",
|
|
@@ -6060,8 +5954,7 @@ class FileService extends BaseApiService {
|
|
|
6060
5954
|
/** Ensure the file has been added to the file cache before calling `uploadFileToS3()` */
|
|
6061
5955
|
async uploadFileToS3(sha1) {
|
|
6062
5956
|
const file = await this.fetchCache(sha1);
|
|
6063
|
-
if (!file)
|
|
6064
|
-
throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
5957
|
+
if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
6065
5958
|
const key = await getFileS3Key(file, sha1);
|
|
6066
5959
|
const dbFileProperties = {
|
|
6067
5960
|
file_name: file.name,
|
|
@@ -6155,7 +6048,7 @@ class FileService extends BaseApiService {
|
|
|
6155
6048
|
isExternalUrl flag in the request details is set to true, because instead of requesting the local
|
|
6156
6049
|
REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
|
|
6157
6050
|
(with an offline_id attached) being returned. Alternatively, you may be running with
|
|
6158
|
-
|
|
6051
|
+
import.meta.env.PROD, which will result in some file requests being treated as
|
|
6159
6052
|
external URLs and therefore not prepended with VITE_API_URL.`;
|
|
6160
6053
|
throw new Error(message);
|
|
6161
6054
|
}
|
|
@@ -6954,8 +6847,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
6954
6847
|
for (const payloadAndFile of payloads) {
|
|
6955
6848
|
const { file, ...payload } = payloadAndFile;
|
|
6956
6849
|
const filePayload = await this.getFilePayload(file);
|
|
6957
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
6958
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
6850
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
6959
6851
|
const offlineMapImage = offline({
|
|
6960
6852
|
...payload,
|
|
6961
6853
|
file_name: file.name,
|
|
@@ -7133,8 +7025,7 @@ class FormRevisionAttachmentService extends BaseUploadService {
|
|
|
7133
7025
|
for (const payload of payloads) {
|
|
7134
7026
|
const { revisionId, fieldIdentifier, file } = payload;
|
|
7135
7027
|
const filePayload = await this.getFilePayload(file);
|
|
7136
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
7137
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
7028
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7138
7029
|
const offlineFormRevisionAttachment = offline({
|
|
7139
7030
|
file: URL.createObjectURL(file),
|
|
7140
7031
|
file_type: file.type,
|
|
@@ -7219,8 +7110,7 @@ class FormSubmissionAttachmentService extends BaseUploadService {
|
|
|
7219
7110
|
for (const payload of payloads) {
|
|
7220
7111
|
const { submissionId, fieldIdentifier, file } = payload;
|
|
7221
7112
|
const filePayload = await this.getFilePayload(file);
|
|
7222
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
7223
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
7113
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7224
7114
|
const offlineFormSubmissionAttachment = offline({
|
|
7225
7115
|
file: URL.createObjectURL(file),
|
|
7226
7116
|
file_type: file.type,
|
|
@@ -7367,8 +7257,7 @@ class AssetTypeFieldsAttachmentService extends BaseUploadService {
|
|
|
7367
7257
|
for (const payload of payloads) {
|
|
7368
7258
|
const { fieldsRevisionId, fieldIdentifier, file } = payload;
|
|
7369
7259
|
const filePayload = await this.getFilePayload(file);
|
|
7370
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
7371
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
7260
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7372
7261
|
const offlineAssetTypeFieldsAttachment = offline({
|
|
7373
7262
|
file: URL.createObjectURL(file),
|
|
7374
7263
|
file_type: file.type,
|
|
@@ -7649,8 +7538,7 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7649
7538
|
for (const payload of batch) {
|
|
7650
7539
|
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7651
7540
|
const filePayload = await this.getFilePayload(file);
|
|
7652
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
7653
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
7541
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7654
7542
|
const offlineAssetTypeFieldValuesAttachment = offline({
|
|
7655
7543
|
file: URL.createObjectURL(file),
|
|
7656
7544
|
file_type: file.type,
|
|
@@ -7690,8 +7578,7 @@ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7690
7578
|
});
|
|
7691
7579
|
});
|
|
7692
7580
|
Promise.all(promises).then((result) => {
|
|
7693
|
-
for (const res of result)
|
|
7694
|
-
this.processPresignedUrls(res.presigned_urls);
|
|
7581
|
+
for (const res of result) this.processPresignedUrls(res.presigned_urls);
|
|
7695
7582
|
const attachments = result.flatMap((res) => res.attachments);
|
|
7696
7583
|
this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
|
|
7697
7584
|
}).catch((error) => {
|
|
@@ -7751,8 +7638,7 @@ class IssueTypeFieldsAttachmentService extends BaseUploadService {
|
|
|
7751
7638
|
for (const payload of payloads) {
|
|
7752
7639
|
const { fieldsRevisionId, fieldIdentifier, file } = payload;
|
|
7753
7640
|
const filePayload = await this.getFilePayload(file);
|
|
7754
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
7755
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
7641
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7756
7642
|
const offlineIssueTypeFieldsAttachment = offline({
|
|
7757
7643
|
file: URL.createObjectURL(file),
|
|
7758
7644
|
file_type: file.type,
|
|
@@ -7866,8 +7752,7 @@ class IssueTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
|
7866
7752
|
for (const payload of payloads) {
|
|
7867
7753
|
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7868
7754
|
const filePayload = await this.getFilePayload(file);
|
|
7869
|
-
if (!(filePayload.sha1 in filePayloads))
|
|
7870
|
-
filePayloads[filePayload.sha1] = filePayload;
|
|
7755
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7871
7756
|
const offlineIssueTypeFieldValuesAttachment = offline({
|
|
7872
7757
|
file: URL.createObjectURL(file),
|
|
7873
7758
|
file_type: file.type,
|
|
@@ -8131,6 +8016,7 @@ export {
|
|
|
8131
8016
|
ProjectFileService,
|
|
8132
8017
|
ProjectService,
|
|
8133
8018
|
TeamService,
|
|
8019
|
+
UNKNOWN_ERROR_MESSAGE,
|
|
8134
8020
|
UserService,
|
|
8135
8021
|
VERSION_REDUCER_KEY,
|
|
8136
8022
|
VerificationCodeType,
|