@30nama/sdk 1.8.6 → 1.8.7
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/api/index.js +81 -97
- package/dist/api/index.js.map +1 -1
- package/dist/api/request.js +56 -70
- package/dist/api/request.js.map +1 -1
- package/dist/api/services/biography.js +41 -67
- package/dist/api/services/biography.js.map +1 -1
- package/dist/api/services/index.js +7 -23
- package/dist/api/services/index.js.map +1 -1
- package/dist/api/services/news.js +41 -67
- package/dist/api/services/news.js.map +1 -1
- package/dist/api/services/operator.js +201 -281
- package/dist/api/services/operator.js.map +1 -1
- package/dist/api/services/soundtrack.js +17 -34
- package/dist/api/services/soundtrack.js.map +1 -1
- package/dist/api/services/stream.js +51 -77
- package/dist/api/services/stream.js.map +1 -1
- package/dist/api/services/support.js +41 -67
- package/dist/api/services/support.js.map +1 -1
- package/dist/api/services/videoContent.js +291 -389
- package/dist/api/services/videoContent.js.map +1 -1
- package/dist/api/types.js +1 -2
- package/dist/core.js +13 -35
- package/dist/core.js.map +1 -1
- package/dist/entities/BaseEntity.js +2 -5
- package/dist/entities/BaseEntity.js.map +1 -1
- package/dist/entities/IArticle.d.ts +0 -4
- package/dist/entities/IArticle.js +10 -6
- package/dist/entities/IArticle.js.map +1 -1
- package/dist/entities/IAttachment.js +1 -2
- package/dist/entities/IBiography.js +14 -6
- package/dist/entities/IBiography.js.map +1 -1
- package/dist/entities/IBoxOffice.js +20 -6
- package/dist/entities/IBoxOffice.js.map +1 -1
- package/dist/entities/ICollection.js +9 -6
- package/dist/entities/ICollection.js.map +1 -1
- package/dist/entities/ICollector.js +1 -2
- package/dist/entities/IOperator.js +2 -5
- package/dist/entities/IOperator.js.map +1 -1
- package/dist/entities/IPerson.js +1 -2
- package/dist/entities/IRating.js +1 -2
- package/dist/entities/ISoundTrack.js +1 -2
- package/dist/entities/IStream.js +1 -2
- package/dist/entities/ITitle.js +34 -8
- package/dist/entities/ITitle.js.map +1 -1
- package/dist/entities/IVideoContent.js +26 -6
- package/dist/entities/IVideoContent.js.map +1 -1
- package/dist/entities/index.js +12 -28
- package/dist/entities/index.js.map +1 -1
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/pattern/index.js +10 -9
- package/dist/pattern/index.js.map +1 -1
- package/package.json +1 -1
package/dist/api/index.js
CHANGED
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.API = void 0;
|
|
13
|
-
const actions = require("./services");
|
|
14
|
-
const request_1 = require("./request");
|
|
1
|
+
import * as actions from './services';
|
|
2
|
+
import request from './request';
|
|
15
3
|
const getFastestResponse = (promises) => {
|
|
16
4
|
const newPromises = promises.map((p) => new Promise((resolve, reject) => p.then((v) => v && resolve(v), reject)));
|
|
17
5
|
newPromises.push(Promise.all(promises).then(() => false));
|
|
18
6
|
return Promise.race(newPromises);
|
|
19
7
|
};
|
|
20
8
|
// API Module
|
|
21
|
-
|
|
9
|
+
export const API = {
|
|
22
10
|
actions: {},
|
|
23
11
|
config: {},
|
|
24
12
|
setConfig(config) {
|
|
25
|
-
this.config =
|
|
13
|
+
this.config = { ...this.config, ...config };
|
|
26
14
|
},
|
|
27
|
-
store: () =>
|
|
15
|
+
store: async () => { },
|
|
28
16
|
setAPIStore(storeCallback) {
|
|
29
17
|
this.store = storeCallback;
|
|
30
18
|
},
|
|
@@ -37,92 +25,88 @@ exports.API = {
|
|
|
37
25
|
return;
|
|
38
26
|
console[type]('[SDK::API]', ...msg);
|
|
39
27
|
},
|
|
40
|
-
useTransferEndpoint(endpoints) {
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
async useTransferEndpoint(endpoints) {
|
|
29
|
+
const checkEndpoint = async (host) => {
|
|
30
|
+
try {
|
|
31
|
+
const testReq = new request('user-video-content/test', { ...this, config: { ...this.config, endpoint: host, requestRetries: 0 } });
|
|
32
|
+
const testRes = await testReq.execute();
|
|
33
|
+
if (!testRes)
|
|
34
|
+
return;
|
|
35
|
+
if (!testRes.success)
|
|
36
|
+
return;
|
|
37
|
+
return host;
|
|
38
|
+
}
|
|
39
|
+
catch { }
|
|
40
|
+
};
|
|
41
|
+
const getFastestEndpoint = (endpoints) => {
|
|
42
|
+
const promises = endpoints.map((endpoint) => checkEndpoint(endpoint.host));
|
|
43
|
+
return getFastestResponse(promises);
|
|
44
|
+
};
|
|
45
|
+
const fastestEndpoint = await getFastestEndpoint(endpoints);
|
|
46
|
+
if (!fastestEndpoint)
|
|
47
|
+
return false;
|
|
48
|
+
this.emmiter('endpointUpdated', fastestEndpoint);
|
|
49
|
+
this.config.endpoint = fastestEndpoint;
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
async initialize() {
|
|
53
|
+
try {
|
|
54
|
+
// Node 1
|
|
55
|
+
const getEndpointsFromAPI = async () => {
|
|
43
56
|
try {
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
// TODO: Implement this
|
|
58
|
+
// const getEndpointsReq = new request('endpoint', this)
|
|
59
|
+
// const endpointsRes = await (getEndpointsReq.execute() as Promise<BaseResponse<Endpoints> | undefined>)
|
|
60
|
+
// return endpointsRes?. as { location: string; host: string }[]
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
this.log('warn', '(getEndpointsFromAPI)', err);
|
|
51
65
|
}
|
|
52
|
-
catch (_a) { }
|
|
53
|
-
});
|
|
54
|
-
const getFastestEndpoint = (endpoints) => {
|
|
55
|
-
const promises = endpoints.map((endpoint) => checkEndpoint(endpoint.host));
|
|
56
|
-
return getFastestResponse(promises);
|
|
57
66
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// const res = await api.get<Endpoints>('')
|
|
87
|
-
// if (!res.ok) throw res.originalError
|
|
88
|
-
// if (!res.data) throw 'Response is falsey'
|
|
89
|
-
// return res.data
|
|
90
|
-
// } catch (err) {
|
|
91
|
-
// this.log('warn', '(getEndpointsFromGithub)', err)
|
|
92
|
-
// }
|
|
93
|
-
// }
|
|
94
|
-
// // Node 3
|
|
95
|
-
// const getEndpointsFromArvanCloud = async (): Promise<Endpoints | undefined> => {
|
|
96
|
-
// try {
|
|
97
|
-
// const api = create({ baseURL: 'https://api-json.s3.ir-thr-at1.arvanstorage.ir/response.json' })
|
|
98
|
-
// const res = await api.get<Endpoints>('')
|
|
99
|
-
// if (!res.ok) throw res.originalError
|
|
100
|
-
// if (!res.data) throw 'Response is falsey'
|
|
101
|
-
// return res.data
|
|
102
|
-
// } catch (err) {
|
|
103
|
-
// this.log('warn', '(getEndpointsFromArvanCloud)', err)
|
|
104
|
-
// }
|
|
105
|
-
// }
|
|
106
|
-
// Try current endpoint, if it's valid, return true
|
|
107
|
-
const testReq = new request_1.default('user-video-content/test', this);
|
|
108
|
-
const testRes = yield testReq.execute(undefined, 1000 * 15);
|
|
109
|
-
if (testRes === null || testRes === void 0 ? void 0 : testRes.success)
|
|
110
|
-
return true;
|
|
111
|
-
// TODO: Utilize all 3 nodes !!!
|
|
112
|
-
// const endpoints = await getFastestResponse<Endpoints>([getEndpointsFromAPI(), getEndpointsFromGithub(), getEndpointsFromArvanCloud()])
|
|
113
|
-
const endpoints = yield getFastestResponse([getEndpointsFromAPI()]);
|
|
114
|
-
if (!endpoints || !(yield this.useTransferEndpoint(endpoints)))
|
|
115
|
-
throw 'Failed to initialize API';
|
|
67
|
+
// // Node 2
|
|
68
|
+
// const getEndpointsFromGithub = async (): Promise<Endpoints | undefined> => {
|
|
69
|
+
// try {
|
|
70
|
+
// const api = create({ baseURL: 'https://raw.githubusercontent.com/EternalC0der/30nama/main/sdk-endpoint.json?t=' + new Date().getTime() })
|
|
71
|
+
// const res = await api.get<Endpoints>('')
|
|
72
|
+
// if (!res.ok) throw res.originalError
|
|
73
|
+
// if (!res.data) throw 'Response is falsey'
|
|
74
|
+
// return res.data
|
|
75
|
+
// } catch (err) {
|
|
76
|
+
// this.log('warn', '(getEndpointsFromGithub)', err)
|
|
77
|
+
// }
|
|
78
|
+
// }
|
|
79
|
+
// // Node 3
|
|
80
|
+
// const getEndpointsFromArvanCloud = async (): Promise<Endpoints | undefined> => {
|
|
81
|
+
// try {
|
|
82
|
+
// const api = create({ baseURL: 'https://api-json.s3.ir-thr-at1.arvanstorage.ir/response.json' })
|
|
83
|
+
// const res = await api.get<Endpoints>('')
|
|
84
|
+
// if (!res.ok) throw res.originalError
|
|
85
|
+
// if (!res.data) throw 'Response is falsey'
|
|
86
|
+
// return res.data
|
|
87
|
+
// } catch (err) {
|
|
88
|
+
// this.log('warn', '(getEndpointsFromArvanCloud)', err)
|
|
89
|
+
// }
|
|
90
|
+
// }
|
|
91
|
+
// Try current endpoint, if it's valid, return true
|
|
92
|
+
const testReq = new request('user-video-content/test', this);
|
|
93
|
+
const testRes = await testReq.execute(undefined, 1000 * 15);
|
|
94
|
+
if (testRes?.success)
|
|
116
95
|
return true;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
96
|
+
// TODO: Utilize all 3 nodes !!!
|
|
97
|
+
// const endpoints = await getFastestResponse<Endpoints>([getEndpointsFromAPI(), getEndpointsFromGithub(), getEndpointsFromArvanCloud()])
|
|
98
|
+
const endpoints = await getFastestResponse([getEndpointsFromAPI()]);
|
|
99
|
+
if (!endpoints || !(await this.useTransferEndpoint(endpoints)))
|
|
100
|
+
throw 'Failed to initialize API';
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
this.log('warn', err);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
123
107
|
}
|
|
124
108
|
};
|
|
125
109
|
// Add all actions to API object and apply API object as first argument
|
|
126
110
|
for (const [key, value] of Object.entries(actions))
|
|
127
|
-
|
|
111
|
+
API.actions[key] = value.bind(API);
|
|
128
112
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,OAAO,MAAM,WAAW,CAAA;AAa/B,MAAM,kBAAkB,GAAG,CAAI,QAAwB,EAAc,EAAE;IACnE,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAe,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const QueryString = require("qs");
|
|
14
|
-
const core_1 = require("../core");
|
|
15
|
-
class default_1 {
|
|
1
|
+
import { create } from 'apisauce';
|
|
2
|
+
import QueryString from 'qs';
|
|
3
|
+
import { delay } from '../core';
|
|
4
|
+
export default class {
|
|
5
|
+
overrideSession;
|
|
6
|
+
method = 'post';
|
|
7
|
+
config;
|
|
8
|
+
actionUrl;
|
|
9
|
+
servicePath = 'videocontent';
|
|
10
|
+
emmiter;
|
|
11
|
+
store;
|
|
12
|
+
log;
|
|
16
13
|
constructor(actionUrl, instance, overrideSession) {
|
|
17
|
-
this.method = 'post';
|
|
18
|
-
this.servicePath = 'videocontent';
|
|
19
14
|
const { config, emmiter, store, log } = instance;
|
|
20
15
|
this.config = config;
|
|
21
16
|
this.actionUrl = actionUrl;
|
|
@@ -27,61 +22,53 @@ class default_1 {
|
|
|
27
22
|
buildUrl() {
|
|
28
23
|
return `${this.config.endpoint}/${this.servicePath}/${this.actionUrl}`;
|
|
29
24
|
}
|
|
30
|
-
buildHeaders() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!headers[key])
|
|
45
|
-
delete headers[key];
|
|
46
|
-
return headers;
|
|
47
|
-
});
|
|
25
|
+
async buildHeaders() {
|
|
26
|
+
const sessionToken = this.overrideSession || (await this.store()) || '';
|
|
27
|
+
const headers = {
|
|
28
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
29
|
+
Authorization: sessionToken ? `Bearer ${sessionToken}` : '',
|
|
30
|
+
'c-version': this.config.version,
|
|
31
|
+
'c-language': this.config.language,
|
|
32
|
+
'user-agent': this.config.userAgent
|
|
33
|
+
};
|
|
34
|
+
// remove indexes with falsy values
|
|
35
|
+
for (const key in headers)
|
|
36
|
+
if (!headers[key])
|
|
37
|
+
delete headers[key];
|
|
38
|
+
return headers;
|
|
48
39
|
}
|
|
49
|
-
sendRequest(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
async sendRequest(body, retry = 1) {
|
|
41
|
+
try {
|
|
42
|
+
const response = await create({ baseURL: this.config.endpoint + `/${this.servicePath}`, headers: await this.buildHeaders() })[this.method](this.actionUrl, this.method === 'get' ? body : QueryString.stringify(body));
|
|
43
|
+
if (!response.ok)
|
|
44
|
+
throw response.originalError;
|
|
45
|
+
this.log('info', `Request to ${this.buildUrl()} was successful.`);
|
|
46
|
+
this.emmiter('requestSuccess');
|
|
47
|
+
return response.data;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
this.log('warn', `Request to ${this.buildUrl()} failed:\n`, error.message || error);
|
|
51
|
+
this.emmiter('requestFail');
|
|
52
|
+
if (!this.config.requestRetries)
|
|
53
|
+
return error?.data;
|
|
54
|
+
if (retry >= this.config.requestRetries) {
|
|
55
|
+
this.log('error', `Request to ${this.buildUrl()} failed ${retry} times. Terminating request retry.`);
|
|
56
|
+
this.emmiter('terminateRequestRetry');
|
|
57
|
+
return error?.data;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (!this.config.requestRetries)
|
|
63
|
-
return error === null || error === void 0 ? void 0 : error.data;
|
|
64
|
-
if (retry >= this.config.requestRetries) {
|
|
65
|
-
this.log('error', `Request to ${this.buildUrl()} failed ${retry} times. Terminating request retry.`);
|
|
66
|
-
this.emmiter('terminateRequestRetry');
|
|
67
|
-
return error === null || error === void 0 ? void 0 : error.data;
|
|
68
|
-
}
|
|
69
|
-
yield (0, core_1.delay)(1000);
|
|
70
|
-
return yield this.sendRequest(body, retry + 1);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
59
|
+
await delay(1000);
|
|
60
|
+
return await this.sendRequest(body, retry + 1);
|
|
61
|
+
}
|
|
73
62
|
}
|
|
74
|
-
execute(body, timeout) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return result;
|
|
84
|
-
});
|
|
63
|
+
async execute(body, timeout) {
|
|
64
|
+
const responsePromise = this.sendRequest(body);
|
|
65
|
+
if (!timeout)
|
|
66
|
+
return await responsePromise;
|
|
67
|
+
const timeoutPromise = delay(timeout);
|
|
68
|
+
const response = Promise.race([responsePromise, timeoutPromise]);
|
|
69
|
+
const result = await response;
|
|
70
|
+
if (result)
|
|
71
|
+
return result;
|
|
85
72
|
}
|
|
86
73
|
withService(servicePath) {
|
|
87
74
|
this.servicePath = servicePath;
|
|
@@ -92,5 +79,4 @@ class default_1 {
|
|
|
92
79
|
return this;
|
|
93
80
|
}
|
|
94
81
|
}
|
|
95
|
-
exports.default = default_1;
|
|
96
82
|
//# sourceMappingURL=request.js.map
|
package/dist/api/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,WAAW,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAO/B,MAAM,CAAC,OAAO;IACF,eAAe,CAAS;IACxB,MAAM,GAAkB,MAAM,CAAA;IAC9B,MAAM,CAAQ;IACd,SAAS,CAAQ;IACjB,WAAW,GAAG,cAAc,CAAA;IAC5B,OAAO,CAAsD;IAC7D,KAAK,CAAmC;IACxC,GAAG,CAA0D;IACrE,YAAY,SAAiB,EAAE,QAAa,EAAE,eAAwB;QAClE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AAK,GAAG,CAAC,CAAC,CAAA;QAClD,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAI,IAA6B,EAAE,OAAgB;QAC5D,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAI,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,OAAO;YAAE,OAAO,MAAM,eAAe,CAAA;QAE1C,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;QACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAA;QAChE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAA;QAC7B,IAAI,MAAM;YAAE,OAAO,MAAM,CAAA;IAC7B,CAAC;IAED,WAAW,CAAC,WAAmB;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,OAAO,IAAI,CAAA;IACf,CAAC;IAED,UAAU,CAAC,MAAqB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,OAAO,IAAI,CAAA;IACf,CAAC;CACJ"}
|
|
@@ -1,74 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.biographyAddToFavorites = biographyAddToFavorites;
|
|
13
|
-
exports.biographyRemoteFromFavorites = biographyRemoteFromFavorites;
|
|
14
|
-
exports.biographyFavorites = biographyFavorites;
|
|
15
|
-
exports.biographyPersonDetails = biographyPersonDetails;
|
|
16
|
-
exports.biographyPersonsList = biographyPersonsList;
|
|
17
|
-
const request_1 = require("../request");
|
|
1
|
+
import request from '../request';
|
|
18
2
|
const servicePath = 'biography';
|
|
19
|
-
function biographyAddToFavorites(person_id) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return response;
|
|
28
|
-
});
|
|
3
|
+
export async function biographyAddToFavorites(person_id) {
|
|
4
|
+
const This = this;
|
|
5
|
+
This.log('info', 'Running action: biographyAddToFavorites');
|
|
6
|
+
const req = new request(`biography/addtofavorites`, this);
|
|
7
|
+
req.withService(servicePath);
|
|
8
|
+
req.withMethod('get');
|
|
9
|
+
const response = (await req.execute({ person_id }));
|
|
10
|
+
return response;
|
|
29
11
|
}
|
|
30
|
-
function biographyRemoteFromFavorites(person_id) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return response;
|
|
39
|
-
});
|
|
12
|
+
export async function biographyRemoteFromFavorites(person_id) {
|
|
13
|
+
const This = this;
|
|
14
|
+
This.log('info', 'Running action: biographyAddToFavorites');
|
|
15
|
+
const req = new request(`biography/deletefromfavorites`, this);
|
|
16
|
+
req.withService(servicePath);
|
|
17
|
+
req.withMethod('get');
|
|
18
|
+
const response = (await req.execute({ person_id }));
|
|
19
|
+
return response;
|
|
40
20
|
}
|
|
41
|
-
function biographyFavorites() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return response;
|
|
50
|
-
});
|
|
21
|
+
export async function biographyFavorites() {
|
|
22
|
+
const This = this;
|
|
23
|
+
This.log('info', 'Running action: biographyFavorites');
|
|
24
|
+
const req = new request(`biography/favorites`, this);
|
|
25
|
+
req.withService(servicePath);
|
|
26
|
+
req.withMethod('get');
|
|
27
|
+
const response = (await req.execute());
|
|
28
|
+
return response;
|
|
51
29
|
}
|
|
52
|
-
function biographyPersonDetails(person_id) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return response;
|
|
61
|
-
});
|
|
30
|
+
export async function biographyPersonDetails(person_id) {
|
|
31
|
+
const This = this;
|
|
32
|
+
This.log('info', 'Running action: biographyPersonDetails');
|
|
33
|
+
const req = new request(`biography/person/detail`, this);
|
|
34
|
+
req.withService(servicePath);
|
|
35
|
+
req.withMethod('get');
|
|
36
|
+
const response = (await req.execute({ person_id }));
|
|
37
|
+
return response;
|
|
62
38
|
}
|
|
63
|
-
function biographyPersonsList(page, gender, profession, search_text) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return response;
|
|
72
|
-
});
|
|
39
|
+
export async function biographyPersonsList(page, gender, profession, search_text) {
|
|
40
|
+
const This = this;
|
|
41
|
+
This.log('info', 'Running action: biographyPersonsList');
|
|
42
|
+
const req = new request(`biography/persons/list`, this);
|
|
43
|
+
req.withService(servicePath);
|
|
44
|
+
req.withMethod('get');
|
|
45
|
+
const response = (await req.execute({ page, gender, profession, search_text }));
|
|
46
|
+
return response;
|
|
73
47
|
}
|
|
74
48
|
//# sourceMappingURL=biography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biography.js","sourceRoot":"","sources":["../../../src/api/services/biography.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"biography.js","sourceRoot":"","sources":["../../../src/api/services/biography.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,YAAY,CAAA;AAGhC,MAAM,WAAW,GAAG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
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./videoContent"), exports);
|
|
18
|
-
__exportStar(require("./news"), exports);
|
|
19
|
-
__exportStar(require("./biography"), exports);
|
|
20
|
-
__exportStar(require("./soundtrack"), exports);
|
|
21
|
-
__exportStar(require("./support"), exports);
|
|
22
|
-
__exportStar(require("./stream"), exports);
|
|
23
|
-
__exportStar(require("./operator"), exports);
|
|
1
|
+
export * from './videoContent';
|
|
2
|
+
export * from './news';
|
|
3
|
+
export * from './biography';
|
|
4
|
+
export * from './soundtrack';
|
|
5
|
+
export * from './support';
|
|
6
|
+
export * from './stream';
|
|
7
|
+
export * from './operator';
|
|
24
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/services/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA"}
|