@lls/store 24.6.0-20da3b9c → 24.6.0-3c93fe5b

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.
Files changed (2) hide show
  1. package/lib/index.js +65 -58
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -742,7 +742,8 @@ var getToken = _.get("auth.token");
742
742
 
743
743
  // src/selectors/school.ts
744
744
  init_define_import_meta();
745
- import { makeEntitiesFilter } from "@lls/utils";
745
+ import { makeEntitiesFilter, pipe } from "@lls/utils";
746
+ import _2 from "lodash/fp.js";
746
747
 
747
748
  // src/selectors/crud.ts
748
749
  init_define_import_meta();
@@ -777,15 +778,21 @@ var makeUseSearch = (makeSearchElements) => {
777
778
  };
778
779
 
779
780
  // src/selectors/school.ts
780
- var search = ({ ids }) => makeEntitiesFilter({ id: ids });
781
+ var search = ({ ids, academyIds, sortByQuery }) => {
782
+ return (schools) => pipe(
783
+ schools,
784
+ makeEntitiesFilter({ id: ids, academy: academyIds }),
785
+ _2.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _2.sortBy(sortByQuery) : _2.identity
786
+ );
787
+ };
781
788
  var { getSchools, getSchool, useSearchSchools } = crud("schools", {
782
789
  search
783
790
  });
784
791
 
785
792
  // src/selectors/book.ts
786
793
  init_define_import_meta();
