@overmap-ai/core 1.0.58-export-overmap-reducer.14 → 1.0.58-export-overmap-reducer.16

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.
@@ -436,13 +436,6 @@ var IssueStatus = /* @__PURE__ */ ((IssueStatus2) => {
436
436
  IssueStatus2[IssueStatus2["DONE"] = 4] = "DONE";
437
437
  return IssueStatus2;
438
438
  })(IssueStatus || {});
439
- var MapStyle = /* @__PURE__ */ ((MapStyle2) => {
440
- MapStyle2["LIGHT"] = "LIGHT";
441
- MapStyle2["DARK"] = "DARK";
442
- MapStyle2["SATELLITE"] = "SATELLITE";
443
- MapStyle2["NONE"] = "NONE";
444
- return MapStyle2;
445
- })(MapStyle || {});
446
439
  const VERSION_REDUCER_KEY$1 = "versioning";
447
440
  const latestVersion = () => migrations.length - 1;
448
441
  const initialVersioning = (state) => {
@@ -469,15 +462,15 @@ const wrapMigration = (migrator) => (state) => {
469
462
  };
470
463
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
471
464
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
472
- const initialState$s = {
465
+ const initialState$r = {
473
466
  accessToken: "",
474
467
  refreshToken: "",
475
468
  isLoggedIn: false
476
469
  };
477
470
  const authSlice = createSlice({
478
471
  name: "auth",
479
- initialState: initialState$s,
480
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
472
+ initialState: initialState$r,
473
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
481
474
  reducers: {
482
475
  setTokens: (state, action) => {
483
476
  state.accessToken = action.payload.accessToken;
@@ -1121,7 +1114,7 @@ const getLocalRelativeDateString = memoize((date, min2, max2) => {
1121
1114
  return getLocalDateString(date);
1122
1115
  return relative.format(days, "days");
1123
1116
  });
1124
- const initialState$r = {
1117
+ const initialState$q = {
1125
1118
  categories: {},
1126
1119
  usedCategoryColors: [],
1127
1120
  categoryVisibility: {
@@ -1131,8 +1124,8 @@ const initialState$r = {
1131
1124
  };
1132
1125
  const categorySlice = createSlice({
1133
1126
  name: "categories",
1134
- initialState: initialState$r,
1135
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1127
+ initialState: initialState$q,
1128
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1136
1129
  reducers: {
1137
1130
  setCategories: (state, action) => {
1138
1131
  if (!Array.isArray(action.payload))
@@ -1316,15 +1309,15 @@ function removeAttachments(state, action) {
1316
1309
  delete state.attachments[attachmentId];
1317
1310
  }
1318
1311
  }
1319
- const initialState$q = {
1312
+ const initialState$p = {
1320
1313
  assetTypes: {},
1321
1314
  hiddenAssetTypeIds: {},
1322
1315
  attachments: {}
1323
1316
  };
1324
1317
  const assetTypeSlice = createSlice({
1325
1318
  name: "assetTypes",
1326
- initialState: initialState$q,
1327
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1319
+ initialState: initialState$p,
1320
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1328
1321
  reducers: {
1329
1322
  addAssetType: (state, action) => {
1330
1323
  state.assetTypes[action.payload.offline_id] = action.payload;
@@ -1434,14 +1427,14 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1434
1427
  )
1435
1428
  );
1436
1429
  const assetTypeReducer = assetTypeSlice.reducer;
1437
- const initialState$p = {
1430
+ const initialState$o = {
1438
1431
  assets: {},
1439
1432
  attachments: {}
1440
1433
  };
1441
1434
  const assetSlice = createSlice({
1442
1435
  name: "assets",
1443
- initialState: initialState$p,
1444
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1436
+ initialState: initialState$o,
1437
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1445
1438
  reducers: {
1446
1439
  addAsset: (state, action) => {
1447
1440
  state.assets[action.payload.offline_id] = action.payload;
@@ -1614,13 +1607,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
1614
1607
  )
1615
1608
  );
1616
1609
  const assetReducer = assetSlice.reducer;
1617
- const initialState$o = {
1610
+ const initialState$n = {
1618
1611
  completionsByAssetId: {}
1619
1612
  };
1620
1613
  const assetStageCompletionSlice = createSlice({
1621
1614
  name: "assetStageCompletions",
1622
- initialState: initialState$o,
1623
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1615
+ initialState: initialState$n,
1616
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1624
1617
  reducers: {
1625
1618
  addStageCompletion: (state, action) => {
1626
1619
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1669,13 +1662,13 @@ const selectCompletedStageIdsForAsset = (asset) => (state) => {
1669
1662
  return Object.keys(state.assetStageCompletionReducer.completionsByAssetId[asset.offline_id] ?? {});
1670
1663
  };
1671
1664
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1672
- const initialState$n = {
1665
+ const initialState$m = {
1673
1666
  stages: {}
1674
1667
  };
1675
1668
  const assetStageSlice = createSlice({
1676
1669
  name: "assetStages",
1677
- initialState: initialState$n,
1678
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1670
+ initialState: initialState$m,
1671
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1679
1672
  reducers: {
1680
1673
  addStages: (state, action) => {
1681
1674
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1776,13 +1769,13 @@ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1776
1769
  );
1777
1770
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = assetStageSlice.actions;
1778
1771
  const assetStageReducer = assetStageSlice.reducer;
1779
- const initialState$m = {
1772
+ const initialState$l = {
1780
1773
  workspaces: {},
1781
1774
  activeWorkspaceId: null
1782
1775
  };
1783
1776
  const workspaceSlice = createSlice({
1784
1777
  name: "workspace",
1785
- initialState: initialState$m,
1778
+ initialState: initialState$l,
1786
1779
  // The `reducers` field lets us define reducers and generate associated actions
1787
1780
  reducers: {
1788
1781
  setWorkspaces: (state, action) => {
@@ -1839,7 +1832,7 @@ const selectPermittedWorkspaceIds = createSelector(
1839
1832
  );
1840
1833
  const workspaceReducer = workspaceSlice.reducer;
1841
1834
  const maxRecentIssues = 10;
1842
- const initialState$l = {
1835
+ const initialState$k = {
1843
1836
  issues: {},
1844
1837
  attachments: {},
1845
1838
  comments: {},
@@ -1851,9 +1844,9 @@ const initialState$l = {
1851
1844
  };
1852
1845
  const issueSlice = createSlice({
1853
1846
  name: "issues",
1854
- initialState: initialState$l,
1847
+ initialState: initialState$k,
1855
1848
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1856
- Object.assign(state, initialState$l);
1849
+ Object.assign(state, initialState$k);
1857
1850
  }),
1858
1851
  reducers: {
1859
1852
  setIssues: (state, action) => {
@@ -2289,14 +2282,14 @@ const selectRecentIssuesAsSearchResults = createSelector(
2289
2282
  }
2290
2283
  );
2291
2284
  const issueReducer = issueSlice.reducer;
2292
- const initialState$k = {
2285
+ const initialState$j = {
2293
2286
  issueTypes: {}
2294
2287
  };
2295
2288
  const issueTypeSlice = createSlice({
2296
2289
  name: "issueTypes",
2297
- initialState: initialState$k,
2290
+ initialState: initialState$j,
2298
2291
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2299
- Object.assign(state, initialState$k);
2292
+ Object.assign(state, initialState$j);
2300
2293
  }),
2301
2294
  reducers: {
2302
2295
  setIssueTypes: (state, action) => {
@@ -2363,15 +2356,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
2363
2356
  return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
2364
2357
  };
2365
2358
  const issueTypeReducer = issueTypeSlice.reducer;
2366
- const initialState$j = {
2359
+ const initialState$i = {
2367
2360
  s3Urls: {}
2368
2361
  };
2369
2362
  const msPerHour = 1e3 * 60 * 60;
2370
2363
  const msPerWeek = msPerHour * 24 * 7;
2371
2364
  const fileSlice = createSlice({
2372
2365
  name: "file",
2373
- initialState: initialState$j,
2374
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2366
+ initialState: initialState$i,
2367
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2375
2368
  reducers: {
2376
2369
  setUploadUrl: (state, action) => {
2377
2370
  const { url, fields, sha1 } = action.payload;
@@ -2398,33 +2391,6 @@ const selectUploadUrl = (sha1) => (state) => {
2398
2391
  return url;
2399
2392
  };
2400
2393
  const fileReducer = fileSlice.reducer;
2401
- const initialState$i = {
2402
- // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2403
- mapStyle: MapStyle.SATELLITE,
2404
- showTooltips: false,
2405
- centerMapToProject: false
2406
- };
2407
- const mapSlice = createSlice({
2408
- name: "map",
2409
- initialState: initialState$i,
2410
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2411
- reducers: {
2412
- setMapStyle: (state, action) => {
2413
- state.mapStyle = action.payload;
2414
- },
2415
- setShowTooltips: (state, action) => {
2416
- state.showTooltips = action.payload;
2417
- },
2418
- setCenterMapToProject: (state, action) => {
2419
- state.centerMapToProject = action.payload;
2420
- }
2421
- }
2422
- });
2423
- const { setMapStyle, setShowTooltips, setCenterMapToProject } = mapSlice.actions;
2424
- const selectMapStyle = (state) => state.mapReducer.mapStyle;
2425
- const selectShowTooltips = (state) => state.mapReducer.showTooltips;
2426
- const selectCenterMapToProject = (state) => state.mapReducer.centerMapToProject;
2427
- const mapReducer = mapSlice.reducer;
2428
2394
  var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
2429
2395
  ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
2430
2396
  ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
@@ -2453,11 +2419,6 @@ var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
2453
2419
  IssueUpdateChange2["DUE_DATE"] = "due_date";
2454
2420
  return IssueUpdateChange2;
2455
2421
  })(IssueUpdateChange || {});
2456
- var ProjectType = /* @__PURE__ */ ((ProjectType2) => {
2457
- ProjectType2[ProjectType2["PERSONAL"] = 0] = "PERSONAL";
2458
- ProjectType2[ProjectType2["ORGANIZATION"] = 2] = "ORGANIZATION";
2459
- return ProjectType2;
2460
- })(ProjectType || {});
2461
2422
  var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
2462
2423
  VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
2463
2424
  VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
@@ -2755,9 +2716,6 @@ const projectAccessReducer = projectAccessSlice.reducer;
2755
2716
  const initialState$d = {
2756
2717
  projects: {},
2757
2718
  activeProjectId: null,
2758
- recentProjectIds: [],
2759
- recentSearchableQueries: [],
2760
- createProjectType: ProjectType.PERSONAL,
2761
2719
  attachments: {}
2762
2720
  };
2763
2721
  const projectSlice = createSlice({
@@ -2770,20 +2728,9 @@ const projectSlice = createSlice({
2770
2728
  projectsMap[project.id] = project;
2771
2729
  });
2772
2730
  state.projects = projectsMap;
2773
- if (state.recentProjectIds.length === 0) {
2774
- state.recentProjectIds = action.payload.map((project) => project.id);
2775
- } else {
2776
- state.recentProjectIds.unshift(
2777
- ...action.payload.map((project) => project.id).filter((id) => !state.recentProjectIds.includes(id))
2778
- );
2779
- }
2780
2731
  },
2781
2732
  setActiveProjectId: (state, action) => {
2782
2733
  state.activeProjectId = action.payload;
2783
- if (action.payload !== null) {
2784
- state.recentProjectIds = state.recentProjectIds.filter((id) => id !== action.payload);
2785
- state.recentProjectIds.push(action.payload);
2786
- }
2787
2734
  },
2788
2735
  updateOrCreateProject: (state, action) => {
2789
2736
  state.projects[action.payload.id] = action.payload;
@@ -2795,12 +2742,8 @@ const projectSlice = createSlice({
2795
2742
  state.projects[project.id] = project;
2796
2743
  });
2797
2744
  },
2798
- setCreateProjectType: (state, action) => {
2799
- state.createProjectType = action.payload;
2800
- },
2801
2745
  deleteProject: (state, action) => {
2802
2746
  delete state.projects[action.payload.id];
2803
- state.recentProjectIds = state.recentProjectIds.filter((id) => id !== action.payload.id);
2804
2747
  },
2805
2748
  acceptProjectInvite: (state, action) => {
2806
2749
  if (action.payload in state.projects) {
@@ -2846,7 +2789,6 @@ const {
2846
2789
  updateOrCreateProject,
2847
2790
  updateOrCreateProjects: addOrReplaceProjects,
2848
2791
  setActiveProjectId,
2849
- setCreateProjectType,
2850
2792
  deleteProject,
2851
2793
  acceptProjectInvite,
2852
2794
  addActiveProjectIssuesCount,
@@ -2870,9 +2812,6 @@ const selectActiveProject = (state) => {
2870
2812
  }
2871
2813
  return state.projectReducer.projects[activeProjectId] ?? null;
2872
2814
  };
2873
- const selectRecentProjects = (state) => {
2874
- return state.projectReducer.recentProjectIds;
2875
- };
2876
2815
  const selectProject = restructureCreateSelectorWithArgs(
2877
2816
  createSelector(
2878
2817
  [selectProjects, (_state, projectId) => projectId],
@@ -2894,7 +2833,6 @@ const selectSortedProjects = createSelector(
2894
2833
  });
2895
2834
  }
2896
2835
  );
2897
- const selectCreateProjectType = (state) => state.projectReducer.createProjectType;
2898
2836
  const projectReducer = projectSlice.reducer;
2899
2837
  const selectProjectUsersIds = createSelector(
2900
2838
  [selectProjectAccesses],
@@ -3254,18 +3192,9 @@ const { setRehydrated } = rehydratedSlice.actions;
3254
3192
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3255
3193
  const rehydratedReducer = rehydratedSlice.reducer;
3256
3194
  const initialState$8 = {
3257
- useIssueTemplate: false,
3258
- // TODO: marked for deletion
3259
3195
  placementMode: false,
3260
3196
  enableClustering: false,
3261
3197
  svgLayout: false,
3262
- expandedSections: {
3263
- // TODO: marked for deletion
3264
- Issues: true,
3265
- "Map Layers": false,
3266
- Components: false,
3267
- Experimental: false
3268
- },
3269
3198
  appearance: "dark",
3270
3199
  isFetchingInitialData: false,
3271
3200
  // TODO: this is being used only in the custom hook in /web called useRetrySDK, which has something to do with licences
@@ -3277,18 +3206,12 @@ const settingSlice = createSlice({
3277
3206
  initialState: initialState$8,
3278
3207
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3279
3208
  reducers: {
3280
- setEnableDuplicateIssues: (state, action) => {
3281
- state.useIssueTemplate = action.payload;
3282
- },
3283
3209
  setEnablePlacementMode: (state, action) => {
3284
3210
  state.placementMode = action.payload;
3285
3211
  },
3286
3212
  setEnableSvgLayout: (state, action) => {
3287
3213
  state.svgLayout = action.payload;
3288
3214
  },
3289
- setSectionExpanded: (state, action) => {
3290
- Object.assign(state.expandedSections, action.payload);
3291
- },
3292
3215
  setEnableClustering: (state, action) => {
3293
3216
  state.enableClustering = action.payload;
3294
3217
  },
@@ -3304,20 +3227,16 @@ const settingSlice = createSlice({
3304
3227
  }
3305
3228
  });
3306
3229
  const {
3307
- setEnableDuplicateIssues,
3308
3230
  setEnablePlacementMode,
3309
3231
  setEnableSvgLayout,
3310
3232
  // TODO: needs to actually be used in /web
3311
- setSectionExpanded,
3312
3233
  setEnableClustering,
3313
3234
  setAppearance,
3314
3235
  setIsFetchingInitialData,
3315
3236
  setIsLoading
3316
3237
  } = settingSlice.actions;
3317
3238
  const selectEnablePlacementMode = (state) => state.settingReducer.placementMode;
3318
- const selectEnableDuplicateIssues = (state) => state.settingReducer.useIssueTemplate;
3319
3239
  const selectEnableSvgLayout = (state) => state.settingReducer.svgLayout;
3320
- const selectExpandedSections = (state) => state.settingReducer.expandedSections;
3321
3240
  const selectEnableClustering = (state) => state.settingReducer.enableClustering;
3322
3241
  const selectAppearance = (state) => state.settingReducer.appearance;
3323
3242
  const settingReducer = settingSlice.reducer;
@@ -3578,17 +3497,15 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
3578
3497
  (_state, search) => search
3579
3498
  ],
3580
3499
  (userForms, revisions, search) => {
3581
- const { searchTerm, maxResults, favorites, owner_organization, owner_user } = search;
3500
+ const { searchTerm, maxResults, favorites, organization } = search;
3582
3501
  const favoriteMatches = [];
3583
3502
  const regularMatches = [];
3584
3503
  for (const [userFormId, userForm] of Object.entries(userForms)) {
3585
3504
  if (favorites !== void 0 && userForm.favorite != favorites)
3586
3505
  continue;
3587
- if (Number.isInteger(owner_organization) && owner_organization !== userForm.owner_organization) {
3506
+ if (Number.isInteger(organization) && organization !== userForm.organization) {
3588
3507
  continue;
3589
3508
  }
3590
- if (Number.isInteger(owner_user) && owner_user !== userForm.owner_user)
3591
- continue;
3592
3509
  const latestRevision = _selectLatestFormRevision(revisions, userFormId);
3593
3510
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
3594
3511
  if (userForm.favorite) {
@@ -4307,7 +4224,6 @@ const overmapReducers = {
4307
4224
  assetTypeReducer,
4308
4225
  issueReducer,
4309
4226
  issueTypeReducer,
4310
- mapReducer,
4311
4227
  organizationReducer,
4312
4228
  outboxReducer,
4313
4229
  projectReducer,
@@ -4373,10 +4289,6 @@ function handleWorkspaceRemoval(draft, action) {
4373
4289
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4374
4290
  }
4375
4291
  }
4376
- const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4377
- for (const form of indexedForms) {
4378
- form.index_workspace = mainWorkspace.offline_id;
4379
- }
4380
4292
  }
4381
4293
  const overmapRootReducer = (state, action) => {
4382
4294
  if (action.type === "auth/setLoggedIn" && !action.payload) {
@@ -6758,8 +6670,7 @@ class ProjectService extends BaseApiService {
6758
6670
  });
6759
6671
  }
6760
6672
  }
6761
- const separateImageFromFields = async (payload) => {
6762
- const { fields } = payload;
6673
+ const separateImageFromFields = async (fields) => {
6763
6674
  const images = {};
6764
6675
  const newFields = [];
6765
6676
  for (const section of fields) {
@@ -6785,11 +6696,7 @@ const separateImageFromFields = async (payload) => {
6785
6696
  }
6786
6697
  newFields.push({ ...section, fields: newSectionFields });
6787
6698
  }
6788
- const payloadWithoutImage = {
6789
- ...payload,
6790
- fields: newFields
6791
- };
6792
- return { payloadWithoutImage, images };
6699
+ return { fields: newFields, images };
6793
6700
  };
6794
6701
  class UserFormService extends BaseApiService {
6795
6702
  constructor() {
@@ -6823,93 +6730,90 @@ class UserFormService extends BaseApiService {
6823
6730
  });
6824
6731
  });
6825
6732
  }
6826
- async add(state, initialRevision, url, ownerUser, ownerOrganization, assetTypeId, issueTypeId) {
6827
- if (!!ownerUser === !!ownerOrganization) {
6828
- throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
6829
- }
6830
- const ownerAttrs = {
6831
- owner_user: ownerUser,
6832
- owner_organization: ownerOrganization
6833
- };
6834
- const currentUser = state.userReducer.currentUser;
6835
- const activeWorkspaceId = state.workspaceReducer.activeWorkspaceId;
6836
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6837
- const offlineFormPayload = offline({ ...ownerAttrs });
6838
- const offlineRevisionPayload = offline({ ...initialRevision, submitted_at: submittedAt });
6839
- const retForm = {
6840
- ...offlineFormPayload,
6841
- index_workspace: activeWorkspaceId,
6842
- favorite: true,
6843
- submitted_at: submittedAt,
6844
- created_by: currentUser.id,
6845
- ...assetTypeId && { asset_type: assetTypeId },
6846
- ...issueTypeId && { issue_type: issueTypeId },
6847
- ...ownerAttrs
6848
- };
6849
- const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
6850
- const retRevision = {
6851
- ...payloadWithoutImage,
6852
- created_by: currentUser.id,
6853
- form: retForm.offline_id,
6854
- revision: 0,
6855
- submitted_at: submittedAt
6856
- };
6733
+ async add(ownerId, form, initialRevision, urlPrefix) {
6857
6734
  const { store } = this.client;
6858
- store.dispatch(addForm(retForm));
6859
- store.dispatch(addFormRevision(retRevision));
6735
+ const { fields, images } = await separateImageFromFields(initialRevision.fields);
6736
+ const offlineFormRevision = offline({
6737
+ ...initialRevision,
6738
+ fields,
6739
+ created_by: form.created_by,
6740
+ form: form.offline_id,
6741
+ submitted_at: form.submitted_at,
6742
+ revision: "Pending"
6743
+ });
6744
+ store.dispatch(addForm(form));
6745
+ store.dispatch(addFormRevision(offlineFormRevision));
6860
6746
  const formPromise = this.client.enqueueRequest({
6861
6747
  description: "Create form",
6862
6748
  method: HttpMethod.POST,
6863
- url,
6864
- queryParams: activeWorkspaceId ? {
6865
- workspace_id: activeWorkspaceId
6866
- } : void 0,
6749
+ url: urlPrefix,
6867
6750
  payload: {
6868
- ...offlineFormPayload,
6869
- ...assetTypeId && { asset_type: assetTypeId },
6870
- ...issueTypeId && { issue_type: issueTypeId },
6871
- initial_revision: payloadWithoutImage
6751
+ // Sending exactly what is currently needed for the endpoint
6752
+ offline_id: form.offline_id,
6753
+ initial_revision: {
6754
+ offline_id: offlineFormRevision.offline_id,
6755
+ submitted_at: offlineFormRevision.submitted_at,
6756
+ title: offlineFormRevision.title,
6757
+ description: offlineFormRevision.description,
6758
+ fields: offlineFormRevision.fields
6759
+ }
6872
6760
  },
6873
- blockers: assetTypeId ? [assetTypeId] : issueTypeId ? [issueTypeId] : [],
6874
- blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
6761
+ blockers: [ownerId],
6762
+ blocks: [form.offline_id, offlineFormRevision.offline_id]
6875
6763
  });
6876
- const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6764
+ const attachImagesPromises = this.getAttachImagePromises(images, offlineFormRevision.offline_id);
6877
6765
  void formPromise.catch((e) => {
6878
- store.dispatch(deleteForm(retForm.offline_id));
6879
- store.dispatch(deleteFormRevision(retRevision.offline_id));
6766
+ store.dispatch(deleteForm(form.offline_id));
6767
+ store.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
6880
6768
  throw e;
6881
6769
  });
6882
6770
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
6883
- return [retForm, retRevision, formPromise, settledPromise];
6771
+ return [form, offlineFormRevision, formPromise, settledPromise];
6884
6772
  }
6885
- async addForOrganization(initialRevision, attachedTo) {
6773
+ addForOrganization(organizationId, initialRevision) {
6886
6774
  const state = this.client.store.getState();
6887
- const activeOrganizationId = state.organizationReducer.activeOrganizationId;
6888
- if (!activeOrganizationId) {
6889
- throw new Error("Cannot add forms for organization when there is no active organization.");
6890
- }
6891
- return await this.add(
6892
- state,
6775
+ const offlineForm = offline({
6776
+ favorite: false,
6777
+ created_by: state.userReducer.currentUser.id,
6778
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6779
+ organization: organizationId
6780
+ });
6781
+ return this.add(
6782
+ organizationId.toString(),
6783
+ offlineForm,
6893
6784
  initialRevision,
6894
- `/forms/in-organization/${activeOrganizationId}/`,
6895
- void 0,
6896
- activeOrganizationId,
6897
- attachedTo && "assetTypeId" in attachedTo ? attachedTo.assetTypeId : void 0,
6898
- attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
6785
+ `/organizations/${organizationId}/create-form/`
6899
6786
  );
6900
6787
  }
6901
- async addForCurrentUser(initialRevision, attachedTo) {
6788
+ addForProject(projectId, initialRevision) {
6902
6789
  const state = this.client.store.getState();
6903
- const currentUser = state.userReducer.currentUser;
6904
- return await this.add(
6905
- state,
6906
- initialRevision,
6907
- "/forms/my-forms/",
6908
- currentUser.id,
6909
- void 0,
6910
- attachedTo && "assetTypeId" in attachedTo ? attachedTo.assetTypeId : void 0,
6911
- attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
6912
- );
6790
+ const offlineForm = offline({
6791
+ favorite: false,
6792
+ created_by: state.userReducer.currentUser.id,
6793
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6794
+ project: projectId
6795
+ });
6796
+ return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
6797
+ }
6798
+ addForIssueType(issueTypeId, initialRevision) {
6799
+ const state = this.client.store.getState();
6800
+ const offlineForm = offline({
6801
+ favorite: false,
6802
+ created_by: state.userReducer.currentUser.id,
6803
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6804
+ issue_type: issueTypeId
6805
+ });
6806
+ return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
6807
+ }
6808
+ addForAssetType(assetTypeId, initialRevision) {
6809
+ const state = this.client.store.getState();
6810
+ const offlineForm = offline({
6811
+ favorite: false,
6812
+ created_by: state.userReducer.currentUser.id,
6813
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6814
+ asset_type: assetTypeId
6815
+ });
6816
+ return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
6913
6817
  }
6914
6818
  async createRevision(formId2, revision) {
6915
6819
  const offlineRevision = offline(revision);
@@ -6920,9 +6824,10 @@ class UserFormService extends BaseApiService {
6920
6824
  throw new Error("Cannot create form revision when there is no active project.");
6921
6825
  }
6922
6826
  const currentUserId = state.userReducer.currentUser.id;
6923
- const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevision);
6827
+ const { fields, images } = await separateImageFromFields(offlineRevision.fields);
6924
6828
  const fullRevision = {
6925
- ...payloadWithoutImage,
6829
+ ...offlineRevision,
6830
+ fields,
6926
6831
  created_by: currentUserId,
6927
6832
  revision: "Pending",
6928
6833
  form: formId2,
@@ -6933,9 +6838,14 @@ class UserFormService extends BaseApiService {
6933
6838
  description: "Create form revision",
6934
6839
  method: HttpMethod.PATCH,
6935
6840
  url: `/forms/${formId2}/`,
6936
- payload: { initial_revision: payloadWithoutImage },
6937
- queryParams: {
6938
- project_id: activeProjectId.toString()
6841
+ payload: {
6842
+ initial_revision: {
6843
+ offline_id: fullRevision.offline_id,
6844
+ submitted_at: fullRevision.submitted_at,
6845
+ title: fullRevision.title,
6846
+ description: fullRevision.description,
6847
+ fields: fullRevision.fields
6848
+ }
6939
6849
  },
6940
6850
  blockers: [formId2],
6941
6851
  blocks: [offlineRevision.offline_id]
@@ -7020,16 +6930,68 @@ class UserFormService extends BaseApiService {
7020
6930
  }
7021
6931
  async refreshStore() {
7022
6932
  const { store } = this.client;
7023
- const result = await this.client.enqueueRequest({
7024
- description: "Fetch user forms",
6933
+ const activeProjectId = store.getState().projectReducer.activeProjectId;
6934
+ if (!activeProjectId) {
6935
+ throw new Error("No active project");
6936
+ }
6937
+ const forms = [];
6938
+ const revisions = [];
6939
+ const attachments = [];
6940
+ const projectFormsResult = await this.client.enqueueRequest({
6941
+ description: "Fetch project forms",
7025
6942
  method: HttpMethod.GET,
7026
- url: `/forms/in-project/${store.getState().projectReducer.activeProjectId}/forms/`,
7027
- blockers: [],
6943
+ url: `/projects/${activeProjectId}/forms/`,
6944
+ blockers: [activeProjectId.toString()],
6945
+ blocks: []
6946
+ });
6947
+ for (const form of projectFormsResult.forms)
6948
+ forms.push(form);
6949
+ for (const revision of projectFormsResult.revisions)
6950
+ revisions.push(revision);
6951
+ for (const attachment of projectFormsResult.attachments)
6952
+ attachments.push(attachment);
6953
+ const organizationFormsResult = await this.client.enqueueRequest({
6954
+ description: "Fetch organization forms",
6955
+ method: HttpMethod.GET,
6956
+ url: `/projects/${activeProjectId}/organizations/forms/`,
6957
+ blockers: [activeProjectId.toString()],
7028
6958
  blocks: []
7029
6959
  });
7030
- store.dispatch(setForms(Object.values(result.forms)));
7031
- store.dispatch(setFormRevisions(Object.values(result.revisions)));
7032
- store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
6960
+ for (const form of organizationFormsResult.forms)
6961
+ forms.push(form);
6962
+ for (const revision of organizationFormsResult.revisions)
6963
+ revisions.push(revision);
6964
+ for (const attachment of organizationFormsResult.attachments)
6965
+ attachments.push(attachment);
6966
+ const assetTypeFormsResult = await this.client.enqueueRequest({
6967
+ description: "Fetch asset type forms",
6968
+ method: HttpMethod.GET,
6969
+ url: `/projects/${activeProjectId}/asset-types/forms/`,
6970
+ blockers: [activeProjectId.toString()],
6971
+ blocks: []
6972
+ });
6973
+ for (const form of assetTypeFormsResult.forms)
6974
+ forms.push(form);
6975
+ for (const revision of assetTypeFormsResult.latest_revisions)
6976
+ revisions.push(revision);
6977
+ for (const attachment of assetTypeFormsResult.attachments)
6978
+ attachments.push(attachment);
6979
+ const issueTypeFormsResult = await this.client.enqueueRequest({
6980
+ description: "Fetch issue type forms",
6981
+ method: HttpMethod.GET,
6982
+ url: `/projects/${activeProjectId}/issue-types/forms/`,
6983
+ blockers: [activeProjectId.toString()],
6984
+ blocks: []
6985
+ });
6986
+ for (const form of issueTypeFormsResult.forms)
6987
+ forms.push(form);
6988
+ for (const revision of issueTypeFormsResult.latest_revisions)
6989
+ revisions.push(revision);
6990
+ for (const attachment of issueTypeFormsResult.attachments)
6991
+ attachments.push(attachment);
6992
+ store.dispatch(setForms(forms));
6993
+ store.dispatch(setFormRevisions(revisions));
6994
+ store.dispatch(setFormRevisionAttachments(attachments));
7033
6995
  }
7034
6996
  }
7035
6997
  const isArrayOfFiles = (value) => {
@@ -18485,7 +18447,6 @@ const styles$2 = {
18485
18447
  regularIcon
18486
18448
  };
18487
18449
  const orgOptionPrefix = "organization:";
18488
- const userOptionPrefix = "user:";
18489
18450
  const FormBrowser = memo(
18490
18451
  forwardRef((props, ref) => {
18491
18452
  const { maxResults = 20, ...entryProps } = props;
@@ -18496,9 +18457,7 @@ const FormBrowser = memo(
18496
18457
  const ret = { maxResults, searchTerm: filter };
18497
18458
  if (ownerFilter) {
18498
18459
  if (ownerFilter.startsWith(orgOptionPrefix)) {
18499
- ret.owner_organization = parseInt(ownerFilter.slice(orgOptionPrefix.length));
18500
- } else if (ownerFilter.startsWith(userOptionPrefix)) {
18501
- ret.owner_user = parseInt(ownerFilter.slice(userOptionPrefix.length));
18460
+ ret.organization = parseInt(ownerFilter.slice(orgOptionPrefix.length));
18502
18461
  }
18503
18462
  }
18504
18463
  return ret;
@@ -18523,14 +18482,10 @@ const FormBrowser = memo(
18523
18482
  const state = sdk.store.getState();
18524
18483
  const accumulator = {};
18525
18484
  for (const form of attachableUserFormMapping) {
18526
- const organization = selectOrganization(form.owner_organization || -1)(state);
18485
+ const organization = selectOrganization(form.organization || -1)(state);
18527
18486
  if (organization) {
18528
18487
  accumulator[`${orgOptionPrefix}${organization.id}`] = organization.name;
18529
18488
  }
18530
- const user = selectUser(form.owner_user || -1)(state);
18531
- if (user) {
18532
- accumulator[`${userOptionPrefix}${user.id}`] = user.username;
18533
- }
18534
18489
  }
18535
18490
  return Object.entries(accumulator).map(([value, label]) => ({ itemContent: label, value }));
18536
18491
  }, [sdk.store, attachableUserFormMapping]);
@@ -18572,11 +18527,7 @@ const FormBrowser = memo(
18572
18527
  const FormBrowserEntry = (props) => {
18573
18528
  var _a2;
18574
18529
  const { form, onSelectForm, isFavoriteEditable, handleToggleFavorite } = props;
18575
- const ownerOrganization = (_a2 = useSelector(selectOrganization(form.owner_organization || -1))) == null ? void 0 : _a2.name;
18576
- const ownerUser = useSelector(selectUser(form.owner_user || -1));
18577
- const currentUserId = useSelector(selectCurrentUser).id;
18578
- const ownedByCurrentUser = !!ownerUser && ownerUser.id === currentUserId;
18579
- const owner = ownerOrganization ?? (ownedByCurrentUser ? "You" : ownerUser == null ? void 0 : ownerUser.username) ?? "Unknown";
18530
+ const ownerOrganization = (_a2 = useSelector(selectOrganization(form.organization || -1))) == null ? void 0 : _a2.name;
18580
18531
  const handleFavoriteClick = useCallback(
18581
18532
  (e) => {
18582
18533
  e.stopPropagation();
@@ -18607,10 +18558,10 @@ const FormBrowserEntry = (props) => {
18607
18558
  /* @__PURE__ */ jsx(Text, { children: form.latestRevision.title }),
18608
18559
  form.latestRevision.description && /* @__PURE__ */ jsx(RiIcon, { icon: "RiQuestionLine" })
18609
18560
  ] }),
18610
- owner && /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
18561
+ ownerOrganization && /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
18611
18562
  /* @__PURE__ */ jsx(RiIcon, { icon: "RiUserLine" }),
18612
18563
  " ",
18613
- owner
18564
+ ownerOrganization
18614
18565
  ] })
18615
18566
  ] })
18616
18567
  }
@@ -19880,7 +19831,6 @@ export {
19880
19831
  LicenseService,
19881
19832
  LicenseStatus,
19882
19833
  MainService,
19883
- MapStyle,
19884
19834
  MultiSelectField,
19885
19835
  MultiSelectInput,
19886
19836
  MultiStringField,
@@ -19905,7 +19855,6 @@ export {
19905
19855
  ProjectAttachmentService,
19906
19856
  ProjectFileService,
19907
19857
  ProjectService,
19908
- ProjectType,
19909
19858
  QrField,
19910
19859
  QrInput,
19911
19860
  QrScanner,
@@ -20091,8 +20040,6 @@ export {
20091
20040
  literalToCoordinates,
20092
20041
  logOnlyOnce,
20093
20042
  makeClient,
20094
- mapReducer,
20095
- mapSlice,
20096
20043
  markAsDeleted,
20097
20044
  markForDeletion,
20098
20045
  markerCoordinatesToText,
@@ -20222,7 +20169,6 @@ export {
20222
20169
  selectCategory,
20223
20170
  selectCategoryMapping,
20224
20171
  selectCategoryVisibility,
20225
- selectCenterMapToProject,
20226
20172
  selectCommentMapping,
20227
20173
  selectCommentsOfIssue,
20228
20174
  selectCompletedStageIdsForAsset,
@@ -20230,7 +20176,6 @@ export {
20230
20176
  selectConversation,
20231
20177
  selectConversationMapping,
20232
20178
  selectConversations,
20233
- selectCreateProjectType,
20234
20179
  selectCurrentUser,
20235
20180
  selectDeletedRequests,
20236
20181
  selectDocument,
@@ -20240,12 +20185,10 @@ export {
20240
20185
  selectDocumentsMapping,
20241
20186
  selectEmailDomainsAsMapping,
20242
20187
  selectEnableClustering,
20243
- selectEnableDuplicateIssues,
20244
20188
  selectEnablePlacementMode,
20245
20189
  selectEnableSvgLayout,
20246
20190
  selectEnabledProjectFileMapping,
20247
20191
  selectEnabledProjectFiles,
20248
- selectExpandedSections,
20249
20192
  selectFavouriteProjects,
20250
20193
  selectFileAttachmentsOfIssue,
20251
20194
  selectFilteredForms,
@@ -20299,7 +20242,6 @@ export {
20299
20242
  selectLicenses,
20300
20243
  selectLicensesForProjectsMapping,
20301
20244
  selectMainWorkspace,
20302
- selectMapStyle,
20303
20245
  selectNumberOfAssetTypesMatchingCaseInsensitiveName,
20304
20246
  selectNumberOfAssetsOfAssetType,
20305
20247
  selectOrganization,
@@ -20329,10 +20271,8 @@ export {
20329
20271
  selectProjectsWithAccess,
20330
20272
  selectRecentIssueIds,
20331
20273
  selectRecentIssuesAsSearchResults,
20332
- selectRecentProjects,
20333
20274
  selectRehydrated,
20334
20275
  selectRootDocuments,
20335
- selectShowTooltips,
20336
20276
  selectSortedEmailDomains,
20337
20277
  selectSortedFormSubmissionsOfForm,
20338
20278
  selectSortedOrganizationLicenses,
@@ -20374,17 +20314,14 @@ export {
20374
20314
  setAssetTypes,
20375
20315
  setAssets,
20376
20316
  setCategories,
20377
- setCenterMapToProject,
20378
20317
  setConversation,
20379
20318
  setConversations,
20380
- setCreateProjectType,
20381
20319
  setCurrentUser,
20382
20320
  setDocumentAttachment,
20383
20321
  setDocumentAttachments,
20384
20322
  setDocuments,
20385
20323
  setEmailDomains,
20386
20324
  setEnableClustering,
20387
- setEnableDuplicateIssues,
20388
20325
  setEnablePlacementMode,
20389
20326
  setEnableSvgLayout,
20390
20327
  setFormRevision,
@@ -20407,7 +20344,6 @@ export {
20407
20344
  setIssues,
20408
20345
  setLicenses,
20409
20346
  setLoggedIn,
20410
- setMapStyle,
20411
20347
  setOrganizationAccesses,
20412
20348
  setOrganizations,
20413
20349
  setProfilePicture,
@@ -20417,8 +20353,6 @@ export {
20417
20353
  setProjectFileVisible,
20418
20354
  setProjects,
20419
20355
  setRehydrated,
20420
- setSectionExpanded,
20421
- setShowTooltips,
20422
20356
  setStageCompletions,
20423
20357
  setTeam,
20424
20358
  setTeams,