@lls/store 24.1.59-5565fe5b → 24.1.59-59d1e176

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