@lls/store 24.1.59-59d1e176 → 24.1.59-65ad9aaa

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 -575
  2. package/package.json +3 -3
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: search5 }) => {
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) => search5(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
  };
@@ -827,8 +820,17 @@ var makeGetBook = () => makeGetEntityById2("books");
827
820
  init_define_import_meta();
828
821
  var import_reselect = __toESM(require_lib(), 1);
829
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();
830
827
  import _4 from "lodash/fp.js";
831
- var search3 = ({ ids, schoolIds }) => _4.flow(filterEntitiesArrayFieldByValues2("schools", schoolIds), filterEntitiesSimpleFieldByValues3("id", ids));
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
  });
@@ -841,8 +843,8 @@ var getCurrentUser = (0, import_reselect.createSelector)(
841
843
  // src/selectors/chapter.ts
842
844
  init_define_import_meta();
843
845
  import { filterEntitiesFieldExists, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues4 } from "@lls/utils";
844
- import _5 from "lodash/fp.js";
845
- var search4 = ({ bookIds, ids, hasTeacherBook }) => _5.flow(
846
+ import _6 from "lodash/fp.js";
847
+ var search4 = ({ bookIds, ids, hasTeacherBook }) => _6.flow(
846
848
  filterEntitiesSimpleFieldByValues4("book", bookIds),
847
849
  filterEntitiesSimpleFieldByValues4("id", ids),
848
850
  filterEntitiesFieldExists("teacherBook", hasTeacherBook)
@@ -851,424 +853,10 @@ var { getChapters, getChapter, searchChapters, makeSearchChapters } = crud("chap
851
853
  search: search4
852
854
  });
853
855
 
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
856
  // src/reducers/entities.ts
1269
857
  init_define_import_meta();
1270
858
  import { makeReducer } from "@lls/utils";
1271
- import _23 from "lodash/fp.js";
859
+ import _7 from "lodash/fp.js";
1272
860
 
1273
861
  // src/actions/index.ts
1274
862
  init_define_import_meta();
@@ -1291,53 +879,47 @@ var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
1291
879
  // src/reducers/entities.ts
1292
880
  var deleteEntityReducer = (state, payload) => {
1293
881
  const { path } = payload;
1294
- return _23.omit(path, state);
882
+ return _7.omit(path, state);
1295
883
  };
1296
884
  var updateEntityReducer = (state, payload) => {
1297
885
  const { path, entity } = payload;
1298
- const currentEntity = _23.get(path, state);
1299
- return _23.set(path, _23.merge(currentEntity, entity), state);
886
+ const currentEntity = _7.get(path, state);
887
+ return _7.set(path, _7.merge(currentEntity, entity), state);
1300
888
  };
1301
889
  var setEntityReducer = (state, payload) => {
1302
890
  const { path, entity } = payload;
1303
- return _23.set(path, entity, state);
891
+ return _7.set(path, entity, state);
1304
892
  };
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
- }
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;
1331
903
  }
1332
- });
1333
- if (Object.keys(entityDraft).length !== 0) {
1334
- stateDrafts[entityName] = { ...state[entityName], ...entityDraft };
1335
- }
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
+ );
1336
922
  });
1337
- if (Object.keys(stateDrafts).length !== 0) {
1338
- return { ...state, ...stateDrafts };
1339
- }
1340
- return state;
1341
923
  };
