@overmap-ai/core 1.0.65-mapbox.1 → 1.0.65-strip-workspace-access.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/offline.d.ts +1 -1
- package/dist/overmap-core.js +98 -130
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +96 -128
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/CategoryService.d.ts +1 -1
- package/dist/sdk/services/FormService.d.ts +0 -2
- package/dist/sdk/services/WorkspaceService.d.ts +1 -1
- package/dist/store/slices/formSlice.d.ts +0 -2
- package/dist/typings/models/base.d.ts +1 -1
- package/dist/typings/models/categories.d.ts +2 -2
- package/dist/typings/models/forms.d.ts +0 -1
- package/dist/typings/models/geo.d.ts +3 -3
- package/dist/typings/models/issues.d.ts +0 -1
- package/dist/typings/models/workspace.d.ts +3 -3
- package/dist/utils/coordinates.d.ts +18 -4
- package/dist/utils/utils.d.ts +7 -1
- package/package.json +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const OUTBOX_RETRY_DELAY =
|
|
1
|
+
export declare const OUTBOX_RETRY_DELAY = 60000;
|
package/dist/overmap-core.js
CHANGED
|
@@ -11,7 +11,7 @@ import { offline as offline$1 } from "@redux-offline/redux-offline";
|
|
|
11
11
|
import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
|
|
12
12
|
import localforage from "localforage";
|
|
13
13
|
import createMigration from "redux-persist-migrate";
|
|
14
|
-
import { createSlice, createSelector, combineReducers
|
|
14
|
+
import { createSlice, createSelector, combineReducers } from "@reduxjs/toolkit";
|
|
15
15
|
import request from "superagent";
|
|
16
16
|
import { saveAs } from "file-saver";
|
|
17
17
|
import React, { useRef, useEffect } from "react";
|
|
@@ -409,21 +409,70 @@ const { setTokens, clearTokens, setLoggedIn } = authSlice.actions;
|
|
|
409
409
|
const selectAccessToken = (state) => state.authReducer.accessToken;
|
|
410
410
|
const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
|
|
411
411
|
const authReducer = authSlice.reducer;
|
|
412
|
-
const
|
|
412
|
+
const coordinatesToLiteral = (coordinates) => {
|
|
413
|
+
return { lng: coordinates[0], lat: coordinates[1] };
|
|
414
|
+
};
|
|
415
|
+
const literalToCoordinates = (literal) => {
|
|
416
|
+
return [literal.lng, literal.lat];
|
|
417
|
+
};
|
|
418
|
+
const flipCoordinates = (coordinates) => {
|
|
419
|
+
return [coordinates[1], coordinates[0]];
|
|
420
|
+
};
|
|
421
|
+
const flipBounds = (bounds) => {
|
|
422
|
+
return [flipCoordinates(bounds[0]), flipCoordinates(bounds[1])];
|
|
423
|
+
};
|
|
424
|
+
function offsetPositionByMeters(originalPosition, latMeters, lngMeters) {
|
|
425
|
+
const { lat, lng } = originalPosition;
|
|
426
|
+
const earthRadius = 6378137;
|
|
427
|
+
const metersPerDegree = 2 * Math.PI * earthRadius / 360;
|
|
428
|
+
const newLng = lng + lngMeters / metersPerDegree / Math.cos(lat * Math.PI / 180);
|
|
429
|
+
const newLat = lat - latMeters / metersPerDegree;
|
|
430
|
+
return { lat: newLat, lng: newLng };
|
|
431
|
+
}
|
|
432
|
+
const createPointGeometry = (coordinates) => {
|
|
413
433
|
return {
|
|
414
434
|
type: "Point",
|
|
415
|
-
coordinates
|
|
435
|
+
coordinates
|
|
416
436
|
};
|
|
417
437
|
};
|
|
438
|
+
const coordinatesAreEqual = (a, b) => {
|
|
439
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
440
|
+
};
|
|
441
|
+
const coordinatesToText = (coordinates, decimalPlaces) => {
|
|
442
|
+
if (!coordinates)
|
|
443
|
+
return "(No Location)";
|
|
444
|
+
const { lat, lng } = coordinatesToLiteral(coordinates);
|
|
445
|
+
if (decimalPlaces)
|
|
446
|
+
return `${lat.toFixed(decimalPlaces)}, ${lng.toFixed(decimalPlaces)}`;
|
|
447
|
+
return `${lat}, ${lng}`;
|
|
448
|
+
};
|
|
449
|
+
const coordinatesToUrlText = (coordinates) => {
|
|
450
|
+
const { lat, lng } = coordinatesToLiteral(coordinates);
|
|
451
|
+
return `${lat}%2C${lng}`;
|
|
452
|
+
};
|
|
453
|
+
const openCoordsInGoogleMaps = (coordinates) => {
|
|
454
|
+
const url = `https://www.google.com/maps/search/?api=1&query=${coordinatesToUrlText(coordinates)}`;
|
|
455
|
+
window.open(url);
|
|
456
|
+
};
|
|
457
|
+
const openDirectionsInGoogleMaps = (startingPoint, destination) => {
|
|
458
|
+
const startingPointUrl = coordinatesToUrlText(startingPoint);
|
|
459
|
+
const destinationUrl = coordinatesToUrlText(destination);
|
|
460
|
+
const url = `https://www.google.com/maps/dir/?api=1&origin=${startingPointUrl}&destination=${destinationUrl}`;
|
|
461
|
+
window.open(url);
|
|
462
|
+
};
|
|
463
|
+
const worldBounds = {
|
|
464
|
+
type: "MultiPoint",
|
|
465
|
+
coordinates: [
|
|
466
|
+
[90, -180],
|
|
467
|
+
[-90, 180]
|
|
468
|
+
]
|
|
469
|
+
};
|
|
418
470
|
const createMultiPointGeometry = (coordinates) => {
|
|
419
471
|
return {
|
|
420
472
|
type: "MultiPoint",
|
|
421
473
|
coordinates
|
|
422
474
|
};
|
|
423
475
|
};
|
|
424
|
-
const coordinatesAreEqual = (a, b) => {
|
|
425
|
-
return a[0] === b[0] && a[1] === b[1];
|
|
426
|
-
};
|
|
427
476
|
function classNames(...args) {
|
|
428
477
|
const classes = [];
|
|
429
478
|
for (const arg of args) {
|
|
@@ -601,11 +650,14 @@ function onlyUniqueHashes(value, index, self) {
|
|
|
601
650
|
return v.file_sha1 === value.file_sha1;
|
|
602
651
|
}) === index;
|
|
603
652
|
}
|
|
653
|
+
function boundsContainPoint(bounds, coordinates) {
|
|
654
|
+
return bounds[0][0] > coordinates[0] && bounds[1][0] < coordinates[0] && bounds[0][1] > coordinates[1] && bounds[1][1] < coordinates[1];
|
|
655
|
+
}
|
|
604
656
|
const emailRegex = /^.+@.+\..+$/;
|
|
605
657
|
const fullAssetMarkerSize = 45;
|
|
606
658
|
const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
|
|
607
659
|
const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
|
|
608
|
-
const OUTBOX_RETRY_DELAY =
|
|
660
|
+
const OUTBOX_RETRY_DELAY = 6e4;
|
|
609
661
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
610
662
|
let debug = false;
|
|
611
663
|
const REACT_APP_DEBUG_MEMOIZATION = {}.REACT_APP_DEBUG_MEMOIZATION || "";
|
|
@@ -2323,29 +2375,18 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
2323
2375
|
(_state, search) => search
|
|
2324
2376
|
],
|
|
2325
2377
|
(formsMapping, revisions, search) => {
|
|
2326
|
-
const { searchTerm, maxResults,
|
|
2327
|
-
const favoriteMatches = [];
|
|
2378
|
+
const { searchTerm, maxResults, organization } = search;
|
|
2328
2379
|
const regularMatches = [];
|
|
2329
2380
|
for (const [formId, form] of Object.entries(formsMapping)) {
|
|
2330
|
-
if (favorites !== void 0 && form.favorite != favorites)
|
|
2331
|
-
continue;
|
|
2332
2381
|
if (Number.isInteger(organization) && organization !== form.organization) {
|
|
2333
2382
|
continue;
|
|
2334
2383
|
}
|
|
2335
2384
|
const latestRevision = _selectLatestFormRevision(revisions, formId);
|
|
2336
2385
|
if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
2337
|
-
|
|
2338
|
-
favoriteMatches.push({ ...form, latestRevision });
|
|
2339
|
-
} else {
|
|
2340
|
-
regularMatches.push({ ...form, latestRevision });
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
if (favoriteMatches.length >= maxResults) {
|
|
2344
|
-
break;
|
|
2386
|
+
regularMatches.push({ ...form, latestRevision });
|
|
2345
2387
|
}
|
|
2346
2388
|
}
|
|
2347
|
-
|
|
2348
|
-
return [...favoriteMatches, ...regularMatches.slice(0, maxRegularMatches)];
|
|
2389
|
+
return [...regularMatches.slice(0, maxResults)];
|
|
2349
2390
|
},
|
|
2350
2391
|
// as the argument is an object, we check the first level of properties for equality
|
|
2351
2392
|
{ memoizeOptions: { equalityCheck: shallowEqual } }
|
|
@@ -3372,62 +3413,11 @@ const overmapReducers = {
|
|
|
3372
3413
|
};
|
|
3373
3414
|
const overmapReducer = combineReducers(overmapReducers);
|
|
3374
3415
|
const resetStore = "RESET";
|
|
3375
|
-
function handleWorkspaceRemoval(draft, action) {
|
|
3376
|
-
const workspaceId = action.payload;
|
|
3377
|
-
const issuesVisibleInWorkspace = Object.values(draft.issueReducer.instances).filter(
|
|
3378
|
-
(issue) => issue.visible_in_workspaces.includes(workspaceId)
|
|
3379
|
-
);
|
|
3380
|
-
const mainWorkspace = selectMainWorkspace(draft);
|
|
3381
|
-
if (!mainWorkspace) {
|
|
3382
|
-
throw new Error("Main workspace not found");
|
|
3383
|
-
}
|
|
3384
|
-
if (action.payload === mainWorkspace.offline_id) {
|
|
3385
|
-
throw new Error("Tried to delete main workspace");
|
|
3386
|
-
}
|
|
3387
|
-
const categoriesInThisWorkspace = new Set(
|
|
3388
|
-
selectCategoriesOfWorkspace(workspaceId)(draft).map((category) => category.offline_id)
|
|
3389
|
-
);
|
|
3390
|
-
for (const issue of issuesVisibleInWorkspace) {
|
|
3391
|
-
if (issue.category && categoriesInThisWorkspace.has(issue.category)) {
|
|
3392
|
-
issue.category = null;
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
|
-
const issuesWithThisWorkspaceIndex = issuesVisibleInWorkspace.filter(
|
|
3396
|
-
(issue) => issue.index_workspace === action.payload
|
|
3397
|
-
);
|
|
3398
|
-
for (const issue of issuesWithThisWorkspaceIndex) {
|
|
3399
|
-
issue.index_workspace = mainWorkspace.offline_id;
|
|
3400
|
-
if (!issue.visible_in_workspaces.includes(mainWorkspace.offline_id)) {
|
|
3401
|
-
issue.visible_in_workspaces.push(mainWorkspace.offline_id);
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
for (const issue of issuesVisibleInWorkspace) {
|
|
3405
|
-
const indexOfWorkspace = issue.visible_in_workspaces.indexOf(workspaceId);
|
|
3406
|
-
if (indexOfWorkspace === -1) {
|
|
3407
|
-
throw new Error("Workspace not found in issue's visible_in_workspaces");
|
|
3408
|
-
}
|
|
3409
|
-
issue.visible_in_workspaces.splice(indexOfWorkspace, 1);
|
|
3410
|
-
}
|
|
3411
|
-
for (const issue of issuesVisibleInWorkspace) {
|
|
3412
|
-
if (issue.visible_in_workspaces.length === 0) {
|
|
3413
|
-
throw new Error(`Unexpected error: Issue ${issue.offline_id} has no visible_in_workspaces`);
|
|
3414
|
-
}
|
|
3415
|
-
if (issue.index_workspace === action.payload || !issue.index_workspace) {
|
|
3416
|
-
throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
|
|
3417
|
-
}
|
|
3418
|
-
}
|
|
3419
|
-
}
|
|
3420
3416
|
const overmapRootReducer = (state, action) => {
|
|
3421
3417
|
if (action.type === "auth/setLoggedIn" && !action.payload) {
|
|
3422
3418
|
return overmapReducer(void 0, action);
|
|
3423
3419
|
}
|
|
3424
|
-
|
|
3425
|
-
if (state && action.type === "workspace/removeWorkspace") {
|
|
3426
|
-
mutatedState = createNextState(state, (draft) => {
|
|
3427
|
-
handleWorkspaceRemoval(draft, action);
|
|
3428
|
-
});
|
|
3429
|
-
}
|
|
3430
|
-
return overmapReducer(mutatedState, action);
|
|
3420
|
+
return overmapReducer(state, action);
|
|
3431
3421
|
};
|
|
3432
3422
|
let __OUTBOX_COORDINATOR = null;
|
|
3433
3423
|
function getOutboxCoordinator() {
|
|
@@ -4046,10 +4036,17 @@ class BaseApiService extends BaseService {
|
|
|
4046
4036
|
}
|
|
4047
4037
|
}
|
|
4048
4038
|
class CategoryService extends BaseApiService {
|
|
4049
|
-
add(
|
|
4050
|
-
const
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4039
|
+
add(payload, workspaceId) {
|
|
4040
|
+
const { store } = this.client;
|
|
4041
|
+
const createdBy = store.getState().userReducer.currentUser.id;
|
|
4042
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4043
|
+
const offlineCategory = offline({
|
|
4044
|
+
...payload,
|
|
4045
|
+
created_by: createdBy,
|
|
4046
|
+
submitted_at: submittedAt,
|
|
4047
|
+
workspace: workspaceId
|
|
4048
|
+
});
|
|
4049
|
+
this.dispatch(addCategory(offlineCategory));
|
|
4053
4050
|
const promise = this.enqueueRequest({
|
|
4054
4051
|
description: "Create Category",
|
|
4055
4052
|
method: HttpMethod.POST,
|
|
@@ -4058,10 +4055,10 @@ class CategoryService extends BaseApiService {
|
|
|
4058
4055
|
workspace_id: workspaceId.toString()
|
|
4059
4056
|
},
|
|
4060
4057
|
payload: offlineCategory,
|
|
4061
|
-
blockers: [],
|
|
4058
|
+
blockers: [workspaceId],
|
|
4062
4059
|
blocks: [offlineCategory.offline_id]
|
|
4063
4060
|
});
|
|
4064
|
-
return [
|
|
4061
|
+
return [offlineCategory, promise];
|
|
4065
4062
|
}
|
|
4066
4063
|
update(category, workspaceId) {
|
|
4067
4064
|
const state = this.client.store.getState();
|
|
@@ -4931,11 +4928,7 @@ class IssueService extends BaseApiService {
|
|
|
4931
4928
|
...issueType ? { issue_type: issueType } : {}
|
|
4932
4929
|
},
|
|
4933
4930
|
payload: issuePayload,
|
|
4934
|
-
blockers: [
|
|
4935
|
-
"add-issue",
|
|
4936
|
-
...issuePayload.index_workspace ? [issuePayload.index_workspace] : [],
|
|
4937
|
-
...issuePayload.visible_in_workspaces
|
|
4938
|
-
],
|
|
4931
|
+
blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
|
|
4939
4932
|
blocks: [issuePayload.offline_id]
|
|
4940
4933
|
});
|
|
4941
4934
|
void promise.then((result) => {
|
|
@@ -5716,48 +5709,6 @@ class FormService extends BaseUploadService {
|
|
|
5716
5709
|
});
|
|
5717
5710
|
return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
|
|
5718
5711
|
}
|
|
5719
|
-
async favorite(formId, projectId) {
|
|
5720
|
-
const { store } = this.client;
|
|
5721
|
-
const state = store.getState();
|
|
5722
|
-
const form = state.formReducer.instances[formId];
|
|
5723
|
-
if (!form) {
|
|
5724
|
-
throw new Error(`Expected form to exist, got ${form}`);
|
|
5725
|
-
}
|
|
5726
|
-
this.dispatch(updateForm({ ...form, favorite: true }));
|
|
5727
|
-
try {
|
|
5728
|
-
await this.enqueueRequest({
|
|
5729
|
-
description: "Favorite form",
|
|
5730
|
-
method: HttpMethod.POST,
|
|
5731
|
-
url: `/forms/${formId}/favorite/${projectId}/`,
|
|
5732
|
-
blockers: [formId, `favorite-${formId}`],
|
|
5733
|
-
blocks: [`favorite-${formId}`]
|
|
5734
|
-
});
|
|
5735
|
-
} catch (e) {
|
|
5736
|
-
this.dispatch(updateForm(form));
|
|
5737
|
-
throw e;
|
|
5738
|
-
}
|
|
5739
|
-
}
|
|
5740
|
-
async unfavorite(formId, projectId) {
|
|
5741
|
-
const { store } = this.client;
|
|
5742
|
-
const state = store.getState();
|
|
5743
|
-
const form = state.formReducer.instances[formId];
|
|
5744
|
-
if (!form) {
|
|
5745
|
-
throw new Error(`Expected form to exist, got ${form}`);
|
|
5746
|
-
}
|
|
5747
|
-
this.dispatch(updateForm({ ...form, favorite: false }));
|
|
5748
|
-
try {
|
|
5749
|
-
return await this.enqueueRequest({
|
|
5750
|
-
description: "Unfavorite form",
|
|
5751
|
-
method: HttpMethod.DELETE,
|
|
5752
|
-
url: `/forms/${formId}/unfavorite/${projectId}/`,
|
|
5753
|
-
blockers: [formId, `favorite-${formId}`],
|
|
5754
|
-
blocks: [`favorite-${formId}`]
|
|
5755
|
-
});
|
|
5756
|
-
} catch (e) {
|
|
5757
|
-
this.dispatch(updateForm(form));
|
|
5758
|
-
throw e;
|
|
5759
|
-
}
|
|
5760
|
-
}
|
|
5761
5712
|
async delete(formId) {
|
|
5762
5713
|
const { store } = this.client;
|
|
5763
5714
|
const state = store.getState();
|
|
@@ -6218,13 +6169,19 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
6218
6169
|
}
|
|
6219
6170
|
}
|
|
6220
6171
|
class WorkspaceService extends BaseApiService {
|
|
6221
|
-
add(
|
|
6222
|
-
const
|
|
6172
|
+
add(payload) {
|
|
6173
|
+
const { store } = this.client;
|
|
6174
|
+
const createdBy = store.getState().userReducer.currentUser.id;
|
|
6175
|
+
const offlineWorkspace = offline({
|
|
6176
|
+
...payload,
|
|
6177
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6178
|
+
created_by: createdBy
|
|
6179
|
+
});
|
|
6223
6180
|
this.dispatch(addWorkspace(offlineWorkspace));
|
|
6224
6181
|
const promise = this.enqueueRequest({
|
|
6225
6182
|
description: "Create Workspace",
|
|
6226
6183
|
method: HttpMethod.POST,
|
|
6227
|
-
url: `/projects/${
|
|
6184
|
+
url: `/projects/${payload.project}/workspaces/`,
|
|
6228
6185
|
payload: offlineWorkspace,
|
|
6229
6186
|
blockers: ["add-workspace"],
|
|
6230
6187
|
blocks: [offlineWorkspace.offline_id]
|
|
@@ -7637,6 +7594,7 @@ export {
|
|
|
7637
7594
|
authReducer,
|
|
7638
7595
|
authSlice,
|
|
7639
7596
|
blobToBase64,
|
|
7597
|
+
boundsContainPoint,
|
|
7640
7598
|
categoryReducer,
|
|
7641
7599
|
categorySlice,
|
|
7642
7600
|
classNames,
|
|
@@ -7644,6 +7602,9 @@ export {
|
|
|
7644
7602
|
clearTokens,
|
|
7645
7603
|
constructUploadedFilePayloads,
|
|
7646
7604
|
coordinatesAreEqual,
|
|
7605
|
+
coordinatesToLiteral,
|
|
7606
|
+
coordinatesToText,
|
|
7607
|
+
coordinatesToUrlText,
|
|
7647
7608
|
createMultiPointGeometry,
|
|
7648
7609
|
createOfflineAction,
|
|
7649
7610
|
createPointGeometry,
|
|
@@ -7706,6 +7667,8 @@ export {
|
|
|
7706
7667
|
fileReducer,
|
|
7707
7668
|
fileSlice,
|
|
7708
7669
|
fileToBlob,
|
|
7670
|
+
flipBounds,
|
|
7671
|
+
flipCoordinates,
|
|
7709
7672
|
formReducer,
|
|
7710
7673
|
formRevisionAttachmentReducer,
|
|
7711
7674
|
formRevisionAttachmentSlice,
|
|
@@ -7772,14 +7735,18 @@ export {
|
|
|
7772
7735
|
issueUpdateSlice,
|
|
7773
7736
|
licenseReducer,
|
|
7774
7737
|
licenseSlice,
|
|
7738
|
+
literalToCoordinates,
|
|
7775
7739
|
logOnlyOnce,
|
|
7776
7740
|
markAsDeleted,
|
|
7777
7741
|
markForDeletion,
|
|
7778
7742
|
memoize,
|
|
7779
7743
|
moveDocument,
|
|
7780
7744
|
offline,
|
|
7745
|
+
offsetPositionByMeters,
|
|
7781
7746
|
onlyUniqueHashes,
|
|
7782
7747
|
onlyUniqueOfflineIds,
|
|
7748
|
+
openCoordsInGoogleMaps,
|
|
7749
|
+
openDirectionsInGoogleMaps,
|
|
7783
7750
|
organizationAccessReducer,
|
|
7784
7751
|
organizationAccessSlice,
|
|
7785
7752
|
organizationReducer,
|
|
@@ -8094,6 +8061,7 @@ export {
|
|
|
8094
8061
|
versioningSlice,
|
|
8095
8062
|
warningColor,
|
|
8096
8063
|
workspaceReducer,
|
|
8097
|
-
workspaceSlice
|
|
8064
|
+
workspaceSlice,
|
|
8065
|
+
worldBounds
|
|
8098
8066
|
};
|
|
8099
8067
|
//# sourceMappingURL=overmap-core.js.map
|