787
- import { createSearchSelector as createSearchSelector2, makeEntitiesFilter as makeEntitiesFilter2, makeGetEntityById as makeGetEntityById2, pipe } from "@lls/utils";
788
- import _2 from "lodash/fp.js";
794
+ import { createSearchSelector as createSearchSelector2, makeEntitiesFilter as makeEntitiesFilter2, makeGetEntityById as makeGetEntityById2, pipe as pipe2 } from "@lls/utils";
795
+ import _3 from "lodash/fp.js";
789
796
  var search2 = ({
790
797
  ids,
791
798
  levelIds,
@@ -803,7 +810,7 @@ var search2 = ({
803
810
  isRenewed,
804
811
  isPrimary
805
812
  }) => {
806
- return (books) => pipe(
813
+ return (books) => pipe2(
807
814
  books,
808
815
  makeEntitiesFilter2({
809
816
  id: ids,
@@ -821,13 +828,13 @@ var search2 = ({
821
828
  isRenewed,
822
829
  isPrimary
823
830
  }),
824
- _2.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _2.sortBy(sortByQuery) : _2.identity
831
+ _3.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _3.sortBy(sortByQuery) : _3.identity
825
832
  );
826
833
  };
827
834
  var { getBooks, getBook, filterBooks, useSearchBooks, makeSearchBooks } = crud("books", {
828
835
  search: search2
829
836
  });
830
- var makeSearchValidBooks = () => createSearchSelector2(makeSearchBooks(), (books) => _2.filter({ valid: true, hasNewDesign: true }, books));
837
+ var makeSearchValidBooks = () => createSearchSelector2(makeSearchBooks(), (books) => _3.filter({ valid: true, hasNewDesign: true }, books));
831
838
  var useSearchValidBooks = makeUseSearch(makeSearchValidBooks);
832
839
  var makeGetBook = () => makeGetEntityById2("books");
833
840
 
@@ -847,18 +854,18 @@ var getCurrentUser = makeGetCurrentUser();
847
854
 
848
855
  // src/selectors/chapter.ts
849
856
  init_define_import_meta();
850
- import { makeEntitiesFilter as makeEntitiesFilter4, pipe as pipe2 } from "@lls/utils";
851
- import _3 from "lodash/fp.js";
852
- var search4 = ({ bookIds, ids, hasTeacherBook, sortByQuery }) => (chapters) => pipe2(
857
+ import { makeEntitiesFilter as makeEntitiesFilter4, pipe as pipe3 } from "@lls/utils";
858
+ import _4 from "lodash/fp.js";
859
+ var search4 = ({ bookIds, ids, hasTeacherBook, sortByQuery }) => (chapters) => pipe3(
853
860
  chapters,
854
861
  makeEntitiesFilter4(
855
862
  {
856
863
  book: bookIds,
857
864
  id: ids
858
865
  },
859
- !_3.isNil(hasTeacherBook) && ((chapter2) => !!chapter2?.teacherBook === hasTeacherBook)
866
+ !_4.isNil(hasTeacherBook) && ((chapter2) => !!chapter2?.teacherBook === hasTeacherBook)
860
867
  ),
861
- _3.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _3.sortBy(sortByQuery) : _3.identity
868
+ _4.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _4.sortBy(sortByQuery) : _4.identity
862
869
  );
863
870
  var { getChapters, getChapter, useSearchChapters } = crud("chapters", {
864
871
  search: search4
@@ -866,8 +873,8 @@ var { getChapters, getChapter, useSearchChapters } = crud("chapters", {
866
873
 
867
874
  // src/selectors/page.ts
868
875
  init_define_import_meta();
869
- import { makeEntitiesFilter as makeEntitiesFilter5, pipe as pipe3 } from "@lls/utils";
870
- import _4 from "lodash/fp.js";
876
+ import { makeEntitiesFilter as makeEntitiesFilter5, pipe as pipe4 } from "@lls/utils";
877
+ import _5 from "lodash/fp.js";
871
878
  var search5 = ({
872
879
  ids,
873
880
  chapterIds,
@@ -892,7 +899,7 @@ var search5 = ({
892
899
  sortByQuery
893
900
  }) => {
894
901
  let pageById = false;
895
- return (pages) => pipe3(
902
+ return (pages) => pipe4(
896
903
  pages,
897
904
  makeEntitiesFilter5(
898
905
  {
@@ -916,12 +923,12 @@ var search5 = ({
916
923
  isDraft
917
924
  },
918
925
  isParentCreatedFromScratch && ((page2, pages2) => {
919
- pageById = pageById || _4.keyBy("id", pages2);
920
- return !!_4.get([page2?.originalPage, "isCreatedFromScratch"], pageById);
926
+ pageById = pageById || _5.keyBy("id", pages2);
927
+ return !!_5.get([page2?.originalPage, "isCreatedFromScratch"], pageById);
921
928
  }),
922
- updatedAfter && _4.flow(_4.get("updatedAt"), (date) => new Date(date).getTime() - updatedAfter.getTime() >= 0)
929
+ updatedAfter && _5.flow(_5.get("updatedAt"), (date) => new Date(date).getTime() - updatedAfter.getTime() >= 0)
923
930
  ),
924
- _4.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _4.sortBy(sortByQuery) : _4.identity
931
+ _5.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _5.sortBy(sortByQuery) : _5.identity
925
932
  );
926
933
  };
927
934
  var { getPages, getPage, filterPages, useSearchPages, makeSearchPages } = crud("pages", {
@@ -935,8 +942,8 @@ var { useSearchPages: useSearchModifiedPages } = crud("pages", { search: searchM
935
942
 
936
943
  // src/selectors/collection.ts
937
944
  init_define_import_meta();
938
- import _5 from "lodash/fp.js";
939
- var search6 = (_params) => _5.identity;
945
+ import _6 from "lodash/fp.js";
946
+ var search6 = (_params) => _6.identity;
940
947
  var { getCollections, getCollection, useSearchCollections } = crud("collections", {
941
948
  search: search6
942
949
  });
@@ -959,8 +966,8 @@ var { getCommunityProjects, getCommunityProject, useSearchCommunityProjects } =
959
966
 
960
967
  // src/selectors/contact.ts
961
968
  init_define_import_meta();
962
- import _6 from "lodash/fp.js";
963
- var search8 = (_params) => _6.identity;
969
+ import _7 from "lodash/fp.js";
970
+ var search8 = (_params) => _7.identity;
964
971
  var { getContacts, getContact, useSearchContacts } = crud("contacts", {
965
972
  search: search8
966
973
  });
@@ -972,7 +979,7 @@ var search9 = ({ ids, read, pageIds }) => {
972
979
  return makeEntitiesFilter7({ read, id: ids, page: pageIds });
973
980
  };
974
981
  var makeSearchCopyNotifications = () => createSearchSelector3(
975
- [makeGetCurrentUser(), makeGetAllEntities2("copyNotifications"), (_18, params) => params],
982
+ [makeGetCurrentUser(), makeGetAllEntities2("copyNotifications"), (_19, params) => params],
976
983
  (currentUser, copyNotifications, { pageIds, read }) => {
977
984
  const ids = currentUser?.copyNotifications;
978
985
  return search9({ ids, read, pageIds })(copyNotifications);
@@ -1000,7 +1007,7 @@ var search11 = ({ ids, read, pageIds }) => {
1000
1007
  return makeEntitiesFilter9({ read, id: ids, page: pageIds });
1001
1008
  };
1002
1009
  var makeSearchDrawerNotifications = () => createSearchSelector4(
1003
- [makeGetCurrentUser(), makeGetAllEntities3("drawerNotifications"), (_18, params) => params],
1010
+ [makeGetCurrentUser(), makeGetAllEntities3("drawerNotifications"), (_19, params) => params],
1004
1011
  (currentUser, drawerNotifications, { read, pageIds }) => {
1005
1012
  const ids = currentUser?.drawerNotifications;
1006
1013
  return search11({ ids, read, pageIds })(drawerNotifications);
@@ -1015,8 +1022,8 @@ var getFaqs = makeGetAllEntities4("faq");
1015
1022
 
1016
1023
  // src/selectors/garDivision.ts
1017
1024
  init_define_import_meta();
1018
- import _7 from "lodash/fp.js";
1019
- var search12 = (_params) => _7.identity;
1025
+ import _8 from "lodash/fp.js";
1026
+ var search12 = (_params) => _8.identity;
1020
1027
  var { getGarDivisions, getGarDivision, useSearchGarDivisions } = crud("garDivisions", {
1021
1028
  search: search12
1022
1029
  });
@@ -1025,8 +1032,8 @@ var { getGarDivisions, getGarDivision, useSearchGarDivisions } = crud("garDivisi
1025
1032
  init_define_import_meta();
1026
1033
  var import_reselect2 = __toESM(require_lib(), 1);
1027
1034
  import { makeEntitiesFilter as makeEntitiesFilter10 } from "@lls/utils";
1028
- import _8 from "lodash/fp.js";
1029
- var search13 = ({ ownerIds }) => _8.flow(makeEntitiesFilter10({ owner: ownerIds }), _8.orderBy("createdAt", ["desc"]));
1035
+ import _9 from "lodash/fp.js";
1036
+ var search13 = ({ ownerIds }) => _9.flow(makeEntitiesFilter10({ owner: ownerIds }), _9.orderBy("createdAt", ["desc"]));
1030
1037
  var { getGroups, getGroup, useSearchGroups } = crud("groups", {
1031
1038
  search: search13
1032
1039
  });
@@ -1039,7 +1046,7 @@ var getUserGroups = (0, import_reselect2.createSelector)(
1039
1046
  init_define_import_meta();
1040
1047
  var import_reselect3 = __toESM(require_lib(), 1);
1041
1048
  import { makeEntitiesFilter as makeEntitiesFilter11 } from "@lls/utils";
1042
- import _9 from "lodash/fp.js";
1049
+ import _10 from "lodash/fp.js";
1043
1050
  var search14 = ({
1044
1051
  ids,
1045
1052
  slugs,
@@ -1049,7 +1056,7 @@ var search14 = ({
1049
1056
  isProHighSchool,
1050
1057
  isGenHighSchool,
1051
1058
  isElementarySchool
1052
- }) => _9.flow(
1059
+ }) => _10.flow(
1053
1060
  makeEntitiesFilter11({
1054
1061
  id: ids,
1055
1062
  slug: slugs,
@@ -1060,20 +1067,20 @@ var search14 = ({
1060
1067
  isGenHighSchool,
1061
1068
  isElementarySchool
1062
1069
  }),
1063
- _9.orderBy("order", "desc")
1070
+ _10.orderBy("order", "desc")
1064
1071
  );
1065
1072
  var crudLevels = crud("levels", { search: search14 });
1066
1073
  var { getLevel, useSearchLevels } = crudLevels;
1067
- var getLevels = (0, import_reselect3.createSelector)(crudLevels.getLevels, _9.orderBy("order", "desc"));
1074
+ var getLevels = (0, import_reselect3.createSelector)(crudLevels.getLevels, _10.orderBy("order", "desc"));
1068
1075
 
1069
1076
  // src/selectors/mainNotification.ts
1070
1077
  init_define_import_meta();
1071
1078
  var import_reselect4 = __toESM(require_lib(), 1);
1072
1079
  import { makeEntitiesFilter as makeEntitiesFilter12, makeGetAllEntities as makeGetAllEntities5 } from "@lls/utils";
1073
- import _10 from "lodash/fp.js";
1080
+ import _11 from "lodash/fp.js";
1074
1081
  var search15 = ({ ids }) => makeEntitiesFilter12({ id: ids });
1075
1082
  var getMainNotifications = (0, import_reselect4.createSelector)(
1076
- [_10.flow(makeGetCurrentUser(), _10.get("mainNotifications")), makeGetAllEntities5("mainNotifications")],
1083
+ [_11.flow(makeGetCurrentUser(), _11.get("mainNotifications")), makeGetAllEntities5("mainNotifications")],
1077
1084
  (userNotifications, notifications) => search15({ ids: userNotifications })(notifications)
1078
1085
  );
1079
1086
 
@@ -1112,7 +1119,7 @@ var { getLexicalFlowers, useSearchLexicalFlowers } = crud("lexicalFlowers", {
1112
1119
 
1113
1120
  // src/selectors/product.ts
1114
1121
  init_define_import_meta();
1115
- import _11 from "lodash/fp.js";
1122
+ import _12 from "lodash/fp.js";
1116
1123
  import { createSearchSelector as createSearchSelector5, makeEntitiesFilter as makeEntitiesFilter16, makeGetAllEntities as makeGetAllEntities6 } from "@lls/utils";
1117
1124
  var getProducts = makeGetAllEntities6("products");
1118
1125
  var search19 = ({
@@ -1136,7 +1143,7 @@ var search19 = ({
1136
1143
  levelIds || subjectIds ? (product2) => !!product2?.books?.some((bookId) => bookIds.has(bookId)) : false
1137
1144
  );
1138
1145
  return (products, books) => {
1139
- bookIds = new Set(_11.flow(_11.map("id"), _11.map(_11.parseInt(10)))(books));
1146
+ bookIds = new Set(_12.flow(_12.map("id"), _12.map(_12.parseInt(10)))(books));
1140
1147
  return filter(products);
1141
1148
  };
1142
1149
  };
@@ -1172,7 +1179,7 @@ var { getSchoolTypes, getSchoolType, useSearchSchoolTypes, makeSearchSchoolTypes
1172
1179
  // src/selectors/sharedPage.ts
1173
1180
  init_define_import_meta();
1174
1181
  import { createSearchSelector as createSearchSelector6, makeEntitiesFilter as makeEntitiesFilter19 } from "@lls/utils";
1175
- import _12 from "lodash/fp.js";
1182
+ import _13 from "lodash/fp.js";
1176
1183
  var search22 = ({
1177
1184
  parentIds,
1178
1185
  userIds,
@@ -1197,7 +1204,7 @@ var makeSearchCurrentUserSharedPages = () => createSearchSelector6(
1197
1204
  (__, params) => params,
1198
1205
  (user2, sharedPages, params) => {
1199
1206
  const sharedUserPageIds = user2?.sharedPages ?? [];
1200
- return search22({ ...params, ids: _12.intersection(sharedUserPageIds, params.ids || sharedUserPageIds) })(sharedPages);
1207
+ return search22({ ...params, ids: _13.intersection(sharedUserPageIds, params.ids || sharedUserPageIds) })(sharedPages);
1201
1208
  }
1202
1209
  );
1203
1210
  var useSearchCurrentUserSharedPages = makeUseSearch(makeSearchCurrentUserSharedPages);
@@ -1212,8 +1219,8 @@ var { getStudents, getStudent, useSearchStudents } = crud("students", {
1212
1219
 
1213
1220
  // src/selectors/subject.ts
1214
1221
  init_define_import_meta();
1215
- import { limitToTeacherSubjects, makeEntitiesFilter as makeEntitiesFilter21, pipe as pipe4 } from "@lls/utils";
1216
- import _13 from "lodash/fp.js";
1222
+ import { limitToTeacherSubjects, makeEntitiesFilter as makeEntitiesFilter21, pipe as pipe5 } from "@lls/utils";
1223
+ import _14 from "lodash/fp.js";
1217
1224
  var search24 = ({
1218
1225
  ids,
1219
1226
  slugs,
@@ -1223,7 +1230,7 @@ var search24 = ({
1223
1230
  hasBooks,
1224
1231
  names,
1225
1232
  sortByQuery
1226
- }) => (subjects) => pipe4(
1233
+ }) => (subjects) => pipe5(
1227
1234
  subjects,
1228
1235
  makeEntitiesFilter21(
1229
1236
  {
@@ -1233,10 +1240,10 @@ var search24 = ({
1233
1240
  hasBooks,
1234
1241
  schoolTypes
1235
1242
  },
1236
- !_13.isNil(hasNewsletterUrl) && ((subject2) => Boolean(subject2?.newsletterUrl) === hasNewsletterUrl)
1243
+ !_14.isNil(hasNewsletterUrl) && ((subject2) => Boolean(subject2?.newsletterUrl) === hasNewsletterUrl)
1237
1244
  ),
1238
- (subjects2) => _13.isNil(isTeacherSubject) ? subjects2 : limitToTeacherSubjects(subjects2),
1239
- _13.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _13.sortBy(sortByQuery) : _13.identity
1245
+ (subjects2) => _14.isNil(isTeacherSubject) ? subjects2 : limitToTeacherSubjects(subjects2),
1246
+ _14.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _14.sortBy(sortByQuery) : _14.identity
1240
1247
  );
1241
1248
  var { getSubjects, getSubject, useSearchSubjects, makeSearchSubjects } = crud("subjects", {
1242
1249
  search: search24
@@ -1289,8 +1296,8 @@ var { getBuilderIos, getBuilderIo, useSearchBuilderIos } = crud("builderIos", {
1289
1296
 
1290
1297
  // src/selectors/circonscription.ts
1291
1298
  init_define_import_meta();
1292
- import _14 from "lodash/fp.js";
1293
- var search29 = (_params) => _14.identity;
1299
+ import _15 from "lodash/fp.js";
1300
+ var search29 = (_params) => _15.identity;
1294
1301
  var { getCirconscriptions } = crud("circonscriptions", {
1295
1302
  search: search29
1296
1303
  });
@@ -1298,7 +1305,7 @@ var { getCirconscriptions } = crud("circonscriptions", {
1298
1305
  // src/reducers/entities.ts
1299
1306
  init_define_import_meta();
1300
1307
  import { makeReducer } from "@lls/utils";
1301
- import _15 from "lodash/fp.js";
1308
+ import _16 from "lodash/fp.js";
1302
1309
 
1303
1310
  // src/actions/index.ts
1304
1311
  init_define_import_meta();
@@ -1321,16 +1328,16 @@ var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
1321
1328
  // src/reducers/entities.ts
1322
1329
  var deleteEntityReducer = (state, payload) => {
1323
1330
  const { path } = payload;
1324
- return _15.omit(path, state);
1331
+ return _16.omit(path, state);
1325
1332
  };
1326
1333
  var updateEntityReducer = (state, payload) => {
1327
1334
  const { path, entity } = payload;
1328
- const currentEntity = _15.get(path, state);
1329
- return _15.set(path, _15.merge(currentEntity, entity), state);
1335
+ const currentEntity = _16.get(path, state);
1336
+ return _16.set(path, _16.merge(currentEntity, entity), state);
1330
1337
  };
1331
1338
  var setEntityReducer = (state, payload) => {
1332
1339
  const { path, entity } = payload;
1333
- return _15.set(path, entity, state);
1340
+ return _16.set(path, entity, state);
1334
1341
  };
1335
1342
  var setEntitiesReducer = (state, payload) => {
1336
1343
  if (typeof payload !== "object") return state;
@@ -1351,7 +1358,7 @@ var setEntitiesReducer = (state, payload) => {
1351
1358
  }
1352
1359
  const diff = Object.keys(entity).some((prop) => {
1353
1360
  const value = entity[prop];
1354
- if (!_15.isEqual(state[entityName]?.[id]?.[prop], value)) {
1361
+ if (!_16.isEqual(state[entityName]?.[id]?.[prop], value)) {
1355
1362
  return true;
1356
1363
  }
1357
1364
  });
@@ -1383,7 +1390,7 @@ var entities_default = entities;
1383
1390
  // src/reducers/auth.ts
1384
1391
  init_define_import_meta();
1385
1392
  import { makeReducer as makeReducer2 } from "@lls/utils";
1386
- import _16 from "lodash/fp.js";
1393
+ import _17 from "lodash/fp.js";
1387
1394
  var initialState = {
1388
1395
  id: void 0,
1389
1396
  role: null,
@@ -1396,15 +1403,15 @@ var initialState = {
1396
1403
  llsUserId: null
1397
1404
  };
1398
1405
  var auth = makeReducer2(initialState, {
1399
- [actionTypes.SET_AUTH]: _16.assign,
1400
- [actionTypes.RESET_AUTH]: _16.constant(initialState)
1406
+ [actionTypes.SET_AUTH]: _17.assign,
1407
+ [actionTypes.RESET_AUTH]: _17.constant(initialState)
1401
1408
  });
1402
1409
  var auth_default = auth;
1403
1410
 
1404
1411
  // src/schema/index.ts
1405
1412
  init_define_import_meta();
1406
1413
  var import_normalizr = __toESM(require_normalizr(), 1);
1407
- import _17 from "lodash/fp.js";
1414
+ import _18 from "lodash/fp.js";
1408
1415
  var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
1409
1416
  var subject = new import_normalizr.schema.Entity("subjects");
1410
1417
  var level = new import_normalizr.schema.Entity("levels");
@@ -1610,7 +1617,7 @@ var querySchema = {
1610
1617
  }
1611
1618
  }
1612
1619
  };
1613
- var normalizeData = _17.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1620
+ var normalizeData = _18.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1614
1621
  export {
1615
1622
  auth_default as authReducer,
1616
1623
  entities_default as entitiesReducer,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@lls/store",
3
3
  "description": "model de donnée et selecteurs",
4
4
  "homepage": "https://github.com/lelivrescolaire/monorepo/tree/dev/libs/store",
5
- "version": "24.6.0-20da3b9c",
5
+ "version": "24.6.0-3c93fe5b",
6
6
  "type": "module",
7
7
  "types": "./lib/builttypes/store/src/index.d.ts",
8
8
  "exports": {
@@ -49,8 +49,8 @@
49
49
  "vite": "5.4.10",
50
50
  "vite-tsconfig-paths": "5.1.0",
51
51
  "vitest": "2.1.4",
52
- "@lls/utils": "24.6.0-20da3b9c",
53
- "@lls/vitescripts": "24.6.0-20da3b9c"
52
+ "@lls/utils": "24.6.0-3c93fe5b",
53
+ "@lls/vitescripts": "24.6.0-3c93fe5b"
54
54
  },
55
55
  "license": "ISC",
56
56
  "dependencies": {