1342
924
  var entities = makeReducer(
1343
925
  {},
@@ -1353,7 +935,7 @@ var entities_default = entities;
1353
935
  // src/reducers/auth.ts
1354
936
  init_define_import_meta();
1355
937
  import { makeReducer as makeReducer2 } from "@lls/utils";
1356
- import _24 from "lodash/fp.js";
938
+ import _8 from "lodash/fp.js";
1357
939
  var initialState = {
1358
940
  id: void 0,
1359
941
  role: null,
@@ -1366,15 +948,15 @@ var initialState = {
1366
948
  llsUserId: null
1367
949
  };
1368
950
  var auth = makeReducer2(initialState, {
1369
- [actionTypes.SET_AUTH]: _24.assign,
1370
- [actionTypes.RESET_AUTH]: _24.constant(initialState)
951
+ [actionTypes.SET_AUTH]: _8.assign,
952
+ [actionTypes.RESET_AUTH]: _8.constant(initialState)
1371
953
  });
1372
954
  var auth_default = auth;
1373
955
 
1374
956
  // src/schema/index.ts
1375
957
  init_define_import_meta();
1376
958
  var import_normalizr = __toESM(require_normalizr(), 1);
1377
- import _25 from "lodash/fp.js";
959
+ import _9 from "lodash/fp.js";
1378
960
  var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
1379
961
  var subject = new import_normalizr.schema.Entity("subjects");
1380
962
  var level = new import_normalizr.schema.Entity("levels");
@@ -1389,8 +971,6 @@ var teacher = new import_normalizr.schema.Entity("teachers");
1389
971
  var faq = new import_normalizr.schema.Entity("faq");
1390
972
  var product = new import_normalizr.schema.Entity("products");
1391
973
  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
974
  var grammarRule = new import_normalizr.schema.Entity("grammarRules", {}, { idAttribute: "objectID" });
1395
975
  var mainNotification = new import_normalizr.schema.Entity("mainNotifications");
1396
976
  var explorerResult = new import_normalizr.schema.Entity("explorerResults", {}, { idAttribute: "resourceId" });
@@ -1470,8 +1050,7 @@ var userSchema = define(user, {
1470
1050
  students: [student],
1471
1051
  subjects: [subject],
1472
1052
  teachers: [teacher],
1473
- userPages: [page],
1474
- lexicalFlowers: { hits: [lexicalFlower] }
1053
+ userPages: [page]
1475
1054
  });
1476
1055
  var notificationSchema = define(mainNotification, { page });
1477
1056
  drawerNotification.define({ page });
@@ -1524,7 +1103,6 @@ var querySchema = {
1524
1103
  createGroup: group,
1525
1104
  createPage: page,
1526
1105
  createUser: user,
1527
- createLexicalFlower: lexicalFlower,
1528
1106
  documents: { hits: [document] },
1529
1107
  explorerResults: [explorerResult],
1530
1108
  levels: [level],
@@ -1546,8 +1124,7 @@ var querySchema = {
1546
1124
  updatePage: page,
1547
1125
  updateTrialUser: user,
1548
1126
  updateUserLastActivitySeenAt: user,
1549
- updateUser: user,
1550
- updateLexicalFlower: lexicalFlower
1127
+ updateUser: user
1551
1128
  },
1552
1129
  auth: {
1553
1130
  user
@@ -1556,8 +1133,7 @@ var querySchema = {
1556
1133
  addLikeFaq: faq,
1557
1134
  communityProjects: [communityProjects],
1558
1135
  createAnalytics: analytic,
1559
- faq: [faq],
1560
- builderIos: [builderIo]
1136
+ faq: [faq]
1561
1137
  },
1562
1138
  static: {
1563
1139
  projetVoltaire: {
@@ -1565,118 +1141,30 @@ var querySchema = {
1565
1141
  }
1566
1142
  }
1567
1143
  };
1568
- var normalizeData = _25.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1144
+ var normalizeData = _9.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1569
1145
  export {
1570
1146
  auth_default as authReducer,
1571
1147
  entities_default as entitiesReducer,
1572
- filterPages,
1573
- getAllNews,
1574
- getAuth,
1575
1148
  getBook,
1576
1149
  getBooks,
1577
1150
  getChapter,
1578
1151
  getChapters,
1579
- getCollection,
1580
- getCollections,
1581
- getCommunityProject,
1582
- getCommunityProjects,
1583
- getContact,
1584
- getContacts,
1585
1152
  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
1153
  getSchool,
1608
- getSchoolType,
1609
- getSchoolTypes,
1610
1154
  getSchools,
1611
- getSharedPage,
1612
- getSharedPages,
1613
- getStudent,
1614
- getStudents,
1615
- getSubject,
1616
- getSubjects,
1617
- getTeacher,
1618
- getTeachers,
1619
- getToken,
1620
- getTool,
1621
- getTools,
1622
1155
  getUser,
1623
- getUserGroups,
1624
1156
  getUsers,
1625
1157
  makeGetBook,
1626
- makeGetDraftPage,
1627
1158
  makeSearchBooks,
1628
1159
  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
1160
  makeSearchSchools,
1645
- makeSearchSharedPages,
1646
- makeSearchStudents,
1647
- makeSearchSubjects,
1648
- makeSearchTeachers,
1649
- makeSearchTools,
1650
1161
  makeSearchUsers,
1651
1162
  makeSearchValidBooks,
1652
1163
  normalizeData,
1653
1164
  querySchema,
1654
1165
  searchBooks,
1655
1166
  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
1167
  searchSchools,
1675
- searchSharedPages,
1676
- searchStudents,
1677
- searchSubjects,
1678
- searchTeachers,
1679
- searchTools,
1680
1168
  searchUsers,
1681
1169
  searchValidBooks,
1682
1170
  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-59d1e176",
5
+ "version": "24.1.59-65ad9aaa",
6
6
  "type": "module",
7
7
  "types": "./lib/builttypes/store/src/index.d.ts",
8
8
  "exports": {
@@ -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-65ad9aaa",
45
+ "@lls/vitescripts": "24.1.59-65ad9aaa"
46
46
  },
47
47
  "license": "ISC",
48
48
  "dependencies": {