jamespot-user-api 1.0.43 → 1.0.44

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 (121) hide show
  1. package/documentation/classes/JApplication.html +1 -1
  2. package/documentation/classes/JApplicationApi.html +8 -8
  3. package/documentation/classes/JArticleApi.html +1 -1
  4. package/documentation/classes/JAudienceApi.html +1 -1
  5. package/documentation/classes/JBaseApi.html +1 -1
  6. package/documentation/classes/JBaseObject.html +1 -1
  7. package/documentation/classes/JBookmark.html +1 -1
  8. package/documentation/classes/JBookmarkApi.html +1 -1
  9. package/documentation/classes/JCommunityApi.html +1 -1
  10. package/documentation/classes/JConcept.html +1 -1
  11. package/documentation/classes/JConceptApi.html +1 -1
  12. package/documentation/classes/JDiapazoneApi.html +1 -1
  13. package/documentation/classes/JFileApi.html +1 -1
  14. package/documentation/classes/JFilebankApi.html +1 -1
  15. package/documentation/classes/JGroupApi.html +1 -1
  16. package/documentation/classes/JLandApi.html +1 -1
  17. package/documentation/classes/JMessengerApi.html +1 -1
  18. package/documentation/classes/JSearchApi.html +6 -6
  19. package/documentation/classes/JUser.html +1 -1
  20. package/documentation/classes/JUserApi.html +3 -3
  21. package/documentation/classes/JWedocApi.html +1 -1
  22. package/documentation/classes/JamespotUserApi.html +1 -1
  23. package/documentation/classes/Network.html +1 -1
  24. package/documentation/enums/JApplicationStatus.html +1 -1
  25. package/documentation/interfaces/ApiError.html +1 -1
  26. package/documentation/interfaces/ApiWrapper.html +1 -1
  27. package/documentation/interfaces/AseiGroups.html +1 -1
  28. package/documentation/interfaces/AseiInstitution.html +1 -1
  29. package/documentation/interfaces/AseiRights.html +1 -1
  30. package/documentation/interfaces/AseiTicket.html +1 -1
  31. package/documentation/interfaces/BaseAutocomplete.html +1 -1
  32. package/documentation/interfaces/BaseMessage.html +1 -1
  33. package/documentation/interfaces/Category.html +1 -1
  34. package/documentation/interfaces/CreateGroup.html +1 -1
  35. package/documentation/interfaces/FileBankProps.html +1 -1
  36. package/documentation/interfaces/FileOption.html +1 -1
  37. package/documentation/interfaces/FolderProps.html +1 -1
  38. package/documentation/interfaces/ListFilterSpec.html +1 -1
  39. package/documentation/interfaces/OF.html +1 -1
  40. package/documentation/interfaces/PagingResults.html +1 -1
  41. package/documentation/interfaces/Result.html +1 -1
  42. package/documentation/interfaces/RootFolderProps.html +1 -1
  43. package/documentation/interfaces/SearchCategoryModel.html +1 -1
  44. package/documentation/interfaces/SearchConfig.html +1 -1
  45. package/documentation/interfaces/SearchFacetModel.html +1 -1
  46. package/documentation/interfaces/SearchFacetValueModel.html +1 -1
  47. package/documentation/interfaces/SearchQuery.html +1 -1
  48. package/documentation/interfaces/SearchQueryFilterModel.html +1 -1
  49. package/documentation/interfaces/SearchQueryOption.html +1 -1
  50. package/documentation/interfaces/SearchQueryResult.html +1 -1
  51. package/documentation/interfaces/SearchQuerySortModel.html +1 -1
  52. package/documentation/interfaces/SearchResultCatProps.html +1 -1
  53. package/documentation/interfaces/SearchResultProps.html +1 -1
  54. package/documentation/interfaces/SpotProps.html +1 -1
  55. package/documentation/interfaces/Taxonomy.html +1 -1
  56. package/documentation/interfaces/TaxonomyCreate.html +1 -1
  57. package/documentation/interfaces/TmpApplication.html +1 -1
  58. package/documentation/interfaces/TmpUser.html +1 -1
  59. package/documentation/interfaces/UserModel.html +1 -1
  60. package/documentation/modules.html +1 -1
  61. package/package.json +1 -1
  62. package/src/apis/application.ts +0 -132
  63. package/src/apis/article.ts +0 -74
  64. package/src/apis/asei.ts +0 -73
  65. package/src/apis/audience.ts +0 -18
  66. package/src/apis/base.ts +0 -9
  67. package/src/apis/bookmark.ts +0 -110
  68. package/src/apis/community.ts +0 -20
  69. package/src/apis/concept.ts +0 -31
  70. package/src/apis/diapazone.ts +0 -65
  71. package/src/apis/file.ts +0 -14
  72. package/src/apis/filebank.ts +0 -50
  73. package/src/apis/group.ts +0 -48
  74. package/src/apis/index.ts +0 -17
  75. package/src/apis/jamespotUserApi.ts +0 -69
  76. package/src/apis/jland.ts +0 -51
  77. package/src/apis/messenger.ts +0 -25
  78. package/src/apis/search.ts +0 -85
  79. package/src/apis/taxonomy.ts +0 -30
  80. package/src/apis/user.ts +0 -53
  81. package/src/apis/wedoc.ts +0 -77
  82. package/src/classes/JApplication.ts +0 -55
  83. package/src/classes/JBaseObject.ts +0 -64
  84. package/src/classes/JBookmark.ts +0 -44
  85. package/src/classes/JConcept.ts +0 -3
  86. package/src/classes/JDiapazone.ts +0 -42
  87. package/src/classes/JFile.ts +0 -37
  88. package/src/classes/JUser.ts +0 -7
  89. package/src/classes/index.ts +0 -5
  90. package/src/index.ts +0 -21
  91. package/src/indexMock.ts +0 -17
  92. package/src/mock/data/autocomplete/audience/data.json +0 -191
  93. package/src/mock/data/autocomplete/community/data.json +0 -47
  94. package/src/mock/data/autocomplete/taxonomy/data.json +0 -35
  95. package/src/mock/data/autocomplete/user/data.json +0 -107
  96. package/src/mock/data/bookmarks/addBookmark/data.json +0 -54
  97. package/src/mock/data/bookmarks/addLink/data.json +0 -63
  98. package/src/mock/data/bookmarks/bookmarkList/data.json +0 -271
  99. package/src/mock/data/bookmarks/delete/data.json +0 -12
  100. package/src/mock/data/community/sendRequest/data.json +0 -12
  101. package/src/mock/data/file/create/data.json +0 -18
  102. package/src/mock/data/messenger/newMessage/data.json +0 -47
  103. package/src/mock/data/misc/tokenCSRF/data.json +0 -7
  104. package/src/mock/data/search/getConfig/data.json +0 -318
  105. package/src/mock/data/search/lastQueries/data.json +0 -7
  106. package/src/mock/data/search/proposition/data.json +0 -125
  107. package/src/mock/data/spot/create/data.json +0 -7
  108. package/src/mock/data/spot/get-available-widget/data.json +0 -56
  109. package/src/mock/data/spot/get-categories/data.json +0 -28
  110. package/src/mock/data/user/signIn/data.json +0 -197
  111. package/src/mock/windowMock.ts +0 -113
  112. package/src/types/asei.ts +0 -33
  113. package/src/types/autocomplete.ts +0 -17
  114. package/src/types/group.ts +0 -27
  115. package/src/types/index.ts +0 -7
  116. package/src/types/listWrapper.ts +0 -6
  117. package/src/types/search.ts +0 -105
  118. package/src/types/taxonomy.ts +0 -47
  119. package/src/types/user.ts +0 -14
  120. package/src/types/utils.ts +0 -66
  121. package/src/util/network.ts +0 -96
