@overmap-ai/core 1.0.45 → 1.0.46-project-attachments.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/overmap-core.js +505 -75
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +505 -75
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/sdk.d.ts +2 -1
- package/dist/sdk/services/AttachmentService.d.ts +6 -1
- package/dist/sdk/services/DocumentService.d.ts +10 -0
- package/dist/sdk/services/index.d.ts +2 -1
- package/dist/sdk/typings.d.ts +1 -1
- package/dist/store/slices/categorySlice.d.ts +1 -0
- package/dist/store/slices/documentSlice.d.ts +66 -0
- package/dist/store/slices/index.d.ts +1 -0
- package/dist/store/slices/issueSlice.d.ts +1 -0
- package/dist/store/slices/projectFileSlice.d.ts +1 -0
- package/dist/store/slices/projectSlice.d.ts +34 -2
- package/dist/store/slices/workspaceSlice.d.ts +1 -0
- package/dist/store/store.d.ts +4 -1
- package/dist/typings/models/attachments.d.ts +4 -0
- package/dist/typings/models/documents.d.ts +11 -0
- package/dist/typings/models/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -622,15 +622,15 @@ var __publicField = (obj, key, value) => {
|
|
|
622
622
|
};
|
|
623
623
|
const migrations = [initialVersioning, signOut, signOut, createOutboxState];
|
|
624
624
|
const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
|
|
625
|
-
const initialState$
|
|
625
|
+
const initialState$n = {
|
|
626
626
|
accessToken: "",
|
|
627
627
|
refreshToken: "",
|
|
628
628
|
isLoggedIn: false
|
|
629
629
|
};
|
|
630
630
|
const authSlice = toolkit.createSlice({
|
|
631
631
|
name: "auth",
|
|
632
|
-
initialState: initialState$
|
|
633
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
632
|
+
initialState: initialState$n,
|
|
633
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
|
|
634
634
|
reducers: {
|
|
635
635
|
setTokens: (state, action) => {
|
|
636
636
|
state.accessToken = action.payload.accessToken;
|
|
@@ -1361,7 +1361,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1361
1361
|
return getLocalDateString(date);
|
|
1362
1362
|
return relative.format(days, "days");
|
|
1363
1363
|
});
|
|
1364
|
-
const initialState$
|
|
1364
|
+
const initialState$m = {
|
|
1365
1365
|
categories: {},
|
|
1366
1366
|
usedCategoryColors: [],
|
|
1367
1367
|
categoryVisibility: {
|
|
@@ -1371,8 +1371,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1371
1371
|
};
|
|
1372
1372
|
const categorySlice = toolkit.createSlice({
|
|
1373
1373
|
name: "categories",
|
|
1374
|
-
initialState: initialState$
|
|
1375
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1374
|
+
initialState: initialState$m,
|
|
1375
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
|
|
1376
1376
|
reducers: {
|
|
1377
1377
|
setCategories: (state, action) => {
|
|
1378
1378
|
if (!Array.isArray(action.payload))
|
|
@@ -1540,14 +1540,14 @@ var __publicField = (obj, key, value) => {
|
|
|
1540
1540
|
delete state.attachments[attachmentId];
|
|
1541
1541
|
}
|
|
1542
1542
|
}
|
|
1543
|
-
const initialState$
|
|
1543
|
+
const initialState$l = {
|
|
1544
1544
|
components: {},
|
|
1545
1545
|
attachments: {}
|
|
1546
1546
|
};
|
|
1547
1547
|
const componentSlice = toolkit.createSlice({
|
|
1548
1548
|
name: "components",
|
|
1549
|
-
initialState: initialState$
|
|
1550
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1549
|
+
initialState: initialState$l,
|
|
1550
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
|
|
1551
1551
|
reducers: {
|
|
1552
1552
|
addComponent: (state, action) => {
|
|
1553
1553
|
state.components[action.payload.offline_id] = action.payload;
|
|
@@ -1701,13 +1701,13 @@ var __publicField = (obj, key, value) => {
|
|
|
1701
1701
|
removeAllComponentsOfType
|
|
1702
1702
|
} = componentSlice.actions;
|
|
1703
1703
|
const componentReducer = componentSlice.reducer;
|
|
1704
|
-
const initialState$
|
|
1704
|
+
const initialState$k = {
|
|
1705
1705
|
completionsByComponentId: {}
|
|
1706
1706
|
};
|
|
1707
1707
|
const componentStageCompletionSlice = toolkit.createSlice({
|
|
1708
1708
|
name: "componentStageCompletions",
|
|
1709
|
-
initialState: initialState$
|
|
1710
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1709
|
+
initialState: initialState$k,
|
|
1710
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
|
|
1711
1711
|
reducers: {
|
|
1712
1712
|
addStageCompletion: (state, action) => {
|
|
1713
1713
|
let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
|
|
@@ -1758,13 +1758,13 @@ var __publicField = (obj, key, value) => {
|
|
|
1758
1758
|
return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
|
|
1759
1759
|
};
|
|
1760
1760
|
const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
|
|
1761
|
-
const initialState$
|
|
1761
|
+
const initialState$j = {
|
|
1762
1762
|
stages: {}
|
|
1763
1763
|
};
|
|
1764
1764
|
const componentStageSlice = toolkit.createSlice({
|
|
1765
1765
|
name: "componentStages",
|
|
1766
|
-
initialState: initialState$
|
|
1767
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1766
|
+
initialState: initialState$j,
|
|
1767
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
|
|
1768
1768
|
reducers: {
|
|
1769
1769
|
addStages: (state, action) => {
|
|
1770
1770
|
Object.assign(state.stages, toOfflineIdRecord(action.payload));
|
|
@@ -1855,15 +1855,15 @@ var __publicField = (obj, key, value) => {
|
|
|
1855
1855
|
);
|
|
1856
1856
|
const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
|
|
1857
1857
|
const componentStageReducer = componentStageSlice.reducer;
|
|
1858
|
-
const initialState$
|
|
1858
|
+
const initialState$i = {
|
|
1859
1859
|
componentTypes: {},
|
|
1860
1860
|
hiddenComponentTypeIds: {},
|
|
1861
1861
|
attachments: {}
|
|
1862
1862
|
};
|
|
1863
1863
|
const componentTypeSlice = toolkit.createSlice({
|
|
1864
1864
|
name: "componentTypes",
|
|
1865
|
-
initialState: initialState$
|
|
1866
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1865
|
+
initialState: initialState$i,
|
|
1866
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
|
|
1867
1867
|
reducers: {
|
|
1868
1868
|
addComponentType: (state, action) => {
|
|
1869
1869
|
state.componentTypes[action.payload.offline_id] = action.payload;
|
|
@@ -1971,13 +1971,13 @@ var __publicField = (obj, key, value) => {
|
|
|
1971
1971
|
deleteComponentType
|
|
1972
1972
|
} = componentTypeSlice.actions;
|
|
1973
1973
|
const componentTypeReducer = componentTypeSlice.reducer;
|
|
1974
|
-
const initialState$
|
|
1974
|
+
const initialState$h = {
|
|
1975
1975
|
workspaces: {},
|
|
1976
1976
|
activeWorkspaceId: null
|
|
1977
1977
|
};
|
|
1978
1978
|
const workspaceSlice = toolkit.createSlice({
|
|
1979
1979
|
name: "workspace",
|
|
1980
|
-
initialState: initialState$
|
|
1980
|
+
initialState: initialState$h,
|
|
1981
1981
|
// The `reducers` field lets us define reducers and generate associated actions
|
|
1982
1982
|
reducers: {
|
|
1983
1983
|
setWorkspaces: (state, action) => {
|
|
@@ -2034,7 +2034,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2034
2034
|
);
|
|
2035
2035
|
const workspaceReducer = workspaceSlice.reducer;
|
|
2036
2036
|
const maxRecentIssues = 10;
|
|
2037
|
-
const initialState$
|
|
2037
|
+
const initialState$g = {
|
|
2038
2038
|
issues: {},
|
|
2039
2039
|
attachments: {},
|
|
2040
2040
|
comments: {},
|
|
@@ -2045,9 +2045,9 @@ var __publicField = (obj, key, value) => {
|
|
|
2045
2045
|
};
|
|
2046
2046
|
const issueSlice = toolkit.createSlice({
|
|
2047
2047
|
name: "issues",
|
|
2048
|
-
initialState: initialState$
|
|
2048
|
+
initialState: initialState$g,
|
|
2049
2049
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
2050
|
-
Object.assign(state, initialState$
|
|
2050
|
+
Object.assign(state, initialState$g);
|
|
2051
2051
|
}),
|
|
2052
2052
|
reducers: {
|
|
2053
2053
|
setIssues: (state, action) => {
|
|
@@ -2058,7 +2058,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2058
2058
|
state.issues[issue.offline_id] = issue;
|
|
2059
2059
|
});
|
|
2060
2060
|
},
|
|
2061
|
-
// TODO: Reusable function
|
|
2062
2061
|
setIssueAttachments: setAttachments,
|
|
2063
2062
|
setActiveIssueId: (state, action) => {
|
|
2064
2063
|
state.activeIssueId = action.payload;
|
|
@@ -2069,7 +2068,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2069
2068
|
}
|
|
2070
2069
|
state.issues[action.payload.offline_id] = action.payload;
|
|
2071
2070
|
},
|
|
2072
|
-
// TODO: Reusable function
|
|
2073
2071
|
addIssueAttachment: addAttachment,
|
|
2074
2072
|
addIssueAttachments: addAttachments,
|
|
2075
2073
|
updateIssue: (state, action) => {
|
|
@@ -2082,7 +2080,6 @@ var __publicField = (obj, key, value) => {
|
|
|
2082
2080
|
throw new Error(`Tried to update issue with ID that doesn't exist: ${action.payload.offline_id}`);
|
|
2083
2081
|
}
|
|
2084
2082
|
},
|
|
2085
|
-
// TODO: Reusable function
|
|
2086
2083
|
updateIssueAttachment: updateAttachment,
|
|
2087
2084
|
removeIssue: (state, action) => {
|
|
2088
2085
|
if (action.payload in state.issues) {
|
|
@@ -2371,15 +2368,15 @@ var __publicField = (obj, key, value) => {
|
|
|
2371
2368
|
}
|
|
2372
2369
|
);
|
|
2373
2370
|
const issueReducer = issueSlice.reducer;
|
|
2374
|
-
const initialState$
|
|
2371
|
+
const initialState$f = {
|
|
2375
2372
|
s3Urls: {}
|
|
2376
2373
|
};
|
|
2377
2374
|
const msPerHour = 1e3 * 60 * 60;
|
|
2378
2375
|
const msPerWeek = msPerHour * 24 * 7;
|
|
2379
2376
|
const fileSlice = toolkit.createSlice({
|
|
2380
2377
|
name: "file",
|
|
2381
|
-
initialState: initialState$
|
|
2382
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2378
|
+
initialState: initialState$f,
|
|
2379
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
|
|
2383
2380
|
reducers: {
|
|
2384
2381
|
setUploadUrl: (state, action) => {
|
|
2385
2382
|
const { url, fields, sha1 } = action.payload;
|
|
@@ -2406,7 +2403,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2406
2403
|
return url;
|
|
2407
2404
|
};
|
|
2408
2405
|
const fileReducer = fileSlice.reducer;
|
|
2409
|
-
const initialState$
|
|
2406
|
+
const initialState$e = {
|
|
2410
2407
|
// TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
|
|
2411
2408
|
mapStyle: MapStyle.SATELLITE,
|
|
2412
2409
|
showTooltips: false,
|
|
@@ -2414,8 +2411,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2414
2411
|
};
|
|
2415
2412
|
const mapSlice = toolkit.createSlice({
|
|
2416
2413
|
name: "map",
|
|
2417
|
-
initialState: initialState$
|
|
2418
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2414
|
+
initialState: initialState$e,
|
|
2415
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
|
|
2419
2416
|
reducers: {
|
|
2420
2417
|
setMapStyle: (state, action) => {
|
|
2421
2418
|
state.mapStyle = action.payload;
|
|
@@ -2474,7 +2471,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2474
2471
|
LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
|
|
2475
2472
|
return LicenseStatus2;
|
|
2476
2473
|
})(LicenseStatus || {});
|
|
2477
|
-
const initialState$
|
|
2474
|
+
const initialState$d = {
|
|
2478
2475
|
users: {},
|
|
2479
2476
|
currentUser: {
|
|
2480
2477
|
id: 0,
|
|
@@ -2485,8 +2482,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2485
2482
|
};
|
|
2486
2483
|
const userSlice = toolkit.createSlice({
|
|
2487
2484
|
name: "users",
|
|
2488
|
-
initialState: initialState$
|
|
2489
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2485
|
+
initialState: initialState$d,
|
|
2486
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
|
|
2490
2487
|
reducers: {
|
|
2491
2488
|
setUsers: (state, action) => {
|
|
2492
2489
|
const usersMapping = {};
|
|
@@ -2548,13 +2545,13 @@ var __publicField = (obj, key, value) => {
|
|
|
2548
2545
|
const selectUsersAsMapping = (state) => state.userReducer.users;
|
|
2549
2546
|
const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
|
|
2550
2547
|
const userReducer = userSlice.reducer;
|
|
2551
|
-
const initialState$
|
|
2548
|
+
const initialState$c = {
|
|
2552
2549
|
organizationAccesses: {}
|
|
2553
2550
|
};
|
|
2554
2551
|
const organizationAccessSlice = toolkit.createSlice({
|
|
2555
2552
|
name: "organizationAccess",
|
|
2556
|
-
initialState: initialState$
|
|
2557
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2553
|
+
initialState: initialState$c,
|
|
2554
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
|
|
2558
2555
|
reducers: {
|
|
2559
2556
|
setOrganizationAccesses: (state, action) => {
|
|
2560
2557
|
if (!Array.isArray(action.payload))
|
|
@@ -2617,13 +2614,13 @@ var __publicField = (obj, key, value) => {
|
|
|
2617
2614
|
return organizationAccesses;
|
|
2618
2615
|
};
|
|
2619
2616
|
const organizationAccessReducer = organizationAccessSlice.reducer;
|
|
2620
|
-
const initialState$
|
|
2617
|
+
const initialState$b = {
|
|
2621
2618
|
licenses: {}
|
|
2622
2619
|
};
|
|
2623
2620
|
const licenseSlice = toolkit.createSlice({
|
|
2624
2621
|
name: "license",
|
|
2625
|
-
initialState: initialState$
|
|
2626
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2622
|
+
initialState: initialState$b,
|
|
2623
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
|
|
2627
2624
|
reducers: {
|
|
2628
2625
|
setLicenses: (state, action) => {
|
|
2629
2626
|
if (!Array.isArray(action.payload))
|
|
@@ -2668,13 +2665,13 @@ var __publicField = (obj, key, value) => {
|
|
|
2668
2665
|
(licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
|
|
2669
2666
|
);
|
|
2670
2667
|
const licenseReducer = licenseSlice.reducer;
|
|
2671
|
-
const initialState$
|
|
2668
|
+
const initialState$a = {
|
|
2672
2669
|
projectAccesses: {}
|
|
2673
2670
|
};
|
|
2674
2671
|
const projectAccessSlice = toolkit.createSlice({
|
|
2675
2672
|
name: "projectAccess",
|
|
2676
|
-
initialState: initialState$
|
|
2677
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2673
|
+
initialState: initialState$a,
|
|
2674
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
|
|
2678
2675
|
reducers: {
|
|
2679
2676
|
setProjectAccesses: (state, action) => {
|
|
2680
2677
|
if (!Array.isArray(action.payload))
|
|
@@ -2742,16 +2739,17 @@ var __publicField = (obj, key, value) => {
|
|
|
2742
2739
|
return projectAccesses;
|
|
2743
2740
|
};
|
|
2744
2741
|
const projectAccessReducer = projectAccessSlice.reducer;
|
|
2745
|
-
const initialState$
|
|
2742
|
+
const initialState$9 = {
|
|
2746
2743
|
projects: {},
|
|
2747
2744
|
activeProjectId: null,
|
|
2748
2745
|
recentProjectIds: [],
|
|
2749
2746
|
recentSearchableQueries: [],
|
|
2750
|
-
createProjectType: ProjectType.PERSONAL
|
|
2747
|
+
createProjectType: ProjectType.PERSONAL,
|
|
2748
|
+
attachments: {}
|
|
2751
2749
|
};
|
|
2752
2750
|
const projectSlice = toolkit.createSlice({
|
|
2753
2751
|
name: "projects",
|
|
2754
|
-
initialState: initialState$
|
|
2752
|
+
initialState: initialState$9,
|
|
2755
2753
|
reducers: {
|
|
2756
2754
|
setProjects: (state, action) => {
|
|
2757
2755
|
const projectsMap = {};
|
|
@@ -2818,7 +2816,14 @@ var __publicField = (obj, key, value) => {
|
|
|
2818
2816
|
} else {
|
|
2819
2817
|
throw new Error("Update form submissions count: no active project");
|
|
2820
2818
|
}
|
|
2821
|
-
}
|
|
2819
|
+
},
|
|
2820
|
+
// Attachment related
|
|
2821
|
+
setProjectAttachments: setAttachments,
|
|
2822
|
+
addProjectAttachment: addAttachment,
|
|
2823
|
+
addProjectAttachments: addAttachments,
|
|
2824
|
+
updateProjectAttachment: updateAttachment,
|
|
2825
|
+
removeProjectAttachment: removeAttachment,
|
|
2826
|
+
removeProjectAttachments: removeAttachments
|
|
2822
2827
|
}
|
|
2823
2828
|
});
|
|
2824
2829
|
const {
|
|
@@ -2830,7 +2835,14 @@ var __publicField = (obj, key, value) => {
|
|
|
2830
2835
|
deleteProject,
|
|
2831
2836
|
acceptProjectInvite,
|
|
2832
2837
|
addActiveProjectIssuesCount,
|
|
2833
|
-
addActiveProjectFormSubmissionsCount
|
|
2838
|
+
addActiveProjectFormSubmissionsCount,
|
|
2839
|
+
// Attachment related
|
|
2840
|
+
setProjectAttachments,
|
|
2841
|
+
addProjectAttachment,
|
|
2842
|
+
addProjectAttachments,
|
|
2843
|
+
updateProjectAttachment,
|
|
2844
|
+
removeProjectAttachment,
|
|
2845
|
+
removeProjectAttachments
|
|
2834
2846
|
} = projectSlice.actions;
|
|
2835
2847
|
const selectProjects = (state) => state.projectReducer.projects;
|
|
2836
2848
|
const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
|
|
@@ -2894,14 +2906,44 @@ var __publicField = (obj, key, value) => {
|
|
|
2894
2906
|
});
|
|
2895
2907
|
}
|
|
2896
2908
|
);
|
|
2897
|
-
const
|
|
2909
|
+
const selectProjectAttachmentMapping = (state) => state.projectReducer.attachments;
|
|
2910
|
+
const selectAllProjectAttachments = toolkit.createSelector(
|
|
2911
|
+
[selectProjectAttachmentMapping],
|
|
2912
|
+
(mapping) => Object.values(mapping)
|
|
2913
|
+
);
|
|
2914
|
+
const selectAttachmentsOfProject = restructureCreateSelectorWithArgs(
|
|
2915
|
+
toolkit.createSelector(
|
|
2916
|
+
[selectAllProjectAttachments, (_state, projectId) => projectId],
|
|
2917
|
+
(attachments, projectId) => {
|
|
2918
|
+
return attachments.filter(({ project }) => projectId === project);
|
|
2919
|
+
}
|
|
2920
|
+
)
|
|
2921
|
+
);
|
|
2922
|
+
const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
|
|
2923
|
+
toolkit.createSelector(
|
|
2924
|
+
[selectAllProjectAttachments, (_state, projectId) => projectId],
|
|
2925
|
+
(attachments, projectId) => {
|
|
2926
|
+
const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
|
|
2927
|
+
const fileAttachments = attachmentsOfProject.filter(
|
|
2928
|
+
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2929
|
+
({ file_type }) => !file_type || !file_type.startsWith("image/")
|
|
2930
|
+
);
|
|
2931
|
+
const imageAttachments = attachmentsOfProject.filter(
|
|
2932
|
+
// this null check here is necessary, there are cases where file_type is null or undefined
|
|
2933
|
+
({ file_type }) => file_type && file_type.startsWith("image/")
|
|
2934
|
+
);
|
|
2935
|
+
return { fileAttachments, imageAttachments };
|
|
2936
|
+
}
|
|
2937
|
+
)
|
|
2938
|
+
);
|
|
2939
|
+
const initialState$8 = {
|
|
2898
2940
|
organizations: {},
|
|
2899
2941
|
activeOrganizationId: null
|
|
2900
2942
|
};
|
|
2901
2943
|
const organizationSlice = toolkit.createSlice({
|
|
2902
2944
|
name: "organizations",
|
|
2903
|
-
initialState: initialState$
|
|
2904
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2945
|
+
initialState: initialState$8,
|
|
2946
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
|
|
2905
2947
|
reducers: {
|
|
2906
2948
|
setOrganizations: (state, action) => {
|
|
2907
2949
|
for (const org of action.payload) {
|
|
@@ -3020,14 +3062,14 @@ var __publicField = (obj, key, value) => {
|
|
|
3020
3062
|
}
|
|
3021
3063
|
};
|
|
3022
3064
|
};
|
|
3023
|
-
const initialState$
|
|
3065
|
+
const initialState$7 = {
|
|
3024
3066
|
deletedRequests: [],
|
|
3025
3067
|
latestRetryTime: 0
|
|
3026
3068
|
};
|
|
3027
3069
|
const outboxSlice = toolkit.createSlice({
|
|
3028
3070
|
name: "outbox",
|
|
3029
|
-
initialState: initialState$
|
|
3030
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3071
|
+
initialState: initialState$7,
|
|
3072
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
|
|
3031
3073
|
reducers: {
|
|
3032
3074
|
// enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
|
|
3033
3075
|
// Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
|
|
@@ -3059,7 +3101,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3059
3101
|
const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
|
|
3060
3102
|
const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
|
|
3061
3103
|
const outboxReducer = outboxSlice.reducer;
|
|
3062
|
-
const initialState$
|
|
3104
|
+
const initialState$6 = {
|
|
3063
3105
|
projectFiles: {},
|
|
3064
3106
|
activeProjectFileId: null,
|
|
3065
3107
|
isImportingProjectFile: false,
|
|
@@ -3067,8 +3109,8 @@ var __publicField = (obj, key, value) => {
|
|
|
3067
3109
|
};
|
|
3068
3110
|
const projectFileSlice = toolkit.createSlice({
|
|
3069
3111
|
name: "projectFiles",
|
|
3070
|
-
initialState: initialState$
|
|
3071
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3112
|
+
initialState: initialState$6,
|
|
3113
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
|
|
3072
3114
|
reducers: {
|
|
3073
3115
|
addOrReplaceProjectFiles: (state, action) => {
|
|
3074
3116
|
for (let fileObj of action.payload) {
|
|
@@ -3169,12 +3211,12 @@ var __publicField = (obj, key, value) => {
|
|
|
3169
3211
|
const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
|
|
3170
3212
|
const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
|
|
3171
3213
|
const projectFileReducer = projectFileSlice.reducer;
|
|
3172
|
-
const initialState$
|
|
3214
|
+
const initialState$5 = {
|
|
3173
3215
|
isRehydrated: false
|
|
3174
3216
|
};
|
|
3175
3217
|
const rehydratedSlice = toolkit.createSlice({
|
|
3176
3218
|
name: "rehydrated",
|
|
3177
|
-
initialState: initialState$
|
|
3219
|
+
initialState: initialState$5,
|
|
3178
3220
|
// The `reducers` field lets us define reducers and generate associated actions
|
|
3179
3221
|
reducers: {
|
|
3180
3222
|
setRehydrated: (state, action) => {
|
|
@@ -3184,7 +3226,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3184
3226
|
});
|
|
3185
3227
|
const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
|
|
3186
3228
|
const rehydratedReducer = rehydratedSlice.reducer;
|
|
3187
|
-
const initialState$
|
|
3229
|
+
const initialState$4 = {
|
|
3188
3230
|
useIssueTemplate: false,
|
|
3189
3231
|
placementMode: false,
|
|
3190
3232
|
enableClustering: true,
|
|
@@ -3201,8 +3243,8 @@ var __publicField = (obj, key, value) => {
|
|
|
3201
3243
|
};
|
|
3202
3244
|
const settingSlice = toolkit.createSlice({
|
|
3203
3245
|
name: "settings",
|
|
3204
|
-
initialState: initialState$
|
|
3205
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3246
|
+
initialState: initialState$4,
|
|
3247
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
|
|
3206
3248
|
reducers: {
|
|
3207
3249
|
setEnableDuplicateIssues: (state, action) => {
|
|
3208
3250
|
state.useIssueTemplate = action.payload;
|
|
@@ -3275,7 +3317,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3275
3317
|
function getLatestRevisionFromCache(formId2) {
|
|
3276
3318
|
return LATEST_REVISION_CACHE[formId2];
|
|
3277
3319
|
}
|
|
3278
|
-
const initialState$
|
|
3320
|
+
const initialState$3 = {
|
|
3279
3321
|
userForms: {},
|
|
3280
3322
|
revisions: {},
|
|
3281
3323
|
submissions: {},
|
|
@@ -3284,8 +3326,8 @@ var __publicField = (obj, key, value) => {
|
|
|
3284
3326
|
};
|
|
3285
3327
|
const userFormSlice = toolkit.createSlice({
|
|
3286
3328
|
name: "userForms",
|
|
3287
|
-
initialState: initialState$
|
|
3288
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
3329
|
+
initialState: initialState$3,
|
|
3330
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
|
|
3289
3331
|
reducers: {
|
|
3290
3332
|
setUserForms: (state, action) => {
|
|
3291
3333
|
state.userForms = {};
|
|
@@ -3589,12 +3631,12 @@ var __publicField = (obj, key, value) => {
|
|
|
3589
3631
|
return Object.values(userForms).filter((form) => !form.component_type).length;
|
|
3590
3632
|
});
|
|
3591
3633
|
const userFormReducer = userFormSlice.reducer;
|
|
3592
|
-
const initialState$
|
|
3634
|
+
const initialState$2 = {
|
|
3593
3635
|
emailDomains: {}
|
|
3594
3636
|
};
|
|
3595
3637
|
const emailDomainsSlice = toolkit.createSlice({
|
|
3596
3638
|
name: "emailDomains",
|
|
3597
|
-
initialState: initialState$
|
|
3639
|
+
initialState: initialState$2,
|
|
3598
3640
|
reducers: {
|
|
3599
3641
|
setEmailDomains: (state, action) => {
|
|
3600
3642
|
const emailDomains = {};
|
|
@@ -3621,6 +3663,166 @@ var __publicField = (obj, key, value) => {
|
|
|
3621
3663
|
(ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
|
|
3622
3664
|
);
|
|
3623
3665
|
const emailDomainsReducer = emailDomainsSlice.reducer;
|
|
3666
|
+
const initialState$1 = {
|
|
3667
|
+
documents: {}
|
|
3668
|
+
};
|
|
3669
|
+
const documentSlice = toolkit.createSlice({
|
|
3670
|
+
name: "documents",
|
|
3671
|
+
initialState: initialState$1,
|
|
3672
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
3673
|
+
Object.assign(state, initialState$1);
|
|
3674
|
+
}),
|
|
3675
|
+
reducers: {
|
|
3676
|
+
setDocuments: (state, action) => {
|
|
3677
|
+
if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
|
|
3678
|
+
throw new Error("Tried to use setIssues reducer with duplicate ID's");
|
|
3679
|
+
}
|
|
3680
|
+
for (const document2 of action.payload) {
|
|
3681
|
+
state.documents[document2.offline_id] = document2;
|
|
3682
|
+
}
|
|
3683
|
+
},
|
|
3684
|
+
addDocuments: (state, action) => {
|
|
3685
|
+
for (const document2 of action.payload) {
|
|
3686
|
+
if (document2.offline_id in state.documents) {
|
|
3687
|
+
throw new Error(
|
|
3688
|
+
`attempting to add a document with offline_id ${document2.offline_id} which already exists in state.documents.`
|
|
3689
|
+
);
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
for (const document2 of action.payload) {
|
|
3693
|
+
if (document2.parent_document && !!state.documents[document2.parent_document]) {
|
|
3694
|
+
const parentDocument = state.documents[document2.parent_document];
|
|
3695
|
+
state.documents[document2.parent_document] = {
|
|
3696
|
+
...parentDocument,
|
|
3697
|
+
children_documents: [...parentDocument.children_documents, document2.offline_id]
|
|
3698
|
+
};
|
|
3699
|
+
}
|
|
3700
|
+
state.documents[document2.offline_id] = document2;
|
|
3701
|
+
}
|
|
3702
|
+
},
|
|
3703
|
+
updateDocuments: (state, action) => {
|
|
3704
|
+
for (const document2 of action.payload) {
|
|
3705
|
+
if (!(document2.offline_id in state.documents)) {
|
|
3706
|
+
throw new Error(
|
|
3707
|
+
`attempting to update a document with offline_id ${document2.offline_id} which doesn't exists in state.documents.`
|
|
3708
|
+
);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
for (const document2 of action.payload) {
|
|
3712
|
+
state.documents[document2.offline_id] = {
|
|
3713
|
+
...state.documents[document2.offline_id],
|
|
3714
|
+
...document2
|
|
3715
|
+
};
|
|
3716
|
+
}
|
|
3717
|
+
},
|
|
3718
|
+
moveDocument: (state, action) => {
|
|
3719
|
+
const { documentId, targetDocumentId, position } = action.payload;
|
|
3720
|
+
if (!(documentId in state.documents)) {
|
|
3721
|
+
throw new Error(
|
|
3722
|
+
`attempting to move a document with offline_id ${documentId} which doesn't exist in state.documents`
|
|
3723
|
+
);
|
|
3724
|
+
}
|
|
3725
|
+
const document2 = state.documents[documentId];
|
|
3726
|
+
if (document2.parent_document && state.documents[document2.parent_document]) {
|
|
3727
|
+
const { children_documents } = state.documents[document2.parent_document];
|
|
3728
|
+
state.documents[document2.parent_document].children_documents.splice(
|
|
3729
|
+
children_documents.indexOf(document2.offline_id),
|
|
3730
|
+
1
|
|
3731
|
+
);
|
|
3732
|
+
}
|
|
3733
|
+
if (targetDocumentId) {
|
|
3734
|
+
const targetDocument = state.documents[targetDocumentId];
|
|
3735
|
+
const newParentDocument = (targetDocument == null ? void 0 : targetDocument.parent_document) ? state.documents[targetDocument.parent_document] : null;
|
|
3736
|
+
switch (position) {
|
|
3737
|
+
case "left":
|
|
3738
|
+
if (!newParentDocument) {
|
|
3739
|
+
throw new Error(
|
|
3740
|
+
"attempting to move a document to the left of a document with no parent_document"
|
|
3741
|
+
);
|
|
3742
|
+
}
|
|
3743
|
+
state.documents[targetDocument.parent_document].children_documents.splice(
|
|
3744
|
+
newParentDocument.children_documents.indexOf(targetDocument.offline_id),
|
|
3745
|
+
0,
|
|
3746
|
+
document2.offline_id
|
|
3747
|
+
);
|
|
3748
|
+
state.documents[documentId].parent_document = newParentDocument.offline_id;
|
|
3749
|
+
break;
|
|
3750
|
+
case "right":
|
|
3751
|
+
if (!newParentDocument) {
|
|
3752
|
+
throw new Error(
|
|
3753
|
+
"attempting to move a document to the left of a document with no parent_document"
|
|
3754
|
+
);
|
|
3755
|
+
}
|
|
3756
|
+
state.documents[targetDocument.parent_document].children_documents.splice(
|
|
3757
|
+
newParentDocument.children_documents.indexOf(targetDocument.offline_id) + 1,
|
|
3758
|
+
0,
|
|
3759
|
+
document2.offline_id
|
|
3760
|
+
);
|
|
3761
|
+
state.documents[documentId].parent_document = newParentDocument.offline_id;
|
|
3762
|
+
break;
|
|
3763
|
+
case "left-child":
|
|
3764
|
+
if (!targetDocument) {
|
|
3765
|
+
throw new Error(
|
|
3766
|
+
"attempting to move a document to the left-child of a document that doesn't exist"
|
|
3767
|
+
);
|
|
3768
|
+
}
|
|
3769
|
+
state.documents[targetDocumentId].children_documents.unshift(document2.offline_id);
|
|
3770
|
+
state.documents[documentId].parent_document = targetDocument.offline_id;
|
|
3771
|
+
break;
|
|
3772
|
+
case "right-child":
|
|
3773
|
+
if (!targetDocument) {
|
|
3774
|
+
throw new Error(
|
|
3775
|
+
"attempting to move a document to the left-child of a document that doesn't exist"
|
|
3776
|
+
);
|
|
3777
|
+
}
|
|
3778
|
+
state.documents[targetDocumentId].children_documents.push(document2.offline_id);
|
|
3779
|
+
state.documents[documentId].parent_document = targetDocument.offline_id;
|
|
3780
|
+
}
|
|
3781
|
+
} else {
|
|
3782
|
+
state.documents[documentId].parent_document = null;
|
|
3783
|
+
}
|
|
3784
|
+
},
|
|
3785
|
+
removeDocuments: (state, action) => {
|
|
3786
|
+
for (const documentId of action.payload) {
|
|
3787
|
+
if (!(documentId in state.documents)) {
|
|
3788
|
+
throw new Error(
|
|
3789
|
+
`attempting to delete a document with offline_id ${documentId} which doesn't exists in state.documents.`
|
|
3790
|
+
);
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
for (const documentId of action.payload) {
|
|
3794
|
+
const document2 = state.documents[documentId];
|
|
3795
|
+
if (document2.parent_document && !!state.documents[document2.parent_document]) {
|
|
3796
|
+
const parentDocument = state.documents[document2.parent_document];
|
|
3797
|
+
state.documents[document2.parent_document] = {
|
|
3798
|
+
...parentDocument,
|
|
3799
|
+
children_documents: parentDocument.children_documents.filter(
|
|
3800
|
+
(offline_id) => offline_id !== document2.offline_id
|
|
3801
|
+
)
|
|
3802
|
+
};
|
|
3803
|
+
}
|
|
3804
|
+
delete state.documents[documentId];
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
});
|
|
3809
|
+
const { setDocuments, addDocuments, updateDocuments, moveDocument, removeDocuments } = documentSlice.actions;
|
|
3810
|
+
const selectDocumentsMapping = (state) => state.documentsReducer.documents;
|
|
3811
|
+
const selectDocuments = toolkit.createSelector(
|
|
3812
|
+
[selectDocumentsMapping],
|
|
3813
|
+
(mapping) => Object.values(mapping)
|
|
3814
|
+
);
|
|
3815
|
+
const selectDocument = restructureCreateSelectorWithArgs(
|
|
3816
|
+
toolkit.createSelector(
|
|
3817
|
+
[selectDocumentsMapping, (_state, documentId) => documentId],
|
|
3818
|
+
(mapping, documentId) => mapping[documentId]
|
|
3819
|
+
)
|
|
3820
|
+
);
|
|
3821
|
+
const selectRootDocuments = toolkit.createSelector(
|
|
3822
|
+
[selectDocuments],
|
|
3823
|
+
(documents) => documents.filter((document2) => !document2.parent_document)
|
|
3824
|
+
);
|
|
3825
|
+
const documentsReducer = documentSlice.reducer;
|
|
3624
3826
|
const initialState = {
|
|
3625
3827
|
version: 0
|
|
3626
3828
|
};
|
|
@@ -3667,7 +3869,8 @@ var __publicField = (obj, key, value) => {
|
|
|
3667
3869
|
userReducer,
|
|
3668
3870
|
workspaceReducer,
|
|
3669
3871
|
emailDomainsReducer,
|
|
3670
|
-
licenseReducer
|
|
3872
|
+
licenseReducer,
|
|
3873
|
+
documentsReducer
|
|
3671
3874
|
};
|
|
3672
3875
|
const overmapReducer = toolkit.combineReducers(overmapReducers);
|
|
3673
3876
|
const resetStore = "RESET";
|
|
@@ -4198,10 +4401,12 @@ var __publicField = (obj, key, value) => {
|
|
|
4198
4401
|
blocks: [],
|
|
4199
4402
|
blockers: []
|
|
4200
4403
|
});
|
|
4404
|
+
const state = this.client.store.getState();
|
|
4201
4405
|
const allAttachments = {
|
|
4202
|
-
issue_attachments: Object.values(
|
|
4203
|
-
component_attachments: Object.values(
|
|
4204
|
-
component_type_attachments: Object.values(
|
|
4406
|
+
issue_attachments: Object.values(state.issueReducer.attachments),
|
|
4407
|
+
component_attachments: Object.values(state.componentReducer.attachments),
|
|
4408
|
+
component_type_attachments: Object.values(state.componentTypeReducer.attachments),
|
|
4409
|
+
project_attachments: Object.values(state.projectReducer.attachments)
|
|
4205
4410
|
};
|
|
4206
4411
|
return [allAttachments, promise];
|
|
4207
4412
|
}
|
|
@@ -4308,6 +4513,40 @@ var __publicField = (obj, key, value) => {
|
|
|
4308
4513
|
});
|
|
4309
4514
|
return [offlineAttachment, promise];
|
|
4310
4515
|
}
|
|
4516
|
+
async addProjectAttachment(attachmentPayload) {
|
|
4517
|
+
const { description: description2, project, file_sha1, offline_id } = attachmentPayload;
|
|
4518
|
+
if (!attachmentPayload.file.objectURL) {
|
|
4519
|
+
throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
|
|
4520
|
+
}
|
|
4521
|
+
const offlineAttachment = {
|
|
4522
|
+
...attachmentPayload,
|
|
4523
|
+
file: attachmentPayload.file.objectURL,
|
|
4524
|
+
file_name: attachmentPayload.file.name,
|
|
4525
|
+
file_type: attachmentPayload.file.type
|
|
4526
|
+
};
|
|
4527
|
+
await this.client.files.addCache(attachmentPayload.file, file_sha1);
|
|
4528
|
+
this.client.store.dispatch(addProjectAttachment(offlineAttachment));
|
|
4529
|
+
const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
|
|
4530
|
+
const promise = this.enqueueRequest({
|
|
4531
|
+
description: "Create attachment",
|
|
4532
|
+
method: HttpMethod.POST,
|
|
4533
|
+
url: `/components/types/${project}/attach/`,
|
|
4534
|
+
blocks: [offline_id, project.toString()],
|
|
4535
|
+
blockers: [file_sha1],
|
|
4536
|
+
payload: {
|
|
4537
|
+
offline_id,
|
|
4538
|
+
project,
|
|
4539
|
+
description: description2 ?? "",
|
|
4540
|
+
submitted_at: (/* @__PURE__ */ new Date()).getTime() / 1e3,
|
|
4541
|
+
...fileProps
|
|
4542
|
+
}
|
|
4543
|
+
});
|
|
4544
|
+
promise.catch((error2) => {
|
|
4545
|
+
this.client.store.dispatch(removeProjectAttachment(offlineAttachment.offline_id));
|
|
4546
|
+
throw error2;
|
|
4547
|
+
});
|
|
4548
|
+
return [offlineAttachment, promise];
|
|
4549
|
+
}
|
|
4311
4550
|
/** the outer Promise is needed to await the hashing of each file, which is required before offline use. If wanting to
|
|
4312
4551
|
* attach promise handlers to the request to add the attachment in the backend, apply it on the promise returned from the
|
|
4313
4552
|
* OptimisticModelResult. */
|
|
@@ -4368,6 +4607,25 @@ var __publicField = (obj, key, value) => {
|
|
|
4368
4607
|
return photoAttachmentPromise(file);
|
|
4369
4608
|
});
|
|
4370
4609
|
}
|
|
4610
|
+
attachFilesToProjectType(filesToSubmit, projectId) {
|
|
4611
|
+
return filesToSubmit.map((file) => {
|
|
4612
|
+
if (!(file instanceof File)) {
|
|
4613
|
+
throw new Error("Expected a File instance.");
|
|
4614
|
+
}
|
|
4615
|
+
const photoAttachmentPromise = async (file2) => {
|
|
4616
|
+
const hash = await hashFile(file2);
|
|
4617
|
+
const attachment = offline({
|
|
4618
|
+
file: file2,
|
|
4619
|
+
file_name: file2.name,
|
|
4620
|
+
file_type: file2.type,
|
|
4621
|
+
project: projectId,
|
|
4622
|
+
file_sha1: hash
|
|
4623
|
+
});
|
|
4624
|
+
return this.addProjectAttachment(attachment);
|
|
4625
|
+
};
|
|
4626
|
+
return photoAttachmentPromise(file);
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
4371
4629
|
async replaceIssueAttachmentFile(attachmentId, newFile) {
|
|
4372
4630
|
const { store } = this.client;
|
|
4373
4631
|
const attachment = store.getState().issueReducer.attachments[attachmentId];
|
|
@@ -4595,6 +4853,22 @@ var __publicField = (obj, key, value) => {
|
|
|
4595
4853
|
blocks: [componentTypeAttachmentId]
|
|
4596
4854
|
});
|
|
4597
4855
|
}
|
|
4856
|
+
deleteProjectAttachment(projectAttachmentId) {
|
|
4857
|
+
const { store } = this.client;
|
|
4858
|
+
const attachment = selectProjectAttachmentMapping(store.getState())[projectAttachmentId];
|
|
4859
|
+
if (!attachment) {
|
|
4860
|
+
throw new Error(`Attachment ${projectAttachmentId} not found`);
|
|
4861
|
+
}
|
|
4862
|
+
store.dispatch(removeProjectAttachment(projectAttachmentId));
|
|
4863
|
+
void this.client.files.removeCache(attachment.file_sha1);
|
|
4864
|
+
return this.enqueueRequest({
|
|
4865
|
+
description: "Delete attachment",
|
|
4866
|
+
method: HttpMethod.DELETE,
|
|
4867
|
+
url: `/attachments/projects/${projectAttachmentId}/`,
|
|
4868
|
+
blockers: [projectAttachmentId],
|
|
4869
|
+
blocks: [projectAttachmentId]
|
|
4870
|
+
});
|
|
4871
|
+
}
|
|
4598
4872
|
}
|
|
4599
4873
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
4600
4874
|
function parseTokens(response) {
|
|
@@ -5707,11 +5981,13 @@ var __publicField = (obj, key, value) => {
|
|
|
5707
5981
|
if (currentProjectId) {
|
|
5708
5982
|
const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
|
|
5709
5983
|
void promise.then((result) => {
|
|
5710
|
-
const { issue_attachments, component_type_attachments, component_attachments } = result;
|
|
5984
|
+
const { issue_attachments, component_type_attachments, component_attachments, project_attachments } = result;
|
|
5711
5985
|
store.dispatch(setIssueAttachments(issue_attachments));
|
|
5712
5986
|
store.dispatch(setComponentAttachments(component_attachments));
|
|
5713
5987
|
store.dispatch(setComponentTypeAttachments(component_type_attachments));
|
|
5988
|
+
store.dispatch(setProjectAttachments(project_attachments));
|
|
5714
5989
|
});
|
|
5990
|
+
void this.client.documents.refreshStore();
|
|
5715
5991
|
}
|
|
5716
5992
|
store.dispatch(setIsFetchingInitialData(false));
|
|
5717
5993
|
if (overwrite) {
|
|
@@ -5950,12 +6226,13 @@ var __publicField = (obj, key, value) => {
|
|
|
5950
6226
|
}
|
|
5951
6227
|
const filesToDelete = selectProjectFiles(state).filter((file) => file.project === projectId);
|
|
5952
6228
|
store.dispatch(removeProjectFilesOfProject(project.id));
|
|
6229
|
+
const attachmentsOfProject = selectAttachmentsOfProject(project.id)(state);
|
|
6230
|
+
store.dispatch(removeProjectAttachments(attachmentsOfProject.map(({ offline_id }) => offline_id)));
|
|
5953
6231
|
const projectAccesses = selectProjectAccesses(state);
|
|
5954
6232
|
store.dispatch(removeProjectAccessesOfProject(project.id));
|
|
5955
6233
|
store.dispatch({ type: "rehydrated/setRehydrated", payload: false });
|
|
5956
6234
|
store.dispatch(deleteProject(project));
|
|
5957
|
-
const
|
|
5958
|
-
const license = licenseSelector(state);
|
|
6235
|
+
const license = selectLicenseForProject(project.id)(state);
|
|
5959
6236
|
if (license) {
|
|
5960
6237
|
store.dispatch(updateLicense({ ...license, project: null }));
|
|
5961
6238
|
}
|
|
@@ -5972,6 +6249,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5972
6249
|
store.dispatch(setProjects(Object.values(projects)));
|
|
5973
6250
|
store.dispatch(setProjectAccesses(Object.values(projectAccesses)));
|
|
5974
6251
|
store.dispatch(addOrReplaceProjectFiles(filesToDelete));
|
|
6252
|
+
store.dispatch(setProjectAttachments(attachmentsOfProject));
|
|
5975
6253
|
store.dispatch(setActiveProjectId(activeProjectId));
|
|
5976
6254
|
store.dispatch({ type: "rehydrated/setRehydrated", payload: true });
|
|
5977
6255
|
if (license) {
|
|
@@ -6999,6 +7277,135 @@ var __publicField = (obj, key, value) => {
|
|
|
6999
7277
|
});
|
|
7000
7278
|
}
|
|
7001
7279
|
}
|
|
7280
|
+
class DocumentService extends BaseApiService {
|
|
7281
|
+
add(document2) {
|
|
7282
|
+
const { store } = this.client;
|
|
7283
|
+
const currentUserId = store.getState().userReducer.currentUser.id;
|
|
7284
|
+
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7285
|
+
const offlineDocument = offline({ ...document2, created_by: currentUserId });
|
|
7286
|
+
store.dispatch(addDocuments([offlineDocument]));
|
|
7287
|
+
const promise = this.enqueueRequest({
|
|
7288
|
+
description: "Create Document",
|
|
7289
|
+
method: HttpMethod.POST,
|
|
7290
|
+
url: `/projects/${activeProjectId}/create-document/`,
|
|
7291
|
+
payload: { ...offlineDocument },
|
|
7292
|
+
// if adding as a child of another document, need that document to exist first
|
|
7293
|
+
blockers: offlineDocument.parent_document ? [offlineDocument.parent_document] : [],
|
|
7294
|
+
blocks: [offlineDocument.offline_id]
|
|
7295
|
+
});
|
|
7296
|
+
promise.catch(() => {
|
|
7297
|
+
store.dispatch(removeDocuments([offlineDocument.offline_id]));
|
|
7298
|
+
});
|
|
7299
|
+
return [offlineDocument, promise];
|
|
7300
|
+
}
|
|
7301
|
+
update(document2) {
|
|
7302
|
+
const { store } = this.client;
|
|
7303
|
+
const documentToBeUpdated = store.getState().documentsReducer.documents[document2.offline_id];
|
|
7304
|
+
if (!documentToBeUpdated) {
|
|
7305
|
+
throw new Error(
|
|
7306
|
+
`attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
|
|
7307
|
+
);
|
|
7308
|
+
}
|
|
7309
|
+
store.dispatch(updateDocuments([documentToBeUpdated]));
|
|
7310
|
+
const promise = this.enqueueRequest({
|
|
7311
|
+
description: "Delete Document",
|
|
7312
|
+
method: HttpMethod.DELETE,
|
|
7313
|
+
url: `/documents/${document2.offline_id}`,
|
|
7314
|
+
blockers: [document2.offline_id],
|
|
7315
|
+
blocks: [document2.offline_id]
|
|
7316
|
+
});
|
|
7317
|
+
promise.catch(() => {
|
|
7318
|
+
setDocuments([documentToBeUpdated]);
|
|
7319
|
+
});
|
|
7320
|
+
const fullDocument = store.getState().documentsReducer.documents[document2.offline_id];
|
|
7321
|
+
return [fullDocument, promise];
|
|
7322
|
+
}
|
|
7323
|
+
move(documentId, targetDocumentId, position) {
|
|
7324
|
+
const { store } = this.client;
|
|
7325
|
+
const documentsMapping = selectDocumentsMapping(store.getState());
|
|
7326
|
+
const documentsToRevertIfMoveFails = [];
|
|
7327
|
+
const documentBeingMoved = documentsMapping[documentId];
|
|
7328
|
+
if (!documentBeingMoved) {
|
|
7329
|
+
throw new Error(
|
|
7330
|
+
`attempting to move a document with offline_id ${documentId} that does not exist in store.documents`
|
|
7331
|
+
);
|
|
7332
|
+
}
|
|
7333
|
+
documentsToRevertIfMoveFails.push(documentBeingMoved);
|
|
7334
|
+
if (documentBeingMoved.parent_document) {
|
|
7335
|
+
documentsToRevertIfMoveFails.push(documentsMapping[documentBeingMoved.parent_document]);
|
|
7336
|
+
}
|
|
7337
|
+
if (targetDocumentId) {
|
|
7338
|
+
const targetDocument = documentsMapping[targetDocumentId];
|
|
7339
|
+
if (!targetDocument) {
|
|
7340
|
+
throw new Error(
|
|
7341
|
+
`attempting to move a document to target with offline_id ${targetDocumentId} that does not exist in store.documents`
|
|
7342
|
+
);
|
|
7343
|
+
}
|
|
7344
|
+
documentsToRevertIfMoveFails.push(targetDocument);
|
|
7345
|
+
if (targetDocument.parent_document) {
|
|
7346
|
+
documentsToRevertIfMoveFails.push(documentsMapping[targetDocument.parent_document]);
|
|
7347
|
+
}
|
|
7348
|
+
}
|
|
7349
|
+
store.dispatch(moveDocument({ documentId, targetDocumentId, position }));
|
|
7350
|
+
const promise = this.enqueueRequest({
|
|
7351
|
+
description: "Delete Document",
|
|
7352
|
+
method: HttpMethod.PATCH,
|
|
7353
|
+
url: `/documents/${documentId}/move/`,
|
|
7354
|
+
queryParams: {
|
|
7355
|
+
target: targetDocumentId ?? void 0,
|
|
7356
|
+
position
|
|
7357
|
+
},
|
|
7358
|
+
blockers: [documentId],
|
|
7359
|
+
blocks: []
|
|
7360
|
+
});
|
|
7361
|
+
promise.then((result) => {
|
|
7362
|
+
setDocuments(result);
|
|
7363
|
+
}).catch(() => {
|
|
7364
|
+
setDocuments(documentsToRevertIfMoveFails);
|
|
7365
|
+
});
|
|
7366
|
+
return promise;
|
|
7367
|
+
}
|
|
7368
|
+
delete(documentId) {
|
|
7369
|
+
const { store } = this.client;
|
|
7370
|
+
const documentsMapping = selectDocumentsMapping(store.getState());
|
|
7371
|
+
const documentToBeDeleted = documentsMapping[documentId];
|
|
7372
|
+
if (!documentToBeDeleted) {
|
|
7373
|
+
throw new Error(
|
|
7374
|
+
`attempting to delete a document with offline_id ${documentId} that does not exist in store.documents`
|
|
7375
|
+
);
|
|
7376
|
+
}
|
|
7377
|
+
const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
|
|
7378
|
+
store.dispatch(removeDocuments([documentId]));
|
|
7379
|
+
const promise = this.enqueueRequest({
|
|
7380
|
+
description: "Delete Document",
|
|
7381
|
+
method: HttpMethod.DELETE,
|
|
7382
|
+
url: `/documents/${documentId}`,
|
|
7383
|
+
blockers: [documentId],
|
|
7384
|
+
blocks: []
|
|
7385
|
+
});
|
|
7386
|
+
promise.then((documentsToUpdate) => {
|
|
7387
|
+
store.dispatch(updateDocuments(documentsToUpdate));
|
|
7388
|
+
}).catch(() => {
|
|
7389
|
+
store.dispatch(setDocuments([documentToBeDeleted]));
|
|
7390
|
+
if (parentDocument) {
|
|
7391
|
+
store.dispatch(setDocuments([parentDocument]));
|
|
7392
|
+
}
|
|
7393
|
+
});
|
|
7394
|
+
return promise;
|
|
7395
|
+
}
|
|
7396
|
+
async refreshStore() {
|
|
7397
|
+
const { store } = this.client;
|
|
7398
|
+
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7399
|
+
const result = await this.enqueueRequest({
|
|
7400
|
+
description: "Get project documents",
|
|
7401
|
+
method: HttpMethod.GET,
|
|
7402
|
+
url: `/documents/projects/${activeProjectId}`,
|
|
7403
|
+
blockers: [],
|
|
7404
|
+
blocks: []
|
|
7405
|
+
});
|
|
7406
|
+
store.dispatch(setDocuments(result));
|
|
7407
|
+
}
|
|
7408
|
+
}
|
|
7002
7409
|
class OvermapSDK {
|
|
7003
7410
|
constructor(apiUrl, store) {
|
|
7004
7411
|
__publicField(this, "API_URL");
|
|
@@ -7025,6 +7432,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7025
7432
|
__publicField(this, "emailVerification", new EmailVerificationService(this));
|
|
7026
7433
|
__publicField(this, "emailDomains", new EmailDomainsService(this));
|
|
7027
7434
|
__publicField(this, "licenses", new LicenseService(this));
|
|
7435
|
+
__publicField(this, "documents", new DocumentService(this));
|
|
7028
7436
|
this.API_URL = apiUrl;
|
|
7029
7437
|
this.store = store;
|
|
7030
7438
|
}
|
|
@@ -15014,6 +15422,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15014
15422
|
exports2.DEFAULT_ISSUE_STATUS = DEFAULT_ISSUE_STATUS;
|
|
15015
15423
|
exports2.DateField = DateField;
|
|
15016
15424
|
exports2.DateInput = DateInput;
|
|
15425
|
+
exports2.DocumentService = DocumentService;
|
|
15017
15426
|
exports2.EmailDomainsService = EmailDomainsService;
|
|
15018
15427
|
exports2.EmailVerificationService = EmailVerificationService;
|
|
15019
15428
|
exports2.FEATHER_ICON_SIZE = FEATHER_ICON_SIZE;
|
|
@@ -15098,6 +15507,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15098
15507
|
exports2.addComponentTypeAttachment = addComponentTypeAttachment;
|
|
15099
15508
|
exports2.addComponentTypeAttachments = addComponentTypeAttachments;
|
|
15100
15509
|
exports2.addComponentsInBatches = addComponentsInBatches;
|
|
15510
|
+
exports2.addDocuments = addDocuments;
|
|
15101
15511
|
exports2.addEmailDomain = addEmailDomain;
|
|
15102
15512
|
exports2.addFavouriteProjectId = addFavouriteProjectId;
|
|
15103
15513
|
exports2.addIssue = addIssue;
|
|
@@ -15110,6 +15520,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15110
15520
|
exports2.addOrReplaceProjectFiles = addOrReplaceProjectFiles;
|
|
15111
15521
|
exports2.addOrReplaceProjects = addOrReplaceProjects;
|
|
15112
15522
|
exports2.addOrReplaceWorkspaces = addOrReplaceWorkspaces;
|
|
15523
|
+
exports2.addProjectAttachment = addProjectAttachment;
|
|
15524
|
+
exports2.addProjectAttachments = addProjectAttachments;
|
|
15113
15525
|
exports2.addStageCompletion = addStageCompletion;
|
|
15114
15526
|
exports2.addStageCompletions = addStageCompletions;
|
|
15115
15527
|
exports2.addStages = addStages;
|
|
@@ -15161,6 +15573,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15161
15573
|
exports2.deserialize = deserialize;
|
|
15162
15574
|
exports2.deserializeField = deserializeField;
|
|
15163
15575
|
exports2.discard = discard;
|
|
15576
|
+
exports2.documentSlice = documentSlice;
|
|
15577
|
+
exports2.documentsReducer = documentsReducer;
|
|
15164
15578
|
exports2.downloadFile = downloadFile;
|
|
15165
15579
|
exports2.downloadInMemoryFile = downloadInMemoryFile;
|
|
15166
15580
|
exports2.emailDomainsReducer = emailDomainsReducer;
|
|
@@ -15216,6 +15630,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15216
15630
|
exports2.markerCoordinatesToText = markerCoordinatesToText;
|
|
15217
15631
|
exports2.markerToCoordinates = markerToCoordinates;
|
|
15218
15632
|
exports2.memoize = memoize;
|
|
15633
|
+
exports2.moveDocument = moveDocument;
|
|
15219
15634
|
exports2.offline = offline;
|
|
15220
15635
|
exports2.offsetPositionByMeters = offsetPositionByMeters;
|
|
15221
15636
|
exports2.onlyUniqueHashes = onlyUniqueHashes;
|
|
@@ -15251,6 +15666,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15251
15666
|
exports2.removeComponentAttachments = removeComponentAttachments;
|
|
15252
15667
|
exports2.removeComponentTypeAttachment = removeComponentTypeAttachment;
|
|
15253
15668
|
exports2.removeComponentTypeAttachments = removeComponentTypeAttachments;
|
|
15669
|
+
exports2.removeDocuments = removeDocuments;
|
|
15254
15670
|
exports2.removeEmailDomain = removeEmailDomain;
|
|
15255
15671
|
exports2.removeFavouriteProjectId = removeFavouriteProjectId;
|
|
15256
15672
|
exports2.removeIssue = removeIssue;
|
|
@@ -15259,6 +15675,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15259
15675
|
exports2.removeOrganizationAccess = removeOrganizationAccess;
|
|
15260
15676
|
exports2.removeProjectAccess = removeProjectAccess;
|
|
15261
15677
|
exports2.removeProjectAccessesOfProject = removeProjectAccessesOfProject;
|
|
15678
|
+
exports2.removeProjectAttachment = removeProjectAttachment;
|
|
15679
|
+
exports2.removeProjectAttachments = removeProjectAttachments;
|
|
15262
15680
|
exports2.removeProjectFile = removeProjectFile;
|
|
15263
15681
|
exports2.removeProjectFilesOfProject = removeProjectFilesOfProject;
|
|
15264
15682
|
exports2.removeRecentIssue = removeRecentIssue;
|
|
@@ -15292,6 +15710,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15292
15710
|
exports2.selectAllAttachments = selectAllAttachments;
|
|
15293
15711
|
exports2.selectAllComponentAttachments = selectAllComponentAttachments;
|
|
15294
15712
|
exports2.selectAllComponentTypeAttachments = selectAllComponentTypeAttachments;
|
|
15713
|
+
exports2.selectAllProjectAttachments = selectAllProjectAttachments;
|
|
15295
15714
|
exports2.selectAppearance = selectAppearance;
|
|
15296
15715
|
exports2.selectAttachmentsOfComponent = selectAttachmentsOfComponent;
|
|
15297
15716
|
exports2.selectAttachmentsOfComponentByType = selectAttachmentsOfComponentByType;
|
|
@@ -15299,6 +15718,8 @@ var __publicField = (obj, key, value) => {
|
|
|
15299
15718
|
exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
|
|
15300
15719
|
exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
|
|
15301
15720
|
exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
|
|
15721
|
+
exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
|
|
15722
|
+
exports2.selectAttachmentsOfProjectByType = selectAttachmentsOfProjectByType;
|
|
15302
15723
|
exports2.selectCategories = selectCategories;
|
|
15303
15724
|
exports2.selectCategoriesOfWorkspace = selectCategoriesOfWorkspace;
|
|
15304
15725
|
exports2.selectCategory = selectCategory;
|
|
@@ -15326,6 +15747,9 @@ var __publicField = (obj, key, value) => {
|
|
|
15326
15747
|
exports2.selectCreateProjectType = selectCreateProjectType;
|
|
15327
15748
|
exports2.selectCurrentUser = selectCurrentUser;
|
|
15328
15749
|
exports2.selectDeletedRequests = selectDeletedRequests;
|
|
15750
|
+
exports2.selectDocument = selectDocument;
|
|
15751
|
+
exports2.selectDocuments = selectDocuments;
|
|
15752
|
+
exports2.selectDocumentsMapping = selectDocumentsMapping;
|
|
15329
15753
|
exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
|
|
15330
15754
|
exports2.selectEnableClustering = selectEnableClustering;
|
|
15331
15755
|
exports2.selectEnableDuplicateIssues = selectEnableDuplicateIssues;
|
|
@@ -15379,6 +15803,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15379
15803
|
exports2.selectProjectAccessForUser = selectProjectAccessForUser;
|
|
15380
15804
|
exports2.selectProjectAccessUserMapping = selectProjectAccessUserMapping;
|
|
15381
15805
|
exports2.selectProjectAccesses = selectProjectAccesses;
|
|
15806
|
+
exports2.selectProjectAttachmentMapping = selectProjectAttachmentMapping;
|
|
15382
15807
|
exports2.selectProjectFileVisibility = selectProjectFileVisibility;
|
|
15383
15808
|
exports2.selectProjectFiles = selectProjectFiles;
|
|
15384
15809
|
exports2.selectProjectUsersAsMapping = selectProjectUsersAsMapping;
|
|
@@ -15391,6 +15816,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15391
15816
|
exports2.selectRehydrated = selectRehydrated;
|
|
15392
15817
|
exports2.selectRevisionAttachments = selectRevisionAttachments;
|
|
15393
15818
|
exports2.selectRevisionsForForm = selectRevisionsForForm;
|
|
15819
|
+
exports2.selectRootDocuments = selectRootDocuments;
|
|
15394
15820
|
exports2.selectShowTooltips = selectShowTooltips;
|
|
15395
15821
|
exports2.selectSortedEmailDomains = selectSortedEmailDomains;
|
|
15396
15822
|
exports2.selectSortedOrganizationLicenses = selectSortedOrganizationLicenses;
|
|
@@ -15432,6 +15858,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15432
15858
|
exports2.setComponents = setComponents;
|
|
15433
15859
|
exports2.setCreateProjectType = setCreateProjectType;
|
|
15434
15860
|
exports2.setCurrentUser = setCurrentUser;
|
|
15861
|
+
exports2.setDocuments = setDocuments;
|
|
15435
15862
|
exports2.setEmailDomains = setEmailDomains;
|
|
15436
15863
|
exports2.setEnableClustering = setEnableClustering;
|
|
15437
15864
|
exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
|
|
@@ -15449,6 +15876,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15449
15876
|
exports2.setOrganizations = setOrganizations;
|
|
15450
15877
|
exports2.setProfilePicture = setProfilePicture;
|
|
15451
15878
|
exports2.setProjectAccesses = setProjectAccesses;
|
|
15879
|
+
exports2.setProjectAttachments = setProjectAttachments;
|
|
15452
15880
|
exports2.setProjectFileVisible = setProjectFileVisible;
|
|
15453
15881
|
exports2.setProjects = setProjects;
|
|
15454
15882
|
exports2.setSectionExpanded = setSectionExpanded;
|
|
@@ -15482,6 +15910,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15482
15910
|
exports2.updateComponent = updateComponent;
|
|
15483
15911
|
exports2.updateComponentAttachment = updateComponentAttachment;
|
|
15484
15912
|
exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
|
|
15913
|
+
exports2.updateDocuments = updateDocuments;
|
|
15485
15914
|
exports2.updateIssue = updateIssue;
|
|
15486
15915
|
exports2.updateIssueAttachment = updateIssueAttachment;
|
|
15487
15916
|
exports2.updateLicense = updateLicense;
|
|
@@ -15489,6 +15918,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15489
15918
|
exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
|
|
15490
15919
|
exports2.updateOrganizationAccess = updateOrganizationAccess;
|
|
15491
15920
|
exports2.updateProjectAccess = updateProjectAccess;
|
|
15921
|
+
exports2.updateProjectAttachment = updateProjectAttachment;
|
|
15492
15922
|
exports2.updateStages = updateStages;
|
|
15493
15923
|
exports2.useAppDispatch = useAppDispatch;
|
|
15494
15924
|
exports2.useAppSelector = useAppSelector;
|