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

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,
@@ -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
  );