@serptech/api 1.0.0
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/LICENSE.md +21 -0
- package/Makefile +12 -0
- package/README.md +39 -0
- package/dist/SerpApi.node.js +65 -0
- package/dist/SerpApi.web.js +65 -0
- package/eslint.config.mjs +51 -0
- package/mychange.diff +50452 -0
- package/package.json +62 -0
- package/packages/serp-rest-api/LICENSE.md +21 -0
- package/packages/serp-rest-api/README.md +30 -0
- package/packages/serp-rest-api/dist/index.node.js +1752 -0
- package/packages/serp-rest-api/dist/index.web.js +1282 -0
- package/packages/serp-rest-api/package.json +59 -0
- package/packages/serp-rest-api/src/base/api.ts +15 -0
- package/packages/serp-rest-api/src/base/auth-api.ts +25 -0
- package/packages/serp-rest-api/src/base/types.ts +33 -0
- package/packages/serp-rest-api/src/constants/index.js +13 -0
- package/packages/serp-rest-api/src/http-client.ts +207 -0
- package/packages/serp-rest-api/src/index.ts +3 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/auth/index.ts +50 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/base.ts +58 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/entries/index.ts +87 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/index.ts +106 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/licenses/index.ts +28 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/notifications/index.ts +40 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/persons/index.ts +60 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/persons-groups/index.ts +54 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/sources/index.ts +46 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/spaces/index.ts +27 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/stream-tokens/index.ts +37 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/thresholds/index.ts +17 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/tokens/index.ts +32 -0
- package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/utilities/index.ts +82 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/auth/v1/index.ts +58 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/entries/v1/index.ts +70 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/licenses/v1/index.ts +82 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/notifications/v1/index.ts +100 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/persons/v1/index.ts +110 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/persons-groups/v1/index.ts +128 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/sources/v1/index.ts +113 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/spaces/v1/index.ts +65 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/stream-tokens/v1/index.ts +76 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/thresholds/v1/index.ts +32 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/tokens/v1/index.ts +61 -0
- package/packages/serp-rest-api/src/serp-rest-api/features/utilities/v1/index.ts +114 -0
- package/packages/serp-rest-api/src/serp-rest-api/index.ts +82 -0
- package/packages/serp-rest-api/src/utils/data.ts +13 -0
- package/packages/serp-rest-api/src/utils/files.ts +83 -0
- package/packages/serp-rest-api/src/utils/index.ts +2 -0
- package/packages/serp-websocket/LICENSE.md +21 -0
- package/packages/serp-websocket/README.md +32 -0
- package/packages/serp-websocket/dist/index.node.js +400 -0
- package/packages/serp-websocket/dist/index.web.js +158 -0
- package/packages/serp-websocket/package.json +60 -0
- package/packages/serp-websocket/src/constants/index.ts +7 -0
- package/packages/serp-websocket/src/index.ts +43 -0
- package/packages/serp-websocket/src/v1/index.ts +183 -0
- package/src/index.js +7 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
import { id } from "../../../../base/types";
|
3
|
+
|
4
|
+
import {
|
5
|
+
NotificationsInterface,
|
6
|
+
NotificationInterface,
|
7
|
+
NotificationsFiltersInterface,
|
8
|
+
} from "../../../api-facade/v1/notifications";
|
9
|
+
|
10
|
+
class Notifications extends Api implements NotificationsInterface {
|
11
|
+
constructor(settings: ApiSettingsInterface) {
|
12
|
+
super(settings);
|
13
|
+
this.getNotifications = this.getNotifications.bind(this);
|
14
|
+
this.getNotification = this.getNotification.bind(this);
|
15
|
+
this.createNotification = this.createNotification.bind(this);
|
16
|
+
this.updateNotification = this.updateNotification.bind(this);
|
17
|
+
this.deleteNotification = this.deleteNotification.bind(this);
|
18
|
+
}
|
19
|
+
|
20
|
+
static apiEndpoint = "notifications/";
|
21
|
+
|
22
|
+
static getNotificationData = ({
|
23
|
+
name,
|
24
|
+
is_active,
|
25
|
+
http_method,
|
26
|
+
destination_url,
|
27
|
+
results,
|
28
|
+
age_from,
|
29
|
+
age_to,
|
30
|
+
sex,
|
31
|
+
moods,
|
32
|
+
sources,
|
33
|
+
persons_groups,
|
34
|
+
liveness,
|
35
|
+
}: NotificationInterface = {}): {} => ({
|
36
|
+
name,
|
37
|
+
is_active,
|
38
|
+
http_method,
|
39
|
+
destination_url,
|
40
|
+
results,
|
41
|
+
age_from,
|
42
|
+
age_to,
|
43
|
+
sex,
|
44
|
+
moods,
|
45
|
+
sources,
|
46
|
+
persons_groups,
|
47
|
+
liveness,
|
48
|
+
});
|
49
|
+
|
50
|
+
getNotifications(filters: NotificationsFiltersInterface = {}): Promise<null> {
|
51
|
+
const getFiltersData = ({
|
52
|
+
q,
|
53
|
+
limit,
|
54
|
+
offset,
|
55
|
+
spaces_ids,
|
56
|
+
}: NotificationsFiltersInterface): {} => ({
|
57
|
+
q,
|
58
|
+
limit,
|
59
|
+
offset,
|
60
|
+
spaces_ids,
|
61
|
+
});
|
62
|
+
|
63
|
+
return this.httpClient.get(
|
64
|
+
Notifications.apiEndpoint,
|
65
|
+
getFiltersData(filters)
|
66
|
+
);
|
67
|
+
}
|
68
|
+
|
69
|
+
getNotification(notificationId: id): Promise<NotificationInterface> {
|
70
|
+
return this.httpClient.get(
|
71
|
+
`${Notifications.apiEndpoint}${notificationId}/`
|
72
|
+
);
|
73
|
+
}
|
74
|
+
|
75
|
+
createNotification(
|
76
|
+
data: NotificationInterface
|
77
|
+
): Promise<NotificationInterface> {
|
78
|
+
return this.httpClient.post(
|
79
|
+
Notifications.apiEndpoint,
|
80
|
+
Notifications.getNotificationData(data)
|
81
|
+
);
|
82
|
+
}
|
83
|
+
|
84
|
+
updateNotification({ id, ...restData }: NotificationInterface = {}): Promise<
|
85
|
+
NotificationInterface
|
86
|
+
> {
|
87
|
+
return this.httpClient.put(
|
88
|
+
`${Notifications.apiEndpoint}${id}/`,
|
89
|
+
Notifications.getNotificationData(restData)
|
90
|
+
);
|
91
|
+
}
|
92
|
+
|
93
|
+
deleteNotification(notificationId: id): Promise<null> {
|
94
|
+
return this.httpClient.delete(
|
95
|
+
`${Notifications.apiEndpoint}${notificationId}/`
|
96
|
+
);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
export { Notifications };
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
|
3
|
+
import { addFileToFormData, addDataToFormData } from "../../../../utils";
|
4
|
+
import {
|
5
|
+
SearchPersonByImageParamsInterface,
|
6
|
+
PersonsInterface,
|
7
|
+
CreatePersonParamsInterface,
|
8
|
+
// ReinitializePersonByEntryParamsInterface,
|
9
|
+
ReinitializePersonByImageParamsInterface,
|
10
|
+
// CreatePersonFromEntryParamsInterface,
|
11
|
+
PersonResponseIterface,
|
12
|
+
} from "../../../api-facade/v1/persons";
|
13
|
+
|
14
|
+
class Persons extends Api implements PersonsInterface {
|
15
|
+
constructor(settings: ApiSettingsInterface) {
|
16
|
+
super(settings);
|
17
|
+
this.searchPersonByImage = this.searchPersonByImage.bind(this);
|
18
|
+
this.createPerson = this.createPerson.bind(this);
|
19
|
+
// this.createPersonFromEntry = this.createPersonFromEntry.bind(this);
|
20
|
+
this.deletePerson = this.deletePerson.bind(this);
|
21
|
+
// this.reinitializePersonByEntry = this.reinitializePersonByEntry.bind(this);
|
22
|
+
this.reinitializePersonByImage = this.reinitializePersonByImage.bind(this);
|
23
|
+
}
|
24
|
+
|
25
|
+
static apiEndpoint = "profiles/";
|
26
|
+
|
27
|
+
searchPersonByImage({
|
28
|
+
image,
|
29
|
+
identify_asm,
|
30
|
+
}: SearchPersonByImageParamsInterface): Promise<PersonResponseIterface> {
|
31
|
+
if (!image) return Promise.reject("No image provided");
|
32
|
+
|
33
|
+
const fieldsData = { identify_asm };
|
34
|
+
const data = new FormData();
|
35
|
+
|
36
|
+
addFileToFormData(data, image, "image");
|
37
|
+
addDataToFormData(data, fieldsData);
|
38
|
+
|
39
|
+
return this.httpClient.post(`${Persons.apiEndpoint}search/`, data);
|
40
|
+
}
|
41
|
+
|
42
|
+
createPerson({
|
43
|
+
image,
|
44
|
+
origin_id,
|
45
|
+
create_min_facesize,
|
46
|
+
create_ha,
|
47
|
+
create_junk,
|
48
|
+
identify_asm,
|
49
|
+
}: CreatePersonParamsInterface): Promise<PersonResponseIterface> {
|
50
|
+
const fieldsData = {
|
51
|
+
origin_id,
|
52
|
+
create_min_facesize,
|
53
|
+
create_ha,
|
54
|
+
create_junk,
|
55
|
+
identify_asm,
|
56
|
+
};
|
57
|
+
const data = new FormData();
|
58
|
+
|
59
|
+
addFileToFormData(data, image, "image");
|
60
|
+
addDataToFormData(data, fieldsData);
|
61
|
+
|
62
|
+
return this.httpClient.post(Persons.apiEndpoint, data);
|
63
|
+
}
|
64
|
+
|
65
|
+
// createPersonFromEntry({
|
66
|
+
// entryId,
|
67
|
+
// create_on_ha,
|
68
|
+
// create_on_junk,
|
69
|
+
// }: CreatePersonFromEntryParamsInterface): Promise<null> {
|
70
|
+
// return this.httpClient.post(`${Persons.apiEndpoint}entry/`, {
|
71
|
+
// id: entryId,
|
72
|
+
// create_on_ha,
|
73
|
+
// create_on_junk,
|
74
|
+
// });
|
75
|
+
// }
|
76
|
+
|
77
|
+
deletePerson(pid: string): Promise<null> {
|
78
|
+
return this.httpClient.delete(`${Persons.apiEndpoint}${pid}/`);
|
79
|
+
}
|
80
|
+
|
81
|
+
// reinitializePersonByEntry({
|
82
|
+
// entryId,
|
83
|
+
// }: ReinitializePersonByEntryParamsInterface): Promise<null> {
|
84
|
+
// if (!entryId) return Promise.reject("No entry id provided");
|
85
|
+
//
|
86
|
+
// return this.httpClient.post(`${Persons.apiEndpoint}reinit/`, {
|
87
|
+
// id: entryId,
|
88
|
+
// });
|
89
|
+
// }
|
90
|
+
|
91
|
+
reinitializePersonByImage({
|
92
|
+
pid,
|
93
|
+
image,
|
94
|
+
min_conf,
|
95
|
+
identify_asm,
|
96
|
+
create_min_facesize,
|
97
|
+
}: ReinitializePersonByImageParamsInterface): Promise<null> {
|
98
|
+
if (!image) return Promise.reject("No image provided");
|
99
|
+
|
100
|
+
const fieldsData = { min_conf, create_min_facesize, identify_asm };
|
101
|
+
const data = new FormData();
|
102
|
+
|
103
|
+
addFileToFormData(data, image, "image");
|
104
|
+
addDataToFormData(data, fieldsData);
|
105
|
+
|
106
|
+
return this.httpClient.post(`${Persons.apiEndpoint}${pid}/reinit/`, data);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
export { Persons };
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
|
3
|
+
import {
|
4
|
+
PersonsGroupsInterface,
|
5
|
+
GetPersonsGroupsFiltersInterface,
|
6
|
+
PersonsGroupInterface,
|
7
|
+
GetPersonsGroupPersonsFiltersInterface,
|
8
|
+
AddPersonsToPersonsGroupsParamsInterface,
|
9
|
+
RemovePersonsFromPersonsGroupsParamsInterface,
|
10
|
+
} from "../../../api-facade/v1/persons-groups";
|
11
|
+
import { id } from "../../../../base/types";
|
12
|
+
|
13
|
+
class PersonsGroups extends Api implements PersonsGroupsInterface {
|
14
|
+
constructor(settings: ApiSettingsInterface) {
|
15
|
+
super(settings);
|
16
|
+
this.getPersonsGroups = this.getPersonsGroups.bind(this);
|
17
|
+
this.getPersonsGroup = this.getPersonsGroup.bind(this);
|
18
|
+
this.createPersonsGroup = this.createPersonsGroup.bind(this);
|
19
|
+
this.updatePersonsGroup = this.updatePersonsGroup.bind(this);
|
20
|
+
this.deletePersonsGroup = this.deletePersonsGroup.bind(this);
|
21
|
+
this.getPersonsGroupPersons = this.getPersonsGroupPersons.bind(this);
|
22
|
+
this.addPersonsToPersonsGroups = this.addPersonsToPersonsGroups.bind(this);
|
23
|
+
this.removePersonsFromPersonsGroups = this.removePersonsFromPersonsGroups.bind(
|
24
|
+
this
|
25
|
+
);
|
26
|
+
}
|
27
|
+
|
28
|
+
static apiEndpoint = "groups/profiles/";
|
29
|
+
|
30
|
+
static getPersonsGroupData = ({ name }: PersonsGroupInterface = {}): {} => ({
|
31
|
+
name,
|
32
|
+
});
|
33
|
+
|
34
|
+
getPersonsGroups(filters: GetPersonsGroupsFiltersInterface): Promise<null> {
|
35
|
+
const getFiltersData = ({
|
36
|
+
q,
|
37
|
+
limit,
|
38
|
+
offset,
|
39
|
+
groups_ids,
|
40
|
+
spaces_ids,
|
41
|
+
person_ids_include,
|
42
|
+
person_ids_exclude,
|
43
|
+
}: GetPersonsGroupsFiltersInterface = {}): {} => ({
|
44
|
+
q,
|
45
|
+
limit,
|
46
|
+
offset,
|
47
|
+
groups_ids,
|
48
|
+
spaces_ids,
|
49
|
+
person_ids_include,
|
50
|
+
person_ids_exclude,
|
51
|
+
});
|
52
|
+
|
53
|
+
return this.httpClient.get(
|
54
|
+
PersonsGroups.apiEndpoint,
|
55
|
+
getFiltersData(filters)
|
56
|
+
);
|
57
|
+
}
|
58
|
+
|
59
|
+
getPersonsGroup(personGroupId: id): Promise<PersonsGroupInterface> {
|
60
|
+
return this.httpClient.get(`${PersonsGroups.apiEndpoint}${personGroupId}/`);
|
61
|
+
}
|
62
|
+
|
63
|
+
createPersonsGroup(
|
64
|
+
personsGroup: PersonsGroupInterface
|
65
|
+
): Promise<PersonsGroupInterface> {
|
66
|
+
return this.httpClient.post(
|
67
|
+
PersonsGroups.apiEndpoint,
|
68
|
+
PersonsGroups.getPersonsGroupData(personsGroup)
|
69
|
+
);
|
70
|
+
}
|
71
|
+
|
72
|
+
updatePersonsGroup({ id, ...restData }: PersonsGroupInterface = {}): Promise<
|
73
|
+
PersonsGroupInterface
|
74
|
+
> {
|
75
|
+
return this.httpClient.put(
|
76
|
+
`${PersonsGroups.apiEndpoint}${id}/`,
|
77
|
+
PersonsGroups.getPersonsGroupData(restData)
|
78
|
+
);
|
79
|
+
}
|
80
|
+
|
81
|
+
deletePersonsGroup(personGroupId: id): Promise<null> {
|
82
|
+
return this.httpClient.delete(
|
83
|
+
`${PersonsGroups.apiEndpoint}${personGroupId}/`
|
84
|
+
);
|
85
|
+
}
|
86
|
+
|
87
|
+
getPersonsGroupPersons({
|
88
|
+
groupId,
|
89
|
+
...filters
|
90
|
+
}: GetPersonsGroupPersonsFiltersInterface = {}): Promise<null> {
|
91
|
+
const getFiltersData = ({
|
92
|
+
limit,
|
93
|
+
offset,
|
94
|
+
person_ids,
|
95
|
+
}: GetPersonsGroupPersonsFiltersInterface = {}): {} => ({
|
96
|
+
limit,
|
97
|
+
offset,
|
98
|
+
person_ids,
|
99
|
+
});
|
100
|
+
|
101
|
+
return this.httpClient.get(
|
102
|
+
`${PersonsGroups.apiEndpoint}${groupId}/person_ids/`,
|
103
|
+
getFiltersData(filters)
|
104
|
+
);
|
105
|
+
}
|
106
|
+
|
107
|
+
addPersonsToPersonsGroups({
|
108
|
+
groupsIds,
|
109
|
+
persons,
|
110
|
+
}: AddPersonsToPersonsGroupsParamsInterface = {}): Promise<null> {
|
111
|
+
return this.httpClient.post(`${PersonsGroups.apiEndpoint}person_ids/`, {
|
112
|
+
groups_ids: groupsIds,
|
113
|
+
person_ids: persons,
|
114
|
+
});
|
115
|
+
}
|
116
|
+
|
117
|
+
removePersonsFromPersonsGroups({
|
118
|
+
groupsIds,
|
119
|
+
persons,
|
120
|
+
}: RemovePersonsFromPersonsGroupsParamsInterface = {}): Promise<null> {
|
121
|
+
return this.httpClient.delete(`${PersonsGroups.apiEndpoint}person_ids/`, null, {
|
122
|
+
groups_ids: groupsIds,
|
123
|
+
person_ids: persons,
|
124
|
+
});
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
export { PersonsGroups };
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
import {
|
3
|
+
SourcesInterface,
|
4
|
+
SourceInterface,
|
5
|
+
SourcesFiltersInterface,
|
6
|
+
} from "../../../api-facade/v1/sources";
|
7
|
+
import { id } from "../../../../base/types";
|
8
|
+
|
9
|
+
class Sources extends Api implements SourcesInterface {
|
10
|
+
constructor(settings: ApiSettingsInterface) {
|
11
|
+
super(settings);
|
12
|
+
this.getSources = this.getSources.bind(this);
|
13
|
+
this.getSource = this.getSource.bind(this);
|
14
|
+
this.createSource = this.createSource.bind(this);
|
15
|
+
this.updateSource = this.updateSource.bind(this);
|
16
|
+
this.deleteSource = this.deleteSource.bind(this);
|
17
|
+
}
|
18
|
+
|
19
|
+
static apiEndpoint = "origins/";
|
20
|
+
|
21
|
+
static getSourceData = ({
|
22
|
+
name,
|
23
|
+
identify_facesize_threshold,
|
24
|
+
use_pps_timestamp,
|
25
|
+
|
26
|
+
manual_create_facesize_threshold,
|
27
|
+
manual_create_on_ha,
|
28
|
+
manual_create_on_junk,
|
29
|
+
manual_identify_asm,
|
30
|
+
|
31
|
+
auto_create_persons,
|
32
|
+
auto_create_facesize_threshold,
|
33
|
+
auto_create_check_blur,
|
34
|
+
auto_create_check_exposure,
|
35
|
+
auto_create_on_ha,
|
36
|
+
auto_create_on_junk,
|
37
|
+
auto_check_face_angle,
|
38
|
+
auto_check_liveness,
|
39
|
+
auto_create_liveness_only,
|
40
|
+
auto_identify_asm,
|
41
|
+
|
42
|
+
store_images_for_results,
|
43
|
+
license_id,
|
44
|
+
license,
|
45
|
+
}: SourceInterface = {}): {} => ({
|
46
|
+
name,
|
47
|
+
identify_facesize_threshold,
|
48
|
+
use_pps_timestamp,
|
49
|
+
|
50
|
+
manual_create_facesize_threshold,
|
51
|
+
manual_create_on_ha,
|
52
|
+
manual_create_on_junk,
|
53
|
+
manual_identify_asm,
|
54
|
+
|
55
|
+
auto_create_persons,
|
56
|
+
auto_create_facesize_threshold,
|
57
|
+
auto_create_check_blur,
|
58
|
+
auto_create_check_exposure,
|
59
|
+
auto_create_on_ha,
|
60
|
+
auto_create_on_junk,
|
61
|
+
auto_check_face_angle,
|
62
|
+
auto_check_liveness,
|
63
|
+
auto_create_liveness_only,
|
64
|
+
auto_identify_asm,
|
65
|
+
|
66
|
+
store_images_for_results,
|
67
|
+
license_id,
|
68
|
+
license,
|
69
|
+
});
|
70
|
+
|
71
|
+
getSources(filters: SourcesFiltersInterface = {}): Promise<null> {
|
72
|
+
const getFiltersData = ({
|
73
|
+
q,
|
74
|
+
limit,
|
75
|
+
offset,
|
76
|
+
spaces_ids,
|
77
|
+
}: SourcesFiltersInterface = {}): {} => ({
|
78
|
+
q,
|
79
|
+
limit,
|
80
|
+
offset,
|
81
|
+
spaces_ids,
|
82
|
+
});
|
83
|
+
|
84
|
+
return this.httpClient.get(Sources.apiEndpoint, getFiltersData(filters));
|
85
|
+
}
|
86
|
+
|
87
|
+
getSource(sourceId: id): Promise<SourceInterface> {
|
88
|
+
return this.httpClient.get(`${Sources.apiEndpoint}${sourceId}/`);
|
89
|
+
}
|
90
|
+
|
91
|
+
createSource(data: SourceInterface): Promise<SourceInterface> {
|
92
|
+
return this.httpClient.post(
|
93
|
+
Sources.apiEndpoint,
|
94
|
+
Sources.getSourceData(data)
|
95
|
+
);
|
96
|
+
}
|
97
|
+
|
98
|
+
updateSource({
|
99
|
+
id,
|
100
|
+
...restData
|
101
|
+
}: SourceInterface = {}): Promise<SourceInterface> {
|
102
|
+
return this.httpClient.put(
|
103
|
+
`${Sources.apiEndpoint}${id}/`,
|
104
|
+
Sources.getSourceData(restData)
|
105
|
+
);
|
106
|
+
}
|
107
|
+
|
108
|
+
deleteSource(sourceId: id): Promise<null> {
|
109
|
+
return this.httpClient.delete(`${Sources.apiEndpoint}${sourceId}/`);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
export { Sources };
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { AuthApi, AuthApiSettingsInterface } from "../../../../base/auth-api";
|
2
|
+
import {
|
3
|
+
SpaceInterface,
|
4
|
+
SpaceDataInterface,
|
5
|
+
SpacesInterface,
|
6
|
+
GetSpacesParamsInterface,
|
7
|
+
CreateSpaceTokenInterface,
|
8
|
+
} from "../../../api-facade/v1/spaces";
|
9
|
+
import { id } from "../../../../base/types";
|
10
|
+
import { TokenInterface } from "../../../api-facade/v1/tokens";
|
11
|
+
|
12
|
+
class Spaces extends AuthApi implements SpacesInterface {
|
13
|
+
constructor(settings: AuthApiSettingsInterface) {
|
14
|
+
super(settings);
|
15
|
+
this.getSpaces = this.getSpaces.bind(this);
|
16
|
+
this.getSpace = this.getSpace.bind(this);
|
17
|
+
this.createSpace = this.createSpace.bind(this);
|
18
|
+
this.updateSpace = this.updateSpace.bind(this);
|
19
|
+
this.deleteSpace = this.deleteSpace.bind(this);
|
20
|
+
this.createToken = this.createToken.bind(this);
|
21
|
+
}
|
22
|
+
|
23
|
+
static apiEndpoint = "spaces/";
|
24
|
+
|
25
|
+
static getSpaceData = ({ name }: SpaceDataInterface): { name: string } => ({
|
26
|
+
name,
|
27
|
+
});
|
28
|
+
|
29
|
+
getSpaces(params: GetSpacesParamsInterface): Promise<Array<SpaceInterface>> {
|
30
|
+
return this.httpClient.get(this.authURL + Spaces.apiEndpoint, params);
|
31
|
+
}
|
32
|
+
|
33
|
+
getSpace(id: id): Promise<SpaceInterface> {
|
34
|
+
return this.httpClient.get(this.authURL + `${Spaces.apiEndpoint}${id}/`);
|
35
|
+
}
|
36
|
+
|
37
|
+
createSpace(data: SpaceDataInterface): Promise<SpaceInterface> {
|
38
|
+
return this.httpClient.post(
|
39
|
+
this.authURL + Spaces.apiEndpoint,
|
40
|
+
Spaces.getSpaceData(data)
|
41
|
+
);
|
42
|
+
}
|
43
|
+
|
44
|
+
updateSpace(data: SpaceInterface): Promise<SpaceInterface> {
|
45
|
+
return this.httpClient.put(
|
46
|
+
this.authURL + `${Spaces.apiEndpoint}${data.id}/`,
|
47
|
+
Spaces.getSpaceData(data)
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
deleteSpace(id: id): Promise<null> {
|
52
|
+
return this.httpClient.delete(this.authURL + `${Spaces.apiEndpoint}${id}/`);
|
53
|
+
}
|
54
|
+
|
55
|
+
createToken(data: CreateSpaceTokenInterface): Promise<TokenInterface> {
|
56
|
+
const { id, ...restData } = data;
|
57
|
+
|
58
|
+
return this.httpClient.post(
|
59
|
+
this.authURL + `${Spaces.apiEndpoint}${id}/tokens/access/`,
|
60
|
+
restData
|
61
|
+
);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
export { Spaces };
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
import {
|
3
|
+
StreamTokensInterface,
|
4
|
+
StreamTokenInterface,
|
5
|
+
GetStreamTokenInterface,
|
6
|
+
GetStreamTokensParamsInterface,
|
7
|
+
UpdateStreamTokenParamsInterface,
|
8
|
+
} from "../../../api-facade/v1/stream-tokens";
|
9
|
+
import { id } from "../../../../base/types";
|
10
|
+
|
11
|
+
class StreamTokens extends Api implements StreamTokensInterface {
|
12
|
+
constructor(settings: ApiSettingsInterface) {
|
13
|
+
super(settings);
|
14
|
+
this.getStreamTokens = this.getStreamTokens.bind(this);
|
15
|
+
this.getStreamToken = this.getStreamToken.bind(this);
|
16
|
+
this.createStreamToken = this.createStreamToken.bind(this);
|
17
|
+
this.updateStreamToken = this.updateStreamToken.bind(this);
|
18
|
+
this.deleteStreamToken = this.deleteStreamToken.bind(this);
|
19
|
+
this.deleteStreamTokens = this.deleteStreamTokens.bind(this);
|
20
|
+
}
|
21
|
+
|
22
|
+
static apiEndpoint = "tokens/streams/";
|
23
|
+
|
24
|
+
getStreamTokens(
|
25
|
+
params: GetStreamTokensParamsInterface
|
26
|
+
): Promise<Array<StreamTokenInterface>> {
|
27
|
+
return this.httpClient.get(StreamTokens.apiEndpoint, params);
|
28
|
+
}
|
29
|
+
|
30
|
+
deleteStreamTokens(params: GetStreamTokensParamsInterface): Promise<null> {
|
31
|
+
const getFiltersData = ({
|
32
|
+
limit,
|
33
|
+
offset,
|
34
|
+
permanent,
|
35
|
+
}: GetStreamTokensParamsInterface = {}) => ({
|
36
|
+
limit,
|
37
|
+
offset,
|
38
|
+
permanent,
|
39
|
+
});
|
40
|
+
|
41
|
+
return this.httpClient.delete(
|
42
|
+
StreamTokens.apiEndpoint,
|
43
|
+
getFiltersData(params)
|
44
|
+
);
|
45
|
+
}
|
46
|
+
|
47
|
+
getStreamToken(id: id): Promise<StreamTokenInterface> {
|
48
|
+
return this.httpClient.get(`${StreamTokens.apiEndpoint}${id}/`);
|
49
|
+
}
|
50
|
+
|
51
|
+
createStreamToken(
|
52
|
+
data: GetStreamTokenInterface
|
53
|
+
): Promise<StreamTokenInterface> {
|
54
|
+
const { permanent } = data || {};
|
55
|
+
|
56
|
+
return this.httpClient.post(StreamTokens.apiEndpoint, {
|
57
|
+
permanent,
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
updateStreamToken(
|
62
|
+
data: UpdateStreamTokenParamsInterface
|
63
|
+
): Promise<StreamTokenInterface> {
|
64
|
+
const { id, is_active } = data || {};
|
65
|
+
|
66
|
+
return this.httpClient.put(`${StreamTokens.apiEndpoint}${id}/`, {
|
67
|
+
is_active,
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
deleteStreamToken(id: id): Promise<null> {
|
72
|
+
return this.httpClient.delete(`${StreamTokens.apiEndpoint}${id}/`);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
export { StreamTokens };
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
import {
|
3
|
+
ThresholdsClassInterface,
|
4
|
+
ThresholdsInterface,
|
5
|
+
} from "../../../api-facade/v1/thresholds";
|
6
|
+
|
7
|
+
class Thresholds extends Api implements ThresholdsClassInterface {
|
8
|
+
constructor(settings: ApiSettingsInterface) {
|
9
|
+
super(settings);
|
10
|
+
this.getThresholds = this.getThresholds.bind(this);
|
11
|
+
this.updateThresholds = this.updateThresholds.bind(this);
|
12
|
+
this.resetThresholds = this.resetThresholds.bind(this);
|
13
|
+
}
|
14
|
+
|
15
|
+
static apiEndpoint = "settings/thresholds/";
|
16
|
+
|
17
|
+
getThresholds(): Promise<ThresholdsInterface> {
|
18
|
+
return this.httpClient.get(Thresholds.apiEndpoint);
|
19
|
+
}
|
20
|
+
|
21
|
+
updateThresholds({ exact, ha, junk }: ThresholdsInterface = {}): Promise<
|
22
|
+
ThresholdsInterface
|
23
|
+
> {
|
24
|
+
return this.httpClient.put(Thresholds.apiEndpoint, { exact, ha, junk });
|
25
|
+
}
|
26
|
+
|
27
|
+
resetThresholds(): Promise<ThresholdsInterface> {
|
28
|
+
return this.httpClient.post(`${Thresholds.apiEndpoint}reset/`);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
export { Thresholds };
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { AuthApi, AuthApiSettingsInterface } from "../../../../base/auth-api";
|
2
|
+
import {
|
3
|
+
TokenInterface,
|
4
|
+
TokensInterface,
|
5
|
+
GetTokensParamsInterface,
|
6
|
+
GetTokenInterface,
|
7
|
+
UpdateTokenParamsInterface,
|
8
|
+
} from "../../../api-facade/v1/tokens";
|
9
|
+
import { id } from "../../../../base/types";
|
10
|
+
|
11
|
+
class Tokens extends AuthApi implements TokensInterface {
|
12
|
+
constructor(settings: AuthApiSettingsInterface) {
|
13
|
+
super(settings);
|
14
|
+
this.getTokens = this.getTokens.bind(this);
|
15
|
+
this.getToken = this.getToken.bind(this);
|
16
|
+
this.deleteTokens = this.deleteTokens.bind(this);
|
17
|
+
this.createToken = this.createToken.bind(this);
|
18
|
+
this.updateToken = this.updateToken.bind(this);
|
19
|
+
this.deleteToken = this.deleteToken.bind(this);
|
20
|
+
}
|
21
|
+
|
22
|
+
static apiEndpoint = "tokens/access/";
|
23
|
+
|
24
|
+
getTokens(params: GetTokensParamsInterface): Promise<Array<TokenInterface>> {
|
25
|
+
return this.httpClient.get(this.authURL + Tokens.apiEndpoint, params);
|
26
|
+
}
|
27
|
+
|
28
|
+
deleteTokens(data: GetTokenInterface): Promise<void> {
|
29
|
+
const { permanent } = data || {};
|
30
|
+
|
31
|
+
return this.httpClient.delete(this.authURL + Tokens.apiEndpoint, {
|
32
|
+
permanent,
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
getToken(id: id): Promise<TokenInterface> {
|
37
|
+
return this.httpClient.get(this.authURL + `${Tokens.apiEndpoint}${id}/`);
|
38
|
+
}
|
39
|
+
|
40
|
+
createToken(data: GetTokenInterface): Promise<TokenInterface> {
|
41
|
+
const { permanent } = data || {};
|
42
|
+
|
43
|
+
return this.httpClient.post(this.authURL + Tokens.apiEndpoint, {
|
44
|
+
permanent,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
updateToken(data: UpdateTokenParamsInterface): Promise<TokenInterface> {
|
49
|
+
const { id, is_active } = data || {};
|
50
|
+
|
51
|
+
return this.httpClient.put(this.authURL + `${Tokens.apiEndpoint}${id}/`, {
|
52
|
+
is_active,
|
53
|
+
});
|
54
|
+
}
|
55
|
+
|
56
|
+
deleteToken(id: id): Promise<void> {
|
57
|
+
return this.httpClient.delete(this.authURL + `${Tokens.apiEndpoint}${id}/`);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
export { Tokens };
|