@coorpacademy/app-review 0.0.15 → 0.0.16

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.
Files changed (112) hide show
  1. package/es/actions/courses.d.ts +7 -0
  2. package/es/actions/courses.d.ts.map +1 -0
  3. package/es/actions/courses.js +5 -0
  4. package/es/actions/index.d.ts +6 -0
  5. package/es/actions/index.d.ts.map +1 -1
  6. package/es/actions/index.js +2 -0
  7. package/es/actions/navigation.d.ts +11 -4
  8. package/es/actions/navigation.d.ts.map +1 -1
  9. package/es/actions/navigation.js +5 -0
  10. package/es/actions/token.d.ts +7 -0
  11. package/es/actions/token.d.ts.map +1 -0
  12. package/es/actions/token.js +5 -0
  13. package/es/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +0 -1
  14. package/es/components/__tmp-backup-vues-mobile/revision-home.stories.js +14 -14
  15. package/es/configure-store.d.ts +11 -3
  16. package/es/configure-store.d.ts.map +1 -1
  17. package/es/configure-store.js +4 -2
  18. package/es/index.d.ts +9 -3
  19. package/es/index.d.ts.map +1 -1
  20. package/es/index.js +4 -4
  21. package/es/middlewares/on-start-app.d.ts +7 -0
  22. package/es/middlewares/on-start-app.d.ts.map +1 -0
  23. package/es/middlewares/on-start-app.js +17 -0
  24. package/es/reducers/courses.d.ts +6 -0
  25. package/es/reducers/courses.d.ts.map +1 -0
  26. package/es/reducers/courses.js +14 -0
  27. package/es/reducers/index.d.ts +2 -0
  28. package/es/reducers/index.d.ts.map +1 -1
  29. package/es/reducers/index.js +5 -1
  30. package/es/reducers/navigation.d.ts +2 -2
  31. package/es/reducers/navigation.d.ts.map +1 -1
  32. package/es/reducers/navigation.js +3 -0
  33. package/es/reducers/token.d.ts +7 -0
  34. package/es/reducers/token.d.ts.map +1 -0
  35. package/es/reducers/token.js +16 -0
  36. package/es/services/fetch-demo.d.ts +12 -0
  37. package/es/services/fetch-demo.d.ts.map +1 -0
  38. package/es/services/fetch-demo.js +26 -0
  39. package/es/services/fetch-demo.test.d.ts +2 -0
  40. package/es/services/fetch-demo.test.d.ts.map +1 -0
  41. package/es/services/fetch-demo.test.js +12 -0
  42. package/es/services/fetch-responses.d.ts +20 -0
  43. package/es/services/fetch-responses.d.ts.map +1 -0
  44. package/es/services/fetch-responses.js +33 -0
  45. package/es/services/fetch.mocks.d.ts +10 -0
  46. package/es/services/fetch.mocks.d.ts.map +1 -0
  47. package/es/services/fetch.mocks.js +12 -0
  48. package/lib/actions/courses.d.ts +7 -0
  49. package/lib/actions/courses.d.ts.map +1 -0
  50. package/lib/actions/courses.js +9 -0
  51. package/lib/actions/index.d.ts +6 -0
  52. package/lib/actions/index.d.ts.map +1 -1
  53. package/lib/actions/index.js +2 -0
  54. package/lib/actions/navigation.d.ts +11 -4
  55. package/lib/actions/navigation.d.ts.map +1 -1
  56. package/lib/actions/navigation.js +7 -1
  57. package/lib/actions/token.d.ts +7 -0
  58. package/lib/actions/token.d.ts.map +1 -0
  59. package/lib/actions/token.js +9 -0
  60. package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +0 -1
  61. package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.js +14 -16
  62. package/lib/configure-store.d.ts +11 -3
  63. package/lib/configure-store.d.ts.map +1 -1
  64. package/lib/configure-store.js +4 -2
  65. package/lib/index.d.ts +9 -3
  66. package/lib/index.d.ts.map +1 -1
  67. package/lib/index.js +3 -3
  68. package/lib/middlewares/on-start-app.d.ts +7 -0
  69. package/lib/middlewares/on-start-app.d.ts.map +1 -0
  70. package/lib/middlewares/on-start-app.js +22 -0
  71. package/lib/reducers/courses.d.ts +6 -0
  72. package/lib/reducers/courses.d.ts.map +1 -0
  73. package/lib/reducers/courses.js +27 -0
  74. package/lib/reducers/index.d.ts +2 -0
  75. package/lib/reducers/index.d.ts.map +1 -1
  76. package/lib/reducers/index.js +5 -1
  77. package/lib/reducers/navigation.d.ts +2 -2
  78. package/lib/reducers/navigation.d.ts.map +1 -1
  79. package/lib/reducers/navigation.js +3 -0
  80. package/lib/reducers/token.d.ts +7 -0
  81. package/lib/reducers/token.d.ts.map +1 -0
  82. package/lib/reducers/token.js +21 -0
  83. package/lib/services/fetch-demo.d.ts +12 -0
  84. package/lib/services/fetch-demo.d.ts.map +1 -0
  85. package/lib/services/fetch-demo.js +76 -0
  86. package/lib/services/fetch-demo.test.d.ts +2 -0
  87. package/lib/services/fetch-demo.test.d.ts.map +1 -0
  88. package/lib/services/fetch-demo.test.js +59 -0
  89. package/lib/services/fetch-responses.d.ts +20 -0
  90. package/lib/services/fetch-responses.d.ts.map +1 -0
  91. package/lib/services/fetch-responses.js +118 -0
  92. package/lib/services/fetch.mocks.d.ts +10 -0
  93. package/lib/services/fetch.mocks.d.ts.map +1 -0
  94. package/lib/services/fetch.mocks.js +31 -0
  95. package/package.json +13 -8
  96. package/readme.md +38 -1
  97. package/src/actions/courses.ts +11 -0
  98. package/src/actions/index.ts +8 -0
  99. package/src/actions/navigation.ts +16 -4
  100. package/src/actions/token.ts +11 -0
  101. package/src/components/__tmp-backup-vues-mobile/revision-home.stories.tsx +14 -14
  102. package/src/configure-store.ts +15 -2
  103. package/src/index.tsx +12 -3
  104. package/src/middlewares/on-start-app.ts +30 -0
  105. package/src/reducers/courses.ts +22 -0
  106. package/src/reducers/index.ts +6 -1
  107. package/src/reducers/navigation.ts +11 -3
  108. package/src/reducers/token.ts +26 -0
  109. package/src/services/fetch-demo.test.ts +16 -0
  110. package/src/services/fetch-demo.ts +55 -0
  111. package/src/services/fetch-responses.ts +53 -0
  112. package/src/services/fetch.mocks.ts +26 -0
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
1
+ export const RECEIVED_COURSE = '@@api/RECEIVED_COURSE';
2
+ export const receivedCourse = (course) => ({
3
+ type: RECEIVED_COURSE,
4
+ payload: course
5
+ });
@@ -1,2 +1,8 @@
1
+ import { ReceivedCourse } from './courses';
2
+ import { NavigateBack, NavigateTo, StartApp } from './navigation';
3
+ import { StoreToken } from './token';
4
+ export * from './courses';
1
5
  export * from './navigation';
