cloudflare
Version:
The official TypeScript library for the Cloudflare API
102 lines • 4.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Language = exports.BaseLanguage = void 0;
const tslib_1 = require("../../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const VttAPI = tslib_1.__importStar(require("./vtt.js"));
const vtt_1 = require("./vtt.js");
const uploads_1 = require("../../../../internal/uploads.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseLanguage = /* @__PURE__ */ (() => {
class BaseLanguage extends resource_1.APIResource {
/**
* Generate captions or subtitles for provided language via AI.
*
* @example
* ```ts
* const caption =
* await client.stream.captions.language.create('tr', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* identifier: 'ea95132c15732412d22c1476fa83f27a',
* });
* ```
*/
create(language, params, options) {
const { account_id, identifier } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/stream/${identifier}/captions/${language}/generate`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Uploads the caption or subtitle file to the endpoint for a specific BCP47
* language. One caption or subtitle file per language is allowed.
*
* @example
* ```ts
* const caption =
* await client.stream.captions.language.update('tr', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* identifier: 'ea95132c15732412d22c1476fa83f27a',
* file: '@/Users/kyle/Desktop/tr.vtt',
* });
* ```
*/
update(language, params, options) {
const { account_id, identifier, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/stream/${identifier}/captions/${language}`, (0, uploads_1.multipartFormRequestOptions)({ body, ...options }, this._client))._thenUnwrap((obj) => obj.result);
}
/**
* Removes the captions or subtitles from a video.
*
* @example
* ```ts
* const language =
* await client.stream.captions.language.delete('tr', {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* identifier: 'ea95132c15732412d22c1476fa83f27a',
* });
* ```
*/
delete(language, params, options) {
const { account_id, identifier } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/stream/${identifier}/captions/${language}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Lists the captions or subtitles for provided language.
*
* @example
* ```ts
* const caption = await client.stream.captions.language.get(
* 'tr',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* identifier: 'ea95132c15732412d22c1476fa83f27a',
* },
* );
* ```
*/
get(language, params, options) {
const { account_id, identifier } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/stream/${identifier}/captions/${language}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseLanguage._key = Object.freeze([
'stream',
'captions',
'language',
]);
return BaseLanguage;
})();
exports.BaseLanguage = BaseLanguage;
var Language = /* @__PURE__ */ (() => {
class Language extends BaseLanguage {
constructor() {
super(...arguments);
this.vtt = new VttAPI.Vtt(this._client);
}
}
Language.Vtt = vtt_1.Vtt;
Language.BaseVtt = vtt_1.BaseVtt;
return Language;
})();
exports.Language = Language;
//# sourceMappingURL=language.js.map