@lls/store 24.1.59-36292a9f → 24.1.59-49f7c5e0
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.
- package/lib/index.js +18 -124
- package/package.json +3 -3
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:
|
|
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) =>
|
|
750
|
+
(elements, params) => search5(params)(elements)
|
|
751
751
|
);
|
|
752
752
|
const methodName = _.capitalize(entityName);
|
|
753
753
|
const getElementById = makeGetEntityById(entityName);
|
|
@@ -853,105 +853,10 @@ var { getChapters, getChapter, searchChapters, makeSearchChapters } = crud("chap
|
|
|
853
853
|
search: search4
|
|
854
854
|
});
|
|
855
855
|
|
|
856
|
-
// src/selectors/page.ts
|
|
857
|
-
init_define_import_meta();
|
|
858
|
-
import {
|
|
859
|
-
createSearchSelector as createSearchSelector3,
|
|
860
|
-
filterEntitiesArrayFieldByValues as filterEntitiesArrayFieldByValues3,
|
|
861
|
-
filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues5,
|
|
862
|
-
makeGetAllEntities as makeGetAllEntities2,
|
|
863
|
-
makeGetEntityById as makeGetEntityById3
|
|
864
|
-
} from "@lls/utils";
|
|
865
|
-
import _7 from "lodash/fp.js";
|
|
866
|
-
var search5 = ({
|
|
867
|
-
ids,
|
|
868
|
-
chapterIds,
|
|
869
|
-
isValid,
|
|
870
|
-
oldLessonIds,
|
|
871
|
-
premium,
|
|
872
|
-
thematicNames,
|
|
873
|
-
bookIds,
|
|
874
|
-
isOriginal,
|
|
875
|
-
hasNewDesign,
|
|
876
|
-
slugs,
|
|
877
|
-
isLearningAssessment,
|
|
878
|
-
isCreatedFromScratch
|
|
879
|
-
}) => _7.flow(
|
|
880
|
-
filterEntitiesSimpleFieldByValues5("id", ids),
|
|
881
|
-
filterEntitiesSimpleFieldByValues5("chapter", chapterIds),
|
|
882
|
-
filterEntitiesSimpleFieldByValues5("valid", _7.isNil(isValid) ? void 0 : [isValid]),
|
|
883
|
-
filterEntitiesSimpleFieldByValues5("isOriginal", _7.isNil(isOriginal) ? void 0 : [isOriginal]),
|
|
884
|
-
filterEntitiesSimpleFieldByValues5("hasNewDesign", _7.isNil(hasNewDesign) ? void 0 : [hasNewDesign]),
|
|
885
|
-
filterEntitiesSimpleFieldByValues5("slug", slugs),
|
|
886
|
-
filterEntitiesSimpleFieldByValues5("oldLesson", oldLessonIds),
|
|
887
|
-
filterEntitiesSimpleFieldByValues5(
|
|
888
|
-
"isLearningAssessment",
|
|
889
|
-
_7.isNil(isLearningAssessment) ? void 0 : [isLearningAssessment]
|
|
890
|
-
),
|
|
891
|
-
filterEntitiesSimpleFieldByValues5(
|
|
892
|
-
"isCreatedFromScratch",
|
|
893
|
-
_7.isNil(isCreatedFromScratch) ? void 0 : [isCreatedFromScratch]
|
|
894
|
-
),
|
|
895
|
-
filterEntitiesSimpleFieldByValues5("premium", _7.isNil(premium) ? void 0 : [premium]),
|
|
896
|
-
filterEntitiesSimpleFieldByValues5("thematicName", thematicNames),
|
|
897
|
-
filterEntitiesSimpleFieldByValues5("book", bookIds)
|
|
898
|
-
);
|
|
899
|
-
var { getPages, getPage, searchPages, makeSearchPages } = crud("pages", {
|
|
900
|
-
search: search5
|
|
901
|
-
});
|
|
902
|
-
var getDraftPages = makeGetAllEntities2("drafts");
|
|
903
|
-
var makeGetDraftPage = () => makeGetEntityById3("drafts");
|
|
904
|
-
var getDraftPage = makeGetDraftPage();
|
|
905
|
-
var makeSearchDraftPages = () => createSearchSelector3(
|
|
906
|
-
getDraftPages,
|
|
907
|
-
(_state, params) => params,
|
|
908
|
-
(pages, params) => search5(params)(pages)
|
|
909
|
-
);
|
|
910
|
-
var searchDraftPages = makeSearchDraftPages();
|
|
911
|
-
var makeSearchModifiedPages = () => createSearchSelector3(
|
|
912
|
-
getPages,
|
|
913
|
-
(_state, params) => params,
|
|
914
|
-
(pages, {
|
|
915
|
-
chapterIds,
|
|
916
|
-
userIds,
|
|
917
|
-
originalPageIds,
|
|
918
|
-
parentIds,
|
|
919
|
-
bookIds,
|
|
920
|
-
sharedUserIds,
|
|
921
|
-
updatedAfter,
|
|
922
|
-
isLearningAssessment,
|
|
923
|
-
thematicNames,
|
|
924
|
-
isDraft,
|
|
925
|
-
isCreatedFromScratch,
|
|
926
|
-
isParentCreatedFromScratch,
|
|
927
|
-
sharedGroups
|
|
928
|
-
}) => _7.flow(
|
|
929
|
-
filterEntitiesSimpleFieldByValues5("parent", parentIds),
|
|
930
|
-
filterEntitiesSimpleFieldByValues5("chapter", chapterIds),
|
|
931
|
-
filterEntitiesSimpleFieldByValues5("book", bookIds),
|
|
932
|
-
filterEntitiesSimpleFieldByValues5("user", userIds),
|
|
933
|
-
filterEntitiesSimpleFieldByValues5("originalPage", originalPageIds),
|
|
934
|
-
filterEntitiesArrayFieldByValues3("sharedUsers", sharedUserIds),
|
|
935
|
-
filterEntitiesArrayFieldByValues3("sharedGroups", sharedGroups),
|
|
936
|
-
filterEntitiesSimpleFieldByValues5("isOriginal", [false]),
|
|
937
|
-
filterEntitiesSimpleFieldByValues5("thematicName", thematicNames),
|
|
938
|
-
!_7.isNil(isLearningAssessment) ? filterEntitiesSimpleFieldByValues5("isLearningAssessment", [isLearningAssessment]) : _7.identity,
|
|
939
|
-
!_7.isNil(isCreatedFromScratch) ? filterEntitiesSimpleFieldByValues5("isCreatedFromScratch", [isCreatedFromScratch]) : _7.identity,
|
|
940
|
-
!_7.isNil(isDraft) ? filterEntitiesSimpleFieldByValues5("isDraft", [isDraft]) : _7.identity,
|
|
941
|
-
isParentCreatedFromScratch ? _7.filter(
|
|
942
|
-
(entity) => _7.flow(_7.find({ id: entity?.originalPage }), _7.get("isCreatedFromScratch"))(pages)
|
|
943
|
-
) : _7.identity,
|
|
944
|
-
updatedAfter ? _7.filter(
|
|
945
|
-
_7.flow(_7.get("updatedAt"), (date) => new Date(date) - updatedAfter >= 0)
|
|
946
|
-
) : _7.identity
|
|
947
|
-
)(pages)
|
|
948
|
-
);
|
|
949
|
-
var searchModifiedPages = makeSearchModifiedPages();
|
|
950
|
-
|
|
951
856
|
// src/reducers/entities.ts
|
|
952
857
|
init_define_import_meta();
|
|
953
858
|
import { makeReducer } from "@lls/utils";
|
|
954
|
-
import
|
|
859
|
+
import _7 from "lodash/fp.js";
|
|
955
860
|
|
|
956
861
|
// src/actions/index.ts
|
|
957
862
|
init_define_import_meta();
|
|
@@ -974,23 +879,23 @@ var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
|
|
|
974
879
|
// src/reducers/entities.ts
|
|
975
880
|
var deleteEntityReducer = (state, payload) => {
|
|
976
881
|
const { path } = payload;
|
|
977
|
-
return
|
|
882
|
+
return _7.omit(path, state);
|
|
978
883
|
};
|
|
979
884
|
var updateEntityReducer = (state, payload) => {
|
|
980
885
|
const { path, entity } = payload;
|
|
981
|
-
const currentEntity =
|
|
982
|
-
return
|
|
886
|
+
const currentEntity = _7.get(path, state);
|
|
887
|
+
return _7.set(path, _7.merge(currentEntity, entity), state);
|
|
983
888
|
};
|
|
984
889
|
var setEntityReducer = (state, payload) => {
|
|
985
890
|
const { path, entity } = payload;
|
|
986
|
-
return
|
|
891
|
+
return _7.set(path, entity, state);
|
|
987
892
|
};
|
|
988
893
|
var shallowAssign = (old, next, transform) => {
|
|
989
894
|
let updated = false;
|
|
990
|
-
const merged =
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
if (
|
|
895
|
+
const merged = _7.flow(
|
|
896
|
+
_7.toPairs,
|
|
897
|
+
_7.reduce((memo, [key, val]) => {
|
|
898
|
+
if (_7.isEmpty(val)) return memo;
|
|
994
899
|
if (!old[key]) {
|
|
995
900
|
updated = true;
|
|
996
901
|
memo[key] = val;
|
|
@@ -1003,7 +908,7 @@ var shallowAssign = (old, next, transform) => {
|
|
|
1003
908
|
return memo;
|
|
1004
909
|
}
|
|
1005
910
|
return memo;
|
|
1006
|
-
},
|
|
911
|
+
}, _7.clone(old))
|
|
1007
912
|
)(next);
|
|
1008
913
|
return updated ? merged : old;
|
|
1009
914
|
};
|
|
@@ -1012,7 +917,7 @@ var setEntitiesReducer = (state, payload) => {
|
|
|
1012
917
|
return shallowAssign(
|
|
1013
918
|
entityKind,
|
|
1014
919
|
nextEntityKind,
|
|
1015
|
-
(oldEntity, nextEntity) =>
|
|
920
|
+
(oldEntity, nextEntity) => _7.isEqual(oldEntity, nextEntity) ? oldEntity : _7.assign(oldEntity, nextEntity)
|
|
1016
921
|
);
|
|
1017
922
|
});
|
|
1018
923
|
};
|
|
@@ -1030,7 +935,7 @@ var entities_default = entities;
|
|
|
1030
935
|
// src/reducers/auth.ts
|
|
1031
936
|
init_define_import_meta();
|
|
1032
937
|
import { makeReducer as makeReducer2 } from "@lls/utils";
|
|
1033
|
-
import
|
|
938
|
+
import _8 from "lodash/fp.js";
|
|
1034
939
|
var initialState = {
|
|
1035
940
|
id: void 0,
|
|
1036
941
|
role: null,
|
|
@@ -1043,15 +948,15 @@ var initialState = {
|
|
|
1043
948
|
llsUserId: null
|
|
1044
949
|
};
|
|
1045
950
|
var auth = makeReducer2(initialState, {
|
|
1046
|
-
[actionTypes.SET_AUTH]:
|
|
1047
|
-
[actionTypes.RESET_AUTH]:
|
|
951
|
+
[actionTypes.SET_AUTH]: _8.assign,
|
|
952
|
+
[actionTypes.RESET_AUTH]: _8.constant(initialState)
|
|
1048
953
|
});
|
|
1049
954
|
var auth_default = auth;
|
|
1050
955
|
|
|
1051
956
|
// src/schema/index.ts
|
|
1052
957
|
init_define_import_meta();
|
|
1053
958
|
var import_normalizr = __toESM(require_normalizr(), 1);
|
|
1054
|
-
import
|
|
959
|
+
import _9 from "lodash/fp.js";
|
|
1055
960
|
var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
|
|
1056
961
|
var subject = new import_normalizr.schema.Entity("subjects");
|
|
1057
962
|
var level = new import_normalizr.schema.Entity("levels");
|
|
@@ -1238,7 +1143,7 @@ var querySchema = {
|
|
|
1238
1143
|
}
|
|
1239
1144
|
}
|
|
1240
1145
|
};
|
|
1241
|
-
var normalizeData =
|
|
1146
|
+
var normalizeData = _9.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
|
|
1242
1147
|
export {
|
|
1243
1148
|
auth_default as authReducer,
|
|
1244
1149
|
entities_default as entitiesReducer,
|
|
@@ -1247,21 +1152,13 @@ export {
|
|
|
1247
1152
|
getChapter,
|
|
1248
1153
|
getChapters,
|
|
1249
1154
|
getCurrentUser,
|
|
1250
|
-
getDraftPage,
|
|
1251
|
-
getDraftPages,
|
|
1252
|
-
getPage,
|
|
1253
|
-
getPages,
|
|
1254
1155
|
getSchool,
|
|
1255
1156
|
getSchools,
|
|
1256
1157
|
getUser,
|
|
1257
1158
|
getUsers,
|
|
1258
1159
|
makeGetBook,
|
|
1259
|
-
makeGetDraftPage,
|
|
1260
1160
|
makeSearchBooks,
|
|
1261
1161
|
makeSearchChapters,
|
|
1262
|
-
makeSearchDraftPages,
|
|
1263
|
-
makeSearchModifiedPages,
|
|
1264
|
-
makeSearchPages,
|
|
1265
1162
|
makeSearchSchools,
|
|
1266
1163
|
makeSearchUsers,
|
|
1267
1164
|
makeSearchValidBooks,
|
|
@@ -1269,9 +1166,6 @@ export {
|
|
|
1269
1166
|
querySchema,
|
|
1270
1167
|
searchBooks,
|
|
1271
1168
|
searchChapters,
|
|
1272
|
-
searchDraftPages,
|
|
1273
|
-
searchModifiedPages,
|
|
1274
|
-
searchPages,
|
|
1275
1169
|
searchSchools,
|
|
1276
1170
|
searchUsers,
|
|
1277
1171
|
searchValidBooks,
|
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-
|
|
5
|
+
"version": "24.1.59-49f7c5e0",
|
|
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-
|
|
45
|
-
"@lls/vitescripts": "24.1.59-
|
|
44
|
+
"@lls/utils": "24.1.59-49f7c5e0",
|
|
45
|
+
"@lls/vitescripts": "24.1.59-49f7c5e0"
|
|
46
46
|
},
|
|
47
47
|
"license": "ISC",
|
|
48
48
|
"dependencies": {
|