@overmap-ai/core 1.0.39 → 1.0.40-projects-licensing.0

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.
@@ -622,15 +622,15 @@ var __publicField = (obj, key, value) => {
622
622
  };
623
623
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
624
624
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
625
- const initialState$l = {
625
+ const initialState$m = {
626
626
  accessToken: "",
627
627
  refreshToken: "",
628
628
  isLoggedIn: false
629
629
  };
630
630
  const authSlice = toolkit.createSlice({
631
631
  name: "auth",
632
- initialState: initialState$l,
633
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
632
+ initialState: initialState$m,
633
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
634
634
  reducers: {
635
635
  setTokens: (state, action) => {
636
636
  state.accessToken = action.payload.accessToken;
@@ -1334,7 +1334,7 @@ var __publicField = (obj, key, value) => {
1334
1334
  return getLocalDateString(date);
1335
1335
  return relative.format(days, "days");
1336
1336
  });
1337
- const initialState$k = {
1337
+ const initialState$l = {
1338
1338
  categories: {},
1339
1339
  usedCategoryColors: [],
1340
1340
  categoryVisibility: {
@@ -1344,8 +1344,8 @@ var __publicField = (obj, key, value) => {
1344
1344
  };
1345
1345
  const categorySlice = toolkit.createSlice({
1346
1346
  name: "categories",
1347
- initialState: initialState$k,
1348
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1347
+ initialState: initialState$l,
1348
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1349
1349
  reducers: {
1350
1350
  setCategories: (state, action) => {
1351
1351
  if (!Array.isArray(action.payload))
@@ -1478,13 +1478,13 @@ var __publicField = (obj, key, value) => {
1478
1478
  return hiddenCategoryCount;
1479
1479
  };
1480
1480
  const categoryReducer = categorySlice.reducer;
1481
- const initialState$j = {
1481
+ const initialState$k = {
1482
1482
  components: {}
1483
1483
  };
1484
1484
  const componentSlice = toolkit.createSlice({
1485
1485
  name: "components",
1486
- initialState: initialState$j,
1487
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1486
+ initialState: initialState$k,
1487
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1488
1488
  reducers: {
1489
1489
  addComponent: (state, action) => {
1490
1490
  state.components[action.payload.offline_id] = action.payload;
@@ -1596,13 +1596,13 @@ var __publicField = (obj, key, value) => {
1596
1596
  removeAllComponentsOfType
1597
1597
  } = componentSlice.actions;
1598
1598
  const componentReducer = componentSlice.reducer;
1599
- const initialState$i = {
1599
+ const initialState$j = {
1600
1600
  completionsByComponentId: {}
1601
1601
  };
1602
1602
  const componentStageCompletionSlice = toolkit.createSlice({
1603
1603
  name: "componentStageCompletions",
1604
- initialState: initialState$i,
1605
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1604
+ initialState: initialState$j,
1605
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1606
1606
  reducers: {
1607
1607
  addStageCompletion: (state, action) => {
1608
1608
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1653,13 +1653,13 @@ var __publicField = (obj, key, value) => {
1653
1653
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1654
1654
  };
1655
1655
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1656
- const initialState$h = {
1656
+ const initialState$i = {
1657
1657
  stages: {}
1658
1658
  };
1659
1659
  const componentStageSlice = toolkit.createSlice({
1660
1660
  name: "componentStages",
1661
- initialState: initialState$h,
1662
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1661
+ initialState: initialState$i,
1662
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1663
1663
  reducers: {
1664
1664
  addStages: (state, action) => {
1665
1665
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1750,14 +1750,14 @@ var __publicField = (obj, key, value) => {
1750
1750
  );
1751
1751
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1752
1752
  const componentStageReducer = componentStageSlice.reducer;
1753
- const initialState$g = {
1753
+ const initialState$h = {
1754
1754
  componentTypes: {},
1755
1755
  hiddenComponentTypeIds: {}
1756
1756
  };
1757
1757
  const componentTypeSlice = toolkit.createSlice({
1758
1758
  name: "componentTypes",
1759
- initialState: initialState$g,
1760
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1759
+ initialState: initialState$h,
1760
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1761
1761
  reducers: {
1762
1762
  addComponentType: (state, action) => {
1763
1763
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1816,13 +1816,13 @@ var __publicField = (obj, key, value) => {
1816
1816
  const selectHiddenComponentTypeIds = (state) => state.componentTypeReducer.hiddenComponentTypeIds;
1817
1817
  const { addComponentType, setComponentTypes, toggleComponentTypeVisibility, deleteComponentType } = componentTypeSlice.actions;
1818
1818
  const componentTypeReducer = componentTypeSlice.reducer;
1819
- const initialState$f = {
1819
+ const initialState$g = {
1820
1820
  workspaces: {},
1821
1821
  activeWorkspaceId: null
1822
1822
  };
1823
1823
  const workspaceSlice = toolkit.createSlice({
1824
1824
  name: "workspace",
1825
- initialState: initialState$f,
1825
+ initialState: initialState$g,
1826
1826
  // The `reducers` field lets us define reducers and generate associated actions
1827
1827
  reducers: {
1828
1828
  setWorkspaces: (state, action) => {
@@ -1879,21 +1879,20 @@ var __publicField = (obj, key, value) => {
1879
1879
  );
1880
1880
  const workspaceReducer = workspaceSlice.reducer;
1881
1881
  const maxRecentIssues = 10;
1882
- const initialState$e = {
1882
+ const initialState$f = {
1883
1883
  issues: {},
1884
1884
  attachments: {},
1885
1885
  comments: {},
1886
1886
  visibleStatuses: [IssueStatus.BACKLOG, IssueStatus.SELECTED],
1887
- isFetchingInitialData: false,
1888
1887
  visibleUserIds: null,
1889
1888
  recentIssueIds: [],
1890
1889
  activeIssueId: null
1891
1890
  };
1892
1891
  const issueSlice = toolkit.createSlice({
1893
1892
  name: "issues",
1894
- initialState: initialState$e,
1893
+ initialState: initialState$f,
1895
1894
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1896
- Object.assign(state, initialState$e);
1895
+ Object.assign(state, initialState$f);
1897
1896
  }),
1898
1897
  reducers: {
1899
1898
  setIssues: (state, action) => {
@@ -1972,9 +1971,6 @@ var __publicField = (obj, key, value) => {
1972
1971
  setVisibleStatuses: (state, action) => {
1973
1972
  state.visibleStatuses = action.payload;
1974
1973
  },
1975
- setIsFetchingInitialData: (state, action) => {
1976
- state.isFetchingInitialData = action.payload;
1977
- },
1978
1974
  setVisibleUserIds: (state, action) => {
1979
1975
  state.visibleUserIds = [...new Set(action.payload)];
1980
1976
  },
@@ -2033,7 +2029,6 @@ var __publicField = (obj, key, value) => {
2033
2029
  resetRecentIssues,
2034
2030
  setActiveIssueId,
2035
2031
  setAttachments,
2036
- setIsFetchingInitialData,
2037
2032
  setIssueComments,
2038
2033
  setIssues,
2039
2034
  setVisibleStatuses,
@@ -2132,7 +2127,6 @@ var __publicField = (obj, key, value) => {
2132
2127
  return mapping[id];
2133
2128
  })
2134
2129
  );
2135
- const selectIsFetchingInitialData = (state) => state.issueReducer.isFetchingInitialData;
2136
2130
  const selectAllAttachments = toolkit.createSelector([selectIssueAttachmentMapping], (mapping) => Object.values(mapping));
2137
2131
  const searchIssues = restructureCreateSelectorWithArgs(
2138
2132
  toolkit.createSelector(
@@ -2224,15 +2218,15 @@ var __publicField = (obj, key, value) => {
2224
2218
  }
2225
2219
  );
2226
2220
  const issueReducer = issueSlice.reducer;
2227
- const initialState$d = {
2221
+ const initialState$e = {
2228
2222
  s3Urls: {}
2229
2223
  };
2230
2224
  const msPerHour = 1e3 * 60 * 60;
2231
2225
  const msPerWeek = msPerHour * 24 * 7;
2232
2226
  const fileSlice = toolkit.createSlice({
2233
2227
  name: "file",
2234
- initialState: initialState$d,
2235
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2228
+ initialState: initialState$e,
2229
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2236
2230
  reducers: {
2237
2231
  setUploadUrl: (state, action) => {
2238
2232
  const { url, fields, sha1 } = action.payload;
@@ -2259,7 +2253,7 @@ var __publicField = (obj, key, value) => {
2259
2253
  return url;
2260
2254
  };
2261
2255
  const fileReducer = fileSlice.reducer;
2262
- const initialState$c = {
2256
+ const initialState$d = {
2263
2257
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2264
2258
  mapStyle: MapStyle.SATELLITE,
2265
2259
  showTooltips: false,
@@ -2267,8 +2261,8 @@ var __publicField = (obj, key, value) => {
2267
2261
  };
2268
2262
  const mapSlice = toolkit.createSlice({
2269
2263
  name: "map",
2270
- initialState: initialState$c,
2271
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2264
+ initialState: initialState$d,
2265
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2272
2266
  reducers: {
2273
2267
  setMapStyle: (state, action) => {
2274
2268
  state.mapStyle = action.payload;
@@ -2310,7 +2304,23 @@ var __publicField = (obj, key, value) => {
2310
2304
  VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
2311
2305
  return VerificationCodeType2;
2312
2306
  })(VerificationCodeType || {});
2313
- const initialState$b = {
2307
+ var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
2308
+ PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
2309
+ PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
2310
+ return PaddleCheckoutEvent2;
2311
+ })(PaddleCheckoutEvent || {});
2312
+ var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
2313
+ LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
2314
+ return LicenseLevel2;
2315
+ })(LicenseLevel || {});
2316
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
2317
+ LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
2318
+ LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
2319
+ LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
2320
+ LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
2321
+ return LicenseStatus2;
2322
+ })(LicenseStatus || {});
2323
+ const initialState$c = {
2314
2324
  users: {},
2315
2325
  currentUser: {
2316
2326
  id: 0,
@@ -2321,8 +2331,8 @@ var __publicField = (obj, key, value) => {
2321
2331
  };
2322
2332
  const userSlice = toolkit.createSlice({
2323
2333
  name: "users",
2324
- initialState: initialState$b,
2325
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2334
+ initialState: initialState$c,
2335
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2326
2336
  reducers: {
2327
2337
  setUsers: (state, action) => {
2328
2338
  const usersMapping = {};
@@ -2384,13 +2394,13 @@ var __publicField = (obj, key, value) => {
2384
2394
  const selectUsersAsMapping = (state) => state.userReducer.users;
2385
2395
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2386
2396
  const userReducer = userSlice.reducer;
2387
- const initialState$a = {
2397
+ const initialState$b = {
2388
2398
  organizationAccesses: {}
2389
2399
  };
2390
2400
  const organizationAccessSlice = toolkit.createSlice({
2391
2401
  name: "organizationAccess",
2392
- initialState: initialState$a,
2393
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2402
+ initialState: initialState$b,
2403
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2394
2404
  reducers: {
2395
2405
  setOrganizationAccesses: (state, action) => {
2396
2406
  if (!Array.isArray(action.payload))
@@ -2453,151 +2463,64 @@ var __publicField = (obj, key, value) => {
2453
2463
  return organizationAccesses;
2454
2464
  };
2455
2465
  const organizationAccessReducer = organizationAccessSlice.reducer;
2456
- const initialState$9 = {
2457
- organizations: {},
2458
- activeOrganizationId: null
2466
+ const initialState$a = {
2467
+ licenses: {}
2459
2468
  };
2460
- const organizationSlice = toolkit.createSlice({
2461
- name: "organizations",
2462
- initialState: initialState$9,
2463
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2469
+ const licenseSlice = toolkit.createSlice({
2470
+ name: "license",
2471
+ initialState: initialState$a,
2472
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2464
2473
  reducers: {
2465
- setOrganizations: (state, action) => {
2466
- for (const org of action.payload) {
2467
- state.organizations[org.id] = org;
2474
+ setLicenses: (state, action) => {
2475
+ if (!Array.isArray(action.payload))
2476
+ throw new Error("Expected an array of Licenses");
2477
+ if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2478
+ throw new Error("Tried to use setLicenses reducer with duplicate ID's");
2468
2479
  }
2469
- },
2470
- updateActiveOrganization: (state, action) => {
2471
- if (!state.activeOrganizationId) {
2472
- throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2480
+ const licenses = {};
2481
+ for (const license of action.payload) {
2482
+ licenses[license.offline_id] = license;
2473
2483
  }
2474
- if (state.activeOrganizationId !== action.payload.id) {
2475
- throw new Error("Tried updating active organization with different organization");
2484
+ state.licenses = licenses;
2485
+ },
2486
+ addLicenses: (state, action) => {
2487
+ for (const license of action.payload) {
2488
+ state.licenses[license.offline_id] = license;
2476
2489
  }
2477
- state.organizations[state.activeOrganizationId] = action.payload;
2478
2490
  },
2479
- setActiveOrganizationId: (state, action) => {
2480
- state.activeOrganizationId = action.payload;
2491
+ updateLicense: (state, action) => {
2492
+ if (!(action.payload.offline_id in state.licenses)) {
2493
+ throw new Error("Tried to update license that does not exist.");
2494
+ }
2495
+ state.licenses[action.payload.offline_id] = action.payload;
2481
2496
  }
2482
2497
  }
2483
2498
  });
2484
- const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2485
- const selectActiveOrganizationId = (state) => {
2486
- return state.organizationReducer.activeOrganizationId;
2487
- };
2488
- const selectOrganizations = (state) => {
2489
- return Object.values(state.organizationReducer.organizations);
2490
- };
2491
- const selectOrganizationsWithAccess = toolkit.createSelector(
2492
- [selectOrganizations],
2493
- (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2494
- );
2495
- const selectActiveOrganization = (state) => {
2496
- const id = selectActiveOrganizationId(state);
2497
- if (!id) {
2498
- return null;
2499
- }
2500
- const organization = state.organizationReducer.organizations[id];
2501
- if (!organization) {
2502
- return null;
2503
- }
2504
- return organization;
2505
- };
2506
- const selectOrganizationUsersIds = toolkit.createSelector(
2507
- [selectOrganizationAccesses],
2508
- (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2499
+ const { setLicenses, addLicenses, updateLicense } = licenseSlice.actions;
2500
+ const selectLicenses = (state) => {
2501
+ return state.licenseReducer.licenses;
2502
+ };
2503
+ const selectLicense = (licenseId) => (state) => state.licenseReducer.licenses[licenseId];
2504
+ const selectActiveLicense = (state) => Object.values(state.licenseReducer.licenses).find(
2505
+ (license) => license.project === state.projectReducer.activeProjectId
2506
+ ) ?? null;
2507
+ const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.licenses).find((license) => license.project === projectId) ?? null;
2508
+ const selectActiveStatusLicenses = toolkit.createSelector(
2509
+ [selectLicenses],
2510
+ (licenses) => Object.values(licenses).filter((license) => license.is_active)
2509
2511
  );
2510
- const selectOrganizationUsersAsMapping = toolkit.createSelector(
2511
- [selectOrganizationUsersIds, selectUsersAsMapping],
2512
- (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2512
+ const selectLicensesForProjectsMapping = toolkit.createSelector(
2513
+ [selectLicenses],
2514
+ (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2513
2515
  );
2514
- const selectSortedOrganizationUsers = toolkit.createSelector(
2515
- [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2516
- (currentUser, userMapping, organizationAccessMapping) => {
2517
- return Object.values(userMapping).sort((userA, userB) => {
2518
- if (userA.id === currentUser.id) {
2519
- return -1;
2520
- } else if (userB.id === currentUser.id) {
2521
- return 1;
2522
- }
2523
- const organizationAccessesA = organizationAccessMapping[userA.id];
2524
- const organizationAccessesB = organizationAccessMapping[userB.id];
2525
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2526
- return userA.username.localeCompare(userB.username);
2527
- }
2528
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2529
- return -1;
2530
- }
2531
- return 1;
2532
- });
2533
- }
2534
- );
2535
- const selectOrganization = (id) => (state) => {
2536
- return state.organizationReducer.organizations[id];
2537
- };
2538
- const organizationReducer = organizationSlice.reducer;
2539
- const createOfflineAction = (request2, baseUrl) => {
2540
- const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: uuid.v4() };
2541
- return {
2542
- payload: requestWithUuid,
2543
- type: "",
2544
- meta: {
2545
- offline: {
2546
- effect: {
2547
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2548
- request: requestWithUuid,
2549
- BASE_URL: baseUrl
2550
- }
2551
- }
2552
- }
2553
- };
2554
- };
2555
- const initialState$8 = {
2556
- deletedRequests: [],
2557
- latestRetryTime: 0
2558
- };
2559
- const outboxSlice = toolkit.createSlice({
2560
- name: "outbox",
2561
- initialState: initialState$8,
2562
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2563
- reducers: {
2564
- // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2565
- // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
2566
- // Then this reducer enqueueRequest() is responsible for adding the actual request data to the outbox
2567
- enqueueRequest: {
2568
- reducer: (state, _action) => {
2569
- return state;
2570
- },
2571
- prepare: (payload) => {
2572
- console.debug("Preparing to enqueue request", payload);
2573
- const { BASE_URL, ...rest } = payload;
2574
- return createOfflineAction(rest, BASE_URL);
2575
- }
2576
- },
2577
- markForDeletion(state, action) {
2578
- state.deletedRequests.push(action.payload);
2579
- },
2580
- markAsDeleted(state, action) {
2581
- const index2 = state.deletedRequests.indexOf(action.payload);
2582
- if (index2 !== -1)
2583
- state.deletedRequests.splice(index2, 1);
2584
- },
2585
- _setLatestRetryTime: (state, action) => {
2586
- state.latestRetryTime = action.payload;
2587
- }
2588
- }
2589
- });
2590
- const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2591
- const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2592
- const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2593
- const outboxReducer = outboxSlice.reducer;
2594
- const initialState$7 = {
2516
+ const licenseReducer = licenseSlice.reducer;
2517
+ const initialState$9 = {
2595
2518
  projectAccesses: {}
2596
2519
  };
2597
2520
  const projectAccessSlice = toolkit.createSlice({
2598
2521
  name: "projectAccess",
2599
- initialState: initialState$7,
2600
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2522
+ initialState: initialState$9,
2523
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2601
2524
  reducers: {
2602
2525
  setProjectAccesses: (state, action) => {
2603
2526
  if (!Array.isArray(action.payload))
@@ -2665,7 +2588,7 @@ var __publicField = (obj, key, value) => {
2665
2588
  return projectAccesses;
2666
2589
  };
2667
2590
  const projectAccessReducer = projectAccessSlice.reducer;
2668
- const initialState$6 = {
2591
+ const initialState$8 = {
2669
2592
  projects: {},
2670
2593
  activeProjectId: null,
2671
2594
  recentProjectIds: [],
@@ -2674,7 +2597,7 @@ var __publicField = (obj, key, value) => {
2674
2597
  };
2675
2598
  const projectSlice = toolkit.createSlice({
2676
2599
  name: "projects",
2677
- initialState: initialState$6,
2600
+ initialState: initialState$8,
2678
2601
  reducers: {
2679
2602
  setProjects: (state, action) => {
2680
2603
  const projectsMap = {};
@@ -2720,6 +2643,27 @@ var __publicField = (obj, key, value) => {
2720
2643
  } else {
2721
2644
  throw new Error("Accept project invite: user is not in this project");
2722
2645
  }
2646
+ },
2647
+ addActiveProjectIssuesCount: (state, action) => {
2648
+ if (!state.activeProjectId || !(state.activeProjectId in state.projects)) {
2649
+ throw new Error("Update issues count: no active project");
2650
+ }
2651
+ if (!state.projects[state.activeProjectId].issues_count) {
2652
+ state.projects[state.activeProjectId].issues_count = action.payload;
2653
+ } else {
2654
+ state.projects[state.activeProjectId].issues_count += action.payload;
2655
+ }
2656
+ },
2657
+ addActiveProjectFormSubmissionsCount: (state, action) => {
2658
+ if (state.activeProjectId && state.activeProjectId in state.projects) {
2659
+ if (!state.projects[state.activeProjectId].form_submissions_count) {
2660
+ state.projects[state.activeProjectId].form_submissions_count = action.payload;
2661
+ } else {
2662
+ state.projects[state.activeProjectId].form_submissions_count += action.payload;
2663
+ }
2664
+ } else {
2665
+ throw new Error("Update form submissions count: no active project");
2666
+ }
2723
2667
  }
2724
2668
  }
2725
2669
  });
@@ -2730,7 +2674,9 @@ var __publicField = (obj, key, value) => {
2730
2674
  setActiveProjectId,
2731
2675
  setCreateProjectType,
2732
2676
  deleteProject,
2733
- acceptProjectInvite
2677
+ acceptProjectInvite,
2678
+ addActiveProjectIssuesCount,
2679
+ addActiveProjectFormSubmissionsCount
2734
2680
  } = projectSlice.actions;
2735
2681
  const selectProjects = (state) => state.projectReducer.projects;
2736
2682
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
@@ -2794,6 +2740,171 @@ var __publicField = (obj, key, value) => {
2794
2740
  });
2795
2741
  }
2796
2742
  );
2743
+ const initialState$7 = {
2744
+ organizations: {},
2745
+ activeOrganizationId: null
2746
+ };
2747
+ const organizationSlice = toolkit.createSlice({
2748
+ name: "organizations",
2749
+ initialState: initialState$7,
2750
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2751
+ reducers: {
2752
+ setOrganizations: (state, action) => {
2753
+ for (const org of action.payload) {
2754
+ state.organizations[org.id] = org;
2755
+ }
2756
+ },
2757
+ updateActiveOrganization: (state, action) => {
2758
+ if (!state.activeOrganizationId) {
2759
+ throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2760
+ }
2761
+ if (state.activeOrganizationId !== action.payload.id) {
2762
+ throw new Error("Tried updating active organization with different organization");
2763
+ }
2764
+ state.organizations[state.activeOrganizationId] = action.payload;
2765
+ },
2766
+ setActiveOrganizationId: (state, action) => {
2767
+ state.activeOrganizationId = action.payload;
2768
+ }
2769
+ }
2770
+ });
2771
+ const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2772
+ const selectActiveOrganizationId = (state) => {
2773
+ return state.organizationReducer.activeOrganizationId;
2774
+ };
2775
+ const selectOrganizations = (state) => {
2776
+ return Object.values(state.organizationReducer.organizations);
2777
+ };
2778
+ const selectOrganizationsMapping = (state) => {
2779
+ return state.organizationReducer.organizations;
2780
+ };
2781
+ const selectOrganizationsWithAccess = toolkit.createSelector(
2782
+ [selectOrganizations],
2783
+ (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2784
+ );
2785
+ const selectActiveOrganization = (state) => {
2786
+ const id = selectActiveOrganizationId(state);
2787
+ if (!id) {
2788
+ return null;
2789
+ }
2790
+ const organization = state.organizationReducer.organizations[id];
2791
+ if (!organization) {
2792
+ return null;
2793
+ }
2794
+ return organization;
2795
+ };
2796
+ const selectOrganizationUsersIds = toolkit.createSelector(
2797
+ [selectOrganizationAccesses],
2798
+ (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2799
+ );
2800
+ const selectActiveOrganizationProjects = toolkit.createSelector(
2801
+ [selectProjects, selectActiveOrganizationId],
2802
+ (projects, activeOrganizationId) => activeOrganizationId ? Object.values(projects).filter((project) => project.owner_organization === activeOrganizationId) : []
2803
+ );
2804
+ const selectActiveOrganizationLicenses = toolkit.createSelector(
2805
+ [selectActiveOrganizationId, selectLicenses],
2806
+ (activeOrganizationId, licenses) => !activeOrganizationId ? [] : Object.values(licenses).filter((license) => license.organization_owner === activeOrganizationId)
2807
+ );
2808
+ const selectSortedOrganizationLicenses = toolkit.createSelector(
2809
+ [selectActiveOrganizationLicenses, selectProjects],
2810
+ (licences, projects) => licences.sort((licenseA, licenseB) => {
2811
+ if (!licenseA.project) {
2812
+ return 1;
2813
+ }
2814
+ if (!licenseB.project) {
2815
+ return -1;
2816
+ }
2817
+ return projects[licenseA.project].name.toLowerCase().localeCompare(
2818
+ projects[licenseB.project].name.toLowerCase(),
2819
+ void 0,
2820
+ { numeric: true }
2821
+ );
2822
+ })
2823
+ );
2824
+ const selectOrganizationUsersAsMapping = toolkit.createSelector(
2825
+ [selectOrganizationUsersIds, selectUsersAsMapping],
2826
+ (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2827
+ );
2828
+ const selectSortedOrganizationUsers = toolkit.createSelector(
2829
+ [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2830
+ (currentUser, userMapping, organizationAccessMapping) => {
2831
+ return Object.values(userMapping).sort((userA, userB) => {
2832
+ if (userA.id === currentUser.id) {
2833
+ return -1;
2834
+ } else if (userB.id === currentUser.id) {
2835
+ return 1;
2836
+ }
2837
+ const organizationAccessesA = organizationAccessMapping[userA.id];
2838
+ const organizationAccessesB = organizationAccessMapping[userB.id];
2839
+ if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2840
+ return userA.username.localeCompare(userB.username);
2841
+ }
2842
+ if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2843
+ return -1;
2844
+ }
2845
+ return 1;
2846
+ });
2847
+ }
2848
+ );
2849
+ const selectOrganization = (id) => (state) => {
2850
+ return state.organizationReducer.organizations[id];
2851
+ };
2852
+ const organizationReducer = organizationSlice.reducer;
2853
+ const createOfflineAction = (request2, baseUrl) => {
2854
+ const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: uuid.v4() };
2855
+ return {
2856
+ payload: requestWithUuid,
2857
+ type: "",
2858
+ meta: {
2859
+ offline: {
2860
+ effect: {
2861
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2862
+ request: requestWithUuid,
2863
+ BASE_URL: baseUrl
2864
+ }
2865
+ }
2866
+ }
2867
+ };
2868
+ };
2869
+ const initialState$6 = {
2870
+ deletedRequests: [],
2871
+ latestRetryTime: 0
2872
+ };
2873
+ const outboxSlice = toolkit.createSlice({
2874
+ name: "outbox",
2875
+ initialState: initialState$6,
2876
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2877
+ reducers: {
2878
+ // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2879
+ // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
2880
+ // Then this reducer enqueueRequest() is responsible for adding the actual request data to the outbox
2881
+ enqueueRequest: {
2882
+ reducer: (state, _action) => {
2883
+ return state;
2884
+ },
2885
+ prepare: (payload) => {
2886
+ console.debug("Preparing to enqueue request", payload);
2887
+ const { BASE_URL, ...rest } = payload;
2888
+ return createOfflineAction(rest, BASE_URL);
2889
+ }
2890
+ },
2891
+ markForDeletion(state, action) {
2892
+ state.deletedRequests.push(action.payload);
2893
+ },
2894
+ markAsDeleted(state, action) {
2895
+ const index2 = state.deletedRequests.indexOf(action.payload);
2896
+ if (index2 !== -1)
2897
+ state.deletedRequests.splice(index2, 1);
2898
+ },
2899
+ _setLatestRetryTime: (state, action) => {
2900
+ state.latestRetryTime = action.payload;
2901
+ }
2902
+ }
2903
+ });
2904
+ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2905
+ const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2906
+ const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2907
+ const outboxReducer = outboxSlice.reducer;
2797
2908
  const initialState$5 = {
2798
2909
  projectFiles: {},
2799
2910
  activeProjectFileId: null,
@@ -2930,7 +3041,9 @@ var __publicField = (obj, key, value) => {
2930
3041
  Components: false,
2931
3042
  Experimental: false
2932
3043
  },
2933
- appearance: "dark"
3044
+ appearance: "dark",
3045
+ isFetchingInitialData: false,
3046
+ isLoading: false
2934
3047
  };
2935
3048
  const settingSlice = toolkit.createSlice({
2936
3049
  name: "settings",
@@ -2954,6 +3067,12 @@ var __publicField = (obj, key, value) => {
2954
3067
  },
2955
3068
  setAppearance: (state, action) => {
2956
3069
  state.appearance = action.payload;
3070
+ },
3071
+ setIsFetchingInitialData: (state, action) => {
3072
+ state.isFetchingInitialData = action.payload;
3073
+ },
3074
+ setIsLoading: (state, action) => {
3075
+ state.isLoading = action.payload;
2957
3076
  }
2958
3077
  }
2959
3078
  });
@@ -2962,7 +3081,9 @@ var __publicField = (obj, key, value) => {
2962
3081
  setEnablePlacementMode,
2963
3082
  setSectionExpanded,
2964
3083
  setEnableClustering,
2965
- setAppearance
3084
+ setAppearance,
3085
+ setIsFetchingInitialData,
3086
+ setIsLoading
2966
3087
  } = settingSlice.actions;
2967
3088
  const selectEnablePlacementMode = (state) => state.settingReducer.placementMode;
2968
3089
  const selectEnableDuplicateIssues = (state) => state.settingReducer.useIssueTemplate;
@@ -2971,6 +3092,8 @@ var __publicField = (obj, key, value) => {
2971
3092
  const selectEnableClustering = (state) => state.settingReducer.enableClustering;
2972
3093
  const selectAppearance = (state) => state.settingReducer.appearance;
2973
3094
  const settingReducer = settingSlice.reducer;
3095
+ const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3096
+ const selectIsLoading = (state) => state.settingReducer.isLoading;
2974
3097
  const LATEST_REVISION_CACHE = {};
2975
3098
  function considerCachingRevision(revision, formId2, preferPending = false) {
2976
3099
  var _a2;
@@ -3388,7 +3511,8 @@ var __publicField = (obj, key, value) => {
3388
3511
  userFormReducer,
3389
3512
  userReducer,
3390
3513
  workspaceReducer,
3391
- emailDomainsReducer
3514
+ emailDomainsReducer,
3515
+ licenseReducer
3392
3516
  };
3393
3517
  const overmapReducer = toolkit.combineReducers(overmapReducers);
3394
3518
  const resetStore = "RESET";
@@ -4875,6 +4999,7 @@ var __publicField = (obj, key, value) => {
4875
4999
  });
4876
5000
  store.dispatch(addIssue(issuePayload));
4877
5001
  store.dispatch(addToRecentIssues(issuePayload.offline_id));
5002
+ store.dispatch(addActiveProjectIssuesCount(1));
4878
5003
  const promise = this.enqueueRequest({
4879
5004
  description: "Create issue",
4880
5005
  method: HttpMethod.POST,
@@ -4884,6 +5009,7 @@ var __publicField = (obj, key, value) => {
4884
5009
  },
4885
5010
  payload: issuePayload,
4886
5011
  blockers: [
5012
+ "add-issue",
4887
5013
  ...issuePayload.index_workspace ? [issuePayload.index_workspace] : [],
4888
5014
  ...issuePayload.visible_in_workspaces
4889
5015
  ],
@@ -4901,6 +5027,7 @@ var __publicField = (obj, key, value) => {
4901
5027
  });
4902
5028
  }
4903
5029
  store.dispatch(removeIssue(issuePayload.offline_id));
5030
+ store.dispatch(addActiveProjectIssuesCount(-1));
4904
5031
  throw error2;
4905
5032
  });
4906
5033
  return [issuePayload, promise];
@@ -4939,16 +5066,18 @@ var __publicField = (obj, key, value) => {
4939
5066
  return [fullIssue, promise];
4940
5067
  }
4941
5068
  async remove(id) {
4942
- const state = this.client.store.getState();
5069
+ const { store } = this.client;
5070
+ const state = store.getState();
4943
5071
  const backup = state.issueReducer.issues[id];
4944
5072
  if (!backup) {
4945
5073
  throw new Error(`No issue with id ${id} found in the store`);
4946
5074
  }
4947
5075
  const attachments = Object.values(state.issueReducer.attachments).filter((a) => a.issue_id === id);
4948
5076
  const attachmentsOfIssue = selectPhotoAttachmentsOfIssue(id)(state);
4949
- this.client.store.dispatch(removeIssue(id));
5077
+ store.dispatch(removeIssue(id));
5078
+ store.dispatch(addActiveProjectIssuesCount(-1));
4950
5079
  if (attachmentsOfIssue) {
4951
- this.client.store.dispatch(removeAttachmentsOfIssue(id));
5080
+ store.dispatch(removeAttachmentsOfIssue(id));
4952
5081
  }
4953
5082
  try {
4954
5083
  return await this.enqueueRequest({
@@ -4959,8 +5088,9 @@ var __publicField = (obj, key, value) => {
4959
5088
  blocks: []
4960
5089
  });
4961
5090
  } catch (e) {
4962
- this.client.store.dispatch(addIssue(backup));
4963
- this.client.store.dispatch(addAttachments(attachments));
5091
+ store.dispatch(addIssue(backup));
5092
+ store.dispatch(addAttachments(attachments));
5093
+ store.dispatch(addActiveProjectIssuesCount(1));
4964
5094
  throw e;
4965
5095
  }
4966
5096
  }
@@ -5036,7 +5166,9 @@ var __publicField = (obj, key, value) => {
5036
5166
  owner_organization: projectData.organization_owner,
5037
5167
  owner_user: projectData.user_owner,
5038
5168
  bounds: projectData.bounds,
5039
- invited: projectData.invited || false
5169
+ invited: projectData.invited || false,
5170
+ issues_count: projectData.issues_count,
5171
+ form_submissions_count: projectData.form_submissions_count
5040
5172
  });
5041
5173
  if (currentProjectId === projectData.id && !projectData.invited) {
5042
5174
  isProjectIdValid = true;
@@ -5054,6 +5186,7 @@ var __publicField = (obj, key, value) => {
5054
5186
  }
5055
5187
  store.dispatch(setCurrentUser(data.user));
5056
5188
  store.dispatch(addUsers(data.project_owners));
5189
+ store.dispatch(setLicenses(data.licenses));
5057
5190
  const organizationsData = data.organizations;
5058
5191
  store.dispatch(setOrganizations(organizationsData));
5059
5192
  const validProjects = projects.filter((project) => !project.invited);
@@ -5167,7 +5300,7 @@ var __publicField = (obj, key, value) => {
5167
5300
  method: HttpMethod.PATCH,
5168
5301
  url: `/access/${projectAccess.offline_id}/`,
5169
5302
  payload: projectAccess,
5170
- blockers: [projectAccess.offline_id],
5303
+ blockers: [projectAccess.offline_id, "change-access-level"],
5171
5304
  blocks: [projectAccess.offline_id]
5172
5305
  });
5173
5306
  }
@@ -5366,6 +5499,7 @@ var __publicField = (obj, key, value) => {
5366
5499
  if (!project) {
5367
5500
  throw new Error("Expected project to exist");
5368
5501
  }
5502
+ const license = selectLicenseForProject(project.id);
5369
5503
  const activeProjectId = state.projectReducer.activeProjectId;
5370
5504
  if (activeProjectId === projectId) {
5371
5505
  store.dispatch({ type: "project/setActiveProjectId", payload: null });
@@ -5376,6 +5510,9 @@ var __publicField = (obj, key, value) => {
5376
5510
  store.dispatch(removeProjectAccessesOfProject(project.id));
5377
5511
  store.dispatch({ type: "rehydrated/setRehydrated", payload: false });
5378
5512
  store.dispatch(deleteProject(project));
5513
+ if (license) {
5514
+ store.dispatch(updateLicense({ ...license, project: null }));
5515
+ }
5379
5516
  try {
5380
5517
  await this.enqueueRequest({
5381
5518
  description: "Delete project",
@@ -5391,6 +5528,9 @@ var __publicField = (obj, key, value) => {
5391
5528
  store.dispatch(addOrReplaceProjectFiles(filesToDelete));
5392
5529
  store.dispatch(setActiveProjectId(activeProjectId));
5393
5530
  store.dispatch({ type: "rehydrated/setRehydrated", payload: true });
5531
+ if (license) {
5532
+ store.dispatch(updateLicense({ ...license, project: project.id }));
5533
+ }
5394
5534
  throw e;
5395
5535
  }
5396
5536
  }
@@ -5765,7 +5905,7 @@ var __publicField = (obj, key, value) => {
5765
5905
  method: HttpMethod.POST,
5766
5906
  url: `/forms/revisions/${payload.form_revision}/respond/`,
5767
5907
  payload: { ...payloadWithoutFiles, project: activeProjectId },
5768
- blockers: [payload.issue, payload.component, payload.component_stage].filter(
5908
+ blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
5769
5909
  (x) => x !== void 0
5770
5910
  ),
5771
5911
  blocks: [payload.offline_id]
@@ -5784,10 +5924,12 @@ var __publicField = (obj, key, value) => {
5784
5924
  };
5785
5925
  store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
5786
5926
  void promise.then((result) => {
5927
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
5787
5928
  store.dispatch(updateOrCreateUserFormSubmission(result));
5788
5929
  return result;
5789
5930
  }).catch(() => {
5790
5931
  store.dispatch(deleteUserFormSubmission(payload.offline_id));
5932
+ store.dispatch(addActiveProjectFormSubmissionsCount(-1));
5791
5933
  });
5792
5934
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
5793
5935
  return [fullOfflineResult, settledPromise];
@@ -5821,6 +5963,7 @@ var __publicField = (obj, key, value) => {
5821
5963
  const state = store.getState();
5822
5964
  const submission = state.userFormReducer.submissions[submissionId];
5823
5965
  store.dispatch(deleteUserFormSubmission(submissionId));
5966
+ store.dispatch(addActiveProjectFormSubmissionsCount(-1));
5824
5967
  try {
5825
5968
  return await this.enqueueRequest({
5826
5969
  description: "Delete user form submissions",
@@ -5831,6 +5974,7 @@ var __publicField = (obj, key, value) => {
5831
5974
  });
5832
5975
  } catch (e) {
5833
5976
  if (submission) {
5977
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
5834
5978
  store.dispatch(updateOrCreateUserFormSubmission(submission));
5835
5979
  }
5836
5980
  throw e;
@@ -5867,7 +6011,7 @@ var __publicField = (obj, key, value) => {
5867
6011
  method: HttpMethod.POST,
5868
6012
  url: `/projects/${store.getState().projectReducer.activeProjectId}/workspaces/`,
5869
6013
  payload: offlineWorkspace,
5870
- blockers: [],
6014
+ blockers: ["add-workspace"],
5871
6015
  blocks: [offlineWorkspace.offline_id]
5872
6016
  });
5873
6017
  void promise.then((result) => {
@@ -6244,10 +6388,12 @@ var __publicField = (obj, key, value) => {
6244
6388
  const organizationAccesses = data.organization_accesses;
6245
6389
  const emailDomains = data.email_domains;
6246
6390
  const users = data.users;
6391
+ const licenses = data.licenses;
6247
6392
  store.dispatch(addUsers(users));
6248
6393
  store.dispatch(setActiveOrganizationId(activeOrganization.id));
6249
6394
  store.dispatch(setOrganizationAccesses(organizationAccesses));
6250
6395
  store.dispatch(setEmailDomains(emailDomains));
6396
+ store.dispatch(addLicenses(licenses));
6251
6397
  if (showLoading) {
6252
6398
  store.dispatch(setIsFetchingInitialData(false));
6253
6399
  }
@@ -6288,6 +6434,103 @@ var __publicField = (obj, key, value) => {
6288
6434
  });
6289
6435
  }
6290
6436
  }
6437
+ class LicenseService extends BaseApiService {
6438
+ async getLicensesForOrganization(organizationId, showLoading = false) {
6439
+ if (showLoading) {
6440
+ this.client.store.dispatch(setIsFetchingInitialData(true));
6441
+ }
6442
+ return this.enqueueRequest({
6443
+ description: "Get licenses",
6444
+ method: HttpMethod.GET,
6445
+ url: `/organizations/${organizationId}/licenses/`,
6446
+ isAuthNeeded: true,
6447
+ blockers: [organizationId.toString()],
6448
+ blocks: ["add-issue", "add-form-entry", "change-access-level", "add-workspace"]
6449
+ }).then((result) => {
6450
+ if (showLoading) {
6451
+ this.client.store.dispatch(setIsFetchingInitialData(false));
6452
+ }
6453
+ return result;
6454
+ });
6455
+ }
6456
+ async pauseLicense(license) {
6457
+ return this.enqueueRequest({
6458
+ description: "Pause license",
6459
+ method: HttpMethod.DELETE,
6460
+ url: `/billing/${license.offline_id}/suspend/`,
6461
+ isAuthNeeded: true,
6462
+ blockers: [
6463
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6464
+ ],
6465
+ blocks: []
6466
+ }).then((result) => {
6467
+ this.client.store.dispatch(updateLicense(result));
6468
+ return result;
6469
+ });
6470
+ }
6471
+ async resumeLicense(license) {
6472
+ return this.enqueueRequest({
6473
+ description: "Resume license",
6474
+ method: HttpMethod.PATCH,
6475
+ url: `/billing/${license.offline_id}/suspend/`,
6476
+ isAuthNeeded: true,
6477
+ blockers: [
6478
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6479
+ ],
6480
+ blocks: []
6481
+ }).then((result) => {
6482
+ this.client.store.dispatch(updateLicense(result));
6483
+ return result;
6484
+ });
6485
+ }
6486
+ async cancelLicense(license) {
6487
+ return this.enqueueRequest({
6488
+ description: "Cancel license",
6489
+ method: HttpMethod.DELETE,
6490
+ url: `/billing/${license.offline_id}/`,
6491
+ isAuthNeeded: true,
6492
+ blockers: [
6493
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6494
+ ],
6495
+ blocks: []
6496
+ }).then((result) => {
6497
+ this.client.store.dispatch(updateLicense(result));
6498
+ return result;
6499
+ });
6500
+ }
6501
+ async attachLicenseToProject(license, project) {
6502
+ return this.enqueueRequest({
6503
+ description: "Attach license",
6504
+ method: HttpMethod.PATCH,
6505
+ url: `/billing/${license.offline_id}/project/`,
6506
+ isAuthNeeded: true,
6507
+ payload: { project: project.id },
6508
+ blockers: [
6509
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : "",
6510
+ project.id ? project.id.toString() : ""
6511
+ ],
6512
+ blocks: ["add-issue", "add-form-entry", "change-access-level", "add-workspace"]
6513
+ }).then((result) => {
6514
+ this.client.store.dispatch(updateLicense(result));
6515
+ return result;
6516
+ });
6517
+ }
6518
+ async detachLicenseFromProject(license) {
6519
+ return this.enqueueRequest({
6520
+ description: "Detach license",
6521
+ method: HttpMethod.DELETE,
6522
+ url: `/billing/${license.offline_id}/project/`,
6523
+ isAuthNeeded: true,
6524
+ blockers: [
6525
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6526
+ ],
6527
+ blocks: ["add-issue", "add-form-entry", "change-access-level", "add-workspace"]
6528
+ }).then((result) => {
6529
+ this.client.store.dispatch(updateLicense(result));
6530
+ return result;
6531
+ });
6532
+ }
6533
+ }
6291
6534
  class OvermapSDK {
6292
6535
  constructor(apiUrl, store) {
6293
6536
  __publicField(this, "API_URL");
@@ -6313,6 +6556,7 @@ var __publicField = (obj, key, value) => {
6313
6556
  __publicField(this, "projectFiles", new ProjectFileService(this));
6314
6557
  __publicField(this, "emailVerification", new EmailVerificationService(this));
6315
6558
  __publicField(this, "emailDomains", new EmailDomainsService(this));
6559
+ __publicField(this, "licenses", new LicenseService(this));
6316
6560
  this.API_URL = apiUrl;
6317
6561
  this.store = store;
6318
6562
  }
@@ -11919,6 +12163,9 @@ var __publicField = (obj, key, value) => {
11919
12163
  exports2.IssuePriority = IssuePriority;
11920
12164
  exports2.IssueService = IssueService;
11921
12165
  exports2.IssueStatus = IssueStatus;
12166
+ exports2.LicenseLevel = LicenseLevel;
12167
+ exports2.LicenseService = LicenseService;
12168
+ exports2.LicenseStatus = LicenseStatus;
11922
12169
  exports2.MainService = MainService;
11923
12170
  exports2.MapStyle = MapStyle;
11924
12171
  exports2.MultiSelectField = MultiSelectField;
@@ -11935,6 +12182,7 @@ var __publicField = (obj, key, value) => {
11935
12182
  exports2.OvermapContext = OvermapContext;
11936
12183
  exports2.OvermapProvider = OvermapProvider;
11937
12184
  exports2.OvermapSDK = OvermapSDK;
12185
+ exports2.PaddleCheckoutEvent = PaddleCheckoutEvent;
11938
12186
  exports2.PatchField = PatchField;
11939
12187
  exports2.PatchFormProvider = PatchFormProvider;
11940
12188
  exports2.ProjectAccessLevel = ProjectAccessLevel;
@@ -11957,6 +12205,8 @@ var __publicField = (obj, key, value) => {
11957
12205
  exports2.YELLOW = YELLOW;
11958
12206
  exports2._setLatestRetryTime = _setLatestRetryTime;
11959
12207
  exports2.acceptProjectInvite = acceptProjectInvite;
12208
+ exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
12209
+ exports2.addActiveProjectIssuesCount = addActiveProjectIssuesCount;
11960
12210
  exports2.addAttachment = addAttachment;
11961
12211
  exports2.addAttachments = addAttachments;
11962
12212
  exports2.addCategory = addCategory;
@@ -11966,6 +12216,7 @@ var __publicField = (obj, key, value) => {
11966
12216
  exports2.addEmailDomain = addEmailDomain;
11967
12217
  exports2.addFavouriteProjectId = addFavouriteProjectId;
11968
12218
  exports2.addIssue = addIssue;
12219
+ exports2.addLicenses = addLicenses;
11969
12220
  exports2.addOrReplaceCategories = addOrReplaceCategories;
11970
12221
  exports2.addOrReplaceIssueComment = addOrReplaceIssueComment;
11971
12222
  exports2.addOrReplaceProjectFile = addOrReplaceProjectFile;
@@ -12064,6 +12315,8 @@ var __publicField = (obj, key, value) => {
12064
12315
  exports2.issueReducer = issueReducer;
12065
12316
  exports2.issueSlice = issueSlice;
12066
12317
  exports2.issueToSearchResult = issueToSearchResult;
12318
+ exports2.licenseReducer = licenseReducer;
12319
+ exports2.licenseSlice = licenseSlice;
12067
12320
  exports2.linkStageToForm = linkStageToForm;
12068
12321
  exports2.literalToCoordinates = literalToCoordinates;
12069
12322
  exports2.logOnlyOnce = logOnlyOnce;
@@ -12131,13 +12384,17 @@ var __publicField = (obj, key, value) => {
12131
12384
  exports2.searchIssues = searchIssues;
12132
12385
  exports2.selectAccessToken = selectAccessToken;
12133
12386
  exports2.selectActiveIssueId = selectActiveIssueId;
12387
+ exports2.selectActiveLicense = selectActiveLicense;
12134
12388
  exports2.selectActiveOrganization = selectActiveOrganization;
12135
12389
  exports2.selectActiveOrganizationAccess = selectActiveOrganizationAccess;
12136
12390
  exports2.selectActiveOrganizationId = selectActiveOrganizationId;
12391
+ exports2.selectActiveOrganizationLicenses = selectActiveOrganizationLicenses;
12392
+ exports2.selectActiveOrganizationProjects = selectActiveOrganizationProjects;
12137
12393
  exports2.selectActiveProject = selectActiveProject;
12138
12394
  exports2.selectActiveProjectAccess = selectActiveProjectAccess;
12139
12395
  exports2.selectActiveProjectFileId = selectActiveProjectFileId;
12140
12396
  exports2.selectActiveProjectId = selectActiveProjectId;
12397
+ exports2.selectActiveStatusLicenses = selectActiveStatusLicenses;
12141
12398
  exports2.selectActiveWorkspace = selectActiveWorkspace;
12142
12399
  exports2.selectActiveWorkspaceId = selectActiveWorkspaceId;
12143
12400
  exports2.selectAllAttachments = selectAllAttachments;
@@ -12183,6 +12440,7 @@ var __publicField = (obj, key, value) => {
12183
12440
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
12184
12441
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
12185
12442
  exports2.selectIsImportingProjectFile = selectIsImportingProjectFile;
12443
+ exports2.selectIsLoading = selectIsLoading;
12186
12444
  exports2.selectIsLoggedIn = selectIsLoggedIn;
12187
12445
  exports2.selectIssue = selectIssue;
12188
12446
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
@@ -12193,6 +12451,10 @@ var __publicField = (obj, key, value) => {
12193
12451
  exports2.selectLatestRetryTime = selectLatestRetryTime;
12194
12452
  exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
12195
12453
  exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
12454
+ exports2.selectLicense = selectLicense;
12455
+ exports2.selectLicenseForProject = selectLicenseForProject;
12456
+ exports2.selectLicenses = selectLicenses;
12457
+ exports2.selectLicensesForProjectsMapping = selectLicensesForProjectsMapping;
12196
12458
  exports2.selectMainWorkspace = selectMainWorkspace;
12197
12459
  exports2.selectMapStyle = selectMapStyle;
12198
12460
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
@@ -12207,6 +12469,7 @@ var __publicField = (obj, key, value) => {
12207
12469
  exports2.selectOrganizationUsersAsMapping = selectOrganizationUsersAsMapping;
12208
12470
  exports2.selectOrganizationUsersIds = selectOrganizationUsersIds;
12209
12471
  exports2.selectOrganizations = selectOrganizations;
12472
+ exports2.selectOrganizationsMapping = selectOrganizationsMapping;
12210
12473
  exports2.selectOrganizationsWithAccess = selectOrganizationsWithAccess;
12211
12474
  exports2.selectPermittedWorkspaceIds = selectPermittedWorkspaceIds;
12212
12475
  exports2.selectPhotoAttachmentsOfIssue = selectPhotoAttachmentsOfIssue;
@@ -12228,6 +12491,7 @@ var __publicField = (obj, key, value) => {
12228
12491
  exports2.selectRevisionsForForm = selectRevisionsForForm;
12229
12492
  exports2.selectShowTooltips = selectShowTooltips;
12230
12493
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
12494
+ exports2.selectSortedOrganizationLicenses = selectSortedOrganizationLicenses;
12231
12495
  exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
12232
12496
  exports2.selectSortedProjectUsers = selectSortedProjectUsers;
12233
12497
  exports2.selectSortedProjects = selectSortedProjects;
@@ -12271,8 +12535,10 @@ var __publicField = (obj, key, value) => {
12271
12535
  exports2.setEnablePlacementMode = setEnablePlacementMode;
12272
12536
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
12273
12537
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
12538
+ exports2.setIsLoading = setIsLoading;
12274
12539
  exports2.setIssueComments = setIssueComments;
12275
12540
  exports2.setIssues = setIssues;
12541
+ exports2.setLicenses = setLicenses;
12276
12542
  exports2.setLoggedIn = setLoggedIn;
12277
12543
  exports2.setMapStyle = setMapStyle;
12278
12544
  exports2.setOrganizationAccesses = setOrganizationAccesses;
@@ -12312,6 +12578,7 @@ var __publicField = (obj, key, value) => {
12312
12578
  exports2.updateAttachment = updateAttachment;
12313
12579
  exports2.updateComponent = updateComponent;
12314
12580
  exports2.updateIssue = updateIssue;
12581
+ exports2.updateLicense = updateLicense;
12315
12582
  exports2.updateOrCreateProject = updateOrCreateProject;
12316
12583
  exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
12317
12584
  exports2.updateOrganizationAccess = updateOrganizationAccess;