@lls/store 24.1.59-5565fe5b → 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 +100 -26
  2. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -742,12 +742,12 @@ import _2 from "lodash/fp.js";
742
742
  init_define_import_meta();
743
743
  import { createSearchSelector, makeGetAllEntities, makeGetEntityById } from "@lls/utils";
744
744
  import _ from "lodash/fp.js";
745
- var crud = (entityName, { search: search3 }) => {
745
+ var crud = (entityName, { search: search5 }) => {
746
746
  const getElements = makeGetAllEntities(entityName);
747
747
  const makeSearchElements = () => createSearchSelector(
748
748
  getElements,
749
749
  (_state, params) => params,
750
- (elements, params) => search3(params)(elements)
750
+ (elements, params) => search5(params)(elements)
751
751
  );
752
752
  const methodName = _.capitalize(entityName);
753
753
  const getElementById = makeGetEntityById(entityName);
@@ -766,23 +766,73 @@ var { getSchools, getSchool, searchSchools, makeSearchSchools } = crud("schools"
766
766
  search
767
767
  });
768
768
 
769
+ // src/selectors/book.ts
770
+ init_define_import_meta();
771
+ import {
772
+ createSearchSelector as createSearchSelector2,
773
+ filterEntitiesArrayFieldByValues,
774
+ filterEntitiesSimpleFieldByValue,
775
+ filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues2,
776
+ makeGetEntityById as makeGetEntityById2
777
+ } from "@lls/utils";
778
+ import _3 from "lodash/fp.js";
779
+ var search2 = ({
780
+ ids,
781
+ levelIds,
782
+ subjectIds,
783
+ years,
784
+ isValid,
785
+ isWorkbook,
786
+ isWorkplan,
787
+ hasNoTeacherBook,
788
+ sortByQuery,
789
+ hasNewDesign,
790
+ slugs,
791
+ uris,
792
+ publishers,
793
+ isRenewed,
794
+ isPrimary
795
+ }) => _3.flow(
796
+ filterEntitiesSimpleFieldByValues2("id", ids),
797
+ filterEntitiesSimpleFieldByValues2("year", years),
798
+ filterEntitiesArrayFieldByValues("levels", levelIds),
799
+ filterEntitiesArrayFieldByValues("subjects", subjectIds),
800
+ filterEntitiesSimpleFieldByValues2("valid", _3.isNil(isValid) ? void 0 : [isValid]),
801
+ filterEntitiesSimpleFieldByValues2("publisher", publishers),
802
+ filterEntitiesSimpleFieldByValues2("hasNewDesign", _3.isNil(hasNewDesign) ? void 0 : [hasNewDesign]),
803
+ filterEntitiesSimpleFieldByValues2("isWorkbook", _3.isNil(isWorkbook) ? void 0 : [isWorkbook]),
804
+ filterEntitiesSimpleFieldByValues2("isWorkplan", _3.isNil(isWorkplan) ? void 0 : [isWorkplan]),
805
+ filterEntitiesSimpleFieldByValues2("hasNoTeacherBook", _3.isNil(hasNoTeacherBook) ? void 0 : [hasNoTeacherBook]),
806
+ filterEntitiesSimpleFieldByValues2("slug", slugs),
807
+ filterEntitiesSimpleFieldByValues2("uri", uris),
808
+ filterEntitiesSimpleFieldByValues2("isRenewed", _3.isNil(isRenewed) ? void 0 : [isRenewed]),
809
+ filterEntitiesSimpleFieldByValue("isPrimary", isPrimary),
810
+ _3.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _3.sortBy(sortByQuery) : _3.identity
811
+ );
812
+ var { getBooks, getBook, searchBooks, makeSearchBooks } = crud("books", {
813
+ search: search2
814
+ });
815
+ var makeSearchValidBooks = () => createSearchSelector2(makeSearchBooks(), (books) => _3.filter({ valid: true, hasNewDesign: true }, books));
816
+ var searchValidBooks = makeSearchValidBooks();
817
+ var makeGetBook = () => makeGetEntityById2("books");
818
+
769
819
  // src/selectors/user.ts
770
820
  init_define_import_meta();
771
821
  var import_reselect = __toESM(require_lib(), 1);
772
- import { filterEntitiesArrayFieldByValues, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues2 } from "@lls/utils";
773
- import _4 from "lodash/fp.js";
822
+ import { filterEntitiesArrayFieldByValues as filterEntitiesArrayFieldByValues2, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues3 } from "@lls/utils";
823
+ import _5 from "lodash/fp.js";
774
824
 
775
825
  // src/selectors/auth.ts
776
826
  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");
827
+ import _4 from "lodash/fp.js";
828
+ var getAuth = _4.get("auth");
829
+ var getIsLogged = _4.flow(_4.get("auth.id"), _4.negate(_4.isNil));
830
+ var getToken = _4.get("auth.token");
781
831
 
782
832
  // src/selectors/user.ts
783
- var search2 = ({ ids, schoolIds }) => _4.flow(filterEntitiesArrayFieldByValues("schools", schoolIds), filterEntitiesSimpleFieldByValues2("id", ids));
833
+ var search3 = ({ ids, schoolIds }) => _5.flow(filterEntitiesArrayFieldByValues2("schools", schoolIds), filterEntitiesSimpleFieldByValues3("id", ids));
784
834
  var { getUsers, getUser, searchUsers, makeSearchUsers } = crud("users", {
785
- search: search2
835
+ search: search3
786
836
  });
787
837
  var getCurrentUser = (0, import_reselect.createSelector)(
788
838
  getAuth,
@@ -790,10 +840,23 @@ var getCurrentUser = (0, import_reselect.createSelector)(
790
840
  (auth2, users) => users?.find((user2) => user2?.id === auth2?.id)
791
841
  );
792
842
 
843
+ // src/selectors/chapter.ts
844
+ init_define_import_meta();
845
+ import { filterEntitiesFieldExists, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues4 } from "@lls/utils";
846
+ import _6 from "lodash/fp.js";
847
+ var search4 = ({ bookIds, ids, hasTeacherBook }) => _6.flow(
848
+ filterEntitiesSimpleFieldByValues4("book", bookIds),
849
+ filterEntitiesSimpleFieldByValues4("id", ids),
850
+ filterEntitiesFieldExists("teacherBook", hasTeacherBook)
851
+ );
852
+ var { getChapters, getChapter, searchChapters, makeSearchChapters } = crud("chapters", {
853
+ search: search4
854
+ });
855
+
793
856
  // src/reducers/entities.ts
794
857
  init_define_import_meta();
795
858
  import { makeReducer } from "@lls/utils";
796
- import _5 from "lodash/fp.js";
859
+ import _7 from "lodash/fp.js";
797
860
 
798
861
  // src/actions/index.ts
799
862
  init_define_import_meta();
@@ -816,23 +879,23 @@ var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
816
879
  // src/reducers/entities.ts
817
880
  var deleteEntityReducer = (state, payload) => {
818
881
  const { path } = payload;
819
- return _5.omit(path, state);
882
+ return _7.omit(path, state);
820
883
  };
821
884
  var updateEntityReducer = (state, payload) => {
822
885
  const { path, entity } = payload;
823
- const currentEntity = _5.get(path, state);
824
- return _5.set(path, _5.merge(currentEntity, entity), state);
886
+ const currentEntity = _7.get(path, state);
887
+ return _7.set(path, _7.merge(currentEntity, entity), state);
825
888
  };
826
889
  var setEntityReducer = (state, payload) => {
827
890
  const { path, entity } = payload;
828
- return _5.set(path, entity, state);
891
+ return _7.set(path, entity, state);
829
892
  };
830
893
  var shallowAssign = (old, next, transform) => {
831
894
  let updated = false;
832
- const merged = _5.flow(
833
- _5.toPairs,
834
- _5.reduce((memo, [key, val]) => {
835
- if (_5.isEmpty(val)) return memo;
895
+ const merged = _7.flow(
896
+ _7.toPairs,
897
+ _7.reduce((memo, [key, val]) => {
898
+ if (_7.isEmpty(val)) return memo;
836
899
  if (!old[key]) {
837
900
  updated = true;
838
901
  memo[key] = val;
@@ -845,7 +908,7 @@ var shallowAssign = (old, next, transform) => {
845
908
  return memo;
846
909
  }
847
910
  return memo;
848
- }, _5.clone(old))
911
+ }, _7.clone(old))
849
912
  )(next);
850
913
  return updated ? merged : old;
851
914
  };
@@ -854,7 +917,7 @@ var setEntitiesReducer = (state, payload) => {
854
917
  return shallowAssign(
855
918
  entityKind,
856
919
  nextEntityKind,
857
- (oldEntity, nextEntity) => _5.isEqual(oldEntity, nextEntity) ? oldEntity : _5.assign(oldEntity, nextEntity)
920
+ (oldEntity, nextEntity) => _7.isEqual(oldEntity, nextEntity) ? oldEntity : _7.assign(oldEntity, nextEntity)
858
921
  );
859
922
  });
860
923
  };
@@ -872,7 +935,7 @@ var entities_default = entities;
872
935
  // src/reducers/auth.ts
873
936
  init_define_import_meta();
874
937
  import { makeReducer as makeReducer2 } from "@lls/utils";
875
- import _6 from "lodash/fp.js";
938
+ import _8 from "lodash/fp.js";
876
939
  var initialState = {
877
940
  id: void 0,
878
941
  role: null,
@@ -885,15 +948,15 @@ var initialState = {
885
948
  llsUserId: null
886
949
  };
887
950
  var auth = makeReducer2(initialState, {
888
- [actionTypes.SET_AUTH]: _6.assign,
889
- [actionTypes.RESET_AUTH]: _6.constant(initialState)
951
+ [actionTypes.SET_AUTH]: _8.assign,
952
+ [actionTypes.RESET_AUTH]: _8.constant(initialState)
890
953
  });
891
954
  var auth_default = auth;
892
955
 
893
956
  // src/schema/index.ts
894
957
  init_define_import_meta();
895
958
  var import_normalizr = __toESM(require_normalizr(), 1);
896
- import _7 from "lodash/fp.js";
959
+ import _9 from "lodash/fp.js";
897
960
  var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
898
961
  var subject = new import_normalizr.schema.Entity("subjects");
899
962
  var level = new import_normalizr.schema.Entity("levels");
@@ -1078,20 +1141,31 @@ var querySchema = {
1078
1141
  }
1079
1142
  }
1080
1143
  };
1081
- var normalizeData = _7.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1144
+ var normalizeData = _9.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
1082
1145
  export {
1083
1146
  auth_default as authReducer,
1084
1147
  entities_default as entitiesReducer,
1148
+ getBook,
1149
+ getBooks,
1150
+ getChapter,
1151
+ getChapters,
1085
1152
  getCurrentUser,
1086
1153
  getSchool,
1087
1154
  getSchools,
1088
1155
  getUser,
1089
1156
  getUsers,
1157
+ makeGetBook,
1158
+ makeSearchBooks,
1159
+ makeSearchChapters,
1090
1160
  makeSearchSchools,
1091
1161
  makeSearchUsers,
1162
+ makeSearchValidBooks,
1092
1163
  normalizeData,
1093
1164
  querySchema,
1165
+ searchBooks,
1166
+ searchChapters,
1094
1167
  searchSchools,
1095
1168
  searchUsers,
1169
+ searchValidBooks,
1096
1170
  setEntitiesReducer
1097
1171
  };
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-65ad9aaa",
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-65ad9aaa",
45
+ "@lls/vitescripts": "24.1.59-65ad9aaa"
46
46
  },
47
47
  "license": "ISC",
48
48
  "dependencies": {