@overmap-ai/core 1.0.71-mapbox.6 → 1.0.71-mapbox.7

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 (54) hide show
  1. package/dist/overmap-core.js +1927 -1079
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +1927 -1079
  4. package/dist/overmap-core.umd.cjs.map +1 -1
  5. package/dist/sdk/services/AssetAttachmentService.d.ts +29 -7
  6. package/dist/sdk/services/AssetService.d.ts +1 -1
  7. package/dist/sdk/services/AssetStageService.d.ts +1 -3
  8. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +29 -8
  9. package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +13 -0
  10. package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +21 -0
  11. package/dist/sdk/services/AssetTypeFieldsAttachmentService.d.ts +13 -0
  12. package/dist/sdk/services/AssetTypeFieldsService.d.ts +9 -0
  13. package/dist/sdk/services/AssetTypeService.d.ts +1 -1
  14. package/dist/sdk/services/BaseAttachmentService.d.ts +17 -19
  15. package/dist/sdk/services/BaseUploadService.d.ts +2 -1
  16. package/dist/sdk/services/DocumentAttachmentService.d.ts +27 -7
  17. package/dist/sdk/services/FormRevisionAttachmentService.d.ts +13 -0
  18. package/dist/sdk/services/FormRevisionService.d.ts +9 -0
  19. package/dist/sdk/services/FormService.d.ts +11 -14
  20. package/dist/sdk/services/FormSubmissionAttachmentService.d.ts +14 -0
  21. package/dist/sdk/services/FormSubmissionService.d.ts +8 -28
  22. package/dist/sdk/services/IssueAssociationService.d.ts +2 -2
  23. package/dist/sdk/services/IssueAttachmentService.d.ts +28 -7
  24. package/dist/sdk/services/IssueService.d.ts +0 -3
  25. package/dist/sdk/services/IssueTypeFieldValuesAttachmentService.d.ts +14 -0
  26. package/dist/sdk/services/IssueTypeFieldValuesService.d.ts +11 -0
  27. package/dist/sdk/services/IssueTypeFieldsAttachmentService.d.ts +13 -0
  28. package/dist/sdk/services/IssueTypeFieldsService.d.ts +9 -0
  29. package/dist/sdk/services/ProjectAttachmentService.d.ts +28 -7
  30. package/dist/sdk/services/index.d.ts +11 -0
  31. package/dist/store/slices/assetStageSlice.d.ts +0 -1
  32. package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +64 -0
  33. package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +64 -0
  34. package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +63 -0
  35. package/dist/store/slices/assetTypeFieldsSlice.d.ts +64 -0
  36. package/dist/store/slices/formRevisionSlice.d.ts +1 -2
  37. package/dist/store/slices/formSlice.d.ts +1 -5
  38. package/dist/store/slices/formSubmissionSlice.d.ts +0 -6
  39. package/dist/store/slices/index.d.ts +8 -0
  40. package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +64 -0
  41. package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +63 -0
  42. package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +63 -0
  43. package/dist/store/slices/issueTypeFieldsSlice.d.ts +65 -0
  44. package/dist/store/store.d.ts +9 -1
  45. package/dist/typings/files.d.ts +8 -4
  46. package/dist/typings/models/assets.d.ts +17 -2
  47. package/dist/typings/models/attachments.d.ts +1 -6
  48. package/dist/typings/models/fields.d.ts +17 -0
  49. package/dist/typings/models/forms.d.ts +12 -29
  50. package/dist/typings/models/index.d.ts +1 -0
  51. package/dist/typings/models/issues.d.ts +15 -0
  52. package/dist/typings/models/store.d.ts +9 -1
  53. package/dist/utils/file.d.ts +2 -2
  54. package/package.json +1 -1
@@ -662,15 +662,15 @@ const wrapMigration = (migrator) => (state) => {
662
662
  };
