@coorpacademy/app-review 0.10.0 → 0.10.1
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/es/actions/api/fetch-correction.d.ts +1 -2
- package/es/actions/api/fetch-rank.d.ts +1 -2
- package/es/actions/api/fetch-skill.d.ts +1 -2
- package/es/actions/api/fetch-skills.d.ts +1 -2
- package/es/actions/api/fetch-slide.d.ts +1 -2
- package/es/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +1 -2
- package/es/actions/api/post-answer.d.ts +1 -2
- package/es/actions/api/post-progression.d.ts +1 -2
- package/es/actions/ui/navigation.d.ts +1 -1
- package/es/actions/ui/slides.d.ts +1 -1
- package/es/common/index.d.ts +1 -1
- package/es/configure-store.d.ts +1 -1
- package/es/configure-store.js +1 -1
- package/es/reducers/data/corrections.d.ts +1 -1
- package/es/reducers/data/current-skill.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +1 -1
- package/es/reducers/data/skills.d.ts +1 -1
- package/es/reducers/data/slides.d.ts +1 -1
- package/es/reducers/ui/slide.d.ts +1 -0
- package/es/reducers/ui/slide.js +3 -2
- package/es/services/fetch-correction.d.ts +2 -0
- package/es/services/fetch-correction.js +14 -0
- package/es/services/fetch-rank.d.ts +2 -0
- package/es/services/fetch-rank.js +10 -0
- package/es/services/fetch-skill.d.ts +2 -0
- package/es/services/fetch-skill.js +11 -0
- package/es/services/fetch-skills.d.ts +2 -0
- package/es/services/fetch-skills.js +10 -0
- package/es/services/fetch-slide.d.ts +2 -0
- package/es/services/fetch-slide.js +10 -0
- package/es/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/es/services/fetch-slides-to-review-by-skill-ref.js +10 -0
- package/es/services/index.d.ts +2 -0
- package/es/services/index.js +18 -0
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +20 -0
- package/es/services/post-progression.d.ts +2 -0
- package/es/services/post-progression.js +21 -0
- package/es/services/tools/fetch-responses.d.ts +7 -0
- package/es/services/tools/fetch-responses.js +33 -0
- package/es/services/tools/sleep.d.ts +1 -0
- package/es/services/tools/sleep.js +3 -0
- package/es/types/common.d.ts +186 -10
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/slides/index.d.ts +1 -1
- package/es/views/slides/index.js +2 -0
- package/es/views/slides/map-api-slide-to-ui.d.ts +1 -2
- package/lib/actions/api/fetch-correction.d.ts +1 -2
- package/lib/actions/api/fetch-rank.d.ts +1 -2
- package/lib/actions/api/fetch-skill.d.ts +1 -2
- package/lib/actions/api/fetch-skills.d.ts +1 -2
- package/lib/actions/api/fetch-slide.d.ts +1 -2
- package/lib/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +1 -2
- package/lib/actions/api/post-answer.d.ts +1 -2
- package/lib/actions/api/post-progression.d.ts +1 -2
- package/lib/actions/ui/navigation.d.ts +1 -1
- package/lib/actions/ui/slides.d.ts +1 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/configure-store.d.ts +1 -1
- package/lib/configure-store.js +2 -2
- package/lib/reducers/data/corrections.d.ts +1 -1
- package/lib/reducers/data/current-skill.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +1 -1
- package/lib/reducers/data/skills.d.ts +1 -1
- package/lib/reducers/data/slides.d.ts +1 -1
- package/lib/reducers/ui/slide.d.ts +1 -0
- package/lib/reducers/ui/slide.js +3 -2
- package/lib/services/fetch-correction.d.ts +2 -0
- package/lib/services/fetch-correction.js +21 -0
- package/lib/services/fetch-rank.d.ts +2 -0
- package/lib/services/fetch-rank.js +17 -0
- package/lib/services/fetch-skill.d.ts +2 -0
- package/lib/services/fetch-skill.js +18 -0
- package/lib/services/fetch-skills.d.ts +2 -0
- package/lib/services/fetch-skills.js +17 -0
- package/lib/services/fetch-slide.d.ts +2 -0
- package/lib/services/fetch-slide.js +17 -0
- package/lib/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/lib/services/fetch-slides-to-review-by-skill-ref.js +17 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +22 -0
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +27 -0
- package/lib/services/post-progression.d.ts +2 -0
- package/lib/services/post-progression.js +28 -0
- package/lib/services/tools/fetch-responses.d.ts +7 -0
- package/lib/services/tools/fetch-responses.js +40 -0
- package/lib/services/tools/sleep.d.ts +1 -0
- package/lib/services/tools/sleep.js +7 -0
- package/lib/types/common.d.ts +186 -10
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/slides/index.d.ts +1 -1
- package/lib/views/slides/index.js +2 -0
- package/lib/views/slides/map-api-slide-to-ui.d.ts +1 -2
- package/locales/bs/review.json +4 -1
- package/locales/cs/review.json +6 -6
- package/locales/de/review.json +7 -7
- package/locales/es/review.json +7 -7
- package/locales/hr/review.json +1 -1
- package/locales/hu/review.json +7 -7
- package/locales/hy/review.json +4 -1
- package/locales/id/review.json +3 -3
- package/locales/it/review.json +6 -6
- package/locales/ja/review.json +5 -5
- package/locales/ko/review.json +7 -7
- package/locales/nl/review.json +6 -6
- package/locales/pl/review.json +6 -6
- package/locales/pt/review.json +7 -7
- package/locales/ro/review.json +6 -6
- package/locales/sk/review.json +3 -3
- package/locales/th/review.json +5 -5
- package/locales/tl/review.json +7 -7
- package/locales/tr/review.json +2 -2
- package/locales/uk/review.json +7 -7
- package/locales/vi/review.json +3 -3
- package/locales/zh/review.json +4 -4
- package/locales/zh_TW/review.json +6 -6
- package/package.json +3 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
2
|
import { ReviewPlayerProps } from '@coorpacademy/components/es/template/app-review/player/prop-types';
|
|
3
3
|
import { SlideProps } from '@coorpacademy/components/es/organism/review-slide/prop-types';
|
|
4
|
-
import { ConnectedOptions } from '../../types/common';
|
|
4
|
+
import type { ConnectedOptions } from '../../types/common';
|
|
5
5
|
import type { StoreState } from '../../reducers';
|
|
6
6
|
import type { AnswerUI } from '../../types/slides';
|
|
7
7
|
declare const ICON_VALUES: {
|
package/es/views/slides/index.js
CHANGED
|
@@ -92,6 +92,7 @@ const buildStackSlides = (state, dispatch, options) => {
|
|
|
92
92
|
const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
|
|
93
93
|
const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
|
|
94
94
|
const animationType = lastAnsweredSlideRef ? slideUI.animationType : undefined;
|
|
95
|
+
const disabledContent = get(['ui', 'slide', slideRef, 'pendingAnswerRequest'], state);
|
|
95
96
|
const updatedUiSlide = {
|
|
96
97
|
...uiSlide,
|
|
97
98
|
position,
|
|
@@ -100,6 +101,7 @@ const buildStackSlides = (state, dispatch, options) => {
|
|
|
100
101
|
loading: false,
|
|
101
102
|
questionText,
|
|
102
103
|
answerUI,
|
|
104
|
+
disabledContent,
|
|
103
105
|
parentContentTitle: translate('Content Parent Title', {
|
|
104
106
|
contentTitle: parentContentTitle,
|
|
105
107
|
contentType: parentContentType
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import { Question, SlideFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
2
|
import { AnswerUI } from '../../types/slides';
|
|
4
|
-
import { Translate } from '../../types/common';
|
|
3
|
+
import { Question, SlideFromAPI, Translate } from '../../types/common';
|
|
5
4
|
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
6
5
|
export declare const mapApiSlideToUi: (dispatch: Dispatch, translate: Translate) => (slide: SlideFromAPI, answers: string[]) => {
|
|
7
6
|
questionText: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { CorrectionFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { CorrectionFromAPI, ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const CORRECTION_FETCH_REQUEST: "@@correction/FETCH_REQUEST";
|
|
6
5
|
export declare const CORRECTION_FETCH_SUCCESS: "@@correction/FETCH_SUCCESS";
|
|
7
6
|
export declare const CORRECTION_FETCH_FAILURE: "@@correction/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { Rank, Services } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Rank, Services, ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const RANK_FETCH_START_REQUEST: "@@rank/FETCH_START_REQUEST";
|
|
6
5
|
export declare const RANK_FETCH_START_SUCCESS: "@@rank/FETCH_START_SUCCESS";
|
|
7
6
|
export declare const RANK_FETCH_START_FAILURE: "@@rank/FETCH_START_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import type { Skill } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Skill, ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const SKILL_FETCH_REQUEST: "@@skill/FETCH_REQUEST";
|
|
6
5
|
export declare const SKILL_FETCH_SUCCESS: "@@skill/FETCH_SUCCESS";
|
|
7
6
|
export declare const SKILL_FETCH_FAILURE: "@@skill/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { SkillToReview } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
2
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import type { ThunkOptions } from '../../types/common';
|
|
3
|
+
import type { ThunkOptions, SkillToReview } from '../../types/common';
|
|
5
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
6
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
7
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { SlideFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import type { ThunkOptions } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { ThunkOptions, SlideFromAPI } from '../../types/common';
|
|
5
4
|
export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
|
|
6
5
|
export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
|
|
7
6
|
export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { SlideIdFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
3
|
-
import { Options } from '../../types/common';
|
|
4
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Options, SlideIdFromAPI } from '../../types/common';
|
|
5
4
|
export declare const SLIDES_TO_REVIEW_FETCH_REQUEST: "@@slidesToReview/FETCH_REQUEST";
|
|
6
5
|
export declare const SLIDES_TO_REVIEW_FETCH_SUCCESS: "@@slidesToReview/FETCH_SUCCESS";
|
|
7
6
|
export declare const SLIDES_TO_REVIEW_FETCH_FAILURE: "@@slidesToReview/FETCH_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { ProgressionFromAPI } from '
|
|
2
|
+
import type { ThunkOptions, ProgressionFromAPI } from '../../types/common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import type { ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
|
|
6
5
|
export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
|
|
7
6
|
export declare const POST_ANSWER_FAILURE: "@@answer/POST_FAILURE";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { ProgressionFromAPI } from '
|
|
2
|
+
import type { ThunkOptions, ProgressionFromAPI } from '../../types/common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import type { ThunkOptions } from '../../types/common';
|
|
5
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
6
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
7
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import { ThunkOptions, AppOptions, ViewName } from '../../types/common';
|
|
3
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
+
import { ThunkOptions, AppOptions, ViewName } from '../../types/common';
|
|
4
4
|
export declare type NavigateToAction = {
|
|
5
5
|
type: '@@navigation/NAVIGATE_TO';
|
|
6
6
|
payload: ViewName;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlideFromAPI } from '
|
|
1
|
+
import { SlideFromAPI } from '../../types/common';
|
|
2
2
|
import { AnswerUI } from '../../types/slides';
|
|
3
3
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
4
4
|
export declare type Slide = {
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProgressionFromAPI } from '
|
|
1
|
+
import type { ProgressionFromAPI } from '../types/common';
|
|
2
2
|
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
3
3
|
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
4
4
|
export declare const getProgressionSlidesRefs: (progression: ProgressionFromAPI) => string[];
|
package/lib/configure-store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AnyAction, Store } from 'redux';
|
|
2
2
|
import { StoreState } from './reducers';
|
|
3
|
-
import
|
|
3
|
+
import { AppOptions } from './types/common';
|
|
4
4
|
export default function configureStore(options: AppOptions): Store<StoreState, AnyAction>;
|
package/lib/configure-store.js
CHANGED
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const redux_1 = require("redux");
|
|
7
7
|
const redux_thunk_1 = __importDefault(require("redux-thunk"));
|
|
8
|
-
const review_services_1 = require("@coorpacademy/review-services");
|
|
9
8
|
const reducers_1 = __importDefault(require("./reducers"));
|
|
9
|
+
const services_1 = require("./services");
|
|
10
10
|
function configureStore(options) {
|
|
11
11
|
const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
12
12
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
|
@@ -16,7 +16,7 @@ function configureStore(options) {
|
|
|
16
16
|
})
|
|
17
17
|
: redux_1.compose;
|
|
18
18
|
const thunkOptions = {
|
|
19
|
-
services: options.services || (0,
|
|
19
|
+
services: options.services || (0, services_1.getServices)(),
|
|
20
20
|
callbackOnViewChanged: options.callbackOnViewChanged
|
|
21
21
|
};
|
|
22
22
|
const thunkMiddleware = redux_thunk_1.default.withExtraArgument(thunkOptions);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CorrectionFromAPI } from '
|
|
1
|
+
import type { CorrectionFromAPI } from '../../types/common';
|
|
2
2
|
import { ReceivedCorrection, FetchCorrection } from '../../actions/api/fetch-correction';
|
|
3
3
|
import { FetchProgression } from '../../actions/api/post-progression';
|
|
4
4
|
export declare type CorrectionsState = Record<string, CorrectionFromAPI>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Skill } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
1
|
import { ReceivedSkill } from '../../actions/api/fetch-skill';
|
|
2
|
+
import { Skill } from '../../types/common';
|
|
3
3
|
export declare type CurrentSkillState = Skill | null;
|
|
4
4
|
declare const reducer: (state: CurrentSkillState | undefined, action: ReceivedSkill) => CurrentSkillState;
|
|
5
5
|
export default reducer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ProgressionFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
1
|
import { PostAnswerSuccessAction } from '../../actions/api/post-answer';
|
|
3
2
|
import { FetchProgression, ReceivedProgression } from '../../actions/api/post-progression';
|
|
3
|
+
import { ProgressionFromAPI } from '../../types/common';
|
|
4
4
|
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
5
5
|
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction | FetchProgression) => ProgressionState;
|
|
6
6
|
export default reducer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SkillToReview } from '
|
|
1
|
+
import { SkillToReview } from '../../types/common';
|
|
2
2
|
import { ReceivedSkills } from '../../actions/api/fetch-skills';
|
|
3
3
|
export declare type SkillsState = SkillToReview[];
|
|
4
4
|
declare const reducer: (state: SkillsState | undefined, action: ReceivedSkills) => SkillsState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SlideFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
1
|
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
3
2
|
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
|
+
import { SlideFromAPI } from '../../types/common';
|
|
4
4
|
export declare type SlidesAction = FetchSlide | ReceivedSlide;
|
|
5
5
|
export declare type SlidesState = Record<string, SlideFromAPI | null>;
|
|
6
6
|
export declare const initialState: SlidesState;
|
|
@@ -10,6 +10,7 @@ export declare type UISlide = {
|
|
|
10
10
|
animateCorrectionPopin: boolean;
|
|
11
11
|
showCorrectionPopin: boolean;
|
|
12
12
|
animationType?: SlideUIAnimations;
|
|
13
|
+
pendingAnswerRequest: boolean;
|
|
13
14
|
};
|
|
14
15
|
export declare type UISlideState = Record<string, UISlide>;
|
|
15
16
|
export declare const initialState: UISlideState;
|
package/lib/reducers/ui/slide.js
CHANGED
|
@@ -24,7 +24,8 @@ state = exports.initialState, action) => {
|
|
|
24
24
|
return (0, pipe_1.default)((0, unset_1.default)([action.meta.slideRef, 'animationType']), (0, set_1.default)([action.meta.slideRef], {
|
|
25
25
|
validateButton: false,
|
|
26
26
|
animateCorrectionPopin: false,
|
|
27
|
-
showCorrectionPopin: false
|
|
27
|
+
showCorrectionPopin: false,
|
|
28
|
+
pendingAnswerRequest: false
|
|
28
29
|
}))(state);
|
|
29
30
|
}
|
|
30
31
|
case answers_1.EDIT_QCM:
|
|
@@ -36,7 +37,7 @@ state = exports.initialState, action) => {
|
|
|
36
37
|
return (0, set_1.default)([action.meta.slideRef, 'validateButton'], !(0, pipe_1.default)(compact_1.default, isEmpty_1.default)(action.payload), state);
|
|
37
38
|
}
|
|
38
39
|
case post_answer_1.POST_ANSWER_REQUEST: {
|
|
39
|
-
return (0, set_1.default)([action.meta.slideRef, 'validateButton'], false, state);
|
|
40
|
+
return (0, pipe_1.default)((0, set_1.default)([action.meta.slideRef, 'validateButton'], false), (0, set_1.default)([action.meta.slideRef, 'pendingAnswerRequest'], true))(state);
|
|
40
41
|
}
|
|
41
42
|
case fetch_correction_1.CORRECTION_FETCH_SUCCESS: {
|
|
42
43
|
return (0, pipe_1.default)((0, set_1.default)([action.meta.slideRef, 'animateCorrectionPopin'], true), (0, set_1.default)([action.meta.slideRef, 'showCorrectionPopin'], true))(state);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchCorrection = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const fetchCorrection = async (slideRef, token, progressionId, answer) => {
|
|
11
|
+
const { host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/progressions/${progressionId}/answers/${slideRef}`, {
|
|
13
|
+
method: 'post',
|
|
14
|
+
headers: { authorization: token },
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
answer
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
20
|
+
};
|
|
21
|
+
exports.fetchCorrection = fetchCorrection;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchRank = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const fetchRank = async (token) => {
|
|
11
|
+
const { user: userId, host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v1/leaderboard/rank/${userId}?group=ALL`, {
|
|
13
|
+
headers: { authorization: token }
|
|
14
|
+
});
|
|
15
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
16
|
+
};
|
|
17
|
+
exports.fetchRank = fetchRank;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchSkill = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const fetchSkill = async (skillRef, token) => {
|
|
11
|
+
const { host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/skills?conditions={"ref":"${skillRef}"}`, {
|
|
13
|
+
headers: { authorization: token }
|
|
14
|
+
});
|
|
15
|
+
const skills = await (0, fetch_responses_1.toJSON)(response);
|
|
16
|
+
return skills[0];
|
|
17
|
+
};
|
|
18
|
+
exports.fetchSkill = fetchSkill;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchSkills = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const fetchSkills = async (token) => {
|
|
11
|
+
const { user: userId, host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/skills/review/user/${userId}`, {
|
|
13
|
+
headers: { authorization: token }
|
|
14
|
+
});
|
|
15
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
16
|
+
};
|
|
17
|
+
exports.fetchSkills = fetchSkills;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchSlide = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const fetchSlide = async (slideRef, token) => {
|
|
11
|
+
const { host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v1/slides/${slideRef}/parentContentTitle`, {
|
|
13
|
+
headers: { authorization: token }
|
|
14
|
+
});
|
|
15
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
16
|
+
};
|
|
17
|
+
exports.fetchSlide = fetchSlide;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchSlidesToReviewBySkillRef = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const fetchSlidesToReviewBySkillRef = async (token, skillRef) => {
|
|
11
|
+
const { user: userId, host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/skills/${skillRef}/review/user/${userId}/slide`, {
|
|
13
|
+
headers: { authorization: token }
|
|
14
|
+
});
|
|
15
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
16
|
+
};
|
|
17
|
+
exports.fetchSlidesToReviewBySkillRef = fetchSlidesToReviewBySkillRef;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServices = void 0;
|
|
4
|
+
const fetch_correction_1 = require("./fetch-correction");
|
|
5
|
+
const fetch_rank_1 = require("./fetch-rank");
|
|
6
|
+
const fetch_skills_1 = require("./fetch-skills");
|
|
7
|
+
const fetch_slide_1 = require("./fetch-slide");
|
|
8
|
+
const fetch_slides_to_review_by_skill_ref_1 = require("./fetch-slides-to-review-by-skill-ref");
|
|
9
|
+
const post_answer_1 = require("./post-answer");
|
|
10
|
+
const post_progression_1 = require("./post-progression");
|
|
11
|
+
const fetch_skill_1 = require("./fetch-skill");
|
|
12
|
+
const getServices = () => ({
|
|
13
|
+
fetchCorrection: fetch_correction_1.fetchCorrection,
|
|
14
|
+
fetchRank: fetch_rank_1.fetchRank,
|
|
15
|
+
fetchSkill: fetch_skill_1.fetchSkill,
|
|
16
|
+
fetchSkills: fetch_skills_1.fetchSkills,
|
|
17
|
+
fetchSlide: fetch_slide_1.fetchSlide,
|
|
18
|
+
fetchSlidesToReviewBySkillRef: fetch_slides_to_review_by_skill_ref_1.fetchSlidesToReviewBySkillRef,
|
|
19
|
+
postAnswer: post_answer_1.postAnswer,
|
|
20
|
+
postProgression: post_progression_1.postProgression
|
|
21
|
+
});
|
|
22
|
+
exports.getServices = getServices;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.postAnswer = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const postAnswer = async (progression, token, answer) => {
|
|
11
|
+
const progressionId = progression._id;
|
|
12
|
+
const slideRef = progression.state.nextContent.ref;
|
|
13
|
+
const { host } = (0, jwt_decode_1.default)(token);
|
|
14
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/progressions/${progressionId}/answers`, {
|
|
15
|
+
method: 'post',
|
|
16
|
+
headers: { authorization: token, 'content-type': 'application/json' },
|
|
17
|
+
body: JSON.stringify({
|
|
18
|
+
content: {
|
|
19
|
+
ref: slideRef,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
answer
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
26
|
+
};
|
|
27
|
+
exports.postAnswer = postAnswer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.postProgression = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const fetch_responses_1 = require("./tools/fetch-responses");
|
|
10
|
+
const postProgression = async (skillRef, token) => {
|
|
11
|
+
const { host } = (0, jwt_decode_1.default)(token);
|
|
12
|
+
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/progressions`, {
|
|
13
|
+
method: 'post',
|
|
14
|
+
headers: { authorization: token, 'content-type': 'application/json' },
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
content: {
|
|
17
|
+
ref: skillRef,
|
|
18
|
+
type: 'skill'
|
|
19
|
+
},
|
|
20
|
+
engine: {
|
|
21
|
+
ref: 'review',
|
|
22
|
+
version: '1'
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
27
|
+
};
|
|
28
|
+
exports.postProgression = postProgression;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class ResponseError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
constructor(statusCode: number, statusText: string, body?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare const toJSON: <T = unknown>(response: Response) => Promise<T>;
|
|
6
|
+
export declare const toText: (response: Response) => Promise<string>;
|
|
7
|
+
export declare const toVoid: (response: Response) => Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toVoid = exports.toText = exports.toJSON = exports.ResponseError = void 0;
|
|
4
|
+
class ResponseError extends Error {
|
|
5
|
+
constructor(statusCode, statusText, body = '') {
|
|
6
|
+
super(`${statusText} ${body}`.trim());
|
|
7
|
+
this.name = 'ResponseError';
|
|
8
|
+
this.statusCode = statusCode;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ResponseError = ResponseError;
|
|
12
|
+
const toJSON = async (response) => {
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
const body = await response.text();
|
|
15
|
+
throw new ResponseError(response.status, response.statusText, body);
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
return await response.json();
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
throw new ResponseError(response.status, response.statusText);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.toJSON = toJSON;
|
|
25
|
+
const toText = async (response) => {
|
|
26
|
+
const body = await response.text();
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new ResponseError(response.status, response.statusText, body);
|
|
29
|
+
}
|
|
30
|
+
return body;
|
|
31
|
+
};
|
|
32
|
+
exports.toText = toText;
|
|
33
|
+
const toVoid = async (response) => {
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const body = await response.text();
|
|
36
|
+
throw new ResponseError(response.status, response.statusText, body);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
};
|
|
40
|
+
exports.toVoid = toVoid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (msToSleep: number) => Promise<void>;
|