jamespot-user-api 1.0.43 → 1.0.47
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.
- package/documentation/assets/search.js +1 -1
- package/documentation/classes/JApplication.html +1 -1
- package/documentation/classes/JApplicationApi.html +8 -8
- package/documentation/classes/JArticleApi.html +1 -1
- package/documentation/classes/JAudienceApi.html +1 -1
- package/documentation/classes/JBaseApi.html +1 -1
- package/documentation/classes/JBaseObject.html +1 -1
- package/documentation/classes/JBookmark.html +1 -1
- package/documentation/classes/JBookmarkApi.html +1 -1
- package/documentation/classes/JCommunityApi.html +1 -1
- package/documentation/classes/JConcept.html +1 -1
- package/documentation/classes/JConceptApi.html +1 -1
- package/documentation/classes/JDiapazoneApi.html +1 -1
- package/documentation/classes/JFileApi.html +1 -1
- package/documentation/classes/JFilebankApi.html +1 -1
- package/documentation/classes/JGroupApi.html +1 -1
- package/documentation/classes/JLandApi.html +1 -1
- package/documentation/classes/JMessengerApi.html +1 -1
- package/documentation/classes/JSearchApi.html +6 -6
- package/documentation/classes/JUser.html +1 -1
- package/documentation/classes/JUserApi.html +3 -3
- package/documentation/classes/JWedocApi.html +1 -1
- package/documentation/classes/JamespotUserApi.html +1 -1
- package/documentation/classes/Network.html +1 -1
- package/documentation/enums/JApplicationStatus.html +1 -1
- package/documentation/index.html +1 -1
- package/documentation/interfaces/ApiError.html +1 -1
- package/documentation/interfaces/ApiWrapper.html +1 -1
- package/documentation/interfaces/AseiGroups.html +1 -1
- package/documentation/interfaces/AseiInstitution.html +1 -1
- package/documentation/interfaces/AseiRights.html +1 -1
- package/documentation/interfaces/AseiTicket.html +1 -1
- package/documentation/interfaces/BaseAutocomplete.html +1 -1
- package/documentation/interfaces/BaseMessage.html +1 -1
- package/documentation/interfaces/Category.html +1 -1
- package/documentation/interfaces/CreateGroup.html +1 -1
- package/documentation/interfaces/FileBankProps.html +1 -1
- package/documentation/interfaces/FileOption.html +1 -1
- package/documentation/interfaces/FolderProps.html +1 -1
- package/documentation/interfaces/ListFilterSpec.html +1 -1
- package/documentation/interfaces/OF.html +1 -1
- package/documentation/interfaces/PagingResults.html +1 -1
- package/documentation/interfaces/Result.html +1 -1
- package/documentation/interfaces/RootFolderProps.html +1 -1
- package/documentation/interfaces/SearchCategoryModel.html +1 -1
- package/documentation/interfaces/SearchConfig.html +1 -1
- package/documentation/interfaces/SearchFacetModel.html +1 -1
- package/documentation/interfaces/SearchFacetValueModel.html +1 -1
- package/documentation/interfaces/SearchQuery.html +1 -1
- package/documentation/interfaces/SearchQueryFilterModel.html +1 -1
- package/documentation/interfaces/SearchQueryOption.html +1 -1
- package/documentation/interfaces/SearchQueryResult.html +1 -1
- package/documentation/interfaces/SearchQuerySortModel.html +1 -1
- package/documentation/interfaces/SearchResultCatProps.html +1 -1
- package/documentation/interfaces/SearchResultProps.html +1 -1
- package/documentation/interfaces/SpotProps.html +1 -1
- package/documentation/interfaces/Taxonomy.html +1 -1
- package/documentation/interfaces/TaxonomyCreate.html +1 -1
- package/documentation/interfaces/TmpApplication.html +1 -1
- package/documentation/interfaces/TmpUser.html +1 -1
- package/documentation/interfaces/UserModel.html +1 -1
- package/documentation/modules.html +1 -1
- package/lib/jamespot-user-api.js.map +1 -1
- package/lib/src/apis/search.d.ts +2 -2
- package/lib/src/types/search.d.ts +3 -0
- package/package.json +1 -1
- package/src/apis/application.ts +0 -132
- package/src/apis/article.ts +0 -74
- package/src/apis/asei.ts +0 -73
- package/src/apis/audience.ts +0 -18
- package/src/apis/base.ts +0 -9
- package/src/apis/bookmark.ts +0 -110
- package/src/apis/community.ts +0 -20
- package/src/apis/concept.ts +0 -31
- package/src/apis/diapazone.ts +0 -65
- package/src/apis/file.ts +0 -14
- package/src/apis/filebank.ts +0 -50
- package/src/apis/group.ts +0 -48
- package/src/apis/index.ts +0 -17
- package/src/apis/jamespotUserApi.ts +0 -69
- package/src/apis/jland.ts +0 -51
- package/src/apis/messenger.ts +0 -25
- package/src/apis/search.ts +0 -85
- package/src/apis/taxonomy.ts +0 -30
- package/src/apis/user.ts +0 -53
- package/src/apis/wedoc.ts +0 -77
- package/src/classes/JApplication.ts +0 -55
- package/src/classes/JBaseObject.ts +0 -64
- package/src/classes/JBookmark.ts +0 -44
- package/src/classes/JConcept.ts +0 -3
- package/src/classes/JDiapazone.ts +0 -42
- package/src/classes/JFile.ts +0 -37
- package/src/classes/JUser.ts +0 -7
- package/src/classes/index.ts +0 -5
- package/src/index.ts +0 -21
- package/src/indexMock.ts +0 -17
- package/src/mock/data/autocomplete/audience/data.json +0 -191
- package/src/mock/data/autocomplete/community/data.json +0 -47
- package/src/mock/data/autocomplete/taxonomy/data.json +0 -35
- package/src/mock/data/autocomplete/user/data.json +0 -107
- package/src/mock/data/bookmarks/addBookmark/data.json +0 -54
- package/src/mock/data/bookmarks/addLink/data.json +0 -63
- package/src/mock/data/bookmarks/bookmarkList/data.json +0 -271
- package/src/mock/data/bookmarks/delete/data.json +0 -12
- package/src/mock/data/community/sendRequest/data.json +0 -12
- package/src/mock/data/file/create/data.json +0 -18
- package/src/mock/data/messenger/newMessage/data.json +0 -47
- package/src/mock/data/misc/tokenCSRF/data.json +0 -7
- package/src/mock/data/search/getConfig/data.json +0 -318
- package/src/mock/data/search/lastQueries/data.json +0 -7
- package/src/mock/data/search/proposition/data.json +0 -125
- package/src/mock/data/spot/create/data.json +0 -7
- package/src/mock/data/spot/get-available-widget/data.json +0 -56
- package/src/mock/data/spot/get-categories/data.json +0 -28
- package/src/mock/data/user/signIn/data.json +0 -197
- package/src/mock/windowMock.ts +0 -113
- package/src/types/asei.ts +0 -33
- package/src/types/autocomplete.ts +0 -17
- package/src/types/group.ts +0 -27
- package/src/types/index.ts +0 -7
- package/src/types/listWrapper.ts +0 -6
- package/src/types/search.ts +0 -105
- package/src/types/taxonomy.ts +0 -47
- package/src/types/user.ts +0 -14
- package/src/types/utils.ts +0 -66
- package/src/util/network.ts +0 -96
package/src/util/network.ts
DELETED
|
@@ -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
|
-
}
|