@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,53 @@
1
+ export type Response = {
2
+ ok: boolean;
3
+ status: number;
4
+ statusText: string;
5
+ json: () => Promise<unknown>;
6
+ text: () => Promise<string>;
7
+ };
8
+
9
+ export type Fetch = (
10
+ url?: string,
11
+ options?: {headers: {authorization: string}}
12
+ ) => Promise<Response>;
13
+
14
+ export class ResponseError extends Error {
15
+ public statusCode: number;
16
+
17
+ public constructor(status: number, statusText: string, body = '') {
18
+ super(`${statusText} ${body}`.trim());
19
+ this.name = 'ResponseError';
20
+ this.statusCode = status;
21
+ }
22
+ }
23
+
24
+ export const toJSON = async (response: Response): Promise<unknown> => {
25
+ if (!response.ok) {
26
+ const body = await response.text();
27
+ throw new ResponseError(response.status, response.statusText, body);
28
+ }
29
+
30
+ try {
31
+ return await response.json();
32
+ } catch (err) {
33
+ throw new ResponseError(response.status, response.statusText);
34
+ }
35
+ };
36
+
37
+ export const toText = async (response: Response): Promise<string> => {
38
+ const body = await response.text();
39
+
40
+ if (!response.ok) {
41
+ throw new ResponseError(response.status, response.statusText, body);
42
+ }
43
+
44
+ return body;
45
+ };
46
+
47
+ export const toVoid = async (response: Response): Promise<void> => {
48
+ if (!response.ok) {
49
+ const body = await response.text();
50
+ throw new ResponseError(response.status, response.statusText, body);
51
+ }
52
+ return;
53
+ };
@@ -0,0 +1,26 @@
1
+ import {Response} from './fetch-responses';
2
+
3
+ export const toResponse = (status: number, statusText: string, body: string): Promise<Response> =>
4
+ Promise.resolve({
5
+ ok: status < 400,
6
+ status,
7
+ statusText,
8
+ json: (): Promise<unknown> => Promise.resolve(body).then(JSON.parse),
9
+ text: (): Promise<string> => Promise.resolve(body)
10
+ });
11
+
12
+ type FetchFunction = () => Promise<Response>;
13
+
14
+ export const okJSONResponse = (body: unknown): FetchFunction => () =>
15
+ toResponse(200, 'OK', JSON.stringify(body));
16
+
17
+ export const internalServerErrorJSONResponse = (body: unknown): FetchFunction => () =>
18
+ toResponse(500, 'InternalServerError', JSON.stringify(body));
19
+
20
+ export const notFoundJSONResponse = (body: unknown): FetchFunction => () =>
21
+ toResponse(404, 'Not Found', JSON.stringify(body));
22
+
23
+ export const okTextResponse = (body: string): FetchFunction => () => toResponse(200, 'OK', body);
24
+
25
+ export const internalServerErrorTextResponse = (body: string): FetchFunction => () =>
26
+ toResponse(500, 'InternalServerError', body);