@coorpacademy/app-review 0.0.15 → 0.0.17

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
@@ -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,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateBack = exports.navigateTo = exports.NAVIGATE_BACK = exports.NAVIGATE_TO = void 0;
3
+ exports.startApp = exports.navigateBack = exports.navigateTo = exports.START_APP = exports.NAVIGATE_BACK = exports.NAVIGATE_TO = void 0;
4
4
  exports.NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
5
5
  exports.NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
6
+ exports.START_APP = '@@navigation/START_APP';
6
7
  var navigateTo = function (newPath) { return ({
7
8
  type: exports.NAVIGATE_TO,
8
9
  payload: newPath
@@ -12,3 +13,8 @@ var navigateBack = function () { return ({
12
13
  type: exports.NAVIGATE_BACK
13
14
  }); };
14
15
  exports.navigateBack = navigateBack;
16
+ var startApp = function (options) { return ({
17
+ type: exports.START_APP,
18
+ payload: options
19
+ }); };
20
+ exports.startApp = startApp;
@@ -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,9 @@
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,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=revision-home.stories.d.ts.map
@@ -1,16 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var React = require("react");
4
- var react_native_1 = require("@storybook/react-native");
5
- var revision_home_1 = require("./revision-home");
6
- var emptySkills = [];
7
- var skillsToRevise = [
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: 'Negotiation and powers of persuasion', info: '75 questions to revise' },
12
- { title: 'Creativity and innovation', info: '75 questions to revise' }
13
- ];
14
- (0, react_native_1.storiesOf)('RevisionHome', module)
15
- .add('No skills', function () { return React.createElement(revision_home_1.default, { skillsToRevise: emptySkills }); })
16
- .add('Few skills', function () { return React.createElement(revision_home_1.default, { 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"}
@@ -4,8 +4,10 @@ var redux_1 = require("redux");
4
4
  var redux_thunk_1 = require("redux-thunk");
5
5
  var redux_devtools_extension_1 = require("redux-devtools-extension");
6
6
  var reducers_1 = require("./reducers");
7
+ var on_start_app_1 = require("./middlewares/on-start-app");
7
8
  var preloadedState = undefined;
8
- function configureStore(services) {
9
+ // -----------------------------------------------------------------------------
10
+ function configureStore() {
9
11
  var _compose = process.env.NODE_ENV !== 'production'
10
12
  ? (0, redux_devtools_extension_1.composeWithDevTools)({
11
13
  name: 'app-review',
@@ -13,7 +15,7 @@ function configureStore(services) {
13
15
  traceLimit: 25
14
16
  })
15
17
  : redux_1.compose;
16
- var enhancer = _compose((0, redux_1.applyMiddleware)(redux_thunk_1.default));
18
+ var enhancer = _compose((0, redux_1.applyMiddleware)(redux_thunk_1.default, on_start_app_1.default));
17
19
  var store = (0, redux_1.createStore)(reducers_1.default, preloadedState, enhancer);
18
20
  return store;
19
21
  }
package/lib/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
@@ -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/lib/index.js CHANGED
@@ -25,10 +25,11 @@ var mapDispatchToProps = { navigateTo: navigation_1.navigateTo, navigateBack: na
25
25
  var App = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(root_view_1.default);
26
26
  // -----------------------------------------------------------------------------
27
27
  var AppRevision = function (_a) {
28
- var services = _a.services;
28
+ var options = _a.options;
29
29
  var _b = (0, react_1.useState)(null), store = _b[0], setStore = _b[1];
30
30
  (0, react_1.useEffect)(function () {
31
- var store = (0, configure_store_1.default)(services);
31
+ var store = (0, configure_store_1.default)();
32
+ store.dispatch((0, navigation_1.startApp)(options));
32
33
  setStore(store);
33
34
  }, []);
34
35
  if (!store)
@@ -36,5 +37,4 @@ var AppRevision = function (_a) {
36
37
  return (react_1.default.createElement(react_redux_1.Provider, { store: store },
37
38
  react_1.default.createElement(App, null)));
38
39
  };
39
- // -----------------------------------------------------------------------------
40
40
  exports.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,22 @@
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;
@@ -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,27 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.initialState = void 0;
13
+ var actions_1 = require("../actions");
14
+ exports.initialState = [];
15
+ // -----------------------------------------------------------------------------
16
+ var reducer = function (state, action) {
17
+ if (state === void 0) { state = exports.initialState; }
18
+ switch (action.type) {
19
+ case actions_1.RECEIVED_COURSE: {
20
+ return __spreadArray(__spreadArray([], state, true), [action.payload], false);
21
+ }
22
+ default:
23
+ return state;
24
+ }
25
+ };
26
+ // -----------------------------------------------------------------------------
27
+ exports.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,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var redux_1 = require("redux");
4
+ var courses_1 = require("./courses");
4
5
  var navigation_1 = require("./navigation");
6
+ var token_1 = require("./token");
5
7
  var rootReducer = (0, redux_1.combineReducers)({
6
- navigation: navigation_1.default
8
+ courses: courses_1.default,
9
+ navigation: navigation_1.default,
10
+ token: token_1.default
7
11
  });
8
12
  exports.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"}
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getCurrentViewName = exports.initialState = void 0;
13
13
  var navigation_1 = require("../actions/navigation");
14
14
  exports.initialState = ['home'];
15
+ // -----------------------------------------------------------------------------
15
16
  var reducer = function (state, action) {
16
17
  if (state === void 0) { state = exports.initialState; }
17
18
  switch (action.type) {
@@ -27,6 +28,8 @@ var reducer = function (state, action) {
27
28
  return state;
28
29
  }
29
30
  };
31
+ // -----------------------------------------------------------------------------
30
32
  var getCurrentViewName = function (appState) { return appState.navigation[appState.navigation.length - 1]; };
31
33
  exports.getCurrentViewName = getCurrentViewName;
34
+ // -----------------------------------------------------------------------------
32
35
  exports.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,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getToken = exports.initialState = void 0;
4
+ var actions_1 = require("../actions");
5
+ exports.initialState = null;
6
+ // -----------------------------------------------------------------------------
7
+ var reducer = function (state, action) {
8
+ if (state === void 0) { state = exports.initialState; }
9
+ switch (action.type) {
10
+ case actions_1.STORE_TOKEN: {
11
+ return action.payload;
12
+ }
13
+ default:
14
+ return state;
15
+ }
16
+ };
17
+ // -----------------------------------------------------------------------------
18
+ var getToken = function (appState) { return appState.token; };
19
+ exports.getToken = getToken;
20
+ // -----------------------------------------------------------------------------
21
+ exports.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,76 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.fetchCourse = void 0;
40
+ var cross_fetch_1 = require("cross-fetch");
41
+ var jwt_decode_1 = require("jwt-decode");
42
+ var fetch_responses_1 = require("./fetch-responses");
43
+ var buildUrlQueryParams = function (params) {
44
+ return Object.keys(params)
45
+ .map(function (key) {
46
+ var value = params[key].toString();
47
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
48
+ })
49
+ .join('&');
50
+ };
51
+ // -----------------------------------------------------------------------------
52
+ var fetchCourse = function (fetch) { return function (token, language, universalRef) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var jwt, query, response, hits;
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0:
57
+ jwt = (0, jwt_decode_1.default)(token);
58
+ query = {
59
+ type: 'course',
60
+ universalRef: universalRef,
61
+ lang: language
62
+ };
63
+ return [4 /*yield*/, fetch("".concat(jwt.host, "/api/v2/contents?").concat(buildUrlQueryParams(query)), {
64
+ headers: { authorization: token }
65
+ })];
66
+ case 1:
67
+ response = _a.sent();
68
+ return [4 /*yield*/, (0, fetch_responses_1.toJSON)(response)];
69
+ case 2:
70
+ hits = (_a.sent()).hits;
71
+ return [2 /*return*/, hits === null || hits === void 0 ? void 0 : hits[0]];
72
+ }
73
+ });
74
+ }); }; };
75
+ exports.fetchCourse = fetchCourse;
76
+ exports.default = fetchCourse(cross_fetch_1.default);
@@ -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,59 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var ava_1 = require("ava");
40
+ var fetch_demo_1 = require("./fetch-demo");
41
+ var fetch_mocks_1 = require("./fetch.mocks");
42
+ (0, ava_1.default)('should fetch a demo course', function (t) { return __awaiter(void 0, void 0, void 0, function () {
43
+ var token, language, universalRef, result, fetchCourse, course;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0:
47
+ token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
48
+ language = 'fr';
49
+ universalRef = 'bar';
50
+ result = { hits: [{ title: 'Digital IQ test' }] };
51
+ fetchCourse = (0, fetch_demo_1.fetchCourse)((0, fetch_mocks_1.okJSONResponse)(result));
52
+ return [4 /*yield*/, fetchCourse(token, language, universalRef)];
53
+ case 1:
54
+ course = _a.sent();
55
+ t.is(course.title, 'Digital IQ test');
56
+ return [2 /*return*/];
57
+ }
58
+ });
59
+ }); });
@@ -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"}