@overmap-ai/core 1.0.63-selector-standardization.7 → 1.0.63-selector-standardization.9
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 +30 -120
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +30 -120
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/FormService.d.ts +2 -2
- package/dist/store/slices/assetSlice.d.ts +39 -13
- package/dist/store/slices/emailDomainsSlice.d.ts +6 -2
- package/dist/store/slices/formRevisionSlice.d.ts +1 -2
- package/dist/store/slices/formSlice.d.ts +8 -4
- package/dist/store/slices/licenseSlice.d.ts +0 -1
- package/dist/store/slices/organizationSlice.d.ts +7 -4
- package/dist/store/slices/userSlice.d.ts +0 -1
- package/dist/typings/models/assets.d.ts +1 -0
- package/dist/typings/models/forms.d.ts +1 -0
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -950,42 +950,15 @@ const assetSlice = createSlice({
|
|
|
950
950
|
initialState: initialState$y,
|
|
951
951
|
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
|
|
952
952
|
reducers: {
|
|
953
|
-
initializeAssets:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
assetAdapter.addMany(state, action);
|
|
963
|
-
prevAssets = null;
|
|
964
|
-
},
|
|
965
|
-
setAsset: (state, action) => {
|
|
966
|
-
assetAdapter.setOne(state, action);
|
|
967
|
-
prevAssets = null;
|
|
968
|
-
},
|
|
969
|
-
setAssets: (state, action) => {
|
|
970
|
-
assetAdapter.setMany(state, action);
|
|
971
|
-
prevAssets = null;
|
|
972
|
-
},
|
|
973
|
-
updateAsset: (state, action) => {
|
|
974
|
-
assetAdapter.updateOne(state, action);
|
|
975
|
-
prevAssets = null;
|
|
976
|
-
},
|
|
977
|
-
updateAssets: (state, action) => {
|
|
978
|
-
assetAdapter.updateMany(state, action);
|
|
979
|
-
prevAssets = null;
|
|
980
|
-
},
|
|
981
|
-
deleteAsset: (state, action) => {
|
|
982
|
-
assetAdapter.deleteOne(state, action);
|
|
983
|
-
prevAssets = null;
|
|
984
|
-
},
|
|
985
|
-
deleteAssets: (state, action) => {
|
|
986
|
-
assetAdapter.deleteMany(state, action);
|
|
987
|
-
prevAssets = null;
|
|
988
|
-
}
|
|
953
|
+
initializeAssets: assetAdapter.initialize,
|
|
954
|
+
addAsset: assetAdapter.addOne,
|
|
955
|
+
addAssets: assetAdapter.addMany,
|
|
956
|
+
setAsset: assetAdapter.setOne,
|
|
957
|
+
setAssets: assetAdapter.setMany,
|
|
958
|
+
updateAsset: assetAdapter.updateOne,
|
|
959
|
+
updateAssets: assetAdapter.updateMany,
|
|
960
|
+
deleteAsset: assetAdapter.deleteOne,
|
|
961
|
+
deleteAssets: assetAdapter.deleteMany
|
|
989
962
|
}
|
|
990
963
|
});
|
|
991
964
|
const {
|
|
@@ -999,13 +972,6 @@ const {
|
|
|
999
972
|
setAsset,
|
|
1000
973
|
setAssets
|
|
1001
974
|
} = assetSlice.actions;
|
|
1002
|
-
let prevAssets = null;
|
|
1003
|
-
const _selectAssets = (state) => {
|
|
1004
|
-
if (!prevAssets) {
|
|
1005
|
-
prevAssets = Object.values(state.assetReducer.instances);
|
|
1006
|
-
}
|
|
1007
|
-
return prevAssets;
|
|
1008
|
-
};
|
|
1009
975
|
const selectAssetsMapping = (state) => state.assetReducer.instances;
|
|
1010
976
|
const selectAssets = createSelector([selectAssetsMapping], (assetsMapping) => {
|
|
1011
977
|
return Object.values(assetsMapping);
|
|
@@ -1742,11 +1708,6 @@ const {
|
|
|
1742
1708
|
const userReducer = userSlice.reducer;
|
|
1743
1709
|
const selectCurrentUser = (state) => state.userReducer.currentUser;
|
|
1744
1710
|
const selectUsersMapping = (state) => state.userReducer.users;
|
|
1745
|
-
const selectUser = (userId) => (state) => {
|
|
1746
|
-
if (userId === null)
|
|
1747
|
-
return void 0;
|
|
1748
|
-
return state.userReducer.users[userId];
|
|
1749
|
-
};
|
|
1750
1711
|
const selectUserById = (id) => (state) => {
|
|
1751
1712
|
return state.userReducer.users[id];
|
|
1752
1713
|
};
|
|
@@ -1825,9 +1786,6 @@ const selectLicenses = (state) => {
|
|
|
1825
1786
|
return state.licenseReducer.instances;
|
|
1826
1787
|
};
|
|
1827
1788
|
const selectLicense = (id) => (state) => state.licenseReducer.instances[id];
|
|
1828
|
-
const selectActiveLicense = (state) => Object.values(state.licenseReducer.instances).find(
|
|
1829
|
-
(license) => license.project === state.projectReducer.activeProjectId
|
|
1830
|
-
) ?? null;
|
|
1831
1789
|
const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.instances).find((license) => license.project === projectId);
|
|
1832
1790
|
const selectActiveStatusLicenses = createSelector(
|
|
1833
1791
|
[selectLicenses],
|
|
@@ -2018,19 +1976,19 @@ const organizationSlice = createSlice({
|
|
|
2018
1976
|
}
|
|
2019
1977
|
});
|
|
2020
1978
|
const { setOrganizations } = organizationSlice.actions;
|
|
2021
|
-
const selectOrganizations = (state) => {
|
|
2022
|
-
return Object.values(state.organizationReducer.organizations);
|
|
2023
|
-
};
|
|
2024
1979
|
const selectOrganizationsMapping = (state) => {
|
|
2025
1980
|
return state.organizationReducer.organizations;
|
|
2026
1981
|
};
|
|
1982
|
+
const selectOrganizations = createSelector([selectOrganizationsMapping], (organizationsMapping) => {
|
|
1983
|
+
return Object.values(organizationsMapping);
|
|
1984
|
+
});
|
|
1985
|
+
const selectOrganizationById = (id) => (state) => {
|
|
1986
|
+
return state.organizationReducer.organizations[id];
|
|
1987
|
+
};
|
|
2027
1988
|
const selectOrganizationsWithAccess = createSelector(
|
|
2028
1989
|
[selectOrganizations],
|
|
2029
1990
|
(organizations) => Object.values(organizations).filter((organization) => organization.has_access)
|
|
2030
1991
|
);
|
|
2031
|
-
const selectOrganizationById = (id) => (state) => {
|
|
2032
|
-
return state.organizationReducer.organizations[id];
|
|
2033
|
-
};
|
|
2034
1992
|
const selectOrganizationUsersIds = createSelector(
|
|
2035
1993
|
[selectOrganizationAccesses],
|
|
2036
1994
|
(organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
|
|
@@ -2073,9 +2031,6 @@ const selectSortedOrganizationUsers = createSelector(
|
|
|
2073
2031
|
});
|
|
2074
2032
|
}
|
|
2075
2033
|
);
|
|
2076
|
-
const selectOrganization = (id) => (state) => {
|
|
2077
|
-
return state.organizationReducer.organizations[id];
|
|
2078
|
-
};
|
|
2079
2034
|
const organizationReducer = organizationSlice.reducer;
|
|
2080
2035
|
const createOfflineAction = (request2, baseUrl, serviceName) => {
|
|
2081
2036
|
const requestWithUuid = request2.uuid ? request2 : { ...request2, uuid: v4() };
|
|
@@ -2380,32 +2335,6 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
2380
2335
|
}
|
|
2381
2336
|
)
|
|
2382
2337
|
);
|
|
2383
|
-
const selectLatestFormRevisionsOfAssetTypes = restructureCreateSelectorWithArgs(
|
|
2384
|
-
createSelector(
|
|
2385
|
-
[
|
|
2386
|
-
(state) => state.formReducer.instances,
|
|
2387
|
-
selectFormRevisionMapping,
|
|
2388
|
-
(_state, assetTypeIds) => assetTypeIds
|
|
2389
|
-
],
|
|
2390
|
-
(formsMapping, revisions, assetTypeIds) => {
|
|
2391
|
-
const assetTypeIdsSet = new Set(assetTypeIds);
|
|
2392
|
-
const formsOfAssetTypes = {};
|
|
2393
|
-
const ret = {};
|
|
2394
|
-
for (const form of Object.values(formsMapping)) {
|
|
2395
|
-
if (form.asset_type && assetTypeIdsSet.has(form.asset_type)) {
|
|
2396
|
-
formsOfAssetTypes[form.offline_id] = form;
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
for (const revision of Object.values(revisions)) {
|
|
2400
|
-
const form = formsOfAssetTypes[revision.form];
|
|
2401
|
-
if (!form || !form.asset_type || ret[form.asset_type] && formRevisionSortFn(ret[form.asset_type], revision) > 0)
|
|
2402
|
-
continue;
|
|
2403
|
-
ret[form.asset_type] = revision;
|
|
2404
|
-
}
|
|
2405
|
-
return ret;
|
|
2406
|
-
}
|
|
2407
|
-
)
|
|
2408
|
-
);
|
|
2409
2338
|
const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
|
|
2410
2339
|
const latestRevisions = {};
|
|
2411
2340
|
for (const revision of Object.values(revisions)) {
|
|
@@ -2434,9 +2363,13 @@ const formSlice = createSlice({
|
|
|
2434
2363
|
}
|
|
2435
2364
|
});
|
|
2436
2365
|
const { initializeForms, setForm, addForm, addForms, updateForm, deleteForm } = formSlice.actions;
|
|
2437
|
-
const
|
|
2366
|
+
const formReducer = formSlice.reducer;
|
|
2367
|
+
const selectFormMapping = (state) => {
|
|
2438
2368
|
return state.formReducer.instances;
|
|
2439
2369
|
};
|
|
2370
|
+
const selectForms = createSelector([selectFormMapping], (formsMapping) => {
|
|
2371
|
+
return Object.values(formsMapping);
|
|
2372
|
+
});
|
|
2440
2373
|
const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
2441
2374
|
createSelector(
|
|
2442
2375
|
[
|
|
@@ -2473,9 +2406,6 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
2473
2406
|
{ memoizeOptions: { equalityCheck: shallowEqual } }
|
|
2474
2407
|
)
|
|
2475
2408
|
);
|
|
2476
|
-
const selectFormMapping = (state) => {
|
|
2477
|
-
return state.formReducer.instances;
|
|
2478
|
-
};
|
|
2479
2409
|
const selectFormById = (formId) => (state) => {
|
|
2480
2410
|
return state.formReducer.instances[formId];
|
|
2481
2411
|
};
|
|
@@ -2501,7 +2431,6 @@ const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
|
|
|
2501
2431
|
const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
|
|
2502
2432
|
return Object.values(formsMapping).filter((form) => !form.asset_type).length;
|
|
2503
2433
|
});
|
|
2504
|
-
const formReducer = formSlice.reducer;
|
|
2505
2434
|
const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
|
|
2506
2435
|
const initialState$d = submissionAdapter.getInitialState({});
|
|
2507
2436
|
const formSubmissionSlice = createSlice({
|
|
@@ -2820,7 +2749,7 @@ const emailDomainsSlice = createSlice({
|
|
|
2820
2749
|
});
|
|
2821
2750
|
const { initializeEmailDomains, addEmailDomain, deleteEmailDomain } = emailDomainsSlice.actions;
|
|
2822
2751
|
const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.instances;
|
|
2823
|
-
const selectEmailDomains = (
|
|
2752
|
+
const selectEmailDomains = createSelector([selectEmailDomainsAsMapping], (mapping) => Object.values(mapping));
|
|
2824
2753
|
const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
|
|
2825
2754
|
createSelector(
|
|
2826
2755
|
[selectEmailDomains, (_, organizationId) => organizationId],
|
|
@@ -4312,7 +4241,6 @@ class AssetService extends BaseApiService {
|
|
|
4312
4241
|
}
|
|
4313
4242
|
// TODO: payload does not require asset_type
|
|
4314
4243
|
bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
|
|
4315
|
-
const { store } = this.client;
|
|
4316
4244
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4317
4245
|
const transactionId = v4();
|
|
4318
4246
|
const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
|
|
@@ -4356,7 +4284,7 @@ class AssetService extends BaseApiService {
|
|
|
4356
4284
|
}
|
|
4357
4285
|
void Promise.all(batchPromises).then((result) => {
|
|
4358
4286
|
const allCreatedAssets = result.flat();
|
|
4359
|
-
|
|
4287
|
+
this.dispatch(addAssets(allCreatedAssets));
|
|
4360
4288
|
});
|
|
4361
4289
|
return batchPromises;
|
|
4362
4290
|
}
|
|
@@ -4777,13 +4705,11 @@ class AssetAttachmentService extends BaseAttachmentService {
|
|
|
4777
4705
|
class AssetTypeService extends BaseApiService {
|
|
4778
4706
|
add(assetType) {
|
|
4779
4707
|
const offlineAssetType = offline(assetType);
|
|
4780
|
-
const { store } = this.client;
|
|
4781
|
-
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
4782
4708
|
this.dispatch(addAssetType(offlineAssetType));
|
|
4783
4709
|
const promise = this.enqueueRequest({
|
|
4784
4710
|
description: "Create asset type",
|
|
4785
4711
|
method: HttpMethod.POST,
|
|
4786
|
-
url: `/projects/${
|
|
4712
|
+
url: `/projects/${assetType.project}/asset-types/`,
|
|
4787
4713
|
payload: { ...offlineAssetType },
|
|
4788
4714
|
blockers: [],
|
|
4789
4715
|
blocks: [offlineAssetType.offline_id]
|
|
@@ -5778,10 +5704,6 @@ class FormService extends BaseUploadService {
|
|
|
5778
5704
|
const offlineRevision = offline(revision);
|
|
5779
5705
|
const { store } = this.client;
|
|
5780
5706
|
const state = store.getState();
|
|
5781
|
-
const activeProjectId = state.projectReducer.activeProjectId;
|
|
5782
|
-
if (!activeProjectId) {
|
|
5783
|
-
throw new Error("Cannot create form revision when there is no active project.");
|
|
5784
|
-
}
|
|
5785
5707
|
const currentUserId = state.userReducer.currentUser.id;
|
|
5786
5708
|
const { fields, images } = await separateImageFromFields(offlineRevision.fields);
|
|
5787
5709
|
const fullRevision = {
|
|
@@ -5820,10 +5742,9 @@ class FormService extends BaseUploadService {
|
|
|
5820
5742
|
});
|
|
5821
5743
|
return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
|
|
5822
5744
|
}
|
|
5823
|
-
async favorite(formId) {
|
|
5745
|
+
async favorite(formId, projectId) {
|
|
5824
5746
|
const { store } = this.client;
|
|
5825
5747
|
const state = store.getState();
|
|
5826
|
-
const activeProjectId = state.projectReducer.activeProjectId;
|
|
5827
5748
|
const form = state.formReducer.instances[formId];
|
|
5828
5749
|
if (!form) {
|
|
5829
5750
|
throw new Error(`Expected form to exist, got ${form}`);
|
|
@@ -5833,7 +5754,7 @@ class FormService extends BaseUploadService {
|
|
|
5833
5754
|
await this.enqueueRequest({
|
|
5834
5755
|
description: "Favorite form",
|
|
5835
5756
|
method: HttpMethod.POST,
|
|
5836
|
-
url: `/forms/${formId}/favorite/${
|
|
5757
|
+
url: `/forms/${formId}/favorite/${projectId}/`,
|
|
5837
5758
|
blockers: [formId, `favorite-${formId}`],
|
|
5838
5759
|
blocks: [`favorite-${formId}`]
|
|
5839
5760
|
});
|
|
@@ -5842,10 +5763,9 @@ class FormService extends BaseUploadService {
|
|
|
5842
5763
|
throw e;
|
|
5843
5764
|
}
|
|
5844
5765
|
}
|
|
5845
|
-
async unfavorite(formId) {
|
|
5766
|
+
async unfavorite(formId, projectId) {
|
|
5846
5767
|
const { store } = this.client;
|
|
5847
5768
|
const state = store.getState();
|
|
5848
|
-
const activeProjectId = state.projectReducer.activeProjectId;
|
|
5849
5769
|
const form = state.formReducer.instances[formId];
|
|
5850
5770
|
if (!form) {
|
|
5851
5771
|
throw new Error(`Expected form to exist, got ${form}`);
|
|
@@ -5855,7 +5775,7 @@ class FormService extends BaseUploadService {
|
|
|
5855
5775
|
return await this.enqueueRequest({
|
|
5856
5776
|
description: "Unfavorite form",
|
|
5857
5777
|
method: HttpMethod.DELETE,
|
|
5858
|
-
url: `/forms/${formId}/unfavorite/${
|
|
5778
|
+
url: `/forms/${formId}/unfavorite/${projectId}/`,
|
|
5859
5779
|
blockers: [formId, `favorite-${formId}`],
|
|
5860
5780
|
blocks: [`favorite-${formId}`]
|
|
5861
5781
|
});
|
|
@@ -6067,10 +5987,6 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
6067
5987
|
async add(payload) {
|
|
6068
5988
|
const { store } = this.client;
|
|
6069
5989
|
const state = store.getState();
|
|
6070
|
-
const activeProjectId = state.projectReducer.activeProjectId;
|
|
6071
|
-
if (!activeProjectId) {
|
|
6072
|
-
throw new Error("Expected an active project");
|
|
6073
|
-
}
|
|
6074
5990
|
const { values, files } = separateFilesFromValues(payload.values);
|
|
6075
5991
|
const offlineSubmission = offline({
|
|
6076
5992
|
...payload,
|
|
@@ -6082,7 +5998,7 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
6082
5998
|
description: "Respond to form",
|
|
6083
5999
|
method: HttpMethod.POST,
|
|
6084
6000
|
url: `/forms/revisions/${payload.form_revision}/respond/`,
|
|
6085
|
-
payload:
|
|
6001
|
+
payload: offlineSubmission,
|
|
6086
6002
|
blockers: [payload.issue, payload.asset, payload.asset_stage, "add-form-entry"].filter(
|
|
6087
6003
|
(x) => x !== void 0
|
|
6088
6004
|
),
|
|
@@ -6303,13 +6219,12 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
6303
6219
|
}
|
|
6304
6220
|
class WorkspaceService extends BaseApiService {
|
|
6305
6221
|
add(workspace) {
|
|
6306
|
-
const { store } = this.client;
|
|
6307
6222
|
const offlineWorkspace = offline(workspace);
|
|
6308
6223
|
this.dispatch(addWorkspace(offlineWorkspace));
|
|
6309
6224
|
const promise = this.enqueueRequest({
|
|
6310
6225
|
description: "Create Workspace",
|
|
6311
6226
|
method: HttpMethod.POST,
|
|
6312
|
-
url: `/projects/${
|
|
6227
|
+
url: `/projects/${workspace.project}/workspaces/`,
|
|
6313
6228
|
payload: offlineWorkspace,
|
|
6314
6229
|
blockers: ["add-workspace"],
|
|
6315
6230
|
blocks: [offlineWorkspace.offline_id]
|
|
@@ -7571,7 +7486,6 @@ export {
|
|
|
7571
7486
|
VerificationCodeType,
|
|
7572
7487
|
WorkspaceService,
|
|
7573
7488
|
YELLOW,
|
|
7574
|
-
_selectAssets,
|
|
7575
7489
|
_selectLatestFormRevision,
|
|
7576
7490
|
_setLatestRetryTime,
|
|
7577
7491
|
acceptProjectInvite,
|
|
@@ -7834,7 +7748,6 @@ export {
|
|
|
7834
7748
|
saveActiveProjectFileBounds,
|
|
7835
7749
|
searchIssues,
|
|
7836
7750
|
selectAccessToken,
|
|
7837
|
-
selectActiveLicense,
|
|
7838
7751
|
selectActiveOrganizationAccess,
|
|
7839
7752
|
selectActiveProject,
|
|
7840
7753
|
selectActiveProjectAccess,
|
|
@@ -7922,8 +7835,8 @@ export {
|
|
|
7922
7835
|
selectFormSubmissionsOfAsset,
|
|
7923
7836
|
selectFormSubmissionsOfForm,
|
|
7924
7837
|
selectFormSubmissionsOfIssue,
|
|
7838
|
+
selectForms,
|
|
7925
7839
|
selectFormsCount,
|
|
7926
|
-
selectFormsMapping,
|
|
7927
7840
|
selectGeneralFormCount,
|
|
7928
7841
|
selectGeoImageById,
|
|
7929
7842
|
selectGeoImageMapping,
|
|
@@ -7956,7 +7869,6 @@ export {
|
|
|
7956
7869
|
selectIssuesOfIssueTypeCount,
|
|
7957
7870
|
selectLatestFormRevisionByForm,
|
|
7958
7871
|
selectLatestFormRevisionOfForm,
|
|
7959
|
-
selectLatestFormRevisionsOfAssetTypes,
|
|
7960
7872
|
selectLatestRetryTime,
|
|
7961
7873
|
selectLicense,
|
|
7962
7874
|
selectLicenseForProject,
|
|
@@ -7965,7 +7877,6 @@ export {
|
|
|
7965
7877
|
selectLicensesOfOrganization,
|
|
7966
7878
|
selectMainWorkspace,
|
|
7967
7879
|
selectNumberOfAssetsOfAssetType,
|
|
7968
|
-
selectOrganization,
|
|
7969
7880
|
selectOrganizationAccessById,
|
|
7970
7881
|
selectOrganizationAccessForUser,
|
|
7971
7882
|
selectOrganizationAccessUserMapping,
|
|
@@ -8010,7 +7921,6 @@ export {
|
|
|
8010
7921
|
selectTeamsOfOrganization,
|
|
8011
7922
|
selectTeamsOfUser,
|
|
8012
7923
|
selectUploadUrl,
|
|
8013
|
-
selectUser,
|
|
8014
7924
|
selectUserById,
|
|
8015
7925
|
selectUsersByIds,
|
|
8016
7926
|
selectUsersMapping,
|