@overmap-ai/core 1.0.34 → 1.0.35-projects-licensing.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -626,15 +626,15 @@ const wrapMigration = (migrator) => (state) => {
626
626
  };
627
627
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
628
628
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
629
- const initialState$l = {
629
+ const initialState$m = {
630
630
  accessToken: "",
631
631
  refreshToken: "",
632
632
  isLoggedIn: false
633
633
  };
634
634
  const authSlice = createSlice({
635
635
  name: "auth",
636
- initialState: initialState$l,
637
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
636
+ initialState: initialState$m,
637
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
638
638
  reducers: {
639
639
  setTokens: (state, action) => {
640
640
  state.accessToken = action.payload.accessToken;
@@ -1338,7 +1338,7 @@ const getLocalRelativeDateString = memoize((date, min, max) => {
1338
1338
  return getLocalDateString(date);
1339
1339
  return relative.format(days, "days");
1340
1340
  });
1341
- const initialState$k = {
1341
+ const initialState$l = {
1342
1342
  categories: {},
1343
1343
  usedCategoryColors: [],
1344
1344
  categoryVisibility: {
@@ -1348,8 +1348,8 @@ const initialState$k = {
1348
1348
  };
1349
1349
  const categorySlice = createSlice({
1350
1350
  name: "categories",
1351
- initialState: initialState$k,
1352
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1351
+ initialState: initialState$l,
1352
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1353
1353
  reducers: {
1354
1354
  setCategories: (state, action) => {
1355
1355
  if (!Array.isArray(action.payload))
@@ -1482,13 +1482,13 @@ const selectHiddenCategoryCount = (state) => {
1482
1482
  return hiddenCategoryCount;
1483
1483
  };
1484
1484
  const categoryReducer = categorySlice.reducer;
1485
- const initialState$j = {
1485
+ const initialState$k = {
1486
1486
  components: {}
1487
1487
  };
1488
1488
  const componentSlice = createSlice({
1489
1489
  name: "components",
1490
- initialState: initialState$j,
1491
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1490
+ initialState: initialState$k,
1491
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1492
1492
  reducers: {
1493
1493
  addComponent: (state, action) => {
1494
1494
  state.components[action.payload.offline_id] = action.payload;
@@ -1600,13 +1600,13 @@ const {
1600
1600
  removeAllComponentsOfType
1601
1601
  } = componentSlice.actions;
1602
1602
  const componentReducer = componentSlice.reducer;
1603
- const initialState$i = {
1603
+ const initialState$j = {
1604
1604
  completionsByComponentId: {}
1605
1605
  };
1606
1606
  const componentStageCompletionSlice = createSlice({
1607
1607
  name: "componentStageCompletions",
1608
- initialState: initialState$i,
1609
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1608
+ initialState: initialState$j,
1609
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1610
1610
  reducers: {
1611
1611
  addStageCompletion: (state, action) => {
1612
1612
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1657,13 +1657,13 @@ const selectCompletedStageIdsForComponent = (component) => (state) => {
1657
1657
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1658
1658
  };
1659
1659
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1660
- const initialState$h = {
1660
+ const initialState$i = {
1661
1661
  stages: {}
1662
1662
  };
1663
1663
  const componentStageSlice = createSlice({
1664
1664
  name: "componentStages",
1665
- initialState: initialState$h,
1666
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1665
+ initialState: initialState$i,
1666
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1667
1667
  reducers: {
1668
1668
  addStages: (state, action) => {
1669
1669
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1723,14 +1723,14 @@ const selectStagesFromStageIds = restructureCreateSelectorWithArgs(
1723
1723
  );
1724
1724
  const { addStages, updateStages, removeStages } = componentStageSlice.actions;
1725
1725
  const componentStageReducer = componentStageSlice.reducer;
1726
- const initialState$g = {
1726
+ const initialState$h = {
1727
1727
  componentTypes: {},
1728
1728
  hiddenComponentTypeIds: {}
1729
1729
  };
1730
1730
  const componentTypeSlice = createSlice({
1731
1731
  name: "componentTypes",
1732
- initialState: initialState$g,
1733
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1732
+ initialState: initialState$h,
1733
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1734
1734
  reducers: {
1735
1735
  addComponentType: (state, action) => {
1736
1736
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1789,13 +1789,13 @@ const selectComponentTypesByName = restructureCreateSelectorWithArgs(
1789
1789
  const selectHiddenComponentTypeIds = (state) => state.componentTypeReducer.hiddenComponentTypeIds;
1790
1790
  const { addComponentType, setComponentTypes, toggleComponentTypeVisibility, deleteComponentType } = componentTypeSlice.actions;
1791
1791
  const componentTypeReducer = componentTypeSlice.reducer;
1792
- const initialState$f = {
1792
+ const initialState$g = {
1793
1793
  workspaces: {},
1794
1794
  activeWorkspaceId: null
1795
1795
  };
1796
1796
  const workspaceSlice = createSlice({
1797
1797
  name: "workspace",
1798
- initialState: initialState$f,
1798
+ initialState: initialState$g,
1799
1799
  // The `reducers` field lets us define reducers and generate associated actions
1800
1800
  reducers: {
1801
1801
  setWorkspaces: (state, action) => {
@@ -1852,7 +1852,7 @@ const selectPermittedWorkspaceIds = createSelector(
1852
1852
  );
1853
1853
  const workspaceReducer = workspaceSlice.reducer;
1854
1854
  const maxRecentIssues = 10;
1855
- const initialState$e = {
1855
+ const initialState$f = {
1856
1856
  issues: {},
1857
1857
  attachments: {},
1858
1858
  comments: {},
@@ -1864,9 +1864,9 @@ const initialState$e = {
1864
1864
  };
1865
1865
  const issueSlice = createSlice({
1866
1866
  name: "issues",
1867
- initialState: initialState$e,
1867
+ initialState: initialState$f,
1868
1868
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1869
- Object.assign(state, initialState$e);
1869
+ Object.assign(state, initialState$f);
1870
1870
  }),
1871
1871
  reducers: {
1872
1872
  setIssues: (state, action) => {
@@ -2197,15 +2197,15 @@ const selectRecentIssuesAsSearchResults = createSelector(
2197
2197
  }
2198
2198
  );
2199
2199
  const issueReducer = issueSlice.reducer;
2200
- const initialState$d = {
2200
+ const initialState$e = {
2201
2201
  s3Urls: {}
2202
2202
  };
2203
2203
  const msPerHour = 1e3 * 60 * 60;
2204
2204
  const msPerWeek = msPerHour * 24 * 7;
2205
2205
  const fileSlice = createSlice({
2206
2206
  name: "file",
2207
- initialState: initialState$d,
2208
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2207
+ initialState: initialState$e,
2208
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2209
2209
  reducers: {
2210
2210
  setUploadUrl: (state, action) => {
2211
2211
  const { url, fields, sha1 } = action.payload;
@@ -2232,7 +2232,7 @@ const selectUploadUrl = (sha1) => (state) => {
2232
2232
  return url;
2233
2233
  };
2234
2234
  const fileReducer = fileSlice.reducer;
2235
- const initialState$c = {
2235
+ const initialState$d = {
2236
2236
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2237
2237
  mapStyle: MapStyle.SATELLITE,
2238
2238
  showTooltips: false,
@@ -2240,8 +2240,8 @@ const initialState$c = {
2240
2240
  };
2241
2241
  const mapSlice = createSlice({
2242
2242
  name: "map",
2243
- initialState: initialState$c,
2244
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2243
+ initialState: initialState$d,
2244
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2245
2245
  reducers: {
2246
2246
  setMapStyle: (state, action) => {
2247
2247
  state.mapStyle = action.payload;
@@ -2283,7 +2283,11 @@ var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
2283
2283
  VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
2284
2284
  return VerificationCodeType2;
2285
2285
  })(VerificationCodeType || {});
2286
- const initialState$b = {
2286
+ var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
2287
+ LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
2288
+ return LicenseLevel2;
2289
+ })(LicenseLevel || {});
2290
+ const initialState$c = {
2287
2291
  users: {},
2288
2292
  currentUser: {
2289
2293
  id: 0,
@@ -2294,8 +2298,8 @@ const initialState$b = {
2294
2298
  };
2295
2299
  const userSlice = createSlice({
2296
2300
  name: "users",
2297
- initialState: initialState$b,
2298
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2301
+ initialState: initialState$c,
2302
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2299
2303
  reducers: {
2300
2304
  setUsers: (state, action) => {
2301
2305
  const usersMapping = {};
@@ -2357,13 +2361,13 @@ const selectUser = (userId) => (state) => {
2357
2361
  const selectUsersAsMapping = (state) => state.userReducer.users;
2358
2362
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2359
2363
  const userReducer = userSlice.reducer;
2360
- const initialState$a = {
2364
+ const initialState$b = {
2361
2365
  organizationAccesses: {}
2362
2366
  };
2363
2367
  const organizationAccessSlice = createSlice({
2364
2368
  name: "organizationAccess",
2365
- initialState: initialState$a,
2366
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2369
+ initialState: initialState$b,
2370
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2367
2371
  reducers: {
2368
2372
  setOrganizationAccesses: (state, action) => {
2369
2373
  if (!Array.isArray(action.payload))
@@ -2426,151 +2430,13 @@ const selectOrganizationAccessUserMapping = (state) => {
2426
2430
  return organizationAccesses;
2427
2431
  };
2428
2432
  const organizationAccessReducer = organizationAccessSlice.reducer;
2429
- const initialState$9 = {
2430
- organizations: {},
2431
- activeOrganizationId: null
2432
- };
2433
- const organizationSlice = createSlice({
2434
- name: "organizations",
2435
- initialState: initialState$9,
2436
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2437
- reducers: {
2438
- setOrganizations: (state, action) => {
2439
- for (const org of action.payload) {
2440
- state.organizations[org.id] = org;
2441
- }
2442
- },
2443
- updateActiveOrganization: (state, action) => {
2444
- if (!state.activeOrganizationId) {
2445
- throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2446
- }
2447
- if (state.activeOrganizationId !== action.payload.id) {
2448
- throw new Error("Tried updating active organization with different organization");
2449
- }
2450
- state.organizations[state.activeOrganizationId] = action.payload;
2451
- },
2452
- setActiveOrganizationId: (state, action) => {
2453
- state.activeOrganizationId = action.payload;
2454
- }
2455
- }
2456
- });
2457
- const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2458
- const selectActiveOrganizationId = (state) => {
2459
- return state.organizationReducer.activeOrganizationId;
2460
- };
2461
- const selectOrganizations = (state) => {
2462
- return Object.values(state.organizationReducer.organizations);
2463
- };
2464
- const selectOrganizationsWithAccess = createSelector(
2465
- [selectOrganizations],
2466
- (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2467
- );
2468
- const selectActiveOrganization = (state) => {
2469
- const id = selectActiveOrganizationId(state);
2470
- if (!id) {
2471
- return null;
2472
- }
2473
- const organization = state.organizationReducer.organizations[id];
2474
- if (!organization) {
2475
- return null;
2476
- }
2477
- return organization;
2478
- };
2479
- const selectOrganizationUsersIds = createSelector(
2480
- [selectOrganizationAccesses],
2481
- (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2482
- );
2483
- const selectOrganizationUsersAsMapping = createSelector(
2484
- [selectOrganizationUsersIds, selectUsersAsMapping],
2485
- (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2486
- );
2487
- const selectSortedOrganizationUsers = createSelector(
2488
- [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2489
- (currentUser, userMapping, organizationAccessMapping) => {
2490
- return Object.values(userMapping).sort((userA, userB) => {
2491
- if (userA.id === currentUser.id) {
2492
- return -1;
2493
- } else if (userB.id === currentUser.id) {
2494
- return 1;
2495
- }
2496
- const organizationAccessesA = organizationAccessMapping[userA.id];
2497
- const organizationAccessesB = organizationAccessMapping[userB.id];
2498
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2499
- return userA.username.localeCompare(userB.username);
2500
- }
2501
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2502
- return -1;
2503
- }
2504
- return 1;
2505
- });
2506
- }
2507
- );
2508
- const selectOrganization = (id) => (state) => {
2509
- return state.organizationReducer.organizations[id];
2510
- };
2511
- const organizationReducer = organizationSlice.reducer;
2512
- const createOfflineAction = (request2, baseUrl) => {
2513
- const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: v4() };
2514
- return {
2515
- payload: requestWithUuid,
2516
- type: "",
2517
- meta: {
2518
- offline: {
2519
- effect: {
2520
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2521
- request: requestWithUuid,
2522
- BASE_URL: baseUrl
2523
- }
2524
- }
2525
- }
2526
- };
2527
- };
2528
- const initialState$8 = {
2529
- deletedRequests: [],
2530
- latestRetryTime: 0
2531
- };
2532
- const outboxSlice = createSlice({
2533
- name: "outbox",
2534
- initialState: initialState$8,
2535
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2536
- reducers: {
2537
- // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2538
- // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
2539
- // Then this reducer enqueueRequest() is responsible for adding the actual request data to the outbox
2540
- enqueueRequest: {
2541
- reducer: (state, _action) => {
2542
- return state;
2543
- },
2544
- prepare: (payload) => {
2545
- console.debug("Preparing to enqueue request", payload);
2546
- const { BASE_URL, ...rest } = payload;
2547
- return createOfflineAction(rest, BASE_URL);
2548
- }
2549
- },
2550
- markForDeletion(state, action) {
2551
- state.deletedRequests.push(action.payload);
2552
- },
2553
- markAsDeleted(state, action) {
2554
- const index2 = state.deletedRequests.indexOf(action.payload);
2555
- if (index2 !== -1)
2556
- state.deletedRequests.splice(index2, 1);
2557
- },
2558
- _setLatestRetryTime: (state, action) => {
2559
- state.latestRetryTime = action.payload;
2560
- }
2561
- }
2562
- });
2563
- const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2564
- const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2565
- const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2566
- const outboxReducer = outboxSlice.reducer;
2567
- const initialState$7 = {
2433
+ const initialState$a = {
2568
2434
  projectAccesses: {}
2569
2435
  };
2570
2436
  const projectAccessSlice = createSlice({
2571
2437
  name: "projectAccess",
2572
- initialState: initialState$7,
2573
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2438
+ initialState: initialState$a,
2439
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2574
2440
  reducers: {
2575
2441
  setProjectAccesses: (state, action) => {
2576
2442
  if (!Array.isArray(action.payload))
@@ -2638,7 +2504,7 @@ const selectProjectAccessUserMapping = (state) => {
2638
2504
  return projectAccesses;
2639
2505
  };
2640
2506
  const projectAccessReducer = projectAccessSlice.reducer;
2641
- const initialState$6 = {
2507
+ const initialState$9 = {
2642
2508
  projects: {},
2643
2509
  activeProjectId: null,
2644
2510
  recentProjectIds: [],
@@ -2647,7 +2513,7 @@ const initialState$6 = {
2647
2513
  };
2648
2514
  const projectSlice = createSlice({
2649
2515
  name: "projects",
2650
- initialState: initialState$6,
2516
+ initialState: initialState$9,
2651
2517
  reducers: {
2652
2518
  setProjects: (state, action) => {
2653
2519
  const projectsMap = {};
@@ -2767,6 +2633,234 @@ const selectSortedProjectUsers = createSelector(
2767
2633
  });
2768
2634
  }
2769
2635
  );
2636
+ const initialState$8 = {
2637
+ licenses: {}
2638
+ };
2639
+ const licenseSlice = createSlice({
2640
+ name: "license",
2641
+ initialState: initialState$8,
2642
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2643
+ reducers: {
2644
+ setLicenses: (state, action) => {
2645
+ if (!Array.isArray(action.payload))
2646
+ throw new Error("Expected an array of License");
2647
+ if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2648
+ throw new Error("Tried to use setLicenses reducer with duplicate ID's");
2649
+ }
2650
+ const licenses = {};
2651
+ for (const license of action.payload) {
2652
+ licenses[license.offline_id] = license;
2653
+ }
2654
+ state.licenses = licenses;
2655
+ },
2656
+ resumeLicense: (state, action) => {
2657
+ if (!(action.payload in state.licenses)) {
2658
+ throw new Error("Tried to resume license that does not exist.");
2659
+ }
2660
+ state.licenses[action.payload].is_paused = false;
2661
+ },
2662
+ pauseLicense: (state, action) => {
2663
+ if (!(action.payload in state.licenses)) {
2664
+ throw new Error("Tried to pause license that does not exist.");
2665
+ }
2666
+ state.licenses[action.payload].is_paused = true;
2667
+ },
2668
+ cancelLicense: (state, action) => {
2669
+ if (!(action.payload in state.licenses)) {
2670
+ throw new Error("Tried to cancel license that does not exist.");
2671
+ }
2672
+ state.licenses[action.payload].is_cancelled = true;
2673
+ }
2674
+ }
2675
+ });
2676
+ const { setLicenses, pauseLicense, resumeLicense, cancelLicense } = licenseSlice.actions;
2677
+ const selectLicenses = (state) => {
2678
+ return state.licenseReducer.licenses;
2679
+ };
2680
+ const selectLicense = (licenseId) => (state) => state.licenseReducer.licenses[licenseId];
2681
+ const selectActiveLicense = createSelector(
2682
+ [selectLicenses, selectActiveProjectId],
2683
+ (licenses, activeProjectId) => {
2684
+ const activeLicense = Object.values(licenses).find((license) => license.project === activeProjectId);
2685
+ return activeLicense ?? null;
2686
+ }
2687
+ );
2688
+ const selectActiveStatusLicenses = createSelector(
2689
+ [selectLicenses],
2690
+ (licenses) => Object.values(licenses).filter((license) => license.is_active)
2691
+ );
2692
+ const selectLicencesMapping = createSelector(
2693
+ [selectLicenses],
2694
+ (licenses) => Object.values(licenses).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2695
+ );
2696
+ const selectSortedLicenses = createSelector(
2697
+ [selectActiveLicense, selectLicenses, selectProjects],
2698
+ (activeLicense, licenses, projects) => {
2699
+ return Object.values(licenses).sort((licenseA, licenseB) => {
2700
+ if (activeLicense) {
2701
+ if (activeLicense.offline_id === licenseA.offline_id) {
2702
+ return -1;
2703
+ } else if (activeLicense.offline_id === licenseB.offline_id) {
2704
+ return 1;
2705
+ }
2706
+ }
2707
+ const projectIds = Object.keys(projects);
2708
+ if (!licenseA.project || !(licenseA.project in projectIds)) {
2709
+ return 1;
2710
+ } else if (!licenseB.project || !(licenseB.project in projectIds)) {
2711
+ return -1;
2712
+ }
2713
+ return projects[licenseA.project].name.toLowerCase().localeCompare(
2714
+ projects[licenseB.project].name.toLowerCase(),
2715
+ void 0,
2716
+ { numeric: true }
2717
+ );
2718
+ });
2719
+ }
2720
+ );
2721
+ const licenseReducer = licenseSlice.reducer;
2722
+ const initialState$7 = {
2723
+ organizations: {},
2724
+ activeOrganizationId: null
2725
+ };
2726
+ const organizationSlice = createSlice({
2727
+ name: "organizations",
2728
+ initialState: initialState$7,
2729
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2730
+ reducers: {
2731
+ setOrganizations: (state, action) => {
2732
+ for (const org of action.payload) {
2733
+ state.organizations[org.id] = org;
2734
+ }
2735
+ },
2736
+ updateActiveOrganization: (state, action) => {
2737
+ if (!state.activeOrganizationId) {
2738
+ throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2739
+ }
2740
+ if (state.activeOrganizationId !== action.payload.id) {
2741
+ throw new Error("Tried updating active organization with different organization");
2742
+ }
2743
+ state.organizations[state.activeOrganizationId] = action.payload;
2744
+ },
2745
+ setActiveOrganizationId: (state, action) => {
2746
+ state.activeOrganizationId = action.payload;
2747
+ }
2748
+ }
2749
+ });
2750
+ const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2751
+ const selectActiveOrganizationId = (state) => {
2752
+ return state.organizationReducer.activeOrganizationId;
2753
+ };
2754
+ const selectOrganizations = (state) => {
2755
+ return Object.values(state.organizationReducer.organizations);
2756
+ };
2757
+ const selectOrganizationsWithAccess = createSelector(
2758
+ [selectOrganizations],
2759
+ (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2760
+ );
2761
+ const selectActiveOrganization = (state) => {
2762
+ const id = selectActiveOrganizationId(state);
2763
+ if (!id) {
2764
+ return null;
2765
+ }
2766
+ const organization = state.organizationReducer.organizations[id];
2767
+ if (!organization) {
2768
+ return null;
2769
+ }
2770
+ return organization;
2771
+ };
2772
+ const selectOrganizationUsersIds = createSelector(
2773
+ [selectOrganizationAccesses],
2774
+ (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2775
+ );
2776
+ const selectOrganizationUsersAsMapping = createSelector(
2777
+ [selectOrganizationUsersIds, selectUsersAsMapping],
2778
+ (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2779
+ );
2780
+ const selectSortedOrganizationUsers = createSelector(
2781
+ [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2782
+ (currentUser, userMapping, organizationAccessMapping) => {
2783
+ return Object.values(userMapping).sort((userA, userB) => {
2784
+ if (userA.id === currentUser.id) {
2785
+ return -1;
2786
+ } else if (userB.id === currentUser.id) {
2787
+ return 1;
2788
+ }
2789
+ const organizationAccessesA = organizationAccessMapping[userA.id];
2790
+ const organizationAccessesB = organizationAccessMapping[userB.id];
2791
+ if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2792
+ return userA.username.localeCompare(userB.username);
2793
+ }
2794
+ if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2795
+ return -1;
2796
+ }
2797
+ return 1;
2798
+ });
2799
+ }
2800
+ );
2801
+ const selectActiveOrganizationLicenses = createSelector(
2802
+ [selectLicenses, selectActiveOrganizationId],
2803
+ (licenses, activeOrganizationId) => Object.values(licenses).filter((license) => license.organization_owner === activeOrganizationId)
2804
+ );
2805
+ const selectOrganization = (id) => (state) => {
2806
+ return state.organizationReducer.organizations[id];
2807
+ };
2808
+ const organizationReducer = organizationSlice.reducer;
2809
+ const createOfflineAction = (request2, baseUrl) => {
2810
+ const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: v4() };
2811
+ return {
2812
+ payload: requestWithUuid,
2813
+ type: "",
2814
+ meta: {
2815
+ offline: {
2816
+ effect: {
2817
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2818
+ request: requestWithUuid,
2819
+ BASE_URL: baseUrl
2820
+ }
2821
+ }
2822
+ }
2823
+ };
2824
+ };
2825
+ const initialState$6 = {
2826
+ deletedRequests: [],
2827
+ latestRetryTime: 0
2828
+ };
2829
+ const outboxSlice = createSlice({
2830
+ name: "outbox",
2831
+ initialState: initialState$6,
2832
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2833
+ reducers: {
2834
+ // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2835
+ // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
2836
+ // Then this reducer enqueueRequest() is responsible for adding the actual request data to the outbox
2837
+ enqueueRequest: {
2838
+ reducer: (state, _action) => {
2839
+ return state;
2840
+ },
2841
+ prepare: (payload) => {
2842
+ console.debug("Preparing to enqueue request", payload);
2843
+ const { BASE_URL, ...rest } = payload;
2844
+ return createOfflineAction(rest, BASE_URL);
2845
+ }
2846
+ },
2847
+ markForDeletion(state, action) {
2848
+ state.deletedRequests.push(action.payload);
2849
+ },
2850
+ markAsDeleted(state, action) {
2851
+ const index2 = state.deletedRequests.indexOf(action.payload);
2852
+ if (index2 !== -1)
2853
+ state.deletedRequests.splice(index2, 1);
2854
+ },
2855
+ _setLatestRetryTime: (state, action) => {
2856
+ state.latestRetryTime = action.payload;
2857
+ }
2858
+ }
2859
+ });
2860
+ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2861
+ const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2862
+ const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2863
+ const outboxReducer = outboxSlice.reducer;
2770
2864
  const initialState$5 = {
2771
2865
  projectFiles: {},
2772
2866
  activeProjectFileId: null,
@@ -3304,7 +3398,8 @@ const overmapReducers = {
3304
3398
  userFormReducer,
3305
3399
  userReducer,
3306
3400
  workspaceReducer,
3307
- emailDomainsReducer
3401
+ emailDomainsReducer,
3402
+ licenseReducer
3308
3403
  };
3309
3404
  const overmapReducer = combineReducers(overmapReducers);
3310
3405
  const resetStore = "RESET";
@@ -4916,6 +5011,7 @@ class MainService extends BaseApiService {
4916
5011
  }
4917
5012
  store.dispatch(setCurrentUser(data.user));
4918
5013
  store.dispatch(addUsers(data.project_owners));
5014
+ store.dispatch(setLicenses(data.licenses));
4919
5015
  const organizationsData = data.organizations;
4920
5016
  store.dispatch(setOrganizations(organizationsData));
4921
5017
  const validProjects = projects.filter((project) => !project.invited);
@@ -6037,6 +6133,50 @@ class OrganizationService extends BaseApiService {
6037
6133
  });
6038
6134
  }
6039
6135
  }
6136
+ class LicenseService extends BaseApiService {
6137
+ async pauseLicense(license) {
6138
+ const promise = this.enqueueRequest({
6139
+ description: "Pause license",
6140
+ method: HttpMethod.DELETE,
6141
+ url: `/billing/${license.offline_id}/suspend/`,
6142
+ isAuthNeeded: true,
6143
+ blockers: [license.organization_owner ? license.organization_owner.toString() : ""],
6144
+ blocks: []
6145
+ });
6146
+ return promise.then((result) => {
6147
+ this.client.store.dispatch(pauseLicense(license.offline_id));
6148
+ return result;
6149
+ });
6150
+ }
6151
+ async resumeLicense(license) {
6152
+ const promise = this.enqueueRequest({
6153
+ description: "Resume license",
6154
+ method: HttpMethod.PATCH,
6155
+ url: `/billing/${license.offline_id}/suspend/`,
6156
+ isAuthNeeded: true,
6157
+ blockers: [license.organization_owner ? license.organization_owner.toString() : ""],
6158
+ blocks: []
6159
+ });
6160
+ return promise.then((result) => {
6161
+ this.client.store.dispatch(resumeLicense(license.offline_id));
6162
+ return result;
6163
+ });
6164
+ }
6165
+ async cancelLicense(license) {
6166
+ const promise = this.enqueueRequest({
6167
+ description: "Cancel license",
6168
+ method: HttpMethod.DELETE,
6169
+ url: `/billing/${license.offline_id}/`,
6170
+ isAuthNeeded: true,
6171
+ blockers: [license.organization_owner ? license.organization_owner.toString() : ""],
6172
+ blocks: []
6173
+ });
6174
+ return promise.then((result) => {
6175
+ this.client.store.dispatch(cancelLicense(license.offline_id));
6176
+ return result;
6177
+ });
6178
+ }
6179
+ }
6040
6180
  class OvermapSDK {
6041
6181
  constructor(apiUrl, store) {
6042
6182
  __publicField(this, "API_URL");
@@ -6062,6 +6202,7 @@ class OvermapSDK {
6062
6202
  __publicField(this, "projectFiles", new ProjectFileService(this));
6063
6203
  __publicField(this, "emailVerification", new EmailVerificationService(this));
6064
6204
  __publicField(this, "emailDomains", new EmailDomainsService(this));
6205
+ __publicField(this, "licenses", new LicenseService(this));
6065
6206
  this.API_URL = apiUrl;
6066
6207
  this.store = store;
6067
6208
  }
@@ -11250,6 +11391,8 @@ export {
11250
11391
  IssuePriority,
11251
11392
  IssueService,
11252
11393
  IssueStatus,
11394
+ LicenseLevel,
11395
+ LicenseService,
11253
11396
  MainService,
11254
11397
  MapStyle,
11255
11398
  MultiSelectField,
@@ -11321,6 +11464,7 @@ export {
11321
11464
  authSlice,
11322
11465
  blobToBase64,
11323
11466
  boundsContainPoint,
11467
+ cancelLicense,
11324
11468
  categoryReducer,
11325
11469
  categorySlice,
11326
11470
  classNames$1 as classNames,
@@ -11395,6 +11539,8 @@ export {
11395
11539
  issueReducer,
11396
11540
  issueSlice,
11397
11541
  issueToSearchResult,
11542
+ licenseReducer,
11543
+ licenseSlice,
11398
11544
  literalToCoordinates,
11399
11545
  logOnlyOnce,
11400
11546
  makeClient,
@@ -11421,6 +11567,7 @@ export {
11421
11567
  overmapReducer,
11422
11568
  overmapReducers,
11423
11569
  patchCategory,
11570
+ pauseLicense,
11424
11571
  performRequest,
11425
11572
  primaryColor,
11426
11573
  projectAccessReducer,
@@ -11456,18 +11603,22 @@ export {
11456
11603
  resetRecentIssues,
11457
11604
  resetStore,
11458
11605
  restructureCreateSelectorWithArgs,
11606
+ resumeLicense,
11459
11607
  rootReducer,
11460
11608
  saveActiveProjectFileBounds,
11461
11609
  searchIssues,
11462
11610
  selectAccessToken,
11463
11611
  selectActiveIssueId,
11612
+ selectActiveLicense,
11464
11613
  selectActiveOrganization,
11465
11614
  selectActiveOrganizationAccess,
11466
11615
  selectActiveOrganizationId,
11616
+ selectActiveOrganizationLicenses,
11467
11617
  selectActiveProject,
11468
11618
  selectActiveProjectAccess,
11469
11619
  selectActiveProjectFileId,
11470
11620
  selectActiveProjectId,
11621
+ selectActiveStatusLicenses,
11471
11622
  selectActiveWorkspace,
11472
11623
  selectActiveWorkspaceId,
11473
11624
  selectAllAttachments,
@@ -11521,6 +11672,9 @@ export {
11521
11672
  selectLatestFormRevision,
11522
11673
  selectLatestRetryTime,
11523
11674
  selectLatestRevisionByFormId,
11675
+ selectLicencesMapping,
11676
+ selectLicense,
11677
+ selectLicenses,
11524
11678
  selectMainWorkspace,
11525
11679
  selectMapStyle,
11526
11680
  selectNumberOfComponentTypesMatchingCaseInsensitiveName,
@@ -11554,6 +11708,7 @@ export {
11554
11708
  selectRevisionsForForm,
11555
11709
  selectShowTooltips,
11556
11710
  selectSortedEmailDomains,
11711
+ selectSortedLicenses,
11557
11712
  selectSortedOrganizationUsers,
11558
11713
  selectSortedProjectUsers,
11559
11714
  selectSortedProjects,
@@ -11598,6 +11753,7 @@ export {
11598
11753
  setIsImportingProjectFile,
11599
11754
  setIssueComments,
11600
11755
  setIssues,
11756
+ setLicenses,
11601
11757
  setLoggedIn,
11602
11758
  setMapStyle,
11603
11759
  setOrganizationAccesses,