@lls/store 24.1.59-0fc150f7 → 24.1.59-10c33c33

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 +97 -586
  2. package/package.json +11 -11
package/lib/index.js CHANGED
@@ -198,7 +198,7 @@ var require_lib = __commonJS({
198
198
  for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
199
199
  memoizeOptionsFromArgs[_key - 1] = arguments[_key];
200
200
  }
201
- var createSelector6 = function createSelector7() {
201
+ var createSelector3 = function createSelector4() {
202
202
  for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
203
203
  funcs[_key2] = arguments[_key2];
204
204
  }
@@ -247,13 +247,13 @@ var require_lib = __commonJS({
247
247
  });
248
248
  return selector;
249
249
  };
250
- return createSelector6;
250
+ return createSelector3;
251
251
  }
252
- var createSelector5 = /* @__PURE__ */ createSelectorCreator(_defaultMemoize.defaultMemoize);
253
- exports.createSelector = createSelector5;
252
+ var createSelector2 = /* @__PURE__ */ createSelectorCreator(_defaultMemoize.defaultMemoize);
253
+ exports.createSelector = createSelector2;
254
254
  var createStructuredSelector = function createStructuredSelector2(selectors, selectorCreator) {
255
255
  if (selectorCreator === void 0) {
256
- selectorCreator = createSelector5;
256
+ selectorCreator = createSelector2;
257
257
  }
258
258
  if (typeof selectors !== "object") {
259
259
  throw new Error("createStructuredSelector expects first argument to be an object " + ("where each property is a selector, instead received a " + typeof selectors));
@@ -733,49 +733,49 @@ var require_normalizr = __commonJS({
733
733
  // src/index.ts
734
734
  init_define_import_meta();
735
735
 
736
- // src/selectors/auth.ts
737
- init_define_import_meta();
738
- import _ from "lodash/fp.js";
739
- var getAuth = _.get("auth");
740
- var getIsLogged = _.flow(_.get("auth.id"), _.negate(_.isNil));
741
- var getToken = _.get("auth.token");
742
-
743
736
  // src/selectors/school.ts
744
737
  init_define_import_meta();
745
- import { makeEntitiesFilter } from "@lls/utils";
738
+ import { filterEntitiesSimpleFieldByValues } from "@lls/utils";
739
+ import _2 from "lodash/fp.js";
746
740
 
747
741
  // src/selectors/crud.ts
748
742
  init_define_import_meta();
749
743
  import { createSearchSelector, makeGetAllEntities, makeGetEntityById } from "@lls/utils";
750
- var crud = (entityName, { search: search24 }) => {
744
+ import _ from "lodash/fp.js";
745
+ var crud = (entityName, { search: search5 }) => {
751
746
  const getElements = makeGetAllEntities(entityName);
752
747
  const makeSearchElements = () => createSearchSelector(
753
748
  getElements,
754
749
  (_state, params) => params,
755
- (elements, params) => search24(params)(elements)
750
+ (elements, params) => search5(params)(elements)
756
751
  );
757
- const methodName = `${entityName.charAt(0).toUpperCase()}${entityName.slice(1)}`;
752
+ const methodName = _.capitalize(entityName);
758
753
  const getElementById = makeGetEntityById(entityName);
759
754
  const back = {
760
755
  [`get${methodName}`]: getElements,
761
756
  [`search${methodName}`]: makeSearchElements(),
762
757
  [`get${methodName.replace(/s$/, "")}`]: getElementById,
763
- [`makeSearch${methodName}`]: makeSearchElements,
764
- [`filter${methodName}`]: search24
758
+ [`makeSearch${methodName}`]: makeSearchElements
765
759
  };
766
760
  return back;
767
761
  };
768
762
 
769
763
  // src/selectors/school.ts
770
- var search = ({ ids }) => makeEntitiesFilter({ id: ids });
764
+ var search = ({ ids }) => _2.flow(filterEntitiesSimpleFieldByValues("id", ids));
771
765
  var { getSchools, getSchool, searchSchools, makeSearchSchools } = crud("schools", {
772
766
  search
773
767
  });
774
768
 
775
769
  // src/selectors/book.ts
776
770
  init_define_import_meta();
777
- import { createSearchSelector as createSearchSelector2, makeEntitiesFilter as makeEntitiesFilter2, makeGetEntityById as makeGetEntityById2, pipe } from "@lls/utils";
778
- import _2 from "lodash/fp.js";
771
+ import {
772
+ createSearchSelector as createSearchSelector2,
773
+ filterEntitiesArrayFieldByValues,
774
+ filterEntitiesSimpleFieldByValue,
775
+ filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues2,
776
+ makeGetEntityById as makeGetEntityById2
777
+ } from "@lls/utils";
778
+ import _3 from "lodash/fp.js";
779
779
  var search2 = ({
780
780
  ids,
781
781
  levelIds,
@@ -792,43 +792,45 @@ var search2 = ({
792
792
  publishers,
793
793
  isRenewed,
794
794
  isPrimary
795
- }) => {
796
- return (books) => pipe(
797
- books,
798
- makeEntitiesFilter2({
799
- id: ids,
800
- year: years,
801
- levels: levelIds,
802
- subjects: subjectIds,
803
- valid: isValid,
804
- publishers,
805
- hasNewDesign,
806
- isWorkbook,
807
- isWorkplan,
808
- hasNoTeacherBook,
809
- slug: slugs,
810
- uri: uris,
811
- isRenewed,
812
- isPrimary
813
- }),
814
- _2.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _2.sortBy(sortByQuery) : _2.identity
815
- );
816
- };
795
+ }) => _3.flow(
796
+ filterEntitiesSimpleFieldByValues2("id", ids),
797
+ filterEntitiesSimpleFieldByValues2("year", years),
798
+ filterEntitiesArrayFieldByValues("levels", levelIds),
799
+ filterEntitiesArrayFieldByValues("subjects", subjectIds),
800
+ filterEntitiesSimpleFieldByValues2("valid", _3.isNil(isValid) ? void 0 : [isValid]),
801
+ filterEntitiesSimpleFieldByValues2("publisher", publishers),
802
+ filterEntitiesSimpleFieldByValues2("hasNewDesign", _3.isNil(hasNewDesign) ? void 0 : [hasNewDesign]),
803
+ filterEntitiesSimpleFieldByValues2("isWorkbook", _3.isNil(isWorkbook) ? void 0 : [isWorkbook]),
804
+ filterEntitiesSimpleFieldByValues2("isWorkplan", _3.isNil(isWorkplan) ? void 0 : [isWorkplan]),
805
+ filterEntitiesSimpleFieldByValues2("hasNoTeacherBook", _3.isNil(hasNoTeacherBook) ? void 0 : [hasNoTeacherBook]),
806
+ filterEntitiesSimpleFieldByValues2("slug", slugs),
807
+ filterEntitiesSimpleFieldByValues2("uri", uris),
808
+ filterEntitiesSimpleFieldByValues2("isRenewed", _3.isNil(isRenewed) ? void 0 : [isRenewed]),
809
+ filterEntitiesSimpleFieldByValue("isPrimary", isPrimary),
810
+ _3.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _3.sortBy(sortByQuery) : _3.identity
811
+ );
817
812
  var { getBooks, getBook, searchBooks, makeSearchBooks } = crud("books", {
818
813
  search: search2
819
814
  });
820
- var makeSearchValidBooks = () => createSearchSelector2(makeSearchBooks(), (books) => _2.filter({ valid: true, hasNewDesign: true }, books));
815
+ var makeSearchValidBooks = () => createSearchSelector2(makeSearchBooks(), (books) => _3.filter({ valid: true, hasNewDesign: true }, books));
821
816
  var searchValidBooks = makeSearchValidBooks();
822
817
  var makeGetBook = () => makeGetEntityById2("books");
823
818
 
824
819
  // src/selectors/user.ts
825
820
  init_define_import_meta();
826
821
  var import_reselect = __toESM(require_lib(), 1);
827
- import { makeEntitiesFilter as makeEntitiesFilter3 } from "@lls/utils";
828
- var search3 = ({ ids, schoolIds }) => makeEntitiesFilter3({
829
- schools: schoolIds,
830
- id: ids
831
- });
822
+ import { filterEntitiesArrayFieldByValues as filterEntitiesArrayFieldByValues2, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues3 } from "@lls/utils";
823
+ import _5 from "lodash/fp.js";
824
+
825
+ // src/selectors/auth.ts
826
+ init_define_import_meta();
827
+ import _4 from "lodash/fp.js";
828
+ var getAuth = _4.get("auth");
829
+ var getIsLogged = _4.flow(_4.get("auth.id"), _4.negate(_4.isNil));
830
+ var getToken = _4.get("auth.token");
831
+
832
+ // src/selectors/user.ts
833
+ var search3 = ({ ids, schoolIds }) => _5.flow(filterEntitiesArrayFieldByValues2("schools", schoolIds), filterEntitiesSimpleFieldByValues3("id", ids));
832
834
  var { getUsers, getUser, searchUsers, makeSearchUsers } = crud("users", {
833
835
  search: search3
834
836
  });
@@ -840,414 +842,21 @@ var getCurrentUser = (0, import_reselect.createSelector)(
840
842
 
841
843
  // src/selectors/chapter.ts
842
844
  init_define_import_meta();
843
- import { makeEntitiesFilter as makeEntitiesFilter4 } from "@lls/utils";
844
- import _3 from "lodash/fp.js";
845
- var search4 = ({ bookIds, ids, hasTeacherBook }) => makeEntitiesFilter4(
846
- {
847
- book: bookIds,
848
- id: ids
849
- },
850
- !_3.isNil(hasTeacherBook) && ((chapter2) => !!chapter2?.teacherBook === hasTeacherBook)
845
+ import { filterEntitiesFieldExists, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues4 } from "@lls/utils";
846
+ import _6 from "lodash/fp.js";
847
+ var search4 = ({ bookIds, ids, hasTeacherBook }) => _6.flow(
848
+ filterEntitiesSimpleFieldByValues4("book", bookIds),
849
+ filterEntitiesSimpleFieldByValues4("id", ids),
850
+ filterEntitiesFieldExists("teacherBook", hasTeacherBook)
851
851
  );
852
852
  var { getChapters, getChapter, searchChapters, makeSearchChapters } = crud("chapters", {
853
853
  search: search4
854
854
  });
855
855
 
856
- // src/selectors/page.ts
857
- init_define_import_meta();
858
- import { createSearchSelector as createSearchSelector3, makeEntitiesFilter as makeEntitiesFilter5, makeGetAllEntities as makeGetAllEntities2, makeGetEntityById as makeGetEntityById3 } from "@lls/utils";
859
- import _4 from "lodash/fp.js";
860
- var search5 = ({
861
- ids,
862
- chapterIds,
863
- isValid,
864
- oldLessonIds,
865
- premium,
866
- thematicNames,
867
- bookIds,
868
- isOriginal,
869
- hasNewDesign,
870
- slugs,
871
- isLearningAssessment,
872
- isCreatedFromScratch,
873
- userIds,
874
- parentIds,
875
- originalPageIds,
876
- sharedUserIds,
877
- sharedGroups,
878
- isDraft,
879
- isParentCreatedFromScratch,
880
- updatedAfter
881
- }) => {
882
- let pageById = false;
883
- return makeEntitiesFilter5(
884
- {
885
- id: ids,
886
- chapter: chapterIds,
887
- valid: isValid,
888
- isOriginal,
889
- hasNewDesign,
890
- slug: slugs,
891
- oldLesson: oldLessonIds,
892
- isLearningAssessment,
893
- isCreatedFromScratch,
894
- premium,
895
- thematicName: thematicNames,
896
- book: bookIds,
897
- parent: parentIds,
898
- user: userIds,
899
- originalPage: originalPageIds,
900
- sharedUsers: sharedUserIds,
901
- sharedGroups,
902
- isDraft
903
- },
904
- isParentCreatedFromScratch && ((page2, pages) => {
905
- pageById = pageById || _4.keyBy("id", pages);
906
- return !!_4.get([page2?.originalPage, "isCreatedFromScratch"], pageById);
907
- }),
908
- updatedAfter && _4.flow(_4.get("updatedAt"), (date) => new Date(date) - updatedAfter >= 0)
909
- );
910
- };
911
- var { getPages, getPage, searchPages, makeSearchPages, filterPages } = crud("pages", {
912
- search: search5
913
- });
914
- var getDraftPages = makeGetAllEntities2("drafts");
915
- var makeGetDraftPage = () => makeGetEntityById3("drafts");
916
- var getDraftPage = makeGetDraftPage();
917
- var makeSearchDraftPages = () => createSearchSelector3(
918
- getDraftPages,
919
- (_state, params) => params,
920
- (pages, params) => search5(params)(pages)
921
- );
922
- var searchDraftPages = makeSearchDraftPages();
923
- var makeSearchModifiedPages = () => createSearchSelector3(
924
- getPages,
925
- (_state, params) => params,
926
- (pages, params) => search5({ ...params, isOriginal: false })(pages)
927
- );
928
- var searchModifiedPages = makeSearchModifiedPages();
929
-
930
- // src/selectors/collection.ts
931
- init_define_import_meta();
932
- import _5 from "lodash/fp.js";
933
- var search6 = (_params) => _5.identity;
934
- var { getCollections, getCollection, searchCollections, makeSearchCollections } = crud("collections", {
935
- search: search6
936
- });
937
-
938
- // src/selectors/communityProject.ts
939
- init_define_import_meta();
940
- import { makeEntitiesFilter as makeEntitiesFilter6 } from "@lls/utils";
941
- var search7 = ({
942
- slugs,
943
- isFeatured,
944
- projectTypes
945
- }) => makeEntitiesFilter6({
946
- slug: slugs,
947
- isFeatured,
948
- projectTypes
949
- });
950
- var { getCommunityProjects, getCommunityProject, searchCommunityProjects, makeSearchCommunityProjects } = crud(
951
- "communityProjects",
952
- {
953
- search: search7
954
- }
955
- );
956
-
957
- // src/selectors/contact.ts
958
- init_define_import_meta();
959
- import _6 from "lodash/fp.js";
960
- var search8 = (_params) => _6.identity;
961
- var { getContacts, getContact, searchContacts, makeSearchContacts } = crud("contacts", {
962
- search: search8
963
- });
964
-
965
- // src/selectors/copyNotification.ts
966
- init_define_import_meta();
967
- import { createSearchSelector as createSearchSelector4, makeEntitiesFilter as makeEntitiesFilter7, makeGetAllEntities as makeGetAllEntities3 } from "@lls/utils";
968
- var getCopyNotifications = makeGetAllEntities3("copyNotifications");
969
- var makeSearchCopyNotifications = () => createSearchSelector4(
970
- [getCurrentUser, getCopyNotifications, (_17, params) => params],
971
- (currentUser, copyNotifications, { pageIds, read }) => {
972
- const ids = currentUser?.copyNotifications;
973
- return makeEntitiesFilter7({ id: ids, read, page: pageIds })(copyNotifications);
974
- }
975
- );
976
- var searchCopyNotifications = makeSearchCopyNotifications();
977
-
978
- // src/selectors/drawerNotification.ts
979
- init_define_import_meta();
980
- import { createSearchSelector as createSearchSelector5, makeEntitiesFilter as makeEntitiesFilter8, makeGetAllEntities as makeGetAllEntities4 } from "@lls/utils";
981
- var getDrawerNotifications = makeGetAllEntities4("drawerNotifications");
982
- var makeSearchDrawerNotifications = () => createSearchSelector5(
983
- [getCurrentUser, getDrawerNotifications, (_17, params) => params],
984
- (currentUser, drawerNotifications, { read, pageIds }) => {
985
- const ids = currentUser?.drawerNotifications;
986
- return makeEntitiesFilter8({ id: ids, read, page: pageIds })(drawerNotifications);
987
- }
988
- );
989
- var searchDrawerNotifications = makeSearchDrawerNotifications();
990
-
991
- // src/selectors/faq.ts
992
- init_define_import_meta();
993
- import { makeGetAllEntities as makeGetAllEntities5 } from "@lls/utils";
994
- var getFaqs = makeGetAllEntities5("faq");
995
-
996
- // src/selectors/garDivision.ts
997
- init_define_import_meta();
998
- import _7 from "lodash/fp.js";
999
- var search9 = (_params) => _7.identity;
1000
- var { getGarDivisions, getGarDivision, searchGarDivisions, makeSearchGarDivisions } = crud("garDivisions", {
1001
- search: search9
1002
- });
1003
-
1004
- // src/selectors/group.ts
1005
- init_define_import_meta();
1006
- var import_reselect2 = __toESM(require_lib(), 1);
1007
- import { makeEntitiesFilter as makeEntitiesFilter9 } from "@lls/utils";
1008
- import _8 from "lodash/fp.js";
1009
- var search10 = ({ ownerIds }) => _8.flow(makeEntitiesFilter9({ owner: ownerIds }), _8.orderBy("createdAt", ["desc"]));
1010
- var { getGroups, getGroup, searchGroups, makeSearchGroups } = crud("groups", {
1011
- search: search10
1012
- });
1013
- var getUserGroups = (0, import_reselect2.createSelector)(
1014
- [getGroups, getCurrentUser],
1015
- (groups, currentUser) => search10({ ownerIds: [currentUser?.id] })(groups)
1016
- );
1017
-
1018
- // src/selectors/level.ts
1019
- init_define_import_meta();
1020
- var import_reselect3 = __toESM(require_lib(), 1);
1021
- import { makeEntitiesFilter as makeEntitiesFilter10 } from "@lls/utils";
1022
- import _9 from "lodash/fp.js";
1023
- var search11 = ({
1024
- ids,
1025
- slugs,
1026
- isPreSchool,
1027
- isMiddleSchool,
1028
- isHighSchool,
1029
- isProHighSchool,
1030
- isGenHighSchool,
1031
- isElementarySchool
1032
- }) => _9.flow(
1033
- makeEntitiesFilter10({
1034
- id: ids,
1035
- slug: slugs,
1036
- isPreSchool,
1037
- isMiddleSchool,
1038
- isHighSchool,
1039
- isProHighSchool,
1040
- isGenHighSchool,
1041
- isElementarySchool
1042
- }),
1043
- _9.orderBy("order", "desc")
1044
- );
1045
- var crudLevels = crud("levels", { search: search11 });
1046
- var { getLevel, searchLevels, makeSearchLevels } = crudLevels;
1047
- var getLevels = (0, import_reselect3.createSelector)(crudLevels.getLevels, _9.orderBy("order", "desc"));
1048
-
1049
- // src/selectors/mainNotification.ts
1050
- init_define_import_meta();
1051
- var import_reselect4 = __toESM(require_lib(), 1);
1052
- import { makeEntitiesFilter as makeEntitiesFilter11, makeGetAllEntities as makeGetAllEntities6 } from "@lls/utils";
1053
- import _10 from "lodash/fp.js";
1054
- var getAllMainNotifications = makeGetAllEntities6("mainNotifications");
1055
- var search12 = ({ ids }) => makeEntitiesFilter11({ id: ids });
1056
- var getMainNotifications = (0, import_reselect4.createSelector)(
1057
- [_10.flow(getCurrentUser, _10.get("mainNotifications")), getAllMainNotifications],
1058
- (userNotifications, notifications) => search12({ ids: userNotifications })(notifications)
1059
- );
1060
-
1061
- // src/selectors/news.ts
1062
- init_define_import_meta();
1063
- import { makeEntitiesFilter as makeEntitiesFilter12 } from "@lls/utils";
1064
- var search13 = ({ ids }) => makeEntitiesFilter12({ id: ids });
1065
- var {
1066
- getNews: getAllNews,
1067
- getNew: getNews,
1068
- searchNews,
1069
- makeSearchNews
1070
- } = crud("news", {
1071
- search: search13
1072
- });
1073
-
1074
- // src/selectors/panorama.ts
1075
- init_define_import_meta();
1076
- import { makeGetEntityById as makeGetEntityById4 } from "@lls/utils";
1077
- var getPanorama = makeGetEntityById4("panoramas");
1078
-
1079
- // src/selectors/premiumResource.ts
1080
- init_define_import_meta();
1081
- import { makeEntitiesFilter as makeEntitiesFilter13 } from "@lls/utils";
1082
- var search14 = ({ bookIds }) => makeEntitiesFilter13({ book: bookIds });
1083
- var { getPremiumResources, getPremiumResource, searchPremiumResources, makeSearchPremiumResources } = crud(
1084
- "premiumResources",
1085
- {
1086
- search: search14
1087
- }
1088
- );
1089
-
1090
- // src/selectors/lexicalFlower.ts
1091
- init_define_import_meta();
1092
- import { makeEntitiesFilter as makeEntitiesFilter14 } from "@lls/utils";
1093
- var search15 = ({ ids }) => makeEntitiesFilter14({ id: ids });
1094
- var { getLexicalFlowers, searchLexicalFlowers } = crud("lexicalFlowers", {
1095
- search: search15
1096
- });
1097
-
1098
- // src/selectors/product.ts
1099
- init_define_import_meta();
1100
- import _11 from "lodash/fp.js";
1101
- import { createSearchSelector as createSearchSelector6, makeEntitiesFilter as makeEntitiesFilter15, makeGetAllEntities as makeGetAllEntities7 } from "@lls/utils";
1102
- var getProducts = makeGetAllEntities7("products");
1103
- var search16 = ({
1104
- ids,
1105
- eans,
1106
- isAdoptant,
1107
- isSupportPlus,
1108
- levelIds,
1109
- subjectIds,
1110
- productTypes
1111
- }) => {
1112
- let bookIds;
1113
- const filter = makeEntitiesFilter15(
1114
- {
1115
- id: ids,
1116
- ean: eans,
1117
- isAdoptant,
1118
- isSupportPlus,
1119
- productType: productTypes
1120
- },
1121
- levelIds || subjectIds ? (product2) => !!product2?.books?.some((bookId) => bookIds.has(bookId)) : false
1122
- );
1123
- return (products, books) => {
1124
- bookIds = new Set(_11.map("id", books));
1125
- return filter(products);
1126
- };
1127
- };
1128
- var searchBooks2 = makeSearchBooks();
1129
- var searchProducts = createSearchSelector6(
1130
- getProducts,
1131
- (state, { levelIds, subjectIds }) => searchBooks2(state, { levelIds, subjectIds }),
1132
- (_state, params) => params,
1133
- (products, books, params) => search16(params)(products, books)
1134
- );
1135
-
1136
- // src/selectors/resource.ts
1137
- init_define_import_meta();
1138
- import { makeEntitiesFilter as makeEntitiesFilter16 } from "@lls/utils";
1139
- var search17 = ({ chapterIds }) => makeEntitiesFilter16({
1140
- chapter: chapterIds
1141
- });
1142
- var { getResources, getResource, searchResources, makeSearchResources } = crud("resources", {
1143
- search: search17
1144
- });
1145
-
1146
- // src/selectors/schoolType.ts
1147
- init_define_import_meta();
1148
- import { makeEntitiesFilter as makeEntitiesFilter17 } from "@lls/utils";
1149
- var search18 = ({ slugs }) => makeEntitiesFilter17({ slug: slugs });
1150
- var { getSchoolTypes, getSchoolType, searchSchoolTypes, makeSearchSchoolTypes } = crud("schoolTypes", {
1151
- search: search18
1152
- });
1153
-
1154
- // src/selectors/sharedPage.ts
1155
- init_define_import_meta();
1156
- import { createSearchSelector as createSearchSelector7, makeEntitiesFilter as makeEntitiesFilter18 } from "@lls/utils";
1157
- import _12 from "lodash/fp.js";
1158
- var search19 = ({
1159
- parentIds,
1160
- userIds,
1161
- bookIds,
1162
- isCreatedFromScratch,
1163
- isLearningAssessment,
1164
- ids
1165
- }) => makeEntitiesFilter18({
1166
- id: ids,
1167
- parent: parentIds,
1168
- user: userIds,
1169
- book: bookIds,
1170
- isLearningAssessment,
1171
- isCreatedFromScratch
1172
- });
1173
- var { getSharedPages, getSharedPage, searchSharedPages, makeSearchSharedPages } = crud("sharedPages", {
1174
- search: search19
1175
- });
1176
- var searchCurrentUserSharedPages = createSearchSelector7(
1177
- getCurrentUser,
1178
- getSharedPages,
1179
- (_17, params) => params,
1180
- (user2, sharedPages, params) => {
1181
- const sharedUserPageIds = user2?.sharedPages ?? [];
1182
- return search19({ ...params, ids: _12.intersection(sharedUserPageIds, params.ids || sharedUserPageIds) })(sharedPages);
1183
- }
1184
- );
1185
-
1186
- // src/selectors/student.ts
1187
- init_define_import_meta();
1188
- import { makeEntitiesFilter as makeEntitiesFilter19 } from "@lls/utils";
1189
- var search20 = ({ ids }) => makeEntitiesFilter19({ id: ids });
1190
- var { getStudents, getStudent, searchStudents, makeSearchStudents } = crud("students", {
1191
- search: search20
1192
- });
1193
-
1194
- // src/selectors/subject.ts
1195
- init_define_import_meta();
1196
- import { limitToTeacherSubjects, makeEntitiesFilter as makeEntitiesFilter20, pipe as pipe2 } from "@lls/utils";
1197
- import _13 from "lodash/fp.js";
1198
- var search21 = ({
1199
- ids,
1200
- slugs,
1201
- isTeacherSubject,
1202
- hasNewsletterUrl,
1203
- schoolTypes,
1204
- hasBooks,
1205
- names
1206
- }) => (subjects) => pipe2(
1207
- subjects,
1208
- makeEntitiesFilter20(
1209
- {
1210
- id: ids,
1211
- slug: slugs,
1212
- name: names,
1213
- hasBooks,
1214
- schoolTypes
1215
- },
1216
- !_13.isNil(hasNewsletterUrl) && ((subject2) => Boolean(subject2?.newsletterUrl) === hasNewsletterUrl)
1217
- ),
1218
- (subjects2) => _13.isNil(isTeacherSubject) ? subjects2 : limitToTeacherSubjects(subjects2)
1219
- );
1220
- var { getSubjects, getSubject, searchSubjects, makeSearchSubjects } = crud("subjects", {
1221
- search: search21
1222
- });
1223
-
1224
- // src/selectors/teacher.ts
1225
- init_define_import_meta();
1226
- import { makeEntitiesFilter as makeEntitiesFilter21 } from "@lls/utils";
1227
- var search22 = ({ ids, schoolIds }) => makeEntitiesFilter21({
1228
- id: ids,
1229
- schools: schoolIds
1230
- });
1231
- var { getTeachers, getTeacher, searchTeachers, makeSearchTeachers } = crud("teachers", {
1232
- search: search22
1233
- });
1234
-
1235
- // src/selectors/tool.ts
1236
- init_define_import_meta();
1237
- import { makeEntitiesFilter as makeEntitiesFilter22 } from "@lls/utils";
1238
- var search23 = ({ ids, locked, bookIds }) => makeEntitiesFilter22({
1239
- id: ids,
1240
- locked,
1241
- books: bookIds
1242
- });
1243
- var { getTools, getTool, searchTools, makeSearchTools } = crud("tools", {
1244
- search: search23
1245
- });
1246
-
1247
856
  // src/reducers/entities.ts
1248
857
  init_define_import_meta();
1249
858
  import { makeReducer } from "@lls/utils";
1250
- import _14 from "lodash/fp.js";
859
+ import _7 from "lodash/fp.js";
1251
860
 
1252
861
  // src/actions/index.ts
1253
862
  init_define_import_meta();
@@ -1270,53 +879,47 @@ var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
1270
879
  // src/reducers/entities.ts
1271
880
  var deleteEntityReducer = (state, payload) => {
1272
881
  const { path } = payload;
1273
- return _14.omit(path, state);
882
+ return _7.omit(path, state);
1274
883
  };
1275
884
  var updateEntityReducer = (state, payload) => {
1276
885
  const { path, entity } = payload;
1277
- const currentEntity = _14.get(path, state);
1278
- return _14.set(path, _14.merge(currentEntity, entity), state);
886
+ const currentEntity = _7.get(path, state);
887
+ return _7.set(path, _7.merge(currentEntity, entity), state);
1279
888
  };
1280
889
  var setEntityReducer = (state, payload) => {
1281
890
  const { path, entity } = payload;
1282
- return _14.set(path, entity, state);
891
+ return _7.set(path, entity, state);
1283
892
  };
1284
- var setEntitiesReducer = (state, payload) => {
1285
- if (typeof payload !== "object") return state;
1286
- const stateDrafts = {};
1287
- Object.keys(payload).forEach((entityName) => {
1288
- const entities2 = payload[entityName];
1289
- const entityDraft = {};
1290
- if (!entities2) {
1291
- return;
1292
- }
1293
- Object.keys(entities2).forEach((id) => {
1294
- const entity = entities2[id];
1295
- if (!state[entityName]?.[id]) {
1296
- entityDraft[id] = entity;
1297
- } else {
1298
- if (typeof entity === "undefined") {
1299
- return;
1300
- }
1301
- const diff = Object.keys(entity).some((prop) => {
1302
- const value = entity[prop];
1303
- if (!_14.isEqual(state[entityName]?.[id]?.[prop], value)) {
1304
- return true;
1305
- }
1306
- });
1307
- if (diff) {
1308
- entityDraft[id] = Object.assign({}, state[entityName]?.[id], entity);
1309
- }
893
+ var shallowAssign = (old, next, transform) => {
894
+ let updated = false;
895
+ const merged = _7.flow(
896
+ _7.toPairs,
897
+ _7.reduce((memo, [key, val]) => {
898
+ if (_7.isEmpty(val)) return memo;
899
+ if (!old[key]) {
900
+ updated = true;
901
+ memo[key] = val;
902
+ return memo;
1310
903
  }
1311
- });
1312
- if (Object.keys(entityDraft).length !== 0) {
1313
- stateDrafts[entityName] = { ...state[entityName], ...entityDraft };
1314
- }
904
+ const maybeEqual = transform(old[key], next[key]);
905
+ if (maybeEqual !== old[key]) {
906
+ updated = true;
907
+ memo[key] = maybeEqual;
908
+ return memo;
909
+ }
910
+ return memo;
911
+ }, _7.clone(old))
912
+ )(next);
913
+ return updated ? merged : old;
914
+ };
915
+ var setEntitiesReducer = (state, payload) => {
916
+ return shallowAssign(state, payload, (entityKind, nextEntityKind) => {
917
+ return shallowAssign(
918
+ entityKind,
919
+ nextEntityKind,
920
+ (oldEntity, nextEntity) => _7.isEqual(oldEntity, nextEntity) ? oldEntity : _7.assign(oldEntity, nextEntity)
921
+ );
1315
922
  });
1316
- if (Object.keys(stateDrafts).length !== 0) {
1317
- return { ...state, ...stateDrafts };
1318
- }
1319
- return state;
1320
923
  };
1321
924
  var entities = makeReducer(
1322
925
  {},
@@ -1332,7 +935,7 @@ var entities_default = entities;
1332
935
  // src/reducers/auth.ts
1333
936
  init_define_import_meta();
1334
937
  import { makeReducer as makeReducer2 } from "@lls/utils";
1335
- import _15 from "lodash/fp.js";
938
+ import _8 from "lodash/fp.js";
1336
939
  var initialState = {
1337
940
  id: void 0,
1338
941
  role: null,
@@ -1345,15 +948,15 @@ var initialState = {
1345
948
  llsUserId: null
1346
949
  };
1347
950
  var auth = makeReducer2(initialState, {
1348
- [actionTypes.SET_AUTH]: _15.assign,
1349
- [actionTypes.RESET_AUTH]: _15.constant(initialState)
951
+ [actionTypes.SET_AUTH]: _8.assign,
952
+ [actionTypes.RESET_AUTH]: _8.constant(initialState)
1350
953
  });
1351
954
  var auth_default = auth;
1352
955
 
1353
956
  // src/schema/index.ts
1354
957
  init_define_import_meta();
1355
958
  var import_normalizr = __toESM(require_normalizr(), 1);
1356
- import _16 from "lodash/fp.js";
959
+ import _9 from "lodash/fp.js";
1357
960
  var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
1358
961
  var subject = new import_normalizr.schema.Entity("subjects");
1359
962
  var level = new import_normalizr.schema.Entity("levels");
@@ -1369,7 +972,6 @@ var faq = new import_normalizr.schema.Entity("faq");
1369
972
  var product = new import_normalizr.schema.Entity("products");
1370
973
  var communityProjects = new import_normalizr.schema.Entity("communityProjects");
1371
974
  var builderIo = new import_normalizr.schema.Entity("builderIos");
1372
- var lexicalFlower = new import_normalizr.schema.Entity("lexicalFlowers");
1373
975
  var grammarRule = new import_normalizr.schema.Entity("grammarRules", {}, { idAttribute: "objectID" });
1374
976
  var mainNotification = new import_normalizr.schema.Entity("mainNotifications");
1375
977
  var explorerResult = new import_normalizr.schema.Entity("explorerResults", {}, { idAttribute: "resourceId" });
@@ -1449,8 +1051,7 @@ var userSchema = define(user, {
1449
1051
  students: [student],
1450
1052
  subjects: [subject],
1451
1053
  teachers: [teacher],
1452
- userPages: [page],
1453
- lexicalFlowers: { hits: [lexicalFlower] }
1054
+ userPages: [page]
1454
1055
  });
1455
1056
  var notificationSchema = define(mainNotification, { page });
1456
1057
  drawerNotification.define({ page });
@@ -1503,7 +1104,6 @@ var querySchema = {
1503
1104
  createGroup: group,
1504
1105
  createPage: page,
1505
1106
  createUser: user,
1506
- createLexicalFlower: lexicalFlower,
1507
1107
  documents: { hits: [document] },
1508
1108
  explorerResults: [explorerResult],
1509
1109
  levels: [level],
@@ -1525,8 +1125,7 @@ var querySchema = {
1525
1125
  updatePage: page,
1526
1126
  updateTrialUser: user,
1527
1127
  updateUserLastActivitySeenAt: user,
1528
- updateUser: user,
1529
- updateLexicalFlower: lexicalFlower
1128
+ updateUser: user
1530
1129
  },
1531
1130
  auth: {
1532
1131
  user
@@ -1544,118 +1143,30 @@ var querySchema = {
1544
1143
  }
1545
1144
  }
1546
1145
  };
1547
- var normalizeData = _16.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1146
+ var normalizeData = _9.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1548
1147
  export {
1549
1148
  auth_default as authReducer,
1550
1149
  entities_default as entitiesReducer,
1551
- filterPages,
1552
- getAllNews,
1553
- getAuth,
1554
1150
  getBook,
1555
1151
  getBooks,
1556
1152
  getChapter,
1557
1153
  getChapters,
1558
- getCollection,
1559
- getCollections,
1560
- getCommunityProject,
1561
- getCommunityProjects,
1562
- getContact,
1563
- getContacts,
1564
1154
  getCurrentUser,
1565
- getDraftPage,
1566
- getDraftPages,
1567
- getFaqs,
1568
- getGarDivision,
1569
- getGarDivisions,
1570
- getGroup,
1571
- getGroups,
1572
- getIsLogged,
1573
- getLevel,
1574
- getLevels,
1575
- getLexicalFlowers,
1576
- getMainNotifications,
1577
- getNews,
1578
- getPage,
1579
- getPages,
1580
- getPanorama,
1581
- getPremiumResource,
1582
- getPremiumResources,
1583
- getProducts,
1584
- getResource,
1585
- getResources,
1586
1155
  getSchool,
1587
- getSchoolType,
1588
- getSchoolTypes,
1589
1156
  getSchools,
1590
- getSharedPage,
1591
- getSharedPages,
1592
- getStudent,
1593
- getStudents,
1594
- getSubject,
1595
- getSubjects,
1596
- getTeacher,
1597
- getTeachers,
1598
- getToken,
1599
- getTool,
1600
- getTools,
1601
1157
  getUser,
1602
- getUserGroups,
1603
1158
  getUsers,
1604
1159
  makeGetBook,
1605
- makeGetDraftPage,
1606
1160
  makeSearchBooks,
1607
1161
  makeSearchChapters,
1608
- makeSearchCollections,
1609
- makeSearchCommunityProjects,
1610
- makeSearchContacts,
1611
- makeSearchCopyNotifications,
1612
- makeSearchDraftPages,
1613
- makeSearchDrawerNotifications,
1614
- makeSearchGarDivisions,
1615
- makeSearchGroups,
1616
- makeSearchLevels,
1617
- makeSearchModifiedPages,
1618
- makeSearchNews,
1619
- makeSearchPages,
1620
- makeSearchPremiumResources,
1621
- makeSearchResources,
1622
- makeSearchSchoolTypes,
1623
1162
  makeSearchSchools,
1624
- makeSearchSharedPages,
1625
- makeSearchStudents,
1626
- makeSearchSubjects,
1627
- makeSearchTeachers,
1628
- makeSearchTools,
1629
1163
  makeSearchUsers,
1630
1164
  makeSearchValidBooks,
1631
1165
  normalizeData,
1632
1166
  querySchema,
1633
1167
  searchBooks,
1634
1168
  searchChapters,
1635
- searchCollections,
1636
- searchCommunityProjects,
1637
- searchContacts,
1638
- searchCopyNotifications,
1639
- searchCurrentUserSharedPages,
1640
- searchDraftPages,
1641
- searchDrawerNotifications,
1642
- searchGarDivisions,
1643
- searchGroups,
1644
- searchLevels,
1645
- searchLexicalFlowers,
1646
- searchModifiedPages,
1647
- searchNews,
1648
- searchPages,
1649
- searchPremiumResources,
1650
- searchProducts,
1651
- searchResources,
1652
- searchSchoolTypes,
1653
1169
  searchSchools,
1654
- searchSharedPages,
1655
- searchStudents,
1656
- searchSubjects,
1657
- searchTeachers,
1658
- searchTools,
1659
1170
  searchUsers,
1660
1171
  searchValidBooks,
1661
1172
  setEntitiesReducer
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.1.59-0fc150f7",
5
+ "version": "24.1.59-10c33c33",
6
6
  "type": "module",
7
7
  "types": "./lib/builttypes/store/src/index.d.ts",
8
8
  "exports": {
@@ -28,21 +28,21 @@
28
28
  "react": "*"
29
29
  },
30
30
  "devDependencies": {
31
- "@biomejs/biome": "1.9.1",
32
- "@types/lodash": "4.17.7",
33
- "@types/node": "22.5.5",
34
- "@types/react": "18.3.6",
31
+ "@biomejs/biome": "1.8.4-nightly.7aaf0ce",
32
+ "@types/lodash": "4.17.6",
33
+ "@types/node": "20.14.10",
34
+ "@types/react": "18.3.3",
35
35
  "@vitejs/plugin-react-swc": "3.7.0",
36
- "esbuild": "0.23.1",
36
+ "esbuild": "0.23.0",
37
37
  "lodash": "4.17.21",
38
38
  "react": "18.3.1",
39
39
  "reselect": "4.1.8",
40
- "typescript": "5.6.2",
41
- "vite": "5.4.6",
40
+ "typescript": "5.5.4",
41
+ "vite": "5.3.3",
42
42
  "vite-tsconfig-paths": "4.3.2",
43
- "vitest": "2.1.1",
44
- "@lls/utils": "24.1.59-0fc150f7",
45
- "@lls/vitescripts": "24.1.59-0fc150f7"
43
+ "vitest": "2.0.0",
44
+ "@lls/utils": "24.1.59-10c33c33",
45
+ "@lls/vitescripts": "24.1.59-10c33c33"
46
46
  },
47
47
  "license": "ISC",
48
48
  "dependencies": {