jamespot-user-api 1.0.13 → 1.0.43
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/.nojekyll +1 -0
- package/documentation/assets/highlight.css +50 -0
- package/documentation/assets/icons.css +1043 -0
- package/documentation/assets/icons.png +0 -0
- package/documentation/assets/icons@2x.png +0 -0
- package/documentation/assets/main.js +52 -0
- package/documentation/assets/search.js +1 -0
- package/documentation/assets/style.css +1413 -0
- package/documentation/assets/widgets.png +0 -0
- package/documentation/assets/widgets@2x.png +0 -0
- package/documentation/classes/JApplication.html +1 -0
- package/documentation/classes/JApplicationApi.html +30 -0
- package/documentation/classes/JArticleApi.html +1 -0
- package/documentation/classes/JAudienceApi.html +4 -0
- package/documentation/classes/JBaseApi.html +1 -0
- package/documentation/classes/JBaseObject.html +4 -0
- package/documentation/classes/JBookmark.html +1 -0
- package/documentation/classes/JBookmarkApi.html +1 -0
- package/documentation/classes/JCommunityApi.html +1 -0
- package/documentation/classes/JConcept.html +1 -0
- package/documentation/classes/JConceptApi.html +7 -0
- package/documentation/classes/JDiapazoneApi.html +1 -0
- package/documentation/classes/JFileApi.html +1 -0
- package/documentation/classes/JFilebankApi.html +1 -0
- package/documentation/classes/JGroupApi.html +12 -0
- package/documentation/classes/JLandApi.html +1 -0
- package/documentation/classes/JMessengerApi.html +1 -0
- package/documentation/classes/JSearchApi.html +18 -0
- package/documentation/classes/JUser.html +1 -0
- package/documentation/classes/JUserApi.html +17 -0
- package/documentation/classes/JWedocApi.html +1 -0
- package/documentation/classes/JamespotUserApi.html +6 -0
- package/documentation/classes/Network.html +1 -0
- package/documentation/enums/JApplicationStatus.html +1 -0
- package/documentation/index.html +79 -0
- package/documentation/interfaces/ApiError.html +1 -0
- package/documentation/interfaces/ApiWrapper.html +1 -0
- package/documentation/interfaces/AseiGroups.html +1 -0
- package/documentation/interfaces/AseiInstitution.html +1 -0
- package/documentation/interfaces/AseiRights.html +1 -0
- package/documentation/interfaces/AseiTicket.html +1 -0
- package/documentation/interfaces/BaseAutocomplete.html +1 -0
- package/documentation/interfaces/BaseMessage.html +1 -0
- package/documentation/interfaces/Category.html +1 -0
- package/documentation/interfaces/CreateGroup.html +1 -0
- package/documentation/interfaces/FileBankProps.html +1 -0
- package/documentation/interfaces/FileOption.html +1 -0
- package/documentation/interfaces/FolderProps.html +1 -0
- package/documentation/interfaces/ListFilterSpec.html +1 -0
- package/documentation/interfaces/OF.html +1 -0
- package/documentation/interfaces/PagingResults.html +1 -0
- package/documentation/interfaces/Result.html +1 -0
- package/documentation/interfaces/RootFolderProps.html +1 -0
- package/documentation/interfaces/SearchCategoryModel.html +1 -0
- package/documentation/interfaces/SearchConfig.html +1 -0
- package/documentation/interfaces/SearchFacetModel.html +1 -0
- package/documentation/interfaces/SearchFacetValueModel.html +1 -0
- package/documentation/interfaces/SearchQuery.html +1 -0
- package/documentation/interfaces/SearchQueryFilterModel.html +6 -0
- package/documentation/interfaces/SearchQueryOption.html +4 -0
- package/documentation/interfaces/SearchQueryResult.html +1 -0
- package/documentation/interfaces/SearchQuerySortModel.html +5 -0
- package/documentation/interfaces/SearchResultCatProps.html +1 -0
- package/documentation/interfaces/SearchResultProps.html +1 -0
- package/documentation/interfaces/SpotProps.html +1 -0
- package/documentation/interfaces/Taxonomy.html +1 -0
- package/documentation/interfaces/TaxonomyCreate.html +1 -0
- package/documentation/interfaces/TmpApplication.html +1 -0
- package/documentation/interfaces/TmpUser.html +1 -0
- package/documentation/interfaces/UserModel.html +1 -0
- package/documentation/modules.html +1 -0
- package/lib/jamespot-user-api.js +1 -1
- package/lib/jamespot-user-api.js.map +1 -1
- package/lib/src/apis/application.d.ts +60 -0
- package/lib/src/apis/article.d.ts +38 -0
- package/lib/src/apis/asei.d.ts +25 -0
- package/lib/src/apis/audience.d.ts +9 -0
- package/lib/src/apis/base.d.ts +5 -0
- package/lib/src/apis/bookmark.d.ts +21 -0
- package/lib/src/apis/community.d.ts +9 -0
- package/lib/src/apis/concept.d.ts +10 -0
- package/lib/src/apis/diapazone.d.ts +8 -0
- package/lib/src/apis/file.d.ts +5 -0
- package/lib/src/apis/filebank.d.ts +34 -0
- package/lib/src/apis/group.d.ts +16 -0
- package/lib/src/apis/index.d.ts +17 -0
- package/lib/src/apis/jamespotUserApi.d.ts +47 -0
- package/lib/src/apis/jland.d.ts +24 -0
- package/lib/src/apis/messenger.d.ts +6 -0
- package/lib/src/apis/search.d.ts +47 -0
- package/lib/src/apis/taxonomy.d.ts +9 -0
- package/lib/src/apis/user.d.ts +27 -0
- package/lib/src/apis/wedoc.d.ts +32 -0
- package/lib/src/classes/JApplication.d.ts +16 -0
- package/lib/src/classes/JBaseObject.d.ts +15 -0
- package/lib/src/classes/JBookmark.d.ts +16 -0
- package/lib/src/classes/JConcept.d.ts +3 -0
- package/lib/src/classes/JDiapazone.d.ts +16 -0
- package/lib/src/classes/JFile.d.ts +13 -0
- package/lib/src/classes/JUser.d.ts +4 -0
- package/lib/src/classes/index.d.ts +5 -0
- package/lib/src/index.d.ts +13 -0
- package/lib/src/indexMock.d.ts +9 -0
- package/lib/src/mock/windowMock.d.ts +9 -0
- package/lib/src/types/asei.d.ts +28 -0
- package/lib/src/types/autocomplete.d.ts +16 -0
- package/lib/src/types/group.d.ts +22 -0
- package/lib/src/types/index.d.ts +7 -0
- package/lib/src/types/listWrapper.d.ts +6 -0
- package/lib/src/types/search.d.ts +96 -0
- package/lib/src/types/taxonomy.d.ts +46 -0
- package/lib/src/types/user.d.ts +14 -0
- package/lib/src/types/utils.d.ts +56 -0
- package/lib/src/util/network.d.ts +23 -0
- package/package.json +1 -1
- package/src/apis/application.ts +132 -0
- package/src/apis/article.ts +74 -0
- package/src/apis/asei.ts +73 -0
- package/src/apis/audience.ts +18 -0
- package/src/apis/base.ts +9 -0
- package/src/apis/bookmark.ts +110 -0
- package/src/apis/community.ts +20 -0
- package/src/apis/concept.ts +31 -0
- package/src/apis/diapazone.ts +65 -0
- package/src/apis/file.ts +14 -0
- package/src/apis/filebank.ts +50 -0
- package/src/apis/group.ts +48 -0
- package/src/apis/index.ts +17 -0
- package/src/apis/jamespotUserApi.ts +69 -0
- package/src/apis/jland.ts +51 -0
- package/src/apis/messenger.ts +25 -0
- package/src/apis/search.ts +85 -0
- package/src/apis/taxonomy.ts +30 -0
- package/src/apis/user.ts +53 -0
- package/src/apis/wedoc.ts +77 -0
- package/src/classes/JApplication.ts +55 -0
- package/src/classes/JBaseObject.ts +64 -0
- package/src/classes/JBookmark.ts +44 -0
- package/src/classes/JConcept.ts +3 -0
- package/src/classes/JDiapazone.ts +42 -0
- package/src/classes/JFile.ts +37 -0
- package/src/classes/JUser.ts +7 -0
- package/src/classes/index.ts +5 -0
- package/src/index.ts +21 -0
- package/src/indexMock.ts +17 -0
- package/src/mock/data/autocomplete/audience/data.json +191 -0
- package/src/mock/data/autocomplete/community/data.json +47 -0
- package/src/mock/data/autocomplete/taxonomy/data.json +35 -0
- package/src/mock/data/autocomplete/user/data.json +107 -0
- package/src/mock/data/bookmarks/addBookmark/data.json +54 -0
- package/src/mock/data/bookmarks/addLink/data.json +63 -0
- package/src/mock/data/bookmarks/bookmarkList/data.json +271 -0
- package/src/mock/data/bookmarks/delete/data.json +12 -0
- package/src/mock/data/community/sendRequest/data.json +12 -0
- package/src/mock/data/file/create/data.json +18 -0
- package/src/mock/data/messenger/newMessage/data.json +47 -0
- package/src/mock/data/misc/tokenCSRF/data.json +7 -0
- package/src/mock/data/search/getConfig/data.json +318 -0
- package/src/mock/data/search/lastQueries/data.json +7 -0
- package/src/mock/data/search/proposition/data.json +125 -0
- package/src/mock/data/spot/create/data.json +7 -0
- package/src/mock/data/spot/get-available-widget/data.json +56 -0
- package/src/mock/data/spot/get-categories/data.json +28 -0
- package/src/mock/data/user/signIn/data.json +197 -0
- package/src/mock/windowMock.ts +113 -0
- package/src/types/asei.ts +33 -0
- package/src/types/autocomplete.ts +17 -0
- package/src/types/group.ts +27 -0
- package/src/types/index.ts +7 -0
- package/src/types/listWrapper.ts +6 -0
- package/src/types/search.ts +105 -0
- package/src/types/taxonomy.ts +47 -0
- package/src/types/user.ts +14 -0
- package/src/types/utils.ts +66 -0
- package/src/util/network.ts +96 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { JApplication, JApplicationStatus } from '../classes';
|
|
2
|
+
import { ApiWrapper, BaseMessages } from '../types';
|
|
3
|
+
import { JBaseApi } from './base';
|
|
4
|
+
import { OF } from '../util/network';
|
|
5
|
+
|
|
6
|
+
export interface TmpApplication {
|
|
7
|
+
idApp: string;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class JApplicationApi extends JBaseApi {
|
|
12
|
+
/**
|
|
13
|
+
* List applications
|
|
14
|
+
* @returns {@link JApplication} objects, in light format
|
|
15
|
+
*/
|
|
16
|
+
public list(): Promise<JApplication[]> {
|
|
17
|
+
return this.network.post<Array<TmpApplication>, BaseMessages>({ o: 'studio', f: 'list' }).then((res) => {
|
|
18
|
+
if (Array.isArray(res.result)) {
|
|
19
|
+
return res.result.map((entry) => {
|
|
20
|
+
const nApp = new JApplication(entry.idApp);
|
|
21
|
+
nApp.hydrate(entry);
|
|
22
|
+
return nApp;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
throw 'Bad response from backend';
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private stdCall<T extends OF = OF>(parameters: T): Promise<JApplication> {
|
|
30
|
+
return this.network.post<TmpApplication, BaseMessages>(parameters).then((res) => {
|
|
31
|
+
const jApplication = new JApplication(res.result.idApp);
|
|
32
|
+
jApplication.hydrate(res.result);
|
|
33
|
+
return jApplication;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private stdCSRFCall<T extends OF = OF>(parameters: T): Promise<JApplication> {
|
|
38
|
+
return this.network.postCSRF<TmpApplication, BaseMessages>(parameters).then((res) => {
|
|
39
|
+
const jApplication = new JApplication(res.result.idApp);
|
|
40
|
+
jApplication.hydrate(res.result);
|
|
41
|
+
return jApplication;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get one application
|
|
47
|
+
* @returns {@link JApplication} object in full format
|
|
48
|
+
*/
|
|
49
|
+
public get(idApp: string, status?: JApplicationStatus): Promise<JApplication> {
|
|
50
|
+
return this.stdCall({ o: 'studio', f: 'get', idApp, status });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Install this application.
|
|
55
|
+
* If everything is ok, remove previous saved and autosaved versions of this application.
|
|
56
|
+
* @param xmlBody: string XML file
|
|
57
|
+
* @returns {@link JApplication} object in full format
|
|
58
|
+
*/
|
|
59
|
+
public install(xmlBody: string): Promise<JApplication> {
|
|
60
|
+
return this.stdCSRFCall({ o: 'studio', f: 'install', value: xmlBody });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Suspend an installed application.
|
|
65
|
+
* @param idApp: application's id
|
|
66
|
+
* @returns {@link JApplication} object in full format
|
|
67
|
+
*/
|
|
68
|
+
public suspend(idApp: string): Promise<JApplication> {
|
|
69
|
+
return this.stdCSRFCall({ o: 'studio', f: 'suspend', idApp });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Restart an suspended application.
|
|
74
|
+
* @param idApp: application's id
|
|
75
|
+
* @returns {@link JApplication} object in full format
|
|
76
|
+
*/
|
|
77
|
+
public restart(idApp: string): Promise<JApplication> {
|
|
78
|
+
return this.stdCSRFCall({ o: 'studio', f: 'restart', idApp });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Save a 'local', 'saved' or 'autosaved' version of the application
|
|
83
|
+
* Returns a 'save' or 'autosaved' application.
|
|
84
|
+
* @param idApp: application's id
|
|
85
|
+
* @param value: data to be saved
|
|
86
|
+
* @param status: must be either 'saved' or 'autosaved'.
|
|
87
|
+
* @returns {@link JApplication} object in full format
|
|
88
|
+
*/
|
|
89
|
+
public save(idApp: string, value: string, status: JApplicationStatus): Promise<JApplication> {
|
|
90
|
+
if (status === JApplicationStatus.saved || status === JApplicationStatus.autosaved) {
|
|
91
|
+
return this.stdCSRFCall({
|
|
92
|
+
o: 'studio',
|
|
93
|
+
f: 'save',
|
|
94
|
+
idApp,
|
|
95
|
+
value,
|
|
96
|
+
status,
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
throw 'Invalid status value';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Delete a selected status of the application
|
|
105
|
+
* @param idApp application id to delete
|
|
106
|
+
* @param status application status to select
|
|
107
|
+
* @returns message after delete execution
|
|
108
|
+
*/
|
|
109
|
+
public async delete(idApp: string, status: JApplicationStatus): Promise<Array<string>> {
|
|
110
|
+
return this.network
|
|
111
|
+
.postCSRF<string>({
|
|
112
|
+
o: 'studio',
|
|
113
|
+
f: 'delete',
|
|
114
|
+
idApp,
|
|
115
|
+
status,
|
|
116
|
+
} as OF)
|
|
117
|
+
.then((res) => {
|
|
118
|
+
if (res.error === 0) {
|
|
119
|
+
return res.messages;
|
|
120
|
+
} else {
|
|
121
|
+
throw res.messages;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get cssClass possible values.
|
|
128
|
+
*/
|
|
129
|
+
public cssClassList(): Promise<ApiWrapper<Array<string>>> {
|
|
130
|
+
return this.network.post<Array<string>>({ o: 'studio', f: 'icons' });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { JBaseApi } from './base';
|
|
2
|
+
import { ApiWrapper, BaseMessages, Filters, Little, Orders, PagingResults } from '../types';
|
|
3
|
+
import { OF } from '../util/network';
|
|
4
|
+
|
|
5
|
+
export type ArticleListConfig = {
|
|
6
|
+
type: string;
|
|
7
|
+
format: string;
|
|
8
|
+
query?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
page?: number;
|
|
11
|
+
orders?: Orders;
|
|
12
|
+
filters?: Filters;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ArticleGetConfig = {
|
|
16
|
+
uri?: string;
|
|
17
|
+
idArticle?: number;
|
|
18
|
+
format?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type ArticleCreation = {
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type BaseArticle = {
|
|
27
|
+
id: number;
|
|
28
|
+
type: string;
|
|
29
|
+
dateCreation: string;
|
|
30
|
+
dateModified: string;
|
|
31
|
+
title: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export class JArticleApi extends JBaseApi {
|
|
35
|
+
public list(config: ArticleListConfig): Promise<ApiWrapper<PagingResults<{ title: string }>>> {
|
|
36
|
+
return this.network.post({
|
|
37
|
+
o: 'ObjectListJamespot',
|
|
38
|
+
f: 'ArticleQueryList',
|
|
39
|
+
...config,
|
|
40
|
+
} as OF);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public get<T extends Little = Little>(config: ArticleGetConfig): Promise<ApiWrapper<T>> {
|
|
44
|
+
return this.network.post({
|
|
45
|
+
o: 'article',
|
|
46
|
+
f: 'get',
|
|
47
|
+
...config,
|
|
48
|
+
} as OF);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public create<T>(article: ArticleCreation): Promise<ApiWrapper<BaseArticle & T>> {
|
|
52
|
+
return this.network.post({
|
|
53
|
+
o: 'article',
|
|
54
|
+
f: 'create',
|
|
55
|
+
...article,
|
|
56
|
+
} as OF);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public update<T extends { uri: string }>(article: T): Promise<ApiWrapper<never, BaseMessages>> {
|
|
60
|
+
return this.network.post({
|
|
61
|
+
o: 'article',
|
|
62
|
+
f: 'update',
|
|
63
|
+
...article,
|
|
64
|
+
} as OF);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public count(type: string): Promise<ApiWrapper<number>> {
|
|
68
|
+
return this.network.post({
|
|
69
|
+
o: 'article',
|
|
70
|
+
f: 'count',
|
|
71
|
+
type,
|
|
72
|
+
} as OF);
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/apis/asei.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { JBaseApi } from './base';
|
|
2
|
+
import { OF } from '../util/network';
|
|
3
|
+
import { AseiGroups, AseiRights, AseiTicket, AseiTicketStatus, Filters, Orders } from '../types';
|
|
4
|
+
import { JArticleApi } from './article';
|
|
5
|
+
import { ApiWrapper, PagingResults } from '../types';
|
|
6
|
+
|
|
7
|
+
export class JAseiApi extends JBaseApi {
|
|
8
|
+
/**
|
|
9
|
+
* List Asei Clearance Tickets
|
|
10
|
+
* @param page page number
|
|
11
|
+
* @param limit number of elements per page
|
|
12
|
+
* @param filters filter object
|
|
13
|
+
* @param orders order object
|
|
14
|
+
*/
|
|
15
|
+
public list(
|
|
16
|
+
page: number,
|
|
17
|
+
limit: number,
|
|
18
|
+
filters?: Filters,
|
|
19
|
+
orders: Orders = [{ name: 'dateCreation', sort: 'DESC' }],
|
|
20
|
+
): Promise<ApiWrapper<PagingResults<AseiTicket>>> {
|
|
21
|
+
const articleApi = new JArticleApi(this.network);
|
|
22
|
+
return articleApi.list({
|
|
23
|
+
type: 'aseiClearanceTicket',
|
|
24
|
+
format: 'raw-view',
|
|
25
|
+
limit,
|
|
26
|
+
page,
|
|
27
|
+
orders,
|
|
28
|
+
filters,
|
|
29
|
+
}) as Promise<ApiWrapper<PagingResults<AseiTicket>>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* change status of an Asei Ticket
|
|
34
|
+
*/
|
|
35
|
+
public requestStatus(
|
|
36
|
+
uri: string,
|
|
37
|
+
requestedStatus: AseiTicketStatus,
|
|
38
|
+
audience?: Array<string>,
|
|
39
|
+
): Promise<AseiTicket> {
|
|
40
|
+
return this.network
|
|
41
|
+
.post<AseiTicket>({ o: 'asei', f: 'setStatus', uri, requestedStatus, audience } as OF)
|
|
42
|
+
.then((res) => {
|
|
43
|
+
if (res && res.result) {
|
|
44
|
+
return res.result;
|
|
45
|
+
}
|
|
46
|
+
throw 'Bad response from backend';
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get asei dedicated groups (dsi, administrators)
|
|
52
|
+
*/
|
|
53
|
+
public getDedicatedGroups(): Promise<AseiGroups> {
|
|
54
|
+
return this.network.post<AseiGroups>({ o: 'asei', f: 'getDedicatedGroups' } as OF).then((res) => {
|
|
55
|
+
if (res && res.result) {
|
|
56
|
+
return res.result;
|
|
57
|
+
}
|
|
58
|
+
throw 'Bad response from backend';
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get asei configuration (rights to access, rights to publish)
|
|
64
|
+
*/
|
|
65
|
+
public getConfiguration(): Promise<AseiRights> {
|
|
66
|
+
return this.network.post<{ right: AseiRights }>({ o: 'asei', f: 'configuration' }).then((res) => {
|
|
67
|
+
if (res && res.result) {
|
|
68
|
+
return res.result.right;
|
|
69
|
+
}
|
|
70
|
+
throw 'Bad response from backend';
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AudienceAutocomplete } from '../types/autocomplete';
|
|
2
|
+
import { JBaseApi } from './base';
|
|
3
|
+
import { OF } from '../util/network';
|
|
4
|
+
|
|
5
|
+
export class JAudienceApi extends JBaseApi {
|
|
6
|
+
/**
|
|
7
|
+
* autocomplete
|
|
8
|
+
* return the list of user and Spot
|
|
9
|
+
*/
|
|
10
|
+
public autocomplete(query: string): Promise<AudienceAutocomplete[]> {
|
|
11
|
+
return this.network.post({ o: 'autocomplete', f: 'audience', q: query } as OF).then((res) => {
|
|
12
|
+
if (Array.isArray(res.result)) {
|
|
13
|
+
return res.result;
|
|
14
|
+
}
|
|
15
|
+
throw 'Bad response from backend';
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/apis/base.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ApiWrapper, BaseMessagesOne } from '../types';
|
|
2
|
+
import { JBaseApi } from './base';
|
|
3
|
+
import { JBookmark } from '../classes/JBookmark';
|
|
4
|
+
import { ListWrapper } from '../types/listWrapper';
|
|
5
|
+
import { OF } from '../util/network';
|
|
6
|
+
|
|
7
|
+
export interface ListFilterSpec {
|
|
8
|
+
query?: string;
|
|
9
|
+
page?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
orders?: {
|
|
12
|
+
name: string;
|
|
13
|
+
sort: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Bookmark = Record<string, object>;
|
|
18
|
+
|
|
19
|
+
type BookmarkList = {
|
|
20
|
+
page: number;
|
|
21
|
+
cnt: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
data: Bookmark[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export class JBookmarkApi extends JBaseApi {
|
|
27
|
+
public getList(filterSpecs: ListFilterSpec): Promise<ListWrapper<JBookmark>> {
|
|
28
|
+
return this.network
|
|
29
|
+
.post<BookmarkList>({
|
|
30
|
+
o: 'object',
|
|
31
|
+
f: 'list',
|
|
32
|
+
namespace: 'bookmarks',
|
|
33
|
+
view: 'list',
|
|
34
|
+
...filterSpecs,
|
|
35
|
+
} as OF)
|
|
36
|
+
.then((res) => {
|
|
37
|
+
const result = res.result;
|
|
38
|
+
|
|
39
|
+
if (Array.isArray(result.data)) {
|
|
40
|
+
const data: JBookmark[] = result.data.map((entry) => JBookmark.createFromObject(entry));
|
|
41
|
+
return { page: result.page, cnt: result.cnt, limit: result.limit, data };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
throw {
|
|
45
|
+
error: res.error,
|
|
46
|
+
messages: res.messages,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public addLink(targetId: number, targetType: string): Promise<JBookmark> {
|
|
52
|
+
return this.network
|
|
53
|
+
.post<Bookmark>({
|
|
54
|
+
o: 'custom',
|
|
55
|
+
f: 'actionAdd',
|
|
56
|
+
type: 'bookmarkLink',
|
|
57
|
+
targetId,
|
|
58
|
+
targetType,
|
|
59
|
+
format: 'list',
|
|
60
|
+
} as OF)
|
|
61
|
+
.then((res) => {
|
|
62
|
+
const result = res.result;
|
|
63
|
+
return JBookmark.createFromObject(result);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public addBookmark(bookmark: JBookmark): Promise<JBookmark> {
|
|
68
|
+
return this.network
|
|
69
|
+
.postCSRF<Bookmark, BaseMessagesOne>({
|
|
70
|
+
o: 'bookmarks',
|
|
71
|
+
f: 'add',
|
|
72
|
+
...bookmark,
|
|
73
|
+
} as OF)
|
|
74
|
+
.then((res) => {
|
|
75
|
+
const result = res.result;
|
|
76
|
+
return JBookmark.createFromObject(result);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public delete(bookmark: JBookmark): Promise<ApiWrapper<null, BaseMessagesOne>> {
|
|
81
|
+
return this.network.postCSRF<null, BaseMessagesOne>({
|
|
82
|
+
o: 'bookmarks',
|
|
83
|
+
f: 'delete',
|
|
84
|
+
bookmarkID: bookmark.id,
|
|
85
|
+
} as OF);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public rename(bookmark: JBookmark): Promise<ApiWrapper<null, BaseMessagesOne>> {
|
|
89
|
+
return this.network.postCSRF<null, BaseMessagesOne>({
|
|
90
|
+
o: 'bookmarks',
|
|
91
|
+
f: 'rename',
|
|
92
|
+
bookmarkID: bookmark.id,
|
|
93
|
+
bookmarkLabel: bookmark.bookmarkLabel,
|
|
94
|
+
} as OF);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public move(
|
|
98
|
+
bookmark: JBookmark,
|
|
99
|
+
bookmarkReference: JBookmark,
|
|
100
|
+
position: 'before' | 'after',
|
|
101
|
+
): Promise<ApiWrapper<null, BaseMessagesOne>> {
|
|
102
|
+
return this.network.postCSRF<null, BaseMessagesOne>({
|
|
103
|
+
o: 'bookmarks',
|
|
104
|
+
f: 'move',
|
|
105
|
+
bookmarkID: bookmark.id,
|
|
106
|
+
bookmarkReference: bookmarkReference.id,
|
|
107
|
+
bookmarkPosition: position,
|
|
108
|
+
} as OF);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiWrapper, CommunityAutocomplete } from '../types';
|
|
2
|
+
import { JBaseApi } from './base';
|
|
3
|
+
import { OF } from '../util/network';
|
|
4
|
+
|
|
5
|
+
export class JCommunityApi extends JBaseApi {
|
|
6
|
+
public sendRequest(message: string, idUserTo: number): Promise<ApiWrapper<boolean, { code: number; msg: string }>> {
|
|
7
|
+
return this.network.post<boolean, { code: number; msg: string }>({
|
|
8
|
+
o: 'community',
|
|
9
|
+
f: 'sendRequest',
|
|
10
|
+
message,
|
|
11
|
+
idUserTo,
|
|
12
|
+
} as OF);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public autocomplete(q: string): Promise<CommunityAutocomplete[]> {
|
|
16
|
+
return this.network
|
|
17
|
+
.post<CommunityAutocomplete[]>({ o: 'autocomplete', f: 'community', q } as OF)
|
|
18
|
+
.then((res) => res.result);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { JBaseApi } from './base';
|
|
2
|
+
import { JConcept } from '../classes';
|
|
3
|
+
import { OF } from '../util/network';
|
|
4
|
+
|
|
5
|
+
export class JConceptApi extends JBaseApi {
|
|
6
|
+
/**
|
|
7
|
+
* autocomplete return a list of tags
|
|
8
|
+
* @param idTaxonomy taxonomy id
|
|
9
|
+
* @param query search characters
|
|
10
|
+
*/
|
|
11
|
+
public autocomplete(idTaxonomy: string, query: string): Promise<JConcept[]> {
|
|
12
|
+
return this.network
|
|
13
|
+
.post<Array<{ id: string; type: string }>>({
|
|
14
|
+
o: 'autocomplete',
|
|
15
|
+
f: 'taxonomy',
|
|
16
|
+
q: query,
|
|
17
|
+
idTaxonomy,
|
|
18
|
+
idToUri: false,
|
|
19
|
+
} as OF)
|
|
20
|
+
.then((res) => {
|
|
21
|
+
if (Array.isArray(res.result)) {
|
|
22
|
+
return res.result.map((concept) => {
|
|
23
|
+
const jConcept = new JConcept(concept.id, concept.type);
|
|
24
|
+
jConcept.hydrate(concept);
|
|
25
|
+
return jConcept;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
throw 'Bad response from backend';
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { JBaseApi } from './base';
|
|
2
|
+
import { ListWrapper } from '../types/listWrapper';
|
|
3
|
+
import { ApiWrapper } from '../types';
|
|
4
|
+
import { OF } from '../util/network';
|
|
5
|
+
|
|
6
|
+
import { JDiapazone } from '../classes/JDiapazone';
|
|
7
|
+
|
|
8
|
+
type Diapazone = Record<string, object>;
|
|
9
|
+
|
|
10
|
+
type DiapazoneList = {
|
|
11
|
+
page: number;
|
|
12
|
+
cnt: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
data: Diapazone[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class JDiapazoneApi extends JBaseApi {
|
|
18
|
+
public create(
|
|
19
|
+
type: string,
|
|
20
|
+
token: string,
|
|
21
|
+
title: string,
|
|
22
|
+
dateStart: string,
|
|
23
|
+
publishTo: Array<any>,
|
|
24
|
+
): Promise<ApiWrapper<string>> {
|
|
25
|
+
return this.network.post({
|
|
26
|
+
o: 'article',
|
|
27
|
+
f: 'create',
|
|
28
|
+
type,
|
|
29
|
+
token,
|
|
30
|
+
title,
|
|
31
|
+
dateStart,
|
|
32
|
+
publishTo,
|
|
33
|
+
} as OF);
|
|
34
|
+
}
|
|
35
|
+
public getList(
|
|
36
|
+
query = '',
|
|
37
|
+
filters: Array<any> = [],
|
|
38
|
+
orders: Array<any> = [],
|
|
39
|
+
page = 1,
|
|
40
|
+
format = 'list',
|
|
41
|
+
): Promise<ListWrapper<JDiapazone>> {
|
|
42
|
+
return this.network
|
|
43
|
+
.post<DiapazoneList>({
|
|
44
|
+
o: 'objectList',
|
|
45
|
+
f: 'diapazoneQueryList',
|
|
46
|
+
query,
|
|
47
|
+
filters,
|
|
48
|
+
orders,
|
|
49
|
+
page,
|
|
50
|
+
format,
|
|
51
|
+
} as OF)
|
|
52
|
+
.then((res) => {
|
|
53
|
+
const result = res.result;
|
|
54
|
+
if (Array.isArray(result.data)) {
|
|
55
|
+
const data: JDiapazone[] = result.data.map((entry) => JDiapazone.createFromObject(entry));
|
|
56
|
+
return { page: result.page, cnt: result.cnt, limit: result.limit, data };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
throw {
|
|
60
|
+
error: res.error,
|
|
61
|
+
messages: res.messages,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/apis/file.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FileOption } from '../util/network';
|
|
2
|
+
import { JBaseApi } from './base';
|
|
3
|
+
|
|
4
|
+
export class JFileApi extends JBaseApi {
|
|
5
|
+
// FIXME when doing the first file upload
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
public create(token: string, attrName: 'attachment' | 'image', file: File, options: FileOption): Promise<any> {
|
|
8
|
+
const body = new FormData();
|
|
9
|
+
body.append('token', token);
|
|
10
|
+
body.append('attrName', attrName);
|
|
11
|
+
body.append(attrName, file);
|
|
12
|
+
return this.network.postFile(body, options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { JBaseApi } from './base';
|
|
2
|
+
import { OF } from '../util/network';
|
|
3
|
+
import { ListWrapper } from '../types/listWrapper';
|
|
4
|
+
import { Little, Rights } from '../types';
|
|
5
|
+
|
|
6
|
+
export interface RootFolderProps {
|
|
7
|
+
id: number;
|
|
8
|
+
title: string;
|
|
9
|
+
uri: string;
|
|
10
|
+
type: string;
|
|
11
|
+
mainType: string;
|
|
12
|
+
folderColor?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SpotProps {
|
|
16
|
+
id: number;
|
|
17
|
+
title: string;
|
|
18
|
+
uri: string;
|
|
19
|
+
type: string;
|
|
20
|
+
mainType: string;
|
|
21
|
+
folderColor?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FileBankProps {
|
|
25
|
+
recents: any[];
|
|
26
|
+
rootFolder: RootFolderProps;
|
|
27
|
+
spot: SpotProps;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FolderProps extends Little {
|
|
31
|
+
mainType: string;
|
|
32
|
+
folderColor?: string;
|
|
33
|
+
parentURI?: string;
|
|
34
|
+
_right: Rights;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class JFilebankApi extends JBaseApi {
|
|
38
|
+
public getBanks(format = 'list'): Promise<Array<FileBankProps>> {
|
|
39
|
+
return this.network.post<Array<FileBankProps>>({ o: 'fileBank', f: 'getBanks', format } as OF).then((res) => {
|
|
40
|
+
return res.result;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
public getFolders(parentURI: string): Promise<ListWrapper<FolderProps>> {
|
|
44
|
+
return this.network
|
|
45
|
+
.post<Array<FolderProps>>({ o: 'fileBank', f: 'getFolders', parentURI } as OF)
|
|
46
|
+
.then((res) => {
|
|
47
|
+
return { data: res.result };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ApiWrapper, Category, CreateGroup, GroupWidgets, Little, PagingResults } from '../types';
|
|
2
|
+
import { JBaseApi } from './base';
|
|
3
|
+
import { OF } from '../util/network';
|
|
4
|
+
|
|
5
|
+
export class JGroupApi extends JBaseApi {
|
|
6
|
+
public create({ type, widgets, ...group }: CreateGroup): Promise<ApiWrapper<string>> {
|
|
7
|
+
return this.network.post({
|
|
8
|
+
o: 'spot',
|
|
9
|
+
f: 'create',
|
|
10
|
+
...group,
|
|
11
|
+
type: type || 'spot',
|
|
12
|
+
widgets: JSON.stringify(widgets),
|
|
13
|
+
} as OF);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public getApplications(): Promise<ApiWrapper<GroupWidgets>> {
|
|
17
|
+
return this.network.post({ o: 'spot', f: 'get-available-widget' });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public getCategories(): Promise<ApiWrapper<Category[]>> {
|
|
21
|
+
return this.network.post<Category[]>({ o: 'spot', f: 'get-categories' });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the members of a group
|
|
26
|
+
* @param idSpot spot id
|
|
27
|
+
* @param query query string to search within user names
|
|
28
|
+
* @param limit limit per page
|
|
29
|
+
* @param page page number
|
|
30
|
+
* @return array of User
|
|
31
|
+
*/
|
|
32
|
+
public getObjectListJamespotSpotMembers(
|
|
33
|
+
idSpot: number | string,
|
|
34
|
+
query?: string,
|
|
35
|
+
limit?: number,
|
|
36
|
+
page = 1,
|
|
37
|
+
): Promise<ApiWrapper<PagingResults<Little>>> {
|
|
38
|
+
return this.network.post<PagingResults<Little>>({
|
|
39
|
+
o: 'objectListJamespot',
|
|
40
|
+
f: 'SpotMembers',
|
|
41
|
+
idSpot,
|
|
42
|
+
limit,
|
|
43
|
+
page,
|
|
44
|
+
format: 'raw-little',
|
|
45
|
+
query,
|
|
46
|
+
} as OF);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './application';
|
|
2
|
+
export * from './article';
|
|
3
|
+
export * from './audience';
|
|
4
|
+
export * from './base';
|
|
5
|
+
export * from './community';
|
|
6
|
+
export * from './concept';
|
|
7
|
+
export * from './file';
|
|
8
|
+
export * from './filebank';
|
|
9
|
+
export * from './group';
|
|
10
|
+
export * from './jamespotUserApi';
|
|
11
|
+
export * from './jland';
|
|
12
|
+
export * from './messenger';
|
|
13
|
+
export * from './search';
|
|
14
|
+
export * from './bookmark';
|
|
15
|
+
export * from './user';
|
|
16
|
+
export * from './diapazone';
|
|
17
|
+
export * from './wedoc';
|