@@ -1,96 +0,0 @@
1
- import { ApiWrapper } from '../types';
2
-
3
- export interface FileOption {
4
- makeImage: boolean;
5
- size: string;
6
- }
7
-
8
- export interface OF {
9
- o: string;
10
- f: string;
11
- }
12
-
13
- export class Network {
14
- private readonly backUrl: string;
15
- private readonly apiUrl: string;
16
- private readonly window: Window;
17
-
18
- public constructor(window: Window, suffix = '/user-api') {
19
- this.window = window;
20
- const location = window.location;
21
- this.backUrl = `${location.protocol}//${location.host}`;
22
- this.apiUrl = this.backUrl + suffix;
23
- }
24
-
25
- public static _formatPostOptions(body: object): RequestInit {
26
- return Object.assign({ method: 'POST', credentials: 'same-origin' as const }, { body: JSON.stringify(body) });
27
- }
28
-
29
- public static _formatQueryOptions(options: Record<string, string | boolean | number>): string {
30
- return Object.entries(options)
31
- .reduce((acc, [optKey, optValue]) => {
32
- acc.append(optKey, optValue.toString());
33
- return acc;
34
- }, new URLSearchParams())
35
- .toString();
36
- }
37
-
38
- // FIXME Promise<Response> should depend of T
39
- public fetch(body: OF, signal?: AbortSignal): Promise<Response> {
40
- return this.window.fetch(this.apiUrl, { ...Network._formatPostOptions(body), signal });
41
- }
42
-
43
- public post<T, U = string[]>(body: OF, signal?: AbortSignal): Promise<ApiWrapper<T, U>> {
44
- return this.fetch(body, signal)
45
- .then((res: Response) => res.json() as Promise<ApiWrapper<T, U>>)
46
- .then((res) => {
47
- if (res.error === 0) {
48
- return res;
49
- }
50
- throw {
51
- error: res.error,
52
- errorMsg: res.errorMsg,
53
- messages: res.messages,
54
- };
55
- })
56
- .catch((err) => {
57
- if (signal && signal.aborted) {
58
- throw {
59
- error: -1,
60
- aborted: true,
61
- };
62
- }
63
- throw err;
64
- });
65
- }
66
-
67
- // FIXME when doing the first file upload
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- public postFile(body: FormData, options: FileOption): Promise<any> {
70
- return this.window
71
- .fetch(`${this.apiUrl}?o=file&f=create&${Network._formatQueryOptions(Object.freeze(options))}`, {
72
- method: 'POST',
73
- credentials: 'same-origin',
74
- body,
75
- })
76
- .then((resp) => resp.json())
77
- .then((response) => {
78
- if (response.error === 0) {
79
- return response.result;
80
- }
81
- throw response.error;
82
- });
83
- }
84
-
85
- public postCSRF<T, U = string[]>(body: OF): Promise<ApiWrapper<T, U>> {
86
- return this.tokenCSRF().then((tokenCSRF) => this.post(Object.assign(body, { tokenCSRF: tokenCSRF.result })));
87
- }
88
-
89
- public token(): Promise<ApiWrapper<string>> {
90
- return this.post({ o: 'misc', f: 'token' });
91
- }
92
-
93
- public tokenCSRF(): Promise<ApiWrapper<string>> {
94
- return this.post({ o: 'misc', f: 'tokenCSRF' });
95
- }
96
- }