@overmap-ai/core 1.0.71-fields.9 → 1.0.71-org-projs-only.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.
Files changed (53) hide show
  1. package/dist/overmap-core.js +1062 -1970
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +1063 -1971
  4. package/dist/overmap-core.umd.cjs.map +1 -1
  5. package/dist/sdk/services/AssetAttachmentService.d.ts +8 -32
  6. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +9 -32
  7. package/dist/sdk/services/BaseAttachmentService.d.ts +20 -18
  8. package/dist/sdk/services/BaseUploadService.d.ts +1 -2
  9. package/dist/sdk/services/DocumentAttachmentService.d.ts +8 -30
  10. package/dist/sdk/services/FormService.d.ts +15 -13
  11. package/dist/sdk/services/FormSubmissionService.d.ts +29 -10
  12. package/dist/sdk/services/GeoImageService.d.ts +1 -1
  13. package/dist/sdk/services/IssueAssociationService.d.ts +2 -2
  14. package/dist/sdk/services/IssueAttachmentService.d.ts +8 -31
  15. package/dist/sdk/services/IssueService.d.ts +3 -0
  16. package/dist/sdk/services/ProjectAttachmentService.d.ts +8 -31
  17. package/dist/sdk/services/TeamService.d.ts +1 -1
  18. package/dist/sdk/services/WorkspaceService.d.ts +1 -1
  19. package/dist/sdk/services/index.d.ts +0 -11
  20. package/dist/store/slices/formRevisionSlice.d.ts +15 -14
  21. package/dist/store/slices/formSlice.d.ts +5 -1
  22. package/dist/store/slices/formSubmissionSlice.d.ts +6 -0
  23. package/dist/store/slices/index.d.ts +0 -8
  24. package/dist/store/store.d.ts +1 -9
  25. package/dist/typings/files.d.ts +4 -8
  26. package/dist/typings/models/assets.d.ts +0 -15
  27. package/dist/typings/models/attachments.d.ts +6 -1
  28. package/dist/typings/models/forms.d.ts +113 -12
  29. package/dist/typings/models/index.d.ts +0 -1
  30. package/dist/typings/models/issues.d.ts +0 -15
  31. package/dist/typings/models/store.d.ts +1 -9
  32. package/dist/utils/file.d.ts +2 -2
  33. package/package.json +3 -5
  34. package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +0 -12
  35. package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +0 -20
  36. package/dist/sdk/services/AssetTypeFieldsAttachmentService.d.ts +0 -12
  37. package/dist/sdk/services/AssetTypeFieldsService.d.ts +0 -8
  38. package/dist/sdk/services/FormRevisionAttachmentService.d.ts +0 -12
  39. package/dist/sdk/services/FormRevisionService.d.ts +0 -8
  40. package/dist/sdk/services/FormSubmissionAttachmentService.d.ts +0 -13
  41. package/dist/sdk/services/IssueTypeFieldValuesAttachmentService.d.ts +0 -13
  42. package/dist/sdk/services/IssueTypeFieldValuesService.d.ts +0 -10
  43. package/dist/sdk/services/IssueTypeFieldsAttachmentService.d.ts +0 -12
  44. package/dist/sdk/services/IssueTypeFieldsService.d.ts +0 -8
  45. package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +0 -52
  46. package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +0 -53
  47. package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +0 -52
  48. package/dist/store/slices/assetTypeFieldsSlice.d.ts +0 -53
  49. package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +0 -52
  50. package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +0 -52
  51. package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +0 -52
  52. package/dist/store/slices/issueTypeFieldsSlice.d.ts +0 -54
  53. package/dist/typings/models/fields.d.ts +0 -16
@@ -758,15 +758,15 @@ const wrapMigration = (migrator) => (state) => {
758
758
  };
