@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
@@ -747,15 +747,15 @@ var __publicField = (obj, key, value) => {
747
747
  };
748
748
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
749
749
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
750
- const initialState$J = {
750
+ const initialState$B = {
751
751
  accessToken: "",
752
752
  refreshToken: "",
753
753
  isLoggedIn: false
754
754
  };
755
755
  const authSlice = toolkit.createSlice({
756
756
  name: "auth",
757
- initialState: initialState$J,
758
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$J)),
757
+ initialState: initialState$B,
758
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
759
759
  reducers: {
760
760
  setTokens: (state, action) => {
761
761
  state.accessToken = action.payload.accessToken;
@@ -843,11 +843,11 @@ var __publicField = (obj, key, value) => {
843
843
  };
844
844
  }
845
845
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
846
- const initialState$I = categoryAdapter.getInitialState({});
846
+ const initialState$A = categoryAdapter.getInitialState({});
847
847
  const categorySlice = toolkit.createSlice({
848
848
  name: "categories",
849
- initialState: initialState$I,
850
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$I)),
849
+ initialState: initialState$A,
850
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
851
851
  reducers: {
852
852
  initializeCategories: categoryAdapter.initialize,
853
853
  addCategory: categoryAdapter.addOne,
@@ -891,11 +891,11 @@ var __publicField = (obj, key, value) => {
891
891
  };
892
892
  const categoryReducer = categorySlice.reducer;
893
893
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
894
- const initialState$H = assetAdapter.getInitialState({});
894
+ const initialState$z = assetAdapter.getInitialState({});
895
895
  const assetSlice = toolkit.createSlice({
896
896
  name: "assets",
897
- initialState: initialState$H,
898
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$H)),
897
+ initialState: initialState$z,
898
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
899
899
  reducers: {
900
900
  initializeAssets: assetAdapter.initialize,
901
901
  addAsset: assetAdapter.addOne,
@@ -947,11 +947,11 @@ var __publicField = (obj, key, value) => {
947
947
  };
948
948
  const assetReducer = assetSlice.reducer;
949
949
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
950
- const initialState$G = assetAttachmentAdapter.getInitialState({});
950
+ const initialState$y = assetAttachmentAdapter.getInitialState({});
951
951
  const assetAttachmentSlice = toolkit.createSlice({
952
952
  name: "assetAttachments",
953
- initialState: initialState$G,
954
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$G)),
953
+ initialState: initialState$y,
954
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
955
955
  reducers: {
956
956
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
957
957
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -1012,11 +1012,11 @@ var __publicField = (obj, key, value) => {
1012
1012
  const assetStageCompletionAdapter = createModelAdapter(
1013
1013
  (stageCompletion) => stageCompletion.offline_id
1014
1014
  );
1015
- const initialState$F = assetStageCompletionAdapter.getInitialState({});
1015
+ const initialState$x = assetStageCompletionAdapter.getInitialState({});
1016
1016
  const assetStageCompletionSlice = toolkit.createSlice({
1017
1017
  name: "assetStageCompletions",
1018
- initialState: initialState$F,
1019
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$F)),
1018
+ initialState: initialState$x,
1019
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1020
1020
  reducers: {
1021
1021
  initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
1022
1022
  addAssetStageCompletion: assetStageCompletionAdapter.addOne,
@@ -1078,11 +1078,11 @@ var __publicField = (obj, key, value) => {
1078
1078
  );
1079
1079
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1080
1080
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1081
- const initialState$E = assetStageAdapter.getInitialState({});
1081
+ const initialState$w = assetStageAdapter.getInitialState({});
1082
1082
  const assetStageSlice = toolkit.createSlice({
1083
1083
  name: "assetStages",
1084
- initialState: initialState$E,
1085
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$E)),
1084
+ initialState: initialState$w,
1085
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1086
1086
  reducers: {
1087
1087
  initializeAssetStages: assetStageAdapter.initialize,
1088
1088
  setAssetStage: assetStageAdapter.setOne,
@@ -1162,11 +1162,11 @@ var __publicField = (obj, key, value) => {
1162
1162
  })
1163
1163
  );
1164
1164
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1165
- const initialState$D = assetTypeAdapter.getInitialState({});
1165
+ const initialState$v = assetTypeAdapter.getInitialState({});
1166
1166
  const assetTypeSlice = toolkit.createSlice({
1167
1167
  name: "assetTypes",
1168
- initialState: initialState$D,
1169
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$D)),
1168
+ initialState: initialState$v,
1169
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1170
1170
  reducers: {
1171
1171
  initializeAssetTypes: assetTypeAdapter.initialize,
1172
1172
  setAssetType: assetTypeAdapter.setOne,
@@ -1219,11 +1219,11 @@ var __publicField = (obj, key, value) => {
1219
1219
  const assetTypeAttachmentAdapter = createModelAdapter(
1220
1220
  (attachment) => attachment.offline_id
1221
1221
  );
1222
- const initialState$C = assetTypeAttachmentAdapter.getInitialState({});
1222
+ const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1223
1223
  const assetTypeAttachmentSlice = toolkit.createSlice({
1224
1224
  name: "assetTypeAttachments",
1225
- initialState: initialState$C,
1226
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
1225
+ initialState: initialState$u,
1226
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1227
1227
  reducers: {
1228
1228
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1229
1229
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1282,12 +1282,12 @@ var __publicField = (obj, key, value) => {
1282
1282
  );
1283
1283
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1284
1284
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1285
- const initialState$B = issueAdapter.getInitialState({});
1285
+ const initialState$t = issueAdapter.getInitialState({});
1286
1286
  const issueSlice = toolkit.createSlice({
1287
1287
  name: "issues",
1288
- initialState: initialState$B,
1288
+ initialState: initialState$t,
1289
1289
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1290
- Object.assign(state, initialState$B);
1290
+ Object.assign(state, initialState$t);
1291
1291
  }),
1292
1292
  reducers: {
1293
1293
  initializeIssues: issueAdapter.initialize,
@@ -1319,12 +1319,12 @@ var __publicField = (obj, key, value) => {
1319
1319
  );
1320
1320
  const issueReducer = issueSlice.reducer;
1321
1321
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1322
- const initialState$A = issueTypeAdapter.getInitialState({});
1322
+ const initialState$s = issueTypeAdapter.getInitialState({});
1323
1323
  const issueTypeSlice = toolkit.createSlice({
1324
1324
  name: "issueTypes",
1325
- initialState: initialState$A,
1325
+ initialState: initialState$s,
1326
1326
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1327
- Object.assign(state, initialState$A);
1327
+ Object.assign(state, initialState$s);
1328
1328
  }),
1329
1329
  reducers: {
1330
1330
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1381,15 +1381,15 @@ var __publicField = (obj, key, value) => {
1381
1381
  return selectIssuesOfIssueType(issueTypeId)(state).length;
1382
1382
  };
1383
1383
  const issueTypeReducer = issueTypeSlice.reducer;
1384
- const initialState$z = {
1384
+ const initialState$r = {
1385
1385
  s3Urls: {}
1386
1386
  };
1387
1387
  const msPerHour = 1e3 * 60 * 60;
1388
1388
  const msPerWeek = msPerHour * 24 * 7;
1389
1389
  const fileSlice = toolkit.createSlice({
1390
1390
  name: "file",
1391
- initialState: initialState$z,
1392
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1391
+ initialState: initialState$r,
1392
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1393
1393
  reducers: {
1394
1394
  setUploadUrl: (state, action) => {
1395
1395
  const { url, fields, sha1 } = action.payload;
@@ -1416,14 +1416,14 @@ var __publicField = (obj, key, value) => {
1416
1416
  return url;
1417
1417
  };
1418
1418
  const fileReducer = fileSlice.reducer;
1419
- const initialState$y = {
1419
+ const initialState$q = {
1420
1420
  users: {},
1421
1421
  currentUser: null
1422
1422
  };
1423
1423
  const userSlice = toolkit.createSlice({
1424
1424
  name: "users",
1425
- initialState: initialState$y,
1426
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1425
+ initialState: initialState$q,
1426
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1427
1427
  reducers: {
1428
1428
  setUsers: (state, action) => {
1429
1429
  const usersMapping = {};
@@ -1481,11 +1481,11 @@ var __publicField = (obj, key, value) => {
1481
1481
  const organizationAccessAdapter = createModelAdapter(
1482
1482
  (organizationAccess) => organizationAccess.offline_id
1483
1483
  );
1484
- const initialState$x = organizationAccessAdapter.getInitialState({});
1484
+ const initialState$p = organizationAccessAdapter.getInitialState({});
1485
1485
  const organizationAccessSlice = toolkit.createSlice({
1486
1486
  name: "organizationAccess",
1487
- initialState: initialState$x,
1488
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1487
+ initialState: initialState$p,
1488
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1489
1489
  reducers: {
1490
1490
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1491
1491
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1522,11 +1522,11 @@ var __publicField = (obj, key, value) => {
1522
1522
  };
1523
1523
  const organizationAccessReducer = organizationAccessSlice.reducer;
1524
1524
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1525
- const initialState$w = licenseAdapter.getInitialState({});
1525
+ const initialState$o = licenseAdapter.getInitialState({});
1526
1526
  const licenseSlice = toolkit.createSlice({
1527
1527
  name: "license",
1528
- initialState: initialState$w,
1529
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1528
+ initialState: initialState$o,
1529
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1530
1530
  reducers: {
1531
1531
  initializeLicences: licenseAdapter.initialize,
1532
1532
  addLicenses: licenseAdapter.addMany,
@@ -1551,11 +1551,11 @@ var __publicField = (obj, key, value) => {
1551
1551
  );
1552
1552
  const licenseReducer = licenseSlice.reducer;
1553
1553
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1554
- const initialState$v = projectAccessAdapter.getInitialState({});
1554
+ const initialState$n = projectAccessAdapter.getInitialState({});
1555
1555
  const projectAccessSlice = toolkit.createSlice({
1556
1556
  name: "projectAccess",
1557
- initialState: initialState$v,
1558
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1557
+ initialState: initialState$n,
1558
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1559
1559
  reducers: {
1560
1560
  initializeProjectAccesses: projectAccessAdapter.initialize,
1561
1561
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1596,14 +1596,14 @@ var __publicField = (obj, key, value) => {
1596
1596
  return projectAccesses;
1597
1597
  };
1598
1598
  const projectAccessReducer = projectAccessSlice.reducer;
1599
- const initialState$u = {
1599
+ const initialState$m = {
1600
1600
  projects: {},
1601
1601
  activeProjectId: null
1602
1602
  };
1603
1603
  const projectSlice = toolkit.createSlice({
1604
1604
  name: "projects",
1605
- initialState: initialState$u,
1606
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1605
+ initialState: initialState$m,
1606
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1607
1607
  reducers: {
1608
1608
  setProjects: (state, action) => {
1609
1609
  const projectsMap = {};
@@ -1710,13 +1710,13 @@ var __publicField = (obj, key, value) => {
1710
1710
  });
1711
1711
  }
1712
1712
  );
1713
- const initialState$t = {
1713
+ const initialState$l = {
1714
1714
  organizations: {}
1715
1715
  };
1716
1716
  const organizationSlice = toolkit.createSlice({
1717
1717
  name: "organizations",
1718
- initialState: initialState$t,
1719
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$t)),
1718
+ initialState: initialState$l,
1719
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1720
1720
  reducers: {
1721
1721
  setOrganizations: (state, action) => {
1722
1722
  for (const org of action.payload) {
@@ -1807,14 +1807,14 @@ var __publicField = (obj, key, value) => {
1807
1807
  }
1808
1808
  };
1809
1809
  };
1810
- const initialState$s = {
1810
+ const initialState$k = {
1811
1811
  deletedRequests: [],
1812
1812
  latestRetryTime: 0
1813
1813
  };
1814
1814
  const outboxSlice = toolkit.createSlice({
1815
1815
  name: "outbox",
1816
- initialState: initialState$s,
1817
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
1816
+ initialState: initialState$k,
1817
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1818
1818
  reducers: {
1819
1819
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
1820
1820
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -1846,15 +1846,15 @@ var __publicField = (obj, key, value) => {
1846
1846
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
1847
1847
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
1848
1848
  const outboxReducer = outboxSlice.reducer;
1849
- const initialState$r = {
1849
+ const initialState$j = {
1850
1850
  projectFiles: {},
1851
1851
  activeProjectFileId: null,
1852
1852
  isImportingProjectFile: false
1853
1853
  };
1854
1854
  const projectFileSlice = toolkit.createSlice({
1855
1855
  name: "projectFiles",
1856
- initialState: initialState$r,
1857
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1856
+ initialState: initialState$j,
1857
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1858
1858
  reducers: {
1859
1859
  addOrReplaceProjectFiles: (state, action) => {
1860
1860
  for (let fileObj of action.payload) {
@@ -1941,11 +1941,11 @@ var __publicField = (obj, key, value) => {
1941
1941
  };
1942
1942
  const projectFileReducer = projectFileSlice.reducer;
1943
1943
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1944
- const initialState$q = projectAttachmentAdapter.getInitialState({});
1944
+ const initialState$i = projectAttachmentAdapter.getInitialState({});
1945
1945
  const projectAttachmentSlice = toolkit.createSlice({
1946
1946
  name: "projectAttachments",
1947
- initialState: initialState$q,
1948
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1947
+ initialState: initialState$i,
1948
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1949
1949
  reducers: {
1950
1950
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
1951
1951
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2000,12 +2000,12 @@ var __publicField = (obj, key, value) => {
2000
2000
  )
2001
2001
  );
2002
2002
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2003
- const initialState$p = {
2003
+ const initialState$h = {
2004
2004
  isRehydrated: false
2005
2005
  };
2006
2006
  const rehydratedSlice = toolkit.createSlice({
2007
2007
  name: "rehydrated",
2008
- initialState: initialState$p,
2008
+ initialState: initialState$h,
2009
2009
  // The `reducers` field lets us define reducers and generate associated actions
2010
2010
  reducers: {
2011
2011
  setRehydrated: (state, action) => {
@@ -2030,11 +2030,11 @@ var __publicField = (obj, key, value) => {
2030
2030
  }
2031
2031
  };
2032
2032
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2033
- const initialState$o = formRevisionAdapter.getInitialState({});
2033
+ const initialState$g = formRevisionAdapter.getInitialState({});
2034
2034
  const formRevisionsSlice = toolkit.createSlice({
2035
2035
  name: "formRevisions",
2036
- initialState: initialState$o,
2037
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
2036
+ initialState: initialState$g,
2037
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2038
2038
  reducers: {
2039
2039
  initializeFormRevisions: formRevisionAdapter.initialize,
2040
2040
  setFormRevision: formRevisionAdapter.setOne,
@@ -2093,13 +2093,24 @@ var __publicField = (obj, key, value) => {
2093
2093
  }
2094
2094
  )
2095
2095
  );
2096
+ const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
2097
+ const latestRevisions = {};
2098
+ for (const revision of Object.values(revisions)) {
2099
+ const formId = revision.form;
2100
+ const currentLatestRevision = latestRevisions[formId];
2101
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
2102
+ latestRevisions[formId] = revision;
2103
+ }
2104
+ }
2105
+ return latestRevisions;
2106
+ });
2096
2107
  const formRevisionReducer = formRevisionsSlice.reducer;
2097
2108
  const formAdapter = createModelAdapter((form) => form.offline_id);
2098
- const initialState$n = formAdapter.getInitialState({});
2109
+ const initialState$f = formAdapter.getInitialState({});
2099
2110
  const formSlice = toolkit.createSlice({
2100
2111
  name: "forms",
2101
- initialState: initialState$n,
2102
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
2112
+ initialState: initialState$f,
2113
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2103
2114
  reducers: {
2104
2115
  initializeForms: formAdapter.initialize,
2105
2116
  setForm: formAdapter.setOne,
@@ -2117,9 +2128,6 @@ var __publicField = (obj, key, value) => {
2117
2128
  const selectForms = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2118
2129
  return Object.values(formsMapping);
2119
2130
  });
2120
- const selectFormById = (formId) => (state) => {
2121
- return state.formReducer.instances[formId];
2122
- };
2123
2131
  const selectFilteredForms = restructureCreateSelectorWithArgs(
2124
2132
  toolkit.createSelector(
2125
2133
  [
@@ -2145,12 +2153,37 @@ var __publicField = (obj, key, value) => {
2145
2153
  { memoizeOptions: { equalityCheck: shallowEqual } }
2146
2154
  )
2147
2155
  );
2156
+ const selectFormById = (formId) => (state) => {
2157
+ return state.formReducer.instances[formId];
2158
+ };
2159
+ const selectFormOfAssetType = restructureCreateSelectorWithArgs(
2160
+ toolkit.createSelector(
2161
+ [selectFormMapping, (_state, assetTypeId) => assetTypeId],
2162
+ (formsMapping, assetTypeId) => {
2163
+ return Object.values(formsMapping).find((form) => form.asset_type === assetTypeId);
2164
+ }
2165
+ )
2166
+ );
2167
+ const selectFormOfIssueType = restructureCreateSelectorWithArgs(
2168
+ toolkit.createSelector(
2169
+ [selectFormMapping, (_state, issueTypeId) => issueTypeId],
2170
+ (formsMapping, issueTypeId) => {
2171
+ return Object.values(formsMapping).find((form) => form.issue_type === issueTypeId);
2172
+ }
2173
+ )
2174
+ );
2175
+ const selectFormsCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2176
+ return Object.keys(formsMapping).length;
2177
+ });
2178
+ const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2179
+ return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2180
+ });
2148
2181
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2149
- const initialState$m = submissionAdapter.getInitialState({});
2182
+ const initialState$e = submissionAdapter.getInitialState({});
2150
2183
  const formSubmissionSlice = toolkit.createSlice({
2151
2184
  name: "formSubmissions",
2152
- initialState: initialState$m,
2153
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
2185
+ initialState: initialState$e,
2186
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2154
2187
  reducers: {
2155
2188
  initializeFormSubmissions: submissionAdapter.initialize,
2156
2189
  setFormSubmission: submissionAdapter.setOne,
@@ -2206,6 +2239,43 @@ var __publicField = (obj, key, value) => {
2206
2239
  }
2207
2240
  )
2208
2241
  );
2242
+ const selectFormSubmissionsByFormRevisions = toolkit.createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
2243
+ var _a2;
2244
+ const submissionMapping = {};
2245
+ for (const revisionId in revisions) {
2246
+ submissionMapping[revisionId] = [];
2247
+ }
2248
+ for (const submission of submissions) {
2249
+ (_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
2250
+ }
2251
+ return submissionMapping;
2252
+ });
2253
+ const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2254
+ toolkit.createSelector(
2255
+ [
2256
+ selectFormRevisionMapping,
2257
+ selectFormSubmissionsByFormRevisions,
2258
+ (_state, formId) => formId
2259
+ ],
2260
+ (revisionsMapping, submissionsByRevision, formId) => {
2261
+ const submissionsByFormRevisions = {};
2262
+ for (const revisionId in revisionsMapping) {
2263
+ const revision = revisionsMapping[revisionId];
2264
+ const submissionsOfRevision = submissionsByRevision[revisionId];
2265
+ if (revision && submissionsOfRevision && revision.form === formId) {
2266
+ submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
2267
+ (a, b) => a.submitted_at < b.submitted_at ? -1 : 1
2268
+ );
2269
+ }
2270
+ }
2271
+ return Object.entries(submissionsByFormRevisions).sort((a, b) => {
2272
+ const aRevision = revisionsMapping[a[0]];
2273
+ const bRevision = revisionsMapping[b[0]];
2274
+ return formRevisionSortFn(aRevision, bRevision);
2275
+ }).map(([_revisionId, submissions]) => submissions).flat();
2276
+ }
2277
+ )
2278
+ );
2209
2279
  const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2210
2280
  toolkit.createSelector(
2211
2281
  [selectFormSubmissions, (_state, issueId) => issueId],
@@ -2216,6 +2286,54 @@ var __publicField = (obj, key, value) => {
2216
2286
  }
2217
2287
  )
2218
2288
  );
2289
+ const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2290
+ toolkit.createSelector(
2291
+ [
2292
+ (state) => state.issueReducer.instances,
2293
+ (state) => state.formReducer.instances,
2294
+ (state) => state.formRevisionReducer.instances,
2295
+ (state) => state.formSubmissionReducer.instances,
2296
+ (_state, issueId) => issueId
2297
+ ],
2298
+ (issues, forms, formRevisions, submissions, issueId) => {
2299
+ const issue = issues[issueId];
2300
+ if (!issue)
2301
+ return [];
2302
+ if (!issue.issue_type) {
2303
+ return Object.values(submissions).filter((submission) => submission.issue === issueId);
2304
+ }
2305
+ const issueTypeForms = new Set(
2306
+ Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
2307
+ );
2308
+ const issueTypeFormRevisions = new Set(
2309
+ Object.keys(formRevisions).filter(
2310
+ (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2311
+ )
2312
+ );
2313
+ return Object.values(submissions).filter(
2314
+ (submission) => submission.issue === issueId && !issueTypeFormRevisions.has(submission.form_revision)
2315
+ );
2316
+ }
2317
+ )
2318
+ );
2319
+ const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
2320
+ toolkit.createSelector(
2321
+ [selectFormSubmissions, (_state, issueIds) => issueIds],
2322
+ (submissions, issueIds) => {
2323
+ var _a2;
2324
+ const issueSubmissions = {};
2325
+ for (const issueId of issueIds) {
2326
+ issueSubmissions[issueId] = [];
2327
+ }
2328
+ for (const submission of submissions) {
2329
+ if (submission.issue && issueIds.includes(submission.issue)) {
2330
+ (_a2 = issueSubmissions[submission.issue]) == null ? void 0 : _a2.push(submission);
2331
+ }
2332
+ }
2333
+ return issueSubmissions;
2334
+ }
2335
+ )
2336
+ );
2219
2337
  const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2220
2338
  toolkit.createSelector(
2221
2339
  [selectFormSubmissions, (_state, assetId) => assetId],
@@ -2226,15 +2344,62 @@ var __publicField = (obj, key, value) => {
2226
2344
  }
2227
2345
  )
2228
2346
  );
2347
+ const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2348
+ toolkit.createSelector(
2349
+ [
2350
+ (state) => state.assetReducer.instances,
2351
+ (state) => state.formReducer.instances,
2352
+ (state) => state.formRevisionReducer.instances,
2353
+ (state) => state.formSubmissionReducer.instances,
2354
+ (_state, assetId) => assetId
2355
+ ],
2356
+ (assets, forms, formRevisions, submissions, assetId) => {
2357
+ const asset = assets[assetId];
2358
+ if (!asset)
2359
+ return [];
2360
+ if (!asset.asset_type) {
2361
+ return Object.values(submissions).filter((submission) => submission.asset === assetId);
2362
+ }
2363
+ const issueTypeForms = new Set(
2364
+ Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
2365
+ );
2366
+ const issueTypeFormRevisions = new Set(
2367
+ Object.keys(formRevisions).filter(
2368
+ (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2369
+ )
2370
+ );
2371
+ return Object.values(submissions).filter(
2372
+ (submission) => submission.asset === assetId && !issueTypeFormRevisions.has(submission.form_revision)
2373
+ );
2374
+ }
2375
+ )
2376
+ );
2377
+ const selectFormSubmissionsByAssets = toolkit.createSelector(
2378
+ [selectFormSubmissionsMapping, selectAssetsMapping],
2379
+ (submissions, assets) => {
2380
+ var _a2;
2381
+ const assetSubmissionMapping = {};
2382
+ for (const assetId in assets) {
2383
+ assetSubmissionMapping[assetId] = [];
2384
+ }
2385
+ for (const submissionId in submissions) {
2386
+ const submission = submissions[submissionId];
2387
+ if (submission.asset) {
2388
+ (_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
2389
+ }
2390
+ }
2391
+ return assetSubmissionMapping;
2392
+ }
2393
+ );
2229
2394
  const formSubmissionReducer = formSubmissionSlice.reducer;
2230
2395
  const formSubmissionAttachmentAdapter = createModelAdapter(
2231
2396
  (attachment) => attachment.offline_id
2232
2397
  );
2233
- const initialState$l = formSubmissionAttachmentAdapter.getInitialState({});
2398
+ const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2234
2399
  const formSubmissionAttachmentSlice = toolkit.createSlice({
2235
2400
  name: "formSubmissionAttachments",
2236
- initialState: initialState$l,
2237
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
2401
+ initialState: initialState$d,
2402
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2238
2403
  reducers: {
2239
2404
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2240
2405
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2277,9 +2442,7 @@ var __publicField = (obj, key, value) => {
2277
2442
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
2278
2443
  (attachmentsMapping, submissionId) => {
2279
2444
  return fallbackToEmptyArray(
2280
- Object.values(attachmentsMapping).filter(
2281
- (attachment) => attachment.form_submission === submissionId
2282
- )
2445
+ Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId)
2283
2446
  );
2284
2447
  }
2285
2448
  )
@@ -2288,11 +2451,11 @@ var __publicField = (obj, key, value) => {
2288
2451
  const formRevisionAttachmentAdapter = createModelAdapter(
2289
2452
  (attachment) => attachment.offline_id
2290
2453
  );
2291
- const initialState$k = formRevisionAttachmentAdapter.getInitialState({});
2454
+ const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2292
2455
  const formRevisionAttachmentSlice = toolkit.createSlice({
2293
2456
  name: "formRevisionAttachments",
2294
- initialState: initialState$k,
2295
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2457
+ initialState: initialState$c,
2458
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2296
2459
  reducers: {
2297
2460
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2298
2461
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2324,17 +2487,17 @@ var __publicField = (obj, key, value) => {
2324
2487
  [selectFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
2325
2488
  (attachments, revisionId) => {
2326
2489
  return fallbackToEmptyArray(
2327
- Object.values(attachments).filter((attachment) => attachment.form_revision === revisionId)
2490
+ Object.values(attachments).filter((attachment) => attachment.revision === revisionId)
2328
2491
  );
2329
2492
  }
2330
2493
  )
2331
2494
  );
2332
2495
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2333
2496
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2334
- const initialState$j = workspaceAdapter.getInitialState({});
2497
+ const initialState$b = workspaceAdapter.getInitialState({});
2335
2498
  const workspaceSlice = toolkit.createSlice({
2336
2499
  name: "workspace",
2337
- initialState: initialState$j,
2500
+ initialState: initialState$b,
2338
2501
  reducers: {
2339
2502
  initializeWorkspaces: workspaceAdapter.initialize,
2340
2503
  setWorkspaces: workspaceAdapter.setMany,
@@ -2365,10 +2528,10 @@ var __publicField = (obj, key, value) => {
2365
2528
  );
2366
2529
  const workspaceReducer = workspaceSlice.reducer;
2367
2530
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2368
- const initialState$i = emailDomainAdapter.getInitialState({});
2531
+ const initialState$a = emailDomainAdapter.getInitialState({});
2369
2532
  const emailDomainsSlice = toolkit.createSlice({
2370
2533
  name: "emailDomains",
2371
- initialState: initialState$i,
2534
+ initialState: initialState$a,
2372
2535
  reducers: {
2373
2536
  initializeEmailDomains: emailDomainAdapter.initialize,
2374
2537
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2389,14 +2552,14 @@ var __publicField = (obj, key, value) => {
2389
2552
  )
2390
2553
  );
2391
2554
  const emailDomainsReducer = emailDomainsSlice.reducer;
2392
- const initialState$h = {
2555
+ const initialState$9 = {
2393
2556
  documents: {}
2394
2557
  };
2395
2558
  const documentSlice = toolkit.createSlice({
2396
2559
  name: "documents",
2397
- initialState: initialState$h,
2560
+ initialState: initialState$9,
2398
2561
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2399
- Object.assign(state, initialState$h);
2562
+ Object.assign(state, initialState$9);
2400
2563
  }),
2401
2564
  reducers: {
2402
2565
  setDocuments: (state, action) => {
@@ -2585,11 +2748,11 @@ var __publicField = (obj, key, value) => {
2585
2748
  );
2586
2749
  const documentsReducer = documentSlice.reducer;
2587
2750
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2588
- const initialState$g = documentAttachmentAdapter.getInitialState({});
2751
+ const initialState$8 = documentAttachmentAdapter.getInitialState({});
2589
2752
  const documentAttachmentSlice = toolkit.createSlice({
2590
2753
  name: "documentAttachments",
2591
- initialState: initialState$g,
2592
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2754
+ initialState: initialState$8,
2755
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2593
2756
  reducers: {
2594
2757
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
2595
2758
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -2648,11 +2811,11 @@ var __publicField = (obj, key, value) => {
2648
2811
  );
2649
2812
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
2650
2813
  const teamAdapter = createModelAdapter((team) => team.offline_id);
2651
- const initialState$f = teamAdapter.getInitialState({});
2814
+ const initialState$7 = teamAdapter.getInitialState({});
2652
2815
  const teamSlice = toolkit.createSlice({
2653
2816
  name: "teams",
2654
- initialState: initialState$f,
2655
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2817
+ initialState: initialState$7,
2818
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2656
2819
  reducers: {
2657
2820
  setTeam: teamAdapter.setOne,
2658
2821
  initializeTeams: teamAdapter.initialize,
@@ -2703,11 +2866,11 @@ var __publicField = (obj, key, value) => {
2703
2866
  const agentUserConversationAdapter = createModelAdapter(
2704
2867
  (conversation) => conversation.offline_id
2705
2868
  );
2706
- const initialState$e = agentUserConversationAdapter.getInitialState({});
2869
+ const initialState$6 = agentUserConversationAdapter.getInitialState({});
2707
2870
  const agentsSlice = toolkit.createSlice({
2708
2871
  name: "agents",
2709
- initialState: initialState$e,
2710
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2872
+ initialState: initialState$6,
2873
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2711
2874
  reducers: {
2712
2875
  initializeConversations: agentUserConversationAdapter.initialize,
2713
2876
  addConversation: agentUserConversationAdapter.addOne,
@@ -2729,11 +2892,11 @@ var __publicField = (obj, key, value) => {
2729
2892
  );
2730
2893
  const agentsReducer = agentsSlice.reducer;
2731
2894
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
2732
- const initialState$d = issueCommentAdapter.getInitialState({});
2895
+ const initialState$5 = issueCommentAdapter.getInitialState({});
2733
2896
  const issueCommentSlice = toolkit.createSlice({
2734
2897
  name: "issueComments",
2735
- initialState: initialState$d,
2736
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2898
+ initialState: initialState$5,
2899
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2737
2900
  reducers: {
2738
2901
  addIssueComment: issueCommentAdapter.addOne,
2739
2902
  addIssueComments: issueCommentAdapter.addMany,
@@ -2762,11 +2925,11 @@ var __publicField = (obj, key, value) => {
2762
2925
  );
2763
2926
  const issueCommentReducer = issueCommentSlice.reducer;
2764
2927
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
2765
- const initialState$c = issueUpdateAdapter.getInitialState({});
2928
+ const initialState$4 = issueUpdateAdapter.getInitialState({});
2766
2929
  const issueUpdateSlice = toolkit.createSlice({
2767
2930
  name: "issueUpdates",
2768
- initialState: initialState$c,
2769
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2931
+ initialState: initialState$4,
2932
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2770
2933
  reducers: {
2771
2934
  initializeIssueUpdates: issueUpdateAdapter.setMany,
2772
2935
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -2795,11 +2958,11 @@ var __publicField = (obj, key, value) => {
2795
2958
  );
2796
2959
  const issueUpdateReducer = issueUpdateSlice.reducer;
2797
2960
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2798
- const initialState$b = issueAttachmentAdapter.getInitialState({});
2961
+ const initialState$3 = issueAttachmentAdapter.getInitialState({});
2799
2962
  const issueAttachmentSlice = toolkit.createSlice({
2800
2963
  name: "issueAttachments",
2801
- initialState: initialState$b,
2802
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2964
+ initialState: initialState$3,
2965
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
2803
2966
  reducers: {
2804
2967
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
2805
2968
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -2857,23 +3020,23 @@ var __publicField = (obj, key, value) => {
2857
3020
  )
2858
3021
  );
2859
3022
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
2860
- const initialState$a = {
3023
+ const initialState$2 = {
2861
3024
  version: 0
2862
3025
  };
2863
3026
  const versioningSlice = toolkit.createSlice({
2864
3027
  name: "versioning",
2865
- initialState: initialState$a,
3028
+ initialState: initialState$2,
2866
3029
  reducers: {}
2867
3030
  });
2868
3031
  const versioningReducer = versioningSlice.reducer;
2869
3032
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
2870
- const initialState$9 = geoImageAdapter.getInitialState({});
3033
+ const initialState$1 = geoImageAdapter.getInitialState({});
2871
3034
  const geoImageSlice = toolkit.createSlice({
2872
3035
  name: "geoImages",
2873
- initialState: initialState$9,
3036
+ initialState: initialState$1,
2874
3037
  extraReducers: (builder) => {
2875
3038
  builder.addCase("RESET", (state) => {
2876
- Object.assign(state, initialState$9);
3039
+ Object.assign(state, initialState$1);
2877
3040
  });
2878
3041
  },
2879
3042
  reducers: {
@@ -2911,11 +3074,11 @@ var __publicField = (obj, key, value) => {
2911
3074
  );
2912
3075
  const geoImageReducer = geoImageSlice.reducer;
2913
3076
  const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
2914
- const initialState$8 = issueAssociationAdapter.getInitialState({});
3077
+ const initialState = issueAssociationAdapter.getInitialState({});
2915
3078
  const issueAssociationSlice = toolkit.createSlice({
2916
3079
  name: "issueAssociations",
2917
- initialState: initialState$8,
2918
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3080
+ initialState,
3081
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
2919
3082
  reducers: {
2920
3083
  initializeIssueAssociations: issueAssociationAdapter.initialize,
2921
3084
  addIssueAssociation: issueAssociationAdapter.addOne,
@@ -2973,432 +3136,32 @@ var __publicField = (obj, key, value) => {
2973
3136
  )
2974
3137
  );
2975
3138
  const issueAssociationReducer = issueAssociationSlice.reducer;
2976
- const issueTypeFieldValuesAdapter = createModelAdapter(
2977
- (fieldValues) => fieldValues.offline_id
2978
- );
2979
- const initialState$7 = issueTypeFieldValuesAdapter.getInitialState({});
2980
- const issueTypeFieldValuesSlice = toolkit.createSlice({
2981
- name: "issueTypeFieldValues",
2982
- initialState: initialState$7,
2983
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2984
- reducers: {
2985
- initializeIssueTypeFieldValues: issueTypeFieldValuesAdapter.initialize,
2986
- addIssueTypeFieldValues: issueTypeFieldValuesAdapter.addOne,
2987
- addIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.addMany,
2988
- setIssueTypeFieldValues: issueTypeFieldValuesAdapter.setOne,
2989
- setIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.setMany,
2990
- updateIssueTypeFieldValues: issueTypeFieldValuesAdapter.updateOne,
2991
- updateIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.updateMany,
2992
- deleteIssueTypeFieldValues: issueTypeFieldValuesAdapter.deleteOne,
2993
- deleteIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.deleteMany
2994
- }
2995
- });
2996
- const {
2997
- initializeIssueTypeFieldValues,
2998
- addIssueTypeFieldValues,
2999
- addIssueTypeFieldValuesMany,
3000
- setIssueTypeFieldValues,
3001
- setIssueTypeFieldValuesMany,
3002
- updateIssueTypeFieldValues,
3003
- updateIssueTypeFieldValuesMany,
3004
- deleteIssueTypeFieldValues,
3005
- deleteIssueTypeFieldValuesMany
3006
- } = issueTypeFieldValuesSlice.actions;
3007
- const selectIssueTypeFieldValuesMapping = (state) => state.issueTypeFieldValuesReducer.instances;
3008
- const selectIssueTypeFieldValues = toolkit.createSelector([selectIssueTypeFieldValuesMapping], (fieldValuesMapping) => {
3009
- return Object.values(fieldValuesMapping);
3010
- });
3011
- const selectIssueTypeFieldValuesOfIssue = restructureCreateSelectorWithArgs(
3012
- toolkit.createSelector([selectIssueTypeFieldValues, (_state, issueId) => issueId], (fieldValues, issueId) => {
3013
- return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.issue === issueId));
3014
- })
3015
- );
3016
- const selectIssueTypeFieldValuesById = (fieldValuesId) => (state) => {
3017
- return state.issueTypeFieldValuesReducer.instances[fieldValuesId];
3018
- };
3019
- const issueTypeFieldValuesReducer = issueTypeFieldValuesSlice.reducer;
3020
- const issueTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
3021
- const initialState$6 = issueTypeFieldsAdapter.getInitialState({});
3022
- const issueTypeFieldsSlice = toolkit.createSlice({
3023
- name: "issueTypeFields",
3024
- initialState: initialState$6,
3025
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3026
- reducers: {
3027
- initializeIssueTypeFields: issueTypeFieldsAdapter.initialize,
3028
- addIssueTypeFields: issueTypeFieldsAdapter.addOne,
3029
- addIssueTypeFieldsMany: issueTypeFieldsAdapter.addMany,
3030
- setIssueTypeFields: issueTypeFieldsAdapter.setOne,
3031
- setIssueTypeFieldsMany: issueTypeFieldsAdapter.setMany,
3032
- updateIssueTypeFields: issueTypeFieldsAdapter.updateOne,
3033
- updateIssueTypeFieldsMany: issueTypeFieldsAdapter.updateMany,
3034
- deleteIssueTypeFields: issueTypeFieldsAdapter.deleteOne,
3035
- deleteIssueTypeFieldsMany: issueTypeFieldsAdapter.deleteMany
3139
+ let clientStore;
3140
+ function setClientStore(store) {
3141
+ clientStore = store;
3142
+ }
3143
+ function getClientStore() {
3144
+ return clientStore;
3145
+ }
3146
+ let clientSDK;
3147
+ function setClientSDK(sdkCtor) {
3148
+ clientSDK = sdkCtor;
3149
+ }
3150
+ function getClientSDK() {
3151
+ return clientSDK;
3152
+ }
3153
+ const CLASS_NAME_TO_SERVICE = {};
3154
+ class BaseService {
3155
+ constructor(sdk) {
3156
+ __publicField(this, "client");
3157
+ CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3158
+ this.client = sdk;
3036
3159
  }
3037
- });
3038
- const {
3039
- initializeIssueTypeFields,
3040
- addIssueTypeFields,
3041
- addIssueTypeFieldsMany,
3042
- setIssueTypeFields,
3043
- setIssueTypeFieldsMany,
3044
- updateIssueTypeFields,
3045
- updateIssueTypeFieldsMany,
3046
- deleteIssueTypeFields,
3047
- deleteIssueTypeFieldsMany
3048
- } = issueTypeFieldsSlice.actions;
3049
- const selectIssueTypeFieldsMapping = (state) => state.issueTypeFieldsReducer.instances;
3050
- const selectIssueTypeFields = toolkit.createSelector([selectIssueTypeFieldsMapping], (fieldsMapping) => {
3051
- return Object.values(fieldsMapping);
3052
- });
3053
- const selectIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
3054
- toolkit.createSelector([selectIssueTypeFields, (_state, issueTypeId) => issueTypeId], (fields, issueTypeId) => {
3055
- return fallbackToEmptyArray(fields.filter((field) => field.issue_type === issueTypeId));
3056
- })
3057
- );
3058
- const selectLatestIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
3059
- toolkit.createSelector([selectIssueTypeFields, (_state, id) => id], (fields, id) => {
3060
- return fields.filter((field) => field.issue_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
3061
- })
3062
- );
3063
- const selectIssueTypeValuesOfIssueType = restructureCreateSelectorWithArgs(
3064
- toolkit.createSelector(
3065
- [selectIssueTypeFields, selectIssueTypeFieldValues, (_state, id) => id],
3066
- (fields, fieldValues, id) => {
3067
- const fieldsIds = new Set(
3068
- fields.filter((field) => field.issue_type === id).map((field) => field.offline_id)
3069
- );
3070
- return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
3071
- }
3072
- )
3073
- );
3074
- const selectIssueTypeFieldsById = (fieldsId) => (state) => {
3075
- return state.issueTypeFieldsReducer.instances[fieldsId];
3076
- };
3077
- const issueTypeFieldsReducer = issueTypeFieldsSlice.reducer;
3078
- const issueTypeFieldsAttachmentAdapter = createModelAdapter(
3079
- (attachment) => attachment.offline_id
3080
- );
3081
- const initialState$5 = issueTypeFieldsAttachmentAdapter.getInitialState({});
3082
- const issueTypeFieldsAttachmentSlice = toolkit.createSlice({
3083
- name: "issueTypeFieldsAttachments",
3084
- initialState: initialState$5,
3085
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3086
- reducers: {
3087
- initializeIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.initialize,
3088
- addIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.addOne,
3089
- addIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.addMany,
3090
- setIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.setOne,
3091
- setIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.setMany,
3092
- updateIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.updateOne,
3093
- updateIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.updateMany,
3094
- deleteIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.deleteOne,
3095
- deleteIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.deleteMany
3160
+ async enqueueRequest(requestDetails) {
3161
+ return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3096
3162
  }
3097
- });
3098
- const {
3099
- initializeIssueTypeFieldsAttachments,
3100
- addIssueTypeFieldsAttachment,
3101
- addIssueTypeFieldsAttachments,
3102
- setIssueTypeFieldsAttachment,
3103
- setIssueTypeFieldsAttachments,
3104
- updateIssueTypeFieldsAttachment,
3105
- updateIssueTypeFieldsAttachments,
3106
- deleteIssueTypeFieldsAttachment,
3107
- deleteIssueTypeFieldsAttachments
3108
- } = issueTypeFieldsAttachmentSlice.actions;
3109
- const selectIssueTypeFieldsAttachmentsMapping = (state) => state.issueTypeFieldsAttachmentReducer.instances;
3110
- const selectIssueTypeFieldsAttachments = toolkit.createSelector(
3111
- [selectIssueTypeFieldsAttachmentsMapping],
3112
- (attachmentsMapping) => {
3113
- return Object.values(attachmentsMapping);
3114
- }
3115
- );
3116
- const selectAttachmentsOfIssueTypeFields = restructureCreateSelectorWithArgs(
3117
- toolkit.createSelector(
3118
- [selectIssueTypeFieldsAttachments, (_state, fieldsRevision) => fieldsRevision],
3119
- (attachments, fieldsRevision) => {
3120
- return fallbackToEmptyArray(
3121
- attachments.filter((attachment) => attachment.fields_revision === fieldsRevision)
3122
- );
3123
- }
3124
- )
3125
- );
3126
- const selectIssueTypeFieldsAttachmentById = (attachmentId) => (state) => {
3127
- return state.issueTypeFieldsAttachmentReducer.instances[attachmentId];
3128
- };
3129
- const issueTypeFieldsAttachmentReducer = issueTypeFieldsAttachmentSlice.reducer;
3130
- const issueTypeFieldValuesAttachmentAdapter = createModelAdapter(
3131
- (attachment) => attachment.offline_id
3132
- );
3133
- const initialState$4 = issueTypeFieldValuesAttachmentAdapter.getInitialState({});
3134
- const issueTypeFieldValuesAttachmentSlice = toolkit.createSlice({
3135
- name: "issueTypeFieldValuesAttachments",
3136
- initialState: initialState$4,
3137
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3138
- reducers: {
3139
- initializeIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.initialize,
3140
- addIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.addOne,
3141
- addIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.addMany,
3142
- setIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.setOne,
3143
- setIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.setMany,
3144
- updateIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.updateOne,
3145
- updateIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.updateMany,
3146
- deleteIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.deleteOne,
3147
- deleteIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.deleteMany
3148
- }
3149
- });
3150
- const {
3151
- initializeIssueTypeFieldValuesAttachments,
3152
- addIssueTypeFieldValuesAttachment,
3153
- addIssueTypeFieldValuesAttachments,
3154
- setIssueTypeFieldValuesAttachment,
3155
- setIssueTypeFieldValuesAttachments,
3156
- updateIssueTypeFieldValuesAttachment,
3157
- updateIssueTypeFieldValuesAttachments,
3158
- deleteIssueTypeFieldValuesAttachment,
3159
- deleteIssueTypeFieldValuesAttachments
3160
- } = issueTypeFieldValuesAttachmentSlice.actions;
3161
- const selectIssueTypeFieldValuesAttachmentsMapping = (state) => state.issueTypeFieldValuesAttachmentReducer.instances;
3162
- const selectIssueTypeFieldValuesAttachments = toolkit.createSelector(
3163
- [selectIssueTypeFieldValuesAttachmentsMapping],
3164
- (attachmentsMapping) => {
3165
- return Object.values(attachmentsMapping);
3166
- }
3167
- );
3168
- const selectAttachmentsOfIssueTypeFieldValues = restructureCreateSelectorWithArgs(
3169
- toolkit.createSelector(
3170
- [selectIssueTypeFieldValuesAttachments, (_state, fieldValuesId) => fieldValuesId],
3171
- (attachments, fieldValuesId) => {
3172
- return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === fieldValuesId));
3173
- }
3174
- )
3175
- );
3176
- const selectIssueTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
3177
- return state.issueTypeFieldValuesAttachmentReducer.instances[attachmentId];
3178
- };
3179
- const issueTypeFieldValuesAttachmentReducer = issueTypeFieldValuesAttachmentSlice.reducer;
3180
- const assetTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
3181
- const initialState$3 = assetTypeFieldsAdapter.getInitialState({});
3182
- const assetTypeFieldsSlice = toolkit.createSlice({
3183
- name: "assetTypeFields",
3184
- initialState: initialState$3,
3185
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3186
- reducers: {
3187
- initializeAssetTypeFields: assetTypeFieldsAdapter.initialize,
3188
- addAssetTypeFields: assetTypeFieldsAdapter.addOne,
3189
- addAssetTypeFieldsMany: assetTypeFieldsAdapter.addMany,
3190
- setAssetTypeFields: assetTypeFieldsAdapter.setOne,
3191
- setAssetTypeFieldsMany: assetTypeFieldsAdapter.setMany,
3192
- updateAssetTypeFields: assetTypeFieldsAdapter.updateOne,
3193
- updateAssetTypeFieldsMany: assetTypeFieldsAdapter.updateMany,
3194
- deleteAssetTypeFields: assetTypeFieldsAdapter.deleteOne,
3195
- deleteAssetTypeFieldsMany: assetTypeFieldsAdapter.deleteMany
3196
- }
3197
- });
3198
- const {
3199
- initializeAssetTypeFields,
3200
- addAssetTypeFields,
3201
- addAssetTypeFieldsMany,
3202
- setAssetTypeFields,
3203
- setAssetTypeFieldsMany,
3204
- updateAssetTypeFields,
3205
- updateAssetTypeFieldsMany,
3206
- deleteAssetTypeFields,
3207
- deleteAssetTypeFieldsMany
3208
- } = assetTypeFieldsSlice.actions;
3209
- const selectAssetTypeFieldsMapping = (state) => state.assetTypeFieldsReducer.instances;
3210
- const selectAssetTypeFields = toolkit.createSelector([selectAssetTypeFieldsMapping], (fieldsMapping) => {
3211
- return Object.values(fieldsMapping);
3212
- });
3213
- const selectAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3214
- toolkit.createSelector([selectAssetTypeFields, (_state, assetTypeId) => assetTypeId], (fields, assetTypeId) => {
3215
- return fallbackToEmptyArray(fields.filter((field) => field.asset_type === assetTypeId));
3216
- })
3217
- );
3218
- const selectLatestAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3219
- toolkit.createSelector([selectAssetTypeFields, (_state, id) => id], (fields, id) => {
3220
- return fields.filter((field) => field.asset_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
3221
- })
3222
- );
3223
- const selectAssetTypeFieldsById = (fieldsId) => (state) => {
3224
- return state.assetTypeFieldsReducer.instances[fieldsId];
3225
- };
3226
- const assetTypeFieldsReducer = assetTypeFieldsSlice.reducer;
3227
- const assetTypeFieldValuesAdapter = createModelAdapter(
3228
- (fieldValues) => fieldValues.offline_id
3229
- );
3230
- const initialState$2 = assetTypeFieldValuesAdapter.getInitialState({});
3231
- const assetTypeFieldValuesSlice = toolkit.createSlice({
3232
- name: "assetTypeFieldValues",
3233
- initialState: initialState$2,
3234
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3235
- reducers: {
3236
- initializeAssetTypeFieldValues: assetTypeFieldValuesAdapter.initialize,
3237
- addAssetTypeFieldValues: assetTypeFieldValuesAdapter.addOne,
3238
- addAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.addMany,
3239
- setAssetTypeFieldValues: assetTypeFieldValuesAdapter.setOne,
3240
- setAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.setMany,
3241
- updateAssetTypeFieldValues: assetTypeFieldValuesAdapter.updateOne,
3242
- updateAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.updateMany,
3243
- deleteAssetTypeFieldValues: assetTypeFieldValuesAdapter.deleteOne,
3244
- deleteAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.deleteMany
3245
- }
3246
- });
3247
- const {
3248
- initializeAssetTypeFieldValues,
3249
- addAssetTypeFieldValues,
3250
- addAssetTypeFieldValuesMany,
3251
- setAssetTypeFieldValues,
3252
- setAssetTypeFieldValuesMany,
3253
- updateAssetTypeFieldValues,
3254
- updateAssetTypeFieldValuesMany,
3255
- deleteAssetTypeFieldValues,
3256
- deleteAssetTypeFieldValuesMany
3257
- } = assetTypeFieldValuesSlice.actions;
3258
- const selectAssetTypeFieldValuesMapping = (state) => state.assetTypeFieldValuesReducer.instances;
3259
- const selectAssetTypeFieldValues = toolkit.createSelector([selectAssetTypeFieldValuesMapping], (fieldValuesMapping) => {
3260
- return Object.values(fieldValuesMapping);
3261
- });
3262
- const selectAssetTypeFieldValuesOfAsset = restructureCreateSelectorWithArgs(
3263
- toolkit.createSelector([selectAssetTypeFieldValues, (_state, assetId) => assetId], (fieldValues, assetId) => {
3264
- return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.asset === assetId));
3265
- })
3266
- );
3267
- const selectAssetTypeValuesOfAssetType = restructureCreateSelectorWithArgs(
3268
- toolkit.createSelector(
3269
- [selectAssetTypeFields, selectAssetTypeFieldValues, (_state, id) => id],
3270
- (fields, fieldValues, id) => {
3271
- const fieldsIds = new Set(
3272
- fields.filter((field) => field.asset_type === id).map((field) => field.offline_id)
3273
- );
3274
- return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
3275
- }
3276
- )
3277
- );
3278
- const selectAssetTypeFieldValuesById = (fieldValuesId) => (state) => {
3279
- return state.assetTypeFieldValuesReducer.instances[fieldValuesId];
3280
- };
3281
- const assetTypeFieldValuesReducer = assetTypeFieldValuesSlice.reducer;
3282
- const assetTypeFieldsAttachmentAdapter = createModelAdapter(
3283
- (attachment) => attachment.offline_id
3284
- );
3285
- const initialState$1 = assetTypeFieldsAttachmentAdapter.getInitialState({});
3286
- const assetTypeFieldsAttachmentSlice = toolkit.createSlice({
3287
- name: "assetTypeFieldsAttachments",
3288
- initialState: initialState$1,
3289
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3290
- reducers: {
3291
- initializeAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.initialize,
3292
- addAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.addOne,
3293
- addAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.addMany,
3294
- setAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.setOne,
3295
- setAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.setMany,
3296
- updateAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.updateOne,
3297
- updateAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.updateMany,
3298
- deleteAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.deleteOne,
3299
- deleteAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.deleteMany
3300
- }
3301
- });
3302
- const {
3303
- initializeAssetTypeFieldsAttachments,
3304
- addAssetTypeFieldsAttachment,
3305
- addAssetTypeFieldsAttachments,
3306
- setAssetTypeFieldsAttachment,
3307
- setAssetTypeFieldsAttachments,
3308
- updateAssetTypeFieldsAttachment,
3309
- updateAssetTypeFieldsAttachments,
3310
- deleteAssetTypeFieldsAttachment,
3311
- deleteAssetTypeFieldsAttachments
3312
- } = assetTypeFieldsAttachmentSlice.actions;
3313
- const selectAssetTypeFieldsAttachmentsMapping = (state) => state.assetTypeFieldsAttachmentReducer.instances;
3314
- const selectAssetTypeFieldsAttachments = toolkit.createSelector(
3315
- [selectAssetTypeFieldsAttachmentsMapping],
3316
- (attachmentsMapping) => {
3317
- return Object.values(attachmentsMapping);
3318
- }
3319
- );
3320
- const selectAttachmentsOfAssetTypeFields = restructureCreateSelectorWithArgs(
3321
- toolkit.createSelector([selectAssetTypeFieldsAttachments, (_state, id) => id], (attachments, id) => {
3322
- return fallbackToEmptyArray(attachments.filter((attachment) => attachment.fields_revision === id));
3323
- })
3324
- );
3325
- const selectAssetTypeFieldsAttachmentById = (attachmentId) => (state) => {
3326
- return state.assetTypeFieldsAttachmentReducer.instances[attachmentId];
3327
- };
3328
- const assetTypeFieldsAttachmentReducer = assetTypeFieldsAttachmentSlice.reducer;
3329
- const assetTypeFieldValuesAttachmentAdapter = createModelAdapter(
3330
- (attachment) => attachment.offline_id
3331
- );
3332
- const initialState = assetTypeFieldValuesAttachmentAdapter.getInitialState({});
3333
- const assetTypeFieldValuesAttachmentSlice = toolkit.createSlice({
3334
- name: "assetTypeFieldValuesAttachments",
3335
- initialState,
3336
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
3337
- reducers: {
3338
- initializeAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.initialize,
3339
- addAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.addOne,
3340
- addAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.addMany,
3341
- setAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.setOne,
3342
- setAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.setMany,
3343
- updateAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.updateOne,
3344
- updateAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.updateMany,
3345
- deleteAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.deleteOne,
3346
- deleteAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.deleteMany
3347
- }
3348
- });
3349
- const {
3350
- initializeAssetTypeFieldValuesAttachments,
3351
- addAssetTypeFieldValuesAttachment,
3352
- addAssetTypeFieldValuesAttachments,
3353
- setAssetTypeFieldValuesAttachment,
3354
- setAssetTypeFieldValuesAttachments,
3355
- updateAssetTypeFieldValuesAttachment,
3356
- updateAssetTypeFieldValuesAttachments,
3357
- deleteAssetTypeFieldValuesAttachment,
3358
- deleteAssetTypeFieldValuesAttachments
3359
- } = assetTypeFieldValuesAttachmentSlice.actions;
3360
- const selectAssetTypeFieldValuesAttachmentsMapping = (state) => state.assetTypeFieldValuesAttachmentReducer.instances;
3361
- const selectAssetTypeFieldValuesAttachments = toolkit.createSelector(
3362
- [selectAssetTypeFieldValuesAttachmentsMapping],
3363
- (attachmentsMapping) => {
3364
- return Object.values(attachmentsMapping);
3365
- }
3366
- );
3367
- const selectAttachmentsOfAssetTypeFieldValues = restructureCreateSelectorWithArgs(
3368
- toolkit.createSelector([selectAssetTypeFieldValuesAttachments, (_state, id) => id], (attachments, id) => {
3369
- return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === id));
3370
- })
3371
- );
3372
- const selectAssetTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
3373
- return state.assetTypeFieldValuesAttachmentReducer.instances[attachmentId];
3374
- };
3375
- const assetTypeFieldValuesAttachmentReducer = assetTypeFieldValuesAttachmentSlice.reducer;
3376
- let clientStore;
3377
- function setClientStore(store) {
3378
- clientStore = store;
3379
- }
3380
- function getClientStore() {
3381
- return clientStore;
3382
- }
3383
- let clientSDK;
3384
- function setClientSDK(sdkCtor) {
3385
- clientSDK = sdkCtor;
3386
- }
3387
- function getClientSDK() {
3388
- return clientSDK;
3389
- }
3390
- const CLASS_NAME_TO_SERVICE = {};
3391
- class BaseService {
3392
- constructor(sdk) {
3393
- __publicField(this, "client");
3394
- CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3395
- this.client = sdk;
3396
- }
3397
- async enqueueRequest(requestDetails) {
3398
- return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3399
- }
3400
- dispatch(action) {
3401
- this.client.store.dispatch(action);
3163
+ dispatch(action) {
3164
+ this.client.store.dispatch(action);
3402
3165
  }
3403
3166
  }
3404
3167
  const VERSION_REDUCER_KEY = "versioning";
@@ -3441,15 +3204,7 @@ var __publicField = (obj, key, value) => {
3441
3204
  issueCommentReducer,
3442
3205
  issueUpdateReducer,
3443
3206
  geoImageReducer,
3444
- issueAssociationReducer,
3445
- issueTypeFieldsReducer,
3446
- issueTypeFieldValuesReducer,
3447
- issueTypeFieldsAttachmentReducer,
3448
- issueTypeFieldValuesAttachmentReducer,
3449
- assetTypeFieldsReducer,
3450
- assetTypeFieldValuesReducer,
3451
- assetTypeFieldsAttachmentReducer,
3452
- assetTypeFieldValuesAttachmentReducer
3207
+ issueAssociationReducer
3453
3208
  };
3454
3209
  const overmapReducer = toolkit.combineReducers(overmapReducers);
3455
3210
  const resetStore = "RESET";
@@ -4091,6 +3846,9 @@ var __publicField = (obj, key, value) => {
4091
3846
  description: "Create Category",
4092
3847
  method: HttpMethod.POST,
4093
3848
  url: "/categories/",
3849
+ queryParams: {
3850
+ workspace_id: payload.workspace.toString()
3851
+ },
4094
3852
  payload: offlineCategory,
4095
3853
  blockers: [payload.workspace],
4096
3854
  blocks: [offlineCategory.offline_id]
@@ -4303,10 +4061,7 @@ var __publicField = (obj, key, value) => {
4303
4061
  const result = await this.enqueueRequest({
4304
4062
  description: "Get assets",
4305
4063
  method: HttpMethod.GET,
4306
- url: "/assets/",
4307
- queryParams: {
4308
- project: projectId.toString()
4309
- },
4064
+ url: `/projects/${projectId}/assets/`,
4310
4065
  blockers: [],
4311
4066
  blocks: []
4312
4067
  });
@@ -4327,7 +4082,7 @@ var __publicField = (obj, key, value) => {
4327
4082
  const promise = this.enqueueRequest({
4328
4083
  description: "Add asset stage completion",
4329
4084
  method: HttpMethod.POST,
4330
- url: "/asset-stage-completions/",
4085
+ url: "/assets/completions/",
4331
4086
  payload: {
4332
4087
  offline_id: offlineStageCompletion.offline_id,
4333
4088
  submitted_at: submittedAt,
@@ -4354,7 +4109,7 @@ var __publicField = (obj, key, value) => {
4354
4109
  const promise = this.enqueueRequest({
4355
4110
  description: "Delete asset stage completion",
4356
4111
  method: HttpMethod.DELETE,
4357
- url: `/asset-stage-completions/${id}/`,
4112
+ url: `/assets/completions/${id}/`,
4358
4113
  blockers: [id],
4359
4114
  blocks: []
4360
4115
  });
@@ -4380,7 +4135,7 @@ var __publicField = (obj, key, value) => {
4380
4135
  const promise = this.enqueueRequest({
4381
4136
  description: "Bulk create asset stage completions",
4382
4137
  method: HttpMethod.POST,
4383
- url: "/asset-stage-completions/bulk/",
4138
+ url: "/assets/completions/bulk/",
4384
4139
  payload: {
4385
4140
  submitted_at: submittedAt,
4386
4141
  completions: payload
@@ -4402,7 +4157,7 @@ var __publicField = (obj, key, value) => {
4402
4157
  const promise = this.enqueueRequest({
4403
4158
  description: "Deleting asset stage completions",
4404
4159
  method: HttpMethod.DELETE,
4405
- url: "/asset-stage-completions/bulk/",
4160
+ url: "/assets/completions/bulk/",
4406
4161
  payload: {
4407
4162
  completion_ids: ids
4408
4163
  },
@@ -4418,10 +4173,7 @@ var __publicField = (obj, key, value) => {
4418
4173
  const result = await this.enqueueRequest({
4419
4174
  description: "Get asset stage completions",
4420
4175
  method: HttpMethod.GET,
4421
- url: "/asset-stage-completions/",
4422
- queryParams: {
4423
- project: projectId.toString()
4424
- },
4176
+ url: `/projects/${projectId}/asset-stage-completions/`,
4425
4177
  blockers: [],
4426
4178
  blocks: []
4427
4179
  });
@@ -4442,7 +4194,7 @@ var __publicField = (obj, key, value) => {
4442
4194
  const promise = this.enqueueRequest({
4443
4195
  description: "Add asset stages",
4444
4196
  method: HttpMethod.POST,
4445
- url: "/asset-stages/bulk/",
4197
+ url: "/assets/stages/bulk/",
4446
4198
  payload: {
4447
4199
  submitted_at: submittedAt,
4448
4200
  asset_type: assetTypeId,
@@ -4466,7 +4218,7 @@ var __publicField = (obj, key, value) => {
4466
4218
  return this.enqueueRequest({
4467
4219
  description: "Edit asset stages",
4468
4220
  method: HttpMethod.PATCH,
4469
- url: `/asset-types/${assetTypeId}/bulk-update-stages/`,
4221
+ url: `/assets/types/${assetTypeId}/bulk-update-stages/`,
4470
4222
  payload: {
4471
4223
  stages: stagesToUpdate
4472
4224
  },
@@ -4484,7 +4236,7 @@ var __publicField = (obj, key, value) => {
4484
4236
  const promise = this.enqueueRequest({
4485
4237
  description: "Delete asset stages",
4486
4238
  method: HttpMethod.DELETE,
4487
- url: "/asset-stages/bulk/",
4239
+ url: "/assets/stages/bulk/",
4488
4240
  payload: {
4489
4241
  stage_ids: idsToDelete
4490
4242
  },
@@ -4509,7 +4261,7 @@ var __publicField = (obj, key, value) => {
4509
4261
  const promise = this.enqueueRequest({
4510
4262
  description: "Update asset stage",
4511
4263
  method: HttpMethod.PATCH,
4512
- url: `/asset-stages/${assetStage.offline_id}/`,
4264
+ url: `/assets/stages/${assetStage.offline_id}/`,
4513
4265
  payload: {
4514
4266
  name: payload.name,
4515
4267
  description: payload.description,
@@ -4537,7 +4289,7 @@ var __publicField = (obj, key, value) => {
4537
4289
  await this.enqueueRequest({
4538
4290
  description: "Link asset stage to form",
4539
4291
  method: HttpMethod.POST,
4540
- url: `/asset-stages/${stageId}/associate-with-form/`,
4292
+ url: `/assets/stages/${stageId}/associate-with-form/`,
4541
4293
  payload: { form: formId },
4542
4294
  blockers: [stageId, formId],
4543
4295
  blocks: [stageId]
@@ -4558,7 +4310,7 @@ var __publicField = (obj, key, value) => {
4558
4310
  await this.enqueueRequest({
4559
4311
  description: "Unlink asset stage from form",
4560
4312
  method: HttpMethod.DELETE,
4561
- url: `/asset-stages/${stageId}/associate-with-form/`,
4313
+ url: `/assets/stages/${stageId}/associate-with-form/`,
4562
4314
  blockers: [stageId, formId],
4563
4315
  blocks: [stageId]
4564
4316
  });
@@ -4571,10 +4323,7 @@ var __publicField = (obj, key, value) => {
4571
4323
  const result = await this.enqueueRequest({
4572
4324
  description: "Get asset stages",
4573
4325
  method: HttpMethod.GET,
4574
- url: "/asset-stages/",
4575
- queryParams: {
4576
- project: projectId.toString()
4577
- },
4326
+ url: `/projects/${projectId}/asset-stages/`,
4578
4327
  blockers: [],
4579
4328
  blocks: []
4580
4329
  });
@@ -4591,12 +4340,7 @@ var __publicField = (obj, key, value) => {
4591
4340
  projectAttachmentReducer: projectAttachmentReducer2,
4592
4341
  formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
4593
4342
  formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
4594
- geoImageReducer: geoImageReducer2,
4595
- // fields
4596
- assetTypeFieldsAttachmentReducer: assetTypeFieldsAttachmentReducer2,
4597
- assetTypeFieldValuesAttachmentReducer: assetTypeFieldValuesAttachmentReducer2,
4598
- issueTypeFieldsAttachmentReducer: issueTypeFieldsAttachmentReducer2,
4599
- issueTypeFieldValuesAttachmentReducer: issueTypeFieldValuesAttachmentReducer2
4343
+ geoImageReducer: geoImageReducer2
4600
4344
  } = this.client.store.getState();
4601
4345
  const objectsWithSha1 = [].concat(
4602
4346
  Object.values(issueAttachmentReducer2.instances),
@@ -4606,11 +4350,7 @@ var __publicField = (obj, key, value) => {
4606
4350
  Object.values(projectAttachmentReducer2.instances),
4607
4351
  Object.values(formRevisionAttachmentReducer2.instances),
4608
4352
  Object.values(formSubmissionAttachmentReducer2.instances),
4609
- Object.values(geoImageReducer2.instances),
4610
- Object.values(assetTypeFieldsAttachmentReducer2.instances),
4611
- Object.values(assetTypeFieldValuesAttachmentReducer2.instances),
4612
- Object.values(issueTypeFieldsAttachmentReducer2.instances),
4613
- Object.values(issueTypeFieldValuesAttachmentReducer2.instances)
4353
+ Object.values(geoImageReducer2.instances)
4614
4354
  );
4615
4355
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4616
4356
  }
@@ -4632,20 +4372,41 @@ var __publicField = (obj, key, value) => {
4632
4372
  }
4633
4373
  return promisesBySha1;
4634
4374
  }
4635
- async getFilePayload(file) {
4636
- const sha1 = await hashFile(file);
4637
- const filePayload = {
4638
- sha1,
4639
- file_type: file.type,
4640
- extension: file.name.split(".").pop(),
4641
- size: file.size
4642
- };
4643
- await this.client.files.addCache(file, sha1);
4644
- return filePayload;
4645
- }
4646
4375
  }
4376
+ const AttachmentModelMeta = {
4377
+ [AttachmentModel.Issue]: {
4378
+ name: "issue",
4379
+ attachUrlPrefix: "/issues",
4380
+ deleteUrlPrefix: "/issues",
4381
+ fetchUrlPostfix: "/issue-attachments"
4382
+ },
4383
+ [AttachmentModel.Asset]: {
4384
+ name: "asset",
4385
+ attachUrlPrefix: "/assets",
4386
+ deleteUrlPrefix: "/assets",
4387
+ fetchUrlPostfix: "/asset-attachments"
4388
+ },
4389
+ [AttachmentModel.AssetType]: {
4390
+ name: "asset type",
4391
+ attachUrlPrefix: "/assets/types",
4392
+ deleteUrlPrefix: "/assets/types",
4393
+ fetchUrlPostfix: "/asset-type-attachments"
4394
+ },
4395
+ [AttachmentModel.Project]: {
4396
+ name: "project",
4397
+ attachUrlPrefix: "/projects",
4398
+ deleteUrlPrefix: "/projects",
4399
+ fetchUrlPostfix: "/attachments"
4400
+ },
4401
+ [AttachmentModel.Document]: {
4402
+ name: "document",
4403
+ attachUrlPrefix: "/documents",
4404
+ deleteUrlPrefix: "/documents",
4405
+ fetchUrlPostfix: "/document-attachments"
4406
+ }
4407
+ };
4647
4408
  class BaseAttachmentService extends BaseUploadService {
4648
- async _bulkAdd(payloads) {
4409
+ async attachFiles(files, modelId, buildOfflineAttachment) {
4649
4410
  var _a2;
4650
4411
  const { store } = this.client;
4651
4412
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -4653,36 +4414,39 @@ var __publicField = (obj, key, value) => {
4653
4414
  const offlineAttachments = [];
4654
4415
  const attachmentPayloads = [];
4655
4416
  const filePayloads = {};
4656
- for (const payload of payloads) {
4657
- const { modelId, file } = payload;
4658
- const filePayload = await this.getFilePayload(file);
4659
- if (!(filePayload.sha1 in filePayloads))
4660
- filePayloads[filePayload.sha1] = filePayload;
4661
- const offlineAttachment = this.buildOfflineAttachment({
4417
+ for (const file of files) {
4418
+ const sha1 = await hashFile(file);
4419
+ if (!(sha1 in filePayloads)) {
4420
+ filePayloads[sha1] = {
4421
+ sha1,
4422
+ file_type: file.type,
4423
+ extension: file.name.split(".").pop(),
4424
+ size: file.size
4425
+ };
4426
+ await this.client.files.addCache(file, sha1);
4427
+ }
4428
+ const offlineAttachment = buildOfflineAttachment({
4662
4429
  file,
4663
- file_sha1: filePayload.sha1,
4664
- submitted_at: submittedAt,
4665
- created_by: createdBy,
4430
+ sha1,
4431
+ submittedAt,
4432
+ createdBy,
4666
4433
  description: "",
4667
4434
  modelId
4668
4435
  });
4669
4436
  offlineAttachments.push(offlineAttachment);
4670
- attachmentPayloads.push(
4671
- this.buildAttachmentPayload({
4672
- offline_id: offlineAttachment.offline_id,
4673
- file_name: offlineAttachment.file_name,
4674
- file_sha1: offlineAttachment.file_sha1,
4675
- file_extension: filePayload.extension,
4676
- description: offlineAttachment.description,
4677
- modelId
4678
- })
4679
- );
4437
+ attachmentPayloads.push({
4438
+ offline_id: offlineAttachment.offline_id,
4439
+ name: offlineAttachment.file_name,
4440
+ sha1: offlineAttachment.file_sha1,
4441
+ description: offlineAttachment.description
4442
+ });
4680
4443
  }
4681
4444
  this.dispatch(this.addAttachments(offlineAttachments));
4445
+ const meta = AttachmentModelMeta[this.attachmentModel];
4682
4446
  const promise = this.enqueueRequest({
4683
- description: `Add ${this.name}`,
4447
+ description: `Attach files to ${meta.name}`,
4684
4448
  method: HttpMethod.POST,
4685
- url: `${this.url}/bulk/`,
4449
+ url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
4686
4450
  payload: {
4687
4451
  submitted_at: submittedAt,
4688
4452
  attachments: attachmentPayloads,
@@ -4699,7 +4463,7 @@ var __publicField = (obj, key, value) => {
4699
4463
  });
4700
4464
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
4701
4465
  }
4702
- async _delete(attachmendId) {
4466
+ async deleteAttachment(attachmendId) {
4703
4467
  const { store } = this.client;
4704
4468
  const attachment = this.selectAttachment(attachmendId)(store.getState());
4705
4469
  if (!attachment) {
@@ -4708,10 +4472,11 @@ var __publicField = (obj, key, value) => {
4708
4472
  );
4709
4473
  }
4710
4474
  this.dispatch(this.removeAttachment(attachment.offline_id));
4475
+ const meta = AttachmentModelMeta[this.attachmentModel];
4711
4476
  const promise = this.enqueueRequest({
4712
- description: `Delete ${this.name}`,
4477
+ description: "Delete attachment",
4713
4478
  method: HttpMethod.DELETE,
4714
- url: `${this.url}/${attachmendId}/`,
4479
+ url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
4715
4480
  blockers: [attachmendId],
4716
4481
  blocks: []
4717
4482
  });
@@ -4724,12 +4489,24 @@ var __publicField = (obj, key, value) => {
4724
4489
  });
4725
4490
  return promise;
4726
4491
  }
4492
+ // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4493
+ // so for some attachment model services, this method will have to be overridden.
4494
+ async refreshStore(projectId, _organizationId) {
4495
+ const meta = AttachmentModelMeta[this.attachmentModel];
4496
+ const result = await this.enqueueRequest({
4497
+ description: `Get ${meta.name} attachments`,
4498
+ method: HttpMethod.GET,
4499
+ url: `/projects/${projectId}${meta.fetchUrlPostfix}/`,
4500
+ blocks: [],
4501
+ blockers: []
4502
+ });
4503
+ this.dispatch(this.initializeAttachments(result));
4504
+ }
4727
4505
  }
4728
4506
  class AssetAttachmentService extends BaseAttachmentService {
4729
4507
  constructor() {
4730
4508
  super(...arguments);
4731
- __publicField(this, "name", "Asset Attachment");
4732
- __publicField(this, "url", "/asset-attachments");
4509
+ __publicField(this, "attachmentModel", AttachmentModel.Asset);
4733
4510
  __publicField(this, "initializeAttachments", initializeAssetAttachments);
4734
4511
  __publicField(this, "addAttachments", addAssetAttachments);
4735
4512
  __publicField(this, "updateAttachments", updateAssetAttachments);
@@ -4741,39 +4518,20 @@ var __publicField = (obj, key, value) => {
4741
4518
  buildOfflineAttachment(data) {
4742
4519
  return offline({
4743
4520
  file: URL.createObjectURL(data.file),
4744
- file_sha1: data.file_sha1,
4745
- created_by: data.created_by,
4521
+ file_sha1: data.sha1,
4522
+ created_by: data.createdBy,
4746
4523
  file_name: data.file.name,
4747
4524
  file_type: data.file.type,
4748
- submitted_at: data.submitted_at,
4525
+ submitted_at: data.submittedAt,
4749
4526
  description: data.description,
4750
4527
  asset: data.modelId
4751
4528
  });
4752
4529
  }
4753
- buildAttachmentPayload(data) {
4754
- return {
4755
- ...data,
4756
- asset: data.modelId
4757
- };
4758
- }
4759
- async bulkAdd(payloads) {
4760
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetId, file: p.file })));
4761
- }
4762
- async delete(id) {
4763
- return this._delete(id);
4530
+ async attachFilesToAsset(files, assetId) {
4531
+ return this.attachFiles(files, assetId, this.buildOfflineAttachment.bind(this));
4764
4532
  }
4765
- async refreshStore(projectId) {
4766
- const result = await this.enqueueRequest({
4767
- description: "Get asset attachments",
4768
- method: HttpMethod.GET,
4769
- url: `${this.url}/`,
4770
- queryParams: {
4771
- project: projectId.toString()
4772
- },
4773
- blocks: [],
4774
- blockers: []
4775
- });
4776
- this.dispatch(initializeAssetAttachments(result));
4533
+ async deleteAssetAttachment(attachmentId) {
4534
+ return this.deleteAttachment(attachmentId);
4777
4535
  }
4778
4536
  }
4779
4537
  class AssetTypeService extends BaseApiService {
@@ -4790,7 +4548,7 @@ var __publicField = (obj, key, value) => {
4790
4548
  const promise = this.enqueueRequest({
4791
4549
  description: "Create asset type",
4792
4550
  method: HttpMethod.POST,
4793
- url: "/asset-types/",
4551
+ url: `/projects/${payload.project}/asset-types/`,
4794
4552
  payload: { ...offlineAssetType },
4795
4553
  blockers: [],
4796
4554
  blocks: [offlineAssetType.offline_id]
@@ -4816,7 +4574,7 @@ var __publicField = (obj, key, value) => {
4816
4574
  const promise = this.enqueueRequest({
4817
4575
  description: "Update asset type",
4818
4576
  method: HttpMethod.PATCH,
4819
- url: `/asset-types/${payload.offline_id}/`,
4577
+ url: `/assets/types/${payload.offline_id}/`,
4820
4578
  payload: {
4821
4579
  icon: payload.icon,
4822
4580
  color: payload.color,
@@ -4850,7 +4608,7 @@ var __publicField = (obj, key, value) => {
4850
4608
  return this.enqueueRequest({
4851
4609
  description: "Delete asset type",
4852
4610
  method: HttpMethod.DELETE,
4853
- url: `/asset-types/${assetTypeId}/`,
4611
+ url: `/assets/types/${assetTypeId}/`,
4854
4612
  blockers: [assetTypeId],
4855
4613
  blocks: []
4856
4614
  }).catch((e) => {
@@ -4865,10 +4623,7 @@ var __publicField = (obj, key, value) => {
4865
4623
  const result = await this.enqueueRequest({
4866
4624
  description: "Get asset types",
4867
4625
  method: HttpMethod.GET,
4868
- url: "/asset-types/",
4869
- queryParams: {
4870
- project: projectId.toString()
4871
- },
4626
+ url: `/projects/${projectId}/asset-types/`,
4872
4627
  blockers: [],
4873
4628
  blocks: []
4874
4629
  });
@@ -4878,8 +4633,8 @@ var __publicField = (obj, key, value) => {
4878
4633
  class AssetTypeAttachmentService extends BaseAttachmentService {
4879
4634
  constructor() {
4880
4635
  super(...arguments);
4881
- __publicField(this, "name", "Asset Type Attachment");
4882
- __publicField(this, "url", "/asset-type-attachments");
4636
+ __publicField(this, "attachmentModel", AttachmentModel.AssetType);
4637
+ __publicField(this, "initializeAttachments", initializeAssetTypeAttachments);
4883
4638
  __publicField(this, "addAttachments", addAssetTypeAttachments);
4884
4639
  __publicField(this, "updateAttachments", updateAssetTypeAttachments);
4885
4640
  __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
@@ -4890,39 +4645,20 @@ var __publicField = (obj, key, value) => {
4890
4645
  buildOfflineAttachment(data) {
4891
4646
  return offline({
4892
4647
  file: URL.createObjectURL(data.file),
4893
- file_sha1: data.file_sha1,
4894
- created_by: data.created_by,
4648
+ file_sha1: data.sha1,
4649
+ created_by: data.createdBy,
4895
4650
  file_name: data.file.name,
4896
4651
  file_type: data.file.type,
4897
- submitted_at: data.submitted_at,
4652
+ submitted_at: data.submittedAt,
4898
4653
  description: data.description,
4899
4654
  asset_type: data.modelId
4900
4655
  });
4901
4656
  }
4902
- buildAttachmentPayload(data) {
4903
- return {
4904
- ...data,
4905
- asset_type: data.modelId
4906
- };
4907
- }
4908
- async bulkAdd(payloads) {
4909
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetTypeId, file: p.file })));
4657
+ async attachFilesToAssetType(files, assetTypeId) {
4658
+ return this.attachFiles(files, assetTypeId, this.buildOfflineAttachment.bind(this));
4910
4659
  }
4911
- async delete(attachmentId) {
4912
- return this._delete(attachmentId);
4913
- }
4914
- async refreshStore(projectId) {
4915
- const result = await this.enqueueRequest({
4916
- description: "Get asset type attachments",
4917
- method: HttpMethod.GET,
4918
- url: `${this.url}/`,
4919
- queryParams: {
4920
- project: projectId.toString()
4921
- },
4922
- blocks: [],
4923
- blockers: []
4924
- });
4925
- this.dispatch(initializeAssetTypeAttachments(result));
4660
+ async deleteAssetTypeAttachment(attachmentId) {
4661
+ return this.deleteAttachment(attachmentId);
4926
4662
  }
4927
4663
  }
4928
4664
  class IssueCommentService extends BaseApiService {
@@ -4938,7 +4674,7 @@ var __publicField = (obj, key, value) => {
4938
4674
  const promise = this.enqueueRequest({
4939
4675
  description: "Add issue comment",
4940
4676
  method: HttpMethod.POST,
4941
- url: "/issue-comments/",
4677
+ url: `/issues/${payload.issue}/comment/`,
4942
4678
  payload: offlineComment,
4943
4679
  blockers: [payload.issue],
4944
4680
  blocks: [offlineComment.offline_id]
@@ -4962,7 +4698,7 @@ var __publicField = (obj, key, value) => {
4962
4698
  const promise = this.enqueueRequest({
4963
4699
  description: "Edit issue comment",
4964
4700
  method: HttpMethod.PATCH,
4965
- url: `/issue-comments/${payload.offline_id}/`,
4701
+ url: `/issues/comments/${payload.offline_id}/`,
4966
4702
  payload,
4967
4703
  blockers: [payload.offline_id],
4968
4704
  blocks: [payload.offline_id]
@@ -4981,7 +4717,7 @@ var __publicField = (obj, key, value) => {
4981
4717
  const promise = this.enqueueRequest({
4982
4718
  description: "Delete comment",
4983
4719
  method: HttpMethod.DELETE,
4984
- url: `/issue-comments/${id}/`,
4720
+ url: `/issues/comments/${id}/`,
4985
4721
  blockers: [id],
4986
4722
  blocks: []
4987
4723
  });
@@ -4994,10 +4730,7 @@ var __publicField = (obj, key, value) => {
4994
4730
  const result = await this.enqueueRequest({
4995
4731
  description: "Get comments",
4996
4732
  method: HttpMethod.GET,
4997
- url: "/issue-comments/",
4998
- queryParams: {
4999
- project: projectId.toString()
5000
- },
4733
+ url: `/projects/${projectId}/comments/`,
5001
4734
  blockers: [],
5002
4735
  blocks: []
5003
4736
  });
@@ -5009,21 +4742,27 @@ var __publicField = (obj, key, value) => {
5009
4742
  const result = await this.enqueueRequest({
5010
4743
  description: "Get issue updates",
5011
4744
  method: HttpMethod.GET,
5012
- url: "/issue-updates/",
5013
- queryParams: {
5014
- project: projectId.toString()
5015
- },
4745
+ url: `/projects/${projectId}/issues/updates/`,
5016
4746
  blockers: [],
5017
4747
  blocks: []
5018
4748
  });
5019
- this.dispatch(initializeIssueUpdates(result));
4749
+ let filteredResult = result.filter(onlyUniqueOfflineIds);
4750
+ filteredResult = filteredResult.map((comment) => {
4751
+ return { ...comment };
4752
+ });
4753
+ if (result.length !== filteredResult.length) {
4754
+ console.error(
4755
+ `Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
4756
+ );
4757
+ }
4758
+ this.dispatch(initializeIssueUpdates(filteredResult));
5020
4759
  }
5021
4760
  }
5022
4761
  class IssueAttachmentService extends BaseAttachmentService {
5023
4762
  constructor() {
5024
4763
  super(...arguments);
5025
- __publicField(this, "name", "Issue Attachment");
5026
- __publicField(this, "url", "/issue-attachments");
4764
+ __publicField(this, "attachmentModel", AttachmentModel.Issue);
4765
+ __publicField(this, "initializeAttachments", initializeIssueAttachments);
5027
4766
  __publicField(this, "addAttachments", addIssueAttachments);
5028
4767
  __publicField(this, "updateAttachments", updateIssueAttachments);
5029
4768
  __publicField(this, "removeAttachments", deleteIssueAttachments);
@@ -5034,42 +4773,24 @@ var __publicField = (obj, key, value) => {
5034
4773
  buildOfflineAttachment(data) {
5035
4774
  return offline({
5036
4775
  file: URL.createObjectURL(data.file),
5037
- file_sha1: data.file_sha1,
5038
- created_by: data.created_by,
4776
+ file_sha1: data.sha1,
4777
+ created_by: data.createdBy,
5039
4778
  file_name: data.file.name,
5040
4779
  file_type: data.file.type,
5041
- submitted_at: data.submitted_at,
4780
+ submitted_at: data.submittedAt,
5042
4781
  description: data.description,
5043
4782
  issue: data.modelId
5044
4783
  });
5045
4784
  }
5046
- buildAttachmentPayload(data) {
5047
- return {
5048
- ...data,
5049
- issue: data.modelId
5050
- };
5051
- }
5052
- async bulkAdd(payloads) {
5053
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.issueId, file: p.file })));
5054
- }
5055
- async delete(id) {
5056
- return this._delete(id);
4785
+ async attachFilesToIssue(files, issueId) {
4786
+ return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this));
5057
4787
  }
5058
- async refreshStore(projectId) {
5059
- const result = await this.enqueueRequest({
5060
- description: "Get issue attachments",
5061
- method: HttpMethod.GET,
5062
- url: `${this.url}/`,
5063
- queryParams: {
5064
- project: projectId.toString()
5065
- },
5066
- blocks: [],
5067
- blockers: []
5068
- });
5069
- this.dispatch(initializeIssueAttachments(result));
4788
+ async deleteIssueAttachment(attachmentId) {
4789
+ return this.deleteAttachment(attachmentId);
5070
4790
  }
5071
4791
  }
5072
4792
  class IssueService extends BaseApiService {
4793
+ // Basic CRUD functions
5073
4794
  add(payload) {
5074
4795
  var _a2;
5075
4796
  const { store } = this.client;
@@ -5087,6 +4808,10 @@ var __publicField = (obj, key, value) => {
5087
4808
  description: "Create issue",
5088
4809
  method: HttpMethod.POST,
5089
4810
  url: "/issues/",
4811
+ queryParams: {
4812
+ workspace_id: payload.index_workspace,
4813
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4814
+ },
5090
4815
  payload: offlineIssue,
5091
4816
  blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
5092
4817
  blocks: [offlineIssue.offline_id]
@@ -5242,10 +4967,7 @@ var __publicField = (obj, key, value) => {
5242
4967
  const result = await this.enqueueRequest({
5243
4968
  description: "Get issues",
5244
4969
  method: HttpMethod.GET,
5245
- url: "/issues/",
5246
- queryParams: {
5247
- project: projectId.toString()
5248
- },
4970
+ url: `/projects/${projectId}/issues/`,
5249
4971
  blockers: [],
5250
4972
  blocks: []
5251
4973
  });
@@ -5265,8 +4987,16 @@ var __publicField = (obj, key, value) => {
5265
4987
  this.dispatch(addIssueType(offlineIssueType));
5266
4988
  const promise = this.enqueueRequest({
5267
4989
  method: HttpMethod.POST,
5268
- url: "/issue-types/",
5269
- payload: offlineIssueType,
4990
+ url: `/organizations/${payload.organization}/issue-types/`,
4991
+ // Sending only whats needed here
4992
+ payload: {
4993
+ offline_id: offlineIssueType.offline_id,
4994
+ submitted_at: offlineIssueType.submitted_at,
4995
+ icon: offlineIssueType.icon,
4996
+ color: offlineIssueType.color,
4997
+ name: offlineIssueType.name,
4998
+ description: offlineIssueType.description
4999
+ },
5270
5000
  blockers: [],
5271
5001
  blocks: [offlineIssueType.offline_id]
5272
5002
  });
@@ -5291,7 +5021,7 @@ var __publicField = (obj, key, value) => {
5291
5021
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
5292
5022
  const promise = this.enqueueRequest({
5293
5023
  method: HttpMethod.PATCH,
5294
- url: `/issue-types/${payload.offline_id}/`,
5024
+ url: `/issues/types/${payload.offline_id}/`,
5295
5025
  payload,
5296
5026
  blockers: [payload.offline_id],
5297
5027
  blocks: [payload.offline_id]
@@ -5315,7 +5045,7 @@ var __publicField = (obj, key, value) => {
5315
5045
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5316
5046
  const promise = this.enqueueRequest({
5317
5047
  method: HttpMethod.DELETE,
5318
- url: `/issue-types/${id}/`,
5048
+ url: `/issues/types/${id}/`,
5319
5049
  blockers: [id],
5320
5050
  blocks: []
5321
5051
  });
@@ -5328,10 +5058,7 @@ var __publicField = (obj, key, value) => {
5328
5058
  async refreshStore(organizationId) {
5329
5059
  const result = await this.enqueueRequest({
5330
5060
  method: HttpMethod.GET,
5331
- url: "/issue-types/",
5332
- queryParams: {
5333
- organization: organizationId.toString()
5334
- },
5061
+ url: `/organizations/${organizationId}/issue-types/`,
5335
5062
  blockers: [],
5336
5063
  blocks: []
5337
5064
  });
@@ -5475,8 +5202,8 @@ var __publicField = (obj, key, value) => {
5475
5202
  class ProjectAttachmentService extends BaseAttachmentService {
5476
5203
  constructor() {
5477
5204
  super(...arguments);
5478
- __publicField(this, "name", "Project Attachment");
5479
- __publicField(this, "url", "/project-attachments");
5205
+ __publicField(this, "attachmentModel", AttachmentModel.Project);
5206
+ __publicField(this, "initializeAttachments", initializeProjectAttachments);
5480
5207
  __publicField(this, "addAttachments", addProjectAttachments);
5481
5208
  __publicField(this, "updateAttachments", updateProjectAttachments);
5482
5209
  __publicField(this, "removeAttachments", deleteProjectAttachments);
@@ -5487,39 +5214,20 @@ var __publicField = (obj, key, value) => {
5487
5214
  buildOfflineAttachment(data) {
5488
5215
  return offline({
5489
5216
  file: URL.createObjectURL(data.file),
5490
- file_sha1: data.file_sha1,
5491
- created_by: data.created_by,
5217
+ file_sha1: data.sha1,
5218
+ created_by: data.createdBy,
5492
5219
  file_name: data.file.name,
5493
5220
  file_type: data.file.type,
5494
- submitted_at: data.submitted_at,
5221
+ submitted_at: data.submittedAt,
5495
5222
  description: data.description,
5496
5223
  project: data.modelId
5497
5224
  });
5498
5225
  }
5499
- buildAttachmentPayload(data) {
5500
- return {
5501
- ...data,
5502
- project: data.modelId
5503
- };
5504
- }
5505
- async bulkAdd(payloads) {
5506
- return this._bulkAdd(payloads.map((p) => ({ modelId: p.projectId, file: p.file })));
5226
+ async attachFilesToProject(files, projectId) {
5227
+ return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this));
5507
5228
  }
5508
- async delete(attachmentId) {
5509
- return this._delete(attachmentId);
5510
- }
5511
- async refreshStore(projectId) {
5512
- const result = await this.enqueueRequest({
5513
- description: "Get project attachments",
5514
- method: HttpMethod.GET,
5515
- url: `${this.url}/`,
5516
- queryParams: {
5517
- project: projectId.toString()
5518
- },
5519
- blockers: [],
5520
- blocks: []
5521
- });
5522
- this.dispatch(initializeProjectAttachments(result));
5229
+ async deleteProjectAttachment(attachmentId) {
5230
+ return this.deleteAttachment(attachmentId);
5523
5231
  }
5524
5232
  }
5525
5233
  class ProjectService extends BaseApiService {
@@ -5662,76 +5370,224 @@ var __publicField = (obj, key, value) => {
5662
5370
  return { fields: newFields, images };
5663
5371
  };
5664
5372
  class FormService extends BaseUploadService {
5665
- add(payload, initialRevision) {
5373
+ async bulkAddRevisionAttachments(revisionId, files) {
5666
5374
  var _a2;
5667
- const { store } = this.client;
5668
5375
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5669
- const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5670
- const offlineForm = offline({
5671
- ...payload,
5672
- submitted_at: submittedAt,
5673
- created_by: createdBy
5674
- });
5675
- const offlineFormRevision = offline({
5676
- ...initialRevision,
5677
- form: offlineForm.offline_id,
5678
- revision: "Pending",
5679
- submitted_at: submittedAt,
5680
- created_by: createdBy
5681
- });
5682
- this.dispatch(addForm(offlineForm));
5683
- this.dispatch(addFormRevision(offlineFormRevision));
5684
- const formPromise = this.enqueueRequest({
5685
- description: "Create form",
5376
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5377
+ const filePayloads = {};
5378
+ const offlineFormRevisionAttachments = [];
5379
+ const attachmentPayloads = [];
5380
+ for (const [fieldIdentifier, file] of Object.entries(files)) {
5381
+ const sha1 = await hashFile(file);
5382
+ if (!(sha1 in filePayloads)) {
5383
+ filePayloads[sha1] = {
5384
+ sha1,
5385
+ file_type: file.type,
5386
+ extension: file.name.split(".").pop(),
5387
+ size: file.size
5388
+ };
5389
+ await this.client.files.addCache(file, sha1);
5390
+ }
5391
+ const offlineFormRevisionAttachment = offline({
5392
+ file: URL.createObjectURL(file),
5393
+ file_type: file.type,
5394
+ file_name: file.name,
5395
+ file_sha1: sha1,
5396
+ created_by: createdBy,
5397
+ revision: revisionId,
5398
+ submitted_at: submittedAt,
5399
+ field_identifier: fieldIdentifier
5400
+ });
5401
+ offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
5402
+ const attachmentPayload = {
5403
+ offline_id: offlineFormRevisionAttachment.offline_id,
5404
+ name: file.name,
5405
+ field_identifier: fieldIdentifier,
5406
+ sha1
5407
+ };
5408
+ attachmentPayloads.push(attachmentPayload);
5409
+ }
5410
+ this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
5411
+ const promise = this.enqueueRequest({
5412
+ description: "Attach files to form revision",
5686
5413
  method: HttpMethod.POST,
5687
- url: "/forms/",
5414
+ url: `/forms/revisions/${revisionId}/attachments/bulk/`,
5688
5415
  payload: {
5689
- // Sending exactly what is currently needed for the endpoint
5690
- offline_id: offlineForm.offline_id,
5691
- submitted_at: offlineForm.submitted_at,
5692
- initial_revision: {
5693
- offline_id: offlineFormRevision.offline_id,
5694
- submitted_at: offlineFormRevision.submitted_at,
5695
- title: offlineFormRevision.title,
5696
- description: offlineFormRevision.description,
5697
- fields: offlineFormRevision.fields
5698
- }
5416
+ submitted_at: submittedAt,
5417
+ attachments: attachmentPayloads,
5418
+ files: Object.values(filePayloads)
5699
5419
  },
5700
- blockers: [
5701
- ...payload.project ? [payload.project.toString()] : [],
5702
- ...payload.organization ? [payload.organization.toString()] : []
5703
- ],
5704
- blocks: [offlineForm.offline_id, offlineFormRevision.offline_id]
5420
+ blockers: [revisionId],
5421
+ blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5422
+ });
5423
+ promise.then((result) => {
5424
+ this.processPresignedUrls(result.presigned_urls);
5425
+ this.dispatch(updateFormRevisionAttachments(result.attachments));
5426
+ }).catch(() => {
5427
+ this.dispatch(
5428
+ deleteFormRevisionAttachments(
5429
+ offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5430
+ )
5431
+ );
5432
+ });
5433
+ return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
5434
+ }
5435
+ async add(ownerId, form, initialRevision, urlPrefix) {
5436
+ const { fields, images } = await separateImageFromFields(initialRevision.fields);
5437
+ const offlineFormRevision = offline({
5438
+ ...initialRevision,
5439
+ fields,
5440
+ created_by: form.created_by,
5441
+ form: form.offline_id,
5442
+ submitted_at: form.submitted_at,
5443
+ revision: "Pending"
5444
+ });
5445
+ this.dispatch(addForm(form));
5446
+ this.dispatch(addFormRevision(offlineFormRevision));
5447
+ const formPromise = this.enqueueRequest({
5448
+ description: "Create form",
5449
+ method: HttpMethod.POST,
5450
+ url: urlPrefix,
5451
+ payload: {
5452
+ // Sending exactly what is currently needed for the endpoint
5453
+ offline_id: form.offline_id,
5454
+ submitted_at: form.submitted_at,
5455
+ initial_revision: {
5456
+ offline_id: offlineFormRevision.offline_id,
5457
+ submitted_at: offlineFormRevision.submitted_at,
5458
+ title: offlineFormRevision.title,
5459
+ description: offlineFormRevision.description,
5460
+ fields: offlineFormRevision.fields
5461
+ }
5462
+ },
5463
+ blockers: [ownerId],
5464
+ blocks: [form.offline_id, offlineFormRevision.offline_id]
5705
5465
  });
5466
+ const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5467
+ offlineFormRevision.offline_id,
5468
+ images
5469
+ );
5706
5470
  void formPromise.catch((e) => {
5707
- this.dispatch(deleteForm(offlineForm.offline_id));
5471
+ this.dispatch(deleteForm(form.offline_id));
5708
5472
  this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
5709
5473
  throw e;
5710
5474
  });
5711
- return [offlineForm, offlineFormRevision, formPromise];
5475
+ return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5712
5476
  }
5713
- async delete(id) {
5477
+ addForOrganization(organizationId, initialRevision) {
5478
+ var _a2;
5479
+ const state = this.client.store.getState();
5480
+ const offlineForm = offline({
5481
+ favorite: false,
5482
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5483
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5484
+ organization: organizationId
5485
+ });
5486
+ return this.add(
5487
+ organizationId.toString(),
5488
+ offlineForm,
5489
+ initialRevision,
5490
+ `/organizations/${organizationId}/create-form/`
5491
+ );
5492
+ }
5493
+ addForProject(projectId, initialRevision) {
5494
+ var _a2;
5495
+ const state = this.client.store.getState();
5496
+ const offlineForm = offline({
5497
+ favorite: false,
5498
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5499
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5500
+ project: projectId
5501
+ });
5502
+ return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5503
+ }
5504
+ addForIssueType(issueTypeId, 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
+ issue_type: issueTypeId
5512
+ });
5513
+ return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5514
+ }
5515
+ addForAssetType(assetTypeId, 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
+ asset_type: assetTypeId
5523
+ });
5524
+ return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5525
+ }
5526
+ async createRevision(formId, revision) {
5527
+ var _a2;
5528
+ const offlineRevision = offline(revision);
5529
+ const { store } = this.client;
5530
+ const state = store.getState();
5531
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5532
+ const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5533
+ const fullRevision = {
5534
+ ...offlineRevision,
5535
+ fields,
5536
+ created_by: createdBy,
5537
+ revision: "Pending",
5538
+ form: formId,
5539
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5540
+ };
5541
+ this.dispatch(addFormRevision(fullRevision));
5542
+ const promise = this.enqueueRequest({
5543
+ description: "Create form revision",
5544
+ method: HttpMethod.PATCH,
5545
+ url: `/forms/${formId}/`,
5546
+ payload: {
5547
+ initial_revision: {
5548
+ offline_id: fullRevision.offline_id,
5549
+ submitted_at: fullRevision.submitted_at,
5550
+ title: fullRevision.title,
5551
+ description: fullRevision.description,
5552
+ fields: fullRevision.fields
5553
+ }
5554
+ },
5555
+ blockers: [formId],
5556
+ blocks: [offlineRevision.offline_id]
5557
+ });
5558
+ const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5559
+ fullRevision.offline_id,
5560
+ images
5561
+ );
5562
+ void promise.then((result) => {
5563
+ this.dispatch(setFormRevision(result));
5564
+ }).catch(() => {
5565
+ this.dispatch(deleteFormRevision(fullRevision.offline_id));
5566
+ });
5567
+ return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5568
+ }
5569
+ async delete(formId) {
5714
5570
  const { store } = this.client;
5715
5571
  const state = store.getState();
5716
- const form = selectFormById(id)(state);
5572
+ const form = selectFormById(formId)(state);
5717
5573
  if (!form) {
5718
5574
  throw new Error("Expected form to exist");
5719
5575
  }
5720
- const formSubmissions = selectFormSubmissionsOfForm(id)(state);
5576
+ const formSubmissions = selectFormSubmissionsOfForm(formId)(state);
5721
5577
  if (formSubmissions.length > 0) {
5722
5578
  this.dispatch(deleteFormSubmissions(formSubmissions.map(({ offline_id }) => offline_id)));
5723
5579
  }
5724
- const formRevisions = selectFormRevisionsOfForm(id)(state);
5580
+ const formRevisions = selectFormRevisionsOfForm(formId)(state);
5725
5581
  if (formRevisions.length > 0) {
5726
5582
  this.dispatch(deleteFormRevisions(formRevisions.map(({ offline_id }) => offline_id)));
5727
5583
  }
5728
- this.dispatch(deleteForm(id));
5584
+ this.dispatch(deleteForm(formId));
5729
5585
  try {
5730
5586
  return await this.enqueueRequest({
5731
5587
  description: "Delete form",
5732
5588
  method: HttpMethod.DELETE,
5733
- url: `/forms/${id}/`,
5734
- blockers: [id],
5589
+ url: `/forms/${formId}/`,
5590
+ blockers: [formId],
5735
5591
  blocks: []
5736
5592
  });
5737
5593
  } catch (e) {
@@ -5745,31 +5601,65 @@ var __publicField = (obj, key, value) => {
5745
5601
  throw e;
5746
5602
  }
5747
5603
  }
5748
- async refreshStore(projectId, organizationId) {
5749
- let forms = [];
5750
- const projectForms = await this.enqueueRequest({
5604
+ async refreshStore(projectId) {
5605
+ const forms = [];
5606
+ const revisions = [];
5607
+ const attachments = [];
5608
+ const projectFormsResult = await this.enqueueRequest({
5751
5609
  description: "Fetch project forms",
5752
5610
  method: HttpMethod.GET,
5753
- url: "/forms/",
5754
- queryParams: {
5755
- project: projectId.toString()
5756
- },
5611
+ url: `/projects/${projectId}/forms/`,
5757
5612
  blockers: [projectId.toString()],
5758
5613
  blocks: []
5759
5614
  });
5760
- forms = forms.concat(projectForms);
5761
- const organizationForms = await this.enqueueRequest({
5615
+ for (const form of projectFormsResult.forms)
5616
+ forms.push(form);
5617
+ for (const revision of projectFormsResult.revisions)
5618
+ revisions.push(revision);
5619
+ for (const attachment of projectFormsResult.attachments)
5620
+ attachments.push(attachment);
5621
+ const organizationFormsResult = await this.enqueueRequest({
5762
5622
  description: "Fetch organization forms",
5763
5623
  method: HttpMethod.GET,
5764
- url: "/forms/",
5765
- queryParams: {
5766
- organization: organizationId.toString()
5767
- },
5768
- blockers: [organizationId.toString()],
5624
+ url: `/projects/${projectId}/organizations/forms/`,
5625
+ blockers: [projectId.toString()],
5626
+ blocks: []
5627
+ });
5628
+ for (const form of organizationFormsResult.forms)
5629
+ forms.push(form);
5630
+ for (const revision of organizationFormsResult.revisions)
5631
+ revisions.push(revision);
5632
+ for (const attachment of organizationFormsResult.attachments)
5633
+ attachments.push(attachment);
5634
+ const assetTypeFormsResult = await this.enqueueRequest({
5635
+ description: "Fetch asset type forms",
5636
+ method: HttpMethod.GET,
5637
+ url: `/projects/${projectId}/asset-types/forms/`,
5638
+ blockers: [projectId.toString()],
5639
+ blocks: []
5640
+ });
5641
+ for (const form of assetTypeFormsResult.forms)
5642
+ forms.push(form);
5643
+ for (const revision of assetTypeFormsResult.revisions)
5644
+ revisions.push(revision);
5645
+ for (const attachment of assetTypeFormsResult.attachments)
5646
+ attachments.push(attachment);
5647
+ const issueTypeFormsResult = await this.enqueueRequest({
5648
+ description: "Fetch issue type forms",
5649
+ method: HttpMethod.GET,
5650
+ url: `/projects/${projectId}/issue-types/forms/`,
5651
+ blockers: [projectId.toString()],
5769
5652
  blocks: []
5770
5653
  });
5771
- forms = forms.concat(organizationForms);
5654
+ for (const form of issueTypeFormsResult.forms)
5655
+ forms.push(form);
5656
+ for (const revision of issueTypeFormsResult.revisions)
5657
+ revisions.push(revision);
5658
+ for (const attachment of issueTypeFormsResult.attachments)
5659
+ attachments.push(attachment);
5772
5660
  this.dispatch(initializeForms(forms));
5661
+ this.dispatch(initializeFormRevisions(revisions));
5662
+ this.dispatch(initializeFormRevisionAttachments(attachments));
5773
5663
  }
5774
5664
  }
5775
5665
  const isArrayOfFiles = (value) => {
@@ -5791,11 +5681,95 @@ var __publicField = (obj, key, value) => {
5791
5681
  return { values: newValues, files };
5792
5682
  };
5793
5683
  class FormSubmissionService extends BaseUploadService {
5794
- add(payload) {
5684
+ async bulkAddSubmissionAttachments(submissionId, files) {
5685
+ var _a2;
5686
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5687
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5688
+ const filePayloads = {};
5689
+ const offlineFormSubmissionAttachments = [];
5690
+ const attachmentPayloads = [];
5691
+ for (const [fieldIdentifier, filesArray] of Object.entries(files)) {
5692
+ for (const file of filesArray) {
5693
+ const sha1 = await hashFile(file);
5694
+ if (!(sha1 in filePayloads)) {
5695
+ filePayloads[sha1] = {
5696
+ sha1,
5697
+ file_type: file.type,
5698
+ extension: file.name.split(".").pop(),
5699
+ size: file.size
5700
+ };
5701
+ await this.client.files.addCache(file, sha1);
5702
+ }
5703
+ const offlineFormSubmissionAttachment = offline({
5704
+ file: URL.createObjectURL(file),
5705
+ file_type: file.type,
5706
+ file_name: file.name,
5707
+ file_sha1: sha1,
5708
+ created_by: createdBy,
5709
+ submission: submissionId,
5710
+ submitted_at: submittedAt,
5711
+ field_identifier: fieldIdentifier
5712
+ });
5713
+ offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
5714
+ const attachmentPayload = {
5715
+ offline_id: offlineFormSubmissionAttachment.offline_id,
5716
+ name: file.name,
5717
+ sha1,
5718
+ field_identifier: fieldIdentifier
5719
+ };
5720
+ attachmentPayloads.push(attachmentPayload);
5721
+ }
5722
+ }
5723
+ this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
5724
+ const promise = this.enqueueRequest({
5725
+ description: "Attach files to form submission",
5726
+ method: HttpMethod.POST,
5727
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5728
+ payload: {
5729
+ submitted_at: submittedAt,
5730
+ attachments: attachmentPayloads,
5731
+ files: Object.values(filePayloads)
5732
+ },
5733
+ blockers: [submissionId],
5734
+ blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5735
+ });
5736
+ promise.then((result) => {
5737
+ this.processPresignedUrls(result.presigned_urls);
5738
+ this.dispatch(updateFormSubmissionAttachments(result.attachments));
5739
+ }).catch(() => {
5740
+ this.dispatch(
5741
+ deleteFormSubmissionAttachments(
5742
+ offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5743
+ )
5744
+ );
5745
+ });
5746
+ return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5747
+ }
5748
+ async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
5749
+ const { store } = this.client;
5750
+ const state = store.getState();
5751
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
5752
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
5753
+ try {
5754
+ await this.enqueueRequest({
5755
+ description: "Delete form submission attachments",
5756
+ method: HttpMethod.DELETE,
5757
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5758
+ payload: { attachments: attachmentsIds },
5759
+ blockers: [submissionId, ...attachmentsIds],
5760
+ blocks: []
5761
+ });
5762
+ } catch (e) {
5763
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
5764
+ throw e;
5765
+ }
5766
+ }
5767
+ // Outer promise is for hashing and caching files for submission attachments
5768
+ async add(payload) {
5795
5769
  var _a2;
5796
5770
  const { store } = this.client;
5797
5771
  const state = store.getState();
5798
- const { values } = separateFilesFromValues(payload.values);
5772
+ const { values, files } = separateFilesFromValues(payload.values);
5799
5773
  const offlineSubmission = offline({
5800
5774
  ...payload,
5801
5775
  values,
@@ -5805,7 +5779,7 @@ var __publicField = (obj, key, value) => {
5805
5779
  const promise = this.enqueueRequest({
5806
5780
  description: "Respond to form",
5807
5781
  method: HttpMethod.POST,
5808
- url: "/form-submissions/",
5782
+ url: `/forms/revisions/${payload.form_revision}/respond/`,
5809
5783
  payload: offlineSubmission,
5810
5784
  blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
5811
5785
  (x) => x !== void 0
@@ -5813,6 +5787,10 @@ var __publicField = (obj, key, value) => {
5813
5787
  blocks: [offlineSubmission.offline_id]
5814
5788
  });
5815
5789
  this.dispatch(addFormSubmission(offlineSubmission));
5790
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5791
+ offlineSubmission.offline_id,
5792
+ files
5793
+ );
5816
5794
  promise.then((result) => {
5817
5795
  this.dispatch(addActiveProjectFormSubmissionsCount(1));
5818
5796
  this.dispatch(setFormSubmission(result));
@@ -5821,16 +5799,115 @@ var __publicField = (obj, key, value) => {
5821
5799
  this.dispatch(deleteFormSubmission(offlineSubmission.offline_id));
5822
5800
  this.dispatch(addActiveProjectFormSubmissionsCount(-1));
5823
5801
  });
5824
- return [offlineSubmission, promise];
5802
+ return [offlineSubmission, offlineFormSubmissionAttachments, promise, attachmentsPromise];
5825
5803
  }
5826
- update(payload) {
5804
+ // Note currently the bulkAdd method is specific to form submissions for assets
5805
+ // TODO: adapt the support bulk adding to any model type
5806
+ async bulkAdd(args, batchSize) {
5807
+ const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
5808
+ const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
5809
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5810
+ const transactionId = uuid.v4();
5811
+ const assetIdBatches = chunkArray(Object.keys(fieldValuesByAsset), batchSize);
5812
+ const bulkAddBatches = await Promise.all(
5813
+ assetIdBatches.map(async (assetIdBatch) => {
5814
+ const batchId = uuid.v4();
5815
+ const submissionPayloads = [];
5816
+ const attachmentPayloads = [];
5817
+ const files = { ...commonFiles };
5818
+ for (const assetId of assetIdBatch) {
5819
+ const { values: fileSeperatedSubmissionSpecificValues, files: submissionSpecificFiles } = separateFilesFromValues(fieldValuesByAsset[assetId] ?? {});
5820
+ Object.assign(files, submissionSpecificFiles);
5821
+ const submissionPayload = offline({
5822
+ asset_id: assetId,
5823
+ form_data: fileSeperatedSubmissionSpecificValues
5824
+ });
5825
+ submissionPayloads.push(submissionPayload);
5826
+ for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
5827
+ for (const file of fileArray) {
5828
+ const sha1 = await hashFile(file);
5829
+ await this.client.files.addCache(file, sha1);
5830
+ const attachmentPayload = offline({
5831
+ submission_id: submissionPayload.offline_id,
5832
+ sha1,
5833
+ name: file.name,
5834
+ field_identifier: fieldIdentifier
5835
+ });
5836
+ attachmentPayloads.push(attachmentPayload);
5837
+ }
5838
+ }
5839
+ }
5840
+ const filePaylods = [];
5841
+ for (const file of Object.values(files).flat()) {
5842
+ const sha1 = await hashFile(file);
5843
+ const filePayload = {
5844
+ sha1,
5845
+ extension: file.name.split(".").pop() || "",
5846
+ file_type: file.type,
5847
+ size: file.size
5848
+ };
5849
+ filePaylods.push(filePayload);
5850
+ }
5851
+ return {
5852
+ batchId,
5853
+ payload: {
5854
+ transaction_id: transactionId,
5855
+ form_data: fileSeperatedCommonFieldValues,
5856
+ submitted_at: submittedAt,
5857
+ submissions: submissionPayloads,
5858
+ attachments: attachmentPayloads,
5859
+ files: filePaylods
5860
+ }
5861
+ };
5862
+ })
5863
+ );
5864
+ const batchPromises = [];
5865
+ let prevBatchId = null;
5866
+ for (const batch of bulkAddBatches) {
5867
+ const { payload, batchId } = batch;
5868
+ const batchAssetIds = payload.submissions.map((x) => x.asset_id);
5869
+ const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
5870
+ const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
5871
+ const blockers = batchAssetIds;
5872
+ if (prevBatchId)
5873
+ blockers.push(prevBatchId);
5874
+ const blocks2 = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
5875
+ const promise = this.enqueueRequest({
5876
+ description: "Bulk add form submissions",
5877
+ method: HttpMethod.POST,
5878
+ url: `/forms/revisions/${formRevision}/bulk-respond/`,
5879
+ payload,
5880
+ blockers,
5881
+ blocks: blocks2
5882
+ });
5883
+ void promise.then(({ presigned_urls }) => {
5884
+ this.processPresignedUrls(presigned_urls);
5885
+ });
5886
+ prevBatchId = batchId;
5887
+ batchPromises.push(promise);
5888
+ }
5889
+ void Promise.all(batchPromises).then((results) => {
5890
+ const createdSubmissions = [];
5891
+ const createdAttachments = [];
5892
+ for (const result of results) {
5893
+ for (const createdSubmission of result.submissions)
5894
+ createdSubmissions.push(createdSubmission);
5895
+ for (const createdAttachment of result.attachments)
5896
+ createdAttachments.push(createdAttachment);
5897
+ }
5898
+ this.dispatch(addFormSubmissions(createdSubmissions));
5899
+ this.dispatch(addFormSubmissionAttachments(createdAttachments));
5900
+ });
5901
+ return batchPromises;
5902
+ }
5903
+ async update(payload) {
5827
5904
  const { store } = this.client;
5828
5905
  const state = store.getState();
5829
5906
  const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
5830
5907
  if (!submissionToBeUpdated) {
5831
5908
  throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
5832
5909
  }
5833
- const { values } = separateFilesFromValues(payload.values ?? {});
5910
+ const { values, files } = separateFilesFromValues(payload.values ?? {});
5834
5911
  const updatedSubmission = {
5835
5912
  ...submissionToBeUpdated,
5836
5913
  ...payload,
@@ -5844,36 +5921,57 @@ var __publicField = (obj, key, value) => {
5844
5921
  const promise = this.enqueueRequest({
5845
5922
  description: "Delete user form submissions",
5846
5923
  method: HttpMethod.PATCH,
5847
- url: `/form-submissions/${updatedSubmission.offline_id}/`,
5924
+ url: `/forms/submissions/${updatedSubmission.offline_id}/`,
5848
5925
  // TODO: send just payload when FormSubmissionDeserializer is updated to handle partial updates
5849
5926
  payload: updatedSubmission,
5850
5927
  blockers: [updatedSubmission.offline_id],
5851
5928
  blocks: [updatedSubmission.offline_id]
5852
5929
  });
5930
+ const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
5931
+ const formSubmissionAttachmentIdsToBeDeleted = [];
5932
+ for (const attachment of formSubmissionAttachments) {
5933
+ if (attachment.field_identifier in files) {
5934
+ formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
5935
+ }
5936
+ }
5937
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5938
+ payload.offline_id,
5939
+ files
5940
+ );
5941
+ const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
5942
+ payload.offline_id,
5943
+ formSubmissionAttachmentIdsToBeDeleted
5944
+ );
5853
5945
  promise.then((result) => {
5854
5946
  this.dispatch(setFormSubmission(result));
5855
5947
  }).catch(() => {
5856
5948
  this.dispatch(setFormSubmission(submissionToBeUpdated));
5857
5949
  });
5858
- return [updatedSubmission, promise];
5950
+ return [
5951
+ updatedSubmission,
5952
+ offlineFormSubmissionAttachments,
5953
+ promise,
5954
+ attachmentsPromise,
5955
+ deleteAttachmentsPromise
5956
+ ];
5859
5957
  }
5860
- async delete(id) {
5958
+ async delete(submissionId) {
5861
5959
  const { store } = this.client;
5862
5960
  const state = store.getState();
5863
- const submissionToBeDeleted = selectFormSubmissionById(id)(state);
5961
+ const submissionToBeDeleted = selectFormSubmissionById(submissionId)(state);
5864
5962
  if (!submissionToBeDeleted) {
5865
- throw new Error(`Expected submission with offline_id ${id} to exist`);
5963
+ throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
5866
5964
  }
5867
- const submissionAttachments = selectAttachmentsOfFormSubmission(id)(state);
5868
- this.dispatch(deleteFormSubmission(id));
5965
+ const submissionAttachments = selectAttachmentsOfFormSubmission(submissionId)(state);
5966
+ this.dispatch(deleteFormSubmission(submissionId));
5869
5967
  this.dispatch(addActiveProjectFormSubmissionsCount(-1));
5870
5968
  this.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
5871
5969
  try {
5872
5970
  return await this.enqueueRequest({
5873
5971
  description: "Delete user form submissions",
5874
5972
  method: HttpMethod.DELETE,
5875
- url: `/form-submissions/${id}/`,
5876
- blockers: [id],
5973
+ url: `/forms/submissions/${submissionId}/`,
5974
+ blockers: [submissionId],
5877
5975
  blocks: []
5878
5976
  });
5879
5977
  } catch (e) {
@@ -5884,17 +5982,50 @@ var __publicField = (obj, key, value) => {
5884
5982
  }
5885
5983
  }
5886
5984
  async refreshStore(projectId) {
5887
- const result = await this.enqueueRequest({
5888
- description: "Fetch form submissions",
5985
+ const formSubmissions = {};
5986
+ const modelSubmissions = await this.enqueueRequest({
5987
+ description: "Fetch model submissions",
5889
5988
  method: HttpMethod.GET,
5890
- url: "/form-submissions/",
5891
- queryParams: {
5892
- project: projectId.toString()
5893
- },
5989
+ url: `/forms/in-project/${projectId}/submissions/model/latest/`,
5990
+ blockers: [],
5991
+ blocks: []
5992
+ });
5993
+ for (const modelSubmission of modelSubmissions) {
5994
+ formSubmissions[modelSubmission.offline_id] = modelSubmission;
5995
+ }
5996
+ const standaloneSubmissions = await this.enqueueRequest({
5997
+ description: "Fetch standalone submissions",
5998
+ method: HttpMethod.GET,
5999
+ url: `/forms/in-project/${projectId}/submissions/standalone/`,
6000
+ blockers: [],
6001
+ blocks: []
6002
+ });
6003
+ for (const standaloneSubmission of standaloneSubmissions) {
6004
+ formSubmissions[standaloneSubmission.offline_id] = standaloneSubmission;
6005
+ }
6006
+ this.dispatch(initializeFormSubmissions(Object.values(formSubmissions)));
6007
+ const attachments = {};
6008
+ const modelAttachments = await this.enqueueRequest({
6009
+ description: "Fetch model submission attachments",
6010
+ method: HttpMethod.GET,
6011
+ url: `/forms/in-project/${projectId}/attachments/model/latest/`,
6012
+ blockers: [],
6013
+ blocks: []
6014
+ });
6015
+ for (const modelAttachment of modelAttachments) {
6016
+ attachments[modelAttachment.offline_id] = modelAttachment;
6017
+ }
6018
+ const standaloneAttachments = await this.enqueueRequest({
6019
+ description: "Fetch standalone submission attachments",
6020
+ method: HttpMethod.GET,
6021
+ url: `/forms/in-project/${projectId}/attachments/standalone/`,
5894
6022
  blockers: [],
5895
6023
  blocks: []
5896
6024
  });
5897
- this.dispatch(initializeFormSubmissions(result));
6025
+ for (const standaloneAttachent of standaloneAttachments) {
6026
+ attachments[standaloneAttachent.offline_id] = standaloneAttachent;
6027
+ }
6028
+ this.dispatch(initializeFormSubmissionAttachments(Object.values(attachments)));
5898
6029
  }
5899
6030
  }
5900
6031
  class WorkspaceService extends BaseApiService {
@@ -5946,22 +6077,22 @@ var __publicField = (obj, key, value) => {
5946
6077
  });
5947
6078
  return [workspace, promise];
5948
6079
  }
5949
- delete(id) {
6080
+ delete(workspaceId) {
5950
6081
  const { store } = this.client;
5951
- const originalWorkspace = selectWorkspaceById(id)(store.getState());
5952
- if (!originalWorkspace) {
5953
- throw new Error(`Expected an existing workspace with id ${id}`);
5954
- }
5955
- this.dispatch(deleteWorkspace(id));
6082
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6083
+ this.dispatch(deleteWorkspace(workspaceId));
5956
6084
  const promise = this.enqueueRequest({
5957
6085
  description: "Delete Workspace",
5958
6086
  method: HttpMethod.DELETE,
5959
- url: `/workspaces/${id}/`,
5960
- blockers: [id],
6087
+ url: `/workspaces/${workspaceId}/`,
6088
+ blockers: [workspaceId],
5961
6089
  blocks: []
5962
6090
  });
5963
- void promise.catch((reason) => {
5964
- this.dispatch(addWorkspace(originalWorkspace));
6091
+ void promise.then(() => {
6092
+ }).catch((reason) => {
6093
+ if (originalWorkspace) {
6094
+ this.dispatch(addWorkspace(originalWorkspace));
6095
+ }
5965
6096
  throw reason;
5966
6097
  });
5967
6098
  return promise;
@@ -6596,8 +6727,8 @@ var __publicField = (obj, key, value) => {
6596
6727
  class DocumentAttachmentService extends BaseAttachmentService {
6597
6728
  constructor() {
6598
6729
  super(...arguments);
6599
- __publicField(this, "name", "Document Attachment");
6600
- __publicField(this, "url", "/document-attachments");
6730
+ __publicField(this, "attachmentModel", AttachmentModel.Document);
6731
+ __publicField(this, "initializeAttachments", initializeDocumentAttachments);
6601
6732
  __publicField(this, "addAttachments", addDocumentAttachments);
6602
6733
  __publicField(this, "updateAttachments", updateDocumentAttachments);
6603
6734
  __publicField(this, "removeAttachments", deleteDocumentAttachments);
@@ -6608,23 +6739,17 @@ var __publicField = (obj, key, value) => {
6608
6739
  buildOfflineAttachment(data) {
6609
6740
  return offline({
6610
6741
  file: URL.createObjectURL(data.file),
6611
- file_sha1: data.file_sha1,
6612
- created_by: data.created_by,
6742
+ file_sha1: data.sha1,
6743
+ created_by: data.createdBy,
6613
6744
  file_name: data.file.name,
6614
6745
  file_type: data.file.type,
6615
- submitted_at: data.submitted_at,
6746
+ submitted_at: data.submittedAt,
6616
6747
  description: data.description,
6617
6748
  document: data.modelId
6618
6749
  });
6619
6750
  }
6620
- buildAttachmentPayload(data) {
6621
- return {
6622
- ...data,
6623
- document: data.modelId
6624
- };
6625
- }
6626
6751
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6627
- async bulkAdd(payloads) {
6752
+ async attachFilesToDocument(files, documentId) {
6628
6753
  var _a2;
6629
6754
  const { store } = this.client;
6630
6755
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -6633,36 +6758,40 @@ var __publicField = (obj, key, value) => {
6633
6758
  const attachmentPayloads = [];
6634
6759
  const filePayloads = {};
6635
6760
  const sha1ToAttachmentIds = {};
6636
- for (const payload of payloads) {
6637
- const { documentId, file } = payload;
6638
- const filePayload = await this.getFilePayload(file);
6639
- if (!(filePayload.sha1 in filePayloads)) {
6640
- filePayloads[filePayload.sha1] = filePayload;
6641
- sha1ToAttachmentIds[filePayload.sha1] = [];
6761
+ for (const file of files) {
6762
+ const sha1 = await hashFile(file);
6763
+ if (!(sha1 in filePayloads)) {
6764
+ filePayloads[sha1] = {
6765
+ sha1,
6766
+ file_type: file.type,
6767
+ extension: file.name.split(".").pop(),
6768
+ size: file.size
6769
+ };
6770
+ sha1ToAttachmentIds[sha1] = [];
6771
+ await this.client.files.addCache(file, sha1);
6642
6772
  }
6643
6773
  const offlineAttachment = this.buildOfflineAttachment({
6644
6774
  file,
6645
- file_sha1: filePayload.sha1,
6646
- submitted_at: submittedAt,
6647
- created_by: createdBy,
6775
+ sha1,
6776
+ submittedAt,
6777
+ createdBy,
6648
6778
  description: "",
6649
6779
  modelId: documentId
6650
6780
  });
6651
6781
  offlineAttachments.push(offlineAttachment);
6652
6782
  attachmentPayloads.push({
6653
6783
  offline_id: offlineAttachment.offline_id,
6654
- file_name: offlineAttachment.file_name,
6655
- file_sha1: offlineAttachment.file_sha1,
6656
- file_extension: filePayload.extension,
6784
+ name: offlineAttachment.file_name,
6785
+ sha1: offlineAttachment.file_sha1,
6657
6786
  description: offlineAttachment.description
6658
6787
  });
6659
- sha1ToAttachmentIds[filePayload.sha1].push(offlineAttachment.offline_id);
6788
+ sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
6660
6789
  }
6661
6790
  this.dispatch(this.addAttachments(offlineAttachments));
6662
6791
  const promise = this.enqueueRequest({
6663
6792
  description: "Attach files to document",
6664
6793
  method: HttpMethod.POST,
6665
- url: "/document-attachments/bulk/",
6794
+ url: `/documents/${documentId}/attach/`,
6666
6795
  payload: {
6667
6796
  submitted_at: submittedAt,
6668
6797
  attachments: attachmentPayloads,
@@ -6687,14 +6816,14 @@ var __publicField = (obj, key, value) => {
6687
6816
  });
6688
6817
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
6689
6818
  }
6690
- async delete(id) {
6691
- return this._delete(id);
6819
+ async deleteDocumentAttachment(attachmentId) {
6820
+ return this.deleteAttachment(attachmentId);
6692
6821
  }
6693
6822
  makeReadable(attachmnentId) {
6694
6823
  void this.enqueueRequest({
6695
6824
  description: "Add attachment to AI assistant",
6696
6825
  method: HttpMethod.PATCH,
6697
- url: `/document-attachments/${attachmnentId}/`,
6826
+ url: `/documents/attachments/${attachmnentId}/`,
6698
6827
  payload: {
6699
6828
  readable_to_assistant: true
6700
6829
  },
@@ -6711,7 +6840,7 @@ var __publicField = (obj, key, value) => {
6711
6840
  blocks: [],
6712
6841
  blockers: []
6713
6842
  });
6714
- this.dispatch(initializeDocumentAttachments(projectDocumentAttachments));
6843
+ this.dispatch(this.initializeAttachments(projectDocumentAttachments));
6715
6844
  const organizationDocumentAttachments = await this.enqueueRequest({
6716
6845
  description: "Get document attachments",
6717
6846
  method: HttpMethod.GET,
@@ -6846,21 +6975,21 @@ var __publicField = (obj, key, value) => {
6846
6975
  });
6847
6976
  return [offlineUpdatedTeam, promise];
6848
6977
  }
6849
- async delete(id) {
6978
+ async delete(teamId) {
6850
6979
  const { store } = this.client;
6851
6980
  const state = store.getState();
6852
- const team = selectTeamById(id)(state);
6981
+ const team = selectTeamById(teamId)(state);
6853
6982
  if (!team) {
6854
- throw new Error(`Expected team with id ${id} to exist`);
6983
+ throw new Error(`Expected team with id ${teamId} to exist`);
6855
6984
  }
6856
- this.dispatch(deleteTeam(id));
6985
+ this.dispatch(deleteTeam(teamId));
6857
6986
  try {
6858
6987
  return await this.enqueueRequest({
6859
6988
  description: "Delete team",
6860
6989
  method: HttpMethod.DELETE,
6861
- url: `/organizations/teams/${id}/`,
6862
- blockers: [id],
6863
- blocks: [id]
6990
+ url: `/organizations/teams/${teamId}/`,
6991
+ blockers: [teamId],
6992
+ blocks: [teamId]
6864
6993
  });
6865
6994
  } catch (e) {
6866
6995
  this.dispatch(setTeam(team));
@@ -6955,11 +7084,17 @@ var __publicField = (obj, key, value) => {
6955
7084
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6956
7085
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6957
7086
  const projectId = payloadWithoutFile.project;
6958
- const filePayload = await this.getFilePayload(file);
7087
+ const sha1 = await hashFile(file);
7088
+ const filePayload = {
7089
+ sha1,
7090
+ file_type: file.type,
7091
+ extension: file.name.split(".").pop(),
7092
+ size: file.size
7093
+ };
6959
7094
  const offlineMapImage = offline({
6960
7095
  ...payloadWithoutFile,
6961
7096
  file_name: file.name,
6962
- file_sha1: filePayload.sha1,
7097
+ file_sha1: sha1,
6963
7098
  file: URL.createObjectURL(file),
6964
7099
  submitted_at: submittedAt,
6965
7100
  created_by: createdBy
@@ -7002,16 +7137,23 @@ var __publicField = (obj, key, value) => {
7002
7137
  const offlineGeoImages = [];
7003
7138
  const offlineIds = [];
7004
7139
  const geoImagePayloads = [];
7005
- const filePayloads = {};
7140
+ const filePayloadRecord = {};
7006
7141
  for (const payloadAndFile of payloads) {
7007
7142
  const { file, ...payload } = payloadAndFile;
7008
- const filePayload = await this.getFilePayload(file);
7009
- if (!(filePayload.sha1 in filePayloads))
7010
- filePayloads[filePayload.sha1] = filePayload;
7143
+ const sha1 = await hashFile(file);
7144
+ if (!(sha1 in filePayloadRecord)) {
7145
+ filePayloadRecord[sha1] = {
7146
+ sha1,
7147
+ file_type: file.type,
7148
+ extension: file.name.split(".").pop(),
7149
+ size: file.size
7150
+ };
7151
+ await this.client.files.addCache(file, sha1);
7152
+ }
7011
7153
  const offlineMapImage = offline({
7012
7154
  ...payload,
7013
7155
  file_name: file.name,
7014
- file_sha1: filePayload.sha1,
7156
+ file_sha1: sha1,
7015
7157
  file: URL.createObjectURL(file),
7016
7158
  submitted_at: submittedAt,
7017
7159
  created_by: createdBy,
@@ -7040,7 +7182,7 @@ var __publicField = (obj, key, value) => {
7040
7182
  submitted_at: submittedAt,
7041
7183
  project: projectId,
7042
7184
  geo_images: geoImagePayloads,
7043
- files: Object.values(filePayloads)
7185
+ files: Object.values(filePayloadRecord)
7044
7186
  },
7045
7187
  blocks: [projectId.toString()],
7046
7188
  blockers: offlineIds
@@ -7077,20 +7219,20 @@ var __publicField = (obj, key, value) => {
7077
7219
  });
7078
7220
  return [updatedGeoImage, promise];
7079
7221
  }
7080
- async delete(id) {
7222
+ async delete(geoImageId) {
7081
7223
  const { store } = this.client;
7082
7224
  const state = store.getState();
7083
- const geoImageToDelete = selectGeoImageById(id)(state);
7225
+ const geoImageToDelete = selectGeoImageById(geoImageId)(state);
7084
7226
  if (!geoImageToDelete) {
7085
- throw new Error(`Map image with offline_id ${id} does not exist in the store`);
7227
+ throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7086
7228
  }
7087
- this.dispatch(deleteGeoImage(id));
7229
+ this.dispatch(deleteGeoImage(geoImageId));
7088
7230
  const promise = this.enqueueRequest({
7089
7231
  description: "Delete geo image",
7090
7232
  method: HttpMethod.DELETE,
7091
- url: `/geo-images/${id}/`,
7092
- blocks: [id],
7093
- blockers: [id]
7233
+ url: `/geo-images/${geoImageId}/`,
7234
+ blocks: [geoImageId],
7235
+ blockers: [geoImageId]
7094
7236
  });
7095
7237
  promise.catch(() => {
7096
7238
  this.dispatch(setGeoImage(geoImageToDelete));
@@ -7108,7 +7250,7 @@ var __publicField = (obj, key, value) => {
7108
7250
  this.dispatch(initializeGeoImages(result));
7109
7251
  }
7110
7252
  }
7111
- class IssueAssociationService extends BaseApiService {
7253
+ class IssueAssociationService extends BaseUploadService {
7112
7254
  add(payload) {
7113
7255
  var _a2;
7114
7256
  const { store } = this.client;
@@ -7123,7 +7265,7 @@ var __publicField = (obj, key, value) => {
7123
7265
  const promise = this.enqueueRequest({
7124
7266
  description: "Add issue association",
7125
7267
  method: HttpMethod.POST,
7126
- url: "/issue-associations/",
7268
+ url: "/issues/associations/",
7127
7269
  payload: {
7128
7270
  offline_id: offlineIssueAssociation.offline_id,
7129
7271
  submitted_at: submittedAt,
@@ -7153,7 +7295,7 @@ var __publicField = (obj, key, value) => {
7153
7295
  const promise = this.enqueueRequest({
7154
7296
  description: "Delete issue association",
7155
7297
  method: HttpMethod.DELETE,
7156
- url: `/issue-associations/${id}/`,
7298
+ url: `/issues/associations/${id}/`,
7157
7299
  blockers: [id],
7158
7300
  blocks: []
7159
7301
  });
@@ -7166,938 +7308,14 @@ var __publicField = (obj, key, value) => {
7166
7308
  const issueAssociations = await this.enqueueRequest({
7167
7309
  description: "Fetch issue associations",
7168
7310
  method: HttpMethod.GET,
7169
- url: "/issue-associations/",
7170
- queryParams: { project: projectId.toString() },
7311
+ url: "/issues/associations/",
7312
+ queryParams: { project_id: projectId.toString() },
7171
7313
  blockers: [],
7172
7314
  blocks: []
7173
7315
  });
7174
7316
  this.dispatch(initializeIssueAssociations(issueAssociations));
7175
7317
  }
7176
7318
  }
7177
- class FormRevisionAttachmentService extends BaseUploadService {
7178
- async bulkAdd(payloads) {
7179
- var _a2;
7180
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7181
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7182
- const filePayloads = {};
7183
- const offlineFormRevisionAttachments = [];
7184
- const attachmentPayloads = [];
7185
- for (const payload of payloads) {
7186
- const { revisionId, fieldIdentifier, file } = payload;
7187
- const filePayload = await this.getFilePayload(file);
7188
- if (!(filePayload.sha1 in filePayloads))
7189
- filePayloads[filePayload.sha1] = filePayload;
7190
- const offlineFormRevisionAttachment = offline({
7191
- file: URL.createObjectURL(file),
7192
- file_type: file.type,
7193
- file_name: file.name,
7194
- file_sha1: filePayload.sha1,
7195
- created_by: createdBy,
7196
- form_revision: revisionId,
7197
- submitted_at: submittedAt,
7198
- field_identifier: fieldIdentifier
7199
- });
7200
- offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
7201
- const attachmentPayload = {
7202
- offline_id: offlineFormRevisionAttachment.offline_id,
7203
- file_name: file.name,
7204
- field_identifier: fieldIdentifier,
7205
- file_extension: filePayload.extension,
7206
- file_sha1: filePayload.sha1,
7207
- form_revision: revisionId
7208
- };
7209
- attachmentPayloads.push(attachmentPayload);
7210
- }
7211
- this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
7212
- const promise = this.enqueueRequest({
7213
- description: "Attach files to form revision",
7214
- method: HttpMethod.POST,
7215
- url: "/form-revision-attachments/bulk/",
7216
- payload: {
7217
- submitted_at: submittedAt,
7218
- attachments: attachmentPayloads,
7219
- files: Object.values(filePayloads)
7220
- },
7221
- blockers: offlineFormRevisionAttachments.map((attachment) => attachment.form_revision),
7222
- blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
7223
- });
7224
- promise.then((result) => {
7225
- this.processPresignedUrls(result.presigned_urls);
7226
- this.dispatch(updateFormRevisionAttachments(result.attachments));
7227
- }).catch(() => {
7228
- this.dispatch(
7229
- deleteFormRevisionAttachments(
7230
- offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
7231
- )
7232
- );
7233
- });
7234
- return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
7235
- }
7236
- async refreshStore(projectId, organizationId) {
7237
- let attachments = [];
7238
- const projectFormRevisions = await this.enqueueRequest({
7239
- description: "Fetch project form revision attachments",
7240
- method: HttpMethod.GET,
7241
- url: "/form-revision-attachments/",
7242
- queryParams: {
7243
- project: projectId.toString()
7244
- },
7245
- blockers: [projectId.toString()],
7246
- blocks: []
7247
- });
7248
- attachments = attachments.concat(projectFormRevisions);
7249
- const organizationFormRevisions = await this.enqueueRequest({
7250
- description: "Fetch organization form revision attachments",
7251
- method: HttpMethod.GET,
7252
- url: "/form-revision-attachments/",
7253
- queryParams: {
7254
- organization: organizationId.toString()
7255
- },
7256
- blockers: [organizationId.toString()],
7257
- blocks: []
7258
- });
7259
- attachments = attachments.concat(organizationFormRevisions);
7260
- this.dispatch(initializeFormRevisionAttachments(attachments));
7261
- }
7262
- }
7263
- class FormSubmissionAttachmentService extends BaseUploadService {
7264
- async bulkAdd(payloads) {
7265
- var _a2;
7266
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7267
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7268
- const filePayloads = {};
7269
- const offlineFormSubmissionAttachments = [];
7270
- const attachmentPayloads = [];
7271
- for (const payload of payloads) {
7272
- const { submissionId, fieldIdentifier, file } = payload;
7273
- const filePayload = await this.getFilePayload(file);
7274
- if (!(filePayload.sha1 in filePayloads))
7275
- filePayloads[filePayload.sha1] = filePayload;
7276
- const offlineFormSubmissionAttachment = offline({
7277
- file: URL.createObjectURL(file),
7278
- file_type: file.type,
7279
- file_name: file.name,
7280
- file_sha1: filePayload.sha1,
7281
- created_by: createdBy,
7282
- form_submission: submissionId,
7283
- submitted_at: submittedAt,
7284
- field_identifier: fieldIdentifier
7285
- });
7286
- offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
7287
- const attachmentPayload = {
7288
- offline_id: offlineFormSubmissionAttachment.offline_id,
7289
- file_name: file.name,
7290
- file_sha1: filePayload.sha1,
7291
- file_extension: filePayload.extension,
7292
- field_identifier: fieldIdentifier,
7293
- form_submission: submissionId
7294
- };
7295
- attachmentPayloads.push(attachmentPayload);
7296
- }
7297
- this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
7298
- const promise = this.enqueueRequest({
7299
- description: "Attach files to form submission",
7300
- method: HttpMethod.POST,
7301
- url: "/form-submission-attachments/bulk/",
7302
- payload: {
7303
- submitted_at: submittedAt,
7304
- attachments: attachmentPayloads,
7305
- files: Object.values(filePayloads)
7306
- },
7307
- blockers: offlineFormSubmissionAttachments.map((attachment) => attachment.form_submission),
7308
- blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
7309
- });
7310
- promise.then((result) => {
7311
- this.processPresignedUrls(result.presigned_urls);
7312
- this.dispatch(updateFormSubmissionAttachments(result.attachments));
7313
- }).catch((error) => {
7314
- this.dispatch(
7315
- deleteFormSubmissionAttachments(
7316
- offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
7317
- )
7318
- );
7319
- throw error;
7320
- });
7321
- return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
7322
- }
7323
- async bulkDelete(attachmentsIds) {
7324
- const { store } = this.client;
7325
- const state = store.getState();
7326
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
7327
- this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
7328
- try {
7329
- await this.enqueueRequest({
7330
- description: "Delete form submission attachments",
7331
- method: HttpMethod.DELETE,
7332
- url: "/form-submission-attachments/bulk/",
7333
- payload: { attachment_ids: attachmentsIds },
7334
- blockers: attachmentsIds,
7335
- blocks: []
7336
- });
7337
- } catch (e) {
7338
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7339
- throw e;
7340
- }
7341
- }
7342
- async refreshStore(projectId) {
7343
- const result = await this.enqueueRequest({
7344
- description: "Get form submission attachments",
7345
- method: HttpMethod.GET,
7346
- url: "/form-submission-attachments/",
7347
- queryParams: {
7348
- project: projectId.toString()
7349
- },
7350
- blockers: [],
7351
- blocks: []
7352
- });
7353
- this.dispatch(initializeFormSubmissionAttachments(result));
7354
- }
7355
- }
7356
- class FormRevisionService extends BaseUploadService {
7357
- add(payload) {
7358
- var _a2;
7359
- const { store } = this.client;
7360
- const state = store.getState();
7361
- const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
7362
- const offlineFormRevision = offline({
7363
- ...payload,
7364
- created_by: createdBy,
7365
- revision: "Pending",
7366
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7367
- });
7368
- this.dispatch(addFormRevision(offlineFormRevision));
7369
- const promise = this.enqueueRequest({
7370
- description: "Create form revision",
7371
- method: HttpMethod.POST,
7372
- url: "/form-revisions/",
7373
- payload: offlineFormRevision,
7374
- blockers: [payload.form],
7375
- blocks: [offlineFormRevision.offline_id]
7376
- });
7377
- void promise.then((result) => {
7378
- this.dispatch(setFormRevision(result));
7379
- }).catch(() => {
7380
- this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
7381
- });
7382
- return [offlineFormRevision, promise];
7383
- }
7384
- async refreshStore(projectId, organizationId) {
7385
- let formRevisions = [];
7386
- const projectFormRevisions = await this.enqueueRequest({
7387
- description: "Fetch project form revisions",
7388
- method: HttpMethod.GET,
7389
- url: "/form-revisions/",
7390
- queryParams: {
7391
- project: projectId.toString()
7392
- },
7393
- blockers: [projectId.toString()],
7394
- blocks: []
7395
- });
7396
- formRevisions = formRevisions.concat(projectFormRevisions);
7397
- const organizationFormRevisions = await this.enqueueRequest({
7398
- description: "Fetch organization form revisions",
7399
- method: HttpMethod.GET,
7400
- url: "/form-revisions/",
7401
- queryParams: {
7402
- organization: organizationId.toString()
7403
- },
7404
- blockers: [organizationId.toString()],
7405
- blocks: []
7406
- });
7407
- formRevisions = formRevisions.concat(organizationFormRevisions);
7408
- this.dispatch(initializeFormRevisions(formRevisions));
7409
- }
7410
- }
7411
- class AssetTypeFieldsAttachmentService extends BaseUploadService {
7412
- async bulkAdd(payloads) {
7413
- var _a2;
7414
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7415
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7416
- const filePayloads = {};
7417
- const offlineAssetTypeFieldsAttachments = [];
7418
- const attachmentPayloads = [];
7419
- for (const payload of payloads) {
7420
- const { fieldsRevisionId, fieldIdentifier, file } = payload;
7421
- const filePayload = await this.getFilePayload(file);
7422
- if (!(filePayload.sha1 in filePayloads))
7423
- filePayloads[filePayload.sha1] = filePayload;
7424
- const offlineAssetTypeFieldsAttachment = offline({
7425
- file: URL.createObjectURL(file),
7426
- file_type: file.type,
7427
- file_name: file.name,
7428
- file_sha1: filePayload.sha1,
7429
- created_by: createdBy,
7430
- fields_revision: fieldsRevisionId,
7431
- submitted_at: submittedAt,
7432
- field_identifier: fieldIdentifier
7433
- });
7434
- offlineAssetTypeFieldsAttachments.push(offlineAssetTypeFieldsAttachment);
7435
- const attachmentPayload = {
7436
- offline_id: offlineAssetTypeFieldsAttachment.offline_id,
7437
- file_name: file.name,
7438
- field_identifier: fieldIdentifier,
7439
- file_extension: filePayload.extension,
7440
- file_sha1: filePayload.sha1,
7441
- fields_revision: fieldsRevisionId
7442
- };
7443
- attachmentPayloads.push(attachmentPayload);
7444
- }
7445
- this.dispatch(addAssetTypeFieldsAttachments(offlineAssetTypeFieldsAttachments));
7446
- const promise = this.enqueueRequest({
7447
- description: "Add asset type fields attachments",
7448
- method: HttpMethod.POST,
7449
- url: "/asset-type-fields-attachments/bulk/",
7450
- payload: {
7451
- submitted_at: submittedAt,
7452
- attachments: attachmentPayloads,
7453
- files: Object.values(filePayloads)
7454
- },
7455
- blockers: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7456
- blocks: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7457
- });
7458
- promise.then((result) => {
7459
- this.processPresignedUrls(result.presigned_urls);
7460
- this.dispatch(updateAssetTypeFieldsAttachments(result.attachments));
7461
- }).catch(() => {
7462
- this.dispatch(
7463
- deleteAssetTypeFieldsAttachments(
7464
- offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7465
- )
7466
- );
7467
- });
7468
- return [offlineAssetTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7469
- }
7470
- async refreshStore(projectId) {
7471
- const result = await this.enqueueRequest({
7472
- description: "get asset type fields attachments",
7473
- method: HttpMethod.GET,
7474
- url: "/asset-type-fields-attachments/",
7475
- queryParams: {
7476
- project: projectId.toString()
7477
- },
7478
- blockers: [projectId.toString()],
7479
- blocks: []
7480
- });
7481
- this.dispatch(initializeAssetTypeFieldsAttachments(result));
7482
- }
7483
- }
7484
- class AssetTypeFieldsService extends BaseApiService {
7485
- add(payload) {
7486
- var _a2;
7487
- const { store } = this.client;
7488
- const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7489
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7490
- const offlineAssetTypeFields = offline({
7491
- ...payload,
7492
- created_by: createdBy,
7493
- submitted_at: submittedAt
7494
- });
7495
- this.dispatch(addAssetTypeFields(offlineAssetTypeFields));
7496
- const promise = this.enqueueRequest({
7497
- description: "Add Asset Type Fields",
7498
- method: HttpMethod.POST,
7499
- url: "/asset-type-fields/",
7500
- payload: offlineAssetTypeFields,
7501
- blockers: [offlineAssetTypeFields.asset_type],
7502
- blocks: [offlineAssetTypeFields.offline_id]
7503
- });
7504
- promise.then((response) => {
7505
- this.dispatch(updateAssetTypeFields(response));
7506
- }).catch((error) => {
7507
- this.dispatch(deleteAssetTypeFields(offlineAssetTypeFields.offline_id));
7508
- throw error;
7509
- });
7510
- return [offlineAssetTypeFields, promise];
7511
- }
7512
- async refreshStore(projectId) {
7513
- const result = await this.enqueueRequest({
7514
- description: "Get Asset Type Fields",
7515
- method: HttpMethod.GET,
7516
- url: "/asset-type-fields/",
7517
- queryParams: {
7518
- project: projectId.toString()
7519
- },
7520
- blockers: [],
7521
- blocks: []
7522
- });
7523
- this.dispatch(initializeAssetTypeFields(result));
7524
- }
7525
- }
7526
- class AssetTypeFieldValuesService extends BaseApiService {
7527
- add(payload) {
7528
- var _a2;
7529
- const { store } = this.client;
7530
- const state = store.getState();
7531
- const { values } = separateFilesFromValues(payload.values);
7532
- const offlineAssetTypeFieldValues = offline({
7533
- ...payload,
7534
- values,
7535
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
7536
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7537
- });
7538
- const promise = this.enqueueRequest({
7539
- description: "Add asset type field values",
7540
- method: HttpMethod.POST,
7541
- url: "/asset-type-field-values/",
7542
- payload: offlineAssetTypeFieldValues,
7543
- blockers: [payload.asset, payload.fields_revision],
7544
- blocks: [offlineAssetTypeFieldValues.offline_id]
7545
- });
7546
- this.dispatch(addAssetTypeFieldValues(offlineAssetTypeFieldValues));
7547
- promise.then((result) => {
7548
- this.dispatch(updateAssetTypeFieldValues(result));
7549
- return result;
7550
- }).catch(() => {
7551
- this.dispatch(deleteAssetTypeFieldValues(offlineAssetTypeFieldValues.offline_id));
7552
- });
7553
- return [offlineAssetTypeFieldValues, promise];
7554
- }
7555
- bulkAdd(payload, batchSize) {
7556
- var _a2;
7557
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7558
- const { values } = separateFilesFromValues(payload.values);
7559
- const offlineAssetTypeFieldValuesMany = [];
7560
- const batches = chunkArray(payload.payloads, batchSize ?? payload.payloads.length);
7561
- const batchPayloads = [];
7562
- for (const batch of batches) {
7563
- const assetTypeFieldValuesPayloads = [];
7564
- for (const payload2 of batch) {
7565
- const offlineAssetTypeFieldValues = offline({
7566
- ...payload2,
7567
- values: separateFilesFromValues(payload2.values).values,
7568
- created_by: (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
7569
- submitted_at: submittedAt
7570
- });
7571
- offlineAssetTypeFieldValuesMany.push(offlineAssetTypeFieldValues);
7572
- assetTypeFieldValuesPayloads.push({
7573
- offline_id: offlineAssetTypeFieldValues.offline_id,
7574
- asset: payload2.asset,
7575
- fields_revision: payload2.fields_revision,
7576
- published_at: payload2.published_at,
7577
- values: offlineAssetTypeFieldValues.values
7578
- });
7579
- }
7580
- batchPayloads.push({
7581
- submitted_at: submittedAt,
7582
- values,
7583
- field_values: assetTypeFieldValuesPayloads
7584
- });
7585
- }
7586
- this.dispatch(addAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany));
7587
- const promises = [];
7588
- for (const payload2 of batchPayloads) {
7589
- const assetIds = payload2.field_values.map((x) => x.asset);
7590
- const assetTypeFieldsIds = payload2.field_values.map((x) => x.fields_revision);
7591
- const assetTypeFieldValuesIds = payload2.field_values.map((x) => x.offline_id);
7592
- const promise = this.enqueueRequest({
7593
- description: "Bulk add asset type field values",
7594
- method: HttpMethod.POST,
7595
- url: "/asset-type-field-values/bulk/",
7596
- payload: payload2,
7597
- blockers: [...assetIds, ...assetTypeFieldsIds],
7598
- blocks: assetTypeFieldValuesIds
7599
- });
7600
- promises.push(promise);
7601
- }
7602
- void Promise.all(promises).then((results) => {
7603
- this.dispatch(updateAssetTypeFieldValuesMany(results.flat()));
7604
- }).catch(() => {
7605
- this.dispatch(deleteAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany.map((x) => x.offline_id)));
7606
- });
7607
- return [offlineAssetTypeFieldValuesMany, promises];
7608
- }
7609
- update(payload) {
7610
- const { store } = this.client;
7611
- const state = store.getState();
7612
- const assetTypeFieldValues = selectAssetTypeFieldValuesById(payload.offline_id)(state);
7613
- if (!assetTypeFieldValues) {
7614
- throw new Error(`Expected AssetTypeFieldValues with offline_id ${payload.offline_id} to exist`);
7615
- }
7616
- const { values } = separateFilesFromValues(payload.values ?? {});
7617
- const updatedAssetTypeFieldValues = {
7618
- ...assetTypeFieldValues,
7619
- ...payload,
7620
- // values could also have a partial update
7621
- values: {
7622
- ...assetTypeFieldValues.values,
7623
- ...values
7624
- }
7625
- };
7626
- this.dispatch(updateAssetTypeFieldValues(updatedAssetTypeFieldValues));
7627
- const promise = this.enqueueRequest({
7628
- description: "Delete asset type field values",
7629
- method: HttpMethod.PATCH,
7630
- url: `/asset-type-field-values/${payload.offline_id}/`,
7631
- payload,
7632
- blockers: [
7633
- updatedAssetTypeFieldValues.offline_id,
7634
- updatedAssetTypeFieldValues.fields_revision,
7635
- updatedAssetTypeFieldValues.asset
7636
- ],
7637
- blocks: [updatedAssetTypeFieldValues.offline_id]
7638
- });
7639
- promise.then((result) => {
7640
- this.dispatch(updateAssetTypeFieldValues(result));
7641
- }).catch(() => {
7642
- this.dispatch(updateAssetTypeFieldValues(assetTypeFieldValues));
7643
- });
7644
- return [updatedAssetTypeFieldValues, promise];
7645
- }
7646
- async delete(id) {
7647
- const { store } = this.client;
7648
- const state = store.getState();
7649
- const assetTypeFieldValues = selectAssetTypeFieldValuesById(id)(state);
7650
- if (!assetTypeFieldValues) {
7651
- throw new Error(`Expected submission with offline_id ${id} to exist`);
7652
- }
7653
- const assetTypeFieldValuesAttachments = selectAttachmentsOfAssetTypeFieldValues(id)(state);
7654
- this.dispatch(deleteAssetTypeFieldValues(id));
7655
- this.dispatch(deleteAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments.map((x) => x.offline_id)));
7656
- try {
7657
- await this.enqueueRequest({
7658
- description: "Delete asset type field values",
7659
- method: HttpMethod.DELETE,
7660
- url: `/asset-type-field-values/${id}/`,
7661
- blockers: [id],
7662
- blocks: []
7663
- });
7664
- } catch (e) {
7665
- this.dispatch(addAssetTypeFieldValues(assetTypeFieldValues));
7666
- this.dispatch(addAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments));
7667
- throw e;
7668
- }
7669
- }
7670
- async refreshStore(projectId) {
7671
- const result = await this.enqueueRequest({
7672
- description: "Get asset type field values",
7673
- method: HttpMethod.GET,
7674
- url: "/asset-type-field-values/",
7675
- queryParams: {
7676
- project: projectId.toString()
7677
- },
7678
- blockers: [],
7679
- blocks: []
7680
- });
7681
- this.dispatch(initializeAssetTypeFieldValues(result));
7682
- }
7683
- }
7684
- class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
7685
- async bulkAdd(payloads, batchSize) {
7686
- var _a2;
7687
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7688
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7689
- const batches = chunkArray(payloads, batchSize ?? payloads.length);
7690
- const offlineAssetTypeFieldValuesAttachments = [];
7691
- const batchPayloads = [];
7692
- for (const batch of batches) {
7693
- const filePayloads = {};
7694
- const attachmentPayloads = [];
7695
- for (const payload of batch) {
7696
- const { fieldValuesId, fieldIdentifier, file } = payload;
7697
- const filePayload = await this.getFilePayload(file);
7698
- if (!(filePayload.sha1 in filePayloads))
7699
- filePayloads[filePayload.sha1] = filePayload;
7700
- const offlineAssetTypeFieldValuesAttachment = offline({
7701
- file: URL.createObjectURL(file),
7702
- file_type: file.type,
7703
- file_name: file.name,
7704
- file_sha1: filePayload.sha1,
7705
- created_by: createdBy,
7706
- field_values: fieldValuesId,
7707
- submitted_at: submittedAt,
7708
- field_identifier: fieldIdentifier
7709
- });
7710
- offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
7711
- const attachmentPayload = {
7712
- offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
7713
- file_name: file.name,
7714
- file_sha1: filePayload.sha1,
7715
- file_extension: filePayload.extension,
7716
- field_identifier: fieldIdentifier,
7717
- field_values: fieldValuesId
7718
- };
7719
- attachmentPayloads.push(attachmentPayload);
7720
- }
7721
- batchPayloads.push({
7722
- submitted_at: submittedAt,
7723
- attachments: attachmentPayloads,
7724
- files: Object.values(filePayloads)
7725
- });
7726
- }
7727
- this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
7728
- const promises = batchPayloads.map((payload) => {
7729
- return this.enqueueRequest({
7730
- description: "Add asset type field values attachments",
7731
- method: HttpMethod.POST,
7732
- url: "/asset-type-field-values-attachments/bulk/",
7733
- payload,
7734
- blockers: payload.attachments.map((payload2) => payload2.field_values),
7735
- blocks: payload.attachments.map((payload2) => payload2.offline_id)
7736
- });
7737
- });
7738
- Promise.all(promises).then((result) => {
7739
- for (const res of result)
7740
- this.processPresignedUrls(res.presigned_urls);
7741
- const attachments = result.flatMap((res) => res.attachments);
7742
- this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
7743
- }).catch((error) => {
7744
- this.dispatch(
7745
- deleteAssetTypeFieldValuesAttachments(
7746
- offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7747
- )
7748
- );
7749
- throw error;
7750
- });
7751
- return [
7752
- offlineAssetTypeFieldValuesAttachments,
7753
- promises.map((promise) => promise.then(({ attachments }) => attachments))
7754
- ];
7755
- }
7756
- async bulkDelete(ids) {
7757
- const { store } = this.client;
7758
- const state = store.getState();
7759
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(ids)(state);
7760
- this.dispatch(deleteFormSubmissionAttachments(ids));
7761
- try {
7762
- await this.enqueueRequest({
7763
- description: "Delete asset type field values attachments",
7764
- method: HttpMethod.DELETE,
7765
- url: "/asset-type-field-values-attachments/bulk/",
7766
- payload: { attachment_ids: ids },
7767
- blockers: ids,
7768
- blocks: []
7769
- });
7770
- } catch (e) {
7771
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7772
- throw e;
7773
- }
7774
- }
7775
- async refreshStore(projectId) {
7776
- const result = await this.enqueueRequest({
7777
- description: "Get asset type field values attachments",
7778
- method: HttpMethod.GET,
7779
- url: "/asset-type-field-values-attachments/",
7780
- queryParams: {
7781
- project: projectId.toString()
7782
- },
7783
- blockers: [],
7784
- blocks: []
7785
- });
7786
- this.dispatch(initializeAssetTypeFieldValuesAttachments(result));
7787
- }
7788
- }
7789
- class IssueTypeFieldsAttachmentService extends BaseUploadService {
7790
- async bulkAdd(payloads) {
7791
- var _a2;
7792
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7793
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7794
- const filePayloads = {};
7795
- const offlineIssueTypeFieldsAttachments = [];
7796
- const attachmentPayloads = [];
7797
- for (const payload of payloads) {
7798
- const { fieldsRevisionId, fieldIdentifier, file } = payload;
7799
- const filePayload = await this.getFilePayload(file);
7800
- if (!(filePayload.sha1 in filePayloads))
7801
- filePayloads[filePayload.sha1] = filePayload;
7802
- const offlineIssueTypeFieldsAttachment = offline({
7803
- file: URL.createObjectURL(file),
7804
- file_type: file.type,
7805
- file_name: file.name,
7806
- file_sha1: filePayload.sha1,
7807
- created_by: createdBy,
7808
- fields_revision: fieldsRevisionId,
7809
- submitted_at: submittedAt,
7810
- field_identifier: fieldIdentifier
7811
- });
7812
- offlineIssueTypeFieldsAttachments.push(offlineIssueTypeFieldsAttachment);
7813
- const attachmentPayload = {
7814
- offline_id: offlineIssueTypeFieldsAttachment.offline_id,
7815
- file_name: file.name,
7816
- file_extension: filePayload.extension,
7817
- field_identifier: fieldIdentifier,
7818
- file_sha1: filePayload.sha1,
7819
- fields_revision: fieldsRevisionId
7820
- };
7821
- attachmentPayloads.push(attachmentPayload);
7822
- }
7823
- this.dispatch(addIssueTypeFieldsAttachments(offlineIssueTypeFieldsAttachments));
7824
- const promise = this.enqueueRequest({
7825
- description: "Add issue type fields attachments",
7826
- method: HttpMethod.POST,
7827
- url: "/issue-type-fields-attachments/bulk/",
7828
- payload: {
7829
- submitted_at: submittedAt,
7830
- attachments: attachmentPayloads,
7831
- files: Object.values(filePayloads)
7832
- },
7833
- blockers: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7834
- blocks: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7835
- });
7836
- promise.then((result) => {
7837
- this.processPresignedUrls(result.presigned_urls);
7838
- this.dispatch(updateIssueTypeFieldsAttachments(result.attachments));
7839
- }).catch(() => {
7840
- this.dispatch(
7841
- deleteIssueTypeFieldsAttachments(
7842
- offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7843
- )
7844
- );
7845
- });
7846
- return [offlineIssueTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7847
- }
7848
- async refreshStore(organizationId) {
7849
- const result = await this.enqueueRequest({
7850
- description: "get issue type fields attachments",
7851
- method: HttpMethod.GET,
7852
- url: "/issue-type-fields-attachments/",
7853
- queryParams: {
7854
- organization: organizationId.toString()
7855
- },
7856
- blockers: [organizationId.toString()],
7857
- blocks: []
7858
- });
7859
- this.dispatch(initializeIssueTypeFieldsAttachments(result));
7860
- }
7861
- }
7862
- class IssueTypeFieldsService extends BaseApiService {
7863
- add(payload) {
7864
- var _a2;
7865
- const { store } = this.client;
7866
- const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7867
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7868
- const offlineIssueTypeFields = offline({
7869
- ...payload,
7870
- created_by: createdBy,
7871
- submitted_at: submittedAt
7872
- });
7873
- this.dispatch(addIssueTypeFields(offlineIssueTypeFields));
7874
- const promise = this.enqueueRequest({
7875
- description: "Add Issue Type Fields",
7876
- method: HttpMethod.POST,
7877
- url: "/issue-type-fields/",
7878
- payload: offlineIssueTypeFields,
7879
- blockers: [offlineIssueTypeFields.issue_type],
7880
- blocks: [offlineIssueTypeFields.offline_id]
7881
- });
7882
- promise.then((response) => {
7883
- this.dispatch(updateIssueTypeFields(response));
7884
- }).catch((error) => {
7885
- this.dispatch(deleteIssueTypeFields(offlineIssueTypeFields.offline_id));
7886
- throw error;
7887
- });
7888
- return [offlineIssueTypeFields, promise];
7889
- }
7890
- async refreshStore(organizationId) {
7891
- const result = await this.enqueueRequest({
7892
- description: "Get Issue Type Fields",
7893
- method: HttpMethod.GET,
7894
- url: "/issue-type-fields/",
7895
- queryParams: {
7896
- organization: organizationId.toString()
7897
- },
7898
- blockers: [],
7899
- blocks: []
7900
- });
7901
- this.dispatch(initializeIssueTypeFields(result));
7902
- }
7903
- }
7904
- class IssueTypeFieldValuesAttachmentService extends BaseUploadService {
7905
- async bulkAdd(payloads) {
7906
- var _a2;
7907
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7908
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7909
- const filePayloads = {};
7910
- const offlineIssueTypeFieldValuesAttachments = [];
7911
- const attachmentPayloads = [];
7912
- for (const payload of payloads) {
7913
- const { fieldValuesId, fieldIdentifier, file } = payload;
7914
- const filePayload = await this.getFilePayload(file);
7915
- if (!(filePayload.sha1 in filePayloads))
7916
- filePayloads[filePayload.sha1] = filePayload;
7917
- const offlineIssueTypeFieldValuesAttachment = offline({
7918
- file: URL.createObjectURL(file),
7919
- file_type: file.type,
7920
- file_name: file.name,
7921
- file_sha1: filePayload.sha1,
7922
- created_by: createdBy,
7923
- field_values: fieldValuesId,
7924
- submitted_at: submittedAt,
7925
- field_identifier: fieldIdentifier
7926
- });
7927
- offlineIssueTypeFieldValuesAttachments.push(offlineIssueTypeFieldValuesAttachment);
7928
- const attachmentPayload = {
7929
- offline_id: offlineIssueTypeFieldValuesAttachment.offline_id,
7930
- file_name: file.name,
7931
- file_sha1: filePayload.sha1,
7932
- file_extension: filePayload.extension,
7933
- field_identifier: fieldIdentifier,
7934
- field_values: fieldValuesId
7935
- };
7936
- attachmentPayloads.push(attachmentPayload);
7937
- }
7938
- this.dispatch(addIssueTypeFieldValuesAttachments(offlineIssueTypeFieldValuesAttachments));
7939
- const promise = this.enqueueRequest({
7940
- description: "Add issue type field values attachments",
7941
- method: HttpMethod.POST,
7942
- url: "/issue-type-field-values-attachments/bulk/",
7943
- payload: {
7944
- submitted_at: submittedAt,
7945
- attachments: attachmentPayloads,
7946
- files: Object.values(filePayloads)
7947
- },
7948
- blockers: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
7949
- blocks: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7950
- });
7951
- promise.then(({ presigned_urls, attachments }) => {
7952
- this.processPresignedUrls(presigned_urls);
7953
- this.dispatch(updateIssueTypeFieldValuesAttachments(attachments));
7954
- }).catch((error) => {
7955
- this.dispatch(
7956
- deleteIssueTypeFieldValuesAttachments(
7957
- offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7958
- )
7959
- );
7960
- throw error;
7961
- });
7962
- return [offlineIssueTypeFieldValuesAttachments, promise.then(({ attachments }) => attachments)];
7963
- }
7964
- async bulkDelete(attachmentsIds) {
7965
- const { store } = this.client;
7966
- const state = store.getState();
7967
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
7968
- this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
7969
- try {
7970
- await this.enqueueRequest({
7971
- description: "Delete issue type field values attachments",
7972
- method: HttpMethod.DELETE,
7973
- url: "/issue-type-field-values-attachments/bulk/",
7974
- payload: { attachment_ids: attachmentsIds },
7975
- blockers: attachmentsIds,
7976
- blocks: []
7977
- });
7978
- } catch (e) {
7979
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7980
- throw e;
7981
- }
7982
- }
7983
- async refreshStore(projectId) {
7984
- const result = await this.enqueueRequest({
7985
- description: "Get issue type field values attachments",
7986
- method: HttpMethod.GET,
7987
- url: "/issue-type-field-values-attachments/",
7988
- queryParams: {
7989
- project: projectId.toString()
7990
- },
7991
- blockers: [],
7992
- blocks: []
7993
- });
7994
- this.dispatch(initializeIssueTypeFieldValuesAttachments(result));
7995
- }
7996
- }
7997
- class IssueTypeFieldValuesService extends BaseApiService {
7998
- add(payload) {
7999
- var _a2;
8000
- const { store } = this.client;
8001
- const state = store.getState();
8002
- const { values } = separateFilesFromValues(payload.values);
8003
- const offlineIssueTypeFieldValues = offline({
8004
- ...payload,
8005
- values,
8006
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
8007
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
8008
- });
8009
- const promise = this.enqueueRequest({
8010
- description: "Add issue type field values",
8011
- method: HttpMethod.POST,
8012
- url: "/issue-type-field-values/",
8013
- payload: offlineIssueTypeFieldValues,
8014
- blockers: [payload.issue, payload.fields_revision],
8015
- blocks: [offlineIssueTypeFieldValues.offline_id]
8016
- });
8017
- this.dispatch(addIssueTypeFieldValues(offlineIssueTypeFieldValues));
8018
- promise.then((result) => {
8019
- this.dispatch(updateIssueTypeFieldValues(result));
8020
- return result;
8021
- }).catch(() => {
8022
- this.dispatch(deleteIssueTypeFieldValues(offlineIssueTypeFieldValues.offline_id));
8023
- });
8024
- return [offlineIssueTypeFieldValues, promise];
8025
- }
8026
- update(payload) {
8027
- const { store } = this.client;
8028
- const state = store.getState();
8029
- const issueTypeFieldValues = selectIssueTypeFieldValuesById(payload.offline_id)(state);
8030
- if (!issueTypeFieldValues) {
8031
- throw new Error(`Expected IssueTypeFieldValues with offline_id ${payload.offline_id} to exist`);
8032
- }
8033
- const { values } = separateFilesFromValues(payload.values ?? {});
8034
- const updatedIssueTypeFieldValues = {
8035
- ...issueTypeFieldValues,
8036
- ...payload,
8037
- // values could also have a partial update
8038
- values: {
8039
- ...issueTypeFieldValues.values,
8040
- ...values
8041
- }
8042
- };
8043
- this.dispatch(updateIssueTypeFieldValues(updatedIssueTypeFieldValues));
8044
- const promise = this.enqueueRequest({
8045
- description: "Update issue type field values",
8046
- method: HttpMethod.PATCH,
8047
- url: `/issue-type-field-values/${payload.offline_id}/`,
8048
- payload,
8049
- blockers: [
8050
- updatedIssueTypeFieldValues.offline_id,
8051
- updatedIssueTypeFieldValues.fields_revision,
8052
- updatedIssueTypeFieldValues.issue
8053
- ],
8054
- blocks: [updatedIssueTypeFieldValues.offline_id]
8055
- });
8056
- promise.then((result) => {
8057
- this.dispatch(updateIssueTypeFieldValues(result));
8058
- }).catch(() => {
8059
- this.dispatch(updateIssueTypeFieldValues(issueTypeFieldValues));
8060
- });
8061
- return [updatedIssueTypeFieldValues, promise];
8062
- }
8063
- async delete(id) {
8064
- const { store } = this.client;
8065
- const state = store.getState();
8066
- const issueTypeFieldValues = selectIssueTypeFieldValuesById(id)(state);
8067
- if (!issueTypeFieldValues) {
8068
- throw new Error(`Expected submission with offline_id ${id} to exist`);
8069
- }
8070
- const issueTypeFieldValuesAttachments = selectAttachmentsOfIssueTypeFieldValues(id)(state);
8071
- this.dispatch(deleteIssueTypeFieldValues(id));
8072
- this.dispatch(deleteIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments.map((x) => x.offline_id)));
8073
- try {
8074
- await this.enqueueRequest({
8075
- description: "Delete issue type field values",
8076
- method: HttpMethod.DELETE,
8077
- url: `/issue-type-field-values/${id}/`,
8078
- blockers: [id],
8079
- blocks: []
8080
- });
8081
- } catch (e) {
8082
- this.dispatch(addIssueTypeFieldValues(issueTypeFieldValues));
8083
- this.dispatch(addIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments));
8084
- throw e;
8085
- }
8086
- }
8087
- async refreshStore(projectId) {
8088
- const result = await this.enqueueRequest({
8089
- description: "Get issue type field values",
8090
- method: HttpMethod.GET,
8091
- url: "/issue-type-field-values/",
8092
- queryParams: {
8093
- project: projectId.toString()
8094
- },
8095
- blockers: [],
8096
- blocks: []
8097
- });
8098
- this.dispatch(initializeIssueTypeFieldValues(result));
8099
- }
8100
- }
8101
7319
  var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
8102
7320
  VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
8103
7321
  VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
@@ -8114,10 +7332,6 @@ var __publicField = (obj, key, value) => {
8114
7332
  exports2.AssetStageCompletionService = AssetStageCompletionService;
8115
7333
  exports2.AssetStageService = AssetStageService;
8116
7334
  exports2.AssetTypeAttachmentService = AssetTypeAttachmentService;
8117
- exports2.AssetTypeFieldValuesAttachmentService = AssetTypeFieldValuesAttachmentService;
8118
- exports2.AssetTypeFieldValuesService = AssetTypeFieldValuesService;
8119
- exports2.AssetTypeFieldsAttachmentService = AssetTypeFieldsAttachmentService;
8120
- exports2.AssetTypeFieldsService = AssetTypeFieldsService;
8121
7335
  exports2.AssetTypeService = AssetTypeService;
8122
7336
  exports2.AttachmentModel = AttachmentModel;
8123
7337
  exports2.BaseApiService = BaseApiService;
@@ -8133,10 +7347,7 @@ var __publicField = (obj, key, value) => {
8133
7347
  exports2.EmailDomainsService = EmailDomainsService;
8134
7348
  exports2.EmailVerificationService = EmailVerificationService;
8135
7349
  exports2.FileService = FileService;
8136
- exports2.FormRevisionAttachmentService = FormRevisionAttachmentService;
8137
- exports2.FormRevisionService = FormRevisionService;
8138
7350
  exports2.FormService = FormService;
8139
- exports2.FormSubmissionAttachmentService = FormSubmissionAttachmentService;
8140
7351
  exports2.FormSubmissionService = FormSubmissionService;
8141
7352
  exports2.GREEN = GREEN;
8142
7353
  exports2.GeoImageService = GeoImageService;
@@ -8147,10 +7358,6 @@ var __publicField = (obj, key, value) => {
8147
7358
  exports2.IssuePriority = IssuePriority;
8148
7359
  exports2.IssueService = IssueService;
8149
7360
  exports2.IssueStatus = IssueStatus;
8150
- exports2.IssueTypeFieldValuesAttachmentService = IssueTypeFieldValuesAttachmentService;
8151
- exports2.IssueTypeFieldValuesService = IssueTypeFieldValuesService;
8152
- exports2.IssueTypeFieldsAttachmentService = IssueTypeFieldsAttachmentService;
8153
- exports2.IssueTypeFieldsService = IssueTypeFieldsService;
8154
7361
  exports2.IssueTypeService = IssueTypeService;
8155
7362
  exports2.IssueUpdateChange = IssueUpdateChange;
8156
7363
  exports2.IssueUpdateService = IssueUpdateService;
@@ -8190,14 +7397,6 @@ var __publicField = (obj, key, value) => {
8190
7397
  exports2.addAssetType = addAssetType;
8191
7398
  exports2.addAssetTypeAttachment = addAssetTypeAttachment;
8192
7399
  exports2.addAssetTypeAttachments = addAssetTypeAttachments;
8193
- exports2.addAssetTypeFieldValues = addAssetTypeFieldValues;
8194
- exports2.addAssetTypeFieldValuesAttachment = addAssetTypeFieldValuesAttachment;
8195
- exports2.addAssetTypeFieldValuesAttachments = addAssetTypeFieldValuesAttachments;
8196
- exports2.addAssetTypeFieldValuesMany = addAssetTypeFieldValuesMany;
8197
- exports2.addAssetTypeFields = addAssetTypeFields;
8198
- exports2.addAssetTypeFieldsAttachment = addAssetTypeFieldsAttachment;
8199
- exports2.addAssetTypeFieldsAttachments = addAssetTypeFieldsAttachments;
8200
- exports2.addAssetTypeFieldsMany = addAssetTypeFieldsMany;
8201
7400
  exports2.addAssetTypes = addAssetTypes;
8202
7401
  exports2.addAssets = addAssets;
8203
7402
  exports2.addCategory = addCategory;
@@ -8226,14 +7425,6 @@ var __publicField = (obj, key, value) => {
8226
7425
  exports2.addIssueComment = addIssueComment;
8227
7426
  exports2.addIssueComments = addIssueComments;
8228
7427
  exports2.addIssueType = addIssueType;
8229
- exports2.addIssueTypeFieldValues = addIssueTypeFieldValues;
8230
- exports2.addIssueTypeFieldValuesAttachment = addIssueTypeFieldValuesAttachment;
8231
- exports2.addIssueTypeFieldValuesAttachments = addIssueTypeFieldValuesAttachments;
8232
- exports2.addIssueTypeFieldValuesMany = addIssueTypeFieldValuesMany;
8233
- exports2.addIssueTypeFields = addIssueTypeFields;
8234
- exports2.addIssueTypeFieldsAttachment = addIssueTypeFieldsAttachment;
8235
- exports2.addIssueTypeFieldsAttachments = addIssueTypeFieldsAttachments;
8236
- exports2.addIssueTypeFieldsMany = addIssueTypeFieldsMany;
8237
7428
  exports2.addIssueUpdate = addIssueUpdate;
8238
7429
  exports2.addIssueUpdates = addIssueUpdates;
8239
7430
  exports2.addIssues = addIssues;
@@ -8259,14 +7450,6 @@ var __publicField = (obj, key, value) => {
8259
7450
  exports2.assetStageSlice = assetStageSlice;
8260
7451
  exports2.assetTypeAttachmentReducer = assetTypeAttachmentReducer;
8261
7452
  exports2.assetTypeAttachmentSlice = assetTypeAttachmentSlice;
8262
- exports2.assetTypeFieldValuesAttachmentReducer = assetTypeFieldValuesAttachmentReducer;
8263
- exports2.assetTypeFieldValuesAttachmentSlice = assetTypeFieldValuesAttachmentSlice;
8264
- exports2.assetTypeFieldValuesReducer = assetTypeFieldValuesReducer;
8265
- exports2.assetTypeFieldValuesSlice = assetTypeFieldValuesSlice;
8266
- exports2.assetTypeFieldsAttachmentReducer = assetTypeFieldsAttachmentReducer;
8267
- exports2.assetTypeFieldsAttachmentSlice = assetTypeFieldsAttachmentSlice;
8268
- exports2.assetTypeFieldsReducer = assetTypeFieldsReducer;
8269
- exports2.assetTypeFieldsSlice = assetTypeFieldsSlice;
8270
7453
  exports2.assetTypeReducer = assetTypeReducer;
8271
7454
  exports2.assetTypeSlice = assetTypeSlice;
8272
7455
  exports2.authReducer = authReducer;
@@ -8295,14 +7478,6 @@ var __publicField = (obj, key, value) => {
8295
7478
  exports2.deleteAssetType = deleteAssetType;
8296
7479
  exports2.deleteAssetTypeAttachment = deleteAssetTypeAttachment;
8297
7480
  exports2.deleteAssetTypeAttachments = deleteAssetTypeAttachments;
8298
- exports2.deleteAssetTypeFieldValues = deleteAssetTypeFieldValues;
8299
- exports2.deleteAssetTypeFieldValuesAttachment = deleteAssetTypeFieldValuesAttachment;
8300
- exports2.deleteAssetTypeFieldValuesAttachments = deleteAssetTypeFieldValuesAttachments;
8301
- exports2.deleteAssetTypeFieldValuesMany = deleteAssetTypeFieldValuesMany;
8302
- exports2.deleteAssetTypeFields = deleteAssetTypeFields;
8303
- exports2.deleteAssetTypeFieldsAttachment = deleteAssetTypeFieldsAttachment;
8304
- exports2.deleteAssetTypeFieldsAttachments = deleteAssetTypeFieldsAttachments;
8305
- exports2.deleteAssetTypeFieldsMany = deleteAssetTypeFieldsMany;
8306
7481
  exports2.deleteAssetTypes = deleteAssetTypes;
8307
7482
  exports2.deleteAssets = deleteAssets;
8308
7483
  exports2.deleteCategory = deleteCategory;
@@ -8327,14 +7502,6 @@ var __publicField = (obj, key, value) => {
8327
7502
  exports2.deleteIssueAttachments = deleteIssueAttachments;
8328
7503
  exports2.deleteIssueComment = deleteIssueComment;
8329
7504
  exports2.deleteIssueComments = deleteIssueComments;
8330
- exports2.deleteIssueTypeFieldValues = deleteIssueTypeFieldValues;
8331
- exports2.deleteIssueTypeFieldValuesAttachment = deleteIssueTypeFieldValuesAttachment;
8332
- exports2.deleteIssueTypeFieldValuesAttachments = deleteIssueTypeFieldValuesAttachments;
8333
- exports2.deleteIssueTypeFieldValuesMany = deleteIssueTypeFieldValuesMany;
8334
- exports2.deleteIssueTypeFields = deleteIssueTypeFields;
8335
- exports2.deleteIssueTypeFieldsAttachment = deleteIssueTypeFieldsAttachment;
8336
- exports2.deleteIssueTypeFieldsAttachments = deleteIssueTypeFieldsAttachments;
8337
- exports2.deleteIssueTypeFieldsMany = deleteIssueTypeFieldsMany;
8338
7505
  exports2.deleteIssueUpdate = deleteIssueUpdate;
8339
7506
  exports2.deleteIssueUpdates = deleteIssueUpdates;
8340
7507
  exports2.deleteIssues = deleteIssues;
@@ -8391,10 +7558,6 @@ var __publicField = (obj, key, value) => {
8391
7558
  exports2.initializeAssetStageCompletions = initializeAssetStageCompletions;
8392
7559
  exports2.initializeAssetStages = initializeAssetStages;
8393
7560
  exports2.initializeAssetTypeAttachments = initializeAssetTypeAttachments;
8394
- exports2.initializeAssetTypeFieldValues = initializeAssetTypeFieldValues;
8395
- exports2.initializeAssetTypeFieldValuesAttachments = initializeAssetTypeFieldValuesAttachments;
8396
- exports2.initializeAssetTypeFields = initializeAssetTypeFields;
8397
- exports2.initializeAssetTypeFieldsAttachments = initializeAssetTypeFieldsAttachments;
8398
7561
  exports2.initializeAssetTypes = initializeAssetTypes;
8399
7562
  exports2.initializeAssets = initializeAssets;
8400
7563
  exports2.initializeCategories = initializeCategories;
@@ -8409,10 +7572,6 @@ var __publicField = (obj, key, value) => {
8409
7572
  exports2.initializeGeoImages = initializeGeoImages;
8410
7573
  exports2.initializeIssueAssociations = initializeIssueAssociations;
8411
7574
  exports2.initializeIssueAttachments = initializeIssueAttachments;
8412
- exports2.initializeIssueTypeFieldValues = initializeIssueTypeFieldValues;
8413
- exports2.initializeIssueTypeFieldValuesAttachments = initializeIssueTypeFieldValuesAttachments;
8414
- exports2.initializeIssueTypeFields = initializeIssueTypeFields;
8415
- exports2.initializeIssueTypeFieldsAttachments = initializeIssueTypeFieldsAttachments;
8416
7575
  exports2.initializeIssueTypes = initializeIssueTypes;
8417
7576
  exports2.initializeIssueUpdates = initializeIssueUpdates;
8418
7577
  exports2.initializeIssues = initializeIssues;
@@ -8431,14 +7590,6 @@ var __publicField = (obj, key, value) => {
8431
7590
  exports2.issueCommentSlice = issueCommentSlice;
8432
7591
  exports2.issueReducer = issueReducer;
8433
7592
  exports2.issueSlice = issueSlice;
8434
- exports2.issueTypeFieldValuesAttachmentReducer = issueTypeFieldValuesAttachmentReducer;
8435
- exports2.issueTypeFieldValuesAttachmentSlice = issueTypeFieldValuesAttachmentSlice;
8436
- exports2.issueTypeFieldValuesReducer = issueTypeFieldValuesReducer;
8437
- exports2.issueTypeFieldValuesSlice = issueTypeFieldValuesSlice;
8438
- exports2.issueTypeFieldsAttachmentReducer = issueTypeFieldsAttachmentReducer;
8439
- exports2.issueTypeFieldsAttachmentSlice = issueTypeFieldsAttachmentSlice;
8440
- exports2.issueTypeFieldsReducer = issueTypeFieldsReducer;
8441
- exports2.issueTypeFieldsSlice = issueTypeFieldsSlice;
8442
7593
  exports2.issueTypeReducer = issueTypeReducer;
8443
7594
  exports2.issueTypeSlice = issueTypeSlice;
8444
7595
  exports2.issueUpdateReducer = issueUpdateReducer;
@@ -8511,22 +7662,7 @@ var __publicField = (obj, key, value) => {
8511
7662
  exports2.selectAssetTypeAttachmentMapping = selectAssetTypeAttachmentMapping;
8512
7663
  exports2.selectAssetTypeAttachments = selectAssetTypeAttachments;
8513
7664
  exports2.selectAssetTypeById = selectAssetTypeById;
8514
- exports2.selectAssetTypeFieldValues = selectAssetTypeFieldValues;
8515
- exports2.selectAssetTypeFieldValuesAttachmentById = selectAssetTypeFieldValuesAttachmentById;
8516
- exports2.selectAssetTypeFieldValuesAttachments = selectAssetTypeFieldValuesAttachments;
8517
- exports2.selectAssetTypeFieldValuesAttachmentsMapping = selectAssetTypeFieldValuesAttachmentsMapping;
8518
- exports2.selectAssetTypeFieldValuesById = selectAssetTypeFieldValuesById;
8519
- exports2.selectAssetTypeFieldValuesMapping = selectAssetTypeFieldValuesMapping;
8520
- exports2.selectAssetTypeFieldValuesOfAsset = selectAssetTypeFieldValuesOfAsset;
8521
- exports2.selectAssetTypeFields = selectAssetTypeFields;
8522
- exports2.selectAssetTypeFieldsAttachmentById = selectAssetTypeFieldsAttachmentById;
8523
- exports2.selectAssetTypeFieldsAttachments = selectAssetTypeFieldsAttachments;
8524
- exports2.selectAssetTypeFieldsAttachmentsMapping = selectAssetTypeFieldsAttachmentsMapping;
8525
- exports2.selectAssetTypeFieldsById = selectAssetTypeFieldsById;
8526
- exports2.selectAssetTypeFieldsMapping = selectAssetTypeFieldsMapping;
8527
- exports2.selectAssetTypeFieldsOfAssetType = selectAssetTypeFieldsOfAssetType;
8528
7665
  exports2.selectAssetTypeStagesMapping = selectAssetTypeStagesMapping;
8529
- exports2.selectAssetTypeValuesOfAssetType = selectAssetTypeValuesOfAssetType;
8530
7666
  exports2.selectAssetTypes = selectAssetTypes;
8531
7667
  exports2.selectAssetTypesByIds = selectAssetTypesByIds;
8532
7668
  exports2.selectAssetTypesMapping = selectAssetTypesMapping;
@@ -8534,20 +7670,18 @@ var __publicField = (obj, key, value) => {
8534
7670
  exports2.selectAssetsByIds = selectAssetsByIds;
8535
7671
  exports2.selectAssetsMapping = selectAssetsMapping;
8536
7672
  exports2.selectAssetsOfAssetType = selectAssetsOfAssetType;
7673
+ exports2.selectAttachedFormSubmissionsOfAsset = selectAttachedFormSubmissionsOfAsset;
7674
+ exports2.selectAttachedFormSubmissionsOfIssue = selectAttachedFormSubmissionsOfIssue;
8537
7675
  exports2.selectAttachmentsOfAsset = selectAttachmentsOfAsset;
8538
7676
  exports2.selectAttachmentsOfAssetByType = selectAttachmentsOfAssetByType;
8539
7677
  exports2.selectAttachmentsOfAssetType = selectAttachmentsOfAssetType;
8540
7678
  exports2.selectAttachmentsOfAssetTypeByType = selectAttachmentsOfAssetTypeByType;
8541
- exports2.selectAttachmentsOfAssetTypeFieldValues = selectAttachmentsOfAssetTypeFieldValues;
8542
- exports2.selectAttachmentsOfAssetTypeFields = selectAttachmentsOfAssetTypeFields;
8543
7679
  exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
8544
7680
  exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
8545
7681
  exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
8546
7682
  exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
8547
7683
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
8548
7684
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
8549
- exports2.selectAttachmentsOfIssueTypeFieldValues = selectAttachmentsOfIssueTypeFieldValues;
8550
- exports2.selectAttachmentsOfIssueTypeFields = selectAttachmentsOfIssueTypeFields;
8551
7685
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
8552
7686
  exports2.selectAttachmentsOfProjectByType = selectAttachmentsOfProjectByType;
8553
7687
  exports2.selectCategories = selectCategories;
@@ -8575,6 +7709,8 @@ var __publicField = (obj, key, value) => {
8575
7709
  exports2.selectFilteredForms = selectFilteredForms;
8576
7710
  exports2.selectFormById = selectFormById;
8577
7711
  exports2.selectFormMapping = selectFormMapping;
7712
+ exports2.selectFormOfAssetType = selectFormOfAssetType;
7713
+ exports2.selectFormOfIssueType = selectFormOfIssueType;
8578
7714
  exports2.selectFormRevisionAttachmentsMapping = selectFormRevisionAttachmentsMapping;
8579
7715
  exports2.selectFormRevisionById = selectFormRevisionById;
8580
7716
  exports2.selectFormRevisionMapping = selectFormRevisionMapping;
@@ -8584,11 +7720,16 @@ var __publicField = (obj, key, value) => {
8584
7720
  exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
8585
7721
  exports2.selectFormSubmissionById = selectFormSubmissionById;
8586
7722
  exports2.selectFormSubmissions = selectFormSubmissions;
7723
+ exports2.selectFormSubmissionsByAssets = selectFormSubmissionsByAssets;
7724
+ exports2.selectFormSubmissionsByFormRevisions = selectFormSubmissionsByFormRevisions;
7725
+ exports2.selectFormSubmissionsByIssues = selectFormSubmissionsByIssues;
8587
7726
  exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
8588
7727
  exports2.selectFormSubmissionsOfAsset = selectFormSubmissionsOfAsset;
8589
7728
  exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
8590
7729
  exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
8591
7730
  exports2.selectForms = selectForms;
7731
+ exports2.selectFormsCount = selectFormsCount;
7732
+ exports2.selectGeneralFormCount = selectGeneralFormCount;
8592
7733
  exports2.selectGeoImageById = selectGeoImageById;
8593
7734
  exports2.selectGeoImageMapping = selectGeoImageMapping;
8594
7735
  exports2.selectGeoImages = selectGeoImages;
@@ -8610,22 +7751,7 @@ var __publicField = (obj, key, value) => {
8610
7751
  exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
8611
7752
  exports2.selectIssueMapping = selectIssueMapping;
8612
7753
  exports2.selectIssueTypeById = selectIssueTypeById;
8613
- exports2.selectIssueTypeFieldValues = selectIssueTypeFieldValues;
8614
- exports2.selectIssueTypeFieldValuesAttachmentById = selectIssueTypeFieldValuesAttachmentById;
8615
- exports2.selectIssueTypeFieldValuesAttachments = selectIssueTypeFieldValuesAttachments;
8616
- exports2.selectIssueTypeFieldValuesAttachmentsMapping = selectIssueTypeFieldValuesAttachmentsMapping;
8617
- exports2.selectIssueTypeFieldValuesById = selectIssueTypeFieldValuesById;
8618
- exports2.selectIssueTypeFieldValuesMapping = selectIssueTypeFieldValuesMapping;
8619
- exports2.selectIssueTypeFieldValuesOfIssue = selectIssueTypeFieldValuesOfIssue;
8620
- exports2.selectIssueTypeFields = selectIssueTypeFields;
8621
- exports2.selectIssueTypeFieldsAttachmentById = selectIssueTypeFieldsAttachmentById;
8622
- exports2.selectIssueTypeFieldsAttachments = selectIssueTypeFieldsAttachments;
8623
- exports2.selectIssueTypeFieldsAttachmentsMapping = selectIssueTypeFieldsAttachmentsMapping;
8624
- exports2.selectIssueTypeFieldsById = selectIssueTypeFieldsById;
8625
- exports2.selectIssueTypeFieldsMapping = selectIssueTypeFieldsMapping;
8626
- exports2.selectIssueTypeFieldsOfIssueType = selectIssueTypeFieldsOfIssueType;
8627
7754
  exports2.selectIssueTypeMapping = selectIssueTypeMapping;
8628
- exports2.selectIssueTypeValuesOfIssueType = selectIssueTypeValuesOfIssueType;
8629
7755
  exports2.selectIssueTypes = selectIssueTypes;
8630
7756
  exports2.selectIssueTypesByIds = selectIssueTypesByIds;
8631
7757
  exports2.selectIssueTypesOfOrganization = selectIssueTypesOfOrganization;
@@ -8634,9 +7760,8 @@ var __publicField = (obj, key, value) => {
8634
7760
  exports2.selectIssuesByIds = selectIssuesByIds;
8635
7761
  exports2.selectIssuesOfIssueType = selectIssuesOfIssueType;
8636
7762
  exports2.selectIssuesOfIssueTypeCount = selectIssuesOfIssueTypeCount;
8637
- exports2.selectLatestAssetTypeFieldsOfAssetType = selectLatestAssetTypeFieldsOfAssetType;
7763
+ exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
8638
7764
  exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
8639
- exports2.selectLatestIssueTypeFieldsOfIssueType = selectLatestIssueTypeFieldsOfIssueType;
8640
7765
  exports2.selectLatestRetryTime = selectLatestRetryTime;
8641
7766
  exports2.selectLicense = selectLicense;
8642
7767
  exports2.selectLicenseForProject = selectLicenseForProject;
@@ -8673,6 +7798,7 @@ var __publicField = (obj, key, value) => {
8673
7798
  exports2.selectProjectsOfOrganization = selectProjectsOfOrganization;
8674
7799
  exports2.selectRehydrated = selectRehydrated;
8675
7800
  exports2.selectRootDocuments = selectRootDocuments;
7801
+ exports2.selectSortedFormSubmissionsOfForm = selectSortedFormSubmissionsOfForm;
8676
7802
  exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
8677
7803
  exports2.selectSortedProjectUsers = selectSortedProjectUsers;
8678
7804
  exports2.selectStageFormIdsFromStageIds = selectStageFormIdsFromStageIds;
@@ -8691,8 +7817,6 @@ var __publicField = (obj, key, value) => {
8691
7817
  exports2.selectWorkspaceById = selectWorkspaceById;
8692
7818
  exports2.selectWorkspaceMapping = selectWorkspaceMapping;
8693
7819
  exports2.selectWorkspaces = selectWorkspaces;
8694
- exports2.separateFilesFromValues = separateFilesFromValues;
8695
- exports2.separateImageFromFields = separateImageFromFields;
8696
7820
  exports2.setActiveProjectFileId = setActiveProjectFileId;
8697
7821
  exports2.setActiveProjectId = setActiveProjectId;
8698
7822
  exports2.setAsset = setAsset;
@@ -8703,14 +7827,6 @@ var __publicField = (obj, key, value) => {
8703
7827
  exports2.setAssetType = setAssetType;
8704
7828
  exports2.setAssetTypeAttachment = setAssetTypeAttachment;
8705
7829
  exports2.setAssetTypeAttachments = setAssetTypeAttachments;
8706
- exports2.setAssetTypeFieldValues = setAssetTypeFieldValues;
8707
- exports2.setAssetTypeFieldValuesAttachment = setAssetTypeFieldValuesAttachment;
8708
- exports2.setAssetTypeFieldValuesAttachments = setAssetTypeFieldValuesAttachments;
8709
- exports2.setAssetTypeFieldValuesMany = setAssetTypeFieldValuesMany;
8710
- exports2.setAssetTypeFields = setAssetTypeFields;
8711
- exports2.setAssetTypeFieldsAttachment = setAssetTypeFieldsAttachment;
8712
- exports2.setAssetTypeFieldsAttachments = setAssetTypeFieldsAttachments;
8713
- exports2.setAssetTypeFieldsMany = setAssetTypeFieldsMany;
8714
7830
  exports2.setAssetTypes = setAssetTypes;
8715
7831
  exports2.setAssets = setAssets;
8716
7832
  exports2.setConversation = setConversation;
@@ -8736,14 +7852,6 @@ var __publicField = (obj, key, value) => {
8736
7852
  exports2.setIssueComment = setIssueComment;
8737
7853
  exports2.setIssueComments = setIssueComments;
8738
7854
  exports2.setIssueType = setIssueType;
8739
- exports2.setIssueTypeFieldValues = setIssueTypeFieldValues;
8740
- exports2.setIssueTypeFieldValuesAttachment = setIssueTypeFieldValuesAttachment;
8741
- exports2.setIssueTypeFieldValuesAttachments = setIssueTypeFieldValuesAttachments;
8742
- exports2.setIssueTypeFieldValuesMany = setIssueTypeFieldValuesMany;
8743
- exports2.setIssueTypeFields = setIssueTypeFields;
8744
- exports2.setIssueTypeFieldsAttachment = setIssueTypeFieldsAttachment;
8745
- exports2.setIssueTypeFieldsAttachments = setIssueTypeFieldsAttachments;
8746
- exports2.setIssueTypeFieldsMany = setIssueTypeFieldsMany;
8747
7855
  exports2.setIssueUpdate = setIssueUpdate;
8748
7856
  exports2.setLoggedIn = setLoggedIn;
8749
7857
  exports2.setOrganizations = setOrganizations;
@@ -8776,14 +7884,6 @@ var __publicField = (obj, key, value) => {
8776
7884
  exports2.updateAssetType = updateAssetType;
8777
7885
  exports2.updateAssetTypeAttachment = updateAssetTypeAttachment;
8778
7886
  exports2.updateAssetTypeAttachments = updateAssetTypeAttachments;
8779
- exports2.updateAssetTypeFieldValues = updateAssetTypeFieldValues;
8780
- exports2.updateAssetTypeFieldValuesAttachment = updateAssetTypeFieldValuesAttachment;
8781
- exports2.updateAssetTypeFieldValuesAttachments = updateAssetTypeFieldValuesAttachments;
8782
- exports2.updateAssetTypeFieldValuesMany = updateAssetTypeFieldValuesMany;
8783
- exports2.updateAssetTypeFields = updateAssetTypeFields;
8784
- exports2.updateAssetTypeFieldsAttachment = updateAssetTypeFieldsAttachment;
8785
- exports2.updateAssetTypeFieldsAttachments = updateAssetTypeFieldsAttachments;
8786
- exports2.updateAssetTypeFieldsMany = updateAssetTypeFieldsMany;
8787
7887
  exports2.updateAssetTypes = updateAssetTypes;
8788
7888
  exports2.updateAssets = updateAssets;
8789
7889
  exports2.updateCategory = updateCategory;
@@ -8806,14 +7906,6 @@ var __publicField = (obj, key, value) => {
8806
7906
  exports2.updateIssueAttachment = updateIssueAttachment;
8807
7907
  exports2.updateIssueAttachments = updateIssueAttachments;
8808
7908
  exports2.updateIssueType = updateIssueType;
8809
- exports2.updateIssueTypeFieldValues = updateIssueTypeFieldValues;
8810
- exports2.updateIssueTypeFieldValuesAttachment = updateIssueTypeFieldValuesAttachment;
8811
- exports2.updateIssueTypeFieldValuesAttachments = updateIssueTypeFieldValuesAttachments;
8812
- exports2.updateIssueTypeFieldValuesMany = updateIssueTypeFieldValuesMany;
8813
- exports2.updateIssueTypeFields = updateIssueTypeFields;
8814
- exports2.updateIssueTypeFieldsAttachment = updateIssueTypeFieldsAttachment;
8815
- exports2.updateIssueTypeFieldsAttachments = updateIssueTypeFieldsAttachments;
8816
- exports2.updateIssueTypeFieldsMany = updateIssueTypeFieldsMany;
8817
7909
  exports2.updateLicense = updateLicense;
8818
7910
  exports2.updateOrCreateProject = updateOrCreateProject;
8819
7911
  exports2.updateOrganizationAccess = updateOrganizationAccess;