@lls/common 24.11.0-b1184a97 → 24.11.0-b1fa4682

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 +8 -21
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -157,33 +157,21 @@ var PACKS_RIGHTS = {
157
157
  };
158
158
 
159
159
  // src/utils/right.ts
160
- var getPackRights = ({ user, bookUri }) => {
160
+ var hasFeatureAccess = ({ feature, user, bookUri }) => {
161
161
  if (!user) {
162
- return PACKS_RIGHTS[PACKS.ANONYMOUS_PACK];
162
+ return PACKS_RIGHTS[PACKS.ANONYMOUS_PACK][feature];
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][feature];
167
167
  }
168
- if (bookUri && packs[PACKS.TEACHER_PACK]?.includes(bookUri)) {
169
- return PACKS_RIGHTS[PACKS.TEACHER_PACK];
168
+ if (packs?.[PACKS.TEACHER_PACK]?.includes(bookUri)) {
169
+ return PACKS_RIGHTS[PACKS.TEACHER_PACK][feature];
170
170
  }
171
- if (bookUri && packs[PACKS.CLASSROOM_PACK]?.includes(bookUri)) {
172
- return PACKS_RIGHTS[PACKS.CLASSROOM_PACK];
171
+ if (packs?.[PACKS.CLASSROOM_PACK]?.includes(bookUri)) {
172
+ return PACKS_RIGHTS[PACKS.CLASSROOM_PACK][feature];
173
173
  }
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 });
174
+ return PACKS_RIGHTS[PACKS.CONNECTED_PACK][feature];
187
175
  };
188
176
  export {
189
177
  FEATURES,
@@ -212,6 +200,5 @@ export {
212
200
  FEATURE_VIDEO_PROJECTION,
213
201
  PACKS,
214
202
  PACKS_RIGHTS,
215
- getFeaturesAccessByBook,
216
203
  hasFeatureAccess
217
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lls/common",
3
- "version": "24.11.0-b1184a97",
3
+ "version": "24.11.0-b1fa4682",
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-b1184a97"
37
+ "@lls/vitescripts": "24.11.0-b1fa4682"
38
38
  },
39
39
  "dependencies": {},
40
40
  "scripts": {