@overmap-ai/core 1.0.31 → 1.0.32
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.
- package/dist/overmap-core.js +72 -37
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +72 -37
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/MainService.d.ts +1 -0
- package/dist/sdk/services/OrganizationService.d.ts +3 -1
- package/dist/store/slices/organizationAccessSlice.d.ts +1 -5
- package/dist/store/slices/organizationSlice.d.ts +1 -0
- package/dist/store/slices/projectSlice.d.ts +1 -0
- package/dist/typings/models/organizations.d.ts +10 -0
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -2357,8 +2357,7 @@ const selectUsersAsMapping = (state) => state.userReducer.users;
|
|
|
2357
2357
|
const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
|
|
2358
2358
|
const userReducer = userSlice.reducer;
|
|
2359
2359
|
const initialState$a = {
|
|
2360
|
-
organizationAccesses: {}
|
|
2361
|
-
activeOrganizationAccessId: null
|
|
2360
|
+
organizationAccesses: {}
|
|
2362
2361
|
};
|
|
2363
2362
|
const organizationAccessSlice = createSlice({
|
|
2364
2363
|
name: "organizationAccess",
|
|
@@ -2394,31 +2393,25 @@ const organizationAccessSlice = createSlice({
|
|
|
2394
2393
|
`Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
|
|
2395
2394
|
);
|
|
2396
2395
|
}
|
|
2397
|
-
},
|
|
2398
|
-
setActiveOrganizationAccessId: (state, action) => {
|
|
2399
|
-
state.activeOrganizationAccessId = action.payload;
|
|
2400
2396
|
}
|
|
2401
2397
|
}
|
|
2402
2398
|
});
|
|
2403
|
-
const {
|
|
2404
|
-
setOrganizationAccesses,
|
|
2405
|
-
updateOrganizationAccess,
|
|
2406
|
-
removeOrganizationAccess,
|
|
2407
|
-
setActiveOrganizationAccessId
|
|
2408
|
-
} = organizationAccessSlice.actions;
|
|
2399
|
+
const { setOrganizationAccesses, updateOrganizationAccess, removeOrganizationAccess } = organizationAccessSlice.actions;
|
|
2409
2400
|
const selectOrganizationAccesses = (state) => {
|
|
2410
2401
|
return state.organizationAccessReducer.organizationAccesses;
|
|
2411
2402
|
};
|
|
2412
2403
|
const selectOrganizationAccess = (organizationAccessId) => (state) => {
|
|
2413
2404
|
return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
|
|
2414
2405
|
};
|
|
2415
|
-
const selectActiveOrganizationAccess = (
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2406
|
+
const selectActiveOrganizationAccess = createSelector(
|
|
2407
|
+
[selectCurrentUser, selectOrganizationAccesses],
|
|
2408
|
+
(currentUser, organizationAccesses) => {
|
|
2409
|
+
const activeOrganizationAccess = Object.values(organizationAccesses).find(
|
|
2410
|
+
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
2411
|
+
);
|
|
2412
|
+
return activeOrganizationAccess ?? null;
|
|
2419
2413
|
}
|
|
2420
|
-
|
|
2421
|
-
};
|
|
2414
|
+
);
|
|
2422
2415
|
const selectOrganizationAccessForUser = (user) => (state) => {
|
|
2423
2416
|
return Object.values(state.organizationAccessReducer.organizationAccesses).find(
|
|
2424
2417
|
(organizationAccess) => organizationAccess.user === user.id
|
|
@@ -2467,6 +2460,10 @@ const selectActiveOrganizationId = (state) => {
|
|
|
2467
2460
|
const selectOrganizations = (state) => {
|
|
2468
2461
|
return Object.values(state.organizationReducer.organizations);
|
|
2469
2462
|
};
|
|
2463
|
+
const selectOrganizationsWithAccess = createSelector(
|
|
2464
|
+
[selectOrganizations],
|
|
2465
|
+
(organizations) => Object.values(organizations).filter((organization) => organization.has_access)
|
|
2466
|
+
);
|
|
2470
2467
|
const selectActiveOrganization = (state) => {
|
|
2471
2468
|
const id = selectActiveOrganizationId(state);
|
|
2472
2469
|
if (!id) {
|
|
@@ -2719,6 +2716,21 @@ const selectActiveProject = (state) => {
|
|
|
2719
2716
|
const selectRecentProjects = (state) => {
|
|
2720
2717
|
return state.projectReducer.recentProjectIds;
|
|
2721
2718
|
};
|
|
2719
|
+
const selectSortedProjects = createSelector(
|
|
2720
|
+
[selectActiveProject, selectProjects],
|
|
2721
|
+
(activeProject, projects) => {
|
|
2722
|
+
return Object.values(projects).sort((projectA, projectB) => {
|
|
2723
|
+
if (activeProject) {
|
|
2724
|
+
if (activeProject.id === projectA.id) {
|
|
2725
|
+
return -1;
|
|
2726
|
+
} else if (activeProject.id === projectB.id) {
|
|
2727
|
+
return 1;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
return projectA.name.toLowerCase().localeCompare(projectB.name.toLowerCase(), void 0, { numeric: true });
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
);
|
|
2722
2734
|
const selectCreateProjectType = (state) => state.projectReducer.createProjectType;
|
|
2723
2735
|
const projectReducer = projectSlice.reducer;
|
|
2724
2736
|
const selectProjectUsersIds = createSelector(
|
|
@@ -4060,7 +4072,6 @@ class AuthService extends BaseApiService {
|
|
|
4060
4072
|
store.dispatch(setLoggedIn(false));
|
|
4061
4073
|
store.dispatch(clearTokens());
|
|
4062
4074
|
store.dispatch(setActiveProjectId(null));
|
|
4063
|
-
store.dispatch(setActiveOrganizationAccessId(null));
|
|
4064
4075
|
store.dispatch(setActiveWorkspaceId(null));
|
|
4065
4076
|
store.dispatch({ type: RESET_STATE });
|
|
4066
4077
|
store.dispatch({ type: resetStore });
|
|
@@ -4903,26 +4914,27 @@ class MainService extends BaseApiService {
|
|
|
4903
4914
|
}
|
|
4904
4915
|
}
|
|
4905
4916
|
store.dispatch(setCurrentUser(data.user));
|
|
4917
|
+
store.dispatch(addUsers(data.project_owners));
|
|
4906
4918
|
const organizationsData = data.organizations;
|
|
4907
4919
|
store.dispatch(setOrganizations(organizationsData));
|
|
4908
4920
|
const validProjects = projects.filter((project) => !project.invited);
|
|
4909
|
-
const
|
|
4921
|
+
const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
|
|
4922
|
+
const firstOrg = organizationsData.find((organization) => organization.has_access);
|
|
4910
4923
|
const currProjObj = projects.find((project) => project.id === currentProjectId);
|
|
4911
4924
|
const isOrgProject = !!(currProjObj == null ? void 0 : currProjObj.owner_organization);
|
|
4912
|
-
const userIsInProjectOrg = isOrgProject && organizationsData.some(
|
|
4925
|
+
const userIsInProjectOrg = isOrgProject && organizationsData.some(
|
|
4926
|
+
(organization) => organization.has_access && organization.id === currProjObj.owner_organization
|
|
4927
|
+
);
|
|
4913
4928
|
let currentOrgId = null;
|
|
4914
|
-
if (
|
|
4929
|
+
if (activeOrganizationId) {
|
|
4930
|
+
currentOrgId = activeOrganizationId;
|
|
4931
|
+
} else if (userIsInProjectOrg) {
|
|
4915
4932
|
currentOrgId = currProjObj.owner_organization;
|
|
4916
4933
|
} else if (firstOrg) {
|
|
4917
4934
|
currentOrgId = firstOrg.id;
|
|
4918
4935
|
}
|
|
4919
4936
|
if (currentOrgId) {
|
|
4920
|
-
|
|
4921
|
-
const orgUsersResultPromise = this.fetchOrganizationUsers(currentOrgId);
|
|
4922
|
-
const organizationAccessRefreshPromise = this.client.organizationAccess.refreshStore();
|
|
4923
|
-
const orgUsersResult = await orgUsersResultPromise;
|
|
4924
|
-
await organizationAccessRefreshPromise;
|
|
4925
|
-
store.dispatch(addUsers(orgUsersResult));
|
|
4937
|
+
await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
|
|
4926
4938
|
}
|
|
4927
4939
|
if (!isProjectIdValid) {
|
|
4928
4940
|
if (validProjects.length !== 0) {
|
|
@@ -4977,7 +4989,6 @@ class MainService extends BaseApiService {
|
|
|
4977
4989
|
void this.client.userForms.refreshStore().then(() => {
|
|
4978
4990
|
void this.client.userFormSubmissions.refreshStore().then();
|
|
4979
4991
|
});
|
|
4980
|
-
void this.client.emailDomains.refreshStore().then();
|
|
4981
4992
|
}
|
|
4982
4993
|
if (currentProjectId) {
|
|
4983
4994
|
const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
|
|
@@ -5689,16 +5700,8 @@ class OrganizationAccessService extends BaseApiService {
|
|
|
5689
5700
|
blockers: [],
|
|
5690
5701
|
blocks: []
|
|
5691
5702
|
});
|
|
5692
|
-
const currentUser = state.userReducer.currentUser;
|
|
5693
5703
|
const organizationAccesses = result;
|
|
5694
|
-
const activeOrganizationAccess = organizationAccesses.find(
|
|
5695
|
-
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
5696
|
-
);
|
|
5697
|
-
if (!activeOrganizationAccess) {
|
|
5698
|
-
throw new Error("Current user does not have an organization access instance");
|
|
5699
|
-
}
|
|
5700
5704
|
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
5701
|
-
store.dispatch(setActiveOrganizationAccessId(activeOrganizationAccess.offline_id));
|
|
5702
5705
|
}
|
|
5703
5706
|
}
|
|
5704
5707
|
const cachedRequestPromises = {};
|
|
@@ -5966,6 +5969,37 @@ class EmailDomainsService extends BaseApiService {
|
|
|
5966
5969
|
}
|
|
5967
5970
|
}
|
|
5968
5971
|
class OrganizationService extends BaseApiService {
|
|
5972
|
+
async fetchInitialOrganizationData(organizationId, showLoading) {
|
|
5973
|
+
if (showLoading) {
|
|
5974
|
+
this.client.store.dispatch(setIsFetchingInitialData(true));
|
|
5975
|
+
}
|
|
5976
|
+
return this.enqueueRequest({
|
|
5977
|
+
description: "Get initial organization data",
|
|
5978
|
+
method: HttpMethod.GET,
|
|
5979
|
+
url: `/organizations/${organizationId}/initial-data/`,
|
|
5980
|
+
payload: {},
|
|
5981
|
+
isAuthNeeded: true,
|
|
5982
|
+
blockers: [],
|
|
5983
|
+
blocks: [organizationId.toString()]
|
|
5984
|
+
}).then((result) => {
|
|
5985
|
+
this._processInitialOrganizationData(result, showLoading);
|
|
5986
|
+
return result;
|
|
5987
|
+
});
|
|
5988
|
+
}
|
|
5989
|
+
_processInitialOrganizationData(data, showLoading) {
|
|
5990
|
+
const { store } = this.client;
|
|
5991
|
+
const activeOrganization = data.organization;
|
|
5992
|
+
const organizationAccesses = data.organization_accesses;
|
|
5993
|
+
const emailDomains = data.email_domains;
|
|
5994
|
+
const users = data.users;
|
|
5995
|
+
store.dispatch(addUsers(users));
|
|
5996
|
+
store.dispatch(setActiveOrganizationId(activeOrganization.id));
|
|
5997
|
+
store.dispatch(setOrganizationAccesses(organizationAccesses));
|
|
5998
|
+
store.dispatch(setEmailDomains(emailDomains));
|
|
5999
|
+
if (showLoading) {
|
|
6000
|
+
store.dispatch(setIsFetchingInitialData(false));
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
5969
6003
|
async create(name) {
|
|
5970
6004
|
const result = await this.enqueueRequest({
|
|
5971
6005
|
description: "Create organization",
|
|
@@ -10978,6 +11012,7 @@ export {
|
|
|
10978
11012
|
selectOrganizationUsersAsMapping,
|
|
10979
11013
|
selectOrganizationUsersIds,
|
|
10980
11014
|
selectOrganizations,
|
|
11015
|
+
selectOrganizationsWithAccess,
|
|
10981
11016
|
selectPermittedWorkspaceIds,
|
|
10982
11017
|
selectPhotoAttachmentsOfIssue,
|
|
10983
11018
|
selectProjectAccess,
|
|
@@ -10999,6 +11034,7 @@ export {
|
|
|
10999
11034
|
selectSortedEmailDomains,
|
|
11000
11035
|
selectSortedOrganizationUsers,
|
|
11001
11036
|
selectSortedProjectUsers,
|
|
11037
|
+
selectSortedProjects,
|
|
11002
11038
|
selectStageMapping,
|
|
11003
11039
|
selectStages,
|
|
11004
11040
|
selectStagesFromComponentType,
|
|
@@ -11020,7 +11056,6 @@ export {
|
|
|
11020
11056
|
selectWorkspaceMapping,
|
|
11021
11057
|
selectWorkspaces,
|
|
11022
11058
|
setActiveIssueId,
|
|
11023
|
-
setActiveOrganizationAccessId,
|
|
11024
11059
|
setActiveOrganizationId,
|
|
11025
11060
|
setActiveProjectFileId,
|
|
11026
11061
|
setActiveProjectId,
|