759
759
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
760
760
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
761
- const initialState$J = {
761
+ const initialState$B = {
762
762
  accessToken: "",
763
763
  refreshToken: "",
764
764
  isLoggedIn: false
765
765
  };
766
766
  const authSlice = createSlice({
767
767
  name: "auth",
768
- initialState: initialState$J,
769
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$J)),
768
+ initialState: initialState$B,
769
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
770
770
  reducers: {
771
771
  setTokens: (state, action) => {
772
772
  state.accessToken = action.payload.accessToken;
@@ -854,11 +854,11 @@ function createModelAdapter(computeModelId) {
854
854
  };
855
855
  }
856
856
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
857
- const initialState$I = categoryAdapter.getInitialState({});
857
+ const initialState$A = categoryAdapter.getInitialState({});
858
858
  const categorySlice = createSlice({
859
859
  name: "categories",
860
- initialState: initialState$I,
861
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$I)),
860
+ initialState: initialState$A,
861
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
862
862
  reducers: {
863
863
  initializeCategories: categoryAdapter.initialize,
864
864
  addCategory: categoryAdapter.addOne,
@@ -902,11 +902,11 @@ const selectIssueCountOfCategory = (categoryId) => (state) => {
902
902
  };
903
903
  const categoryReducer = categorySlice.reducer;
904
904
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
905
- const initialState$H = assetAdapter.getInitialState({});
905
+ const initialState$z = assetAdapter.getInitialState({});
906
906
  const assetSlice = createSlice({
907
907
  name: "assets",
908
- initialState: initialState$H,
909
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$H)),
908
+ initialState: initialState$z,
909
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
910
910
  reducers: {
911
911
  initializeAssets: assetAdapter.initialize,
912
912
  addAsset: assetAdapter.addOne,
@@ -958,11 +958,11 @@ const selectNumberOfAssetsOfAssetType = (assetTypeId) => (state) => {
958
958
  };
959
959
  const assetReducer = assetSlice.reducer;
960
960
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
961
- const initialState$G = assetAttachmentAdapter.getInitialState({});
961
+ const initialState$y = assetAttachmentAdapter.getInitialState({});
962
962
  const assetAttachmentSlice = createSlice({
963
963
  name: "assetAttachments",
964
- initialState: initialState$G,
965
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$G)),
964
+ initialState: initialState$y,
965
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
966
966
  reducers: {
967
967
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
968
968
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -1023,11 +1023,11 @@ const assetAttachmentReducer = assetAttachmentSlice.reducer;
1023
1023
  const assetStageCompletionAdapter = createModelAdapter(
1024
1024
  (stageCompletion) => stageCompletion.offline_id
1025
1025
  );
1026
- const initialState$F = assetStageCompletionAdapter.getInitialState({});
1026
+ const initialState$x = assetStageCompletionAdapter.getInitialState({});
1027
1027
  const assetStageCompletionSlice = createSlice({
1028
1028
  name: "assetStageCompletions",
1029
- initialState: initialState$F,
1030
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$F)),
1029
+ initialState: initialState$x,
1030
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1031
1031
  reducers: {
1032
1032
  initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
1033
1033
  addAssetStageCompletion: assetStageCompletionAdapter.addOne,
@@ -1089,11 +1089,11 @@ const selectAssetStageCompletionsByIds = restructureCreateSelectorWithArgs(
1089
1089
  );
1090
1090
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1091
1091
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1092
- const initialState$E = assetStageAdapter.getInitialState({});
1092
+ const initialState$w = assetStageAdapter.getInitialState({});
1093
1093
  const assetStageSlice = createSlice({
1094
1094
  name: "assetStages",
1095
- initialState: initialState$E,
1096
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$E)),
1095
+ initialState: initialState$w,
1096
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1097
1097
  reducers: {
1098
1098
  initializeAssetStages: assetStageAdapter.initialize,
1099
1099
  setAssetStage: assetStageAdapter.setOne,
@@ -1173,11 +1173,11 @@ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1173
1173
  })
1174
1174
  );
1175
1175
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1176
- const initialState$D = assetTypeAdapter.getInitialState({});
1176
+ const initialState$v = assetTypeAdapter.getInitialState({});
1177
1177
  const assetTypeSlice = createSlice({
1178
1178
  name: "assetTypes",
1179
- initialState: initialState$D,
1180
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$D)),
1179
+ initialState: initialState$v,
1180
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1181
1181
  reducers: {
1182
1182
  initializeAssetTypes: assetTypeAdapter.initialize,
1183
1183
  setAssetType: assetTypeAdapter.setOne,
@@ -1230,11 +1230,11 @@ const assetTypeReducer = assetTypeSlice.reducer;
1230
1230
  const assetTypeAttachmentAdapter = createModelAdapter(
1231
1231
  (attachment) => attachment.offline_id
1232
1232
  );
1233
- const initialState$C = assetTypeAttachmentAdapter.getInitialState({});
1233
+ const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1234
1234
  const assetTypeAttachmentSlice = createSlice({
1235
1235
  name: "assetTypeAttachments",
1236
- initialState: initialState$C,
1237
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
1236
+ initialState: initialState$u,
1237
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1238
1238
  reducers: {
1239
1239
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1240
1240
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1293,12 +1293,12 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1293
1293
  );
1294
1294
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1295
1295
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1296
- const initialState$B = issueAdapter.getInitialState({});
1296
+ const initialState$t = issueAdapter.getInitialState({});
1297
1297
  const issueSlice = createSlice({
1298
1298
  name: "issues",
1299
- initialState: initialState$B,
1299
+ initialState: initialState$t,
1300
1300
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1301
- Object.assign(state, initialState$B);
1301
+ Object.assign(state, initialState$t);
1302
1302
  }),
1303
1303
  reducers: {
1304
1304
  initializeIssues: issueAdapter.initialize,
@@ -1330,12 +1330,12 @@ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1330
1330
  );
1331
1331
  const issueReducer = issueSlice.reducer;
1332
1332
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1333
- const initialState$A = issueTypeAdapter.getInitialState({});
1333
+ const initialState$s = issueTypeAdapter.getInitialState({});
1334
1334
  const issueTypeSlice = createSlice({
1335
1335
  name: "issueTypes",
1336
- initialState: initialState$A,
1336
+ initialState: initialState$s,
1337
1337
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1338
- Object.assign(state, initialState$A);
1338
+ Object.assign(state, initialState$s);
1339
1339
  }),
1340
1340
  reducers: {
1341
1341
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1392,15 +1392,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1392
1392
  return selectIssuesOfIssueType(issueTypeId)(state).length;
1393
1393
  };
1394
1394
  const issueTypeReducer = issueTypeSlice.reducer;
1395
- const initialState$z = {
1395
+ const initialState$r = {
1396
1396
  s3Urls: {}
1397
1397
  };
1398
1398
  const msPerHour = 1e3 * 60 * 60;
1399
1399
  const msPerWeek = msPerHour * 24 * 7;
1400
1400
  const fileSlice = createSlice({
1401
1401
  name: "file",
1402
- initialState: initialState$z,
1403
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1402
+ initialState: initialState$r,
1403
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1404
1404
  reducers: {
1405
1405
  setUploadUrl: (state, action) => {
1406
1406
  const { url, fields, sha1 } = action.payload;
@@ -1427,14 +1427,14 @@ const selectUploadUrl = (sha1) => (state) => {
1427
1427
  return url;
1428
1428
  };
1429
1429
  const fileReducer = fileSlice.reducer;
1430
- const initialState$y = {
1430
+ const initialState$q = {
1431
1431
  users: {},
1432
1432
  currentUser: null
1433
1433
  };
1434
1434
  const userSlice = createSlice({
1435
1435
  name: "users",
1436
- initialState: initialState$y,
1437
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1436
+ initialState: initialState$q,
1437
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1438
1438
  reducers: {
1439
1439
  setUsers: (state, action) => {
1440
1440
  const usersMapping = {};
@@ -1492,11 +1492,11 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
1492
1492
  const organizationAccessAdapter = createModelAdapter(
1493
1493
  (organizationAccess) => organizationAccess.offline_id
1494
1494
  );
1495
- const initialState$x = organizationAccessAdapter.getInitialState({});
1495
+ const initialState$p = organizationAccessAdapter.getInitialState({});
1496
1496
  const organizationAccessSlice = createSlice({
1497
1497
  name: "organizationAccess",
1498
- initialState: initialState$x,
1499
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1498
+ initialState: initialState$p,
1499
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1500
1500
  reducers: {
1501
1501
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1502
1502
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1533,11 +1533,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1533
1533
  };
1534
1534
  const organizationAccessReducer = organizationAccessSlice.reducer;
1535
1535
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1536
- const initialState$w = licenseAdapter.getInitialState({});
1536
+ const initialState$o = licenseAdapter.getInitialState({});
1537
1537
  const licenseSlice = createSlice({
1538
1538
  name: "license",
1539
- initialState: initialState$w,
1540
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1539
+ initialState: initialState$o,
1540
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1541
1541
  reducers: {
1542
1542
  initializeLicences: licenseAdapter.initialize,
1543
1543
  addLicenses: licenseAdapter.addMany,
@@ -1562,11 +1562,11 @@ const selectLicensesForProjectsMapping = createSelector(
1562
1562
  );
1563
1563
  const licenseReducer = licenseSlice.reducer;
1564
1564
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1565
- const initialState$v = projectAccessAdapter.getInitialState({});
1565
+ const initialState$n = projectAccessAdapter.getInitialState({});
1566
1566
  const projectAccessSlice = createSlice({
1567
1567
  name: "projectAccess",
1568
- initialState: initialState$v,
1569
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1568
+ initialState: initialState$n,
1569
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1570
1570
  reducers: {
1571
1571
  initializeProjectAccesses: projectAccessAdapter.initialize,
1572
1572
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1607,14 +1607,14 @@ const selectProjectAccessUserMapping = (state) => {
1607
1607
  return projectAccesses;
1608
1608
  };
1609
1609
  const projectAccessReducer = projectAccessSlice.reducer;
1610
- const initialState$u = {
1610
+ const initialState$m = {
1611
1611
  projects: {},
1612
1612
  activeProjectId: null
1613
1613
  };
1614
1614
  const projectSlice = createSlice({
1615
1615
  name: "projects",
1616
- initialState: initialState$u,
1617
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1616
+ initialState: initialState$m,
1617
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1618
1618
  reducers: {
1619
1619
  setProjects: (state, action) => {
1620
1620
  const projectsMap = {};
@@ -1721,13 +1721,13 @@ const selectSortedProjectUsers = createSelector(
1721
1721
  });
1722
1722
  }
1723
1723
  );
1724
- const initialState$t = {
1724
+ const initialState$l = {
1725
1725
  organizations: {}
1726
1726
  };
1727
1727
  const organizationSlice = createSlice({
1728
1728
  name: "organizations",
1729
- initialState: initialState$t,
1730
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$t)),
1729
+ initialState: initialState$l,
1730
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1731
1731
  reducers: {
1732
1732
  setOrganizations: (state, action) => {
1733
1733
  for (const org of action.payload) {
@@ -1818,14 +1818,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
1818
1818
  }
1819
1819
  };
1820
1820
  };
1821
- const initialState$s = {
1821
+ const initialState$k = {
1822
1822
  deletedRequests: [],
1823
1823
  latestRetryTime: 0
1824
1824
  };
1825
1825
  const outboxSlice = createSlice({
1826
1826
  name: "outbox",
1827
- initialState: initialState$s,
1828
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
1827
+ initialState: initialState$k,
1828
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1829
1829
  reducers: {
1830
1830
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
1831
1831
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -1857,15 +1857,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
1857
1857
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
1858
1858
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
1859
1859
  const outboxReducer = outboxSlice.reducer;
1860
- const initialState$r = {
1860
+ const initialState$j = {
1861
1861
  projectFiles: {},
1862
1862
  activeProjectFileId: null,
1863
1863
  isImportingProjectFile: false
1864
1864
  };
1865
1865
  const projectFileSlice = createSlice({
1866
1866
  name: "projectFiles",
1867
- initialState: initialState$r,
1868
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1867
+ initialState: initialState$j,
1868
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1869
1869
  reducers: {
1870
1870
  addOrReplaceProjectFiles: (state, action) => {
1871
1871
  for (let fileObj of action.payload) {
@@ -1952,11 +1952,11 @@ const selectProjectFileById = (id) => (state) => {
1952
1952
  };
1953
1953
  const projectFileReducer = projectFileSlice.reducer;
1954
1954
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1955
- const initialState$q = projectAttachmentAdapter.getInitialState({});
1955
+ const initialState$i = projectAttachmentAdapter.getInitialState({});
1956
1956
  const projectAttachmentSlice = createSlice({
1957
1957
  name: "projectAttachments",
1958
- initialState: initialState$q,
1959
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1958
+ initialState: initialState$i,
1959
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1960
1960
  reducers: {
1961
1961
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
1962
1962
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2011,12 +2011,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2011
2011
  )
2012
2012
  );
2013
2013
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2014
- const initialState$p = {
2014
+ const initialState$h = {
2015
2015
  isRehydrated: false
2016
2016
  };
2017
2017
  const rehydratedSlice = createSlice({
2018
2018
  name: "rehydrated",
2019
- initialState: initialState$p,
2019
+ initialState: initialState$h,
2020
2020
  // The `reducers` field lets us define reducers and generate associated actions
2021
2021
  reducers: {
2022
2022
  setRehydrated: (state, action) => {
@@ -2041,11 +2041,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2041
2041
  }
2042
2042
  };
2043
2043
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2044
- const initialState$o = formRevisionAdapter.getInitialState({});
2044
+ const initialState$g = formRevisionAdapter.getInitialState({});
2045
2045
  const formRevisionsSlice = createSlice({
2046
2046
  name: "formRevisions",
2047
- initialState: initialState$o,
2048
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
2047
+ initialState: initialState$g,
2048
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2049
2049
  reducers: {
2050
2050
  initializeFormRevisions: formRevisionAdapter.initialize,
2051
2051
  setFormRevision: formRevisionAdapter.setOne,
@@ -2104,13 +2104,24 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
2104
2104
  }
2105
2105
  )
2106
2106
  );
2107
+ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
2108
+ const latestRevisions = {};
2109
+ for (const revision of Object.values(revisions)) {
2110
+ const formId = revision.form;
2111
+ const currentLatestRevision = latestRevisions[formId];
2112
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
2113
+ latestRevisions[formId] = revision;
2114
+ }
2115
+ }
2116
+ return latestRevisions;
2117
+ });
2107
2118
  const formRevisionReducer = formRevisionsSlice.reducer;
2108
2119
  const formAdapter = createModelAdapter((form) => form.offline_id);
2109
- const initialState$n = formAdapter.getInitialState({});
2120
+ const initialState$f = formAdapter.getInitialState({});
2110
2121
  const formSlice = createSlice({
2111
2122
  name: "forms",
2112
- initialState: initialState$n,
2113
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
2123
+ initialState: initialState$f,
2124
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2114
2125
  reducers: {
2115
2126
  initializeForms: formAdapter.initialize,
2116
2127
  setForm: formAdapter.setOne,
@@ -2128,9 +2139,6 @@ const selectFormMapping = (state) => {
2128
2139
  const selectForms = createSelector([selectFormMapping], (formsMapping) => {
2129
2140
  return Object.values(formsMapping);
2130
2141
  });
2131
- const selectFormById = (formId) => (state) => {
2132
- return state.formReducer.instances[formId];
2133
- };
2134
2142
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2135
2143
  createSelector(
2136
2144
  [
@@ -2156,12 +2164,37 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2156
2164
  { memoizeOptions: { equalityCheck: shallowEqual } }
2157
2165
  )
2158
2166
  );
2167
+ const selectFormById = (formId) => (state) => {
2168
+ return state.formReducer.instances[formId];
2169
+ };
2170
+ const selectFormOfAssetType = restructureCreateSelectorWithArgs(
2171
+ createSelector(
2172
+ [selectFormMapping, (_state, assetTypeId) => assetTypeId],
2173
+ (formsMapping, assetTypeId) => {
2174
+ return Object.values(formsMapping).find((form) => form.asset_type === assetTypeId);
2175
+ }
2176
+ )
2177
+ );
2178
+ const selectFormOfIssueType = restructureCreateSelectorWithArgs(
2179
+ createSelector(
2180
+ [selectFormMapping, (_state, issueTypeId) => issueTypeId],
2181
+ (formsMapping, issueTypeId) => {
2182
+ return Object.values(formsMapping).find((form) => form.issue_type === issueTypeId);
2183
+ }
2184
+ )
2185
+ );
2186
+ const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
2187
+ return Object.keys(formsMapping).length;
2188
+ });
2189
+ const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
2190
+ return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2191
+ });
2159
2192
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2160
- const initialState$m = submissionAdapter.getInitialState({});
2193
+ const initialState$e = submissionAdapter.getInitialState({});
2161
2194
  const formSubmissionSlice = createSlice({
2162
2195
  name: "formSubmissions",
2163
- initialState: initialState$m,
2164
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
2196
+ initialState: initialState$e,
2197
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2165
2198
  reducers: {
2166
2199
  initializeFormSubmissions: submissionAdapter.initialize,
2167
2200
  setFormSubmission: submissionAdapter.setOne,
@@ -2217,6 +2250,43 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2217
2250
  }
2218
2251
  )
2219
2252
  );
2253
+ const selectFormSubmissionsByFormRevisions = createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
2254
+ var _a2;
2255
+ const submissionMapping = {};
2256
+ for (const revisionId in revisions) {
2257
+ submissionMapping[revisionId] = [];
2258
+ }
2259
+ for (const submission of submissions) {
2260
+ (_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
2261
+ }
2262
+ return submissionMapping;
2263
+ });
2264
+ const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2265
+ createSelector(
2266
+ [
2267
+ selectFormRevisionMapping,
2268
+ selectFormSubmissionsByFormRevisions,
2269
+ (_state, formId) => formId
2270
+ ],
2271
+ (revisionsMapping, submissionsByRevision, formId) => {
2272
+ const submissionsByFormRevisions = {};
2273
+ for (const revisionId in revisionsMapping) {
2274
+ const revision = revisionsMapping[revisionId];
2275
+ const submissionsOfRevision = submissionsByRevision[revisionId];
2276
+ if (revision && submissionsOfRevision && revision.form === formId) {
2277
+ submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
2278
+ (a, b) => a.submitted_at < b.submitted_at ? -1 : 1
2279
+ );
2280
+ }
2281
+ }
2282
+ return Object.entries(submissionsByFormRevisions).sort((a, b) => {
2283
+ const aRevision = revisionsMapping[a[0]];
2284
+ const bRevision = revisionsMapping[b[0]];
2285
+ return formRevisionSortFn(aRevision, bRevision);
2286
+ }).map(([_revisionId, submissions]) => submissions).flat();
2287
+ }
2288
+ )
2289
+ );
2220
2290
  const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2221
2291
  createSelector(
2222
2292
  [selectFormSubmissions, (_state, issueId) => issueId],
@@ -2227,6 +2297,54 @@ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2227
2297
  }
2228
2298
  )
2229
2299
  );
2300
+ const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2301
+ createSelector(
2302
+ [
2303
+ (state) => state.issueReducer.instances,
2304
+ (state) => state.formReducer.instances,
2305
+ (state) => state.formRevisionReducer.instances,
2306
+ (state) => state.formSubmissionReducer.instances,
2307
+ (_state, issueId) => issueId
2308
+ ],
2309
+ (issues, forms, formRevisions, submissions, issueId) => {
2310
+ const issue = issues[issueId];
2311
+ if (!issue)
2312
+ return [];
2313
+ if (!issue.issue_type) {
2314
+ return Object.values(submissions).filter((submission) => submission.issue === issueId);
2315
+ }
2316
+ const issueTypeForms = new Set(
2317
+ Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
2318
+ );
2319
+ const issueTypeFormRevisions = new Set(
2320
+ Object.keys(formRevisions).filter(
2321
+ (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2322
+ )
2323
+ );
2324
+ return Object.values(submissions).filter(
2325
+ (submission) => submission.issue === issueId && !issueTypeFormRevisions.has(submission.form_revision)
2326
+ );
2327
+ }
2328
+ )
2329
+ );
2330
+ const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
2331
+ createSelector(
2332
+ [selectFormSubmissions, (_state, issueIds) => issueIds],
2333
+ (submissions, issueIds) => {
2334
+ var _a2;
2335
+ const issueSubmissions = {};
2336
+ for (const issueId of issueIds) {
2337
+ issueSubmissions[issueId] = [];
2338
+ }
2339
+ for (const submission of submissions) {
2340
+ if (submission.issue && issueIds.includes(submission.issue)) {
2341
+ (_a2 = issueSubmissions[submission.issue]) == null ? void 0 : _a2.push(submission);
2342
+ }
2343
+ }
2344
+ return issueSubmissions;
2345
+ }
2346
+ )
2347
+ );
2230
2348
  const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2231
2349
  createSelector(
2232
2350
  [selectFormSubmissions, (_state, assetId) => assetId],
@@ -2237,15 +2355,62 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2237
2355
  }
2238
2356
  )
2239
2357
  );
2358
+ const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2359
+ createSelector(
2360
+ [
2361
+ (state) => state.assetReducer.instances,
2362
+ (state) => state.formReducer.instances,
2363
+ (state) => state.formRevisionReducer.instances,
2364
+ (state) => state.formSubmissionReducer.instances,
2365
+ (_state, assetId) => assetId
2366
+ ],
2367
+ (assets, forms, formRevisions, submissions, assetId) => {
2368
+ const asset = assets[assetId];
2369
+ if (!asset)
2370
+ return [];
2371
+ if (!asset.asset_type) {
2372
+ return Object.values(submissions).filter((submission) => submission.asset === assetId);
2373
+ }
2374
+ const issueTypeForms = new Set(
2375
+ Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
2376
+ );
2377
+ const issueTypeFormRevisions = new Set(
2378
+ Object.keys(formRevisions).filter(
2379
+ (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2380
+ )
2381
+ );
2382
+ return Object.values(submissions).filter(
2383
+ (submission) => submission.asset === assetId && !issueTypeFormRevisions.has(submission.form_revision)
2384
+ );
2385
+ }
2386
+ )
2387
+ );
2388
+ const selectFormSubmissionsByAssets = createSelector(
2389
+ [selectFormSubmissionsMapping, selectAssetsMapping],
2390
+ (submissions, assets) => {
2391
+ var _a2;
2392
+ const assetSubmissionMapping = {};
2393
+ for (const assetId in assets) {
2394
+ assetSubmissionMapping[assetId] = [];
2395
+ }
2396
+ for (const submissionId in submissions) {
2397
+ const submission = submissions[submissionId];
2398
+ if (submission.asset) {
2399
+ (_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
2400
+ }
2401
+ }
2402
+ return assetSubmissionMapping;
2403
+ }
2404
+ );
2240
2405
  const formSubmissionReducer = formSubmissionSlice.reducer;
2241
2406
  const formSubmissionAttachmentAdapter = createModelAdapter(
2242
2407
  (attachment) => attachment.offline_id
2243
2408
  );
2244
- const initialState$l = formSubmissionAttachmentAdapter.getInitialState({});
2409
+ const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2245
2410
  const formSubmissionAttachmentSlice = createSlice({
2246
2411
  name: "formSubmissionAttachments",
2247
- initialState: initialState$l,
2248
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
2412
+ initialState: initialState$d,
2413
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2249
2414
  reducers: {
2250
2415
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2251
2416
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2288,9 +2453,7 @@ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2288
2453
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
2289
2454
  (attachmentsMapping, submissionId) => {
2290
2455
  return fallbackToEmptyArray(
2291
- Object.values(attachmentsMapping).filter(
2292
- (attachment) => attachment.form_submission === submissionId
2293
- )
2456
+ Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId)
2294
2457
  );
2295
2458
  }
2296
2459
  )
@@ -2299,11 +2462,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2299
2462
  const formRevisionAttachmentAdapter = createModelAdapter(
2300
2463
  (attachment) => attachment.offline_id
2301
2464
  );
2302
- const initialState$k = formRevisionAttachmentAdapter.getInitialState({});
2465
+ const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2303
2466
  const formRevisionAttachmentSlice = createSlice({
2304
2467
  name: "formRevisionAttachments",
2305
- initialState: initialState$k,
2306
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2468
+ initialState: initialState$c,
2469
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2307
2470
  reducers: {
2308
2471
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2309
2472
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2335,17 +2498,17 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2335
2498
  [selectFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
2336
2499
  (attachments, revisionId) => {
2337
2500
  return fallbackToEmptyArray(
2338
- Object.values(attachments).filter((attachment) => attachment.form_revision === revisionId)
2501
+ Object.values(attachments).filter((attachment) => attachment.revision === revisionId)
2339
2502
  );
2340
2503
  }
2341
2504
  )
2342
2505
  );
2343
2506
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2344
2507
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2345
- const initialState$j = workspaceAdapter.getInitialState({});
2508
+ const initialState$b = workspaceAdapter.getInitialState({});
2346
2509
  const workspaceSlice = createSlice({
2347
2510
  name: "workspace",
2348
- initialState: initialState$j,
2511
+ initialState: initialState$b,
2349
2512
  reducers: {
2350
2513
  initializeWorkspaces: workspaceAdapter.initialize,
2351
2514
  setWorkspaces: workspaceAdapter.setMany,
@@ -2376,10 +2539,10 @@ const selectPermittedWorkspaceIds = createSelector(
2376
2539
  );
2377
2540
  const workspaceReducer = workspaceSlice.reducer;
2378
2541
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2379
- const initialState$i = emailDomainAdapter.getInitialState({});
2542
+ const initialState$a = emailDomainAdapter.getInitialState({});
2380
2543
  const emailDomainsSlice = createSlice({
2381
2544
  name: "emailDomains",
2382
- initialState: initialState$i,
2545
+ initialState: initialState$a,
2383
2546
  reducers: {
2384
2547
  initializeEmailDomains: emailDomainAdapter.initialize,
2385
2548
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2400,14 +2563,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2400
2563
  )
2401
2564
  );
2402
2565
  const emailDomainsReducer = emailDomainsSlice.reducer;
2403
- const initialState$h = {
2566
+ const initialState$9 = {
2404
2567
  documents: {}
2405
2568
  };
2406
2569
  const documentSlice = createSlice({
2407
2570
  name: "documents",
2408
- initialState: initialState$h,
2571
+ initialState: initialState$9,
2409
2572
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2410
- Object.assign(state, initialState$h);
2573
+ Object.assign(state, initialState$9);
2411
2574
  }),
2412
2575
  reducers: {
2413
2576
  setDocuments: (state, action) => {
@@ -2596,11 +2759,11 @@ const selectRootDocuments = createSelector(
2596
2759
  );
2597
2760
  const documentsReducer = documentSlice.reducer;
2598
2761
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2599
- const initialState$g = documentAttachmentAdapter.getInitialState({});
2762
+ const initialState$8 = documentAttachmentAdapter.getInitialState({});
2600
2763
  const documentAttachmentSlice = createSlice({
2601
2764
  name: "documentAttachments",
2602
- initialState: initialState$g,
2603
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2765
+ initialState: initialState$8,
2766
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2604
2767
  reducers: {
2605
2768
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
2606
2769
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -2659,11 +2822,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
2659
2822
  );
2660
2823
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
2661
2824
  const teamAdapter = createModelAdapter((team) => team.offline_id);
2662
- const initialState$f = teamAdapter.getInitialState({});
2825
+ const initialState$7 = teamAdapter.getInitialState({});
2663
2826
  const teamSlice = createSlice({
2664
2827
  name: "teams",
2665
- initialState: initialState$f,
2666
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2828
+ initialState: initialState$7,
2829
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2667
2830
  reducers: {
2668
2831
  setTeam: teamAdapter.setOne,
2669
2832
  initializeTeams: teamAdapter.initialize,
@@ -2714,11 +2877,11 @@ const teamReducer = teamSlice.reducer;
2714
2877
  const agentUserConversationAdapter = createModelAdapter(
2715
2878
  (conversation) => conversation.offline_id
2716
2879
  );
2717
- const initialState$e = agentUserConversationAdapter.getInitialState({});
2880
+ const initialState$6 = agentUserConversationAdapter.getInitialState({});
2718
2881
  const agentsSlice = createSlice({
2719
2882
  name: "agents",
2720
- initialState: initialState$e,
2721
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2883
+ initialState: initialState$6,
2884
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2722
2885
  reducers: {
2723
2886
  initializeConversations: agentUserConversationAdapter.initialize,
2724
2887
  addConversation: agentUserConversationAdapter.addOne,
@@ -2740,11 +2903,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
2740
2903
  );
2741
2904
  const agentsReducer = agentsSlice.reducer;
2742
2905
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
2743
- const initialState$d = issueCommentAdapter.getInitialState({});
2906
+ const initialState$5 = issueCommentAdapter.getInitialState({});
2744
2907
  const issueCommentSlice = createSlice({
2745
2908
  name: "issueComments",
2746
- initialState: initialState$d,
2747
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2909
+ initialState: initialState$5,
2910
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2748
2911
  reducers: {
2749
2912
  addIssueComment: issueCommentAdapter.addOne,
2750
2913
  addIssueComments: issueCommentAdapter.addMany,
@@ -2773,11 +2936,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
2773
2936
  );
2774
2937
  const issueCommentReducer = issueCommentSlice.reducer;
2775
2938
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
2776
- const initialState$c = issueUpdateAdapter.getInitialState({});
2939
+ const initialState$4 = issueUpdateAdapter.getInitialState({});
2777
2940
  const issueUpdateSlice = createSlice({
2778
2941
  name: "issueUpdates",
2779
- initialState: initialState$c,
2780
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2942
+ initialState: initialState$4,
2943
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2781
2944
  reducers: {
2782
2945
  initializeIssueUpdates: issueUpdateAdapter.setMany,
2783
2946
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -2806,11 +2969,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
2806
2969
  );
2807
2970
  const issueUpdateReducer = issueUpdateSlice.reducer;
2808
2971
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2809
- const initialState$b = issueAttachmentAdapter.getInitialState({});
2972
+ const initialState$3 = issueAttachmentAdapter.getInitialState({});
2810
2973
  const issueAttachmentSlice = createSlice({
2811
2974
  name: "issueAttachments",
2812
- initialState: initialState$b,
2813
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2975
+ initialState: initialState$3,
2976
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
2814
2977
  reducers: {
2815
2978
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
2816
2979
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -2868,23 +3031,23 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2868
3031
  )
2869
3032
  );
2870
3033
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
2871
- const initialState$a = {
3034
+ const initialState$2 = {
2872
3035
  version: 0
2873
3036
  };
2874
3037
  const versioningSlice = createSlice({
2875
3038
  name: "versioning",
2876
- initialState: initialState$a,
3039
+ initialState: initialState$2,
2877
3040
  reducers: {}
2878
3041
  });
2879
3042
  const versioningReducer = versioningSlice.reducer;
2880
3043
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
2881
- const initialState$9 = geoImageAdapter.getInitialState({});
3044
+ const initialState$1 = geoImageAdapter.getInitialState({});
2882
3045
  const geoImageSlice = createSlice({
2883
3046
  name: "geoImages",
2884
- initialState: initialState$9,
3047
+ initialState: initialState$1,
2885
3048
  extraReducers: (builder) => {
2886
3049
  builder.addCase("RESET", (state) => {
2887
- Object.assign(state, initialState$9);
3050
+ Object.assign(state, initialState$1);
2888
3051
  });
2889
3052
  },
2890
3053
  reducers: {
@@ -2922,11 +3085,11 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
2922
3085
  );
2923
3086
  const geoImageReducer = geoImageSlice.reducer;
2924
3087
  const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
2925
- const initialState$8 = issueAssociationAdapter.getInitialState({});
3088
+ const initialState = issueAssociationAdapter.getInitialState({});
2926
3089
  const issueAssociationSlice = createSlice({
2927
3090
  name: "issueAssociations",
2928
- initialState: initialState$8,
2929
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3091
+ initialState,
3092
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
2930
3093
  reducers: {
2931
3094
  initializeIssueAssociations: issueAssociationAdapter.initialize,
2932
3095
  addIssueAssociation: issueAssociationAdapter.addOne,
@@ -2984,432 +3147,32 @@ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
2984
3147
  )
2985
3148
  );
2986
3149
  const issueAssociationReducer = issueAssociationSlice.reducer;
2987
- const issueTypeFieldValuesAdapter = createModelAdapter(
2988
- (fieldValues) => fieldValues.offline_id
2989
- );
2990
- const initialState$7 = issueTypeFieldValuesAdapter.getInitialState({});
2991
- const issueTypeFieldValuesSlice = createSlice({
2992
- name: "issueTypeFieldValues",
2993
- initialState: initialState$7,
2994
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2995
- reducers: {
2996
- initializeIssueTypeFieldValues: issueTypeFieldValuesAdapter.initialize,
2997
- addIssueTypeFieldValues: issueTypeFieldValuesAdapter.addOne,
2998
- addIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.addMany,
2999
- setIssueTypeFieldValues: issueTypeFieldValuesAdapter.setOne,
3000
- setIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.setMany,
3001
- updateIssueTypeFieldValues: issueTypeFieldValuesAdapter.updateOne,
3002
- updateIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.updateMany,
3003
- deleteIssueTypeFieldValues: issueTypeFieldValuesAdapter.deleteOne,
3004
- deleteIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.deleteMany
3005
- }
3006
- });
3007
- const {
3008
- initializeIssueTypeFieldValues,
3009
- addIssueTypeFieldValues,
3010
- addIssueTypeFieldValuesMany,
3011
- setIssueTypeFieldValues,
3012
- setIssueTypeFieldValuesMany,
3013
- updateIssueTypeFieldValues,
3014
- updateIssueTypeFieldValuesMany,
3015
- deleteIssueTypeFieldValues,
3016
- deleteIssueTypeFieldValuesMany
3017
- } = issueTypeFieldValuesSlice.actions;
3018
- const selectIssueTypeFieldValuesMapping = (state) => state.issueTypeFieldValuesReducer.instances;
3019
- const selectIssueTypeFieldValues = createSelector([selectIssueTypeFieldValuesMapping], (fieldValuesMapping) => {
3020
- return Object.values(fieldValuesMapping);
3021
- });
3022
- const selectIssueTypeFieldValuesOfIssue = restructureCreateSelectorWithArgs(
3023
- createSelector([selectIssueTypeFieldValues, (_state, issueId) => issueId], (fieldValues, issueId) => {
3024
- return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.issue === issueId));
3025
- })
3026
- );
3027
- const selectIssueTypeFieldValuesById = (fieldValuesId) => (state) => {
3028
- return state.issueTypeFieldValuesReducer.instances[fieldValuesId];
3029
- };
3030
- const issueTypeFieldValuesReducer = issueTypeFieldValuesSlice.reducer;
3031
- const issueTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
3032
- const initialState$6 = issueTypeFieldsAdapter.getInitialState({});
3033
- const issueTypeFieldsSlice = createSlice({
3034
- name: "issueTypeFields",
3035
- initialState: initialState$6,
3036
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3037
- reducers: {
3038
- initializeIssueTypeFields: issueTypeFieldsAdapter.initialize,
3039
- addIssueTypeFields: issueTypeFieldsAdapter.addOne,
3040
- addIssueTypeFieldsMany: issueTypeFieldsAdapter.addMany,
3041
- setIssueTypeFields: issueTypeFieldsAdapter.setOne,
3042
- setIssueTypeFieldsMany: issueTypeFieldsAdapter.setMany,
3043
- updateIssueTypeFields: issueTypeFieldsAdapter.updateOne,
3044
- updateIssueTypeFieldsMany: issueTypeFieldsAdapter.updateMany,
3045
- deleteIssueTypeFields: issueTypeFieldsAdapter.deleteOne,
3046
- deleteIssueTypeFieldsMany: issueTypeFieldsAdapter.deleteMany
3150
+ let clientStore;
3151
+ function setClientStore(store) {
3152
+ clientStore = store;
3153
+ }
3154
+ function getClientStore() {
3155
+ return clientStore;
3156
+ }
3157
+ let clientSDK;
3158
+ function setClientSDK(sdkCtor) {
3159
+ clientSDK = sdkCtor;
3160
+ }
3161
+ function getClientSDK() {
3162
+ return clientSDK;
3163
+ }
3164
+ const CLASS_NAME_TO_SERVICE = {};
3165
+ class BaseService {
3166
+ constructor(sdk) {
3167
+ __publicField(this, "client");
3168
+ CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3169
+ this.client = sdk;
3047
3170
  }
3048
- });
3049
- const {
3050
- initializeIssueTypeFields,
3051
- addIssueTypeFields,
3052
- addIssueTypeFieldsMany,
3053
- setIssueTypeFields,
3054
- setIssueTypeFieldsMany,
3055
- updateIssueTypeFields,
3056
- updateIssueTypeFieldsMany,
3057
- deleteIssueTypeFields,
3058
- deleteIssueTypeFieldsMany
3059
- } = issueTypeFieldsSlice.actions;
3060
- const selectIssueTypeFieldsMapping = (state) => state.issueTypeFieldsReducer.instances;
3061
- const selectIssueTypeFields = createSelector([selectIssueTypeFieldsMapping], (fieldsMapping) => {
3062
- return Object.values(fieldsMapping);
3063
- });
3064
- const selectIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
3065
- createSelector([selectIssueTypeFields, (_state, issueTypeId) => issueTypeId], (fields, issueTypeId) => {
3066
- return fallbackToEmptyArray(fields.filter((field) => field.issue_type === issueTypeId));
3067
- })
3068
- );
3069
- const selectLatestIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
3070
- createSelector([selectIssueTypeFields, (_state, id) => id], (fields, id) => {
3071
- return fields.filter((field) => field.issue_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
3072
- })
3073
- );
3074
- const selectIssueTypeValuesOfIssueType = restructureCreateSelectorWithArgs(
3075
- createSelector(
3076
- [selectIssueTypeFields, selectIssueTypeFieldValues, (_state, id) => id],
3077
- (fields, fieldValues, id) => {
3078
- const fieldsIds = new Set(
3079
- fields.filter((field) => field.issue_type === id).map((field) => field.offline_id)
3080
- );
3081
- return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
3082
- }
3083
- )
3084
- );
3085
- const selectIssueTypeFieldsById = (fieldsId) => (state) => {
3086
- return state.issueTypeFieldsReducer.instances[fieldsId];
3087
- };
3088
- const issueTypeFieldsReducer = issueTypeFieldsSlice.reducer;
3089
- const issueTypeFieldsAttachmentAdapter = createModelAdapter(
3090
- (attachment) => attachment.offline_id
3091
- );
3092
- const initialState$5 = issueTypeFieldsAttachmentAdapter.getInitialState({});
3093
- const issueTypeFieldsAttachmentSlice = createSlice({
3094
- name: "issueTypeFieldsAttachments",
3095
- initialState: initialState$5,
3096
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3097
- reducers: {
3098
- initializeIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.initialize,
3099
- addIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.addOne,
3100
- addIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.addMany,
3101
- setIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.setOne,
3102
- setIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.setMany,
3103
- updateIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.updateOne,
3104
- updateIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.updateMany,
3105
- deleteIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.deleteOne,
3106
- deleteIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.deleteMany
3171
+ async enqueueRequest(requestDetails) {
3172
+ return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3107
3173
  }
3108
- });
3109
- const {
3110
- initializeIssueTypeFieldsAttachments,
3111
- addIssueTypeFieldsAttachment,
3112
- addIssueTypeFieldsAttachments,
3113
- setIssueTypeFieldsAttachment,
3114
- setIssueTypeFieldsAttachments,
3115
- updateIssueTypeFieldsAttachment,
3116
- updateIssueTypeFieldsAttachments,
3117
- deleteIssueTypeFieldsAttachment,
3118
- deleteIssueTypeFieldsAttachments
3119
- } = issueTypeFieldsAttachmentSlice.actions;
3120
- const selectIssueTypeFieldsAttachmentsMapping = (state) => state.issueTypeFieldsAttachmentReducer.instances;
3121
- const selectIssueTypeFieldsAttachments = createSelector(
3122
- [selectIssueTypeFieldsAttachmentsMapping],
3123
- (attachmentsMapping) => {
3124
- return Object.values(attachmentsMapping);
3125
- }
3126
- );
3127
- const selectAttachmentsOfIssueTypeFields = restructureCreateSelectorWithArgs(
3128
- createSelector(
3129
- [selectIssueTypeFieldsAttachments, (_state, fieldsRevision) => fieldsRevision],
3130
- (attachments, fieldsRevision) => {
3131
- return fallbackToEmptyArray(
3132
- attachments.filter((attachment) => attachment.fields_revision === fieldsRevision)
3133
- );
3134
- }
3135
- )
3136
- );
3137
- const selectIssueTypeFieldsAttachmentById = (attachmentId) => (state) => {
3138
- return state.issueTypeFieldsAttachmentReducer.instances[attachmentId];
3139
- };
3140
- const issueTypeFieldsAttachmentReducer = issueTypeFieldsAttachmentSlice.reducer;
3141
- const issueTypeFieldValuesAttachmentAdapter = createModelAdapter(
3142
- (attachment) => attachment.offline_id
3143
- );
3144
- const initialState$4 = issueTypeFieldValuesAttachmentAdapter.getInitialState({});
3145
- const issueTypeFieldValuesAttachmentSlice = createSlice({
3146
- name: "issueTypeFieldValuesAttachments",
3147
- initialState: initialState$4,
3148
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3149
- reducers: {
3150
- initializeIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.initialize,
3151
- addIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.addOne,
3152
- addIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.addMany,
3153
- setIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.setOne,
3154
- setIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.setMany,
3155
- updateIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.updateOne,
3156
- updateIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.updateMany,
3157
- deleteIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.deleteOne,
3158
- deleteIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.deleteMany
3159
- }
3160
- });
3161
- const {
3162
- initializeIssueTypeFieldValuesAttachments,
3163
- addIssueTypeFieldValuesAttachment,
3164
- addIssueTypeFieldValuesAttachments,
3165
- setIssueTypeFieldValuesAttachment,
3166
- setIssueTypeFieldValuesAttachments,
3167
- updateIssueTypeFieldValuesAttachment,
3168
- updateIssueTypeFieldValuesAttachments,
3169
- deleteIssueTypeFieldValuesAttachment,
3170
- deleteIssueTypeFieldValuesAttachments
3171
- } = issueTypeFieldValuesAttachmentSlice.actions;
3172
- const selectIssueTypeFieldValuesAttachmentsMapping = (state) => state.issueTypeFieldValuesAttachmentReducer.instances;
3173
- const selectIssueTypeFieldValuesAttachments = createSelector(
3174
- [selectIssueTypeFieldValuesAttachmentsMapping],
3175
- (attachmentsMapping) => {
3176
- return Object.values(attachmentsMapping);
3177
- }
3178
- );
3179
- const selectAttachmentsOfIssueTypeFieldValues = restructureCreateSelectorWithArgs(
3180
- createSelector(
3181
- [selectIssueTypeFieldValuesAttachments, (_state, fieldValuesId) => fieldValuesId],
3182
- (attachments, fieldValuesId) => {
3183
- return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === fieldValuesId));
3184
- }
3185
- )
3186
- );
3187
- const selectIssueTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
3188
- return state.issueTypeFieldValuesAttachmentReducer.instances[attachmentId];
3189
- };
3190
- const issueTypeFieldValuesAttachmentReducer = issueTypeFieldValuesAttachmentSlice.reducer;
3191
- const assetTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
3192
- const initialState$3 = assetTypeFieldsAdapter.getInitialState({});
3193
- const assetTypeFieldsSlice = createSlice({
3194
- name: "assetTypeFields",
3195
- initialState: initialState$3,
3196
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3197
- reducers: {
3198
- initializeAssetTypeFields: assetTypeFieldsAdapter.initialize,
3199
- addAssetTypeFields: assetTypeFieldsAdapter.addOne,
3200
- addAssetTypeFieldsMany: assetTypeFieldsAdapter.addMany,
3201
- setAssetTypeFields: assetTypeFieldsAdapter.setOne,
3202
- setAssetTypeFieldsMany: assetTypeFieldsAdapter.setMany,
3203
- updateAssetTypeFields: assetTypeFieldsAdapter.updateOne,
3204
- updateAssetTypeFieldsMany: assetTypeFieldsAdapter.updateMany,
3205
- deleteAssetTypeFields: assetTypeFieldsAdapter.deleteOne,
3206
- deleteAssetTypeFieldsMany: assetTypeFieldsAdapter.deleteMany
3207
- }
3208
- });
3209
- const {
3210
- initializeAssetTypeFields,
3211
- addAssetTypeFields,
3212
- addAssetTypeFieldsMany,
3213
- setAssetTypeFields,
3214
- setAssetTypeFieldsMany,
3215
- updateAssetTypeFields,
3216
- updateAssetTypeFieldsMany,
3217
- deleteAssetTypeFields,
3218
- deleteAssetTypeFieldsMany
3219
- } = assetTypeFieldsSlice.actions;
3220
- const selectAssetTypeFieldsMapping = (state) => state.assetTypeFieldsReducer.instances;
3221
- const selectAssetTypeFields = createSelector([selectAssetTypeFieldsMapping], (fieldsMapping) => {
3222
- return Object.values(fieldsMapping);
3223
- });
3224
- const selectAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3225
- createSelector([selectAssetTypeFields, (_state, assetTypeId) => assetTypeId], (fields, assetTypeId) => {
3226
- return fallbackToEmptyArray(fields.filter((field) => field.asset_type === assetTypeId));
3227
- })
3228
- );
3229
- const selectLatestAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3230
- createSelector([selectAssetTypeFields, (_state, id) => id], (fields, id) => {
3231
- return fields.filter((field) => field.asset_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
3232
- })
3233
- );
3234
- const selectAssetTypeFieldsById = (fieldsId) => (state) => {
3235
- return state.assetTypeFieldsReducer.instances[fieldsId];
3236
- };
3237
- const assetTypeFieldsReducer = assetTypeFieldsSlice.reducer;
3238
- const assetTypeFieldValuesAdapter = createModelAdapter(
3239
- (fieldValues) => fieldValues.offline_id
3240
- );
3241
- const initialState$2 = assetTypeFieldValuesAdapter.getInitialState({});
3242
- const assetTypeFieldValuesSlice = createSlice({
3243
- name: "assetTypeFieldValues",
3244
- initialState: initialState$2,
3245
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3246
- reducers: {
3247
- initializeAssetTypeFieldValues: assetTypeFieldValuesAdapter.initialize,
3248
- addAssetTypeFieldValues: assetTypeFieldValuesAdapter.addOne,
3249
- addAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.addMany,
3250
- setAssetTypeFieldValues: assetTypeFieldValuesAdapter.setOne,
3251
- setAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.setMany,
3252
- updateAssetTypeFieldValues: assetTypeFieldValuesAdapter.updateOne,
3253
- updateAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.updateMany,
3254
- deleteAssetTypeFieldValues: assetTypeFieldValuesAdapter.deleteOne,
3255
- deleteAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.deleteMany
3256
- }
3257
- });
3258
- const {
3259
- initializeAssetTypeFieldValues,
3260
- addAssetTypeFieldValues,
3261
- addAssetTypeFieldValuesMany,
3262
- setAssetTypeFieldValues,
3263
- setAssetTypeFieldValuesMany,
3264
- updateAssetTypeFieldValues,
3265
- updateAssetTypeFieldValuesMany,
3266
- deleteAssetTypeFieldValues,
3267
- deleteAssetTypeFieldValuesMany
3268
- } = assetTypeFieldValuesSlice.actions;
3269
- const selectAssetTypeFieldValuesMapping = (state) => state.assetTypeFieldValuesReducer.instances;
3270
- const selectAssetTypeFieldValues = createSelector([selectAssetTypeFieldValuesMapping], (fieldValuesMapping) => {
3271
- return Object.values(fieldValuesMapping);
3272
- });
3273
- const selectAssetTypeFieldValuesOfAsset = restructureCreateSelectorWithArgs(
3274
- createSelector([selectAssetTypeFieldValues, (_state, assetId) => assetId], (fieldValues, assetId) => {
3275
- return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.asset === assetId));
3276
- })
3277
- );
3278
- const selectAssetTypeValuesOfAssetType = restructureCreateSelectorWithArgs(
3279
- createSelector(
3280
- [selectAssetTypeFields, selectAssetTypeFieldValues, (_state, id) => id],
3281
- (fields, fieldValues, id) => {
3282
- const fieldsIds = new Set(
3283
- fields.filter((field) => field.asset_type === id).map((field) => field.offline_id)
3284
- );
3285
- return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
3286
- }
3287
- )
3288
- );
3289
- const selectAssetTypeFieldValuesById = (fieldValuesId) => (state) => {
3290
- return state.assetTypeFieldValuesReducer.instances[fieldValuesId];
3291
- };
3292
- const assetTypeFieldValuesReducer = assetTypeFieldValuesSlice.reducer;
3293
- const assetTypeFieldsAttachmentAdapter = createModelAdapter(
3294
- (attachment) => attachment.offline_id
3295
- );
3296
- const initialState$1 = assetTypeFieldsAttachmentAdapter.getInitialState({});
3297
- const assetTypeFieldsAttachmentSlice = createSlice({
3298
- name: "assetTypeFieldsAttachments",
3299
- initialState: initialState$1,
3300
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3301
- reducers: {
3302
- initializeAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.initialize,
3303
- addAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.addOne,
3304
- addAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.addMany,
3305
- setAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.setOne,
3306
- setAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.setMany,
3307
- updateAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.updateOne,
3308
- updateAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.updateMany,
3309
- deleteAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.deleteOne,
3310
- deleteAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.deleteMany
3311
- }
3312
- });
3313
- const {
3314
- initializeAssetTypeFieldsAttachments,
3315
- addAssetTypeFieldsAttachment,
3316
- addAssetTypeFieldsAttachments,
3317
- setAssetTypeFieldsAttachment,
3318
- setAssetTypeFieldsAttachments,
3319
- updateAssetTypeFieldsAttachment,
3320
- updateAssetTypeFieldsAttachments,
3321
- deleteAssetTypeFieldsAttachment,
3322
- deleteAssetTypeFieldsAttachments
3323
- } = assetTypeFieldsAttachmentSlice.actions;
3324
- const selectAssetTypeFieldsAttachmentsMapping = (state) => state.assetTypeFieldsAttachmentReducer.instances;
3325
- const selectAssetTypeFieldsAttachments = createSelector(
3326
- [selectAssetTypeFieldsAttachmentsMapping],
3327
- (attachmentsMapping) => {
3328
- return Object.values(attachmentsMapping);
3329
- }
3330
- );
3331
- const selectAttachmentsOfAssetTypeFields = restructureCreateSelectorWithArgs(
3332
- createSelector([selectAssetTypeFieldsAttachments, (_state, id) => id], (attachments, id) => {
3333
- return fallbackToEmptyArray(attachments.filter((attachment) => attachment.fields_revision === id));
3334
- })
3335
- );
3336
- const selectAssetTypeFieldsAttachmentById = (attachmentId) => (state) => {
3337
- return state.assetTypeFieldsAttachmentReducer.instances[attachmentId];
3338
- };
3339
- const assetTypeFieldsAttachmentReducer = assetTypeFieldsAttachmentSlice.reducer;
3340
- const assetTypeFieldValuesAttachmentAdapter = createModelAdapter(
3341
- (attachment) => attachment.offline_id
3342
- );
3343
- const initialState = assetTypeFieldValuesAttachmentAdapter.getInitialState({});
3344
- const assetTypeFieldValuesAttachmentSlice = createSlice({
3345
- name: "assetTypeFieldValuesAttachments",
3346
- initialState,
3347
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
3348
- reducers: {
3349
- initializeAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.initialize,
3350
- addAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.addOne,
3351
- addAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.addMany,
3352
- setAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.setOne,
3353
- setAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.setMany,
3354
- updateAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.updateOne,
3355
- updateAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.updateMany,
3356
- deleteAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.deleteOne,
3357
- deleteAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.deleteMany
3358
- }
3359
- });
3360
- const {
3361
- initializeAssetTypeFieldValuesAttachments,
3362
- addAssetTypeFieldValuesAttachment,
3363
- addAssetTypeFieldValuesAttachments,
3364
- setAssetTypeFieldValuesAttachment,
3365
- setAssetTypeFieldValuesAttachments,
3366
- updateAssetTypeFieldValuesAttachment,
3367
- updateAssetTypeFieldValuesAttachments,
3368
- deleteAssetTypeFieldValuesAttachment,
3369
- deleteAssetTypeFieldValuesAttachments
3370
- } = assetTypeFieldValuesAttachmentSlice.actions;
3371
- const selectAssetTypeFieldValuesAttachmentsMapping = (state) => state.assetTypeFieldValuesAttachmentReducer.instances;
3372
- const selectAssetTypeFieldValuesAttachments = createSelector(
3373
- [selectAssetTypeFieldValuesAttachmentsMapping],
3374
- (attachmentsMapping) => {
3375
- return Object.values(attachmentsMapping);
3376
- }
3377
- );
3378
- const selectAttachmentsOfAssetTypeFieldValues = restructureCreateSelectorWithArgs(
3379
- createSelector([selectAssetTypeFieldValuesAttachments, (_state, id) => id], (attachments, id) => {
3380
- return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === id));
3381
- })
3382
- );
3383
- const selectAssetTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
3384
- return state.assetTypeFieldValuesAttachmentReducer.instances[attachmentId];
3385
- };
3386
- const assetTypeFieldValuesAttachmentReducer = assetTypeFieldValuesAttachmentSlice.reducer;
3387
- let clientStore;
3388
- function setClientStore(store) {
3389
- clientStore = store;
3390
- }
3391
- function getClientStore() {
3392
- return clientStore;
3393
- }
3394
- let clientSDK;
3395
- function setClientSDK(sdkCtor) {
3396
- clientSDK = sdkCtor;
3397
- }
3398
- function getClientSDK() {
3399
- return clientSDK;
3400
- }
3401
- const CLASS_NAME_TO_SERVICE = {};
3402
- class BaseService {
3403
- constructor(sdk) {
3404
- __publicField(this, "client");
3405
- CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3406
- this.client = sdk;
3407
- }
3408
- async enqueueRequest(requestDetails) {
3409
- return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3410
- }
3411
- dispatch(action) {
3412
- this.client.store.dispatch(action);
3174
+ dispatch(action) {
3175
+ this.client.store.dispatch(action);
3413
3176
  }
3414
3177
  }
3415
3178
  const VERSION_REDUCER_KEY = "versioning";
@@ -3452,15 +3215,7 @@ const overmapReducers = {
3452
3215
  issueCommentReducer,
3453
3216
  issueUpdateReducer,
3454
3217
  geoImageReducer,
3455
- issueAssociationReducer,
3456
- issueTypeFieldsReducer,
3457
- issueTypeFieldValuesReducer,
3458
- issueTypeFieldsAttachmentReducer,
3459
- issueTypeFieldValuesAttachmentReducer,
3460
- assetTypeFieldsReducer,
3461
- assetTypeFieldValuesReducer,
3462
- assetTypeFieldsAttachmentReducer,
3463
- assetTypeFieldValuesAttachmentReducer
3218
+ issueAssociationReducer
3464
3219
  };
3465
3220
  const overmapReducer = combineReducers(overmapReducers);
3466
3221
  const resetStore = "RESET";
@@ -4102,6 +3857,9 @@ class CategoryService extends BaseApiService {
4102
3857
  description: "Create Category",
4103
3858
  method: HttpMethod.POST,
4104
3859
  url: "/categories/",
3860
+ queryParams: {
3861
+ workspace_id: payload.workspace.toString()
3862
+ },
4105
3863
  payload: offlineCategory,
4106
3864
  blockers: [payload.workspace],
4107
3865
  blocks: [offlineCategory.offline_id]
@@ -4314,10 +4072,7 @@ class AssetService extends BaseApiService {
4314
4072
  const result = await this.enqueueRequest({
4315
4073
  description: "Get assets",
4316
4074
  method: HttpMethod.GET,
4317
- url: "/assets/",
4318
- queryParams: {
4319
- project: projectId.toString()
4320
- },
4075
+ url: `/projects/${projectId}/assets/`,
4321
4076
  blockers: [],
4322
4077
  blocks: []
4323
4078
  });
@@ -4338,7 +4093,7 @@ class AssetStageCompletionService extends BaseApiService {
4338
4093
  const promise = this.enqueueRequest({
4339
4094
  description: "Add asset stage completion",
4340
4095
  method: HttpMethod.POST,
4341
- url: "/asset-stage-completions/",
4096
+ url: "/assets/completions/",
4342
4097
  payload: {
4343
4098
  offline_id: offlineStageCompletion.offline_id,
4344
4099
  submitted_at: submittedAt,
@@ -4365,7 +4120,7 @@ class AssetStageCompletionService extends BaseApiService {
4365
4120
  const promise = this.enqueueRequest({
4366
4121
  description: "Delete asset stage completion",
4367
4122
  method: HttpMethod.DELETE,
4368
- url: `/asset-stage-completions/${id}/`,
4123
+ url: `/assets/completions/${id}/`,
4369
4124
  blockers: [id],
4370
4125
  blocks: []
4371
4126
  });
@@ -4391,7 +4146,7 @@ class AssetStageCompletionService extends BaseApiService {
4391
4146
  const promise = this.enqueueRequest({
4392
4147
  description: "Bulk create asset stage completions",
4393
4148
  method: HttpMethod.POST,
4394
- url: "/asset-stage-completions/bulk/",
4149
+ url: "/assets/completions/bulk/",
4395
4150
  payload: {
4396
4151
  submitted_at: submittedAt,
4397
4152
  completions: payload
@@ -4413,7 +4168,7 @@ class AssetStageCompletionService extends BaseApiService {
4413
4168
  const promise = this.enqueueRequest({
4414
4169
  description: "Deleting asset stage completions",
4415
4170
  method: HttpMethod.DELETE,
4416
- url: "/asset-stage-completions/bulk/",
4171
+ url: "/assets/completions/bulk/",
4417
4172
  payload: {
4418
4173
  completion_ids: ids
4419
4174
  },
@@ -4429,10 +4184,7 @@ class AssetStageCompletionService extends BaseApiService {
4429
4184
  const result = await this.enqueueRequest({
4430
4185
  description: "Get asset stage completions",
4431
4186
  method: HttpMethod.GET,
4432
- url: "/asset-stage-completions/",
4433
- queryParams: {
4434
- project: projectId.toString()
4435
- },
4187
+ url: `/projects/${projectId}/asset-stage-completions/`,
4436
4188
  blockers: [],
4437
4189
  blocks: []
4438
4190
  });
@@ -4453,7 +4205,7 @@ class AssetStageService extends BaseApiService {
4453
4205
  const promise = this.enqueueRequest({
4454
4206
  description: "Add asset stages",
4455
4207
  method: HttpMethod.POST,
4456
- url: "/asset-stages/bulk/",
4208
+ url: "/assets/stages/bulk/",
4457
4209
  payload: {
4458
4210
  submitted_at: submittedAt,
4459
4211
  asset_type: assetTypeId,
@@ -4477,7 +4229,7 @@ class AssetStageService extends BaseApiService {
4477
4229
  return this.enqueueRequest({
4478
4230
  description: "Edit asset stages",
4479
4231
  method: HttpMethod.PATCH,
4480
- url: `/asset-types/${assetTypeId}/bulk-update-stages/`,
4232
+ url: `/assets/types/${assetTypeId}/bulk-update-stages/`,
4481
4233
  payload: {
4482
4234
  stages: stagesToUpdate
4483
4235
  },
@@ -4495,7 +4247,7 @@ class AssetStageService extends BaseApiService {
4495
4247
  const promise = this.enqueueRequest({
4496
4248
  description: "Delete asset stages",
4497
4249
  method: HttpMethod.DELETE,
4498
- url: "/asset-stages/bulk/",
4250
+ url: "/assets/stages/bulk/",
4499
4251
  payload: {
4500
4252
  stage_ids: idsToDelete
4501
4253
  },
@@ -4520,7 +4272,7 @@ class AssetStageService extends BaseApiService {
4520
4272
  const promise = this.enqueueRequest({
4521
4273
  description: "Update asset stage",
4522
4274
  method: HttpMethod.PATCH,
4523
- url: `/asset-stages/${assetStage.offline_id}/`,
4275
+ url: `/assets/stages/${assetStage.offline_id}/`,
4524
4276
  payload: {
4525
4277
  name: payload.name,
4526
4278
  description: payload.description,
@@ -4548,7 +4300,7 @@ class AssetStageService extends BaseApiService {
4548
4300
  await this.enqueueRequest({
4549
4301
  description: "Link asset stage to form",
4550
4302
  method: HttpMethod.POST,
4551
- url: `/asset-stages/${stageId}/associate-with-form/`,
4303
+ url: `/assets/stages/${stageId}/associate-with-form/`,
4552
4304
  payload: { form: formId },
4553
4305
  blockers: [stageId, formId],
4554
4306
  blocks: [stageId]
@@ -4569,7 +4321,7 @@ class AssetStageService extends BaseApiService {
4569
4321
  await this.enqueueRequest({
4570
4322
  description: "Unlink asset stage from form",
4571
4323
  method: HttpMethod.DELETE,
4572
- url: `/asset-stages/${stageId}/associate-with-form/`,
4324
+ url: `/assets/stages/${stageId}/associate-with-form/`,
4573
4325
  blockers: [stageId, formId],
4574
4326
  blocks: [stageId]
4575
4327
  });
@@ -4582,10 +4334,7 @@ class AssetStageService extends BaseApiService {
4582
4334
  const result = await this.enqueueRequest({
4583
4335
  description: "Get asset stages",
4584
4336
  method: HttpMethod.GET,
4585
- url: "/asset-stages/",
4586
- queryParams: {
4587
- project: projectId.toString()
4588
- },
4337
+ url: `/projects/${projectId}/asset-stages/`,
4589
4338
  blockers: [],
4590
4339
  blocks: []
4591
4340
  });
@@ -4602,12 +4351,7 @@ class BaseUploadService extends BaseApiService {
4602
4351
  projectAttachmentReducer: projectAttachmentReducer2,
4603
4352
  formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
4604
4353
  formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
4605
- geoImageReducer: geoImageReducer2,
4606
- // fields
4607
- assetTypeFieldsAttachmentReducer: assetTypeFieldsAttachmentReducer2,
4608
- assetTypeFieldValuesAttachmentReducer: assetTypeFieldValuesAttachmentReducer2,
4609
- issueTypeFieldsAttachmentReducer: issueTypeFieldsAttachmentReducer2,
4610
- issueTypeFieldValuesAttachmentReducer: issueTypeFieldValuesAttachmentReducer2
4354
+ geoImageReducer: geoImageReducer2
4611
4355
  } = this.client.store.getState();
4612
4356
  const objectsWithSha1 = [].concat(
4613
4357
  Object.values(issueAttachmentReducer2.instances),
@@ -4617,11 +4361,7 @@ class BaseUploadService extends BaseApiService {
4617
4361
  Object.values(projectAttachmentReducer2.instances),
4618
4362
  Object.values(formRevisionAttachmentReducer2.instances),
4619
4363
  Object.values(formSubmissionAttachmentReducer2.instances),
4620
- Object.values(geoImageReducer2.instances),
4621
- Object.values(assetTypeFieldsAttachmentReducer2.instances),
4622
- Object.values(assetTypeFieldValuesAttachmentReducer2.instances),
4623
- Object.values(issueTypeFieldsAttachmentReducer2.instances),
4624
- Object.values(issueTypeFieldValuesAttachmentReducer2.instances)
4364
+ Object.values(geoImageReducer2.instances)
4625
4365
  );
4626
4366
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4627
4367
  }
@@ -4643,20 +4383,41 @@ class BaseUploadService extends BaseApiService {
4643
4383
  }
4644
4384
  return promisesBySha1;
4645
4385
  }
4646
- async getFilePayload(file) {
4647
- const sha1 = await hashFile(file);
4648
- const filePayload = {
4649
- sha1,
4650
- file_type: file.type,
4651
- extension: file.name.split(".").pop(),
4652
- size: file.size
4653
- };
4654
- await this.client.files.addCache(file, sha1);
4655
- return filePayload;
4656
- }
4657
4386
  }
4387
+ const AttachmentModelMeta = {
4388
+ [AttachmentModel.Issue]: {
4389
+ name: "issue",
4390
+ attachUrlPrefix: "/issues",
4391
+ deleteUrlPrefix: "/issues",
4392
+ fetchUrlPostfix: "/issue-attachments"
4393
+ },
4394
+ [AttachmentModel.Asset]: {
4395
+ name: "asset",
4396
+ attachUrlPrefix: "/assets",
4397
+ deleteUrlPrefix: "/assets",
4398
+ fetchUrlPostfix: "/asset-attachments"
4399
+ },
4400
+ [AttachmentModel.AssetType]: {
4401
+ name: "asset type",
4402
+ attachUrlPrefix: "/assets/types",
4403
+ deleteUrlPrefix: "/assets/types",
4404
+ fetchUrlPostfix: "/asset-type-attachments"
4405
+ },
4406
+ [AttachmentModel.Project]: {
4407
+ name: "project",
4408
+ attachUrlPrefix: "/projects",
4409
+ deleteUrlPrefix: "/projects",
4410
+ fetchUrlPostfix: "/attachments"
4411
+ },
4412
+ [AttachmentModel.Document]: {
4413
+ name: "document",
4414
+ attachUrlPrefix: "/documents",
4415
+ deleteUrlPrefix: "/documents",
4416
+ fetchUrlPostfix: "/document-attachments"
4417
+ }
4418
+ };
4658
4419
  class BaseAttachmentService extends BaseUploadService {
4659
- async _bulkAdd(payloads) {
4420
+ async attachFiles(files, modelId, buildOfflineAttachment) {
4660
4421
  var _a2;
4661
4422
  const { store } = this.client;
4662
4423
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -4664,36 +4425,39 @@ class BaseAttachmentService extends BaseUploadService {
4664
4425
  const offlineAttachments = [];
4665
4426
  const attachmentPayloads = [];
4666
4427
  const filePayloads = {};
4667
- for (const payload of payloads) {
4668
- const { modelId, file } = payload;
4669
- const filePayload = await this.getFilePayload(file);
4670
- if (!(filePayload.sha1 in filePayloads))
4671
- filePayloads[filePayload.sha1] = filePayload;
4672
- const offlineAttachment = this.buildOfflineAttachment({
4428
+ for (const file of files) {
4429
+ const sha1 = await hashFile(file);
4430
+ if (!(sha1 in filePayloads)) {
4431
+ filePayloads[sha1] = {
4432
+ sha1,
4433
+ file_type: file.type,
4434
+ extension: file.name.split(".").pop(),
4435
+ size: file.size
4436
+ };
4437
+ await this.client.files.addCache(file, sha1);
4438
+ }
4439
+ const offlineAttachment = buildOfflineAttachment({
4673
4440
  file,
4674
- file_sha1: filePayload.sha1,
4675
- submitted_at: submittedAt,
4676
- created_by: createdBy,
4441
+ sha1,
4442
+ submittedAt,
4443
+ createdBy,
4677
4444
  description: "",
4678
4445
  modelId
4679
4446
  });
4680
4447
  offlineAttachments.push(offlineAttachment);
4681
- attachmentPayloads.push(
4682
- this.buildAttachmentPayload({
4683
- offline_id: offlineAttachment.offline_id,
4684
- file_name: offlineAttachment.file_name,
4685
- file_sha1: offlineAttachment.file_sha1,
4686
- file_extension: filePayload.extension,
4687
- description: offlineAttachment.description,
4688
- modelId
4689
- })
4690
- );
4448
+ attachmentPayloads.push({
4449
+ offline_id: offlineAttachment.offline_id,
4450
+ name: offlineAttachment.file_name,
4451
+ sha1: offlineAttachment.file_sha1,
4452
+ description: offlineAttachment.description
4453
+ });
4691
4454
  }
4692
4455
  this.dispatch(this.addAttachments(offlineAttachments));
4456
+ const meta = AttachmentModelMeta[this.attachmentModel];
4693
4457
  const promise = this.enqueueRequest({
4694
- description: `Add ${this.name}`,
4458
+ description: `Attach files to ${meta.name}`,
4695
4459
  method: HttpMethod.POST,
4696
- url: `${this.url}/bulk/`,
4460
+ url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
4697
4461
  payload: {
4698
4462
  submitted_at: submittedAt,
4699
4463
  attachments: attachmentPayloads,
@@ -4710,7 +4474,7 @@ class BaseAttachmentService extends BaseUploadService {
4710
4474
  });
4711
4475
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
4712
4476
  }
4713
- async _delete(attachmendId) {
4477
+ async deleteAttachment(attachmendId) {
4714
4478
  const { store } = this.client;
4715
4479
  const attachment = this.selectAttachment(attachmendId)(store.getState());
4716
4480
  if (!attachment) {
@@ -4719,10 +4483,11 @@ class BaseAttachmentService extends BaseUploadService {
4719
4483
  );
4720
4484
  }
4721
4485
  this.dispatch(this.removeAttachment(attachment.offline_id));
4486
+ const meta = AttachmentModelMeta[this.attachmentModel];
4722
4487
  const promise = this.enqueueRequest({
4723
- description: `Delete ${this.name}`,
4488
+ description: "Delete attachment",
4724
4489
  method: HttpMethod.DELETE,
4725
- url: `${this.url}/${attachmendId}/`,
4490
+ url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
4726
4491
  blockers: [attachmendId],
4727
4492
  blocks: []
4728
4493
  });
@@ -4735,12 +4500,24 @@ class BaseAttachmentService extends BaseUploadService {
4735
4500
  });
4736
4501
  return promise;
4737
4502
  }
4503
+ // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4504
+ // so for some attachment model services, this method will have to be overridden.
4505
+ async refreshStore(projectId, _organizationId) {
4506
+ const meta = AttachmentModelMeta[this.attachmentModel];
4507
+ const result = await this.enqueueRequest({
4508
+ description: `Get ${meta.name} attachments`,
4509
+ method: HttpMethod.GET,
4510
+ url: `/projects/${projectId}${meta.fetchUrlPostfix}/`,
4511
+ blocks: [],
4512
+ blockers: []
4513
+ });
4514
+ this.dispatch(this.initializeAttachments(result));
4515
+ }
4738
4516
  }
4739
4517
  class AssetAttachmentService extends BaseAttachmentService {
4740
4518
  constructor() {
4741
4519
  super(...arguments);
4742
- __publicField(this, "name", "Asset Attachment");
4743
- __publicField(this, "url", "/asset-attachments");
4520
+ __publicField(this, "attachmentModel", AttachmentModel.Asset);
4744
4521
  __publicField(this, "initializeAttachments", initializeAssetAttachments);
4745
4522
  __publicField(this, "addAttachments", addAssetAttachments);
4746
4523
  __publicField(this, "updateAttachments", updateAssetAttachments);
@@ -4752,39 +4529,20 @@ class AssetAttachmentService extends BaseAttachmentService {
4752
4529
  buildOfflineAttachment(data) {
4753
4530
  return offline({
4754
4531
  file: URL.createObjectURL(data.file),
4755
- file_sha1: data.file_sha1,
4756
- created_by: data.created_by,
4532
+ file_sha1: data.sha1,
4533
+ created_by: data.createdBy,
4757
4534
  file_name: data.file.name,
4758
4535
  file_type: data.file.type,
4759
- submitted_at: data.submitted_at,
4536
+ submitted_at: data.submittedAt,
4760
4537
  description: data.description,
4761
4538
  asset: data.modelId
4762
4539
  });
4763
4540
  }
4764
- buildAttachmentPayload(data) {
4765
- return {
4766
- ...data,
4767
- asset: data.modelId
4768
- };
4769
- }
4770
- async bulkAdd(payloads) {
4771
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetId, file: p.file })));
4772
- }
4773
- async delete(id) {
4774
- return this._delete(id);
4541
+ async attachFilesToAsset(files, assetId) {
4542
+ return this.attachFiles(files, assetId, this.buildOfflineAttachment.bind(this));
4775
4543
  }
4776
- async refreshStore(projectId) {
4777
- const result = await this.enqueueRequest({
4778
- description: "Get asset attachments",
4779
- method: HttpMethod.GET,
4780
- url: `${this.url}/`,
4781
- queryParams: {
4782
- project: projectId.toString()
4783
- },
4784
- blocks: [],
4785
- blockers: []
4786
- });
4787
- this.dispatch(initializeAssetAttachments(result));
4544
+ async deleteAssetAttachment(attachmentId) {
4545
+ return this.deleteAttachment(attachmentId);
4788
4546
  }
4789
4547
  }
4790
4548
  class AssetTypeService extends BaseApiService {
@@ -4801,7 +4559,7 @@ class AssetTypeService extends BaseApiService {
4801
4559
  const promise = this.enqueueRequest({
4802
4560
  description: "Create asset type",
4803
4561
  method: HttpMethod.POST,
4804
- url: "/asset-types/",
4562
+ url: `/projects/${payload.project}/asset-types/`,
4805
4563
  payload: { ...offlineAssetType },
4806
4564
  blockers: [],
4807
4565
  blocks: [offlineAssetType.offline_id]
@@ -4827,7 +4585,7 @@ class AssetTypeService extends BaseApiService {
4827
4585
  const promise = this.enqueueRequest({
4828
4586
  description: "Update asset type",
4829
4587
  method: HttpMethod.PATCH,
4830
- url: `/asset-types/${payload.offline_id}/`,
4588
+ url: `/assets/types/${payload.offline_id}/`,
4831
4589
  payload: {
4832
4590
  icon: payload.icon,
4833
4591
  color: payload.color,
@@ -4861,7 +4619,7 @@ class AssetTypeService extends BaseApiService {
4861
4619
  return this.enqueueRequest({
4862
4620
  description: "Delete asset type",
4863
4621
  method: HttpMethod.DELETE,
4864
- url: `/asset-types/${assetTypeId}/`,
4622
+ url: `/assets/types/${assetTypeId}/`,
4865
4623
  blockers: [assetTypeId],
4866
4624
  blocks: []
4867
4625
  }).catch((e) => {
@@ -4876,10 +4634,7 @@ class AssetTypeService extends BaseApiService {
4876
4634
  const result = await this.enqueueRequest({
4877
4635
  description: "Get asset types",
4878
4636
  method: HttpMethod.GET,
4879
- url: "/asset-types/",
4880
- queryParams: {
4881
- project: projectId.toString()
4882
- },
4637
+ url: `/projects/${projectId}/asset-types/`,
4883
4638
  blockers: [],
4884
4639
  blocks: []
4885
4640
  });
@@ -4889,8 +4644,8 @@ class AssetTypeService extends BaseApiService {
4889
4644
  class AssetTypeAttachmentService extends BaseAttachmentService {
4890
4645
  constructor() {
4891
4646
  super(...arguments);
4892
- __publicField(this, "name", "Asset Type Attachment");
4893
- __publicField(this, "url", "/asset-type-attachments");
4647
+ __publicField(this, "attachmentModel", AttachmentModel.AssetType);
4648
+ __publicField(this, "initializeAttachments", initializeAssetTypeAttachments);
4894
4649
  __publicField(this, "addAttachments", addAssetTypeAttachments);
4895
4650
  __publicField(this, "updateAttachments", updateAssetTypeAttachments);
4896
4651
  __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
@@ -4901,39 +4656,20 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4901
4656
  buildOfflineAttachment(data) {
4902
4657
  return offline({
4903
4658
  file: URL.createObjectURL(data.file),
4904
- file_sha1: data.file_sha1,
4905
- created_by: data.created_by,
4659
+ file_sha1: data.sha1,
4660
+ created_by: data.createdBy,
4906
4661
  file_name: data.file.name,
4907
4662
  file_type: data.file.type,
4908
- submitted_at: data.submitted_at,
4663
+ submitted_at: data.submittedAt,
4909
4664
  description: data.description,
4910
4665
  asset_type: data.modelId
4911
4666
  });
4912
4667
  }
4913
- buildAttachmentPayload(data) {
4914
- return {
4915
- ...data,
4916
- asset_type: data.modelId
4917
- };
4918
- }
4919
- async bulkAdd(payloads) {
4920
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetTypeId, file: p.file })));
4921
- }
4922
- async delete(attachmentId) {
4923
- return this._delete(attachmentId);
4668
+ async attachFilesToAssetType(files, assetTypeId) {
4669
+ return this.attachFiles(files, assetTypeId, this.buildOfflineAttachment.bind(this));
4924
4670
  }
4925
- async refreshStore(projectId) {
4926
- const result = await this.enqueueRequest({
4927
- description: "Get asset type attachments",
4928
- method: HttpMethod.GET,
4929
- url: `${this.url}/`,
4930
- queryParams: {
4931
- project: projectId.toString()
4932
- },
4933
- blocks: [],
4934
- blockers: []
4935
- });
4936
- this.dispatch(initializeAssetTypeAttachments(result));
4671
+ async deleteAssetTypeAttachment(attachmentId) {
4672
+ return this.deleteAttachment(attachmentId);
4937
4673
  }
4938
4674
  }
4939
4675
  class IssueCommentService extends BaseApiService {
@@ -4949,7 +4685,7 @@ class IssueCommentService extends BaseApiService {
4949
4685
  const promise = this.enqueueRequest({
4950
4686
  description: "Add issue comment",
4951
4687
  method: HttpMethod.POST,
4952
- url: "/issue-comments/",
4688
+ url: `/issues/${payload.issue}/comment/`,
4953
4689
  payload: offlineComment,
4954
4690
  blockers: [payload.issue],
4955
4691
  blocks: [offlineComment.offline_id]
@@ -4973,7 +4709,7 @@ class IssueCommentService extends BaseApiService {
4973
4709
  const promise = this.enqueueRequest({
4974
4710
  description: "Edit issue comment",
4975
4711
  method: HttpMethod.PATCH,
4976
- url: `/issue-comments/${payload.offline_id}/`,
4712
+ url: `/issues/comments/${payload.offline_id}/`,
4977
4713
  payload,
4978
4714
  blockers: [payload.offline_id],
4979
4715
  blocks: [payload.offline_id]
@@ -4992,7 +4728,7 @@ class IssueCommentService extends BaseApiService {
4992
4728
  const promise = this.enqueueRequest({
4993
4729
  description: "Delete comment",
4994
4730
  method: HttpMethod.DELETE,
4995
- url: `/issue-comments/${id}/`,
4731
+ url: `/issues/comments/${id}/`,
4996
4732
  blockers: [id],
4997
4733
  blocks: []
4998
4734
  });
@@ -5005,10 +4741,7 @@ class IssueCommentService extends BaseApiService {
5005
4741
  const result = await this.enqueueRequest({
5006
4742
  description: "Get comments",
5007
4743
  method: HttpMethod.GET,
5008
- url: "/issue-comments/",
5009
- queryParams: {
5010
- project: projectId.toString()
5011
- },
4744
+ url: `/projects/${projectId}/comments/`,
5012
4745
  blockers: [],
5013
4746
  blocks: []
5014
4747
  });
@@ -5020,21 +4753,27 @@ class IssueUpdateService extends BaseApiService {
5020
4753
  const result = await this.enqueueRequest({
5021
4754
  description: "Get issue updates",
5022
4755
  method: HttpMethod.GET,
5023
- url: "/issue-updates/",
5024
- queryParams: {
5025
- project: projectId.toString()
5026
- },
4756
+ url: `/projects/${projectId}/issues/updates/`,
5027
4757
  blockers: [],
5028
4758
  blocks: []
5029
4759
  });
5030
- this.dispatch(initializeIssueUpdates(result));
4760
+ let filteredResult = result.filter(onlyUniqueOfflineIds);
4761
+ filteredResult = filteredResult.map((comment) => {
4762
+ return { ...comment };
4763
+ });
4764
+ if (result.length !== filteredResult.length) {
4765
+ console.error(
4766
+ `Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
4767
+ );
4768
+ }
4769
+ this.dispatch(initializeIssueUpdates(filteredResult));
5031
4770
  }
5032
4771
  }
5033
4772
  class IssueAttachmentService extends BaseAttachmentService {
5034
4773
  constructor() {
5035
4774
  super(...arguments);
5036
- __publicField(this, "name", "Issue Attachment");
5037
- __publicField(this, "url", "/issue-attachments");
4775
+ __publicField(this, "attachmentModel", AttachmentModel.Issue);
4776
+ __publicField(this, "initializeAttachments", initializeIssueAttachments);
5038
4777
  __publicField(this, "addAttachments", addIssueAttachments);
5039
4778
  __publicField(this, "updateAttachments", updateIssueAttachments);
5040
4779
  __publicField(this, "removeAttachments", deleteIssueAttachments);
@@ -5045,42 +4784,24 @@ class IssueAttachmentService extends BaseAttachmentService {
5045
4784
  buildOfflineAttachment(data) {
5046
4785
  return offline({
5047
4786
  file: URL.createObjectURL(data.file),
5048
- file_sha1: data.file_sha1,
5049
- created_by: data.created_by,
4787
+ file_sha1: data.sha1,
4788
+ created_by: data.createdBy,
5050
4789
  file_name: data.file.name,
5051
4790
  file_type: data.file.type,
5052
- submitted_at: data.submitted_at,
4791
+ submitted_at: data.submittedAt,
5053
4792
  description: data.description,
5054
4793
  issue: data.modelId
5055
4794
  });
5056
4795
  }
5057
- buildAttachmentPayload(data) {
5058
- return {
5059
- ...data,
5060
- issue: data.modelId
5061
- };
5062
- }
5063
- async bulkAdd(payloads) {
5064
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.issueId, file: p.file })));
5065
- }
5066
- async delete(id) {
5067
- return this._delete(id);
4796
+ async attachFilesToIssue(files, issueId) {
4797
+ return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this));
5068
4798
  }
5069
- async refreshStore(projectId) {
5070
- const result = await this.enqueueRequest({
5071
- description: "Get issue attachments",
5072
- method: HttpMethod.GET,
5073
- url: `${this.url}/`,
5074
- queryParams: {
5075
- project: projectId.toString()
5076
- },
5077
- blocks: [],
5078
- blockers: []
5079
- });
5080
- this.dispatch(initializeIssueAttachments(result));
4799
+ async deleteIssueAttachment(attachmentId) {
4800
+ return this.deleteAttachment(attachmentId);
5081
4801
  }
5082
4802
  }
5083
4803
  class IssueService extends BaseApiService {
4804
+ // Basic CRUD functions
5084
4805
  add(payload) {
5085
4806
  var _a2;
5086
4807
  const { store } = this.client;
@@ -5098,6 +4819,10 @@ class IssueService extends BaseApiService {
5098
4819
  description: "Create issue",
5099
4820
  method: HttpMethod.POST,
5100
4821
  url: "/issues/",
4822
+ queryParams: {
4823
+ workspace_id: payload.index_workspace,
4824
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4825
+ },
5101
4826
  payload: offlineIssue,
5102
4827
  blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
5103
4828
  blocks: [offlineIssue.offline_id]
@@ -5253,10 +4978,7 @@ class IssueService extends BaseApiService {
5253
4978
  const result = await this.enqueueRequest({
5254
4979
  description: "Get issues",
5255
4980
  method: HttpMethod.GET,
5256
- url: "/issues/",
5257
- queryParams: {
5258
- project: projectId.toString()
5259
- },
4981
+ url: `/projects/${projectId}/issues/`,
5260
4982
  blockers: [],
5261
4983
  blocks: []
5262
4984
  });
@@ -5276,8 +4998,16 @@ class IssueTypeService extends BaseApiService {
5276
4998
  this.dispatch(addIssueType(offlineIssueType));
5277
4999
  const promise = this.enqueueRequest({
5278
5000
  method: HttpMethod.POST,
5279
- url: "/issue-types/",
5280
- payload: offlineIssueType,
5001
+ url: `/organizations/${payload.organization}/issue-types/`,
5002
+ // Sending only whats needed here
5003
+ payload: {
5004
+ offline_id: offlineIssueType.offline_id,
5005
+ submitted_at: offlineIssueType.submitted_at,
5006
+ icon: offlineIssueType.icon,
5007
+ color: offlineIssueType.color,
5008
+ name: offlineIssueType.name,
5009
+ description: offlineIssueType.description
5010
+ },
5281
5011
  blockers: [],
5282
5012
  blocks: [offlineIssueType.offline_id]
5283
5013
  });
@@ -5302,7 +5032,7 @@ class IssueTypeService extends BaseApiService {
5302
5032
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
5303
5033
  const promise = this.enqueueRequest({
5304
5034
  method: HttpMethod.PATCH,
5305
- url: `/issue-types/${payload.offline_id}/`,
5035
+ url: `/issues/types/${payload.offline_id}/`,
5306
5036
  payload,
5307
5037
  blockers: [payload.offline_id],
5308
5038
  blocks: [payload.offline_id]
@@ -5326,7 +5056,7 @@ class IssueTypeService extends BaseApiService {
5326
5056
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5327
5057
  const promise = this.enqueueRequest({
5328
5058
  method: HttpMethod.DELETE,
5329
- url: `/issue-types/${id}/`,
5059
+ url: `/issues/types/${id}/`,
5330
5060
  blockers: [id],
5331
5061
  blocks: []
5332
5062
  });
@@ -5339,10 +5069,7 @@ class IssueTypeService extends BaseApiService {
5339
5069
  async refreshStore(organizationId) {
5340
5070
  const result = await this.enqueueRequest({
5341
5071
  method: HttpMethod.GET,
5342
- url: "/issue-types/",
5343
- queryParams: {
5344
- organization: organizationId.toString()
5345
- },
5072
+ url: `/organizations/${organizationId}/issue-types/`,
5346
5073
  blockers: [],
5347
5074
  blocks: []
5348
5075
  });
@@ -5486,8 +5213,8 @@ class ProjectFileService extends BaseApiService {
5486
5213
  class ProjectAttachmentService extends BaseAttachmentService {
5487
5214
  constructor() {
5488
5215
  super(...arguments);
5489
- __publicField(this, "name", "Project Attachment");
5490
- __publicField(this, "url", "/project-attachments");
5216
+ __publicField(this, "attachmentModel", AttachmentModel.Project);
5217
+ __publicField(this, "initializeAttachments", initializeProjectAttachments);
5491
5218
  __publicField(this, "addAttachments", addProjectAttachments);
5492
5219
  __publicField(this, "updateAttachments", updateProjectAttachments);
5493
5220
  __publicField(this, "removeAttachments", deleteProjectAttachments);
@@ -5498,39 +5225,20 @@ class ProjectAttachmentService extends BaseAttachmentService {
5498
5225
  buildOfflineAttachment(data) {
5499
5226
  return offline({
5500
5227
  file: URL.createObjectURL(data.file),
5501
- file_sha1: data.file_sha1,
5502
- created_by: data.created_by,
5228
+ file_sha1: data.sha1,
5229
+ created_by: data.createdBy,
5503
5230
  file_name: data.file.name,
5504
5231
  file_type: data.file.type,
5505
- submitted_at: data.submitted_at,
5232
+ submitted_at: data.submittedAt,
5506
5233
  description: data.description,
5507
5234
  project: data.modelId
5508
5235
  });
5509
5236
  }
5510
- buildAttachmentPayload(data) {
5511
- return {
5512
- ...data,
5513
- project: data.modelId
5514
- };
5515
- }
5516
- async bulkAdd(payloads) {
5517
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.projectId, file: p.file })));
5518
- }
5519
- async delete(attachmentId) {
5520
- return this._delete(attachmentId);
5237
+ async attachFilesToProject(files, projectId) {
5238
+ return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this));
5521
5239
  }
5522
- async refreshStore(projectId) {
5523
- const result = await this.enqueueRequest({
5524
- description: "Get project attachments",
5525
- method: HttpMethod.GET,
5526
- url: `${this.url}/`,
5527
- queryParams: {
5528
- project: projectId.toString()
5529
- },
5530
- blockers: [],
5531
- blocks: []
5532
- });
5533
- this.dispatch(initializeProjectAttachments(result));
5240
+ async deleteProjectAttachment(attachmentId) {
5241
+ return this.deleteAttachment(attachmentId);
5534
5242
  }
5535
5243
  }
5536
5244
  class ProjectService extends BaseApiService {
@@ -5673,76 +5381,224 @@ const separateImageFromFields = async (fields) => {
5673
5381
  return { fields: newFields, images };
5674
5382
  };
5675
5383
  class FormService extends BaseUploadService {
5676
- add(payload, initialRevision) {
5384
+ async bulkAddRevisionAttachments(revisionId, files) {
5677
5385
  var _a2;
5678
- const { store } = this.client;
5679
5386
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5680
- const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5681
- const offlineForm = offline({
5682
- ...payload,
5683
- submitted_at: submittedAt,
5684
- created_by: createdBy
5685
- });
5686
- const offlineFormRevision = offline({
5687
- ...initialRevision,
5688
- form: offlineForm.offline_id,
5689
- revision: "Pending",
5690
- submitted_at: submittedAt,
5691
- created_by: createdBy
5692
- });
5693
- this.dispatch(addForm(offlineForm));
5694
- this.dispatch(addFormRevision(offlineFormRevision));
5695
- const formPromise = this.enqueueRequest({
5696
- description: "Create form",
5387
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5388
+ const filePayloads = {};
5389
+ const offlineFormRevisionAttachments = [];
5390
+ const attachmentPayloads = [];
5391
+ for (const [fieldIdentifier, file] of Object.entries(files)) {
5392
+ const sha1 = await hashFile(file);
5393
+ if (!(sha1 in filePayloads)) {
5394
+ filePayloads[sha1] = {
5395
+ sha1,
5396
+ file_type: file.type,
5397
+ extension: file.name.split(".").pop(),
5398
+ size: file.size
5399
+ };
5400
+ await this.client.files.addCache(file, sha1);
5401
+ }
5402
+ const offlineFormRevisionAttachment = offline({
5403
+ file: URL.createObjectURL(file),
5404
+ file_type: file.type,
5405
+ file_name: file.name,
5406
+ file_sha1: sha1,
5407
+ created_by: createdBy,
5408
+ revision: revisionId,
5409
+ submitted_at: submittedAt,
5410
+ field_identifier: fieldIdentifier
5411
+ });
5412
+ offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
5413
+ const attachmentPayload = {
5414
+ offline_id: offlineFormRevisionAttachment.offline_id,
5415
+ name: file.name,
5416
+ field_identifier: fieldIdentifier,
5417
+ sha1
5418
+ };
5419
+ attachmentPayloads.push(attachmentPayload);
5420
+ }
5421
+ this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
5422
+ const promise = this.enqueueRequest({
5423
+ description: "Attach files to form revision",
5697
5424
  method: HttpMethod.POST,
5698
- url: "/forms/",
5425
+ url: `/forms/revisions/${revisionId}/attachments/bulk/`,
5699
5426
  payload: {
5700
- // Sending exactly what is currently needed for the endpoint
5701
- offline_id: offlineForm.offline_id,
5702
- submitted_at: offlineForm.submitted_at,
5703
- initial_revision: {
5704
- offline_id: offlineFormRevision.offline_id,
5705
- submitted_at: offlineFormRevision.submitted_at,
5706
- title: offlineFormRevision.title,
5707
- description: offlineFormRevision.description,
5708
- fields: offlineFormRevision.fields
5427
+ submitted_at: submittedAt,
5428
+ attachments: attachmentPayloads,
5429
+ files: Object.values(filePayloads)
5430
+ },
5431
+ blockers: [revisionId],
5432
+ blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5433
+ });
5434
+ promise.then((result) => {
5435
+ this.processPresignedUrls(result.presigned_urls);
5436
+ this.dispatch(updateFormRevisionAttachments(result.attachments));
5437
+ }).catch(() => {
5438
+ this.dispatch(
5439
+ deleteFormRevisionAttachments(
5440
+ offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5441
+ )
5442
+ );
5443
+ });
5444
+ return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
5445
+ }
5446
+ async add(ownerId, form, initialRevision, urlPrefix) {
5447
+ const { fields, images } = await separateImageFromFields(initialRevision.fields);
5448
+ const offlineFormRevision = offline({
5449
+ ...initialRevision,
5450
+ fields,
5451
+ created_by: form.created_by,
5452
+ form: form.offline_id,
5453
+ submitted_at: form.submitted_at,
5454
+ revision: "Pending"
5455
+ });
5456
+ this.dispatch(addForm(form));
5457
+ this.dispatch(addFormRevision(offlineFormRevision));
5458
+ const formPromise = this.enqueueRequest({
5459
+ description: "Create form",
5460
+ method: HttpMethod.POST,
5461
+ url: urlPrefix,
5462
+ payload: {
5463
+ // Sending exactly what is currently needed for the endpoint
5464
+ offline_id: form.offline_id,
5465
+ submitted_at: form.submitted_at,
5466
+ initial_revision: {
5467
+ offline_id: offlineFormRevision.offline_id,
5468
+ submitted_at: offlineFormRevision.submitted_at,
5469
+ title: offlineFormRevision.title,
5470
+ description: offlineFormRevision.description,
5471
+ fields: offlineFormRevision.fields
5709
5472
  }
5710
5473
  },
5711
- blockers: [
5712
- ...payload.project ? [payload.project.toString()] : [],
5713
- ...payload.organization ? [payload.organization.toString()] : []
5714
- ],
5715
- blocks: [offlineForm.offline_id, offlineFormRevision.offline_id]
5474
+ blockers: [ownerId],
5475
+ blocks: [form.offline_id, offlineFormRevision.offline_id]
5716
5476
  });
5477
+ const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5478
+ offlineFormRevision.offline_id,
5479
+ images
5480
+ );
5717
5481
  void formPromise.catch((e) => {
5718
- this.dispatch(deleteForm(offlineForm.offline_id));
5482
+ this.dispatch(deleteForm(form.offline_id));
5719
5483
  this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
5720
5484
  throw e;
5721
5485
  });
5722
- return [offlineForm, offlineFormRevision, formPromise];
5486
+ return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5723
5487
  }
5724
- async delete(id) {
5488
+ addForOrganization(organizationId, initialRevision) {
5489
+ var _a2;
5490
+ const state = this.client.store.getState();
5491
+ const offlineForm = offline({
5492
+ favorite: false,
5493
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5494
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5495
+ organization: organizationId
5496
+ });
5497
+ return this.add(
5498
+ organizationId.toString(),
5499
+ offlineForm,
5500
+ initialRevision,
5501
+ `/organizations/${organizationId}/create-form/`
5502
+ );
5503
+ }
5504
+ addForProject(projectId, initialRevision) {
5505
+ var _a2;
5506
+ const state = this.client.store.getState();
5507
+ const offlineForm = offline({
5508
+ favorite: false,
5509
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5510
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5511
+ project: projectId
5512
+ });
5513
+ return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5514
+ }
5515
+ addForIssueType(issueTypeId, initialRevision) {
5516
+ var _a2;
5517
+ const state = this.client.store.getState();
5518
+ const offlineForm = offline({
5519
+ favorite: false,
5520
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5521
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5522
+ issue_type: issueTypeId
5523
+ });
5524
+ return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5525
+ }
5526
+ addForAssetType(assetTypeId, initialRevision) {
5527
+ var _a2;
5528
+ const state = this.client.store.getState();
5529
+ const offlineForm = offline({
5530
+ favorite: false,
5531
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5532
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5533
+ asset_type: assetTypeId
5534
+ });
5535
+ return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5536
+ }
5537
+ async createRevision(formId, revision) {
5538
+ var _a2;
5539
+ const offlineRevision = offline(revision);
5540
+ const { store } = this.client;
5541
+ const state = store.getState();
5542
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5543
+ const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5544
+ const fullRevision = {
5545
+ ...offlineRevision,
5546
+ fields,
5547
+ created_by: createdBy,
5548
+ revision: "Pending",
5549
+ form: formId,
5550
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5551
+ };
5552
+ this.dispatch(addFormRevision(fullRevision));
5553
+ const promise = this.enqueueRequest({
5554
+ description: "Create form revision",
5555
+ method: HttpMethod.PATCH,
5556
+ url: `/forms/${formId}/`,
5557
+ payload: {
5558
+ initial_revision: {
5559
+ offline_id: fullRevision.offline_id,
5560
+ submitted_at: fullRevision.submitted_at,
5561
+ title: fullRevision.title,
5562
+ description: fullRevision.description,
5563
+ fields: fullRevision.fields
5564
+ }
5565
+ },
5566
+ blockers: [formId],
5567
+ blocks: [offlineRevision.offline_id]
5568
+ });
5569
+ const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5570
+ fullRevision.offline_id,
5571
+ images
5572
+ );
5573
+ void promise.then((result) => {
5574
+ this.dispatch(setFormRevision(result));
5575
+ }).catch(() => {
5576
+ this.dispatch(deleteFormRevision(fullRevision.offline_id));
5577
+ });
5578
+ return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5579
+ }
5580
+ async delete(formId) {
5725
5581
  const { store } = this.client;
5726
5582
  const state = store.getState();
5727
- const form = selectFormById(id)(state);
5583
+ const form = selectFormById(formId)(state);
5728
5584
  if (!form) {
5729
5585
  throw new Error("Expected form to exist");
5730
5586
  }
5731
- const formSubmissions = selectFormSubmissionsOfForm(id)(state);
5587
+ const formSubmissions = selectFormSubmissionsOfForm(formId)(state);
5732
5588
  if (formSubmissions.length > 0) {
5733
5589
  this.dispatch(deleteFormSubmissions(formSubmissions.map(({ offline_id }) => offline_id)));
5734
5590
  }
5735
- const formRevisions = selectFormRevisionsOfForm(id)(state);
5591
+ const formRevisions = selectFormRevisionsOfForm(formId)(state);
5736
5592
  if (formRevisions.length > 0) {
5737
5593
  this.dispatch(deleteFormRevisions(formRevisions.map(({ offline_id }) => offline_id)));
5738
5594
  }
5739
- this.dispatch(deleteForm(id));
5595
+ this.dispatch(deleteForm(formId));
5740
5596
  try {
5741
5597
  return await this.enqueueRequest({
5742
5598
  description: "Delete form",
5743
5599
  method: HttpMethod.DELETE,
5744
- url: `/forms/${id}/`,
5745
- blockers: [id],
5600
+ url: `/forms/${formId}/`,
5601
+ blockers: [formId],
5746
5602
  blocks: []
5747
5603
  });
5748
5604
  } catch (e) {
@@ -5756,31 +5612,65 @@ class FormService extends BaseUploadService {
5756
5612
  throw e;
5757
5613
  }
5758
5614
  }
5759
- async refreshStore(projectId, organizationId) {
5760
- let forms = [];
5761
- const projectForms = await this.enqueueRequest({
5615
+ async refreshStore(projectId) {
5616
+ const forms = [];
5617
+ const revisions = [];
5618
+ const attachments = [];
5619
+ const projectFormsResult = await this.enqueueRequest({
5762
5620
  description: "Fetch project forms",
5763
5621
  method: HttpMethod.GET,
5764
- url: "/forms/",
5765
- queryParams: {
5766
- project: projectId.toString()
5767
- },
5622
+ url: `/projects/${projectId}/forms/`,
5768
5623
  blockers: [projectId.toString()],
5769
5624
  blocks: []
5770
5625
  });
5771
- forms = forms.concat(projectForms);
5772
- const organizationForms = await this.enqueueRequest({
5626
+ for (const form of projectFormsResult.forms)
5627
+ forms.push(form);
5628
+ for (const revision of projectFormsResult.revisions)
5629
+ revisions.push(revision);
5630
+ for (const attachment of projectFormsResult.attachments)
5631
+ attachments.push(attachment);
5632
+ const organizationFormsResult = await this.enqueueRequest({
5773
5633
  description: "Fetch organization forms",
5774
5634
  method: HttpMethod.GET,
5775
- url: "/forms/",
5776
- queryParams: {
5777
- organization: organizationId.toString()
5778
- },
5779
- blockers: [organizationId.toString()],
5635
+ url: `/projects/${projectId}/organizations/forms/`,
5636
+ blockers: [projectId.toString()],
5637
+ blocks: []
5638
+ });
5639
+ for (const form of organizationFormsResult.forms)
5640
+ forms.push(form);
5641
+ for (const revision of organizationFormsResult.revisions)
5642
+ revisions.push(revision);
5643
+ for (const attachment of organizationFormsResult.attachments)
5644
+ attachments.push(attachment);
5645
+ const assetTypeFormsResult = await this.enqueueRequest({
5646
+ description: "Fetch asset type forms",
5647
+ method: HttpMethod.GET,
5648
+ url: `/projects/${projectId}/asset-types/forms/`,
5649
+ blockers: [projectId.toString()],
5650
+ blocks: []
5651
+ });
5652
+ for (const form of assetTypeFormsResult.forms)
5653
+ forms.push(form);
5654
+ for (const revision of assetTypeFormsResult.revisions)
5655
+ revisions.push(revision);
5656
+ for (const attachment of assetTypeFormsResult.attachments)
5657
+ attachments.push(attachment);
5658
+ const issueTypeFormsResult = await this.enqueueRequest({
5659
+ description: "Fetch issue type forms",
5660
+ method: HttpMethod.GET,
5661
+ url: `/projects/${projectId}/issue-types/forms/`,
5662
+ blockers: [projectId.toString()],
5780
5663
  blocks: []
5781
5664
  });
5782
- forms = forms.concat(organizationForms);
5665
+ for (const form of issueTypeFormsResult.forms)
5666
+ forms.push(form);
5667
+ for (const revision of issueTypeFormsResult.revisions)
5668
+ revisions.push(revision);
5669
+ for (const attachment of issueTypeFormsResult.attachments)
5670
+ attachments.push(attachment);
5783
5671
  this.dispatch(initializeForms(forms));
5672
+ this.dispatch(initializeFormRevisions(revisions));
5673
+ this.dispatch(initializeFormRevisionAttachments(attachments));
5784
5674
  }
5785
5675
  }
5786
5676
  const isArrayOfFiles = (value) => {
@@ -5802,11 +5692,95 @@ const separateFilesFromValues = (values) => {
5802
5692
  return { values: newValues, files };
5803
5693
  };
5804
5694
  class FormSubmissionService extends BaseUploadService {
5805
- add(payload) {
5695
+ async bulkAddSubmissionAttachments(submissionId, files) {
5696
+ var _a2;
5697
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5698
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5699
+ const filePayloads = {};
5700
+ const offlineFormSubmissionAttachments = [];
5701
+ const attachmentPayloads = [];
5702
+ for (const [fieldIdentifier, filesArray] of Object.entries(files)) {
5703
+ for (const file of filesArray) {
5704
+ const sha1 = await hashFile(file);
5705
+ if (!(sha1 in filePayloads)) {
5706
+ filePayloads[sha1] = {
5707
+ sha1,
5708
+ file_type: file.type,
5709
+ extension: file.name.split(".").pop(),
5710
+ size: file.size
5711
+ };
5712
+ await this.client.files.addCache(file, sha1);
5713
+ }
5714
+ const offlineFormSubmissionAttachment = offline({
5715
+ file: URL.createObjectURL(file),
5716
+ file_type: file.type,
5717
+ file_name: file.name,
5718
+ file_sha1: sha1,
5719
+ created_by: createdBy,
5720
+ submission: submissionId,
5721
+ submitted_at: submittedAt,
5722
+ field_identifier: fieldIdentifier
5723
+ });
5724
+ offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
5725
+ const attachmentPayload = {
5726
+ offline_id: offlineFormSubmissionAttachment.offline_id,
5727
+ name: file.name,
5728
+ sha1,
5729
+ field_identifier: fieldIdentifier
5730
+ };
5731
+ attachmentPayloads.push(attachmentPayload);
5732
+ }
5733
+ }
5734
+ this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
5735
+ const promise = this.enqueueRequest({
5736
+ description: "Attach files to form submission",
5737
+ method: HttpMethod.POST,
5738
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5739
+ payload: {
5740
+ submitted_at: submittedAt,
5741
+ attachments: attachmentPayloads,
5742
+ files: Object.values(filePayloads)
5743
+ },
5744
+ blockers: [submissionId],
5745
+ blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5746
+ });
5747
+ promise.then((result) => {
5748
+ this.processPresignedUrls(result.presigned_urls);
5749
+ this.dispatch(updateFormSubmissionAttachments(result.attachments));
5750
+ }).catch(() => {
5751
+ this.dispatch(
5752
+ deleteFormSubmissionAttachments(
5753
+ offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5754
+ )
5755
+ );
5756
+ });
5757
+ return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5758
+ }
5759
+ async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
5760
+ const { store } = this.client;
5761
+ const state = store.getState();
5762
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
5763
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
5764
+ try {
5765
+ await this.enqueueRequest({
5766
+ description: "Delete form submission attachments",
5767
+ method: HttpMethod.DELETE,
5768
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5769
+ payload: { attachments: attachmentsIds },
5770
+ blockers: [submissionId, ...attachmentsIds],
5771
+ blocks: []
5772
+ });
5773
+ } catch (e) {
5774
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
5775
+ throw e;
5776
+ }
5777
+ }
5778
+ // Outer promise is for hashing and caching files for submission attachments
5779
+ async add(payload) {
5806
5780
  var _a2;
5807
5781
  const { store } = this.client;
5808
5782
  const state = store.getState();
5809
- const { values } = separateFilesFromValues(payload.values);
5783
+ const { values, files } = separateFilesFromValues(payload.values);
5810
5784
  const offlineSubmission = offline({
5811
5785
  ...payload,
5812
5786
  values,
@@ -5816,7 +5790,7 @@ class FormSubmissionService extends BaseUploadService {
5816
5790
  const promise = this.enqueueRequest({
5817
5791
  description: "Respond to form",
5818
5792
  method: HttpMethod.POST,
5819
- url: "/form-submissions/",
5793
+ url: `/forms/revisions/${payload.form_revision}/respond/`,
5820
5794
  payload: offlineSubmission,
5821
5795
  blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
5822
5796
  (x) => x !== void 0
@@ -5824,6 +5798,10 @@ class FormSubmissionService extends BaseUploadService {
5824
5798
  blocks: [offlineSubmission.offline_id]
5825
5799
  });
5826
5800
  this.dispatch(addFormSubmission(offlineSubmission));
5801
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5802
+ offlineSubmission.offline_id,
5803
+ files
5804
+ );
5827
5805
  promise.then((result) => {
5828
5806
  this.dispatch(addActiveProjectFormSubmissionsCount(1));
5829
5807
  this.dispatch(setFormSubmission(result));
@@ -5832,16 +5810,115 @@ class FormSubmissionService extends BaseUploadService {
5832
5810
  this.dispatch(deleteFormSubmission(offlineSubmission.offline_id));
5833
5811
  this.dispatch(addActiveProjectFormSubmissionsCount(-1));
5834
5812
  });
5835
- return [offlineSubmission, promise];
5813
+ return [offlineSubmission, offlineFormSubmissionAttachments, promise, attachmentsPromise];
5836
5814
  }
5837
- update(payload) {
5815
+ // Note currently the bulkAdd method is specific to form submissions for assets
5816
+ // TODO: adapt the support bulk adding to any model type
5817
+ async bulkAdd(args, batchSize) {
5818
+ const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
5819
+ const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
5820
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5821
+ const transactionId = v4();
5822
+ const assetIdBatches = chunkArray(Object.keys(fieldValuesByAsset), batchSize);
5823
+ const bulkAddBatches = await Promise.all(
5824
+ assetIdBatches.map(async (assetIdBatch) => {
5825
+ const batchId = v4();
5826
+ const submissionPayloads = [];
5827
+ const attachmentPayloads = [];
5828
+ const files = { ...commonFiles };
5829
+ for (const assetId of assetIdBatch) {
5830
+ const { values: fileSeperatedSubmissionSpecificValues, files: submissionSpecificFiles } = separateFilesFromValues(fieldValuesByAsset[assetId] ?? {});
5831
+ Object.assign(files, submissionSpecificFiles);
5832
+ const submissionPayload = offline({
5833
+ asset_id: assetId,
5834
+ form_data: fileSeperatedSubmissionSpecificValues
5835
+ });
5836
+ submissionPayloads.push(submissionPayload);
5837
+ for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
5838
+ for (const file of fileArray) {
5839
+ const sha1 = await hashFile(file);
5840
+ await this.client.files.addCache(file, sha1);
5841
+ const attachmentPayload = offline({
5842
+ submission_id: submissionPayload.offline_id,
5843
+ sha1,
5844
+ name: file.name,
5845
+ field_identifier: fieldIdentifier
5846
+ });
5847
+ attachmentPayloads.push(attachmentPayload);
5848
+ }
5849
+ }
5850
+ }
5851
+ const filePaylods = [];
5852
+ for (const file of Object.values(files).flat()) {
5853
+ const sha1 = await hashFile(file);
5854
+ const filePayload = {
5855
+ sha1,
5856
+ extension: file.name.split(".").pop() || "",
5857
+ file_type: file.type,
5858
+ size: file.size
5859
+ };
5860
+ filePaylods.push(filePayload);
5861
+ }
5862
+ return {
5863
+ batchId,
5864
+ payload: {
5865
+ transaction_id: transactionId,
5866
+ form_data: fileSeperatedCommonFieldValues,
5867
+ submitted_at: submittedAt,
5868
+ submissions: submissionPayloads,
5869
+ attachments: attachmentPayloads,
5870
+ files: filePaylods
5871
+ }
5872
+ };
5873
+ })
5874
+ );
5875
+ const batchPromises = [];
5876
+ let prevBatchId = null;
5877
+ for (const batch of bulkAddBatches) {
5878
+ const { payload, batchId } = batch;
5879
+ const batchAssetIds = payload.submissions.map((x) => x.asset_id);
5880
+ const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
5881
+ const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
5882
+ const blockers = batchAssetIds;
5883
+ if (prevBatchId)
5884
+ blockers.push(prevBatchId);
5885
+ const blocks = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
5886
+ const promise = this.enqueueRequest({
5887
+ description: "Bulk add form submissions",
5888
+ method: HttpMethod.POST,
5889
+ url: `/forms/revisions/${formRevision}/bulk-respond/`,
5890
+ payload,
5891
+ blockers,
5892
+ blocks
5893
+ });
5894
+ void promise.then(({ presigned_urls }) => {
5895
+ this.processPresignedUrls(presigned_urls);
5896
+ });
5897
+ prevBatchId = batchId;
5898
+ batchPromises.push(promise);
5899
+ }
5900
+ void Promise.all(batchPromises).then((results) => {
5901
+ const createdSubmissions = [];
5902
+ const createdAttachments = [];
5903
+ for (const result of results) {
5904
+ for (const createdSubmission of result.submissions)
5905
+ createdSubmissions.push(createdSubmission);
5906
+ for (const createdAttachment of result.attachments)
5907
+ createdAttachments.push(createdAttachment);
5908
+ }
5909
+ this.dispatch(addFormSubmissions(createdSubmissions));
5910
+ this.dispatch(addFormSubmissionAttachments(createdAttachments));
5911
+ });
5912
+ return batchPromises;
5913
+ }
5914
+ async update(payload) {
5838
5915
  const { store } = this.client;
5839
5916
  const state = store.getState();
5840
5917
  const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
5841
5918
  if (!submissionToBeUpdated) {
5842
5919
  throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
5843
5920
  }
5844
- const { values } = separateFilesFromValues(payload.values ?? {});
5921
+ const { values, files } = separateFilesFromValues(payload.values ?? {});
5845
5922
  const updatedSubmission = {
5846
5923
  ...submissionToBeUpdated,
5847
5924
  ...payload,
@@ -5855,36 +5932,57 @@ class FormSubmissionService extends BaseUploadService {
5855
5932
  const promise = this.enqueueRequest({
5856
5933
  description: "Delete user form submissions",
5857
5934
  method: HttpMethod.PATCH,
5858
- url: `/form-submissions/${updatedSubmission.offline_id}/`,
5935
+ url: `/forms/submissions/${updatedSubmission.offline_id}/`,
5859
5936
  // TODO: send just payload when FormSubmissionDeserializer is updated to handle partial updates
5860
5937
  payload: updatedSubmission,
5861
5938
  blockers: [updatedSubmission.offline_id],
5862
5939
  blocks: [updatedSubmission.offline_id]
5863
5940
  });
5941
+ const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
5942
+ const formSubmissionAttachmentIdsToBeDeleted = [];
5943
+ for (const attachment of formSubmissionAttachments) {
5944
+ if (attachment.field_identifier in files) {
5945
+ formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
5946
+ }
5947
+ }
5948
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5949
+ payload.offline_id,
5950
+ files
5951
+ );
5952
+ const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
5953
+ payload.offline_id,
5954
+ formSubmissionAttachmentIdsToBeDeleted
5955
+ );
5864
5956
  promise.then((result) => {
5865
5957
  this.dispatch(setFormSubmission(result));
5866
5958
  }).catch(() => {
5867
5959
  this.dispatch(setFormSubmission(submissionToBeUpdated));
5868
5960
  });
5869
- return [updatedSubmission, promise];
5961
+ return [
5962
+ updatedSubmission,
5963
+ offlineFormSubmissionAttachments,
5964
+ promise,
5965
+ attachmentsPromise,
5966
+ deleteAttachmentsPromise
5967
+ ];
5870
5968
  }
5871
- async delete(id) {
5969
+ async delete(submissionId) {
5872
5970
  const { store } = this.client;
5873
5971
  const state = store.getState();
5874
- const submissionToBeDeleted = selectFormSubmissionById(id)(state);
5972
+ const submissionToBeDeleted = selectFormSubmissionById(submissionId)(state);
5875
5973
  if (!submissionToBeDeleted) {
5876
- throw new Error(`Expected submission with offline_id ${id} to exist`);
5974
+ throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
5877
5975
  }
5878
- const submissionAttachments = selectAttachmentsOfFormSubmission(id)(state);
5879
- this.dispatch(deleteFormSubmission(id));
5976
+ const submissionAttachments = selectAttachmentsOfFormSubmission(submissionId)(state);
5977
+ this.dispatch(deleteFormSubmission(submissionId));
5880
5978
  this.dispatch(addActiveProjectFormSubmissionsCount(-1));
5881
5979
  this.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
5882
5980
  try {
5883
5981
  return await this.enqueueRequest({
5884
5982
  description: "Delete user form submissions",
5885
5983
  method: HttpMethod.DELETE,
5886
- url: `/form-submissions/${id}/`,
5887
- blockers: [id],
5984
+ url: `/forms/submissions/${submissionId}/`,
5985
+ blockers: [submissionId],
5888
5986
  blocks: []
5889
5987
  });
5890
5988
  } catch (e) {
@@ -5895,17 +5993,50 @@ class FormSubmissionService extends BaseUploadService {
5895
5993
  }
5896
5994
  }
5897
5995
  async refreshStore(projectId) {
5898
- const result = await this.enqueueRequest({
5899
- description: "Fetch form submissions",
5996
+ const formSubmissions = {};
5997
+ const modelSubmissions = await this.enqueueRequest({
5998
+ description: "Fetch model submissions",
5900
5999
  method: HttpMethod.GET,
5901
- url: "/form-submissions/",
5902
- queryParams: {
5903
- project: projectId.toString()
5904
- },
6000
+ url: `/forms/in-project/${projectId}/submissions/model/latest/`,
5905
6001
  blockers: [],
5906
6002
  blocks: []
5907
6003
  });
5908
- this.dispatch(initializeFormSubmissions(result));
6004
+ for (const modelSubmission of modelSubmissions) {
6005
+ formSubmissions[modelSubmission.offline_id] = modelSubmission;
6006
+ }
6007
+ const standaloneSubmissions = await this.enqueueRequest({
6008
+ description: "Fetch standalone submissions",
6009
+ method: HttpMethod.GET,
6010
+ url: `/forms/in-project/${projectId}/submissions/standalone/`,
6011
+ blockers: [],
6012
+ blocks: []
6013
+ });
6014
+ for (const standaloneSubmission of standaloneSubmissions) {
6015
+ formSubmissions[standaloneSubmission.offline_id] = standaloneSubmission;
6016
+ }
6017
+ this.dispatch(initializeFormSubmissions(Object.values(formSubmissions)));
6018
+ const attachments = {};
6019
+ const modelAttachments = await this.enqueueRequest({
6020
+ description: "Fetch model submission attachments",
6021
+ method: HttpMethod.GET,
6022
+ url: `/forms/in-project/${projectId}/attachments/model/latest/`,
6023
+ blockers: [],
6024
+ blocks: []
6025
+ });
6026
+ for (const modelAttachment of modelAttachments) {
6027
+ attachments[modelAttachment.offline_id] = modelAttachment;
6028
+ }
6029
+ const standaloneAttachments = await this.enqueueRequest({
6030
+ description: "Fetch standalone submission attachments",
6031
+ method: HttpMethod.GET,
6032
+ url: `/forms/in-project/${projectId}/attachments/standalone/`,
6033
+ blockers: [],
6034
+ blocks: []
6035
+ });
6036
+ for (const standaloneAttachent of standaloneAttachments) {
6037
+ attachments[standaloneAttachent.offline_id] = standaloneAttachent;
6038
+ }
6039
+ this.dispatch(initializeFormSubmissionAttachments(Object.values(attachments)));
5909
6040
  }
5910
6041
  }
5911
6042
  class WorkspaceService extends BaseApiService {
@@ -5957,22 +6088,22 @@ class WorkspaceService extends BaseApiService {
5957
6088
  });
5958
6089
  return [workspace, promise];
5959
6090
  }
5960
- delete(id) {
6091
+ delete(workspaceId) {
5961
6092
  const { store } = this.client;
5962
- const originalWorkspace = selectWorkspaceById(id)(store.getState());
5963
- if (!originalWorkspace) {
5964
- throw new Error(`Expected an existing workspace with id ${id}`);
5965
- }
5966
- this.dispatch(deleteWorkspace(id));
6093
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6094
+ this.dispatch(deleteWorkspace(workspaceId));
5967
6095
  const promise = this.enqueueRequest({
5968
6096
  description: "Delete Workspace",
5969
6097
  method: HttpMethod.DELETE,
5970
- url: `/workspaces/${id}/`,
5971
- blockers: [id],
6098
+ url: `/workspaces/${workspaceId}/`,
6099
+ blockers: [workspaceId],
5972
6100
  blocks: []
5973
6101
  });
5974
- void promise.catch((reason) => {
5975
- this.dispatch(addWorkspace(originalWorkspace));
6102
+ void promise.then(() => {
6103
+ }).catch((reason) => {
6104
+ if (originalWorkspace) {
6105
+ this.dispatch(addWorkspace(originalWorkspace));
6106
+ }
5976
6107
  throw reason;
5977
6108
  });
5978
6109
  return promise;
@@ -6607,8 +6738,8 @@ class DocumentService extends BaseApiService {
6607
6738
  class DocumentAttachmentService extends BaseAttachmentService {
6608
6739
  constructor() {
6609
6740
  super(...arguments);
6610
- __publicField(this, "name", "Document Attachment");
6611
- __publicField(this, "url", "/document-attachments");
6741
+ __publicField(this, "attachmentModel", AttachmentModel.Document);
6742
+ __publicField(this, "initializeAttachments", initializeDocumentAttachments);
6612
6743
  __publicField(this, "addAttachments", addDocumentAttachments);
6613
6744
  __publicField(this, "updateAttachments", updateDocumentAttachments);
6614
6745
  __publicField(this, "removeAttachments", deleteDocumentAttachments);
@@ -6619,23 +6750,17 @@ class DocumentAttachmentService extends BaseAttachmentService {
6619
6750
  buildOfflineAttachment(data) {
6620
6751
  return offline({
6621
6752
  file: URL.createObjectURL(data.file),
6622
- file_sha1: data.file_sha1,
6623
- created_by: data.created_by,
6753
+ file_sha1: data.sha1,
6754
+ created_by: data.createdBy,
6624
6755
  file_name: data.file.name,
6625
6756
  file_type: data.file.type,
6626
- submitted_at: data.submitted_at,
6757
+ submitted_at: data.submittedAt,
6627
6758
  description: data.description,
6628
6759
  document: data.modelId
6629
6760
  });
6630
6761
  }
6631
- buildAttachmentPayload(data) {
6632
- return {
6633
- ...data,
6634
- document: data.modelId
6635
- };
6636
- }
6637
6762
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6638
- async bulkAdd(payloads) {
6763
+ async attachFilesToDocument(files, documentId) {
6639
6764
  var _a2;
6640
6765
  const { store } = this.client;
6641
6766
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -6644,36 +6769,40 @@ class DocumentAttachmentService extends BaseAttachmentService {
6644
6769
  const attachmentPayloads = [];
6645
6770
  const filePayloads = {};
6646
6771
  const sha1ToAttachmentIds = {};
6647
- for (const payload of payloads) {
6648
- const { documentId, file } = payload;
6649
- const filePayload = await this.getFilePayload(file);
6650
- if (!(filePayload.sha1 in filePayloads)) {
6651
- filePayloads[filePayload.sha1] = filePayload;
6652
- sha1ToAttachmentIds[filePayload.sha1] = [];
6772
+ for (const file of files) {
6773
+ const sha1 = await hashFile(file);
6774
+ if (!(sha1 in filePayloads)) {
6775
+ filePayloads[sha1] = {
6776
+ sha1,
6777
+ file_type: file.type,
6778
+ extension: file.name.split(".").pop(),
6779
+ size: file.size
6780
+ };
6781
+ sha1ToAttachmentIds[sha1] = [];
6782
+ await this.client.files.addCache(file, sha1);
6653
6783
  }
6654
6784
  const offlineAttachment = this.buildOfflineAttachment({
6655
6785
  file,
6656
- file_sha1: filePayload.sha1,
6657
- submitted_at: submittedAt,
6658
- created_by: createdBy,
6786
+ sha1,
6787
+ submittedAt,
6788
+ createdBy,
6659
6789
  description: "",
6660
6790
  modelId: documentId
6661
6791
  });
6662
6792
  offlineAttachments.push(offlineAttachment);
6663
6793
  attachmentPayloads.push({
6664
6794
  offline_id: offlineAttachment.offline_id,
6665
- file_name: offlineAttachment.file_name,
6666
- file_sha1: offlineAttachment.file_sha1,
6667
- file_extension: filePayload.extension,
6795
+ name: offlineAttachment.file_name,
6796
+ sha1: offlineAttachment.file_sha1,
6668
6797
  description: offlineAttachment.description
6669
6798
  });
6670
- sha1ToAttachmentIds[filePayload.sha1].push(offlineAttachment.offline_id);
6799
+ sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
6671
6800
  }
6672
6801
  this.dispatch(this.addAttachments(offlineAttachments));
6673
6802
  const promise = this.enqueueRequest({
6674
6803
  description: "Attach files to document",
6675
6804
  method: HttpMethod.POST,
6676
- url: "/document-attachments/bulk/",
6805
+ url: `/documents/${documentId}/attach/`,
6677
6806
  payload: {
6678
6807
  submitted_at: submittedAt,
6679
6808
  attachments: attachmentPayloads,
@@ -6698,14 +6827,14 @@ class DocumentAttachmentService extends BaseAttachmentService {
6698
6827
  });
6699
6828
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
6700
6829
  }
6701
- async delete(id) {
6702
- return this._delete(id);
6830
+ async deleteDocumentAttachment(attachmentId) {
6831
+ return this.deleteAttachment(attachmentId);
6703
6832
  }
6704
6833
  makeReadable(attachmnentId) {
6705
6834
  void this.enqueueRequest({
6706
6835
  description: "Add attachment to AI assistant",
6707
6836
  method: HttpMethod.PATCH,
6708
- url: `/document-attachments/${attachmnentId}/`,
6837
+ url: `/documents/attachments/${attachmnentId}/`,
6709
6838
  payload: {
6710
6839
  readable_to_assistant: true
6711
6840
  },
@@ -6722,7 +6851,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6722
6851
  blocks: [],
6723
6852
  blockers: []
6724
6853
  });
6725
- this.dispatch(initializeDocumentAttachments(projectDocumentAttachments));
6854
+ this.dispatch(this.initializeAttachments(projectDocumentAttachments));
6726
6855
  const organizationDocumentAttachments = await this.enqueueRequest({
6727
6856
  description: "Get document attachments",
6728
6857
  method: HttpMethod.GET,
@@ -6857,21 +6986,21 @@ class TeamService extends BaseApiService {
6857
6986
  });
6858
6987
  return [offlineUpdatedTeam, promise];
6859
6988
  }
6860
- async delete(id) {
6989
+ async delete(teamId) {
6861
6990
  const { store } = this.client;
6862
6991
  const state = store.getState();
6863
- const team = selectTeamById(id)(state);
6992
+ const team = selectTeamById(teamId)(state);
6864
6993
  if (!team) {
6865
- throw new Error(`Expected team with id ${id} to exist`);
6994
+ throw new Error(`Expected team with id ${teamId} to exist`);
6866
6995
  }
6867
- this.dispatch(deleteTeam(id));
6996
+ this.dispatch(deleteTeam(teamId));
6868
6997
  try {
6869
6998
  return await this.enqueueRequest({
6870
6999
  description: "Delete team",
6871
7000
  method: HttpMethod.DELETE,
6872
- url: `/organizations/teams/${id}/`,
6873
- blockers: [id],
6874
- blocks: [id]
7001
+ url: `/organizations/teams/${teamId}/`,
7002
+ blockers: [teamId],
7003
+ blocks: [teamId]
6875
7004
  });
6876
7005
  } catch (e) {
6877
7006
  this.dispatch(setTeam(team));
@@ -6966,11 +7095,17 @@ class GeoImageService extends BaseUploadService {
6966
7095
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6967
7096
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6968
7097
  const projectId = payloadWithoutFile.project;
6969
- const filePayload = await this.getFilePayload(file);
7098
+ const sha1 = await hashFile(file);
7099
+ const filePayload = {
7100
+ sha1,
7101
+ file_type: file.type,
7102
+ extension: file.name.split(".").pop(),
7103
+ size: file.size
7104
+ };
6970
7105
  const offlineMapImage = offline({
6971
7106
  ...payloadWithoutFile,
6972
7107
  file_name: file.name,
6973
- file_sha1: filePayload.sha1,
7108
+ file_sha1: sha1,
6974
7109
  file: URL.createObjectURL(file),
6975
7110
  submitted_at: submittedAt,
6976
7111
  created_by: createdBy
@@ -7013,16 +7148,23 @@ class GeoImageService extends BaseUploadService {
7013
7148
  const offlineGeoImages = [];
7014
7149
  const offlineIds = [];
7015
7150
  const geoImagePayloads = [];
7016
- const filePayloads = {};
7151
+ const filePayloadRecord = {};
7017
7152
  for (const payloadAndFile of payloads) {
7018
7153
  const { file, ...payload } = payloadAndFile;
7019
- const filePayload = await this.getFilePayload(file);
7020
- if (!(filePayload.sha1 in filePayloads))
7021
- filePayloads[filePayload.sha1] = filePayload;
7154
+ const sha1 = await hashFile(file);
7155
+ if (!(sha1 in filePayloadRecord)) {
7156
+ filePayloadRecord[sha1] = {
7157
+ sha1,
7158
+ file_type: file.type,
7159
+ extension: file.name.split(".").pop(),
7160
+ size: file.size
7161
+ };
7162
+ await this.client.files.addCache(file, sha1);
7163
+ }
7022
7164
  const offlineMapImage = offline({
7023
7165
  ...payload,
7024
7166
  file_name: file.name,
7025
- file_sha1: filePayload.sha1,
7167
+ file_sha1: sha1,
7026
7168
  file: URL.createObjectURL(file),
7027
7169
  submitted_at: submittedAt,
7028
7170
  created_by: createdBy,
@@ -7051,7 +7193,7 @@ class GeoImageService extends BaseUploadService {
7051
7193
  submitted_at: submittedAt,
7052
7194
  project: projectId,
7053
7195
  geo_images: geoImagePayloads,
7054
- files: Object.values(filePayloads)
7196
+ files: Object.values(filePayloadRecord)
7055
7197
  },
7056
7198
  blocks: [projectId.toString()],
7057
7199
  blockers: offlineIds
@@ -7088,20 +7230,20 @@ class GeoImageService extends BaseUploadService {
7088
7230
  });
7089
7231
  return [updatedGeoImage, promise];
7090
7232
  }
7091
- async delete(id) {
7233
+ async delete(geoImageId) {
7092
7234
  const { store } = this.client;
7093
7235
  const state = store.getState();
7094
- const geoImageToDelete = selectGeoImageById(id)(state);
7236
+ const geoImageToDelete = selectGeoImageById(geoImageId)(state);
7095
7237
  if (!geoImageToDelete) {
7096
- throw new Error(`Map image with offline_id ${id} does not exist in the store`);
7238
+ throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7097
7239
  }
7098
- this.dispatch(deleteGeoImage(id));
7240
+ this.dispatch(deleteGeoImage(geoImageId));
7099
7241
  const promise = this.enqueueRequest({
7100
7242
  description: "Delete geo image",
7101
7243
  method: HttpMethod.DELETE,
7102
- url: `/geo-images/${id}/`,
7103
- blocks: [id],
7104
- blockers: [id]
7244
+ url: `/geo-images/${geoImageId}/`,
7245
+ blocks: [geoImageId],
7246
+ blockers: [geoImageId]
7105
7247
  });
7106
7248
  promise.catch(() => {
7107
7249
  this.dispatch(setGeoImage(geoImageToDelete));
@@ -7119,7 +7261,7 @@ class GeoImageService extends BaseUploadService {
7119
7261
  this.dispatch(initializeGeoImages(result));
7120
7262
  }
7121
7263
  }
7122
- class IssueAssociationService extends BaseApiService {
7264
+ class IssueAssociationService extends BaseUploadService {
7123
7265
  add(payload) {
7124
7266
  var _a2;
7125
7267
  const { store } = this.client;
@@ -7134,7 +7276,7 @@ class IssueAssociationService extends BaseApiService {
7134
7276
  const promise = this.enqueueRequest({
7135
7277
  description: "Add issue association",
7136
7278
  method: HttpMethod.POST,
7137
- url: "/issue-associations/",
7279
+ url: "/issues/associations/",
7138
7280
  payload: {
7139
7281
  offline_id: offlineIssueAssociation.offline_id,
7140
7282
  submitted_at: submittedAt,
@@ -7164,7 +7306,7 @@ class IssueAssociationService extends BaseApiService {
7164
7306
  const promise = this.enqueueRequest({
7165
7307
  description: "Delete issue association",
7166
7308
  method: HttpMethod.DELETE,
7167
- url: `/issue-associations/${id}/`,
7309
+ url: `/issues/associations/${id}/`,
7168
7310
  blockers: [id],
7169
7311
  blocks: []
7170
7312
  });
@@ -7177,938 +7319,14 @@ class IssueAssociationService extends BaseApiService {
7177
7319
  const issueAssociations = await this.enqueueRequest({
7178
7320
  description: "Fetch issue associations",
7179
7321
  method: HttpMethod.GET,
7180
- url: "/issue-associations/",
7181
- queryParams: { project: projectId.toString() },
7322
+ url: "/issues/associations/",
7323
+ queryParams: { project_id: projectId.toString() },
7182
7324
  blockers: [],
7183
7325
  blocks: []
7184
7326
  });
7185
7327
  this.dispatch(initializeIssueAssociations(issueAssociations));
7186
7328
  }
7187
7329
  }
7188
- class FormRevisionAttachmentService extends BaseUploadService {
7189
- async bulkAdd(payloads) {
7190
- var _a2;
7191
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7192
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7193
- const filePayloads = {};
7194
- const offlineFormRevisionAttachments = [];
7195
- const attachmentPayloads = [];
7196
- for (const payload of payloads) {
7197
- const { revisionId, fieldIdentifier, file } = payload;
7198
- const filePayload = await this.getFilePayload(file);
7199
- if (!(filePayload.sha1 in filePayloads))
7200
- filePayloads[filePayload.sha1] = filePayload;
7201
- const offlineFormRevisionAttachment = offline({
7202
- file: URL.createObjectURL(file),
7203
- file_type: file.type,
7204
- file_name: file.name,
7205
- file_sha1: filePayload.sha1,
7206
- created_by: createdBy,
7207
- form_revision: revisionId,
7208
- submitted_at: submittedAt,
7209
- field_identifier: fieldIdentifier
7210
- });
7211
- offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
7212
- const attachmentPayload = {
7213
- offline_id: offlineFormRevisionAttachment.offline_id,
7214
- file_name: file.name,
7215
- field_identifier: fieldIdentifier,
7216
- file_extension: filePayload.extension,
7217
- file_sha1: filePayload.sha1,
7218
- form_revision: revisionId
7219
- };
7220
- attachmentPayloads.push(attachmentPayload);
7221
- }
7222
- this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
7223
- const promise = this.enqueueRequest({
7224
- description: "Attach files to form revision",
7225
- method: HttpMethod.POST,
7226
- url: "/form-revision-attachments/bulk/",
7227
- payload: {
7228
- submitted_at: submittedAt,
7229
- attachments: attachmentPayloads,
7230
- files: Object.values(filePayloads)
7231
- },
7232
- blockers: offlineFormRevisionAttachments.map((attachment) => attachment.form_revision),
7233
- blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
7234
- });
7235
- promise.then((result) => {
7236
- this.processPresignedUrls(result.presigned_urls);
7237
- this.dispatch(updateFormRevisionAttachments(result.attachments));
7238
- }).catch(() => {
7239
- this.dispatch(
7240
- deleteFormRevisionAttachments(
7241
- offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
7242
- )
7243
- );
7244
- });
7245
- return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
7246
- }
7247
- async refreshStore(projectId, organizationId) {
7248
- let attachments = [];
7249
- const projectFormRevisions = await this.enqueueRequest({
7250
- description: "Fetch project form revision attachments",
7251
- method: HttpMethod.GET,
7252
- url: "/form-revision-attachments/",
7253
- queryParams: {
7254
- project: projectId.toString()
7255
- },
7256
- blockers: [projectId.toString()],
7257
- blocks: []
7258
- });
7259
- attachments = attachments.concat(projectFormRevisions);
7260
- const organizationFormRevisions = await this.enqueueRequest({
7261
- description: "Fetch organization form revision attachments",
7262
- method: HttpMethod.GET,
7263
- url: "/form-revision-attachments/",
7264
- queryParams: {
7265
- organization: organizationId.toString()
7266
- },
7267
- blockers: [organizationId.toString()],
7268
- blocks: []
7269
- });
7270
- attachments = attachments.concat(organizationFormRevisions);
7271
- this.dispatch(initializeFormRevisionAttachments(attachments));
7272
- }
7273
- }
7274
- class FormSubmissionAttachmentService extends BaseUploadService {
7275
- async bulkAdd(payloads) {
7276
- var _a2;
7277
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7278
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7279
- const filePayloads = {};
7280
- const offlineFormSubmissionAttachments = [];
7281
- const attachmentPayloads = [];
7282
- for (const payload of payloads) {
7283
- const { submissionId, fieldIdentifier, file } = payload;
7284
- const filePayload = await this.getFilePayload(file);
7285
- if (!(filePayload.sha1 in filePayloads))
7286
- filePayloads[filePayload.sha1] = filePayload;
7287
- const offlineFormSubmissionAttachment = offline({
7288
- file: URL.createObjectURL(file),
7289
- file_type: file.type,
7290
- file_name: file.name,
7291
- file_sha1: filePayload.sha1,
7292
- created_by: createdBy,
7293
- form_submission: submissionId,
7294
- submitted_at: submittedAt,
7295
- field_identifier: fieldIdentifier
7296
- });
7297
- offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
7298
- const attachmentPayload = {
7299
- offline_id: offlineFormSubmissionAttachment.offline_id,
7300
- file_name: file.name,
7301
- file_sha1: filePayload.sha1,
7302
- file_extension: filePayload.extension,
7303
- field_identifier: fieldIdentifier,
7304
- form_submission: submissionId
7305
- };
7306
- attachmentPayloads.push(attachmentPayload);
7307
- }
7308
- this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
7309
- const promise = this.enqueueRequest({
7310
- description: "Attach files to form submission",
7311
- method: HttpMethod.POST,
7312
- url: "/form-submission-attachments/bulk/",
7313
- payload: {
7314
- submitted_at: submittedAt,
7315
- attachments: attachmentPayloads,
7316
- files: Object.values(filePayloads)
7317
- },
7318
- blockers: offlineFormSubmissionAttachments.map((attachment) => attachment.form_submission),
7319
- blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
7320
- });
7321
- promise.then((result) => {
7322
- this.processPresignedUrls(result.presigned_urls);
7323
- this.dispatch(updateFormSubmissionAttachments(result.attachments));
7324
- }).catch((error) => {
7325
- this.dispatch(
7326
- deleteFormSubmissionAttachments(
7327
- offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
7328
- )
7329
- );
7330
- throw error;
7331
- });
7332
- return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
7333
- }
7334
- async bulkDelete(attachmentsIds) {
7335
- const { store } = this.client;
7336
- const state = store.getState();
7337
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
7338
- this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
7339
- try {
7340
- await this.enqueueRequest({
7341
- description: "Delete form submission attachments",
7342
- method: HttpMethod.DELETE,
7343
- url: "/form-submission-attachments/bulk/",
7344
- payload: { attachment_ids: attachmentsIds },
7345
- blockers: attachmentsIds,
7346
- blocks: []
7347
- });
7348
- } catch (e) {
7349
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7350
- throw e;
7351
- }
7352
- }
7353
- async refreshStore(projectId) {
7354
- const result = await this.enqueueRequest({
7355
- description: "Get form submission attachments",
7356
- method: HttpMethod.GET,
7357
- url: "/form-submission-attachments/",
7358
- queryParams: {
7359
- project: projectId.toString()
7360
- },
7361
- blockers: [],
7362
- blocks: []
7363
- });
7364
- this.dispatch(initializeFormSubmissionAttachments(result));
7365
- }
7366
- }
7367
- class FormRevisionService extends BaseUploadService {
7368
- add(payload) {
7369
- var _a2;
7370
- const { store } = this.client;
7371
- const state = store.getState();
7372
- const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
7373
- const offlineFormRevision = offline({
7374
- ...payload,
7375
- created_by: createdBy,
7376
- revision: "Pending",
7377
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7378
- });
7379
- this.dispatch(addFormRevision(offlineFormRevision));
7380
- const promise = this.enqueueRequest({
7381
- description: "Create form revision",
7382
- method: HttpMethod.POST,
7383
- url: "/form-revisions/",
7384
- payload: offlineFormRevision,
7385
- blockers: [payload.form],
7386
- blocks: [offlineFormRevision.offline_id]
7387
- });
7388
- void promise.then((result) => {
7389
- this.dispatch(setFormRevision(result));
7390
- }).catch(() => {
7391
- this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
7392
- });
7393
- return [offlineFormRevision, promise];
7394
- }
7395
- async refreshStore(projectId, organizationId) {
7396
- let formRevisions = [];
7397
- const projectFormRevisions = await this.enqueueRequest({
7398
- description: "Fetch project form revisions",
7399
- method: HttpMethod.GET,
7400
- url: "/form-revisions/",
7401
- queryParams: {
7402
- project: projectId.toString()
7403
- },
7404
- blockers: [projectId.toString()],
7405
- blocks: []
7406
- });
7407
- formRevisions = formRevisions.concat(projectFormRevisions);
7408
- const organizationFormRevisions = await this.enqueueRequest({
7409
- description: "Fetch organization form revisions",
7410
- method: HttpMethod.GET,
7411
- url: "/form-revisions/",
7412
- queryParams: {
7413
- organization: organizationId.toString()
7414
- },
7415
- blockers: [organizationId.toString()],
7416
- blocks: []
7417
- });
7418
- formRevisions = formRevisions.concat(organizationFormRevisions);
7419
- this.dispatch(initializeFormRevisions(formRevisions));
7420
- }
7421
- }
7422
- class AssetTypeFieldsAttachmentService extends BaseUploadService {
7423
- async bulkAdd(payloads) {
7424
- var _a2;
7425
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7426
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7427
- const filePayloads = {};
7428
- const offlineAssetTypeFieldsAttachments = [];
7429
- const attachmentPayloads = [];
7430
- for (const payload of payloads) {
7431
- const { fieldsRevisionId, fieldIdentifier, file } = payload;
7432
- const filePayload = await this.getFilePayload(file);
7433
- if (!(filePayload.sha1 in filePayloads))
7434
- filePayloads[filePayload.sha1] = filePayload;
7435
- const offlineAssetTypeFieldsAttachment = offline({
7436
- file: URL.createObjectURL(file),
7437
- file_type: file.type,
7438
- file_name: file.name,
7439
- file_sha1: filePayload.sha1,
7440
- created_by: createdBy,
7441
- fields_revision: fieldsRevisionId,
7442
- submitted_at: submittedAt,
7443
- field_identifier: fieldIdentifier
7444
- });
7445
- offlineAssetTypeFieldsAttachments.push(offlineAssetTypeFieldsAttachment);
7446
- const attachmentPayload = {
7447
- offline_id: offlineAssetTypeFieldsAttachment.offline_id,
7448
- file_name: file.name,
7449
- field_identifier: fieldIdentifier,
7450
- file_extension: filePayload.extension,
7451
- file_sha1: filePayload.sha1,
7452
- fields_revision: fieldsRevisionId
7453
- };
7454
- attachmentPayloads.push(attachmentPayload);
7455
- }
7456
- this.dispatch(addAssetTypeFieldsAttachments(offlineAssetTypeFieldsAttachments));
7457
- const promise = this.enqueueRequest({
7458
- description: "Add asset type fields attachments",
7459
- method: HttpMethod.POST,
7460
- url: "/asset-type-fields-attachments/bulk/",
7461
- payload: {
7462
- submitted_at: submittedAt,
7463
- attachments: attachmentPayloads,
7464
- files: Object.values(filePayloads)
7465
- },
7466
- blockers: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7467
- blocks: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7468
- });
7469
- promise.then((result) => {
7470
- this.processPresignedUrls(result.presigned_urls);
7471
- this.dispatch(updateAssetTypeFieldsAttachments(result.attachments));
7472
- }).catch(() => {
7473
- this.dispatch(
7474
- deleteAssetTypeFieldsAttachments(
7475
- offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7476
- )
7477
- );
7478
- });
7479
- return [offlineAssetTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7480
- }
7481
- async refreshStore(projectId) {
7482
- const result = await this.enqueueRequest({
7483
- description: "get asset type fields attachments",
7484
- method: HttpMethod.GET,
7485
- url: "/asset-type-fields-attachments/",
7486
- queryParams: {
7487
- project: projectId.toString()
7488
- },
7489
- blockers: [projectId.toString()],
7490
- blocks: []
7491
- });
7492
- this.dispatch(initializeAssetTypeFieldsAttachments(result));
7493
- }
7494
- }
7495
- class AssetTypeFieldsService extends BaseApiService {
7496
- add(payload) {
7497
- var _a2;
7498
- const { store } = this.client;
7499
- const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7500
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7501
- const offlineAssetTypeFields = offline({
7502
- ...payload,
7503
- created_by: createdBy,
7504
- submitted_at: submittedAt
7505
- });
7506
- this.dispatch(addAssetTypeFields(offlineAssetTypeFields));
7507
- const promise = this.enqueueRequest({
7508
- description: "Add Asset Type Fields",
7509
- method: HttpMethod.POST,
7510
- url: "/asset-type-fields/",
7511
- payload: offlineAssetTypeFields,
7512
- blockers: [offlineAssetTypeFields.asset_type],
7513
- blocks: [offlineAssetTypeFields.offline_id]
7514
- });
7515
- promise.then((response) => {
7516
- this.dispatch(updateAssetTypeFields(response));
7517
- }).catch((error) => {
7518
- this.dispatch(deleteAssetTypeFields(offlineAssetTypeFields.offline_id));
7519
- throw error;
7520
- });
7521
- return [offlineAssetTypeFields, promise];
7522
- }
7523
- async refreshStore(projectId) {
7524
- const result = await this.enqueueRequest({
7525
- description: "Get Asset Type Fields",
7526
- method: HttpMethod.GET,
7527
- url: "/asset-type-fields/",
7528
- queryParams: {
7529
- project: projectId.toString()
7530
- },
7531
- blockers: [],
7532
- blocks: []
7533
- });
7534
- this.dispatch(initializeAssetTypeFields(result));
7535
- }
7536
- }
7537
- class AssetTypeFieldValuesService extends BaseApiService {
7538
- add(payload) {
7539
- var _a2;
7540
- const { store } = this.client;
7541
- const state = store.getState();
7542
- const { values } = separateFilesFromValues(payload.values);
7543
- const offlineAssetTypeFieldValues = offline({
7544
- ...payload,
7545
- values,
7546
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
7547
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7548
- });
7549
- const promise = this.enqueueRequest({
7550
- description: "Add asset type field values",
7551
- method: HttpMethod.POST,
7552
- url: "/asset-type-field-values/",
7553
- payload: offlineAssetTypeFieldValues,
7554
- blockers: [payload.asset, payload.fields_revision],
7555
- blocks: [offlineAssetTypeFieldValues.offline_id]
7556
- });
7557
- this.dispatch(addAssetTypeFieldValues(offlineAssetTypeFieldValues));
7558
- promise.then((result) => {
7559
- this.dispatch(updateAssetTypeFieldValues(result));
7560
- return result;
7561
- }).catch(() => {
7562
- this.dispatch(deleteAssetTypeFieldValues(offlineAssetTypeFieldValues.offline_id));
7563
- });
7564
- return [offlineAssetTypeFieldValues, promise];
7565
- }
7566
- bulkAdd(payload, batchSize) {
7567
- var _a2;
7568
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7569
- const { values } = separateFilesFromValues(payload.values);
7570
- const offlineAssetTypeFieldValuesMany = [];
7571
- const batches = chunkArray(payload.payloads, batchSize ?? payload.payloads.length);
7572
- const batchPayloads = [];
7573
- for (const batch of batches) {
7574
- const assetTypeFieldValuesPayloads = [];
7575
- for (const payload2 of batch) {
7576
- const offlineAssetTypeFieldValues = offline({
7577
- ...payload2,
7578
- values: separateFilesFromValues(payload2.values).values,
7579
- created_by: (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
7580
- submitted_at: submittedAt
7581
- });
7582
- offlineAssetTypeFieldValuesMany.push(offlineAssetTypeFieldValues);
7583
- assetTypeFieldValuesPayloads.push({
7584
- offline_id: offlineAssetTypeFieldValues.offline_id,
7585
- asset: payload2.asset,
7586
- fields_revision: payload2.fields_revision,
7587
- published_at: payload2.published_at,
7588
- values: offlineAssetTypeFieldValues.values
7589
- });
7590
- }
7591
- batchPayloads.push({
7592
- submitted_at: submittedAt,
7593
- values,
7594
- field_values: assetTypeFieldValuesPayloads
7595
- });
7596
- }
7597
- this.dispatch(addAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany));
7598
- const promises = [];
7599
- for (const payload2 of batchPayloads) {
7600
- const assetIds = payload2.field_values.map((x) => x.asset);
7601
- const assetTypeFieldsIds = payload2.field_values.map((x) => x.fields_revision);
7602
- const assetTypeFieldValuesIds = payload2.field_values.map((x) => x.offline_id);
7603
- const promise = this.enqueueRequest({
7604
- description: "Bulk add asset type field values",
7605
- method: HttpMethod.POST,
7606
- url: "/asset-type-field-values/bulk/",
7607
- payload: payload2,
7608
- blockers: [...assetIds, ...assetTypeFieldsIds],
7609
- blocks: assetTypeFieldValuesIds
7610
- });
7611
- promises.push(promise);
7612
- }
7613
- void Promise.all(promises).then((results) => {
7614
- this.dispatch(updateAssetTypeFieldValuesMany(results.flat()));
7615
- }).catch(() => {
7616
- this.dispatch(deleteAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany.map((x) => x.offline_id)));
7617
- });
7618
- return [offlineAssetTypeFieldValuesMany, promises];
7619
- }
7620
- update(payload) {
7621
- const { store } = this.client;
7622
- const state = store.getState();
7623
- const assetTypeFieldValues = selectAssetTypeFieldValuesById(payload.offline_id)(state);
7624
- if (!assetTypeFieldValues) {
7625
- throw new Error(`Expected AssetTypeFieldValues with offline_id ${payload.offline_id} to exist`);
7626
- }
7627
- const { values } = separateFilesFromValues(payload.values ?? {});
7628
- const updatedAssetTypeFieldValues = {
7629
- ...assetTypeFieldValues,
7630
- ...payload,
7631
- // values could also have a partial update
7632
- values: {
7633
- ...assetTypeFieldValues.values,
7634
- ...values
7635
- }
7636
- };
7637
- this.dispatch(updateAssetTypeFieldValues(updatedAssetTypeFieldValues));
7638
- const promise = this.enqueueRequest({
7639
- description: "Delete asset type field values",
7640
- method: HttpMethod.PATCH,
7641
- url: `/asset-type-field-values/${payload.offline_id}/`,
7642
- payload,
7643
- blockers: [
7644
- updatedAssetTypeFieldValues.offline_id,
7645
- updatedAssetTypeFieldValues.fields_revision,
7646
- updatedAssetTypeFieldValues.asset
7647
- ],
7648
- blocks: [updatedAssetTypeFieldValues.offline_id]
7649
- });
7650
- promise.then((result) => {
7651
- this.dispatch(updateAssetTypeFieldValues(result));
7652
- }).catch(() => {
7653
- this.dispatch(updateAssetTypeFieldValues(assetTypeFieldValues));
7654
- });
7655
- return [updatedAssetTypeFieldValues, promise];
7656
- }
7657
- async delete(id) {
7658
- const { store } = this.client;
7659
- const state = store.getState();
7660
- const assetTypeFieldValues = selectAssetTypeFieldValuesById(id)(state);
7661
- if (!assetTypeFieldValues) {
7662
- throw new Error(`Expected submission with offline_id ${id} to exist`);
7663
- }
7664
- const assetTypeFieldValuesAttachments = selectAttachmentsOfAssetTypeFieldValues(id)(state);
7665
- this.dispatch(deleteAssetTypeFieldValues(id));
7666
- this.dispatch(deleteAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments.map((x) => x.offline_id)));
7667
- try {
7668
- await this.enqueueRequest({
7669
- description: "Delete asset type field values",
7670
- method: HttpMethod.DELETE,
7671
- url: `/asset-type-field-values/${id}/`,
7672
- blockers: [id],
7673
- blocks: []
7674
- });
7675
- } catch (e) {
7676
- this.dispatch(addAssetTypeFieldValues(assetTypeFieldValues));
7677
- this.dispatch(addAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments));
7678
- throw e;
7679
- }
7680
- }
7681
- async refreshStore(projectId) {
7682
- const result = await this.enqueueRequest({
7683
- description: "Get asset type field values",
7684
- method: HttpMethod.GET,
7685
- url: "/asset-type-field-values/",
7686
- queryParams: {
7687
- project: projectId.toString()
7688
- },
7689
- blockers: [],
7690
- blocks: []
7691
- });
7692
- this.dispatch(initializeAssetTypeFieldValues(result));
7693
- }
7694
- }
7695
- class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
7696
- async bulkAdd(payloads, batchSize) {
7697
- var _a2;
7698
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7699
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7700
- const batches = chunkArray(payloads, batchSize ?? payloads.length);
7701
- const offlineAssetTypeFieldValuesAttachments = [];
7702
- const batchPayloads = [];
7703
- for (const batch of batches) {
7704
- const filePayloads = {};
7705
- const attachmentPayloads = [];
7706
- for (const payload of batch) {
7707
- const { fieldValuesId, fieldIdentifier, file } = payload;
7708
- const filePayload = await this.getFilePayload(file);
7709
- if (!(filePayload.sha1 in filePayloads))
7710
- filePayloads[filePayload.sha1] = filePayload;
7711
- const offlineAssetTypeFieldValuesAttachment = offline({
7712
- file: URL.createObjectURL(file),
7713
- file_type: file.type,
7714
- file_name: file.name,
7715
- file_sha1: filePayload.sha1,
7716
- created_by: createdBy,
7717
- field_values: fieldValuesId,
7718
- submitted_at: submittedAt,
7719
- field_identifier: fieldIdentifier
7720
- });
7721
- offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
7722
- const attachmentPayload = {
7723
- offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
7724
- file_name: file.name,
7725
- file_sha1: filePayload.sha1,
7726
- file_extension: filePayload.extension,
7727
- field_identifier: fieldIdentifier,
7728
- field_values: fieldValuesId
7729
- };
7730
- attachmentPayloads.push(attachmentPayload);
7731
- }
7732
- batchPayloads.push({
7733
- submitted_at: submittedAt,
7734
- attachments: attachmentPayloads,
7735
- files: Object.values(filePayloads)
7736
- });
7737
- }
7738
- this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
7739
- const promises = batchPayloads.map((payload) => {
7740
- return this.enqueueRequest({
7741
- description: "Add asset type field values attachments",
7742
- method: HttpMethod.POST,
7743
- url: "/asset-type-field-values-attachments/bulk/",
7744
- payload,
7745
- blockers: payload.attachments.map((payload2) => payload2.field_values),
7746
- blocks: payload.attachments.map((payload2) => payload2.offline_id)
7747
- });
7748
- });
7749
- Promise.all(promises).then((result) => {
7750
- for (const res of result)
7751
- this.processPresignedUrls(res.presigned_urls);
7752
- const attachments = result.flatMap((res) => res.attachments);
7753
- this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
7754
- }).catch((error) => {
7755
- this.dispatch(
7756
- deleteAssetTypeFieldValuesAttachments(
7757
- offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7758
- )
7759
- );
7760
- throw error;
7761
- });
7762
- return [
7763
- offlineAssetTypeFieldValuesAttachments,
7764
- promises.map((promise) => promise.then(({ attachments }) => attachments))
7765
- ];
7766
- }
7767
- async bulkDelete(ids) {
7768
- const { store } = this.client;
7769
- const state = store.getState();
7770
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(ids)(state);
7771
- this.dispatch(deleteFormSubmissionAttachments(ids));
7772
- try {
7773
- await this.enqueueRequest({
7774
- description: "Delete asset type field values attachments",
7775
- method: HttpMethod.DELETE,
7776
- url: "/asset-type-field-values-attachments/bulk/",
7777
- payload: { attachment_ids: ids },
7778
- blockers: ids,
7779
- blocks: []
7780
- });
7781
- } catch (e) {
7782
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7783
- throw e;
7784
- }
7785
- }
7786
- async refreshStore(projectId) {
7787
- const result = await this.enqueueRequest({
7788
- description: "Get asset type field values attachments",
7789
- method: HttpMethod.GET,
7790
- url: "/asset-type-field-values-attachments/",
7791
- queryParams: {
7792
- project: projectId.toString()
7793
- },
7794
- blockers: [],
7795
- blocks: []
7796
- });
7797
- this.dispatch(initializeAssetTypeFieldValuesAttachments(result));
7798
- }
7799
- }
7800
- class IssueTypeFieldsAttachmentService extends BaseUploadService {
7801
- async bulkAdd(payloads) {
7802
- var _a2;
7803
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7804
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7805
- const filePayloads = {};
7806
- const offlineIssueTypeFieldsAttachments = [];
7807
- const attachmentPayloads = [];
7808
- for (const payload of payloads) {
7809
- const { fieldsRevisionId, fieldIdentifier, file } = payload;
7810
- const filePayload = await this.getFilePayload(file);
7811
- if (!(filePayload.sha1 in filePayloads))
7812
- filePayloads[filePayload.sha1] = filePayload;
7813
- const offlineIssueTypeFieldsAttachment = offline({
7814
- file: URL.createObjectURL(file),
7815
- file_type: file.type,
7816
- file_name: file.name,
7817
- file_sha1: filePayload.sha1,
7818
- created_by: createdBy,
7819
- fields_revision: fieldsRevisionId,
7820
- submitted_at: submittedAt,
7821
- field_identifier: fieldIdentifier
7822
- });
7823
- offlineIssueTypeFieldsAttachments.push(offlineIssueTypeFieldsAttachment);
7824
- const attachmentPayload = {
7825
- offline_id: offlineIssueTypeFieldsAttachment.offline_id,
7826
- file_name: file.name,
7827
- file_extension: filePayload.extension,
7828
- field_identifier: fieldIdentifier,
7829
- file_sha1: filePayload.sha1,
7830
- fields_revision: fieldsRevisionId
7831
- };
7832
- attachmentPayloads.push(attachmentPayload);
7833
- }
7834
- this.dispatch(addIssueTypeFieldsAttachments(offlineIssueTypeFieldsAttachments));
7835
- const promise = this.enqueueRequest({
7836
- description: "Add issue type fields attachments",
7837
- method: HttpMethod.POST,
7838
- url: "/issue-type-fields-attachments/bulk/",
7839
- payload: {
7840
- submitted_at: submittedAt,
7841
- attachments: attachmentPayloads,
7842
- files: Object.values(filePayloads)
7843
- },
7844
- blockers: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7845
- blocks: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7846
- });
7847
- promise.then((result) => {
7848
- this.processPresignedUrls(result.presigned_urls);
7849
- this.dispatch(updateIssueTypeFieldsAttachments(result.attachments));
7850
- }).catch(() => {
7851
- this.dispatch(
7852
- deleteIssueTypeFieldsAttachments(
7853
- offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7854
- )
7855
- );
7856
- });
7857
- return [offlineIssueTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7858
- }
7859
- async refreshStore(organizationId) {
7860
- const result = await this.enqueueRequest({
7861
- description: "get issue type fields attachments",
7862
- method: HttpMethod.GET,
7863
- url: "/issue-type-fields-attachments/",
7864
- queryParams: {
7865
- organization: organizationId.toString()
7866
- },
7867
- blockers: [organizationId.toString()],
7868
- blocks: []
7869
- });
7870
- this.dispatch(initializeIssueTypeFieldsAttachments(result));
7871
- }
7872
- }
7873
- class IssueTypeFieldsService extends BaseApiService {
7874
- add(payload) {
7875
- var _a2;
7876
- const { store } = this.client;
7877
- const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7878
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7879
- const offlineIssueTypeFields = offline({
7880
- ...payload,
7881
- created_by: createdBy,
7882
- submitted_at: submittedAt
7883
- });
7884
- this.dispatch(addIssueTypeFields(offlineIssueTypeFields));
7885
- const promise = this.enqueueRequest({
7886
- description: "Add Issue Type Fields",
7887
- method: HttpMethod.POST,
7888
- url: "/issue-type-fields/",
7889
- payload: offlineIssueTypeFields,
7890
- blockers: [offlineIssueTypeFields.issue_type],
7891
- blocks: [offlineIssueTypeFields.offline_id]
7892
- });
7893
- promise.then((response) => {
7894
- this.dispatch(updateIssueTypeFields(response));
7895
- }).catch((error) => {
7896
- this.dispatch(deleteIssueTypeFields(offlineIssueTypeFields.offline_id));
7897
- throw error;
7898
- });
7899
- return [offlineIssueTypeFields, promise];
7900
- }
7901
- async refreshStore(organizationId) {
7902
- const result = await this.enqueueRequest({
7903
- description: "Get Issue Type Fields",
7904
- method: HttpMethod.GET,
7905
- url: "/issue-type-fields/",
7906
- queryParams: {
7907
- organization: organizationId.toString()
7908
- },
7909
- blockers: [],
7910
- blocks: []
7911
- });
7912
- this.dispatch(initializeIssueTypeFields(result));
7913
- }
7914
- }
7915
- class IssueTypeFieldValuesAttachmentService extends BaseUploadService {
7916
- async bulkAdd(payloads) {
7917
- var _a2;
7918
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7919
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7920
- const filePayloads = {};
7921
- const offlineIssueTypeFieldValuesAttachments = [];
7922
- const attachmentPayloads = [];
7923
- for (const payload of payloads) {
7924
- const { fieldValuesId, fieldIdentifier, file } = payload;
7925
- const filePayload = await this.getFilePayload(file);
7926
- if (!(filePayload.sha1 in filePayloads))
7927
- filePayloads[filePayload.sha1] = filePayload;
7928
- const offlineIssueTypeFieldValuesAttachment = offline({
7929
- file: URL.createObjectURL(file),
7930
- file_type: file.type,
7931
- file_name: file.name,
7932
- file_sha1: filePayload.sha1,
7933
- created_by: createdBy,
7934
- field_values: fieldValuesId,
7935
- submitted_at: submittedAt,
7936
- field_identifier: fieldIdentifier
7937
- });
7938
- offlineIssueTypeFieldValuesAttachments.push(offlineIssueTypeFieldValuesAttachment);
7939
- const attachmentPayload = {
7940
- offline_id: offlineIssueTypeFieldValuesAttachment.offline_id,
7941
- file_name: file.name,
7942
- file_sha1: filePayload.sha1,
7943
- file_extension: filePayload.extension,
7944
- field_identifier: fieldIdentifier,
7945
- field_values: fieldValuesId
7946
- };
7947
- attachmentPayloads.push(attachmentPayload);
7948
- }
7949
- this.dispatch(addIssueTypeFieldValuesAttachments(offlineIssueTypeFieldValuesAttachments));
7950
- const promise = this.enqueueRequest({
7951
- description: "Add issue type field values attachments",
7952
- method: HttpMethod.POST,
7953
- url: "/issue-type-field-values-attachments/bulk/",
7954
- payload: {
7955
- submitted_at: submittedAt,
7956
- attachments: attachmentPayloads,
7957
- files: Object.values(filePayloads)
7958
- },
7959
- blockers: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
7960
- blocks: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7961
- });
7962
- promise.then(({ presigned_urls, attachments }) => {
7963
- this.processPresignedUrls(presigned_urls);
7964
- this.dispatch(updateIssueTypeFieldValuesAttachments(attachments));
7965
- }).catch((error) => {
7966
- this.dispatch(
7967
- deleteIssueTypeFieldValuesAttachments(
7968
- offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7969
- )
7970
- );
7971
- throw error;
7972
- });
7973
- return [offlineIssueTypeFieldValuesAttachments, promise.then(({ attachments }) => attachments)];
7974
- }
7975
- async bulkDelete(attachmentsIds) {
7976
- const { store } = this.client;
7977
- const state = store.getState();
7978
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
7979
- this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
7980
- try {
7981
- await this.enqueueRequest({
7982
- description: "Delete issue type field values attachments",
7983
- method: HttpMethod.DELETE,
7984
- url: "/issue-type-field-values-attachments/bulk/",
7985
- payload: { attachment_ids: attachmentsIds },
7986
- blockers: attachmentsIds,
7987
- blocks: []
7988
- });
7989
- } catch (e) {
7990
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7991
- throw e;
7992
- }
7993
- }
7994
- async refreshStore(projectId) {
7995
- const result = await this.enqueueRequest({
7996
- description: "Get issue type field values attachments",
7997
- method: HttpMethod.GET,
7998
- url: "/issue-type-field-values-attachments/",
7999
- queryParams: {
8000
- project: projectId.toString()
8001
- },
8002
- blockers: [],
8003
- blocks: []
8004
- });
8005
- this.dispatch(initializeIssueTypeFieldValuesAttachments(result));
8006
- }
8007
- }
8008
- class IssueTypeFieldValuesService extends BaseApiService {
8009
- add(payload) {
8010
- var _a2;
8011
- const { store } = this.client;
8012
- const state = store.getState();
8013
- const { values } = separateFilesFromValues(payload.values);
8014
- const offlineIssueTypeFieldValues = offline({
8015
- ...payload,
8016
- values,
8017
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
8018
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
8019
- });
8020
- const promise = this.enqueueRequest({
8021
- description: "Add issue type field values",
8022
- method: HttpMethod.POST,
8023
- url: "/issue-type-field-values/",
8024
- payload: offlineIssueTypeFieldValues,
8025
- blockers: [payload.issue, payload.fields_revision],
8026
- blocks: [offlineIssueTypeFieldValues.offline_id]
8027
- });
8028
- this.dispatch(addIssueTypeFieldValues(offlineIssueTypeFieldValues));
8029
- promise.then((result) => {
8030
- this.dispatch(updateIssueTypeFieldValues(result));
8031
- return result;
8032
- }).catch(() => {
8033
- this.dispatch(deleteIssueTypeFieldValues(offlineIssueTypeFieldValues.offline_id));
8034
- });
8035
- return [offlineIssueTypeFieldValues, promise];
8036
- }
8037
- update(payload) {
8038
- const { store } = this.client;
8039
- const state = store.getState();
8040
- const issueTypeFieldValues = selectIssueTypeFieldValuesById(payload.offline_id)(state);
8041
- if (!issueTypeFieldValues) {
8042
- throw new Error(`Expected IssueTypeFieldValues with offline_id ${payload.offline_id} to exist`);
8043
- }
8044
- const { values } = separateFilesFromValues(payload.values ?? {});
8045
- const updatedIssueTypeFieldValues = {
8046
- ...issueTypeFieldValues,
8047
- ...payload,
8048
- // values could also have a partial update
8049
- values: {
8050
- ...issueTypeFieldValues.values,
8051
- ...values
8052
- }
8053
- };
8054
- this.dispatch(updateIssueTypeFieldValues(updatedIssueTypeFieldValues));
8055
- const promise = this.enqueueRequest({
8056
- description: "Update issue type field values",
8057
- method: HttpMethod.PATCH,
8058
- url: `/issue-type-field-values/${payload.offline_id}/`,
8059
- payload,
8060
- blockers: [
8061
- updatedIssueTypeFieldValues.offline_id,
8062
- updatedIssueTypeFieldValues.fields_revision,
8063
- updatedIssueTypeFieldValues.issue
8064
- ],
8065
- blocks: [updatedIssueTypeFieldValues.offline_id]
8066
- });
8067
- promise.then((result) => {
8068
- this.dispatch(updateIssueTypeFieldValues(result));
8069
- }).catch(() => {
8070
- this.dispatch(updateIssueTypeFieldValues(issueTypeFieldValues));
8071
- });
8072
- return [updatedIssueTypeFieldValues, promise];
8073
- }
8074
- async delete(id) {
8075
- const { store } = this.client;
8076
- const state = store.getState();
8077
- const issueTypeFieldValues = selectIssueTypeFieldValuesById(id)(state);
8078
- if (!issueTypeFieldValues) {
8079
- throw new Error(`Expected submission with offline_id ${id} to exist`);
8080
- }
8081
- const issueTypeFieldValuesAttachments = selectAttachmentsOfIssueTypeFieldValues(id)(state);
8082
- this.dispatch(deleteIssueTypeFieldValues(id));
8083
- this.dispatch(deleteIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments.map((x) => x.offline_id)));
8084
- try {
8085
- await this.enqueueRequest({
8086
- description: "Delete issue type field values",
8087
- method: HttpMethod.DELETE,
8088
- url: `/issue-type-field-values/${id}/`,
8089
- blockers: [id],
8090
- blocks: []
8091
- });
8092
- } catch (e) {
8093
- this.dispatch(addIssueTypeFieldValues(issueTypeFieldValues));
8094
- this.dispatch(addIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments));
8095
- throw e;
8096
- }
8097
- }
8098
- async refreshStore(projectId) {
8099
- const result = await this.enqueueRequest({
8100
- description: "Get issue type field values",
8101
- method: HttpMethod.GET,
8102
- url: "/issue-type-field-values/",
8103
- queryParams: {
8104
- project: projectId.toString()
8105
- },
8106
- blockers: [],
8107
- blocks: []
8108
- });
8109
- this.dispatch(initializeIssueTypeFieldValues(result));
8110
- }
8111
- }
8112
7330
  var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
8113
7331
  VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
8114
7332
  VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
@@ -8126,10 +7344,6 @@ export {
8126
7344
  AssetStageCompletionService,
8127
7345
  AssetStageService,
8128
7346
  AssetTypeAttachmentService,
8129
- AssetTypeFieldValuesAttachmentService,
8130
- AssetTypeFieldValuesService,
8131
- AssetTypeFieldsAttachmentService,
8132
- AssetTypeFieldsService,
8133
7347
  AssetTypeService,
8134
7348
  AttachmentModel,
8135
7349
  BaseApiService,
@@ -8145,10 +7359,7 @@ export {
8145
7359
  EmailDomainsService,
8146
7360
  EmailVerificationService,
8147
7361
  FileService,
8148
- FormRevisionAttachmentService,
8149
- FormRevisionService,
8150
7362
  FormService,
8151
- FormSubmissionAttachmentService,
8152
7363
  FormSubmissionService,
8153
7364
  GREEN,
8154
7365
  GeoImageService,
@@ -8159,10 +7370,6 @@ export {
8159
7370
  IssuePriority,
8160
7371
  IssueService,
8161
7372
  IssueStatus,
8162
- IssueTypeFieldValuesAttachmentService,
8163
- IssueTypeFieldValuesService,
8164
- IssueTypeFieldsAttachmentService,
8165
- IssueTypeFieldsService,
8166
7373
  IssueTypeService,
8167
7374
  IssueUpdateChange,
8168
7375
  IssueUpdateService,
@@ -8202,14 +7409,6 @@ export {
8202
7409
  addAssetType,
8203
7410
  addAssetTypeAttachment,
8204
7411
  addAssetTypeAttachments,
8205
- addAssetTypeFieldValues,
8206
- addAssetTypeFieldValuesAttachment,
8207
- addAssetTypeFieldValuesAttachments,
8208
- addAssetTypeFieldValuesMany,
8209
- addAssetTypeFields,
8210
- addAssetTypeFieldsAttachment,
8211
- addAssetTypeFieldsAttachments,
8212
- addAssetTypeFieldsMany,
8213
7412
  addAssetTypes,
8214
7413
  addAssets,
8215
7414
  addCategory,
@@ -8238,14 +7437,6 @@ export {
8238
7437
  addIssueComment,
8239
7438
  addIssueComments,
8240
7439
  addIssueType,
8241
- addIssueTypeFieldValues,
8242
- addIssueTypeFieldValuesAttachment,
8243
- addIssueTypeFieldValuesAttachments,
8244
- addIssueTypeFieldValuesMany,
8245
- addIssueTypeFields,
8246
- addIssueTypeFieldsAttachment,
8247
- addIssueTypeFieldsAttachments,
8248
- addIssueTypeFieldsMany,
8249
7440
  addIssueUpdate,
8250
7441
  addIssueUpdates,
8251
7442
  addIssues,
@@ -8271,14 +7462,6 @@ export {
8271
7462
  assetStageSlice,
8272
7463
  assetTypeAttachmentReducer,
8273
7464
  assetTypeAttachmentSlice,
8274
- assetTypeFieldValuesAttachmentReducer,
8275
- assetTypeFieldValuesAttachmentSlice,
8276
- assetTypeFieldValuesReducer,
8277
- assetTypeFieldValuesSlice,
8278
- assetTypeFieldsAttachmentReducer,
8279
- assetTypeFieldsAttachmentSlice,
8280
- assetTypeFieldsReducer,
8281
- assetTypeFieldsSlice,
8282
7465
  assetTypeReducer,
8283
7466
  assetTypeSlice,
8284
7467
  authReducer,
@@ -8307,14 +7490,6 @@ export {
8307
7490
  deleteAssetType,
8308
7491
  deleteAssetTypeAttachment,
8309
7492
  deleteAssetTypeAttachments,
8310
- deleteAssetTypeFieldValues,
8311
- deleteAssetTypeFieldValuesAttachment,
8312
- deleteAssetTypeFieldValuesAttachments,
8313
- deleteAssetTypeFieldValuesMany,
8314
- deleteAssetTypeFields,
8315
- deleteAssetTypeFieldsAttachment,
8316
- deleteAssetTypeFieldsAttachments,
8317
- deleteAssetTypeFieldsMany,
8318
7493
  deleteAssetTypes,
8319
7494
  deleteAssets,
8320
7495
  deleteCategory,
@@ -8339,14 +7514,6 @@ export {
8339
7514
  deleteIssueAttachments,
8340
7515
  deleteIssueComment,
8341
7516
  deleteIssueComments,
8342
- deleteIssueTypeFieldValues,
8343
- deleteIssueTypeFieldValuesAttachment,
8344
- deleteIssueTypeFieldValuesAttachments,
8345
- deleteIssueTypeFieldValuesMany,
8346
- deleteIssueTypeFields,
8347
- deleteIssueTypeFieldsAttachment,
8348
- deleteIssueTypeFieldsAttachments,
8349
- deleteIssueTypeFieldsMany,
8350
7517
  deleteIssueUpdate,
8351
7518
  deleteIssueUpdates,
8352
7519
  deleteIssues,
@@ -8403,10 +7570,6 @@ export {
8403
7570
  initializeAssetStageCompletions,
8404
7571
  initializeAssetStages,
8405
7572
  initializeAssetTypeAttachments,
8406
- initializeAssetTypeFieldValues,
8407
- initializeAssetTypeFieldValuesAttachments,
8408
- initializeAssetTypeFields,
8409
- initializeAssetTypeFieldsAttachments,
8410
7573
  initializeAssetTypes,
8411
7574
  initializeAssets,
8412
7575
  initializeCategories,
@@ -8421,10 +7584,6 @@ export {
8421
7584
  initializeGeoImages,
8422
7585
  initializeIssueAssociations,
8423
7586
  initializeIssueAttachments,
8424
- initializeIssueTypeFieldValues,
8425
- initializeIssueTypeFieldValuesAttachments,
8426
- initializeIssueTypeFields,
8427
- initializeIssueTypeFieldsAttachments,
8428
7587
  initializeIssueTypes,
8429
7588
  initializeIssueUpdates,
8430
7589
  initializeIssues,
@@ -8443,14 +7602,6 @@ export {
8443
7602
  issueCommentSlice,
8444
7603
  issueReducer,
8445
7604
  issueSlice,
8446
- issueTypeFieldValuesAttachmentReducer,
8447
- issueTypeFieldValuesAttachmentSlice,
8448
- issueTypeFieldValuesReducer,
8449
- issueTypeFieldValuesSlice,
8450
- issueTypeFieldsAttachmentReducer,
8451
- issueTypeFieldsAttachmentSlice,
8452
- issueTypeFieldsReducer,
8453
- issueTypeFieldsSlice,
8454
7605
  issueTypeReducer,
8455
7606
  issueTypeSlice,
8456
7607
  issueUpdateReducer,
@@ -8523,22 +7674,7 @@ export {
8523
7674
  selectAssetTypeAttachmentMapping,
8524
7675
  selectAssetTypeAttachments,
8525
7676
  selectAssetTypeById,
8526
- selectAssetTypeFieldValues,
8527
- selectAssetTypeFieldValuesAttachmentById,
8528
- selectAssetTypeFieldValuesAttachments,
8529
- selectAssetTypeFieldValuesAttachmentsMapping,
8530
- selectAssetTypeFieldValuesById,
8531
- selectAssetTypeFieldValuesMapping,
8532
- selectAssetTypeFieldValuesOfAsset,
8533
- selectAssetTypeFields,
8534
- selectAssetTypeFieldsAttachmentById,
8535
- selectAssetTypeFieldsAttachments,
8536
- selectAssetTypeFieldsAttachmentsMapping,
8537
- selectAssetTypeFieldsById,
8538
- selectAssetTypeFieldsMapping,
8539
- selectAssetTypeFieldsOfAssetType,
8540
7677
  selectAssetTypeStagesMapping,
8541
- selectAssetTypeValuesOfAssetType,
8542
7678
  selectAssetTypes,
8543
7679
  selectAssetTypesByIds,
8544
7680
  selectAssetTypesMapping,
@@ -8546,20 +7682,18 @@ export {
8546
7682
  selectAssetsByIds,
8547
7683
  selectAssetsMapping,
8548
7684
  selectAssetsOfAssetType,
7685
+ selectAttachedFormSubmissionsOfAsset,
7686
+ selectAttachedFormSubmissionsOfIssue,
8549
7687
  selectAttachmentsOfAsset,
8550
7688
  selectAttachmentsOfAssetByType,
8551
7689
  selectAttachmentsOfAssetType,
8552
7690
  selectAttachmentsOfAssetTypeByType,
8553
- selectAttachmentsOfAssetTypeFieldValues,
8554
- selectAttachmentsOfAssetTypeFields,
8555
7691
  selectAttachmentsOfDocument,
8556
7692
  selectAttachmentsOfDocumentByType,
8557
7693
  selectAttachmentsOfFormRevision,
8558
7694
  selectAttachmentsOfFormSubmission,
8559
7695
  selectAttachmentsOfIssue,
8560
7696
  selectAttachmentsOfIssueByType,
8561
- selectAttachmentsOfIssueTypeFieldValues,
8562
- selectAttachmentsOfIssueTypeFields,
8563
7697
  selectAttachmentsOfProject,
8564
7698
  selectAttachmentsOfProjectByType,
8565
7699
  selectCategories,
@@ -8587,6 +7721,8 @@ export {
8587
7721
  selectFilteredForms,
8588
7722
  selectFormById,
8589
7723
  selectFormMapping,
7724
+ selectFormOfAssetType,
7725
+ selectFormOfIssueType,
8590
7726
  selectFormRevisionAttachmentsMapping,
8591
7727
  selectFormRevisionById,
8592
7728
  selectFormRevisionMapping,
@@ -8596,11 +7732,16 @@ export {
8596
7732
  selectFormSubmissionAttachmentsMapping,
8597
7733
  selectFormSubmissionById,
8598
7734
  selectFormSubmissions,
7735
+ selectFormSubmissionsByAssets,
7736
+ selectFormSubmissionsByFormRevisions,
7737
+ selectFormSubmissionsByIssues,
8599
7738
  selectFormSubmissionsMapping,
8600
7739
  selectFormSubmissionsOfAsset,
8601
7740
  selectFormSubmissionsOfForm,
8602
7741
  selectFormSubmissionsOfIssue,
8603
7742
  selectForms,
7743
+ selectFormsCount,
7744
+ selectGeneralFormCount,
8604
7745
  selectGeoImageById,
8605
7746
  selectGeoImageMapping,
8606
7747
  selectGeoImages,
@@ -8622,22 +7763,7 @@ export {
8622
7763
  selectIssueCountOfCategory,
8623
7764
  selectIssueMapping,
8624
7765
  selectIssueTypeById,
8625
- selectIssueTypeFieldValues,
8626
- selectIssueTypeFieldValuesAttachmentById,
8627
- selectIssueTypeFieldValuesAttachments,
8628
- selectIssueTypeFieldValuesAttachmentsMapping,
8629
- selectIssueTypeFieldValuesById,
8630
- selectIssueTypeFieldValuesMapping,
8631
- selectIssueTypeFieldValuesOfIssue,
8632
- selectIssueTypeFields,
8633
- selectIssueTypeFieldsAttachmentById,
8634
- selectIssueTypeFieldsAttachments,
8635
- selectIssueTypeFieldsAttachmentsMapping,
8636
- selectIssueTypeFieldsById,
8637
- selectIssueTypeFieldsMapping,
8638
- selectIssueTypeFieldsOfIssueType,
8639
7766
  selectIssueTypeMapping,
8640
- selectIssueTypeValuesOfIssueType,
8641
7767
  selectIssueTypes,
8642
7768
  selectIssueTypesByIds,
8643
7769
  selectIssueTypesOfOrganization,
@@ -8646,9 +7772,8 @@ export {
8646
7772
  selectIssuesByIds,
8647
7773
  selectIssuesOfIssueType,
8648
7774
  selectIssuesOfIssueTypeCount,
8649
- selectLatestAssetTypeFieldsOfAssetType,
7775
+ selectLatestFormRevisionByForm,
8650
7776
  selectLatestFormRevisionOfForm,
8651
- selectLatestIssueTypeFieldsOfIssueType,
8652
7777
  selectLatestRetryTime,
8653
7778
  selectLicense,
8654
7779
  selectLicenseForProject,
@@ -8685,6 +7810,7 @@ export {
8685
7810
  selectProjectsOfOrganization,
8686
7811
  selectRehydrated,
8687
7812
  selectRootDocuments,
7813
+ selectSortedFormSubmissionsOfForm,
8688
7814
  selectSortedOrganizationUsers,
8689
7815
  selectSortedProjectUsers,
8690
7816
  selectStageFormIdsFromStageIds,
@@ -8703,8 +7829,6 @@ export {
8703
7829
  selectWorkspaceById,
8704
7830
  selectWorkspaceMapping,
8705
7831
  selectWorkspaces,
8706
- separateFilesFromValues,
8707
- separateImageFromFields,
8708
7832
  setActiveProjectFileId,
8709
7833
  setActiveProjectId,
8710
7834
  setAsset,
@@ -8715,14 +7839,6 @@ export {
8715
7839
  setAssetType,
8716
7840
  setAssetTypeAttachment,
8717
7841
  setAssetTypeAttachments,
8718
- setAssetTypeFieldValues,
8719
- setAssetTypeFieldValuesAttachment,
8720
- setAssetTypeFieldValuesAttachments,
8721
- setAssetTypeFieldValuesMany,
8722
- setAssetTypeFields,
8723
- setAssetTypeFieldsAttachment,
8724
- setAssetTypeFieldsAttachments,
8725
- setAssetTypeFieldsMany,
8726
7842
  setAssetTypes,
8727
7843
  setAssets,
8728
7844
  setConversation,
@@ -8748,14 +7864,6 @@ export {
8748
7864
  setIssueComment,
8749
7865
  setIssueComments,
8750
7866
  setIssueType,
8751
- setIssueTypeFieldValues,
8752
- setIssueTypeFieldValuesAttachment,
8753
- setIssueTypeFieldValuesAttachments,
8754
- setIssueTypeFieldValuesMany,
8755
- setIssueTypeFields,
8756
- setIssueTypeFieldsAttachment,
8757
- setIssueTypeFieldsAttachments,
8758
- setIssueTypeFieldsMany,
8759
7867
  setIssueUpdate,
8760
7868
  setLoggedIn,
8761
7869
  setOrganizations,
@@ -8788,14 +7896,6 @@ export {
8788
7896
  updateAssetType,
8789
7897
  updateAssetTypeAttachment,
8790
7898
  updateAssetTypeAttachments,
8791
- updateAssetTypeFieldValues,
8792
- updateAssetTypeFieldValuesAttachment,
8793
- updateAssetTypeFieldValuesAttachments,
8794
- updateAssetTypeFieldValuesMany,
8795
- updateAssetTypeFields,
8796
- updateAssetTypeFieldsAttachment,
8797
- updateAssetTypeFieldsAttachments,
8798
- updateAssetTypeFieldsMany,
8799
7899
  updateAssetTypes,
8800
7900
  updateAssets,
8801
7901
  updateCategory,
@@ -8818,14 +7918,6 @@ export {
8818
7918
  updateIssueAttachment,
8819
7919
  updateIssueAttachments,
8820
7920
  updateIssueType,
8821
- updateIssueTypeFieldValues,
8822
- updateIssueTypeFieldValuesAttachment,
8823
- updateIssueTypeFieldValuesAttachments,
8824
- updateIssueTypeFieldValuesMany,
8825
- updateIssueTypeFields,
8826
- updateIssueTypeFieldsAttachment,
8827
- updateIssueTypeFieldsAttachments,
8828
- updateIssueTypeFieldsMany,
8829
7921
  updateLicense,
8830
7922
  updateOrCreateProject,
8831
7923
  updateOrganizationAccess,