@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,40 @@
|
|
1
|
+
import {
|
2
|
+
Liveness,
|
3
|
+
Sex,
|
4
|
+
Mood,
|
5
|
+
Result,
|
6
|
+
Paginatable,
|
7
|
+
Searchable,
|
8
|
+
id,
|
9
|
+
} from "../../../../base/types";
|
10
|
+
|
11
|
+
export interface NotificationInterface {
|
12
|
+
id?: id;
|
13
|
+
// read only
|
14
|
+
space_id?: id;
|
15
|
+
name?: string;
|
16
|
+
is_active?: boolean;
|
17
|
+
http_method?: number;
|
18
|
+
destination_url?: string;
|
19
|
+
results?: Array<Result>;
|
20
|
+
age_from?: number;
|
21
|
+
age_to?: number;
|
22
|
+
sex?: Array<Sex>;
|
23
|
+
moods?: Array<Mood>;
|
24
|
+
sources?: Array<string>;
|
25
|
+
persons_groups?: Array<id>;
|
26
|
+
liveness?: Array<Liveness>;
|
27
|
+
}
|
28
|
+
|
29
|
+
export interface NotificationsFiltersInterface extends Paginatable, Searchable {
|
30
|
+
spaces_ids?: Array<id>;
|
31
|
+
}
|
32
|
+
|
33
|
+
export interface NotificationsInterface {
|
34
|
+
getNotifications(filters: NotificationsFiltersInterface): Promise<null>;
|
35
|
+
getNotification(notificationId: id): Promise<NotificationInterface>;
|
36
|
+
createNotification(
|
37
|
+
notification: NotificationInterface
|
38
|
+
): Promise<NotificationInterface>;
|
39
|
+
deleteNotification(notificationId: id): Promise<null>;
|
40
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { Result, Sex, Mood } from "../../../../base/types";
|
2
|
+
|
3
|
+
export interface PersonResponseIterface {
|
4
|
+
result: Result;
|
5
|
+
pid: string;
|
6
|
+
age: number;
|
7
|
+
sex: Sex;
|
8
|
+
mood: Mood;
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface SearchPersonByImageParamsInterface {
|
12
|
+
image: File;
|
13
|
+
identify_asm?: boolean;
|
14
|
+
}
|
15
|
+
|
16
|
+
export interface CreatePersonParamsInterface {
|
17
|
+
image: File;
|
18
|
+
origin_id: number;
|
19
|
+
create_min_facesize?: number;
|
20
|
+
create_ha?: boolean;
|
21
|
+
create_junk?: boolean;
|
22
|
+
identify_asm?: boolean;
|
23
|
+
}
|
24
|
+
|
25
|
+
// export interface CreatePersonFromEntryParamsInterface {
|
26
|
+
// entryId: number;
|
27
|
+
// create_on_ha?: boolean;
|
28
|
+
// create_on_junk?: boolean;
|
29
|
+
// }
|
30
|
+
|
31
|
+
// export interface ReinitializePersonByEntryParamsInterface {
|
32
|
+
// entryId: id;
|
33
|
+
// }
|
34
|
+
|
35
|
+
export interface ReinitializePersonByImageParamsInterface {
|
36
|
+
pid: string;
|
37
|
+
image: File;
|
38
|
+
create_min_facesize?: number;
|
39
|
+
min_conf: number;
|
40
|
+
identify_asm?: boolean;
|
41
|
+
}
|
42
|
+
|
43
|
+
export interface PersonsInterface {
|
44
|
+
searchPersonByImage(
|
45
|
+
params: SearchPersonByImageParamsInterface
|
46
|
+
): Promise<PersonResponseIterface>;
|
47
|
+
createPerson(
|
48
|
+
person: CreatePersonParamsInterface
|
49
|
+
): Promise<PersonResponseIterface>;
|
50
|
+
// createPersonFromEntry(
|
51
|
+
// person: CreatePersonFromEntryParamsInterface
|
52
|
+
// ): Promise<null>;
|
53
|
+
deletePerson(pid: string): Promise<null>;
|
54
|
+
// reinitializePersonByEntry(
|
55
|
+
// params: ReinitializePersonByEntryParamsInterface
|
56
|
+
// ): Promise<null>;
|
57
|
+
reinitializePersonByImage(
|
58
|
+
params: ReinitializePersonByImageParamsInterface
|
59
|
+
): Promise<null>;
|
60
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { Paginatable, Searchable, id } from "../../../../base/types";
|
2
|
+
|
3
|
+
export interface GetPersonsGroupsFiltersInterface
|
4
|
+
extends Paginatable,
|
5
|
+
Searchable {
|
6
|
+
groups_ids?: Array<id>;
|
7
|
+
spaces_ids?: Array<id>;
|
8
|
+
person_ids_include?: Array<string>;
|
9
|
+
person_ids_exclude?: Array<string>;
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface PersonsGroupInterface {
|
13
|
+
id?: id;
|
14
|
+
// read only
|
15
|
+
space_id?: id;
|
16
|
+
name?: string;
|
17
|
+
persons_count?: number;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface GetPersonsGroupPersonsFiltersInterface extends Paginatable {
|
21
|
+
groupId?: id;
|
22
|
+
person_ids?: Array<string>;
|
23
|
+
}
|
24
|
+
|
25
|
+
export interface AddPersonsToPersonsGroupsParamsInterface {
|
26
|
+
groupsIds?: Array<id>;
|
27
|
+
persons?: Array<string>;
|
28
|
+
}
|
29
|
+
|
30
|
+
export interface RemovePersonsFromPersonsGroupsParamsInterface {
|
31
|
+
groupsIds?: Array<id>;
|
32
|
+
persons?: Array<string>;
|
33
|
+
}
|
34
|
+
|
35
|
+
export interface PersonsGroupsInterface {
|
36
|
+
getPersonsGroups(params: GetPersonsGroupsFiltersInterface): Promise<null>;
|
37
|
+
getPersonsGroup(personsGroupId: id): Promise<PersonsGroupInterface>;
|
38
|
+
createPersonsGroup(
|
39
|
+
personsGroup: PersonsGroupInterface
|
40
|
+
): Promise<PersonsGroupInterface>;
|
41
|
+
updatePersonsGroup(
|
42
|
+
personsGroup: PersonsGroupInterface
|
43
|
+
): Promise<PersonsGroupInterface>;
|
44
|
+
deletePersonsGroup(personsGroupId: id): Promise<null>;
|
45
|
+
getPersonsGroupPersons(
|
46
|
+
filters: GetPersonsGroupPersonsFiltersInterface
|
47
|
+
): Promise<null>;
|
48
|
+
addPersonsToPersonsGroups(
|
49
|
+
params: AddPersonsToPersonsGroupsParamsInterface
|
50
|
+
): Promise<null>;
|
51
|
+
removePersonsFromPersonsGroups(
|
52
|
+
params: RemovePersonsFromPersonsGroupsParamsInterface
|
53
|
+
): Promise<null>;
|
54
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { Result, Paginatable, Searchable, id } from "../../../../base/types";
|
2
|
+
|
3
|
+
export interface SourceInterface {
|
4
|
+
// General
|
5
|
+
id?: id;
|
6
|
+
// read only
|
7
|
+
space_id?: id;
|
8
|
+
name?: string;
|
9
|
+
license_id?: id;
|
10
|
+
license?: Record<string, unknown>;
|
11
|
+
identify_facesize_threshold?: number;
|
12
|
+
use_pps_timestamp?: boolean;
|
13
|
+
|
14
|
+
// Photo processing
|
15
|
+
manual_create_facesize_threshold?: number;
|
16
|
+
manual_create_on_ha?: boolean;
|
17
|
+
manual_create_on_junk?: boolean;
|
18
|
+
manual_identify_asm?: boolean;
|
19
|
+
|
20
|
+
// Processing a video stream
|
21
|
+
auto_create_persons?: boolean;
|
22
|
+
auto_create_facesize_threshold?: boolean;
|
23
|
+
auto_create_check_blur?: boolean;
|
24
|
+
auto_create_check_exposure?: boolean;
|
25
|
+
auto_create_on_ha?: boolean;
|
26
|
+
auto_create_on_junk?: boolean;
|
27
|
+
auto_check_face_angle?: boolean;
|
28
|
+
auto_check_angle_threshold?: number;
|
29
|
+
auto_check_liveness?: boolean;
|
30
|
+
auto_create_liveness_only?: boolean;
|
31
|
+
auto_identify_asm?: boolean;
|
32
|
+
|
33
|
+
// Saving images
|
34
|
+
store_images_for_results?: Array<Result>;
|
35
|
+
}
|
36
|
+
|
37
|
+
export interface SourcesFiltersInterface extends Paginatable, Searchable {
|
38
|
+
spaces_ids?: Array<id>;
|
39
|
+
}
|
40
|
+
|
41
|
+
export interface SourcesInterface {
|
42
|
+
getSources(filters: SourcesFiltersInterface): Promise<null>;
|
43
|
+
getSource(sourceId: id): Promise<SourceInterface>;
|
44
|
+
createSource(source: SourceInterface): Promise<SourceInterface>;
|
45
|
+
deleteSource(sourceId: id): Promise<null>;
|
46
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { Paginatable, Searchable, id } from "../../../../base/types";
|
2
|
+
import { AuthApiInterface } from "../../../../base/auth-api";
|
3
|
+
import { GetTokenInterface, TokenInterface } from "../tokens";
|
4
|
+
|
5
|
+
export interface SpaceInterface {
|
6
|
+
id: id;
|
7
|
+
name: string;
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface SpaceDataInterface {
|
11
|
+
name: string;
|
12
|
+
}
|
13
|
+
|
14
|
+
export interface GetSpacesParamsInterface extends Paginatable, Searchable {}
|
15
|
+
|
16
|
+
export interface CreateSpaceTokenInterface extends GetTokenInterface {
|
17
|
+
id: id;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface SpacesInterface extends AuthApiInterface {
|
21
|
+
getSpaces(params: GetSpacesParamsInterface): Promise<Array<SpaceInterface>>;
|
22
|
+
getSpace(id: id): Promise<SpaceInterface>;
|
23
|
+
createSpace(data: SpaceDataInterface): Promise<SpaceInterface>;
|
24
|
+
updateSpace(data: SpaceInterface): Promise<SpaceInterface>;
|
25
|
+
deleteSpace(id: id): Promise<null>;
|
26
|
+
createToken(data: CreateSpaceTokenInterface): Promise<TokenInterface>;
|
27
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Paginatable, id } from "../../../../base/types";
|
2
|
+
|
3
|
+
export interface StreamTokenInterface {
|
4
|
+
key: string;
|
5
|
+
id: id;
|
6
|
+
is_active: boolean;
|
7
|
+
created: string;
|
8
|
+
expires: string;
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface GetStreamTokenInterface {
|
12
|
+
permanent?: boolean;
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface GetStreamTokensParamsInterface
|
16
|
+
extends Paginatable,
|
17
|
+
GetStreamTokenInterface {}
|
18
|
+
|
19
|
+
export interface UpdateStreamTokenParamsInterface {
|
20
|
+
id: id;
|
21
|
+
is_active: boolean;
|
22
|
+
}
|
23
|
+
|
24
|
+
export interface StreamTokensInterface {
|
25
|
+
getStreamTokens(
|
26
|
+
filters: GetStreamTokenInterface
|
27
|
+
): Promise<Array<StreamTokenInterface>>;
|
28
|
+
getStreamToken(streamTokenId: id): Promise<StreamTokenInterface>;
|
29
|
+
createStreamToken(
|
30
|
+
streamToken: GetStreamTokenInterface
|
31
|
+
): Promise<StreamTokenInterface>;
|
32
|
+
updateStreamToken(
|
33
|
+
params: UpdateStreamTokenParamsInterface
|
34
|
+
): Promise<StreamTokenInterface>;
|
35
|
+
deleteStreamToken(streamTokenId: id): Promise<null>;
|
36
|
+
deleteStreamTokens(params: GetStreamTokenInterface): Promise<null>;
|
37
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { id } from "../../../../base/types";
|
2
|
+
|
3
|
+
export interface ThresholdsInterface {
|
4
|
+
// read only
|
5
|
+
space_id?: id;
|
6
|
+
exact?: number;
|
7
|
+
ha?: number;
|
8
|
+
junk?: number;
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface ThresholdsClassInterface {
|
12
|
+
getThresholds(): Promise<ThresholdsInterface>;
|
13
|
+
updateThresholds(
|
14
|
+
Thresholds: ThresholdsInterface
|
15
|
+
): Promise<ThresholdsInterface>;
|
16
|
+
resetThresholds(): Promise<ThresholdsInterface>;
|
17
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Paginatable, id } from "../../../../base/types";
|
2
|
+
import { AuthApiInterface } from "../../../../base/auth-api";
|
3
|
+
|
4
|
+
export interface TokenInterface {
|
5
|
+
key: string;
|
6
|
+
id: id;
|
7
|
+
is_active: boolean;
|
8
|
+
created: string;
|
9
|
+
expires: string;
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface GetTokenInterface {
|
13
|
+
permanent?: boolean;
|
14
|
+
}
|
15
|
+
|
16
|
+
export interface GetTokensParamsInterface
|
17
|
+
extends Paginatable,
|
18
|
+
GetTokenInterface {}
|
19
|
+
|
20
|
+
export interface UpdateTokenParamsInterface {
|
21
|
+
id: id;
|
22
|
+
is_active: boolean;
|
23
|
+
}
|
24
|
+
|
25
|
+
export interface TokensInterface extends AuthApiInterface {
|
26
|
+
getTokens(params: GetTokensParamsInterface): Promise<Array<TokenInterface>>;
|
27
|
+
getToken(id: id): Promise<TokenInterface>;
|
28
|
+
createToken(params: GetTokenInterface): Promise<TokenInterface>;
|
29
|
+
updateToken(params: UpdateTokenParamsInterface): Promise<TokenInterface>;
|
30
|
+
deleteToken(id: id): Promise<void>;
|
31
|
+
deleteTokens(params: GetTokenInterface): Promise<void>;
|
32
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { Result, Sex, Mood } from "../../../../base/types";
|
2
|
+
|
3
|
+
export interface ComparePhotosParamsInterface {
|
4
|
+
image1: File;
|
5
|
+
image2: File;
|
6
|
+
result?: Result;
|
7
|
+
}
|
8
|
+
|
9
|
+
export interface ComparePhotosResponseInterface {
|
10
|
+
similar: boolean;
|
11
|
+
result: Result;
|
12
|
+
}
|
13
|
+
|
14
|
+
export interface ComparePersonPhotoWithDocumentPhotoParamsInterface {
|
15
|
+
photo: File;
|
16
|
+
facesize?: number;
|
17
|
+
result?: Result;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface VerifyPersonPhotoWithDocumentPhotoParamsInterface {
|
21
|
+
photo_face: File;
|
22
|
+
photo_face_facesize?: number;
|
23
|
+
|
24
|
+
id_code: string;
|
25
|
+
photo_id: File;
|
26
|
+
photo_id_facesize?: number;
|
27
|
+
|
28
|
+
result?: Result;
|
29
|
+
}
|
30
|
+
|
31
|
+
export interface VerifyPersonPhotoWithDocumentPhotoResponseInterface
|
32
|
+
extends ComparePhotosResponseInterface {
|
33
|
+
extra?: {};
|
34
|
+
documents: [];
|
35
|
+
}
|
36
|
+
|
37
|
+
export interface CheckAsmParamsInterface {
|
38
|
+
image: File;
|
39
|
+
}
|
40
|
+
|
41
|
+
export interface CheckAsmResponseInterface {
|
42
|
+
age: number;
|
43
|
+
sex: Sex;
|
44
|
+
mood: Mood;
|
45
|
+
}
|
46
|
+
|
47
|
+
export interface FindOutCustomerParamsInterface {
|
48
|
+
source?: string;
|
49
|
+
offset?: number;
|
50
|
+
}
|
51
|
+
|
52
|
+
export interface FindOutCustomerResponseInterface {
|
53
|
+
pid: string;
|
54
|
+
}
|
55
|
+
|
56
|
+
export interface GetApiVersionResponseInterface {
|
57
|
+
version: string;
|
58
|
+
}
|
59
|
+
|
60
|
+
export interface UtilitiesInterface {
|
61
|
+
comparePhotos(
|
62
|
+
params: ComparePhotosParamsInterface
|
63
|
+
): Promise<ComparePhotosResponseInterface>;
|
64
|
+
|
65
|
+
comparePersonPhotoWithDocumentPhoto(
|
66
|
+
params: ComparePersonPhotoWithDocumentPhotoParamsInterface
|
67
|
+
): Promise<ComparePhotosResponseInterface>;
|
68
|
+
|
69
|
+
verifyPersonPhotoWithDocumentPhoto(
|
70
|
+
params: VerifyPersonPhotoWithDocumentPhotoParamsInterface
|
71
|
+
): Promise<VerifyPersonPhotoWithDocumentPhotoResponseInterface>;
|
72
|
+
|
73
|
+
checkAsm(params: CheckAsmParamsInterface): Promise<CheckAsmResponseInterface>;
|
74
|
+
|
75
|
+
findOutCustomer(
|
76
|
+
params: FindOutCustomerParamsInterface
|
77
|
+
): Promise<FindOutCustomerResponseInterface>;
|
78
|
+
|
79
|
+
getSupportedIdTypes(): Promise<null>;
|
80
|
+
|
81
|
+
getApiVersion(): Promise<GetApiVersionResponseInterface>;
|
82
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { AuthApi, AuthApiSettingsInterface } from "../../../../base/auth-api";
|
2
|
+
import {
|
3
|
+
AuthInterface,
|
4
|
+
UserInterface,
|
5
|
+
LoginUserInterface,
|
6
|
+
ChangeUserPasswordInterface,
|
7
|
+
} from "../../../api-facade/auth";
|
8
|
+
|
9
|
+
class Auth extends AuthApi implements AuthInterface {
|
10
|
+
constructor(settings: AuthApiSettingsInterface) {
|
11
|
+
super(settings);
|
12
|
+
this.login = this.login.bind(this);
|
13
|
+
this.logout = this.logout.bind(this);
|
14
|
+
this.whoami = this.whoami.bind(this);
|
15
|
+
this.changePassword = this.changePassword.bind(this);
|
16
|
+
}
|
17
|
+
|
18
|
+
login(username: string, password: string): Promise<LoginUserInterface> {
|
19
|
+
const data = new FormData();
|
20
|
+
data.append("username", username);
|
21
|
+
data.append("password", password);
|
22
|
+
|
23
|
+
return this.httpClient
|
24
|
+
.post(this.authURL + "auth/token/", data)
|
25
|
+
.then((body: LoginUserInterface) => ({
|
26
|
+
token: {
|
27
|
+
id: body.token_meta.id,
|
28
|
+
key: body.access_token,
|
29
|
+
created: body.token_meta.created,
|
30
|
+
expires: body.token_meta.expires,
|
31
|
+
expires_in: body.expires_in,
|
32
|
+
is_active: body.token_meta.is_active,
|
33
|
+
},
|
34
|
+
user: {
|
35
|
+
username: body.user_meta.username,
|
36
|
+
created: body.user_meta.created,
|
37
|
+
space: {
|
38
|
+
id: body.user_meta.id,
|
39
|
+
name: "default",
|
40
|
+
},
|
41
|
+
},
|
42
|
+
}));
|
43
|
+
}
|
44
|
+
|
45
|
+
logout(tokenId: string): Promise<null> {
|
46
|
+
return this.httpClient.delete(this.authURL + `tokens/${tokenId}/`);
|
47
|
+
}
|
48
|
+
|
49
|
+
whoami(): Promise<UserInterface> {
|
50
|
+
return this.httpClient.get(this.authURL + "whoami/");
|
51
|
+
}
|
52
|
+
|
53
|
+
changePassword(data: ChangeUserPasswordInterface): Promise<null> {
|
54
|
+
return this.httpClient.post(this.authURL + "auth/password/change/", data);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
export { Auth };
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { Api, ApiSettingsInterface } from "../../../../base/api";
|
2
|
+
import { id } from "../../../../base/types";
|
3
|
+
|
4
|
+
import {
|
5
|
+
EntriesFiltersInterface,
|
6
|
+
EntriesInterface,
|
7
|
+
EntryInterface,
|
8
|
+
EntriesStatsInterface,
|
9
|
+
} from "../../../api-facade/v1/entries";
|
10
|
+
|
11
|
+
class Entries extends Api implements EntriesInterface {
|
12
|
+
constructor(settings: ApiSettingsInterface) {
|
13
|
+
super(settings);
|
14
|
+
this.getEntries = this.getEntries.bind(this);
|
15
|
+
this.getEntriesStatsByPersonId = this.getEntriesStatsByPersonId.bind(this);
|
16
|
+
this.deleteEntry = this.deleteEntry.bind(this);
|
17
|
+
}
|
18
|
+
|
19
|
+
static apiEndpoint = "entries/";
|
20
|
+
|
21
|
+
getEntries(
|
22
|
+
filters: EntriesFiltersInterface = {}
|
23
|
+
): Promise<Array<EntryInterface>> {
|
24
|
+
const getFiltersData = ({
|
25
|
+
pid,
|
26
|
+
person_ids,
|
27
|
+
spaces_ids,
|
28
|
+
origin_ids,
|
29
|
+
conf,
|
30
|
+
liveness,
|
31
|
+
id_from,
|
32
|
+
date_from,
|
33
|
+
date_to,
|
34
|
+
limit,
|
35
|
+
offset,
|
36
|
+
sex,
|
37
|
+
mood,
|
38
|
+
age_from,
|
39
|
+
age_to,
|
40
|
+
}: EntriesFiltersInterface): {} => ({
|
41
|
+
pid,
|
42
|
+
person_ids,
|
43
|
+
spaces_ids,
|
44
|
+
origin_ids,
|
45
|
+
conf,
|
46
|
+
liveness,
|
47
|
+
id_from,
|
48
|
+
date_from,
|
49
|
+
date_to,
|
50
|
+
limit,
|
51
|
+
offset,
|
52
|
+
sex,
|
53
|
+
mood,
|
54
|
+
age_from,
|
55
|
+
age_to,
|
56
|
+
});
|
57
|
+
|
58
|
+
return this.httpClient.get(Entries.apiEndpoint, getFiltersData(filters));
|
59
|
+
}
|
60
|
+
|
61
|
+
getEntriesStatsByPersonId(pid: string): Promise<EntriesStatsInterface> {
|
62
|
+
return this.httpClient.get(`${Entries.apiEndpoint}stats/pid/${pid}/`);
|
63
|
+
}
|
64
|
+
|
65
|
+
deleteEntry(entryId: id): Promise<null> {
|
66
|
+
return this.httpClient.delete(`${Entries.apiEndpoint}${entryId}/`);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
export { Entries };
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { AuthApi, AuthApiSettingsInterface } from "../../../../base/auth-api";
|
2
|
+
import {
|
3
|
+
LicensesInterface,
|
4
|
+
LicenseInterface,
|
5
|
+
LicensesFiltersInterface,
|
6
|
+
} from "../../../api-facade/v1/licenses";
|
7
|
+
import { id } from "../../../../base/types";
|
8
|
+
|
9
|
+
class Licenses extends AuthApi implements LicensesInterface {
|
10
|
+
constructor(settings: AuthApiSettingsInterface) {
|
11
|
+
super(settings);
|
12
|
+
this.getLicenses = this.getLicenses.bind(this);
|
13
|
+
this.getLicense = this.getLicense.bind(this);
|
14
|
+
this.createLicense = this.createLicense.bind(this);
|
15
|
+
this.updateLicense = this.updateLicense.bind(this);
|
16
|
+
this.deleteLicense = this.deleteLicense.bind(this);
|
17
|
+
}
|
18
|
+
|
19
|
+
static apiEndpoint = "licenses/sources/";
|
20
|
+
|
21
|
+
getLicenses(
|
22
|
+
filters: LicensesFiltersInterface = {}
|
23
|
+
): Promise<LicenseInterface[]> {
|
24
|
+
const getFiltersData = ({
|
25
|
+
q,
|
26
|
+
limit,
|
27
|
+
offset,
|
28
|
+
date_from,
|
29
|
+
date_to,
|
30
|
+
is_bound,
|
31
|
+
}: LicensesFiltersInterface = {}): Record<string, unknown> => ({
|
32
|
+
q,
|
33
|
+
limit,
|
34
|
+
offset,
|
35
|
+
date_from,
|
36
|
+
date_to,
|
37
|
+
is_bound,
|
38
|
+
});
|
39
|
+
|
40
|
+
return this.httpClient.get(
|
41
|
+
this.authURL + Licenses.apiEndpoint,
|
42
|
+
getFiltersData(filters)
|
43
|
+
);
|
44
|
+
}
|
45
|
+
|
46
|
+
getLicense(licenseId: id): Promise<LicenseInterface> {
|
47
|
+
return this.httpClient.get(
|
48
|
+
this.authURL + `${Licenses.apiEndpoint}${licenseId}/`
|
49
|
+
);
|
50
|
+
}
|
51
|
+
|
52
|
+
createLicense({
|
53
|
+
name,
|
54
|
+
entry_storage_days,
|
55
|
+
}: LicenseInterface = {}): Promise<LicenseInterface> {
|
56
|
+
return this.httpClient.post(this.authURL + Licenses.apiEndpoint, {
|
57
|
+
name,
|
58
|
+
entry_storage_days,
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
62
|
+
updateLicense({
|
63
|
+
id,
|
64
|
+
name,
|
65
|
+
entry_storage_days,
|
66
|
+
is_active,
|
67
|
+
}: LicenseInterface = {}): Promise<LicenseInterface> {
|
68
|
+
return this.httpClient.put(this.authURL + `${Licenses.apiEndpoint}${id}/`, {
|
69
|
+
name,
|
70
|
+
entry_storage_days,
|
71
|
+
is_active,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
|
75
|
+
deleteLicense(licenseId: id): Promise<null> {
|
76
|
+
return this.httpClient.delete(
|
77
|
+
this.authURL + `${Licenses.apiEndpoint}${licenseId}/`
|
78
|
+
);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
export { Licenses };
|