@overmap-ai/core 1.0.23-organization-management.0 → 1.0.24

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.
@@ -617,15 +617,15 @@ const wrapMigration = (migrator) => (state) => {
617
617
  };
618
618
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
619
619
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
620
- const initialState$l = {
620
+ const initialState$k = {
621
621
  accessToken: "",
622
622
  refreshToken: "",
623
623
  isLoggedIn: false
624
624
  };
625
625
  const authSlice = createSlice({
626
626
  name: "auth",
627
- initialState: initialState$l,
628
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
627
+ initialState: initialState$k,
628
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
629
629
  reducers: {
630
630
  setTokens: (state, action) => {
631
631
  state.accessToken = action.payload.accessToken;
@@ -1328,7 +1328,7 @@ const getLocalRelativeDateString = memoize((date, min, max) => {
1328
1328
  return getLocalDateString(date);
1329
1329
  return relative.format(days, "days");
1330
1330
  });
1331
- const initialState$k = {
1331
+ const initialState$j = {
1332
1332
  categories: {},
1333
1333
  usedCategoryColors: [],
1334
1334
  categoryVisibility: {
@@ -1338,8 +1338,8 @@ const initialState$k = {
1338
1338
  };
1339
1339
  const categorySlice = createSlice({
1340
1340
  name: "categories",
1341
- initialState: initialState$k,
1342
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1341
+ initialState: initialState$j,
1342
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1343
1343
  reducers: {
1344
1344
  setCategories: (state, action) => {
1345
1345
  if (!Array.isArray(action.payload))
@@ -1472,13 +1472,13 @@ const selectHiddenCategoryCount = (state) => {
1472
1472
  return hiddenCategoryCount;
1473
1473
  };
1474
1474
  const categoryReducer = categorySlice.reducer;
1475
- const initialState$j = {
1475
+ const initialState$i = {
1476
1476
  components: {}
1477
1477
  };
1478
1478
  const componentSlice = createSlice({
1479
1479
  name: "components",
1480
- initialState: initialState$j,
1481
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1480
+ initialState: initialState$i,
1481
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1482
1482
  reducers: {
1483
1483
  addComponent: (state, action) => {
1484
1484
  state.components[action.payload.offline_id] = action.payload;
@@ -1590,13 +1590,13 @@ const {
1590
1590
  removeAllComponentsOfType
1591
1591
  } = componentSlice.actions;
1592
1592
  const componentReducer = componentSlice.reducer;
1593
- const initialState$i = {
1593
+ const initialState$h = {
1594
1594
  completionsByComponentId: {}
1595
1595
  };
1596
1596
  const componentStageCompletionSlice = createSlice({
1597
1597
  name: "componentStageCompletions",
1598
- initialState: initialState$i,
1599
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1598
+ initialState: initialState$h,
1599
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1600
1600
  reducers: {
1601
1601
  addStageCompletion: (state, action) => {
1602
1602
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1647,13 +1647,13 @@ const selectCompletedStageIdsForComponent = (component) => (state) => {
1647
1647
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1648
1648
  };
1649
1649
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1650
- const initialState$h = {
1650
+ const initialState$g = {
1651
1651
  stages: {}
1652
1652
  };
1653
1653
  const componentStageSlice = createSlice({
1654
1654
  name: "componentStages",
1655
- initialState: initialState$h,
1656
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1655
+ initialState: initialState$g,
1656
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1657
1657
  reducers: {
1658
1658
  addStages: (state, action) => {
1659
1659
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1713,14 +1713,14 @@ const selectStagesFromStageIds = restructureCreateSelectorWithArgs(
1713
1713
  );
1714
1714
  const { addStages, updateStages, removeStages } = componentStageSlice.actions;
1715
1715
  const componentStageReducer = componentStageSlice.reducer;
1716
- const initialState$g = {
1716
+ const initialState$f = {
1717
1717
  componentTypes: {},
1718
1718
  hiddenComponentTypeIds: {}
1719
1719
  };
1720
1720
  const componentTypeSlice = createSlice({
1721
1721
  name: "componentTypes",
1722
- initialState: initialState$g,
1723
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1722
+ initialState: initialState$f,
1723
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
1724
1724
  reducers: {
1725
1725
  addComponentType: (state, action) => {
1726
1726
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1779,13 +1779,13 @@ const selectComponentTypesByName = restructureCreateSelectorWithArgs(
1779
1779
  const selectHiddenComponentTypeIds = (state) => state.componentTypeReducer.hiddenComponentTypeIds;
1780
1780
  const { addComponentType, setComponentTypes, toggleComponentTypeVisibility, deleteComponentType } = componentTypeSlice.actions;
1781
1781
  const componentTypeReducer = componentTypeSlice.reducer;
1782
- const initialState$f = {
1782
+ const initialState$e = {
1783
1783
  workspaces: {},
1784
1784
  activeWorkspaceId: null
1785
1785
  };
1786
1786
  const workspaceSlice = createSlice({
1787
1787
  name: "workspace",
1788
- initialState: initialState$f,
1788
+ initialState: initialState$e,
1789
1789
  // The `reducers` field lets us define reducers and generate associated actions
1790
1790
  reducers: {
1791
1791
  setWorkspaces: (state, action) => {
@@ -1842,7 +1842,7 @@ const selectPermittedWorkspaceIds = createSelector(
1842
1842
  );
1843
1843
  const workspaceReducer = workspaceSlice.reducer;
1844
1844
  const maxRecentIssues = 10;
1845
- const initialState$e = {
1845
+ const initialState$d = {
1846
1846
  issues: {},
1847
1847
  attachments: {},
1848
1848
  comments: {},
@@ -1854,9 +1854,9 @@ const initialState$e = {
1854
1854
  };
1855
1855
  const issueSlice = createSlice({
1856
1856
  name: "issues",
1857
- initialState: initialState$e,
1857
+ initialState: initialState$d,
1858
1858
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1859
- Object.assign(state, initialState$e);
1859
+ Object.assign(state, initialState$d);
1860
1860
  }),
1861
1861
  reducers: {
1862
1862
  setIssues: (state, action) => {
@@ -2187,15 +2187,15 @@ const selectRecentIssuesAsSearchResults = createSelector(
2187
2187
  }
2188
2188
  );
2189
2189
  const issueReducer = issueSlice.reducer;
2190
- const initialState$d = {
2190
+ const initialState$c = {
2191
2191
  s3Urls: {}
2192
2192
  };
2193
2193
  const msPerHour = 1e3 * 60 * 60;
2194
2194
  const msPerWeek = msPerHour * 24 * 7;
2195
2195
  const fileSlice = createSlice({
2196
2196
  name: "file",
2197
- initialState: initialState$d,
2198
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2197
+ initialState: initialState$c,
2198
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2199
2199
  reducers: {
2200
2200
  setUploadUrl: (state, action) => {
2201
2201
  const { url, fields, sha1 } = action.payload;
@@ -2222,7 +2222,7 @@ const selectUploadUrl = (sha1) => (state) => {
2222
2222
  return url;
2223
2223
  };
2224
2224
  const fileReducer = fileSlice.reducer;
2225
- const initialState$c = {
2225
+ const initialState$b = {
2226
2226
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2227
2227
  mapStyle: MapStyle.SATELLITE,
2228
2228
  showTooltips: false,
@@ -2230,8 +2230,8 @@ const initialState$c = {
2230
2230
  };
2231
2231
  const mapSlice = createSlice({
2232
2232
  name: "map",
2233
- initialState: initialState$c,
2234
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2233
+ initialState: initialState$b,
2234
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2235
2235
  reducers: {
2236
2236
  setMapStyle: (state, action) => {
2237
2237
  state.mapStyle = action.payload;
@@ -2249,315 +2249,26 @@ const selectMapStyle = (state) => state.mapReducer.mapStyle;
2249
2249
  const selectShowTooltips = (state) => state.mapReducer.showTooltips;
2250
2250
  const selectCenterMapToProject = (state) => state.mapReducer.centerMapToProject;
2251
2251
  const mapReducer = mapSlice.reducer;
2252
- const initialState$b = {
2253
- organizationAccesses: {},
2254
- activeOrganizationAccessId: null
2255
- };
2256
- const organizationAccessSlice = createSlice({
2257
- name: "organizationAccess",
2258
- initialState: initialState$b,
2259
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2260
- reducers: {
2261
- setOrganizationAccesses: (state, action) => {
2262
- if (!Array.isArray(action.payload))
2263
- throw new Error("Expected an array of OrganizationAccess");
2264
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2265
- throw new Error("Tried to use setOrganizationAccesses reducer with duplicate ID's");
2266
- }
2267
- const organizationAccesses = {};
2268
- for (const organizationAccess of action.payload) {
2269
- organizationAccesses[organizationAccess.offline_id] = organizationAccess;
2270
- }
2271
- state.organizationAccesses = organizationAccesses;
2272
- },
2273
- updateOrganizationAccess: (state, action) => {
2274
- if (action.payload.offline_id in state.organizationAccesses) {
2275
- state.organizationAccesses[action.payload.offline_id] = action.payload;
2276
- } else {
2277
- throw new Error(
2278
- `Tried to update organization access with ID that doesn't exist: ${action.payload.offline_id}`
2279
- );
2280
- }
2281
- },
2282
- removeOrganizationAccess: (state, action) => {
2283
- if (action.payload.offline_id in state.organizationAccesses) {
2284
- delete state.organizationAccesses[action.payload.offline_id];
2285
- } else {
2286
- throw new Error(
2287
- `Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
2288
- );
2289
- }
2290
- },
2291
- setActiveOrganizationAccessId: (state, action) => {
2292
- state.activeOrganizationAccessId = action.payload;
2293
- }
2294
- }
2295
- });
2296
- const {
2297
- setOrganizationAccesses,
2298
- updateOrganizationAccess,
2299
- removeOrganizationAccess,
2300
- setActiveOrganizationAccessId
2301
- } = organizationAccessSlice.actions;
2302
- const selectOrganizationAccesses = (state) => {
2303
- return state.organizationAccessReducer.organizationAccesses;
2304
- };
2305
- const selectOrganizationAccess = (organizationAccessId) => (state) => {
2306
- return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
2307
- };
2308
- const selectActiveOrganizationAccess = (state) => {
2309
- const activeOrganizationAccessId = state.organizationAccessReducer.activeOrganizationAccessId;
2310
- if (!activeOrganizationAccessId) {
2311
- return null;
2312
- }
2313
- return state.organizationAccessReducer.organizationAccesses[activeOrganizationAccessId] ?? null;
2314
- };
2315
- const selectOrganizationAccessForUser = (user) => (state) => {
2316
- return Object.values(state.organizationAccessReducer.organizationAccesses).find(
2317
- (organizationAccess) => organizationAccess.user === user.id
2318
- );
2319
- };
2320
- const selectOrganizationAccessUserMapping = (state) => {
2321
- const organizationAccesses = {};
2322
- Object.values(state.organizationAccessReducer.organizationAccesses).forEach((organizationAccess) => {
2323
- organizationAccesses[organizationAccess.user] = organizationAccess;
2324
- });
2325
- return organizationAccesses;
2326
- };
2327
- const organizationAccessReducer = organizationAccessSlice.reducer;
2328
- var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
2329
- ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
2330
- ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
2331
- return ProjectAccessLevel2;
2332
- })(ProjectAccessLevel || {});
2333
- var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
2334
- OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
2335
- OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
2336
- return OrganizationAccessLevel2;
2337
- })(OrganizationAccessLevel || {});
2338
- var ProjectType = /* @__PURE__ */ ((ProjectType2) => {
2339
- ProjectType2[ProjectType2["PERSONAL"] = 0] = "PERSONAL";
2340
- ProjectType2[ProjectType2["ORGANIZATION"] = 2] = "ORGANIZATION";
2341
- return ProjectType2;
2342
- })(ProjectType || {});
2343
- var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
2344
- VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
2345
- VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
2346
- VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
2347
- VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
2348
- VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
2349
- VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
2350
- return VerificationCodeType2;
2351
- })(VerificationCodeType || {});
2352
2252
  const initialState$a = {
2353
- projectAccesses: {}
2354
- };
2355
- const projectAccessSlice = createSlice({
2356
- name: "projectAccess",
2357
- initialState: initialState$a,
2358
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2359
- reducers: {
2360
- setProjectAccesses: (state, action) => {
2361
- if (!Array.isArray(action.payload))
2362
- throw new Error("Expected an array of ProjectAccess");
2363
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2364
- throw new Error("Tried to use setProjectAccesses reducer with duplicate ID's");
2365
- }
2366
- const projectAccesses = {};
2367
- for (const projectAccess of action.payload) {
2368
- projectAccesses[projectAccess.offline_id] = projectAccess;
2369
- }
2370
- state.projectAccesses = projectAccesses;
2371
- },
2372
- updateProjectAccess: (state, action) => {
2373
- if (action.payload.offline_id in state.projectAccesses) {
2374
- state.projectAccesses[action.payload.offline_id] = action.payload;
2375
- } else {
2376
- throw new Error(
2377
- `Tried to update project access with ID that doesn't exist: ${action.payload.offline_id}`
2378
- );
2379
- }
2380
- },
2381
- removeProjectAccess: (state, action) => {
2382
- if (action.payload.offline_id in state.projectAccesses) {
2383
- delete state.projectAccesses[action.payload.offline_id];
2384
- } else {
2385
- throw new Error(
2386
- `Tried to remove project access with ID that doesn't exist: ${action.payload.offline_id}`
2387
- );
2388
- }
2389
- },
2390
- removeProjectAccessesOfProject: (state, action) => {
2391
- for (const projectAccess of Object.values(state.projectAccesses)) {
2392
- if (projectAccess.project === action.payload) {
2393
- delete state.projectAccesses[projectAccess.offline_id];
2394
- }
2395
- }
2396
- }
2397
- }
2398
- });
2399
- const { setProjectAccesses, updateProjectAccess, removeProjectAccess, removeProjectAccessesOfProject } = projectAccessSlice.actions;
2400
- const selectProjectAccesses = (state) => {
2401
- return state.projectAccessReducer.projectAccesses;
2402
- };
2403
- const selectProjectAccess = (projectAccessId) => (state) => {
2404
- return state.projectAccessReducer.projectAccesses[projectAccessId];
2405
- };
2406
- const selectActiveProjectAccess = (state) => {
2407
- const currentUser = state.userReducer.currentUser;
2408
- const activeProjectId = state.projectReducer.activeProjectId;
2409
- return Object.values(state.projectAccessReducer.projectAccesses).find((projectAccess) => {
2410
- return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
2411
- }) ?? null;
2412
- };
2413
- const selectProjectAccessForUser = (user) => (state) => {
2414
- return Object.values(state.projectAccessReducer.projectAccesses).find(
2415
- (projectAccess) => projectAccess.user === user.id
2416
- );
2417
- };
2418
- const selectProjectAccessUserMapping = (state) => {
2419
- const projectAccesses = {};
2420
- for (const projectAccess of Object.values(state.projectAccessReducer.projectAccesses)) {
2421
- projectAccesses[projectAccess.user] = projectAccess;
2422
- }
2423
- return projectAccesses;
2424
- };
2425
- const projectAccessReducer = projectAccessSlice.reducer;
2426
- const initialState$9 = {
2427
- users: {},
2428
- currentUser: {
2429
- id: 0,
2430
- username: "",
2431
- email: "",
2432
- profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
2433
- }
2434
- };
2435
- const userSlice = createSlice({
2436
- name: "users",
2437
- initialState: initialState$9,
2438
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2439
- reducers: {
2440
- setUsers: (state, action) => {
2441
- const usersMapping = {};
2442
- action.payload.forEach((user) => {
2443
- usersMapping[user.id] = user;
2444
- });
2445
- state.users = usersMapping;
2446
- },
2447
- setCurrentUser: (state, action) => {
2448
- state.currentUser = action.payload;
2449
- },
2450
- setProfilePicture: (state, action) => {
2451
- state.currentUser.profile.file = action.payload.file ?? null;
2452
- state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
2453
- const currentUser = state.users[state.currentUser.id];
2454
- if (!currentUser) {
2455
- throw new Error("Unable to find current user in users slice");
2456
- }
2457
- currentUser.profile.file = action.payload.file ?? null;
2458
- currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
2459
- },
2460
- addFavouriteProjectId: (state, action) => {
2461
- state.currentUser.profile.favourite_project_ids.push(action.payload);
2462
- },
2463
- removeFavouriteProjectId: (state, action) => {
2464
- state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
2465
- (id) => id !== action.payload
2466
- );
2467
- },
2468
- setTourStep: (state, action) => {
2469
- state.currentUser.profile.tour_step = action.payload;
2470
- },
2471
- removeUser: (state, action) => {
2472
- delete state.users[action.payload];
2473
- }
2474
- }
2475
- });
2476
- const {
2477
- setCurrentUser,
2478
- setProfilePicture,
2479
- setUsers,
2480
- addFavouriteProjectId,
2481
- removeFavouriteProjectId,
2482
- setTourStep,
2483
- removeUser
2484
- } = userSlice.actions;
2485
- const selectCurrentUser = (state) => state.userReducer.currentUser;
2486
- const selectUser = (userId) => (state) => {
2487
- if (userId === null)
2488
- return void 0;
2489
- return state.userReducer.users[userId];
2490
- };
2491
- const selectUsersAsMapping = (state) => state.userReducer.users;
2492
- const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2493
- const selectSortedUsers = createSelector(
2494
- [selectCurrentUser, selectUsersAsMapping, selectProjectAccessUserMapping],
2495
- (currentUser, userMapping, projectAccessMapping) => {
2496
- return Object.values(userMapping).sort((userA, userB) => {
2497
- if (userA.id === currentUser.id) {
2498
- return -1;
2499
- } else if (userB.id === currentUser.id) {
2500
- return 1;
2501
- }
2502
- const projectAccessesA = projectAccessMapping[userA.id];
2503
- const projectAccessesB = projectAccessMapping[userB.id];
2504
- if ((projectAccessesA == null ? void 0 : projectAccessesA.access_level) === (projectAccessesB == null ? void 0 : projectAccessesB.access_level)) {
2505
- return userA.username.localeCompare(userB.username);
2506
- }
2507
- if ((projectAccessesA == null ? void 0 : projectAccessesA.access_level) === ProjectAccessLevel.ADMIN) {
2508
- return -1;
2509
- }
2510
- return 1;
2511
- });
2512
- }
2513
- );
2514
- const userReducer = userSlice.reducer;
2515
- const initialState$8 = {
2516
2253
  organizations: {},
2517
- users: {},
2518
- activeOrganizationId: 0
2254
+ activeOrganizationId: null
2519
2255
  };
2520
2256
  const organizationSlice = createSlice({
2521
2257
  name: "organizations",
2522
- initialState: initialState$8,
2523
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2258
+ initialState: initialState$a,
2259
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2524
2260
  reducers: {
2525
2261
  setOrganizations: (state, action) => {
2526
2262
  for (const org of action.payload) {
2527
2263
  state.organizations[org.id] = org;
2528
2264
  }
2529
2265
  },
2530
- setActiveOrganization: (state, action) => {
2531
- if (!state.activeOrganizationId) {
2532
- throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2533
- }
2534
- if (state.activeOrganizationId !== action.payload.id) {
2535
- throw new Error("Tried updating active organization with different organization");
2536
- }
2537
- state.organizations[state.activeOrganizationId] = action.payload;
2538
- },
2539
2266
  setActiveOrganizationId: (state, action) => {
2540
2267
  state.activeOrganizationId = action.payload;
2541
- },
2542
- setOrganizationUsers: (state, action) => {
2543
- const usersMapping = {};
2544
- action.payload.forEach((user) => {
2545
- usersMapping[user.id] = user;
2546
- });
2547
- state.users = usersMapping;
2548
- },
2549
- removeOrganizationUser: (state, action) => {
2550
- delete state.users[action.payload];
2551
2268
  }
2552
2269
  }
2553
2270
  });
2554
- const {
2555
- setOrganizations,
2556
- setActiveOrganizationId,
2557
- setActiveOrganization,
2558
- setOrganizationUsers,
2559
- removeOrganizationUser
2560
- } = organizationSlice.actions;
2271
+ const { setOrganizations, setActiveOrganizationId } = organizationSlice.actions;
2561
2272
  const selectActiveOrganizationId = (state) => {
2562
2273
  return state.organizationReducer.activeOrganizationId;
2563
2274
  };
@@ -2575,28 +2286,6 @@ const selectActiveOrganization = (state) => {
2575
2286
  }
2576
2287
  return organization;
2577
2288
  };
2578
- const selectOrganizationUsersAsMapping = (state) => state.organizationReducer.users;
2579
- const selectSortedOrganizationUsers = createSelector(
2580
- [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2581
- (currentUser, userMapping, organizationAccessMapping) => {
2582
- return Object.values(userMapping).sort((userA, userB) => {
2583
- if (userA.id === currentUser.id) {
2584
- return -1;
2585
- } else if (userB.id === currentUser.id) {
2586
- return 1;
2587
- }
2588
- const organizationAccessesA = organizationAccessMapping[userA.id];
2589
- const organizationAccessesB = organizationAccessMapping[userB.id];
2590
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2591
- return userA.username.localeCompare(userB.username);
2592
- }
2593
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2594
- return -1;
2595
- }
2596
- return 1;
2597
- });
2598
- }
2599
- );
2600
2289
  const selectOrganization = (id) => (state) => {
2601
2290
  return state.organizationReducer.organizations[id];
2602
2291
  };
@@ -2617,14 +2306,14 @@ const createOfflineAction = (request2, baseUrl) => {
2617
2306
  }
2618
2307
  };
2619
2308
  };
2620
- const initialState$7 = {
2309
+ const initialState$9 = {
2621
2310
  deletedRequests: [],
2622
2311
  latestRetryTime: 0
2623
2312
  };
2624
2313
  const outboxSlice = createSlice({
2625
2314
  name: "outbox",
2626
- initialState: initialState$7,
2627
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2315
+ initialState: initialState$9,
2316
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2628
2317
  reducers: {
2629
2318
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2630
2319
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2656,7 +2345,105 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2656
2345
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2657
2346
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2658
2347
  const outboxReducer = outboxSlice.reducer;
2659
- const initialState$6 = {
2348
+ const initialState$8 = {
2349
+ projectAccesses: {}
2350
+ };
2351
+ const projectAccessSlice = createSlice({
2352
+ name: "projectAccess",
2353
+ initialState: initialState$8,
2354
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2355
+ reducers: {
2356
+ setProjectAccesses: (state, action) => {
2357
+ if (!Array.isArray(action.payload))
2358
+ throw new Error("Expected an array of ProjectAccess");
2359
+ if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2360
+ throw new Error("Tried to use setProjectAccesses reducer with duplicate ID's");
2361
+ }
2362
+ const projectAccesses = {};
2363
+ for (const projectAccess of action.payload) {
2364
+ projectAccesses[projectAccess.offline_id] = projectAccess;
2365
+ }
2366
+ state.projectAccesses = projectAccesses;
2367
+ },
2368
+ updateProjectAccess: (state, action) => {
2369
+ if (action.payload.offline_id in state.projectAccesses) {
2370
+ state.projectAccesses[action.payload.offline_id] = action.payload;
2371
+ } else {
2372
+ throw new Error(
2373
+ `Tried to update project access with ID that doesn't exist: ${action.payload.offline_id}`
2374
+ );
2375
+ }
2376
+ },
2377
+ removeProjectAccess: (state, action) => {
2378
+ if (action.payload.offline_id in state.projectAccesses) {
2379
+ delete state.projectAccesses[action.payload.offline_id];
2380
+ } else {
2381
+ throw new Error(
2382
+ `Tried to remove project access with ID that doesn't exist: ${action.payload.offline_id}`
2383
+ );
2384
+ }
2385
+ },
2386
+ removeProjectAccessesOfProject: (state, action) => {
2387
+ for (const projectAccess of Object.values(state.projectAccesses)) {
2388
+ if (projectAccess.project === action.payload) {
2389
+ delete state.projectAccesses[projectAccess.offline_id];
2390
+ }
2391
+ }
2392
+ }
2393
+ }
2394
+ });
2395
+ const { setProjectAccesses, updateProjectAccess, removeProjectAccess, removeProjectAccessesOfProject } = projectAccessSlice.actions;
2396
+ const selectProjectAccesses = (state) => {
2397
+ return state.projectAccessReducer.projectAccesses;
2398
+ };
2399
+ const selectProjectAccess = (projectAccessId) => (state) => {
2400
+ return state.projectAccessReducer.projectAccesses[projectAccessId];
2401
+ };
2402
+ const selectActiveProjectAccess = (state) => {
2403
+ const currentUser = state.userReducer.currentUser;
2404
+ const activeProjectId = state.projectReducer.activeProjectId;
2405
+ return Object.values(state.projectAccessReducer.projectAccesses).find((projectAccess) => {
2406
+ return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
2407
+ }) ?? null;
2408
+ };
2409
+ const selectProjectAccessForUser = (user) => (state) => {
2410
+ return Object.values(state.projectAccessReducer.projectAccesses).find(
2411
+ (projectAccess) => projectAccess.user === user.id
2412
+ );
2413
+ };
2414
+ const selectProjectAccessUserMapping = (state) => {
2415
+ const projectAccesses = {};
2416
+ for (const projectAccess of Object.values(state.projectAccessReducer.projectAccesses)) {
2417
+ projectAccesses[projectAccess.user] = projectAccess;
2418
+ }
2419
+ return projectAccesses;
2420
+ };
2421
+ const projectAccessReducer = projectAccessSlice.reducer;
2422
+ var ProjectAccessLevel = /* @__PURE__ */ ((ProjectAccessLevel2) => {
2423
+ ProjectAccessLevel2[ProjectAccessLevel2["BASIC"] = 0] = "BASIC";
2424
+ ProjectAccessLevel2[ProjectAccessLevel2["ADMIN"] = 2] = "ADMIN";
2425
+ return ProjectAccessLevel2;
2426
+ })(ProjectAccessLevel || {});
2427
+ var OrganizationAccessLevel = /* @__PURE__ */ ((OrganizationAccessLevel2) => {
2428
+ OrganizationAccessLevel2[OrganizationAccessLevel2["BASIC"] = 0] = "BASIC";
2429
+ OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
2430
+ return OrganizationAccessLevel2;
2431
+ })(OrganizationAccessLevel || {});
2432
+ var ProjectType = /* @__PURE__ */ ((ProjectType2) => {
2433
+ ProjectType2[ProjectType2["PERSONAL"] = 0] = "PERSONAL";
2434
+ ProjectType2[ProjectType2["ORGANIZATION"] = 2] = "ORGANIZATION";
2435
+ return ProjectType2;
2436
+ })(ProjectType || {});
2437
+ var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
2438
+ VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
2439
+ VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
2440
+ VerificationCodeType2[VerificationCodeType2["PROJECT_INVITE"] = 4] = "PROJECT_INVITE";
2441
+ VerificationCodeType2[VerificationCodeType2["ORGANIZATION_INVITE"] = 6] = "ORGANIZATION_INVITE";
2442
+ VerificationCodeType2[VerificationCodeType2["ADD_EMAIL_DOMAIN"] = 8] = "ADD_EMAIL_DOMAIN";
2443
+ VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
2444
+ return VerificationCodeType2;
2445
+ })(VerificationCodeType || {});
2446
+ const initialState$7 = {
2660
2447
  projects: {},
2661
2448
  activeProjectId: null,
2662
2449
  recentProjectIds: [],
@@ -2665,7 +2452,7 @@ const initialState$6 = {
2665
2452
  };
2666
2453
  const projectSlice = createSlice({
2667
2454
  name: "projects",
2668
- initialState: initialState$6,
2455
+ initialState: initialState$7,
2669
2456
  reducers: {
2670
2457
  setProjects: (state, action) => {
2671
2458
  const projectsMap = {};
@@ -2729,7 +2516,7 @@ const selectRecentProjects = (state) => {
2729
2516
  };
2730
2517
  const selectCreateProjectType = (state) => state.projectReducer.createProjectType;
2731
2518
  const projectReducer = projectSlice.reducer;
2732
- const initialState$5 = {
2519
+ const initialState$6 = {
2733
2520
  projectFiles: {},
2734
2521
  activeProjectFileId: null,
2735
2522
  isImportingProjectFile: false,
@@ -2737,8 +2524,8 @@ const initialState$5 = {
2737
2524
  };
2738
2525
  const projectFileSlice = createSlice({
2739
2526
  name: "projectFiles",
2740
- initialState: initialState$5,
2741
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2527
+ initialState: initialState$6,
2528
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2742
2529
  reducers: {
2743
2530
  addOrReplaceProjectFiles: (state, action) => {
2744
2531
  for (let fileObj of action.payload) {
@@ -2839,12 +2626,12 @@ const selectProjectFiles = createSelector(
2839
2626
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
2840
2627
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
2841
2628
  const projectFileReducer = projectFileSlice.reducer;
2842
- const initialState$4 = {
2629
+ const initialState$5 = {
2843
2630
  isRehydrated: false
2844
2631
  };
2845
2632
  const rehydratedSlice = createSlice({
2846
2633
  name: "rehydrated",
2847
- initialState: initialState$4,
2634
+ initialState: initialState$5,
2848
2635
  // The `reducers` field lets us define reducers and generate associated actions
2849
2636
  reducers: {
2850
2637
  setRehydrated: (state, action) => {
@@ -2854,7 +2641,7 @@ const rehydratedSlice = createSlice({
2854
2641
  });
2855
2642
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
2856
2643
  const rehydratedReducer = rehydratedSlice.reducer;
2857
- const initialState$3 = {
2644
+ const initialState$4 = {
2858
2645
  useIssueTemplate: false,
2859
2646
  placementMode: false,
2860
2647
  enableClustering: true,
@@ -2869,8 +2656,8 @@ const initialState$3 = {
2869
2656
  };
2870
2657
  const settingSlice = createSlice({
2871
2658
  name: "settings",
2872
- initialState: initialState$3,
2873
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
2659
+ initialState: initialState$4,
2660
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
2874
2661
  reducers: {
2875
2662
  setEnableDuplicateIssues: (state, action) => {
2876
2663
  state.useIssueTemplate = action.payload;
@@ -2933,7 +2720,7 @@ function considerCachingRevision(revision, formId, preferPending = false) {
2933
2720
  function getLatestRevisionFromCache(formId) {
2934
2721
  return LATEST_REVISION_CACHE[formId];
2935
2722
  }
2936
- const initialState$2 = {
2723
+ const initialState$3 = {
2937
2724
  userForms: {},
2938
2725
  revisions: {},
2939
2726
  submissions: {},
@@ -2941,8 +2728,8 @@ const initialState$2 = {
2941
2728
  };
2942
2729
  const userFormSlice = createSlice({
2943
2730
  name: "userForms",
2944
- initialState: initialState$2,
2945
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
2731
+ initialState: initialState$3,
2732
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
2946
2733
  reducers: {
2947
2734
  setUserForms: (state, action) => {
2948
2735
  state.userForms = {};
@@ -3190,38 +2977,171 @@ const selectNumberOfUserForms = createSelector([selectUserFormMapping], (userFor
3190
2977
  return Object.keys(userForms).length;
3191
2978
  });
3192
2979
  const userFormReducer = userFormSlice.reducer;
2980
+ const initialState$2 = {
2981
+ users: {},
2982
+ currentUser: {
2983
+ id: 0,
2984
+ username: "",
2985
+ email: "",
2986
+ profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
2987
+ }
2988
+ };
2989
+ const userSlice = createSlice({
2990
+ name: "users",
2991
+ initialState: initialState$2,
2992
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
2993
+ reducers: {
2994
+ setUsers: (state, action) => {
2995
+ const usersMapping = {};
2996
+ action.payload.forEach((user) => {
2997
+ usersMapping[user.id] = user;
2998
+ });
2999
+ state.users = usersMapping;
3000
+ },
3001
+ setCurrentUser: (state, action) => {
3002
+ state.currentUser = action.payload;
3003
+ },
3004
+ setProfilePicture: (state, action) => {
3005
+ state.currentUser.profile.file = action.payload.file ?? null;
3006
+ state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
3007
+ const currentUser = state.users[state.currentUser.id];
3008
+ if (!currentUser) {
3009
+ throw new Error("Unable to find current user in users slice");
3010
+ }
3011
+ currentUser.profile.file = action.payload.file ?? null;
3012
+ currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
3013
+ },
3014
+ addFavouriteProjectId: (state, action) => {
3015
+ state.currentUser.profile.favourite_project_ids.push(action.payload);
3016
+ },
3017
+ removeFavouriteProjectId: (state, action) => {
3018
+ state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
3019
+ (id) => id !== action.payload
3020
+ );
3021
+ },
3022
+ setTourStep: (state, action) => {
3023
+ state.currentUser.profile.tour_step = action.payload;
3024
+ },
3025
+ removeUser: (state, action) => {
3026
+ delete state.users[action.payload];
3027
+ }
3028
+ }
3029
+ });
3030
+ const {
3031
+ setCurrentUser,
3032
+ setProfilePicture,
3033
+ setUsers,
3034
+ addFavouriteProjectId,
3035
+ removeFavouriteProjectId,
3036
+ setTourStep,
3037
+ removeUser
3038
+ } = userSlice.actions;
3039
+ const selectCurrentUser = (state) => state.userReducer.currentUser;
3040
+ const selectUser = (userId) => (state) => {
3041
+ if (userId === null)
3042
+ return void 0;
3043
+ return state.userReducer.users[userId];
3044
+ };
3045
+ const selectUsersAsMapping = (state) => state.userReducer.users;
3046
+ const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
3047
+ const selectSortedUsers = createSelector(
3048
+ [selectCurrentUser, selectUsersAsMapping, selectProjectAccessUserMapping],
3049
+ (currentUser, userMapping, projectAccessMapping) => {
3050
+ return Object.values(userMapping).sort((userA, userB) => {
3051
+ if (userA.id === currentUser.id) {
3052
+ return -1;
3053
+ } else if (userB.id === currentUser.id) {
3054
+ return 1;
3055
+ }
3056
+ const projectAccessesA = projectAccessMapping[userA.id];
3057
+ const projectAccessesB = projectAccessMapping[userB.id];
3058
+ if ((projectAccessesA == null ? void 0 : projectAccessesA.access_level) === (projectAccessesB == null ? void 0 : projectAccessesB.access_level)) {
3059
+ return userA.username.localeCompare(userB.username);
3060
+ }
3061
+ if ((projectAccessesA == null ? void 0 : projectAccessesA.access_level) === ProjectAccessLevel.ADMIN) {
3062
+ return -1;
3063
+ }
3064
+ return 1;
3065
+ });
3066
+ }
3067
+ );
3068
+ const userReducer = userSlice.reducer;
3193
3069
  const initialState$1 = {
3194
- emailDomains: {}
3070
+ organizationAccesses: {},
3071
+ activeOrganizationAccessId: null
3195
3072
  };
3196
- const emailDomainsSlice = createSlice({
3197
- name: "emailDomains",
3073
+ const organizationAccessSlice = createSlice({
3074
+ name: "organizationAccess",
3198
3075
  initialState: initialState$1,
3076
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3199
3077
  reducers: {
3200
- setEmailDomains: (state, action) => {
3201
- const emailDomains = {};
3202
- action.payload.forEach((emailDomain) => {
3203
- emailDomains[emailDomain.offline_id] = emailDomain;
3204
- });
3205
- state.emailDomains = emailDomains;
3078
+ setOrganizationAccesses: (state, action) => {
3079
+ if (!Array.isArray(action.payload))
3080
+ throw new Error("Expected an array of OrganizationAccess");
3081
+ if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
3082
+ throw new Error("Tried to use setOrganizationAccesses reducer with duplicate ID's");
3083
+ }
3084
+ const organizationAccesses = {};
3085
+ for (const organizationAccess of action.payload) {
3086
+ organizationAccesses[organizationAccess.offline_id] = organizationAccess;
3087
+ }
3088
+ state.organizationAccesses = organizationAccesses;
3206
3089
  },
3207
- addEmailDomain: (state, action) => {
3208
- state.emailDomains[action.payload.offline_id] = action.payload;
3090
+ updateOrganizationAccess: (state, action) => {
3091
+ if (action.payload.offline_id in state.organizationAccesses) {
3092
+ state.organizationAccesses[action.payload.offline_id] = action.payload;
3093
+ } else {
3094
+ throw new Error(
3095
+ `Tried to update organization access with ID that doesn't exist: ${action.payload.offline_id}`
3096
+ );
3097
+ }
3209
3098
  },
3210
- removeEmailDomain: (state, action) => {
3211
- if (action.payload.offline_id in state.emailDomains) {
3212
- delete state.emailDomains[action.payload.offline_id];
3099
+ removeOrganizationAccess: (state, action) => {
3100
+ if (action.payload.offline_id in state.organizationAccesses) {
3101
+ delete state.organizationAccesses[action.payload.offline_id];
3213
3102
  } else {
3214
- throw new Error(`Tried to remove email domain with ID that doesn't exist: ${action.payload.offline_id}`);
3103
+ throw new Error(
3104
+ `Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
3105
+ );
3215
3106
  }
3107
+ },
3108
+ setActiveOrganizationAccessId: (state, action) => {
3109
+ state.activeOrganizationAccessId = action.payload;
3216
3110
  }
3217
3111
  }
3218
3112
  });
3219
- const { setEmailDomains, addEmailDomain, removeEmailDomain } = emailDomainsSlice.actions;
3220
- const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.emailDomains;
3221
- const selectSortedEmailDomains = (state) => Object.values(state.emailDomainsReducer.emailDomains).sort(
3222
- (ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
3223
- );
3224
- const emailDomainsReducer = emailDomainsSlice.reducer;
3113
+ const {
3114
+ setOrganizationAccesses,
3115
+ updateOrganizationAccess,
3116
+ removeOrganizationAccess,
3117
+ setActiveOrganizationAccessId
3118
+ } = organizationAccessSlice.actions;
3119
+ const selectOrganizationAccesses = (state) => {
3120
+ return state.organizationAccessReducer.organizationAccesses;
3121
+ };
3122
+ const selectOrganizationAccess = (organizationAccessId) => (state) => {
3123
+ return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
3124
+ };
3125
+ const selectActiveOrganizationAccess = (state) => {
3126
+ const activeOrganizationAccessId = state.organizationAccessReducer.activeOrganizationAccessId;
3127
+ if (!activeOrganizationAccessId) {
3128
+ return null;
3129
+ }
3130
+ return state.organizationAccessReducer.organizationAccesses[activeOrganizationAccessId] ?? null;
3131
+ };
3132
+ const selectOrganizationAccessForUser = (user) => (state) => {
3133
+ return Object.values(state.organizationAccessReducer.organizationAccesses).find(
3134
+ (organizationAccess) => organizationAccess.user === user.id
3135
+ );
3136
+ };
3137
+ const selectOrganizationAccessUserMapping = (state) => {
3138
+ const organizationAccesses = {};
3139
+ Object.values(state.organizationAccessReducer.organizationAccesses).forEach((organizationAccess) => {
3140
+ organizationAccesses[organizationAccess.user] = organizationAccess;
3141
+ });
3142
+ return organizationAccesses;
3143
+ };
3144
+ const organizationAccessReducer = organizationAccessSlice.reducer;
3225
3145
  const initialState = {
3226
3146
  version: 0
3227
3147
  };
@@ -3258,8 +3178,7 @@ const overmapReducers = {
3258
3178
  settingReducer,
3259
3179
  userFormReducer,
3260
3180
  userReducer,
3261
- workspaceReducer,
3262
- emailDomainsReducer
3181
+ workspaceReducer
3263
3182
  };
3264
3183
  const overmapReducer = combineReducers(overmapReducers);
3265
3184
  const resetStore = "RESET";
@@ -3511,7 +3430,8 @@ async function performRequest(action, client) {
3511
3430
  throw new APIError("You have been signed out due to inactivity.", originalError, { discard: true });
3512
3431
  }
3513
3432
  }
3514
- const apiErrorMessage = (_a2 = originalError.body) == null ? void 0 : _a2.error;
3433
+ const apiErrorMessage = ((_a2 = originalError.body) == null ? void 0 : _a2.error) ?? originalError.text ?? originalError.error;
3434
+ console.log("API error message (best effort extraction):", apiErrorMessage);
3515
3435
  throw new APIError(
3516
3436
  typeof apiErrorMessage === "string" ? apiErrorMessage : (
3517
3437
  // TODO: Error codes for all APIErrors.
@@ -4788,7 +4708,7 @@ class MainService extends BaseApiService {
4788
4708
  return result;
4789
4709
  });
4790
4710
  }
4791
- async fetchProjectUsers(projectId) {
4711
+ async fetchUsers(projectId) {
4792
4712
  return this.enqueueRequest({
4793
4713
  description: "Fetch users",
4794
4714
  method: HttpMethod.GET,
@@ -4797,15 +4717,6 @@ class MainService extends BaseApiService {
4797
4717
  blocks: []
4798
4718
  });
4799
4719
  }
4800
- async fetchOrganizationUsers(orgId) {
4801
- return this.enqueueRequest({
4802
- description: "Fetch organization users",
4803
- method: HttpMethod.GET,
4804
- url: `/organizations/${orgId}/users/`,
4805
- blockers: [],
4806
- blocks: []
4807
- });
4808
- }
4809
4720
  // TODO:
4810
4721
  // Don't accept updateStore in ComponentService.list. Just return the offline objects and promise. Here, if
4811
4722
  // overwrite, use setComponents. Otherwise, use bulkAddComponents.
@@ -4848,22 +4759,13 @@ class MainService extends BaseApiService {
4848
4759
  const firstOrg = organizationsData[0];
4849
4760
  const currProjObj = projects.find((project) => project.id === currentProjectId);
4850
4761
  const isOrgProject = !!(currProjObj == null ? void 0 : currProjObj.owner_organization);
4851
- let currentOrgId = -1;
4852
4762
  if (isOrgProject && currProjObj.owner_organization) {
4853
- currentOrgId = currProjObj.owner_organization;
4763
+ store.dispatch(setActiveOrganizationId(currProjObj.owner_organization));
4854
4764
  } else if (firstOrg) {
4855
4765
  console.warn(
4856
4766
  "No active organization; using the first available one. TODO: No active organization in personal projects."
4857
4767
  );
4858
- currentOrgId = firstOrg.id;
4859
- }
4860
- if (currentOrgId !== -1) {
4861
- store.dispatch(setActiveOrganizationId(currentOrgId));
4862
- const orgUsersResultPromise = this.fetchOrganizationUsers(currentOrgId);
4863
- const organizationAccessRefreshPromise = this.client.organizationAccess.refreshStore();
4864
- const orgUsersResult = await orgUsersResultPromise;
4865
- await organizationAccessRefreshPromise;
4866
- store.dispatch(setOrganizationUsers(orgUsersResult));
4768
+ store.dispatch(setActiveOrganizationId(firstOrg.id));
4867
4769
  }
4868
4770
  if (!isProjectIdValid) {
4869
4771
  if (projects.length !== 0) {
@@ -4886,10 +4788,12 @@ class MainService extends BaseApiService {
4886
4788
  }
4887
4789
  }
4888
4790
  if (currentProjectId) {
4889
- const usersResultPromise = this.fetchProjectUsers(currentProjectId);
4791
+ const usersResultPromise = this.fetchUsers(currentProjectId);
4890
4792
  const projectAccessRefreshPromise = this.client.projectAccesses.refreshStore();
4793
+ const organizationAccessRefreshPromise = this.client.organizationAccess.refreshStore();
4891
4794
  const usersResult = await usersResultPromise;
4892
4795
  await projectAccessRefreshPromise;
4796
+ await organizationAccessRefreshPromise;
4893
4797
  store.dispatch(setUsers(usersResult));
4894
4798
  }
4895
4799
  let currentWorkspaceId;
@@ -4916,7 +4820,6 @@ class MainService extends BaseApiService {
4916
4820
  void this.client.userForms.refreshStore().then(() => {
4917
4821
  void this.client.userFormSubmissions.refreshStore().then();
4918
4822
  });
4919
- void this.client.emailDomains.refreshStore().then();
4920
4823
  }
4921
4824
  if (currentProjectId) {
4922
4825
  const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
@@ -4940,7 +4843,8 @@ class MainService extends BaseApiService {
4940
4843
  }
4941
4844
  }
4942
4845
  class ProjectAccessService extends BaseApiService {
4943
- async fetchAll(projectId) {
4846
+ fetchAll(projectId) {
4847
+ const { store } = this.client;
4944
4848
  const promise = this.enqueueRequest({
4945
4849
  description: "Get project accesses",
4946
4850
  method: HttpMethod.GET,
@@ -4948,11 +4852,12 @@ class ProjectAccessService extends BaseApiService {
4948
4852
  blockers: [],
4949
4853
  blocks: []
4950
4854
  });
4951
- return promise;
4855
+ const offlineProjectAccesses = Object.values(store.getState().projectAccessReducer.projectAccesses);
4856
+ return [offlineProjectAccesses, promise];
4952
4857
  }
4953
- async update(projectAccess) {
4858
+ update(projectAccess) {
4954
4859
  this.client.store.dispatch(updateProjectAccess(projectAccess));
4955
- return this.enqueueRequest({
4860
+ const promise = this.enqueueRequest({
4956
4861
  description: "Edit project access",
4957
4862
  method: HttpMethod.PATCH,
4958
4863
  url: `/access/${projectAccess.offline_id}/`,
@@ -4960,9 +4865,10 @@ class ProjectAccessService extends BaseApiService {
4960
4865
  blockers: [projectAccess.offline_id],
4961
4866
  blocks: [projectAccess.offline_id]
4962
4867
  });
4868
+ return [projectAccess, promise];
4963
4869
  }
4964
4870
  // TODO: Re-add user to project if removal fails
4965
- async remove(projectAccess) {
4871
+ remove(projectAccess) {
4966
4872
  const { store } = this.client;
4967
4873
  store.dispatch(removeProjectAccess(projectAccess));
4968
4874
  store.dispatch(removeUser(projectAccess.user));
@@ -4982,7 +4888,7 @@ class ProjectAccessService extends BaseApiService {
4982
4888
  if (!projectId) {
4983
4889
  throw new Error("No active project");
4984
4890
  }
4985
- const promise = this.fetchAll(projectId);
4891
+ const [_offlineProjectAccesses, promise] = this.fetchAll(projectId);
4986
4892
  const result = await promise;
4987
4893
  const activeProjectAccess = result.find((projectAccess) => projectAccess.user === currentUser.id);
4988
4894
  if (!activeProjectAccess) {
@@ -5579,31 +5485,6 @@ class WorkspaceService extends BaseApiService {
5579
5485
  }
5580
5486
  }
5581
5487
  class OrganizationAccessService extends BaseApiService {
5582
- async update(organizationAccess) {
5583
- const promise = this.enqueueRequest({
5584
- description: "Edit organization access",
5585
- method: HttpMethod.PATCH,
5586
- url: `/organizations/${organizationAccess.organization}/access/${organizationAccess.offline_id}/`,
5587
- payload: organizationAccess,
5588
- blockers: [organizationAccess.offline_id],
5589
- blocks: [organizationAccess.offline_id]
5590
- });
5591
- void promise.then(() => {
5592
- this.client.store.dispatch(updateOrganizationAccess(organizationAccess));
5593
- });
5594
- return promise;
5595
- }
5596
- async remove(organizationAccess) {
5597
- this.client.store.dispatch(removeOrganizationAccess(organizationAccess));
5598
- this.client.store.dispatch(removeOrganizationUser(organizationAccess.user));
5599
- return this.enqueueRequest({
5600
- description: "Remove organization access",
5601
- method: HttpMethod.DELETE,
5602
- url: `/organizations/${organizationAccess.organization}/access/${organizationAccess.offline_id}/`,
5603
- blockers: [organizationAccess.offline_id],
5604
- blocks: []
5605
- });
5606
- }
5607
5488
  async refreshStore() {
5608
5489
  const { store } = this.client;
5609
5490
  const state = store.getState();
@@ -5851,86 +5732,6 @@ class EmailVerificationService extends BaseApiService {
5851
5732
  return this.enqueueRequest(requestDetails);
5852
5733
  }
5853
5734
  }
5854
- class EmailDomainsService extends BaseApiService {
5855
- async fetchAll(orgId) {
5856
- return this.enqueueRequest({
5857
- description: "Fetch email domains for organization",
5858
- method: HttpMethod.GET,
5859
- url: `/organizations/${orgId}/email-domains/`,
5860
- blockers: [orgId.toString()],
5861
- blocks: []
5862
- });
5863
- }
5864
- async add(orgId, email) {
5865
- return this.enqueueRequest({
5866
- description: "Add email domain to organization",
5867
- method: HttpMethod.POST,
5868
- url: `/organizations/${orgId}/email-domains/`,
5869
- payload: { email },
5870
- blockers: [orgId.toString()],
5871
- blocks: []
5872
- });
5873
- }
5874
- async remove(emailDomain) {
5875
- this.client.store.dispatch(removeEmailDomain(emailDomain));
5876
- return this.enqueueRequest({
5877
- description: "Remove email domain from organization",
5878
- method: HttpMethod.DELETE,
5879
- url: `/organizations/${emailDomain.organization}/email-domains/${emailDomain.offline_id}/`,
5880
- blockers: [],
5881
- blocks: []
5882
- }).catch((e) => {
5883
- this.client.store.dispatch(addEmailDomain(emailDomain));
5884
- throw e;
5885
- });
5886
- }
5887
- async refreshStore() {
5888
- const organizationId = this.client.store.getState().organizationReducer.activeOrganizationId;
5889
- if (!organizationId) {
5890
- throw new Error("No active organization");
5891
- }
5892
- const promise = this.fetchAll(organizationId);
5893
- const result = await promise;
5894
- this.client.store.dispatch(setEmailDomains(result));
5895
- }
5896
- }
5897
- class OrganizationService extends BaseApiService {
5898
- async create(name) {
5899
- const result = await this.enqueueRequest({
5900
- description: "Create organization",
5901
- method: HttpMethod.POST,
5902
- url: "/organizations/",
5903
- payload: { name },
5904
- blockers: [`add-org-${name}`],
5905
- blocks: [`add-org-${name}`]
5906
- });
5907
- await this.client.main.fetchInitialData(true);
5908
- return result;
5909
- }
5910
- async update(organization) {
5911
- const promise = this.enqueueRequest({
5912
- description: "Edit organization",
5913
- method: HttpMethod.PATCH,
5914
- url: `/organizations/${organization.id}/`,
5915
- payload: organization,
5916
- blockers: [`add-org-${organization.name}`, organization.id.toString()],
5917
- blocks: [organization.id.toString()]
5918
- });
5919
- void promise.then(() => {
5920
- this.client.store.dispatch(setActiveOrganization(organization));
5921
- });
5922
- return promise;
5923
- }
5924
- async invite(organizationId, email) {
5925
- return this.enqueueRequest({
5926
- description: "Invite user to organization",
5927
- method: HttpMethod.POST,
5928
- url: `/organizations/${organizationId}/invite/${email}/`,
5929
- blockers: [],
5930
- blocks: []
5931
- });
5932
- }
5933
- }
5934
5735
  class OvermapSDK {
5935
5736
  constructor(apiUrl, store) {
5936
5737
  __publicField(this, "API_URL");
@@ -5940,7 +5741,6 @@ class OvermapSDK {
5940
5741
  __publicField(this, "auth", new AuthService(this));
5941
5742
  __publicField(this, "categories", new CategoryService(this));
5942
5743
  __publicField(this, "projectAccesses", new ProjectAccessService(this));
5943
- __publicField(this, "organizations", new OrganizationService(this));
5944
5744
  __publicField(this, "organizationAccess", new OrganizationAccessService(this));
5945
5745
  __publicField(this, "issues", new IssueService(this));
5946
5746
  __publicField(this, "issueComments", new IssueCommentService(this));
@@ -5955,7 +5755,6 @@ class OvermapSDK {
5955
5755
  __publicField(this, "projects", new ProjectService(this));
5956
5756
  __publicField(this, "projectFiles", new ProjectFileService(this));
5957
5757
  __publicField(this, "emailVerification", new EmailVerificationService(this));
5958
- __publicField(this, "emailDomains", new EmailDomainsService(this));
5959
5758
  this.API_URL = apiUrl;
5960
5759
  this.store = store;
5961
5760
  }
@@ -5998,7 +5797,6 @@ export {
5998
5797
  ComponentTypeService,
5999
5798
  DEFAULT_ISSUE_PRIORITY,
6000
5799
  DEFAULT_ISSUE_STATUS,
6001
- EmailDomainsService,
6002
5800
  EmailVerificationService,
6003
5801
  FileService,
6004
5802
  GREEN,
@@ -6012,7 +5810,6 @@ export {
6012
5810
  OUTBOX_RETRY_DELAY,
6013
5811
  OrganizationAccessLevel,
6014
5812
  OrganizationAccessService,
6015
- OrganizationService,
6016
5813
  OutboxCoordinator,
6017
5814
  OvermapContext,
6018
5815
  OvermapProvider,
@@ -6036,7 +5833,6 @@ export {
6036
5833
  addComponent,
6037
5834
  addComponentType,
6038
5835
  addComponentsInBatches,
6039
- addEmailDomain,
6040
5836
  addFavouriteProjectId,
6041
5837
  addIssue,
6042
5838
  addOrReplaceCategories,
@@ -6095,8 +5891,6 @@ export {
6095
5891
  dequeue,
6096
5892
  discard,
6097
5893
  downloadInMemoryFile,
6098
- emailDomainsReducer,
6099
- emailDomainsSlice,
6100
5894
  emailRegex,
6101
5895
  enqueue,
6102
5896
  enqueueRequest,
@@ -6165,12 +5959,10 @@ export {
6165
5959
  removeCategory,
6166
5960
  removeColor,
6167
5961
  removeComponent,
6168
- removeEmailDomain,
6169
5962
  removeFavouriteProjectId,
6170
5963
  removeIssue,
6171
5964
  removeIssueComment,
6172
5965
  removeOrganizationAccess,
6173
- removeOrganizationUser,
6174
5966
  removeProjectAccess,
6175
5967
  removeProjectAccessesOfProject,
6176
5968
  removeProjectFile,
@@ -6225,7 +6017,6 @@ export {
6225
6017
  selectCreateProjectType,
6226
6018
  selectCurrentUser,
6227
6019
  selectDeletedRequests,
6228
- selectEmailDomainsAsMapping,
6229
6020
  selectEnableClustering,
6230
6021
  selectEnableDuplicateIssues,
6231
6022
  selectEnablePlacementMode,
@@ -6260,7 +6051,6 @@ export {
6260
6051
  selectOrganizationAccessForUser,
6261
6052
  selectOrganizationAccessUserMapping,
6262
6053
  selectOrganizationAccesses,
6263
- selectOrganizationUsersAsMapping,
6264
6054
  selectOrganizations,
6265
6055
  selectPermittedWorkspaceIds,
6266
6056
  selectPhotoAttachmentsOfIssue,
@@ -6277,8 +6067,6 @@ export {
6277
6067
  selectRehydrated,
6278
6068
  selectRevisionsForForm,
6279
6069
  selectShowTooltips,
6280
- selectSortedEmailDomains,
6281
- selectSortedOrganizationUsers,
6282
6070
  selectSortedUsers,
6283
6071
  selectStageMapping,
6284
6072
  selectStages,
@@ -6301,7 +6089,6 @@ export {
6301
6089
  selectWorkspaceMapping,
6302
6090
  selectWorkspaces,
6303
6091
  setActiveIssueId,
6304
- setActiveOrganization,
6305
6092
  setActiveOrganizationAccessId,
6306
6093
  setActiveOrganizationId,
6307
6094
  setActiveProjectFileId,
@@ -6315,7 +6102,6 @@ export {
6315
6102
  setComponents,
6316
6103
  setCreateProjectType,
6317
6104
  setCurrentUser,
6318
- setEmailDomains,
6319
6105
  setEnableClustering,
6320
6106
  setEnableDuplicateIssues,
6321
6107
  setEnablePlacementMode,
@@ -6326,7 +6112,6 @@ export {
6326
6112
  setLoggedIn,
6327
6113
  setMapStyle,
6328
6114
  setOrganizationAccesses,
6329
- setOrganizationUsers,
6330
6115
  setOrganizations,
6331
6116
  setProfilePicture,
6332
6117
  setProjectAccesses,