@lls/common 24.11.0-9405fed2 → 24.11.0-b1184a97
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 +21 -8
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -157,21 +157,33 @@ var PACKS_RIGHTS = {
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
// src/utils/right.ts
|
|
160
|
-
var
|
|
160
|
+
var getPackRights = ({ user, bookUri }) => {
|
|
161
161
|
if (!user) {
|
|
162
|
-
return PACKS_RIGHTS[PACKS.ANONYMOUS_PACK]
|
|
162
|
+
return PACKS_RIGHTS[PACKS.ANONYMOUS_PACK];
|
|
163
163
|
}
|
|
164
164
|
const packs = user?.packs ?? {};
|
|
165
165
|
if (!Object.keys(packs)?.length) {
|
|
166
|
-
return PACKS_RIGHTS[PACKS.CONNECTED_PACK]
|
|
166
|
+
return PACKS_RIGHTS[PACKS.CONNECTED_PACK];
|
|
167
167
|
}
|
|
168
|
-
if (packs
|
|
169
|
-
return PACKS_RIGHTS[PACKS.TEACHER_PACK]
|
|
168
|
+
if (bookUri && packs[PACKS.TEACHER_PACK]?.includes(bookUri)) {
|
|
169
|
+
return PACKS_RIGHTS[PACKS.TEACHER_PACK];
|
|
170
170
|
}
|
|
171
|
-
if (packs
|
|
172
|
-
return PACKS_RIGHTS[PACKS.CLASSROOM_PACK]
|
|
171
|
+
if (bookUri && packs[PACKS.CLASSROOM_PACK]?.includes(bookUri)) {
|
|
172
|
+
return PACKS_RIGHTS[PACKS.CLASSROOM_PACK];
|
|
173
173
|
}
|
|
174
|
-
return PACKS_RIGHTS[PACKS.CONNECTED_PACK]
|
|
174
|
+
return PACKS_RIGHTS[PACKS.CONNECTED_PACK];
|
|
175
|
+
};
|
|
176
|
+
var hasFeatureAccess = ({ feature, user, bookUri }) => {
|
|
177
|
+
if (!feature) return false;
|
|
178
|
+
const packRights = getPackRights({ user, bookUri });
|
|
179
|
+
if (feature in packRights) return packRights[feature] ?? false;
|
|
180
|
+
return false;
|
|
181
|
+
};
|
|
182
|
+
var getFeaturesAccessByBook = ({
|
|
183
|
+
user,
|
|
184
|
+
bookUri
|
|
185
|
+
}) => {
|
|
186
|
+
return getPackRights({ user, bookUri });
|
|
175
187
|
};
|
|
176
188
|
export {
|
|
177
189
|
FEATURES,
|
|
@@ -200,5 +212,6 @@ export {
|
|
|
200
212
|
FEATURE_VIDEO_PROJECTION,
|
|
201
213
|
PACKS,
|
|
202
214
|
PACKS_RIGHTS,
|
|
215
|
+
getFeaturesAccessByBook,
|
|
203
216
|
hasFeatureAccess
|
|
204
217
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lls/common",
|
|
3
|
-
"version": "24.11.0-
|
|
3
|
+
"version": "24.11.0-b1184a97",
|
|
4
4
|
"description": "utils and constants shared between front and backend",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"lodash": "4.17.21",
|
|
35
35
|
"esbuild": "0.24.0",
|
|
36
36
|
"typescript": "5.6.3",
|
|
37
|
-
"@lls/vitescripts": "24.11.0-
|
|
37
|
+
"@lls/vitescripts": "24.11.0-b1184a97"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {},
|
|
40
40
|
"scripts": {
|