6
+ export * from './token';
7
+ export declare type Action = StartApp | StoreToken | NavigateBack | NavigateTo | ReceivedCourse;
2
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,oBAAY,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,CAAC"}
@@ -1 +1,3 @@
1
+ export * from './courses';
1
2
  export * from './navigation';
3
+ export * from './token';
@@ -1,13 +1,20 @@
1
1
  import { ActionCreator } from 'redux';
2
+ import { AppOptions } from '..';
2
3
  export declare const NAVIGATE_TO = "@@navigation/NAVIGATE_TO";
3
4
  export declare const NAVIGATE_BACK = "@@navigation/NAVIGATE_BACK";
4
- export declare type $NAVIGATE_TO = {
5
+ export declare const START_APP = "@@navigation/START_APP";
6
+ export declare type NavigateTo = {
5
7
  type: '@@navigation/NAVIGATE_TO';
6
8
  payload: string;
7
9
  };
8
- export declare type $NAVIGATE_BACK = {
10
+ export declare type NavigateBack = {
9
11
  type: '@@navigation/NAVIGATE_BACK';
10
12
  };
11
- export declare const navigateTo: ActionCreator<$NAVIGATE_TO>;
12
- export declare const navigateBack: ActionCreator<$NAVIGATE_BACK>;
13
+ export declare type StartApp = {
14
+ type: '@@navigation/START_APP';
15
+ payload: AppOptions;
16
+ };
17
+ export declare const navigateTo: ActionCreator<NavigateTo>;
18
+ export declare const navigateBack: ActionCreator<NavigateBack>;
19
+ export declare const startApp: (options: AppOptions) => StartApp;
13
20
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/actions/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEpC,eAAO,MAAM,WAAW,6BAA6B,CAAC;AACtD,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAE1D,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,4BAA4B,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,YAAY,CAGjD,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,cAAc,CAErD,CAAC"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/actions/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,IAAI,CAAC;AAE9B,eAAO,MAAM,WAAW,6BAA6B,CAAC;AACtD,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAC1D,eAAO,MAAM,SAAS,2BAA2B,CAAC;AAElD,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,4BAA4B,CAAC;CACpC,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,UAAU,CAG/C,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,YAAY,CAEnD,CAAC;AAEH,eAAO,MAAM,QAAQ,YAAa,UAAU,KAAG,QAG7C,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
2
2
  export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
3
+ export const START_APP = '@@navigation/START_APP';
3
4
  export const navigateTo = (newPath) => ({
4
5
  type: NAVIGATE_TO,
5
6
  payload: newPath
@@ -7,3 +8,7 @@ export const navigateTo = (newPath) => ({
7
8
  export const navigateBack = () => ({
8
9
  type: NAVIGATE_BACK
9
10
  });
11
+ export const startApp = (options) => ({
12
+ type: START_APP,
13
+ payload: options
14
+ });
@@ -0,0 +1,7 @@
1
+ export declare const STORE_TOKEN = "@@token/STORE_TOKEN";
2
+ export declare type StoreToken = {
3
+ type: '@@token/STORE_TOKEN';
4
+ payload: string;
5
+ };
6
+ export declare const storeToken: (token: string) => StoreToken;
7
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
1
+ export const STORE_TOKEN = '@@token/STORE_TOKEN';
2
+ export const storeToken = (token) => ({
3
+ type: STORE_TOKEN,
4
+ payload: token
5
+ });
@@ -1,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=revision-home.stories.d.ts.map
@@ -1,14 +1,14 @@
1
- import * as React from 'react';
2
- import { storiesOf } from '@storybook/react-native';
3
- import RevisionHome from './revision-home';
4
- const emptySkills = [];
5
- const skillsToRevise = [
6
- { title: 'Negotiation and powers of persuasion', info: '75 questions to revise' },
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: 'Creativity and innovation', info: '75 questions to revise' }
11
- ];
12
- storiesOf('RevisionHome', module)
13
- .add('No skills', () => React.createElement(RevisionHome, { skillsToRevise: emptySkills }))
14
- .add('Few skills', () => React.createElement(RevisionHome, { skillsToRevise: skillsToRevise }));
1
+ // import * as React from 'react';
2
+ // import {storiesOf} from '@storybook/react-native';
3
+ // import RevisionHome from './revision-home';
4
+ // const emptySkills: [] = [];
5
+ // const skillsToRevise: {title: string; info: string}[] = [
6
+ // {title: 'Negotiation and powers of persuasion', info: '75 questions to revise'},
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: 'Creativity and innovation', info: '75 questions to revise'}
11
+ // ];
12
+ // storiesOf('RevisionHome', module)
13
+ // .add('No skills', () => <RevisionHome skillsToRevise={emptySkills} />)
14
+ // .add('Few skills', () => <RevisionHome skillsToRevise={skillsToRevise} />);
@@ -1,6 +1,14 @@
1
- export default function configureStore(services: any): import("redux").Store<import("redux").EmptyObject & {
2
- navigation: import("./reducers/navigation").State;
1
+ import { State as NavigationState } from './reducers/navigation';
2
+ import { State as TokenState } from './reducers/token';
3
+ export default function configureStore(): import("redux").Store<import("redux").EmptyObject & {
4
+ courses: import("./reducers/courses").State;
5
+ navigation: NavigationState;
6
+ token: string;
3
7
  }, import("redux").AnyAction> & {
4
- dispatch: unknown;
8
+ dispatch: {};
9
+ };
10
+ export declare type StoreState = {
11
+ navigation: NavigationState;
12
+ token: TokenState;
5
13
  };
6
14
  //# sourceMappingURL=configure-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configure-store.d.ts","sourceRoot":"","sources":["../src/configure-store.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,KAAA;;;;EAc9C"}
1
+ {"version":3,"file":"configure-store.d.ts","sourceRoot":"","sources":["../src/configure-store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,IAAI,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAC,KAAK,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAOrD,MAAM,CAAC,OAAO,UAAU,cAAc;;;;;;EAcrC;AAID,oBAAY,UAAU,GAAG;IACvB,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC"}
@@ -2,8 +2,10 @@ import { applyMiddleware, compose, createStore } from 'redux';
2
2
  import thunk from 'redux-thunk';
3
3
  import { composeWithDevTools } from 'redux-devtools-extension';
4
4
  import rootReducer from './reducers';
5
+ import onStartApp from './middlewares/on-start-app';
5
6
  const preloadedState = undefined;
6
- export default function configureStore(services) {
7
+ // -----------------------------------------------------------------------------
8
+ export default function configureStore() {
7
9
  const _compose = process.env.NODE_ENV !== 'production'
8
10
  ? composeWithDevTools({
9
11
  name: 'app-review',
@@ -11,7 +13,7 @@ export default function configureStore(services) {
11
13
  traceLimit: 25
12
14
  })
13
15
  : compose;
14
- const enhancer = _compose(applyMiddleware(thunk));
16
+ const enhancer = _compose(applyMiddleware(thunk, onStartApp));
15
17
  const store = createStore(rootReducer, preloadedState, enhancer);
16
18
  return store;
17
19
  }
package/es/index.d.ts CHANGED
@@ -1,5 +1,11 @@
1
- declare const AppRevision: ({ services }: {
2
- services: any;
3
- }) => JSX.Element;
1
+ declare const AppRevision: ({ options }: Props) => JSX.Element;
2
+ declare type Props = {
3
+ options: AppOptions;
4
+ };
5
+ export declare type AppOptions = {
6
+ token: string;
7
+ theme?: any;
8
+ translations?: any;
9
+ };
4
10
  export default AppRevision;
5
11
  //# sourceMappingURL=index.d.ts.map
package/es/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAmBA,QAAA,MAAM,WAAW;;iBAehB,CAAC;AAIF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAmBA,QAAA,MAAM,WAAW,gBAAe,KAAK,gBAgBpC,CAAC;AAIF,aAAK,KAAK,GAAG;IAAC,OAAO,EAAE,UAAU,CAAA;CAAC,CAAC;AAEnC,oBAAY,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB,CAAC;AAEF,eAAe,WAAW,CAAC"}
package/es/index.js CHANGED
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import { connect, Provider } from 'react-redux';
3
3
  import AppReviewRootView from '@coorpacademy/components/es/template/app-review/root-view/root-view';
4
4
  import configureStore from './configure-store';
5
- import { navigateTo, navigateBack } from './actions/navigation';
5
+ import { navigateTo, navigateBack, startApp } from './actions/navigation';
6
6
  import { getCurrentViewName } from './reducers/navigation';
7
7
  // -----------------------------------------------------------------------------
8
8
  const mapStateToProps = (state, ownProps) => {
@@ -11,10 +11,11 @@ const mapStateToProps = (state, ownProps) => {
11
11
  const mapDispatchToProps = { navigateTo, navigateBack };
12
12
  const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewRootView);
13
13
  // -----------------------------------------------------------------------------
14
- const AppRevision = ({ services }) => {
14
+ const AppRevision = ({ options }) => {
15
15
  const [store, setStore] = useState(null);
16
16
  useEffect(() => {
17
- const store = configureStore(services);
17
+ const store = configureStore();
18
+ store.dispatch(startApp(options));
18
19
  setStore(store);
19
20
  }, []);
20
21
  if (!store)
@@ -22,5 +23,4 @@ const AppRevision = ({ services }) => {
22
23
  return (React.createElement(Provider, { store: store },
23
24
  React.createElement(App, null)));
24
25
  };
25
- // -----------------------------------------------------------------------------
26
26
  export default AppRevision;
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,14 @@
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;
@@ -1,5 +1,7 @@
1
1
  declare const rootReducer: import("redux").Reducer<import("redux").CombinedState<{
2
+ courses: import("./courses").State;
2
3
  navigation: import("./navigation").State;
4
+ token: string;
3
5
  }>, import("redux").AnyAction>;
4
6
  export default rootReducer;
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW;;8BAEf,CAAC;AAEH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,WAAW;;;;8BAIf,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -1,6 +1,10 @@
1
1
  import { combineReducers } from 'redux';
2
+ import courses from './courses';
2
3
  import navigation from './navigation';
4
+ import token from './token';
3
5
  const rootReducer = combineReducers({
4
- navigation
6
+ courses,
7
+ navigation,
8
+ token
5
9
  });
6
10
  export default rootReducer;
@@ -1,7 +1,7 @@
1
- import type { $NAVIGATE_TO, $NAVIGATE_BACK } from '../actions/navigation';
1
+ import type { NavigateTo, NavigateBack } from '../actions/navigation';
2
2
  export declare type State = Array<string>;
3
3
  export declare const initialState: State;
4
- declare const reducer: (state: State, action: $NAVIGATE_TO | $NAVIGATE_BACK) => State;
4
+ declare const reducer: (state: State, action: NavigateTo | NavigateBack) => State;
5
5
  export declare const getCurrentViewName: (appState: any) => any;
6
6
  export default reducer;
7
7
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/reducers/navigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAExE,oBAAY,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAElC,eAAO,MAAM,YAAY,EAAE,KAAgB,CAAC;AAE5C,QAAA,MAAM,OAAO,yBAAyC,YAAY,GAAG,cAAc,UAalF,CAAC;AAEF,eAAO,MAAM,kBAAkB,wBAAkE,CAAC;AAClG,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/reducers/navigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAIpE,oBAAY,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAClC,eAAO,MAAM,YAAY,EAAE,KAAgB,CAAC;AAI5C,QAAA,MAAM,OAAO,yBAAyC,UAAU,GAAG,YAAY,UAa9E,CAAC;AAIF,eAAO,MAAM,kBAAkB,wBAAkE,CAAC;AAIlG,eAAe,OAAO,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { NAVIGATE_BACK, NAVIGATE_TO } from '../actions/navigation';
2
2
  export const initialState = ['home'];
3
+ // -----------------------------------------------------------------------------
3
4
  const reducer = (state = initialState, action) => {
4
5
  switch (action.type) {
5
6
  case NAVIGATE_TO: {
@@ -14,5 +15,7 @@ const reducer = (state = initialState, action) => {
14
15
  return state;
15
16
  }
16
17
  };
18
+ // -----------------------------------------------------------------------------
17
19
  export const getCurrentViewName = appState => appState.navigation[appState.navigation.length - 1];
20
+ // -----------------------------------------------------------------------------
18
21
  export default reducer;
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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;
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,26 @@
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);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fetch-demo.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-demo.test.d.ts","sourceRoot":"","sources":["../../src/services/fetch-demo.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,20 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,33 @@
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
+ };
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
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);
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,9 @@
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;
@@ -1,2 +1,8 @@
1
+ import { ReceivedCourse } from './courses';
2
+ import { NavigateBack, NavigateTo, StartApp } from './navigation';
3
+ import { StoreToken } from './token';
4
+ export * from './courses';
1
5
  export * from './navigation';
6
+ export * from './token';
7
+ export declare type Action = StartApp | StoreToken | NavigateBack | NavigateTo | ReceivedCourse;
2
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,oBAAY,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,cAAc,CAAC"}
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./courses"), exports);
17
18
  __exportStar(require("./navigation"), exports);
19
+ __exportStar(require("./token"), exports);
@@ -1,13 +1,20 @@
1
1
  import { ActionCreator } from 'redux';
2
+ import { AppOptions } from '..';
2
3
  export declare const NAVIGATE_TO = "@@navigation/NAVIGATE_TO";
3
4
  export declare const NAVIGATE_BACK = "@@navigation/NAVIGATE_BACK";
4
- export declare type $NAVIGATE_TO = {
5
+ export declare const START_APP = "@@navigation/START_APP";
6
+ export declare type NavigateTo = {
5
7
  type: '@@navigation/NAVIGATE_TO';
6
8
  payload: string;
7
9
  };
8
- export declare type $NAVIGATE_BACK = {
10
+ export declare type NavigateBack = {
9
11
  type: '@@navigation/NAVIGATE_BACK';
10
12
  };
11
- export declare const navigateTo: ActionCreator<$NAVIGATE_TO>;
12
- export declare const navigateBack: ActionCreator<$NAVIGATE_BACK>;
13
+ export declare type StartApp = {
14
+ type: '@@navigation/START_APP';
15
+ payload: AppOptions;
16
+ };
17
+ export declare const navigateTo: ActionCreator<NavigateTo>;
18
+ export declare const navigateBack: ActionCreator<NavigateBack>;
19
+ export declare const startApp: (options: AppOptions) => StartApp;
13
20
  //# sourceMappingURL=navigation.d.ts.map