Skip to content

Commit

Permalink
4.8.15 dev v1 (#375)
Browse files Browse the repository at this point in the history
* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type (#363)

* Updated log details for Parichay login error

* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type

1. Added the v5 of the apis for the assessment.

* Update proxies_v8.ts

* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type

1. FIxed Build fail issue.

---------

Co-authored-by: karthik-tarento <[email protected]>

* Added ui-proxy for interest-capture APIs (#365)

* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type (#367)

* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type

* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type

* KB-4705 | DEV| Assessment | BE | Consumption Logic for the QuestionWeightage Assessment Type (#369)

* added updateDemandstatus ui-proxy. (#366)

* added updateDemandstatus ui-proxy.

* added role for updatedemandstatus

* Updating roles in demads api

* Updateing proxy url

* Fix the build issue

* changes some role for deamnd API

* orgBookmark API addition

* second commit for  role  chnages for demand's API's

* orgBookmark update the read and delete API

* Added the ui-proxy for playList v2 and CRUD and search for announcement

---------

Co-authored-by: tarentomaheshvakkund <[email protected]>
Co-authored-by: karthik-tarento <[email protected]>
Co-authored-by: ruksana2808 <[email protected]>
Co-authored-by: pathiktarento1089 <[email protected]>
Co-authored-by: pathiknandi <[email protected]>
  • Loading branch information
6 people authored Jun 5, 2024
1 parent 25b1aa2 commit 76d6ae4
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 8 deletions.
40 changes: 38 additions & 2 deletions src/protectedApi_v8/user/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const API_END_POINTS = {
assessmentSubmitV2: `${CONSTANTS.KONG_API_BASE}/v2/user`,
assessmentSubmitV3: `${CONSTANTS.KONG_API_BASE}/v3/user`,
assessmentSubmitV4: `${CONSTANTS.KONG_API_BASE}/v4/user`,
assessmentSubmitV5: `${CONSTANTS.KONG_API_BASE}/v5/user`,
iapSubmitAssessment: `${CONSTANTS.SB_EXT_API_BASE_2}/v3/iap-assessment`,
postAssessment: `${CONSTANTS.POST_ASSESSMENT_BASE}/lmsapi/v1/post_assessment`,
}
Expand Down Expand Up @@ -170,5 +171,40 @@ evaluateApi.post('/assessment/submit/v4', async (req, res) => {
error: GENERAL_ERR_MSG,
}
)
}
})
}})

