@overmap-ai/core 1.0.71-mapbox.5 → 1.0.71-mapbox.6
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 +123 -247
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +132 -255
- 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 +13 -12
- 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 +13 -12
- 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 +7 -6
- 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 +13 -12
- 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/FormService.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 +13 -12
- package/dist/sdk/services/IssueCommentService.d.ts +5 -4
- package/dist/sdk/services/IssueService.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 +13 -12
- 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 +34 -34
- 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/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 +35 -24
- package/dist/store/slices/index.d.ts +38 -38
- 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/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 +40 -29
- 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 +3 -2
- 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/forms.d.ts +4 -3
- package/dist/typings/models/geo.d.ts +2 -1
- package/dist/typings/models/geoImages.d.ts +4 -3
- package/dist/typings/models/index.d.ts +21 -21
- package/dist/typings/models/issueTypes.d.ts +3 -2
- package/dist/typings/models/issues.d.ts +7 -6
- 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 +2 -1
- 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 +20 -21
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)}`;
|
|
@@ -367,7 +358,7 @@ function hashFile(file) {
|
|
|
367
358
|
reader.onload = () => {
|
|
368
359
|
const fileResult = reader.result;
|
|
369
360
|
if (!fileResult) {
|
|
370
|
-
reject();
|
|
361
|
+
reject(new Error("FileReader did not return a valid ArrayBuffer."));
|
|
371
362
|
return;
|
|
372
363
|
}
|
|
373
364
|
void crypto.subtle.digest("SHA-1", fileResult).then((hash) => {
|
|
@@ -381,8 +372,7 @@ function hashFile(file) {
|
|
|
381
372
|
function getFileIdentifier(file) {
|
|
382
373
|
if (!file.name || !file.type || !file.size) {
|
|
383
374
|
const message = "File has no name, type, and/or size";
|
|
384
|
-
|
|
385
|
-
throw new Error(`${message}.`);
|
|
375
|
+
throw new Error(message);
|
|
386
376
|
}
|
|
387
377
|
return `${file.name}&${file.type}${file.size}`;
|
|
388
378
|
}
|
|
@@ -502,21 +492,19 @@ const OUTBOX_RETRY_DELAY = 6e4;
|
|
|
502
492
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
503
493
|
const EMPTY_OBJECT = Object.freeze({});
|
|
504
494
|
let debug = false;
|
|
505
|
-
const REACT_APP_DEBUG_MEMOIZATION =
|
|
495
|
+
const REACT_APP_DEBUG_MEMOIZATION = "";
|
|
506
496
|
if (["true", "1"].includes(REACT_APP_DEBUG_MEMOIZATION.toLowerCase())) {
|
|
507
497
|
debug = true;
|
|
508
498
|
}
|
|
509
499
|
function shallowEqual(objA, objB) {
|
|
510
|
-
if (objA === objB)
|
|
511
|
-
return true;
|
|
500
|
+
if (objA === objB) return true;
|
|
512
501
|
if (typeof objA !== typeof objB) {
|
|
513
502
|
return false;
|
|
514
503
|
}
|
|
515
504
|
const keysA = Object.keys(objA);
|
|
516
505
|
const keysB = Object.keys(objB);
|
|
517
506
|
const keysALength = keysA.length;
|
|
518
|
-
if (keysALength !== keysB.length)
|
|
519
|
-
return false;
|
|
507
|
+
if (keysALength !== keysB.length) return false;
|
|
520
508
|
for (let i = 0; i < keysALength; i++) {
|
|
521
509
|
const key = keysA[i];
|
|
522
510
|
if (!Object.prototype.hasOwnProperty.call(objB, key) || objA[key] !== objB[key]) {
|
|
@@ -543,11 +531,9 @@ function memoize(func) {
|
|
|
543
531
|
};
|
|
544
532
|
}
|
|
545
533
|
function areArraysEqual(first, second) {
|
|
546
|
-
if (first.length !== second.length)
|
|
547
|
-
return false;
|
|
534
|
+
if (first.length !== second.length) return false;
|
|
548
535
|
for (let i = 0; i < first.length; i++) {
|
|
549
|
-
if (first[i] !== second[i])
|
|
550
|
-
return false;
|
|
536
|
+
if (first[i] !== second[i]) return false;
|
|
551
537
|
}
|
|
552
538
|
return true;
|
|
553
539
|
}
|
|
@@ -595,13 +581,11 @@ const generateBadgeColors = (rawColor) => {
|
|
|
595
581
|
return { backgroundColor, textColor };
|
|
596
582
|
};
|
|
597
583
|
const getLocalDateString = memoize((date) => {
|
|
598
|
-
if (!date)
|
|
599
|
-
return "";
|
|
584
|
+
if (!date) return "";
|
|
600
585
|
const asDate = new Date(date);
|
|
601
586
|
const isThisYear = asDate.getFullYear() === today.getFullYear();
|
|
602
587
|
const options = { day: "numeric", month: "short" };
|
|
603
|
-
if (!isThisYear)
|
|
604
|
-
options.year = "numeric";
|
|
588
|
+
if (!isThisYear) options.year = "numeric";
|
|
605
589
|
return asDate.toLocaleDateString([], options);
|
|
606
590
|
});
|
|
607
591
|
const relative = new Intl.RelativeTimeFormat([], { style: "long", numeric: "auto" });
|
|
@@ -612,10 +596,10 @@ const isToday = (date) => {
|
|
|
612
596
|
};
|
|
613
597
|
const getLocalRelativeDateString = memoize((date, min, max) => {
|
|
614
598
|
const days = Math.round((new Date(date).getTime() - today.getTime()) / msInDay);
|
|
615
|
-
if (days < min || days > max)
|
|
616
|
-
return getLocalDateString(date);
|
|
599
|
+
if (days < min || days > max) return getLocalDateString(date);
|
|
617
600
|
return relative.format(days, "days");
|
|
618
601
|
});
|
|
602
|
+
_a = Symbol.toStringTag;
|
|
619
603
|
class DeferredPromise {
|
|
620
604
|
constructor() {
|
|
621
605
|
__publicField(this, _a, "Promise");
|
|
@@ -640,14 +624,12 @@ class DeferredPromise {
|
|
|
640
624
|
return this._promise.catch(onRejected);
|
|
641
625
|
}
|
|
642
626
|
resolve(value) {
|
|
643
|
-
if (!this._resolve)
|
|
644
|
-
throw new Error("No resolve callback");
|
|
627
|
+
if (!this._resolve) throw new Error("No resolve callback");
|
|
645
628
|
this._resolve(value);
|
|
646
629
|
this._state = "fulfilled";
|
|
647
630
|
}
|
|
648
631
|
reject(reason) {
|
|
649
|
-
if (!this._reject)
|
|
650
|
-
throw reason;
|
|
632
|
+
if (!this._reject) throw reason;
|
|
651
633
|
this._reject(reason);
|
|
652
634
|
this._state = "rejected";
|
|
653
635
|
}
|
|
@@ -655,35 +637,6 @@ class DeferredPromise {
|
|
|
655
637
|
throw new Error("`finally` not implemented");
|
|
656
638
|
}
|
|
657
639
|
}
|
|
658
|
-
_a = Symbol.toStringTag;
|
|
659
|
-
var randomString = function randomString2() {
|
|
660
|
-
return Math.random().toString(36).substring(7).split("").join(".");
|
|
661
|
-
};
|
|
662
|
-
({
|
|
663
|
-
INIT: "@@redux/INIT" + randomString(),
|
|
664
|
-
REPLACE: "@@redux/REPLACE" + randomString(),
|
|
665
|
-
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
|
666
|
-
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
function compose() {
|
|
670
|
-
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
671
|
-
funcs[_key] = arguments[_key];
|
|
672
|
-
}
|
|
673
|
-
if (funcs.length === 0) {
|
|
674
|
-
return function(arg) {
|
|
675
|
-
return arg;
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
if (funcs.length === 1) {
|
|
679
|
-
return funcs[0];
|
|
680
|
-
}
|
|
681
|
-
return funcs.reduce(function(a, b) {
|
|
682
|
-
return function() {
|
|
683
|
-
return a(b.apply(void 0, arguments));
|
|
684
|
-
};
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
640
|
const VERSION_REDUCER_KEY$1 = "versioning";
|
|
688
641
|
const latestVersion = () => migrations.length - 1;
|
|
689
642
|
const initialVersioning = (state) => {
|
|
@@ -704,8 +657,7 @@ const wrapMigration = (migrator) => (state) => {
|
|
|
704
657
|
if (state === void 0) {
|
|
705
658
|
state = {};
|
|
706
659
|
}
|
|
707
|
-
if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion())
|
|
708
|
-
return state;
|
|
660
|
+
if (((_a2 = state[VERSION_REDUCER_KEY$1]) == null ? void 0 : _a2.version) === latestVersion()) return state;
|
|
709
661
|
return migrator(state);
|
|
710
662
|
};
|
|
711
663
|
const migrations = [initialVersioning, signOut, signOut, createOutboxState];
|
|
@@ -893,8 +845,7 @@ const selectAssetsByIds = restructureCreateSelectorWithArgs(
|
|
|
893
845
|
const assets = [];
|
|
894
846
|
for (const assetId of assetIds) {
|
|
895
847
|
const asset = assetsMapping[assetId];
|
|
896
|
-
if (asset)
|
|
897
|
-
assets.push(asset);
|
|
848
|
+
if (asset) assets.push(asset);
|
|
898
849
|
}
|
|
899
850
|
return fallbackToEmptyArray(assets);
|
|
900
851
|
})
|
|
@@ -953,17 +904,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
|
|
|
953
904
|
[selectAssetAttachments, (_state, assetId) => assetId],
|
|
954
905
|
(attachments, assetId) => {
|
|
955
906
|
const attachmentsOfAsset = attachments.filter(({ asset }) => assetId === asset);
|
|
956
|
-
const fileAttachments =
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
({ file_type }) => !file_type || !file_type.startsWith("image/")
|
|
960
|
-
)
|
|
907
|
+
const fileAttachments = attachmentsOfAsset.filter(
|
|
908
|
+
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
909
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
961
910
|
);
|
|
962
|
-
const imageAttachments =
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
({ file_type }) => file_type && file_type.startsWith("image/")
|
|
966
|
-
)
|
|
911
|
+
const imageAttachments = attachmentsOfAsset.filter(
|
|
912
|
+
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
913
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
967
914
|
);
|
|
968
915
|
return { fileAttachments, imageAttachments };
|
|
969
916
|
}
|
|
@@ -1006,8 +953,7 @@ const selectCompletedStagesByAsset = createSelector(
|
|
|
1006
953
|
const completedStagesByAsset = {};
|
|
1007
954
|
for (const stageCompletion of Object.values(completedStagesMapping)) {
|
|
1008
955
|
const { asset, stage, submitted_at } = stageCompletion;
|
|
1009
|
-
if (!completedStagesByAsset[asset])
|
|
1010
|
-
completedStagesByAsset[asset] = {};
|
|
956
|
+
if (!completedStagesByAsset[asset]) completedStagesByAsset[asset] = {};
|
|
1011
957
|
completedStagesByAsset[asset][stage] = submitted_at;
|
|
1012
958
|
}
|
|
1013
959
|
return fallbackToEmptyObject(completedStagesByAsset);
|
|
@@ -1223,11 +1169,11 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
|
|
|
1223
1169
|
const attachmentsOfAssetType = attachments.filter(({ asset_type }) => asset_type === assetTypeId);
|
|
1224
1170
|
const fileAttachments = attachmentsOfAssetType.filter(
|
|
1225
1171
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1226
|
-
({ file_type }) => !file_type
|
|
1172
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
1227
1173
|
);
|
|
1228
1174
|
const imageAttachments = attachmentsOfAssetType.filter(
|
|
1229
1175
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1230
|
-
({ file_type }) => file_type
|
|
1176
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
1231
1177
|
);
|
|
1232
1178
|
return { fileAttachments, imageAttachments };
|
|
1233
1179
|
}
|
|
@@ -1364,8 +1310,7 @@ const selectUploadUrl = (sha1) => (state) => {
|
|
|
1364
1310
|
}
|
|
1365
1311
|
const today2 = (/* @__PURE__ */ new Date()).getTime();
|
|
1366
1312
|
const expiringWithinAnHour = (url.exp ?? today2) - today2 < msPerHour;
|
|
1367
|
-
if (expiringWithinAnHour)
|
|
1368
|
-
return void 0;
|
|
1313
|
+
if (expiringWithinAnHour) return void 0;
|
|
1369
1314
|
return url;
|
|
1370
1315
|
};
|
|
1371
1316
|
const fileReducer = fileSlice.reducer;
|
|
@@ -1394,8 +1339,7 @@ const userSlice = createSlice({
|
|
|
1394
1339
|
state.currentUser = action.payload;
|
|
1395
1340
|
},
|
|
1396
1341
|
setProfilePicture: (state, action) => {
|
|
1397
|
-
if (!state.currentUser)
|
|
1398
|
-
return;
|
|
1342
|
+
if (!state.currentUser) return;
|
|
1399
1343
|
state.currentUser.profile.file = action.payload.file ?? null;
|
|
1400
1344
|
state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
|
|
1401
1345
|
const currentUser = state.users[state.currentUser.id];
|
|
@@ -1739,8 +1683,7 @@ const outboxSlice = createSlice({
|
|
|
1739
1683
|
},
|
|
1740
1684
|
markAsDeleted(state, action) {
|
|
1741
1685
|
const index = state.deletedRequests.indexOf(action.payload);
|
|
1742
|
-
if (index !== -1)
|
|
1743
|
-
state.deletedRequests.splice(index, 1);
|
|
1686
|
+
if (index !== -1) state.deletedRequests.splice(index, 1);
|
|
1744
1687
|
},
|
|
1745
1688
|
_setLatestRetryTime: (state, action) => {
|
|
1746
1689
|
state.latestRetryTime = action.payload;
|
|
@@ -1872,11 +1815,11 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
|
|
|
1872
1815
|
const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
|
|
1873
1816
|
const fileAttachments = attachmentsOfProject.filter(
|
|
1874
1817
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1875
|
-
({ file_type }) => !file_type
|
|
1818
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
1876
1819
|
);
|
|
1877
1820
|
const imageAttachments = attachmentsOfProject.filter(
|
|
1878
1821
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1879
|
-
({ file_type }) => file_type
|
|
1822
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
1880
1823
|
);
|
|
1881
1824
|
return { fileAttachments, imageAttachments };
|
|
1882
1825
|
}
|
|
@@ -1960,8 +1903,7 @@ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
|
|
|
1960
1903
|
[selectFormRevisionMapping, (_state, formId) => formId],
|
|
1961
1904
|
(revisions, formId) => {
|
|
1962
1905
|
const revisionsOfForm = Object.values(revisions).filter((revision) => revision.form === formId);
|
|
1963
|
-
if (revisionsOfForm.length === 0)
|
|
1964
|
-
return void 0;
|
|
1906
|
+
if (revisionsOfForm.length === 0) return void 0;
|
|
1965
1907
|
const sortedRevisions = revisionsOfForm.sort(formRevisionSortFn);
|
|
1966
1908
|
const latestRevision = sortedRevisions[revisionsOfForm.length - 1];
|
|
1967
1909
|
return revisions[latestRevision.offline_id];
|
|
@@ -2033,7 +1975,7 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
2033
1975
|
return [...regularMatches.slice(0, maxResults)];
|
|
2034
1976
|
},
|
|
2035
1977
|
// as the argument is an object, we check the first level of properties for equality
|
|
2036
|
-
{ memoizeOptions: {
|
|
1978
|
+
{ memoizeOptions: { resultEqualityCheck: shallowEqual } }
|
|
2037
1979
|
)
|
|
2038
1980
|
);
|
|
2039
1981
|
const selectFormById = (formId) => (state) => {
|
|
@@ -2112,8 +2054,7 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
2112
2054
|
(submissionsMapping, revisionMapping, formId) => {
|
|
2113
2055
|
const revisionIds = /* @__PURE__ */ new Set();
|
|
2114
2056
|
for (const revision of Object.values(revisionMapping)) {
|
|
2115
|
-
if (revision.form !== formId)
|
|
2116
|
-
continue;
|
|
2057
|
+
if (revision.form !== formId) continue;
|
|
2117
2058
|
revisionIds.add(revision.offline_id);
|
|
2118
2059
|
}
|
|
2119
2060
|
return Object.values(submissionsMapping).filter(
|
|
@@ -2180,8 +2121,7 @@ const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
|
2180
2121
|
],
|
|
2181
2122
|
(issues, forms, formRevisions, submissions, issueId) => {
|
|
2182
2123
|
const issue = issues[issueId];
|
|
2183
|
-
if (!issue)
|
|
2184
|
-
return [];
|
|
2124
|
+
if (!issue) return [];
|
|
2185
2125
|
if (!issue.issue_type) {
|
|
2186
2126
|
return Object.values(submissions).filter((submission) => submission.issue === issueId);
|
|
2187
2127
|
}
|
|
@@ -2238,8 +2178,7 @@ const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
|
|
|
2238
2178
|
],
|
|
2239
2179
|
(assets, forms, formRevisions, submissions, assetId) => {
|
|
2240
2180
|
const asset = assets[assetId];
|
|
2241
|
-
if (!asset)
|
|
2242
|
-
return [];
|
|
2181
|
+
if (!asset) return [];
|
|
2243
2182
|
if (!asset.asset_type) {
|
|
2244
2183
|
return Object.values(submissions).filter((submission) => submission.asset === assetId);
|
|
2245
2184
|
}
|
|
@@ -2615,8 +2554,7 @@ const selectAncestorIdsOfDocument = restructureCreateSelectorWithArgs(
|
|
|
2615
2554
|
createSelector([selectDocumentsMapping, (_state, documentId) => documentId], (mapping, documentId) => {
|
|
2616
2555
|
const listOfAncestors = [];
|
|
2617
2556
|
const document2 = mapping[documentId];
|
|
2618
|
-
if (!document2 || !document2.parent_document)
|
|
2619
|
-
return listOfAncestors;
|
|
2557
|
+
if (!document2 || !document2.parent_document) return listOfAncestors;
|
|
2620
2558
|
let currentAncestor = mapping[document2.parent_document];
|
|
2621
2559
|
while (currentAncestor) {
|
|
2622
2560
|
listOfAncestors.push(currentAncestor.offline_id);
|
|
@@ -2682,11 +2620,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
|
|
|
2682
2620
|
const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
|
|
2683
2621
|
const fileAttachments = attachmentsOfProject.filter(
|
|
2684
2622
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2685
|
-
({ file_type }) => !file_type
|
|
2623
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
2686
2624
|
);
|
|
2687
2625
|
const imageAttachments = attachmentsOfProject.filter(
|
|
2688
2626
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2689
|
-
({ file_type }) => file_type
|
|
2627
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
2690
2628
|
);
|
|
2691
2629
|
return { fileAttachments, imageAttachments };
|
|
2692
2630
|
}
|
|
@@ -2892,11 +2830,11 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
|
|
|
2892
2830
|
const attachmentsOfIssue = attachments.filter(({ issue }) => issue === issueId);
|
|
2893
2831
|
const fileAttachments = attachmentsOfIssue.filter(
|
|
2894
2832
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2895
|
-
({ file_type }) => !file_type
|
|
2833
|
+
({ file_type }) => !file_type.startsWith("image/")
|
|
2896
2834
|
);
|
|
2897
2835
|
const imageAttachments = attachmentsOfIssue.filter(
|
|
2898
2836
|
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2899
|
-
({ file_type }) => file_type
|
|
2837
|
+
({ file_type }) => file_type.startsWith("image/")
|
|
2900
2838
|
);
|
|
2901
2839
|
return { fileAttachments, imageAttachments };
|
|
2902
2840
|
}
|
|
@@ -3045,6 +2983,7 @@ class BaseService {
|
|
|
3045
2983
|
async enqueueRequest(requestDetails) {
|
|
3046
2984
|
return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
|
|
3047
2985
|
}
|
|
2986
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3048
2987
|
dispatch(action) {
|
|
3049
2988
|
this.client.store.dispatch(action);
|
|
3050
2989
|
}
|
|
@@ -3114,9 +3053,8 @@ function getOutboxCoordinator() {
|
|
|
3114
3053
|
__OUTBOX_COORDINATOR = coordinator;
|
|
3115
3054
|
return coordinator;
|
|
3116
3055
|
}
|
|
3117
|
-
const persistCallback = (
|
|
3118
|
-
if (
|
|
3119
|
-
throw err;
|
|
3056
|
+
const persistCallback = (e) => {
|
|
3057
|
+
if (e) throw e;
|
|
3120
3058
|
const clientStore2 = getClientStore();
|
|
3121
3059
|
if (clientStore2) {
|
|
3122
3060
|
clientStore2.dispatch({ type: "rehydrated/setRehydrated", payload: true });
|
|
@@ -3180,14 +3118,11 @@ function extractResponseFromError(error) {
|
|
|
3180
3118
|
const knownKeys = ["ok", "redirect", "clientError", "serverError", "error"];
|
|
3181
3119
|
return typeof response === "object" && response !== null && knownKeys.every((key) => key in response);
|
|
3182
3120
|
}
|
|
3183
|
-
if (isResponse(error))
|
|
3184
|
-
return error;
|
|
3121
|
+
if (isResponse(error)) return error;
|
|
3185
3122
|
if (typeof error === "object" && error !== null) {
|
|
3186
3123
|
const typedError = error;
|
|
3187
|
-
if (isResponse(typedError.response))
|
|
3188
|
-
|
|
3189
|
-
if (typedError.response && isResponse(typedError.response.response))
|
|
3190
|
-
return typedError.response.response;
|
|
3124
|
+
if (isResponse(typedError.response)) return typedError.response;
|
|
3125
|
+
if (typedError.response && isResponse(typedError.response.response)) return typedError.response.response;
|
|
3191
3126
|
}
|
|
3192
3127
|
return void 0;
|
|
3193
3128
|
}
|
|
@@ -3228,15 +3163,11 @@ async function performRequest(action, client) {
|
|
|
3228
3163
|
const addPayload = (req) => {
|
|
3229
3164
|
if (attachmentHash) {
|
|
3230
3165
|
const s3url = requestDetails.s3url;
|
|
3231
|
-
if (!s3url)
|
|
3232
|
-
|
|
3233
|
-
if (
|
|
3234
|
-
throw new Error(`S3 URL warning for file ${attachmentHash}`);
|
|
3235
|
-
if (!file)
|
|
3236
|
-
throw new Error(`No file for file ${attachmentHash}`);
|
|
3166
|
+
if (!s3url) throw new Error(`No S3 URL for file ${attachmentHash}`);
|
|
3167
|
+
if ("warning" in s3url) throw new Error(`S3 URL warning for file ${attachmentHash}`);
|
|
3168
|
+
if (!file) throw new Error(`No file for file ${attachmentHash}`);
|
|
3237
3169
|
const s3Sha1Checksum = s3url.fields["x-amz-checksum-sha1"];
|
|
3238
|
-
if (!s3Sha1Checksum)
|
|
3239
|
-
throw new Error(`No checksum for file ${attachmentHash}`);
|
|
3170
|
+
if (!s3Sha1Checksum) throw new Error(`No checksum for file ${attachmentHash}`);
|
|
3240
3171
|
return req.set("x-amz-checksum-sha1", s3Sha1Checksum).field({ ...payload, ...s3url.fields }).attach("file", file);
|
|
3241
3172
|
}
|
|
3242
3173
|
return req.send(payload);
|
|
@@ -3296,8 +3227,7 @@ class MiddlewareChainerPrivate {
|
|
|
3296
3227
|
this.compile = this.compile.bind(this);
|
|
3297
3228
|
}
|
|
3298
3229
|
then(next) {
|
|
3299
|
-
if (this._previous)
|
|
3300
|
-
this._previous.next = next;
|
|
3230
|
+
if (this._previous) this._previous.next = next;
|
|
3301
3231
|
this._all.push(next);
|
|
3302
3232
|
this._previous = next;
|
|
3303
3233
|
return {
|
|
@@ -3325,11 +3255,9 @@ class OfflineMiddleware {
|
|
|
3325
3255
|
} else {
|
|
3326
3256
|
console.debug("Middleware finished. Performing request:", action);
|
|
3327
3257
|
const clientStore2 = getClientStore();
|
|
3328
|
-
if (!clientStore2)
|
|
3329
|
-
throw new Error("Client store not set");
|
|
3258
|
+
if (!clientStore2) throw new Error("Client store not set");
|
|
3330
3259
|
const clientSDK2 = getClientSDK();
|
|
3331
|
-
if (!clientSDK2)
|
|
3332
|
-
throw new Error("Client SDK not set");
|
|
3260
|
+
if (!clientSDK2) throw new Error("Client SDK not set");
|
|
3333
3261
|
return performRequest(action, clientSDK2);
|
|
3334
3262
|
}
|
|
3335
3263
|
}
|
|
@@ -3350,20 +3278,6 @@ function runMiddleware(action) {
|
|
|
3350
3278
|
return (_a2 = allMiddleware[0]) == null ? void 0 : _a2.run(action);
|
|
3351
3279
|
}
|
|
3352
3280
|
const discardStatuses = [400, 409, 403, 404, 405, 500];
|
|
3353
|
-
const statusMessages = {
|
|
3354
|
-
403: { title: "Forbidden", description: "You are not authorized to perform this action.", accentColor: "red" },
|
|
3355
|
-
404: { title: "Not found", description: "The requested resource was not found.", accentColor: "red" },
|
|
3356
|
-
405: {
|
|
3357
|
-
title: "Not supported",
|
|
3358
|
-
description: "It's not you. It's us. Sorry for the inconvenience.",
|
|
3359
|
-
accentColor: "red"
|
|
3360
|
-
},
|
|
3361
|
-
500: {
|
|
3362
|
-
title: "Server error",
|
|
3363
|
-
description: "Our server seems to be experiencing problems at the moment. We have been alerted and will fix the problem as soon as possible.",
|
|
3364
|
-
accentColor: "red"
|
|
3365
|
-
}
|
|
3366
|
-
};
|
|
3367
3281
|
function discard(reason, action, retries = 0) {
|
|
3368
3282
|
var _a2;
|
|
3369
3283
|
console.debug(
|
|
@@ -3416,14 +3330,6 @@ function discard(reason, action, retries = 0) {
|
|
|
3416
3330
|
}
|
|
3417
3331
|
if (status !== void 0 && discardStatuses.includes(status)) {
|
|
3418
3332
|
console.warn("Discarding request due to error:", reason, "\nAction:", action);
|
|
3419
|
-
const message = statusMessages[status];
|
|
3420
|
-
if (message) {
|
|
3421
|
-
if (unsafeShowToast) {
|
|
3422
|
-
unsafeShowToast(message);
|
|
3423
|
-
} else {
|
|
3424
|
-
console.error(`Could not display toast for status ${status} because there is no toast handle.`);
|
|
3425
|
-
}
|
|
3426
|
-
}
|
|
3427
3333
|
const coordinator2 = getOutboxCoordinator();
|
|
3428
3334
|
if (!coordinator2) {
|
|
3429
3335
|
throw new Error("Outbox coordinator not set");
|
|
@@ -3451,6 +3357,7 @@ function retry(_action, _retries) {
|
|
|
3451
3357
|
}
|
|
3452
3358
|
class BaseSDK {
|
|
3453
3359
|
constructor(store) {
|
|
3360
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3454
3361
|
__publicField(this, "store");
|
|
3455
3362
|
this.store = store;
|
|
3456
3363
|
}
|
|
@@ -3486,9 +3393,13 @@ class BaseSDK {
|
|
|
3486
3393
|
};
|
|
3487
3394
|
performRequest(fullOfflineAction, this).then((result) => {
|
|
3488
3395
|
promise.resolve(result.body);
|
|
3489
|
-
}).catch((
|
|
3490
|
-
discard(
|
|
3491
|
-
|
|
3396
|
+
}).catch((e) => {
|
|
3397
|
+
discard(e, fullOfflineAction);
|
|
3398
|
+
if (e instanceof Error) {
|
|
3399
|
+
promise.reject(e);
|
|
3400
|
+
} else {
|
|
3401
|
+
promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
|
|
3402
|
+
}
|
|
3492
3403
|
});
|
|
3493
3404
|
} else {
|
|
3494
3405
|
const innerPromise = this.store.dispatch(
|
|
@@ -3542,10 +3453,8 @@ class BaseAuthService extends BaseService {
|
|
|
3542
3453
|
}
|
|
3543
3454
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
3544
3455
|
function parseTokens(response) {
|
|
3545
|
-
if (!response.access)
|
|
3546
|
-
|
|
3547
|
-
if (!response.refresh)
|
|
3548
|
-
throw new Error("Missing refresh token");
|
|
3456
|
+
if (!response.access) throw new Error("Missing access token");
|
|
3457
|
+
if (!response.refresh) throw new Error("Missing refresh token");
|
|
3549
3458
|
return { accessToken: response.access, refreshToken: response.refresh };
|
|
3550
3459
|
}
|
|
3551
3460
|
class JWTService extends BaseAuthService {
|
|
@@ -3582,8 +3491,7 @@ class JWTService extends BaseAuthService {
|
|
|
3582
3491
|
this.clearAuth();
|
|
3583
3492
|
return void 0;
|
|
3584
3493
|
}
|
|
3585
|
-
if (!response.access)
|
|
3586
|
-
throw new Error("Missing access token");
|
|
3494
|
+
if (!response.access) throw new Error("Missing access token");
|
|
3587
3495
|
return { accessToken: response.access, refreshToken: response.refresh ?? this.getRefreshToken() };
|
|
3588
3496
|
});
|
|
3589
3497
|
}
|
|
@@ -3639,8 +3547,7 @@ class JWTService extends BaseAuthService {
|
|
|
3639
3547
|
return `Bearer ${accessToken}`;
|
|
3640
3548
|
}
|
|
3641
3549
|
async prepareAuth() {
|
|
3642
|
-
if (!this.tokenIsExpiringSoon())
|
|
3643
|
-
return;
|
|
3550
|
+
if (!this.tokenIsExpiringSoon()) return;
|
|
3644
3551
|
console.debug(this.constructor.name, "preparing auth");
|
|
3645
3552
|
try {
|
|
3646
3553
|
await this.renewTokens();
|
|
@@ -3648,7 +3555,11 @@ class JWTService extends BaseAuthService {
|
|
|
3648
3555
|
if (e instanceof APIError) {
|
|
3649
3556
|
this.clearAuth();
|
|
3650
3557
|
}
|
|
3651
|
-
|
|
3558
|
+
if (e instanceof Error) {
|
|
3559
|
+
return Promise.reject(e);
|
|
3560
|
+
} else {
|
|
3561
|
+
return Promise.reject(new Error((e ?? UNKNOWN_ERROR_MESSAGE).toString()));
|
|
3562
|
+
}
|
|
3652
3563
|
}
|
|
3653
3564
|
}
|
|
3654
3565
|
/* if not successfull in gracefully handling an unauthorized response, throw and APIError */
|
|
@@ -3679,7 +3590,7 @@ class JWTService extends BaseAuthService {
|
|
|
3679
3590
|
async initAuth(payload) {
|
|
3680
3591
|
const uuid = v4();
|
|
3681
3592
|
console.debug(this.constructor.name, "Initiating auth");
|
|
3682
|
-
|
|
3593
|
+
return this.enqueueRequest({
|
|
3683
3594
|
uuid,
|
|
3684
3595
|
description: "Get token pair",
|
|
3685
3596
|
method: HttpMethod.POST,
|
|
@@ -3687,25 +3598,12 @@ class JWTService extends BaseAuthService {
|
|
|
3687
3598
|
payload,
|
|
3688
3599
|
isAuthNeeded: false,
|
|
3689
3600
|
checkAuth: false,
|
|
3601
|
+
immediate: true,
|
|
3690
3602
|
blockers: [],
|
|
3691
3603
|
blocks: []
|
|
3692
|
-
}).then(
|
|
3693
|
-
|
|
3694
|
-
let timedOut = false;
|
|
3695
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
3696
|
-
setTimeout(() => {
|
|
3697
|
-
timedOut = true;
|
|
3698
|
-
this.dispatch(markForDeletion(uuid));
|
|
3699
|
-
reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
|
|
3700
|
-
}, timeout * 1e3);
|
|
3701
|
-
});
|
|
3702
|
-
const successPromise = promise.then((tokens) => {
|
|
3703
|
-
if (timedOut) {
|
|
3704
|
-
return void 0;
|
|
3705
|
-
}
|
|
3706
|
-
this.setTokens(tokens);
|
|
3604
|
+
}).then((tokens) => {
|
|
3605
|
+
this.setTokens(parseTokens(tokens));
|
|
3707
3606
|
});
|
|
3708
|
-
return Promise.race([timeoutPromise, successPromise]);
|
|
3709
3607
|
}
|
|
3710
3608
|
}
|
|
3711
3609
|
class BaseApiService extends BaseService {
|
|
@@ -3868,8 +3766,7 @@ class AssetService extends BaseApiService {
|
|
|
3868
3766
|
const { store } = this.client;
|
|
3869
3767
|
const state = store.getState();
|
|
3870
3768
|
const assetToBeDeleted = selectAssetById(id)(state);
|
|
3871
|
-
if (!assetToBeDeleted)
|
|
3872
|
-
throw new Error(`No asset with id ${id} found in the store`);
|
|
3769
|
+
if (!assetToBeDeleted) throw new Error(`No asset with id ${id} found in the store`);
|
|
3873
3770
|
const attachmentsOfAssets = selectAttachmentsOfAsset(id)(state);
|
|
3874
3771
|
const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(id)(state);
|
|
3875
3772
|
const issueAssociations = selectIssueAssociationsOfAsset(id)(state);
|
|
@@ -3892,12 +3789,12 @@ class AssetService extends BaseApiService {
|
|
|
3892
3789
|
url: `/assets/${id}/`,
|
|
3893
3790
|
blockers: [id],
|
|
3894
3791
|
blocks: []
|
|
3895
|
-
}).catch((
|
|
3792
|
+
}).catch((e) => {
|
|
3896
3793
|
this.dispatch(addAsset(assetToBeDeleted));
|
|
3897
3794
|
this.dispatch(addAssetAttachments(attachmentsOfAssets));
|
|
3898
3795
|
this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
|
|
3899
3796
|
this.dispatch(addIssueAssociations(issueAssociations));
|
|
3900
|
-
throw
|
|
3797
|
+
throw e;
|
|
3901
3798
|
});
|
|
3902
3799
|
}
|
|
3903
3800
|
bulkAdd(payloads, assetTypeId, batchSize) {
|
|
@@ -3921,8 +3818,7 @@ class AssetService extends BaseApiService {
|
|
|
3921
3818
|
const { batchId, payload } = assetBatch;
|
|
3922
3819
|
const batchAssetOfflineIds = payload.assets.map((c) => c.offline_id);
|
|
3923
3820
|
const blockers = [assetTypeId];
|
|
3924
|
-
if (prevBatchId)
|
|
3925
|
-
blockers.push(prevBatchId);
|
|
3821
|
+
if (prevBatchId) blockers.push(prevBatchId);
|
|
3926
3822
|
const blocks = batchAssetOfflineIds;
|
|
3927
3823
|
blocks.push(batchId);
|
|
3928
3824
|
const promise = this.enqueueRequest({
|
|
@@ -4136,8 +4032,7 @@ class AssetStageService extends BaseApiService {
|
|
|
4136
4032
|
update(payload) {
|
|
4137
4033
|
const { store } = this.client;
|
|
4138
4034
|
const assetStage = selectAssetStageById(payload.offline_id)(store.getState());
|
|
4139
|
-
if (!assetStage)
|
|
4140
|
-
throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
|
|
4035
|
+
if (!assetStage) throw new Error(`No asset stage with id ${payload.offline_id} found in the store`);
|
|
4141
4036
|
const updatedAssetStage = {
|
|
4142
4037
|
...assetStage,
|
|
4143
4038
|
...payload
|
|
@@ -4731,7 +4626,18 @@ class IssueService extends BaseApiService {
|
|
|
4731
4626
|
]) {
|
|
4732
4627
|
if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
|
|
4733
4628
|
switch (issueUpdateChange) {
|
|
4734
|
-
case
|
|
4629
|
+
case IssueUpdateChange.PRIORITY:
|
|
4630
|
+
case IssueUpdateChange.STATUS: {
|
|
4631
|
+
const val = payload[issueUpdateChange];
|
|
4632
|
+
changes[issueUpdateChange] = val !== void 0 ? Number(val) : null;
|
|
4633
|
+
break;
|
|
4634
|
+
}
|
|
4635
|
+
case IssueUpdateChange.DUE_DATE:
|
|
4636
|
+
case IssueUpdateChange.DESCRIPTION:
|
|
4637
|
+
case IssueUpdateChange.TITLE:
|
|
4638
|
+
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
4639
|
+
break;
|
|
4640
|
+
case IssueUpdateChange.CATEGORY: {
|
|
4735
4641
|
let categoryOrNull = null;
|
|
4736
4642
|
const categoryIdOrNull = payload[issueUpdateChange];
|
|
4737
4643
|
if (categoryIdOrNull) {
|
|
@@ -4748,7 +4654,7 @@ class IssueService extends BaseApiService {
|
|
|
4748
4654
|
} : null;
|
|
4749
4655
|
break;
|
|
4750
4656
|
}
|
|
4751
|
-
case
|
|
4657
|
+
case IssueUpdateChange.ASSIGNED_TO: {
|
|
4752
4658
|
let userOrNull = null;
|
|
4753
4659
|
const userIdOrNull = payload[issueUpdateChange];
|
|
4754
4660
|
if (userIdOrNull) {
|
|
@@ -4764,20 +4670,6 @@ class IssueService extends BaseApiService {
|
|
|
4764
4670
|
} : null;
|
|
4765
4671
|
break;
|
|
4766
4672
|
}
|
|
4767
|
-
case "description":
|
|
4768
|
-
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
4769
|
-
break;
|
|
4770
|
-
case "title":
|
|
4771
|
-
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
4772
|
-
break;
|
|
4773
|
-
case "priority":
|
|
4774
|
-
changes[issueUpdateChange] = payload[issueUpdateChange];
|
|
4775
|
-
break;
|
|
4776
|
-
case "status":
|
|
4777
|
-
changes[issueUpdateChange] = payload[issueUpdateChange];
|
|
4778
|
-
break;
|
|
4779
|
-
case "due_date":
|
|
4780
|
-
changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
|
|
4781
4673
|
}
|
|
4782
4674
|
}
|
|
4783
4675
|
}
|
|
@@ -5488,12 +5380,9 @@ class FormService extends BaseUploadService {
|
|
|
5488
5380
|
blockers: [projectId.toString()],
|
|
5489
5381
|
blocks: []
|
|
5490
5382
|
});
|
|
5491
|
-
for (const form of projectFormsResult.forms)
|
|
5492
|
-
|
|
5493
|
-
for (const
|
|
5494
|
-
revisions.push(revision);
|
|
5495
|
-
for (const attachment of projectFormsResult.attachments)
|
|
5496
|
-
attachments.push(attachment);
|
|
5383
|
+
for (const form of projectFormsResult.forms) forms.push(form);
|
|
5384
|
+
for (const revision of projectFormsResult.revisions) revisions.push(revision);
|
|
5385
|
+
for (const attachment of projectFormsResult.attachments) attachments.push(attachment);
|
|
5497
5386
|
const organizationFormsResult = await this.enqueueRequest({
|
|
5498
5387
|
description: "Fetch organization forms",
|
|
5499
5388
|
method: HttpMethod.GET,
|
|
@@ -5501,12 +5390,9 @@ class FormService extends BaseUploadService {
|
|
|
5501
5390
|
blockers: [projectId.toString()],
|
|
5502
5391
|
blocks: []
|
|
5503
5392
|
});
|
|
5504
|
-
for (const form of organizationFormsResult.forms)
|
|
5505
|
-
|
|
5506
|
-
for (const
|
|
5507
|
-
revisions.push(revision);
|
|
5508
|
-
for (const attachment of organizationFormsResult.attachments)
|
|
5509
|
-
attachments.push(attachment);
|
|
5393
|
+
for (const form of organizationFormsResult.forms) forms.push(form);
|
|
5394
|
+
for (const revision of organizationFormsResult.revisions) revisions.push(revision);
|
|
5395
|
+
for (const attachment of organizationFormsResult.attachments) attachments.push(attachment);
|
|
5510
5396
|
const assetTypeFormsResult = await this.enqueueRequest({
|
|
5511
5397
|
description: "Fetch asset type forms",
|
|
5512
5398
|
method: HttpMethod.GET,
|
|
@@ -5514,12 +5400,9 @@ class FormService extends BaseUploadService {
|
|
|
5514
5400
|
blockers: [projectId.toString()],
|
|
5515
5401
|
blocks: []
|
|
5516
5402
|
});
|
|
5517
|
-
for (const form of assetTypeFormsResult.forms)
|
|
5518
|
-
|
|
5519
|
-
for (const
|
|
5520
|
-
revisions.push(revision);
|
|
5521
|
-
for (const attachment of assetTypeFormsResult.attachments)
|
|
5522
|
-
attachments.push(attachment);
|
|
5403
|
+
for (const form of assetTypeFormsResult.forms) forms.push(form);
|
|
5404
|
+
for (const revision of assetTypeFormsResult.revisions) revisions.push(revision);
|
|
5405
|
+
for (const attachment of assetTypeFormsResult.attachments) attachments.push(attachment);
|
|
5523
5406
|
const issueTypeFormsResult = await this.enqueueRequest({
|
|
5524
5407
|
description: "Fetch issue type forms",
|
|
5525
5408
|
method: HttpMethod.GET,
|
|
@@ -5527,12 +5410,9 @@ class FormService extends BaseUploadService {
|
|
|
5527
5410
|
blockers: [projectId.toString()],
|
|
5528
5411
|
blocks: []
|
|
5529
5412
|
});
|
|
5530
|
-
for (const form of issueTypeFormsResult.forms)
|
|
5531
|
-
|
|
5532
|
-
for (const
|
|
5533
|
-
revisions.push(revision);
|
|
5534
|
-
for (const attachment of issueTypeFormsResult.attachments)
|
|
5535
|
-
attachments.push(attachment);
|
|
5413
|
+
for (const form of issueTypeFormsResult.forms) forms.push(form);
|
|
5414
|
+
for (const revision of issueTypeFormsResult.revisions) revisions.push(revision);
|
|
5415
|
+
for (const attachment of issueTypeFormsResult.attachments) attachments.push(attachment);
|
|
5536
5416
|
this.dispatch(initializeForms(forms));
|
|
5537
5417
|
this.dispatch(initializeFormRevisions(revisions));
|
|
5538
5418
|
this.dispatch(initializeFormRevisionAttachments(attachments));
|
|
@@ -5743,8 +5623,7 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5743
5623
|
const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
|
|
5744
5624
|
const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
|
|
5745
5625
|
const blockers = batchAssetIds;
|
|
5746
|
-
if (prevBatchId)
|
|
5747
|
-
blockers.push(prevBatchId);
|
|
5626
|
+
if (prevBatchId) blockers.push(prevBatchId);
|
|
5748
5627
|
const blocks = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
|
|
5749
5628
|
const promise = this.enqueueRequest({
|
|
5750
5629
|
description: "Bulk add form submissions",
|
|
@@ -5764,10 +5643,8 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5764
5643
|
const createdSubmissions = [];
|
|
5765
5644
|
const createdAttachments = [];
|
|
5766
5645
|
for (const result of results) {
|
|
5767
|
-
for (const createdSubmission of result.submissions)
|
|
5768
|
-
|
|
5769
|
-
for (const createdAttachment of result.attachments)
|
|
5770
|
-
createdAttachments.push(createdAttachment);
|
|
5646
|
+
for (const createdSubmission of result.submissions) createdSubmissions.push(createdSubmission);
|
|
5647
|
+
for (const createdAttachment of result.attachments) createdAttachments.push(createdAttachment);
|
|
5771
5648
|
}
|
|
5772
5649
|
this.dispatch(addFormSubmissions(createdSubmissions));
|
|
5773
5650
|
this.dispatch(addFormSubmissionAttachments(createdAttachments));
|
|
@@ -5963,9 +5840,9 @@ class WorkspaceService extends BaseApiService {
|
|
|
5963
5840
|
blockers: [id],
|
|
5964
5841
|
blocks: []
|
|
5965
5842
|
});
|
|
5966
|
-
void promise.catch((
|
|
5843
|
+
void promise.catch((e) => {
|
|
5967
5844
|
this.dispatch(addWorkspace(originalWorkspace));
|
|
5968
|
-
throw
|
|
5845
|
+
throw e;
|
|
5969
5846
|
});
|
|
5970
5847
|
return promise;
|
|
5971
5848
|
}
|
|
@@ -6026,7 +5903,7 @@ const summarizeEvery = 20;
|
|
|
6026
5903
|
class FileService extends BaseApiService {
|
|
6027
5904
|
constructor() {
|
|
6028
5905
|
super(...arguments);
|
|
6029
|
-
__publicField(this, "host"
|
|
5906
|
+
__publicField(this, "host");
|
|
6030
5907
|
// NOTE: If you alter the schema (of the IndexedDB database) in any way, you must increment the version in order to
|
|
6031
5908
|
// migrate the store. This allows idb to automatically migrate the user's existing data to the new schema.
|
|
6032
5909
|
__publicField(this, "_dbPromise", openDB("fileCache", 1, {
|
|
@@ -6037,8 +5914,7 @@ class FileService extends BaseApiService {
|
|
|
6037
5914
|
}
|
|
6038
5915
|
async renewUploadUrl(sha1) {
|
|
6039
5916
|
const file = await this.fetchCache(sha1);
|
|
6040
|
-
if (!file)
|
|
6041
|
-
throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
5917
|
+
if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
6042
5918
|
const key = await getFileS3Key(file, sha1);
|
|
6043
5919
|
const s3UploadUrl = await this.enqueueRequest({
|
|
6044
5920
|
description: "Get S3 URL",
|
|
@@ -6108,8 +5984,7 @@ class FileService extends BaseApiService {
|
|
|
6108
5984
|
/** Ensure the file has been added to the file cache before calling `uploadFileToS3()` */
|
|
6109
5985
|
async uploadFileToS3(sha1) {
|
|
6110
5986
|
const file = await this.fetchCache(sha1);
|
|
6111
|
-
if (!file)
|
|
6112
|
-
throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
5987
|
+
if (!file) throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
6113
5988
|
const key = await getFileS3Key(file, sha1);
|
|
6114
5989
|
const dbFileProperties = {
|
|
6115
5990
|
file_name: file.name,
|
|
@@ -6203,7 +6078,7 @@ class FileService extends BaseApiService {
|
|
|
6203
6078
|
isExternalUrl flag in the request details is set to true, because instead of requesting the local
|
|
6204
6079
|
REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
|
|
6205
6080
|
(with an offline_id attached) being returned. Alternatively, you may be running with
|
|
6206
|
-
|
|
6081
|
+
import.meta.env.PROD, which will result in some file requests being treated as
|
|
6207
6082
|
external URLs and therefore not prepended with VITE_API_URL.`;
|
|
6208
6083
|
throw new Error(message);
|
|
6209
6084
|
}
|
|
@@ -7243,6 +7118,7 @@ export {
|
|
|
7243
7118
|
ProjectFileService,
|
|
7244
7119
|
ProjectService,
|
|
7245
7120
|
TeamService,
|
|
7121
|
+
UNKNOWN_ERROR_MESSAGE,
|
|
7246
7122
|
UserService,
|
|
7247
7123
|
VERSION_REDUCER_KEY,
|
|
7248
7124
|
VerificationCodeType,
|