@overmap-ai/core 1.0.63-selector-standardization.3 → 1.0.63-selector-standardization.5

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.
@@ -904,101 +904,12 @@ const selectIssueCountOfCategory = (categoryId) => (state) => {
904
904
  return Object.values(state.issueReducer.instances).filter((issue) => issue.category === categoryId).length;
905
905
  };
906
906
  const categoryReducer = categorySlice.reducer;
907
- const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
908
- const initialState$z = assetStageAdapter.getInitialState({});
909
- const assetStageSlice = createSlice({
910
- name: "assetStages",
911
- initialState: initialState$z,
912
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
913
- reducers: {
914
- initializeStages: assetStageAdapter.initialize,
915
- setStage: assetStageAdapter.setOne,
916
- addStages: assetStageAdapter.addMany,
917
- updateStage: assetStageAdapter.updateOne,
918
- updateStages: assetStageAdapter.updateMany,
919
- removeStages: assetStageAdapter.deleteMany
920
- }
921
- });
922
- const selectStageMapping = (state) => state.assetStageReducer.instances;
923
- const selectAssetStageById = restructureCreateSelectorWithArgs(
924
- createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
925
- return stageMapping[stageId];
926
- })
927
- );
928
- const selectAssetStages = createSelector([selectStageMapping], (stageMapping) => {
929
- return Object.values(stageMapping);
930
- });
931
- const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
932
- createSelector([selectAssetStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
933
- const assetTypeIdsSet = new Set(assetTypeIds);
934
- const ret = {};
935
- for (const stage of stages) {
936
- if (assetTypeIdsSet.has(stage.asset_type)) {
937
- if (!ret[stage.asset_type]) {
938
- ret[stage.asset_type] = [];
939
- }
940
- ret[stage.asset_type].push(stage);
941
- }
942
- }
943
- for (const key in ret) {
944
- ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
945
- }
946
- return ret;
947
- })
948
- );
949
- const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
950
- createSelector([selectStageMapping, (_state, assetTypeId) => assetTypeId], (stagesMapping, assetTypeId) => {
951
- const assetTypeStagesMapping = {};
952
- for (const [stageId, stage] of Object.entries(stagesMapping)) {
953
- if (stage.asset_type === assetTypeId) {
954
- assetTypeStagesMapping[stageId] = stage;
955
- }
956
- }
957
- return assetTypeStagesMapping;
958
- })
959
- );
960
- const selectStagesOfAssetType = restructureCreateSelectorWithArgs(
961
- createSelector([selectAssetStages, (_state, assetTypeId) => assetTypeId], (stages, assetTypeId) => {
962
- return stages.filter((stage) => stage.asset_type === assetTypeId).sort((a, b) => a.priority - b.priority);
963
- })
964
- );
965
- const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
966
- createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
967
- const assetStages = [];
968
- for (const stageId of stageIds) {
969
- const stage = stageMapping[stageId];
970
- if (stage) {
971
- assetStages.push(stage);
972
- } else {
973
- console.warn("selectStagesFromStageIds: No stage exists with the id", stageId);
974
- }
975
- }
976
- return assetStages;
977
- })
978
- );
979
- const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
980
- createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
981
- const ret = {};
982
- for (const stageId of stageIds) {
983
- const stage = stageMapping[stageId];
984
- if (!stage) {
985
- throw new Error("No stage exists with the id " + stageId);
986
- }
987
- if (stage.form) {
988
- ret[stageId] = stage.form;
989
- }
990
- }
991
- return ret;
992
- })
993
- );
994
- const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
995
- const assetStageReducer = assetStageSlice.reducer;
996
907
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
997
- const initialState$y = assetTypeAdapter.getInitialState({});
908
+ const initialState$z = assetTypeAdapter.getInitialState({});
998
909
  const assetTypeSlice = createSlice({
999
910
  name: "assetTypes",
1000
- initialState: initialState$y,
1001
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
911
+ initialState: initialState$z,
912
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1002
913
  reducers: {
1003
914
  initializeAssetTypes: assetTypeAdapter.initialize,
1004
915
  addAssetType: assetTypeAdapter.addOne,
@@ -1016,15 +927,15 @@ const selectAssetTypeById = (id) => (state) => {
1016
927
  };
1017
928
  const selectAssetTypesByIds = restructureCreateSelectorWithArgs(
1018
929
  createSelector(
1019
- [selectStageMapping, (_state, assetTypeIds) => assetTypeIds],
930
+ [selectAssetTypesMapping, (_state, assetTypeIds) => assetTypeIds],
1020
931
  (assetTypeMapping, assetTypeIds) => {
1021
932
  const assetTypes = [];
1022
- for (const stageId of assetTypeIds) {
1023
- const stage = assetTypeMapping[stageId];
1024
- if (stage) {
1025
- assetTypes.push(stage);
933
+ for (const assetTypeId of assetTypeIds) {
934
+ const assetType = assetTypeMapping[assetTypeId];
935
+ if (assetType) {
936
+ assetTypes.push(assetType);
1026
937
  } else {
1027
- console.warn("selectAssetTypesByIds: No stage exists with the id", stageId);
938
+ console.warn("selectAssetTypesByIds: No assetType exists with the id", assetTypeId);
1028
939
  }
1029
940
  }
1030
941
  return assetTypes;
@@ -1033,11 +944,11 @@ const selectAssetTypesByIds = restructureCreateSelectorWithArgs(
1033
944
  );
1034
945
  const assetTypeReducer = assetTypeSlice.reducer;
1035
946
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
1036
- const initialState$x = assetAdapter.getInitialState({});
947
+ const initialState$y = assetAdapter.getInitialState({});
1037
948
  const assetSlice = createSlice({
1038
949
  name: "assets",
1039
- initialState: initialState$x,
1040
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
950
+ initialState: initialState$y,
951
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1041
952
  reducers: {
1042
953
  initializeAssets: (state, action) => {
1043
954
  assetAdapter.initialize(state, action);
@@ -1139,11 +1050,11 @@ const selectNumberOfAssetsOfAssetType = (assetTypeId) => (state) => {
1139
1050
  };
1140
1051
  const assetReducer = assetSlice.reducer;
1141
1052
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1142
- const initialState$w = assetAttachmentAdapter.getInitialState({});
1053
+ const initialState$x = assetAttachmentAdapter.getInitialState({});
1143
1054
  const assetAttachmentSlice = createSlice({
1144
1055
  name: "assetAttachments",
1145
- initialState: initialState$w,
1146
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1056
+ initialState: initialState$x,
1057
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1147
1058
  reducers: {
1148
1059
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
1149
1060
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -1172,8 +1083,8 @@ const selectAssetAttachments = createSelector(
1172
1083
  [selectAssetAttachmentMapping],
1173
1084
  (mapping) => Object.values(mapping)
1174
1085
  );
1175
- const selectAssetAttachment = (attachmentId) => (state) => {
1176
- return state.assetAttachmentReducer.instances[attachmentId];
1086
+ const selectAssetAttachmentById = (id) => (state) => {
1087
+ return state.assetAttachmentReducer.instances[id];
1177
1088
  };
1178
1089
  const selectAttachmentsOfAsset = restructureCreateSelectorWithArgs(
1179
1090
  createSelector(
@@ -1201,13 +1112,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
1201
1112
  )
1202
1113
  );
1203
1114
  const assetAttachmentReducer = assetAttachmentSlice.reducer;
1204
- const initialState$v = {
1115
+ const initialState$w = {
1205
1116
  completionsByAssetId: {}
1206
1117
  };
1207
1118
  const assetStageCompletionSlice = createSlice({
1208
1119
  name: "assetStageCompletions",
1209
- initialState: initialState$v,
1210
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1120
+ initialState: initialState$w,
1121
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1211
1122
  reducers: {
1212
1123
  addStageCompletion: (state, action) => {
1213
1124
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1258,6 +1169,95 @@ const selectCompletedStageIdsForAsset = restructureCreateSelectorWithArgs(
1258
1169
  })
1259
1170
  );
1260
1171
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1172
+ const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1173
+ const initialState$v = assetStageAdapter.getInitialState({});
1174
+ const assetStageSlice = createSlice({
1175
+ name: "assetStages",
1176
+ initialState: initialState$v,
1177
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1178
+ reducers: {
1179
+ initializeStages: assetStageAdapter.initialize,
1180
+ setStage: assetStageAdapter.setOne,
1181
+ addStages: assetStageAdapter.addMany,
1182
+ updateStage: assetStageAdapter.updateOne,
1183
+ updateStages: assetStageAdapter.updateMany,
1184
+ removeStages: assetStageAdapter.deleteMany
1185
+ }
1186
+ });
1187
+ const selectStageMapping = (state) => state.assetStageReducer.instances;
1188
+ const selectAssetStageById = restructureCreateSelectorWithArgs(
1189
+ createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
1190
+ return stageMapping[stageId];
1191
+ })
1192
+ );
1193
+ const selectAssetStages = createSelector([selectStageMapping], (stageMapping) => {
1194
+ return Object.values(stageMapping);
1195
+ });
1196
+ const selectStagesFromAssetTypeIds = restructureCreateSelectorWithArgs(
1197
+ createSelector([selectAssetStages, (_state, assetTypeIds) => assetTypeIds], (stages, assetTypeIds) => {
1198
+ const assetTypeIdsSet = new Set(assetTypeIds);
1199
+ const ret = {};
1200
+ for (const stage of stages) {
1201
+ if (assetTypeIdsSet.has(stage.asset_type)) {
1202
+ if (!ret[stage.asset_type]) {
1203
+ ret[stage.asset_type] = [];
1204
+ }
1205
+ ret[stage.asset_type].push(stage);
1206
+ }
1207
+ }
1208
+ for (const key in ret) {
1209
+ ret[key] = ret[key].sort((a, b) => a.priority - b.priority);
1210
+ }
1211
+ return ret;
1212
+ })
1213
+ );
1214
+ const selectAssetTypeStagesMapping = restructureCreateSelectorWithArgs(
1215
+ createSelector([selectStageMapping, (_state, assetTypeId) => assetTypeId], (stagesMapping, assetTypeId) => {
1216
+ const assetTypeStagesMapping = {};
1217
+ for (const [stageId, stage] of Object.entries(stagesMapping)) {
1218
+ if (stage.asset_type === assetTypeId) {
1219
+ assetTypeStagesMapping[stageId] = stage;
1220
+ }
1221
+ }
1222
+ return assetTypeStagesMapping;
1223
+ })
1224
+ );
1225
+ const selectStagesOfAssetType = restructureCreateSelectorWithArgs(
1226
+ createSelector([selectAssetStages, (_state, assetTypeId) => assetTypeId], (stages, assetTypeId) => {
1227
+ return stages.filter((stage) => stage.asset_type === assetTypeId).sort((a, b) => a.priority - b.priority);
1228
+ })
1229
+ );
1230
+ const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
1231
+ createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1232
+ const assetStages = [];
1233
+ for (const stageId of stageIds) {
1234
+ const stage = stageMapping[stageId];
1235
+ if (stage) {
1236
+ assetStages.push(stage);
1237
+ } else {
1238
+ console.warn("selectStagesFromStageIds: No stage exists with the id", stageId);
1239
+ }
1240
+ }
1241
+ return assetStages;
1242
+ })
1243
+ );
1244
+ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1245
+ createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
1246
+ const ret = {};
1247
+ for (const stageId of stageIds) {
1248
+ const stage = stageMapping[stageId];
1249
+ if (!stage) {
1250
+ throw new Error("No stage exists with the id " + stageId);
1251
+ }
1252
+ if (stage.form) {
1253
+ ret[stageId] = stage.form;
1254
+ }
1255
+ }
1256
+ return ret;
1257
+ })
1258
+ );
1259
+ const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
1260
+ const assetStageReducer = assetStageSlice.reducer;
1261
1261
  const assetTypeAttachmentAdapter = createModelAdapter(
1262
1262
  (attachment) => attachment.offline_id
1263
1263
  );
@@ -1294,8 +1294,8 @@ const selectAssetTypeAttachments = createSelector(
1294
1294
  [selectAssetTypeAttachmentMapping],
1295
1295
  (mapping) => Object.values(mapping)
1296
1296
  );
1297
- const selectAssetTypeAttachment = (attachmentId) => (state) => {
1298
- return state.assetTypeAttachmentReducer.instances[attachmentId];
1297
+ const selectAssetTypeAttachmentById = (id) => (state) => {
1298
+ return state.assetTypeAttachmentReducer.instances[id];
1299
1299
  };
1300
1300
  const selectAttachmentsOfAssetType = restructureCreateSelectorWithArgs(
1301
1301
  createSelector(
@@ -2256,7 +2256,7 @@ const selectAllProjectAttachments = createSelector(
2256
2256
  [selectProjectAttachmentMapping],
2257
2257
  (mapping) => Object.values(mapping)
2258
2258
  );
2259
- const selectProjectAttachment = (id) => (state) => {
2259
+ const selectProjectAttachmentById = (id) => (state) => {
2260
2260
  return state.projectAttachmentReducer.instances[id];
2261
2261
  };
2262
2262
  const selectAttachmentsOfProject = restructureCreateSelectorWithArgs(
@@ -3056,8 +3056,8 @@ const selectAllDocumentAttachments = createSelector(
3056
3056
  [selectDocumentAttachmentMapping],
3057
3057
  (mapping) => Object.values(mapping)
3058
3058
  );
3059
- const selectDocumentAttachment = (attachmentId) => (state) => {
3060
- return state.documentAttachmentReducer.instances[attachmentId];
3059
+ const selectDocumentAttachmentById = (id) => (state) => {
3060
+ return state.documentAttachmentReducer.instances[id];
3061
3061
  };
3062
3062
  const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
3063
3063
  createSelector(
@@ -4750,7 +4750,7 @@ class AssetAttachmentService extends BaseAttachmentService {
4750
4750
  __publicField(this, "removeAttachments", deleteAssetAttachments);
4751
4751
  __publicField(this, "removeAttachment", deleteAssetAttachment);
4752
4752
  __publicField(this, "setAttachment", setAssetAttachment);
4753
- __publicField(this, "selectAttachment", selectAssetAttachment);
4753
+ __publicField(this, "selectAttachment", selectAssetAttachmentById);
4754
4754
  }
4755
4755
  buildOfflineAttachment(data) {
4756
4756
  return offline({
@@ -4850,7 +4850,7 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4850
4850
  __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
4851
4851
  __publicField(this, "removeAttachment", deleteAssetTypeAttachment);
4852
4852
  __publicField(this, "setAttachment", setAssetTypeAttachment);
4853
- __publicField(this, "selectAttachment", selectAssetTypeAttachment);
4853
+ __publicField(this, "selectAttachment", selectAssetTypeAttachmentById);
4854
4854
  }
4855
4855
  buildOfflineAttachment(data) {
4856
4856
  return offline({
@@ -5450,7 +5450,7 @@ class ProjectAttachmentService extends BaseAttachmentService {
5450
5450
  __publicField(this, "removeAttachments", deleteProjectAttachments);
5451
5451
  __publicField(this, "removeAttachment", deleteProjectAttachment);
5452
5452
  __publicField(this, "setAttachment", setProjectAttachment);
5453
- __publicField(this, "selectAttachment", selectProjectAttachment);
5453
+ __publicField(this, "selectAttachment", selectProjectAttachmentById);
5454
5454
  }
5455
5455
  buildOfflineAttachment(data) {
5456
5456
  return offline({
@@ -6993,7 +6993,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6993
6993
  __publicField(this, "removeAttachments", deleteDocumentAttachments);
6994
6994
  __publicField(this, "removeAttachment", deleteDocumentAttachment);
6995
6995
  __publicField(this, "setAttachment", setDocumentAttachment);
6996
- __publicField(this, "selectAttachment", selectDocumentAttachment);
6996
+ __publicField(this, "selectAttachment", selectDocumentAttachmentById);
6997
6997
  }
6998
6998
  buildOfflineAttachment(data) {
6999
6999
  return offline({
@@ -7840,7 +7840,7 @@ export {
7840
7840
  selectAllDocumentAttachments,
7841
7841
  selectAllProjectAttachments,
7842
7842
  selectAncestorIdsOfDocument,
7843
- selectAssetAttachment,
7843
+ selectAssetAttachmentById,
7844
7844
  selectAssetAttachmentMapping,
7845
7845
  selectAssetAttachments,
7846
7846
  selectAssetById,
@@ -7848,7 +7848,7 @@ export {
7848
7848
  selectAssetStages,
7849
7849
  selectAssetStagesByIds,
7850
7850
  selectAssetToAssetTypeMapping,
7851
- selectAssetTypeAttachment,
7851
+ selectAssetTypeAttachmentById,
7852
7852
  selectAssetTypeAttachmentMapping,
7853
7853
  selectAssetTypeAttachments,
7854
7854
  selectAssetTypeById,
@@ -7887,7 +7887,7 @@ export {
7887
7887
  selectConversations,
7888
7888
  selectCurrentUser,
7889
7889
  selectDeletedRequests,
7890
- selectDocumentAttachment,
7890
+ selectDocumentAttachmentById,
7891
7891
  selectDocumentAttachmentMapping,
7892
7892
  selectDocumentById,
7893
7893
  selectDocuments,
@@ -7978,7 +7978,7 @@ export {
7978
7978
  selectProjectAccessMapping,
7979
7979
  selectProjectAccessUserMapping,
7980
7980
  selectProjectAccesses,
7981
- selectProjectAttachment,
7981
+ selectProjectAttachmentById,
7982
7982
  selectProjectAttachmentMapping,
7983
7983
  selectProjectById,
7984
7984
  selectProjectFileById,