663
663
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
664
664
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
665
- const initialState$B = {
665
+ const initialState$J = {
666
666
  accessToken: "",
667
667
  refreshToken: "",
668
668
  isLoggedIn: false
669
669
  };
670
670
  const authSlice = createSlice({
671
671
  name: "auth",
672
- initialState: initialState$B,
673
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
672
+ initialState: initialState$J,
673
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$J)),
674
674
  reducers: {
675
675
  setTokens: (state, action) => {
676
676
  state.accessToken = action.payload.accessToken;
@@ -758,11 +758,11 @@ function createModelAdapter(computeModelId) {
758
758
  };
759
759
  }
760
760
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
761
- const initialState$A = categoryAdapter.getInitialState({});
761
+ const initialState$I = categoryAdapter.getInitialState({});
762
762
  const categorySlice = createSlice({
763
763
  name: "categories",
764
- initialState: initialState$A,
765
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
764
+ initialState: initialState$I,
765
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$I)),
766
766
  reducers: {
767
767
  initializeCategories: categoryAdapter.initialize,
768
768
  addCategory: categoryAdapter.addOne,
@@ -800,11 +800,11 @@ const selectIssueCountOfCategory = (categoryId) => (state) => {
800
800
  };
801
801
  const categoryReducer = categorySlice.reducer;
802
802
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
803
- const initialState$z = assetAdapter.getInitialState({});
803
+ const initialState$H = assetAdapter.getInitialState({});
804
804
  const assetSlice = createSlice({
805
805
  name: "assets",
806
- initialState: initialState$z,
807
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
806
+ initialState: initialState$H,
807
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$H)),
808
808
  reducers: {
809
809
  initializeAssets: assetAdapter.initialize,
810
810
  addAsset: assetAdapter.addOne,
@@ -855,11 +855,11 @@ const selectNumberOfAssetsOfAssetType = (assetTypeId) => (state) => {
855
855
  };
856
856
  const assetReducer = assetSlice.reducer;
857
857
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
858
- const initialState$y = assetAttachmentAdapter.getInitialState({});
858
+ const initialState$G = assetAttachmentAdapter.getInitialState({});
859
859
  const assetAttachmentSlice = createSlice({
860
860
  name: "assetAttachments",
861
- initialState: initialState$y,
862
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
861
+ initialState: initialState$G,
862
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$G)),
863
863
  reducers: {
864
864
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
865
865
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -920,11 +920,11 @@ const assetAttachmentReducer = assetAttachmentSlice.reducer;
920
920
  const assetStageCompletionAdapter = createModelAdapter(
921
921
  (stageCompletion) => stageCompletion.offline_id
922
922
  );
923
- const initialState$x = assetStageCompletionAdapter.getInitialState({});
923
+ const initialState$F = assetStageCompletionAdapter.getInitialState({});
924
924
  const assetStageCompletionSlice = createSlice({
925
925
  name: "assetStageCompletions",
926
- initialState: initialState$x,
927
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
926
+ initialState: initialState$F,
927
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$F)),
928
928
  reducers: {
929
929
  initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
930
930
  addAssetStageCompletion: assetStageCompletionAdapter.addOne,
@@ -977,11 +977,11 @@ const selectAssetStageCompletionsByIds = restructureCreateSelectorWithArgs(
977
977
  );
978
978
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
979
979
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
980
- const initialState$w = assetStageAdapter.getInitialState({});
980
+ const initialState$E = assetStageAdapter.getInitialState({});
981
981
  const assetStageSlice = createSlice({
982
982
  name: "assetStages",
983
- initialState: initialState$w,
984
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
983
+ initialState: initialState$E,
984
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$E)),
985
985
  reducers: {
986
986
  initializeAssetStages: assetStageAdapter.initialize,
987
987
  setAssetStage: assetStageAdapter.setOne,
@@ -1045,27 +1045,12 @@ const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
1045
1045
  return fallbackToEmptyArray(assetStages);
1046
1046
  })
1047
1047
  );
1048
- const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1049
- createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1050
- const ret = {};
1051
- for (const stageId of stageIds) {
1052
- const stage = stageMapping[stageId];
1053
- if (!stage) {
1054
- throw new Error("No stage exists with the id " + stageId);
1055
- }
1056
- if (stage.form) {
1057
- ret[stageId] = stage.form;
1058
- }
1059
- }
1060
- return ret;
1061
- })
1062
- );
1063
1048
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1064
- const initialState$v = assetTypeAdapter.getInitialState({});
1049
+ const initialState$D = assetTypeAdapter.getInitialState({});
1065
1050
  const assetTypeSlice = createSlice({
1066
1051
  name: "assetTypes",
1067
- initialState: initialState$v,
1068
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1052
+ initialState: initialState$D,
1053
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$D)),
1069
1054
  reducers: {
1070
1055
  initializeAssetTypes: assetTypeAdapter.initialize,
1071
1056
  setAssetType: assetTypeAdapter.setOne,
@@ -1118,11 +1103,11 @@ const assetTypeReducer = assetTypeSlice.reducer;
1118
1103
  const assetTypeAttachmentAdapter = createModelAdapter(
1119
1104
  (attachment) => attachment.offline_id
1120
1105
  );
1121
- const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1106
+ const initialState$C = assetTypeAttachmentAdapter.getInitialState({});
1122
1107
  const assetTypeAttachmentSlice = createSlice({
1123
1108
  name: "assetTypeAttachments",
1124
- initialState: initialState$u,
1125
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1109
+ initialState: initialState$C,
1110
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
1126
1111
  reducers: {
1127
1112
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1128
1113
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1181,12 +1166,12 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1181
1166
  );
1182
1167
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1183
1168
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1184
- const initialState$t = issueAdapter.getInitialState({});
1169
+ const initialState$B = issueAdapter.getInitialState({});
1185
1170
  const issueSlice = createSlice({
1186
1171
  name: "issues",
1187
- initialState: initialState$t,
1172
+ initialState: initialState$B,
1188
1173
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1189
- Object.assign(state, initialState$t);
1174
+ Object.assign(state, initialState$B);
1190
1175
  }),
1191
1176
  reducers: {
1192
1177
  initializeIssues: issueAdapter.initialize,
@@ -1218,12 +1203,12 @@ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1218
1203
  );
1219
1204
  const issueReducer = issueSlice.reducer;
1220
1205
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1221
- const initialState$s = issueTypeAdapter.getInitialState({});
1206
+ const initialState$A = issueTypeAdapter.getInitialState({});
1222
1207
  const issueTypeSlice = createSlice({
1223
1208
  name: "issueTypes",
1224
- initialState: initialState$s,
1209
+ initialState: initialState$A,
1225
1210
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1226
- Object.assign(state, initialState$s);
1211
+ Object.assign(state, initialState$A);
1227
1212
  }),
1228
1213
  reducers: {
1229
1214
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1280,15 +1265,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1280
1265
  return selectIssuesOfIssueType(issueTypeId)(state).length;
1281
1266
  };
1282
1267
  const issueTypeReducer = issueTypeSlice.reducer;
1283
- const initialState$r = {
1268
+ const initialState$z = {
1284
1269
  s3Urls: {}
1285
1270
  };
1286
1271
  const msPerHour = 1e3 * 60 * 60;
1287
1272
  const msPerWeek = msPerHour * 24 * 7;
1288
1273
  const fileSlice = createSlice({
1289
1274
  name: "file",
1290
- initialState: initialState$r,
1291
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1275
+ initialState: initialState$z,
1276
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1292
1277
  reducers: {
1293
1278
  setUploadUrl: (state, action) => {
1294
1279
  const { url, fields, sha1 } = action.payload;
@@ -1314,14 +1299,14 @@ const selectUploadUrl = (sha1) => (state) => {
1314
1299
  return url;
1315
1300
  };
1316
1301
  const fileReducer = fileSlice.reducer;
1317
- const initialState$q = {
1302
+ const initialState$y = {
1318
1303
  users: {},
1319
1304
  currentUser: null
1320
1305
  };
1321
1306
  const userSlice = createSlice({
1322
1307
  name: "users",
1323
- initialState: initialState$q,
1324
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1308
+ initialState: initialState$y,
1309
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1325
1310
  reducers: {
1326
1311
  setUsers: (state, action) => {
1327
1312
  const usersMapping = {};
@@ -1378,11 +1363,11 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
1378
1363
  const organizationAccessAdapter = createModelAdapter(
1379
1364
  (organizationAccess) => organizationAccess.offline_id
1380
1365
  );
1381
- const initialState$p = organizationAccessAdapter.getInitialState({});
1366
+ const initialState$x = organizationAccessAdapter.getInitialState({});
1382
1367
  const organizationAccessSlice = createSlice({
1383
1368
  name: "organizationAccess",
1384
- initialState: initialState$p,
1385
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1369
+ initialState: initialState$x,
1370
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1386
1371
  reducers: {
1387
1372
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1388
1373
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1419,11 +1404,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1419
1404
  };
1420
1405
  const organizationAccessReducer = organizationAccessSlice.reducer;
1421
1406
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1422
- const initialState$o = licenseAdapter.getInitialState({});
1407
+ const initialState$w = licenseAdapter.getInitialState({});
1423
1408
  const licenseSlice = createSlice({
1424
1409
  name: "license",
1425
- initialState: initialState$o,
1426
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1410
+ initialState: initialState$w,
1411
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1427
1412
  reducers: {
1428
1413
  initializeLicences: licenseAdapter.initialize,
1429
1414
  addLicenses: licenseAdapter.addMany,
@@ -1450,11 +1435,11 @@ const selectLicensesForProjectsMapping = createSelector(
1450
1435
  );
1451
1436
  const licenseReducer = licenseSlice.reducer;
1452
1437
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1453
- const initialState$n = projectAccessAdapter.getInitialState({});
1438
+ const initialState$v = projectAccessAdapter.getInitialState({});
1454
1439
  const projectAccessSlice = createSlice({
1455
1440
  name: "projectAccess",
1456
- initialState: initialState$n,
1457
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1441
+ initialState: initialState$v,
1442
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1458
1443
  reducers: {
1459
1444
  initializeProjectAccesses: projectAccessAdapter.initialize,
1460
1445
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1488,13 +1473,13 @@ const selectProjectAccessUserMapping = (state) => {
1488
1473
  return fallbackToEmptyObject(projectAccesses);
1489
1474
  };
1490
1475
  const projectAccessReducer = projectAccessSlice.reducer;
1491
- const initialState$m = {
1476
+ const initialState$u = {
1492
1477
  projects: {}
1493
1478
  };
1494
1479
  const projectSlice = createSlice({
1495
1480
  name: "projects",
1496
- initialState: initialState$m,
1497
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1481
+ initialState: initialState$u,
1482
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1498
1483
  reducers: {
1499
1484
  setProjects: (state, action) => {
1500
1485
  const projectsMap = {};
@@ -1555,13 +1540,13 @@ const selectSortedProjectUsers = createSelector(
1555
1540
  );
1556
1541
  }
1557
1542
  );
1558
- const initialState$l = {
1543
+ const initialState$t = {
1559
1544
  organizations: {}
1560
1545
  };
1561
1546
  const organizationSlice = createSlice({
1562
1547
  name: "organizations",
1563
- initialState: initialState$l,
1564
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1548
+ initialState: initialState$t,
1549
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$t)),
1565
1550
  reducers: {
1566
1551
  setOrganizations: (state, action) => {
1567
1552
  for (const org of action.payload) {
@@ -1656,14 +1641,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
1656
1641
  }
1657
1642
  };
1658
1643
  };
1659
- const initialState$k = {
1644
+ const initialState$s = {
1660
1645
  deletedRequests: [],
1661
1646
  latestRetryTime: 0
1662
1647
  };
1663
1648
  const outboxSlice = createSlice({
1664
1649
  name: "outbox",
1665
- initialState: initialState$k,
1666
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1650
+ initialState: initialState$s,
1651
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
1667
1652
  reducers: {
1668
1653
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
1669
1654
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -1695,14 +1680,14 @@ const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
1695
1680
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
1696
1681
  const outboxReducer = outboxSlice.reducer;
1697
1682
  const projectFileModelAdapter = createModelAdapter((projectFile) => projectFile.offline_id);
1698
- const initialState$j = projectFileModelAdapter.getInitialState({
1683
+ const initialState$r = projectFileModelAdapter.getInitialState({
1699
1684
  activeProjectFileId: null,
1700
1685
  isImportingProjectFile: false
1701
1686
  });
1702
1687
  const projectFileSlice = createSlice({
1703
1688
  name: "projectFiles",
1704
- initialState: initialState$j,
1705
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1689
+ initialState: initialState$r,
1690
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1706
1691
  reducers: {
1707
1692
  initializeProjectFiles: projectFileModelAdapter.initialize,
1708
1693
  setProjectFile: projectFileModelAdapter.setOne,
@@ -1767,11 +1752,11 @@ const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProj
1767
1752
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
1768
1753
  const projectFileReducer = projectFileSlice.reducer;
1769
1754
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1770
- const initialState$i = projectAttachmentAdapter.getInitialState({});
1755
+ const initialState$q = projectAttachmentAdapter.getInitialState({});
1771
1756
  const projectAttachmentSlice = createSlice({
1772
1757
  name: "projectAttachments",
1773
- initialState: initialState$i,
1774
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1758
+ initialState: initialState$q,
1759
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1775
1760
  reducers: {
1776
1761
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
1777
1762
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -1826,12 +1811,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
1826
1811
  )
1827
1812
  );
1828
1813
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
1829
- const initialState$h = {
1814
+ const initialState$p = {
1830
1815
  isRehydrated: false
1831
1816
  };
1832
1817
  const rehydratedSlice = createSlice({
1833
1818
  name: "rehydrated",
1834
- initialState: initialState$h,
1819
+ initialState: initialState$p,
1835
1820
  // The `reducers` field lets us define reducers and generate associated actions
1836
1821
  reducers: {
1837
1822
  setRehydrated: (state, action) => {
@@ -1856,11 +1841,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
1856
1841
  }
1857
1842
  };
1858
1843
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
1859
- const initialState$g = formRevisionAdapter.getInitialState({});
1844
+ const initialState$o = formRevisionAdapter.getInitialState({});
1860
1845
  const formRevisionsSlice = createSlice({
1861
1846
  name: "formRevisions",
1862
- initialState: initialState$g,
1863
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1847
+ initialState: initialState$o,
1848
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1864
1849
  reducers: {
1865
1850
  initializeFormRevisions: formRevisionAdapter.initialize,
1866
1851
  setFormRevision: formRevisionAdapter.setOne,
@@ -1918,24 +1903,13 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
1918
1903
  }
1919
1904
  )
1920
1905
  );
1921
- const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
1922
- const latestRevisions = {};
1923
- for (const revision of Object.values(revisions)) {
1924
- const formId = revision.form;
1925
- const currentLatestRevision = latestRevisions[formId];
1926
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
1927
- latestRevisions[formId] = revision;
1928
- }
1929
- }
1930
- return latestRevisions;
1931
- });
1932
1906
  const formRevisionReducer = formRevisionsSlice.reducer;
1933
1907
  const formAdapter = createModelAdapter((form) => form.offline_id);
1934
- const initialState$f = formAdapter.getInitialState({});
1908
+ const initialState$n = formAdapter.getInitialState({});
1935
1909
  const formSlice = createSlice({
1936
1910
  name: "forms",
1937
- initialState: initialState$f,
1938
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
1911
+ initialState: initialState$n,
1912
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1939
1913
  reducers: {
1940
1914
  initializeForms: formAdapter.initialize,
1941
1915
  setForm: formAdapter.setOne,
@@ -1953,6 +1927,9 @@ const selectFormMapping = (state) => {
1953
1927
  const selectForms = createSelector([selectFormMapping], (formsMapping) => {
1954
1928
  return Object.values(formsMapping);
1955
1929
  });
1930
+ const selectFormById = (formId) => (state) => {
1931
+ return state.formReducer.instances[formId];
1932
+ };
1956
1933
  const selectFilteredForms = restructureCreateSelectorWithArgs(
1957
1934
  createSelector(
1958
1935
  [
@@ -1978,37 +1955,12 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
1978
1955
  { memoizeOptions: { resultEqualityCheck: shallowEqual } }
1979
1956
  )
1980
1957
  );
1981
- const selectFormById = (formId) => (state) => {
1982
- return state.formReducer.instances[formId];
1983
- };
1984
- const selectFormOfAssetType = restructureCreateSelectorWithArgs(
1985
- createSelector(
1986
- [selectFormMapping, (_state, assetTypeId) => assetTypeId],
1987
- (formsMapping, assetTypeId) => {
1988
- return Object.values(formsMapping).find((form) => form.asset_type === assetTypeId);
1989
- }
1990
- )
1991
- );
1992
- const selectFormOfIssueType = restructureCreateSelectorWithArgs(
1993
- createSelector(
1994
- [selectFormMapping, (_state, issueTypeId) => issueTypeId],
1995
- (formsMapping, issueTypeId) => {
1996
- return Object.values(formsMapping).find((form) => form.issue_type === issueTypeId);
1997
- }
1998
- )
1999
- );
2000
- const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
2001
- return Object.keys(formsMapping).length;
2002
- });
2003
- const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
2004
- return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2005
- });
2006
1958
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2007
- const initialState$e = submissionAdapter.getInitialState({});
1959
+ const initialState$m = submissionAdapter.getInitialState({});
2008
1960
  const formSubmissionSlice = createSlice({
2009
1961
  name: "formSubmissions",
2010
- initialState: initialState$e,
2011
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
1962
+ initialState: initialState$m,
1963
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
2012
1964
  reducers: {
2013
1965
  initializeFormSubmissions: submissionAdapter.initialize,
2014
1966
  setFormSubmission: submissionAdapter.setOne,
@@ -2063,43 +2015,6 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2063
2015
  }
2064
2016
  )
2065
2017
  );
2066
- const selectFormSubmissionsByFormRevisions = createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
2067
- var _a2;
2068
- const submissionMapping = {};
2069
- for (const revisionId in revisions) {
2070
- submissionMapping[revisionId] = [];
2071
- }
2072
- for (const submission of submissions) {
2073
- (_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
2074
- }
2075
- return submissionMapping;
2076
- });
2077
- const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
2078
- createSelector(
2079
- [
2080
- selectFormRevisionMapping,
2081
- selectFormSubmissionsByFormRevisions,
2082
- (_state, formId) => formId
2083
- ],
2084
- (revisionsMapping, submissionsByRevision, formId) => {
2085
- const submissionsByFormRevisions = {};
2086
- for (const revisionId in revisionsMapping) {
2087
- const revision = revisionsMapping[revisionId];
2088
- const submissionsOfRevision = submissionsByRevision[revisionId];
2089
- if (revision && submissionsOfRevision && revision.form === formId) {
2090
- submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
2091
- (a, b) => a.submitted_at < b.submitted_at ? -1 : 1
2092
- );
2093
- }
2094
- }
2095
- return Object.entries(submissionsByFormRevisions).sort((a, b) => {
2096
- const aRevision = revisionsMapping[a[0]];
2097
- const bRevision = revisionsMapping[b[0]];
2098
- return formRevisionSortFn(aRevision, bRevision);
2099
- }).map(([_revisionId, submissions]) => submissions).flat();
2100
- }
2101
- )
2102
- );
2103
2018
  const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2104
2019
  createSelector(
2105
2020
  [selectFormSubmissions, (_state, issueId) => issueId],
@@ -2110,53 +2025,6 @@ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2110
2025
  }
2111
2026
  )
2112
2027
  );
2113
- const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2114
- createSelector(
2115
- [
2116
- (state) => state.issueReducer.instances,
2117
- (state) => state.formReducer.instances,
2118
- (state) => state.formRevisionReducer.instances,
2119
- (state) => state.formSubmissionReducer.instances,
2120
- (_state, issueId) => issueId
2121
- ],
2122
- (issues, forms, formRevisions, submissions, issueId) => {
2123
- const issue = issues[issueId];
2124
- if (!issue) return [];
2125
- if (!issue.issue_type) {
2126
- return Object.values(submissions).filter((submission) => submission.issue === issueId);
2127
- }
2128
- const issueTypeForms = new Set(
2129
- Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
2130
- );
2131
- const issueTypeFormRevisions = new Set(
2132
- Object.keys(formRevisions).filter(
2133
- (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2134
- )
2135
- );
2136
- return Object.values(submissions).filter(
2137
- (submission) => submission.issue === issueId && !issueTypeFormRevisions.has(submission.form_revision)
2138
- );
2139
- }
2140
- )
2141
- );
2142
- const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
2143
- createSelector(
2144
- [selectFormSubmissions, (_state, issueIds) => issueIds],
2145
- (submissions, issueIds) => {
2146
- var _a2;
2147
- const issueSubmissions = {};
2148
- for (const issueId of issueIds) {
2149
- issueSubmissions[issueId] = [];
2150
- }
2151
- for (const submission of submissions) {
2152
- if (submission.issue && issueIds.includes(submission.issue)) {
2153
- (_a2 = issueSubmissions[submission.issue]) == null ? void 0 : _a2.push(submission);
2154
- }
2155
- }
2156
- return issueSubmissions;
2157
- }
2158
- )
2159
- );
2160
2028
  const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2161
2029
  createSelector(
2162
2030
  [selectFormSubmissions, (_state, assetId) => assetId],
@@ -2167,61 +2035,15 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2167
2035
  }
2168
2036
  )
2169
2037
  );
2170
- const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2171
- createSelector(
2172
- [
2173
- (state) => state.assetReducer.instances,
2174
- (state) => state.formReducer.instances,
2175
- (state) => state.formRevisionReducer.instances,
2176
- (state) => state.formSubmissionReducer.instances,
2177
- (_state, assetId) => assetId
2178
- ],
2179
- (assets, forms, formRevisions, submissions, assetId) => {
2180
- const asset = assets[assetId];
2181
- if (!asset) return [];
2182
- if (!asset.asset_type) {
2183
- return Object.values(submissions).filter((submission) => submission.asset === assetId);
2184
- }
2185
- const issueTypeForms = new Set(
2186
- Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
2187
- );
2188
- const issueTypeFormRevisions = new Set(
2189
- Object.keys(formRevisions).filter(
2190
- (formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
2191
- )
2192
- );
2193
- return Object.values(submissions).filter(
2194
- (submission) => submission.asset === assetId && !issueTypeFormRevisions.has(submission.form_revision)
2195
- );
2196
- }
2197
- )
2198
- );
2199
- const selectFormSubmissionsByAssets = createSelector(
2200
- [selectFormSubmissionsMapping, selectAssetsMapping],
2201
- (submissions, assets) => {
2202
- var _a2;
2203
- const assetSubmissionMapping = {};
2204
- for (const assetId in assets) {
2205
- assetSubmissionMapping[assetId] = [];
2206
- }
2207
- for (const submissionId in submissions) {
2208
- const submission = submissions[submissionId];
2209
- if (submission.asset) {
2210
- (_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
2211
- }
2212
- }
2213
- return assetSubmissionMapping;
2214
- }
2215
- );
2216
2038
  const formSubmissionReducer = formSubmissionSlice.reducer;
2217
2039
  const formSubmissionAttachmentAdapter = createModelAdapter(
2218
2040
  (attachment) => attachment.offline_id
2219
2041
  );
2220
- const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2042
+ const initialState$l = formSubmissionAttachmentAdapter.getInitialState({});
2221
2043
  const formSubmissionAttachmentSlice = createSlice({
2222
2044
  name: "formSubmissionAttachments",
2223
- initialState: initialState$d,
2224
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2045
+ initialState: initialState$l,
2046
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
2225
2047
  reducers: {
2226
2048
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2227
2049
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2264,7 +2086,9 @@ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2264
2086
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
2265
2087
  (attachmentsMapping, submissionId) => {
2266
2088
  return fallbackToEmptyArray(
2267
- Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId)
2089
+ Object.values(attachmentsMapping).filter(
2090
+ (attachment) => attachment.form_submission === submissionId
2091
+ )
2268
2092
  );
2269
2093
  }
2270
2094
  )
@@ -2273,11 +2097,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2273
2097
  const formRevisionAttachmentAdapter = createModelAdapter(
2274
2098
  (attachment) => attachment.offline_id
2275
2099
  );
2276
- const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2100
+ const initialState$k = formRevisionAttachmentAdapter.getInitialState({});
2277
2101
  const formRevisionAttachmentSlice = createSlice({
2278
2102
  name: "formRevisionAttachments",
2279
- initialState: initialState$c,
2280
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2103
+ initialState: initialState$k,
2104
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2281
2105
  reducers: {
2282
2106
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2283
2107
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2309,17 +2133,17 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2309
2133
  [selectFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
2310
2134
  (attachments, revisionId) => {
2311
2135
  return fallbackToEmptyArray(
2312
- Object.values(attachments).filter((attachment) => attachment.revision === revisionId)
2136
+ Object.values(attachments).filter((attachment) => attachment.form_revision === revisionId)
2313
2137
  );
2314
2138
  }
2315
2139
  )
2316
2140
  );
2317
2141
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2318
2142
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2319
- const initialState$b = workspaceAdapter.getInitialState({});
2143
+ const initialState$j = workspaceAdapter.getInitialState({});
2320
2144
  const workspaceSlice = createSlice({
2321
2145
  name: "workspace",
2322
- initialState: initialState$b,
2146
+ initialState: initialState$j,
2323
2147
  reducers: {
2324
2148
  initializeWorkspaces: workspaceAdapter.initialize,
2325
2149
  setWorkspaces: workspaceAdapter.setMany,
@@ -2350,10 +2174,10 @@ const selectPermittedWorkspaceIds = createSelector(
2350
2174
  );
2351
2175
  const workspaceReducer = workspaceSlice.reducer;
2352
2176
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2353
- const initialState$a = emailDomainAdapter.getInitialState({});
2177
+ const initialState$i = emailDomainAdapter.getInitialState({});
2354
2178
  const emailDomainsSlice = createSlice({
2355
2179
  name: "emailDomains",
2356
- initialState: initialState$a,
2180
+ initialState: initialState$i,
2357
2181
  reducers: {
2358
2182
  initializeEmailDomains: emailDomainAdapter.initialize,
2359
2183
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2374,14 +2198,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2374
2198
  )
2375
2199
  );
2376
2200
  const emailDomainsReducer = emailDomainsSlice.reducer;
2377
- const initialState$9 = {
2201
+ const initialState$h = {
2378
2202
  documents: {}
2379
2203
  };
2380
2204
  const documentSlice = createSlice({
2381
2205
  name: "documents",
2382
- initialState: initialState$9,
2206
+ initialState: initialState$h,
2383
2207
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2384
- Object.assign(state, initialState$9);
2208
+ Object.assign(state, initialState$h);
2385
2209
  }),
2386
2210
  reducers: {
2387
2211
  setDocuments: (state, action) => {
@@ -2569,11 +2393,11 @@ const selectRootDocuments = createSelector(
2569
2393
  );
2570
2394
  const documentsReducer = documentSlice.reducer;
2571
2395
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2572
- const initialState$8 = documentAttachmentAdapter.getInitialState({});
2396
+ const initialState$g = documentAttachmentAdapter.getInitialState({});
2573
2397
  const documentAttachmentSlice = createSlice({
2574
2398
  name: "documentAttachments",
2575
- initialState: initialState$8,
2576
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2399
+ initialState: initialState$g,
2400
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2577
2401
  reducers: {
2578
2402
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
2579
2403
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -2632,11 +2456,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
2632
2456
  );
2633
2457
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
2634
2458
  const teamAdapter = createModelAdapter((team) => team.offline_id);
2635
- const initialState$7 = teamAdapter.getInitialState({});
2459
+ const initialState$f = teamAdapter.getInitialState({});
2636
2460
  const teamSlice = createSlice({
2637
2461
  name: "teams",
2638
- initialState: initialState$7,
2639
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2462
+ initialState: initialState$f,
2463
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2640
2464
  reducers: {
2641
2465
  setTeam: teamAdapter.setOne,
2642
2466
  initializeTeams: teamAdapter.initialize,
@@ -2687,11 +2511,11 @@ const teamReducer = teamSlice.reducer;
2687
2511
  const agentUserConversationAdapter = createModelAdapter(
2688
2512
  (conversation) => conversation.offline_id
2689
2513
  );
2690
- const initialState$6 = agentUserConversationAdapter.getInitialState({});
2514
+ const initialState$e = agentUserConversationAdapter.getInitialState({});
2691
2515
  const agentsSlice = createSlice({
2692
2516
  name: "agents",
2693
- initialState: initialState$6,
2694
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2517
+ initialState: initialState$e,
2518
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2695
2519
  reducers: {
2696
2520
  initializeConversations: agentUserConversationAdapter.initialize,
2697
2521
  addConversation: agentUserConversationAdapter.addOne,
@@ -2713,11 +2537,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
2713
2537
  );
2714
2538
  const agentsReducer = agentsSlice.reducer;
2715
2539
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
2716
- const initialState$5 = issueCommentAdapter.getInitialState({});
2540
+ const initialState$d = issueCommentAdapter.getInitialState({});
2717
2541
  const issueCommentSlice = createSlice({
2718
2542
  name: "issueComments",
2719
- initialState: initialState$5,
2720
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2543
+ initialState: initialState$d,
2544
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2721
2545
  reducers: {
2722
2546
  addIssueComment: issueCommentAdapter.addOne,
2723
2547
  addIssueComments: issueCommentAdapter.addMany,
@@ -2746,11 +2570,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
2746
2570
  );
2747
2571
  const issueCommentReducer = issueCommentSlice.reducer;
2748
2572
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
2749
- const initialState$4 = issueUpdateAdapter.getInitialState({});
2573
+ const initialState$c = issueUpdateAdapter.getInitialState({});
2750
2574
  const issueUpdateSlice = createSlice({
2751
2575
  name: "issueUpdates",
2752
- initialState: initialState$4,
2753
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2576
+ initialState: initialState$c,
2577
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2754
2578
  reducers: {
2755
2579
  initializeIssueUpdates: issueUpdateAdapter.setMany,
2756
2580
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -2779,11 +2603,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
2779
2603
  );
2780
2604
  const issueUpdateReducer = issueUpdateSlice.reducer;
2781
2605
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2782
- const initialState$3 = issueAttachmentAdapter.getInitialState({});
2606
+ const initialState$b = issueAttachmentAdapter.getInitialState({});
2783
2607
  const issueAttachmentSlice = createSlice({
2784
2608
  name: "issueAttachments",
2785
- initialState: initialState$3,
2786
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
2609
+ initialState: initialState$b,
2610
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2787
2611
  reducers: {
2788
2612
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
2789
2613
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -2841,23 +2665,23 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2841
2665
  )
2842
2666
  );
2843
2667
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
2844
- const initialState$2 = {
2668
+ const initialState$a = {
2845
2669
  version: 0
2846
2670
  };
2847
2671
  const versioningSlice = createSlice({
2848
2672
  name: "versioning",
2849
- initialState: initialState$2,
2673
+ initialState: initialState$a,
2850
2674
  reducers: {}
2851
2675
  });
2852
2676
  const versioningReducer = versioningSlice.reducer;
2853
2677
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
2854
- const initialState$1 = geoImageAdapter.getInitialState({});
2678
+ const initialState$9 = geoImageAdapter.getInitialState({});
2855
2679
  const geoImageSlice = createSlice({
2856
2680
  name: "geoImages",
2857
- initialState: initialState$1,
2681
+ initialState: initialState$9,
2858
2682
  extraReducers: (builder) => {
2859
2683
  builder.addCase("RESET", (state) => {
2860
- Object.assign(state, initialState$1);
2684
+ Object.assign(state, initialState$9);
2861
2685
  });
2862
2686
  },
2863
2687
  reducers: {
@@ -2897,11 +2721,11 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
2897
2721
  );
2898
2722
  const geoImageReducer = geoImageSlice.reducer;
2899
2723
  const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
2900
- const initialState = issueAssociationAdapter.getInitialState({});
2724
+ const initialState$8 = issueAssociationAdapter.getInitialState({});
2901
2725
  const issueAssociationSlice = createSlice({
2902
2726
  name: "issueAssociations",
2903
- initialState,
2904
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
2727
+ initialState: initialState$8,
2728
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2905
2729
  reducers: {
2906
2730
  initializeIssueAssociations: issueAssociationAdapter.initialize,
2907
2731
  addIssueAssociation: issueAssociationAdapter.addOne,
@@ -2959,37 +2783,459 @@ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
2959
2783
  )
2960
2784
  );
2961
2785
  const issueAssociationReducer = issueAssociationSlice.reducer;
2962
- let clientStore;
2963
- function setClientStore(store) {
2964
- clientStore = store;
2965
- }
2966
- function getClientStore() {
2967
- return clientStore;
2968
- }
2969
- let clientSDK;
2970
- function setClientSDK(sdkCtor) {
2971
- clientSDK = sdkCtor;
2972
- }
2973
- function getClientSDK() {
2974
- return clientSDK;
2975
- }
2976
- const CLASS_NAME_TO_SERVICE = {};
2977
- class BaseService {
2978
- constructor(sdk) {
2979
- __publicField(this, "client");
2980
- CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
2981
- this.client = sdk;
2786
+ const issueTypeFieldValuesAdapter = createModelAdapter(
2787
+ (fieldValues) => fieldValues.offline_id
2788
+ );
2789
+ const initialState$7 = issueTypeFieldValuesAdapter.getInitialState({});
2790
+ const issueTypeFieldValuesSlice = createSlice({
2791
+ name: "issueTypeFieldValues",
2792
+ initialState: initialState$7,
2793
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2794
+ reducers: {
2795
+ initializeIssueTypeFieldValues: issueTypeFieldValuesAdapter.initialize,
2796
+ addIssueTypeFieldValues: issueTypeFieldValuesAdapter.addOne,
2797
+ addIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.addMany,
2798
+ setIssueTypeFieldValues: issueTypeFieldValuesAdapter.setOne,
2799
+ setIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.setMany,
2800
+ updateIssueTypeFieldValues: issueTypeFieldValuesAdapter.updateOne,
2801
+ updateIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.updateMany,
2802
+ deleteIssueTypeFieldValues: issueTypeFieldValuesAdapter.deleteOne,
2803
+ deleteIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.deleteMany
2982
2804
  }
2983
- async enqueueRequest(requestDetails) {
2984
- return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
2805
+ });
2806
+ const {
2807
+ initializeIssueTypeFieldValues,
2808
+ addIssueTypeFieldValues,
2809
+ addIssueTypeFieldValuesMany,
2810
+ setIssueTypeFieldValues,
2811
+ setIssueTypeFieldValuesMany,
2812
+ updateIssueTypeFieldValues,
2813
+ updateIssueTypeFieldValuesMany,
2814
+ deleteIssueTypeFieldValues,
2815
+ deleteIssueTypeFieldValuesMany
2816
+ } = issueTypeFieldValuesSlice.actions;
2817
+ const selectIssueTypeFieldValuesMapping = (state) => state.issueTypeFieldValuesReducer.instances;
2818
+ const selectIssueTypeFieldValues = createSelector([selectIssueTypeFieldValuesMapping], (fieldValuesMapping) => {
2819
+ return Object.values(fieldValuesMapping);
2820
+ });
2821
+ const selectIssueTypeFieldValuesOfIssue = restructureCreateSelectorWithArgs(
2822
+ createSelector([selectIssueTypeFieldValues, (_state, issueId) => issueId], (fieldValues, issueId) => {
2823
+ return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.issue === issueId));
2824
+ })
2825
+ );
2826
+ const selectIssueTypeFieldValuesById = (fieldValuesId) => (state) => {
2827
+ return state.issueTypeFieldValuesReducer.instances[fieldValuesId];
2828
+ };
2829
+ const issueTypeFieldValuesReducer = issueTypeFieldValuesSlice.reducer;
2830
+ const issueTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
2831
+ const initialState$6 = issueTypeFieldsAdapter.getInitialState({});
2832
+ const issueTypeFieldsSlice = createSlice({
2833
+ name: "issueTypeFields",
2834
+ initialState: initialState$6,
2835
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2836
+ reducers: {
2837
+ initializeIssueTypeFields: issueTypeFieldsAdapter.initialize,
2838
+ addIssueTypeFields: issueTypeFieldsAdapter.addOne,
2839
+ addIssueTypeFieldsMany: issueTypeFieldsAdapter.addMany,
2840
+ setIssueTypeFields: issueTypeFieldsAdapter.setOne,
2841
+ setIssueTypeFieldsMany: issueTypeFieldsAdapter.setMany,
2842
+ updateIssueTypeFields: issueTypeFieldsAdapter.updateOne,
2843
+ updateIssueTypeFieldsMany: issueTypeFieldsAdapter.updateMany,
2844
+ deleteIssueTypeFields: issueTypeFieldsAdapter.deleteOne,
2845
+ deleteIssueTypeFieldsMany: issueTypeFieldsAdapter.deleteMany
2985
2846
  }
2986
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2987
- dispatch(action) {
2988
- this.client.store.dispatch(action);
2847
+ });
2848
+ const {
2849
+ initializeIssueTypeFields,
2850
+ addIssueTypeFields,
2851
+ addIssueTypeFieldsMany,
2852
+ setIssueTypeFields,
2853
+ setIssueTypeFieldsMany,
2854
+ updateIssueTypeFields,
2855
+ updateIssueTypeFieldsMany,
2856
+ deleteIssueTypeFields,
2857
+ deleteIssueTypeFieldsMany
2858
+ } = issueTypeFieldsSlice.actions;
2859
+ const selectIssueTypeFieldsMapping = (state) => state.issueTypeFieldsReducer.instances;
2860
+ const selectIssueTypeFields = createSelector([selectIssueTypeFieldsMapping], (fieldsMapping) => {
2861
+ return Object.values(fieldsMapping);
2862
+ });
2863
+ const selectIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
2864
+ createSelector([selectIssueTypeFields, (_state, issueTypeId) => issueTypeId], (fields, issueTypeId) => {
2865
+ return fallbackToEmptyArray(fields.filter((field) => field.issue_type === issueTypeId));
2866
+ })
2867
+ );
2868
+ const selectLatestIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
2869
+ createSelector([selectIssueTypeFields, (_state, id) => id], (fields, id) => {
2870
+ return fields.filter((field) => field.issue_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
2871
+ })
2872
+ );
2873
+ const selectIssueTypeValuesOfIssueType = restructureCreateSelectorWithArgs(
2874
+ createSelector(
2875
+ [selectIssueTypeFields, selectIssueTypeFieldValues, (_state, id) => id],
2876
+ (fields, fieldValues, id) => {
2877
+ const fieldsIds = new Set(
2878
+ fields.filter((field) => field.issue_type === id).map((field) => field.offline_id)
2879
+ );
2880
+ return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
2881
+ }
2882
+ )
2883
+ );
2884
+ const selectIssueTypeFieldsById = (fieldsId) => (state) => {
2885
+ return state.issueTypeFieldsReducer.instances[fieldsId];
2886
+ };
2887
+ const issueTypeFieldsReducer = issueTypeFieldsSlice.reducer;
2888
+ const issueTypeFieldsAttachmentAdapter = createModelAdapter(
2889
+ (attachment) => attachment.offline_id
2890
+ );
2891
+ const initialState$5 = issueTypeFieldsAttachmentAdapter.getInitialState({});
2892
+ const issueTypeFieldsAttachmentSlice = createSlice({
2893
+ name: "issueTypeFieldsAttachments",
2894
+ initialState: initialState$5,
2895
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2896
+ reducers: {
2897
+ initializeIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.initialize,
2898
+ addIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.addOne,
2899
+ addIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.addMany,
2900
+ setIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.setOne,
2901
+ setIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.setMany,
2902
+ updateIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.updateOne,
2903
+ updateIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.updateMany,
2904
+ deleteIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.deleteOne,
2905
+ deleteIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.deleteMany
2989
2906
  }
2990
- }
2991
- const VERSION_REDUCER_KEY = "versioning";
2992
- const overmapReducers = {
2907
+ });
2908
+ const {
2909
+ initializeIssueTypeFieldsAttachments,
2910
+ addIssueTypeFieldsAttachment,
2911
+ addIssueTypeFieldsAttachments,
2912
+ setIssueTypeFieldsAttachment,
2913
+ setIssueTypeFieldsAttachments,
2914
+ updateIssueTypeFieldsAttachment,
2915
+ updateIssueTypeFieldsAttachments,
2916
+ deleteIssueTypeFieldsAttachment,
2917
+ deleteIssueTypeFieldsAttachments
2918
+ } = issueTypeFieldsAttachmentSlice.actions;
2919
+ const selectIssueTypeFieldsAttachmentsMapping = (state) => state.issueTypeFieldsAttachmentReducer.instances;
2920
+ const selectIssueTypeFieldsAttachments = createSelector(
2921
+ [selectIssueTypeFieldsAttachmentsMapping],
2922
+ (attachmentsMapping) => {
2923
+ return Object.values(attachmentsMapping);
2924
+ }
2925
+ );
2926
+ const selectAttachmentsOfIssueTypeFields = restructureCreateSelectorWithArgs(
2927
+ createSelector(
2928
+ [selectIssueTypeFieldsAttachments, (_state, fieldsRevision) => fieldsRevision],
2929
+ (attachments, fieldsRevision) => {
2930
+ return fallbackToEmptyArray(
2931
+ attachments.filter((attachment) => attachment.fields_revision === fieldsRevision)
2932
+ );
2933
+ }
2934
+ )
2935
+ );
2936
+ const selectIssueTypeFieldsAttachmentById = (attachmentId) => (state) => {
2937
+ return state.issueTypeFieldsAttachmentReducer.instances[attachmentId];
2938
+ };
2939
+ const issueTypeFieldsAttachmentReducer = issueTypeFieldsAttachmentSlice.reducer;
2940
+ const issueTypeFieldValuesAttachmentAdapter = createModelAdapter(
2941
+ (attachment) => attachment.offline_id
2942
+ );
2943
+ const initialState$4 = issueTypeFieldValuesAttachmentAdapter.getInitialState({});
2944
+ const issueTypeFieldValuesAttachmentSlice = createSlice({
2945
+ name: "issueTypeFieldValuesAttachments",
2946
+ initialState: initialState$4,
2947
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2948
+ reducers: {
2949
+ initializeIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.initialize,
2950
+ addIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.addOne,
2951
+ addIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.addMany,
2952
+ setIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.setOne,
2953
+ setIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.setMany,
2954
+ updateIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.updateOne,
2955
+ updateIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.updateMany,
2956
+ deleteIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.deleteOne,
2957
+ deleteIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.deleteMany
2958
+ }
2959
+ });
2960
+ const {
2961
+ initializeIssueTypeFieldValuesAttachments,
2962
+ addIssueTypeFieldValuesAttachment,
2963
+ addIssueTypeFieldValuesAttachments,
2964
+ setIssueTypeFieldValuesAttachment,
2965
+ setIssueTypeFieldValuesAttachments,
2966
+ updateIssueTypeFieldValuesAttachment,
2967
+ updateIssueTypeFieldValuesAttachments,
2968
+ deleteIssueTypeFieldValuesAttachment,
2969
+ deleteIssueTypeFieldValuesAttachments
2970
+ } = issueTypeFieldValuesAttachmentSlice.actions;
2971
+ const selectIssueTypeFieldValuesAttachmentsMapping = (state) => state.issueTypeFieldValuesAttachmentReducer.instances;
2972
+ const selectIssueTypeFieldValuesAttachments = createSelector(
2973
+ [selectIssueTypeFieldValuesAttachmentsMapping],
2974
+ (attachmentsMapping) => {
2975
+ return Object.values(attachmentsMapping);
2976
+ }
2977
+ );
2978
+ const selectIssueTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
2979
+ return state.issueTypeFieldValuesAttachmentReducer.instances[attachmentId];
2980
+ };
2981
+ const selectIssueTypeFieldValuesAttachmentsByIds = restructureCreateSelectorWithArgs(
2982
+ createSelector(
2983
+ [selectIssueTypeFieldValuesAttachmentsMapping, (_, attachmentIds) => attachmentIds],
2984
+ (mapping, attachmentIds) => {
2985
+ const attachmentIdsSet = new Set(attachmentIds);
2986
+ return fallbackToEmptyArray(
2987
+ Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id))
2988
+ );
2989
+ }
2990
+ )
2991
+ );
2992
+ const selectAttachmentsOfIssueTypeFieldValues = restructureCreateSelectorWithArgs(
2993
+ createSelector(
2994
+ [selectIssueTypeFieldValuesAttachments, (_state, fieldValuesId) => fieldValuesId],
2995
+ (attachments, fieldValuesId) => {
2996
+ return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === fieldValuesId));
2997
+ }
2998
+ )
2999
+ );
3000
+ const issueTypeFieldValuesAttachmentReducer = issueTypeFieldValuesAttachmentSlice.reducer;
3001
+ const assetTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
3002
+ const initialState$3 = assetTypeFieldsAdapter.getInitialState({});
3003
+ const assetTypeFieldsSlice = createSlice({
3004
+ name: "assetTypeFields",
3005
+ initialState: initialState$3,
3006
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3007
+ reducers: {
3008
+ initializeAssetTypeFields: assetTypeFieldsAdapter.initialize,
3009
+ addAssetTypeFields: assetTypeFieldsAdapter.addOne,
3010
+ addAssetTypeFieldsMany: assetTypeFieldsAdapter.addMany,
3011
+ setAssetTypeFields: assetTypeFieldsAdapter.setOne,
3012
+ setAssetTypeFieldsMany: assetTypeFieldsAdapter.setMany,
3013
+ updateAssetTypeFields: assetTypeFieldsAdapter.updateOne,
3014
+ updateAssetTypeFieldsMany: assetTypeFieldsAdapter.updateMany,
3015
+ deleteAssetTypeFields: assetTypeFieldsAdapter.deleteOne,
3016
+ deleteAssetTypeFieldsMany: assetTypeFieldsAdapter.deleteMany
3017
+ }
3018
+ });
3019
+ const {
3020
+ initializeAssetTypeFields,
3021
+ addAssetTypeFields,
3022
+ addAssetTypeFieldsMany,
3023
+ setAssetTypeFields,
3024
+ setAssetTypeFieldsMany,
3025
+ updateAssetTypeFields,
3026
+ updateAssetTypeFieldsMany,
3027
+ deleteAssetTypeFields,
3028
+ deleteAssetTypeFieldsMany
3029
+ } = assetTypeFieldsSlice.actions;
3030
+ const selectAssetTypeFieldsMapping = (state) => state.assetTypeFieldsReducer.instances;
3031
+ const selectAssetTypeFields = createSelector([selectAssetTypeFieldsMapping], (fieldsMapping) => {
3032
+ return Object.values(fieldsMapping);
3033
+ });
3034
+ const selectAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3035
+ createSelector([selectAssetTypeFields, (_state, assetTypeId) => assetTypeId], (fields, assetTypeId) => {
3036
+ return fallbackToEmptyArray(fields.filter((field) => field.asset_type === assetTypeId));
3037
+ })
3038
+ );
3039
+ const selectLatestAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
3040
+ createSelector([selectAssetTypeFields, (_state, id) => id], (fields, id) => {
3041
+ return fields.filter((field) => field.asset_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
3042
+ })
3043
+ );
3044
+ const selectAssetTypeFieldsById = (fieldsId) => (state) => {
3045
+ return state.assetTypeFieldsReducer.instances[fieldsId];
3046
+ };
3047
+ const assetTypeFieldsReducer = assetTypeFieldsSlice.reducer;
3048
+ const assetTypeFieldValuesAdapter = createModelAdapter(
3049
+ (fieldValues) => fieldValues.offline_id
3050
+ );
3051
+ const initialState$2 = assetTypeFieldValuesAdapter.getInitialState({});
3052
+ const assetTypeFieldValuesSlice = createSlice({
3053
+ name: "assetTypeFieldValues",
3054
+ initialState: initialState$2,
3055
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3056
+ reducers: {
3057
+ initializeAssetTypeFieldValues: assetTypeFieldValuesAdapter.initialize,
3058
+ addAssetTypeFieldValues: assetTypeFieldValuesAdapter.addOne,
3059
+ addAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.addMany,
3060
+ setAssetTypeFieldValues: assetTypeFieldValuesAdapter.setOne,
3061
+ setAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.setMany,
3062
+ updateAssetTypeFieldValues: assetTypeFieldValuesAdapter.updateOne,
3063
+ updateAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.updateMany,
3064
+ deleteAssetTypeFieldValues: assetTypeFieldValuesAdapter.deleteOne,
3065
+ deleteAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.deleteMany
3066
+ }
3067
+ });
3068
+ const {
3069
+ initializeAssetTypeFieldValues,
3070
+ addAssetTypeFieldValues,
3071
+ addAssetTypeFieldValuesMany,
3072
+ setAssetTypeFieldValues,
3073
+ setAssetTypeFieldValuesMany,
3074
+ updateAssetTypeFieldValues,
3075
+ updateAssetTypeFieldValuesMany,
3076
+ deleteAssetTypeFieldValues,
3077
+ deleteAssetTypeFieldValuesMany
3078
+ } = assetTypeFieldValuesSlice.actions;
3079
+ const selectAssetTypeFieldValuesMapping = (state) => state.assetTypeFieldValuesReducer.instances;
3080
+ const selectAssetTypeFieldValues = createSelector([selectAssetTypeFieldValuesMapping], (fieldValuesMapping) => {
3081
+ return Object.values(fieldValuesMapping);
3082
+ });
3083
+ const selectAssetTypeFieldValuesOfAsset = restructureCreateSelectorWithArgs(
3084
+ createSelector([selectAssetTypeFieldValues, (_state, assetId) => assetId], (fieldValues, assetId) => {
3085
+ return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.asset === assetId));
3086
+ })
3087
+ );
3088
+ const selectAssetTypeValuesOfAssetType = restructureCreateSelectorWithArgs(
3089
+ createSelector(
3090
+ [selectAssetTypeFields, selectAssetTypeFieldValues, (_state, id) => id],
3091
+ (fields, fieldValues, id) => {
3092
+ const fieldsIds = new Set(
3093
+ fields.filter((field) => field.asset_type === id).map((field) => field.offline_id)
3094
+ );
3095
+ return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
3096
+ }
3097
+ )
3098
+ );
3099
+ const selectAssetTypeFieldValuesById = (fieldValuesId) => (state) => {
3100
+ return state.assetTypeFieldValuesReducer.instances[fieldValuesId];
3101
+ };
3102
+ const assetTypeFieldValuesReducer = assetTypeFieldValuesSlice.reducer;
3103
+ const assetTypeFieldsAttachmentAdapter = createModelAdapter(
3104
+ (attachment) => attachment.offline_id
3105
+ );
3106
+ const initialState$1 = assetTypeFieldsAttachmentAdapter.getInitialState({});
3107
+ const assetTypeFieldsAttachmentSlice = createSlice({
3108
+ name: "assetTypeFieldsAttachments",
3109
+ initialState: initialState$1,
3110
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3111
+ reducers: {
3112
+ initializeAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.initialize,
3113
+ addAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.addOne,
3114
+ addAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.addMany,
3115
+ setAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.setOne,
3116
+ setAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.setMany,
3117
+ updateAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.updateOne,
3118
+ updateAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.updateMany,
3119
+ deleteAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.deleteOne,
3120
+ deleteAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.deleteMany
3121
+ }
3122
+ });
3123
+ const {
3124
+ initializeAssetTypeFieldsAttachments,
3125
+ addAssetTypeFieldsAttachment,
3126
+ addAssetTypeFieldsAttachments,
3127
+ setAssetTypeFieldsAttachment,
3128
+ setAssetTypeFieldsAttachments,
3129
+ updateAssetTypeFieldsAttachment,
3130
+ updateAssetTypeFieldsAttachments,
3131
+ deleteAssetTypeFieldsAttachment,
3132
+ deleteAssetTypeFieldsAttachments
3133
+ } = assetTypeFieldsAttachmentSlice.actions;
3134
+ const selectAssetTypeFieldsAttachmentsMapping = (state) => state.assetTypeFieldsAttachmentReducer.instances;
3135
+ const selectAssetTypeFieldsAttachments = createSelector(
3136
+ [selectAssetTypeFieldsAttachmentsMapping],
3137
+ (attachmentsMapping) => {
3138
+ return Object.values(attachmentsMapping);
3139
+ }
3140
+ );
3141
+ const selectAttachmentsOfAssetTypeFields = restructureCreateSelectorWithArgs(
3142
+ createSelector([selectAssetTypeFieldsAttachments, (_state, id) => id], (attachments, id) => {
3143
+ return fallbackToEmptyArray(attachments.filter((attachment) => attachment.fields_revision === id));
3144
+ })
3145
+ );
3146
+ const selectAssetTypeFieldsAttachmentById = (attachmentId) => (state) => {
3147
+ return state.assetTypeFieldsAttachmentReducer.instances[attachmentId];
3148
+ };
3149
+ const assetTypeFieldsAttachmentReducer = assetTypeFieldsAttachmentSlice.reducer;
3150
+ const assetTypeFieldValuesAttachmentAdapter = createModelAdapter(
3151
+ (attachment) => attachment.offline_id
3152
+ );
3153
+ const initialState = assetTypeFieldValuesAttachmentAdapter.getInitialState({});
3154
+ const assetTypeFieldValuesAttachmentSlice = createSlice({
3155
+ name: "assetTypeFieldValuesAttachments",
3156
+ initialState,
3157
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
3158
+ reducers: {
3159
+ initializeAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.initialize,
3160
+ addAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.addOne,
3161
+ addAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.addMany,
3162
+ setAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.setOne,
3163
+ setAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.setMany,
3164
+ updateAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.updateOne,
3165
+ updateAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.updateMany,
3166
+ deleteAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.deleteOne,
3167
+ deleteAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.deleteMany
3168
+ }
3169
+ });
3170
+ const {
3171
+ initializeAssetTypeFieldValuesAttachments,
3172
+ addAssetTypeFieldValuesAttachment,
3173
+ addAssetTypeFieldValuesAttachments,
3174
+ setAssetTypeFieldValuesAttachment,
3175
+ setAssetTypeFieldValuesAttachments,
3176
+ updateAssetTypeFieldValuesAttachment,
3177
+ updateAssetTypeFieldValuesAttachments,
3178
+ deleteAssetTypeFieldValuesAttachment,
3179
+ deleteAssetTypeFieldValuesAttachments
3180
+ } = assetTypeFieldValuesAttachmentSlice.actions;
3181
+ const selectAssetTypeFieldValuesAttachmentsMapping = (state) => state.assetTypeFieldValuesAttachmentReducer.instances;
3182
+ const selectAssetTypeFieldValuesAttachments = createSelector(
3183
+ [selectAssetTypeFieldValuesAttachmentsMapping],
3184
+ (attachmentsMapping) => {
3185
+ return Object.values(attachmentsMapping);
3186
+ }
3187
+ );
3188
+ const selectAssetTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
3189
+ return state.assetTypeFieldValuesAttachmentReducer.instances[attachmentId];
3190
+ };
3191
+ const selectAssetTypeFieldValuesAttachmentsByIds = restructureCreateSelectorWithArgs(
3192
+ createSelector(
3193
+ [selectAssetTypeFieldValuesAttachmentsMapping, (_, attachmentIds) => attachmentIds],
3194
+ (mapping, attachmentIds) => {
3195
+ const attachmentIdsSet = new Set(attachmentIds);
3196
+ return fallbackToEmptyArray(
3197
+ Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id))
3198
+ );
3199
+ }
3200
+ )
3201
+ );
3202
+ const selectAttachmentsOfAssetTypeFieldValues = restructureCreateSelectorWithArgs(
3203
+ createSelector([selectAssetTypeFieldValuesAttachments, (_state, id) => id], (attachments, id) => {
3204
+ return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === id));
3205
+ })
3206
+ );
3207
+ const assetTypeFieldValuesAttachmentReducer = assetTypeFieldValuesAttachmentSlice.reducer;
3208
+ let clientStore;
3209
+ function setClientStore(store) {
3210
+ clientStore = store;
3211
+ }
3212
+ function getClientStore() {
3213
+ return clientStore;
3214
+ }
3215
+ let clientSDK;
3216
+ function setClientSDK(sdkCtor) {
3217
+ clientSDK = sdkCtor;
3218
+ }
3219
+ function getClientSDK() {
3220
+ return clientSDK;
3221
+ }
3222
+ const CLASS_NAME_TO_SERVICE = {};
3223
+ class BaseService {
3224
+ constructor(sdk) {
3225
+ __publicField(this, "client");
3226
+ CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
3227
+ this.client = sdk;
3228
+ }
3229
+ async enqueueRequest(requestDetails) {
3230
+ return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
3231
+ }
3232
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3233
+ dispatch(action) {
3234
+ this.client.store.dispatch(action);
3235
+ }
3236
+ }
3237
+ const VERSION_REDUCER_KEY = "versioning";
3238
+ const overmapReducers = {
2993
3239
  // TODO: attachmentReducer,
2994
3240
  [VERSION_REDUCER_KEY]: versioningReducer,
2995
3241
  fileReducer,
@@ -3028,7 +3274,15 @@ const overmapReducers = {
3028
3274
  issueCommentReducer,
3029
3275
  issueUpdateReducer,
3030
3276
  geoImageReducer,
3031
- issueAssociationReducer
3277
+ issueAssociationReducer,
3278
+ issueTypeFieldsReducer,
3279
+ issueTypeFieldValuesReducer,
3280
+ issueTypeFieldsAttachmentReducer,
3281
+ issueTypeFieldValuesAttachmentReducer,
3282
+ assetTypeFieldsReducer,
3283
+ assetTypeFieldValuesReducer,
3284
+ assetTypeFieldsAttachmentReducer,
3285
+ assetTypeFieldValuesAttachmentReducer
3032
3286
  };
3033
3287
  const overmapReducer = combineReducers(overmapReducers);
3034
3288
  const resetStore = "RESET";
@@ -3629,9 +3883,6 @@ class CategoryService extends BaseApiService {
3629
3883
  description: "Create Category",
3630
3884
  method: HttpMethod.POST,
3631
3885
  url: "/categories/",
3632
- queryParams: {
3633
- workspace_id: payload.workspace.toString()
3634
- },
3635
3886
  payload: offlineCategory,
3636
3887
  blockers: [payload.workspace],
3637
3888
  blocks: [offlineCategory.offline_id]
@@ -3714,15 +3965,7 @@ class AssetService extends BaseApiService {
3714
3965
  description: "Create asset",
3715
3966
  method: HttpMethod.POST,
3716
3967
  url: "/assets/",
3717
- payload: {
3718
- offline_id: offlineAsset.offline_id,
3719
- submitted_at: offlineAsset.submitted_at,
3720
- geo_marker: offlineAsset.geo_marker,
3721
- canvas_marker: offlineAsset.canvas_marker,
3722
- label: offlineAsset.label,
3723
- description: offlineAsset.description,
3724
- asset_type: offlineAsset.asset_type
3725
- },
3968
+ payload: offlineAsset,
3726
3969
  blockers: [offlineAsset.asset_type],
3727
3970
  blocks: [offlineAsset.offline_id]
3728
3971
  });
@@ -3797,7 +4040,7 @@ class AssetService extends BaseApiService {
3797
4040
  throw e;
3798
4041
  });
3799
4042
  }
3800
- bulkAdd(payloads, assetTypeId, batchSize) {
4043
+ bulkAdd(payloads, assetTypeId, projectId, batchSize) {
3801
4044
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
3802
4045
  const transactionId = v4();
3803
4046
  const assetBatches = chunkArray(payloads, batchSize).map((assetBatch) => {
@@ -3808,6 +4051,7 @@ class AssetService extends BaseApiService {
3808
4051
  transaction_id: transactionId,
3809
4052
  submitted_at: submittedAt,
3810
4053
  asset_type: assetTypeId,
4054
+ project: projectId,
3811
4055
  assets: assetPayloads
3812
4056
  }
3813
4057
  };
@@ -3842,7 +4086,10 @@ class AssetService extends BaseApiService {
3842
4086
  const result = await this.enqueueRequest({
3843
4087
  description: "Get assets",
3844
4088
  method: HttpMethod.GET,
3845
- url: `/projects/${projectId}/assets/`,
4089
+ url: "/assets/",
4090
+ queryParams: {
4091
+ project: projectId.toString()
4092
+ },
3846
4093
  blockers: [],
3847
4094
  blocks: []
3848
4095
  });
@@ -3863,7 +4110,7 @@ class AssetStageCompletionService extends BaseApiService {
3863
4110
  const promise = this.enqueueRequest({
3864
4111
  description: "Add asset stage completion",
3865
4112
  method: HttpMethod.POST,
3866
- url: "/assets/completions/",
4113
+ url: "/asset-stage-completions/",
3867
4114
  payload: {
3868
4115
  offline_id: offlineStageCompletion.offline_id,
3869
4116
  submitted_at: submittedAt,
@@ -3890,7 +4137,7 @@ class AssetStageCompletionService extends BaseApiService {
3890
4137
  const promise = this.enqueueRequest({
3891
4138
  description: "Delete asset stage completion",
3892
4139
  method: HttpMethod.DELETE,
3893
- url: `/assets/completions/${id}/`,
4140
+ url: `/asset-stage-completions/${id}/`,
3894
4141
  blockers: [id],
3895
4142
  blocks: []
3896
4143
  });
@@ -3916,7 +4163,7 @@ class AssetStageCompletionService extends BaseApiService {
3916
4163
  const promise = this.enqueueRequest({
3917
4164
  description: "Bulk create asset stage completions",
3918
4165
  method: HttpMethod.POST,
3919
- url: "/assets/completions/bulk/",
4166
+ url: "/asset-stage-completions/bulk/",
3920
4167
  payload: {
3921
4168
  submitted_at: submittedAt,
3922
4169
  completions: payload
@@ -3938,7 +4185,7 @@ class AssetStageCompletionService extends BaseApiService {
3938
4185
  const promise = this.enqueueRequest({
3939
4186
  description: "Deleting asset stage completions",
3940
4187
  method: HttpMethod.DELETE,
3941
- url: "/assets/completions/bulk/",
4188
+ url: "/asset-stage-completions/bulk/",
3942
4189
  payload: {
3943
4190
  completion_ids: ids
3944
4191
  },
@@ -3954,7 +4201,10 @@ class AssetStageCompletionService extends BaseApiService {
3954
4201
  const result = await this.enqueueRequest({
3955
4202
  description: "Get asset stage completions",
3956
4203
  method: HttpMethod.GET,
3957
- url: `/projects/${projectId}/asset-stage-completions/`,
4204
+ url: "/asset-stage-completions/",
4205
+ queryParams: {
4206
+ project: projectId.toString()
4207
+ },
3958
4208
  blockers: [],
3959
4209
  blocks: []
3960
4210
  });
@@ -3975,7 +4225,7 @@ class AssetStageService extends BaseApiService {
3975
4225
  const promise = this.enqueueRequest({
3976
4226
  description: "Add asset stages",
3977
4227
  method: HttpMethod.POST,
3978
- url: "/assets/stages/bulk/",
4228
+ url: "/asset-stages/bulk/",
3979
4229
  payload: {
3980
4230
  submitted_at: submittedAt,
3981
4231
  asset_type: assetTypeId,
@@ -3999,7 +4249,7 @@ class AssetStageService extends BaseApiService {
3999
4249
  return this.enqueueRequest({
4000
4250
  description: "Edit asset stages",
4001
4251
  method: HttpMethod.PATCH,
4002
- url: `/assets/types/${assetTypeId}/bulk-update-stages/`,
4252
+ url: `/asset-types/${assetTypeId}/bulk-update-stages/`,
4003
4253
  payload: {
4004
4254
  stages: stagesToUpdate
4005
4255
  },
@@ -4017,7 +4267,7 @@ class AssetStageService extends BaseApiService {
4017
4267
  const promise = this.enqueueRequest({
4018
4268
  description: "Delete asset stages",
4019
4269
  method: HttpMethod.DELETE,
4020
- url: "/assets/stages/bulk/",
4270
+ url: "/asset-stages/bulk/",
4021
4271
  payload: {
4022
4272
  stage_ids: idsToDelete
4023
4273
  },
@@ -4041,7 +4291,7 @@ class AssetStageService extends BaseApiService {
4041
4291
  const promise = this.enqueueRequest({
4042
4292
  description: "Update asset stage",
4043
4293
  method: HttpMethod.PATCH,
4044
- url: `/assets/stages/${assetStage.offline_id}/`,
4294
+ url: `/asset-stages/${assetStage.offline_id}/`,
4045
4295
  payload: {
4046
4296
  name: payload.name,
4047
4297
  description: payload.description,
@@ -4058,52 +4308,14 @@ class AssetStageService extends BaseApiService {
4058
4308
  });
4059
4309
  return [updatedAssetStage, promise];
4060
4310
  }
4061
- async linkForm(stageId, formId) {
4062
- const { store } = this.client;
4063
- const stage = store.getState().assetStageReducer.instances[stageId];
4064
- if (!stage) {
4065
- throw new Error(`No asset stage with id ${stageId} found in the store`);
4066
- }
4067
- this.dispatch(updateAssetStage({ ...stage, form: formId }));
4068
- try {
4069
- await this.enqueueRequest({
4070
- description: "Link asset stage to form",
4071
- method: HttpMethod.POST,
4072
- url: `/assets/stages/${stageId}/associate-with-form/`,
4073
- payload: { form: formId },
4074
- blockers: [stageId, formId],
4075
- blocks: [stageId]
4076
- });
4077
- } catch (e) {
4078
- this.dispatch(setAssetStage(stage));
4079
- throw e;
4080
- }
4081
- }
4082
- async unlinkForm(stageId, formId) {
4083
- const { store } = this.client;
4084
- const stage = store.getState().assetStageReducer.instances[stageId];
4085
- if (!stage) {
4086
- throw new Error(`No asset stage with id ${stageId} found in the store`);
4087
- }
4088
- this.dispatch(updateAssetStage({ ...stage, form: void 0 }));
4089
- try {
4090
- await this.enqueueRequest({
4091
- description: "Unlink asset stage from form",
4092
- method: HttpMethod.DELETE,
4093
- url: `/assets/stages/${stageId}/associate-with-form/`,
4094
- blockers: [stageId, formId],
4095
- blocks: [stageId]
4096
- });
4097
- } catch (e) {
4098
- this.dispatch(setAssetStage(stage));
4099
- throw e;
4100
- }
4101
- }
4102
- async refreshStore(projectId) {
4311
+ async refreshStore(organizationId) {
4103
4312
  const result = await this.enqueueRequest({
4104
4313
  description: "Get asset stages",
4105
4314
  method: HttpMethod.GET,
4106
- url: `/projects/${projectId}/asset-stages/`,
4315
+ url: "/asset-stages/",
4316
+ queryParams: {
4317
+ organization: organizationId.toString()
4318
+ },
4107
4319
  blockers: [],
4108
4320
  blocks: []
4109
4321
  });
@@ -4120,7 +4332,12 @@ class BaseUploadService extends BaseApiService {
4120
4332
  projectAttachmentReducer: projectAttachmentReducer2,
4121
4333
  formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
4122
4334
  formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
4123
- geoImageReducer: geoImageReducer2
4335
+ geoImageReducer: geoImageReducer2,
4336
+ // fields
4337
+ assetTypeFieldsAttachmentReducer: assetTypeFieldsAttachmentReducer2,
4338
+ assetTypeFieldValuesAttachmentReducer: assetTypeFieldValuesAttachmentReducer2,
4339
+ issueTypeFieldsAttachmentReducer: issueTypeFieldsAttachmentReducer2,
4340
+ issueTypeFieldValuesAttachmentReducer: issueTypeFieldValuesAttachmentReducer2
4124
4341
  } = this.client.store.getState();
4125
4342
  const objectsWithSha1 = [].concat(
4126
4343
  Object.values(issueAttachmentReducer2.instances),
@@ -4130,7 +4347,11 @@ class BaseUploadService extends BaseApiService {
4130
4347
  Object.values(projectAttachmentReducer2.instances),
4131
4348
  Object.values(formRevisionAttachmentReducer2.instances),
4132
4349
  Object.values(formSubmissionAttachmentReducer2.instances),
4133
- Object.values(geoImageReducer2.instances)
4350
+ Object.values(geoImageReducer2.instances),
4351
+ Object.values(assetTypeFieldsAttachmentReducer2.instances),
4352
+ Object.values(assetTypeFieldValuesAttachmentReducer2.instances),
4353
+ Object.values(issueTypeFieldsAttachmentReducer2.instances),
4354
+ Object.values(issueTypeFieldValuesAttachmentReducer2.instances)
4134
4355
  );
4135
4356
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4136
4357
  }
@@ -4152,41 +4373,20 @@ class BaseUploadService extends BaseApiService {
4152
4373
  }
4153
4374
  return promisesBySha1;
4154
4375
  }
4155
- }
4156
- const AttachmentModelMeta = {
4157
- [AttachmentModel.Issue]: {
4158
- name: "issue",
4159
- attachUrlPrefix: "/issues",
4160
- deleteUrlPrefix: "/issues",
4161
- fetchUrlPostfix: "/issue-attachments"
4162
- },
4163
- [AttachmentModel.Asset]: {
4164
- name: "asset",
4165
- attachUrlPrefix: "/assets",
4166
- deleteUrlPrefix: "/assets",
4167
- fetchUrlPostfix: "/asset-attachments"
4168
- },
4169
- [AttachmentModel.AssetType]: {
4170
- name: "asset type",
4171
- attachUrlPrefix: "/assets/types",
4172
- deleteUrlPrefix: "/assets/types",
4173
- fetchUrlPostfix: "/asset-type-attachments"
4174
- },
4175
- [AttachmentModel.Project]: {
4176
- name: "project",
4177
- attachUrlPrefix: "/projects",
4178
- deleteUrlPrefix: "/projects",
4179
- fetchUrlPostfix: "/attachments"
4180
- },
4181
- [AttachmentModel.Document]: {
4182
- name: "document",
4183
- attachUrlPrefix: "/documents",
4184
- deleteUrlPrefix: "/documents",
4185
- fetchUrlPostfix: "/document-attachments"
4376
+ async getFilePayload(file) {
4377
+ const sha1 = await hashFile(file);
4378
+ const filePayload = {
4379
+ sha1,
4380
+ file_type: file.type,
4381
+ extension: file.name.split(".").pop(),
4382
+ size: file.size
4383
+ };
4384
+ await this.client.files.addCache(file, sha1);
4385
+ return filePayload;
4186
4386
  }
4187
- };
4387
+ }
4188
4388
  class BaseAttachmentService extends BaseUploadService {
4189
- async attachFiles(files, modelId, buildOfflineAttachment) {
4389
+ async _bulkAdd(payloads) {
4190
4390
  var _a2;
4191
4391
  const { store } = this.client;
4192
4392
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
@@ -4194,39 +4394,35 @@ class BaseAttachmentService extends BaseUploadService {
4194
4394
  const offlineAttachments = [];
4195
4395
  const attachmentPayloads = [];
4196
4396
  const filePayloads = {};
4197
- for (const file of files) {
4198
- const sha1 = await hashFile(file);
4199
- if (!(sha1 in filePayloads)) {
4200
- filePayloads[sha1] = {
4201
- sha1,
4202
- file_type: file.type,
4203
- extension: file.name.split(".").pop(),
4204
- size: file.size
4205
- };
4206
- await this.client.files.addCache(file, sha1);
4207
- }
4208
- const offlineAttachment = buildOfflineAttachment({
4397
+ for (const payload of payloads) {
4398
+ const { modelId, file } = payload;
4399
+ const filePayload = await this.getFilePayload(file);
4400
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
4401
+ const offlineAttachment = this.buildOfflineAttachment({
4209
4402
  file,
4210
- sha1,
4211
- submittedAt,
4212
- createdBy,
4403
+ file_sha1: filePayload.sha1,
4404
+ submitted_at: submittedAt,
4405
+ created_by: createdBy,
4213
4406
  description: "",
4214
4407
  modelId
4215
4408
  });
4216
4409
  offlineAttachments.push(offlineAttachment);
4217
- attachmentPayloads.push({
4218
- offline_id: offlineAttachment.offline_id,
4219
- name: offlineAttachment.file_name,
4220
- sha1: offlineAttachment.file_sha1,
4221
- description: offlineAttachment.description
4222
- });
4410
+ attachmentPayloads.push(
4411
+ this.buildAttachmentPayload({
4412
+ offline_id: offlineAttachment.offline_id,
4413
+ file_name: offlineAttachment.file_name,
4414
+ file_sha1: offlineAttachment.file_sha1,
4415
+ file_extension: filePayload.extension,
4416
+ description: offlineAttachment.description,
4417
+ modelId
4418
+ })
4419
+ );
4223
4420
  }
4224
4421
  this.dispatch(this.addAttachments(offlineAttachments));
4225
- const meta = AttachmentModelMeta[this.attachmentModel];
4226
4422
  const promise = this.enqueueRequest({
4227
- description: `Attach files to ${meta.name}`,
4423
+ description: `Add ${this.name}`,
4228
4424
  method: HttpMethod.POST,
4229
- url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
4425
+ url: `${this.url}/bulk/`,
4230
4426
  payload: {
4231
4427
  submitted_at: submittedAt,
4232
4428
  attachments: attachmentPayloads,
@@ -4243,7 +4439,7 @@ class BaseAttachmentService extends BaseUploadService {
4243
4439
  });
4244
4440
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
4245
4441
  }
4246
- async deleteAttachment(attachmendId) {
4442
+ async _delete(attachmendId) {
4247
4443
  const { store } = this.client;
4248
4444
  const attachment = this.selectAttachment(attachmendId)(store.getState());
4249
4445
  if (!attachment) {
@@ -4252,11 +4448,10 @@ class BaseAttachmentService extends BaseUploadService {
4252
4448
  );
4253
4449
  }
4254
4450
  this.dispatch(this.removeAttachment(attachment.offline_id));
4255
- const meta = AttachmentModelMeta[this.attachmentModel];
4256
4451
  const promise = this.enqueueRequest({
4257
- description: "Delete attachment",
4452
+ description: `Delete ${this.name}`,
4258
4453
  method: HttpMethod.DELETE,
4259
- url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
4454
+ url: `${this.url}/${attachmendId}/`,
4260
4455
  blockers: [attachmendId],
4261
4456
  blocks: []
4262
4457
  });
@@ -4269,24 +4464,12 @@ class BaseAttachmentService extends BaseUploadService {
4269
4464
  });
4270
4465
  return promise;
4271
4466
  }
4272
- // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4273
- // so for some attachment model services, this method will have to be overridden.
4274
- async refreshStore(projectId, _organizationId) {
4275
- const meta = AttachmentModelMeta[this.attachmentModel];
4276
- const result = await this.enqueueRequest({
4277
- description: `Get ${meta.name} attachments`,
4278
- method: HttpMethod.GET,
4279
- url: `/projects/${projectId}${meta.fetchUrlPostfix}/`,
4280
- blocks: [],
4281
- blockers: []
4282
- });
4283
- this.dispatch(this.initializeAttachments(result));
4284
- }
4285
4467
  }
4286
4468
  class AssetAttachmentService extends BaseAttachmentService {
4287
4469
  constructor() {
4288
4470
  super(...arguments);
4289
- __publicField(this, "attachmentModel", AttachmentModel.Asset);
4471
+ __publicField(this, "name", "Asset Attachment");
4472
+ __publicField(this, "url", "/asset-attachments");
4290
4473
  __publicField(this, "initializeAttachments", initializeAssetAttachments);
4291
4474
  __publicField(this, "addAttachments", addAssetAttachments);
4292
4475
  __publicField(this, "updateAttachments", updateAssetAttachments);
@@ -4298,20 +4481,39 @@ class AssetAttachmentService extends BaseAttachmentService {
4298
4481
  buildOfflineAttachment(data) {
4299
4482
  return offline({
4300
4483
  file: URL.createObjectURL(data.file),
4301
- file_sha1: data.sha1,
4302
- created_by: data.createdBy,
4484
+ file_sha1: data.file_sha1,
4485
+ created_by: data.created_by,
4303
4486
  file_name: data.file.name,
4304
4487
  file_type: data.file.type,
4305
- submitted_at: data.submittedAt,
4488
+ submitted_at: data.submitted_at,
4306
4489
  description: data.description,
4307
4490
  asset: data.modelId
4308
4491
  });
4309
4492
  }
4310
- async attachFilesToAsset(files, assetId) {
4311
- return this.attachFiles(files, assetId, this.buildOfflineAttachment.bind(this));
4493
+ buildAttachmentPayload(data) {
4494
+ return {
4495
+ ...data,
4496
+ asset: data.modelId
4497
+ };
4498
+ }
4499
+ async bulkAdd(payloads) {
4500
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetId, file: p.file })));
4501
+ }
4502
+ async delete(id) {
4503
+ return this._delete(id);
4312
4504
  }
4313
- async deleteAssetAttachment(attachmentId) {
4314
- return this.deleteAttachment(attachmentId);
4505
+ async refreshStore(projectId) {
4506
+ const result = await this.enqueueRequest({
4507
+ description: "Get asset attachments",
4508
+ method: HttpMethod.GET,
4509
+ url: `${this.url}/`,
4510
+ queryParams: {
4511
+ project: projectId.toString()
4512
+ },
4513
+ blocks: [],
4514
+ blockers: []
4515
+ });
4516
+ this.dispatch(initializeAssetAttachments(result));
4315
4517
  }
4316
4518
  }
4317
4519
  class AssetTypeService extends BaseApiService {
@@ -4328,8 +4530,8 @@ class AssetTypeService extends BaseApiService {
4328
4530
  const promise = this.enqueueRequest({
4329
4531
  description: "Create asset type",
4330
4532
  method: HttpMethod.POST,
4331
- url: `/projects/${payload.project}/asset-types/`,
4332
- payload: { ...offlineAssetType },
4533
+ url: "/asset-types/",
4534
+ payload: offlineAssetType,
4333
4535
  blockers: [],
4334
4536
  blocks: [offlineAssetType.offline_id]
4335
4537
  });
@@ -4354,7 +4556,7 @@ class AssetTypeService extends BaseApiService {
4354
4556
  const promise = this.enqueueRequest({
4355
4557
  description: "Update asset type",
4356
4558
  method: HttpMethod.PATCH,
4357
- url: `/assets/types/${payload.offline_id}/`,
4559
+ url: `/asset-types/${payload.offline_id}/`,
4358
4560
  payload: {
4359
4561
  icon: payload.icon,
4360
4562
  color: payload.color,
@@ -4388,7 +4590,7 @@ class AssetTypeService extends BaseApiService {
4388
4590
  return this.enqueueRequest({
4389
4591
  description: "Delete asset type",
4390
4592
  method: HttpMethod.DELETE,
4391
- url: `/assets/types/${assetTypeId}/`,
4593
+ url: `/asset-types/${assetTypeId}/`,
4392
4594
  blockers: [assetTypeId],
4393
4595
  blocks: []
4394
4596
  }).catch((e) => {
@@ -4399,11 +4601,14 @@ class AssetTypeService extends BaseApiService {
4399
4601
  throw e;
4400
4602
  });
4401
4603
  }
4402
- async refreshStore(projectId) {
4604
+ async refreshStore(organizationId) {
4403
4605
  const result = await this.enqueueRequest({
4404
4606
  description: "Get asset types",
4405
4607
  method: HttpMethod.GET,
4406
- url: `/projects/${projectId}/asset-types/`,
4608
+ url: "/asset-types/",
4609
+ queryParams: {
4610
+ organization: organizationId.toString()
4611
+ },
4407
4612
  blockers: [],
4408
4613
  blocks: []
4409
4614
  });
@@ -4413,8 +4618,8 @@ class AssetTypeService extends BaseApiService {
4413
4618
  class AssetTypeAttachmentService extends BaseAttachmentService {
4414
4619
  constructor() {
4415
4620
  super(...arguments);
4416
- __publicField(this, "attachmentModel", AttachmentModel.AssetType);
4417
- __publicField(this, "initializeAttachments", initializeAssetTypeAttachments);
4621
+ __publicField(this, "name", "Asset Type Attachment");
4622
+ __publicField(this, "url", "/asset-type-attachments");
4418
4623
  __publicField(this, "addAttachments", addAssetTypeAttachments);
4419
4624
  __publicField(this, "updateAttachments", updateAssetTypeAttachments);
4420
4625
  __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
@@ -4425,20 +4630,39 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4425
4630
  buildOfflineAttachment(data) {
4426
4631
  return offline({
4427
4632
  file: URL.createObjectURL(data.file),
4428
- file_sha1: data.sha1,
4429
- created_by: data.createdBy,
4633
+ file_sha1: data.file_sha1,
4634
+ created_by: data.created_by,
4430
4635
  file_name: data.file.name,
4431
4636
  file_type: data.file.type,
4432
- submitted_at: data.submittedAt,
4637
+ submitted_at: data.submitted_at,
4433
4638
  description: data.description,
4434
4639
  asset_type: data.modelId
4435
4640
  });
4436
4641
  }
4437
- async attachFilesToAssetType(files, assetTypeId) {
4438
- return this.attachFiles(files, assetTypeId, this.buildOfflineAttachment.bind(this));
4642
+ buildAttachmentPayload(data) {
4643
+ return {
4644
+ ...data,
4645
+ asset_type: data.modelId
4646
+ };
4647
+ }
4648
+ async bulkAdd(payloads) {
4649
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetTypeId, file: p.file })));
4650
+ }
4651
+ async delete(attachmentId) {
4652
+ return this._delete(attachmentId);
4439
4653
  }
4440
- async deleteAssetTypeAttachment(attachmentId) {
4441
- return this.deleteAttachment(attachmentId);
4654
+ async refreshStore(organizationId) {
4655
+ const result = await this.enqueueRequest({
4656
+ description: "Get asset type attachments",
4657
+ method: HttpMethod.GET,
4658
+ url: `${this.url}/`,
4659
+ queryParams: {
4660
+ organization: organizationId.toString()
4661
+ },
4662
+ blocks: [],
4663
+ blockers: []
4664
+ });
4665
+ this.dispatch(initializeAssetTypeAttachments(result));
4442
4666
  }
4443
4667
  }
4444
4668
  class IssueCommentService extends BaseApiService {
@@ -4454,7 +4678,7 @@ class IssueCommentService extends BaseApiService {
4454
4678
  const promise = this.enqueueRequest({
4455
4679
  description: "Add issue comment",
4456
4680
  method: HttpMethod.POST,
4457
- url: `/issues/${payload.issue}/comment/`,
4681
+ url: "/issue-comments/",
4458
4682
  payload: offlineComment,
4459
4683
  blockers: [payload.issue],
4460
4684
  blocks: [offlineComment.offline_id]
@@ -4478,7 +4702,7 @@ class IssueCommentService extends BaseApiService {
4478
4702
  const promise = this.enqueueRequest({
4479
4703
  description: "Edit issue comment",
4480
4704
  method: HttpMethod.PATCH,
4481
- url: `/issues/comments/${payload.offline_id}/`,
4705
+ url: `/issue-comments/${payload.offline_id}/`,
4482
4706
  payload,
4483
4707
  blockers: [payload.offline_id],
4484
4708
  blocks: [payload.offline_id]
@@ -4497,7 +4721,7 @@ class IssueCommentService extends BaseApiService {
4497
4721
  const promise = this.enqueueRequest({
4498
4722
  description: "Delete comment",
4499
4723
  method: HttpMethod.DELETE,
4500
- url: `/issues/comments/${id}/`,
4724
+ url: `/issue-comments/${id}/`,
4501
4725
  blockers: [id],
4502
4726
  blocks: []
4503
4727
  });
@@ -4510,7 +4734,10 @@ class IssueCommentService extends BaseApiService {
4510
4734
  const result = await this.enqueueRequest({
4511
4735
  description: "Get comments",
4512
4736
  method: HttpMethod.GET,
4513
- url: `/projects/${projectId}/comments/`,
4737
+ url: "/issue-comments/",
4738
+ queryParams: {
4739
+ project: projectId.toString()
4740
+ },
4514
4741
  blockers: [],
4515
4742
  blocks: []
4516
4743
  });
@@ -4522,27 +4749,21 @@ class IssueUpdateService extends BaseApiService {
4522
4749
  const result = await this.enqueueRequest({
4523
4750
  description: "Get issue updates",
4524
4751
  method: HttpMethod.GET,
4525
- url: `/projects/${projectId}/issues/updates/`,
4752
+ url: "/issue-updates/",
4753
+ queryParams: {
4754
+ project: projectId.toString()
4755
+ },
4526
4756
  blockers: [],
4527
4757
  blocks: []
4528
4758
  });
4529
- let filteredResult = result.filter(onlyUniqueOfflineIds);
4530
- filteredResult = filteredResult.map((comment) => {
4531
- return { ...comment };
4532
- });
4533
- if (result.length !== filteredResult.length) {
4534
- console.error(
4535
- `Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
4536
- );
4537
- }
4538
- this.dispatch(initializeIssueUpdates(filteredResult));
4759
+ this.dispatch(initializeIssueUpdates(result));
4539
4760
  }
4540
4761
  }
4541
4762
  class IssueAttachmentService extends BaseAttachmentService {
4542
4763
  constructor() {
4543
4764
  super(...arguments);
4544
- __publicField(this, "attachmentModel", AttachmentModel.Issue);
4545
- __publicField(this, "initializeAttachments", initializeIssueAttachments);
4765
+ __publicField(this, "name", "Issue Attachment");
4766
+ __publicField(this, "url", "/issue-attachments");
4546
4767
  __publicField(this, "addAttachments", addIssueAttachments);
4547
4768
  __publicField(this, "updateAttachments", updateIssueAttachments);
4548
4769
  __publicField(this, "removeAttachments", deleteIssueAttachments);
@@ -4553,24 +4774,42 @@ class IssueAttachmentService extends BaseAttachmentService {
4553
4774
  buildOfflineAttachment(data) {
4554
4775
  return offline({
4555
4776
  file: URL.createObjectURL(data.file),
4556
- file_sha1: data.sha1,
4557
- created_by: data.createdBy,
4777
+ file_sha1: data.file_sha1,
4778
+ created_by: data.created_by,
4558
4779
  file_name: data.file.name,
4559
4780
  file_type: data.file.type,
4560
- submitted_at: data.submittedAt,
4781
+ submitted_at: data.submitted_at,
4561
4782
  description: data.description,
4562
4783
  issue: data.modelId
4563
4784
  });
4564
4785
  }
4565
- async attachFilesToIssue(files, issueId) {
4566
- return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this));
4786
+ buildAttachmentPayload(data) {
4787
+ return {
4788
+ ...data,
4789
+ issue: data.modelId
4790
+ };
4791
+ }
4792
+ async bulkAdd(payloads) {
4793
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.issueId, file: p.file })));
4794
+ }
4795
+ async delete(id) {
4796
+ return this._delete(id);
4567
4797
  }
4568
- async deleteIssueAttachment(attachmentId) {
4569
- return this.deleteAttachment(attachmentId);
4798
+ async refreshStore(projectId) {
4799
+ const result = await this.enqueueRequest({
4800
+ description: "Get issue attachments",
4801
+ method: HttpMethod.GET,
4802
+ url: `${this.url}/`,
4803
+ queryParams: {
4804
+ project: projectId.toString()
4805
+ },
4806
+ blocks: [],
4807
+ blockers: []
4808
+ });
4809
+ this.dispatch(initializeIssueAttachments(result));
4570
4810
  }
4571
4811
  }
4572
4812
  class IssueService extends BaseApiService {
4573
- // Basic CRUD functions
4574
4813
  add(payload) {
4575
4814
  var _a2;
4576
4815
  const { store } = this.client;
@@ -4587,10 +4826,6 @@ class IssueService extends BaseApiService {
4587
4826
  description: "Create issue",
4588
4827
  method: HttpMethod.POST,
4589
4828
  url: "/issues/",
4590
- queryParams: {
4591
- workspace_id: payload.index_workspace,
4592
- ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4593
- },
4594
4829
  payload: offlineIssue,
4595
4830
  blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4596
4831
  blocks: [offlineIssue.offline_id]
@@ -4740,7 +4975,10 @@ class IssueService extends BaseApiService {
4740
4975
  const result = await this.enqueueRequest({
4741
4976
  description: "Get issues",
4742
4977
  method: HttpMethod.GET,
4743
- url: `/projects/${projectId}/issues/`,
4978
+ url: "/issues/",
4979
+ queryParams: {
4980
+ project: projectId.toString()
4981
+ },
4744
4982
  blockers: [],
4745
4983
  blocks: []
4746
4984
  });
@@ -4760,16 +4998,8 @@ class IssueTypeService extends BaseApiService {
4760
4998
  this.dispatch(addIssueType(offlineIssueType));
4761
4999
  const promise = this.enqueueRequest({
4762
5000
  method: HttpMethod.POST,
4763
- url: `/organizations/${payload.organization}/issue-types/`,
4764
- // Sending only whats needed here
4765
- payload: {
4766
- offline_id: offlineIssueType.offline_id,
4767
- submitted_at: offlineIssueType.submitted_at,
4768
- icon: offlineIssueType.icon,
4769
- color: offlineIssueType.color,
4770
- name: offlineIssueType.name,
4771
- description: offlineIssueType.description
4772
- },
5001
+ url: "/issue-types/",
5002
+ payload: offlineIssueType,
4773
5003
  blockers: [],
4774
5004
  blocks: [offlineIssueType.offline_id]
4775
5005
  });
@@ -4794,7 +5024,7 @@ class IssueTypeService extends BaseApiService {
4794
5024
  this.dispatch(updateIssueType(offlineUpdatedIssueType));
4795
5025
  const promise = this.enqueueRequest({
4796
5026
  method: HttpMethod.PATCH,
4797
- url: `/issues/types/${payload.offline_id}/`,
5027
+ url: `/issue-types/${payload.offline_id}/`,
4798
5028
  payload,
4799
5029
  blockers: [payload.offline_id],
4800
5030
  blocks: [payload.offline_id]
@@ -4818,7 +5048,7 @@ class IssueTypeService extends BaseApiService {
4818
5048
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
4819
5049
  const promise = this.enqueueRequest({
4820
5050
  method: HttpMethod.DELETE,
4821
- url: `/issues/types/${id}/`,
5051
+ url: `/issue-types/${id}/`,
4822
5052
  blockers: [id],
4823
5053
  blocks: []
4824
5054
  });
@@ -4831,7 +5061,10 @@ class IssueTypeService extends BaseApiService {
4831
5061
  async refreshStore(organizationId) {
4832
5062
  const result = await this.enqueueRequest({
4833
5063
  method: HttpMethod.GET,
4834
- url: `/organizations/${organizationId}/issue-types/`,
5064
+ url: "/issue-types/",
5065
+ queryParams: {
5066
+ organization: organizationId.toString()
5067
+ },
4835
5068
  blockers: [],
4836
5069
  blocks: []
4837
5070
  });
@@ -4970,8 +5203,8 @@ class ProjectFileService extends BaseApiService {
4970
5203
  class ProjectAttachmentService extends BaseAttachmentService {
4971
5204
  constructor() {
4972
5205
  super(...arguments);
4973
- __publicField(this, "attachmentModel", AttachmentModel.Project);
4974
- __publicField(this, "initializeAttachments", initializeProjectAttachments);
5206
+ __publicField(this, "name", "Project Attachment");
5207
+ __publicField(this, "url", "/project-attachments");
4975
5208
  __publicField(this, "addAttachments", addProjectAttachments);
4976
5209
  __publicField(this, "updateAttachments", updateProjectAttachments);
4977
5210
  __publicField(this, "removeAttachments", deleteProjectAttachments);
@@ -4982,20 +5215,39 @@ class ProjectAttachmentService extends BaseAttachmentService {
4982
5215
  buildOfflineAttachment(data) {
4983
5216
  return offline({
4984
5217
  file: URL.createObjectURL(data.file),
4985
- file_sha1: data.sha1,
4986
- created_by: data.createdBy,
5218
+ file_sha1: data.file_sha1,
5219
+ created_by: data.created_by,
4987
5220
  file_name: data.file.name,
4988
5221
  file_type: data.file.type,
4989
- submitted_at: data.submittedAt,
5222
+ submitted_at: data.submitted_at,
4990
5223
  description: data.description,
4991
5224
  project: data.modelId
4992
5225
  });
4993
5226
  }
4994
- async attachFilesToProject(files, projectId) {
4995
- return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this));
5227
+ buildAttachmentPayload(data) {
5228
+ return {
5229
+ ...data,
5230
+ project: data.modelId
5231
+ };
4996
5232
  }
4997
- async deleteProjectAttachment(attachmentId) {
4998
- return this.deleteAttachment(attachmentId);
5233
+ async bulkAdd(payloads) {
5234
+ return this._bulkAdd(payloads.map((p) => ({ modelId: p.projectId, file: p.file })));
5235
+ }
5236
+ async delete(attachmentId) {
5237
+ return this._delete(attachmentId);
5238
+ }
5239
+ async refreshStore(projectId) {
5240
+ const result = await this.enqueueRequest({
5241
+ description: "Get project attachments",
5242
+ method: HttpMethod.GET,
5243
+ url: `${this.url}/`,
5244
+ queryParams: {
5245
+ project: projectId.toString()
5246
+ },
5247
+ blockers: [],
5248
+ blocks: []
5249
+ });
5250
+ this.dispatch(initializeProjectAttachments(result));
4999
5251
  }
5000
5252
  }
5001
5253
  class ProjectService extends BaseApiService {
@@ -5138,88 +5390,31 @@ const separateImageFromFields = async (fields) => {
5138
5390
  return { fields: newFields, images };
5139
5391
  };
5140
5392
  class FormService extends BaseUploadService {
5141
- async bulkAddRevisionAttachments(revisionId, files) {
5393
+ add(payload, initialRevision) {
5142
5394
  var _a2;
5395
+ const { store } = this.client;
5143
5396
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5144
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5145
- const filePayloads = {};
5146
- const offlineFormRevisionAttachments = [];
5147
- const attachmentPayloads = [];
5148
- for (const [fieldIdentifier, file] of Object.entries(files)) {
5149
- const sha1 = await hashFile(file);
5150
- if (!(sha1 in filePayloads)) {
5151
- filePayloads[sha1] = {
5152
- sha1,
5153
- file_type: file.type,
5154
- extension: file.name.split(".").pop(),
5155
- size: file.size
5156
- };
5157
- await this.client.files.addCache(file, sha1);
5158
- }
5159
- const offlineFormRevisionAttachment = offline({
5160
- file: URL.createObjectURL(file),
5161
- file_type: file.type,
5162
- file_name: file.name,
5163
- file_sha1: sha1,
5164
- created_by: createdBy,
5165
- revision: revisionId,
5166
- submitted_at: submittedAt,
5167
- field_identifier: fieldIdentifier
5168
- });
5169
- offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
5170
- const attachmentPayload = {
5171
- offline_id: offlineFormRevisionAttachment.offline_id,
5172
- name: file.name,
5173
- field_identifier: fieldIdentifier,
5174
- sha1
5175
- };
5176
- attachmentPayloads.push(attachmentPayload);
5177
- }
5178
- this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
5179
- const promise = this.enqueueRequest({
5180
- description: "Attach files to form revision",
5181
- method: HttpMethod.POST,
5182
- url: `/forms/revisions/${revisionId}/attachments/bulk/`,
5183
- payload: {
5184
- submitted_at: submittedAt,
5185
- attachments: attachmentPayloads,
5186
- files: Object.values(filePayloads)
5187
- },
5188
- blockers: [revisionId],
5189
- blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5190
- });
5191
- promise.then((result) => {
5192
- this.processPresignedUrls(result.presigned_urls);
5193
- this.dispatch(updateFormRevisionAttachments(result.attachments));
5194
- }).catch(() => {
5195
- this.dispatch(
5196
- deleteFormRevisionAttachments(
5197
- offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
5198
- )
5199
- );
5397
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5398
+ const offlineForm = offline({
5399
+ ...payload,
5400
+ submitted_at: submittedAt,
5401
+ created_by: createdBy
5200
5402
  });
5201
- return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
5202
- }
5203
- async add(ownerId, form, initialRevision, urlPrefix) {
5204
- const { fields, images } = await separateImageFromFields(initialRevision.fields);
5205
5403
  const offlineFormRevision = offline({
5206
5404
  ...initialRevision,
5207
- fields,
5208
- created_by: form.created_by,
5209
- form: form.offline_id,
5210
- submitted_at: form.submitted_at,
5211
- revision: "Pending"
5405
+ form: offlineForm.offline_id,
5406
+ revision: "Pending",
5407
+ submitted_at: submittedAt,
5408
+ created_by: createdBy
5212
5409
  });
5213
- this.dispatch(addForm(form));
5410
+ this.dispatch(addForm(offlineForm));
5214
5411
  this.dispatch(addFormRevision(offlineFormRevision));
5215
5412
  const formPromise = this.enqueueRequest({
5216
5413
  description: "Create form",
5217
5414
  method: HttpMethod.POST,
5218
- url: urlPrefix,
5415
+ url: "/forms/",
5219
5416
  payload: {
5220
- // Sending exactly what is currently needed for the endpoint
5221
- offline_id: form.offline_id,
5222
- submitted_at: form.submitted_at,
5417
+ ...offlineForm,
5223
5418
  initial_revision: {
5224
5419
  offline_id: offlineFormRevision.offline_id,
5225
5420
  submitted_at: offlineFormRevision.submitted_at,
@@ -5228,111 +5423,15 @@ class FormService extends BaseUploadService {
5228
5423
  fields: offlineFormRevision.fields
5229
5424
  }
5230
5425
  },
5231
- blockers: [ownerId],
5232
- blocks: [form.offline_id, offlineFormRevision.offline_id]
5426
+ blockers: [],
5427
+ blocks: [offlineForm.offline_id, offlineFormRevision.offline_id]
5233
5428
  });
5234
- const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5235
- offlineFormRevision.offline_id,
5236
- images
5237
- );
5238
5429
  void formPromise.catch((e) => {
5239
- this.dispatch(deleteForm(form.offline_id));
5430
+ this.dispatch(deleteForm(offlineForm.offline_id));
5240
5431
  this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
5241
5432
  throw e;
5242
5433
  });
5243
- return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5244
- }
5245
- addForOrganization(organizationId, initialRevision) {
5246
- var _a2;
5247
- const state = this.client.store.getState();
5248
- const offlineForm = offline({
5249
- favorite: false,
5250
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5251
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5252
- organization: organizationId
5253
- });
5254
- return this.add(
5255
- organizationId.toString(),
5256
- offlineForm,
5257
- initialRevision,
5258
- `/organizations/${organizationId}/create-form/`
5259
- );
5260
- }
5261
- addForProject(projectId, initialRevision) {
5262
- var _a2;
5263
- const state = this.client.store.getState();
5264
- const offlineForm = offline({
5265
- favorite: false,
5266
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5267
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5268
- project: projectId
5269
- });
5270
- return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5271
- }
5272
- addForIssueType(issueTypeId, initialRevision) {
5273
- var _a2;
5274
- const state = this.client.store.getState();
5275
- const offlineForm = offline({
5276
- favorite: false,
5277
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5278
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5279
- issue_type: issueTypeId
5280
- });
5281
- return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5282
- }
5283
- addForAssetType(assetTypeId, initialRevision) {
5284
- var _a2;
5285
- const state = this.client.store.getState();
5286
- const offlineForm = offline({
5287
- favorite: false,
5288
- created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5289
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5290
- asset_type: assetTypeId
5291
- });
5292
- return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5293
- }
5294
- async createRevision(formId, revision) {
5295
- var _a2;
5296
- const offlineRevision = offline(revision);
5297
- const { store } = this.client;
5298
- const state = store.getState();
5299
- const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5300
- const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5301
- const fullRevision = {
5302
- ...offlineRevision,
5303
- fields,
5304
- created_by: createdBy,
5305
- revision: "Pending",
5306
- form: formId,
5307
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5308
- };
5309
- this.dispatch(addFormRevision(fullRevision));
5310
- const promise = this.enqueueRequest({
5311
- description: "Create form revision",
5312
- method: HttpMethod.PATCH,
5313
- url: `/forms/${formId}/`,
5314
- payload: {
5315
- initial_revision: {
5316
- offline_id: fullRevision.offline_id,
5317
- submitted_at: fullRevision.submitted_at,
5318
- title: fullRevision.title,
5319
- description: fullRevision.description,
5320
- fields: fullRevision.fields
5321
- }
5322
- },
5323
- blockers: [formId],
5324
- blocks: [offlineRevision.offline_id]
5325
- });
5326
- const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
5327
- fullRevision.offline_id,
5328
- images
5329
- );
5330
- void promise.then((result) => {
5331
- this.dispatch(setFormRevision(result));
5332
- }).catch(() => {
5333
- this.dispatch(deleteFormRevision(fullRevision.offline_id));
5334
- });
5335
- return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
5434
+ return [offlineForm, offlineFormRevision, formPromise];
5336
5435
  }
5337
5436
  async delete(id) {
5338
5437
  const { store } = this.client;
@@ -5369,53 +5468,18 @@ class FormService extends BaseUploadService {
5369
5468
  throw e;
5370
5469
  }
5371
5470
  }
5372
- async refreshStore(projectId) {
5373
- const forms = [];
5374
- const revisions = [];
5375
- const attachments = [];
5376
- const projectFormsResult = await this.enqueueRequest({
5377
- description: "Fetch project forms",
5378
- method: HttpMethod.GET,
5379
- url: `/projects/${projectId}/forms/`,
5380
- blockers: [projectId.toString()],
5381
- blocks: []
5382
- });
5383
- for (const form of projectFormsResult.forms) forms.push(form);
5384
- for (const revision of projectFormsResult.revisions) revisions.push(revision);
5385
- for (const attachment of projectFormsResult.attachments) attachments.push(attachment);
5386
- const organizationFormsResult = await this.enqueueRequest({
5471
+ async refreshStore(organizationId) {
5472
+ const forms = await this.enqueueRequest({
5387
5473
  description: "Fetch organization forms",
5388
5474
  method: HttpMethod.GET,
5389
- url: `/projects/${projectId}/organizations/forms/`,
5390
- blockers: [projectId.toString()],
5391
- blocks: []
5392
- });
5393
- for (const form of organizationFormsResult.forms) forms.push(form);
5394
- for (const revision of organizationFormsResult.revisions) revisions.push(revision);
5395
- for (const attachment of organizationFormsResult.attachments) attachments.push(attachment);
5396
- const assetTypeFormsResult = await this.enqueueRequest({
5397
- description: "Fetch asset type forms",
5398
- method: HttpMethod.GET,
5399
- url: `/projects/${projectId}/asset-types/forms/`,
5400
- blockers: [projectId.toString()],
5401
- blocks: []
5402
- });
5403
- for (const form of assetTypeFormsResult.forms) forms.push(form);
5404
- for (const revision of assetTypeFormsResult.revisions) revisions.push(revision);
5405
- for (const attachment of assetTypeFormsResult.attachments) attachments.push(attachment);
5406
- const issueTypeFormsResult = await this.enqueueRequest({
5407
- description: "Fetch issue type forms",
5408
- method: HttpMethod.GET,
5409
- url: `/projects/${projectId}/issue-types/forms/`,
5410
- blockers: [projectId.toString()],
5475
+ url: "/forms/",
5476
+ queryParams: {
5477
+ organization: organizationId.toString()
5478
+ },
5479
+ blockers: [organizationId.toString()],
5411
5480
  blocks: []
5412
5481
  });
5413
- for (const form of issueTypeFormsResult.forms) forms.push(form);
5414
- for (const revision of issueTypeFormsResult.revisions) revisions.push(revision);
5415
- for (const attachment of issueTypeFormsResult.attachments) attachments.push(attachment);
5416
5482
  this.dispatch(initializeForms(forms));
5417
- this.dispatch(initializeFormRevisions(revisions));
5418
- this.dispatch(initializeFormRevisionAttachments(attachments));
5419
5483
  }
5420
5484
  }
5421
5485
  const isArrayOfFiles = (value) => {
@@ -5437,95 +5501,11 @@ const separateFilesFromValues = (values) => {
5437
5501
  return { values: newValues, files };
5438
5502
  };
5439
5503
  class FormSubmissionService extends BaseUploadService {
5440
- async bulkAddSubmissionAttachments(submissionId, files) {
5441
- var _a2;
5442
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5443
- const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5444
- const filePayloads = {};
5445
- const offlineFormSubmissionAttachments = [];
5446
- const attachmentPayloads = [];
5447
- for (const [fieldIdentifier, filesArray] of Object.entries(files)) {
5448
- for (const file of filesArray) {
5449
- const sha1 = await hashFile(file);
5450
- if (!(sha1 in filePayloads)) {
5451
- filePayloads[sha1] = {
5452
- sha1,
5453
- file_type: file.type,
5454
- extension: file.name.split(".").pop(),
5455
- size: file.size
5456
- };
5457
- await this.client.files.addCache(file, sha1);
5458
- }
5459
- const offlineFormSubmissionAttachment = offline({
5460
- file: URL.createObjectURL(file),
5461
- file_type: file.type,
5462
- file_name: file.name,
5463
- file_sha1: sha1,
5464
- created_by: createdBy,
5465
- submission: submissionId,
5466
- submitted_at: submittedAt,
5467
- field_identifier: fieldIdentifier
5468
- });
5469
- offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
5470
- const attachmentPayload = {
5471
- offline_id: offlineFormSubmissionAttachment.offline_id,
5472
- name: file.name,
5473
- sha1,
5474
- field_identifier: fieldIdentifier
5475
- };
5476
- attachmentPayloads.push(attachmentPayload);
5477
- }
5478
- }
5479
- this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
5480
- const promise = this.enqueueRequest({
5481
- description: "Attach files to form submission",
5482
- method: HttpMethod.POST,
5483
- url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5484
- payload: {
5485
- submitted_at: submittedAt,
5486
- attachments: attachmentPayloads,
5487
- files: Object.values(filePayloads)
5488
- },
5489
- blockers: [submissionId],
5490
- blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5491
- });
5492
- promise.then((result) => {
5493
- this.processPresignedUrls(result.presigned_urls);
5494
- this.dispatch(updateFormSubmissionAttachments(result.attachments));
5495
- }).catch(() => {
5496
- this.dispatch(
5497
- deleteFormSubmissionAttachments(
5498
- offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
5499
- )
5500
- );
5501
- });
5502
- return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5503
- }
5504
- async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
5505
- const { store } = this.client;
5506
- const state = store.getState();
5507
- const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
5508
- this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
5509
- try {
5510
- await this.enqueueRequest({
5511
- description: "Delete form submission attachments",
5512
- method: HttpMethod.DELETE,
5513
- url: `/forms/submissions/${submissionId}/attachments/bulk/`,
5514
- payload: { attachments: attachmentsIds },
5515
- blockers: [submissionId, ...attachmentsIds],
5516
- blocks: []
5517
- });
5518
- } catch (e) {
5519
- this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
5520
- throw e;
5521
- }
5522
- }
5523
- // Outer promise is for hashing and caching files for submission attachments
5524
- async add(payload) {
5504
+ add(payload) {
5525
5505
  var _a2;
5526
5506
  const { store } = this.client;
5527
5507
  const state = store.getState();
5528
- const { values, files } = separateFilesFromValues(payload.values);
5508
+ const { values } = separateFilesFromValues(payload.values);
5529
5509
  const offlineSubmission = offline({
5530
5510
  ...payload,
5531
5511
  values,
@@ -5533,132 +5513,35 @@ class FormSubmissionService extends BaseUploadService {
5533
5513
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5534
5514
  });
5535
5515
  const promise = this.enqueueRequest({
5536
- description: "Respond to form",
5516
+ description: "Add form submission",
5537
5517
  method: HttpMethod.POST,
5538
- url: `/forms/revisions/${payload.form_revision}/respond/`,
5518
+ url: "/form-submissions/",
5539
5519
  payload: offlineSubmission,
5540
- blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
5541
- (x) => x !== void 0
5542
- ),
5520
+ blockers: [
5521
+ "add-form-entry",
5522
+ payload.form_revision,
5523
+ ...payload.issue ? [payload.issue] : [],
5524
+ ...payload.asset ? [payload.asset] : []
5525
+ ],
5543
5526
  blocks: [offlineSubmission.offline_id]
5544
5527
  });
5545
5528
  this.dispatch(addFormSubmission(offlineSubmission));
5546
- const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5547
- offlineSubmission.offline_id,
5548
- files
5549
- );
5550
5529
  promise.then((result) => {
5551
5530
  this.dispatch(setFormSubmission(result));
5552
5531
  return result;
5553
5532
  }).catch(() => {
5554
5533
  this.dispatch(deleteFormSubmission(offlineSubmission.offline_id));
5555
5534
  });
5556
- return [offlineSubmission, offlineFormSubmissionAttachments, promise, attachmentsPromise];
5557
- }
5558
- // Note currently the bulkAdd method is specific to form submissions for assets
5559
- // TODO: adapt the support bulk adding to any model type
5560
- async bulkAdd(args, batchSize) {
5561
- const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
5562
- const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
5563
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5564
- const transactionId = v4();
5565
- const assetIdBatches = chunkArray(Object.keys(fieldValuesByAsset), batchSize);
5566
- const bulkAddBatches = await Promise.all(
5567
- assetIdBatches.map(async (assetIdBatch) => {
5568
- const batchId = v4();
5569
- const submissionPayloads = [];
5570
- const attachmentPayloads = [];
5571
- const files = { ...commonFiles };
5572
- for (const assetId of assetIdBatch) {
5573
- const { values: fileSeperatedSubmissionSpecificValues, files: submissionSpecificFiles } = separateFilesFromValues(fieldValuesByAsset[assetId] ?? {});
5574
- Object.assign(files, submissionSpecificFiles);
5575
- const submissionPayload = offline({
5576
- asset_id: assetId,
5577
- form_data: fileSeperatedSubmissionSpecificValues
5578
- });
5579
- submissionPayloads.push(submissionPayload);
5580
- for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
5581
- for (const file of fileArray) {
5582
- const sha1 = await hashFile(file);
5583
- await this.client.files.addCache(file, sha1);
5584
- const attachmentPayload = offline({
5585
- submission_id: submissionPayload.offline_id,
5586
- sha1,
5587
- name: file.name,
5588
- field_identifier: fieldIdentifier
5589
- });
5590
- attachmentPayloads.push(attachmentPayload);
5591
- }
5592
- }
5593
- }
5594
- const filePaylods = [];
5595
- for (const file of Object.values(files).flat()) {
5596
- const sha1 = await hashFile(file);
5597
- const filePayload = {
5598
- sha1,
5599
- extension: file.name.split(".").pop() || "",
5600
- file_type: file.type,
5601
- size: file.size
5602
- };
5603
- filePaylods.push(filePayload);
5604
- }
5605
- return {
5606
- batchId,
5607
- payload: {
5608
- transaction_id: transactionId,
5609
- form_data: fileSeperatedCommonFieldValues,
5610
- submitted_at: submittedAt,
5611
- submissions: submissionPayloads,
5612
- attachments: attachmentPayloads,
5613
- files: filePaylods
5614
- }
5615
- };
5616
- })
5617
- );
5618
- const batchPromises = [];
5619
- let prevBatchId = null;
5620
- for (const batch of bulkAddBatches) {
5621
- const { payload, batchId } = batch;
5622
- const batchAssetIds = payload.submissions.map((x) => x.asset_id);
5623
- const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
5624
- const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
5625
- const blockers = batchAssetIds;
5626
- if (prevBatchId) blockers.push(prevBatchId);
5627
- const blocks = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
5628
- const promise = this.enqueueRequest({
5629
- description: "Bulk add form submissions",
5630
- method: HttpMethod.POST,
5631
- url: `/forms/revisions/${formRevision}/bulk-respond/`,
5632
- payload,
5633
- blockers,
5634
- blocks
5635
- });
5636
- void promise.then(({ presigned_urls }) => {
5637
- this.processPresignedUrls(presigned_urls);
5638
- });
5639
- prevBatchId = batchId;
5640
- batchPromises.push(promise);
5641
- }
5642
- void Promise.all(batchPromises).then((results) => {
5643
- const createdSubmissions = [];
5644
- const createdAttachments = [];
5645
- for (const result of results) {
5646
- for (const createdSubmission of result.submissions) createdSubmissions.push(createdSubmission);
5647
- for (const createdAttachment of result.attachments) createdAttachments.push(createdAttachment);
5648
- }
5649
- this.dispatch(addFormSubmissions(createdSubmissions));
5650
- this.dispatch(addFormSubmissionAttachments(createdAttachments));
5651
- });
5652
- return batchPromises;
5535
+ return [offlineSubmission, promise];
5653
5536
  }
5654
- async update(payload) {
5537
+ update(payload) {
5655
5538
  const { store } = this.client;
5656
5539
  const state = store.getState();
5657
5540
  const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
5658
5541
  if (!submissionToBeUpdated) {
5659
5542
  throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
5660
5543
  }
5661
- const { values, files } = separateFilesFromValues(payload.values ?? {});
5544
+ const { values } = separateFilesFromValues(payload.values ?? {});
5662
5545
  const updatedSubmission = {
5663
5546
  ...submissionToBeUpdated,
5664
5547
  ...payload,
@@ -5672,39 +5555,18 @@ class FormSubmissionService extends BaseUploadService {
5672
5555
  const promise = this.enqueueRequest({
5673
5556
  description: "Delete user form submissions",
5674
5557
  method: HttpMethod.PATCH,
5675
- url: `/forms/submissions/${updatedSubmission.offline_id}/`,
5558
+ url: `/form-submissions/${updatedSubmission.offline_id}/`,
5676
5559
  // TODO: send just payload when FormSubmissionDeserializer is updated to handle partial updates
5677
5560
  payload: updatedSubmission,
5678
5561
  blockers: [updatedSubmission.offline_id],
5679
5562
  blocks: [updatedSubmission.offline_id]
5680
5563
  });
5681
- const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
5682
- const formSubmissionAttachmentIdsToBeDeleted = [];
5683
- for (const attachment of formSubmissionAttachments) {
5684
- if (attachment.field_identifier in files) {
5685
- formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
5686
- }
5687
- }
5688
- const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
5689
- payload.offline_id,
5690
- files
5691
- );
5692
- const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
5693
- payload.offline_id,
5694
- formSubmissionAttachmentIdsToBeDeleted
5695
- );
5696
5564
  promise.then((result) => {
5697
5565
  this.dispatch(setFormSubmission(result));
5698
5566
  }).catch(() => {
5699
5567
  this.dispatch(setFormSubmission(submissionToBeUpdated));
5700
5568
  });
5701
- return [
5702
- updatedSubmission,
5703
- offlineFormSubmissionAttachments,
5704
- promise,
5705
- attachmentsPromise,
5706
- deleteAttachmentsPromise
5707
- ];
5569
+ return [updatedSubmission, promise];
5708
5570
  }
5709
5571
  async delete(id) {
5710
5572
  const { store } = this.client;
@@ -5720,7 +5582,7 @@ class FormSubmissionService extends BaseUploadService {
5720
5582
  return await this.enqueueRequest({
5721
5583
  description: "Delete user form submissions",
5722
5584
  method: HttpMethod.DELETE,
5723
- url: `/forms/submissions/${id}/`,
5585
+ url: `/form-submissions/${id}/`,
5724
5586
  blockers: [id],
5725
5587
  blocks: []
5726
5588
  });
@@ -5731,50 +5593,17 @@ class FormSubmissionService extends BaseUploadService {
5731
5593
  }
5732
5594
  }
5733
5595
  async refreshStore(projectId) {
5734
- const formSubmissions = {};
5735
- const modelSubmissions = await this.enqueueRequest({
5736
- description: "Fetch model submissions",
5737
- method: HttpMethod.GET,
5738
- url: `/forms/in-project/${projectId}/submissions/model/latest/`,
5739
- blockers: [],
5740
- blocks: []
5741
- });
5742
- for (const modelSubmission of modelSubmissions) {
5743
- formSubmissions[modelSubmission.offline_id] = modelSubmission;
5744
- }
5745
- const standaloneSubmissions = await this.enqueueRequest({
5746
- description: "Fetch standalone submissions",
5747
- method: HttpMethod.GET,
5748
- url: `/forms/in-project/${projectId}/submissions/standalone/`,
5749
- blockers: [],
5750
- blocks: []
5751
- });
5752
- for (const standaloneSubmission of standaloneSubmissions) {
5753
- formSubmissions[standaloneSubmission.offline_id] = standaloneSubmission;
5754
- }
5755
- this.dispatch(initializeFormSubmissions(Object.values(formSubmissions)));
5756
- const attachments = {};
5757
- const modelAttachments = await this.enqueueRequest({
5758
- description: "Fetch model submission attachments",
5759
- method: HttpMethod.GET,
5760
- url: `/forms/in-project/${projectId}/attachments/model/latest/`,
5761
- blockers: [],
5762
- blocks: []
5763
- });
5764
- for (const modelAttachment of modelAttachments) {
5765
- attachments[modelAttachment.offline_id] = modelAttachment;
5766
- }
5767
- const standaloneAttachments = await this.enqueueRequest({
5768
- description: "Fetch standalone submission attachments",
5596
+ const result = await this.enqueueRequest({
5597
+ description: "Fetch form submissions",
5769
5598
  method: HttpMethod.GET,
5770
- url: `/forms/in-project/${projectId}/attachments/standalone/`,
5599
+ url: "/form-submissions/",
5600
+ queryParams: {
5601
+ project: projectId.toString()
5602
+ },
5771
5603
  blockers: [],
5772
5604
  blocks: []
5773
5605
  });
5774
- for (const standaloneAttachent of standaloneAttachments) {
5775
- attachments[standaloneAttachent.offline_id] = standaloneAttachent;
5776
- }
5777
- this.dispatch(initializeFormSubmissionAttachments(Object.values(attachments)));
5606
+ this.dispatch(initializeFormSubmissions(result));
5778
5607
  }
5779
5608
  }
5780
5609
  class WorkspaceService extends BaseApiService {
@@ -6474,8 +6303,8 @@ class DocumentService extends BaseApiService {
6474
6303
  class DocumentAttachmentService extends BaseAttachmentService {
6475
6304
  constructor() {
6476
6305
  super(...arguments);
6477
- __publicField(this, "attachmentModel", AttachmentModel.Document);
6478
- __publicField(this, "initializeAttachments", initializeDocumentAttachments);
6306
+ __publicField(this, "name", "Document Attachment");
6307
+ __publicField(this, "url", "/document-attachments");
6479
6308
  __publicField(this, "addAttachments", addDocumentAttachments);
6480
6309
  __publicField(this, "updateAttachments", updateDocumentAttachments);
6481
6310
  __publicField(this, "removeAttachments", deleteDocumentAttachments);
@@ -6486,18 +6315,24 @@ class DocumentAttachmentService extends BaseAttachmentService {
6486
6315
  buildOfflineAttachment(data) {
6487
6316
  return offline({
6488
6317
  file: URL.createObjectURL(data.file),
6489
- file_sha1: data.sha1,
6490
- created_by: data.createdBy,
6318
+ file_sha1: data.file_sha1,
6319
+ created_by: data.created_by,
6491
6320
  file_name: data.file.name,
6492
6321
  file_type: data.file.type,
6493
- submitted_at: data.submittedAt,
6322
+ submitted_at: data.submitted_at,
6494
6323
  description: data.description,
6495
6324
  document: data.modelId
6496
6325
  });
6497
6326
  }
6498
- // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6499
- async attachFilesToDocument(files, documentId) {
6500
- var _a2;
6327
+ buildAttachmentPayload(data) {
6328
+ return {
6329
+ ...data,
6330
+ document: data.modelId
6331
+ };
6332
+ }
6333
+ // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6334
+ async bulkAdd(payloads) {
6335
+ var _a2;
6501
6336
  const { store } = this.client;
6502
6337
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6503
6338
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -6505,40 +6340,37 @@ class DocumentAttachmentService extends BaseAttachmentService {
6505
6340
  const attachmentPayloads = [];
6506
6341
  const filePayloads = {};
6507
6342
  const sha1ToAttachmentIds = {};
6508
- for (const file of files) {
6509
- const sha1 = await hashFile(file);
6510
- if (!(sha1 in filePayloads)) {
6511
- filePayloads[sha1] = {
6512
- sha1,
6513
- file_type: file.type,
6514
- extension: file.name.split(".").pop(),
6515
- size: file.size
6516
- };
6517
- sha1ToAttachmentIds[sha1] = [];
6518
- await this.client.files.addCache(file, sha1);
6343
+ for (const payload of payloads) {
6344
+ const { documentId, file } = payload;
6345
+ const filePayload = await this.getFilePayload(file);
6346
+ if (!(filePayload.sha1 in filePayloads)) {
6347
+ filePayloads[filePayload.sha1] = filePayload;
6348
+ sha1ToAttachmentIds[filePayload.sha1] = [];
6519
6349
  }
6520
6350
  const offlineAttachment = this.buildOfflineAttachment({
6521
6351
  file,
6522
- sha1,
6523
- submittedAt,
6524
- createdBy,
6352
+ file_sha1: filePayload.sha1,
6353
+ submitted_at: submittedAt,
6354
+ created_by: createdBy,
6525
6355
  description: "",
6526
6356
  modelId: documentId
6527
6357
  });
6528
6358
  offlineAttachments.push(offlineAttachment);
6529
6359
  attachmentPayloads.push({
6530
6360
  offline_id: offlineAttachment.offline_id,
6531
- name: offlineAttachment.file_name,
6532
- sha1: offlineAttachment.file_sha1,
6533
- description: offlineAttachment.description
6361
+ file_name: offlineAttachment.file_name,
6362
+ file_sha1: offlineAttachment.file_sha1,
6363
+ file_extension: filePayload.extension,
6364
+ description: offlineAttachment.description,
6365
+ document: documentId
6534
6366
  });
6535
- sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
6367
+ sha1ToAttachmentIds[filePayload.sha1].push(offlineAttachment.offline_id);
6536
6368
  }
6537
6369
  this.dispatch(this.addAttachments(offlineAttachments));
6538
6370
  const promise = this.enqueueRequest({
6539
6371
  description: "Attach files to document",
6540
6372
  method: HttpMethod.POST,
6541
- url: `/documents/${documentId}/attach/`,
6373
+ url: "/document-attachments/bulk/",
6542
6374
  payload: {
6543
6375
  submitted_at: submittedAt,
6544
6376
  attachments: attachmentPayloads,
@@ -6563,14 +6395,14 @@ class DocumentAttachmentService extends BaseAttachmentService {
6563
6395
  });
6564
6396
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
6565
6397
  }
6566
- async deleteDocumentAttachment(attachmentId) {
6567
- return this.deleteAttachment(attachmentId);
6398
+ async delete(id) {
6399
+ return this._delete(id);
6568
6400
  }
6569
6401
  makeReadable(attachmnentId) {
6570
6402
  void this.enqueueRequest({
6571
6403
  description: "Add attachment to AI assistant",
6572
6404
  method: HttpMethod.PATCH,
6573
- url: `/documents/attachments/${attachmnentId}/`,
6405
+ url: `/document-attachments/${attachmnentId}/`,
6574
6406
  payload: {
6575
6407
  readable_to_assistant: true
6576
6408
  },
@@ -6587,7 +6419,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6587
6419
  blocks: [],
6588
6420
  blockers: []
6589
6421
  });
6590
- this.dispatch(this.initializeAttachments(projectDocumentAttachments));
6422
+ this.dispatch(initializeDocumentAttachments(projectDocumentAttachments));
6591
6423
  const organizationDocumentAttachments = await this.enqueueRequest({
6592
6424
  description: "Get document attachments",
6593
6425
  method: HttpMethod.GET,
@@ -6823,17 +6655,11 @@ class GeoImageService extends BaseUploadService {
6823
6655
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6824
6656
  const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6825
6657
  const projectId = payloadWithoutFile.project;
6826
- const sha1 = await hashFile(file);
6827
- const filePayload = {
6828
- sha1,
6829
- file_type: file.type,
6830
- extension: file.name.split(".").pop(),
6831
- size: file.size
6832
- };
6658
+ const filePayload = await this.getFilePayload(file);
6833
6659
  const offlineMapImage = offline({
6834
6660
  ...payloadWithoutFile,
6835
6661
  file_name: file.name,
6836
- file_sha1: sha1,
6662
+ file_sha1: filePayload.sha1,
6837
6663
  file: URL.createObjectURL(file),
6838
6664
  submitted_at: submittedAt,
6839
6665
  created_by: createdBy
@@ -6876,23 +6702,15 @@ class GeoImageService extends BaseUploadService {
6876
6702
  const offlineGeoImages = [];
6877
6703
  const offlineIds = [];
6878
6704
  const geoImagePayloads = [];
6879
- const filePayloadRecord = {};
6705
+ const filePayloads = {};
6880
6706
  for (const payloadAndFile of payloads) {
6881
6707
  const { file, ...payload } = payloadAndFile;
6882
- const sha1 = await hashFile(file);
6883
- if (!(sha1 in filePayloadRecord)) {
6884
- filePayloadRecord[sha1] = {
6885
- sha1,
6886
- file_type: file.type,
6887
- extension: file.name.split(".").pop(),
6888
- size: file.size
6889
- };
6890
- await this.client.files.addCache(file, sha1);
6891
- }
6708
+ const filePayload = await this.getFilePayload(file);
6709
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
6892
6710
  const offlineMapImage = offline({
6893
6711
  ...payload,
6894
6712
  file_name: file.name,
6895
- file_sha1: sha1,
6713
+ file_sha1: filePayload.sha1,
6896
6714
  file: URL.createObjectURL(file),
6897
6715
  submitted_at: submittedAt,
6898
6716
  created_by: createdBy,
@@ -6921,7 +6739,7 @@ class GeoImageService extends BaseUploadService {
6921
6739
  submitted_at: submittedAt,
6922
6740
  project: projectId,
6923
6741
  geo_images: geoImagePayloads,
6924
- files: Object.values(filePayloadRecord)
6742
+ files: Object.values(filePayloads)
6925
6743
  },
6926
6744
  blocks: [projectId.toString()],
6927
6745
  blockers: offlineIds
@@ -6989,7 +6807,7 @@ class GeoImageService extends BaseUploadService {
6989
6807
  this.dispatch(initializeGeoImages(result));
6990
6808
  }
6991
6809
  }
6992
- class IssueAssociationService extends BaseUploadService {
6810
+ class IssueAssociationService extends BaseApiService {
6993
6811
  add(payload) {
6994
6812
  var _a2;
6995
6813
  const { store } = this.client;
@@ -7004,7 +6822,7 @@ class IssueAssociationService extends BaseUploadService {
7004
6822
  const promise = this.enqueueRequest({
7005
6823
  description: "Add issue association",
7006
6824
  method: HttpMethod.POST,
7007
- url: "/issues/associations/",
6825
+ url: "/issue-associations/",
7008
6826
  payload: {
7009
6827
  offline_id: offlineIssueAssociation.offline_id,
7010
6828
  submitted_at: submittedAt,
@@ -7034,7 +6852,7 @@ class IssueAssociationService extends BaseUploadService {
7034
6852
  const promise = this.enqueueRequest({
7035
6853
  description: "Delete issue association",
7036
6854
  method: HttpMethod.DELETE,
7037
- url: `/issues/associations/${id}/`,
6855
+ url: `/issue-associations/${id}/`,
7038
6856
  blockers: [id],
7039
6857
  blocks: []
7040
6858
  });
@@ -7047,14 +6865,917 @@ class IssueAssociationService extends BaseUploadService {
7047
6865
  const issueAssociations = await this.enqueueRequest({
7048
6866
  description: "Fetch issue associations",
7049
6867
  method: HttpMethod.GET,
7050
- url: "/issues/associations/",
7051
- queryParams: { project_id: projectId.toString() },
6868
+ url: "/issue-associations/",
6869
+ queryParams: { project: projectId.toString() },
7052
6870
  blockers: [],
7053
6871
  blocks: []
7054
6872
  });
7055
6873
  this.dispatch(initializeIssueAssociations(issueAssociations));
7056
6874
  }
7057
6875
  }
6876
+ class FormRevisionAttachmentService extends BaseUploadService {
6877
+ async bulkAdd(payloads) {
6878
+ var _a2;
6879
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6880
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6881
+ const filePayloads = {};
6882
+ const offlineFormRevisionAttachments = [];
6883
+ const attachmentPayloads = [];
6884
+ for (const payload of payloads) {
6885
+ const { revisionId, fieldIdentifier, file } = payload;
6886
+ const filePayload = await this.getFilePayload(file);
6887
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
6888
+ const offlineFormRevisionAttachment = offline({
6889
+ file: URL.createObjectURL(file),
6890
+ file_type: file.type,
6891
+ file_name: file.name,
6892
+ file_sha1: filePayload.sha1,
6893
+ created_by: createdBy,
6894
+ form_revision: revisionId,
6895
+ submitted_at: submittedAt,
6896
+ field_identifier: fieldIdentifier
6897
+ });
6898
+ offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
6899
+ const attachmentPayload = {
6900
+ offline_id: offlineFormRevisionAttachment.offline_id,
6901
+ file_name: file.name,
6902
+ field_identifier: fieldIdentifier,
6903
+ file_extension: filePayload.extension,
6904
+ file_sha1: filePayload.sha1,
6905
+ form_revision: revisionId
6906
+ };
6907
+ attachmentPayloads.push(attachmentPayload);
6908
+ }
6909
+ this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
6910
+ const promise = this.enqueueRequest({
6911
+ description: "Attach files to form revision",
6912
+ method: HttpMethod.POST,
6913
+ url: "/form-revision-attachments/bulk/",
6914
+ payload: {
6915
+ submitted_at: submittedAt,
6916
+ attachments: attachmentPayloads,
6917
+ files: Object.values(filePayloads)
6918
+ },
6919
+ blockers: offlineFormRevisionAttachments.map((attachment) => attachment.form_revision),
6920
+ blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
6921
+ });
6922
+ promise.then((result) => {
6923
+ this.processPresignedUrls(result.presigned_urls);
6924
+ this.dispatch(updateFormRevisionAttachments(result.attachments));
6925
+ }).catch(() => {
6926
+ this.dispatch(
6927
+ deleteFormRevisionAttachments(
6928
+ offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
6929
+ )
6930
+ );
6931
+ });
6932
+ return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
6933
+ }
6934
+ async refreshStore(organizationId) {
6935
+ const formRevisions = await this.enqueueRequest({
6936
+ description: "Fetch organization form revision attachments",
6937
+ method: HttpMethod.GET,
6938
+ url: "/form-revision-attachments/",
6939
+ queryParams: {
6940
+ organization: organizationId.toString()
6941
+ },
6942
+ blockers: [organizationId.toString()],
6943
+ blocks: []
6944
+ });
6945
+ this.dispatch(initializeFormRevisionAttachments(formRevisions));
6946
+ }
6947
+ }
6948
+ class FormSubmissionAttachmentService extends BaseUploadService {
6949
+ async bulkAdd(payloads) {
6950
+ var _a2;
6951
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6952
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6953
+ const filePayloads = {};
6954
+ const offlineFormSubmissionAttachments = [];
6955
+ const attachmentPayloads = [];
6956
+ for (const payload of payloads) {
6957
+ const { submissionId, fieldIdentifier, file } = payload;
6958
+ const filePayload = await this.getFilePayload(file);
6959
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
6960
+ const offlineFormSubmissionAttachment = offline({
6961
+ file: URL.createObjectURL(file),
6962
+ file_type: file.type,
6963
+ file_name: file.name,
6964
+ file_sha1: filePayload.sha1,
6965
+ created_by: createdBy,
6966
+ form_submission: submissionId,
6967
+ submitted_at: submittedAt,
6968
+ field_identifier: fieldIdentifier
6969
+ });
6970
+ offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
6971
+ const attachmentPayload = {
6972
+ offline_id: offlineFormSubmissionAttachment.offline_id,
6973
+ file_name: file.name,
6974
+ file_sha1: filePayload.sha1,
6975
+ file_extension: filePayload.extension,
6976
+ field_identifier: fieldIdentifier,
6977
+ form_submission: submissionId
6978
+ };
6979
+ attachmentPayloads.push(attachmentPayload);
6980
+ }
6981
+ this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
6982
+ const promise = this.enqueueRequest({
6983
+ description: "Attach files to form submission",
6984
+ method: HttpMethod.POST,
6985
+ url: "/form-submission-attachments/bulk/",
6986
+ payload: {
6987
+ submitted_at: submittedAt,
6988
+ attachments: attachmentPayloads,
6989
+ files: Object.values(filePayloads)
6990
+ },
6991
+ blockers: offlineFormSubmissionAttachments.map((attachment) => attachment.form_submission),
6992
+ blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
6993
+ });
6994
+ promise.then((result) => {
6995
+ this.processPresignedUrls(result.presigned_urls);
6996
+ this.dispatch(updateFormSubmissionAttachments(result.attachments));
6997
+ }).catch((error) => {
6998
+ this.dispatch(
6999
+ deleteFormSubmissionAttachments(
7000
+ offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
7001
+ )
7002
+ );
7003
+ throw error;
7004
+ });
7005
+ return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
7006
+ }
7007
+ async bulkDelete(attachmentsIds) {
7008
+ const { store } = this.client;
7009
+ const state = store.getState();
7010
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
7011
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
7012
+ try {
7013
+ await this.enqueueRequest({
7014
+ description: "Delete form submission attachments",
7015
+ method: HttpMethod.DELETE,
7016
+ url: "/form-submission-attachments/bulk/",
7017
+ payload: { attachment_ids: attachmentsIds },
7018
+ blockers: attachmentsIds,
7019
+ blocks: []
7020
+ });
7021
+ } catch (e) {
7022
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
7023
+ throw e;
7024
+ }
7025
+ }
7026
+ async refreshStore(projectId) {
7027
+ const result = await this.enqueueRequest({
7028
+ description: "Get form submission attachments",
7029
+ method: HttpMethod.GET,
7030
+ url: "/form-submission-attachments/",
7031
+ queryParams: {
7032
+ project: projectId.toString()
7033
+ },
7034
+ blockers: [],
7035
+ blocks: []
7036
+ });
7037
+ this.dispatch(initializeFormSubmissionAttachments(result));
7038
+ }
7039
+ }
7040
+ class FormRevisionService extends BaseUploadService {
7041
+ add(payload) {
7042
+ var _a2;
7043
+ const { store } = this.client;
7044
+ const state = store.getState();
7045
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
7046
+ const offlineFormRevision = offline({
7047
+ ...payload,
7048
+ created_by: createdBy,
7049
+ revision: "Pending",
7050
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7051
+ });
7052
+ this.dispatch(addFormRevision(offlineFormRevision));
7053
+ const promise = this.enqueueRequest({
7054
+ description: "Create form revision",
7055
+ method: HttpMethod.POST,
7056
+ url: "/form-revisions/",
7057
+ payload: offlineFormRevision,
7058
+ blockers: [payload.form],
7059
+ blocks: [offlineFormRevision.offline_id]
7060
+ });
7061
+ void promise.then((result) => {
7062
+ this.dispatch(setFormRevision(result));
7063
+ }).catch(() => {
7064
+ this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
7065
+ });
7066
+ return [offlineFormRevision, promise];
7067
+ }
7068
+ async refreshStore(organizationId) {
7069
+ const formRevisions = await this.enqueueRequest({
7070
+ description: "Get organization form revisions",
7071
+ method: HttpMethod.GET,
7072
+ url: "/form-revisions/",
7073
+ queryParams: {
7074
+ organization: organizationId.toString()
7075
+ },
7076
+ blockers: [organizationId.toString()],
7077
+ blocks: []
7078
+ });
7079
+ this.dispatch(initializeFormRevisions(formRevisions));
7080
+ }
7081
+ }
7082
+ class AssetTypeFieldsAttachmentService extends BaseUploadService {
7083
+ async bulkAdd(payloads) {
7084
+ var _a2;
7085
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7086
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7087
+ const filePayloads = {};
7088
+ const offlineAssetTypeFieldsAttachments = [];
7089
+ const attachmentPayloads = [];
7090
+ for (const payload of payloads) {
7091
+ const { fieldsRevisionId, fieldIdentifier, file } = payload;
7092
+ const filePayload = await this.getFilePayload(file);
7093
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7094
+ const offlineAssetTypeFieldsAttachment = offline({
7095
+ file: URL.createObjectURL(file),
7096
+ file_type: file.type,
7097
+ file_name: file.name,
7098
+ file_sha1: filePayload.sha1,
7099
+ created_by: createdBy,
7100
+ fields_revision: fieldsRevisionId,
7101
+ submitted_at: submittedAt,
7102
+ field_identifier: fieldIdentifier
7103
+ });
7104
+ offlineAssetTypeFieldsAttachments.push(offlineAssetTypeFieldsAttachment);
7105
+ const attachmentPayload = {
7106
+ offline_id: offlineAssetTypeFieldsAttachment.offline_id,
7107
+ file_name: file.name,
7108
+ field_identifier: fieldIdentifier,
7109
+ file_extension: filePayload.extension,
7110
+ file_sha1: filePayload.sha1,
7111
+ fields_revision: fieldsRevisionId
7112
+ };
7113
+ attachmentPayloads.push(attachmentPayload);
7114
+ }
7115
+ this.dispatch(addAssetTypeFieldsAttachments(offlineAssetTypeFieldsAttachments));
7116
+ const promise = this.enqueueRequest({
7117
+ description: "Add asset type fields attachments",
7118
+ method: HttpMethod.POST,
7119
+ url: "/asset-type-fields-attachments/bulk/",
7120
+ payload: {
7121
+ submitted_at: submittedAt,
7122
+ attachments: attachmentPayloads,
7123
+ files: Object.values(filePayloads)
7124
+ },
7125
+ blockers: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7126
+ blocks: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7127
+ });
7128
+ promise.then((result) => {
7129
+ this.processPresignedUrls(result.presigned_urls);
7130
+ this.dispatch(updateAssetTypeFieldsAttachments(result.attachments));
7131
+ }).catch(() => {
7132
+ this.dispatch(
7133
+ deleteAssetTypeFieldsAttachments(
7134
+ offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7135
+ )
7136
+ );
7137
+ });
7138
+ return [offlineAssetTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7139
+ }
7140
+ async refreshStore(organization) {
7141
+ const result = await this.enqueueRequest({
7142
+ description: "Get asset type fields attachments",
7143
+ method: HttpMethod.GET,
7144
+ url: "/asset-type-fields-attachments/",
7145
+ queryParams: {
7146
+ organization: organization.toString()
7147
+ },
7148
+ blockers: [organization.toString()],
7149
+ blocks: []
7150
+ });
7151
+ this.dispatch(initializeAssetTypeFieldsAttachments(result));
7152
+ }
7153
+ }
7154
+ class AssetTypeFieldsService extends BaseApiService {
7155
+ add(payload) {
7156
+ var _a2;
7157
+ const { store } = this.client;
7158
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7159
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7160
+ const offlineAssetTypeFields = offline({
7161
+ ...payload,
7162
+ created_by: createdBy,
7163
+ submitted_at: submittedAt
7164
+ });
7165
+ this.dispatch(addAssetTypeFields(offlineAssetTypeFields));
7166
+ const promise = this.enqueueRequest({
7167
+ description: "Add Asset Type Fields",
7168
+ method: HttpMethod.POST,
7169
+ url: "/asset-type-fields/",
7170
+ payload: offlineAssetTypeFields,
7171
+ blockers: [offlineAssetTypeFields.asset_type],
7172
+ blocks: [offlineAssetTypeFields.offline_id]
7173
+ });
7174
+ promise.then((response) => {
7175
+ this.dispatch(updateAssetTypeFields(response));
7176
+ }).catch((error) => {
7177
+ this.dispatch(deleteAssetTypeFields(offlineAssetTypeFields.offline_id));
7178
+ throw error;
7179
+ });
7180
+ return [offlineAssetTypeFields, promise];
7181
+ }
7182
+ async refreshStore(organizationId) {
7183
+ const result = await this.enqueueRequest({
7184
+ description: "Get Asset Type Fields",
7185
+ method: HttpMethod.GET,
7186
+ url: "/asset-type-fields/",
7187
+ queryParams: {
7188
+ organization: organizationId.toString()
7189
+ },
7190
+ blockers: [],
7191
+ blocks: []
7192
+ });
7193
+ this.dispatch(initializeAssetTypeFields(result));
7194
+ }
7195
+ }
7196
+ class AssetTypeFieldValuesService extends BaseApiService {
7197
+ add(payload) {
7198
+ var _a2;
7199
+ const { store } = this.client;
7200
+ const state = store.getState();
7201
+ const { values } = separateFilesFromValues(payload.values);
7202
+ const offlineAssetTypeFieldValues = offline({
7203
+ ...payload,
7204
+ values,
7205
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
7206
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7207
+ });
7208
+ const promise = this.enqueueRequest({
7209
+ description: "Add asset type field values",
7210
+ method: HttpMethod.POST,
7211
+ url: "/asset-type-field-values/",
7212
+ payload: offlineAssetTypeFieldValues,
7213
+ blockers: [payload.asset, payload.fields_revision],
7214
+ blocks: [offlineAssetTypeFieldValues.offline_id]
7215
+ });
7216
+ this.dispatch(addAssetTypeFieldValues(offlineAssetTypeFieldValues));
7217
+ promise.then((result) => {
7218
+ this.dispatch(updateAssetTypeFieldValues(result));
7219
+ return result;
7220
+ }).catch(() => {
7221
+ this.dispatch(deleteAssetTypeFieldValues(offlineAssetTypeFieldValues.offline_id));
7222
+ });
7223
+ return [offlineAssetTypeFieldValues, promise];
7224
+ }
7225
+ bulkAdd(payload, batchSize) {
7226
+ var _a2;
7227
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7228
+ const { values } = separateFilesFromValues(payload.values);
7229
+ const offlineAssetTypeFieldValuesMany = [];
7230
+ const batches = chunkArray(payload.payloads, batchSize ?? payload.payloads.length);
7231
+ const batchPayloads = [];
7232
+ for (const batch of batches) {
7233
+ const assetTypeFieldValuesPayloads = [];
7234
+ for (const payload2 of batch) {
7235
+ const offlineAssetTypeFieldValues = offline({
7236
+ ...payload2,
7237
+ values: separateFilesFromValues(payload2.values).values,
7238
+ created_by: (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
7239
+ submitted_at: submittedAt
7240
+ });
7241
+ offlineAssetTypeFieldValuesMany.push(offlineAssetTypeFieldValues);
7242
+ assetTypeFieldValuesPayloads.push({
7243
+ offline_id: offlineAssetTypeFieldValues.offline_id,
7244
+ asset: payload2.asset,
7245
+ fields_revision: payload2.fields_revision,
7246
+ published_at: payload2.published_at,
7247
+ values: offlineAssetTypeFieldValues.values
7248
+ });
7249
+ }
7250
+ batchPayloads.push({
7251
+ submitted_at: submittedAt,
7252
+ values,
7253
+ field_values: assetTypeFieldValuesPayloads
7254
+ });
7255
+ }
7256
+ this.dispatch(addAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany));
7257
+ const promises = [];
7258
+ for (const payload2 of batchPayloads) {
7259
+ const assetIds = payload2.field_values.map((x) => x.asset);
7260
+ const assetTypeFieldsIds = payload2.field_values.map((x) => x.fields_revision);
7261
+ const assetTypeFieldValuesIds = payload2.field_values.map((x) => x.offline_id);
7262
+ const promise = this.enqueueRequest({
7263
+ description: "Bulk add asset type field values",
7264
+ method: HttpMethod.POST,
7265
+ url: "/asset-type-field-values/bulk/",
7266
+ payload: payload2,
7267
+ blockers: [...assetIds, ...assetTypeFieldsIds],
7268
+ blocks: assetTypeFieldValuesIds
7269
+ });
7270
+ promises.push(promise);
7271
+ }
7272
+ void Promise.all(promises).then((results) => {
7273
+ this.dispatch(updateAssetTypeFieldValuesMany(results.flat()));
7274
+ }).catch(() => {
7275
+ this.dispatch(deleteAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany.map((x) => x.offline_id)));
7276
+ });
7277
+ return [offlineAssetTypeFieldValuesMany, promises];
7278
+ }
7279
+ update(payload) {
7280
+ const { store } = this.client;
7281
+ const state = store.getState();
7282
+ const assetTypeFieldValues = selectAssetTypeFieldValuesById(payload.offline_id)(state);
7283
+ if (!assetTypeFieldValues) {
7284
+ throw new Error(`Expected AssetTypeFieldValues with offline_id ${payload.offline_id} to exist`);
7285
+ }
7286
+ const { values } = separateFilesFromValues(payload.values ?? {});
7287
+ const updatedAssetTypeFieldValues = {
7288
+ ...assetTypeFieldValues,
7289
+ ...payload,
7290
+ // values could also have a partial update
7291
+ values: {
7292
+ ...assetTypeFieldValues.values,
7293
+ ...values
7294
+ }
7295
+ };
7296
+ this.dispatch(updateAssetTypeFieldValues(updatedAssetTypeFieldValues));
7297
+ const promise = this.enqueueRequest({
7298
+ description: "Delete asset type field values",
7299
+ method: HttpMethod.PATCH,
7300
+ url: `/asset-type-field-values/${payload.offline_id}/`,
7301
+ payload: {
7302
+ ...payload,
7303
+ values: {
7304
+ ...assetTypeFieldValues.values,
7305
+ ...values
7306
+ }
7307
+ },
7308
+ blockers: [
7309
+ updatedAssetTypeFieldValues.offline_id,
7310
+ updatedAssetTypeFieldValues.fields_revision,
7311
+ updatedAssetTypeFieldValues.asset
7312
+ ],
7313
+ blocks: [updatedAssetTypeFieldValues.offline_id]
7314
+ });
7315
+ promise.then((result) => {
7316
+ this.dispatch(updateAssetTypeFieldValues(result));
7317
+ }).catch(() => {
7318
+ this.dispatch(updateAssetTypeFieldValues(assetTypeFieldValues));
7319
+ });
7320
+ return [updatedAssetTypeFieldValues, promise];
7321
+ }
7322
+ async delete(id) {
7323
+ const { store } = this.client;
7324
+ const state = store.getState();
7325
+ const assetTypeFieldValues = selectAssetTypeFieldValuesById(id)(state);
7326
+ if (!assetTypeFieldValues) {
7327
+ throw new Error(`Expected submission with offline_id ${id} to exist`);
7328
+ }
7329
+ const assetTypeFieldValuesAttachments = selectAttachmentsOfAssetTypeFieldValues(id)(state);
7330
+ this.dispatch(deleteAssetTypeFieldValues(id));
7331
+ this.dispatch(deleteAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments.map((x) => x.offline_id)));
7332
+ try {
7333
+ await this.enqueueRequest({
7334
+ description: "Delete asset type field values",
7335
+ method: HttpMethod.DELETE,
7336
+ url: `/asset-type-field-values/${id}/`,
7337
+ blockers: [id],
7338
+ blocks: []
7339
+ });
7340
+ } catch (e) {
7341
+ this.dispatch(addAssetTypeFieldValues(assetTypeFieldValues));
7342
+ this.dispatch(addAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments));
7343
+ throw e;
7344
+ }
7345
+ }
7346
+ async refreshStore(projectId) {
7347
+ const result = await this.enqueueRequest({
7348
+ description: "Get asset type field values",
7349
+ method: HttpMethod.GET,
7350
+ url: "/asset-type-field-values/",
7351
+ queryParams: {
7352
+ project: projectId.toString()
7353
+ },
7354
+ blockers: [],
7355
+ blocks: []
7356
+ });
7357
+ this.dispatch(initializeAssetTypeFieldValues(result));
7358
+ }
7359
+ }
7360
+ class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
7361
+ async bulkAdd(payloads, batchSize) {
7362
+ var _a2;
7363
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7364
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7365
+ const batches = chunkArray(payloads, batchSize ?? payloads.length);
7366
+ const offlineAssetTypeFieldValuesAttachments = [];
7367
+ const batchPayloads = [];
7368
+ for (const batch of batches) {
7369
+ const filePayloads = {};
7370
+ const attachmentPayloads = [];
7371
+ for (const payload of batch) {
7372
+ const { fieldValuesId, fieldIdentifier, file } = payload;
7373
+ const filePayload = await this.getFilePayload(file);
7374
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7375
+ const offlineAssetTypeFieldValuesAttachment = offline({
7376
+ file: URL.createObjectURL(file),
7377
+ file_type: file.type,
7378
+ file_name: file.name,
7379
+ file_sha1: filePayload.sha1,
7380
+ created_by: createdBy,
7381
+ field_values: fieldValuesId,
7382
+ submitted_at: submittedAt,
7383
+ field_identifier: fieldIdentifier
7384
+ });
7385
+ offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
7386
+ const attachmentPayload = {
7387
+ offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
7388
+ file_name: file.name,
7389
+ file_sha1: filePayload.sha1,
7390
+ file_extension: filePayload.extension,
7391
+ field_identifier: fieldIdentifier,
7392
+ field_values: fieldValuesId
7393
+ };
7394
+ attachmentPayloads.push(attachmentPayload);
7395
+ }
7396
+ batchPayloads.push({
7397
+ submitted_at: submittedAt,
7398
+ attachments: attachmentPayloads,
7399
+ files: Object.values(filePayloads)
7400
+ });
7401
+ }
7402
+ this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
7403
+ const promises = batchPayloads.map((payload) => {
7404
+ return this.enqueueRequest({
7405
+ description: "Add asset type field values attachments",
7406
+ method: HttpMethod.POST,
7407
+ url: "/asset-type-field-values-attachments/bulk/",
7408
+ payload,
7409
+ blockers: payload.attachments.map((payload2) => payload2.field_values),
7410
+ blocks: payload.attachments.map((payload2) => payload2.offline_id)
7411
+ });
7412
+ });
7413
+ Promise.all(promises).then((result) => {
7414
+ for (const res of result) this.processPresignedUrls(res.presigned_urls);
7415
+ const attachments = result.flatMap((res) => res.attachments);
7416
+ this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
7417
+ }).catch((error) => {
7418
+ this.dispatch(
7419
+ deleteAssetTypeFieldValuesAttachments(
7420
+ offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7421
+ )
7422
+ );
7423
+ throw error;
7424
+ });
7425
+ return [
7426
+ offlineAssetTypeFieldValuesAttachments,
7427
+ promises.map((promise) => promise.then(({ attachments }) => attachments))
7428
+ ];
7429
+ }
7430
+ async bulkDelete(ids) {
7431
+ const { store } = this.client;
7432
+ const state = store.getState();
7433
+ const attachments = selectAssetTypeFieldValuesAttachmentsByIds(ids)(state);
7434
+ this.dispatch(deleteAssetTypeFieldValuesAttachments(ids));
7435
+ try {
7436
+ await this.enqueueRequest({
7437
+ description: "Delete asset type field values attachments",
7438
+ method: HttpMethod.DELETE,
7439
+ url: "/asset-type-field-values-attachments/bulk/",
7440
+ payload: { attachment_ids: ids },
7441
+ blockers: ids,
7442
+ blocks: []
7443
+ });
7444
+ } catch (e) {
7445
+ this.dispatch(addAssetTypeFieldValuesAttachments(attachments));
7446
+ throw e;
7447
+ }
7448
+ }
7449
+ async refreshStore(projectId) {
7450
+ const result = await this.enqueueRequest({
7451
+ description: "Get asset type field values attachments",
7452
+ method: HttpMethod.GET,
7453
+ url: "/asset-type-field-values-attachments/",
7454
+ queryParams: {
7455
+ project: projectId.toString()
7456
+ },
7457
+ blockers: [],
7458
+ blocks: []
7459
+ });
7460
+ this.dispatch(initializeAssetTypeFieldValuesAttachments(result));
7461
+ }
7462
+ }
7463
+ class IssueTypeFieldsAttachmentService extends BaseUploadService {
7464
+ async bulkAdd(payloads) {
7465
+ var _a2;
7466
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7467
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7468
+ const filePayloads = {};
7469
+ const offlineIssueTypeFieldsAttachments = [];
7470
+ const attachmentPayloads = [];
7471
+ for (const payload of payloads) {
7472
+ const { fieldsRevisionId, fieldIdentifier, file } = payload;
7473
+ const filePayload = await this.getFilePayload(file);
7474
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7475
+ const offlineIssueTypeFieldsAttachment = offline({
7476
+ file: URL.createObjectURL(file),
7477
+ file_type: file.type,
7478
+ file_name: file.name,
7479
+ file_sha1: filePayload.sha1,
7480
+ created_by: createdBy,
7481
+ fields_revision: fieldsRevisionId,
7482
+ submitted_at: submittedAt,
7483
+ field_identifier: fieldIdentifier
7484
+ });
7485
+ offlineIssueTypeFieldsAttachments.push(offlineIssueTypeFieldsAttachment);
7486
+ const attachmentPayload = {
7487
+ offline_id: offlineIssueTypeFieldsAttachment.offline_id,
7488
+ file_name: file.name,
7489
+ file_extension: filePayload.extension,
7490
+ field_identifier: fieldIdentifier,
7491
+ file_sha1: filePayload.sha1,
7492
+ fields_revision: fieldsRevisionId
7493
+ };
7494
+ attachmentPayloads.push(attachmentPayload);
7495
+ }
7496
+ this.dispatch(addIssueTypeFieldsAttachments(offlineIssueTypeFieldsAttachments));
7497
+ const promise = this.enqueueRequest({
7498
+ description: "Add issue type fields attachments",
7499
+ method: HttpMethod.POST,
7500
+ url: "/issue-type-fields-attachments/bulk/",
7501
+ payload: {
7502
+ submitted_at: submittedAt,
7503
+ attachments: attachmentPayloads,
7504
+ files: Object.values(filePayloads)
7505
+ },
7506
+ blockers: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
7507
+ blocks: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7508
+ });
7509
+ promise.then((result) => {
7510
+ this.processPresignedUrls(result.presigned_urls);
7511
+ this.dispatch(updateIssueTypeFieldsAttachments(result.attachments));
7512
+ }).catch(() => {
7513
+ this.dispatch(
7514
+ deleteIssueTypeFieldsAttachments(
7515
+ offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
7516
+ )
7517
+ );
7518
+ });
7519
+ return [offlineIssueTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
7520
+ }
7521
+ async refreshStore(organizationId) {
7522
+ const result = await this.enqueueRequest({
7523
+ description: "get issue type fields attachments",
7524
+ method: HttpMethod.GET,
7525
+ url: "/issue-type-fields-attachments/",
7526
+ queryParams: {
7527
+ organization: organizationId.toString()
7528
+ },
7529
+ blockers: [organizationId.toString()],
7530
+ blocks: []
7531
+ });
7532
+ this.dispatch(initializeIssueTypeFieldsAttachments(result));
7533
+ }
7534
+ }
7535
+ class IssueTypeFieldsService extends BaseApiService {
7536
+ add(payload) {
7537
+ var _a2;
7538
+ const { store } = this.client;
7539
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7540
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7541
+ const offlineIssueTypeFields = offline({
7542
+ ...payload,
7543
+ created_by: createdBy,
7544
+ submitted_at: submittedAt
7545
+ });
7546
+ this.dispatch(addIssueTypeFields(offlineIssueTypeFields));
7547
+ const promise = this.enqueueRequest({
7548
+ description: "Add Issue Type Fields",
7549
+ method: HttpMethod.POST,
7550
+ url: "/issue-type-fields/",
7551
+ payload: offlineIssueTypeFields,
7552
+ blockers: [offlineIssueTypeFields.issue_type],
7553
+ blocks: [offlineIssueTypeFields.offline_id]
7554
+ });
7555
+ promise.then((response) => {
7556
+ this.dispatch(updateIssueTypeFields(response));
7557
+ }).catch((error) => {
7558
+ this.dispatch(deleteIssueTypeFields(offlineIssueTypeFields.offline_id));
7559
+ throw error;
7560
+ });
7561
+ return [offlineIssueTypeFields, promise];
7562
+ }
7563
+ async refreshStore(organizationId) {
7564
+ const result = await this.enqueueRequest({
7565
+ description: "Get Issue Type Fields",
7566
+ method: HttpMethod.GET,
7567
+ url: "/issue-type-fields/",
7568
+ queryParams: {
7569
+ organization: organizationId.toString()
7570
+ },
7571
+ blockers: [],
7572
+ blocks: []
7573
+ });
7574
+ this.dispatch(initializeIssueTypeFields(result));
7575
+ }
7576
+ }
7577
+ class IssueTypeFieldValuesAttachmentService extends BaseUploadService {
7578
+ async bulkAdd(payloads) {
7579
+ var _a2;
7580
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7581
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7582
+ const filePayloads = {};
7583
+ const offlineIssueTypeFieldValuesAttachments = [];
7584
+ const attachmentPayloads = [];
7585
+ for (const payload of payloads) {
7586
+ const { fieldValuesId, fieldIdentifier, file } = payload;
7587
+ const filePayload = await this.getFilePayload(file);
7588
+ if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
7589
+ const offlineIssueTypeFieldValuesAttachment = offline({
7590
+ file: URL.createObjectURL(file),
7591
+ file_type: file.type,
7592
+ file_name: file.name,
7593
+ file_sha1: filePayload.sha1,
7594
+ created_by: createdBy,
7595
+ field_values: fieldValuesId,
7596
+ submitted_at: submittedAt,
7597
+ field_identifier: fieldIdentifier
7598
+ });
7599
+ offlineIssueTypeFieldValuesAttachments.push(offlineIssueTypeFieldValuesAttachment);
7600
+ const attachmentPayload = {
7601
+ offline_id: offlineIssueTypeFieldValuesAttachment.offline_id,
7602
+ file_name: file.name,
7603
+ file_sha1: filePayload.sha1,
7604
+ file_extension: filePayload.extension,
7605
+ field_identifier: fieldIdentifier,
7606
+ field_values: fieldValuesId
7607
+ };
7608
+ attachmentPayloads.push(attachmentPayload);
7609
+ }
7610
+ this.dispatch(addIssueTypeFieldValuesAttachments(offlineIssueTypeFieldValuesAttachments));
7611
+ const promise = this.enqueueRequest({
7612
+ description: "Add issue type field values attachments",
7613
+ method: HttpMethod.POST,
7614
+ url: "/issue-type-field-values-attachments/bulk/",
7615
+ payload: {
7616
+ submitted_at: submittedAt,
7617
+ attachments: attachmentPayloads,
7618
+ files: Object.values(filePayloads)
7619
+ },
7620
+ blockers: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
7621
+ blocks: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7622
+ });
7623
+ promise.then(({ presigned_urls, attachments }) => {
7624
+ this.processPresignedUrls(presigned_urls);
7625
+ this.dispatch(updateIssueTypeFieldValuesAttachments(attachments));
7626
+ }).catch((error) => {
7627
+ this.dispatch(
7628
+ deleteIssueTypeFieldValuesAttachments(
7629
+ offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
7630
+ )
7631
+ );
7632
+ throw error;
7633
+ });
7634
+ return [offlineIssueTypeFieldValuesAttachments, promise.then(({ attachments }) => attachments)];
7635
+ }
7636
+ async bulkDelete(attachmentsIds) {
7637
+ const { store } = this.client;
7638
+ const state = store.getState();
7639
+ const attachments = selectIssueTypeFieldValuesAttachmentsByIds(attachmentsIds)(state);
7640
+ this.dispatch(deleteIssueTypeFieldValuesAttachments(attachmentsIds));
7641
+ try {
7642
+ await this.enqueueRequest({
7643
+ description: "Delete issue type field values attachments",
7644
+ method: HttpMethod.DELETE,
7645
+ url: "/issue-type-field-values-attachments/bulk/",
7646
+ payload: { attachment_ids: attachmentsIds },
7647
+ blockers: attachmentsIds,
7648
+ blocks: []
7649
+ });
7650
+ } catch (e) {
7651
+ this.dispatch(addIssueTypeFieldValuesAttachments(attachments));
7652
+ throw e;
7653
+ }
7654
+ }
7655
+ async refreshStore(projectId) {
7656
+ const result = await this.enqueueRequest({
7657
+ description: "Get issue type field values attachments",
7658
+ method: HttpMethod.GET,
7659
+ url: "/issue-type-field-values-attachments/",
7660
+ queryParams: {
7661
+ project: projectId.toString()
7662
+ },
7663
+ blockers: [],
7664
+ blocks: []
7665
+ });
7666
+ this.dispatch(initializeIssueTypeFieldValuesAttachments(result));
7667
+ }
7668
+ }
7669
+ class IssueTypeFieldValuesService extends BaseApiService {
7670
+ add(payload) {
7671
+ var _a2;
7672
+ const { store } = this.client;
7673
+ const state = store.getState();
7674
+ const { values } = separateFilesFromValues(payload.values);
7675
+ const offlineIssueTypeFieldValues = offline({
7676
+ ...payload,
7677
+ values,
7678
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
7679
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7680
+ });
7681
+ const promise = this.enqueueRequest({
7682
+ description: "Add issue type field values",
7683
+ method: HttpMethod.POST,
7684
+ url: "/issue-type-field-values/",
7685
+ payload: offlineIssueTypeFieldValues,
7686
+ blockers: [payload.issue, payload.fields_revision],
7687
+ blocks: [offlineIssueTypeFieldValues.offline_id]
7688
+ });
7689
+ this.dispatch(addIssueTypeFieldValues(offlineIssueTypeFieldValues));
7690
+ promise.then((result) => {
7691
+ this.dispatch(updateIssueTypeFieldValues(result));
7692
+ return result;
7693
+ }).catch(() => {
7694
+ this.dispatch(deleteIssueTypeFieldValues(offlineIssueTypeFieldValues.offline_id));
7695
+ });
7696
+ return [offlineIssueTypeFieldValues, promise];
7697
+ }
7698
+ update(payload) {
7699
+ const { store } = this.client;
7700
+ const state = store.getState();
7701
+ const issueTypeFieldValues = selectIssueTypeFieldValuesById(payload.offline_id)(state);
7702
+ if (!issueTypeFieldValues) {
7703
+ throw new Error(`Expected IssueTypeFieldValues with offline_id ${payload.offline_id} to exist`);
7704
+ }
7705
+ const { values } = separateFilesFromValues(payload.values ?? {});
7706
+ const updatedIssueTypeFieldValues = {
7707
+ ...issueTypeFieldValues,
7708
+ ...payload,
7709
+ // values could also have a partial update
7710
+ values: {
7711
+ ...issueTypeFieldValues.values,
7712
+ ...values
7713
+ }
7714
+ };
7715
+ this.dispatch(updateIssueTypeFieldValues(updatedIssueTypeFieldValues));
7716
+ const promise = this.enqueueRequest({
7717
+ description: "Update issue type field values",
7718
+ method: HttpMethod.PATCH,
7719
+ url: `/issue-type-field-values/${payload.offline_id}/`,
7720
+ payload: {
7721
+ ...payload,
7722
+ values: {
7723
+ ...issueTypeFieldValues.values,
7724
+ ...values
7725
+ }
7726
+ },
7727
+ blockers: [
7728
+ updatedIssueTypeFieldValues.offline_id,
7729
+ updatedIssueTypeFieldValues.fields_revision,
7730
+ updatedIssueTypeFieldValues.issue
7731
+ ],
7732
+ blocks: [updatedIssueTypeFieldValues.offline_id]
7733
+ });
7734
+ promise.then((result) => {
7735
+ this.dispatch(updateIssueTypeFieldValues(result));
7736
+ }).catch(() => {
7737
+ this.dispatch(updateIssueTypeFieldValues(issueTypeFieldValues));
7738
+ });
7739
+ return [updatedIssueTypeFieldValues, promise];
7740
+ }
7741
+ async delete(id) {
7742
+ const { store } = this.client;
7743
+ const state = store.getState();
7744
+ const issueTypeFieldValues = selectIssueTypeFieldValuesById(id)(state);
7745
+ if (!issueTypeFieldValues) {
7746
+ throw new Error(`Expected submission with offline_id ${id} to exist`);
7747
+ }
7748
+ const issueTypeFieldValuesAttachments = selectAttachmentsOfIssueTypeFieldValues(id)(state);
7749
+ this.dispatch(deleteIssueTypeFieldValues(id));
7750
+ this.dispatch(deleteIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments.map((x) => x.offline_id)));
7751
+ try {
7752
+ await this.enqueueRequest({
7753
+ description: "Delete issue type field values",
7754
+ method: HttpMethod.DELETE,
7755
+ url: `/issue-type-field-values/${id}/`,
7756
+ blockers: [id],
7757
+ blocks: []
7758
+ });
7759
+ } catch (e) {
7760
+ this.dispatch(addIssueTypeFieldValues(issueTypeFieldValues));
7761
+ this.dispatch(addIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments));
7762
+ throw e;
7763
+ }
7764
+ }
7765
+ async refreshStore(projectId) {
7766
+ const result = await this.enqueueRequest({
7767
+ description: "Get issue type field values",
7768
+ method: HttpMethod.GET,
7769
+ url: "/issue-type-field-values/",
7770
+ queryParams: {
7771
+ project: projectId.toString()
7772
+ },
7773
+ blockers: [],
7774
+ blocks: []
7775
+ });
7776
+ this.dispatch(initializeIssueTypeFieldValues(result));
7777
+ }
7778
+ }
7058
7779
  var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
7059
7780
  VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
7060
7781
  VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
@@ -7072,6 +7793,10 @@ export {
7072
7793
  AssetStageCompletionService,
7073
7794
  AssetStageService,
7074
7795
  AssetTypeAttachmentService,
7796
+ AssetTypeFieldValuesAttachmentService,
7797
+ AssetTypeFieldValuesService,
7798
+ AssetTypeFieldsAttachmentService,
7799
+ AssetTypeFieldsService,
7075
7800
  AssetTypeService,
7076
7801
  AttachmentModel,
7077
7802
  BaseApiService,
@@ -7088,7 +7813,10 @@ export {
7088
7813
  EmailDomainsService,
7089
7814
  EmailVerificationService,
7090
7815
  FileService,
7816
+ FormRevisionAttachmentService,
7817
+ FormRevisionService,
7091
7818
  FormService,
7819
+ FormSubmissionAttachmentService,
7092
7820
  FormSubmissionService,
7093
7821
  GREEN,
7094
7822
  GeoImageService,
@@ -7099,6 +7827,10 @@ export {
7099
7827
  IssuePriority,
7100
7828
  IssueService,
7101
7829
  IssueStatus,
7830
+ IssueTypeFieldValuesAttachmentService,
7831
+ IssueTypeFieldValuesService,
7832
+ IssueTypeFieldsAttachmentService,
7833
+ IssueTypeFieldsService,
7102
7834
  IssueTypeService,
7103
7835
  IssueUpdateChange,
7104
7836
  IssueUpdateService,
@@ -7137,6 +7869,14 @@ export {
7137
7869
  addAssetType,
7138
7870
  addAssetTypeAttachment,
7139
7871
  addAssetTypeAttachments,
7872
+ addAssetTypeFieldValues,
7873
+ addAssetTypeFieldValuesAttachment,
7874
+ addAssetTypeFieldValuesAttachments,
7875
+ addAssetTypeFieldValuesMany,
7876
+ addAssetTypeFields,
7877
+ addAssetTypeFieldsAttachment,
7878
+ addAssetTypeFieldsAttachments,
7879
+ addAssetTypeFieldsMany,
7140
7880
  addAssetTypes,
7141
7881
  addAssets,
7142
7882
  addCategory,
@@ -7165,6 +7905,14 @@ export {
7165
7905
  addIssueComment,
7166
7906
  addIssueComments,
7167
7907
  addIssueType,
7908
+ addIssueTypeFieldValues,
7909
+ addIssueTypeFieldValuesAttachment,
7910
+ addIssueTypeFieldValuesAttachments,
7911
+ addIssueTypeFieldValuesMany,
7912
+ addIssueTypeFields,
7913
+ addIssueTypeFieldsAttachment,
7914
+ addIssueTypeFieldsAttachments,
7915
+ addIssueTypeFieldsMany,
7168
7916
  addIssueUpdate,
7169
7917
  addIssueUpdates,
7170
7918
  addIssues,
@@ -7189,6 +7937,14 @@ export {
7189
7937
  assetStageSlice,
7190
7938
  assetTypeAttachmentReducer,
7191
7939
  assetTypeAttachmentSlice,
7940
+ assetTypeFieldValuesAttachmentReducer,
7941
+ assetTypeFieldValuesAttachmentSlice,
7942
+ assetTypeFieldValuesReducer,
7943
+ assetTypeFieldValuesSlice,
7944
+ assetTypeFieldsAttachmentReducer,
7945
+ assetTypeFieldsAttachmentSlice,
7946
+ assetTypeFieldsReducer,
7947
+ assetTypeFieldsSlice,
7192
7948
  assetTypeReducer,
7193
7949
  assetTypeSlice,
7194
7950
  authReducer,
@@ -7213,6 +7969,14 @@ export {
7213
7969
  deleteAssetType,
7214
7970
  deleteAssetTypeAttachment,
7215
7971
  deleteAssetTypeAttachments,
7972
+ deleteAssetTypeFieldValues,
7973
+ deleteAssetTypeFieldValuesAttachment,
7974
+ deleteAssetTypeFieldValuesAttachments,
7975
+ deleteAssetTypeFieldValuesMany,
7976
+ deleteAssetTypeFields,
7977
+ deleteAssetTypeFieldsAttachment,
7978
+ deleteAssetTypeFieldsAttachments,
7979
+ deleteAssetTypeFieldsMany,
7216
7980
  deleteAssetTypes,
7217
7981
  deleteAssets,
7218
7982
  deleteCategory,
@@ -7237,6 +8001,14 @@ export {
7237
8001
  deleteIssueAttachments,
7238
8002
  deleteIssueComment,
7239
8003
  deleteIssueComments,
8004
+ deleteIssueTypeFieldValues,
8005
+ deleteIssueTypeFieldValuesAttachment,
8006
+ deleteIssueTypeFieldValuesAttachments,
8007
+ deleteIssueTypeFieldValuesMany,
8008
+ deleteIssueTypeFields,
8009
+ deleteIssueTypeFieldsAttachment,
8010
+ deleteIssueTypeFieldsAttachments,
8011
+ deleteIssueTypeFieldsMany,
7240
8012
  deleteIssueUpdate,
7241
8013
  deleteIssueUpdates,
7242
8014
  deleteIssues,
@@ -7294,6 +8066,10 @@ export {
7294
8066
  initializeAssetStageCompletions,
7295
8067
  initializeAssetStages,
7296
8068
  initializeAssetTypeAttachments,
8069
+ initializeAssetTypeFieldValues,
8070
+ initializeAssetTypeFieldValuesAttachments,
8071
+ initializeAssetTypeFields,
8072
+ initializeAssetTypeFieldsAttachments,
7297
8073
  initializeAssetTypes,
7298
8074
  initializeAssets,
7299
8075
  initializeCategories,
@@ -7308,6 +8084,10 @@ export {
7308
8084
  initializeGeoImages,
7309
8085
  initializeIssueAssociations,
7310
8086
  initializeIssueAttachments,
8087
+ initializeIssueTypeFieldValues,
8088
+ initializeIssueTypeFieldValuesAttachments,
8089
+ initializeIssueTypeFields,
8090
+ initializeIssueTypeFieldsAttachments,
7311
8091
  initializeIssueTypes,
7312
8092
  initializeIssueUpdates,
7313
8093
  initializeIssues,
@@ -7327,6 +8107,14 @@ export {
7327
8107
  issueCommentSlice,
7328
8108
  issueReducer,
7329
8109
  issueSlice,
8110
+ issueTypeFieldValuesAttachmentReducer,
8111
+ issueTypeFieldValuesAttachmentSlice,
8112
+ issueTypeFieldValuesReducer,
8113
+ issueTypeFieldValuesSlice,
8114
+ issueTypeFieldsAttachmentReducer,
8115
+ issueTypeFieldsAttachmentSlice,
8116
+ issueTypeFieldsReducer,
8117
+ issueTypeFieldsSlice,
7330
8118
  issueTypeReducer,
7331
8119
  issueTypeSlice,
7332
8120
  issueUpdateReducer,
@@ -7390,7 +8178,23 @@ export {
7390
8178
  selectAssetTypeAttachmentMapping,
7391
8179
  selectAssetTypeAttachments,
7392
8180
  selectAssetTypeById,
8181
+ selectAssetTypeFieldValues,
8182
+ selectAssetTypeFieldValuesAttachmentById,
8183
+ selectAssetTypeFieldValuesAttachments,
8184
+ selectAssetTypeFieldValuesAttachmentsByIds,
8185
+ selectAssetTypeFieldValuesAttachmentsMapping,
8186
+ selectAssetTypeFieldValuesById,
8187
+ selectAssetTypeFieldValuesMapping,
8188
+ selectAssetTypeFieldValuesOfAsset,
8189
+ selectAssetTypeFields,
8190
+ selectAssetTypeFieldsAttachmentById,
8191
+ selectAssetTypeFieldsAttachments,
8192
+ selectAssetTypeFieldsAttachmentsMapping,
8193
+ selectAssetTypeFieldsById,
8194
+ selectAssetTypeFieldsMapping,
8195
+ selectAssetTypeFieldsOfAssetType,
7393
8196
  selectAssetTypeStagesMapping,
8197
+ selectAssetTypeValuesOfAssetType,
7394
8198
  selectAssetTypes,
7395
8199
  selectAssetTypesByIds,
7396
8200
  selectAssetTypesMapping,
@@ -7398,18 +8202,20 @@ export {
7398
8202
  selectAssetsByIds,
7399
8203
  selectAssetsMapping,
7400
8204
  selectAssetsOfAssetType,
7401
- selectAttachedFormSubmissionsOfAsset,
7402
- selectAttachedFormSubmissionsOfIssue,
7403
8205
  selectAttachmentsOfAsset,
7404
8206
  selectAttachmentsOfAssetByType,
7405
8207
  selectAttachmentsOfAssetType,
7406
8208
  selectAttachmentsOfAssetTypeByType,
8209
+ selectAttachmentsOfAssetTypeFieldValues,
8210
+ selectAttachmentsOfAssetTypeFields,
7407
8211
  selectAttachmentsOfDocument,
7408
8212
  selectAttachmentsOfDocumentByType,
7409
8213
  selectAttachmentsOfFormRevision,
7410
8214
  selectAttachmentsOfFormSubmission,
7411
8215
  selectAttachmentsOfIssue,
7412
8216
  selectAttachmentsOfIssueByType,
8217
+ selectAttachmentsOfIssueTypeFieldValues,
8218
+ selectAttachmentsOfIssueTypeFields,
7413
8219
  selectAttachmentsOfProject,
7414
8220
  selectAttachmentsOfProjectByType,
7415
8221
  selectCategories,
@@ -7435,8 +8241,6 @@ export {
7435
8241
  selectFilteredForms,
7436
8242
  selectFormById,
7437
8243
  selectFormMapping,
7438
- selectFormOfAssetType,
7439
- selectFormOfIssueType,
7440
8244
  selectFormRevisionAttachmentsMapping,
7441
8245
  selectFormRevisionById,
7442
8246
  selectFormRevisionMapping,
@@ -7446,16 +8250,11 @@ export {
7446
8250
  selectFormSubmissionAttachmentsMapping,
7447
8251
  selectFormSubmissionById,
7448
8252
  selectFormSubmissions,
7449
- selectFormSubmissionsByAssets,
7450
- selectFormSubmissionsByFormRevisions,
7451
- selectFormSubmissionsByIssues,
7452
8253
  selectFormSubmissionsMapping,
7453
8254
  selectFormSubmissionsOfAsset,
7454
8255
  selectFormSubmissionsOfForm,
7455
8256
  selectFormSubmissionsOfIssue,
7456
8257
  selectForms,
7457
- selectFormsCount,
7458
- selectGeneralFormCount,
7459
8258
  selectGeoImageById,
7460
8259
  selectGeoImageMapping,
7461
8260
  selectGeoImages,
@@ -7477,7 +8276,23 @@ export {
7477
8276
  selectIssueCountOfCategory,
7478
8277
  selectIssueMapping,
7479
8278
  selectIssueTypeById,
8279
+ selectIssueTypeFieldValues,
8280
+ selectIssueTypeFieldValuesAttachmentById,
8281
+ selectIssueTypeFieldValuesAttachments,
8282
+ selectIssueTypeFieldValuesAttachmentsByIds,
8283
+ selectIssueTypeFieldValuesAttachmentsMapping,
8284
+ selectIssueTypeFieldValuesById,
8285
+ selectIssueTypeFieldValuesMapping,
8286
+ selectIssueTypeFieldValuesOfIssue,
8287
+ selectIssueTypeFields,
8288
+ selectIssueTypeFieldsAttachmentById,
8289
+ selectIssueTypeFieldsAttachments,
8290
+ selectIssueTypeFieldsAttachmentsMapping,
8291
+ selectIssueTypeFieldsById,
8292
+ selectIssueTypeFieldsMapping,
8293
+ selectIssueTypeFieldsOfIssueType,
7480
8294
  selectIssueTypeMapping,
8295
+ selectIssueTypeValuesOfIssueType,
7481
8296
  selectIssueTypes,
7482
8297
  selectIssueTypesByIds,
7483
8298
  selectIssueTypesOfOrganization,
@@ -7486,8 +8301,9 @@ export {
7486
8301
  selectIssuesByIds,
7487
8302
  selectIssuesOfIssueType,
7488
8303
  selectIssuesOfIssueTypeCount,
7489
- selectLatestFormRevisionByForm,
8304
+ selectLatestAssetTypeFieldsOfAssetType,
7490
8305
  selectLatestFormRevisionOfForm,
8306
+ selectLatestIssueTypeFieldsOfIssueType,
7491
8307
  selectLatestRetryTime,
7492
8308
  selectLicense,
7493
8309
  selectLicenseForProject,
@@ -7524,10 +8340,8 @@ export {
7524
8340
  selectProjectsOfOrganization,
7525
8341
  selectRehydrated,
7526
8342
  selectRootDocuments,
7527
- selectSortedFormSubmissionsOfForm,
7528
8343
  selectSortedOrganizationUsers,
7529
8344
  selectSortedProjectUsers,
7530
- selectStageFormIdsFromStageIds,
7531
8345
  selectStageMapping,
7532
8346
  selectStagesOfAssetType,
7533
8347
  selectTeamById,
@@ -7543,6 +8357,8 @@ export {
7543
8357
  selectWorkspaceById,
7544
8358
  selectWorkspaceMapping,
7545
8359
  selectWorkspaces,
8360
+ separateFilesFromValues,
8361
+ separateImageFromFields,
7546
8362
  setActiveProjectFileId,
7547
8363
  setAsset,
7548
8364
  setAssetAttachment,
@@ -7552,6 +8368,14 @@ export {
7552
8368
  setAssetType,
7553
8369
  setAssetTypeAttachment,
7554
8370
  setAssetTypeAttachments,
8371
+ setAssetTypeFieldValues,
8372
+ setAssetTypeFieldValuesAttachment,
8373
+ setAssetTypeFieldValuesAttachments,
8374
+ setAssetTypeFieldValuesMany,
8375
+ setAssetTypeFields,
8376
+ setAssetTypeFieldsAttachment,
8377
+ setAssetTypeFieldsAttachments,
8378
+ setAssetTypeFieldsMany,
7555
8379
  setAssetTypes,
7556
8380
  setAssets,
7557
8381
  setConversation,
@@ -7577,6 +8401,14 @@ export {
7577
8401
  setIssueComment,
7578
8402
  setIssueComments,
7579
8403
  setIssueType,
8404
+ setIssueTypeFieldValues,
8405
+ setIssueTypeFieldValuesAttachment,
8406
+ setIssueTypeFieldValuesAttachments,
8407
+ setIssueTypeFieldValuesMany,
8408
+ setIssueTypeFields,
8409
+ setIssueTypeFieldsAttachment,
8410
+ setIssueTypeFieldsAttachments,
8411
+ setIssueTypeFieldsMany,
7580
8412
  setIssueUpdate,
7581
8413
  setLoggedIn,
7582
8414
  setOrganizations,
@@ -7611,6 +8443,14 @@ export {
7611
8443
  updateAssetType,
7612
8444
  updateAssetTypeAttachment,
7613
8445
  updateAssetTypeAttachments,
8446
+ updateAssetTypeFieldValues,
8447
+ updateAssetTypeFieldValuesAttachment,
8448
+ updateAssetTypeFieldValuesAttachments,
8449
+ updateAssetTypeFieldValuesMany,
8450
+ updateAssetTypeFields,
8451
+ updateAssetTypeFieldsAttachment,
8452
+ updateAssetTypeFieldsAttachments,
8453
+ updateAssetTypeFieldsMany,
7614
8454
  updateAssetTypes,
7615
8455
  updateAssets,
7616
8456
  updateCategory,
@@ -7633,6 +8473,14 @@ export {
7633
8473
  updateIssueAttachment,
7634
8474
  updateIssueAttachments,
7635
8475
  updateIssueType,
8476
+ updateIssueTypeFieldValues,
8477
+ updateIssueTypeFieldValuesAttachment,
8478
+ updateIssueTypeFieldValuesAttachments,
8479
+ updateIssueTypeFieldValuesMany,
8480
+ updateIssueTypeFields,
8481
+ updateIssueTypeFieldsAttachment,
8482
+ updateIssueTypeFieldsAttachments,
8483
+ updateIssueTypeFieldsMany,
7636
8484
  updateLicense,
7637
8485
  updateOrganizationAccess,
7638
8486
  updateProject,