@exode-team/kinescope.api 2.0.32 → 2.0.34
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/dist/base-service.d.ts +4 -4
- package/dist/base-service.js +2 -2
- package/dist/types/dto/video/videoUpload.d.ts +14 -4
- package/dist/types/index.d.ts +7 -44
- package/dist/types/index.js +13 -0
- package/examples/api-test.ts +112 -108
- package/package.json +3 -2
package/dist/base-service.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author: exode <hello@exode.ru>
|
|
5
5
|
*/
|
|
6
6
|
/// <reference types="node" />
|
|
7
|
-
import { Request, Response } from './types';
|
|
7
|
+
import { Headers, Request, Response } from './types';
|
|
8
8
|
export declare class BaseService {
|
|
9
9
|
/**
|
|
10
10
|
* Kinescope apiToken
|
|
@@ -20,9 +20,9 @@ export declare class BaseService {
|
|
|
20
20
|
* Make request to Kinescope API
|
|
21
21
|
* @param {string} apiUrl
|
|
22
22
|
* @param {Request | File | Buffer} data
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
23
|
+
* @param {"post" | "get" | "put" | "delete"} httpMethod
|
|
24
|
+
* @param {Headers} headers
|
|
25
25
|
* @returns {Promise<T>}
|
|
26
26
|
*/
|
|
27
|
-
requestApi<T = Response>(apiUrl: string, data: Request | File | Buffer, httpMethod: 'post' | 'get' | 'put' | 'delete', headers?:
|
|
27
|
+
requestApi<T = Response>(apiUrl: string, data: Request | File | Buffer, httpMethod: 'post' | 'get' | 'put' | 'delete', headers?: Headers): Promise<T>;
|
|
28
28
|
}
|
package/dist/base-service.js
CHANGED
|
@@ -41,8 +41,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
* Make request to Kinescope API
|
|
42
42
|
* @param {string} apiUrl
|
|
43
43
|
* @param {Request | File | Buffer} data
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
44
|
+
* @param {"post" | "get" | "put" | "delete"} httpMethod
|
|
45
|
+
* @param {Headers} headers
|
|
46
46
|
* @returns {Promise<T>}
|
|
47
47
|
*/
|
|
48
48
|
requestApi(apiUrl, data, httpMethod, headers) {
|
|
@@ -2,18 +2,28 @@
|
|
|
2
2
|
* Upload Video
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export interface VideoUploadHeadersByFile
|
|
5
|
+
export interface VideoUploadHeadersByFile {
|
|
6
6
|
'X-Parent-ID': string;
|
|
7
7
|
'X-Video-Title': string;
|
|
8
|
-
'X-Video-Trim'
|
|
8
|
+
'X-Video-Trim'?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface VideoUploadHeadersByUrl
|
|
11
|
+
export interface VideoUploadHeadersByUrl {
|
|
12
12
|
'X-Parent-ID': string;
|
|
13
13
|
'X-Video-Title': string;
|
|
14
14
|
'X-Video-URL': string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface VideoUploadResponse {
|
|
18
|
-
readonly data:
|
|
18
|
+
readonly data: {
|
|
19
|
+
id: string;
|
|
20
|
+
parent_id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
status: 'uploading' | 'done';
|
|
24
|
+
play_link: string;
|
|
25
|
+
embed_link: string;
|
|
26
|
+
hls_link: string;
|
|
27
|
+
created_at: string;
|
|
28
|
+
};
|
|
19
29
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,63 +1,26 @@
|
|
|
1
|
-
// noinspection ES6PreferShortImport @note: for correct dist types
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Index
|
|
5
3
|
*
|
|
6
4
|
* @author: exode <hello@exode.ru>
|
|
7
5
|
*/
|
|
8
|
-
|
|
9
6
|
import { AnalyticsGetOverviewRequest, AnalyticsGetOverviewResponse } from './dto/analytics/analyticsGetOverview';
|
|
10
7
|
import { AnalyticsGetCustomRequest, AnalyticsGetCustomResponse } from './dto/analytics/analyticsGetCustom';
|
|
11
|
-
|
|
12
8
|
import { ProjectCreateRequest, ProjectCreateResponse } from './dto/project/projectCreate';
|
|
13
9
|
import { ProjectGetRequest, ProjectGetResponse } from './dto/project/projectGet';
|
|
14
10
|
import { ProjectGetByIdRequest, ProjectGetByIdResponse } from './dto/project/projectGetById';
|
|
15
11
|
import { ProjectUpdateRequest, ProjectUpdateResponse } from './dto/project/projectUpdateById';
|
|
16
12
|
import { ProjectDeleteResponse } from './dto/project/projectDelete';
|
|
17
|
-
|
|
18
13
|
import { VideoUploadHeadersByFile, VideoUploadHeadersByUrl, VideoUploadResponse } from './dto/video/videoUpload';
|
|
19
|
-
|
|
20
|
-
|
|
21
14
|
/**
|
|
22
15
|
* Types of request
|
|
23
16
|
*/
|
|
24
|
-
export type Request = AnalyticsGetOverviewRequest |
|
|
25
|
-
AnalyticsGetCustomRequest |
|
|
26
|
-
ProjectCreateRequest |
|
|
27
|
-
ProjectGetRequest |
|
|
28
|
-
ProjectGetByIdRequest |
|
|
29
|
-
ProjectUpdateRequest |
|
|
30
|
-
VideoUploadHeadersByFile |
|
|
31
|
-
VideoUploadHeadersByUrl;
|
|
32
|
-
|
|
17
|
+
export type Request = AnalyticsGetOverviewRequest | AnalyticsGetCustomRequest | ProjectCreateRequest | ProjectGetRequest | ProjectGetByIdRequest | ProjectUpdateRequest | VideoUploadHeadersByFile | VideoUploadHeadersByUrl;
|
|
33
18
|
/**
|
|
34
19
|
* Types of response
|
|
35
20
|
*/
|
|
36
|
-
export type Response = AnalyticsGetOverviewResponse |
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
ProjectDeleteResponse |
|
|
43
|
-
VideoUploadResponse;
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
AnalyticsGetOverviewRequest,
|
|
47
|
-
AnalyticsGetCustomRequest,
|
|
48
|
-
ProjectCreateRequest,
|
|
49
|
-
ProjectGetRequest,
|
|
50
|
-
ProjectGetByIdRequest,
|
|
51
|
-
ProjectUpdateRequest,
|
|
52
|
-
VideoUploadHeadersByFile,
|
|
53
|
-
VideoUploadHeadersByUrl,
|
|
54
|
-
AnalyticsGetOverviewResponse,
|
|
55
|
-
AnalyticsGetCustomResponse,
|
|
56
|
-
ProjectCreateResponse,
|
|
57
|
-
ProjectGetResponse,
|
|
58
|
-
ProjectGetByIdResponse,
|
|
59
|
-
ProjectUpdateResponse,
|
|
60
|
-
ProjectDeleteResponse,
|
|
61
|
-
VideoUploadResponse,
|
|
62
|
-
};
|
|
63
|
-
|
|
21
|
+
export type Response = AnalyticsGetOverviewResponse | AnalyticsGetCustomResponse | ProjectCreateResponse | ProjectGetResponse | ProjectGetByIdResponse | ProjectUpdateResponse | ProjectDeleteResponse | VideoUploadResponse;
|
|
22
|
+
/**
|
|
23
|
+
* Types of headers
|
|
24
|
+
*/
|
|
25
|
+
export type Headers = VideoUploadHeadersByFile | VideoUploadHeadersByUrl;
|
|
26
|
+
export { AnalyticsGetOverviewRequest, AnalyticsGetCustomRequest, ProjectCreateRequest, ProjectGetRequest, ProjectGetByIdRequest, ProjectUpdateRequest, VideoUploadHeadersByFile, VideoUploadHeadersByUrl, AnalyticsGetOverviewResponse, AnalyticsGetCustomResponse, ProjectCreateResponse, ProjectGetResponse, ProjectGetByIdResponse, ProjectUpdateResponse, ProjectDeleteResponse, VideoUploadResponse, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// noinspection ES6PreferShortImport @note: for correct dist types
|
|
2
|
+
(function (factory) {
|
|
3
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
4
|
+
var v = factory(require, exports);
|
|
5
|
+
if (v !== undefined) module.exports = v;
|
|
6
|
+
}
|
|
7
|
+
else if (typeof define === "function" && define.amd) {
|
|
8
|
+
define(["require", "exports"], factory);
|
|
9
|
+
}
|
|
10
|
+
})(function (require, exports) {
|
|
11
|
+
"use strict";
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
});
|
package/examples/api-test.ts
CHANGED
|
@@ -14,118 +14,122 @@ require('dotenv').config();
|
|
|
14
14
|
const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
15
15
|
|
|
16
16
|
const createProject = await apiService.project.create({
|
|
17
|
-
name: 'Мой тестовый проект
|
|
17
|
+
name: 'Мой тестовый проект',
|
|
18
18
|
privacy_type: 'custom',
|
|
19
19
|
privacy_domains: [ 'exode.ru', 'staging.exode.ru' ],
|
|
20
|
+
encrypted: true,
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
console.log('createProject', createProject);
|
|
23
24
|
})();
|
|
24
25
|
|
|
25
|
-
(async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})();
|
|
36
|
-
|
|
37
|
-
(async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})();
|
|
46
|
-
|
|
47
|
-
(async () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})();
|
|
61
|
-
|
|
62
|
-
(async () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})();
|
|
71
|
-
|
|
72
|
-
(async () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})();
|
|
83
|
-
|
|
84
|
-
(async () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})();
|
|
97
|
-
|
|
98
|
-
(async () => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
26
|
+
// (async () => {
|
|
27
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
28
|
+
//
|
|
29
|
+
// const getProject = await apiService.project.getMany({
|
|
30
|
+
// per_page: 10,
|
|
31
|
+
// page: 1,
|
|
32
|
+
// });
|
|
33
|
+
//
|
|
34
|
+
// console.log('getProject', getProject);
|
|
35
|
+
//
|
|
36
|
+
// })();
|
|
37
|
+
|
|
38
|
+
// (async () => {
|
|
39
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
40
|
+
//
|
|
41
|
+
// const getProjectById = await apiService.project.getById({
|
|
42
|
+
// id: 'f95f15f3-f826-4af1-8641-cf5f8ce83231',
|
|
43
|
+
// });
|
|
44
|
+
//
|
|
45
|
+
// console.log('getProjectById', getProjectById);
|
|
46
|
+
// })();
|
|
47
|
+
//
|
|
48
|
+
// (async () => {
|
|
49
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
50
|
+
//
|
|
51
|
+
// const updateProject = await apiService.project.updateById(
|
|
52
|
+
// 'f95f15f3-f826-4af1-8641-cf5f8ce83231',
|
|
53
|
+
// {
|
|
54
|
+
// name: 'new name of project',
|
|
55
|
+
// privacy_type: 'custom',
|
|
56
|
+
// privacy_domains: [ 'exode.ru', 'staging.exode.ru' ],
|
|
57
|
+
// },
|
|
58
|
+
// );
|
|
59
|
+
//
|
|
60
|
+
// console.log('updateProject', updateProject);
|
|
61
|
+
// })();
|
|
62
|
+
//
|
|
63
|
+
// (async () => {
|
|
64
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
65
|
+
//
|
|
66
|
+
// const deleteProject = await apiService.project.deleteById(
|
|
67
|
+
// 'f95f15f3-f826-4af1-8641-cf5f8ce83231',
|
|
68
|
+
// );
|
|
69
|
+
//
|
|
70
|
+
// console.log('deleteProject', deleteProject);
|
|
71
|
+
// })();
|
|
72
|
+
//
|
|
73
|
+
// (async () => {
|
|
74
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
75
|
+
//
|
|
76
|
+
// const getOverview = await apiService.analytics.getOverview({
|
|
77
|
+
// from: '2020-08-30',
|
|
78
|
+
// to: '2020-09-01',
|
|
79
|
+
// group_time: 'day',
|
|
80
|
+
// });
|
|
81
|
+
//
|
|
82
|
+
// console.log('getOverview', getOverview);
|
|
83
|
+
// })();
|
|
84
|
+
//
|
|
85
|
+
// (async () => {
|
|
86
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
87
|
+
//
|
|
88
|
+
// const getCustom = await apiService.analytics.getCustom({
|
|
89
|
+
// from: '2020-11-01T06:00:00Z',
|
|
90
|
+
// to: '2020-11-01T06:00:00Z',
|
|
91
|
+
// group: 'day',
|
|
92
|
+
// group_entities: 'video_id',
|
|
93
|
+
// fields: [ 'view', 'play' ],
|
|
94
|
+
// });
|
|
95
|
+
//
|
|
96
|
+
// console.log('getCustom', getCustom);
|
|
97
|
+
// })();
|
|
98
|
+
|
|
99
|
+
// (async () => {
|
|
100
|
+
// console.log(process.env.API_TOKEN);
|
|
101
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
102
|
+
// const form = new FormData();
|
|
103
|
+
//
|
|
104
|
+
// form.append('file', fs.createReadStream('test.mp4'), {
|
|
105
|
+
// filename: 'test.mp4',
|
|
106
|
+
// contentType: 'video/mp4',
|
|
107
|
+
// });
|
|
108
|
+
//
|
|
109
|
+
// const uploadVideo = await apiService.video.uploadVideoByFile(
|
|
110
|
+
// fs.readFileSync('test.mp4'),
|
|
111
|
+
// {
|
|
112
|
+
// // 'X-Parent-ID': '8270802c-c632-403f-abe8-f26344088947',
|
|
113
|
+
// 'X-Parent-ID': 'd875c211-0fa1-46eb-8596-4b1c1eeae56b',
|
|
114
|
+
// 'X-Video-Title': 'Test video',
|
|
115
|
+
// 'X-Video-Trim': JSON.stringify({ start: 1, length: 2 }),
|
|
116
|
+
// ...form.getHeaders(),
|
|
117
|
+
// },
|
|
118
|
+
// );
|
|
119
|
+
//
|
|
120
|
+
// console.log('uploadVideo', uploadVideo.data);
|
|
121
|
+
// })();
|
|
122
|
+
|
|
123
|
+
// (async () => {
|
|
124
|
+
// const apiService = new ApiService(`${process.env.API_TOKEN}`);
|
|
125
|
+
//
|
|
126
|
+
// const headers = {
|
|
127
|
+
// 'X-Parent-ID': '8270802c-c632-403f-abe8-f26344088947',
|
|
128
|
+
// 'X-Video-Title': 'testTwo',
|
|
129
|
+
// 'X-Video-URL': 'https://www.youtube.com/watch?v=qzbtdclsJXw',
|
|
130
|
+
// };
|
|
131
|
+
//
|
|
132
|
+
// const uploadVideo = await apiService.video.uploadVideoByUrl(headers);
|
|
133
|
+
// console.log('uploadVideo', uploadVideo);
|
|
134
|
+
//
|
|
135
|
+
// })();
|
package/package.json
CHANGED