@lls/store 24.1.59-59d1e176 → 24.1.59-6b359862

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 +63 -649
  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 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,13 +733,6 @@ 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
738
  import { filterEntitiesSimpleFieldByValues } from "@lls/utils";
@@ -748,21 +741,21 @@ import _2 from "lodash/fp.js";
748
741
  // src/selectors/crud.ts
749
742
  init_define_import_meta();
750
743
  import { createSearchSelector, makeGetAllEntities, makeGetEntityById } from "@lls/utils";
751
- var crud = (entityName, { search: search24 }) => {
744
+ import _ from "lodash/fp.js";
745
+ var crud = (entityName, { search: search3 }) => {
752
746
  const getElements = makeGetAllEntities(entityName);
753
747
  const makeSearchElements = () => createSearchSelector(
754
748
  getElements,
755
749
  (_state, params) => params,
756
- (elements, params) => search24(params)(elements)
750
+ (elements, params) => search3(params)(elements)
757
751
  );
758
- const methodName = `${entityName.charAt(0).toUpperCase()}${entityName.slice(1)}`;
752
+ const methodName = _.capitalize(entityName);
759
753
  const getElementById = makeGetEntityById(entityName);
760
754
  const back = {
761
755
  [`get${methodName}`]: getElements,
762
756
  [`search${methodName}`]: makeSearchElements(),
763
757
  [`get${methodName.replace(/s$/, "")}`]: getElementById,
764
- [`makeSearch${methodName}`]: makeSearchElements,
765
- [`filter${methodName}`]: search24
758
+ [`makeSearch${methodName}`]: makeSearchElements
766
759
  };
767
760
  return back;
768
761
  };
@@ -773,64 +766,23 @@ var { getSchools, getSchool, searchSchools, makeSearchSchools } = crud("schools"
773
766
  search
774
767
  });
775
768
 
776
- // src/selectors/book.ts
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";
785
- import _3 from "lodash/fp.js";
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");
825
-
826
769
  // src/selectors/user.ts
827
770
  init_define_import_meta();
828
771
  var import_reselect = __toESM(require_lib(), 1);
829
- import { filterEntitiesArrayFieldByValues as filterEntitiesArrayFieldByValues2, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues3 } from "@lls/utils";
772
+ import { filterEntitiesArrayFieldByValues, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues2 } from "@lls/utils";
830
773
  import _4 from "lodash/fp.js";
831
- var search3 = ({ ids, schoolIds }) => _4.flow(filterEntitiesArrayFieldByValues2("schools", schoolIds), filterEntitiesSimpleFieldByValues3("id", ids));
774
+
775
+ // src/selectors/auth.ts
776
+ init_define_import_meta();
777
+ 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");
781
+
782
+ // src/selectors/user.ts
783
+ var search2 = ({ ids, schoolIds }) => _4.flow(filterEntitiesArrayFieldByValues("schools", schoolIds), filterEntitiesSimpleFieldByValues2("id", ids));
832
784
  var { getUsers, getUser, searchUsers, makeSearchUsers } = crud("users", {
833
- search: search3
785
+ search: search2
834
786
  });
835
787
  var getCurrentUser = (0, import_reselect.createSelector)(
836
788
  getAuth,
@@ -838,437 +790,10 @@ var getCurrentUser = (0, import_reselect.createSelector)(
838
790
  (auth2, users) => users?.find((user2) => user2?.id === auth2?.id)
839
791
  );
840
792
 
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
-
1268
793
  // src/reducers/entities.ts
1269
794
  init_define_import_meta();
1270
795
  import { makeReducer } from "@lls/utils";
1271
- import _23 from "lodash/fp.js";
796
+ import _5 from "lodash/fp.js";
1272
797
 
1273
798
  // src/actions/index.ts
1274
799
  init_define_import_meta();
@@ -1291,53 +816,47 @@ var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
1291
816
  // src/reducers/entities.ts
1292
817
  var deleteEntityReducer = (state, payload) => {
1293
818
  const { path } = payload;
1294
- return _23.omit(path, state);
819
+ return _5.omit(path, state);
1295
820
  };
1296
821
  var updateEntityReducer = (state, payload) => {
1297
822
  const { path, entity } = payload;
1298
- const currentEntity = _23.get(path, state);
1299
- return _23.set(path, _23.merge(currentEntity, entity), state);
823
+ const currentEntity = _5.get(path, state);
824
+ return _5.set(path, _5.merge(currentEntity, entity), state);
1300
825
  };
1301
826
  var setEntityReducer = (state, payload) => {
1302
827
  const { path, entity } = payload;
1303
- return _23.set(path, entity, state);
828
+ return _5.set(path, entity, state);
1304
829
  };
1305
- var setEntitiesReducer = (state, payload) => {
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
- }
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;
1331
840
  }
1332
- });
1333
- if (Object.keys(entityDraft).length !== 0) {
1334
- stateDrafts[entityName] = { ...state[entityName], ...entityDraft };
1335
- }
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;
851
+ };
852
+ 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
+ );
1336
859
  });
1337
- if (Object.keys(stateDrafts).length !== 0) {
1338
- return { ...state, ...stateDrafts };
1339
- }
1340
- return state;
1341
860
  };