evaluateApi.post('/assessment/submit/v5', async (req, res) => {
try {
const userId = extractUserIdFromRequest(req)
const url = `${API_END_POINTS.assessmentSubmitV5}/assessment/submit`
const requestBody = {
...req.body,
}
let rootOrgId = ''
// tslint:disable-next-line
if (typeof req.session != "undefined" && typeof req.session.rootOrgId != "undefined") {
// tslint:disable-next-line
rootOrgId = req.session.rootOrgId
}
const response = await axios({
...axiosRequestConfig,
data: requestBody,
headers: {
Authorization: CONSTANTS.SB_API_KEY,
userId,
'x-authenticated-user-orgid': rootOrgId,
// tslint:disable-next-line: no-duplicate-string
'x-authenticated-user-token': extractUserToken(req),
},
method: 'POST',
url,
})
res.status(response.status).send(response.data)
} catch (error) {
res.status((error && error.response && error.response.status) || 500).send(
(error && error.response && error.response.data) || {
error: GENERAL_ERR_MSG,
}
)
}
})
28 changes: 28 additions & 0 deletions src/proxies_v8/proxies_v8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ilpProxyCreatorRoute,
// proxyCreatorDiscussion,
proxyAssessmentRead,
proxyAssessmentReadV2,
proxyContent,
proxyContentLearnerVM,
proxyCreatorForms,
Expand Down Expand Up @@ -709,6 +710,29 @@ proxiesV8.use('/demand/content/*',
proxiesV8.use('/playList/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

proxiesV8.use('/question/v5/read',
// tslint:disable-next-line: max-line-length
proxyQuestionRead(express.Router(), `${CONSTANTS.KONG_API_BASE}` + '/player/question/v5/list')
)

proxiesV8.use('/assessment/v5/read/*',
// tslint:disable-next-line: max-line-length
proxyAssessmentReadV2(express.Router(), `${CONSTANTS.KONG_API_BASE}` + '/player/questionset/v5/hierarchy')
)

proxiesV8.use('/interest/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

proxiesV8.use('/assessment/save/',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

proxiesV8.use('/announcements/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

function removePrefix(prefix: string, s: string) {
return s.substr(prefix.length)
}
Expand Down Expand Up @@ -909,6 +933,10 @@ proxiesV8.use('/careers/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

proxiesV8.use('/orgBookmark/*',
proxyCreatorSunbird(express.Router(), `${CONSTANTS.KONG_API_BASE}`)
)

export interface IUserProfile {
channel: string
firstName: string
Expand Down
6 changes: 3 additions & 3 deletions src/publicApi_v8/ssoUserHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ export async function updateKeycloakSession(emailId: string, req: any, res: any)
keycloakClient.authenticated(req, (error: any) => {
logInfo('ssoUserHelper::keycloakClient::authenticated..')
if (error) {
logError('googleauthhelper:createSession error creating session')
result.errMessage = 'GOOGLE_CREATE_SESSION_FAILED'
logError('ssoUserHelper:: keycloak.authenticate failed Email: ' + emailId + ', Error: ' + JSON.stringify(error))
result.errMessage = 'FAILED_TO_CREATE_KEYCLOAK_SESSION'
}
})
return Promise.resolve(result)
} catch (err) {
logError('googleOauthHelper: createSession failed. Error: ' + JSON.stringify(err))
logError('ssoUserHelper: createSession failed for Email: ' + emailId + ', Error: ' + JSON.stringify(err))
result.errMessage = 'FAILED_TO_CREATE_KEYCLOAK_SESSION'
}
return Promise.resolve(result)
Expand Down
20 changes: 20 additions & 0 deletions src/utils/proxyCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,23 @@ export function proxyCreatorForms(route: Router, _timeout = 10000): Router {
})
return route
}

export function proxyAssessmentReadV2(route: Router, targetUrl: string, _timeout = 10000): Router {
route.all('/*', (req, res) => {
let url = removePrefix(`${PROXY_SLUG}/assessment/v5/read`, req.originalUrl)
// Check if the target URL already contains query parameters
if (url.includes('?')) {
url = targetUrl + url + '&hierarchy=detail'
} else {
url = targetUrl + url + '?hierarchy=detail'
}
// tslint:disable-next-line: no-console
console.log('REQ_URL_UPDATED proxyAssessmentReadV5', url)
proxy.web(req, res, {
changeOrigin: true,
ignorePath: true,
target: url,
})
})
return route
}
207 changes: 204 additions & 3 deletions src/utils/whitelistApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,9 @@ export const API_LIST = {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
ROLE.MDO_ADMIN,
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/demand/content/read/:do_id': {
Expand All @@ -3156,14 +3158,15 @@ export const API_LIST = {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
ROLE.MDO_ADMIN,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/demand/content/search': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
ROLE.PUBLIC,
],
},
'/proxies/v8/playList/create': {
Expand Down Expand Up @@ -3203,6 +3206,181 @@ export const API_LIST = {
ROLE.SPV_PUBLISHER,
],
},
'/proxies/v8/user/assessment/v5/result': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/user/assessment/v5/retake/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/protected/v8/user/evaluate/assessment/submit/v5': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/assessment/v5/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/question/v5/read': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/interest/v1/create': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.CBP_ADMIN,
ROLE.CONTENT_CREATOR,
],
},
'/proxies/v8/interest/v1/search': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/interest/v1/assign': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_ADMIN,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/interest/v1/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/assessment/save': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/demand/content/v1/update/status': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_ADMIN,
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/orgBookmark/v1/create': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_ADMIN,
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/orgBookmark/v1/update': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_ADMIN,
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/orgBookmark/v1/search': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/orgBookmark/v1/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/orgBookmark/v1/delete/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/playList/v2/search': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/playList/read/:id/:orgId': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/announcements/v1/create': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_ADMIN,
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/announcements/v1/update': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_ADMIN,
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
'/proxies/v8/announcements/v1/search': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/announcements/v1/read/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.PUBLIC,
],
},
'/proxies/v8/announcements/v1/delete/:id': {
checksNeeded: [CHECK.ROLE],
// tslint:disable-next-line: object-literal-sort-keys
ROLE_CHECK: [
ROLE.MDO_LEADER,
ROLE.SPV_ADMIN,
],
},
},
URL_PATTERN:
[
Expand Down Expand Up @@ -3613,5 +3791,28 @@ export const API_LIST = {
'/proxies/v8/playList/update',
'/proxies/v8/playList/search',
'/proxies/v8/playList/delete/:do_id',
'/proxies/v8/user/assessment/v5/result',
'/proxies/v8/user/assessment/v5/retake/:id',
'/protected/v8/user/evaluate/assessment/submit/v5',
'/proxies/v8/assessment/v5/read/:id',
'/proxies/v8/question/v5/read',
'/proxies/v8/interest/v1/create',
'/proxies/v8/interest/v1/search',
'/proxies/v8/interest/v1/assign',
'/proxies/v8/interest/v1/read/:id',
'/proxies/v8/assessment/save',
'/proxies/v8/demand/content/v1/update/status',
'/proxies/v8/orgBookmark/v1/create',
'/proxies/v8/orgBookmark/v1/update',
'/proxies/v8/orgBookmark/v1/search',
'/proxies/v8/orgBookmark/v1/read/:id',
'/proxies/v8/orgBookmark/v1/delete/:id',
'/proxies/v8/playList/v2/search',
'/proxies/v8/playList/read/:id/:orgId',
'/proxies/v8/announcements/v1/create',
'/proxies/v8/announcements/v1/update',
'/proxies/v8/announcements/v1/search',
'/proxies/v8/announcements/v1/read/:id',
'/proxies/v8/announcements/v1/delete/:id',
],
}

0 comments on commit 76d6ae4

Please sign in to comment.