@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.
@@ -425,13 +425,6 @@ var __publicField = (obj, key, value) => {
425
425
  IssueStatus2[IssueStatus2["DONE"] = 4] = "DONE";
426
426
  return IssueStatus2;
427
427
  })(IssueStatus || {});
428
- var MapStyle = /* @__PURE__ */ ((MapStyle2) => {
429
- MapStyle2["LIGHT"] = "LIGHT";
430
- MapStyle2["DARK"] = "DARK";
431
- MapStyle2["SATELLITE"] = "SATELLITE";
432
- MapStyle2["NONE"] = "NONE";
433
- return MapStyle2;
434
- })(MapStyle || {});
435
428
  const VERSION_REDUCER_KEY$1 = "versioning";
436
429
  const latestVersion = () => migrations.length - 1;
437
430
  const initialVersioning = (state) => {
@@ -458,15 +451,15 @@ var __publicField = (obj, key, value) => {
458
451
  };
459
452
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
460
453
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
461
- const initialState$s = {
454
+ const initialState$r = {
462
455
  accessToken: "",
463
456
  refreshToken: "",
464
457
  isLoggedIn: false
465
458
  };
466
459
  const authSlice = toolkit.createSlice({
467
460
  name: "auth",
468
- initialState: initialState$s,
469
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
461
+ initialState: initialState$r,
462
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
470
463
  reducers: {
471
464
  setTokens: (state, action) => {
472
465
  state.accessToken = action.payload.accessToken;
@@ -1110,7 +1103,7 @@ var __publicField = (obj, key, value) => {
1110
1103
  return getLocalDateString(date);
1111
1104
  return relative.format(days, "days");
1112
1105
  });
1113
- const initialState$r = {
1106
+ const initialState$q = {
1114
1107
  categories: {},
1115
1108
  usedCategoryColors: [],
1116
1109
  categoryVisibility: {
@@ -1120,8 +1113,8 @@ var __publicField = (obj, key, value) => {
1120
1113
  };
1121
1114
  const categorySlice = toolkit.createSlice({
1122
1115
  name: "categories",
1123
- initialState: initialState$r,
1124
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1116
+ initialState: initialState$q,
1117
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1125
1118
  reducers: {
1126
1119
  setCategories: (state, action) => {
1127
1120
  if (!Array.isArray(action.payload))
@@ -1305,15 +1298,15 @@ var __publicField = (obj, key, value) => {
1305
1298
  delete state.attachments[attachmentId];
1306
1299
  }
1307
1300
  }
1308
- const initialState$q = {
1301
+ const initialState$p = {
1309
1302
  assetTypes: {},
1310
1303
  hiddenAssetTypeIds: {},
1311
1304
  attachments: {}
1312
1305
  };
1313
1306
  const assetTypeSlice = toolkit.createSlice({
1314
1307
  name: "assetTypes",
1315
- initialState: initialState$q,
1316
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1308
+ initialState: initialState$p,
1309
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1317
1310
  reducers: {
1318
1311
  addAssetType: (state, action) => {
1319
1312
  state.assetTypes[action.payload.offline_id] = action.payload;
@@ -1423,14 +1416,14 @@ var __publicField = (obj, key, value) => {
1423
1416
  )
1424
1417
  );
1425
1418
  const assetTypeReducer = assetTypeSlice.reducer;
1426
- const initialState$p = {
1419
+ const initialState$o = {
1427
1420
  assets: {},
1428
1421
  attachments: {}
1429
1422
  };
1430
1423
  const assetSlice = toolkit.createSlice({
1431
1424
  name: "assets",
1432
- initialState: initialState$p,
1433
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1425
+ initialState: initialState$o,
1426
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1434
1427
  reducers: {
1435
1428
  addAsset: (state, action) => {
1436
1429
  state.assets[action.payload.offline_id] = action.payload;
@@ -1603,13 +1596,13 @@ var __publicField = (obj, key, value) => {
1603
1596
  )
1604
1597
  );
1605
1598
  const assetReducer = assetSlice.reducer;
1606
- const initialState$o = {
1599
+ const initialState$n = {
1607
1600
  completionsByAssetId: {}
1608
1601
  };
1609
1602
  const assetStageCompletionSlice = toolkit.createSlice({
1610
1603
  name: "assetStageCompletions",
1611
- initialState: initialState$o,
1612
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1604
+ initialState: initialState$n,
1605
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1613
1606
  reducers: {
1614
1607
  addStageCompletion: (state, action) => {
1615
1608
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1658,13 +1651,13 @@ var __publicField = (obj, key, value) => {
1658
1651
  return Object.keys(state.assetStageCompletionReducer.completionsByAssetId[asset.offline_id] ?? {});
1659
1652
  };
1660
1653
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1661
- const initialState$n = {
1654
+ const initialState$m = {
1662
1655
  stages: {}
1663
1656
  };
1664
1657
  const assetStageSlice = toolkit.createSlice({
1665
1658
  name: "assetStages",
1666
- initialState: initialState$n,
1667
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1659
+ initialState: initialState$m,
1660
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1668
1661
  reducers: {
1669
1662
  addStages: (state, action) => {
1670
1663
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1765,13 +1758,13 @@ var __publicField = (obj, key, value) => {
1765
1758
  );
1766
1759
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = assetStageSlice.actions;
1767
1760
  const assetStageReducer = assetStageSlice.reducer;
1768
- const initialState$m = {
1761
+ const initialState$l = {
1769
1762
  workspaces: {},
1770
1763
  activeWorkspaceId: null
1771
1764
  };
1772
1765
  const workspaceSlice = toolkit.createSlice({
1773
1766
  name: "workspace",
1774
- initialState: initialState$m,
1767
+ initialState: initialState$l,
1775
1768
  // The `reducers` field lets us define reducers and generate associated actions
1776
1769
  reducers: {
1777
1770
  setWorkspaces: (state, action) => {
@@ -1828,7 +1821,7 @@ var __publicField = (obj, key, value) => {
1828
1821
  );
1829
1822
  const workspaceReducer = workspaceSlice.reducer;
1830
1823
  const maxRecentIssues = 10;
1831
- const initialState$l = {
1824
+ const initialState$k = {
1832
1825
  issues: {},
1833
1826
  attachments: {},
1834
1827
  comments: {},
@@ -1840,9 +1833,9 @@ var __publicField = (obj, key, value) => {
1840
1833
  };
1841
1834
  const issueSlice = toolkit.createSlice({
1842
1835
  name: "issues",
1843
- initialState: initialState$l,
1836
+ initialState: initialState$k,
1844
1837
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1845
- Object.assign(state, initialState$l);
1838
+ Object.assign(state, initialState$k);
1846
1839
  }),
1847
1840
  reducers: {
1848
1841
  setIssues: (state, action) => {
@@ -2278,14 +2271,14 @@ var __publicField = (obj, key, value) => {
2278
2271
  }
2279
2272
  );
2280
2273
  const issueReducer = issueSlice.reducer;
2281
- const initialState$k = {
2274
+ const initialState$j = {
2282
2275
  issueTypes: {}
2283
2276
  };
2284
2277
  const issueTypeSlice = toolkit.createSlice({
2285
2278
  name: "issueTypes",
2286
- initialState: initialState$k,
2279
+ initialState: initialState$j,
2287
2280
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2288
- Object.assign(state, initialState$k);
2281
+ Object.assign(state, initialState$j);
2289
2282
  }),
2290
2283
  reducers: {
2291
2284
  setIssueTypes: (state, action) => {
@@ -2352,15 +2345,15 @@ var __publicField = (obj, key, value) => {
2352
2345
  return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
2353
2346
  };
2354
2347
  const issueTypeReducer = issueTypeSlice.reducer;
2355
- const initialState$j = {
2348
+ const initialState$i = {
2356
2349
  s3Urls: {}
2357
2350
  };
2358
2351
  const msPerHour = 1e3 * 60 * 60;
2359
2352
  const msPerWeek = msPerHour * 24 * 7;
2360
2353
  const fileSlice = toolkit.createSlice({
2361
2354
  name: "file",
2362
- initialState: initialState$j,
2363
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2355
+ initialState: initialState$i,
2356
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2364
2357
  reducers: {
2365
2358
  setUploadUrl: (state, action) => {
2366
2359
  const { url, fields, sha1 } = action.payload;
@@ -2387,33 +2380,6 @@ var __publicField = (obj, key, value) => {
2387
2380
  return url;
2388
2381
  };
2389
2382
  const fileReducer = fileSlice.reducer;
2390
- const initialState$i = {
2391
- // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2392
- mapStyle: MapStyle.SATELLITE,
2393
- showTooltips: false,
2394
- centerMapToProject: false
2395
- };
2396
- const mapSlice = toolkit.createSlice({
2397
- name: "map",
2398
- initialState: initialState$i,
2399
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2400
- reducers: {
2401
- setMapStyle: (state, action) => {
2402
- state.mapStyle = action.payload;
2403
- },
2404
- setShowTooltips: (state, action) => {
2405
- state.showTooltips = action.payload;
2406
- },
2407
- setCenterMapToProject: (state, action) => {
2408
- state.centerMapToProject = action.payload;
2409
- }
2410
- }
2411
- });
2412
- const { setMapStyle, setShowTooltips, setCenterMapToProject } = mapSlice.actions;
2413
- const selectMapStyle = (state) => state.mapReducer.mapStyle;
2414
- const selectShowTooltips = (state) => state.mapReducer.showTooltips;
2415
- const selectCenterMapToProject = (state) => state.mapReducer.centerMapToProject;
2416
- const mapReducer = mapSlice.reducer;
2417
2383
  var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
2418
2384
  ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
2419
2385
  ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
@@ -2442,11 +2408,6 @@ var __publicField = (obj, key, value) => {
2442
2408
  IssueUpdateChange2["DUE_DATE"] = "due_date";
2443
2409
  return IssueUpdateChange2;
2444
2410
  })(IssueUpdateChange || {});
2445
- var ProjectType = /* @__PURE__ */ ((ProjectType2) => {
2446
- ProjectType2[ProjectType2["PERSONAL"] = 0] = "PERSONAL";
2447
- ProjectType2[ProjectType2["ORGANIZATION"] = 2] = "ORGANIZATION";
2448
- return ProjectType2;
2449
- })(ProjectType || {});
2450
2411
  var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
2451
2412
  VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
2452
2413
  VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
@@ -2744,9 +2705,6 @@ var __publicField = (obj, key, value) => {
2744
2705
  const initialState$d = {
2745
2706
  projects: {},
2746
2707
  activeProjectId: null,
2747
- recentProjectIds: [],
2748
- recentSearchableQueries: [],
2749
- createProjectType: ProjectType.PERSONAL,
2750
2708
  attachments: {}
2751
2709
  };
2752
2710
  const projectSlice = toolkit.createSlice({
@@ -2759,20 +2717,9 @@ var __publicField = (obj, key, value) => {
2759
2717
  projectsMap[project.id] = project;
2760
2718
  });
2761
2719
  state.projects = projectsMap;
2762
- if (state.recentProjectIds.length === 0) {
2763
- state.recentProjectIds = action.payload.map((project) => project.id);
2764
- } else {
2765
- state.recentProjectIds.unshift(
2766
- ...action.payload.map((project) => project.id).filter((id) => !state.recentProjectIds.includes(id))
2767
- );
2768
- }
2769
2720
  },
2770
2721
  setActiveProjectId: (state, action) => {
2771
2722
  state.activeProjectId = action.payload;
2772
- if (action.payload !== null) {
2773
- state.recentProjectIds = state.recentProjectIds.filter((id) => id !== action.payload);
2774
- state.recentProjectIds.push(action.payload);
2775
- }
2776
2723
  },
2777
2724
  updateOrCreateProject: (state, action) => {
2778
2725
  state.projects[action.payload.id] = action.payload;
@@ -2784,12 +2731,8 @@ var __publicField = (obj, key, value) => {
2784
2731
  state.projects[project.id] = project;
2785
2732
  });
2786
2733
  },
2787
- setCreateProjectType: (state, action) => {
2788
- state.createProjectType = action.payload;
2789
- },
2790
2734
  deleteProject: (state, action) => {
2791
2735
  delete state.projects[action.payload.id];
2792
- state.recentProjectIds = state.recentProjectIds.filter((id) => id !== action.payload.id);
2793
2736
  },
2794
2737
  acceptProjectInvite: (state, action) => {
2795
2738
  if (action.payload in state.projects) {
@@ -2835,7 +2778,6 @@ var __publicField = (obj, key, value) => {
2835
2778
  updateOrCreateProject,
2836
2779
  updateOrCreateProjects: addOrReplaceProjects,
2837
2780
  setActiveProjectId,
2838
- setCreateProjectType,
2839
2781
  deleteProject,
2840
2782
  acceptProjectInvite,
2841
2783
  addActiveProjectIssuesCount,
@@ -2859,9 +2801,6 @@ var __publicField = (obj, key, value) => {
2859
2801
  }
2860
2802
  return state.projectReducer.projects[activeProjectId] ?? null;
2861
2803
  };
2862
- const selectRecentProjects = (state) => {
2863
- return state.projectReducer.recentProjectIds;
2864
- };
2865
2804
  const selectProject = restructureCreateSelectorWithArgs(
2866
2805
  toolkit.createSelector(
2867
2806
  [selectProjects, (_state, projectId) => projectId],
@@ -2883,7 +2822,6 @@ var __publicField = (obj, key, value) => {
2883
2822
  });
2884
2823
  }
2885
2824
  );
2886
- const selectCreateProjectType = (state) => state.projectReducer.createProjectType;
2887
2825
  const projectReducer = projectSlice.reducer;
2888
2826
  const selectProjectUsersIds = toolkit.createSelector(
2889
2827
  [selectProjectAccesses],
@@ -3243,18 +3181,9 @@ var __publicField = (obj, key, value) => {
3243
3181
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3244
3182
  const rehydratedReducer = rehydratedSlice.reducer;
3245
3183
  const initialState$8 = {
3246
- useIssueTemplate: false,
3247
- // TODO: marked for deletion
3248
3184
  placementMode: false,
3249
3185
  enableClustering: false,
3250
3186
  svgLayout: false,
3251
- expandedSections: {
3252
- // TODO: marked for deletion
3253
- Issues: true,
3254
- "Map Layers": false,
3255
- Components: false,
3256
- Experimental: false
3257
- },
3258
3187
  appearance: "dark",
3259
3188
  isFetchingInitialData: false,
3260
3189
  // TODO: this is being used only in the custom hook in /web called useRetrySDK, which has something to do with licences
@@ -3266,18 +3195,12 @@ var __publicField = (obj, key, value) => {
3266
3195
  initialState: initialState$8,
3267
3196
  extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3268
3197
  reducers: {
3269
- setEnableDuplicateIssues: (state, action) => {
3270
- state.useIssueTemplate = action.payload;
3271
- },
3272
3198
  setEnablePlacementMode: (state, action) => {
3273
3199
  state.placementMode = action.payload;
3274
3200
  },
3275
3201
  setEnableSvgLayout: (state, action) => {
3276
3202
  state.svgLayout = action.payload;
3277
3203
  },
3278
- setSectionExpanded: (state, action) => {
3279
- Object.assign(state.expandedSections, action.payload);
3280
- },
3281
3204
  setEnableClustering: (state, action) => {
3282
3205
  state.enableClustering = action.payload;
3283
3206
  },
@@ -3293,20 +3216,16 @@ var __publicField = (obj, key, value) => {
3293
3216
  }
3294
3217
  });
3295
3218
  const {
3296
- setEnableDuplicateIssues,
3297
3219
  setEnablePlacementMode,
3298
3220
  setEnableSvgLayout,
3299
3221
  // TODO: needs to actually be used in /web
3300
- setSectionExpanded,
3301
3222
  setEnableClustering,
3302
3223
  setAppearance,
3303
3224
  setIsFetchingInitialData,
3304
3225
  setIsLoading
3305
3226
  } = settingSlice.actions;
3306
3227
  const selectEnablePlacementMode = (state) => state.settingReducer.placementMode;
3307
- const selectEnableDuplicateIssues = (state) => state.settingReducer.useIssueTemplate;
3308
3228
  const selectEnableSvgLayout = (state) => state.settingReducer.svgLayout;
3309
- const selectExpandedSections = (state) => state.settingReducer.expandedSections;
3310
3229
  const selectEnableClustering = (state) => state.settingReducer.enableClustering;
3311
3230
  const selectAppearance = (state) => state.settingReducer.appearance;
3312
3231
  const settingReducer = settingSlice.reducer;
@@ -3567,17 +3486,15 @@ var __publicField = (obj, key, value) => {
3567
3486
  (_state, search) => search
3568
3487
  ],
3569
3488
  (userForms, revisions, search) => {
3570
- const { searchTerm, maxResults, favorites, owner_organization, owner_user } = search;
3489
+ const { searchTerm, maxResults, favorites, organization } = search;
3571
3490
  const favoriteMatches = [];
3572
3491
  const regularMatches = [];
3573
3492
  for (const [userFormId, userForm] of Object.entries(userForms)) {
3574
3493
  if (favorites !== void 0 && userForm.favorite != favorites)
3575
3494
  continue;
3576
- if (Number.isInteger(owner_organization) && owner_organization !== userForm.owner_organization) {
3495
+ if (Number.isInteger(organization) && organization !== userForm.organization) {
3577
3496
  continue;
3578
3497
  }
3579
- if (Number.isInteger(owner_user) && owner_user !== userForm.owner_user)
3580
- continue;
3581
3498
  const latestRevision = _selectLatestFormRevision(revisions, userFormId);
3582
3499
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
3583
3500
  if (userForm.favorite) {
@@ -4296,7 +4213,6 @@ var __publicField = (obj, key, value) => {
4296
4213
  assetTypeReducer,
4297
4214
  issueReducer,
4298
4215
  issueTypeReducer,
4299
- mapReducer,
4300
4216
  organizationReducer,
4301
4217
  outboxReducer,
4302
4218
  projectReducer,
@@ -4362,10 +4278,6 @@ var __publicField = (obj, key, value) => {
4362
4278
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4363
4279
  }
4364
4280
  }
4365
- const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4366
- for (const form of indexedForms) {
4367
- form.index_workspace = mainWorkspace.offline_id;
4368
- }
4369
4281
  }
4370
4282
  const overmapRootReducer = (state, action) => {
4371
4283
  if (action.type === "auth/setLoggedIn" && !action.payload) {
@@ -6747,8 +6659,7 @@ var __publicField = (obj, key, value) => {
6747
6659
  });
6748
6660
  }
6749
6661
  }
6750
- const separateImageFromFields = async (payload) => {
6751
- const { fields } = payload;
6662
+ const separateImageFromFields = async (fields) => {
6752
6663
  const images = {};
6753
6664
  const newFields = [];
6754
6665
  for (const section of fields) {
@@ -6774,11 +6685,7 @@ var __publicField = (obj, key, value) => {
6774
6685
  }
6775
6686
  newFields.push({ ...section, fields: newSectionFields });
6776
6687
  }
6777
- const payloadWithoutImage = {
6778
- ...payload,
6779
- fields: newFields
6780
- };
6781
- return { payloadWithoutImage, images };
6688
+ return { fields: newFields, images };
6782
6689
  };
6783
6690
  class UserFormService extends BaseApiService {
6784
6691
  constructor() {
@@ -6812,93 +6719,90 @@ var __publicField = (obj, key, value) => {
6812
6719
  });
6813
6720
  });
6814
6721
  }
6815
- async add(state, initialRevision, url, ownerUser, ownerOrganization, assetTypeId, issueTypeId) {
6816
- if (!!ownerUser === !!ownerOrganization) {
6817
- throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
6818
- }
6819
- const ownerAttrs = {
6820
- owner_user: ownerUser,
6821
- owner_organization: ownerOrganization
6822
- };
6823
- const currentUser = state.userReducer.currentUser;
6824
- const activeWorkspaceId = state.workspaceReducer.activeWorkspaceId;
6825
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6826
- const offlineFormPayload = offline({ ...ownerAttrs });
6827
- const offlineRevisionPayload = offline({ ...initialRevision, submitted_at: submittedAt });
6828
- const retForm = {
6829
- ...offlineFormPayload,
6830
- index_workspace: activeWorkspaceId,
6831
- favorite: true,
6832
- submitted_at: submittedAt,
6833
- created_by: currentUser.id,
6834
- ...assetTypeId && { asset_type: assetTypeId },
6835
- ...issueTypeId && { issue_type: issueTypeId },
6836
- ...ownerAttrs
6837
- };
6838
- const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
6839
- const retRevision = {
6840
- ...payloadWithoutImage,
6841
- created_by: currentUser.id,
6842
- form: retForm.offline_id,
6843
- revision: 0,
6844
- submitted_at: submittedAt
6845
- };
6722
+ async add(ownerId, form, initialRevision, urlPrefix) {
6846
6723
  const { store } = this.client;
6847
- store.dispatch(addForm(retForm));
6848
- store.dispatch(addFormRevision(retRevision));
6724
+ const { fields, images } = await separateImageFromFields(initialRevision.fields);
6725
+ const offlineFormRevision = offline({
6726
+ ...initialRevision,
6727
+ fields,
6728
+ created_by: form.created_by,
6729
+ form: form.offline_id,
6730
+ submitted_at: form.submitted_at,
6731
+ revision: "Pending"
6732
+ });
6733
+ store.dispatch(addForm(form));
6734
+ store.dispatch(addFormRevision(offlineFormRevision));
6849
6735
  const formPromise = this.client.enqueueRequest({
6850
6736
  description: "Create form",
6851
6737
  method: HttpMethod.POST,
6852
- url,
6853
- queryParams: activeWorkspaceId ? {
6854
- workspace_id: activeWorkspaceId
6855
- } : void 0,
6738
+ url: urlPrefix,
6856
6739
  payload: {
6857
- ...offlineFormPayload,
6858
- ...assetTypeId && { asset_type: assetTypeId },
6859
- ...issueTypeId && { issue_type: issueTypeId },
6860
- initial_revision: payloadWithoutImage
6740
+ // Sending exactly what is currently needed for the endpoint
6741
+ offline_id: form.offline_id,
6742
+ initial_revision: {
6743
+ offline_id: offlineFormRevision.offline_id,
6744
+ submitted_at: offlineFormRevision.submitted_at,
6745
+ title: offlineFormRevision.title,
6746
+ description: offlineFormRevision.description,
6747
+ fields: offlineFormRevision.fields
6748
+ }
6861
6749
  },
6862
- blockers: assetTypeId ? [assetTypeId] : issueTypeId ? [issueTypeId] : [],
6863
- blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
6750
+ blockers: [ownerId],
6751
+ blocks: [form.offline_id, offlineFormRevision.offline_id]
6864
6752
  });
6865
- const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6753
+ const attachImagesPromises = this.getAttachImagePromises(images, offlineFormRevision.offline_id);
6866
6754
  void formPromise.catch((e) => {
6867
- store.dispatch(deleteForm(retForm.offline_id));
6868
- store.dispatch(deleteFormRevision(retRevision.offline_id));
6755
+ store.dispatch(deleteForm(form.offline_id));
6756
+ store.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
6869
6757
  throw e;
6870
6758
  });
6871
6759
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
6872
- return [retForm, retRevision, formPromise, settledPromise];
6760
+ return [form, offlineFormRevision, formPromise, settledPromise];
6873
6761
  }
6874
- async addForOrganization(initialRevision, attachedTo) {
6762
+ addForOrganization(organizationId, initialRevision) {
6875
6763
  const state = this.client.store.getState();
6876
- const activeOrganizationId = state.organizationReducer.activeOrganizationId;
6877
- if (!activeOrganizationId) {
6878
- throw new Error("Cannot add forms for organization when there is no active organization.");
6879
- }
6880
- return await this.add(
6881
- state,
6764
+ const offlineForm = offline({
6765
+ favorite: false,
6766
+ created_by: state.userReducer.currentUser.id,
6767
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6768
+ organization: organizationId
6769
+ });
6770
+ return this.add(
6771
+ organizationId.toString(),
6772
+ offlineForm,
6882
6773
  initialRevision,
6883
- `/forms/in-organization/${activeOrganizationId}/`,
6884
- void 0,
6885
- activeOrganizationId,
6886
- attachedTo && "assetTypeId" in attachedTo ? attachedTo.assetTypeId : void 0,
6887
- attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
6774
+ `/organizations/${organizationId}/create-form/`
6888
6775
  );
6889
6776
  }
6890
- async addForCurrentUser(initialRevision, attachedTo) {
6777
+ addForProject(projectId, initialRevision) {
6891
6778
  const state = this.client.store.getState();
6892
- const currentUser = state.userReducer.currentUser;
6893
- return await this.add(
6894
- state,
6895
- initialRevision,
6896
- "/forms/my-forms/",
6897
- currentUser.id,
6898
- void 0,
6899
- attachedTo && "assetTypeId" in attachedTo ? attachedTo.assetTypeId : void 0,
6900
- attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
6901
- );
6779
+ const offlineForm = offline({
6780
+ favorite: false,
6781
+ created_by: state.userReducer.currentUser.id,
6782
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6783
+ project: projectId
6784
+ });
6785
+ return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
6786
+ }
6787
+ addForIssueType(issueTypeId, initialRevision) {
6788
+ const state = this.client.store.getState();
6789
+ const offlineForm = offline({
6790
+ favorite: false,
6791
+ created_by: state.userReducer.currentUser.id,
6792
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6793
+ issue_type: issueTypeId
6794
+ });
6795
+ return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
6796
+ }
6797
+ addForAssetType(assetTypeId, initialRevision) {
6798
+ const state = this.client.store.getState();
6799
+ const offlineForm = offline({
6800
+ favorite: false,
6801
+ created_by: state.userReducer.currentUser.id,
6802
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6803
+ asset_type: assetTypeId
6804
+ });
6805
+ return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
6902
6806
  }
6903
6807
  async createRevision(formId2, revision) {
6904
6808
  const offlineRevision = offline(revision);
@@ -6909,9 +6813,10 @@ var __publicField = (obj, key, value) => {
6909
6813
  throw new Error("Cannot create form revision when there is no active project.");
6910
6814
  }
6911
6815
  const currentUserId = state.userReducer.currentUser.id;
6912
- const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevision);
6816
+ const { fields, images } = await separateImageFromFields(offlineRevision.fields);
6913
6817
  const fullRevision = {
6914
- ...payloadWithoutImage,
6818
+ ...offlineRevision,
6819
+ fields,
6915
6820
  created_by: currentUserId,
6916
6821
  revision: "Pending",
6917
6822
  form: formId2,
@@ -6922,9 +6827,14 @@ var __publicField = (obj, key, value) => {
6922
6827
  description: "Create form revision",
6923
6828
  method: HttpMethod.PATCH,
6924
6829
  url: `/forms/${formId2}/`,
6925
- payload: { initial_revision: payloadWithoutImage },
6926
- queryParams: {
6927
- project_id: activeProjectId.toString()
6830
+ payload: {
6831
+ initial_revision: {
6832
+ offline_id: fullRevision.offline_id,
6833
+ submitted_at: fullRevision.submitted_at,
6834
+ title: fullRevision.title,
6835
+ description: fullRevision.description,
6836
+ fields: fullRevision.fields
6837
+ }
6928
6838
  },
6929
6839
  blockers: [formId2],
6930
6840
  blocks: [offlineRevision.offline_id]
@@ -7009,16 +6919,68 @@ var __publicField = (obj, key, value) => {
7009
6919
  }
7010
6920
  async refreshStore() {
7011
6921
  const { store } = this.client;
7012
- const result = await this.client.enqueueRequest({
7013
- description: "Fetch user forms",
6922
+ const activeProjectId = store.getState().projectReducer.activeProjectId;
6923
+ if (!activeProjectId) {
6924
+ throw new Error("No active project");
6925
+ }
6926
+ const forms = [];
6927
+ const revisions = [];
6928
+ const attachments = [];
6929
+ const projectFormsResult = await this.client.enqueueRequest({
6930
+ description: "Fetch project forms",
7014
6931
  method: HttpMethod.GET,
7015
- url: `/forms/in-project/${store.getState().projectReducer.activeProjectId}/forms/`,
7016
- blockers: [],
6932
+ url: `/projects/${activeProjectId}/forms/`,
6933
+ blockers: [activeProjectId.toString()],
6934
+ blocks: []
6935
+ });
6936
+ for (const form of projectFormsResult.forms)
6937
+ forms.push(form);
6938
+ for (const revision of projectFormsResult.revisions)
6939
+ revisions.push(revision);
6940
+ for (const attachment of projectFormsResult.attachments)
6941
+ attachments.push(attachment);
6942
+ const organizationFormsResult = await this.client.enqueueRequest({
6943
+ description: "Fetch organization forms",
6944
+ method: HttpMethod.GET,
6945
+ url: `/projects/${activeProjectId}/organizations/forms/`,
6946
+ blockers: [activeProjectId.toString()],
7017
6947
  blocks: []
7018
6948
  });
7019
- store.dispatch(setForms(Object.values(result.forms)));
7020
- store.dispatch(setFormRevisions(Object.values(result.revisions)));
7021
- store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
6949
+ for (const form of organizationFormsResult.forms)
6950
+ forms.push(form);
6951
+ for (const revision of organizationFormsResult.revisions)
6952
+ revisions.push(revision);
6953
+ for (const attachment of organizationFormsResult.attachments)
6954
+ attachments.push(attachment);
6955
+ const assetTypeFormsResult = await this.client.enqueueRequest({
6956
+ description: "Fetch asset type forms",
6957
+ method: HttpMethod.GET,
6958
+ url: `/projects/${activeProjectId}/asset-types/forms/`,
6959
+ blockers: [activeProjectId.toString()],
6960
+ blocks: []
6961
+ });
6962
+ for (const form of assetTypeFormsResult.forms)
6963
+ forms.push(form);
6964
+ for (const revision of assetTypeFormsResult.latest_revisions)
6965
+ revisions.push(revision);
6966
+ for (const attachment of assetTypeFormsResult.attachments)
6967
+ attachments.push(attachment);
6968
+ const issueTypeFormsResult = await this.client.enqueueRequest({
6969
+ description: "Fetch issue type forms",
6970
+ method: HttpMethod.GET,
6971
+ url: `/projects/${activeProjectId}/issue-types/forms/`,
6972
+ blockers: [activeProjectId.toString()],
6973
+ blocks: []
6974
+ });
6975
+ for (const form of issueTypeFormsResult.forms)
6976
+ forms.push(form);
6977
+ for (const revision of issueTypeFormsResult.latest_revisions)
6978
+ revisions.push(revision);
6979
+ for (const attachment of issueTypeFormsResult.attachments)
6980
+ attachments.push(attachment);
6981
+ store.dispatch(setForms(forms));
6982
+ store.dispatch(setFormRevisions(revisions));
6983
+ store.dispatch(setFormRevisionAttachments(attachments));
7022
6984
  }
7023
6985
  }
7024
6986
  const isArrayOfFiles = (value) => {
@@ -18474,7 +18436,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
18474
18436
  regularIcon
18475
18437
  };
18476
18438
  const orgOptionPrefix = "organization:";
18477
- const userOptionPrefix = "user:";
18478
18439
  const FormBrowser = React.memo(
18479
18440
  React.forwardRef((props, ref) => {
18480
18441
  const { maxResults = 20, ...entryProps } = props;
@@ -18485,9 +18446,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
18485
18446
  const ret = { maxResults, searchTerm: filter };
18486
18447
  if (ownerFilter) {
18487
18448
  if (ownerFilter.startsWith(orgOptionPrefix)) {
18488
- ret.owner_organization = parseInt(ownerFilter.slice(orgOptionPrefix.length));
18489
- } else if (ownerFilter.startsWith(userOptionPrefix)) {
18490
- ret.owner_user = parseInt(ownerFilter.slice(userOptionPrefix.length));
18449
+ ret.organization = parseInt(ownerFilter.slice(orgOptionPrefix.length));
18491
18450
  }
18492
18451
  }
18493
18452
  return ret;
@@ -18512,14 +18471,10 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
18512
18471
  const state = sdk.store.getState();
18513
18472
  const accumulator = {};
18514
18473
  for (const form of attachableUserFormMapping) {
18515
- const organization = selectOrganization(form.owner_organization || -1)(state);
18474
+ const organization = selectOrganization(form.organization || -1)(state);
18516
18475
  if (organization) {
18517
18476
  accumulator[`${orgOptionPrefix}${organization.id}`] = organization.name;
18518
18477
  }
18519
- const user = selectUser(form.owner_user || -1)(state);
18520
- if (user) {
18521
- accumulator[`${userOptionPrefix}${user.id}`] = user.username;
18522
- }
18523
18478
  }
18524
18479
  return Object.entries(accumulator).map(([value, label]) => ({ itemContent: label, value }));
18525
18480
  }, [sdk.store, attachableUserFormMapping]);
@@ -18561,11 +18516,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
18561
18516
  const FormBrowserEntry = (props) => {
18562
18517
  var _a2;
18563
18518
  const { form, onSelectForm, isFavoriteEditable, handleToggleFavorite } = props;
18564
- const ownerOrganization = (_a2 = reactRedux.useSelector(selectOrganization(form.owner_organization || -1))) == null ? void 0 : _a2.name;
18565
- const ownerUser = reactRedux.useSelector(selectUser(form.owner_user || -1));
18566
- const currentUserId = reactRedux.useSelector(selectCurrentUser).id;
18567
- const ownedByCurrentUser = !!ownerUser && ownerUser.id === currentUserId;
18568
- const owner = ownerOrganization ?? (ownedByCurrentUser ? "You" : ownerUser == null ? void 0 : ownerUser.username) ?? "Unknown";
18519
+ const ownerOrganization = (_a2 = reactRedux.useSelector(selectOrganization(form.organization || -1))) == null ? void 0 : _a2.name;
18569
18520
  const handleFavoriteClick = React.useCallback(
18570
18521
  (e) => {
18571
18522
  e.stopPropagation();
@@ -18596,10 +18547,10 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
18596
18547
  /* @__PURE__ */ jsxRuntime.jsx(Text, { children: form.latestRevision.title }),
18597
18548
  form.latestRevision.description && /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiQuestionLine" })
18598
18549
  ] }),
18599
- owner && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", gap: "2", children: [
18550
+ ownerOrganization && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", gap: "2", children: [
18600
18551
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiUserLine" }),
18601
18552
  " ",
18602
- owner
18553
+ ownerOrganization
18603
18554
  ] })
18604
18555
  ] })
18605
18556
  }
@@ -19868,7 +19819,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
19868
19819
  exports2.LicenseService = LicenseService;
19869
19820
  exports2.LicenseStatus = LicenseStatus;
19870
19821
  exports2.MainService = MainService;
19871
- exports2.MapStyle = MapStyle;
19872
19822
  exports2.MultiSelectField = MultiSelectField;
19873
19823
  exports2.MultiSelectInput = MultiSelectInput;
19874
19824
  exports2.MultiStringField = MultiStringField;
@@ -19893,7 +19843,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
19893
19843
  exports2.ProjectAttachmentService = ProjectAttachmentService;
19894
19844
  exports2.ProjectFileService = ProjectFileService;
19895
19845
  exports2.ProjectService = ProjectService;
19896
- exports2.ProjectType = ProjectType;
19897
19846
  exports2.QrField = QrField;
19898
19847
  exports2.QrInput = QrInput;
19899
19848
  exports2.QrScanner = QrScanner;
@@ -20079,8 +20028,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20079
20028
  exports2.literalToCoordinates = literalToCoordinates;
20080
20029
  exports2.logOnlyOnce = logOnlyOnce;
20081
20030
  exports2.makeClient = makeClient;
20082
- exports2.mapReducer = mapReducer;
20083
- exports2.mapSlice = mapSlice;
20084
20031
  exports2.markAsDeleted = markAsDeleted;
20085
20032
  exports2.markForDeletion = markForDeletion;
20086
20033
  exports2.markerCoordinatesToText = markerCoordinatesToText;
@@ -20210,7 +20157,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20210
20157
  exports2.selectCategory = selectCategory;
20211
20158
  exports2.selectCategoryMapping = selectCategoryMapping;
20212
20159
  exports2.selectCategoryVisibility = selectCategoryVisibility;
20213
- exports2.selectCenterMapToProject = selectCenterMapToProject;
20214
20160
  exports2.selectCommentMapping = selectCommentMapping;
20215
20161
  exports2.selectCommentsOfIssue = selectCommentsOfIssue;
20216
20162
  exports2.selectCompletedStageIdsForAsset = selectCompletedStageIdsForAsset;
@@ -20218,7 +20164,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20218
20164
  exports2.selectConversation = selectConversation;
20219
20165
  exports2.selectConversationMapping = selectConversationMapping;
20220
20166
  exports2.selectConversations = selectConversations;
20221
- exports2.selectCreateProjectType = selectCreateProjectType;
20222
20167
  exports2.selectCurrentUser = selectCurrentUser;
20223
20168
  exports2.selectDeletedRequests = selectDeletedRequests;
20224
20169
  exports2.selectDocument = selectDocument;
@@ -20228,12 +20173,10 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20228
20173
  exports2.selectDocumentsMapping = selectDocumentsMapping;
20229
20174
  exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
20230
20175
  exports2.selectEnableClustering = selectEnableClustering;
20231
- exports2.selectEnableDuplicateIssues = selectEnableDuplicateIssues;
20232
20176
  exports2.selectEnablePlacementMode = selectEnablePlacementMode;
20233
20177
  exports2.selectEnableSvgLayout = selectEnableSvgLayout;
20234
20178
  exports2.selectEnabledProjectFileMapping = selectEnabledProjectFileMapping;
20235
20179
  exports2.selectEnabledProjectFiles = selectEnabledProjectFiles;
20236
- exports2.selectExpandedSections = selectExpandedSections;
20237
20180
  exports2.selectFavouriteProjects = selectFavouriteProjects;
20238
20181
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
20239
20182
  exports2.selectFilteredForms = selectFilteredForms;
@@ -20287,7 +20230,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20287
20230
  exports2.selectLicenses = selectLicenses;
20288
20231
  exports2.selectLicensesForProjectsMapping = selectLicensesForProjectsMapping;
20289
20232
  exports2.selectMainWorkspace = selectMainWorkspace;
20290
- exports2.selectMapStyle = selectMapStyle;
20291
20233
  exports2.selectNumberOfAssetTypesMatchingCaseInsensitiveName = selectNumberOfAssetTypesMatchingCaseInsensitiveName;
20292
20234
  exports2.selectNumberOfAssetsOfAssetType = selectNumberOfAssetsOfAssetType;
20293
20235
  exports2.selectOrganization = selectOrganization;
@@ -20317,10 +20259,8 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20317
20259
  exports2.selectProjectsWithAccess = selectProjectsWithAccess;
20318
20260
  exports2.selectRecentIssueIds = selectRecentIssueIds;
20319
20261
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
20320
- exports2.selectRecentProjects = selectRecentProjects;
20321
20262
  exports2.selectRehydrated = selectRehydrated;
20322
20263
  exports2.selectRootDocuments = selectRootDocuments;
20323
- exports2.selectShowTooltips = selectShowTooltips;
20324
20264
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
20325
20265
  exports2.selectSortedFormSubmissionsOfForm = selectSortedFormSubmissionsOfForm;
20326
20266
  exports2.selectSortedOrganizationLicenses = selectSortedOrganizationLicenses;
@@ -20362,17 +20302,14 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20362
20302
  exports2.setAssetTypes = setAssetTypes;
20363
20303
  exports2.setAssets = setAssets;
20364
20304
  exports2.setCategories = setCategories;
20365
- exports2.setCenterMapToProject = setCenterMapToProject;
20366
20305
  exports2.setConversation = setConversation;
20367
20306
  exports2.setConversations = setConversations;
20368
- exports2.setCreateProjectType = setCreateProjectType;
20369
20307
  exports2.setCurrentUser = setCurrentUser;
20370
20308
  exports2.setDocumentAttachment = setDocumentAttachment;
20371
20309
  exports2.setDocumentAttachments = setDocumentAttachments;
20372
20310
  exports2.setDocuments = setDocuments;
20373
20311
  exports2.setEmailDomains = setEmailDomains;
20374
20312
  exports2.setEnableClustering = setEnableClustering;
20375
- exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
20376
20313
  exports2.setEnablePlacementMode = setEnablePlacementMode;
20377
20314
  exports2.setEnableSvgLayout = setEnableSvgLayout;
20378
20315
  exports2.setFormRevision = setFormRevision;
@@ -20395,7 +20332,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20395
20332
  exports2.setIssues = setIssues;
20396
20333
  exports2.setLicenses = setLicenses;
20397
20334
  exports2.setLoggedIn = setLoggedIn;
20398
- exports2.setMapStyle = setMapStyle;
20399
20335
  exports2.setOrganizationAccesses = setOrganizationAccesses;
20400
20336
  exports2.setOrganizations = setOrganizations;
20401
20337
  exports2.setProfilePicture = setProfilePicture;
@@ -20405,8 +20341,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
20405
20341
  exports2.setProjectFileVisible = setProjectFileVisible;
20406
20342
  exports2.setProjects = setProjects;
20407
20343
  exports2.setRehydrated = setRehydrated;
20408
- exports2.setSectionExpanded = setSectionExpanded;
20409
- exports2.setShowTooltips = setShowTooltips;
20410
20344
  exports2.setStageCompletions = setStageCompletions;
20411
20345
  exports2.setTeam = setTeam;
20412
20346
  exports2.setTeams = setTeams;