1342
861
  var entities = makeReducer(
1343
862
  {},
@@ -1353,7 +872,7 @@ var entities_default = entities;
1353
872
  // src/reducers/auth.ts
1354
873
  init_define_import_meta();
1355
874
  import { makeReducer as makeReducer2 } from "@lls/utils";
1356
- import _24 from "lodash/fp.js";
875
+ import _6 from "lodash/fp.js";
1357
876
  var initialState = {
1358
877
  id: void 0,
1359
878
  role: null,
@@ -1366,15 +885,15 @@ var initialState = {
1366
885
  llsUserId: null
1367
886
  };
1368
887
  var auth = makeReducer2(initialState, {
1369
- [actionTypes.SET_AUTH]: _24.assign,
1370
- [actionTypes.RESET_AUTH]: _24.constant(initialState)
888
+ [actionTypes.SET_AUTH]: _6.assign,
889
+ [actionTypes.RESET_AUTH]: _6.constant(initialState)
1371
890
  });
1372
891
  var auth_default = auth;
1373
892
 
1374
893
  // src/schema/index.ts
1375
894
  init_define_import_meta();
1376
895
  var import_normalizr = __toESM(require_normalizr(), 1);
1377
- import _25 from "lodash/fp.js";
896
+ import _7 from "lodash/fp.js";
1378
897
  var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
1379
898
  var subject = new import_normalizr.schema.Entity("subjects");
1380
899
  var level = new import_normalizr.schema.Entity("levels");
@@ -1389,8 +908,6 @@ var teacher = new import_normalizr.schema.Entity("teachers");
1389
908
  var faq = new import_normalizr.schema.Entity("faq");
1390
909
  var product = new import_normalizr.schema.Entity("products");
1391
910
  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");
1394
911
  var grammarRule = new import_normalizr.schema.Entity("grammarRules", {}, { idAttribute: "objectID" });
1395
912
  var mainNotification = new import_normalizr.schema.Entity("mainNotifications");
1396
913
  var explorerResult = new import_normalizr.schema.Entity("explorerResults", {}, { idAttribute: "resourceId" });
@@ -1470,8 +987,7 @@ var userSchema = define(user, {
1470
987
  students: [student],
1471
988
  subjects: [subject],
1472
989
  teachers: [teacher],
1473
- userPages: [page],
1474
- lexicalFlowers: { hits: [lexicalFlower] }
990
+ userPages: [page]
1475
991
  });
1476
992
  var notificationSchema = define(mainNotification, { page });
1477
993
  drawerNotification.define({ page });
@@ -1524,7 +1040,6 @@ var querySchema = {
1524
1040
  createGroup: group,
1525
1041
  createPage: page,
1526
1042
  createUser: user,
1527
- createLexicalFlower: lexicalFlower,
1528
1043
  documents: { hits: [document] },
1529
1044
  explorerResults: [explorerResult],
1530
1045
  levels: [level],
@@ -1546,8 +1061,7 @@ var querySchema = {
1546
1061
  updatePage: page,
1547
1062
  updateTrialUser: user,
1548
1063
  updateUserLastActivitySeenAt: user,
1549
- updateUser: user,
1550
- updateLexicalFlower: lexicalFlower
1064
+ updateUser: user
1551
1065
  },
1552
1066
  auth: {
1553
1067
  user
@@ -1556,8 +1070,7 @@ var querySchema = {
1556
1070
  addLikeFaq: faq,
1557
1071
  communityProjects: [communityProjects],
1558
1072
  createAnalytics: analytic,
1559
- faq: [faq],
1560
- builderIos: [builderIo]
1073
+ faq: [faq]
1561
1074
  },
1562
1075
  static: {
1563
1076
  projetVoltaire: {
@@ -1565,119 +1078,20 @@ var querySchema = {
1565
1078
  }
1566
1079
  }
1567
1080
  };
1568
- var normalizeData = _25.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1081
+ var normalizeData = _7.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1569
1082
  export {
1570
1083
  auth_default as authReducer,
1571
1084
  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,
1585
1085
  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,
1607
1086
  getSchool,
1608
- getSchoolType,
1609
- getSchoolTypes,
1610
1087
  getSchools,
1611
- getSharedPage,
1612
- getSharedPages,
1613
- getStudent,
1614
- getStudents,
1615
- getSubject,
1616
- getSubjects,
1617
- getTeacher,
1618
- getTeachers,
1619
- getToken,
1620
- getTool,
1621
- getTools,
1622
1088
  getUser,
1623
- getUserGroups,
1624
1089
  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,
1644
1090
  makeSearchSchools,
1645
- makeSearchSharedPages,
1646
- makeSearchStudents,
1647
- makeSearchSubjects,
1648
- makeSearchTeachers,
1649
- makeSearchTools,
1650
1091
  makeSearchUsers,
1651
- makeSearchValidBooks,
1652
1092
  normalizeData,
1653
1093
  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,
1674
1094
  searchSchools,
1675
- searchSharedPages,
1676
- searchStudents,
1677
- searchSubjects,
1678
- searchTeachers,
1679
- searchTools,
1680
1095
  searchUsers,
1681
- searchValidBooks,
1682
1096
  setEntitiesReducer
1683
1097
  };
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-59d1e176",
5
+ "version": "24.1.59-6b359862",
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.7aaf0ce",
31
+ "@biomejs/biome": "1.8.4-nightly.a579bf7",
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-59d1e176",
45
- "@lls/vitescripts": "24.1.59-59d1e176"
44
+ "@lls/utils": "24.1.59-6b359862",
45
+ "@lls/vitescripts": "24.1.59-6b359862"
46
46
  },
47
47
  "license": "ISC",
48
48
  "dependencies": {