@overmap-ai/core 1.0.41 → 1.0.43-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;
@@ -1361,7 +1361,7 @@ var __publicField = (obj, key, value) => {
1361
1361
  return getLocalDateString(date);
1362
1362
  return relative.format(days, "days");
1363
1363
  });
1364
- const initialState$k = {
1364
+ const initialState$l = {
1365
1365
  categories: {},
1366
1366
  usedCategoryColors: [],
1367
1367
  categoryVisibility: {
@@ -1371,8 +1371,8 @@ var __publicField = (obj, key, value) => {
1371
1371
  };
1372
1372
  const categorySlice = toolkit.createSlice({
1373
1373
  name: "categories",
1374
- initialState: initialState$k,
1375
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1374
+ initialState: initialState$l,
1375
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1376
1376
  reducers: {
1377
1377
  setCategories: (state, action) => {
1378
1378
  if (!Array.isArray(action.payload))
@@ -1505,13 +1505,13 @@ var __publicField = (obj, key, value) => {
1505
1505
  return hiddenCategoryCount;
1506
1506
  };
1507
1507
  const categoryReducer = categorySlice.reducer;
1508
- const initialState$j = {
1508
+ const initialState$k = {
1509
1509
  components: {}
1510
1510
  };
1511
1511
  const componentSlice = toolkit.createSlice({
1512
1512
  name: "components",
1513
- initialState: initialState$j,
1514
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1513
+ initialState: initialState$k,
1514
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1515
1515
  reducers: {
1516
1516
  addComponent: (state, action) => {
1517
1517
  state.components[action.payload.offline_id] = action.payload;
@@ -1623,13 +1623,13 @@ var __publicField = (obj, key, value) => {
1623
1623
  removeAllComponentsOfType
1624
1624
  } = componentSlice.actions;
1625
1625
  const componentReducer = componentSlice.reducer;
1626
- const initialState$i = {
1626
+ const initialState$j = {
1627
1627
  completionsByComponentId: {}
1628
1628
  };
1629
1629
  const componentStageCompletionSlice = toolkit.createSlice({
1630
1630
  name: "componentStageCompletions",
1631
- initialState: initialState$i,
1632
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1631
+ initialState: initialState$j,
1632
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1633
1633
  reducers: {
1634
1634
  addStageCompletion: (state, action) => {
1635
1635
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1680,13 +1680,13 @@ var __publicField = (obj, key, value) => {
1680
1680
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1681
1681
  };
1682
1682
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1683
- const initialState$h = {
1683
+ const initialState$i = {
1684
1684
  stages: {}
1685
1685
  };
1686
1686
  const componentStageSlice = toolkit.createSlice({
1687
1687
  name: "componentStages",
1688
- initialState: initialState$h,
1689
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1688
+ initialState: initialState$i,
1689
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1690
1690
  reducers: {
1691
1691
  addStages: (state, action) => {
1692
1692
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1777,14 +1777,14 @@ var __publicField = (obj, key, value) => {
1777
1777
  );
1778
1778
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1779
1779
  const componentStageReducer = componentStageSlice.reducer;
1780
- const initialState$g = {
1780
+ const initialState$h = {
1781
1781
  componentTypes: {},
1782
1782
  hiddenComponentTypeIds: {}
1783
1783
  };
1784
1784
  const componentTypeSlice = toolkit.createSlice({
1785
1785
  name: "componentTypes",
1786
- initialState: initialState$g,
1787
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
1786
+ initialState: initialState$h,
1787
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1788
1788
  reducers: {
1789
1789
  addComponentType: (state, action) => {
1790
1790
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1843,13 +1843,13 @@ var __publicField = (obj, key, value) => {
1843
1843
  const selectHiddenComponentTypeIds = (state) => state.componentTypeReducer.hiddenComponentTypeIds;
1844
1844
  const { addComponentType, setComponentTypes, toggleComponentTypeVisibility, deleteComponentType } = componentTypeSlice.actions;
1845
1845
  const componentTypeReducer = componentTypeSlice.reducer;
1846
- const initialState$f = {
1846
+ const initialState$g = {
1847
1847
  workspaces: {},
1848
1848
  activeWorkspaceId: null
1849
1849
  };
1850
1850
  const workspaceSlice = toolkit.createSlice({
1851
1851
  name: "workspace",
1852
- initialState: initialState$f,
1852
+ initialState: initialState$g,
1853
1853
  // The `reducers` field lets us define reducers and generate associated actions
1854
1854
  reducers: {
1855
1855
  setWorkspaces: (state, action) => {
@@ -1906,21 +1906,20 @@ var __publicField = (obj, key, value) => {
1906
1906
  );
1907
1907
  const workspaceReducer = workspaceSlice.reducer;
1908
1908
  const maxRecentIssues = 10;
1909
- const initialState$e = {
1909
+ const initialState$f = {
1910
1910
  issues: {},
1911
1911
  attachments: {},
1912
1912
  comments: {},
1913
1913
  visibleStatuses: [IssueStatus.BACKLOG, IssueStatus.SELECTED],
1914
- isFetchingInitialData: false,
1915
1914
  visibleUserIds: null,
1916
1915
  recentIssueIds: [],
1917
1916
  activeIssueId: null
1918
1917
  };
1919
1918
  const issueSlice = toolkit.createSlice({
1920
1919
  name: "issues",
1921
- initialState: initialState$e,
1920
+ initialState: initialState$f,
1922
1921
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1923
- Object.assign(state, initialState$e);
1922
+ Object.assign(state, initialState$f);
1924
1923
  }),
1925
1924
  reducers: {
1926
1925
  setIssues: (state, action) => {
@@ -1999,9 +1998,6 @@ var __publicField = (obj, key, value) => {
1999
1998
  setVisibleStatuses: (state, action) => {
2000
1999
  state.visibleStatuses = action.payload;
2001
2000
  },
2002
- setIsFetchingInitialData: (state, action) => {
2003
- state.isFetchingInitialData = action.payload;
2004
- },
2005
2001
  setVisibleUserIds: (state, action) => {
2006
2002
  state.visibleUserIds = [...new Set(action.payload)];
2007
2003
  },
@@ -2060,7 +2056,6 @@ var __publicField = (obj, key, value) => {
2060
2056
  resetRecentIssues,
2061
2057
  setActiveIssueId,
2062
2058
  setAttachments,
2063
- setIsFetchingInitialData,
2064
2059
  setIssueComments,
2065
2060
  setIssues,
2066
2061
  setVisibleStatuses,
@@ -2159,7 +2154,6 @@ var __publicField = (obj, key, value) => {
2159
2154
  return mapping[id];
2160
2155
  })
2161
2156
  );
2162
- const selectIsFetchingInitialData = (state) => state.issueReducer.isFetchingInitialData;
2163
2157
  const selectAllAttachments = toolkit.createSelector([selectIssueAttachmentMapping], (mapping) => Object.values(mapping));
2164
2158
  const searchIssues = restructureCreateSelectorWithArgs(
2165
2159
  toolkit.createSelector(
@@ -2251,15 +2245,15 @@ var __publicField = (obj, key, value) => {
2251
2245
  }
2252
2246
  );
2253
2247
  const issueReducer = issueSlice.reducer;
2254
- const initialState$d = {
2248
+ const initialState$e = {
2255
2249
  s3Urls: {}
2256
2250
  };
2257
2251
  const msPerHour = 1e3 * 60 * 60;
2258
2252
  const msPerWeek = msPerHour * 24 * 7;
2259
2253
  const fileSlice = toolkit.createSlice({
2260
2254
  name: "file",
2261
- initialState: initialState$d,
2262
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2255
+ initialState: initialState$e,
2256
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2263
2257
  reducers: {
2264
2258
  setUploadUrl: (state, action) => {
2265
2259
  const { url, fields, sha1 } = action.payload;
@@ -2286,7 +2280,7 @@ var __publicField = (obj, key, value) => {
2286
2280
  return url;
2287
2281
  };
2288
2282
  const fileReducer = fileSlice.reducer;
2289
- const initialState$c = {
2283
+ const initialState$d = {
2290
2284
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2291
2285
  mapStyle: MapStyle.SATELLITE,
2292
2286
  showTooltips: false,
@@ -2294,8 +2288,8 @@ var __publicField = (obj, key, value) => {
2294
2288
  };
2295
2289
  const mapSlice = toolkit.createSlice({
2296
2290
  name: "map",
2297
- initialState: initialState$c,
2298
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2291
+ initialState: initialState$d,
2292
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2299
2293
  reducers: {
2300
2294
  setMapStyle: (state, action) => {
2301
2295
  state.mapStyle = action.payload;
@@ -2337,7 +2331,24 @@ var __publicField = (obj, key, value) => {
2337
2331
  VerificationCodeType2[VerificationCodeType2["RESET_PASSWORD"] = 10] = "RESET_PASSWORD";
2338
2332
  return VerificationCodeType2;
2339
2333
  })(VerificationCodeType || {});
2340
- const initialState$b = {
2334
+ var PaddleCheckoutEvent = /* @__PURE__ */ ((PaddleCheckoutEvent2) => {
2335
+ PaddleCheckoutEvent2["COMPLETED"] = "checkout.completed";
2336
+ PaddleCheckoutEvent2["CLOSED"] = "checkout.closed";
2337
+ return PaddleCheckoutEvent2;
2338
+ })(PaddleCheckoutEvent || {});
2339
+ var LicenseLevel = /* @__PURE__ */ ((LicenseLevel2) => {
2340
+ LicenseLevel2[LicenseLevel2["PRO"] = 0] = "PRO";
2341
+ return LicenseLevel2;
2342
+ })(LicenseLevel || {});
2343
+ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
2344
+ LicenseStatus2[LicenseStatus2["ACTIVE"] = 0] = "ACTIVE";
2345
+ LicenseStatus2[LicenseStatus2["PAUSED"] = 2] = "PAUSED";
2346
+ LicenseStatus2[LicenseStatus2["CANCELLED"] = 4] = "CANCELLED";
2347
+ LicenseStatus2[LicenseStatus2["INACTIVE"] = 6] = "INACTIVE";
2348
+ LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2349
+ return LicenseStatus2;
2350
+ })(LicenseStatus || {});
2351
+ const initialState$c = {
2341
2352
  users: {},
2342
2353
  currentUser: {
2343
2354
  id: 0,
@@ -2348,8 +2359,8 @@ var __publicField = (obj, key, value) => {
2348
2359
  };
2349
2360
  const userSlice = toolkit.createSlice({
2350
2361
  name: "users",
2351
- initialState: initialState$b,
2352
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2362
+ initialState: initialState$c,
2363
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2353
2364
  reducers: {
2354
2365
  setUsers: (state, action) => {
2355
2366
  const usersMapping = {};
@@ -2411,13 +2422,13 @@ var __publicField = (obj, key, value) => {
2411
2422
  const selectUsersAsMapping = (state) => state.userReducer.users;
2412
2423
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2413
2424
  const userReducer = userSlice.reducer;
2414
- const initialState$a = {
2425
+ const initialState$b = {
2415
2426
  organizationAccesses: {}
2416
2427
  };
2417
2428
  const organizationAccessSlice = toolkit.createSlice({
2418
2429
  name: "organizationAccess",
2419
- initialState: initialState$a,
2420
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2430
+ initialState: initialState$b,
2431
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2421
2432
  reducers: {
2422
2433
  setOrganizationAccesses: (state, action) => {
2423
2434
  if (!Array.isArray(action.payload))
@@ -2480,151 +2491,64 @@ var __publicField = (obj, key, value) => {
2480
2491
  return organizationAccesses;
2481
2492
  };
2482
2493
  const organizationAccessReducer = organizationAccessSlice.reducer;
2483
- const initialState$9 = {
2484
- organizations: {},
2485
- activeOrganizationId: null
2494
+ const initialState$a = {
2495
+ licenses: {}
2486
2496
  };
2487
- const organizationSlice = toolkit.createSlice({
2488
- name: "organizations",
2489
- initialState: initialState$9,
2490
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2497
+ const licenseSlice = toolkit.createSlice({
2498
+ name: "license",
2499
+ initialState: initialState$a,
2500
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2491
2501
  reducers: {
2492
- setOrganizations: (state, action) => {
2493
- for (const org of action.payload) {
2494
- state.organizations[org.id] = org;
2502
+ setLicenses: (state, action) => {
2503
+ if (!Array.isArray(action.payload))
2504
+ throw new Error("Expected an array of Licenses");
2505
+ if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2506
+ throw new Error("Tried to use setLicenses reducer with duplicate ID's");
2495
2507
  }
2496
- },
2497
- updateActiveOrganization: (state, action) => {
2498
- if (!state.activeOrganizationId) {
2499
- throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2508
+ const licenses = {};
2509
+ for (const license of action.payload) {
2510
+ licenses[license.offline_id] = license;
2500
2511
  }
2501
- if (state.activeOrganizationId !== action.payload.id) {
2502
- throw new Error("Tried updating active organization with different organization");
2512
+ state.licenses = licenses;
2513
+ },
2514
+ addLicenses: (state, action) => {
2515
+ for (const license of action.payload) {
2516
+ state.licenses[license.offline_id] = license;
2503
2517
  }
2504
- state.organizations[state.activeOrganizationId] = action.payload;
2505
2518
  },
2506
- setActiveOrganizationId: (state, action) => {
2507
- state.activeOrganizationId = action.payload;
2519
+ updateLicense: (state, action) => {
2520
+ if (!(action.payload.offline_id in state.licenses)) {
2521
+ throw new Error("Tried to update license that does not exist.");
2522
+ }
2523
+ state.licenses[action.payload.offline_id] = action.payload;
2508
2524
  }
2509
2525
  }
2510
2526
  });
2511
- const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2512
- const selectActiveOrganizationId = (state) => {
2513
- return state.organizationReducer.activeOrganizationId;
2514
- };
2515
- const selectOrganizations = (state) => {
2516
- return Object.values(state.organizationReducer.organizations);
2527
+ const { setLicenses, addLicenses, updateLicense } = licenseSlice.actions;
2528
+ const selectLicenses = (state) => {
2529
+ return state.licenseReducer.licenses;
2517
2530
  };
2518
- const selectOrganizationsWithAccess = toolkit.createSelector(
2519
- [selectOrganizations],
2520
- (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2531
+ const selectLicense = (licenseId) => (state) => state.licenseReducer.licenses[licenseId];
2532
+ const selectActiveLicense = (state) => Object.values(state.licenseReducer.licenses).find(
2533
+ (license) => license.project === state.projectReducer.activeProjectId
2534
+ ) ?? null;
2535
+ const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.licenses).find((license) => license.project === projectId) ?? null;
2536
+ const selectActiveStatusLicenses = toolkit.createSelector(
2537
+ [selectLicenses],
2538
+ (licenses) => Object.values(licenses).filter((license) => license.is_active)
2521
2539
  );
2522
- const selectActiveOrganization = (state) => {
2523
- const id = selectActiveOrganizationId(state);
2524
- if (!id) {
2525
- return null;
2526
- }
2527
- const organization = state.organizationReducer.organizations[id];
2528
- if (!organization) {
2529
- return null;
2530
- }
2531
- return organization;
2532
- };
2533
- const selectOrganizationUsersIds = toolkit.createSelector(
2534
- [selectOrganizationAccesses],
2535
- (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2536
- );
2537
- const selectOrganizationUsersAsMapping = toolkit.createSelector(
2538
- [selectOrganizationUsersIds, selectUsersAsMapping],
2539
- (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2540
+ const selectLicensesForProjectsMapping = toolkit.createSelector(
2541
+ [selectLicenses],
2542
+ (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2540
2543
  );
2541
- const selectSortedOrganizationUsers = toolkit.createSelector(
2542
- [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2543
- (currentUser, userMapping, organizationAccessMapping) => {
2544
- return Object.values(userMapping).sort((userA, userB) => {
2545
- if (userA.id === currentUser.id) {
2546
- return -1;
2547
- } else if (userB.id === currentUser.id) {
2548
- return 1;
2549
- }
2550
- const organizationAccessesA = organizationAccessMapping[userA.id];
2551
- const organizationAccessesB = organizationAccessMapping[userB.id];
2552
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2553
- return userA.username.localeCompare(userB.username);
2554
- }
2555
- if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2556
- return -1;
2557
- }
2558
- return 1;
2559
- });
2560
- }
2561
- );
2562
- const selectOrganization = (id) => (state) => {
2563
- return state.organizationReducer.organizations[id];
2564
- };
2565
- const organizationReducer = organizationSlice.reducer;
2566
- const createOfflineAction = (request2, baseUrl) => {
2567
- const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: uuid.v4() };
2568
- return {
2569
- payload: requestWithUuid,
2570
- type: "",
2571
- meta: {
2572
- offline: {
2573
- effect: {
2574
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2575
- request: requestWithUuid,
2576
- BASE_URL: baseUrl
2577
- }
2578
- }
2579
- }
2580
- };
2581
- };
2582
- const initialState$8 = {
2583
- deletedRequests: [],
2584
- latestRetryTime: 0
2585
- };
2586
- const outboxSlice = toolkit.createSlice({
2587
- name: "outbox",
2588
- initialState: initialState$8,
2589
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2590
- reducers: {
2591
- // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2592
- // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
2593
- // Then this reducer enqueueRequest() is responsible for adding the actual request data to the outbox
2594
- enqueueRequest: {
2595
- reducer: (state, _action) => {
2596
- return state;
2597
- },
2598
- prepare: (payload) => {
2599
- console.debug("Preparing to enqueue request", payload);
2600
- const { BASE_URL, ...rest } = payload;
2601
- return createOfflineAction(rest, BASE_URL);
2602
- }
2603
- },
2604
- markForDeletion(state, action) {
2605
- state.deletedRequests.push(action.payload);
2606
- },
2607
- markAsDeleted(state, action) {
2608
- const index2 = state.deletedRequests.indexOf(action.payload);
2609
- if (index2 !== -1)
2610
- state.deletedRequests.splice(index2, 1);
2611
- },
2612
- _setLatestRetryTime: (state, action) => {
2613
- state.latestRetryTime = action.payload;
2614
- }
2615
- }
2616
- });
2617
- const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2618
- const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2619
- const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2620
- const outboxReducer = outboxSlice.reducer;
2621
- const initialState$7 = {
2544
+ const licenseReducer = licenseSlice.reducer;
2545
+ const initialState$9 = {
2622
2546
  projectAccesses: {}
2623
2547
  };
2624
2548
  const projectAccessSlice = toolkit.createSlice({
2625
2549
  name: "projectAccess",
2626
- initialState: initialState$7,
2627
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2550
+ initialState: initialState$9,
2551
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2628
2552
  reducers: {
2629
2553
  setProjectAccesses: (state, action) => {
2630
2554
  if (!Array.isArray(action.payload))
@@ -2692,7 +2616,7 @@ var __publicField = (obj, key, value) => {
2692
2616
  return projectAccesses;
2693
2617
  };
2694
2618
  const projectAccessReducer = projectAccessSlice.reducer;
2695
- const initialState$6 = {
2619
+ const initialState$8 = {
2696
2620
  projects: {},
2697
2621
  activeProjectId: null,
2698
2622
  recentProjectIds: [],
@@ -2701,7 +2625,7 @@ var __publicField = (obj, key, value) => {
2701
2625
  };
2702
2626
  const projectSlice = toolkit.createSlice({
2703
2627
  name: "projects",
2704
- initialState: initialState$6,
2628
+ initialState: initialState$8,
2705
2629
  reducers: {
2706
2630
  setProjects: (state, action) => {
2707
2631
  const projectsMap = {};
@@ -2747,6 +2671,27 @@ var __publicField = (obj, key, value) => {
2747
2671
  } else {
2748
2672
  throw new Error("Accept project invite: user is not in this project");
2749
2673
  }
2674
+ },
2675
+ addActiveProjectIssuesCount: (state, action) => {
2676
+ if (!state.activeProjectId || !(state.activeProjectId in state.projects)) {
2677
+ throw new Error("Update issues count: no active project");
2678
+ }
2679
+ if (!state.projects[state.activeProjectId].issues_count) {
2680
+ state.projects[state.activeProjectId].issues_count = action.payload;
2681
+ } else {
2682
+ state.projects[state.activeProjectId].issues_count += action.payload;
2683
+ }
2684
+ },
2685
+ addActiveProjectFormSubmissionsCount: (state, action) => {
2686
+ if (state.activeProjectId && state.activeProjectId in state.projects) {
2687
+ if (!state.projects[state.activeProjectId].form_submissions_count) {
2688
+ state.projects[state.activeProjectId].form_submissions_count = action.payload;
2689
+ } else {
2690
+ state.projects[state.activeProjectId].form_submissions_count += action.payload;
2691
+ }
2692
+ } else {
2693
+ throw new Error("Update form submissions count: no active project");
2694
+ }
2750
2695
  }
2751
2696
  }
2752
2697
  });
@@ -2757,7 +2702,9 @@ var __publicField = (obj, key, value) => {
2757
2702
  setActiveProjectId,
2758
2703
  setCreateProjectType,
2759
2704
  deleteProject,
2760
- acceptProjectInvite
2705
+ acceptProjectInvite,
2706
+ addActiveProjectIssuesCount,
2707
+ addActiveProjectFormSubmissionsCount
2761
2708
  } = projectSlice.actions;
2762
2709
  const selectProjects = (state) => state.projectReducer.projects;
2763
2710
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
@@ -2821,6 +2768,171 @@ var __publicField = (obj, key, value) => {
2821
2768
  });
2822
2769
  }
2823
2770
  );
2771
+ const initialState$7 = {
2772
+ organizations: {},
2773
+ activeOrganizationId: null
2774
+ };
2775
+ const organizationSlice = toolkit.createSlice({
2776
+ name: "organizations",
2777
+ initialState: initialState$7,
2778
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2779
+ reducers: {
2780
+ setOrganizations: (state, action) => {
2781
+ for (const org of action.payload) {
2782
+ state.organizations[org.id] = org;
2783
+ }
2784
+ },
2785
+ updateActiveOrganization: (state, action) => {
2786
+ if (!state.activeOrganizationId) {
2787
+ throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2788
+ }
2789
+ if (state.activeOrganizationId !== action.payload.id) {
2790
+ throw new Error("Tried updating active organization with different organization");
2791
+ }
2792
+ state.organizations[state.activeOrganizationId] = action.payload;
2793
+ },
2794
+ setActiveOrganizationId: (state, action) => {
2795
+ state.activeOrganizationId = action.payload;
2796
+ }
2797
+ }
2798
+ });
2799
+ const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2800
+ const selectActiveOrganizationId = (state) => {
2801
+ return state.organizationReducer.activeOrganizationId;
2802
+ };
2803
+ const selectOrganizations = (state) => {
2804
+ return Object.values(state.organizationReducer.organizations);
2805
+ };
2806
+ const selectOrganizationsMapping = (state) => {
2807
+ return state.organizationReducer.organizations;
2808
+ };
2809
+ const selectOrganizationsWithAccess = toolkit.createSelector(
2810
+ [selectOrganizations],
2811
+ (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2812
+ );
2813
+ const selectActiveOrganization = (state) => {
2814
+ const id = selectActiveOrganizationId(state);
2815
+ if (!id) {
2816
+ return null;
2817
+ }
2818
+ const organization = state.organizationReducer.organizations[id];
2819
+ if (!organization) {
2820
+ return null;
2821
+ }
2822
+ return organization;
2823
+ };
2824
+ const selectOrganizationUsersIds = toolkit.createSelector(
2825
+ [selectOrganizationAccesses],
2826
+ (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2827
+ );
2828
+ const selectActiveOrganizationProjects = toolkit.createSelector(
2829
+ [selectProjects, selectActiveOrganizationId],
2830
+ (projects, activeOrganizationId) => activeOrganizationId ? Object.values(projects).filter((project) => project.owner_organization === activeOrganizationId) : []
2831
+ );
2832
+ const selectActiveOrganizationLicenses = toolkit.createSelector(
2833
+ [selectActiveOrganizationId, selectLicenses],
2834
+ (activeOrganizationId, licenses) => !activeOrganizationId ? [] : Object.values(licenses).filter((license) => license.organization_owner === activeOrganizationId)
2835
+ );
2836
+ const selectSortedOrganizationLicenses = toolkit.createSelector(
2837
+ [selectActiveOrganizationLicenses, selectProjects],
2838
+ (licences, projects) => licences.sort((licenseA, licenseB) => {
2839
+ if (!licenseA.project) {
2840
+ return 1;
2841
+ }
2842
+ if (!licenseB.project) {
2843
+ return -1;
2844
+ }
2845
+ return projects[licenseA.project].name.toLowerCase().localeCompare(
2846
+ projects[licenseB.project].name.toLowerCase(),
2847
+ void 0,
2848
+ { numeric: true }
2849
+ );
2850
+ })
2851
+ );
2852
+ const selectOrganizationUsersAsMapping = toolkit.createSelector(
2853
+ [selectOrganizationUsersIds, selectUsersAsMapping],
2854
+ (organizationUserIds, users) => organizationUserIds.reduce((accum, userId) => ({ ...accum, [userId]: users[userId] }), {})
2855
+ );
2856
+ const selectSortedOrganizationUsers = toolkit.createSelector(
2857
+ [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2858
+ (currentUser, userMapping, organizationAccessMapping) => {
2859
+ return Object.values(userMapping).sort((userA, userB) => {
2860
+ if (userA.id === currentUser.id) {
2861
+ return -1;
2862
+ } else if (userB.id === currentUser.id) {
2863
+ return 1;
2864
+ }
2865
+ const organizationAccessesA = organizationAccessMapping[userA.id];
2866
+ const organizationAccessesB = organizationAccessMapping[userB.id];
2867
+ if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === (organizationAccessesB == null ? void 0 : organizationAccessesB.access_level)) {
2868
+ return userA.username.localeCompare(userB.username);
2869
+ }
2870
+ if ((organizationAccessesA == null ? void 0 : organizationAccessesA.access_level) === OrganizationAccessLevel.ADMIN) {
2871
+ return -1;
2872
+ }
2873
+ return 1;
2874
+ });
2875
+ }
2876
+ );
2877
+ const selectOrganization = (id) => (state) => {
2878
+ return state.organizationReducer.organizations[id];
2879
+ };
2880
+ const organizationReducer = organizationSlice.reducer;
2881
+ const createOfflineAction = (request2, baseUrl) => {
2882
+ const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: uuid.v4() };
2883
+ return {
2884
+ payload: requestWithUuid,
2885
+ type: "",
2886
+ meta: {
2887
+ offline: {
2888
+ effect: {
2889
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2890
+ request: requestWithUuid,
2891
+ BASE_URL: baseUrl
2892
+ }
2893
+ }
2894
+ }
2895
+ };
2896
+ };
2897
+ const initialState$6 = {
2898
+ deletedRequests: [],
2899
+ latestRetryTime: 0
2900
+ };
2901
+ const outboxSlice = toolkit.createSlice({
2902
+ name: "outbox",
2903
+ initialState: initialState$6,
2904
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2905
+ reducers: {
2906
+ // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2907
+ // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
2908
+ // Then this reducer enqueueRequest() is responsible for adding the actual request data to the outbox
2909
+ enqueueRequest: {
2910
+ reducer: (state, _action) => {
2911
+ return state;
2912
+ },
2913
+ prepare: (payload) => {
2914
+ console.debug("Preparing to enqueue request", payload);
2915
+ const { BASE_URL, ...rest } = payload;
2916
+ return createOfflineAction(rest, BASE_URL);
2917
+ }
2918
+ },
2919
+ markForDeletion(state, action) {
2920
+ state.deletedRequests.push(action.payload);
2921
+ },
2922
+ markAsDeleted(state, action) {
2923
+ const index2 = state.deletedRequests.indexOf(action.payload);
2924
+ if (index2 !== -1)
2925
+ state.deletedRequests.splice(index2, 1);
2926
+ },
2927
+ _setLatestRetryTime: (state, action) => {
2928
+ state.latestRetryTime = action.payload;
2929
+ }
2930
+ }
2931
+ });
2932
+ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2933
+ const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2934
+ const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2935
+ const outboxReducer = outboxSlice.reducer;
2824
2936
  const initialState$5 = {
2825
2937
  projectFiles: {},
2826
2938
  activeProjectFileId: null,
@@ -2957,7 +3069,9 @@ var __publicField = (obj, key, value) => {
2957
3069
  Components: false,
2958
3070
  Experimental: false
2959
3071
  },
2960
- appearance: "dark"
3072
+ appearance: "dark",
3073
+ isFetchingInitialData: false,
3074
+ isLoading: false
2961
3075
  };
2962
3076
  const settingSlice = toolkit.createSlice({
2963
3077
  name: "settings",
@@ -2981,6 +3095,12 @@ var __publicField = (obj, key, value) => {
2981
3095
  },
2982
3096
  setAppearance: (state, action) => {
2983
3097
  state.appearance = action.payload;
3098
+ },
3099
+ setIsFetchingInitialData: (state, action) => {
3100
+ state.isFetchingInitialData = action.payload;
3101
+ },
3102
+ setIsLoading: (state, action) => {
3103
+ state.isLoading = action.payload;
2984
3104
  }
2985
3105
  }
2986
3106
  });
@@ -2989,7 +3109,9 @@ var __publicField = (obj, key, value) => {
2989
3109
  setEnablePlacementMode,
2990
3110
  setSectionExpanded,
2991
3111
  setEnableClustering,
2992
- setAppearance
3112
+ setAppearance,
3113
+ setIsFetchingInitialData,
3114
+ setIsLoading
2993
3115
  } = settingSlice.actions;
2994
3116
  const selectEnablePlacementMode = (state) => state.settingReducer.placementMode;
2995
3117
  const selectEnableDuplicateIssues = (state) => state.settingReducer.useIssueTemplate;
@@ -2998,6 +3120,8 @@ var __publicField = (obj, key, value) => {
2998
3120
  const selectEnableClustering = (state) => state.settingReducer.enableClustering;
2999
3121
  const selectAppearance = (state) => state.settingReducer.appearance;
3000
3122
  const settingReducer = settingSlice.reducer;
3123
+ const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3124
+ const selectIsLoading = (state) => state.settingReducer.isLoading;
3001
3125
  const LATEST_REVISION_CACHE = {};
3002
3126
  function considerCachingRevision(revision, formId2, preferPending = false) {
3003
3127
  var _a2;
@@ -3416,7 +3540,8 @@ var __publicField = (obj, key, value) => {
3416
3540
  userFormReducer,
3417
3541
  userReducer,
3418
3542
  workspaceReducer,
3419
- emailDomainsReducer
3543
+ emailDomainsReducer,
3544
+ licenseReducer
3420
3545
  };
3421
3546
  const overmapReducer = toolkit.combineReducers(overmapReducers);
3422
3547
  const resetStore = "RESET";
@@ -4903,6 +5028,7 @@ var __publicField = (obj, key, value) => {
4903
5028
  });
4904
5029
  store.dispatch(addIssue(issuePayload));
4905
5030
  store.dispatch(addToRecentIssues(issuePayload.offline_id));
5031
+ store.dispatch(addActiveProjectIssuesCount(1));
4906
5032
  const promise = this.enqueueRequest({
4907
5033
  description: "Create issue",
4908
5034
  method: HttpMethod.POST,
@@ -4912,6 +5038,7 @@ var __publicField = (obj, key, value) => {
4912
5038
  },
4913
5039
  payload: issuePayload,
4914
5040
  blockers: [
5041
+ "add-issue",
4915
5042
  ...issuePayload.index_workspace ? [issuePayload.index_workspace] : [],
4916
5043
  ...issuePayload.visible_in_workspaces
4917
5044
  ],
@@ -4929,6 +5056,7 @@ var __publicField = (obj, key, value) => {
4929
5056
  });
4930
5057
  }
4931
5058
  store.dispatch(removeIssue(issuePayload.offline_id));
5059
+ store.dispatch(addActiveProjectIssuesCount(-1));
4932
5060
  throw error2;
4933
5061
  });
4934
5062
  return [issuePayload, promise];
@@ -4967,16 +5095,18 @@ var __publicField = (obj, key, value) => {
4967
5095
  return [fullIssue, promise];
4968
5096
  }
4969
5097
  async remove(id) {
4970
- const state = this.client.store.getState();
5098
+ const { store } = this.client;
5099
+ const state = store.getState();
4971
5100
  const backup = state.issueReducer.issues[id];
4972
5101
  if (!backup) {
4973
5102
  throw new Error(`No issue with id ${id} found in the store`);
4974
5103
  }
4975
5104
  const attachments = Object.values(state.issueReducer.attachments).filter((a) => a.issue_id === id);
4976
5105
  const attachmentsOfIssue = selectPhotoAttachmentsOfIssue(id)(state);
4977
- this.client.store.dispatch(removeIssue(id));
5106
+ store.dispatch(removeIssue(id));
5107
+ store.dispatch(addActiveProjectIssuesCount(-1));
4978
5108
  if (attachmentsOfIssue) {
4979
- this.client.store.dispatch(removeAttachmentsOfIssue(id));
5109
+ store.dispatch(removeAttachmentsOfIssue(id));
4980
5110
  }
4981
5111
  try {
4982
5112
  return await this.enqueueRequest({
@@ -4987,8 +5117,9 @@ var __publicField = (obj, key, value) => {
4987
5117
  blocks: []
4988
5118
  });
4989
5119
  } catch (e) {
4990
- this.client.store.dispatch(addIssue(backup));
4991
- this.client.store.dispatch(addAttachments(attachments));
5120
+ store.dispatch(addIssue(backup));
5121
+ store.dispatch(addAttachments(attachments));
5122
+ store.dispatch(addActiveProjectIssuesCount(1));
4992
5123
  throw e;
4993
5124
  }
4994
5125
  }
@@ -5064,7 +5195,9 @@ var __publicField = (obj, key, value) => {
5064
5195
  owner_organization: projectData.organization_owner,
5065
5196
  owner_user: projectData.user_owner,
5066
5197
  bounds: projectData.bounds,
5067
- invited: projectData.invited || false
5198
+ invited: projectData.invited || false,
5199
+ issues_count: projectData.issues_count,
5200
+ form_submissions_count: projectData.form_submissions_count
5068
5201
  });
5069
5202
  if (currentProjectId === projectData.id && !projectData.invited) {
5070
5203
  isProjectIdValid = true;
@@ -5082,6 +5215,7 @@ var __publicField = (obj, key, value) => {
5082
5215
  }
5083
5216
  store.dispatch(setCurrentUser(data.user));
5084
5217
  store.dispatch(addUsers(data.project_owners));
5218
+ store.dispatch(setLicenses(data.licenses));
5085
5219
  const organizationsData = data.organizations;
5086
5220
  store.dispatch(setOrganizations(organizationsData));
5087
5221
  const validProjects = projects.filter((project) => !project.invited);
@@ -5195,7 +5329,7 @@ var __publicField = (obj, key, value) => {
5195
5329
  method: HttpMethod.PATCH,
5196
5330
  url: `/access/${projectAccess.offline_id}/`,
5197
5331
  payload: projectAccess,
5198
- blockers: [projectAccess.offline_id],
5332
+ blockers: [projectAccess.offline_id, "change-access-level"],
5199
5333
  blocks: [projectAccess.offline_id]
5200
5334
  });
5201
5335
  }
@@ -5394,6 +5528,7 @@ var __publicField = (obj, key, value) => {
5394
5528
  if (!project) {
5395
5529
  throw new Error("Expected project to exist");
5396
5530
  }
5531
+ const license = selectLicenseForProject(project.id);
5397
5532
  const activeProjectId = state.projectReducer.activeProjectId;
5398
5533
  if (activeProjectId === projectId) {
5399
5534
  store.dispatch({ type: "project/setActiveProjectId", payload: null });
@@ -5404,6 +5539,9 @@ var __publicField = (obj, key, value) => {
5404
5539
  store.dispatch(removeProjectAccessesOfProject(project.id));
5405
5540
  store.dispatch({ type: "rehydrated/setRehydrated", payload: false });
5406
5541
  store.dispatch(deleteProject(project));
5542
+ if (license) {
5543
+ store.dispatch(updateLicense({ ...license, project: null }));
5544
+ }
5407
5545
  try {
5408
5546
  await this.enqueueRequest({
5409
5547
  description: "Delete project",
@@ -5419,6 +5557,9 @@ var __publicField = (obj, key, value) => {
5419
5557
  store.dispatch(addOrReplaceProjectFiles(filesToDelete));
5420
5558
  store.dispatch(setActiveProjectId(activeProjectId));
5421
5559
  store.dispatch({ type: "rehydrated/setRehydrated", payload: true });
5560
+ if (license) {
5561
+ store.dispatch(updateLicense({ ...license, project: project.id }));
5562
+ }
5422
5563
  throw e;
5423
5564
  }
5424
5565
  }
@@ -5793,7 +5934,7 @@ var __publicField = (obj, key, value) => {
5793
5934
  method: HttpMethod.POST,
5794
5935
  url: `/forms/revisions/${payload.form_revision}/respond/`,
5795
5936
  payload: { ...payloadWithoutFiles, project: activeProjectId },
5796
- blockers: [payload.issue, payload.component, payload.component_stage].filter(
5937
+ blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
5797
5938
  (x) => x !== void 0
5798
5939
  ),
5799
5940
  blocks: [payload.offline_id]
@@ -5812,10 +5953,12 @@ var __publicField = (obj, key, value) => {
5812
5953
  };
5813
5954
  store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
5814
5955
  void promise.then((result) => {
5956
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
5815
5957
  store.dispatch(updateOrCreateUserFormSubmission(result));
5816
5958
  return result;
5817
5959
  }).catch(() => {
5818
5960
  store.dispatch(deleteUserFormSubmission(payload.offline_id));
5961
+ store.dispatch(addActiveProjectFormSubmissionsCount(-1));
5819
5962
  });
5820
5963
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
5821
5964
  return [fullOfflineResult, settledPromise];
@@ -5849,6 +5992,7 @@ var __publicField = (obj, key, value) => {
5849
5992
  const state = store.getState();
5850
5993
  const submission = state.userFormReducer.submissions[submissionId];
5851
5994
  store.dispatch(deleteUserFormSubmission(submissionId));
5995
+ store.dispatch(addActiveProjectFormSubmissionsCount(-1));
5852
5996
  try {
5853
5997
  return await this.enqueueRequest({
5854
5998
  description: "Delete user form submissions",
@@ -5859,6 +6003,7 @@ var __publicField = (obj, key, value) => {
5859
6003
  });
5860
6004
  } catch (e) {
5861
6005
  if (submission) {
6006
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
5862
6007
  store.dispatch(updateOrCreateUserFormSubmission(submission));
5863
6008
  }
5864
6009
  throw e;
@@ -5895,7 +6040,7 @@ var __publicField = (obj, key, value) => {
5895
6040
  method: HttpMethod.POST,
5896
6041
  url: `/projects/${store.getState().projectReducer.activeProjectId}/workspaces/`,
5897
6042
  payload: offlineWorkspace,
5898
- blockers: [],
6043
+ blockers: ["add-workspace"],
5899
6044
  blocks: [offlineWorkspace.offline_id]
5900
6045
  });
5901
6046
  void promise.then((result) => {
@@ -6272,10 +6417,12 @@ var __publicField = (obj, key, value) => {
6272
6417
  const organizationAccesses = data.organization_accesses;
6273
6418
  const emailDomains = data.email_domains;
6274
6419
  const users = data.users;
6420
+ const licenses = data.licenses;
6275
6421
  store.dispatch(addUsers(users));
6276
6422
  store.dispatch(setActiveOrganizationId(activeOrganization.id));
6277
6423
  store.dispatch(setOrganizationAccesses(organizationAccesses));
6278
6424
  store.dispatch(setEmailDomains(emailDomains));
6425
+ store.dispatch(addLicenses(licenses));
6279
6426
  if (showLoading) {
6280
6427
  store.dispatch(setIsFetchingInitialData(false));
6281
6428
  }
@@ -6316,6 +6463,128 @@ var __publicField = (obj, key, value) => {
6316
6463
  });
6317
6464
  }
6318
6465
  }
6466
+ class LicenseService extends BaseApiService {
6467
+ async getLicensesForOrganization(organizationId, showLoading = false) {
6468
+ if (showLoading) {
6469
+ this.client.store.dispatch(setIsFetchingInitialData(true));
6470
+ }
6471
+ return this.enqueueRequest({
6472
+ description: "Get licenses",
6473
+ method: HttpMethod.GET,
6474
+ url: `/organizations/${organizationId}/licenses/`,
6475
+ isAuthNeeded: true,
6476
+ blockers: [organizationId.toString()],
6477
+ blocks: ["add-issue", "add-form-entry", "change-access-level", "add-workspace"]
6478
+ }).then((result) => {
6479
+ if (showLoading) {
6480
+ this.client.store.dispatch(setIsFetchingInitialData(false));
6481
+ }
6482
+ return result;
6483
+ });
6484
+ }
6485
+ async getLicense(license) {
6486
+ return this.enqueueRequest({
6487
+ description: "Get license",
6488
+ method: HttpMethod.GET,
6489
+ url: `/billing/${license.offline_id}/`,
6490
+ isAuthNeeded: true,
6491
+ blockers: [
6492
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6493
+ ],
6494
+ blocks: []
6495
+ }).then((result) => {
6496
+ this.client.store.dispatch(updateLicense(result));
6497
+ return result;
6498
+ });
6499
+ }
6500
+ async pauseLicense(license) {
6501
+ return this.enqueueRequest({
6502
+ description: "Pause license",
6503
+ method: HttpMethod.DELETE,
6504
+ url: `/billing/${license.offline_id}/suspend/`,
6505
+ isAuthNeeded: true,
6506
+ blockers: [
6507
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6508
+ ],
6509
+ blocks: []
6510
+ }).then((result) => {
6511
+ this.client.store.dispatch(updateLicense(result));
6512
+ return result;
6513
+ });
6514
+ }
6515
+ async resumeLicense(license) {
6516
+ return this.enqueueRequest({
6517
+ description: "Resume license",
6518
+ method: HttpMethod.PATCH,
6519
+ url: `/billing/${license.offline_id}/suspend/`,
6520
+ isAuthNeeded: true,
6521
+ blockers: [
6522
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6523
+ ],
6524
+ blocks: []
6525
+ }).then((result) => {
6526
+ this.client.store.dispatch(updateLicense(result));
6527
+ return result;
6528
+ });
6529
+ }
6530
+ async cancelLicense(license) {
6531
+ return this.enqueueRequest({
6532
+ description: "Cancel license",
6533
+ method: HttpMethod.DELETE,
6534
+ url: `/billing/${license.offline_id}/`,
6535
+ isAuthNeeded: true,
6536
+ blockers: [
6537
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6538
+ ],
6539
+ blocks: []
6540
+ }).then((result) => {
6541
+ this.client.store.dispatch(updateLicense(result));
6542
+ return result;
6543
+ });
6544
+ }
6545
+ async attachLicenseToProject(license, project) {
6546
+ return this.enqueueRequest({
6547
+ description: "Attach license",
6548
+ method: HttpMethod.PATCH,
6549
+ url: `/billing/${license.offline_id}/project/`,
6550
+ isAuthNeeded: true,
6551
+ payload: { project: project.id },
6552
+ blockers: [
6553
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : "",
6554
+ project.id ? project.id.toString() : ""
6555
+ ],
6556
+ blocks: ["add-issue", "add-form-entry", "change-access-level", "add-workspace"]
6557
+ }).then((result) => {
6558
+ this.client.store.dispatch(updateLicense(result));
6559
+ return result;
6560
+ });
6561
+ }
6562
+ async detachLicenseFromProject(license) {
6563
+ return this.enqueueRequest({
6564
+ description: "Detach license",
6565
+ method: HttpMethod.DELETE,
6566
+ url: `/billing/${license.offline_id}/project/`,
6567
+ isAuthNeeded: true,
6568
+ blockers: [
6569
+ license.organization_owner ? license.organization_owner.toString() : license.user_owner ? license.user_owner.toString() : ""
6570
+ ],
6571
+ blocks: ["add-issue", "add-form-entry", "change-access-level", "add-workspace"]
6572
+ }).then((result) => {
6573
+ this.client.store.dispatch(updateLicense(result));
6574
+ return result;
6575
+ });
6576
+ }
6577
+ async getLatestTransaction(license) {
6578
+ return this.enqueueRequest({
6579
+ description: "Get latest transaction",
6580
+ method: HttpMethod.GET,
6581
+ url: `/billing/${license.offline_id}/transaction/`,
6582
+ isAuthNeeded: true,
6583
+ blockers: [license.offline_id],
6584
+ blocks: [license.offline_id]
6585
+ });
6586
+ }
6587
+ }
6319
6588
  class OvermapSDK {
6320
6589
  constructor(apiUrl, store) {
6321
6590
  __publicField(this, "API_URL");
@@ -6341,6 +6610,7 @@ var __publicField = (obj, key, value) => {
6341
6610
  __publicField(this, "projectFiles", new ProjectFileService(this));
6342
6611
  __publicField(this, "emailVerification", new EmailVerificationService(this));
6343
6612
  __publicField(this, "emailDomains", new EmailDomainsService(this));
6613
+ __publicField(this, "licenses", new LicenseService(this));
6344
6614
  this.API_URL = apiUrl;
6345
6615
  this.store = store;
6346
6616
  }
@@ -14353,6 +14623,9 @@ var __publicField = (obj, key, value) => {
14353
14623
  exports2.IssuePriority = IssuePriority;
14354
14624
  exports2.IssueService = IssueService;
14355
14625
  exports2.IssueStatus = IssueStatus;
14626
+ exports2.LicenseLevel = LicenseLevel;
14627
+ exports2.LicenseService = LicenseService;
14628
+ exports2.LicenseStatus = LicenseStatus;
14356
14629
  exports2.MainService = MainService;
14357
14630
  exports2.MapStyle = MapStyle;
14358
14631
  exports2.MultiSelectField = MultiSelectField;
@@ -14370,6 +14643,7 @@ var __publicField = (obj, key, value) => {
14370
14643
  exports2.OvermapProvider = OvermapProvider;
14371
14644
  exports2.OvermapSDK = OvermapSDK;
14372
14645
  exports2.PDFViewer = PDFViewer;
14646
+ exports2.PaddleCheckoutEvent = PaddleCheckoutEvent;
14373
14647
  exports2.PatchField = PatchField;
14374
14648
  exports2.PatchFormProvider = PatchFormProvider;
14375
14649
  exports2.ProjectAccessLevel = ProjectAccessLevel;
@@ -14396,6 +14670,8 @@ var __publicField = (obj, key, value) => {
14396
14670
  exports2.YELLOW = YELLOW;
14397
14671
  exports2._setLatestRetryTime = _setLatestRetryTime;
14398
14672
  exports2.acceptProjectInvite = acceptProjectInvite;
14673
+ exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
14674
+ exports2.addActiveProjectIssuesCount = addActiveProjectIssuesCount;
14399
14675
  exports2.addAttachment = addAttachment;
14400
14676
  exports2.addAttachments = addAttachments;
14401
14677
  exports2.addCategory = addCategory;
@@ -14405,6 +14681,7 @@ var __publicField = (obj, key, value) => {
14405
14681
  exports2.addEmailDomain = addEmailDomain;
14406
14682
  exports2.addFavouriteProjectId = addFavouriteProjectId;
14407
14683
  exports2.addIssue = addIssue;
14684
+ exports2.addLicenses = addLicenses;
14408
14685
  exports2.addOrReplaceCategories = addOrReplaceCategories;
14409
14686
  exports2.addOrReplaceIssueComment = addOrReplaceIssueComment;
14410
14687
  exports2.addOrReplaceProjectFile = addOrReplaceProjectFile;
@@ -14504,6 +14781,8 @@ var __publicField = (obj, key, value) => {
14504
14781
  exports2.issueReducer = issueReducer;
14505
14782
  exports2.issueSlice = issueSlice;
14506
14783
  exports2.issueToSearchResult = issueToSearchResult;
14784
+ exports2.licenseReducer = licenseReducer;
14785
+ exports2.licenseSlice = licenseSlice;
14507
14786
  exports2.linkStageToForm = linkStageToForm;
14508
14787
  exports2.literalToCoordinates = literalToCoordinates;
14509
14788
  exports2.logOnlyOnce = logOnlyOnce;
@@ -14571,13 +14850,17 @@ var __publicField = (obj, key, value) => {
14571
14850
  exports2.searchIssues = searchIssues;
14572
14851
  exports2.selectAccessToken = selectAccessToken;
14573
14852
  exports2.selectActiveIssueId = selectActiveIssueId;
14853
+ exports2.selectActiveLicense = selectActiveLicense;
14574
14854
  exports2.selectActiveOrganization = selectActiveOrganization;
14575
14855
  exports2.selectActiveOrganizationAccess = selectActiveOrganizationAccess;
14576
14856
  exports2.selectActiveOrganizationId = selectActiveOrganizationId;
14857
+ exports2.selectActiveOrganizationLicenses = selectActiveOrganizationLicenses;
14858
+ exports2.selectActiveOrganizationProjects = selectActiveOrganizationProjects;
14577
14859
  exports2.selectActiveProject = selectActiveProject;
14578
14860
  exports2.selectActiveProjectAccess = selectActiveProjectAccess;
14579
14861
  exports2.selectActiveProjectFileId = selectActiveProjectFileId;
14580
14862
  exports2.selectActiveProjectId = selectActiveProjectId;
14863
+ exports2.selectActiveStatusLicenses = selectActiveStatusLicenses;
14581
14864
  exports2.selectActiveWorkspace = selectActiveWorkspace;
14582
14865
  exports2.selectActiveWorkspaceId = selectActiveWorkspaceId;
14583
14866
  exports2.selectAllAttachments = selectAllAttachments;
@@ -14623,6 +14906,7 @@ var __publicField = (obj, key, value) => {
14623
14906
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
14624
14907
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
14625
14908
  exports2.selectIsImportingProjectFile = selectIsImportingProjectFile;
14909
+ exports2.selectIsLoading = selectIsLoading;
14626
14910
  exports2.selectIsLoggedIn = selectIsLoggedIn;
14627
14911
  exports2.selectIssue = selectIssue;
14628
14912
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
@@ -14633,6 +14917,10 @@ var __publicField = (obj, key, value) => {
14633
14917
  exports2.selectLatestRetryTime = selectLatestRetryTime;
14634
14918
  exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
14635
14919
  exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
14920
+ exports2.selectLicense = selectLicense;
14921
+ exports2.selectLicenseForProject = selectLicenseForProject;
14922
+ exports2.selectLicenses = selectLicenses;
14923
+ exports2.selectLicensesForProjectsMapping = selectLicensesForProjectsMapping;
14636
14924
  exports2.selectMainWorkspace = selectMainWorkspace;
14637
14925
  exports2.selectMapStyle = selectMapStyle;
14638
14926
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
@@ -14647,6 +14935,7 @@ var __publicField = (obj, key, value) => {
14647
14935
  exports2.selectOrganizationUsersAsMapping = selectOrganizationUsersAsMapping;
14648
14936
  exports2.selectOrganizationUsersIds = selectOrganizationUsersIds;
14649
14937
  exports2.selectOrganizations = selectOrganizations;
14938
+ exports2.selectOrganizationsMapping = selectOrganizationsMapping;
14650
14939
  exports2.selectOrganizationsWithAccess = selectOrganizationsWithAccess;
14651
14940
  exports2.selectPermittedWorkspaceIds = selectPermittedWorkspaceIds;
14652
14941
  exports2.selectPhotoAttachmentsOfIssue = selectPhotoAttachmentsOfIssue;
@@ -14668,6 +14957,7 @@ var __publicField = (obj, key, value) => {
14668
14957
  exports2.selectRevisionsForForm = selectRevisionsForForm;
14669
14958
  exports2.selectShowTooltips = selectShowTooltips;
14670
14959
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
14960
+ exports2.selectSortedOrganizationLicenses = selectSortedOrganizationLicenses;
14671
14961
  exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
14672
14962
  exports2.selectSortedProjectUsers = selectSortedProjectUsers;
14673
14963
  exports2.selectSortedProjects = selectSortedProjects;
@@ -14711,8 +15001,10 @@ var __publicField = (obj, key, value) => {
14711
15001
  exports2.setEnablePlacementMode = setEnablePlacementMode;
14712
15002
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
14713
15003
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
15004
+ exports2.setIsLoading = setIsLoading;
14714
15005
  exports2.setIssueComments = setIssueComments;
14715
15006
  exports2.setIssues = setIssues;
15007
+ exports2.setLicenses = setLicenses;
14716
15008
  exports2.setLoggedIn = setLoggedIn;
14717
15009
  exports2.setMapStyle = setMapStyle;
14718
15010
  exports2.setOrganizationAccesses = setOrganizationAccesses;
@@ -14752,6 +15044,7 @@ var __publicField = (obj, key, value) => {
14752
15044
  exports2.updateAttachment = updateAttachment;
14753
15045
  exports2.updateComponent = updateComponent;
14754
15046
  exports2.updateIssue = updateIssue;
15047
+ exports2.updateLicense = updateLicense;
14755
15048
  exports2.updateOrCreateProject = updateOrCreateProject;
14756
15049
  exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
14757
15050
  exports2.updateOrganizationAccess = updateOrganizationAccess;