@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,59 @@
|
|
1
|
+
{
|
2
|
+
"name": "@serp/rest-api",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Library for work with Serp REST API",
|
5
|
+
"main": "./dist/index.node.js",
|
6
|
+
"types": "./dist/@types/index.d.ts",
|
7
|
+
"browser": {
|
8
|
+
"./dist/index.node.js": "./dist/index.web.js"
|
9
|
+
},
|
10
|
+
"scripts": {
|
11
|
+
"check-types": "tsc",
|
12
|
+
"create-declaration": "tsc --noEmit false --emitDeclarationOnly --declarationDir ./dist/@types --declaration true",
|
13
|
+
"build": "set NODE_OPTIONS=--openssl-legacy-provider && webpack",
|
14
|
+
"prepublishOnly": "npm run build && npm run create-declaration",
|
15
|
+
"test": "jest",
|
16
|
+
"test:watch": "jest --watch",
|
17
|
+
"test:coverage": "jest --coverage"
|
18
|
+
},
|
19
|
+
"dependencies": {
|
20
|
+
"axios": "^0.19.2",
|
21
|
+
"isomorphic-form-data": "^2.0.0",
|
22
|
+
"object-sizeof": "^1.6.1",
|
23
|
+
"qs": "^6.10.1"
|
24
|
+
},
|
25
|
+
"devDependencies": {
|
26
|
+
"@babel/cli": "^7.15.7",
|
27
|
+
"@babel/core": "^7.15.8",
|
28
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
29
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
|
30
|
+
"@babel/preset-env": "^7.15.8",
|
31
|
+
"@babel/preset-typescript": "^7.15.0",
|
32
|
+
"@types/axios": "^0.14.0",
|
33
|
+
"@types/isomorphic-form-data": "^2.0.0",
|
34
|
+
"@types/jest": "^26.0.24",
|
35
|
+
"@types/qs": "^6.9.7",
|
36
|
+
"@typescript-eslint/eslint-plugin": "^3.10.1",
|
37
|
+
"@typescript-eslint/parser": "^3.10.1",
|
38
|
+
"babel-eslint": "^10.1.0",
|
39
|
+
"babel-jest": "^26.6.3",
|
40
|
+
"babel-loader": "^8.2.2",
|
41
|
+
"eslint": "^7.32.0",
|
42
|
+
"eslint-config-prettier": "^6.15.0",
|
43
|
+
"eslint-plugin-jest": "^23.20.0",
|
44
|
+
"eslint-plugin-prettier": "^3.4.1",
|
45
|
+
"file-api": "^0.10.4",
|
46
|
+
"jest": "^26.6.3",
|
47
|
+
"jest-mock-axios": "^4.4.1",
|
48
|
+
"parallel-webpack": "^2.6.0",
|
49
|
+
"prettier": "^2.4.1",
|
50
|
+
"ts-jest": "^26.5.6",
|
51
|
+
"ts-loader": "^8.3.0",
|
52
|
+
"typescript": "^3.9.10",
|
53
|
+
"webpack": "^4.46.0",
|
54
|
+
"webpack-cli": "^3.3.12"
|
55
|
+
},
|
56
|
+
"keywords": [],
|
57
|
+
"author": "Dmitriy Balashov <mockedcat@gmail.com>",
|
58
|
+
"license": "MIT"
|
59
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export interface ApiSettingsInterface {
|
2
|
+
httpClient: any;
|
3
|
+
}
|
4
|
+
|
5
|
+
export interface ApiInterface {}
|
6
|
+
|
7
|
+
class Api implements ApiInterface {
|
8
|
+
protected httpClient: any;
|
9
|
+
|
10
|
+
constructor(settings: ApiSettingsInterface) {
|
11
|
+
this.httpClient = settings.httpClient;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
export { Api };
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { ApiSettingsInterface, ApiInterface } from "./api";
|
2
|
+
|
3
|
+
export interface AuthApiSettingsInterface extends ApiSettingsInterface {
|
4
|
+
authURL: string;
|
5
|
+
}
|
6
|
+
|
7
|
+
export interface AuthApiInterface extends ApiInterface {
|
8
|
+
setAuthURL(url: string): void;
|
9
|
+
}
|
10
|
+
|
11
|
+
class AuthApi implements AuthApiInterface {
|
12
|
+
protected httpClient: any;
|
13
|
+
protected authURL: string;
|
14
|
+
|
15
|
+
constructor(settings: AuthApiSettingsInterface) {
|
16
|
+
this.httpClient = settings.httpClient;
|
17
|
+
this.authURL = settings.authURL;
|
18
|
+
}
|
19
|
+
|
20
|
+
setAuthURL(url: string) {
|
21
|
+
this.authURL = url;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
export { AuthApi };
|
@@ -0,0 +1,33 @@
|
|
1
|
+
export type numeric = number | string;
|
2
|
+
|
3
|
+
export type id = number;
|
4
|
+
|
5
|
+
export enum SexEnum {
|
6
|
+
Male = 0,
|
7
|
+
Female = 1,
|
8
|
+
}
|
9
|
+
|
10
|
+
export type Sex = 1 | 0;
|
11
|
+
|
12
|
+
export type Liveness = "passed" | "failed" | "undetermined";
|
13
|
+
|
14
|
+
export type Result = "new" | "reinit" | "exact" | "ha" | "junk" | "nm" | "det";
|
15
|
+
|
16
|
+
export type Mood =
|
17
|
+
| "neutral"
|
18
|
+
| "anger"
|
19
|
+
| "contempt"
|
20
|
+
| "disgust"
|
21
|
+
| "fear"
|
22
|
+
| "happiness"
|
23
|
+
| "sadness"
|
24
|
+
| "surprise";
|
25
|
+
|
26
|
+
export interface Paginatable {
|
27
|
+
offset?: numeric;
|
28
|
+
limit?: numeric;
|
29
|
+
}
|
30
|
+
|
31
|
+
export interface Searchable {
|
32
|
+
q?: string;
|
33
|
+
}
|
@@ -0,0 +1,207 @@
|
|
1
|
+
import { removeEmpty, isEmpty } from "./utils";
|
2
|
+
import qs from "qs";
|
3
|
+
import { HttpClientInterface } from "./serp-rest-api/api-facade/auth";
|
4
|
+
import sizeof from "object-sizeof";
|
5
|
+
import { getFormDataSize } from "./utils";
|
6
|
+
|
7
|
+
function getPayloadSize(payload: Record<string, unknown> | FormData): number {
|
8
|
+
if (payload instanceof FormData) {
|
9
|
+
return getFormDataSize(payload);
|
10
|
+
} else {
|
11
|
+
return sizeof(payload);
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
const payloadIsTooLargeError = new Error("Payload is too large");
|
16
|
+
|
17
|
+
// 6mb
|
18
|
+
const MAX_PAYLOAD_SIZE = 6291456;
|
19
|
+
|
20
|
+
function prepareUrlParams(params: { q?: string }): Record<string, unknown> {
|
21
|
+
const paramsWithValues = removeEmpty(params);
|
22
|
+
|
23
|
+
if (Object.prototype.hasOwnProperty.call(params, "q")) {
|
24
|
+
if (params.q === "") {
|
25
|
+
delete paramsWithValues.q;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
return !isEmpty(paramsWithValues) ? paramsWithValues : {};
|
30
|
+
}
|
31
|
+
|
32
|
+
type RequestData = FormData | Record<string, unknown>;
|
33
|
+
|
34
|
+
type ResponseData = { data: Record<string, unknown> };
|
35
|
+
|
36
|
+
interface RequestClientInterface {
|
37
|
+
defaults: { baseURL?: string; headers?: { Authorization?: string } };
|
38
|
+
get(
|
39
|
+
url: string,
|
40
|
+
config?: { params?: Record<string, unknown> }
|
41
|
+
): Promise<ResponseData>;
|
42
|
+
post(url: string, data?: RequestData): Promise<ResponseData>;
|
43
|
+
put(url: string, data?: RequestData): Promise<ResponseData>;
|
44
|
+
delete(
|
45
|
+
url: string,
|
46
|
+
config?: {
|
47
|
+
params?: Record<string, unknown>;
|
48
|
+
data?: Record<string, unknown> | FormData;
|
49
|
+
}
|
50
|
+
): Promise<ResponseData>;
|
51
|
+
}
|
52
|
+
|
53
|
+
interface RequestClientCreatorSettingsInterface {
|
54
|
+
baseURL?: string;
|
55
|
+
headers?: { "Content-Type": string; token?: string };
|
56
|
+
paramsSerializer?(params: any): string;
|
57
|
+
}
|
58
|
+
|
59
|
+
interface RequestClientCreatorInterface {
|
60
|
+
create(
|
61
|
+
settings: RequestClientCreatorSettingsInterface
|
62
|
+
): RequestClientInterface;
|
63
|
+
}
|
64
|
+
|
65
|
+
interface RequestClientCreatorSettingsInterface {
|
66
|
+
baseURL?: string;
|
67
|
+
token?: string;
|
68
|
+
}
|
69
|
+
|
70
|
+
function createHttpClient({
|
71
|
+
client,
|
72
|
+
}: {
|
73
|
+
client: RequestClientCreatorInterface;
|
74
|
+
}): {
|
75
|
+
new (settings: RequestClientCreatorSettingsInterface): HttpClientInterface;
|
76
|
+
} {
|
77
|
+
return class HttpClient implements HttpClientInterface {
|
78
|
+
private client: RequestClientInterface;
|
79
|
+
|
80
|
+
constructor({ baseURL, token }: RequestClientCreatorSettingsInterface) {
|
81
|
+
Object.assign(this, { baseURL, token });
|
82
|
+
|
83
|
+
const headers: {
|
84
|
+
"Content-Type": string;
|
85
|
+
token?: string;
|
86
|
+
} = {
|
87
|
+
"Content-Type": "application/json",
|
88
|
+
};
|
89
|
+
|
90
|
+
if (token) {
|
91
|
+
headers.token = `Token ${token}`;
|
92
|
+
}
|
93
|
+
|
94
|
+
this.client = client.create({
|
95
|
+
baseURL,
|
96
|
+
headers,
|
97
|
+
paramsSerializer: function (params) {
|
98
|
+
return qs.stringify(params, { arrayFormat: "comma" });
|
99
|
+
},
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
setToken(token: string): void {
|
104
|
+
if (token && this.client.defaults.headers) {
|
105
|
+
this.client.defaults.headers["Authorization"] = `Token ${token}`;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
deleteToken(): void {
|
110
|
+
if (this.client.defaults.headers) {
|
111
|
+
delete this.client.defaults.headers["Authorization"];
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
setBaseURL(baseURL: string): void {
|
116
|
+
if (baseURL) {
|
117
|
+
this.client.defaults.baseURL = baseURL;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
post(url: string, data?: RequestData): Promise<Record<string, unknown>> {
|
122
|
+
let preparedData = data;
|
123
|
+
|
124
|
+
if (data && !(data instanceof FormData)) {
|
125
|
+
preparedData = removeEmpty(data);
|
126
|
+
}
|
127
|
+
|
128
|
+
if (data && getPayloadSize(data) >= MAX_PAYLOAD_SIZE) {
|
129
|
+
return Promise.reject(payloadIsTooLargeError);
|
130
|
+
}
|
131
|
+
|
132
|
+
if (preparedData) {
|
133
|
+
return this.client.post(url, preparedData).then(({ data }) => data);
|
134
|
+
} else {
|
135
|
+
return this.client.post(url).then(({ data }) => data);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
get(
|
140
|
+
url: string,
|
141
|
+
params?: Record<string, unknown>
|
142
|
+
): Promise<Record<string, unknown>> {
|
143
|
+
const config: { params?: Record<string, unknown> } = {};
|
144
|
+
|
145
|
+
if (params) {
|
146
|
+
config.params = prepareUrlParams(params);
|
147
|
+
}
|
148
|
+
|
149
|
+
if (!isEmpty(config)) {
|
150
|
+
return this.client.get(url, config).then(({ data }) => data);
|
151
|
+
} else {
|
152
|
+
return this.client.get(url).then(({ data }) => data);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
put(url: string, data?: RequestData): Promise<Record<string, unknown>> {
|
157
|
+
let preparedData = data;
|
158
|
+
|
159
|
+
if (data && !(data instanceof FormData)) {
|
160
|
+
preparedData = removeEmpty(data);
|
161
|
+
}
|
162
|
+
|
163
|
+
if (data && getPayloadSize(data) >= MAX_PAYLOAD_SIZE) {
|
164
|
+
return Promise.reject(payloadIsTooLargeError);
|
165
|
+
}
|
166
|
+
|
167
|
+
return this.client.put(url, preparedData).then(({ data }) => data);
|
168
|
+
}
|
169
|
+
|
170
|
+
delete(
|
171
|
+
url: string,
|
172
|
+
params?: Record<string, unknown>,
|
173
|
+
data?: RequestData
|
174
|
+
): Promise<Record<string, unknown>> {
|
175
|
+
const config: {
|
176
|
+
params?: Record<string, unknown>;
|
177
|
+
data?: Record<string, unknown> | FormData;
|
178
|
+
} = {};
|
179
|
+
|
180
|
+
if (params) {
|
181
|
+
config.params = prepareUrlParams(params);
|
182
|
+
}
|
183
|
+
|
184
|
+
let preparedData = data;
|
185
|
+
|
186
|
+
if (data && !(data instanceof FormData)) {
|
187
|
+
preparedData = removeEmpty(data);
|
188
|
+
}
|
189
|
+
|
190
|
+
if (preparedData) {
|
191
|
+
config.data = preparedData;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (data && getPayloadSize(data) >= MAX_PAYLOAD_SIZE) {
|
195
|
+
return Promise.reject(payloadIsTooLargeError);
|
196
|
+
}
|
197
|
+
|
198
|
+
if (!isEmpty(config)) {
|
199
|
+
return this.client.delete(url, config).then(({ data }) => data);
|
200
|
+
} else {
|
201
|
+
return this.client.delete(url).then(({ data }) => data);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
};
|
205
|
+
}
|
206
|
+
|
207
|
+
export { createHttpClient };
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { SpaceInterface } from "../v1/spaces";
|
2
|
+
import { AuthApiInterface } from "../../../base/auth-api";
|
3
|
+
|
4
|
+
export interface UserInterface {
|
5
|
+
username: string;
|
6
|
+
space: SpaceInterface | null;
|
7
|
+
}
|
8
|
+
|
9
|
+
export interface LoginUserInterface {
|
10
|
+
expires_in: number;
|
11
|
+
access_token: string;
|
12
|
+
token_type: string,
|
13
|
+
token_meta: {
|
14
|
+
id: number,
|
15
|
+
created: string,
|
16
|
+
expires: string,
|
17
|
+
is_active: boolean,
|
18
|
+
last_accessed_timestamp: string,
|
19
|
+
last_accessed_sender_uid: string,
|
20
|
+
};
|
21
|
+
user_meta: {
|
22
|
+
id: number;
|
23
|
+
created: string;
|
24
|
+
username: string;
|
25
|
+
};
|
26
|
+
token: {
|
27
|
+
key: string,
|
28
|
+
},
|
29
|
+
}
|
30
|
+
|
31
|
+
export interface ChangeUserPasswordInterface {
|
32
|
+
old_password: string;
|
33
|
+
password: string;
|
34
|
+
password2: string;
|
35
|
+
reset_tokens?: boolean;
|
36
|
+
}
|
37
|
+
|
38
|
+
export interface AuthInterface extends AuthApiInterface {
|
39
|
+
login(username: string, password: string): Promise<LoginUserInterface>;
|
40
|
+
logout(tokenId: string): Promise<null>;
|
41
|
+
whoami(): Promise<UserInterface>;
|
42
|
+
changePassword(data: ChangeUserPasswordInterface): Promise<null>;
|
43
|
+
}
|
44
|
+
|
45
|
+
// _________
|
46
|
+
export interface HttpClientInterface {
|
47
|
+
setToken(token: string): void;
|
48
|
+
deleteToken(): void;
|
49
|
+
setBaseURL(url: string): void;
|
50
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { AuthInterface, LoginUserInterface, HttpClientInterface } from "./auth";
|
2
|
+
|
3
|
+
export interface EndpointInterface {
|
4
|
+
base: string;
|
5
|
+
auth: string;
|
6
|
+
}
|
7
|
+
|
8
|
+
export interface ApiFacadeSettingsInterface {
|
9
|
+
httpClient: HttpClientInterface;
|
10
|
+
auth: AuthInterface;
|
11
|
+
}
|
12
|
+
|
13
|
+
export interface ApiFacadeInterface {
|
14
|
+
init(username: string, password: string): Promise<LoginUserInterface>;
|
15
|
+
setToken(token: string): void;
|
16
|
+
deleteToken(): void;
|
17
|
+
setEndpoint(endpoint: EndpointInterface): void;
|
18
|
+
|
19
|
+
auth: AuthInterface;
|
20
|
+
}
|
21
|
+
|
22
|
+
class ApiFacade implements ApiFacadeInterface {
|
23
|
+
protected httpClient: HttpClientInterface;
|
24
|
+
auth: AuthInterface;
|
25
|
+
|
26
|
+
constructor({ httpClient, auth }: ApiFacadeSettingsInterface) {
|
27
|
+
this.httpClient = httpClient;
|
28
|
+
this.auth = auth;
|
29
|
+
}
|
30
|
+
|
31
|
+
init(username: string, password: string): Promise<LoginUserInterface> {
|
32
|
+
return this.auth
|
33
|
+
.login(username, password)
|
34
|
+
.then((body: LoginUserInterface) => {
|
35
|
+
const { token } = body;
|
36
|
+
|
37
|
+
this.setToken(token.key);
|
38
|
+
|
39
|
+
return body;
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
setToken(token: string): void {
|
44
|
+
this.httpClient.setToken(token);
|
45
|
+
}
|
46
|
+
|
47
|
+
deleteToken(): void {
|
48
|
+
this.httpClient.deleteToken();
|
49
|
+
}
|
50
|
+
|
51
|
+
setEndpoint(endpoint: EndpointInterface): void {
|
52
|
+
if (!endpoint) return;
|
53
|
+
this.httpClient.setBaseURL(endpoint.base);
|
54
|
+
this.auth.setAuthURL(endpoint.auth);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
export { ApiFacade };
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import {
|
2
|
+
id,
|
3
|
+
Sex,
|
4
|
+
Liveness,
|
5
|
+
Result,
|
6
|
+
Mood,
|
7
|
+
Paginatable,
|
8
|
+
Searchable,
|
9
|
+
} from "../../../../base/types";
|
10
|
+
import { SpaceInterface } from "../spaces";
|
11
|
+
|
12
|
+
export interface EntriesFiltersInterface extends Paginatable, Searchable {
|
13
|
+
pid?: string;
|
14
|
+
|
15
|
+
person_ids?: Array<id>;
|
16
|
+
spaces_ids?: Array<id>;
|
17
|
+
origin_ids?: string;
|
18
|
+
conf?: Array<Result>;
|
19
|
+
liveness?: Array<Liveness>;
|
20
|
+
sex?: Array<Sex>;
|
21
|
+
mood?: Array<Mood>;
|
22
|
+
age_from?: number;
|
23
|
+
age_to?: number;
|
24
|
+
|
25
|
+
id_from?: number;
|
26
|
+
entry_id_from?: number;
|
27
|
+
|
28
|
+
date_to?: string;
|
29
|
+
date_from?: string;
|
30
|
+
}
|
31
|
+
|
32
|
+
export interface EntryInterface {
|
33
|
+
id: id;
|
34
|
+
created: string;
|
35
|
+
face_image: string;
|
36
|
+
full_image: string;
|
37
|
+
source: {
|
38
|
+
id: id;
|
39
|
+
name: string;
|
40
|
+
};
|
41
|
+
space: SpaceInterface;
|
42
|
+
facesize: number;
|
43
|
+
age: number;
|
44
|
+
sex: Sex;
|
45
|
+
mood: Mood;
|
46
|
+
liveness: Liveness;
|
47
|
+
pid: string;
|
48
|
+
result: string;
|
49
|
+
confidence: number;
|
50
|
+
pid_created: string;
|
51
|
+
initial_face_image: string;
|
52
|
+
initial_full_image: string;
|
53
|
+
exposure: number;
|
54
|
+
pan: number;
|
55
|
+
tilt: number;
|
56
|
+
}
|
57
|
+
|
58
|
+
export interface EntriesStatsInterface {
|
59
|
+
pid: string;
|
60
|
+
pid_created: string;
|
61
|
+
pid_source: {
|
62
|
+
id: id;
|
63
|
+
name: string;
|
64
|
+
};
|
65
|
+
age: number;
|
66
|
+
sex: Sex;
|
67
|
+
initial_face_image: string;
|
68
|
+
initial_full_image: string;
|
69
|
+
initial_facesize: number;
|
70
|
+
initial_liveness: string;
|
71
|
+
total: number;
|
72
|
+
exact: number;
|
73
|
+
ha: number;
|
74
|
+
junk: number;
|
75
|
+
reinit: number;
|
76
|
+
liveness: {
|
77
|
+
passed: number;
|
78
|
+
failed: number;
|
79
|
+
undetermined: number;
|
80
|
+
};
|
81
|
+
}
|
82
|
+
|
83
|
+
export interface EntriesInterface {
|
84
|
+
getEntries(filters: EntriesFiltersInterface): Promise<Array<EntryInterface>>;
|
85
|
+
getEntriesStatsByPersonId(pid: string): Promise<EntriesStatsInterface>;
|
86
|
+
deleteEntry(entryId: id): Promise<null>;
|
87
|
+
}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import {
|
2
|
+
ApiFacade,
|
3
|
+
ApiFacadeInterface,
|
4
|
+
ApiFacadeSettingsInterface,
|
5
|
+
EndpointInterface,
|
6
|
+
} from "../base";
|
7
|
+
|
8
|
+
import { TokensInterface } from "./tokens";
|
9
|
+
import { SpacesInterface } from "./spaces";
|
10
|
+
import { NotificationsInterface } from "./notifications";
|
11
|
+
import { EntriesInterface } from "./entries";
|
12
|
+
import { PersonsInterface } from "./persons";
|
13
|
+
import { SourcesInterface } from "./sources";
|
14
|
+
import { UtilitiesInterface } from "./utilities";
|
15
|
+
import { PersonsGroupsInterface } from "./persons-groups";
|
16
|
+
import { ThresholdsClassInterface } from "./thresholds";
|
17
|
+
import { StreamTokensInterface } from "./stream-tokens";
|
18
|
+
import { LicensesInterface } from "./licenses";
|
19
|
+
|
20
|
+
interface ApiFacadeV1SettingsInterface extends ApiFacadeSettingsInterface {
|
21
|
+
tokens: TokensInterface;
|
22
|
+
spaces: SpacesInterface;
|
23
|
+
licenses: LicensesInterface;
|
24
|
+
|
25
|
+
notifications: NotificationsInterface;
|
26
|
+
entries: EntriesInterface;
|
27
|
+
persons: PersonsInterface;
|
28
|
+
sources: SourcesInterface;
|
29
|
+
utilities: UtilitiesInterface;
|
30
|
+
personsGroups: PersonsGroupsInterface;
|
31
|
+
thresholds: ThresholdsClassInterface;
|
32
|
+
streamTokens: StreamTokensInterface;
|
33
|
+
}
|
34
|
+
|
35
|
+
export interface ApiFacadeV1Interface extends ApiFacadeInterface {
|
36
|
+
tokens: TokensInterface;
|
37
|
+
spaces: SpacesInterface;
|
38
|
+
licenses: LicensesInterface;
|
39
|
+
|
40
|
+
notifications: NotificationsInterface;
|
41
|
+
entries: EntriesInterface;
|
42
|
+
persons: PersonsInterface;
|
43
|
+
sources: SourcesInterface;
|
44
|
+
utilities: UtilitiesInterface;
|
45
|
+
personsGroups: PersonsGroupsInterface;
|
46
|
+
thresholds: ThresholdsClassInterface;
|
47
|
+
streamTokens: StreamTokensInterface;
|
48
|
+
}
|
49
|
+
|
50
|
+
class ApiFacadeV1 extends ApiFacade {
|
51
|
+
tokens: TokensInterface;
|
52
|
+
spaces: SpacesInterface;
|
53
|
+
licenses: LicensesInterface;
|
54
|
+
|
55
|
+
notifications: NotificationsInterface;
|
56
|
+
entries: EntriesInterface;
|
57
|
+
persons: PersonsInterface;
|
58
|
+
sources: SourcesInterface;
|
59
|
+
utilities: UtilitiesInterface;
|
60
|
+
personsGroups: PersonsGroupsInterface;
|
61
|
+
thresholds: ThresholdsClassInterface;
|
62
|
+
streamTokens: StreamTokensInterface;
|
63
|
+
|
64
|
+
constructor({
|
65
|
+
httpClient,
|
66
|
+
auth,
|
67
|
+
tokens,
|
68
|
+
spaces,
|
69
|
+
licenses,
|
70
|
+
notifications,
|
71
|
+
entries,
|
72
|
+
persons,
|
73
|
+
sources,
|
74
|
+
utilities,
|
75
|
+
personsGroups,
|
76
|
+
thresholds,
|
77
|
+
streamTokens,
|
78
|
+
}: ApiFacadeV1SettingsInterface) {
|
79
|
+
super({
|
80
|
+
auth,
|
81
|
+
httpClient,
|
82
|
+
});
|
83
|
+
|
84
|
+
this.tokens = tokens;
|
85
|
+
this.spaces = spaces;
|
86
|
+
this.licenses = licenses;
|
87
|
+
|
88
|
+
this.notifications = notifications;
|
89
|
+
this.entries = entries;
|
90
|
+
this.persons = persons;
|
91
|
+
this.sources = sources;
|
92
|
+
this.utilities = utilities;
|
93
|
+
this.personsGroups = personsGroups;
|
94
|
+
this.thresholds = thresholds;
|
95
|
+
this.streamTokens = streamTokens;
|
96
|
+
}
|
97
|
+
|
98
|
+
setEndpoint(endpoint: EndpointInterface): void {
|
99
|
+
super.setEndpoint(endpoint);
|
100
|
+
this.tokens.setAuthURL(endpoint.auth);
|
101
|
+
this.spaces.setAuthURL(endpoint.auth);
|
102
|
+
this.licenses.setAuthURL(endpoint.auth);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
export { ApiFacadeV1 };
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Paginatable, Searchable, id } from "../../../../base/types";
|
2
|
+
import { AuthApiInterface } from "../../../../base/auth-api";
|
3
|
+
|
4
|
+
export interface LicenseInterface {
|
5
|
+
// General
|
6
|
+
id?: id;
|
7
|
+
|
8
|
+
// read only
|
9
|
+
unavailable_at?: string;
|
10
|
+
created?: string;
|
11
|
+
|
12
|
+
name?: string;
|
13
|
+
entry_storage_days?: number;
|
14
|
+
is_active?: boolean;
|
15
|
+
}
|
16
|
+
|
17
|
+
export interface LicensesFiltersInterface extends Paginatable, Searchable {
|
18
|
+
date_from?: string;
|
19
|
+
date_to?: string;
|
20
|
+
is_bound?: boolean;
|
21
|
+
}
|
22
|
+
|
23
|
+
export interface LicensesInterface extends AuthApiInterface {
|
24
|
+
getLicenses(filters: LicensesFiltersInterface): Promise<LicenseInterface[]>;
|
25
|
+
getLicense(licenseId: id): Promise<LicenseInterface>;
|
26
|
+
createLicense(license: LicenseInterface): Promise<LicenseInterface>;
|
27
|
+
deleteLicense(licenseId: id): Promise<null>;
|
28
|
+
}
|