@iblai/data-layer 1.12.107 → 1.13.0
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/dist/index.d.ts +335 -2
- package/dist/index.esm.js +68 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +73 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/features/user/__tests__/user-roles.test.d.ts +1 -0
- package/dist/src/features/user/api-slice.d.ts +276 -1
- package/dist/src/features/user/constants.d.ts +6 -0
- package/dist/src/features/user/types.d.ts +44 -0
- package/dist/src/features/user/utils.d.ts +12 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40799,6 +40799,17 @@ const USERS_ENDPOINTS = {
|
|
|
40799
40799
|
service: exports.SERVICES.LMS,
|
|
40800
40800
|
path: () => `/api/ibl/users/manage/roles/`,
|
|
40801
40801
|
},
|
|
40802
|
+
// All roles assigned to a user across every scope (global, org, course).
|
|
40803
|
+
// The same path is served by the CMS/Studio host and, deprecated, by the LMS.
|
|
40804
|
+
// Studio is the default because course-creation roles are only fully
|
|
40805
|
+
// resolvable there; `lmsService` is the fallback for deployments without a
|
|
40806
|
+
// reachable Studio host. Both hosts share one cache tag, so this stays a
|
|
40807
|
+
// single endpoint rather than two.
|
|
40808
|
+
GET_USER_ROLES: {
|
|
40809
|
+
service: exports.SERVICES.STUDIO,
|
|
40810
|
+
lmsService: exports.SERVICES.LMS,
|
|
40811
|
+
path: () => `/api/ibl/users/manage/roles/`,
|
|
40812
|
+
},
|
|
40802
40813
|
UPLOAD_PROFILE_IMAGE: {
|
|
40803
40814
|
service: exports.SERVICES.LMS,
|
|
40804
40815
|
path: (username) => `/api/user/v1/accounts/${username}/image`,
|
|
@@ -40828,6 +40839,7 @@ const USERS_QUERY_KEYS = {
|
|
|
40828
40839
|
GET_USER_METADATA_EDX: () => ['USER_METADATA_EDX'],
|
|
40829
40840
|
RESET_PASSWORD: () => ['RESET_PASSWORD'],
|
|
40830
40841
|
UPDATE_USER_ROLES: () => ['UPDATE_USER_ROLES'],
|
|
40842
|
+
GET_USER_ROLES: () => ['USER_ROLES'],
|
|
40831
40843
|
UPLOAD_PROFILE_IMAGE: () => ['UPLOAD_PROFILE_IMAGE'],
|
|
40832
40844
|
EDX_UPDATE_USER_METADATA: () => ['EDX_UPDATE_USER_METADATA'],
|
|
40833
40845
|
EDX_GET_USER_METADATA: () => ['EDX_GET_USER_METADATA'],
|
|
@@ -40842,6 +40854,7 @@ const userApiSlice = react.createApi({
|
|
|
40842
40854
|
...USERS_QUERY_KEYS.GET_USER_METADATA(),
|
|
40843
40855
|
...USERS_QUERY_KEYS.GET_USER_METADATA_EDX(),
|
|
40844
40856
|
...USERS_QUERY_KEYS.GET_USER_PLATFORM_METADATA(),
|
|
40857
|
+
...USERS_QUERY_KEYS.GET_USER_ROLES(),
|
|
40845
40858
|
featureTags.PLATFORM_USERS,
|
|
40846
40859
|
],
|
|
40847
40860
|
endpoints: (builder) => ({
|
|
@@ -40902,7 +40915,39 @@ const userApiSlice = react.createApi({
|
|
|
40902
40915
|
body: args,
|
|
40903
40916
|
method: 'POST',
|
|
40904
40917
|
}),
|
|
40905
|
-
invalidatesTags: [featureTags.PLATFORM_USERS],
|
|
40918
|
+
invalidatesTags: [featureTags.PLATFORM_USERS, ...USERS_QUERY_KEYS.GET_USER_ROLES()],
|
|
40919
|
+
}),
|
|
40920
|
+
/**
|
|
40921
|
+
* Every role assigned to a user, across all scopes — global, organization
|
|
40922
|
+
* and individual course. A user with no roles returns `[]`.
|
|
40923
|
+
*
|
|
40924
|
+
* At least one of `username`, `email` or `userId` is required (400
|
|
40925
|
+
* otherwise). Non-staff users can only look up their own roles; asking for
|
|
40926
|
+
* someone else's returns 404.
|
|
40927
|
+
*
|
|
40928
|
+
* Defaults to the CMS/Studio host, where course-creation roles are fully
|
|
40929
|
+
* resolvable; pass `useLms` to fall back to the deprecated LMS host.
|
|
40930
|
+
*/
|
|
40931
|
+
getUserRoles: builder.query({
|
|
40932
|
+
query: ({ username, email, userId, useLms }) => {
|
|
40933
|
+
const endpoint = USERS_ENDPOINTS.GET_USER_ROLES;
|
|
40934
|
+
const params = {};
|
|
40935
|
+
if (username) {
|
|
40936
|
+
params.username = username;
|
|
40937
|
+
}
|
|
40938
|
+
if (email) {
|
|
40939
|
+
params.email = email;
|
|
40940
|
+
}
|
|
40941
|
+
if (userId !== undefined) {
|
|
40942
|
+
params.user_id = userId;
|
|
40943
|
+
}
|
|
40944
|
+
return {
|
|
40945
|
+
url: endpoint.path(),
|
|
40946
|
+
service: useLms ? endpoint.lmsService : endpoint.service,
|
|
40947
|
+
params,
|
|
40948
|
+
};
|
|
40949
|
+
},
|
|
40950
|
+
providesTags: USERS_QUERY_KEYS.GET_USER_ROLES(),
|
|
40906
40951
|
}),
|
|
40907
40952
|
getUserMetadataEdx: builder.query({
|
|
40908
40953
|
query: (args) => ({
|
|
@@ -40971,7 +41016,27 @@ const userApiSlice = react.createApi({
|
|
|
40971
41016
|
}),
|
|
40972
41017
|
}),
|
|
40973
41018
|
});
|
|
40974
|
-
const { useGetUserMetadataQuery, useLazyGetUserMetadataQuery, useUpdateUserMetadataMutation, useUpdateUserAccountMutation, useResetPasswordMutation, useUpdateUserRoleMutation, useUploadProfileImageMutation, useRemoveProfileImageMutation, useGetUserMetadataEdxQuery, useLazyGetUserMetadataEdxQuery, useUpdateUserMetadataEdxMutation, useGetUserPlatformMetadataQuery, useLazyGetUserPlatformMetadataQuery, useUpdateUserPlatformMetadataMutation, } = userApiSlice;
|
|
41019
|
+
const { useGetUserMetadataQuery, useLazyGetUserMetadataQuery, useUpdateUserMetadataMutation, useUpdateUserAccountMutation, useResetPasswordMutation, useUpdateUserRoleMutation, useGetUserRolesQuery, useLazyGetUserRolesQuery, useUploadProfileImageMutation, useRemoveProfileImageMutation, useGetUserMetadataEdxQuery, useLazyGetUserMetadataEdxQuery, useUpdateUserMetadataEdxMutation, useGetUserPlatformMetadataQuery, useLazyGetUserPlatformMetadataQuery, useUpdateUserPlatformMetadataMutation, } = userApiSlice;
|
|
41020
|
+
|
|
41021
|
+
/**
|
|
41022
|
+
* Scope a role row applies to, read off its `org`/`course` fields:
|
|
41023
|
+
* both empty → global, `org` only → org, both set → course.
|
|
41024
|
+
*/
|
|
41025
|
+
const getUserRoleScope = (role) => {
|
|
41026
|
+
if (role.course) {
|
|
41027
|
+
return 'course';
|
|
41028
|
+
}
|
|
41029
|
+
if (role.org) {
|
|
41030
|
+
return 'org';
|
|
41031
|
+
}
|
|
41032
|
+
return 'global';
|
|
41033
|
+
};
|
|
41034
|
+
/** Roles that apply platform-wide (e.g. `staff`). */
|
|
41035
|
+
const filterGlobalUserRoles = (roles) => roles.filter((role) => getUserRoleScope(role) === 'global');
|
|
41036
|
+
/** Roles scoped to an organization, optionally narrowed to one org short name. */
|
|
41037
|
+
const filterOrgUserRoles = (roles, org) => roles.filter((role) => getUserRoleScope(role) === 'org' && (org === undefined || role.org === org));
|
|
41038
|
+
/** Roles scoped to a course run, optionally narrowed to one course ID. */
|
|
41039
|
+
const filterCourseUserRoles = (roles, course) => roles.filter((role) => getUserRoleScope(role) === 'course' && (course === undefined || role.course === course));
|
|
40975
41040
|
|
|
40976
41041
|
/**
|
|
40977
41042
|
* Shared fetch for the paginated LTI provider list endpoints. Sends
|
|
@@ -48300,9 +48365,13 @@ exports.evalTotalPages = evalTotalPages;
|
|
|
48300
48365
|
exports.evaluationsApiSlice = evaluationsApiSlice;
|
|
48301
48366
|
exports.fakeBaseQueryWithLogging = fakeBaseQueryWithLogging;
|
|
48302
48367
|
exports.featureTags = featureTags;
|
|
48368
|
+
exports.filterCourseUserRoles = filterCourseUserRoles;
|
|
48369
|
+
exports.filterGlobalUserRoles = filterGlobalUserRoles;
|
|
48370
|
+
exports.filterOrgUserRoles = filterOrgUserRoles;
|
|
48303
48371
|
exports.filterSlashSkills = filterSlashSkills;
|
|
48304
48372
|
exports.getNextRecentMessagesPageParam = getNextRecentMessagesPageParam;
|
|
48305
48373
|
exports.getSpendCapExceededError = getSpendCapExceededError;
|
|
48374
|
+
exports.getUserRoleScope = getUserRoleScope;
|
|
48306
48375
|
exports.gradingApiSlice = gradingApiSlice;
|
|
48307
48376
|
exports.iblFakeBaseQuery = iblFakeBaseQuery;
|
|
48308
48377
|
exports.initializeDataLayer = initializeDataLayer;
|
|
@@ -48764,6 +48833,7 @@ exports.useGetUserProjectDetailsQuery = useGetUserProjectDetailsQuery;
|
|
|
48764
48833
|
exports.useGetUserProjectsQuery = useGetUserProjectsQuery;
|
|
48765
48834
|
exports.useGetUserReportedSkillsQuery = useGetUserReportedSkillsQuery;
|
|
48766
48835
|
exports.useGetUserResumeQuery = useGetUserResumeQuery;
|
|
48836
|
+
exports.useGetUserRolesQuery = useGetUserRolesQuery;
|
|
48767
48837
|
exports.useGetUserSkillsPointsQuery = useGetUserSkillsPointsQuery;
|
|
48768
48838
|
exports.useGetUserSpendCapQuery = useGetUserSpendCapQuery;
|
|
48769
48839
|
exports.useGetUserTenantsQuery = useGetUserTenantsQuery;
|
|
@@ -48973,6 +49043,7 @@ exports.useLazyGetUserProjectDetailsQuery = useLazyGetUserProjectDetailsQuery;
|
|
|
48973
49043
|
exports.useLazyGetUserProjectsQuery = useLazyGetUserProjectsQuery;
|
|
48974
49044
|
exports.useLazyGetUserReportedSkillsQuery = useLazyGetUserReportedSkillsQuery;
|
|
48975
49045
|
exports.useLazyGetUserResumeQuery = useLazyGetUserResumeQuery;
|
|
49046
|
+
exports.useLazyGetUserRolesQuery = useLazyGetUserRolesQuery;
|
|
48976
49047
|
exports.useLazyGetUserSkillsPointsQuery = useLazyGetUserSkillsPointsQuery;
|
|
48977
49048
|
exports.useLazyGetUserSpendCapQuery = useLazyGetUserSpendCapQuery;
|
|
48978
49049
|
exports.useLazyGetUserTenantsQuery = useLazyGetUserTenantsQuery;
|