@overmap-ai/core 1.0.53 → 1.0.55
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/README.md +4 -4
- package/dist/overmap-core.js +834 -714
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +838 -718
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/classes/OutboxCoordinator.d.ts +1 -1
- package/dist/sdk/sdk.d.ts +14 -2
- package/dist/sdk/services/AgentService.d.ts +6 -13
- package/dist/sdk/services/BaseApiService.d.ts +0 -12
- package/dist/sdk/services/ComponentService.d.ts +1 -1
- package/dist/sdk/services/MainService.d.ts +4 -11
- package/dist/store/slices/agentsSlice.d.ts +16 -0
- package/dist/store/slices/categorySlice.d.ts +1 -0
- package/dist/store/slices/componentSlice.d.ts +1 -1
- package/dist/store/slices/documentSlice.d.ts +1 -0
- package/dist/store/slices/formRevisionSlice.d.ts +1 -0
- package/dist/store/slices/index.d.ts +1 -0
- package/dist/store/slices/issueSlice.d.ts +1 -0
- package/dist/store/slices/projectFileSlice.d.ts +1 -0
- package/dist/store/slices/workspaceSlice.d.ts +1 -0
- package/dist/store/store.d.ts +4 -1
- package/dist/typings/models/agents.d.ts +26 -0
- package/dist/typings/models/base.d.ts +5 -0
- package/dist/typings/models/index.d.ts +1 -0
- package/package.json +153 -153
package/dist/overmap-core.js
CHANGED
|
@@ -10,6 +10,7 @@ import React__default, { useState, useEffect, useRef, memo, useMemo, useCallback
|
|
|
10
10
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { unsafeShowToast, AlertDialogProvider, ToastProvider, DefaultTheme, Flex as Flex$1, IconButton, RiIcon, Text as Text$1, useSeverityColor, TextArea, Select, useToast, Badge, MultiSelect, Overlay, Button, Spinner, useViewportSize, ButtonGroup, IconColorUtility, Tooltip, Popover, useSize, ToggleButton, Separator, OvermapItem, ButtonList, divButtonProps, OvermapDropdownMenu, Checkbox as Checkbox$1, Input, useAlertDialog } from "@overmap-ai/blocks";
|
|
12
12
|
import { DepGraph } from "dependency-graph";
|
|
13
|
+
import saveAs$1, { saveAs } from "file-saver";
|
|
13
14
|
import { offline as offline$1 } from "@redux-offline/redux-offline";
|
|
14
15
|
import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
|
|
15
16
|
import localforage from "localforage";
|
|
@@ -17,7 +18,6 @@ import createMigration from "redux-persist-migrate";
|
|
|
17
18
|
import { createSlice, createSelector, combineReducers, configureStore, createNextState } from "@reduxjs/toolkit";
|
|
18
19
|
import request from "superagent";
|
|
19
20
|
import { shallowEqual as shallowEqual$1, useDispatch, useSelector } from "react-redux";
|
|
20
|
-
import saveAs$1, { saveAs } from "file-saver";
|
|
21
21
|
import { v4 } from "uuid";
|
|
22
22
|
import ColorCls from "color";
|
|
23
23
|
import jwtDecode from "jwt-decode";
|
|
@@ -46,7 +46,7 @@ class OutboxCoordinator {
|
|
|
46
46
|
/**
|
|
47
47
|
* Used when the app is loaded. Reconstructs the dependency graph based on an outbox from the redux-offline store.
|
|
48
48
|
*/
|
|
49
|
-
static
|
|
49
|
+
static _fromOutbox(outbox) {
|
|
50
50
|
const ret = new OutboxCoordinator();
|
|
51
51
|
for (let i = 0; i < outbox.length; i++) {
|
|
52
52
|
const outboxItem = outbox[i];
|
|
@@ -278,46 +278,112 @@ class APIError extends Error {
|
|
|
278
278
|
this.options = options;
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
class
|
|
282
|
-
constructor() {
|
|
283
|
-
__publicField(this,
|
|
284
|
-
|
|
285
|
-
__publicField(this, "_resolve");
|
|
286
|
-
__publicField(this, "_reject");
|
|
287
|
-
__publicField(this, "_state", "pending");
|
|
288
|
-
this._resolve = null;
|
|
289
|
-
this._reject = null;
|
|
290
|
-
this._promise = new Promise((resolve, reject) => {
|
|
291
|
-
this._resolve = resolve;
|
|
292
|
-
this._reject = reject;
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
get state() {
|
|
296
|
-
return this._state;
|
|
281
|
+
class BaseApiService {
|
|
282
|
+
constructor(sdk) {
|
|
283
|
+
__publicField(this, "client");
|
|
284
|
+
this.client = sdk;
|
|
297
285
|
}
|
|
298
|
-
|
|
299
|
-
|
|
286
|
+
}
|
|
287
|
+
function hex(buffer) {
|
|
288
|
+
const hashArray = new Uint8Array(buffer);
|
|
289
|
+
return hashArray.reduce((data, byte) => data + byte.toString(16).padStart(2, "0"), "");
|
|
290
|
+
}
|
|
291
|
+
const getFileS3Key = async (file, hash) => {
|
|
292
|
+
if (!hash) {
|
|
293
|
+
hash = await hashFile(file);
|
|
300
294
|
}
|
|
301
|
-
|
|
302
|
-
|
|
295
|
+
let fileType = file.type;
|
|
296
|
+
if (fileType.includes("/")) {
|
|
297
|
+
fileType = fileType.split("/")[1];
|
|
303
298
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
throw new Error("No resolve callback");
|
|
307
|
-
this._resolve(value);
|
|
308
|
-
this._state = "fulfilled";
|
|
299
|
+
if (!fileType) {
|
|
300
|
+
throw new Error(`Could not extract file type from ${file.type}`);
|
|
309
301
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
302
|
+
return `${hash}.${fileType}`;
|
|
303
|
+
};
|
|
304
|
+
function hashFile(file) {
|
|
305
|
+
return new Promise((resolve, reject) => {
|
|
306
|
+
const reader = new FileReader();
|
|
307
|
+
reader.onload = () => {
|
|
308
|
+
const fileResult = reader.result;
|
|
309
|
+
if (!fileResult) {
|
|
310
|
+
reject();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
void crypto.subtle.digest("SHA-1", fileResult).then((hash) => {
|
|
314
|
+
const sha1result = hex(hash);
|
|
315
|
+
resolve(sha1result);
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
reader.readAsArrayBuffer(file);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function getFileIdentifier(file) {
|
|
322
|
+
if (!file.name || !file.type || !file.size) {
|
|
323
|
+
const message = "File has no name, type, and/or size";
|
|
324
|
+
console.error(`${message}`, file);
|
|
325
|
+
throw new Error(`${message}.`);
|
|
315
326
|
}
|
|
316
|
-
|
|
317
|
-
|
|
327
|
+
return `${file.name}&${file.type}${file.size}`;
|
|
328
|
+
}
|
|
329
|
+
function getRenamedFile(file, newName) {
|
|
330
|
+
return new File([file], newName, { type: file.type });
|
|
331
|
+
}
|
|
332
|
+
function downloadInMemoryFile(filename, text) {
|
|
333
|
+
const element = document.createElement("a");
|
|
334
|
+
element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text));
|
|
335
|
+
element.setAttribute("download", filename);
|
|
336
|
+
element.style.display = "none";
|
|
337
|
+
document.body.appendChild(element);
|
|
338
|
+
element.click();
|
|
339
|
+
document.body.removeChild(element);
|
|
340
|
+
}
|
|
341
|
+
const constructUploadedFilePayloads = async (files) => {
|
|
342
|
+
const filePayloads = {};
|
|
343
|
+
for (const file of files) {
|
|
344
|
+
const sha1 = await hashFile(file);
|
|
345
|
+
filePayloads[sha1] = {
|
|
346
|
+
sha1,
|
|
347
|
+
extension: file.name.split(".").pop() || "",
|
|
348
|
+
file_type: file.type,
|
|
349
|
+
size: file.size
|
|
350
|
+
};
|
|
318
351
|
}
|
|
352
|
+
return Object.values(filePayloads);
|
|
353
|
+
};
|
|
354
|
+
const fileToBlob = async (dataUrl) => {
|
|
355
|
+
return (await fetch(dataUrl)).blob();
|
|
356
|
+
};
|
|
357
|
+
const blobToBase64 = (blob) => {
|
|
358
|
+
return new Promise((resolve, _) => {
|
|
359
|
+
const reader = new FileReader();
|
|
360
|
+
reader.onloadend = () => {
|
|
361
|
+
var _a2;
|
|
362
|
+
resolve(((_a2 = reader.result) == null ? void 0 : _a2.toString()) || "");
|
|
363
|
+
};
|
|
364
|
+
reader.readAsDataURL(blob);
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
const useFileSrc = (props) => {
|
|
368
|
+
const { file, fileSha1, placeholder } = props;
|
|
369
|
+
const [src, setSrc] = useState(placeholder);
|
|
370
|
+
const { sdk } = useSDK();
|
|
371
|
+
useEffect(() => {
|
|
372
|
+
if (!fileSha1 || !file)
|
|
373
|
+
return;
|
|
374
|
+
sdk.files.fetchFileFromUrl(file, fileSha1).then((file2) => {
|
|
375
|
+
setSrc(URL.createObjectURL(file2));
|
|
376
|
+
}).catch((reason) => {
|
|
377
|
+
console.error(`Failed to fetch file ${file} (${fileSha1}):
|
|
378
|
+
`, reason);
|
|
379
|
+
});
|
|
380
|
+
}, [file, fileSha1, sdk.files]);
|
|
381
|
+
return src;
|
|
382
|
+
};
|
|
383
|
+
function downloadFile(file) {
|
|
384
|
+
const blob = new Blob([file]);
|
|
385
|
+
saveAs(blob, file.name);
|
|
319
386
|
}
|
|
320
|
-
_a = Symbol.toStringTag;
|
|
321
387
|
const global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
322
388
|
function defaultSetTimout() {
|
|
323
389
|
throw new Error("setTimeout has not been defined");
|
|
@@ -678,15 +744,15 @@ const wrapMigration = (migrator) => (state) => {
|
|
|
678
744
|
};
|
|
679
745
|
const migrations = [initialVersioning, signOut, signOut, createOutboxState];
|
|
680
746
|
const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
|
|
681
|
-
const initialState$
|
|
747
|
+
const initialState$s = {
|
|
682
748
|
accessToken: "",
|
|
683
749
|
refreshToken: "",
|
|
684
750
|
isLoggedIn: false
|
|
685
751
|
};
|
|
686
752
|
const authSlice = createSlice({
|
|
687
753
|
name: "auth",
|
|
688
|
-
initialState: initialState$
|
|
689
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
754
|
+
initialState: initialState$s,
|
|
755
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
|
|
690
756
|
reducers: {
|
|
691
757
|
setTokens: (state, action) => {
|
|
692
758
|
state.accessToken = action.payload.accessToken;
|
|
@@ -797,106 +863,6 @@ function classNames$1(...args) {
|
|
|
797
863
|
}
|
|
798
864
|
return classes.join(" ");
|
|
799
865
|
}
|
|
800
|
-
function hex(buffer) {
|
|
801
|
-
const hashArray = new Uint8Array(buffer);
|
|
802
|
-
return hashArray.reduce((data, byte) => data + byte.toString(16).padStart(2, "0"), "");
|
|
803
|
-
}
|
|
804
|
-
const getFileS3Key = async (file, hash) => {
|
|
805
|
-
if (!hash) {
|
|
806
|
-
hash = await hashFile(file);
|
|
807
|
-
}
|
|
808
|
-
let fileType = file.type;
|
|
809
|
-
if (fileType.includes("/")) {
|
|
810
|
-
fileType = fileType.split("/")[1];
|
|
811
|
-
}
|
|
812
|
-
if (!fileType) {
|
|
813
|
-
throw new Error(`Could not extract file type from ${file.type}`);
|
|
814
|
-
}
|
|
815
|
-
return `${hash}.${fileType}`;
|
|
816
|
-
};
|
|
817
|
-
function hashFile(file) {
|
|
818
|
-
return new Promise((resolve, reject) => {
|
|
819
|
-
const reader = new FileReader();
|
|
820
|
-
reader.onload = () => {
|
|
821
|
-
const fileResult = reader.result;
|
|
822
|
-
if (!fileResult) {
|
|
823
|
-
reject();
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
void crypto.subtle.digest("SHA-1", fileResult).then((hash) => {
|
|
827
|
-
const sha1result = hex(hash);
|
|
828
|
-
resolve(sha1result);
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
reader.readAsArrayBuffer(file);
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
function getFileIdentifier(file) {
|
|
835
|
-
if (!file.name || !file.type || !file.size) {
|
|
836
|
-
const message = "File has no name, type, and/or size";
|
|
837
|
-
console.error(`${message}`, file);
|
|
838
|
-
throw new Error(`${message}.`);
|
|
839
|
-
}
|
|
840
|
-
return `${file.name}&${file.type}${file.size}`;
|
|
841
|
-
}
|
|
842
|
-
function getRenamedFile(file, newName) {
|
|
843
|
-
return new File([file], newName, { type: file.type });
|
|
844
|
-
}
|
|
845
|
-
function downloadInMemoryFile(filename, text) {
|
|
846
|
-
const element = document.createElement("a");
|
|
847
|
-
element.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text));
|
|
848
|
-
element.setAttribute("download", filename);
|
|
849
|
-
element.style.display = "none";
|
|
850
|
-
document.body.appendChild(element);
|
|
851
|
-
element.click();
|
|
852
|
-
document.body.removeChild(element);
|
|
853
|
-
}
|
|
854
|
-
const constructUploadedFilePayloads = async (files) => {
|
|
855
|
-
const filePayloads = {};
|
|
856
|
-
for (const file of files) {
|
|
857
|
-
const sha1 = await hashFile(file);
|
|
858
|
-
filePayloads[sha1] = {
|
|
859
|
-
sha1,
|
|
860
|
-
extension: file.name.split(".").pop() || "",
|
|
861
|
-
file_type: file.type,
|
|
862
|
-
size: file.size
|
|
863
|
-
};
|
|
864
|
-
}
|
|
865
|
-
return Object.values(filePayloads);
|
|
866
|
-
};
|
|
867
|
-
const fileToBlob = async (dataUrl) => {
|
|
868
|
-
return (await fetch(dataUrl)).blob();
|
|
869
|
-
};
|
|
870
|
-
const blobToBase64 = (blob) => {
|
|
871
|
-
return new Promise((resolve, _) => {
|
|
872
|
-
const reader = new FileReader();
|
|
873
|
-
reader.onloadend = () => {
|
|
874
|
-
var _a2;
|
|
875
|
-
resolve(((_a2 = reader.result) == null ? void 0 : _a2.toString()) || "");
|
|
876
|
-
};
|
|
877
|
-
reader.readAsDataURL(blob);
|
|
878
|
-
});
|
|
879
|
-
};
|
|
880
|
-
const useFileSrc = (props) => {
|
|
881
|
-
const { file, fileSha1, placeholder } = props;
|
|
882
|
-
const [src, setSrc] = useState(placeholder);
|
|
883
|
-
const { sdk } = useSDK();
|
|
884
|
-
useEffect(() => {
|
|
885
|
-
if (!fileSha1 || !file)
|
|
886
|
-
return;
|
|
887
|
-
sdk.files.fetchFileFromUrl(file, fileSha1).then((file2) => {
|
|
888
|
-
setSrc(URL.createObjectURL(file2));
|
|
889
|
-
}).catch((reason) => {
|
|
890
|
-
console.error(`Failed to fetch file ${file} (${fileSha1}):
|
|
891
|
-
`, reason);
|
|
892
|
-
});
|
|
893
|
-
}, [file, fileSha1, sdk.files]);
|
|
894
|
-
return src;
|
|
895
|
-
};
|
|
896
|
-
function downloadFile(file) {
|
|
897
|
-
const blob = new Blob([file]);
|
|
898
|
-
saveAs(blob, file.name);
|
|
899
|
-
}
|
|
900
866
|
const logCache = {};
|
|
901
867
|
function logOnlyOnce(logId, objId, level, ...args) {
|
|
902
868
|
const thisLogIdCache = logCache[logId];
|
|
@@ -1430,7 +1396,7 @@ const getLocalRelativeDateString = memoize((date, min, max) => {
|
|
|
1430
1396
|
return getLocalDateString(date);
|
|
1431
1397
|
return relative.format(days, "days");
|
|
1432
1398
|
});
|
|
1433
|
-
const initialState$
|
|
1399
|
+
const initialState$r = {
|
|
1434
1400
|
categories: {},
|
|
1435
1401
|
usedCategoryColors: [],
|
|
1436
1402
|
categoryVisibility: {
|
|
@@ -1440,8 +1406,8 @@ const initialState$q = {
|
|
|
1440
1406
|
};
|
|
1441
1407
|
const categorySlice = createSlice({
|
|
1442
1408
|
name: "categories",
|
|
1443
|
-
initialState: initialState$
|
|
1444
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1409
|
+
initialState: initialState$r,
|
|
1410
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
|
|
1445
1411
|
reducers: {
|
|
1446
1412
|
setCategories: (state, action) => {
|
|
1447
1413
|
if (!Array.isArray(action.payload))
|
|
@@ -1625,14 +1591,139 @@ function removeAttachments(state, action) {
|
|
|
1625
1591
|
delete state.attachments[attachmentId];
|
|
1626
1592
|
}
|
|
1627
1593
|
}
|
|
1628
|
-
const initialState$
|
|
1629
|
-
|
|
1594
|
+
const initialState$q = {
|
|
1595
|
+
componentTypes: {},
|
|
1596
|
+
hiddenComponentTypeIds: {},
|
|
1630
1597
|
attachments: {}
|
|
1631
1598
|
};
|
|
1632
|
-
const
|
|
1633
|
-
name: "
|
|
1634
|
-
initialState: initialState$
|
|
1635
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1599
|
+
const componentTypeSlice = createSlice({
|
|
1600
|
+
name: "componentTypes",
|
|
1601
|
+
initialState: initialState$q,
|
|
1602
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
|
|
1603
|
+
reducers: {
|
|
1604
|
+
addComponentType: (state, action) => {
|
|
1605
|
+
state.componentTypes[action.payload.offline_id] = action.payload;
|
|
1606
|
+
},
|
|
1607
|
+
setComponentTypes: (state, action) => {
|
|
1608
|
+
state.componentTypes = toOfflineIdRecord(action.payload);
|
|
1609
|
+
},
|
|
1610
|
+
toggleComponentTypeVisibility: (state, action) => {
|
|
1611
|
+
state.hiddenComponentTypeIds[action.payload] = !state.hiddenComponentTypeIds[action.payload];
|
|
1612
|
+
},
|
|
1613
|
+
deleteComponentType: (state, action) => {
|
|
1614
|
+
delete state.componentTypes[action.payload];
|
|
1615
|
+
},
|
|
1616
|
+
// Attachments
|
|
1617
|
+
setComponentTypeAttachment: setAttachment,
|
|
1618
|
+
setComponentTypeAttachments: setAttachments,
|
|
1619
|
+
addComponentTypeAttachment: addAttachment,
|
|
1620
|
+
addComponentTypeAttachments: addAttachments,
|
|
1621
|
+
updateComponentTypeAttachment: updateAttachment,
|
|
1622
|
+
updateComponentTypeAttachments: updateAttachments,
|
|
1623
|
+
removeComponentTypeAttachment: removeAttachment,
|
|
1624
|
+
removeComponentTypeAttachments: removeAttachments
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
const {
|
|
1628
|
+
addComponentType,
|
|
1629
|
+
setComponentTypes,
|
|
1630
|
+
toggleComponentTypeVisibility,
|
|
1631
|
+
deleteComponentType,
|
|
1632
|
+
// Attachmet
|
|
1633
|
+
setComponentTypeAttachment,
|
|
1634
|
+
setComponentTypeAttachments,
|
|
1635
|
+
addComponentTypeAttachment,
|
|
1636
|
+
addComponentTypeAttachments,
|
|
1637
|
+
updateComponentTypeAttachment,
|
|
1638
|
+
updateComponentTypeAttachments,
|
|
1639
|
+
removeComponentTypeAttachment,
|
|
1640
|
+
removeComponentTypeAttachments
|
|
1641
|
+
} = componentTypeSlice.actions;
|
|
1642
|
+
const selectComponentTypesMapping = (state) => state.componentTypeReducer.componentTypes;
|
|
1643
|
+
const selectComponentTypes = createSelector(
|
|
1644
|
+
[selectComponentTypesMapping],
|
|
1645
|
+
(mapping) => Object.values(mapping)
|
|
1646
|
+
);
|
|
1647
|
+
const selectComponentType = restructureCreateSelectorWithArgs(
|
|
1648
|
+
createSelector([selectComponentTypesMapping, (_state, id) => id], (mapping, id) => mapping[id])
|
|
1649
|
+
);
|
|
1650
|
+
const selectNumberOfComponentTypesMatchingCaseInsensitiveName = restructureCreateSelectorWithArgs(
|
|
1651
|
+
createSelector(
|
|
1652
|
+
[
|
|
1653
|
+
selectComponentTypesMapping,
|
|
1654
|
+
(_state, args) => args
|
|
1655
|
+
],
|
|
1656
|
+
(mapping, args) => {
|
|
1657
|
+
var _a2;
|
|
1658
|
+
const name = ((_a2 = args.name) == null ? void 0 : _a2.toLowerCase()) ?? null;
|
|
1659
|
+
return Object.values(mapping).filter(
|
|
1660
|
+
(componentType) => {
|
|
1661
|
+
var _a3;
|
|
1662
|
+
return (((_a3 = componentType.name) == null ? void 0 : _a3.toLowerCase()) ?? null) === name && componentType.offline_id !== args.componentTypeId;
|
|
1663
|
+
}
|
|
1664
|
+
).length;
|
|
1665
|
+
}
|
|
1666
|
+
)
|
|
1667
|
+
);
|
|
1668
|
+
const selectComponentTypesByName = restructureCreateSelectorWithArgs(
|
|
1669
|
+
createSelector(
|
|
1670
|
+
[selectComponentTypesMapping, (_state, name) => name],
|
|
1671
|
+
(mapping, name) => {
|
|
1672
|
+
name = (name == null ? void 0 : name.toLowerCase()) ?? null;
|
|
1673
|
+
return Object.values(mapping).filter(
|
|
1674
|
+
(componentType) => {
|
|
1675
|
+
var _a2;
|
|
1676
|
+
return (((_a2 = componentType.name) == null ? void 0 : _a2.toLowerCase()) ?? null) === name;
|
|
1677
|
+
}
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
)
|
|
1681
|
+
);
|
|
1682
|
+
const selectHiddenComponentTypeIds = (state) => state.componentTypeReducer.hiddenComponentTypeIds;
|
|
1683
|
+
const selectComponentTypeAttachmentMapping = (state) => state.componentTypeReducer.attachments;
|
|
1684
|
+
const selectAllComponentTypeAttachments = createSelector(
|
|
1685
|
+
[selectComponentTypeAttachmentMapping],
|
|
1686
|
+
(mapping) => Object.values(mapping)
|
|
1687
|
+
);
|
|
1688
|
+
const selectComponentTypeAttachment = (attachmentId) => (state) => {
|
|
1689
|
+
return state.componentTypeReducer.attachments[attachmentId];
|
|
1690
|
+
};
|
|
1691
|
+
const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
|
|
1692
|
+
createSelector(
|
|
1693
|
+
[selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
|
|
1694
|
+
(attachments, componentTypeId) => {
|
|
1695
|
+
return attachments.filter(({ component_type }) => componentTypeId === component_type);
|
|
1696
|
+
}
|
|
1697
|
+
)
|
|
1698
|
+
);
|
|
1699
|
+
const selectAttachmentsOfComponentTypeByType = restructureCreateSelectorWithArgs(
|
|
1700
|
+
createSelector(
|
|
1701
|
+
[selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
|
|
1702
|
+
(attachments, componentTypeId) => {
|
|
1703
|
+
const attachmentsOfComponent = attachments.filter(
|
|
1704
|
+
({ component_type }) => component_type === componentTypeId
|
|
1705
|
+
);
|
|
1706
|
+
const fileAttachments = attachmentsOfComponent.filter(
|
|
1707
|
+
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1708
|
+
({ file_type }) => !file_type || !file_type.startsWith("image/")
|
|
1709
|
+
);
|
|
1710
|
+
const imageAttachments = attachmentsOfComponent.filter(
|
|
1711
|
+
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
1712
|
+
({ file_type }) => file_type && file_type.startsWith("image/")
|
|
1713
|
+
);
|
|
1714
|
+
return { fileAttachments, imageAttachments };
|
|
1715
|
+
}
|
|
1716
|
+
)
|
|
1717
|
+
);
|
|
1718
|
+
const componentTypeReducer = componentTypeSlice.reducer;
|
|
1719
|
+
const initialState$p = {
|
|
1720
|
+
components: {},
|
|
1721
|
+
attachments: {}
|
|
1722
|
+
};
|
|
1723
|
+
const componentSlice = createSlice({
|
|
1724
|
+
name: "components",
|
|
1725
|
+
initialState: initialState$p,
|
|
1726
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
|
|
1636
1727
|
reducers: {
|
|
1637
1728
|
addComponent: (state, action) => {
|
|
1638
1729
|
state.components[action.payload.offline_id] = action.payload;
|
|
@@ -1707,36 +1798,41 @@ const selectComponents = (state) => {
|
|
|
1707
1798
|
return prevComponents;
|
|
1708
1799
|
};
|
|
1709
1800
|
const selectComponentsMapping = (state) => state.componentReducer.components;
|
|
1710
|
-
const selectComponentsFromComponentType = (
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1801
|
+
const selectComponentsFromComponentType = restructureCreateSelectorWithArgs(
|
|
1802
|
+
createSelector(
|
|
1803
|
+
[selectComponents, (_state, componentTypeId) => componentTypeId],
|
|
1804
|
+
(components, componentTypeId) => {
|
|
1805
|
+
if (!componentTypeId)
|
|
1806
|
+
return [];
|
|
1807
|
+
return components.filter((component) => component.component_type === componentTypeId);
|
|
1808
|
+
}
|
|
1809
|
+
)
|
|
1810
|
+
);
|
|
1716
1811
|
const selectComponent = (componentId) => (state) => {
|
|
1717
1812
|
return state.componentReducer.components[componentId];
|
|
1718
1813
|
};
|
|
1719
1814
|
const selectComponentTypeFromComponent = (componentTypeId) => (state) => {
|
|
1720
1815
|
return state.componentTypeReducer.componentTypes[componentTypeId];
|
|
1721
1816
|
};
|
|
1722
|
-
const selectComponentTypeFromComponents = (
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1817
|
+
const selectComponentTypeFromComponents = createSelector(
|
|
1818
|
+
[selectComponents, selectComponentTypesMapping],
|
|
1819
|
+
(components, componentTypeMapping) => {
|
|
1820
|
+
const ret = {};
|
|
1821
|
+
for (const component of components) {
|
|
1822
|
+
const componentType = componentTypeMapping[component.component_type];
|
|
1823
|
+
if (!componentType) {
|
|
1824
|
+
console.error(
|
|
1825
|
+
`Component type with ID ${component.component_type} not found.
|
|
1731
1826
|
Expected all referenced component types to be populated.
|
|
1732
1827
|
Returning empty object to avoid fatal errors.`
|
|
1733
|
-
|
|
1734
|
-
|
|
1828
|
+
);
|
|
1829
|
+
return {};
|
|
1830
|
+
}
|
|
1831
|
+
ret[component.offline_id] = componentType;
|
|
1735
1832
|
}
|
|
1736
|
-
ret
|
|
1833
|
+
return ret;
|
|
1737
1834
|
}
|
|
1738
|
-
|
|
1739
|
-
};
|
|
1835
|
+
);
|
|
1740
1836
|
const selectComponentsByType = restructureCreateSelectorWithArgs(
|
|
1741
1837
|
createSelector(
|
|
1742
1838
|
[selectComponents, (_state, componentTypeId) => componentTypeId],
|
|
@@ -1886,219 +1982,94 @@ const componentStageSlice = createSlice({
|
|
|
1886
1982
|
if (!stage) {
|
|
1887
1983
|
throw new Error("No stage exists with the id " + stageId);
|
|
1888
1984
|
}
|
|
1889
|
-
delete stage.user_form;
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
});
|
|
1893
|
-
const selectStageMapping = (state) => state.componentStageReducer.stages;
|
|
1894
|
-
const selectStage = restructureCreateSelectorWithArgs(
|
|
1895
|
-
createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
|
|
1896
|
-
return stageMapping[stageId];
|
|
1897
|
-
})
|
|
1898
|
-
);
|
|
1899
|
-
const selectStages = createSelector(
|
|
1900
|
-
[selectStageMapping],
|
|
1901
|
-
(stageMapping) => {
|
|
1902
|
-
return Object.values(stageMapping);
|
|
1903
|
-
}
|
|
1904
|
-
);
|
|
1905
|
-
const selectStagesFromComponentTypeIds = restructureCreateSelectorWithArgs(
|
|
1906
|
-
createSelector(
|
|
1907
|
-
[selectStages, (_state, componentTypeIds) => componentTypeIds],
|
|
1908
|
-
(stages, componentTypeIds) => {
|
|
1909
|
-
const componentTypeIdsSet = new Set(componentTypeIds);
|
|
1910
|
-
const ret = {};
|
|
1911
|
-
for (const stage of stages) {
|
|
1912
|
-
if (componentTypeIdsSet.has(stage.component_type)) {
|
|
1913
|
-
if (!ret[stage.component_type]) {
|
|
1914
|
-
ret[stage.component_type] = [];
|
|
1915
|
-
}
|
|
1916
|
-
ret[stage.component_type].push(stage);
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
for (const key in ret) {
|
|
1920
|
-
ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
|
|
1921
|
-
}
|
|
1922
|
-
return ret;
|
|
1923
|
-
}
|
|
1924
|
-
)
|
|
1925
|
-
);
|
|
1926
|
-
const selectComponentTypeStagesMapping = restructureCreateSelectorWithArgs(
|
|
1927
|
-
createSelector(
|
|
1928
|
-
[selectStageMapping, (_state, componentTypeId) => componentTypeId],
|
|
1929
|
-
(stagesMapping, componentTypeId) => {
|
|
1930
|
-
const componentTypeStagesMapping = {};
|
|
1931
|
-
for (const [stageId, stage] of Object.entries(stagesMapping)) {
|
|
1932
|
-
if (stage.component_type === componentTypeId) {
|
|
1933
|
-
componentTypeStagesMapping[stageId] = stage;
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
return componentTypeStagesMapping;
|
|
1937
|
-
}
|
|
1938
|
-
)
|
|
1939
|
-
);
|
|
1940
|
-
const selectStagesFromComponentType = restructureCreateSelectorWithArgs(
|
|
1941
|
-
createSelector(
|
|
1942
|
-
[selectStages, (_state, componentTypeId) => componentTypeId],
|
|
1943
|
-
(stages, componentTypeId) => {
|
|
1944
|
-
return stages.filter((stage) => stage.component_type === componentTypeId).sort((a, b) => a.priority - b.priority);
|
|
1945
|
-
}
|
|
1946
|
-
)
|
|
1947
|
-
);
|
|
1948
|
-
const selectStagesFromStageIds = restructureCreateSelectorWithArgs(
|
|
1949
|
-
createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
|
|
1950
|
-
return stageIds.map((offline_id) => stageMapping[offline_id]).filter((stage) => !!stage);
|
|
1951
|
-
})
|
|
1952
|
-
);
|
|
1953
|
-
const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
|
|
1954
|
-
createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
|
|
1955
|
-
const ret = {};
|
|
1956
|
-
for (const stageId of stageIds) {
|
|
1957
|
-
const stage = stageMapping[stageId];
|
|
1958
|
-
if (!stage) {
|
|
1959
|
-
throw new Error("No stage exists with the id " + stageId);
|
|
1960
|
-
}
|
|
1961
|
-
if (stage.user_form) {
|
|
1962
|
-
ret[stageId] = stage.user_form;
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
return ret;
|
|
1966
|
-
})
|
|
1967
|
-
);
|
|
1968
|
-
const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
|
|
1969
|
-
const componentStageReducer = componentStageSlice.reducer;
|
|
1970
|
-
const initialState$m = {
|
|
1971
|
-
componentTypes: {},
|
|
1972
|
-
hiddenComponentTypeIds: {},
|
|
1973
|
-
attachments: {}
|
|
1974
|
-
};
|
|
1975
|
-
const componentTypeSlice = createSlice({
|
|
1976
|
-
name: "componentTypes",
|
|
1977
|
-
initialState: initialState$m,
|
|
1978
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
|
|
1979
|
-
reducers: {
|
|
1980
|
-
addComponentType: (state, action) => {
|
|
1981
|
-
state.componentTypes[action.payload.offline_id] = action.payload;
|
|
1982
|
-
},
|
|
1983
|
-
setComponentTypes: (state, action) => {
|
|
1984
|
-
state.componentTypes = toOfflineIdRecord(action.payload);
|
|
1985
|
-
},
|
|
1986
|
-
toggleComponentTypeVisibility: (state, action) => {
|
|
1987
|
-
state.hiddenComponentTypeIds[action.payload] = !state.hiddenComponentTypeIds[action.payload];
|
|
1988
|
-
},
|
|
1989
|
-
deleteComponentType: (state, action) => {
|
|
1990
|
-
delete state.componentTypes[action.payload];
|
|
1991
|
-
},
|
|
1992
|
-
// Attachments
|
|
1993
|
-
setComponentTypeAttachment: setAttachment,
|
|
1994
|
-
setComponentTypeAttachments: setAttachments,
|
|
1995
|
-
addComponentTypeAttachment: addAttachment,
|
|
1996
|
-
addComponentTypeAttachments: addAttachments,
|
|
1997
|
-
updateComponentTypeAttachment: updateAttachment,
|
|
1998
|
-
updateComponentTypeAttachments: updateAttachments,
|
|
1999
|
-
removeComponentTypeAttachment: removeAttachment,
|
|
2000
|
-
removeComponentTypeAttachments: removeAttachments
|
|
2001
|
-
}
|
|
2002
|
-
});
|
|
2003
|
-
const {
|
|
2004
|
-
addComponentType,
|
|
2005
|
-
setComponentTypes,
|
|
2006
|
-
toggleComponentTypeVisibility,
|
|
2007
|
-
deleteComponentType,
|
|
2008
|
-
// Attachmet
|
|
2009
|
-
setComponentTypeAttachment,
|
|
2010
|
-
setComponentTypeAttachments,
|
|
2011
|
-
addComponentTypeAttachment,
|
|
2012
|
-
addComponentTypeAttachments,
|
|
2013
|
-
updateComponentTypeAttachment,
|
|
2014
|
-
updateComponentTypeAttachments,
|
|
2015
|
-
removeComponentTypeAttachment,
|
|
2016
|
-
removeComponentTypeAttachments
|
|
2017
|
-
} = componentTypeSlice.actions;
|
|
2018
|
-
const selectComponentTypesMapping = (state) => state.componentTypeReducer.componentTypes;
|
|
2019
|
-
const selectComponentTypes = createSelector(
|
|
2020
|
-
[selectComponentTypesMapping],
|
|
2021
|
-
(mapping) => Object.values(mapping)
|
|
1985
|
+
delete stage.user_form;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
});
|
|
1989
|
+
const selectStageMapping = (state) => state.componentStageReducer.stages;
|
|
1990
|
+
const selectStage = restructureCreateSelectorWithArgs(
|
|
1991
|
+
createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
|
|
1992
|
+
return stageMapping[stageId];
|
|
1993
|
+
})
|
|
2022
1994
|
);
|
|
2023
|
-
const
|
|
2024
|
-
|
|
1995
|
+
const selectStages = createSelector(
|
|
1996
|
+
[selectStageMapping],
|
|
1997
|
+
(stageMapping) => {
|
|
1998
|
+
return Object.values(stageMapping);
|
|
1999
|
+
}
|
|
2025
2000
|
);
|
|
2026
|
-
const
|
|
2001
|
+
const selectStagesFromComponentTypeIds = restructureCreateSelectorWithArgs(
|
|
2027
2002
|
createSelector(
|
|
2028
|
-
[
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
return (((_a3 = componentType.name) == null ? void 0 : _a3.toLowerCase()) ?? null) === name && componentType.offline_id !== args.componentTypeId;
|
|
2003
|
+
[selectStages, (_state, componentTypeIds) => componentTypeIds],
|
|
2004
|
+
(stages, componentTypeIds) => {
|
|
2005
|
+
const componentTypeIdsSet = new Set(componentTypeIds);
|
|
2006
|
+
const ret = {};
|
|
2007
|
+
for (const stage of stages) {
|
|
2008
|
+
if (componentTypeIdsSet.has(stage.component_type)) {
|
|
2009
|
+
if (!ret[stage.component_type]) {
|
|
2010
|
+
ret[stage.component_type] = [];
|
|
2011
|
+
}
|
|
2012
|
+
ret[stage.component_type].push(stage);
|
|
2039
2013
|
}
|
|
2040
|
-
|
|
2014
|
+
}
|
|
2015
|
+
for (const key in ret) {
|
|
2016
|
+
ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
|
|
2017
|
+
}
|
|
2018
|
+
return ret;
|
|
2041
2019
|
}
|
|
2042
2020
|
)
|
|
2043
2021
|
);
|
|
2044
|
-
const
|
|
2022
|
+
const selectComponentTypeStagesMapping = restructureCreateSelectorWithArgs(
|
|
2045
2023
|
createSelector(
|
|
2046
|
-
[
|
|
2047
|
-
(
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
(
|
|
2051
|
-
|
|
2052
|
-
return (((_a2 = componentType.name) == null ? void 0 : _a2.toLowerCase()) ?? null) === name;
|
|
2024
|
+
[selectStageMapping, (_state, componentTypeId) => componentTypeId],
|
|
2025
|
+
(stagesMapping, componentTypeId) => {
|
|
2026
|
+
const componentTypeStagesMapping = {};
|
|
2027
|
+
for (const [stageId, stage] of Object.entries(stagesMapping)) {
|
|
2028
|
+
if (stage.component_type === componentTypeId) {
|
|
2029
|
+
componentTypeStagesMapping[stageId] = stage;
|
|
2053
2030
|
}
|
|
2054
|
-
|
|
2031
|
+
}
|
|
2032
|
+
return componentTypeStagesMapping;
|
|
2055
2033
|
}
|
|
2056
2034
|
)
|
|
2057
2035
|
);
|
|
2058
|
-
const
|
|
2059
|
-
const selectComponentTypeAttachmentMapping = (state) => state.componentTypeReducer.attachments;
|
|
2060
|
-
const selectAllComponentTypeAttachments = createSelector(
|
|
2061
|
-
[selectComponentTypeAttachmentMapping],
|
|
2062
|
-
(mapping) => Object.values(mapping)
|
|
2063
|
-
);
|
|
2064
|
-
const selectComponentTypeAttachment = (attachmentId) => (state) => {
|
|
2065
|
-
return state.componentTypeReducer.attachments[attachmentId];
|
|
2066
|
-
};
|
|
2067
|
-
const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
|
|
2036
|
+
const selectStagesFromComponentType = restructureCreateSelectorWithArgs(
|
|
2068
2037
|
createSelector(
|
|
2069
|
-
[
|
|
2070
|
-
(
|
|
2071
|
-
return
|
|
2038
|
+
[selectStages, (_state, componentTypeId) => componentTypeId],
|
|
2039
|
+
(stages, componentTypeId) => {
|
|
2040
|
+
return stages.filter((stage) => stage.component_type === componentTypeId).sort((a, b) => a.priority - b.priority);
|
|
2072
2041
|
}
|
|
2073
2042
|
)
|
|
2074
2043
|
);
|
|
2075
|
-
const
|
|
2076
|
-
createSelector(
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
)
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2044
|
+
const selectStagesFromStageIds = restructureCreateSelectorWithArgs(
|
|
2045
|
+
createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
|
|
2046
|
+
return stageIds.map((offline_id) => stageMapping[offline_id]).filter((stage) => !!stage);
|
|
2047
|
+
})
|
|
2048
|
+
);
|
|
2049
|
+
const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
|
|
2050
|
+
createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
|
|
2051
|
+
const ret = {};
|
|
2052
|
+
for (const stageId of stageIds) {
|
|
2053
|
+
const stage = stageMapping[stageId];
|
|
2054
|
+
if (!stage) {
|
|
2055
|
+
throw new Error("No stage exists with the id " + stageId);
|
|
2056
|
+
}
|
|
2057
|
+
if (stage.user_form) {
|
|
2058
|
+
ret[stageId] = stage.user_form;
|
|
2059
|
+
}
|
|
2091
2060
|
}
|
|
2092
|
-
|
|
2061
|
+
return ret;
|
|
2062
|
+
})
|
|
2093
2063
|
);
|
|
2094
|
-
const
|
|
2095
|
-
const
|
|
2064
|
+
const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
|
|
2065
|
+
const componentStageReducer = componentStageSlice.reducer;
|
|
2066
|
+
const initialState$m = {
|
|
2096
2067
|
workspaces: {},
|
|
2097
2068
|
activeWorkspaceId: null
|
|
2098
2069
|
};
|
|
2099
2070
|
const workspaceSlice = createSlice({
|
|
2100
2071
|
name: "workspace",
|
|
2101
|
-
initialState: initialState$
|
|
2072
|
+
initialState: initialState$m,
|
|
2102
2073
|
// The `reducers` field lets us define reducers and generate associated actions
|
|
2103
2074
|
reducers: {
|
|
2104
2075
|
setWorkspaces: (state, action) => {
|
|
@@ -2155,7 +2126,7 @@ const selectPermittedWorkspaceIds = createSelector(
|
|
|
2155
2126
|
);
|
|
2156
2127
|
const workspaceReducer = workspaceSlice.reducer;
|
|
2157
2128
|
const maxRecentIssues = 10;
|
|
2158
|
-
const initialState$
|
|
2129
|
+
const initialState$l = {
|
|
2159
2130
|
issues: {},
|
|
2160
2131
|
attachments: {},
|
|
2161
2132
|
comments: {},
|
|
@@ -2167,9 +2138,9 @@ const initialState$k = {
|
|
|
2167
2138
|
};
|
|
2168
2139
|
const issueSlice = createSlice({
|
|
2169
2140
|
name: "issues",
|
|
2170
|
-
initialState: initialState$
|
|
2141
|
+
initialState: initialState$l,
|
|
2171
2142
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
2172
|
-
Object.assign(state, initialState$
|
|
2143
|
+
Object.assign(state, initialState$l);
|
|
2173
2144
|
}),
|
|
2174
2145
|
reducers: {
|
|
2175
2146
|
setIssues: (state, action) => {
|
|
@@ -2602,14 +2573,14 @@ const selectRecentIssuesAsSearchResults = createSelector(
|
|
|
2602
2573
|
}
|
|
2603
2574
|
);
|
|
2604
2575
|
const issueReducer = issueSlice.reducer;
|
|
2605
|
-
const initialState$
|
|
2576
|
+
const initialState$k = {
|
|
2606
2577
|
issueTypes: {}
|
|
2607
2578
|
};
|
|
2608
2579
|
const issueTypeSlice = createSlice({
|
|
2609
2580
|
name: "issueTypes",
|
|
2610
|
-
initialState: initialState$
|
|
2581
|
+
initialState: initialState$k,
|
|
2611
2582
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
2612
|
-
Object.assign(state, initialState$
|
|
2583
|
+
Object.assign(state, initialState$k);
|
|
2613
2584
|
}),
|
|
2614
2585
|
reducers: {
|
|
2615
2586
|
setIssueTypes: (state, action) => {
|
|
@@ -2676,15 +2647,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
|
|
|
2676
2647
|
return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
|
|
2677
2648
|
};
|
|
2678
2649
|
const issueTypeReducer = issueTypeSlice.reducer;
|
|
2679
|
-
const initialState$
|
|
2650
|
+
const initialState$j = {
|
|
2680
2651
|
s3Urls: {}
|
|
2681
2652
|
};
|
|
2682
2653
|
const msPerHour = 1e3 * 60 * 60;
|
|
2683
2654
|
const msPerWeek = msPerHour * 24 * 7;
|
|
2684
2655
|
const fileSlice = createSlice({
|
|
2685
2656
|
name: "file",
|
|
2686
|
-
initialState: initialState$
|
|
2687
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2657
|
+
initialState: initialState$j,
|
|
2658
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
|
|
2688
2659
|
reducers: {
|
|
2689
2660
|
setUploadUrl: (state, action) => {
|
|
2690
2661
|
const { url, fields, sha1 } = action.payload;
|
|
@@ -2711,7 +2682,7 @@ const selectUploadUrl = (sha1) => (state) => {
|
|
|
2711
2682
|
return url;
|
|
2712
2683
|
};
|
|
2713
2684
|
const fileReducer = fileSlice.reducer;
|
|
2714
|
-
const initialState$
|
|
2685
|
+
const initialState$i = {
|
|
2715
2686
|
// TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
|
|
2716
2687
|
mapStyle: MapStyle.SATELLITE,
|
|
2717
2688
|
showTooltips: false,
|
|
@@ -2719,8 +2690,8 @@ const initialState$h = {
|
|
|
2719
2690
|
};
|
|
2720
2691
|
const mapSlice = createSlice({
|
|
2721
2692
|
name: "map",
|
|
2722
|
-
initialState: initialState$
|
|
2723
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2693
|
+
initialState: initialState$i,
|
|
2694
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
|
|
2724
2695
|
reducers: {
|
|
2725
2696
|
setMapStyle: (state, action) => {
|
|
2726
2697
|
state.mapStyle = action.payload;
|
|
@@ -2797,7 +2768,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
|
|
|
2797
2768
|
LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
|
|
2798
2769
|
return LicenseStatus2;
|
|
2799
2770
|
})(LicenseStatus || {});
|
|
2800
|
-
const initialState$
|
|
2771
|
+
const initialState$h = {
|
|
2801
2772
|
users: {},
|
|
2802
2773
|
currentUser: {
|
|
2803
2774
|
id: 0,
|
|
@@ -2808,8 +2779,8 @@ const initialState$g = {
|
|
|
2808
2779
|
};
|
|
2809
2780
|
const userSlice = createSlice({
|
|
2810
2781
|
name: "users",
|
|
2811
|
-
initialState: initialState$
|
|
2812
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2782
|
+
initialState: initialState$h,
|
|
2783
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
|
|
2813
2784
|
reducers: {
|
|
2814
2785
|
setUsers: (state, action) => {
|
|
2815
2786
|
const usersMapping = {};
|
|
@@ -2871,13 +2842,13 @@ const selectUser = (userId) => (state) => {
|
|
|
2871
2842
|
const selectUsersAsMapping = (state) => state.userReducer.users;
|
|
2872
2843
|
const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
|
|
2873
2844
|
const userReducer = userSlice.reducer;
|
|
2874
|
-
const initialState$
|
|
2845
|
+
const initialState$g = {
|
|
2875
2846
|
organizationAccesses: {}
|
|
2876
2847
|
};
|
|
2877
2848
|
const organizationAccessSlice = createSlice({
|
|
2878
2849
|
name: "organizationAccess",
|
|
2879
|
-
initialState: initialState$
|
|
2880
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2850
|
+
initialState: initialState$g,
|
|
2851
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
|
|
2881
2852
|
reducers: {
|
|
2882
2853
|
setOrganizationAccesses: (state, action) => {
|
|
2883
2854
|
if (!Array.isArray(action.payload))
|
|
@@ -2940,13 +2911,13 @@ const selectOrganizationAccessUserMapping = (state) => {
|
|
|
2940
2911
|
return organizationAccesses;
|
|
2941
2912
|
};
|
|
2942
2913
|
const organizationAccessReducer = organizationAccessSlice.reducer;
|
|
2943
|
-
const initialState$
|
|
2914
|
+
const initialState$f = {
|
|
2944
2915
|
licenses: {}
|
|
2945
2916
|
};
|
|
2946
2917
|
const licenseSlice = createSlice({
|
|
2947
2918
|
name: "license",
|
|
2948
|
-
initialState: initialState$
|
|
2949
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2919
|
+
initialState: initialState$f,
|
|
2920
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
|
|
2950
2921
|
reducers: {
|
|
2951
2922
|
setLicenses: (state, action) => {
|
|
2952
2923
|
if (!Array.isArray(action.payload))
|
|
@@ -2991,13 +2962,13 @@ const selectLicensesForProjectsMapping = createSelector(
|
|
|
2991
2962
|
(licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
|
|
2992
2963
|
);
|
|
2993
2964
|
const licenseReducer = licenseSlice.reducer;
|
|
2994
|
-
const initialState$
|
|
2965
|
+
const initialState$e = {
|
|
2995
2966
|
projectAccesses: {}
|
|
2996
2967
|
};
|
|
2997
2968
|
const projectAccessSlice = createSlice({
|
|
2998
2969
|
name: "projectAccess",
|
|
2999
|
-
initialState: initialState$
|
|
3000
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2970
|
+
initialState: initialState$e,
|
|
2971
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
|
|
3001
2972
|
reducers: {
|
|
3002
2973
|
setProjectAccesses: (state, action) => {
|
|
3003
2974
|
if (!Array.isArray(action.payload))
|
|
@@ -3065,7 +3036,7 @@ const selectProjectAccessUserMapping = (state) => {
|
|
|
3065
3036
|
return projectAccesses;
|
|
3066
3037
|
};
|
|
3067
3038
|
const projectAccessReducer = projectAccessSlice.reducer;
|
|
3068
|
-
const initialState$
|
|
3039
|
+
const initialState$d = {
|
|
3069
3040
|
projects: {},
|
|
3070
3041
|
activeProjectId: null,
|
|
3071
3042
|
recentProjectIds: [],
|
|
@@ -3075,7 +3046,7 @@ const initialState$c = {
|
|
|
3075
3046
|
};
|
|
3076
3047
|
const projectSlice = createSlice({
|
|
3077
3048
|
name: "projects",
|
|
3078
|
-
initialState: initialState$
|
|
3049
|
+
initialState: initialState$d,
|
|
3079
3050
|
reducers: {
|
|
3080
3051
|
setProjects: (state, action) => {
|
|
3081
3052
|
const projectsMap = {};
|
|
@@ -3269,14 +3240,14 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
|
|
|
3269
3240
|
}
|
|
3270
3241
|
)
|
|
3271
3242
|
);
|
|
3272
|
-
const initialState$
|
|
3243
|
+
const initialState$c = {
|
|
3273
3244
|
organizations: {},
|
|
3274
3245
|
activeOrganizationId: null
|
|
3275
3246
|
};
|
|
3276
3247
|
const organizationSlice = createSlice({
|
|
3277
3248
|
name: "organizations",
|
|
3278
|
-
initialState: initialState$
|
|
3279
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3249
|
+
initialState: initialState$c,
|
|
3250
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
|
|
3280
3251
|
reducers: {
|
|
3281
3252
|
setOrganizations: (state, action) => {
|
|
3282
3253
|
for (const org of action.payload) {
|
|
@@ -3395,14 +3366,14 @@ const createOfflineAction = (request2, baseUrl) => {
|
|
|
3395
3366
|
}
|
|
3396
3367
|
};
|
|
3397
3368
|
};
|
|
3398
|
-
const initialState$
|
|
3369
|
+
const initialState$b = {
|
|
3399
3370
|
deletedRequests: [],
|
|
3400
3371
|
latestRetryTime: 0
|
|
3401
3372
|
};
|
|
3402
3373
|
const outboxSlice = createSlice({
|
|
3403
3374
|
name: "outbox",
|
|
3404
|
-
initialState: initialState$
|
|
3405
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3375
|
+
initialState: initialState$b,
|
|
3376
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
|
|
3406
3377
|
reducers: {
|
|
3407
3378
|
// enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
|
|
3408
3379
|
// Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
|
|
@@ -3434,7 +3405,7 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
|
|
|
3434
3405
|
const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
|
|
3435
3406
|
const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
|
|
3436
3407
|
const outboxReducer = outboxSlice.reducer;
|
|
3437
|
-
const initialState$
|
|
3408
|
+
const initialState$a = {
|
|
3438
3409
|
projectFiles: {},
|
|
3439
3410
|
activeProjectFileId: null,
|
|
3440
3411
|
isImportingProjectFile: false,
|
|
@@ -3442,8 +3413,8 @@ const initialState$9 = {
|
|
|
3442
3413
|
};
|
|
3443
3414
|
const projectFileSlice = createSlice({
|
|
3444
3415
|
name: "projectFiles",
|
|
3445
|
-
initialState: initialState$
|
|
3446
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3416
|
+
initialState: initialState$a,
|
|
3417
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
|
|
3447
3418
|
reducers: {
|
|
3448
3419
|
addOrReplaceProjectFiles: (state, action) => {
|
|
3449
3420
|
for (let fileObj of action.payload) {
|
|
@@ -3544,12 +3515,12 @@ const selectProjectFiles = createSelector(
|
|
|
3544
3515
|
const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
|
|
3545
3516
|
const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
|
|
3546
3517
|
const projectFileReducer = projectFileSlice.reducer;
|
|
3547
|
-
const initialState$
|
|
3518
|
+
const initialState$9 = {
|
|
3548
3519
|
isRehydrated: false
|
|
3549
3520
|
};
|
|
3550
3521
|
const rehydratedSlice = createSlice({
|
|
3551
3522
|
name: "rehydrated",
|
|
3552
|
-
initialState: initialState$
|
|
3523
|
+
initialState: initialState$9,
|
|
3553
3524
|
// The `reducers` field lets us define reducers and generate associated actions
|
|
3554
3525
|
reducers: {
|
|
3555
3526
|
setRehydrated: (state, action) => {
|
|
@@ -3559,7 +3530,7 @@ const rehydratedSlice = createSlice({
|
|
|
3559
3530
|
});
|
|
3560
3531
|
const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
|
|
3561
3532
|
const rehydratedReducer = rehydratedSlice.reducer;
|
|
3562
|
-
const initialState$
|
|
3533
|
+
const initialState$8 = {
|
|
3563
3534
|
useIssueTemplate: false,
|
|
3564
3535
|
placementMode: false,
|
|
3565
3536
|
enableClustering: false,
|
|
@@ -3576,8 +3547,8 @@ const initialState$7 = {
|
|
|
3576
3547
|
};
|
|
3577
3548
|
const settingSlice = createSlice({
|
|
3578
3549
|
name: "settings",
|
|
3579
|
-
initialState: initialState$
|
|
3580
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3550
|
+
initialState: initialState$8,
|
|
3551
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
|
|
3581
3552
|
reducers: {
|
|
3582
3553
|
setEnableDuplicateIssues: (state, action) => {
|
|
3583
3554
|
state.useIssueTemplate = action.payload;
|
|
@@ -3636,14 +3607,14 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
|
|
|
3636
3607
|
return revisionA < revisionB ? -1 : 1;
|
|
3637
3608
|
}
|
|
3638
3609
|
};
|
|
3639
|
-
const initialState$
|
|
3610
|
+
const initialState$7 = {
|
|
3640
3611
|
formRevisions: {},
|
|
3641
3612
|
attachments: {}
|
|
3642
3613
|
};
|
|
3643
3614
|
const formRevisionsSlice = createSlice({
|
|
3644
3615
|
name: "formRevisions",
|
|
3645
|
-
initialState: initialState$
|
|
3646
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3616
|
+
initialState: initialState$7,
|
|
3617
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
|
|
3647
3618
|
reducers: {
|
|
3648
3619
|
// revision related actions
|
|
3649
3620
|
setFormRevision: (state, action) => {
|
|
@@ -3823,13 +3794,13 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
|
|
|
3823
3794
|
)
|
|
3824
3795
|
);
|
|
3825
3796
|
const formRevisionReducer = formRevisionsSlice.reducer;
|
|
3826
|
-
const initialState$
|
|
3797
|
+
const initialState$6 = {
|
|
3827
3798
|
forms: {}
|
|
3828
3799
|
};
|
|
3829
3800
|
const formSlice = createSlice({
|
|
3830
3801
|
name: "forms",
|
|
3831
|
-
initialState: initialState$
|
|
3832
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3802
|
+
initialState: initialState$6,
|
|
3803
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
|
|
3833
3804
|
reducers: {
|
|
3834
3805
|
setForms: (state, action) => {
|
|
3835
3806
|
state.forms = {};
|
|
@@ -3934,14 +3905,14 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (userForms) =
|
|
|
3934
3905
|
return Object.values(userForms).filter((form) => !form.component_type).length;
|
|
3935
3906
|
});
|
|
3936
3907
|
const formReducer = formSlice.reducer;
|
|
3937
|
-
const initialState$
|
|
3908
|
+
const initialState$5 = {
|
|
3938
3909
|
formSubmissions: {},
|
|
3939
3910
|
attachments: {}
|
|
3940
3911
|
};
|
|
3941
3912
|
const formSubmissionSlice = createSlice({
|
|
3942
3913
|
name: "formSubmissions",
|
|
3943
|
-
initialState: initialState$
|
|
3944
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3914
|
+
initialState: initialState$5,
|
|
3915
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
|
|
3945
3916
|
reducers: {
|
|
3946
3917
|
setFormSubmission: (state, action) => {
|
|
3947
3918
|
state.formSubmissions[action.payload.offline_id] = action.payload;
|
|
@@ -4178,12 +4149,12 @@ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
|
|
|
4178
4149
|
)
|
|
4179
4150
|
);
|
|
4180
4151
|
const formSubmissionReducer = formSubmissionSlice.reducer;
|
|
4181
|
-
const initialState$
|
|
4152
|
+
const initialState$4 = {
|
|
4182
4153
|
emailDomains: {}
|
|
4183
4154
|
};
|
|
4184
4155
|
const emailDomainsSlice = createSlice({
|
|
4185
4156
|
name: "emailDomains",
|
|
4186
|
-
initialState: initialState$
|
|
4157
|
+
initialState: initialState$4,
|
|
4187
4158
|
reducers: {
|
|
4188
4159
|
setEmailDomains: (state, action) => {
|
|
4189
4160
|
const emailDomains = {};
|
|
@@ -4210,15 +4181,15 @@ const selectSortedEmailDomains = (state) => Object.values(state.emailDomainsRedu
|
|
|
4210
4181
|
(ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
|
|
4211
4182
|
);
|
|
4212
4183
|
const emailDomainsReducer = emailDomainsSlice.reducer;
|
|
4213
|
-
const initialState$
|
|
4184
|
+
const initialState$3 = {
|
|
4214
4185
|
documents: {},
|
|
4215
4186
|
attachments: {}
|
|
4216
4187
|
};
|
|
4217
4188
|
const documentSlice = createSlice({
|
|
4218
4189
|
name: "documents",
|
|
4219
|
-
initialState: initialState$
|
|
4190
|
+
initialState: initialState$3,
|
|
4220
4191
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
4221
|
-
Object.assign(state, initialState$
|
|
4192
|
+
Object.assign(state, initialState$3);
|
|
4222
4193
|
}),
|
|
4223
4194
|
reducers: {
|
|
4224
4195
|
setDocuments: (state, action) => {
|
|
@@ -4449,13 +4420,13 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
|
|
|
4449
4420
|
)
|
|
4450
4421
|
);
|
|
4451
4422
|
const documentsReducer = documentSlice.reducer;
|
|
4452
|
-
const initialState$
|
|
4423
|
+
const initialState$2 = {
|
|
4453
4424
|
teams: {}
|
|
4454
4425
|
};
|
|
4455
4426
|
const teamSlice = createSlice({
|
|
4456
4427
|
name: "teams",
|
|
4457
|
-
initialState: initialState$
|
|
4458
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
4428
|
+
initialState: initialState$2,
|
|
4429
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
|
|
4459
4430
|
reducers: {
|
|
4460
4431
|
setTeam: (state, action) => {
|
|
4461
4432
|
state.teams[action.payload.offline_id] = action.payload;
|
|
@@ -4505,6 +4476,54 @@ const selectTeamsOfUser = restructureCreateSelectorWithArgs(
|
|
|
4505
4476
|
})
|
|
4506
4477
|
);
|
|
4507
4478
|
const teamReducer = teamSlice.reducer;
|
|
4479
|
+
const initialState$1 = {
|
|
4480
|
+
conversations: {}
|
|
4481
|
+
};
|
|
4482
|
+
const agentsSlice = createSlice({
|
|
4483
|
+
name: "agents",
|
|
4484
|
+
initialState: initialState$1,
|
|
4485
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
|
|
4486
|
+
reducers: {
|
|
4487
|
+
setConversations: (state, action) => {
|
|
4488
|
+
state.conversations = {};
|
|
4489
|
+
for (const conversation of action.payload) {
|
|
4490
|
+
state.conversations[conversation.offline_id] = conversation;
|
|
4491
|
+
}
|
|
4492
|
+
},
|
|
4493
|
+
addConversation: (state, action) => {
|
|
4494
|
+
if (action.payload.offline_id in state.conversations) {
|
|
4495
|
+
throw new Error("Conversation already exists in history");
|
|
4496
|
+
}
|
|
4497
|
+
state.conversations[action.payload.offline_id] = action.payload;
|
|
4498
|
+
},
|
|
4499
|
+
setConversation: (state, action) => {
|
|
4500
|
+
if (!(action.payload.offline_id in state.conversations)) {
|
|
4501
|
+
throw new Error("Conversation does not exist in history");
|
|
4502
|
+
}
|
|
4503
|
+
state.conversations[action.payload.offline_id] = action.payload;
|
|
4504
|
+
},
|
|
4505
|
+
updateConversation: (state, action) => {
|
|
4506
|
+
const existing = state.conversations[action.payload.offline_id];
|
|
4507
|
+
if (!existing) {
|
|
4508
|
+
throw new Error("Conversation does not exist in history");
|
|
4509
|
+
}
|
|
4510
|
+
state.conversations[action.payload.offline_id] = { ...existing, ...action.payload };
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
});
|
|
4514
|
+
const { setConversations, addConversation, setConversation, updateConversation } = agentsSlice.actions;
|
|
4515
|
+
const selectConversationMapping = (state) => state.agentsReducer.conversations;
|
|
4516
|
+
const selectConversations = createSelector(
|
|
4517
|
+
[selectConversationMapping],
|
|
4518
|
+
(conversationMapping) => Object.values(conversationMapping)
|
|
4519
|
+
);
|
|
4520
|
+
const selectConversation = restructureCreateSelectorWithArgs(
|
|
4521
|
+
createSelector(
|
|
4522
|
+
[selectConversationMapping, (_state, conversationId) => conversationId],
|
|
4523
|
+
(conversationMapping, conversationId) => conversationMapping[conversationId]
|
|
4524
|
+
)
|
|
4525
|
+
);
|
|
4526
|
+
const agentsReducer = agentsSlice.reducer;
|
|
4508
4527
|
const initialState = {
|
|
4509
4528
|
version: 0
|
|
4510
4529
|
};
|
|
@@ -4555,7 +4574,8 @@ const overmapReducers = {
|
|
|
4555
4574
|
emailDomainsReducer,
|
|
4556
4575
|
licenseReducer,
|
|
4557
4576
|
documentsReducer,
|
|
4558
|
-
teamReducer
|
|
4577
|
+
teamReducer,
|
|
4578
|
+
agentsReducer
|
|
4559
4579
|
};
|
|
4560
4580
|
const overmapReducer = combineReducers(overmapReducers);
|
|
4561
4581
|
const resetStore = "RESET";
|
|
@@ -4621,11 +4641,19 @@ const rootReducer = (state, action) => {
|
|
|
4621
4641
|
return overmapReducer(mutatedState, action);
|
|
4622
4642
|
};
|
|
4623
4643
|
let __OUTBOX_COORDINATOR = null;
|
|
4624
|
-
function
|
|
4625
|
-
|
|
4626
|
-
|
|
4644
|
+
function getOutboxCoordinator() {
|
|
4645
|
+
const clientStore2 = getClientStore();
|
|
4646
|
+
if (!clientStore2) {
|
|
4647
|
+
console.warn("Client store not set; cannot get outbox coordinator yet.");
|
|
4648
|
+
return null;
|
|
4649
|
+
}
|
|
4650
|
+
if (__OUTBOX_COORDINATOR) {
|
|
4651
|
+
return __OUTBOX_COORDINATOR;
|
|
4627
4652
|
}
|
|
4628
|
-
|
|
4653
|
+
const outbox = clientStore2.getState().offline.outbox;
|
|
4654
|
+
const coordinator = OutboxCoordinator._fromOutbox(outbox);
|
|
4655
|
+
__OUTBOX_COORDINATOR = coordinator;
|
|
4656
|
+
return coordinator;
|
|
4629
4657
|
}
|
|
4630
4658
|
const persistCallback = (err) => {
|
|
4631
4659
|
if (err)
|
|
@@ -4638,12 +4666,20 @@ const persistCallback = (err) => {
|
|
|
4638
4666
|
}
|
|
4639
4667
|
};
|
|
4640
4668
|
const enqueue = (_array, item, _context) => {
|
|
4641
|
-
const coordinator =
|
|
4669
|
+
const coordinator = getOutboxCoordinator();
|
|
4670
|
+
if (!coordinator) {
|
|
4671
|
+
console.warn("Outbox coordinator not set; cannot enqueue request yet.");
|
|
4672
|
+
return [];
|
|
4673
|
+
}
|
|
4642
4674
|
coordinator.addRequest(item);
|
|
4643
4675
|
return coordinator.getQueue();
|
|
4644
4676
|
};
|
|
4645
4677
|
const dequeue = (_array, item, _context) => {
|
|
4646
|
-
const coordinator =
|
|
4678
|
+
const coordinator = getOutboxCoordinator();
|
|
4679
|
+
if (!coordinator) {
|
|
4680
|
+
console.warn("Outbox coordinator not set; cannot dequeue request yet.");
|
|
4681
|
+
return [];
|
|
4682
|
+
}
|
|
4647
4683
|
const meta = item.meta;
|
|
4648
4684
|
const uuid = meta.offlineAction.payload.uuid;
|
|
4649
4685
|
coordinator.remove(uuid);
|
|
@@ -4727,7 +4763,6 @@ async function performRequest(action, client) {
|
|
|
4727
4763
|
}
|
|
4728
4764
|
}
|
|
4729
4765
|
}
|
|
4730
|
-
console.debug("Done checking tokens");
|
|
4731
4766
|
const defaultSettings = {
|
|
4732
4767
|
queryParams: "",
|
|
4733
4768
|
isAuthNeeded: true
|
|
@@ -4871,7 +4906,7 @@ class OfflineMiddleware {
|
|
|
4871
4906
|
if (this.next) {
|
|
4872
4907
|
return this.next.run(action);
|
|
4873
4908
|
} else {
|
|
4874
|
-
console.debug(
|
|
4909
|
+
console.debug("Middleware finished. Performing request:", action);
|
|
4875
4910
|
const baseUrl = action.meta.offline.effect.BASE_URL;
|
|
4876
4911
|
const clientStore2 = getClientStore();
|
|
4877
4912
|
if (!clientStore2)
|
|
@@ -4935,7 +4970,11 @@ function discard(reason, action, retries = 0) {
|
|
|
4935
4970
|
const uuid = action.payload.uuid;
|
|
4936
4971
|
function rollbackAndThrow() {
|
|
4937
4972
|
clientStore2.dispatch(markAsDeleted(uuid));
|
|
4938
|
-
|
|
4973
|
+
const coordinator2 = getOutboxCoordinator();
|
|
4974
|
+
if (!coordinator2) {
|
|
4975
|
+
throw new Error("Outbox coordinator not set");
|
|
4976
|
+
}
|
|
4977
|
+
coordinator2.remove(action.payload.uuid);
|
|
4939
4978
|
const rollbackAction = action.meta.offline.rollback;
|
|
4940
4979
|
if (rollbackAction) {
|
|
4941
4980
|
console.warn("Rolling back request due to SDK error:", action);
|
|
@@ -4966,17 +5005,26 @@ function discard(reason, action, retries = 0) {
|
|
|
4966
5005
|
console.error(`Could not display toast for status ${status} because there is no toast handle.`);
|
|
4967
5006
|
}
|
|
4968
5007
|
}
|
|
4969
|
-
|
|
5008
|
+
const coordinator2 = getOutboxCoordinator();
|
|
5009
|
+
if (!coordinator2) {
|
|
5010
|
+
throw new Error("Outbox coordinator not set");
|
|
5011
|
+
}
|
|
5012
|
+
coordinator2.remove(action.payload.uuid);
|
|
4970
5013
|
reason.options.discard = true;
|
|
4971
5014
|
rollbackAndThrow();
|
|
4972
5015
|
}
|
|
4973
5016
|
}
|
|
4974
5017
|
console.debug("Registering a retry for request:", action.payload.uuid);
|
|
4975
|
-
|
|
5018
|
+
const coordinator = getOutboxCoordinator();
|
|
5019
|
+
if (!coordinator) {
|
|
5020
|
+
throw new Error("Outbox coordinator not set");
|
|
5021
|
+
}
|
|
5022
|
+
coordinator.registerRetry(action.payload.uuid);
|
|
4976
5023
|
return false;
|
|
4977
5024
|
}
|
|
4978
5025
|
function peek(_array, _item, _context) {
|
|
4979
|
-
|
|
5026
|
+
var _a2;
|
|
5027
|
+
return (_a2 = getOutboxCoordinator()) == null ? void 0 : _a2.peek();
|
|
4980
5028
|
}
|
|
4981
5029
|
function retry(_action, _retries) {
|
|
4982
5030
|
getClientStore().dispatch(_setLatestRetryTime((/* @__PURE__ */ new Date()).getTime()));
|
|
@@ -4984,94 +5032,6 @@ function retry(_action, _retries) {
|
|
|
4984
5032
|
}
|
|
4985
5033
|
const useAppDispatch = () => useDispatch();
|
|
4986
5034
|
const useAppSelector = useSelector;
|
|
4987
|
-
class BaseApiService {
|
|
4988
|
-
constructor(sdk) {
|
|
4989
|
-
__publicField(this, "client");
|
|
4990
|
-
this.client = sdk;
|
|
4991
|
-
}
|
|
4992
|
-
/**
|
|
4993
|
-
* Enqueues an API request to the offline outbox.
|
|
4994
|
-
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
4995
|
-
* @protected
|
|
4996
|
-
*/
|
|
4997
|
-
async enqueueRequest(requestDetails) {
|
|
4998
|
-
return this._enqueueRequest(requestDetails).then((result) => {
|
|
4999
|
-
if (result instanceof APIError) {
|
|
5000
|
-
throw result;
|
|
5001
|
-
}
|
|
5002
|
-
return result;
|
|
5003
|
-
});
|
|
5004
|
-
}
|
|
5005
|
-
/**
|
|
5006
|
-
* Enqueues an API request to the Redux Offline outbox
|
|
5007
|
-
* @protected
|
|
5008
|
-
*/
|
|
5009
|
-
_enqueueRequest(requestDetails) {
|
|
5010
|
-
const promise = new DeferredPromise();
|
|
5011
|
-
const requestDetailsWithBaseUrl = { ...requestDetails, BASE_URL: this.client.API_URL };
|
|
5012
|
-
const { store } = this.client;
|
|
5013
|
-
if (requestDetails.immediate) {
|
|
5014
|
-
const requestWithUuid = {
|
|
5015
|
-
...requestDetailsWithBaseUrl,
|
|
5016
|
-
uuid: requestDetails.uuid ?? v4()
|
|
5017
|
-
};
|
|
5018
|
-
const fullOfflineAction = {
|
|
5019
|
-
payload: requestWithUuid,
|
|
5020
|
-
type: "",
|
|
5021
|
-
meta: {
|
|
5022
|
-
offline: {
|
|
5023
|
-
effect: {
|
|
5024
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5025
|
-
request: requestWithUuid,
|
|
5026
|
-
BASE_URL: this.client.API_URL
|
|
5027
|
-
}
|
|
5028
|
-
}
|
|
5029
|
-
}
|
|
5030
|
-
};
|
|
5031
|
-
performRequest(fullOfflineAction, this.client).then((result) => {
|
|
5032
|
-
promise.resolve(result.body);
|
|
5033
|
-
}).catch((error2) => {
|
|
5034
|
-
discard(error2, fullOfflineAction);
|
|
5035
|
-
promise.reject(error2);
|
|
5036
|
-
});
|
|
5037
|
-
} else {
|
|
5038
|
-
const innerPromise = store.dispatch(
|
|
5039
|
-
enqueueRequest(requestDetailsWithBaseUrl)
|
|
5040
|
-
);
|
|
5041
|
-
const successOrUndefinedHandler = (response) => {
|
|
5042
|
-
if (response) {
|
|
5043
|
-
promise.resolve(response.body);
|
|
5044
|
-
} else {
|
|
5045
|
-
const error2 = new APIError({
|
|
5046
|
-
message: "Could not get a response from the server.",
|
|
5047
|
-
response,
|
|
5048
|
-
discard: true
|
|
5049
|
-
});
|
|
5050
|
-
promise.reject(error2);
|
|
5051
|
-
}
|
|
5052
|
-
};
|
|
5053
|
-
const errorHandler = (error2) => {
|
|
5054
|
-
if (error2 instanceof APIError) {
|
|
5055
|
-
error2.options.discard = true;
|
|
5056
|
-
} else {
|
|
5057
|
-
console.error(
|
|
5058
|
-
"Received an unexpected error while processing a request:",
|
|
5059
|
-
error2,
|
|
5060
|
-
"\nConverting error to APIError and discarding."
|
|
5061
|
-
);
|
|
5062
|
-
error2 = new APIError({
|
|
5063
|
-
message: "An error occurred while processing the request.",
|
|
5064
|
-
innerError: error2,
|
|
5065
|
-
discard: true
|
|
5066
|
-
});
|
|
5067
|
-
}
|
|
5068
|
-
promise.reject(error2);
|
|
5069
|
-
};
|
|
5070
|
-
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
5071
|
-
}
|
|
5072
|
-
return promise;
|
|
5073
|
-
}
|
|
5074
|
-
}
|
|
5075
5035
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
5076
5036
|
function parseTokens(response) {
|
|
5077
5037
|
if (!response.access)
|
|
@@ -5098,7 +5058,7 @@ class AuthService extends BaseApiService {
|
|
|
5098
5058
|
*/
|
|
5099
5059
|
__publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
|
|
5100
5060
|
const uuid = v4();
|
|
5101
|
-
const responsePromise = this.enqueueRequest({
|
|
5061
|
+
const responsePromise = this.client.enqueueRequest({
|
|
5102
5062
|
uuid,
|
|
5103
5063
|
description: "Get token pair",
|
|
5104
5064
|
method: HttpMethod.POST,
|
|
@@ -5123,7 +5083,7 @@ class AuthService extends BaseApiService {
|
|
|
5123
5083
|
* @returns {Promise<TokenPair>} The new access and refresh tokens
|
|
5124
5084
|
*/
|
|
5125
5085
|
__publicField(this, "_getRenewedTokens", async (refreshToken) => {
|
|
5126
|
-
const promise = this.enqueueRequest({
|
|
5086
|
+
const promise = this.client.enqueueRequest({
|
|
5127
5087
|
description: "Get renewed tokens",
|
|
5128
5088
|
method: HttpMethod.POST,
|
|
5129
5089
|
url: "/api/token/refresh/",
|
|
@@ -5236,7 +5196,7 @@ class AuthService extends BaseApiService {
|
|
|
5236
5196
|
* Register a new user
|
|
5237
5197
|
*/
|
|
5238
5198
|
register(payload) {
|
|
5239
|
-
return this.enqueueRequest({
|
|
5199
|
+
return this.client.enqueueRequest({
|
|
5240
5200
|
description: "Register",
|
|
5241
5201
|
method: HttpMethod.POST,
|
|
5242
5202
|
url: "/authentication/users/register/",
|
|
@@ -5247,7 +5207,7 @@ class AuthService extends BaseApiService {
|
|
|
5247
5207
|
});
|
|
5248
5208
|
}
|
|
5249
5209
|
async resetPassword(email) {
|
|
5250
|
-
return this.enqueueRequest({
|
|
5210
|
+
return this.client.enqueueRequest({
|
|
5251
5211
|
description: "Reset password",
|
|
5252
5212
|
method: HttpMethod.PATCH,
|
|
5253
5213
|
url: "/authentication/users/reset-password/",
|
|
@@ -5284,7 +5244,7 @@ class AuthService extends BaseApiService {
|
|
|
5284
5244
|
const { store } = this.client;
|
|
5285
5245
|
const [fileProps] = await this.client.files.uploadFileToS3(hash);
|
|
5286
5246
|
store.dispatch(setProfilePicture({ file: `/files/${fileProps.file}`, file_sha1: hash }));
|
|
5287
|
-
return this.enqueueRequest({
|
|
5247
|
+
return this.client.enqueueRequest({
|
|
5288
5248
|
description: "Replace profile picture",
|
|
5289
5249
|
method: HttpMethod.PATCH,
|
|
5290
5250
|
url: "/authentication/users/profile-details/",
|
|
@@ -5295,7 +5255,7 @@ class AuthService extends BaseApiService {
|
|
|
5295
5255
|
}
|
|
5296
5256
|
async addFavouriteProjectId(projectId) {
|
|
5297
5257
|
this.client.store.dispatch(addFavouriteProjectId(projectId));
|
|
5298
|
-
return this.enqueueRequest({
|
|
5258
|
+
return this.client.enqueueRequest({
|
|
5299
5259
|
description: "Add favourite project",
|
|
5300
5260
|
method: HttpMethod.POST,
|
|
5301
5261
|
url: `/authentication/users/favourite-project/${projectId}/`,
|
|
@@ -5305,7 +5265,7 @@ class AuthService extends BaseApiService {
|
|
|
5305
5265
|
}
|
|
5306
5266
|
async removeFavouriteProjectId(projectId) {
|
|
5307
5267
|
this.client.store.dispatch(removeFavouriteProjectId(projectId));
|
|
5308
|
-
return this.enqueueRequest({
|
|
5268
|
+
return this.client.enqueueRequest({
|
|
5309
5269
|
description: "Add favourite project",
|
|
5310
5270
|
method: HttpMethod.POST,
|
|
5311
5271
|
url: `/authentication/users/unfavourite-project/${projectId}/`,
|
|
@@ -5315,7 +5275,10 @@ class AuthService extends BaseApiService {
|
|
|
5315
5275
|
}
|
|
5316
5276
|
async setTourStep(stepIndex) {
|
|
5317
5277
|
this.client.store.dispatch(setTourStep(stepIndex));
|
|
5318
|
-
|
|
5278
|
+
const currentStep = this.client.store.getState().userReducer.currentUser.profile.tour_step;
|
|
5279
|
+
if (currentStep === stepIndex)
|
|
5280
|
+
return Promise.resolve(void 0);
|
|
5281
|
+
return this.client.enqueueRequest({
|
|
5319
5282
|
description: "Set tour step",
|
|
5320
5283
|
method: HttpMethod.PATCH,
|
|
5321
5284
|
url: "/authentication/users/profile-details/",
|
|
@@ -5327,7 +5290,7 @@ class AuthService extends BaseApiService {
|
|
|
5327
5290
|
});
|
|
5328
5291
|
}
|
|
5329
5292
|
async joinApplication(projectInviteId, verification_code, username, password) {
|
|
5330
|
-
return this.enqueueRequest({
|
|
5293
|
+
return this.client.enqueueRequest({
|
|
5331
5294
|
description: "Join application",
|
|
5332
5295
|
method: HttpMethod.PATCH,
|
|
5333
5296
|
url: `/authentication/join-app/${projectInviteId}/${verification_code}/`,
|
|
@@ -5346,7 +5309,7 @@ class CategoryService extends BaseApiService {
|
|
|
5346
5309
|
const offlineCategory = offline(category);
|
|
5347
5310
|
const categoryWithWorkspace = { ...offlineCategory, workspace: workspaceId };
|
|
5348
5311
|
this.client.store.dispatch(addCategory(categoryWithWorkspace));
|
|
5349
|
-
const promise = this.enqueueRequest({
|
|
5312
|
+
const promise = this.client.enqueueRequest({
|
|
5350
5313
|
description: "Create Category",
|
|
5351
5314
|
method: HttpMethod.POST,
|
|
5352
5315
|
url: "/categories/",
|
|
@@ -5360,7 +5323,7 @@ class CategoryService extends BaseApiService {
|
|
|
5360
5323
|
return [categoryWithWorkspace, promise];
|
|
5361
5324
|
}
|
|
5362
5325
|
fetchAll(projectId) {
|
|
5363
|
-
const promise = this.enqueueRequest({
|
|
5326
|
+
const promise = this.client.enqueueRequest({
|
|
5364
5327
|
description: "Get categories",
|
|
5365
5328
|
method: HttpMethod.GET,
|
|
5366
5329
|
url: `/projects/${projectId}/categories/`,
|
|
@@ -5377,7 +5340,7 @@ class CategoryService extends BaseApiService {
|
|
|
5377
5340
|
}
|
|
5378
5341
|
this.client.store.dispatch(patchCategory(category));
|
|
5379
5342
|
const optimisticCategory = { ...existingCategory, ...category };
|
|
5380
|
-
const promise = this.enqueueRequest({
|
|
5343
|
+
const promise = this.client.enqueueRequest({
|
|
5381
5344
|
description: "Edit Category",
|
|
5382
5345
|
method: HttpMethod.PATCH,
|
|
5383
5346
|
url: `/categories/${category.offline_id}/`,
|
|
@@ -5392,7 +5355,7 @@ class CategoryService extends BaseApiService {
|
|
|
5392
5355
|
}
|
|
5393
5356
|
remove(category, workspaceId) {
|
|
5394
5357
|
this.client.store.dispatch(removeCategory(category.offline_id));
|
|
5395
|
-
return this.enqueueRequest({
|
|
5358
|
+
return this.client.enqueueRequest({
|
|
5396
5359
|
description: "Delete Category",
|
|
5397
5360
|
method: HttpMethod.DELETE,
|
|
5398
5361
|
url: `/categories/${category.offline_id}/`,
|
|
@@ -5438,7 +5401,7 @@ class ComponentService extends BaseApiService {
|
|
|
5438
5401
|
add(component, workspaceId) {
|
|
5439
5402
|
const offlineComponent = offline(component);
|
|
5440
5403
|
this.client.store.dispatch(addComponent(offlineComponent));
|
|
5441
|
-
const promise = this.enqueueRequest({
|
|
5404
|
+
const promise = this.client.enqueueRequest({
|
|
5442
5405
|
description: "Create Component",
|
|
5443
5406
|
method: HttpMethod.POST,
|
|
5444
5407
|
url: `/components/types/${offlineComponent.component_type}/add-components/`,
|
|
@@ -5453,7 +5416,7 @@ class ComponentService extends BaseApiService {
|
|
|
5453
5416
|
}
|
|
5454
5417
|
update(component, workspaceId) {
|
|
5455
5418
|
this.client.store.dispatch(updateComponent(component));
|
|
5456
|
-
const promise = this.enqueueRequest({
|
|
5419
|
+
const promise = this.client.enqueueRequest({
|
|
5457
5420
|
description: "Edit component",
|
|
5458
5421
|
method: HttpMethod.PATCH,
|
|
5459
5422
|
url: `/components/${component.offline_id}/`,
|
|
@@ -5477,7 +5440,7 @@ class ComponentService extends BaseApiService {
|
|
|
5477
5440
|
const attachmentsOfComponentIds = attachmentsOfComponent.map(({ offline_id }) => offline_id);
|
|
5478
5441
|
store.dispatch(removeComponentAttachments(attachmentsOfComponentIds));
|
|
5479
5442
|
}
|
|
5480
|
-
return this.enqueueRequest({
|
|
5443
|
+
return this.client.enqueueRequest({
|
|
5481
5444
|
description: "Delete issue",
|
|
5482
5445
|
method: HttpMethod.DELETE,
|
|
5483
5446
|
url: `/components/${id}/`,
|
|
@@ -5498,7 +5461,7 @@ class ComponentService extends BaseApiService {
|
|
|
5498
5461
|
const state = store.getState();
|
|
5499
5462
|
const componentsOfThisType = selectComponentsByType(componentTypeId)(state);
|
|
5500
5463
|
store.dispatch(removeAllComponentsOfType(componentTypeId));
|
|
5501
|
-
return this.enqueueRequest({
|
|
5464
|
+
return this.client.enqueueRequest({
|
|
5502
5465
|
description: "Batch delete components by component type",
|
|
5503
5466
|
method: HttpMethod.DELETE,
|
|
5504
5467
|
url: `/components/types/${componentTypeId}/delete-all-of-type/`,
|
|
@@ -5517,7 +5480,7 @@ class ComponentService extends BaseApiService {
|
|
|
5517
5480
|
});
|
|
5518
5481
|
const { store } = this.client;
|
|
5519
5482
|
store.dispatch(addComponentsInBatches(fullComponents));
|
|
5520
|
-
const promise = this.enqueueRequest({
|
|
5483
|
+
const promise = this.client.enqueueRequest({
|
|
5521
5484
|
description: "Batch create components",
|
|
5522
5485
|
method: HttpMethod.POST,
|
|
5523
5486
|
url: `/components/types/${componentTypeId}/add-components/`,
|
|
@@ -5542,20 +5505,16 @@ class ComponentService extends BaseApiService {
|
|
|
5542
5505
|
});
|
|
5543
5506
|
return promise;
|
|
5544
5507
|
}
|
|
5545
|
-
async refreshStore(
|
|
5508
|
+
async refreshStore() {
|
|
5546
5509
|
const { store } = this.client;
|
|
5547
|
-
const result = await this.enqueueRequest({
|
|
5510
|
+
const result = await this.client.enqueueRequest({
|
|
5548
5511
|
description: "Get components",
|
|
5549
5512
|
method: HttpMethod.GET,
|
|
5550
5513
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/components/`,
|
|
5551
5514
|
blockers: [],
|
|
5552
5515
|
blocks: []
|
|
5553
5516
|
});
|
|
5554
|
-
|
|
5555
|
-
store.dispatch(setComponents(result));
|
|
5556
|
-
} else {
|
|
5557
|
-
store.dispatch(addComponentsInBatches(result));
|
|
5558
|
-
}
|
|
5517
|
+
store.dispatch(setComponents(result));
|
|
5559
5518
|
}
|
|
5560
5519
|
}
|
|
5561
5520
|
class ComponentStageCompletionService extends BaseApiService {
|
|
@@ -5571,7 +5530,7 @@ class ComponentStageCompletionService extends BaseApiService {
|
|
|
5571
5530
|
stage: stageId
|
|
5572
5531
|
});
|
|
5573
5532
|
store.dispatch(addStageCompletion(offlineCompletion));
|
|
5574
|
-
const promise = this.enqueueRequest({
|
|
5533
|
+
const promise = this.client.enqueueRequest({
|
|
5575
5534
|
description: "Mark stage as completed",
|
|
5576
5535
|
method: HttpMethod.POST,
|
|
5577
5536
|
url: `/components/types/${componentType}/complete-stages/`,
|
|
@@ -5584,7 +5543,7 @@ class ComponentStageCompletionService extends BaseApiService {
|
|
|
5584
5543
|
}
|
|
5585
5544
|
async refreshStore() {
|
|
5586
5545
|
const { store } = this.client;
|
|
5587
|
-
const result = await this.enqueueRequest({
|
|
5546
|
+
const result = await this.client.enqueueRequest({
|
|
5588
5547
|
description: "Get completed stages",
|
|
5589
5548
|
method: HttpMethod.GET,
|
|
5590
5549
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/component-stage-completions/`,
|
|
@@ -5611,7 +5570,7 @@ class ComponentStageCompletionService extends BaseApiService {
|
|
|
5611
5570
|
asMapping[completion.component] = stageToCompletionDateMapping;
|
|
5612
5571
|
}
|
|
5613
5572
|
this.client.store.dispatch(addStageCompletions(asMapping));
|
|
5614
|
-
await this.enqueueRequest({
|
|
5573
|
+
await this.client.enqueueRequest({
|
|
5615
5574
|
description: "Mark multiple stage as completed",
|
|
5616
5575
|
method: HttpMethod.POST,
|
|
5617
5576
|
url: `/components/types/${componentTypeId}/complete-stages/`,
|
|
@@ -5634,7 +5593,7 @@ class ComponentStageCompletionService extends BaseApiService {
|
|
|
5634
5593
|
};
|
|
5635
5594
|
});
|
|
5636
5595
|
this.client.store.dispatch(removeStageCompletions(completionsToRemove));
|
|
5637
|
-
return this.enqueueRequest({
|
|
5596
|
+
return this.client.enqueueRequest({
|
|
5638
5597
|
description: `Undo stage for ${componentIds.length} component(s)`,
|
|
5639
5598
|
// TODO: Rename to setCompletedStages
|
|
5640
5599
|
method: HttpMethod.DELETE,
|
|
@@ -5656,7 +5615,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5656
5615
|
return { ...stage, component_type: componentTypeId };
|
|
5657
5616
|
});
|
|
5658
5617
|
this.client.store.dispatch(addStages(fullStages));
|
|
5659
|
-
return this.enqueueRequest({
|
|
5618
|
+
return this.client.enqueueRequest({
|
|
5660
5619
|
description: "Add component stages",
|
|
5661
5620
|
method: HttpMethod.POST,
|
|
5662
5621
|
url: `/components/types/${componentTypeId}/add-stages/`,
|
|
@@ -5680,7 +5639,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5680
5639
|
throw new Error("Could not find the desired stages to update within the store");
|
|
5681
5640
|
}
|
|
5682
5641
|
store.dispatch(updateStages(stagesToUpdate));
|
|
5683
|
-
return this.enqueueRequest({
|
|
5642
|
+
return this.client.enqueueRequest({
|
|
5684
5643
|
description: "Edit component stages",
|
|
5685
5644
|
method: HttpMethod.PATCH,
|
|
5686
5645
|
url: `/components/types/${componentTypeId}/bulk-update-stages/`,
|
|
@@ -5696,7 +5655,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5696
5655
|
}
|
|
5697
5656
|
async bulkDelete(idsToDelete) {
|
|
5698
5657
|
this.client.store.dispatch(removeStages(idsToDelete));
|
|
5699
|
-
return this.enqueueRequest({
|
|
5658
|
+
return this.client.enqueueRequest({
|
|
5700
5659
|
description: "Delete component stages",
|
|
5701
5660
|
method: HttpMethod.DELETE,
|
|
5702
5661
|
url: "/components/stages/bulk-delete/",
|
|
@@ -5709,7 +5668,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5709
5668
|
}
|
|
5710
5669
|
async update(componentStage) {
|
|
5711
5670
|
this.client.store.dispatch(addStages([componentStage]));
|
|
5712
|
-
return this.enqueueRequest({
|
|
5671
|
+
return this.client.enqueueRequest({
|
|
5713
5672
|
description: "Update component stage",
|
|
5714
5673
|
method: HttpMethod.PATCH,
|
|
5715
5674
|
url: `/components/stages/${componentStage.offline_id}/`,
|
|
@@ -5722,7 +5681,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5722
5681
|
const { store } = this.client;
|
|
5723
5682
|
store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
|
|
5724
5683
|
try {
|
|
5725
|
-
await this.enqueueRequest({
|
|
5684
|
+
await this.client.enqueueRequest({
|
|
5726
5685
|
description: "Link component stage to form",
|
|
5727
5686
|
method: HttpMethod.POST,
|
|
5728
5687
|
url: `/components/stages/${stageId}/associate-with-form/`,
|
|
@@ -5739,7 +5698,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5739
5698
|
const { store } = this.client;
|
|
5740
5699
|
store.dispatch(unlinkStageToForm({ stageId }));
|
|
5741
5700
|
try {
|
|
5742
|
-
await this.enqueueRequest({
|
|
5701
|
+
await this.client.enqueueRequest({
|
|
5743
5702
|
description: "Unlink component stage from form",
|
|
5744
5703
|
method: HttpMethod.DELETE,
|
|
5745
5704
|
url: `/components/stages/${stageId}/associate-with-form/`,
|
|
@@ -5753,7 +5712,7 @@ class ComponentStageService extends BaseApiService {
|
|
|
5753
5712
|
}
|
|
5754
5713
|
async refreshStore() {
|
|
5755
5714
|
const { store } = this.client;
|
|
5756
|
-
const result = await this.enqueueRequest({
|
|
5715
|
+
const result = await this.client.enqueueRequest({
|
|
5757
5716
|
description: "Get component stages",
|
|
5758
5717
|
method: HttpMethod.GET,
|
|
5759
5718
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/component-stages/`,
|
|
@@ -5819,7 +5778,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5819
5778
|
}
|
|
5820
5779
|
processPresignedUrls(presignedUrls) {
|
|
5821
5780
|
for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
|
|
5822
|
-
void this.enqueueRequest({
|
|
5781
|
+
void this.client.enqueueRequest({
|
|
5823
5782
|
url: presignedUrl.url,
|
|
5824
5783
|
description: "Upload file to S3",
|
|
5825
5784
|
method: HttpMethod.POST,
|
|
@@ -5839,7 +5798,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5839
5798
|
const { store } = this.client;
|
|
5840
5799
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
5841
5800
|
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
5842
|
-
const result = await this.enqueueRequest({
|
|
5801
|
+
const result = await this.client.enqueueRequest({
|
|
5843
5802
|
description: `Get ${meta.name} attachments`,
|
|
5844
5803
|
method: HttpMethod.GET,
|
|
5845
5804
|
url: `/projects/${activeProjectId}${meta.fetchUrlPostfix}/`,
|
|
@@ -5884,7 +5843,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5884
5843
|
}
|
|
5885
5844
|
store.dispatch(actions.addAttachments(offlineAttachments));
|
|
5886
5845
|
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
5887
|
-
const promise = this.enqueueRequest({
|
|
5846
|
+
const promise = this.client.enqueueRequest({
|
|
5888
5847
|
description: `Attach files to ${meta.name}`,
|
|
5889
5848
|
method: HttpMethod.POST,
|
|
5890
5849
|
url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
|
|
@@ -5914,7 +5873,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5914
5873
|
}
|
|
5915
5874
|
store.dispatch(actions.removeAttachment(attachment.offline_id));
|
|
5916
5875
|
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
5917
|
-
const promise = this.enqueueRequest({
|
|
5876
|
+
const promise = this.client.enqueueRequest({
|
|
5918
5877
|
description: "Delete attachment",
|
|
5919
5878
|
method: HttpMethod.DELETE,
|
|
5920
5879
|
url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
|
|
@@ -5984,7 +5943,7 @@ class ComponentTypeService extends BaseApiService {
|
|
|
5984
5943
|
const { store } = this.client;
|
|
5985
5944
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
5986
5945
|
store.dispatch(addComponentType(offlineComponentType));
|
|
5987
|
-
const promise = this.enqueueRequest({
|
|
5946
|
+
const promise = this.client.enqueueRequest({
|
|
5988
5947
|
description: "Create ComponentType",
|
|
5989
5948
|
method: HttpMethod.POST,
|
|
5990
5949
|
url: `/projects/${activeProjectId}/component-types/`,
|
|
@@ -5996,7 +5955,7 @@ class ComponentTypeService extends BaseApiService {
|
|
|
5996
5955
|
}
|
|
5997
5956
|
update(componentType) {
|
|
5998
5957
|
this.client.store.dispatch(addComponentType(componentType));
|
|
5999
|
-
return this.enqueueRequest({
|
|
5958
|
+
return this.client.enqueueRequest({
|
|
6000
5959
|
description: "Update ComponentType",
|
|
6001
5960
|
method: HttpMethod.PATCH,
|
|
6002
5961
|
url: `/components/types/${componentType.offline_id}/`,
|
|
@@ -6025,7 +5984,7 @@ class ComponentTypeService extends BaseApiService {
|
|
|
6025
5984
|
const attachmentsOfComponentTypeIds = attachmentsOfComponentType.map(({ offline_id }) => offline_id);
|
|
6026
5985
|
store.dispatch(removeComponentTypeAttachments(attachmentsOfComponentTypeIds));
|
|
6027
5986
|
}
|
|
6028
|
-
return this.enqueueRequest({
|
|
5987
|
+
return this.client.enqueueRequest({
|
|
6029
5988
|
description: "Delete ComponentType",
|
|
6030
5989
|
method: HttpMethod.DELETE,
|
|
6031
5990
|
url: `/components/types/${componentTypeId}/`,
|
|
@@ -6040,7 +5999,7 @@ class ComponentTypeService extends BaseApiService {
|
|
|
6040
5999
|
}
|
|
6041
6000
|
async refreshStore() {
|
|
6042
6001
|
const { store } = this.client;
|
|
6043
|
-
const result = await this.enqueueRequest({
|
|
6002
|
+
const result = await this.client.enqueueRequest({
|
|
6044
6003
|
description: "Get component types",
|
|
6045
6004
|
method: HttpMethod.GET,
|
|
6046
6005
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/component-types/`,
|
|
@@ -6107,7 +6066,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6107
6066
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
6108
6067
|
});
|
|
6109
6068
|
store.dispatch(addIssueComment(offlineComment));
|
|
6110
|
-
const promise = this.enqueueRequest({
|
|
6069
|
+
const promise = this.client.enqueueRequest({
|
|
6111
6070
|
description: `${truncate(comment.content, 80)}`,
|
|
6112
6071
|
method: HttpMethod.POST,
|
|
6113
6072
|
url: `/issues/${comment.issue}/comment/`,
|
|
@@ -6127,7 +6086,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6127
6086
|
throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
|
|
6128
6087
|
}
|
|
6129
6088
|
store.dispatch(setIssueComment(comment));
|
|
6130
|
-
const promise = this.enqueueRequest({
|
|
6089
|
+
const promise = this.client.enqueueRequest({
|
|
6131
6090
|
description: `Edit comment: ${truncate(comment.content, 80)}`,
|
|
6132
6091
|
method: HttpMethod.PATCH,
|
|
6133
6092
|
url: `/issues/comments/${comment.offline_id}/`,
|
|
@@ -6146,7 +6105,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6146
6105
|
throw new Error(`Comment with offline_id ${offline_id} not found in store`);
|
|
6147
6106
|
}
|
|
6148
6107
|
this.client.store.dispatch(removeIssueComment(offline_id));
|
|
6149
|
-
const promise = this.enqueueRequest({
|
|
6108
|
+
const promise = this.client.enqueueRequest({
|
|
6150
6109
|
description: "Delete comment",
|
|
6151
6110
|
method: HttpMethod.DELETE,
|
|
6152
6111
|
url: `/issues/comments/${offline_id}/`,
|
|
@@ -6160,7 +6119,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6160
6119
|
}
|
|
6161
6120
|
async refreshStore() {
|
|
6162
6121
|
const { store } = this.client;
|
|
6163
|
-
const result = await this.enqueueRequest({
|
|
6122
|
+
const result = await this.client.enqueueRequest({
|
|
6164
6123
|
description: "Get comments",
|
|
6165
6124
|
method: HttpMethod.GET,
|
|
6166
6125
|
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
@@ -6174,7 +6133,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6174
6133
|
class IssueUpdateService extends BaseApiService {
|
|
6175
6134
|
async refreshStore() {
|
|
6176
6135
|
const { store } = this.client;
|
|
6177
|
-
const result = await this.enqueueRequest({
|
|
6136
|
+
const result = await this.client.enqueueRequest({
|
|
6178
6137
|
description: "Get issue updates",
|
|
6179
6138
|
method: HttpMethod.GET,
|
|
6180
6139
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/issues/updates/`,
|
|
@@ -6260,7 +6219,7 @@ class IssueService extends BaseApiService {
|
|
|
6260
6219
|
store.dispatch(addIssue(issuePayload));
|
|
6261
6220
|
store.dispatch(addToRecentIssues(issuePayload.offline_id));
|
|
6262
6221
|
store.dispatch(addActiveProjectIssuesCount(1));
|
|
6263
|
-
const promise = this.enqueueRequest({
|
|
6222
|
+
const promise = this.client.enqueueRequest({
|
|
6264
6223
|
description: "Create issue",
|
|
6265
6224
|
method: HttpMethod.POST,
|
|
6266
6225
|
url: "/issues/",
|
|
@@ -6284,7 +6243,8 @@ class IssueService extends BaseApiService {
|
|
|
6284
6243
|
if (error2 instanceof APIError) {
|
|
6285
6244
|
(_a2 = unsafeShowToast) == null ? void 0 : _a2({
|
|
6286
6245
|
title: "Could not create issue",
|
|
6287
|
-
description:
|
|
6246
|
+
description: error2.message,
|
|
6247
|
+
severity: "danger"
|
|
6288
6248
|
});
|
|
6289
6249
|
}
|
|
6290
6250
|
store.dispatch(removeIssue(issuePayload.offline_id));
|
|
@@ -6294,7 +6254,7 @@ class IssueService extends BaseApiService {
|
|
|
6294
6254
|
return [issuePayload, promise];
|
|
6295
6255
|
}
|
|
6296
6256
|
fetchAll(projectId) {
|
|
6297
|
-
const promise = this.enqueueRequest({
|
|
6257
|
+
const promise = this.client.enqueueRequest({
|
|
6298
6258
|
description: "Get issues",
|
|
6299
6259
|
method: HttpMethod.GET,
|
|
6300
6260
|
url: `/projects/${projectId}/issues/`,
|
|
@@ -6391,7 +6351,7 @@ class IssueService extends BaseApiService {
|
|
|
6391
6351
|
changes
|
|
6392
6352
|
});
|
|
6393
6353
|
this.client.store.dispatch(addIssueUpdate(offlineIssueUpdate));
|
|
6394
|
-
const promise = this.enqueueRequest({
|
|
6354
|
+
const promise = this.client.enqueueRequest({
|
|
6395
6355
|
description: "Edit issue",
|
|
6396
6356
|
method: HttpMethod.PATCH,
|
|
6397
6357
|
url: `/issues/${issue.offline_id}/`,
|
|
@@ -6424,7 +6384,7 @@ class IssueService extends BaseApiService {
|
|
|
6424
6384
|
if (updatesOfIssue.length > 0)
|
|
6425
6385
|
dispatch(removeIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
|
|
6426
6386
|
try {
|
|
6427
|
-
return await this.enqueueRequest({
|
|
6387
|
+
return await this.client.enqueueRequest({
|
|
6428
6388
|
description: "Delete issue",
|
|
6429
6389
|
method: HttpMethod.DELETE,
|
|
6430
6390
|
url: `/issues/${id}/`,
|
|
@@ -6466,7 +6426,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6466
6426
|
organization: activeOrganizationId
|
|
6467
6427
|
});
|
|
6468
6428
|
store.dispatch(addIssueType(offlineIssueType));
|
|
6469
|
-
const promise = this.enqueueRequest({
|
|
6429
|
+
const promise = this.client.enqueueRequest({
|
|
6470
6430
|
method: HttpMethod.POST,
|
|
6471
6431
|
url: `/organizations/${activeOrganizationId}/issue-types/`,
|
|
6472
6432
|
// Sending only whats needed here
|
|
@@ -6499,7 +6459,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6499
6459
|
...issueTypeFields
|
|
6500
6460
|
};
|
|
6501
6461
|
store.dispatch(updateIssueType(offlineUpdatedIssueType));
|
|
6502
|
-
const promise = this.enqueueRequest({
|
|
6462
|
+
const promise = this.client.enqueueRequest({
|
|
6503
6463
|
method: HttpMethod.PATCH,
|
|
6504
6464
|
url: `/issues/types/${issueTypeFields.offline_id}/`,
|
|
6505
6465
|
payload: issueTypeFields,
|
|
@@ -6523,7 +6483,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6523
6483
|
const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state) ?? [];
|
|
6524
6484
|
store.dispatch(removeIssueType(issueTypeId));
|
|
6525
6485
|
store.dispatch(removeIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
|
|
6526
|
-
const promise = this.enqueueRequest({
|
|
6486
|
+
const promise = this.client.enqueueRequest({
|
|
6527
6487
|
method: HttpMethod.DELETE,
|
|
6528
6488
|
url: `/issues/types/${issueTypeId}/`,
|
|
6529
6489
|
blockers: [issueTypeId],
|
|
@@ -6541,7 +6501,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6541
6501
|
if (!activeOrganizationId) {
|
|
6542
6502
|
throw new Error(`No active organization, got ${activeOrganizationId} for activeOrganizationId.`);
|
|
6543
6503
|
}
|
|
6544
|
-
const result = await this.enqueueRequest({
|
|
6504
|
+
const result = await this.client.enqueueRequest({
|
|
6545
6505
|
method: HttpMethod.GET,
|
|
6546
6506
|
url: `/organizations/${activeOrganizationId}/issue-types/`,
|
|
6547
6507
|
blockers: [],
|
|
@@ -6555,7 +6515,7 @@ class MainService extends BaseApiService {
|
|
|
6555
6515
|
if (replaceExisting) {
|
|
6556
6516
|
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
6557
6517
|
}
|
|
6558
|
-
|
|
6518
|
+
const result = await this.client.enqueueRequest({
|
|
6559
6519
|
uuid,
|
|
6560
6520
|
description: "Get initial data",
|
|
6561
6521
|
method: HttpMethod.GET,
|
|
@@ -6564,22 +6524,24 @@ class MainService extends BaseApiService {
|
|
|
6564
6524
|
isAuthNeeded: true,
|
|
6565
6525
|
blockers: [],
|
|
6566
6526
|
blocks: []
|
|
6567
|
-
}).then((result) => {
|
|
6568
|
-
void this._processInitialData(result, replaceExisting);
|
|
6569
|
-
return result;
|
|
6570
6527
|
});
|
|
6528
|
+
void this._processInitialData(result, replaceExisting);
|
|
6571
6529
|
}
|
|
6572
|
-
async fetchProjectUsers(
|
|
6573
|
-
|
|
6530
|
+
async fetchProjectUsers() {
|
|
6531
|
+
const projectId = this.client.store.getState().projectReducer.activeProjectId;
|
|
6532
|
+
return this.client.enqueueRequest({
|
|
6574
6533
|
description: "Fetch users",
|
|
6575
6534
|
method: HttpMethod.GET,
|
|
6576
6535
|
url: `/projects/${projectId}/users/`,
|
|
6577
6536
|
blockers: [],
|
|
6578
6537
|
blocks: []
|
|
6538
|
+
}).then((users) => {
|
|
6539
|
+
this.client.store.dispatch(addUsers(users));
|
|
6540
|
+
return users;
|
|
6579
6541
|
});
|
|
6580
6542
|
}
|
|
6581
6543
|
async fetchOrganizationUsers(orgId) {
|
|
6582
|
-
return this.enqueueRequest({
|
|
6544
|
+
return this.client.enqueueRequest({
|
|
6583
6545
|
description: "Fetch organization users",
|
|
6584
6546
|
method: HttpMethod.GET,
|
|
6585
6547
|
url: `/organizations/${orgId}/users/`,
|
|
@@ -6590,11 +6552,12 @@ class MainService extends BaseApiService {
|
|
|
6590
6552
|
// TODO:
|
|
6591
6553
|
// Don't accept updateStore in ComponentService.list. Just return the offline objects and promise. Here, if
|
|
6592
6554
|
// overwrite, use setComponents. Otherwise, use bulkAddComponents.
|
|
6555
|
+
// TODO: This needs major cleanup. Send less in the initial data: Only the basic project info and anything needed
|
|
6556
|
+
// literally immediately.
|
|
6593
6557
|
async _processInitialData(data, overwrite) {
|
|
6594
6558
|
var _a2, _b, _c;
|
|
6595
6559
|
const workspaces = {};
|
|
6596
6560
|
const projects = [];
|
|
6597
|
-
const categories = [];
|
|
6598
6561
|
const projectsData = data.projects;
|
|
6599
6562
|
const { store } = this.client;
|
|
6600
6563
|
const oldProjectId = (_a2 = projectsData.find(
|
|
@@ -6618,18 +6581,11 @@ class MainService extends BaseApiService {
|
|
|
6618
6581
|
isProjectIdValid = true;
|
|
6619
6582
|
for (const workspaceData of projectData.workspaces) {
|
|
6620
6583
|
const workspace = { ...workspaceData, project: projectData.id };
|
|
6621
|
-
if (workspace.categories) {
|
|
6622
|
-
for (const category of workspace.categories) {
|
|
6623
|
-
categories.push(category);
|
|
6624
|
-
}
|
|
6625
|
-
}
|
|
6626
|
-
delete workspace.categories;
|
|
6627
6584
|
workspaces[workspace.offline_id] = workspace;
|
|
6628
6585
|
}
|
|
6629
6586
|
}
|
|
6630
6587
|
}
|
|
6631
6588
|
store.dispatch(setCurrentUser(data.user));
|
|
6632
|
-
store.dispatch(addUsers(data.project_owners));
|
|
6633
6589
|
store.dispatch(setLicenses(data.licenses));
|
|
6634
6590
|
const organizationsData = data.organizations;
|
|
6635
6591
|
store.dispatch(setOrganizations(organizationsData));
|
|
@@ -6650,8 +6606,11 @@ class MainService extends BaseApiService {
|
|
|
6650
6606
|
currentOrgId = firstOrg.id;
|
|
6651
6607
|
}
|
|
6652
6608
|
if (currentOrgId) {
|
|
6653
|
-
await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
|
|
6654
|
-
|
|
6609
|
+
const initialOrgData = await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
|
|
6610
|
+
currentOrgId = initialOrgData.organization.id;
|
|
6611
|
+
}
|
|
6612
|
+
if (!currentOrgId) {
|
|
6613
|
+
throw new Error("No organization found");
|
|
6655
6614
|
}
|
|
6656
6615
|
if (!isProjectIdValid) {
|
|
6657
6616
|
if (validProjects.length !== 0) {
|
|
@@ -6661,12 +6620,6 @@ class MainService extends BaseApiService {
|
|
|
6661
6620
|
if (projectData) {
|
|
6662
6621
|
for (const workspaceData of projectData.workspaces) {
|
|
6663
6622
|
const workspace = { ...workspaceData, project: projectData.id };
|
|
6664
|
-
if (workspace.categories) {
|
|
6665
|
-
for (const category of workspace.categories) {
|
|
6666
|
-
categories.push(category);
|
|
6667
|
-
}
|
|
6668
|
-
}
|
|
6669
|
-
delete workspace.categories;
|
|
6670
6623
|
workspaces[workspace.offline_id] = workspace;
|
|
6671
6624
|
}
|
|
6672
6625
|
}
|
|
@@ -6675,14 +6628,6 @@ class MainService extends BaseApiService {
|
|
|
6675
6628
|
store.dispatch(setActiveProjectId(currentProjectId));
|
|
6676
6629
|
}
|
|
6677
6630
|
}
|
|
6678
|
-
if (currentProjectId) {
|
|
6679
|
-
const usersResultPromise = this.fetchProjectUsers(currentProjectId);
|
|
6680
|
-
const projectAccessRefreshPromise = this.client.projectAccesses.refreshStore();
|
|
6681
|
-
const usersResult = await usersResultPromise;
|
|
6682
|
-
await projectAccessRefreshPromise;
|
|
6683
|
-
store.dispatch(addUsers(usersResult));
|
|
6684
|
-
void this.client.projectAttachments.refreshStore();
|
|
6685
|
-
}
|
|
6686
6631
|
let currentWorkspaceId;
|
|
6687
6632
|
const oldWorkspaceId = this.client.store.getState().workspaceReducer.activeWorkspaceId;
|
|
6688
6633
|
if (overwrite || !oldWorkspaceId) {
|
|
@@ -6690,56 +6635,54 @@ class MainService extends BaseApiService {
|
|
|
6690
6635
|
} else {
|
|
6691
6636
|
currentWorkspaceId = oldWorkspaceId;
|
|
6692
6637
|
}
|
|
6693
|
-
if (currentWorkspaceId
|
|
6638
|
+
if (currentWorkspaceId) {
|
|
6694
6639
|
store.dispatch(setActiveWorkspaceId(currentWorkspaceId));
|
|
6695
|
-
void this.client.categories.refreshStore().then(() => {
|
|
6696
|
-
void this.client.issues.refreshStore().then(() => {
|
|
6697
|
-
void this.client.issueAttachments.refreshStore().then();
|
|
6698
|
-
void this.client.issueComments.refreshStore().then();
|
|
6699
|
-
void this.client.issueUpdates.refreshStore().then();
|
|
6700
|
-
});
|
|
6701
|
-
});
|
|
6702
|
-
void this.client.projectFiles.refreshStore().then();
|
|
6703
|
-
void this.client.componentTypes.refreshStore().then(() => {
|
|
6704
|
-
void this.client.componentTypeAttachments.refreshStore().then(() => {
|
|
6705
|
-
void this.client.componentStages.refreshStore().then(() => {
|
|
6706
|
-
void this.client.components.refreshStore(overwrite).then(() => {
|
|
6707
|
-
void this.client.componentAttachments.refreshStore().then();
|
|
6708
|
-
});
|
|
6709
|
-
});
|
|
6710
|
-
void this.client.componentStageCompletions.refreshStore().then();
|
|
6711
|
-
});
|
|
6712
|
-
});
|
|
6713
|
-
void this.client.userForms.refreshStore().then(() => {
|
|
6714
|
-
void this.client.userFormSubmissions.refreshStore().then();
|
|
6715
|
-
});
|
|
6716
|
-
}
|
|
6717
|
-
if (currentProjectId) {
|
|
6718
|
-
void this.client.documents.refreshStore().then(() => {
|
|
6719
|
-
void this.client.documentAttachments.refreshStore().then();
|
|
6720
|
-
});
|
|
6721
|
-
void this.client.documents.refreshStore();
|
|
6722
|
-
void this.client.issueUpdates.refreshStore();
|
|
6723
|
-
void this.client.issueTypes.refreshStore();
|
|
6724
6640
|
}
|
|
6725
|
-
store.dispatch(setIsFetchingInitialData(false));
|
|
6726
6641
|
if (overwrite) {
|
|
6727
6642
|
console.log("Overwriting data");
|
|
6728
6643
|
store.dispatch(setProjects(projects));
|
|
6729
6644
|
store.dispatch(setWorkspaces(workspaces));
|
|
6730
|
-
store.dispatch(setCategories(categories));
|
|
6731
6645
|
store.dispatch(resetRecentIssues());
|
|
6732
6646
|
} else {
|
|
6733
6647
|
console.log("Updating data (collisions will be replaced)");
|
|
6734
6648
|
store.dispatch(addOrReplaceProjects(projects));
|
|
6735
6649
|
store.dispatch(addOrReplaceWorkspaces(workspaces));
|
|
6736
|
-
store.dispatch(addOrReplaceCategories(categories));
|
|
6737
6650
|
}
|
|
6651
|
+
if (!currentProjectId) {
|
|
6652
|
+
store.dispatch(setIsFetchingInitialData(false));
|
|
6653
|
+
} else {
|
|
6654
|
+
try {
|
|
6655
|
+
await this.client.projectFiles.refreshStore();
|
|
6656
|
+
} finally {
|
|
6657
|
+
store.dispatch(setIsFetchingInitialData(false));
|
|
6658
|
+
}
|
|
6659
|
+
void this.client.componentTypes.refreshStore();
|
|
6660
|
+
void this.client.componentStages.refreshStore();
|
|
6661
|
+
void this.client.components.refreshStore();
|
|
6662
|
+
void this.client.componentStageCompletions.refreshStore();
|
|
6663
|
+
void this.client.categories.refreshStore();
|
|
6664
|
+
void this.client.issueTypes.refreshStore();
|
|
6665
|
+
void this.client.issues.refreshStore();
|
|
6666
|
+
void this.fetchProjectUsers();
|
|
6667
|
+
void this.client.documents.refreshStore();
|
|
6668
|
+
void this.client.userForms.refreshStore();
|
|
6669
|
+
void this.client.documentAttachments.refreshStore();
|
|
6670
|
+
void this.client.userFormSubmissions.refreshStore();
|
|
6671
|
+
void this.client.agent.refreshStore();
|
|
6672
|
+
void this.client.issueAttachments.refreshStore();
|
|
6673
|
+
void this.client.issueComments.refreshStore();
|
|
6674
|
+
void this.client.issueUpdates.refreshStore();
|
|
6675
|
+
void this.client.projectAccesses.refreshStore();
|
|
6676
|
+
void this.client.projectAttachments.refreshStore();
|
|
6677
|
+
void this.client.componentTypeAttachments.refreshStore();
|
|
6678
|
+
void this.client.componentAttachments.refreshStore();
|
|
6679
|
+
}
|
|
6680
|
+
void this.client.teams.refreshStore();
|
|
6738
6681
|
}
|
|
6739
6682
|
}
|
|
6740
6683
|
class ProjectAccessService extends BaseApiService {
|
|
6741
6684
|
async fetchAll(projectId) {
|
|
6742
|
-
return this.enqueueRequest({
|
|
6685
|
+
return this.client.enqueueRequest({
|
|
6743
6686
|
description: "Get project accesses",
|
|
6744
6687
|
method: HttpMethod.GET,
|
|
6745
6688
|
url: `/projects/${projectId}/access/`,
|
|
@@ -6749,7 +6692,7 @@ class ProjectAccessService extends BaseApiService {
|
|
|
6749
6692
|
}
|
|
6750
6693
|
async update(projectAccess) {
|
|
6751
6694
|
this.client.store.dispatch(updateProjectAccess(projectAccess));
|
|
6752
|
-
return this.enqueueRequest({
|
|
6695
|
+
return this.client.enqueueRequest({
|
|
6753
6696
|
description: "Edit project access",
|
|
6754
6697
|
method: HttpMethod.PATCH,
|
|
6755
6698
|
url: `/access/${projectAccess.offline_id}/`,
|
|
@@ -6762,7 +6705,7 @@ class ProjectAccessService extends BaseApiService {
|
|
|
6762
6705
|
async remove(projectAccess) {
|
|
6763
6706
|
const { store } = this.client;
|
|
6764
6707
|
store.dispatch(removeProjectAccess(projectAccess));
|
|
6765
|
-
return this.enqueueRequest({
|
|
6708
|
+
return this.client.enqueueRequest({
|
|
6766
6709
|
description: "Delete project access",
|
|
6767
6710
|
method: HttpMethod.DELETE,
|
|
6768
6711
|
url: `/access/${projectAccess.offline_id}/`,
|
|
@@ -6774,23 +6717,18 @@ class ProjectAccessService extends BaseApiService {
|
|
|
6774
6717
|
const { store } = this.client;
|
|
6775
6718
|
const state = store.getState();
|
|
6776
6719
|
const projectId = state.projectReducer.activeProjectId;
|
|
6777
|
-
const currentUser = state.userReducer.currentUser;
|
|
6778
6720
|
if (!projectId) {
|
|
6779
6721
|
throw new Error("No active project");
|
|
6780
6722
|
}
|
|
6781
6723
|
const promise = this.fetchAll(projectId);
|
|
6782
6724
|
const result = await promise;
|
|
6783
|
-
const activeProjectAccess = result.find((projectAccess) => projectAccess.user === currentUser.id);
|
|
6784
|
-
if (!activeProjectAccess) {
|
|
6785
|
-
throw new Error("Current user does not have a project access instance");
|
|
6786
|
-
}
|
|
6787
6725
|
store.dispatch(setProjectAccesses(result));
|
|
6788
6726
|
}
|
|
6789
6727
|
}
|
|
6790
6728
|
class ProjectFileService extends BaseApiService {
|
|
6791
6729
|
async refreshStore() {
|
|
6792
6730
|
const { store } = this.client;
|
|
6793
|
-
const result = await this.enqueueRequest({
|
|
6731
|
+
const result = await this.client.enqueueRequest({
|
|
6794
6732
|
description: "Get project files",
|
|
6795
6733
|
method: HttpMethod.GET,
|
|
6796
6734
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/files/`,
|
|
@@ -6807,7 +6745,7 @@ class ProjectFileService extends BaseApiService {
|
|
|
6807
6745
|
}
|
|
6808
6746
|
const editableData = { ...file };
|
|
6809
6747
|
delete editableData.file;
|
|
6810
|
-
const promise = this.enqueueRequest({
|
|
6748
|
+
const promise = this.client.enqueueRequest({
|
|
6811
6749
|
method: HttpMethod.PATCH,
|
|
6812
6750
|
url: `/projects/files/${file.offline_id}/`,
|
|
6813
6751
|
payload: editableData,
|
|
@@ -6865,7 +6803,7 @@ class ProjectFileService extends BaseApiService {
|
|
|
6865
6803
|
});
|
|
6866
6804
|
}
|
|
6867
6805
|
const promise = Promise.resolve(requestDetails).then((requestDetails2) => {
|
|
6868
|
-
return this.enqueueRequest(requestDetails2);
|
|
6806
|
+
return this.client.enqueueRequest(requestDetails2);
|
|
6869
6807
|
});
|
|
6870
6808
|
void promise.then((result) => {
|
|
6871
6809
|
store.dispatch(addOrReplaceProjectFile(result));
|
|
@@ -6877,7 +6815,7 @@ class ProjectFileService extends BaseApiService {
|
|
|
6877
6815
|
}
|
|
6878
6816
|
delete(projectFileId) {
|
|
6879
6817
|
this.client.store.dispatch(removeProjectFile(projectFileId));
|
|
6880
|
-
return this.enqueueRequest({
|
|
6818
|
+
return this.client.enqueueRequest({
|
|
6881
6819
|
method: HttpMethod.DELETE,
|
|
6882
6820
|
url: `/projects/files/${projectFileId}`,
|
|
6883
6821
|
blockers: [projectFileId],
|
|
@@ -6948,7 +6886,7 @@ class ProjectService extends BaseApiService {
|
|
|
6948
6886
|
}
|
|
6949
6887
|
const url = isOrganizationProject ? `/organizations/${project.owner_organization}/projects/` : "/projects/";
|
|
6950
6888
|
const projectType = isOrganizationProject ? { organization_owner: project.owner_organization } : { user_owner: project.owner_user };
|
|
6951
|
-
const result = await this.enqueueRequest({
|
|
6889
|
+
const result = await this.client.enqueueRequest({
|
|
6952
6890
|
description: "Create project",
|
|
6953
6891
|
method: HttpMethod.POST,
|
|
6954
6892
|
url,
|
|
@@ -6972,7 +6910,7 @@ class ProjectService extends BaseApiService {
|
|
|
6972
6910
|
throw new Error("Project bounds were not set before trying to create a project");
|
|
6973
6911
|
}
|
|
6974
6912
|
store.dispatch(updateOrCreateProject(project));
|
|
6975
|
-
return await this.enqueueRequest({
|
|
6913
|
+
return await this.client.enqueueRequest({
|
|
6976
6914
|
description: "Update project",
|
|
6977
6915
|
method: HttpMethod.PATCH,
|
|
6978
6916
|
url: `/projects/${project.id}/`,
|
|
@@ -7012,7 +6950,7 @@ class ProjectService extends BaseApiService {
|
|
|
7012
6950
|
store.dispatch(updateLicense({ ...license, project: null }));
|
|
7013
6951
|
}
|
|
7014
6952
|
try {
|
|
7015
|
-
await this.enqueueRequest({
|
|
6953
|
+
await this.client.enqueueRequest({
|
|
7016
6954
|
description: "Delete project",
|
|
7017
6955
|
method: HttpMethod.DELETE,
|
|
7018
6956
|
url: `/projects/${projectId}/`,
|
|
@@ -7035,7 +6973,7 @@ class ProjectService extends BaseApiService {
|
|
|
7035
6973
|
}
|
|
7036
6974
|
invite(projectId, email) {
|
|
7037
6975
|
const offline_id = v4();
|
|
7038
|
-
return this.enqueueRequest({
|
|
6976
|
+
return this.client.enqueueRequest({
|
|
7039
6977
|
description: "Invite user to project",
|
|
7040
6978
|
method: HttpMethod.POST,
|
|
7041
6979
|
url: `/projects/${projectId}/invite/${email}/`,
|
|
@@ -7047,7 +6985,7 @@ class ProjectService extends BaseApiService {
|
|
|
7047
6985
|
});
|
|
7048
6986
|
}
|
|
7049
6987
|
joinProject(projectId, userId, inviteCode) {
|
|
7050
|
-
return this.enqueueRequest({
|
|
6988
|
+
return this.client.enqueueRequest({
|
|
7051
6989
|
description: "Join project",
|
|
7052
6990
|
method: HttpMethod.GET,
|
|
7053
6991
|
url: `/projects/${projectId}/join-project/${userId}/${inviteCode}/`,
|
|
@@ -7057,7 +6995,7 @@ class ProjectService extends BaseApiService {
|
|
|
7057
6995
|
});
|
|
7058
6996
|
}
|
|
7059
6997
|
async acceptInvite(projectId) {
|
|
7060
|
-
return this.enqueueRequest({
|
|
6998
|
+
return this.client.enqueueRequest({
|
|
7061
6999
|
description: "Accept project invite",
|
|
7062
7000
|
method: HttpMethod.PATCH,
|
|
7063
7001
|
url: `/projects/${projectId}/accept-invite/`,
|
|
@@ -7116,7 +7054,7 @@ class UserFormService extends BaseApiService {
|
|
|
7116
7054
|
revision: offlineRevisionId,
|
|
7117
7055
|
field_identifier: key
|
|
7118
7056
|
});
|
|
7119
|
-
const attach = await this.enqueueRequest({
|
|
7057
|
+
const attach = await this.client.enqueueRequest({
|
|
7120
7058
|
description: "Attach image to form revision field",
|
|
7121
7059
|
method: HttpMethod.POST,
|
|
7122
7060
|
url: `/forms/revisions/${offlineRevisionId}/attachments/`,
|
|
@@ -7167,7 +7105,7 @@ class UserFormService extends BaseApiService {
|
|
|
7167
7105
|
const { store } = this.client;
|
|
7168
7106
|
store.dispatch(addForm(retForm));
|
|
7169
7107
|
store.dispatch(addFormRevision(retRevision));
|
|
7170
|
-
const formPromise = this.enqueueRequest({
|
|
7108
|
+
const formPromise = this.client.enqueueRequest({
|
|
7171
7109
|
description: "Create form",
|
|
7172
7110
|
method: HttpMethod.POST,
|
|
7173
7111
|
url,
|
|
@@ -7239,7 +7177,7 @@ class UserFormService extends BaseApiService {
|
|
|
7239
7177
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7240
7178
|
};
|
|
7241
7179
|
store.dispatch(addFormRevision(fullRevision));
|
|
7242
|
-
const promise = this.enqueueRequest({
|
|
7180
|
+
const promise = this.client.enqueueRequest({
|
|
7243
7181
|
description: "Create form revision",
|
|
7244
7182
|
method: HttpMethod.PATCH,
|
|
7245
7183
|
url: `/forms/${formId2}/`,
|
|
@@ -7264,7 +7202,7 @@ class UserFormService extends BaseApiService {
|
|
|
7264
7202
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7265
7203
|
store.dispatch(favoriteForm({ formId: formId2 }));
|
|
7266
7204
|
try {
|
|
7267
|
-
await this.enqueueRequest({
|
|
7205
|
+
await this.client.enqueueRequest({
|
|
7268
7206
|
description: "Favorite form",
|
|
7269
7207
|
method: HttpMethod.POST,
|
|
7270
7208
|
url: `/forms/${formId2}/favorite/${activeProjectId}/`,
|
|
@@ -7281,7 +7219,7 @@ class UserFormService extends BaseApiService {
|
|
|
7281
7219
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7282
7220
|
store.dispatch(unfavoriteForm({ formId: formId2 }));
|
|
7283
7221
|
try {
|
|
7284
|
-
return await this.enqueueRequest({
|
|
7222
|
+
return await this.client.enqueueRequest({
|
|
7285
7223
|
description: "Unfavorite form",
|
|
7286
7224
|
method: HttpMethod.DELETE,
|
|
7287
7225
|
url: `/forms/${formId2}/unfavorite/${activeProjectId}/`,
|
|
@@ -7310,7 +7248,7 @@ class UserFormService extends BaseApiService {
|
|
|
7310
7248
|
}
|
|
7311
7249
|
store.dispatch(deleteForm(formId2));
|
|
7312
7250
|
try {
|
|
7313
|
-
return await this.enqueueRequest({
|
|
7251
|
+
return await this.client.enqueueRequest({
|
|
7314
7252
|
description: "Delete form",
|
|
7315
7253
|
method: HttpMethod.DELETE,
|
|
7316
7254
|
url: `/forms/${formId2}/`,
|
|
@@ -7330,7 +7268,7 @@ class UserFormService extends BaseApiService {
|
|
|
7330
7268
|
}
|
|
7331
7269
|
async refreshStore() {
|
|
7332
7270
|
const { store } = this.client;
|
|
7333
|
-
const result = await this.enqueueRequest({
|
|
7271
|
+
const result = await this.client.enqueueRequest({
|
|
7334
7272
|
description: "Fetch user forms",
|
|
7335
7273
|
method: HttpMethod.GET,
|
|
7336
7274
|
url: `/forms/in-project/${store.getState().projectReducer.activeProjectId}/forms/`,
|
|
@@ -7379,7 +7317,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7379
7317
|
submission: submission.offline_id,
|
|
7380
7318
|
field_identifier: key
|
|
7381
7319
|
});
|
|
7382
|
-
const attach = await this.enqueueRequest({
|
|
7320
|
+
const attach = await this.client.enqueueRequest({
|
|
7383
7321
|
description: "Attach file to form submission",
|
|
7384
7322
|
method: HttpMethod.POST,
|
|
7385
7323
|
url: `/forms/submission/${submission.offline_id}/attachments/`,
|
|
@@ -7417,7 +7355,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7417
7355
|
created_by: state.userReducer.currentUser.id,
|
|
7418
7356
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7419
7357
|
};
|
|
7420
|
-
const promise = this.enqueueRequest({
|
|
7358
|
+
const promise = this.client.enqueueRequest({
|
|
7421
7359
|
description: "Respond to form",
|
|
7422
7360
|
method: HttpMethod.POST,
|
|
7423
7361
|
url: `/forms/revisions/${payload.form_revision}/respond/`,
|
|
@@ -7498,7 +7436,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7498
7436
|
}
|
|
7499
7437
|
store.dispatch(addFormSubmissions(offlineSubmissions));
|
|
7500
7438
|
store.dispatch(addFormSubmissionAttachments(offlineAttachments));
|
|
7501
|
-
const promise = this.enqueueRequest({
|
|
7439
|
+
const promise = this.client.enqueueRequest({
|
|
7502
7440
|
description: "Bulk add form submissions",
|
|
7503
7441
|
method: HttpMethod.POST,
|
|
7504
7442
|
url: `/forms/revisions/${formRevision}/bulk-respond/`,
|
|
@@ -7519,7 +7457,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7519
7457
|
const file = filesRecord[sha1];
|
|
7520
7458
|
if (!file)
|
|
7521
7459
|
continue;
|
|
7522
|
-
void this.enqueueRequest({
|
|
7460
|
+
void this.client.enqueueRequest({
|
|
7523
7461
|
url: presigned_url.url,
|
|
7524
7462
|
description: "Upload file",
|
|
7525
7463
|
method: HttpMethod.POST,
|
|
@@ -7547,7 +7485,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7547
7485
|
};
|
|
7548
7486
|
const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
|
|
7549
7487
|
store.dispatch(updateFormSubmission(offlineSubmission));
|
|
7550
|
-
const promise = this.enqueueRequest({
|
|
7488
|
+
const promise = this.client.enqueueRequest({
|
|
7551
7489
|
description: "Patch form submission",
|
|
7552
7490
|
method: HttpMethod.PATCH,
|
|
7553
7491
|
url: `/forms/submissions/${submission.offline_id}/`,
|
|
@@ -7573,7 +7511,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7573
7511
|
store.dispatch(addActiveProjectFormSubmissionsCount(-1));
|
|
7574
7512
|
store.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
|
|
7575
7513
|
try {
|
|
7576
|
-
return await this.enqueueRequest({
|
|
7514
|
+
return await this.client.enqueueRequest({
|
|
7577
7515
|
description: "Delete user form submissions",
|
|
7578
7516
|
method: HttpMethod.DELETE,
|
|
7579
7517
|
url: `/forms/submissions/${submissionId}/`,
|
|
@@ -7590,7 +7528,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7590
7528
|
async refreshStore() {
|
|
7591
7529
|
const { store } = this.client;
|
|
7592
7530
|
const projectId = store.getState().projectReducer.activeProjectId;
|
|
7593
|
-
const submissions = await this.enqueueRequest({
|
|
7531
|
+
const submissions = await this.client.enqueueRequest({
|
|
7594
7532
|
description: "Fetch form submissions",
|
|
7595
7533
|
method: HttpMethod.GET,
|
|
7596
7534
|
url: `/forms/in-project/${projectId}/submissions/`,
|
|
@@ -7598,7 +7536,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7598
7536
|
blocks: []
|
|
7599
7537
|
});
|
|
7600
7538
|
store.dispatch(setFormSubmissions(submissions));
|
|
7601
|
-
const attachments = await this.enqueueRequest({
|
|
7539
|
+
const attachments = await this.client.enqueueRequest({
|
|
7602
7540
|
description: "Fetch form attachments",
|
|
7603
7541
|
method: HttpMethod.GET,
|
|
7604
7542
|
url: `/forms/in-project/${projectId}/attachments/`,
|
|
@@ -7613,7 +7551,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7613
7551
|
const { store } = this.client;
|
|
7614
7552
|
const offlineWorkspace = offline(workspace);
|
|
7615
7553
|
store.dispatch(addWorkspace(offlineWorkspace));
|
|
7616
|
-
const promise = this.enqueueRequest({
|
|
7554
|
+
const promise = this.client.enqueueRequest({
|
|
7617
7555
|
description: "Create Workspace",
|
|
7618
7556
|
method: HttpMethod.POST,
|
|
7619
7557
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/workspaces/`,
|
|
@@ -7631,7 +7569,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7631
7569
|
update(workspace) {
|
|
7632
7570
|
const { store } = this.client;
|
|
7633
7571
|
store.dispatch(addOrReplaceWorkspaces({ [workspace.offline_id]: workspace }));
|
|
7634
|
-
const promise = this.enqueueRequest({
|
|
7572
|
+
const promise = this.client.enqueueRequest({
|
|
7635
7573
|
description: "Update Workspace",
|
|
7636
7574
|
method: HttpMethod.PATCH,
|
|
7637
7575
|
url: `/workspaces/${workspace.offline_id}/`,
|
|
@@ -7643,7 +7581,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7643
7581
|
}
|
|
7644
7582
|
delete(workspaceId) {
|
|
7645
7583
|
const { store } = this.client;
|
|
7646
|
-
const promise = this.enqueueRequest({
|
|
7584
|
+
const promise = this.client.enqueueRequest({
|
|
7647
7585
|
description: "Delete Workspace",
|
|
7648
7586
|
method: HttpMethod.DELETE,
|
|
7649
7587
|
url: `/workspaces/${workspaceId}/`,
|
|
@@ -7665,7 +7603,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7665
7603
|
}
|
|
7666
7604
|
class OrganizationAccessService extends BaseApiService {
|
|
7667
7605
|
async update(organizationAccess) {
|
|
7668
|
-
const promise = this.enqueueRequest({
|
|
7606
|
+
const promise = this.client.enqueueRequest({
|
|
7669
7607
|
description: "Edit organization access",
|
|
7670
7608
|
method: HttpMethod.PATCH,
|
|
7671
7609
|
url: `/organizations/${organizationAccess.organization}/access/${organizationAccess.offline_id}/`,
|
|
@@ -7681,7 +7619,7 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
7681
7619
|
async remove(organizationAccess) {
|
|
7682
7620
|
this.client.store.dispatch(removeOrganizationAccess(organizationAccess));
|
|
7683
7621
|
this.client.store.dispatch(removeUser(organizationAccess.user));
|
|
7684
|
-
return this.enqueueRequest({
|
|
7622
|
+
return this.client.enqueueRequest({
|
|
7685
7623
|
description: "Remove organization access",
|
|
7686
7624
|
method: HttpMethod.DELETE,
|
|
7687
7625
|
url: `/organizations/${organizationAccess.organization}/access/${organizationAccess.offline_id}/`,
|
|
@@ -7696,7 +7634,7 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
7696
7634
|
if (!organizationId) {
|
|
7697
7635
|
return;
|
|
7698
7636
|
}
|
|
7699
|
-
const result = await this.enqueueRequest({
|
|
7637
|
+
const result = await this.client.enqueueRequest({
|
|
7700
7638
|
description: "Get organization accesses",
|
|
7701
7639
|
method: HttpMethod.GET,
|
|
7702
7640
|
url: `/organizations/${organizationId}/access/`,
|
|
@@ -7728,7 +7666,7 @@ class FileService extends BaseApiService {
|
|
|
7728
7666
|
if (!file)
|
|
7729
7667
|
throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
7730
7668
|
const key = await getFileS3Key(file, sha1);
|
|
7731
|
-
const s3UploadUrl = await this.enqueueRequest({
|
|
7669
|
+
const s3UploadUrl = await this.client.enqueueRequest({
|
|
7732
7670
|
description: "Get S3 URL",
|
|
7733
7671
|
method: HttpMethod.GET,
|
|
7734
7672
|
url: "/authentication/files/presigned-upload-url/",
|
|
@@ -7812,7 +7750,7 @@ class FileService extends BaseApiService {
|
|
|
7812
7750
|
throw new Error(fileUploadUrlResponse.warning);
|
|
7813
7751
|
}
|
|
7814
7752
|
const url = fileUploadUrlResponse.url;
|
|
7815
|
-
const promise = this.enqueueRequest({
|
|
7753
|
+
const promise = this.client.enqueueRequest({
|
|
7816
7754
|
url,
|
|
7817
7755
|
description: "Upload file",
|
|
7818
7756
|
method: HttpMethod.POST,
|
|
@@ -7854,7 +7792,7 @@ class FileService extends BaseApiService {
|
|
|
7854
7792
|
let isFirstRequest = true;
|
|
7855
7793
|
if (!promise) {
|
|
7856
7794
|
promise = new Promise((resolve) => {
|
|
7857
|
-
void this.enqueueRequest({
|
|
7795
|
+
void this.client.enqueueRequest({
|
|
7858
7796
|
description: "Download file",
|
|
7859
7797
|
method: HttpMethod.GET,
|
|
7860
7798
|
url,
|
|
@@ -7922,7 +7860,7 @@ class EmailVerificationService extends BaseApiService {
|
|
|
7922
7860
|
blockers: [],
|
|
7923
7861
|
blocks: []
|
|
7924
7862
|
};
|
|
7925
|
-
return this.enqueueRequest(requestDetails);
|
|
7863
|
+
return this.client.enqueueRequest(requestDetails);
|
|
7926
7864
|
}
|
|
7927
7865
|
validateVerificationCode(verificationCode, payload = void 0) {
|
|
7928
7866
|
const requestDetails = {
|
|
@@ -7934,12 +7872,12 @@ class EmailVerificationService extends BaseApiService {
|
|
|
7934
7872
|
blockers: [],
|
|
7935
7873
|
blocks: []
|
|
7936
7874
|
};
|
|
7937
|
-
return this.enqueueRequest(requestDetails);
|
|
7875
|
+
return this.client.enqueueRequest(requestDetails);
|
|
7938
7876
|
}
|
|
7939
7877
|
}
|
|
7940
7878
|
class EmailDomainsService extends BaseApiService {
|
|
7941
7879
|
async fetchAll(orgId) {
|
|
7942
|
-
return this.enqueueRequest({
|
|
7880
|
+
return this.client.enqueueRequest({
|
|
7943
7881
|
description: "Fetch email domains for organization",
|
|
7944
7882
|
method: HttpMethod.GET,
|
|
7945
7883
|
url: `/organizations/${orgId}/email-domains/`,
|
|
@@ -7948,7 +7886,7 @@ class EmailDomainsService extends BaseApiService {
|
|
|
7948
7886
|
});
|
|
7949
7887
|
}
|
|
7950
7888
|
async add(orgId, email) {
|
|
7951
|
-
return this.enqueueRequest({
|
|
7889
|
+
return this.client.enqueueRequest({
|
|
7952
7890
|
description: "Add email domain to organization",
|
|
7953
7891
|
method: HttpMethod.POST,
|
|
7954
7892
|
url: `/organizations/${orgId}/email-domains/`,
|
|
@@ -7959,7 +7897,7 @@ class EmailDomainsService extends BaseApiService {
|
|
|
7959
7897
|
}
|
|
7960
7898
|
async remove(emailDomain) {
|
|
7961
7899
|
this.client.store.dispatch(removeEmailDomain(emailDomain));
|
|
7962
|
-
return this.enqueueRequest({
|
|
7900
|
+
return this.client.enqueueRequest({
|
|
7963
7901
|
description: "Remove email domain from organization",
|
|
7964
7902
|
method: HttpMethod.DELETE,
|
|
7965
7903
|
url: `/organizations/${emailDomain.organization}/email-domains/${emailDomain.offline_id}/`,
|
|
@@ -7985,7 +7923,7 @@ class OrganizationService extends BaseApiService {
|
|
|
7985
7923
|
if (showLoading) {
|
|
7986
7924
|
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
7987
7925
|
}
|
|
7988
|
-
return this.enqueueRequest({
|
|
7926
|
+
return this.client.enqueueRequest({
|
|
7989
7927
|
description: "Get initial organization data",
|
|
7990
7928
|
method: HttpMethod.GET,
|
|
7991
7929
|
url: `/organizations/${organizationId}/initial-data/`,
|
|
@@ -8013,7 +7951,7 @@ class OrganizationService extends BaseApiService {
|
|
|
8013
7951
|
}
|
|
8014
7952
|
}
|
|
8015
7953
|
async create(name) {
|
|
8016
|
-
const result = await this.enqueueRequest({
|
|
7954
|
+
const result = await this.client.enqueueRequest({
|
|
8017
7955
|
description: "Create organization",
|
|
8018
7956
|
method: HttpMethod.POST,
|
|
8019
7957
|
url: "/organizations/",
|
|
@@ -8025,7 +7963,7 @@ class OrganizationService extends BaseApiService {
|
|
|
8025
7963
|
return result;
|
|
8026
7964
|
}
|
|
8027
7965
|
async update(organization) {
|
|
8028
|
-
const promise = this.enqueueRequest({
|
|
7966
|
+
const promise = this.client.enqueueRequest({
|
|
8029
7967
|
description: "Edit organization",
|
|
8030
7968
|
method: HttpMethod.PATCH,
|
|
8031
7969
|
url: `/organizations/${organization.id}/`,
|
|
@@ -8039,7 +7977,7 @@ class OrganizationService extends BaseApiService {
|
|
|
8039
7977
|
});
|
|
8040
7978
|
}
|
|
8041
7979
|
async invite(organizationId, email) {
|
|
8042
|
-
return this.enqueueRequest({
|
|
7980
|
+
return this.client.enqueueRequest({
|
|
8043
7981
|
description: "Invite user to organization",
|
|
8044
7982
|
method: HttpMethod.POST,
|
|
8045
7983
|
url: `/organizations/${organizationId}/invite/${email}/`,
|
|
@@ -8053,7 +7991,7 @@ class LicenseService extends BaseApiService {
|
|
|
8053
7991
|
if (showLoading) {
|
|
8054
7992
|
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
8055
7993
|
}
|
|
8056
|
-
const result = await this.enqueueRequest({
|
|
7994
|
+
const result = await this.client.enqueueRequest({
|
|
8057
7995
|
description: "Get licenses",
|
|
8058
7996
|
method: HttpMethod.GET,
|
|
8059
7997
|
url: `/organizations/${organizationId}/licenses/`,
|
|
@@ -8068,7 +8006,7 @@ class LicenseService extends BaseApiService {
|
|
|
8068
8006
|
return result;
|
|
8069
8007
|
}
|
|
8070
8008
|
async getLicense(license) {
|
|
8071
|
-
const result = await this.enqueueRequest({
|
|
8009
|
+
const result = await this.client.enqueueRequest({
|
|
8072
8010
|
description: "Get license",
|
|
8073
8011
|
method: HttpMethod.GET,
|
|
8074
8012
|
url: `/billing/${license.offline_id}/`,
|
|
@@ -8082,7 +8020,7 @@ class LicenseService extends BaseApiService {
|
|
|
8082
8020
|
return result;
|
|
8083
8021
|
}
|
|
8084
8022
|
async pauseLicense(license) {
|
|
8085
|
-
const result = await this.enqueueRequest({
|
|
8023
|
+
const result = await this.client.enqueueRequest({
|
|
8086
8024
|
description: "Pause license",
|
|
8087
8025
|
method: HttpMethod.DELETE,
|
|
8088
8026
|
url: `/billing/${license.offline_id}/suspend/`,
|
|
@@ -8096,7 +8034,7 @@ class LicenseService extends BaseApiService {
|
|
|
8096
8034
|
return result;
|
|
8097
8035
|
}
|
|
8098
8036
|
async resumeLicense(license) {
|
|
8099
|
-
const result = await this.enqueueRequest({
|
|
8037
|
+
const result = await this.client.enqueueRequest({
|
|
8100
8038
|
description: "Resume license",
|
|
8101
8039
|
method: HttpMethod.PATCH,
|
|
8102
8040
|
url: `/billing/${license.offline_id}/suspend/`,
|
|
@@ -8110,7 +8048,7 @@ class LicenseService extends BaseApiService {
|
|
|
8110
8048
|
return result;
|
|
8111
8049
|
}
|
|
8112
8050
|
async cancelLicense(license) {
|
|
8113
|
-
const result = await this.enqueueRequest({
|
|
8051
|
+
const result = await this.client.enqueueRequest({
|
|
8114
8052
|
description: "Cancel license",
|
|
8115
8053
|
method: HttpMethod.DELETE,
|
|
8116
8054
|
url: `/billing/${license.offline_id}/`,
|
|
@@ -8124,7 +8062,7 @@ class LicenseService extends BaseApiService {
|
|
|
8124
8062
|
return result;
|
|
8125
8063
|
}
|
|
8126
8064
|
async attachLicenseToProject(license, project) {
|
|
8127
|
-
const result = await this.enqueueRequest({
|
|
8065
|
+
const result = await this.client.enqueueRequest({
|
|
8128
8066
|
description: "Attach license",
|
|
8129
8067
|
method: HttpMethod.PATCH,
|
|
8130
8068
|
url: `/billing/${license.offline_id}/project/`,
|
|
@@ -8140,7 +8078,7 @@ class LicenseService extends BaseApiService {
|
|
|
8140
8078
|
return result;
|
|
8141
8079
|
}
|
|
8142
8080
|
async detachLicenseFromProject(license) {
|
|
8143
|
-
const result = await this.enqueueRequest({
|
|
8081
|
+
const result = await this.client.enqueueRequest({
|
|
8144
8082
|
description: "Detach license",
|
|
8145
8083
|
method: HttpMethod.DELETE,
|
|
8146
8084
|
url: `/billing/${license.offline_id}/project/`,
|
|
@@ -8154,7 +8092,7 @@ class LicenseService extends BaseApiService {
|
|
|
8154
8092
|
return result;
|
|
8155
8093
|
}
|
|
8156
8094
|
async getLatestTransaction(license) {
|
|
8157
|
-
return await this.enqueueRequest({
|
|
8095
|
+
return await this.client.enqueueRequest({
|
|
8158
8096
|
description: "Get latest transaction",
|
|
8159
8097
|
method: HttpMethod.GET,
|
|
8160
8098
|
url: `/billing/${license.offline_id}/transaction/`,
|
|
@@ -8182,7 +8120,7 @@ class DocumentService extends BaseApiService {
|
|
|
8182
8120
|
children_documents: []
|
|
8183
8121
|
};
|
|
8184
8122
|
store.dispatch(addDocuments([submittedDocument]));
|
|
8185
|
-
const promise = this.enqueueRequest({
|
|
8123
|
+
const promise = this.client.enqueueRequest({
|
|
8186
8124
|
description: "Create Document",
|
|
8187
8125
|
method: HttpMethod.POST,
|
|
8188
8126
|
url: `/projects/${activeProjectId}/documents/`,
|
|
@@ -8208,7 +8146,7 @@ class DocumentService extends BaseApiService {
|
|
|
8208
8146
|
);
|
|
8209
8147
|
}
|
|
8210
8148
|
store.dispatch(updateDocuments([document2]));
|
|
8211
|
-
const promise = this.enqueueRequest({
|
|
8149
|
+
const promise = this.client.enqueueRequest({
|
|
8212
8150
|
description: "Update Document",
|
|
8213
8151
|
method: HttpMethod.PATCH,
|
|
8214
8152
|
url: `/documents/${document2.offline_id}/`,
|
|
@@ -8249,7 +8187,7 @@ class DocumentService extends BaseApiService {
|
|
|
8249
8187
|
}
|
|
8250
8188
|
}
|
|
8251
8189
|
store.dispatch(moveDocument({ documentId, targetDocumentId, position }));
|
|
8252
|
-
const promise = this.enqueueRequest({
|
|
8190
|
+
const promise = this.client.enqueueRequest({
|
|
8253
8191
|
description: "Move Document",
|
|
8254
8192
|
method: HttpMethod.PATCH,
|
|
8255
8193
|
url: `/documents/${documentId}/move/`,
|
|
@@ -8278,7 +8216,7 @@ class DocumentService extends BaseApiService {
|
|
|
8278
8216
|
}
|
|
8279
8217
|
const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
|
|
8280
8218
|
store.dispatch(removeDocuments([documentId]));
|
|
8281
|
-
const promise = this.enqueueRequest({
|
|
8219
|
+
const promise = this.client.enqueueRequest({
|
|
8282
8220
|
description: "Delete Document",
|
|
8283
8221
|
method: HttpMethod.DELETE,
|
|
8284
8222
|
url: `/documents/${documentId}/`,
|
|
@@ -8299,7 +8237,7 @@ class DocumentService extends BaseApiService {
|
|
|
8299
8237
|
const { store } = this.client;
|
|
8300
8238
|
const state = store.getState();
|
|
8301
8239
|
const activeProjectId = state.projectReducer.activeProjectId;
|
|
8302
|
-
const projectDocumentsPromise = this.enqueueRequest({
|
|
8240
|
+
const projectDocumentsPromise = this.client.enqueueRequest({
|
|
8303
8241
|
description: "Get project documents",
|
|
8304
8242
|
method: HttpMethod.GET,
|
|
8305
8243
|
url: `/projects/${activeProjectId}/documents/`,
|
|
@@ -8307,7 +8245,7 @@ class DocumentService extends BaseApiService {
|
|
|
8307
8245
|
blocks: []
|
|
8308
8246
|
});
|
|
8309
8247
|
const activeOrganizationId = state.organizationReducer.activeOrganizationId;
|
|
8310
|
-
const organizationDocumentsPromise = this.enqueueRequest({
|
|
8248
|
+
const organizationDocumentsPromise = this.client.enqueueRequest({
|
|
8311
8249
|
description: "Get organization documents",
|
|
8312
8250
|
method: HttpMethod.GET,
|
|
8313
8251
|
url: `/organizations/${activeOrganizationId}/documents/`,
|
|
@@ -8361,28 +8299,68 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
8361
8299
|
}
|
|
8362
8300
|
}
|
|
8363
8301
|
class AgentService extends BaseApiService {
|
|
8302
|
+
async startConversation(prompt) {
|
|
8303
|
+
const activeProjectId = this.client.store.getState().projectReducer.activeProjectId;
|
|
8304
|
+
return this.client.enqueueRequest({
|
|
8305
|
+
description: "Start agent conversation",
|
|
8306
|
+
method: HttpMethod.POST,
|
|
8307
|
+
url: "/agents/prompt/",
|
|
8308
|
+
payload: {
|
|
8309
|
+
prompt,
|
|
8310
|
+
active_project: activeProjectId
|
|
8311
|
+
},
|
|
8312
|
+
blockers: ["prompt"],
|
|
8313
|
+
blocks: ["prompt"]
|
|
8314
|
+
}).then((response) => {
|
|
8315
|
+
this.client.store.dispatch(addConversation(response));
|
|
8316
|
+
return response;
|
|
8317
|
+
});
|
|
8318
|
+
}
|
|
8364
8319
|
/**
|
|
8365
8320
|
* Prompt the agent with a message.
|
|
8366
|
-
* @param
|
|
8321
|
+
* @param prompt The message to prompt the agent with.
|
|
8367
8322
|
* @param conversationId If continuing an existing message, the UUID of that conversation.
|
|
8368
8323
|
*/
|
|
8369
|
-
async prompt
|
|
8370
|
-
const
|
|
8371
|
-
|
|
8324
|
+
async continueConversation(prompt, conversationId) {
|
|
8325
|
+
const { store } = this.client;
|
|
8326
|
+
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
8327
|
+
return this.client.enqueueRequest({
|
|
8372
8328
|
description: "Prompt agent",
|
|
8373
8329
|
method: HttpMethod.POST,
|
|
8374
8330
|
url: "/agents/prompt/",
|
|
8375
8331
|
payload: {
|
|
8376
|
-
prompt
|
|
8332
|
+
prompt,
|
|
8377
8333
|
active_project: activeProjectId
|
|
8378
8334
|
},
|
|
8379
8335
|
blockers: ["prompt"],
|
|
8380
8336
|
blocks: ["prompt"],
|
|
8381
|
-
queryParams:
|
|
8337
|
+
queryParams: { conversation_id: conversationId }
|
|
8338
|
+
}).then((response) => {
|
|
8339
|
+
const conversation = store.getState().agentsReducer.conversations[conversationId];
|
|
8340
|
+
if (!conversation) {
|
|
8341
|
+
throw new Error("Conversation not found");
|
|
8342
|
+
}
|
|
8343
|
+
store.dispatch(
|
|
8344
|
+
updateConversation({
|
|
8345
|
+
offline_id: conversationId,
|
|
8346
|
+
tiptap_content: [...conversation.tiptap_content || [], response.response]
|
|
8347
|
+
})
|
|
8348
|
+
);
|
|
8349
|
+
});
|
|
8350
|
+
}
|
|
8351
|
+
async fetchDetails(conversationId) {
|
|
8352
|
+
return this.client.enqueueRequest({
|
|
8353
|
+
description: "Get agent conversation",
|
|
8354
|
+
method: HttpMethod.GET,
|
|
8355
|
+
url: `/agents/conversations/${conversationId}/`,
|
|
8356
|
+
blockers: ["conversation"],
|
|
8357
|
+
blocks: ["conversation"]
|
|
8358
|
+
}).then((response) => {
|
|
8359
|
+
this.client.store.dispatch(setConversation(response));
|
|
8382
8360
|
});
|
|
8383
8361
|
}
|
|
8384
8362
|
async rate(responseId, rating) {
|
|
8385
|
-
return this.enqueueRequest({
|
|
8363
|
+
return this.client.enqueueRequest({
|
|
8386
8364
|
description: "Rate agent response",
|
|
8387
8365
|
method: HttpMethod.PUT,
|
|
8388
8366
|
url: `/agents/responses/${responseId}/rate/`,
|
|
@@ -8391,6 +8369,18 @@ class AgentService extends BaseApiService {
|
|
|
8391
8369
|
blocks: ["rate"]
|
|
8392
8370
|
});
|
|
8393
8371
|
}
|
|
8372
|
+
async refreshStore() {
|
|
8373
|
+
const { store } = this.client;
|
|
8374
|
+
const activeProject = store.getState().projectReducer.activeProjectId;
|
|
8375
|
+
const result = await this.client.enqueueRequest({
|
|
8376
|
+
description: "Get agent conversation history",
|
|
8377
|
+
method: HttpMethod.GET,
|
|
8378
|
+
url: `/projects/${activeProject}/agent-conversations/`,
|
|
8379
|
+
blockers: ["agent-conversations"],
|
|
8380
|
+
blocks: ["agent-conversations"]
|
|
8381
|
+
});
|
|
8382
|
+
store.dispatch(setConversations(result));
|
|
8383
|
+
}
|
|
8394
8384
|
}
|
|
8395
8385
|
class TeamService extends BaseApiService {
|
|
8396
8386
|
add(teamPayload) {
|
|
@@ -8408,7 +8398,7 @@ class TeamService extends BaseApiService {
|
|
|
8408
8398
|
// created_by: state.userReducer.currentUser.id,
|
|
8409
8399
|
});
|
|
8410
8400
|
store.dispatch(addTeam(offlineTeam));
|
|
8411
|
-
const promise = this.enqueueRequest({
|
|
8401
|
+
const promise = this.client.enqueueRequest({
|
|
8412
8402
|
description: "Create team",
|
|
8413
8403
|
method: HttpMethod.POST,
|
|
8414
8404
|
url: `/organizations/${activeOrganizationId}/teams/`,
|
|
@@ -8433,7 +8423,7 @@ class TeamService extends BaseApiService {
|
|
|
8433
8423
|
...team
|
|
8434
8424
|
};
|
|
8435
8425
|
store.dispatch(updateTeam(offlineUpdatedTeam));
|
|
8436
|
-
const promise = this.enqueueRequest({
|
|
8426
|
+
const promise = this.client.enqueueRequest({
|
|
8437
8427
|
description: "Update team",
|
|
8438
8428
|
method: HttpMethod.PATCH,
|
|
8439
8429
|
url: `/organizations/teams/${team.offline_id}/`,
|
|
@@ -8457,7 +8447,7 @@ class TeamService extends BaseApiService {
|
|
|
8457
8447
|
}
|
|
8458
8448
|
store.dispatch(deleteTeam(teamId));
|
|
8459
8449
|
try {
|
|
8460
|
-
return await this.enqueueRequest({
|
|
8450
|
+
return await this.client.enqueueRequest({
|
|
8461
8451
|
description: "Delete team",
|
|
8462
8452
|
method: HttpMethod.DELETE,
|
|
8463
8453
|
url: `/organizations/teams/${teamId}/`,
|
|
@@ -8479,7 +8469,7 @@ class TeamService extends BaseApiService {
|
|
|
8479
8469
|
throw new Error("Duplicate members found in the list");
|
|
8480
8470
|
}
|
|
8481
8471
|
store.dispatch(updateTeam({ ...team, members }));
|
|
8482
|
-
const promise = this.enqueueRequest({
|
|
8472
|
+
const promise = this.client.enqueueRequest({
|
|
8483
8473
|
description: "Set team members",
|
|
8484
8474
|
method: HttpMethod.PUT,
|
|
8485
8475
|
url: `/organizations/teams/${teamId}/set-members/`,
|
|
@@ -8518,7 +8508,7 @@ class TeamService extends BaseApiService {
|
|
|
8518
8508
|
if (!activeOrganizationId) {
|
|
8519
8509
|
throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
|
|
8520
8510
|
}
|
|
8521
|
-
const result = await this.enqueueRequest({
|
|
8511
|
+
const result = await this.client.enqueueRequest({
|
|
8522
8512
|
description: "Fetch teams",
|
|
8523
8513
|
method: HttpMethod.GET,
|
|
8524
8514
|
url: `/organizations/${activeOrganizationId}/teams/`,
|
|
@@ -8528,6 +8518,46 @@ class TeamService extends BaseApiService {
|
|
|
8528
8518
|
store.dispatch(setTeams(result));
|
|
8529
8519
|
}
|
|
8530
8520
|
}
|
|
8521
|
+
class DeferredPromise {
|
|
8522
|
+
constructor() {
|
|
8523
|
+
__publicField(this, _a, "Promise");
|
|
8524
|
+
__publicField(this, "_promise");
|
|
8525
|
+
__publicField(this, "_resolve");
|
|
8526
|
+
__publicField(this, "_reject");
|
|
8527
|
+
__publicField(this, "_state", "pending");
|
|
8528
|
+
this._resolve = null;
|
|
8529
|
+
this._reject = null;
|
|
8530
|
+
this._promise = new Promise((resolve, reject) => {
|
|
8531
|
+
this._resolve = resolve;
|
|
8532
|
+
this._reject = reject;
|
|
8533
|
+
});
|
|
8534
|
+
}
|
|
8535
|
+
get state() {
|
|
8536
|
+
return this._state;
|
|
8537
|
+
}
|
|
8538
|
+
then(onFulfilled, onRejected) {
|
|
8539
|
+
return this._promise.then(onFulfilled, onRejected);
|
|
8540
|
+
}
|
|
8541
|
+
catch(onRejected) {
|
|
8542
|
+
return this._promise.catch(onRejected);
|
|
8543
|
+
}
|
|
8544
|
+
resolve(value) {
|
|
8545
|
+
if (!this._resolve)
|
|
8546
|
+
throw new Error("No resolve callback");
|
|
8547
|
+
this._resolve(value);
|
|
8548
|
+
this._state = "fulfilled";
|
|
8549
|
+
}
|
|
8550
|
+
reject(reason) {
|
|
8551
|
+
if (!this._reject)
|
|
8552
|
+
throw reason;
|
|
8553
|
+
this._reject(reason);
|
|
8554
|
+
this._state = "rejected";
|
|
8555
|
+
}
|
|
8556
|
+
finally(_onFinally) {
|
|
8557
|
+
throw new Error("`finally` not implemented");
|
|
8558
|
+
}
|
|
8559
|
+
}
|
|
8560
|
+
_a = Symbol.toStringTag;
|
|
8531
8561
|
class OvermapSDK {
|
|
8532
8562
|
constructor(apiUrl, store) {
|
|
8533
8563
|
__publicField(this, "API_URL");
|
|
@@ -8566,6 +8596,87 @@ class OvermapSDK {
|
|
|
8566
8596
|
this.API_URL = apiUrl;
|
|
8567
8597
|
this.store = store;
|
|
8568
8598
|
}
|
|
8599
|
+
/**
|
|
8600
|
+
* Enqueues an API request to the offline outbox.
|
|
8601
|
+
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
8602
|
+
* @protected
|
|
8603
|
+
*/
|
|
8604
|
+
async enqueueRequest(requestDetails) {
|
|
8605
|
+
return this._enqueueRequest(requestDetails).then((result) => {
|
|
8606
|
+
if (result instanceof APIError) {
|
|
8607
|
+
throw result;
|
|
8608
|
+
}
|
|
8609
|
+
return result;
|
|
8610
|
+
});
|
|
8611
|
+
}
|
|
8612
|
+
/**
|
|
8613
|
+
* Enqueues an API request to the Redux Offline outbox
|
|
8614
|
+
* @protected
|
|
8615
|
+
*/
|
|
8616
|
+
_enqueueRequest(requestDetails) {
|
|
8617
|
+
const promise = new DeferredPromise();
|
|
8618
|
+
const requestDetailsWithBaseUrl = { ...requestDetails, BASE_URL: this.API_URL };
|
|
8619
|
+
if (requestDetails.immediate) {
|
|
8620
|
+
const requestWithUuid = {
|
|
8621
|
+
...requestDetailsWithBaseUrl,
|
|
8622
|
+
uuid: requestDetails.uuid ?? v4()
|
|
8623
|
+
};
|
|
8624
|
+
const fullOfflineAction = {
|
|
8625
|
+
payload: requestWithUuid,
|
|
8626
|
+
type: "",
|
|
8627
|
+
meta: {
|
|
8628
|
+
offline: {
|
|
8629
|
+
effect: {
|
|
8630
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8631
|
+
request: requestWithUuid,
|
|
8632
|
+
BASE_URL: this.API_URL
|
|
8633
|
+
}
|
|
8634
|
+
}
|
|
8635
|
+
}
|
|
8636
|
+
};
|
|
8637
|
+
performRequest(fullOfflineAction, this).then((result) => {
|
|
8638
|
+
promise.resolve(result.body);
|
|
8639
|
+
}).catch((error2) => {
|
|
8640
|
+
discard(error2, fullOfflineAction);
|
|
8641
|
+
promise.reject(error2);
|
|
8642
|
+
});
|
|
8643
|
+
} else {
|
|
8644
|
+
const innerPromise = this.store.dispatch(
|
|
8645
|
+
enqueueRequest(requestDetailsWithBaseUrl)
|
|
8646
|
+
);
|
|
8647
|
+
const successOrUndefinedHandler = (response) => {
|
|
8648
|
+
if (response) {
|
|
8649
|
+
promise.resolve(response.body);
|
|
8650
|
+
} else {
|
|
8651
|
+
const error2 = new APIError({
|
|
8652
|
+
message: "Could not get a response from the server.",
|
|
8653
|
+
response,
|
|
8654
|
+
discard: true
|
|
8655
|
+
});
|
|
8656
|
+
promise.reject(error2);
|
|
8657
|
+
}
|
|
8658
|
+
};
|
|
8659
|
+
const errorHandler = (error2) => {
|
|
8660
|
+
if (error2 instanceof APIError) {
|
|
8661
|
+
error2.options.discard = true;
|
|
8662
|
+
} else {
|
|
8663
|
+
console.error(
|
|
8664
|
+
"Received an unexpected error while processing a request:",
|
|
8665
|
+
error2,
|
|
8666
|
+
"\nConverting error to APIError and discarding."
|
|
8667
|
+
);
|
|
8668
|
+
error2 = new APIError({
|
|
8669
|
+
message: "An error occurred while processing the request.",
|
|
8670
|
+
innerError: error2,
|
|
8671
|
+
discard: true
|
|
8672
|
+
});
|
|
8673
|
+
}
|
|
8674
|
+
promise.reject(error2);
|
|
8675
|
+
};
|
|
8676
|
+
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
8677
|
+
}
|
|
8678
|
+
return promise;
|
|
8679
|
+
}
|
|
8569
8680
|
}
|
|
8570
8681
|
const makeClient = (apiUrl, store) => new OvermapSDK(apiUrl, store);
|
|
8571
8682
|
const SDKContext = React__default.createContext({});
|
|
@@ -16706,6 +16817,7 @@ export {
|
|
|
16706
16817
|
addComponentTypeAttachment,
|
|
16707
16818
|
addComponentTypeAttachments,
|
|
16708
16819
|
addComponentsInBatches,
|
|
16820
|
+
addConversation,
|
|
16709
16821
|
addDocumentAttachment,
|
|
16710
16822
|
addDocumentAttachments,
|
|
16711
16823
|
addDocuments,
|
|
@@ -16746,6 +16858,8 @@ export {
|
|
|
16746
16858
|
addToRecentIssues,
|
|
16747
16859
|
addUsers,
|
|
16748
16860
|
addWorkspace,
|
|
16861
|
+
agentsReducer,
|
|
16862
|
+
agentsSlice,
|
|
16749
16863
|
areArraysEqual,
|
|
16750
16864
|
authReducer,
|
|
16751
16865
|
authSlice,
|
|
@@ -16987,6 +17101,9 @@ export {
|
|
|
16987
17101
|
selectComponentsByType,
|
|
16988
17102
|
selectComponentsFromComponentType,
|
|
16989
17103
|
selectComponentsMapping,
|
|
17104
|
+
selectConversation,
|
|
17105
|
+
selectConversationMapping,
|
|
17106
|
+
selectConversations,
|
|
16990
17107
|
selectCreateProjectType,
|
|
16991
17108
|
selectCurrentUser,
|
|
16992
17109
|
selectDeletedRequests,
|
|
@@ -17130,6 +17247,8 @@ export {
|
|
|
17130
17247
|
setComponentTypeAttachments,
|
|
17131
17248
|
setComponentTypes,
|
|
17132
17249
|
setComponents,
|
|
17250
|
+
setConversation,
|
|
17251
|
+
setConversations,
|
|
17133
17252
|
setCreateProjectType,
|
|
17134
17253
|
setCurrentUser,
|
|
17135
17254
|
setDocumentAttachment,
|
|
@@ -17202,6 +17321,7 @@ export {
|
|
|
17202
17321
|
updateComponentAttachments,
|
|
17203
17322
|
updateComponentTypeAttachment,
|
|
17204
17323
|
updateComponentTypeAttachments,
|
|
17324
|
+
updateConversation,
|
|
17205
17325
|
updateDocumentAttachment,
|
|
17206
17326
|
updateDocumentAttachments,
|
|
17207
17327
|
updateDocuments,
|