@coorpacademy/app-review 0.9.6 → 0.10.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/es/actions/api/fetch-correction.d.ts +2 -1
- package/es/actions/api/fetch-rank.d.ts +2 -1
- package/es/actions/api/fetch-skill.d.ts +2 -1
- package/es/actions/api/fetch-skills.d.ts +2 -1
- package/es/actions/api/fetch-slide.d.ts +2 -1
- package/es/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +2 -1
- package/es/actions/api/post-answer.d.ts +2 -1
- package/es/actions/api/post-progression.d.ts +2 -1
- 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/types/common.d.ts +10 -186
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/slides/index.d.ts +1 -1
- package/es/views/slides/map-api-slide-to-ui.d.ts +2 -1
- package/lib/actions/api/fetch-correction.d.ts +2 -1
- package/lib/actions/api/fetch-rank.d.ts +2 -1
- package/lib/actions/api/fetch-skill.d.ts +2 -1
- package/lib/actions/api/fetch-skills.d.ts +2 -1
- package/lib/actions/api/fetch-slide.d.ts +2 -1
- package/lib/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +2 -1
- package/lib/actions/api/post-answer.d.ts +2 -1
- package/lib/actions/api/post-progression.d.ts +2 -1
- 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/types/common.d.ts +10 -186
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/slides/index.d.ts +1 -1
- package/lib/views/slides/map-api-slide-to-ui.d.ts +2 -1
- package/package.json +4 -3
- package/es/services/fetch-correction.d.ts +0 -2
- package/es/services/fetch-correction.js +0 -14
- package/es/services/fetch-rank.d.ts +0 -2
- package/es/services/fetch-rank.js +0 -10
- package/es/services/fetch-skill.d.ts +0 -2
- package/es/services/fetch-skill.js +0 -11
- package/es/services/fetch-skills.d.ts +0 -2
- package/es/services/fetch-skills.js +0 -10
- package/es/services/fetch-slide.d.ts +0 -2
- package/es/services/fetch-slide.js +0 -10
- package/es/services/fetch-slides-to-review-by-skill-ref.d.ts +0 -2
- package/es/services/fetch-slides-to-review-by-skill-ref.js +0 -10
- package/es/services/index.d.ts +0 -2
- package/es/services/index.js +0 -18
- package/es/services/post-answer.d.ts +0 -2
- package/es/services/post-answer.js +0 -20
- package/es/services/post-progression.d.ts +0 -2
- package/es/services/post-progression.js +0 -21
- package/es/services/tools/fetch-responses.d.ts +0 -7
- package/es/services/tools/fetch-responses.js +0 -33
- package/es/services/tools/sleep.d.ts +0 -1
- package/es/services/tools/sleep.js +0 -3
- package/lib/services/fetch-correction.d.ts +0 -2
- package/lib/services/fetch-correction.js +0 -21
- package/lib/services/fetch-rank.d.ts +0 -2
- package/lib/services/fetch-rank.js +0 -17
- package/lib/services/fetch-skill.d.ts +0 -2
- package/lib/services/fetch-skill.js +0 -18
- package/lib/services/fetch-skills.d.ts +0 -2
- package/lib/services/fetch-skills.js +0 -17
- package/lib/services/fetch-slide.d.ts +0 -2
- package/lib/services/fetch-slide.js +0 -17
- package/lib/services/fetch-slides-to-review-by-skill-ref.d.ts +0 -2
- package/lib/services/fetch-slides-to-review-by-skill-ref.js +0 -17
- package/lib/services/index.d.ts +0 -2
- package/lib/services/index.js +0 -22
- package/lib/services/post-answer.d.ts +0 -2
- package/lib/services/post-answer.js +0 -27
- package/lib/services/post-progression.d.ts +0 -2
- package/lib/services/post-progression.js +0 -28
- package/lib/services/tools/fetch-responses.d.ts +0 -7
- package/lib/services/tools/fetch-responses.js +0 -40
- package/lib/services/tools/sleep.d.ts +0 -1
- package/lib/services/tools/sleep.js +0 -7
package/lib/types/common.d.ts
CHANGED
|
@@ -1,163 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { Services } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
|
+
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
3
|
+
[P in K]-?: T[P];
|
|
4
|
+
};
|
|
2
5
|
export interface Translate {
|
|
3
6
|
(key: string, data?: Record<string, string>): string;
|
|
4
7
|
}
|
|
5
|
-
export declare type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
name?: string;
|
|
10
|
-
type?: 'text' | 'select';
|
|
11
|
-
label?: string;
|
|
12
|
-
items: {
|
|
13
|
-
text: string;
|
|
14
|
-
value: string;
|
|
15
|
-
_id: string;
|
|
16
|
-
}[];
|
|
17
|
-
media?: unknown;
|
|
18
|
-
};
|
|
19
|
-
declare type BaseContent = {
|
|
20
|
-
media?: unknown;
|
|
21
|
-
choices: ChoiceFromAPI[];
|
|
22
|
-
answers: string[][];
|
|
23
|
-
};
|
|
24
|
-
declare type BaseQuestion = {
|
|
25
|
-
header?: string;
|
|
26
|
-
content: BaseContent;
|
|
27
|
-
explanation?: string;
|
|
28
|
-
};
|
|
29
|
-
export declare type QcmQuestion = BaseQuestion & {
|
|
30
|
-
type: 'qcm';
|
|
31
|
-
};
|
|
32
|
-
export declare type QcmGraphicQuestion = BaseQuestion & {
|
|
33
|
-
type: 'qcmGraphic';
|
|
34
|
-
};
|
|
35
|
-
export declare type QcmDragQuestion = BaseQuestion & {
|
|
36
|
-
type: 'qcmDrag';
|
|
37
|
-
};
|
|
38
|
-
export declare type BasicQuestion = Omit<BaseQuestion, 'content'> & {
|
|
39
|
-
type: 'basic';
|
|
40
|
-
content: {
|
|
41
|
-
media?: unknown;
|
|
42
|
-
label?: string;
|
|
43
|
-
placeholder?: string;
|
|
44
|
-
id: string;
|
|
45
|
-
answers: string[][];
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export declare type SliderQuestion = Omit<BaseQuestion, 'content'> & {
|
|
49
|
-
content: {
|
|
50
|
-
media?: unknown;
|
|
51
|
-
unitLabel: string;
|
|
52
|
-
min: number;
|
|
53
|
-
max: number;
|
|
54
|
-
step?: number;
|
|
55
|
-
answers: string[][];
|
|
56
|
-
};
|
|
57
|
-
type: 'slider';
|
|
58
|
-
};
|
|
59
|
-
export declare type TemplateQuestion = Omit<BaseQuestion, 'content'> & {
|
|
60
|
-
content: BaseContent & {
|
|
61
|
-
template: string;
|
|
62
|
-
answers: string[][];
|
|
63
|
-
};
|
|
64
|
-
type: 'template';
|
|
65
|
-
};
|
|
66
|
-
export declare type Question = QcmQuestion | QcmGraphicQuestion | QcmDragQuestion | BasicQuestion | SliderQuestion | TemplateQuestion;
|
|
67
|
-
export declare type SlideFromAPI = {
|
|
68
|
-
_id: string;
|
|
69
|
-
question: Question;
|
|
70
|
-
klf: string;
|
|
71
|
-
universalRef: string;
|
|
72
|
-
tips?: string;
|
|
73
|
-
clue?: string;
|
|
74
|
-
hasClue?: boolean;
|
|
75
|
-
parentContentTitle: {
|
|
76
|
-
title: string;
|
|
77
|
-
type: 'chapter' | 'course';
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
export declare type SlideIdFromAPI = {
|
|
81
|
-
slideId: string;
|
|
82
|
-
};
|
|
83
|
-
export declare type Rank = {
|
|
84
|
-
rank: number;
|
|
85
|
-
};
|
|
86
|
-
export declare type ProgressionAnswerItem = {
|
|
87
|
-
isCorrect: boolean;
|
|
88
|
-
slideRef: string;
|
|
89
|
-
answer: string[];
|
|
90
|
-
};
|
|
91
|
-
export declare type SlideContent = {
|
|
92
|
-
type: 'slide';
|
|
93
|
-
ref: string;
|
|
94
|
-
};
|
|
95
|
-
export declare type SuccessNodeContent = {
|
|
96
|
-
type: 'success';
|
|
97
|
-
ref: 'successExitNode';
|
|
98
|
-
};
|
|
99
|
-
export declare type ProgressionState = {
|
|
100
|
-
allAnswers: ProgressionAnswerItem[];
|
|
101
|
-
content?: SlideContent;
|
|
102
|
-
isCorrect: boolean;
|
|
103
|
-
lives?: number;
|
|
104
|
-
livesDisabled?: boolean;
|
|
105
|
-
hasViewedAResourceAtThisStep?: boolean;
|
|
106
|
-
nextContent: SlideContent | SuccessNodeContent;
|
|
107
|
-
pendingSlides: string[];
|
|
108
|
-
remainingLifeRequests?: number;
|
|
109
|
-
requestedClues?: [];
|
|
110
|
-
variables?: {};
|
|
111
|
-
viewedResources?: [];
|
|
112
|
-
slides: string[];
|
|
113
|
-
step: {
|
|
114
|
-
current: number;
|
|
8
|
+
export declare type ViewName = 'skills' | 'onboarding' | 'slides' | 'loader';
|
|
9
|
+
export declare type Skin = {
|
|
10
|
+
common: {
|
|
11
|
+
primary: string;
|
|
115
12
|
};
|
|
116
|
-
stars: number;
|
|
117
|
-
};
|
|
118
|
-
export declare type ReviewContent = {
|
|
119
|
-
type: 'skill';
|
|
120
|
-
ref: string;
|
|
121
|
-
};
|
|
122
|
-
export declare type ReviewEngine = {
|
|
123
|
-
ref: 'review';
|
|
124
|
-
};
|
|
125
|
-
export declare type ProgressionFromAPI = {
|
|
126
|
-
_id: string;
|
|
127
|
-
content: ReviewContent;
|
|
128
|
-
engine: ReviewEngine;
|
|
129
|
-
state: ProgressionState;
|
|
130
|
-
};
|
|
131
|
-
export declare type CorrectedChoice = {
|
|
132
|
-
answer: string;
|
|
133
|
-
isCorrect: boolean;
|
|
134
|
-
};
|
|
135
|
-
export declare type CorrectionFromAPI = {
|
|
136
|
-
correctAnswer: string[];
|
|
137
|
-
corrections: CorrectedChoice[];
|
|
138
|
-
};
|
|
139
|
-
export declare type SkillToReview = {
|
|
140
|
-
skillRef: string;
|
|
141
|
-
slidesToReview: number;
|
|
142
|
-
custom: boolean;
|
|
143
|
-
name: string;
|
|
144
|
-
};
|
|
145
|
-
export declare type Skill = {
|
|
146
|
-
name: string;
|
|
147
|
-
ref: string;
|
|
148
|
-
};
|
|
149
|
-
export declare type Services = {
|
|
150
|
-
fetchSkill(skillRef: string, token: string): Promise<Skill>;
|
|
151
|
-
fetchSkills(token: string): Promise<SkillToReview[]>;
|
|
152
|
-
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
153
|
-
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
154
|
-
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
155
|
-
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
156
|
-
fetchRank(token: string): Promise<Rank>;
|
|
157
|
-
fetchSlidesToReviewBySkillRef(token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
|
|
158
|
-
};
|
|
159
|
-
export declare type Options = {
|
|
160
|
-
services: Services;
|
|
161
13
|
};
|
|
162
14
|
export declare type ConnectedOptions = {
|
|
163
15
|
translate: Translate;
|
|
@@ -174,34 +26,6 @@ export declare type ThunkOptions = {
|
|
|
174
26
|
callbackOnViewChanged?: AppOptions['callbackOnViewChanged'];
|
|
175
27
|
services: Services;
|
|
176
28
|
};
|
|
177
|
-
export declare type
|
|
178
|
-
|
|
179
|
-
iat: number;
|
|
180
|
-
grants: unknown;
|
|
181
|
-
iss: string;
|
|
182
|
-
user: string;
|
|
183
|
-
usage: string;
|
|
184
|
-
host: string;
|
|
185
|
-
};
|
|
186
|
-
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
187
|
-
[P in K]-?: T[P];
|
|
188
|
-
};
|
|
189
|
-
export declare type Skin = {
|
|
190
|
-
common: {
|
|
191
|
-
primary: string;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
export declare type Config = {
|
|
195
|
-
version: string;
|
|
196
|
-
livesDisabled: boolean;
|
|
197
|
-
lives: number;
|
|
198
|
-
maxTypos: number;
|
|
199
|
-
slidesToComplete: number;
|
|
200
|
-
shuffleChoices?: boolean;
|
|
201
|
-
answerBoundaryLimit: number;
|
|
202
|
-
starsPerAskingClue: number;
|
|
203
|
-
starsPerCorrectAnswer: number;
|
|
204
|
-
starsPerResourceViewed: number;
|
|
205
|
-
remainingLifeRequests: number;
|
|
29
|
+
export declare type Options = {
|
|
30
|
+
services: Services;
|
|
206
31
|
};
|
|
207
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ReviewSkillsProps } from '@coorpacademy/components/es/template/app-review/skills/prop-types';
|
|
2
|
-
import { StoreState } from '../../reducers';
|
|
3
2
|
import type { ConnectedOptions } from '../../types/common';
|
|
3
|
+
import { StoreState } from '../../reducers';
|
|
4
4
|
export declare const mapStateToSkillsProps: (state: StoreState, options: ConnectedOptions) => ReviewSkillsProps;
|
|
@@ -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
|
|
4
|
+
import { 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: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
+
import { Question, SlideFromAPI } from '@coorpacademy/review-services/es/types/services-types';
|
|
2
3
|
import { AnswerUI } from '../../types/slides';
|
|
3
|
-
import {
|
|
4
|
+
import { Translate } from '../../types/common';
|
|
4
5
|
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
5
6
|
export declare const mapApiSlideToUi: (dispatch: Dispatch, translate: Translate) => (slide: SlideFromAPI, answers: string[]) => {
|
|
6
7
|
questionText: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
"main": "lib/index.js",
|
|
36
36
|
"module": "es/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@coorpacademy/components": "10.29.5",
|
|
38
|
+
"@coorpacademy/components": "10.29.5-alpha.0",
|
|
39
39
|
"@coorpacademy/progression-engine": "11.5.2",
|
|
40
40
|
"@coorpacademy/redux-task": "1.1.6",
|
|
41
|
+
"@coorpacademy/review-services": "1.0.1",
|
|
41
42
|
"@coorpacademy/translate": "6.2.0",
|
|
42
43
|
"cross-fetch": "^3.1.5",
|
|
43
44
|
"jwt-decode": "^3.1.2",
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"webpack-cli": "^4.10.0",
|
|
73
74
|
"webpack-dev-server": "^4.11.1"
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "c87618fe91e37b1321eecaadf7657eafc2d9bb0e"
|
|
76
77
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const fetchCorrection = async (slideRef, token, progressionId, answer) => {
|
|
5
|
-
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers/${slideRef}`, {
|
|
7
|
-
method: 'post',
|
|
8
|
-
headers: { authorization: token },
|
|
9
|
-
body: JSON.stringify({
|
|
10
|
-
answer
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
return toJSON(response);
|
|
14
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const fetchRank = async (token) => {
|
|
5
|
-
const { user: userId, host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v1/leaderboard/rank/${userId}?group=ALL`, {
|
|
7
|
-
headers: { authorization: token }
|
|
8
|
-
});
|
|
9
|
-
return toJSON(response);
|
|
10
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const fetchSkill = async (skillRef, token) => {
|
|
5
|
-
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/skills?conditions={"ref":"${skillRef}"}`, {
|
|
7
|
-
headers: { authorization: token }
|
|
8
|
-
});
|
|
9
|
-
const skills = await toJSON(response);
|
|
10
|
-
return skills[0];
|
|
11
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const fetchSkills = async (token) => {
|
|
5
|
-
const { user: userId, host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/skills/review/user/${userId}`, {
|
|
7
|
-
headers: { authorization: token }
|
|
8
|
-
});
|
|
9
|
-
return toJSON(response);
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const fetchSlide = async (slideRef, token) => {
|
|
5
|
-
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v1/slides/${slideRef}/parentContentTitle`, {
|
|
7
|
-
headers: { authorization: token }
|
|
8
|
-
});
|
|
9
|
-
return toJSON(response);
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const fetchSlidesToReviewBySkillRef = async (token, skillRef) => {
|
|
5
|
-
const { user: userId, host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/skills/${skillRef}/review/user/${userId}/slide`, {
|
|
7
|
-
headers: { authorization: token }
|
|
8
|
-
});
|
|
9
|
-
return toJSON(response);
|
|
10
|
-
};
|
package/es/services/index.d.ts
DELETED
package/es/services/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { fetchCorrection } from './fetch-correction';
|
|
2
|
-
import { fetchRank } from './fetch-rank';
|
|
3
|
-
import { fetchSkills } from './fetch-skills';
|
|
4
|
-
import { fetchSlide } from './fetch-slide';
|
|
5
|
-
import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
|
|
6
|
-
import { postAnswer } from './post-answer';
|
|
7
|
-
import { postProgression } from './post-progression';
|
|
8
|
-
import { fetchSkill } from './fetch-skill';
|
|
9
|
-
export const getServices = () => ({
|
|
10
|
-
fetchCorrection,
|
|
11
|
-
fetchRank,
|
|
12
|
-
fetchSkill,
|
|
13
|
-
fetchSkills,
|
|
14
|
-
fetchSlide,
|
|
15
|
-
fetchSlidesToReviewBySkillRef,
|
|
16
|
-
postAnswer,
|
|
17
|
-
postProgression
|
|
18
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const postAnswer = async (progression, token, answer) => {
|
|
5
|
-
const progressionId = progression._id;
|
|
6
|
-
const slideRef = progression.state.nextContent.ref;
|
|
7
|
-
const { host } = decode(token);
|
|
8
|
-
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers`, {
|
|
9
|
-
method: 'post',
|
|
10
|
-
headers: { authorization: token, 'content-type': 'application/json' },
|
|
11
|
-
body: JSON.stringify({
|
|
12
|
-
content: {
|
|
13
|
-
ref: slideRef,
|
|
14
|
-
type: 'slide'
|
|
15
|
-
},
|
|
16
|
-
answer
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
return toJSON(response);
|
|
20
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './tools/fetch-responses';
|
|
4
|
-
export const postProgression = async (skillRef, token) => {
|
|
5
|
-
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/progressions`, {
|
|
7
|
-
method: 'post',
|
|
8
|
-
headers: { authorization: token, 'content-type': 'application/json' },
|
|
9
|
-
body: JSON.stringify({
|
|
10
|
-
content: {
|
|
11
|
-
ref: skillRef,
|
|
12
|
-
type: 'skill'
|
|
13
|
-
},
|
|
14
|
-
engine: {
|
|
15
|
-
ref: 'review',
|
|
16
|
-
version: '1'
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
return toJSON(response);
|
|
21
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
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>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export class ResponseError extends Error {
|
|
2
|
-
constructor(statusCode, statusText, body = '') {
|
|
3
|
-
super(`${statusText} ${body}`.trim());
|
|
4
|
-
this.name = 'ResponseError';
|
|
5
|
-
this.statusCode = statusCode;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export const toJSON = async (response) => {
|
|
9
|
-
if (!response.ok) {
|
|
10
|
-
const body = await response.text();
|
|
11
|
-
throw new ResponseError(response.status, response.statusText, body);
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
return await response.json();
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
throw new ResponseError(response.status, response.statusText);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
export const toText = async (response) => {
|
|
21
|
-
const body = await response.text();
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
throw new ResponseError(response.status, response.statusText, body);
|
|
24
|
-
}
|
|
25
|
-
return body;
|
|
26
|
-
};
|
|
27
|
-
export const toVoid = async (response) => {
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
const body = await response.text();
|
|
30
|
-
throw new ResponseError(response.status, response.statusText, body);
|
|
31
|
-
}
|
|
32
|
-
return;
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const sleep: (msToSleep: number) => Promise<void>;
|
|
@@ -1,21 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
package/lib/services/index.d.ts
DELETED