@coorpacademy/app-review 0.0.14-alpha.6.6 → 0.0.14
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/index.d.ts +0 -6
- package/es/actions/index.d.ts.map +1 -1
- package/es/actions/index.js +0 -2
- package/es/actions/navigation.d.ts +4 -11
- package/es/actions/navigation.d.ts.map +1 -1
- package/es/actions/navigation.js +0 -5
- package/es/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +1 -0
- package/es/components/__tmp-backup-vues-mobile/revision-home.stories.js +14 -14
- package/es/configure-store.d.ts +3 -11
- package/es/configure-store.d.ts.map +1 -1
- package/es/configure-store.js +2 -4
- package/es/index.d.ts +3 -9
- package/es/index.d.ts.map +1 -1
- package/es/index.js +4 -4
- package/es/reducers/index.d.ts +0 -2
- package/es/reducers/index.d.ts.map +1 -1
- package/es/reducers/index.js +1 -5
- package/es/reducers/navigation.d.ts +2 -2
- package/es/reducers/navigation.d.ts.map +1 -1
- package/es/reducers/navigation.js +0 -3
- package/lib/actions/index.d.ts +0 -6
- package/lib/actions/index.d.ts.map +1 -1
- package/lib/actions/index.js +0 -2
- package/lib/actions/navigation.d.ts +4 -11
- package/lib/actions/navigation.d.ts.map +1 -1
- package/lib/actions/navigation.js +1 -7
- package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +1 -0
- package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.js +16 -14
- package/lib/configure-store.d.ts +3 -11
- package/lib/configure-store.d.ts.map +1 -1
- package/lib/configure-store.js +2 -4
- package/lib/index.d.ts +3 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/reducers/index.d.ts +0 -2
- package/lib/reducers/index.d.ts.map +1 -1
- package/lib/reducers/index.js +1 -5
- package/lib/reducers/navigation.d.ts +2 -2
- package/lib/reducers/navigation.d.ts.map +1 -1
- package/lib/reducers/navigation.js +0 -3
- package/package.json +11 -13
- package/readme.md +0 -24
- package/src/actions/index.ts +0 -8
- package/src/actions/navigation.ts +4 -16
- package/src/components/__tmp-backup-vues-mobile/revision-home.stories.tsx +14 -14
- package/src/configure-store.ts +2 -15
- package/src/index.tsx +3 -12
- package/src/reducers/index.ts +1 -6
- package/src/reducers/navigation.ts +3 -11
- package/es/actions/courses.d.ts +0 -7
- package/es/actions/courses.d.ts.map +0 -1
- package/es/actions/courses.js +0 -5
- package/es/actions/token.d.ts +0 -7
- package/es/actions/token.d.ts.map +0 -1
- package/es/actions/token.js +0 -5
- package/es/middlewares/on-start-app.d.ts +0 -7
- package/es/middlewares/on-start-app.d.ts.map +0 -1
- package/es/middlewares/on-start-app.js +0 -17
- package/es/reducers/courses.d.ts +0 -6
- package/es/reducers/courses.d.ts.map +0 -1
- package/es/reducers/courses.js +0 -14
- package/es/reducers/token.d.ts +0 -7
- package/es/reducers/token.d.ts.map +0 -1
- package/es/reducers/token.js +0 -16
- package/es/services/fetch-demo.d.ts +0 -12
- package/es/services/fetch-demo.d.ts.map +0 -1
- package/es/services/fetch-demo.js +0 -26
- package/es/services/fetch-demo.test.d.ts +0 -2
- package/es/services/fetch-demo.test.d.ts.map +0 -1
- package/es/services/fetch-demo.test.js +0 -12
- package/es/services/fetch-responses.d.ts +0 -20
- package/es/services/fetch-responses.d.ts.map +0 -1
- package/es/services/fetch-responses.js +0 -33
- package/es/services/fetch.mocks.d.ts +0 -10
- package/es/services/fetch.mocks.d.ts.map +0 -1
- package/es/services/fetch.mocks.js +0 -12
- package/lib/actions/courses.d.ts +0 -7
- package/lib/actions/courses.d.ts.map +0 -1
- package/lib/actions/courses.js +0 -9
- package/lib/actions/token.d.ts +0 -7
- package/lib/actions/token.d.ts.map +0 -1
- package/lib/actions/token.js +0 -9
- package/lib/middlewares/on-start-app.d.ts +0 -7
- package/lib/middlewares/on-start-app.d.ts.map +0 -1
- package/lib/middlewares/on-start-app.js +0 -22
- package/lib/reducers/courses.d.ts +0 -6
- package/lib/reducers/courses.d.ts.map +0 -1
- package/lib/reducers/courses.js +0 -27
- package/lib/reducers/token.d.ts +0 -7
- package/lib/reducers/token.d.ts.map +0 -1
- package/lib/reducers/token.js +0 -21
- package/lib/services/fetch-demo.d.ts +0 -12
- package/lib/services/fetch-demo.d.ts.map +0 -1
- package/lib/services/fetch-demo.js +0 -76
- package/lib/services/fetch-demo.test.d.ts +0 -2
- package/lib/services/fetch-demo.test.d.ts.map +0 -1
- package/lib/services/fetch-demo.test.js +0 -59
- package/lib/services/fetch-responses.d.ts +0 -20
- package/lib/services/fetch-responses.d.ts.map +0 -1
- package/lib/services/fetch-responses.js +0 -118
- package/lib/services/fetch.mocks.d.ts +0 -10
- package/lib/services/fetch.mocks.d.ts.map +0 -1
- package/lib/services/fetch.mocks.js +0 -31
- package/src/actions/courses.ts +0 -11
- package/src/actions/token.ts +0 -11
- package/src/middlewares/on-start-app.ts +0 -30
- package/src/reducers/courses.ts +0 -22
- package/src/reducers/token.ts +0 -26
- package/src/services/fetch-demo.test.ts +0 -16
- package/src/services/fetch-demo.ts +0 -55
- package/src/services/fetch-responses.ts +0 -53
- package/src/services/fetch.mocks.ts +0 -26
package/readme.md
CHANGED
|
@@ -6,11 +6,6 @@
|
|
|
6
6
|
npm start
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
requirements:
|
|
10
|
-
|
|
11
|
-
- [mooc](https://github.com/CoorpAcademy/coorpacademy) installed and running to expose a local API.
|
|
12
|
-
- duplicated `.env.sample` to `.env` with a local token to access the mooc API.
|
|
13
|
-
|
|
14
9
|
## generate /static
|
|
15
10
|
|
|
16
11
|
```sh
|
|
@@ -19,18 +14,6 @@ npm run static
|
|
|
19
14
|
|
|
20
15
|
(This script is generated by lerna to publish the static web app)
|
|
21
16
|
|
|
22
|
-
## unit tests
|
|
23
|
-
|
|
24
|
-
```sh
|
|
25
|
-
npm run test:unit
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
or
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
npx ava --watch
|
|
32
|
-
```
|
|
33
|
-
|
|
34
17
|
## dependencies notes
|
|
35
18
|
|
|
36
19
|
`react-native` must be the same version on this package and the rootApp
|
|
@@ -42,10 +25,3 @@ npx ava --watch
|
|
|
42
25
|
### tmp notes
|
|
43
26
|
|
|
44
27
|
export: <https://stackoverflow.com/a/70020984/959219>
|
|
45
|
-
|
|
46
|
-
css modules:
|
|
47
|
-
|
|
48
|
-
- <https://github.com/evanw/esbuild/issues/20>
|
|
49
|
-
- <https://github.com/indooorsman/esbuild-css-modules-plugin/issues/35>
|
|
50
|
-
- <https://github.com/princed/postcss-modules-values-replace>
|
|
51
|
-
- <https://github.com/CoorpAcademy/coorpacademy-lambda/blob/master/teams/postcss.config.js#L4>
|
package/src/actions/index.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import {ReceivedCourse} from './courses';
|
|
2
|
-
import {NavigateBack, NavigateTo, StartApp} from './navigation';
|
|
3
|
-
import {StoreToken} from './token';
|
|
4
|
-
|
|
5
|
-
export * from './courses';
|
|
6
1
|
export * from './navigation';
|
|
7
|
-
export * from './token';
|
|
8
|
-
|
|
9
|
-
export type Action = StartApp | StoreToken | NavigateBack | NavigateTo | ReceivedCourse;
|
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
import {ActionCreator} from 'redux';
|
|
2
|
-
import {AppOptions} from '..';
|
|
3
2
|
|
|
4
3
|
export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
|
|
5
4
|
export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
|
|
6
|
-
export const START_APP = '@@navigation/START_APP';
|
|
7
5
|
|
|
8
|
-
export type
|
|
6
|
+
export type $NAVIGATE_TO = {
|
|
9
7
|
type: '@@navigation/NAVIGATE_TO';
|
|
10
8
|
payload: string;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
|
-
export type
|
|
11
|
+
export type $NAVIGATE_BACK = {
|
|
14
12
|
type: '@@navigation/NAVIGATE_BACK';
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
export
|
|
18
|
-
type: '@@navigation/START_APP';
|
|
19
|
-
payload: AppOptions;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const navigateTo: ActionCreator<NavigateTo> = (newPath: string) => ({
|
|
15
|
+
export const navigateTo: ActionCreator<$NAVIGATE_TO> = (newPath: string) => ({
|
|
23
16
|
type: NAVIGATE_TO,
|
|
24
17
|
payload: newPath
|
|
25
18
|
});
|
|
26
19
|
|
|
27
|
-
export const navigateBack: ActionCreator
|
|
20
|
+
export const navigateBack: ActionCreator<$NAVIGATE_BACK> = () => ({
|
|
28
21
|
type: NAVIGATE_BACK
|
|
29
22
|
});
|
|
30
|
-
|
|
31
|
-
export const startApp = (options: AppOptions): StartApp => ({
|
|
32
|
-
type: START_APP,
|
|
33
|
-
payload: options
|
|
34
|
-
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {storiesOf} from '@storybook/react-native';
|
|
3
|
+
import RevisionHome from './revision-home';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const emptySkills: [] = [];
|
|
6
|
+
const skillsToRevise: {title: string; info: string}[] = [
|
|
7
|
+
{title: 'Negotiation and powers of persuasion', info: '75 questions to revise'},
|
|
8
|
+
{title: 'Negotiation and powers of persuasion', info: '75 questions to revise'},
|
|
9
|
+
{title: 'Negotiation and powers of persuasion', info: '75 questions to revise'},
|
|
10
|
+
{title: 'Negotiation and powers of persuasion', info: '75 questions to revise'},
|
|
11
|
+
{title: 'Creativity and innovation', info: '75 questions to revise'}
|
|
12
|
+
];
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
storiesOf('RevisionHome', module)
|
|
15
|
+
.add('No skills', () => <RevisionHome skillsToRevise={emptySkills} />)
|
|
16
|
+
.add('Few skills', () => <RevisionHome skillsToRevise={skillsToRevise} />);
|
package/src/configure-store.ts
CHANGED
|
@@ -4,15 +4,9 @@ import {composeWithDevTools} from 'redux-devtools-extension';
|
|
|
4
4
|
|
|
5
5
|
import rootReducer from './reducers';
|
|
6
6
|
|
|
7
|
-
import {State as NavigationState} from './reducers/navigation';
|
|
8
|
-
import {State as TokenState} from './reducers/token';
|
|
9
|
-
import onStartApp from './middlewares/on-start-app';
|
|
10
|
-
|
|
11
7
|
const preloadedState = undefined;
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export default function configureStore() {
|
|
9
|
+
export default function configureStore(services) {
|
|
16
10
|
const _compose =
|
|
17
11
|
process.env.NODE_ENV !== 'production'
|
|
18
12
|
? composeWithDevTools({
|
|
@@ -22,15 +16,8 @@ export default function configureStore() {
|
|
|
22
16
|
})
|
|
23
17
|
: compose;
|
|
24
18
|
|
|
25
|
-
const enhancer = _compose(applyMiddleware(thunk
|
|
19
|
+
const enhancer = _compose(applyMiddleware(thunk));
|
|
26
20
|
const store = createStore(rootReducer, preloadedState, enhancer);
|
|
27
21
|
|
|
28
22
|
return store;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
|
-
// -----------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
export type StoreState = {
|
|
34
|
-
navigation: NavigationState;
|
|
35
|
-
token: TokenState;
|
|
36
|
-
};
|
package/src/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {connect, Provider} from 'react-redux';
|
|
|
3
3
|
import AppReviewRootView from '@coorpacademy/components/es/template/app-review/root-view/root-view';
|
|
4
4
|
|
|
5
5
|
import configureStore from './configure-store';
|
|
6
|
-
import {navigateTo, navigateBack
|
|
6
|
+
import {navigateTo, navigateBack} from './actions/navigation';
|
|
7
7
|
import {getCurrentViewName} from './reducers/navigation';
|
|
8
8
|
|
|
9
9
|
// -----------------------------------------------------------------------------
|
|
@@ -17,12 +17,11 @@ const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewRootView);
|
|
|
17
17
|
|
|
18
18
|
// -----------------------------------------------------------------------------
|
|
19
19
|
|
|
20
|
-
const AppRevision = ({
|
|
20
|
+
const AppRevision = ({services}) => {
|
|
21
21
|
const [store, setStore] = useState(null);
|
|
22
22
|
|
|
23
23
|
useEffect(() => {
|
|
24
|
-
const store = configureStore();
|
|
25
|
-
store.dispatch(startApp(options));
|
|
24
|
+
const store = configureStore(services);
|
|
26
25
|
setStore(store);
|
|
27
26
|
}, []);
|
|
28
27
|
|
|
@@ -37,12 +36,4 @@ const AppRevision = ({options}: Props) => {
|
|
|
37
36
|
|
|
38
37
|
// -----------------------------------------------------------------------------
|
|
39
38
|
|
|
40
|
-
type Props = {options: AppOptions};
|
|
41
|
-
|
|
42
|
-
export type AppOptions = {
|
|
43
|
-
token: string;
|
|
44
|
-
theme?: any;
|
|
45
|
-
translations?: any;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
39
|
export default AppRevision;
|
package/src/reducers/index.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import {combineReducers} from 'redux';
|
|
2
|
-
|
|
3
|
-
import courses from './courses';
|
|
4
2
|
import navigation from './navigation';
|
|
5
|
-
import token from './token';
|
|
6
3
|
|
|
7
4
|
const rootReducer = combineReducers({
|
|
8
|
-
|
|
9
|
-
navigation,
|
|
10
|
-
token
|
|
5
|
+
navigation
|
|
11
6
|
});
|
|
12
7
|
|
|
13
8
|
export default rootReducer;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import {NAVIGATE_BACK, NAVIGATE_TO} from '../actions/navigation';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
2
|
+
import type {$NAVIGATE_TO, $NAVIGATE_BACK} from '../actions/navigation';
|
|
5
3
|
|
|
6
4
|
export type State = Array<string>;
|
|
7
|
-
export const initialState: State = ['home'];
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
export const initialState: State = ['home'];
|
|
10
7
|
|
|
11
|
-
const reducer = (state: State = initialState, action:
|
|
8
|
+
const reducer = (state: State = initialState, action: $NAVIGATE_TO | $NAVIGATE_BACK): State => {
|
|
12
9
|
switch (action.type) {
|
|
13
10
|
case NAVIGATE_TO: {
|
|
14
11
|
return [...state, action.payload];
|
|
@@ -23,10 +20,5 @@ const reducer = (state: State = initialState, action: NavigateTo | NavigateBack)
|
|
|
23
20
|
}
|
|
24
21
|
};
|
|
25
22
|
|
|
26
|
-
// -----------------------------------------------------------------------------
|
|
27
|
-
|
|
28
23
|
export const getCurrentViewName = appState => appState.navigation[appState.navigation.length - 1];
|
|
29
|
-
|
|
30
|
-
// -----------------------------------------------------------------------------
|
|
31
|
-
|
|
32
24
|
export default reducer;
|
package/es/actions/courses.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const RECEIVED_COURSE = "@@api/RECEIVED_COURSE";
|
|
2
|
-
export declare type ReceivedCourse = {
|
|
3
|
-
type: '@@api/RECEIVED_COURSE';
|
|
4
|
-
payload: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const receivedCourse: (course: any) => ReceivedCourse;
|
|
7
|
-
//# sourceMappingURL=courses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/actions/courses.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,cAG3C,CAAC"}
|
package/es/actions/courses.js
DELETED
package/es/actions/token.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/actions/token.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AAEjD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,UAGzC,CAAC"}
|
package/es/actions/token.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Middleware } from 'redux';
|
|
2
|
-
import { Dispatch } from 'redux';
|
|
3
|
-
import { Action } from '../actions';
|
|
4
|
-
import { StoreState } from '../configure-store';
|
|
5
|
-
declare const onStartApp: Middleware<{}, StoreState, Dispatch<Action>>;
|
|
6
|
-
export default onStartApp;
|
|
7
|
-
//# sourceMappingURL=on-start-app.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"on-start-app.d.ts","sourceRoot":"","sources":["../../src/middlewares/on-start-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,MAAM,EAAwC,MAAM,YAAY,CAAC;AACzE,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG9C,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAmB5D,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { receivedCourse, START_APP, storeToken } from '../actions';
|
|
2
|
-
import fetchCourse from '../services/fetch-demo';
|
|
3
|
-
const onStartApp = ({ dispatch }) => next => (action) => {
|
|
4
|
-
if (action.type === START_APP) {
|
|
5
|
-
const { token } = action.payload;
|
|
6
|
-
dispatch(storeToken(token));
|
|
7
|
-
// --------------
|
|
8
|
-
// demo service
|
|
9
|
-
const language = 'fr';
|
|
10
|
-
const universalRef = 'dis_xxx15';
|
|
11
|
-
fetchCourse(token, language, universalRef).then(course => {
|
|
12
|
-
dispatch(receivedCourse(course));
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return next(action);
|
|
16
|
-
};
|
|
17
|
-
export default onStartApp;
|
package/es/reducers/courses.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ReceivedCourse } from '../actions';
|
|
2
|
-
export declare type State = Array<any>;
|
|
3
|
-
export declare const initialState: State;
|
|
4
|
-
declare const reducer: (state: State, action: ReceivedCourse) => State;
|
|
5
|
-
export default reducer;
|
|
6
|
-
//# sourceMappingURL=courses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/reducers/courses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAkB,MAAM,YAAY,CAAC;AAI3D,oBAAY,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,eAAO,MAAM,YAAY,EAAE,KAAU,CAAC;AAItC,QAAA,MAAM,OAAO,yBAAyC,cAAc,UAQnE,CAAC;AAIF,eAAe,OAAO,CAAC"}
|
package/es/reducers/courses.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { RECEIVED_COURSE } from '../actions';
|
|
2
|
-
export const initialState = [];
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
const reducer = (state = initialState, action) => {
|
|
5
|
-
switch (action.type) {
|
|
6
|
-
case RECEIVED_COURSE: {
|
|
7
|
-
return [...state, action.payload];
|
|
8
|
-
}
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
// -----------------------------------------------------------------------------
|
|
14
|
-
export default reducer;
|
package/es/reducers/token.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { StoreToken } from '../actions';
|
|
2
|
-
export declare type State = string;
|
|
3
|
-
export declare const initialState: State;
|
|
4
|
-
declare const reducer: (state: State, action: StoreToken) => State;
|
|
5
|
-
export declare const getToken: (appState: any) => any;
|
|
6
|
-
export default reducer;
|
|
7
|
-
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/reducers/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAc,MAAM,YAAY,CAAC;AAInD,oBAAY,KAAK,GAAG,MAAM,CAAC;AAC3B,eAAO,MAAM,YAAY,EAAE,KAAY,CAAC;AAIxC,QAAA,MAAM,OAAO,UAAW,KAAK,UAAyB,UAAU,KAAG,KAQlE,CAAC;AAIF,eAAO,MAAM,QAAQ,wBAA6B,CAAC;AAInD,eAAe,OAAO,CAAC"}
|
package/es/reducers/token.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { STORE_TOKEN } from '../actions';
|
|
2
|
-
export const initialState = null;
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
const reducer = (state = initialState, action) => {
|
|
5
|
-
switch (action.type) {
|
|
6
|
-
case STORE_TOKEN: {
|
|
7
|
-
return action.payload;
|
|
8
|
-
}
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
// -----------------------------------------------------------------------------
|
|
14
|
-
export const getToken = appState => appState.token;
|
|
15
|
-
// -----------------------------------------------------------------------------
|
|
16
|
-
export default reducer;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Fetch } from './fetch-responses';
|
|
2
|
-
declare const fetchCourse: (fetch: Fetch) => (token: any, language: any, universalRef: any) => Promise<Course>;
|
|
3
|
-
export declare type Course = {
|
|
4
|
-
title: any;
|
|
5
|
-
};
|
|
6
|
-
export declare type CatalogHits = {
|
|
7
|
-
hits: Course[];
|
|
8
|
-
};
|
|
9
|
-
export { fetchCourse };
|
|
10
|
-
declare const _default: (token: any, language: any, universalRef: any) => Promise<Course>;
|
|
11
|
-
export default _default;
|
|
12
|
-
//# sourceMappingURL=fetch-demo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-demo.d.ts","sourceRoot":"","sources":["../../src/services/fetch-demo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,EAAS,MAAM,mBAAmB,CAAC;AA4BhD,QAAA,MAAM,WAAW,UAAW,KAAK,uDAA4C,QAAQ,MAAM,CAc1F,CAAC;AAIF,oBAAY,MAAM,GAAG;IAAC,KAAK,MAAA;CAAC,CAAC;AAC7B,oBAAY,WAAW,GAAG;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC;AAI3C,OAAO,EAAC,WAAW,EAAC,CAAC;;AACrB,wBAAuC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './fetch-responses';
|
|
4
|
-
const buildUrlQueryParams = (params) => Object.keys(params)
|
|
5
|
-
.map(key => {
|
|
6
|
-
const value = params[key].toString();
|
|
7
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
8
|
-
})
|
|
9
|
-
.join('&');
|
|
10
|
-
// -----------------------------------------------------------------------------
|
|
11
|
-
const fetchCourse = (fetch) => async (token, language, universalRef) => {
|
|
12
|
-
const jwt = decode(token);
|
|
13
|
-
const query = {
|
|
14
|
-
type: 'course',
|
|
15
|
-
universalRef,
|
|
16
|
-
lang: language
|
|
17
|
-
};
|
|
18
|
-
const response = await fetch(`${jwt.host}/api/v2/contents?${buildUrlQueryParams(query)}`, {
|
|
19
|
-
headers: { authorization: token }
|
|
20
|
-
});
|
|
21
|
-
const { hits } = (await toJSON(response));
|
|
22
|
-
return hits?.[0];
|
|
23
|
-
};
|
|
24
|
-
// -----------------------------------------------------------------------------
|
|
25
|
-
export { fetchCourse };
|
|
26
|
-
export default fetchCourse(crossFetch);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-demo.test.d.ts","sourceRoot":"","sources":["../../src/services/fetch-demo.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import { fetchCourse as _fetchCourse } from './fetch-demo';
|
|
3
|
-
import { okJSONResponse } from './fetch.mocks';
|
|
4
|
-
test('should fetch a demo course', async (t) => {
|
|
5
|
-
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
6
|
-
const language = 'fr';
|
|
7
|
-
const universalRef = 'bar';
|
|
8
|
-
const result = { hits: [{ title: 'Digital IQ test' }] };
|
|
9
|
-
const fetchCourse = _fetchCourse(okJSONResponse(result));
|
|
10
|
-
const course = await fetchCourse(token, language, universalRef);
|
|
11
|
-
t.is(course.title, 'Digital IQ test');
|
|
12
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare type Response = {
|
|
2
|
-
ok: boolean;
|
|
3
|
-
status: number;
|
|
4
|
-
statusText: string;
|
|
5
|
-
json: () => Promise<unknown>;
|
|
6
|
-
text: () => Promise<string>;
|
|
7
|
-
};
|
|
8
|
-
export declare type Fetch = (url?: string, options?: {
|
|
9
|
-
headers: {
|
|
10
|
-
authorization: string;
|
|
11
|
-
};
|
|
12
|
-
}) => Promise<Response>;
|
|
13
|
-
export declare class ResponseError extends Error {
|
|
14
|
-
statusCode: number;
|
|
15
|
-
constructor(status: number, statusText: string, body?: string);
|
|
16
|
-
}
|
|
17
|
-
export declare const toJSON: (response: Response) => Promise<unknown>;
|
|
18
|
-
export declare const toText: (response: Response) => Promise<string>;
|
|
19
|
-
export declare const toVoid: (response: Response) => Promise<void>;
|
|
20
|
-
//# sourceMappingURL=fetch-responses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-responses.d.ts","sourceRoot":"","sources":["../../src/services/fetch-responses.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ,GAAG;IACrB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,oBAAY,KAAK,GAAG,CAClB,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAC,OAAO,EAAE;QAAC,aAAa,EAAE,MAAM,CAAA;KAAC,CAAA;CAAC,KACzC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,qBAAa,aAAc,SAAQ,KAAK;IAC/B,UAAU,EAAE,MAAM,CAAC;gBAEP,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,SAAK;CAKjE;AAED,eAAO,MAAM,MAAM,aAAoB,QAAQ,KAAG,QAAQ,OAAO,CAWhE,CAAC;AAEF,eAAO,MAAM,MAAM,aAAoB,QAAQ,KAAG,QAAQ,MAAM,CAQ/D,CAAC;AAEF,eAAO,MAAM,MAAM,aAAoB,QAAQ,KAAG,QAAQ,IAAI,CAM7D,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export class ResponseError extends Error {
|
|
2
|
-
constructor(status, statusText, body = '') {
|
|
3
|
-
super(`${statusText} ${body}`.trim());
|
|
4
|
-
this.name = 'ResponseError';
|
|
5
|
-
this.statusCode = status;
|
|
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,10 +0,0 @@
|
|
|
1
|
-
import { Response } from './fetch-responses';
|
|
2
|
-
export declare const toResponse: (status: number, statusText: string, body: string) => Promise<Response>;
|
|
3
|
-
declare type FetchFunction = () => Promise<Response>;
|
|
4
|
-
export declare const okJSONResponse: (body: unknown) => FetchFunction;
|
|
5
|
-
export declare const internalServerErrorJSONResponse: (body: unknown) => FetchFunction;
|
|
6
|
-
export declare const notFoundJSONResponse: (body: unknown) => FetchFunction;
|
|
7
|
-
export declare const okTextResponse: (body: string) => FetchFunction;
|
|
8
|
-
export declare const internalServerErrorTextResponse: (body: string) => FetchFunction;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=fetch.mocks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.mocks.d.ts","sourceRoot":"","sources":["../../src/services/fetch.mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,eAAO,MAAM,UAAU,WAAY,MAAM,cAAc,MAAM,QAAQ,MAAM,KAAG,QAAQ,QAAQ,CAO1F,CAAC;AAEL,aAAK,aAAa,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE7C,eAAO,MAAM,cAAc,SAAU,OAAO,KAAG,aACF,CAAC;AAE9C,eAAO,MAAM,+BAA+B,SAAU,OAAO,KAAG,aACF,CAAC;AAE/D,eAAO,MAAM,oBAAoB,SAAU,OAAO,KAAG,aACD,CAAC;AAErD,eAAO,MAAM,cAAc,SAAU,MAAM,KAAG,aAAkD,CAAC;AAEjG,eAAO,MAAM,+BAA+B,SAAU,MAAM,KAAG,aACjB,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const toResponse = (status, statusText, body) => Promise.resolve({
|
|
2
|
-
ok: status < 400,
|
|
3
|
-
status,
|
|
4
|
-
statusText,
|
|
5
|
-
json: () => Promise.resolve(body).then(JSON.parse),
|
|
6
|
-
text: () => Promise.resolve(body)
|
|
7
|
-
});
|
|
8
|
-
export const okJSONResponse = (body) => () => toResponse(200, 'OK', JSON.stringify(body));
|
|
9
|
-
export const internalServerErrorJSONResponse = (body) => () => toResponse(500, 'InternalServerError', JSON.stringify(body));
|
|
10
|
-
export const notFoundJSONResponse = (body) => () => toResponse(404, 'Not Found', JSON.stringify(body));
|
|
11
|
-
export const okTextResponse = (body) => () => toResponse(200, 'OK', body);
|
|
12
|
-
export const internalServerErrorTextResponse = (body) => () => toResponse(500, 'InternalServerError', body);
|
package/lib/actions/courses.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const RECEIVED_COURSE = "@@api/RECEIVED_COURSE";
|
|
2
|
-
export declare type ReceivedCourse = {
|
|
3
|
-
type: '@@api/RECEIVED_COURSE';
|
|
4
|
-
payload: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const receivedCourse: (course: any) => ReceivedCourse;
|
|
7
|
-
//# sourceMappingURL=courses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/actions/courses.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,cAG3C,CAAC"}
|
package/lib/actions/courses.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.receivedCourse = exports.RECEIVED_COURSE = void 0;
|
|
4
|
-
exports.RECEIVED_COURSE = '@@api/RECEIVED_COURSE';
|
|
5
|
-
var receivedCourse = function (course) { return ({
|
|
6
|
-
type: exports.RECEIVED_COURSE,
|
|
7
|
-
payload: course
|
|
8
|
-
}); };
|
|
9
|
-
exports.receivedCourse = receivedCourse;
|
package/lib/actions/token.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/actions/token.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,wBAAwB,CAAC;AAEjD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,UAGzC,CAAC"}
|
package/lib/actions/token.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storeToken = exports.STORE_TOKEN = void 0;
|
|
4
|
-
exports.STORE_TOKEN = '@@token/STORE_TOKEN';
|
|
5
|
-
var storeToken = function (token) { return ({
|
|
6
|
-
type: exports.STORE_TOKEN,
|
|
7
|
-
payload: token
|
|
8
|
-
}); };
|
|
9
|
-
exports.storeToken = storeToken;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Middleware } from 'redux';
|
|
2
|
-
import { Dispatch } from 'redux';
|
|
3
|
-
import { Action } from '../actions';
|
|
4
|
-
import { StoreState } from '../configure-store';
|
|
5
|
-
declare const onStartApp: Middleware<{}, StoreState, Dispatch<Action>>;
|
|
6
|
-
export default onStartApp;
|
|
7
|
-
//# sourceMappingURL=on-start-app.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"on-start-app.d.ts","sourceRoot":"","sources":["../../src/middlewares/on-start-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,MAAM,EAAwC,MAAM,YAAY,CAAC;AACzE,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG9C,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAmB5D,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var actions_1 = require("../actions");
|
|
4
|
-
var fetch_demo_1 = require("../services/fetch-demo");
|
|
5
|
-
var onStartApp = function (_a) {
|
|
6
|
-
var dispatch = _a.dispatch;
|
|
7
|
-
return function (next) { return function (action) {
|
|
8
|
-
if (action.type === actions_1.START_APP) {
|
|
9
|
-
var token = action.payload.token;
|
|
10
|
-
dispatch((0, actions_1.storeToken)(token));
|
|
11
|
-
// --------------
|
|
12
|
-
// demo service
|
|
13
|
-
var language = 'fr';
|
|
14
|
-
var universalRef = 'dis_xxx15';
|
|
15
|
-
(0, fetch_demo_1.default)(token, language, universalRef).then(function (course) {
|
|
16
|
-
dispatch((0, actions_1.receivedCourse)(course));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return next(action);
|
|
20
|
-
}; };
|
|
21
|
-
};
|
|
22
|
-
exports.default = onStartApp;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ReceivedCourse } from '../actions';
|
|
2
|
-
export declare type State = Array<any>;
|
|
3
|
-
export declare const initialState: State;
|
|
4
|
-
declare const reducer: (state: State, action: ReceivedCourse) => State;
|
|
5
|
-
export default reducer;
|
|
6
|
-
//# sourceMappingURL=courses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/reducers/courses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAkB,MAAM,YAAY,CAAC;AAI3D,oBAAY,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,eAAO,MAAM,YAAY,EAAE,KAAU,CAAC;AAItC,QAAA,MAAM,OAAO,yBAAyC,cAAc,UAQnE,CAAC;AAIF,eAAe,OAAO,CAAC"}
|