@coorpacademy/app-review 0.0.14-alpha.1 → 0.0.14-alpha.3

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 (87) 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/token.d.ts +7 -0
  8. package/es/actions/token.d.ts.map +1 -0
  9. package/es/actions/token.js +5 -0
  10. package/es/configure-store.d.ts +9 -2
  11. package/es/configure-store.d.ts.map +1 -1
  12. package/es/configure-store.js +3 -1
  13. package/es/index.d.ts +2 -0
  14. package/es/index.d.ts.map +1 -1
  15. package/es/middlewares/on-start-app.d.ts +7 -0
  16. package/es/middlewares/on-start-app.d.ts.map +1 -0
  17. package/es/middlewares/on-start-app.js +17 -0
  18. package/es/reducers/courses.d.ts +6 -0
  19. package/es/reducers/courses.d.ts.map +1 -0
  20. package/es/reducers/courses.js +14 -0
  21. package/es/reducers/index.d.ts +1 -0
  22. package/es/reducers/index.d.ts.map +1 -1
  23. package/es/reducers/index.js +2 -0
  24. package/es/reducers/token.d.ts +2 -2
  25. package/es/reducers/token.d.ts.map +1 -1
  26. package/es/reducers/token.js +3 -3
  27. package/es/services/fetch-demo.d.ts +5 -2
  28. package/es/services/fetch-demo.d.ts.map +1 -1
  29. package/es/services/fetch-demo.js +5 -4
  30. package/es/services/fetch-demo.test.js +6 -4
  31. package/es/services/fetch-responses.d.ts +20 -0
  32. package/es/services/fetch-responses.d.ts.map +1 -0
  33. package/es/services/fetch-responses.js +33 -0
  34. package/es/services/fetch.test.d.ts +10 -0
  35. package/es/services/fetch.test.d.ts.map +1 -0
  36. package/es/services/fetch.test.js +12 -0
  37. package/lib/actions/courses.d.ts +7 -0
  38. package/lib/actions/courses.d.ts.map +1 -0
  39. package/lib/actions/courses.js +9 -0
  40. package/lib/actions/index.d.ts +6 -0
  41. package/lib/actions/index.d.ts.map +1 -1
  42. package/lib/actions/index.js +2 -0
  43. package/lib/actions/token.d.ts +7 -0
  44. package/lib/actions/token.d.ts.map +1 -0
  45. package/lib/actions/token.js +9 -0
  46. package/lib/configure-store.d.ts +9 -2
  47. package/lib/configure-store.d.ts.map +1 -1
  48. package/lib/configure-store.js +3 -1
  49. package/lib/index.d.ts +2 -0
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/middlewares/on-start-app.d.ts +7 -0
  52. package/lib/middlewares/on-start-app.d.ts.map +1 -0
  53. package/lib/middlewares/on-start-app.js +22 -0
  54. package/lib/reducers/courses.d.ts +6 -0
  55. package/lib/reducers/courses.d.ts.map +1 -0
  56. package/lib/reducers/courses.js +27 -0
  57. package/lib/reducers/index.d.ts +1 -0
  58. package/lib/reducers/index.d.ts.map +1 -1
  59. package/lib/reducers/index.js +2 -0
  60. package/lib/reducers/token.d.ts +2 -2
  61. package/lib/reducers/token.d.ts.map +1 -1
  62. package/lib/reducers/token.js +3 -3
  63. package/lib/services/fetch-demo.d.ts +5 -2
  64. package/lib/services/fetch-demo.d.ts.map +1 -1
  65. package/lib/services/fetch-demo.js +8 -7
  66. package/lib/services/fetch-demo.test.js +7 -5
  67. package/lib/services/fetch-responses.d.ts +20 -0
  68. package/lib/services/fetch-responses.d.ts.map +1 -0
  69. package/lib/services/fetch-responses.js +118 -0
  70. package/lib/services/fetch.test.d.ts +10 -0
  71. package/lib/services/fetch.test.d.ts.map +1 -0
  72. package/lib/services/fetch.test.js +31 -0
  73. package/package.json +3 -3
  74. package/readme.md +2 -0
  75. package/src/actions/courses.ts +11 -0
  76. package/src/actions/index.ts +8 -0
  77. package/src/actions/token.ts +11 -0
  78. package/src/configure-store.ts +14 -1
  79. package/src/index.tsx +2 -0
  80. package/src/middlewares/on-start-app.ts +30 -0
  81. package/src/reducers/courses.ts +22 -0
  82. package/src/reducers/index.ts +3 -0
  83. package/src/reducers/token.ts +4 -5
  84. package/src/services/fetch-demo.test.ts +6 -4
  85. package/src/services/fetch-demo.ts +5 -4
  86. package/src/services/fetch-responses.ts +53 -0
  87. package/src/services/fetch.test.ts +26 -0
