@overmap-ai/core 1.0.53-component-asset-renames.5 → 1.0.53-component-asset-renames.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/overmap-core.js +386 -359
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +387 -360
- 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/BaseApiService.d.ts +0 -12
- package/dist/store/store.d.ts +1 -1
- package/package.json +1 -1
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");
|
|
@@ -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];
|
|
@@ -4639,11 +4605,19 @@ const rootReducer = (state, action) => {
|
|
|
4639
4605
|
return overmapReducer(mutatedState, action);
|
|
4640
4606
|
};
|
|
4641
4607
|
let __OUTBOX_COORDINATOR = null;
|
|
4642
|
-
function
|
|
4643
|
-
|
|
4644
|
-
|
|
4608
|
+
function getOutboxCoordinator() {
|
|
4609
|
+
const clientStore2 = getClientStore();
|
|
4610
|
+
if (!clientStore2) {
|
|
4611
|
+
console.warn("Client store not set; cannot get outbox coordinator yet.");
|
|
4612
|
+
return null;
|
|
4613
|
+
}
|
|
4614
|
+
if (__OUTBOX_COORDINATOR) {
|
|
4615
|
+
return __OUTBOX_COORDINATOR;
|
|
4645
4616
|
}
|
|
4646
|
-
|
|
4617
|
+
const outbox = clientStore2.getState().offline.outbox;
|
|
4618
|
+
const coordinator = OutboxCoordinator._fromOutbox(outbox);
|
|
4619
|
+
__OUTBOX_COORDINATOR = coordinator;
|
|
4620
|
+
return coordinator;
|
|
4647
4621
|
}
|
|
4648
4622
|
const persistCallback = (err) => {
|
|
4649
4623
|
if (err)
|
|
@@ -4656,12 +4630,20 @@ const persistCallback = (err) => {
|
|
|
4656
4630
|
}
|
|
4657
4631
|
};
|
|
4658
4632
|
const enqueue = (_array, item, _context) => {
|
|
4659
|
-
const coordinator =
|
|
4633
|
+
const coordinator = getOutboxCoordinator();
|
|
4634
|
+
if (!coordinator) {
|
|
4635
|
+
console.warn("Outbox coordinator not set; cannot enqueue request yet.");
|
|
4636
|
+
return [];
|
|
4637
|
+
}
|
|
4660
4638
|
coordinator.addRequest(item);
|
|
4661
4639
|
return coordinator.getQueue();
|
|
4662
4640
|
};
|
|
4663
4641
|
const dequeue = (_array, item, _context) => {
|
|
4664
|
-
const coordinator =
|
|
4642
|
+
const coordinator = getOutboxCoordinator();
|
|
4643
|
+
if (!coordinator) {
|
|
4644
|
+
console.warn("Outbox coordinator not set; cannot dequeue request yet.");
|
|
4645
|
+
return [];
|
|
4646
|
+
}
|
|
4665
4647
|
const meta = item.meta;
|
|
4666
4648
|
const uuid = meta.offlineAction.payload.uuid;
|
|
4667
4649
|
coordinator.remove(uuid);
|
|
@@ -4745,7 +4727,6 @@ async function performRequest(action, client) {
|
|
|
4745
4727
|
}
|
|
4746
4728
|
}
|
|
4747
4729
|
}
|
|
4748
|
-
console.debug("Done checking tokens");
|
|
4749
4730
|
const defaultSettings = {
|
|
4750
4731
|
queryParams: "",
|
|
4751
4732
|
isAuthNeeded: true
|
|
@@ -4889,7 +4870,7 @@ class OfflineMiddleware {
|
|
|
4889
4870
|
if (this.next) {
|
|
4890
4871
|
return this.next.run(action);
|
|
4891
4872
|
} else {
|
|
4892
|
-
console.debug(
|
|
4873
|
+
console.debug("Middleware finished. Performing request:", action);
|
|
4893
4874
|
const baseUrl = action.meta.offline.effect.BASE_URL;
|
|
4894
4875
|
const clientStore2 = getClientStore();
|
|
4895
4876
|
if (!clientStore2)
|
|
@@ -4953,7 +4934,11 @@ function discard(reason, action, retries = 0) {
|
|
|
4953
4934
|
const uuid = action.payload.uuid;
|
|
4954
4935
|
function rollbackAndThrow() {
|
|
4955
4936
|
clientStore2.dispatch(markAsDeleted(uuid));
|
|
4956
|
-
|
|
4937
|
+
const coordinator2 = getOutboxCoordinator();
|
|
4938
|
+
if (!coordinator2) {
|
|
4939
|
+
throw new Error("Outbox coordinator not set");
|
|
4940
|
+
}
|
|
4941
|
+
coordinator2.remove(action.payload.uuid);
|
|
4957
4942
|
const rollbackAction = action.meta.offline.rollback;
|
|
4958
4943
|
if (rollbackAction) {
|
|
4959
4944
|
console.warn("Rolling back request due to SDK error:", action);
|
|
@@ -4984,17 +4969,26 @@ function discard(reason, action, retries = 0) {
|
|
|
4984
4969
|
console.error(`Could not display toast for status ${status} because there is no toast handle.`);
|
|
4985
4970
|
}
|
|
4986
4971
|
}
|
|
4987
|
-
|
|
4972
|
+
const coordinator2 = getOutboxCoordinator();
|
|
4973
|
+
if (!coordinator2) {
|
|
4974
|
+
throw new Error("Outbox coordinator not set");
|
|
4975
|
+
}
|
|
4976
|
+
coordinator2.remove(action.payload.uuid);
|
|
4988
4977
|
reason.options.discard = true;
|
|
4989
4978
|
rollbackAndThrow();
|
|
4990
4979
|
}
|
|
4991
4980
|
}
|
|
4992
4981
|
console.debug("Registering a retry for request:", action.payload.uuid);
|
|
4993
|
-
|
|
4982
|
+
const coordinator = getOutboxCoordinator();
|
|
4983
|
+
if (!coordinator) {
|
|
4984
|
+
throw new Error("Outbox coordinator not set");
|
|
4985
|
+
}
|
|
4986
|
+
coordinator.registerRetry(action.payload.uuid);
|
|
4994
4987
|
return false;
|
|
4995
4988
|
}
|
|
4996
4989
|
function peek(_array, _item, _context) {
|
|
4997
|
-
|
|
4990
|
+
var _a2;
|
|
4991
|
+
return (_a2 = getOutboxCoordinator()) == null ? void 0 : _a2.peek();
|
|
4998
4992
|
}
|
|
4999
4993
|
function retry(_action, _retries) {
|
|
5000
4994
|
getClientStore().dispatch(_setLatestRetryTime((/* @__PURE__ */ new Date()).getTime()));
|
|
@@ -5002,94 +4996,6 @@ function retry(_action, _retries) {
|
|
|
5002
4996
|
}
|
|
5003
4997
|
const useAppDispatch = () => useDispatch();
|
|
5004
4998
|
const useAppSelector = useSelector;
|
|
5005
|
-
class BaseApiService {
|
|
5006
|
-
constructor(sdk) {
|
|
5007
|
-
__publicField(this, "client");
|
|
5008
|
-
this.client = sdk;
|
|
5009
|
-
}
|
|
5010
|
-
/**
|
|
5011
|
-
* Enqueues an API request to the offline outbox.
|
|
5012
|
-
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
5013
|
-
* @protected
|
|
5014
|
-
*/
|
|
5015
|
-
async enqueueRequest(requestDetails) {
|
|
5016
|
-
return this._enqueueRequest(requestDetails).then((result) => {
|
|
5017
|
-
if (result instanceof APIError) {
|
|
5018
|
-
throw result;
|
|
5019
|
-
}
|
|
5020
|
-
return result;
|
|
5021
|
-
});
|
|
5022
|
-
}
|
|
5023
|
-
/**
|
|
5024
|
-
* Enqueues an API request to the Redux Offline outbox
|
|
5025
|
-
* @protected
|
|
5026
|
-
*/
|
|
5027
|
-
_enqueueRequest(requestDetails) {
|
|
5028
|
-
const promise = new DeferredPromise();
|
|
5029
|
-
const requestDetailsWithBaseUrl = { ...requestDetails, BASE_URL: this.client.API_URL };
|
|
5030
|
-
const { store } = this.client;
|
|
5031
|
-
if (requestDetails.immediate) {
|
|
5032
|
-
const requestWithUuid = {
|
|
5033
|
-
...requestDetailsWithBaseUrl,
|
|
5034
|
-
uuid: requestDetails.uuid ?? v4()
|
|
5035
|
-
};
|
|
5036
|
-
const fullOfflineAction = {
|
|
5037
|
-
payload: requestWithUuid,
|
|
5038
|
-
type: "",
|
|
5039
|
-
meta: {
|
|
5040
|
-
offline: {
|
|
5041
|
-
effect: {
|
|
5042
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5043
|
-
request: requestWithUuid,
|
|
5044
|
-
BASE_URL: this.client.API_URL
|
|
5045
|
-
}
|
|
5046
|
-
}
|
|
5047
|
-
}
|
|
5048
|
-
};
|
|
5049
|
-
performRequest(fullOfflineAction, this.client).then((result) => {
|
|
5050
|
-
promise.resolve(result.body);
|
|
5051
|
-
}).catch((error2) => {
|
|
5052
|
-
discard(error2, fullOfflineAction);
|
|
5053
|
-
promise.reject(error2);
|
|
5054
|
-
});
|
|
5055
|
-
} else {
|
|
5056
|
-
const innerPromise = store.dispatch(
|
|
5057
|
-
enqueueRequest(requestDetailsWithBaseUrl)
|
|
5058
|
-
);
|
|
5059
|
-
const successOrUndefinedHandler = (response) => {
|
|
5060
|
-
if (response) {
|
|
5061
|
-
promise.resolve(response.body);
|
|
5062
|
-
} else {
|
|
5063
|
-
const error2 = new APIError({
|
|
5064
|
-
message: "Could not get a response from the server.",
|
|
5065
|
-
response,
|
|
5066
|
-
discard: true
|
|
5067
|
-
});
|
|
5068
|
-
promise.reject(error2);
|
|
5069
|
-
}
|
|
5070
|
-
};
|
|
5071
|
-
const errorHandler = (error2) => {
|
|
5072
|
-
if (error2 instanceof APIError) {
|
|
5073
|
-
error2.options.discard = true;
|
|
5074
|
-
} else {
|
|
5075
|
-
console.error(
|
|
5076
|
-
"Received an unexpected error while processing a request:",
|
|
5077
|
-
error2,
|
|
5078
|
-
"\nConverting error to APIError and discarding."
|
|
5079
|
-
);
|
|
5080
|
-
error2 = new APIError({
|
|
5081
|
-
message: "An error occurred while processing the request.",
|
|
5082
|
-
innerError: error2,
|
|
5083
|
-
discard: true
|
|
5084
|
-
});
|
|
5085
|
-
}
|
|
5086
|
-
promise.reject(error2);
|
|
5087
|
-
};
|
|
5088
|
-
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
5089
|
-
}
|
|
5090
|
-
return promise;
|
|
5091
|
-
}
|
|
5092
|
-
}
|
|
5093
4999
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
5094
5000
|
function parseTokens(response) {
|
|
5095
5001
|
if (!response.access)
|
|
@@ -5116,7 +5022,7 @@ class AuthService extends BaseApiService {
|
|
|
5116
5022
|
*/
|
|
5117
5023
|
__publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
|
|
5118
5024
|
const uuid = v4();
|
|
5119
|
-
const responsePromise = this.enqueueRequest({
|
|
5025
|
+
const responsePromise = this.client.enqueueRequest({
|
|
5120
5026
|
uuid,
|
|
5121
5027
|
description: "Get token pair",
|
|
5122
5028
|
method: HttpMethod.POST,
|
|
@@ -5141,7 +5047,7 @@ class AuthService extends BaseApiService {
|
|
|
5141
5047
|
* @returns {Promise<TokenPair>} The new access and refresh tokens
|
|
5142
5048
|
*/
|
|
5143
5049
|
__publicField(this, "_getRenewedTokens", async (refreshToken) => {
|
|
5144
|
-
const promise = this.enqueueRequest({
|
|
5050
|
+
const promise = this.client.enqueueRequest({
|
|
5145
5051
|
description: "Get renewed tokens",
|
|
5146
5052
|
method: HttpMethod.POST,
|
|
5147
5053
|
url: "/api/token/refresh/",
|
|
@@ -5254,7 +5160,7 @@ class AuthService extends BaseApiService {
|
|
|
5254
5160
|
* Register a new user
|
|
5255
5161
|
*/
|
|
5256
5162
|
register(payload) {
|
|
5257
|
-
return this.enqueueRequest({
|
|
5163
|
+
return this.client.enqueueRequest({
|
|
5258
5164
|
description: "Register",
|
|
5259
5165
|
method: HttpMethod.POST,
|
|
5260
5166
|
url: "/authentication/users/register/",
|
|
@@ -5265,7 +5171,7 @@ class AuthService extends BaseApiService {
|
|
|
5265
5171
|
});
|
|
5266
5172
|
}
|
|
5267
5173
|
async resetPassword(email) {
|
|
5268
|
-
return this.enqueueRequest({
|
|
5174
|
+
return this.client.enqueueRequest({
|
|
5269
5175
|
description: "Reset password",
|
|
5270
5176
|
method: HttpMethod.PATCH,
|
|
5271
5177
|
url: "/authentication/users/reset-password/",
|
|
@@ -5302,7 +5208,7 @@ class AuthService extends BaseApiService {
|
|
|
5302
5208
|
const { store } = this.client;
|
|
5303
5209
|
const [fileProps] = await this.client.files.uploadFileToS3(hash);
|
|
5304
5210
|
store.dispatch(setProfilePicture({ file: `/files/${fileProps.file}`, file_sha1: hash }));
|
|
5305
|
-
return this.enqueueRequest({
|
|
5211
|
+
return this.client.enqueueRequest({
|
|
5306
5212
|
description: "Replace profile picture",
|
|
5307
5213
|
method: HttpMethod.PATCH,
|
|
5308
5214
|
url: "/authentication/users/profile-details/",
|
|
@@ -5313,7 +5219,7 @@ class AuthService extends BaseApiService {
|
|
|
5313
5219
|
}
|
|
5314
5220
|
async addFavouriteProjectId(projectId) {
|
|
5315
5221
|
this.client.store.dispatch(addFavouriteProjectId(projectId));
|
|
5316
|
-
return this.enqueueRequest({
|
|
5222
|
+
return this.client.enqueueRequest({
|
|
5317
5223
|
description: "Add favourite project",
|
|
5318
5224
|
method: HttpMethod.POST,
|
|
5319
5225
|
url: `/authentication/users/favourite-project/${projectId}/`,
|
|
@@ -5323,7 +5229,7 @@ class AuthService extends BaseApiService {
|
|
|
5323
5229
|
}
|
|
5324
5230
|
async removeFavouriteProjectId(projectId) {
|
|
5325
5231
|
this.client.store.dispatch(removeFavouriteProjectId(projectId));
|
|
5326
|
-
return this.enqueueRequest({
|
|
5232
|
+
return this.client.enqueueRequest({
|
|
5327
5233
|
description: "Add favourite project",
|
|
5328
5234
|
method: HttpMethod.POST,
|
|
5329
5235
|
url: `/authentication/users/unfavourite-project/${projectId}/`,
|
|
@@ -5336,7 +5242,7 @@ class AuthService extends BaseApiService {
|
|
|
5336
5242
|
const currentStep = this.client.store.getState().userReducer.currentUser.profile.tour_step;
|
|
5337
5243
|
if (currentStep === stepIndex)
|
|
5338
5244
|
return Promise.resolve(void 0);
|
|
5339
|
-
return this.enqueueRequest({
|
|
5245
|
+
return this.client.enqueueRequest({
|
|
5340
5246
|
description: "Set tour step",
|
|
5341
5247
|
method: HttpMethod.PATCH,
|
|
5342
5248
|
url: "/authentication/users/profile-details/",
|
|
@@ -5348,7 +5254,7 @@ class AuthService extends BaseApiService {
|
|
|
5348
5254
|
});
|
|
5349
5255
|
}
|
|
5350
5256
|
async joinApplication(projectInviteId, verification_code, username, password) {
|
|
5351
|
-
return this.enqueueRequest({
|
|
5257
|
+
return this.client.enqueueRequest({
|
|
5352
5258
|
description: "Join application",
|
|
5353
5259
|
method: HttpMethod.PATCH,
|
|
5354
5260
|
url: `/authentication/join-app/${projectInviteId}/${verification_code}/`,
|
|
@@ -5367,7 +5273,7 @@ class CategoryService extends BaseApiService {
|
|
|
5367
5273
|
const offlineCategory = offline(category);
|
|
5368
5274
|
const categoryWithWorkspace = { ...offlineCategory, workspace: workspaceId };
|
|
5369
5275
|
this.client.store.dispatch(addCategory(categoryWithWorkspace));
|
|
5370
|
-
const promise = this.enqueueRequest({
|
|
5276
|
+
const promise = this.client.enqueueRequest({
|
|
5371
5277
|
description: "Create Category",
|
|
5372
5278
|
method: HttpMethod.POST,
|
|
5373
5279
|
url: "/categories/",
|
|
@@ -5381,7 +5287,7 @@ class CategoryService extends BaseApiService {
|
|
|
5381
5287
|
return [categoryWithWorkspace, promise];
|
|
5382
5288
|
}
|
|
5383
5289
|
fetchAll(projectId) {
|
|
5384
|
-
const promise = this.enqueueRequest({
|
|
5290
|
+
const promise = this.client.enqueueRequest({
|
|
5385
5291
|
description: "Get categories",
|
|
5386
5292
|
method: HttpMethod.GET,
|
|
5387
5293
|
url: `/projects/${projectId}/categories/`,
|
|
@@ -5398,7 +5304,7 @@ class CategoryService extends BaseApiService {
|
|
|
5398
5304
|
}
|
|
5399
5305
|
this.client.store.dispatch(patchCategory(category));
|
|
5400
5306
|
const optimisticCategory = { ...existingCategory, ...category };
|
|
5401
|
-
const promise = this.enqueueRequest({
|
|
5307
|
+
const promise = this.client.enqueueRequest({
|
|
5402
5308
|
description: "Edit Category",
|
|
5403
5309
|
method: HttpMethod.PATCH,
|
|
5404
5310
|
url: `/categories/${category.offline_id}/`,
|
|
@@ -5413,7 +5319,7 @@ class CategoryService extends BaseApiService {
|
|
|
5413
5319
|
}
|
|
5414
5320
|
remove(category, workspaceId) {
|
|
5415
5321
|
this.client.store.dispatch(removeCategory(category.offline_id));
|
|
5416
|
-
return this.enqueueRequest({
|
|
5322
|
+
return this.client.enqueueRequest({
|
|
5417
5323
|
description: "Delete Category",
|
|
5418
5324
|
method: HttpMethod.DELETE,
|
|
5419
5325
|
url: `/categories/${category.offline_id}/`,
|
|
@@ -5459,7 +5365,7 @@ class AssetService extends BaseApiService {
|
|
|
5459
5365
|
add(asset, workspaceId) {
|
|
5460
5366
|
const offlineAsset = offline(asset);
|
|
5461
5367
|
this.client.store.dispatch(addAsset(offlineAsset));
|
|
5462
|
-
const promise = this.enqueueRequest({
|
|
5368
|
+
const promise = this.client.enqueueRequest({
|
|
5463
5369
|
description: "Create asset",
|
|
5464
5370
|
method: HttpMethod.POST,
|
|
5465
5371
|
url: `/assets/types/${offlineAsset.asset_type}/add-assets/`,
|
|
@@ -5474,7 +5380,7 @@ class AssetService extends BaseApiService {
|
|
|
5474
5380
|
}
|
|
5475
5381
|
update(asset, workspaceId) {
|
|
5476
5382
|
this.client.store.dispatch(updateAsset(asset));
|
|
5477
|
-
const promise = this.enqueueRequest({
|
|
5383
|
+
const promise = this.client.enqueueRequest({
|
|
5478
5384
|
description: "Edit asset",
|
|
5479
5385
|
method: HttpMethod.PATCH,
|
|
5480
5386
|
url: `/assets/${asset.offline_id}/`,
|
|
@@ -5498,7 +5404,7 @@ class AssetService extends BaseApiService {
|
|
|
5498
5404
|
const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
|
|
5499
5405
|
store.dispatch(removeAssetAttachments(attachmentsOfAssetIds));
|
|
5500
5406
|
}
|
|
5501
|
-
return this.enqueueRequest({
|
|
5407
|
+
return this.client.enqueueRequest({
|
|
5502
5408
|
description: "Delete asset",
|
|
5503
5409
|
method: HttpMethod.DELETE,
|
|
5504
5410
|
url: `/assets/${assetId}/`,
|
|
@@ -5517,7 +5423,7 @@ class AssetService extends BaseApiService {
|
|
|
5517
5423
|
const allAssetsOfAssetTypeIds = (allAssetsOfAssetType || []).map((c) => c.offline_id);
|
|
5518
5424
|
const affectedOfflineIds = [assetTypeId, ...allAssetsOfAssetTypeIds];
|
|
5519
5425
|
store.dispatch(removeAllAssetsOfType(assetTypeId));
|
|
5520
|
-
return this.enqueueRequest({
|
|
5426
|
+
return this.client.enqueueRequest({
|
|
5521
5427
|
description: "Delete all assets of asset type",
|
|
5522
5428
|
method: HttpMethod.DELETE,
|
|
5523
5429
|
url: `/assets/types/${assetTypeId}/delete-all-of-type/`,
|
|
@@ -5536,7 +5442,7 @@ class AssetService extends BaseApiService {
|
|
|
5536
5442
|
});
|
|
5537
5443
|
const { store } = this.client;
|
|
5538
5444
|
store.dispatch(addAssetsInBatches(fullAssets));
|
|
5539
|
-
const promise = this.enqueueRequest({
|
|
5445
|
+
const promise = this.client.enqueueRequest({
|
|
5540
5446
|
description: "Batch create assets",
|
|
5541
5447
|
method: HttpMethod.POST,
|
|
5542
5448
|
url: `/assets/types/${assetTypeId}/add-assets/`,
|
|
@@ -5563,7 +5469,7 @@ class AssetService extends BaseApiService {
|
|
|
5563
5469
|
}
|
|
5564
5470
|
async refreshStore() {
|
|
5565
5471
|
const { store } = this.client;
|
|
5566
|
-
const result = await this.enqueueRequest({
|
|
5472
|
+
const result = await this.client.enqueueRequest({
|
|
5567
5473
|
description: "Get assets",
|
|
5568
5474
|
method: HttpMethod.GET,
|
|
5569
5475
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/assets/`,
|
|
@@ -5586,7 +5492,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
5586
5492
|
stage: stageId
|
|
5587
5493
|
});
|
|
5588
5494
|
store.dispatch(addStageCompletion(offlineStageCompletion));
|
|
5589
|
-
const promise = this.enqueueRequest({
|
|
5495
|
+
const promise = this.client.enqueueRequest({
|
|
5590
5496
|
description: "Complete stage",
|
|
5591
5497
|
method: HttpMethod.POST,
|
|
5592
5498
|
url: `/assets/types/${assetTypeId}/complete-stages/`,
|
|
@@ -5599,7 +5505,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
5599
5505
|
}
|
|
5600
5506
|
async refreshStore() {
|
|
5601
5507
|
const { store } = this.client;
|
|
5602
|
-
const result = await this.enqueueRequest({
|
|
5508
|
+
const result = await this.client.enqueueRequest({
|
|
5603
5509
|
description: "Get stage completions",
|
|
5604
5510
|
method: HttpMethod.GET,
|
|
5605
5511
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/asset-stage-completions/`,
|
|
@@ -5626,7 +5532,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
5626
5532
|
asMapping[completion.asset] = stageToCompletionDateMapping;
|
|
5627
5533
|
}
|
|
5628
5534
|
this.client.store.dispatch(addStageCompletions(asMapping));
|
|
5629
|
-
await this.enqueueRequest({
|
|
5535
|
+
await this.client.enqueueRequest({
|
|
5630
5536
|
description: "Bulk complete stages",
|
|
5631
5537
|
method: HttpMethod.POST,
|
|
5632
5538
|
url: `/assets/types/${assetTypeId}/complete-stages/`,
|
|
@@ -5645,7 +5551,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
5645
5551
|
};
|
|
5646
5552
|
});
|
|
5647
5553
|
this.client.store.dispatch(removeStageCompletions(stageCompletionsToRemove));
|
|
5648
|
-
return this.enqueueRequest({
|
|
5554
|
+
return this.client.enqueueRequest({
|
|
5649
5555
|
description: `Undo stage for ${assetIds.length} assets(s)`,
|
|
5650
5556
|
// TODO: Rename to setCompletedStages
|
|
5651
5557
|
method: HttpMethod.DELETE,
|
|
@@ -5667,7 +5573,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5667
5573
|
return { ...stage, asset_type: assetTypeId };
|
|
5668
5574
|
});
|
|
5669
5575
|
this.client.store.dispatch(addStages(fullStages));
|
|
5670
|
-
return this.enqueueRequest({
|
|
5576
|
+
return this.client.enqueueRequest({
|
|
5671
5577
|
description: "Add asset stages",
|
|
5672
5578
|
method: HttpMethod.POST,
|
|
5673
5579
|
url: `/assets/types/${assetTypeId}/add-stages/`,
|
|
@@ -5691,7 +5597,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5691
5597
|
throw new Error("Could not find the desired stages to update within the store");
|
|
5692
5598
|
}
|
|
5693
5599
|
store.dispatch(updateStages(stagesToUpdate));
|
|
5694
|
-
return this.enqueueRequest({
|
|
5600
|
+
return this.client.enqueueRequest({
|
|
5695
5601
|
description: "Edit asset stages",
|
|
5696
5602
|
method: HttpMethod.PATCH,
|
|
5697
5603
|
url: `/assets/types/${assetTypeId}/bulk-update-stages/`,
|
|
@@ -5707,7 +5613,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5707
5613
|
}
|
|
5708
5614
|
async bulkDelete(idsToDelete) {
|
|
5709
5615
|
this.client.store.dispatch(removeStages(idsToDelete));
|
|
5710
|
-
return this.enqueueRequest({
|
|
5616
|
+
return this.client.enqueueRequest({
|
|
5711
5617
|
description: "Delete asset stages",
|
|
5712
5618
|
method: HttpMethod.DELETE,
|
|
5713
5619
|
url: "/assets/stages/bulk-delete/",
|
|
@@ -5720,7 +5626,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5720
5626
|
}
|
|
5721
5627
|
async update(assetStage) {
|
|
5722
5628
|
this.client.store.dispatch(addStages([assetStage]));
|
|
5723
|
-
return this.enqueueRequest({
|
|
5629
|
+
return this.client.enqueueRequest({
|
|
5724
5630
|
description: "Update asset stage",
|
|
5725
5631
|
method: HttpMethod.PATCH,
|
|
5726
5632
|
url: `/assets/stages/${assetStage.offline_id}/`,
|
|
@@ -5733,7 +5639,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5733
5639
|
const { store } = this.client;
|
|
5734
5640
|
store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
|
|
5735
5641
|
try {
|
|
5736
|
-
await this.enqueueRequest({
|
|
5642
|
+
await this.client.enqueueRequest({
|
|
5737
5643
|
description: "Link asset stage to form",
|
|
5738
5644
|
method: HttpMethod.POST,
|
|
5739
5645
|
url: `/assets/stages/${stageId}/associate-with-form/`,
|
|
@@ -5750,7 +5656,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5750
5656
|
const { store } = this.client;
|
|
5751
5657
|
store.dispatch(unlinkStageToForm({ stageId }));
|
|
5752
5658
|
try {
|
|
5753
|
-
await this.enqueueRequest({
|
|
5659
|
+
await this.client.enqueueRequest({
|
|
5754
5660
|
description: "Unlink asset stage from form",
|
|
5755
5661
|
method: HttpMethod.DELETE,
|
|
5756
5662
|
url: `/assets/stages/${stageId}/associate-with-form/`,
|
|
@@ -5764,7 +5670,7 @@ class AssetStageService extends BaseApiService {
|
|
|
5764
5670
|
}
|
|
5765
5671
|
async refreshStore() {
|
|
5766
5672
|
const { store } = this.client;
|
|
5767
|
-
const result = await this.enqueueRequest({
|
|
5673
|
+
const result = await this.client.enqueueRequest({
|
|
5768
5674
|
description: "Get asset stages",
|
|
5769
5675
|
method: HttpMethod.GET,
|
|
5770
5676
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/asset-stages/`,
|
|
@@ -5830,7 +5736,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5830
5736
|
}
|
|
5831
5737
|
processPresignedUrls(presignedUrls) {
|
|
5832
5738
|
for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
|
|
5833
|
-
void this.enqueueRequest({
|
|
5739
|
+
void this.client.enqueueRequest({
|
|
5834
5740
|
url: presignedUrl.url,
|
|
5835
5741
|
description: "Upload file to S3",
|
|
5836
5742
|
method: HttpMethod.POST,
|
|
@@ -5850,7 +5756,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5850
5756
|
const { store } = this.client;
|
|
5851
5757
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
5852
5758
|
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
5853
|
-
const result = await this.enqueueRequest({
|
|
5759
|
+
const result = await this.client.enqueueRequest({
|
|
5854
5760
|
description: `Get ${meta.name} attachments`,
|
|
5855
5761
|
method: HttpMethod.GET,
|
|
5856
5762
|
url: `/projects/${activeProjectId}${meta.fetchUrlPostfix}/`,
|
|
@@ -5895,7 +5801,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5895
5801
|
}
|
|
5896
5802
|
store.dispatch(actions.addAttachments(offlineAttachments));
|
|
5897
5803
|
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
5898
|
-
const promise = this.enqueueRequest({
|
|
5804
|
+
const promise = this.client.enqueueRequest({
|
|
5899
5805
|
description: `Attach files to ${meta.name}`,
|
|
5900
5806
|
method: HttpMethod.POST,
|
|
5901
5807
|
url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
|
|
@@ -5925,7 +5831,7 @@ class BaseAttachmentService extends BaseApiService {
|
|
|
5925
5831
|
}
|
|
5926
5832
|
store.dispatch(actions.removeAttachment(attachment.offline_id));
|
|
5927
5833
|
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
5928
|
-
const promise = this.enqueueRequest({
|
|
5834
|
+
const promise = this.client.enqueueRequest({
|
|
5929
5835
|
description: "Delete attachment",
|
|
5930
5836
|
method: HttpMethod.DELETE,
|
|
5931
5837
|
url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
|
|
@@ -5990,7 +5896,7 @@ class AssetTypeService extends BaseApiService {
|
|
|
5990
5896
|
const { store } = this.client;
|
|
5991
5897
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
5992
5898
|
store.dispatch(addAssetType(offlineAssetType));
|
|
5993
|
-
const promise = this.enqueueRequest({
|
|
5899
|
+
const promise = this.client.enqueueRequest({
|
|
5994
5900
|
description: "Create asset type",
|
|
5995
5901
|
method: HttpMethod.POST,
|
|
5996
5902
|
url: `/projects/${activeProjectId}/asset-types/`,
|
|
@@ -6002,7 +5908,7 @@ class AssetTypeService extends BaseApiService {
|
|
|
6002
5908
|
}
|
|
6003
5909
|
update(assetType) {
|
|
6004
5910
|
this.client.store.dispatch(addAssetType(assetType));
|
|
6005
|
-
return this.enqueueRequest({
|
|
5911
|
+
return this.client.enqueueRequest({
|
|
6006
5912
|
description: "Update asset type",
|
|
6007
5913
|
method: HttpMethod.PATCH,
|
|
6008
5914
|
url: `/assets/types/${assetType.offline_id}/`,
|
|
@@ -6029,7 +5935,7 @@ class AssetTypeService extends BaseApiService {
|
|
|
6029
5935
|
const attachmentsOfAssetTypeIds = attachmentsOfAssetType.map(({ offline_id }) => offline_id);
|
|
6030
5936
|
store.dispatch(removeAssetTypeAttachments(attachmentsOfAssetTypeIds));
|
|
6031
5937
|
}
|
|
6032
|
-
return this.enqueueRequest({
|
|
5938
|
+
return this.client.enqueueRequest({
|
|
6033
5939
|
description: "Delete asset type",
|
|
6034
5940
|
method: HttpMethod.DELETE,
|
|
6035
5941
|
url: `/assets/types/${assetTypeId}/`,
|
|
@@ -6044,7 +5950,7 @@ class AssetTypeService extends BaseApiService {
|
|
|
6044
5950
|
}
|
|
6045
5951
|
async refreshStore() {
|
|
6046
5952
|
const { store } = this.client;
|
|
6047
|
-
const result = await this.enqueueRequest({
|
|
5953
|
+
const result = await this.client.enqueueRequest({
|
|
6048
5954
|
description: "Get asset types",
|
|
6049
5955
|
method: HttpMethod.GET,
|
|
6050
5956
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/asset-types/`,
|
|
@@ -6111,7 +6017,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6111
6017
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
6112
6018
|
});
|
|
6113
6019
|
store.dispatch(addIssueComment(offlineComment));
|
|
6114
|
-
const promise = this.enqueueRequest({
|
|
6020
|
+
const promise = this.client.enqueueRequest({
|
|
6115
6021
|
description: `${truncate(comment.content, 80)}`,
|
|
6116
6022
|
method: HttpMethod.POST,
|
|
6117
6023
|
url: `/issues/${comment.issue}/comment/`,
|
|
@@ -6131,7 +6037,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6131
6037
|
throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
|
|
6132
6038
|
}
|
|
6133
6039
|
store.dispatch(setIssueComment(comment));
|
|
6134
|
-
const promise = this.enqueueRequest({
|
|
6040
|
+
const promise = this.client.enqueueRequest({
|
|
6135
6041
|
description: `Edit comment: ${truncate(comment.content, 80)}`,
|
|
6136
6042
|
method: HttpMethod.PATCH,
|
|
6137
6043
|
url: `/issues/comments/${comment.offline_id}/`,
|
|
@@ -6150,7 +6056,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6150
6056
|
throw new Error(`Comment with offline_id ${offline_id} not found in store`);
|
|
6151
6057
|
}
|
|
6152
6058
|
this.client.store.dispatch(removeIssueComment(offline_id));
|
|
6153
|
-
const promise = this.enqueueRequest({
|
|
6059
|
+
const promise = this.client.enqueueRequest({
|
|
6154
6060
|
description: "Delete comment",
|
|
6155
6061
|
method: HttpMethod.DELETE,
|
|
6156
6062
|
url: `/issues/comments/${offline_id}/`,
|
|
@@ -6164,7 +6070,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6164
6070
|
}
|
|
6165
6071
|
async refreshStore() {
|
|
6166
6072
|
const { store } = this.client;
|
|
6167
|
-
const result = await this.enqueueRequest({
|
|
6073
|
+
const result = await this.client.enqueueRequest({
|
|
6168
6074
|
description: "Get comments",
|
|
6169
6075
|
method: HttpMethod.GET,
|
|
6170
6076
|
// TODO: Choose between /issues/comments/in-project/${projectId}/ and /projects/${projectId}/issue-comments/
|
|
@@ -6178,7 +6084,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
6178
6084
|
class IssueUpdateService extends BaseApiService {
|
|
6179
6085
|
async refreshStore() {
|
|
6180
6086
|
const { store } = this.client;
|
|
6181
|
-
const result = await this.enqueueRequest({
|
|
6087
|
+
const result = await this.client.enqueueRequest({
|
|
6182
6088
|
description: "Get issue updates",
|
|
6183
6089
|
method: HttpMethod.GET,
|
|
6184
6090
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/issues/updates/`,
|
|
@@ -6264,7 +6170,7 @@ class IssueService extends BaseApiService {
|
|
|
6264
6170
|
store.dispatch(addIssue(issuePayload));
|
|
6265
6171
|
store.dispatch(addToRecentIssues(issuePayload.offline_id));
|
|
6266
6172
|
store.dispatch(addActiveProjectIssuesCount(1));
|
|
6267
|
-
const promise = this.enqueueRequest({
|
|
6173
|
+
const promise = this.client.enqueueRequest({
|
|
6268
6174
|
description: "Create issue",
|
|
6269
6175
|
method: HttpMethod.POST,
|
|
6270
6176
|
url: "/issues/",
|
|
@@ -6299,7 +6205,7 @@ class IssueService extends BaseApiService {
|
|
|
6299
6205
|
return [issuePayload, promise];
|
|
6300
6206
|
}
|
|
6301
6207
|
fetchAll(projectId) {
|
|
6302
|
-
const promise = this.enqueueRequest({
|
|
6208
|
+
const promise = this.client.enqueueRequest({
|
|
6303
6209
|
description: "Get issues",
|
|
6304
6210
|
method: HttpMethod.GET,
|
|
6305
6211
|
url: `/projects/${projectId}/issues/`,
|
|
@@ -6396,7 +6302,7 @@ class IssueService extends BaseApiService {
|
|
|
6396
6302
|
changes
|
|
6397
6303
|
});
|
|
6398
6304
|
this.client.store.dispatch(addIssueUpdate(offlineIssueUpdate));
|
|
6399
|
-
const promise = this.enqueueRequest({
|
|
6305
|
+
const promise = this.client.enqueueRequest({
|
|
6400
6306
|
description: "Edit issue",
|
|
6401
6307
|
method: HttpMethod.PATCH,
|
|
6402
6308
|
url: `/issues/${issue.offline_id}/`,
|
|
@@ -6429,7 +6335,7 @@ class IssueService extends BaseApiService {
|
|
|
6429
6335
|
if (updatesOfIssue.length > 0)
|
|
6430
6336
|
dispatch(removeIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
|
|
6431
6337
|
try {
|
|
6432
|
-
return await this.enqueueRequest({
|
|
6338
|
+
return await this.client.enqueueRequest({
|
|
6433
6339
|
description: "Delete issue",
|
|
6434
6340
|
method: HttpMethod.DELETE,
|
|
6435
6341
|
url: `/issues/${id}/`,
|
|
@@ -6471,7 +6377,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6471
6377
|
organization: activeOrganizationId
|
|
6472
6378
|
});
|
|
6473
6379
|
store.dispatch(addIssueType(offlineIssueType));
|
|
6474
|
-
const promise = this.enqueueRequest({
|
|
6380
|
+
const promise = this.client.enqueueRequest({
|
|
6475
6381
|
method: HttpMethod.POST,
|
|
6476
6382
|
url: `/organizations/${activeOrganizationId}/issue-types/`,
|
|
6477
6383
|
// Sending only whats needed here
|
|
@@ -6504,7 +6410,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6504
6410
|
...issueTypeFields
|
|
6505
6411
|
};
|
|
6506
6412
|
store.dispatch(updateIssueType(offlineUpdatedIssueType));
|
|
6507
|
-
const promise = this.enqueueRequest({
|
|
6413
|
+
const promise = this.client.enqueueRequest({
|
|
6508
6414
|
method: HttpMethod.PATCH,
|
|
6509
6415
|
url: `/issues/types/${issueTypeFields.offline_id}/`,
|
|
6510
6416
|
payload: issueTypeFields,
|
|
@@ -6528,7 +6434,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6528
6434
|
const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state) ?? [];
|
|
6529
6435
|
store.dispatch(removeIssueType(issueTypeId));
|
|
6530
6436
|
store.dispatch(removeIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
|
|
6531
|
-
const promise = this.enqueueRequest({
|
|
6437
|
+
const promise = this.client.enqueueRequest({
|
|
6532
6438
|
method: HttpMethod.DELETE,
|
|
6533
6439
|
url: `/issues/types/${issueTypeId}/`,
|
|
6534
6440
|
blockers: [issueTypeId],
|
|
@@ -6546,7 +6452,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
6546
6452
|
if (!activeOrganizationId) {
|
|
6547
6453
|
throw new Error(`No active organization, got ${activeOrganizationId} for activeOrganizationId.`);
|
|
6548
6454
|
}
|
|
6549
|
-
const result = await this.enqueueRequest({
|
|
6455
|
+
const result = await this.client.enqueueRequest({
|
|
6550
6456
|
method: HttpMethod.GET,
|
|
6551
6457
|
url: `/organizations/${activeOrganizationId}/issue-types/`,
|
|
6552
6458
|
blockers: [],
|
|
@@ -6560,7 +6466,7 @@ class MainService extends BaseApiService {
|
|
|
6560
6466
|
if (replaceExisting) {
|
|
6561
6467
|
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
6562
6468
|
}
|
|
6563
|
-
const result = await this.enqueueRequest({
|
|
6469
|
+
const result = await this.client.enqueueRequest({
|
|
6564
6470
|
uuid,
|
|
6565
6471
|
description: "Get initial data",
|
|
6566
6472
|
method: HttpMethod.GET,
|
|
@@ -6574,7 +6480,7 @@ class MainService extends BaseApiService {
|
|
|
6574
6480
|
}
|
|
6575
6481
|
async fetchProjectUsers() {
|
|
6576
6482
|
const projectId = this.client.store.getState().projectReducer.activeProjectId;
|
|
6577
|
-
return this.enqueueRequest({
|
|
6483
|
+
return this.client.enqueueRequest({
|
|
6578
6484
|
description: "Fetch users",
|
|
6579
6485
|
method: HttpMethod.GET,
|
|
6580
6486
|
url: `/projects/${projectId}/users/`,
|
|
@@ -6586,7 +6492,7 @@ class MainService extends BaseApiService {
|
|
|
6586
6492
|
});
|
|
6587
6493
|
}
|
|
6588
6494
|
async fetchOrganizationUsers(orgId) {
|
|
6589
|
-
return this.enqueueRequest({
|
|
6495
|
+
return this.client.enqueueRequest({
|
|
6590
6496
|
description: "Fetch organization users",
|
|
6591
6497
|
method: HttpMethod.GET,
|
|
6592
6498
|
url: `/organizations/${orgId}/users/`,
|
|
@@ -6727,7 +6633,7 @@ class MainService extends BaseApiService {
|
|
|
6727
6633
|
}
|
|
6728
6634
|
class ProjectAccessService extends BaseApiService {
|
|
6729
6635
|
async fetchAll(projectId) {
|
|
6730
|
-
return this.enqueueRequest({
|
|
6636
|
+
return this.client.enqueueRequest({
|
|
6731
6637
|
description: "Get project accesses",
|
|
6732
6638
|
method: HttpMethod.GET,
|
|
6733
6639
|
url: `/projects/${projectId}/access/`,
|
|
@@ -6737,7 +6643,7 @@ class ProjectAccessService extends BaseApiService {
|
|
|
6737
6643
|
}
|
|
6738
6644
|
async update(projectAccess) {
|
|
6739
6645
|
this.client.store.dispatch(updateProjectAccess(projectAccess));
|
|
6740
|
-
return this.enqueueRequest({
|
|
6646
|
+
return this.client.enqueueRequest({
|
|
6741
6647
|
description: "Edit project access",
|
|
6742
6648
|
method: HttpMethod.PATCH,
|
|
6743
6649
|
url: `/access/${projectAccess.offline_id}/`,
|
|
@@ -6750,7 +6656,7 @@ class ProjectAccessService extends BaseApiService {
|
|
|
6750
6656
|
async remove(projectAccess) {
|
|
6751
6657
|
const { store } = this.client;
|
|
6752
6658
|
store.dispatch(removeProjectAccess(projectAccess));
|
|
6753
|
-
return this.enqueueRequest({
|
|
6659
|
+
return this.client.enqueueRequest({
|
|
6754
6660
|
description: "Delete project access",
|
|
6755
6661
|
method: HttpMethod.DELETE,
|
|
6756
6662
|
url: `/access/${projectAccess.offline_id}/`,
|
|
@@ -6773,7 +6679,7 @@ class ProjectAccessService extends BaseApiService {
|
|
|
6773
6679
|
class ProjectFileService extends BaseApiService {
|
|
6774
6680
|
async refreshStore() {
|
|
6775
6681
|
const { store } = this.client;
|
|
6776
|
-
const result = await this.enqueueRequest({
|
|
6682
|
+
const result = await this.client.enqueueRequest({
|
|
6777
6683
|
description: "Get project files",
|
|
6778
6684
|
method: HttpMethod.GET,
|
|
6779
6685
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/files/`,
|
|
@@ -6790,7 +6696,7 @@ class ProjectFileService extends BaseApiService {
|
|
|
6790
6696
|
}
|
|
6791
6697
|
const editableData = { ...file };
|
|
6792
6698
|
delete editableData.file;
|
|
6793
|
-
const promise = this.enqueueRequest({
|
|
6699
|
+
const promise = this.client.enqueueRequest({
|
|
6794
6700
|
method: HttpMethod.PATCH,
|
|
6795
6701
|
url: `/projects/files/${file.offline_id}/`,
|
|
6796
6702
|
payload: editableData,
|
|
@@ -6848,7 +6754,7 @@ class ProjectFileService extends BaseApiService {
|
|
|
6848
6754
|
});
|
|
6849
6755
|
}
|
|
6850
6756
|
const promise = Promise.resolve(requestDetails).then((requestDetails2) => {
|
|
6851
|
-
return this.enqueueRequest(requestDetails2);
|
|
6757
|
+
return this.client.enqueueRequest(requestDetails2);
|
|
6852
6758
|
});
|
|
6853
6759
|
void promise.then((result) => {
|
|
6854
6760
|
store.dispatch(addOrReplaceProjectFile(result));
|
|
@@ -6860,7 +6766,7 @@ class ProjectFileService extends BaseApiService {
|
|
|
6860
6766
|
}
|
|
6861
6767
|
delete(projectFileId) {
|
|
6862
6768
|
this.client.store.dispatch(removeProjectFile(projectFileId));
|
|
6863
|
-
return this.enqueueRequest({
|
|
6769
|
+
return this.client.enqueueRequest({
|
|
6864
6770
|
method: HttpMethod.DELETE,
|
|
6865
6771
|
url: `/projects/files/${projectFileId}`,
|
|
6866
6772
|
blockers: [projectFileId],
|
|
@@ -6931,7 +6837,7 @@ class ProjectService extends BaseApiService {
|
|
|
6931
6837
|
}
|
|
6932
6838
|
const url = isOrganizationProject ? `/organizations/${project.owner_organization}/projects/` : "/projects/";
|
|
6933
6839
|
const projectType = isOrganizationProject ? { organization_owner: project.owner_organization } : { user_owner: project.owner_user };
|
|
6934
|
-
const result = await this.enqueueRequest({
|
|
6840
|
+
const result = await this.client.enqueueRequest({
|
|
6935
6841
|
description: "Create project",
|
|
6936
6842
|
method: HttpMethod.POST,
|
|
6937
6843
|
url,
|
|
@@ -6955,7 +6861,7 @@ class ProjectService extends BaseApiService {
|
|
|
6955
6861
|
throw new Error("Project bounds were not set before trying to create a project");
|
|
6956
6862
|
}
|
|
6957
6863
|
store.dispatch(updateOrCreateProject(project));
|
|
6958
|
-
return await this.enqueueRequest({
|
|
6864
|
+
return await this.client.enqueueRequest({
|
|
6959
6865
|
description: "Update project",
|
|
6960
6866
|
method: HttpMethod.PATCH,
|
|
6961
6867
|
url: `/projects/${project.id}/`,
|
|
@@ -6995,7 +6901,7 @@ class ProjectService extends BaseApiService {
|
|
|
6995
6901
|
store.dispatch(updateLicense({ ...license, project: null }));
|
|
6996
6902
|
}
|
|
6997
6903
|
try {
|
|
6998
|
-
await this.enqueueRequest({
|
|
6904
|
+
await this.client.enqueueRequest({
|
|
6999
6905
|
description: "Delete project",
|
|
7000
6906
|
method: HttpMethod.DELETE,
|
|
7001
6907
|
url: `/projects/${projectId}/`,
|
|
@@ -7018,7 +6924,7 @@ class ProjectService extends BaseApiService {
|
|
|
7018
6924
|
}
|
|
7019
6925
|
invite(projectId, email) {
|
|
7020
6926
|
const offline_id = v4();
|
|
7021
|
-
return this.enqueueRequest({
|
|
6927
|
+
return this.client.enqueueRequest({
|
|
7022
6928
|
description: "Invite user to project",
|
|
7023
6929
|
method: HttpMethod.POST,
|
|
7024
6930
|
url: `/projects/${projectId}/invite/${email}/`,
|
|
@@ -7030,7 +6936,7 @@ class ProjectService extends BaseApiService {
|
|
|
7030
6936
|
});
|
|
7031
6937
|
}
|
|
7032
6938
|
joinProject(projectId, userId, inviteCode) {
|
|
7033
|
-
return this.enqueueRequest({
|
|
6939
|
+
return this.client.enqueueRequest({
|
|
7034
6940
|
description: "Join project",
|
|
7035
6941
|
method: HttpMethod.GET,
|
|
7036
6942
|
url: `/projects/${projectId}/join-project/${userId}/${inviteCode}/`,
|
|
@@ -7040,7 +6946,7 @@ class ProjectService extends BaseApiService {
|
|
|
7040
6946
|
});
|
|
7041
6947
|
}
|
|
7042
6948
|
async acceptInvite(projectId) {
|
|
7043
|
-
return this.enqueueRequest({
|
|
6949
|
+
return this.client.enqueueRequest({
|
|
7044
6950
|
description: "Accept project invite",
|
|
7045
6951
|
method: HttpMethod.PATCH,
|
|
7046
6952
|
url: `/projects/${projectId}/accept-invite/`,
|
|
@@ -7099,7 +7005,7 @@ class UserFormService extends BaseApiService {
|
|
|
7099
7005
|
revision: offlineRevisionId,
|
|
7100
7006
|
field_identifier: key
|
|
7101
7007
|
});
|
|
7102
|
-
const attach = await this.enqueueRequest({
|
|
7008
|
+
const attach = await this.client.enqueueRequest({
|
|
7103
7009
|
description: "Attach image to form revision field",
|
|
7104
7010
|
method: HttpMethod.POST,
|
|
7105
7011
|
url: `/forms/revisions/${offlineRevisionId}/attachments/`,
|
|
@@ -7150,7 +7056,7 @@ class UserFormService extends BaseApiService {
|
|
|
7150
7056
|
const { store } = this.client;
|
|
7151
7057
|
store.dispatch(addForm(retForm));
|
|
7152
7058
|
store.dispatch(addFormRevision(retRevision));
|
|
7153
|
-
const formPromise = this.enqueueRequest({
|
|
7059
|
+
const formPromise = this.client.enqueueRequest({
|
|
7154
7060
|
description: "Create form",
|
|
7155
7061
|
method: HttpMethod.POST,
|
|
7156
7062
|
url,
|
|
@@ -7222,7 +7128,7 @@ class UserFormService extends BaseApiService {
|
|
|
7222
7128
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7223
7129
|
};
|
|
7224
7130
|
store.dispatch(addFormRevision(fullRevision));
|
|
7225
|
-
const promise = this.enqueueRequest({
|
|
7131
|
+
const promise = this.client.enqueueRequest({
|
|
7226
7132
|
description: "Create form revision",
|
|
7227
7133
|
method: HttpMethod.PATCH,
|
|
7228
7134
|
url: `/forms/${formId2}/`,
|
|
@@ -7247,7 +7153,7 @@ class UserFormService extends BaseApiService {
|
|
|
7247
7153
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7248
7154
|
store.dispatch(favoriteForm({ formId: formId2 }));
|
|
7249
7155
|
try {
|
|
7250
|
-
await this.enqueueRequest({
|
|
7156
|
+
await this.client.enqueueRequest({
|
|
7251
7157
|
description: "Favorite form",
|
|
7252
7158
|
method: HttpMethod.POST,
|
|
7253
7159
|
url: `/forms/${formId2}/favorite/${activeProjectId}/`,
|
|
@@ -7264,7 +7170,7 @@ class UserFormService extends BaseApiService {
|
|
|
7264
7170
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7265
7171
|
store.dispatch(unfavoriteForm({ formId: formId2 }));
|
|
7266
7172
|
try {
|
|
7267
|
-
return await this.enqueueRequest({
|
|
7173
|
+
return await this.client.enqueueRequest({
|
|
7268
7174
|
description: "Unfavorite form",
|
|
7269
7175
|
method: HttpMethod.DELETE,
|
|
7270
7176
|
url: `/forms/${formId2}/unfavorite/${activeProjectId}/`,
|
|
@@ -7293,7 +7199,7 @@ class UserFormService extends BaseApiService {
|
|
|
7293
7199
|
}
|
|
7294
7200
|
store.dispatch(deleteForm(formId2));
|
|
7295
7201
|
try {
|
|
7296
|
-
return await this.enqueueRequest({
|
|
7202
|
+
return await this.client.enqueueRequest({
|
|
7297
7203
|
description: "Delete form",
|
|
7298
7204
|
method: HttpMethod.DELETE,
|
|
7299
7205
|
url: `/forms/${formId2}/`,
|
|
@@ -7313,7 +7219,7 @@ class UserFormService extends BaseApiService {
|
|
|
7313
7219
|
}
|
|
7314
7220
|
async refreshStore() {
|
|
7315
7221
|
const { store } = this.client;
|
|
7316
|
-
const result = await this.enqueueRequest({
|
|
7222
|
+
const result = await this.client.enqueueRequest({
|
|
7317
7223
|
description: "Fetch user forms",
|
|
7318
7224
|
method: HttpMethod.GET,
|
|
7319
7225
|
url: `/forms/in-project/${store.getState().projectReducer.activeProjectId}/forms/`,
|
|
@@ -7362,7 +7268,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7362
7268
|
submission: submission.offline_id,
|
|
7363
7269
|
field_identifier: key
|
|
7364
7270
|
});
|
|
7365
|
-
const attach = await this.enqueueRequest({
|
|
7271
|
+
const attach = await this.client.enqueueRequest({
|
|
7366
7272
|
description: "Attach file to form submission",
|
|
7367
7273
|
method: HttpMethod.POST,
|
|
7368
7274
|
url: `/forms/submission/${submission.offline_id}/attachments/`,
|
|
@@ -7400,7 +7306,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7400
7306
|
created_by: state.userReducer.currentUser.id,
|
|
7401
7307
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7402
7308
|
};
|
|
7403
|
-
const promise = this.enqueueRequest({
|
|
7309
|
+
const promise = this.client.enqueueRequest({
|
|
7404
7310
|
description: "Respond to form",
|
|
7405
7311
|
method: HttpMethod.POST,
|
|
7406
7312
|
url: `/forms/revisions/${payload.form_revision}/respond/`,
|
|
@@ -7481,7 +7387,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7481
7387
|
}
|
|
7482
7388
|
store.dispatch(addFormSubmissions(offlineSubmissions));
|
|
7483
7389
|
store.dispatch(addFormSubmissionAttachments(offlineAttachments));
|
|
7484
|
-
const promise = this.enqueueRequest({
|
|
7390
|
+
const promise = this.client.enqueueRequest({
|
|
7485
7391
|
description: "Bulk add form submissions",
|
|
7486
7392
|
method: HttpMethod.POST,
|
|
7487
7393
|
url: `/forms/revisions/${formRevision}/bulk-respond/`,
|
|
@@ -7502,7 +7408,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7502
7408
|
const file = filesRecord[sha1];
|
|
7503
7409
|
if (!file)
|
|
7504
7410
|
continue;
|
|
7505
|
-
void this.enqueueRequest({
|
|
7411
|
+
void this.client.enqueueRequest({
|
|
7506
7412
|
url: presigned_url.url,
|
|
7507
7413
|
description: "Upload file",
|
|
7508
7414
|
method: HttpMethod.POST,
|
|
@@ -7530,7 +7436,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7530
7436
|
};
|
|
7531
7437
|
const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
|
|
7532
7438
|
store.dispatch(updateFormSubmission(offlineSubmission));
|
|
7533
|
-
const promise = this.enqueueRequest({
|
|
7439
|
+
const promise = this.client.enqueueRequest({
|
|
7534
7440
|
description: "Patch form submission",
|
|
7535
7441
|
method: HttpMethod.PATCH,
|
|
7536
7442
|
url: `/forms/submissions/${submission.offline_id}/`,
|
|
@@ -7556,7 +7462,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7556
7462
|
store.dispatch(addActiveProjectFormSubmissionsCount(-1));
|
|
7557
7463
|
store.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
|
|
7558
7464
|
try {
|
|
7559
|
-
return await this.enqueueRequest({
|
|
7465
|
+
return await this.client.enqueueRequest({
|
|
7560
7466
|
description: "Delete user form submissions",
|
|
7561
7467
|
method: HttpMethod.DELETE,
|
|
7562
7468
|
url: `/forms/submissions/${submissionId}/`,
|
|
@@ -7573,7 +7479,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7573
7479
|
async refreshStore() {
|
|
7574
7480
|
const { store } = this.client;
|
|
7575
7481
|
const projectId = store.getState().projectReducer.activeProjectId;
|
|
7576
|
-
const submissions = await this.enqueueRequest({
|
|
7482
|
+
const submissions = await this.client.enqueueRequest({
|
|
7577
7483
|
description: "Fetch form submissions",
|
|
7578
7484
|
method: HttpMethod.GET,
|
|
7579
7485
|
url: `/forms/in-project/${projectId}/submissions/`,
|
|
@@ -7581,7 +7487,7 @@ class UserFormSubmissionService extends BaseApiService {
|
|
|
7581
7487
|
blocks: []
|
|
7582
7488
|
});
|
|
7583
7489
|
store.dispatch(setFormSubmissions(submissions));
|
|
7584
|
-
const attachments = await this.enqueueRequest({
|
|
7490
|
+
const attachments = await this.client.enqueueRequest({
|
|
7585
7491
|
description: "Fetch form attachments",
|
|
7586
7492
|
method: HttpMethod.GET,
|
|
7587
7493
|
url: `/forms/in-project/${projectId}/attachments/`,
|
|
@@ -7596,7 +7502,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7596
7502
|
const { store } = this.client;
|
|
7597
7503
|
const offlineWorkspace = offline(workspace);
|
|
7598
7504
|
store.dispatch(addWorkspace(offlineWorkspace));
|
|
7599
|
-
const promise = this.enqueueRequest({
|
|
7505
|
+
const promise = this.client.enqueueRequest({
|
|
7600
7506
|
description: "Create Workspace",
|
|
7601
7507
|
method: HttpMethod.POST,
|
|
7602
7508
|
url: `/projects/${store.getState().projectReducer.activeProjectId}/workspaces/`,
|
|
@@ -7614,7 +7520,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7614
7520
|
update(workspace) {
|
|
7615
7521
|
const { store } = this.client;
|
|
7616
7522
|
store.dispatch(addOrReplaceWorkspaces({ [workspace.offline_id]: workspace }));
|
|
7617
|
-
const promise = this.enqueueRequest({
|
|
7523
|
+
const promise = this.client.enqueueRequest({
|
|
7618
7524
|
description: "Update Workspace",
|
|
7619
7525
|
method: HttpMethod.PATCH,
|
|
7620
7526
|
url: `/workspaces/${workspace.offline_id}/`,
|
|
@@ -7626,7 +7532,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7626
7532
|
}
|
|
7627
7533
|
delete(workspaceId) {
|
|
7628
7534
|
const { store } = this.client;
|
|
7629
|
-
const promise = this.enqueueRequest({
|
|
7535
|
+
const promise = this.client.enqueueRequest({
|
|
7630
7536
|
description: "Delete Workspace",
|
|
7631
7537
|
method: HttpMethod.DELETE,
|
|
7632
7538
|
url: `/workspaces/${workspaceId}/`,
|
|
@@ -7648,7 +7554,7 @@ class WorkspaceService extends BaseApiService {
|
|
|
7648
7554
|
}
|
|
7649
7555
|
class OrganizationAccessService extends BaseApiService {
|
|
7650
7556
|
async update(organizationAccess) {
|
|
7651
|
-
const promise = this.enqueueRequest({
|
|
7557
|
+
const promise = this.client.enqueueRequest({
|
|
7652
7558
|
description: "Edit organization access",
|
|
7653
7559
|
method: HttpMethod.PATCH,
|
|
7654
7560
|
url: `/organizations/${organizationAccess.organization}/access/${organizationAccess.offline_id}/`,
|
|
@@ -7664,7 +7570,7 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
7664
7570
|
async remove(organizationAccess) {
|
|
7665
7571
|
this.client.store.dispatch(removeOrganizationAccess(organizationAccess));
|
|
7666
7572
|
this.client.store.dispatch(removeUser(organizationAccess.user));
|
|
7667
|
-
return this.enqueueRequest({
|
|
7573
|
+
return this.client.enqueueRequest({
|
|
7668
7574
|
description: "Remove organization access",
|
|
7669
7575
|
method: HttpMethod.DELETE,
|
|
7670
7576
|
url: `/organizations/${organizationAccess.organization}/access/${organizationAccess.offline_id}/`,
|
|
@@ -7679,7 +7585,7 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
7679
7585
|
if (!organizationId) {
|
|
7680
7586
|
return;
|
|
7681
7587
|
}
|
|
7682
|
-
const result = await this.enqueueRequest({
|
|
7588
|
+
const result = await this.client.enqueueRequest({
|
|
7683
7589
|
description: "Get organization accesses",
|
|
7684
7590
|
method: HttpMethod.GET,
|
|
7685
7591
|
url: `/organizations/${organizationId}/access/`,
|
|
@@ -7711,7 +7617,7 @@ class FileService extends BaseApiService {
|
|
|
7711
7617
|
if (!file)
|
|
7712
7618
|
throw new Error(`File with sha1 ${sha1} not found in cache`);
|
|
7713
7619
|
const key = await getFileS3Key(file, sha1);
|
|
7714
|
-
const s3UploadUrl = await this.enqueueRequest({
|
|
7620
|
+
const s3UploadUrl = await this.client.enqueueRequest({
|
|
7715
7621
|
description: "Get S3 URL",
|
|
7716
7622
|
method: HttpMethod.GET,
|
|
7717
7623
|
url: "/authentication/files/presigned-upload-url/",
|
|
@@ -7795,7 +7701,7 @@ class FileService extends BaseApiService {
|
|
|
7795
7701
|
throw new Error(fileUploadUrlResponse.warning);
|
|
7796
7702
|
}
|
|
7797
7703
|
const url = fileUploadUrlResponse.url;
|
|
7798
|
-
const promise = this.enqueueRequest({
|
|
7704
|
+
const promise = this.client.enqueueRequest({
|
|
7799
7705
|
url,
|
|
7800
7706
|
description: "Upload file",
|
|
7801
7707
|
method: HttpMethod.POST,
|
|
@@ -7837,7 +7743,7 @@ class FileService extends BaseApiService {
|
|
|
7837
7743
|
let isFirstRequest = true;
|
|
7838
7744
|
if (!promise) {
|
|
7839
7745
|
promise = new Promise((resolve) => {
|
|
7840
|
-
void this.enqueueRequest({
|
|
7746
|
+
void this.client.enqueueRequest({
|
|
7841
7747
|
description: "Download file",
|
|
7842
7748
|
method: HttpMethod.GET,
|
|
7843
7749
|
url,
|
|
@@ -7905,7 +7811,7 @@ class EmailVerificationService extends BaseApiService {
|
|
|
7905
7811
|
blockers: [],
|
|
7906
7812
|
blocks: []
|
|
7907
7813
|
};
|
|
7908
|
-
return this.enqueueRequest(requestDetails);
|
|
7814
|
+
return this.client.enqueueRequest(requestDetails);
|
|
7909
7815
|
}
|
|
7910
7816
|
validateVerificationCode(verificationCode, payload = void 0) {
|
|
7911
7817
|
const requestDetails = {
|
|
@@ -7917,12 +7823,12 @@ class EmailVerificationService extends BaseApiService {
|
|
|
7917
7823
|
blockers: [],
|
|
7918
7824
|
blocks: []
|
|
7919
7825
|
};
|
|
7920
|
-
return this.enqueueRequest(requestDetails);
|
|
7826
|
+
return this.client.enqueueRequest(requestDetails);
|
|
7921
7827
|
}
|
|
7922
7828
|
}
|
|
7923
7829
|
class EmailDomainsService extends BaseApiService {
|
|
7924
7830
|
async fetchAll(orgId) {
|
|
7925
|
-
return this.enqueueRequest({
|
|
7831
|
+
return this.client.enqueueRequest({
|
|
7926
7832
|
description: "Fetch email domains for organization",
|
|
7927
7833
|
method: HttpMethod.GET,
|
|
7928
7834
|
url: `/organizations/${orgId}/email-domains/`,
|
|
@@ -7931,7 +7837,7 @@ class EmailDomainsService extends BaseApiService {
|
|
|
7931
7837
|
});
|
|
7932
7838
|
}
|
|
7933
7839
|
async add(orgId, email) {
|
|
7934
|
-
return this.enqueueRequest({
|
|
7840
|
+
return this.client.enqueueRequest({
|
|
7935
7841
|
description: "Add email domain to organization",
|
|
7936
7842
|
method: HttpMethod.POST,
|
|
7937
7843
|
url: `/organizations/${orgId}/email-domains/`,
|
|
@@ -7942,7 +7848,7 @@ class EmailDomainsService extends BaseApiService {
|
|
|
7942
7848
|
}
|
|
7943
7849
|
async remove(emailDomain) {
|
|
7944
7850
|
this.client.store.dispatch(removeEmailDomain(emailDomain));
|
|
7945
|
-
return this.enqueueRequest({
|
|
7851
|
+
return this.client.enqueueRequest({
|
|
7946
7852
|
description: "Remove email domain from organization",
|
|
7947
7853
|
method: HttpMethod.DELETE,
|
|
7948
7854
|
url: `/organizations/${emailDomain.organization}/email-domains/${emailDomain.offline_id}/`,
|
|
@@ -7968,7 +7874,7 @@ class OrganizationService extends BaseApiService {
|
|
|
7968
7874
|
if (showLoading) {
|
|
7969
7875
|
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
7970
7876
|
}
|
|
7971
|
-
return this.enqueueRequest({
|
|
7877
|
+
return this.client.enqueueRequest({
|
|
7972
7878
|
description: "Get initial organization data",
|
|
7973
7879
|
method: HttpMethod.GET,
|
|
7974
7880
|
url: `/organizations/${organizationId}/initial-data/`,
|
|
@@ -7996,7 +7902,7 @@ class OrganizationService extends BaseApiService {
|
|
|
7996
7902
|
}
|
|
7997
7903
|
}
|
|
7998
7904
|
async create(name) {
|
|
7999
|
-
const result = await this.enqueueRequest({
|
|
7905
|
+
const result = await this.client.enqueueRequest({
|
|
8000
7906
|
description: "Create organization",
|
|
8001
7907
|
method: HttpMethod.POST,
|
|
8002
7908
|
url: "/organizations/",
|
|
@@ -8008,7 +7914,7 @@ class OrganizationService extends BaseApiService {
|
|
|
8008
7914
|
return result;
|
|
8009
7915
|
}
|
|
8010
7916
|
async update(organization) {
|
|
8011
|
-
const promise = this.enqueueRequest({
|
|
7917
|
+
const promise = this.client.enqueueRequest({
|
|
8012
7918
|
description: "Edit organization",
|
|
8013
7919
|
method: HttpMethod.PATCH,
|
|
8014
7920
|
url: `/organizations/${organization.id}/`,
|
|
@@ -8022,7 +7928,7 @@ class OrganizationService extends BaseApiService {
|
|
|
8022
7928
|
});
|
|
8023
7929
|
}
|
|
8024
7930
|
async invite(organizationId, email) {
|
|
8025
|
-
return this.enqueueRequest({
|
|
7931
|
+
return this.client.enqueueRequest({
|
|
8026
7932
|
description: "Invite user to organization",
|
|
8027
7933
|
method: HttpMethod.POST,
|
|
8028
7934
|
url: `/organizations/${organizationId}/invite/${email}/`,
|
|
@@ -8036,7 +7942,7 @@ class LicenseService extends BaseApiService {
|
|
|
8036
7942
|
if (showLoading) {
|
|
8037
7943
|
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
8038
7944
|
}
|
|
8039
|
-
const result = await this.enqueueRequest({
|
|
7945
|
+
const result = await this.client.enqueueRequest({
|
|
8040
7946
|
description: "Get licenses",
|
|
8041
7947
|
method: HttpMethod.GET,
|
|
8042
7948
|
url: `/organizations/${organizationId}/licenses/`,
|
|
@@ -8051,7 +7957,7 @@ class LicenseService extends BaseApiService {
|
|
|
8051
7957
|
return result;
|
|
8052
7958
|
}
|
|
8053
7959
|
async getLicense(license) {
|
|
8054
|
-
const result = await this.enqueueRequest({
|
|
7960
|
+
const result = await this.client.enqueueRequest({
|
|
8055
7961
|
description: "Get license",
|
|
8056
7962
|
method: HttpMethod.GET,
|
|
8057
7963
|
url: `/billing/${license.offline_id}/`,
|
|
@@ -8065,7 +7971,7 @@ class LicenseService extends BaseApiService {
|
|
|
8065
7971
|
return result;
|
|
8066
7972
|
}
|
|
8067
7973
|
async pauseLicense(license) {
|
|
8068
|
-
const result = await this.enqueueRequest({
|
|
7974
|
+
const result = await this.client.enqueueRequest({
|
|
8069
7975
|
description: "Pause license",
|
|
8070
7976
|
method: HttpMethod.DELETE,
|
|
8071
7977
|
url: `/billing/${license.offline_id}/suspend/`,
|
|
@@ -8079,7 +7985,7 @@ class LicenseService extends BaseApiService {
|
|
|
8079
7985
|
return result;
|
|
8080
7986
|
}
|
|
8081
7987
|
async resumeLicense(license) {
|
|
8082
|
-
const result = await this.enqueueRequest({
|
|
7988
|
+
const result = await this.client.enqueueRequest({
|
|
8083
7989
|
description: "Resume license",
|
|
8084
7990
|
method: HttpMethod.PATCH,
|
|
8085
7991
|
url: `/billing/${license.offline_id}/suspend/`,
|
|
@@ -8093,7 +7999,7 @@ class LicenseService extends BaseApiService {
|
|
|
8093
7999
|
return result;
|
|
8094
8000
|
}
|
|
8095
8001
|
async cancelLicense(license) {
|
|
8096
|
-
const result = await this.enqueueRequest({
|
|
8002
|
+
const result = await this.client.enqueueRequest({
|
|
8097
8003
|
description: "Cancel license",
|
|
8098
8004
|
method: HttpMethod.DELETE,
|
|
8099
8005
|
url: `/billing/${license.offline_id}/`,
|
|
@@ -8107,7 +8013,7 @@ class LicenseService extends BaseApiService {
|
|
|
8107
8013
|
return result;
|
|
8108
8014
|
}
|
|
8109
8015
|
async attachLicenseToProject(license, project) {
|
|
8110
|
-
const result = await this.enqueueRequest({
|
|
8016
|
+
const result = await this.client.enqueueRequest({
|
|
8111
8017
|
description: "Attach license",
|
|
8112
8018
|
method: HttpMethod.PATCH,
|
|
8113
8019
|
url: `/billing/${license.offline_id}/project/`,
|
|
@@ -8123,7 +8029,7 @@ class LicenseService extends BaseApiService {
|
|
|
8123
8029
|
return result;
|
|
8124
8030
|
}
|
|
8125
8031
|
async detachLicenseFromProject(license) {
|
|
8126
|
-
const result = await this.enqueueRequest({
|
|
8032
|
+
const result = await this.client.enqueueRequest({
|
|
8127
8033
|
description: "Detach license",
|
|
8128
8034
|
method: HttpMethod.DELETE,
|
|
8129
8035
|
url: `/billing/${license.offline_id}/project/`,
|
|
@@ -8137,7 +8043,7 @@ class LicenseService extends BaseApiService {
|
|
|
8137
8043
|
return result;
|
|
8138
8044
|
}
|
|
8139
8045
|
async getLatestTransaction(license) {
|
|
8140
|
-
return await this.enqueueRequest({
|
|
8046
|
+
return await this.client.enqueueRequest({
|
|
8141
8047
|
description: "Get latest transaction",
|
|
8142
8048
|
method: HttpMethod.GET,
|
|
8143
8049
|
url: `/billing/${license.offline_id}/transaction/`,
|
|
@@ -8165,7 +8071,7 @@ class DocumentService extends BaseApiService {
|
|
|
8165
8071
|
children_documents: []
|
|
8166
8072
|
};
|
|
8167
8073
|
store.dispatch(addDocuments([submittedDocument]));
|
|
8168
|
-
const promise = this.enqueueRequest({
|
|
8074
|
+
const promise = this.client.enqueueRequest({
|
|
8169
8075
|
description: "Create Document",
|
|
8170
8076
|
method: HttpMethod.POST,
|
|
8171
8077
|
url: `/projects/${activeProjectId}/documents/`,
|
|
@@ -8191,7 +8097,7 @@ class DocumentService extends BaseApiService {
|
|
|
8191
8097
|
);
|
|
8192
8098
|
}
|
|
8193
8099
|
store.dispatch(updateDocuments([document2]));
|
|
8194
|
-
const promise = this.enqueueRequest({
|
|
8100
|
+
const promise = this.client.enqueueRequest({
|
|
8195
8101
|
description: "Update Document",
|
|
8196
8102
|
method: HttpMethod.PATCH,
|
|
8197
8103
|
url: `/documents/${document2.offline_id}/`,
|
|
@@ -8232,7 +8138,7 @@ class DocumentService extends BaseApiService {
|
|
|
8232
8138
|
}
|
|
8233
8139
|
}
|
|
8234
8140
|
store.dispatch(moveDocument({ documentId, targetDocumentId, position }));
|
|
8235
|
-
const promise = this.enqueueRequest({
|
|
8141
|
+
const promise = this.client.enqueueRequest({
|
|
8236
8142
|
description: "Move Document",
|
|
8237
8143
|
method: HttpMethod.PATCH,
|
|
8238
8144
|
url: `/documents/${documentId}/move/`,
|
|
@@ -8261,7 +8167,7 @@ class DocumentService extends BaseApiService {
|
|
|
8261
8167
|
}
|
|
8262
8168
|
const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
|
|
8263
8169
|
store.dispatch(removeDocuments([documentId]));
|
|
8264
|
-
const promise = this.enqueueRequest({
|
|
8170
|
+
const promise = this.client.enqueueRequest({
|
|
8265
8171
|
description: "Delete Document",
|
|
8266
8172
|
method: HttpMethod.DELETE,
|
|
8267
8173
|
url: `/documents/${documentId}/`,
|
|
@@ -8282,7 +8188,7 @@ class DocumentService extends BaseApiService {
|
|
|
8282
8188
|
const { store } = this.client;
|
|
8283
8189
|
const state = store.getState();
|
|
8284
8190
|
const activeProjectId = state.projectReducer.activeProjectId;
|
|
8285
|
-
const projectDocumentsPromise = this.enqueueRequest({
|
|
8191
|
+
const projectDocumentsPromise = this.client.enqueueRequest({
|
|
8286
8192
|
description: "Get project documents",
|
|
8287
8193
|
method: HttpMethod.GET,
|
|
8288
8194
|
url: `/projects/${activeProjectId}/documents/`,
|
|
@@ -8290,7 +8196,7 @@ class DocumentService extends BaseApiService {
|
|
|
8290
8196
|
blocks: []
|
|
8291
8197
|
});
|
|
8292
8198
|
const activeOrganizationId = state.organizationReducer.activeOrganizationId;
|
|
8293
|
-
const organizationDocumentsPromise = this.enqueueRequest({
|
|
8199
|
+
const organizationDocumentsPromise = this.client.enqueueRequest({
|
|
8294
8200
|
description: "Get organization documents",
|
|
8295
8201
|
method: HttpMethod.GET,
|
|
8296
8202
|
url: `/organizations/${activeOrganizationId}/documents/`,
|
|
@@ -8346,7 +8252,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
8346
8252
|
class AgentService extends BaseApiService {
|
|
8347
8253
|
async startConversation(prompt) {
|
|
8348
8254
|
const activeProjectId = this.client.store.getState().projectReducer.activeProjectId;
|
|
8349
|
-
return this.enqueueRequest({
|
|
8255
|
+
return this.client.enqueueRequest({
|
|
8350
8256
|
description: "Start agent conversation",
|
|
8351
8257
|
method: HttpMethod.POST,
|
|
8352
8258
|
url: "/agents/prompt/",
|
|
@@ -8372,7 +8278,7 @@ class AgentService extends BaseApiService {
|
|
|
8372
8278
|
async continueConversation(prompt, conversationId) {
|
|
8373
8279
|
const { store } = this.client;
|
|
8374
8280
|
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
8375
|
-
return this.enqueueRequest({
|
|
8281
|
+
return this.client.enqueueRequest({
|
|
8376
8282
|
description: "Prompt agent",
|
|
8377
8283
|
method: HttpMethod.POST,
|
|
8378
8284
|
url: "/agents/prompt/",
|
|
@@ -8400,7 +8306,7 @@ class AgentService extends BaseApiService {
|
|
|
8400
8306
|
});
|
|
8401
8307
|
}
|
|
8402
8308
|
async fetchDetails(conversationId) {
|
|
8403
|
-
return this.enqueueRequest({
|
|
8309
|
+
return this.client.enqueueRequest({
|
|
8404
8310
|
description: "Get agent conversation",
|
|
8405
8311
|
method: HttpMethod.GET,
|
|
8406
8312
|
url: `/agents/conversations/${conversationId}/`,
|
|
@@ -8411,7 +8317,7 @@ class AgentService extends BaseApiService {
|
|
|
8411
8317
|
});
|
|
8412
8318
|
}
|
|
8413
8319
|
async rate(responseId, rating) {
|
|
8414
|
-
return this.enqueueRequest({
|
|
8320
|
+
return this.client.enqueueRequest({
|
|
8415
8321
|
description: "Rate agent response",
|
|
8416
8322
|
method: HttpMethod.PUT,
|
|
8417
8323
|
url: `/agents/responses/${responseId}/rate/`,
|
|
@@ -8423,7 +8329,7 @@ class AgentService extends BaseApiService {
|
|
|
8423
8329
|
async refreshStore() {
|
|
8424
8330
|
const { store } = this.client;
|
|
8425
8331
|
const activeProject = store.getState().projectReducer.activeProjectId;
|
|
8426
|
-
const result = await this.enqueueRequest({
|
|
8332
|
+
const result = await this.client.enqueueRequest({
|
|
8427
8333
|
description: "Get agent conversation history",
|
|
8428
8334
|
method: HttpMethod.GET,
|
|
8429
8335
|
url: `/projects/${activeProject}/agent-conversations/`,
|
|
@@ -8449,7 +8355,7 @@ class TeamService extends BaseApiService {
|
|
|
8449
8355
|
// created_by: state.userReducer.currentUser.id,
|
|
8450
8356
|
});
|
|
8451
8357
|
store.dispatch(addTeam(offlineTeam));
|
|
8452
|
-
const promise = this.enqueueRequest({
|
|
8358
|
+
const promise = this.client.enqueueRequest({
|
|
8453
8359
|
description: "Create team",
|
|
8454
8360
|
method: HttpMethod.POST,
|
|
8455
8361
|
url: `/organizations/${activeOrganizationId}/teams/`,
|
|
@@ -8474,7 +8380,7 @@ class TeamService extends BaseApiService {
|
|
|
8474
8380
|
...team
|
|
8475
8381
|
};
|
|
8476
8382
|
store.dispatch(updateTeam(offlineUpdatedTeam));
|
|
8477
|
-
const promise = this.enqueueRequest({
|
|
8383
|
+
const promise = this.client.enqueueRequest({
|
|
8478
8384
|
description: "Update team",
|
|
8479
8385
|
method: HttpMethod.PATCH,
|
|
8480
8386
|
url: `/organizations/teams/${team.offline_id}/`,
|
|
@@ -8498,7 +8404,7 @@ class TeamService extends BaseApiService {
|
|
|
8498
8404
|
}
|
|
8499
8405
|
store.dispatch(deleteTeam(teamId));
|
|
8500
8406
|
try {
|
|
8501
|
-
return await this.enqueueRequest({
|
|
8407
|
+
return await this.client.enqueueRequest({
|
|
8502
8408
|
description: "Delete team",
|
|
8503
8409
|
method: HttpMethod.DELETE,
|
|
8504
8410
|
url: `/organizations/teams/${teamId}/`,
|
|
@@ -8520,7 +8426,7 @@ class TeamService extends BaseApiService {
|
|
|
8520
8426
|
throw new Error("Duplicate members found in the list");
|
|
8521
8427
|
}
|
|
8522
8428
|
store.dispatch(updateTeam({ ...team, members }));
|
|
8523
|
-
const promise = this.enqueueRequest({
|
|
8429
|
+
const promise = this.client.enqueueRequest({
|
|
8524
8430
|
description: "Set team members",
|
|
8525
8431
|
method: HttpMethod.PUT,
|
|
8526
8432
|
url: `/organizations/teams/${teamId}/set-members/`,
|
|
@@ -8559,7 +8465,7 @@ class TeamService extends BaseApiService {
|
|
|
8559
8465
|
if (!activeOrganizationId) {
|
|
8560
8466
|
throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
|
|
8561
8467
|
}
|
|
8562
|
-
const result = await this.enqueueRequest({
|
|
8468
|
+
const result = await this.client.enqueueRequest({
|
|
8563
8469
|
description: "Fetch teams",
|
|
8564
8470
|
method: HttpMethod.GET,
|
|
8565
8471
|
url: `/organizations/${activeOrganizationId}/teams/`,
|
|
@@ -8569,6 +8475,46 @@ class TeamService extends BaseApiService {
|
|
|
8569
8475
|
store.dispatch(setTeams(result));
|
|
8570
8476
|
}
|
|
8571
8477
|
}
|
|
8478
|
+
class DeferredPromise {
|
|
8479
|
+
constructor() {
|
|
8480
|
+
__publicField(this, _a, "Promise");
|
|
8481
|
+
__publicField(this, "_promise");
|
|
8482
|
+
__publicField(this, "_resolve");
|
|
8483
|
+
__publicField(this, "_reject");
|
|
8484
|
+
__publicField(this, "_state", "pending");
|
|
8485
|
+
this._resolve = null;
|
|
8486
|
+
this._reject = null;
|
|
8487
|
+
this._promise = new Promise((resolve, reject) => {
|
|
8488
|
+
this._resolve = resolve;
|
|
8489
|
+
this._reject = reject;
|
|
8490
|
+
});
|
|
8491
|
+
}
|
|
8492
|
+
get state() {
|
|
8493
|
+
return this._state;
|
|
8494
|
+
}
|
|
8495
|
+
then(onFulfilled, onRejected) {
|
|
8496
|
+
return this._promise.then(onFulfilled, onRejected);
|
|
8497
|
+
}
|
|
8498
|
+
catch(onRejected) {
|
|
8499
|
+
return this._promise.catch(onRejected);
|
|
8500
|
+
}
|
|
8501
|
+
resolve(value) {
|
|
8502
|
+
if (!this._resolve)
|
|
8503
|
+
throw new Error("No resolve callback");
|
|
8504
|
+
this._resolve(value);
|
|
8505
|
+
this._state = "fulfilled";
|
|
8506
|
+
}
|
|
8507
|
+
reject(reason) {
|
|
8508
|
+
if (!this._reject)
|
|
8509
|
+
throw reason;
|
|
8510
|
+
this._reject(reason);
|
|
8511
|
+
this._state = "rejected";
|
|
8512
|
+
}
|
|
8513
|
+
finally(_onFinally) {
|
|
8514
|
+
throw new Error("`finally` not implemented");
|
|
8515
|
+
}
|
|
8516
|
+
}
|
|
8517
|
+
_a = Symbol.toStringTag;
|
|
8572
8518
|
class OvermapSDK {
|
|
8573
8519
|
constructor(apiUrl, store) {
|
|
8574
8520
|
__publicField(this, "API_URL");
|
|
@@ -8607,6 +8553,87 @@ class OvermapSDK {
|
|
|
8607
8553
|
this.API_URL = apiUrl;
|
|
8608
8554
|
this.store = store;
|
|
8609
8555
|
}
|
|
8556
|
+
/**
|
|
8557
|
+
* Enqueues an API request to the offline outbox.
|
|
8558
|
+
* @param requestDetails An SDKRequest object containing the details of the request.
|
|
8559
|
+
* @protected
|
|
8560
|
+
*/
|
|
8561
|
+
async enqueueRequest(requestDetails) {
|
|
8562
|
+
return this._enqueueRequest(requestDetails).then((result) => {
|
|
8563
|
+
if (result instanceof APIError) {
|
|
8564
|
+
throw result;
|
|
8565
|
+
}
|
|
8566
|
+
return result;
|
|
8567
|
+
});
|
|
8568
|
+
}
|
|
8569
|
+
/**
|
|
8570
|
+
* Enqueues an API request to the Redux Offline outbox
|
|
8571
|
+
* @protected
|
|
8572
|
+
*/
|
|
8573
|
+
_enqueueRequest(requestDetails) {
|
|
8574
|
+
const promise = new DeferredPromise();
|
|
8575
|
+
const requestDetailsWithBaseUrl = { ...requestDetails, BASE_URL: this.API_URL };
|
|
8576
|
+
if (requestDetails.immediate) {
|
|
8577
|
+
const requestWithUuid = {
|
|
8578
|
+
...requestDetailsWithBaseUrl,
|
|
8579
|
+
uuid: requestDetails.uuid ?? v4()
|
|
8580
|
+
};
|
|
8581
|
+
const fullOfflineAction = {
|
|
8582
|
+
payload: requestWithUuid,
|
|
8583
|
+
type: "",
|
|
8584
|
+
meta: {
|
|
8585
|
+
offline: {
|
|
8586
|
+
effect: {
|
|
8587
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8588
|
+
request: requestWithUuid,
|
|
8589
|
+
BASE_URL: this.API_URL
|
|
8590
|
+
}
|
|
8591
|
+
}
|
|
8592
|
+
}
|
|
8593
|
+
};
|
|
8594
|
+
performRequest(fullOfflineAction, this).then((result) => {
|
|
8595
|
+
promise.resolve(result.body);
|
|
8596
|
+
}).catch((error2) => {
|
|
8597
|
+
discard(error2, fullOfflineAction);
|
|
8598
|
+
promise.reject(error2);
|
|
8599
|
+
});
|
|
8600
|
+
} else {
|
|
8601
|
+
const innerPromise = this.store.dispatch(
|
|
8602
|
+
enqueueRequest(requestDetailsWithBaseUrl)
|
|
8603
|
+
);
|
|
8604
|
+
const successOrUndefinedHandler = (response) => {
|
|
8605
|
+
if (response) {
|
|
8606
|
+
promise.resolve(response.body);
|
|
8607
|
+
} else {
|
|
8608
|
+
const error2 = new APIError({
|
|
8609
|
+
message: "Could not get a response from the server.",
|
|
8610
|
+
response,
|
|
8611
|
+
discard: true
|
|
8612
|
+
});
|
|
8613
|
+
promise.reject(error2);
|
|
8614
|
+
}
|
|
8615
|
+
};
|
|
8616
|
+
const errorHandler = (error2) => {
|
|
8617
|
+
if (error2 instanceof APIError) {
|
|
8618
|
+
error2.options.discard = true;
|
|
8619
|
+
} else {
|
|
8620
|
+
console.error(
|
|
8621
|
+
"Received an unexpected error while processing a request:",
|
|
8622
|
+
error2,
|
|
8623
|
+
"\nConverting error to APIError and discarding."
|
|
8624
|
+
);
|
|
8625
|
+
error2 = new APIError({
|
|
8626
|
+
message: "An error occurred while processing the request.",
|
|
8627
|
+
innerError: error2,
|
|
8628
|
+
discard: true
|
|
8629
|
+
});
|
|
8630
|
+
}
|
|
8631
|
+
promise.reject(error2);
|
|
8632
|
+
};
|
|
8633
|
+
innerPromise.then(successOrUndefinedHandler, errorHandler);
|
|
8634
|
+
}
|
|
8635
|
+
return promise;
|
|
8636
|
+
}
|
|
8610
8637
|
}
|
|
8611
8638
|
const makeClient = (apiUrl, store) => new OvermapSDK(apiUrl, store);
|
|
8612
8639
|
const SDKContext = React__default.createContext({});
|