UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

194 lines • 8.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Stream = exports.BaseStream = 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 AudioTracksAPI = tslib_1.__importStar(require("./audio-tracks.js")); const audio_tracks_1 = require("./audio-tracks.js"); const ClipAPI = tslib_1.__importStar(require("./clip.js")); const clip_1 = require("./clip.js"); const CopyAPI = tslib_1.__importStar(require("./copy.js")); const copy_1 = require("./copy.js"); const DirectUploadAPI = tslib_1.__importStar(require("./direct-upload.js")); const direct_upload_1 = require("./direct-upload.js"); const DownloadsAPI = tslib_1.__importStar(require("./downloads.js")); const downloads_1 = require("./downloads.js"); const EmbedAPI = tslib_1.__importStar(require("./embed.js")); const embed_1 = require("./embed.js"); const KeysAPI = tslib_1.__importStar(require("./keys.js")); const keys_1 = require("./keys.js"); const TokenAPI = tslib_1.__importStar(require("./token.js")); const token_1 = require("./token.js"); const VideosAPI = tslib_1.__importStar(require("./videos.js")); const videos_1 = require("./videos.js"); const WatermarksAPI = tslib_1.__importStar(require("./watermarks.js")); const watermarks_1 = require("./watermarks.js"); const WebhooksAPI = tslib_1.__importStar(require("./webhooks.js")); const webhooks_1 = require("./webhooks.js"); const CaptionsAPI = tslib_1.__importStar(require("./captions/captions.js")); const captions_1 = require("./captions/captions.js"); const LiveInputsAPI = tslib_1.__importStar(require("./live-inputs/live-inputs.js")); const live_inputs_1 = require("./live-inputs/live-inputs.js"); const pagination_1 = require("../../core/pagination.js"); const headers_1 = require("../../internal/headers.js"); const path_1 = require("../../internal/utils/path.js"); var BaseStream = /* @__PURE__ */ (() => { class BaseStream extends resource_1.APIResource { /** * Initiates a video upload using the TUS protocol. On success, the server responds * with a status code 201 (created) and includes a `location` header to indicate * where the content should be uploaded. Refer to https://tus.io for protocol * details. * * @example * ```ts * await client.stream.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * 'Tus-Resumable': '1.0.0', * 'Upload-Length': 0, * }); * ``` */ create(params, options) { const { account_id, 'Tus-Resumable': tusResumable, 'Upload-Length': uploadLength, direct_user, 'Upload-Creator': uploadCreator, 'Upload-Metadata': uploadMetadata, } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/stream`, { query: { direct_user }, ...options, headers: (0, headers_1.buildHeaders)([ { Accept: '*/*', 'Tus-Resumable': tusResumable.toString(), 'Upload-Length': uploadLength.toString(), ...(uploadCreator != null ? { 'Upload-Creator': uploadCreator } : undefined), ...(uploadMetadata != null ? { 'Upload-Metadata': uploadMetadata } : undefined), }, options?.headers, ]), }); } /** * Lists up to 1000 videos from a single request. For a specific range, refer to * the optional parameters. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const video of client.stream.list({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/stream`, (pagination_1.SinglePage), { query, ...options, }); } /** * Deletes a video and its copies from Cloudflare Stream. * * @example * ```ts * await client.stream.delete( * 'ea95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(identifier, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/stream/${identifier}`, { ...options, headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]), }); } /** * Edit details for a single video. * * @example * ```ts * const video = await client.stream.edit( * 'ea95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(identifier, params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/stream/${identifier}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches details for a single video. * * @example * ```ts * const video = await client.stream.get( * 'ea95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(identifier, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/stream/${identifier}`, options)._thenUnwrap((obj) => obj.result); } } BaseStream._key = Object.freeze(['stream']); return BaseStream; })(); exports.BaseStream = BaseStream; var Stream = /* @__PURE__ */ (() => { class Stream extends BaseStream { constructor() { super(...arguments); this.audioTracks = new AudioTracksAPI.AudioTracks(this._client); this.videos = new VideosAPI.Videos(this._client); this.clip = new ClipAPI.Clip(this._client); this.copy = new CopyAPI.Copy(this._client); this.directUpload = new DirectUploadAPI.DirectUpload(this._client); this.keys = new KeysAPI.Keys(this._client); this.liveInputs = new LiveInputsAPI.LiveInputs(this._client); this.watermarks = new WatermarksAPI.Watermarks(this._client); this.webhooks = new WebhooksAPI.Webhooks(this._client); this.captions = new CaptionsAPI.Captions(this._client); this.downloads = new DownloadsAPI.Downloads(this._client); this.embed = new EmbedAPI.Embed(this._client); this.token = new TokenAPI.Token(this._client); } } Stream.AudioTracks = audio_tracks_1.AudioTracks; Stream.BaseAudioTracks = audio_tracks_1.BaseAudioTracks; Stream.Videos = videos_1.Videos; Stream.BaseVideos = videos_1.BaseVideos; Stream.Clip = clip_1.Clip; Stream.BaseClip = clip_1.BaseClip; Stream.Copy = copy_1.Copy; Stream.BaseCopy = copy_1.BaseCopy; Stream.DirectUpload = direct_upload_1.DirectUpload; Stream.BaseDirectUpload = direct_upload_1.BaseDirectUpload; Stream.BaseKeys = keys_1.BaseKeys; Stream.LiveInputs = live_inputs_1.LiveInputs; Stream.BaseLiveInputs = live_inputs_1.BaseLiveInputs; Stream.Watermarks = watermarks_1.Watermarks; Stream.BaseWatermarks = watermarks_1.BaseWatermarks; Stream.Webhooks = webhooks_1.Webhooks; Stream.BaseWebhooks = webhooks_1.BaseWebhooks; Stream.Captions = captions_1.Captions; Stream.BaseCaptions = captions_1.BaseCaptions; Stream.Downloads = downloads_1.Downloads; Stream.BaseDownloads = downloads_1.BaseDownloads; Stream.Embed = embed_1.Embed; Stream.BaseEmbed = embed_1.BaseEmbed; Stream.Token = token_1.Token; Stream.BaseToken = token_1.BaseToken; return Stream; })(); exports.Stream = Stream; //# sourceMappingURL=stream.js.map