@@ -0,0 +1,7 @@
1
+ export declare const RECEIVED_COURSE = "@@api/RECEIVED_COURSE";
2
+ export declare type $RECEIVED_COURSE = {
3
+ type: '@@api/RECEIVED_COURSE';
4
+ payload: string;
5
+ };
6
+ export declare const receivedCourse: (course: any) => $RECEIVED_COURSE;
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,gBAAgB,GAAG;IAC7B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,gBAG3C,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 { $RECEIVED_COURSE } from './courses';
2
+ import { $NAVIGATE_BACK, $NAVIGATE_TO, $START_APP } from './navigation';
3
+ import { $STORE_TOKEN } from './token';
4
+ export * from './courses';
1
5
  export * from './navigation';
6
+ export * from './token';
7
+ export declare type Action = $START_APP | $STORE_TOKEN | $NAVIGATE_BACK | $NAVIGATE_TO | $RECEIVED_COURSE;
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,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,oBAAY,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,gBAAgB,CAAC"}
@@ -1 +1,3 @@
1
+ export * from './courses';
1
2
  export * from './navigation';
3
+ export * from './token';
@@ -0,0 +1,7 @@
1
+ export declare const STORE_TOKEN = "@@token/STORE_TOKEN";
2
+ export declare type $STORE_TOKEN = {
3
+ type: '@@token/STORE_TOKEN';
4
+ payload: string;
5
+ };
6
+ export declare const storeToken: (token: string) => $STORE_TOKEN;
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,YAAY,GAAG;IACzB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,YAGzC,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,7 +1,14 @@
1
+ import { State as NavigationState } from './reducers/navigation';
2
+ import { State as TokenState } from './reducers/token';
1
3
  export default function configureStore(): import("redux").Store<import("redux").EmptyObject & {
2
- navigation: import("./reducers/navigation").State;
4
+ courses: import("./reducers/courses").State;
5
+ navigation: NavigationState;
3
6
  token: string;
4
7
  }, import("redux").AnyAction> & {
5
- dispatch: unknown;
8
+ dispatch: {};
9
+ };
10
+ export declare type StoreState = {
11
+ navigation: NavigationState;
12
+ token: TokenState;
6
13
  };
7
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;;;;;EAcrC"}
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,7 +2,9 @@ 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;
7
+ // -----------------------------------------------------------------------------
6
8
  export default function configureStore() {
7
9
  const _compose = process.env.NODE_ENV !== 'production'
8
10
  ? composeWithDevTools({
@@ -11,7 +13,7 @@ export default function configureStore() {
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
@@ -4,6 +4,8 @@ declare type Props = {
4
4
  };
5
5
  export declare type AppOptions = {
6
6
  token: string;
7
+ theme?: any;
8
+ translations?: any;
7
9
  };
8
10
  export default AppRevision;
9
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,gBAAe,KAAK,gBAgBpC,CAAC;AAIF,aAAK,KAAK,GAAG;IAAC,OAAO,EAAE,UAAU,CAAA;CAAC,CAAC;AAEnC,oBAAY,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,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"}
@@ -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 { $RECEIVED_COURSE } from '../actions';
2
+ export declare type State = Array<any>;
3
+ export declare const initialState: State;
4
+ declare const reducer: (state: State, action: $RECEIVED_COURSE) => 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,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAI7D,oBAAY,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,eAAO,MAAM,YAAY,EAAE,KAAU,CAAC;AAItC,QAAA,MAAM,OAAO,yBAAyC,gBAAgB,UAQrE,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,4 +1,5 @@
1
1
  declare const rootReducer: import("redux").Reducer<import("redux").CombinedState<{
2
+ courses: import("./courses").State;
2
3
  navigation: import("./navigation").State;
3
4
  token: string;
4
5
  }>, import("redux").AnyAction>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,WAAW;;;8BAGf,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,7 +1,9 @@
1
1
  import { combineReducers } from 'redux';
2
+ import courses from './courses';
2
3
  import navigation from './navigation';
3
4
  import token from './token';
4
5
  const rootReducer = combineReducers({
6
+ courses,
5
7
  navigation,
6
8
  token
7
9
  });
@@ -1,7 +1,7 @@
1
- import type { $START_APP } from '../actions/navigation';
1
+ import { $STORE_TOKEN } from '../actions';
2
2
  export declare type State = string;
3
3
  export declare const initialState: State;
4
- declare const reducer: (state: State, action: $START_APP) => State;
4
+ declare const reducer: (state: State, action: $STORE_TOKEN) => State;
5
5
  export declare const getToken: (appState: any) => any;
6
6
  export default reducer;
7
7
  //# sourceMappingURL=token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/reducers/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAItD,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"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/reducers/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAc,MAAM,YAAY,CAAC;AAIrD,oBAAY,KAAK,GAAG,MAAM,CAAC;AAC3B,eAAO,MAAM,YAAY,EAAE,KAAY,CAAC;AAIxC,QAAA,MAAM,OAAO,UAAW,KAAK,UAAyB,YAAY,KAAG,KAQpE,CAAC;AAIF,eAAO,MAAM,QAAQ,wBAA6B,CAAC;AAInD,eAAe,OAAO,CAAC"}
@@ -1,10 +1,10 @@
1
- import { START_APP } from '../actions/navigation';
1
+ import { STORE_TOKEN } from '../actions';
2
2
  export const initialState = null;
3
3
  // -----------------------------------------------------------------------------
4
4
  const reducer = (state = initialState, action) => {
5
5
  switch (action.type) {
6
- case START_APP: {
7
- return action.payload.token;
6
+ case STORE_TOKEN: {
7
+ return action.payload;
8
8
  }
9
9
  default:
10
10
  return state;
@@ -1,3 +1,6 @@
1
- declare const fetchCourse: (token: any, language: any, universalRef: any) => Promise<any>;
2
- export default fetchCourse;
1
+ import { Fetch } from './fetch-responses';
2
+ declare const fetchCourse: (fetch: Fetch) => (token: any, language: any, universalRef: any) => Promise<any>;
3
+ export { fetchCourse };
4
+ declare const _default: (token: any, language: any, universalRef: any) => Promise<any>;
5
+ export default _default;
3
6
  //# sourceMappingURL=fetch-demo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-demo.d.ts","sourceRoot":"","sources":["../../src/services/fetch-demo.ts"],"names":[],"mappings":"AA6BA,QAAA,MAAM,WAAW,gEAchB,CAAC;AAIF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"fetch-demo.d.ts","sourceRoot":"","sources":["../../src/services/fetch-demo.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAS,MAAM,mBAAmB,CAAC;AA4BhD,QAAA,MAAM,WAAW,UAAW,KAAK,mEAchC,CAAC;AAIF,OAAO,EAAC,WAAW,EAAC,CAAC;;AACrB,wBAAkC"}
@@ -1,5 +1,5 @@
1
- import fetch from 'cross-fetch';
2
1
  import decode from 'jwt-decode';
2
+ import { toJSON } from './fetch-responses';
3
3
  const buildUrlQueryParams = (params) => Object.keys(params)
4
4
  .map(key => {
5
5
  const value = params[key].toString();
@@ -7,7 +7,7 @@ const buildUrlQueryParams = (params) => Object.keys(params)
7
7
  })
8
8
  .join('&');
9
9
  // -----------------------------------------------------------------------------
10
- const fetchCourse = async (token, language, universalRef) => {
10
+ const fetchCourse = (fetch) => async (token, language, universalRef) => {
11
11
  const jwt = decode(token);
12
12
  const query = {
13
13
  type: 'course',
@@ -17,8 +17,9 @@ const fetchCourse = async (token, language, universalRef) => {
17
17
  const response = await fetch(`${jwt.host}/api/v2/contents?${buildUrlQueryParams(query)}`, {
18
18
  headers: { authorization: token }
19
19
  });
20
- const { hits } = await response.json();
20
+ const { hits } = (await toJSON(response));
21
21
  return hits?.[0];
22
22
  };
23
23
  // -----------------------------------------------------------------------------
24
- export default fetchCourse;
24
+ export { fetchCourse };
25
+ export default fetchCourse(fetch);
@@ -1,11 +1,13 @@
1
1
  import test from 'ava';
2
- import fetchCourse from './fetch-demo.js';
2
+ import { fetchCourse as _fetchCourse } from './fetch-demo.js';
3
+ import { okJSONResponse } from './fetch.test';
3
4
  import dotenv from 'dotenv';
4
5
  dotenv.config();
5
6
  test('should fetch a demo course with mobile-staging dev token', async (t) => {
6
- const token = process.env.API_TEST_TOKEN;
7
+ const token = 'foo';
7
8
  const language = 'fr';
8
- const universalRef = 'dis_NkAPG3m4U';
9
+ const universalRef = 'bar';
10
+ const fetchCourse = _fetchCourse(okJSONResponse({ title: 'Digital IQ test' }));
9
11
  const course = await fetchCourse(token, language, universalRef);
10
- t.is(course.title, 'March-ing towards a greener tomorrow');
12
+ t.is(course.title, 'Digital IQs test');
11
13
  });
@@ -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.js';
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.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.test.d.ts","sourceRoot":"","sources":["../../src/services/fetch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,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 $RECEIVED_COURSE = {
3
+ type: '@@api/RECEIVED_COURSE';
4
+ payload: string;
5
+ };
6
+ export declare const receivedCourse: (course: any) => $RECEIVED_COURSE;
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,gBAAgB,GAAG;IAC7B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,gBAG3C,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 { $RECEIVED_COURSE } from './courses';
2
+ import { $NAVIGATE_BACK, $NAVIGATE_TO, $START_APP } from './navigation';
3
+ import { $STORE_TOKEN } from './token';
4
+ export * from './courses';
1
5
  export * from './navigation';
6
+ export * from './token';
7
+ export declare type Action = $START_APP | $STORE_TOKEN | $NAVIGATE_BACK | $NAVIGATE_TO | $RECEIVED_COURSE;
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,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,oBAAY,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,YAAY,GAAG,gBAAgB,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);
@@ -0,0 +1,7 @@
1
+ export declare const STORE_TOKEN = "@@token/STORE_TOKEN";
2
+ export declare type $STORE_TOKEN = {
3
+ type: '@@token/STORE_TOKEN';
4
+ payload: string;
5
+ };
6
+ export declare const storeToken: (token: string) => $STORE_TOKEN;
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,YAAY,GAAG;IACzB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,YAGzC,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,7 +1,14 @@
1
+ import { State as NavigationState } from './reducers/navigation';
2
+ import { State as TokenState } from './reducers/token';
1
3
  export default function configureStore(): import("redux").Store<import("redux").EmptyObject & {
2
- navigation: import("./reducers/navigation").State;
4
+ courses: import("./reducers/courses").State;
5
+ navigation: NavigationState;
3
6
  token: string;
4
7
  }, import("redux").AnyAction> & {
5
- dispatch: unknown;
8
+ dispatch: {};
9
+ };
10
+ export declare type StoreState = {
11
+ navigation: NavigationState;
12
+ token: TokenState;
6
13
  };
7
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;;;;;EAcrC"}
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,7 +4,9 @@ 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;
9
+ // -----------------------------------------------------------------------------
8
10
  function configureStore() {
9
11
  var _compose = process.env.NODE_ENV !== 'production'
10
12
  ? (0, redux_devtools_extension_1.composeWithDevTools)({
@@ -13,7 +15,7 @@ function configureStore() {
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
@@ -4,6 +4,8 @@ declare type Props = {
4
4
  };
5
5
  export declare type AppOptions = {
6
6
  token: string;
7
+ theme?: any;
8
+ translations?: any;
7
9
  };
8
10
  export default AppRevision;
9
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,gBAAe,KAAK,gBAgBpC,CAAC;AAIF,aAAK,KAAK,GAAG;IAAC,OAAO,EAAE,UAAU,CAAA;CAAC,CAAC;AAEnC,oBAAY,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,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"}
@@ -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 { $RECEIVED_COURSE } from '../actions';
2
+ export declare type State = Array<any>;
3
+ export declare const initialState: State;
4
+ declare const reducer: (state: State, action: $RECEIVED_COURSE) => 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,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAI7D,oBAAY,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,eAAO,MAAM,YAAY,EAAE,KAAU,CAAC;AAItC,QAAA,MAAM,OAAO,yBAAyC,gBAAgB,UAQrE,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,4 +1,5 @@
1
1
  declare const rootReducer: import("redux").Reducer<import("redux").CombinedState<{
2
+ courses: import("./courses").State;
2
3
  navigation: import("./navigation").State;
3
4
  token: string;
4
5
  }>, import("redux").AnyAction>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,WAAW;;;8BAGf,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,9 +1,11 @@
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");
5
6
  var token_1 = require("./token");
6
7
  var rootReducer = (0, redux_1.combineReducers)({
8
+ courses: courses_1.default,
7
9
  navigation: navigation_1.default,
8
10
  token: token_1.default
9
11
  });