UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

188 lines • 7.76 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as AudioTracksAPI from "./audio-tracks.mjs"; import { AudioTracks, BaseAudioTracks, } from "./audio-tracks.mjs"; import * as ClipAPI from "./clip.mjs"; import { BaseClip, Clip } from "./clip.mjs"; import * as CopyAPI from "./copy.mjs"; import { BaseCopy, Copy } from "./copy.mjs"; import * as DirectUploadAPI from "./direct-upload.mjs"; import { BaseDirectUpload, DirectUpload, } from "./direct-upload.mjs"; import * as DownloadsAPI from "./downloads.mjs"; import { BaseDownloads, Downloads, } from "./downloads.mjs"; import * as EmbedAPI from "./embed.mjs"; import { BaseEmbed, Embed } from "./embed.mjs"; import * as KeysAPI from "./keys.mjs"; import { BaseKeys, } from "./keys.mjs"; import * as TokenAPI from "./token.mjs"; import { BaseToken, Token } from "./token.mjs"; import * as VideosAPI from "./videos.mjs"; import { BaseVideos, Videos } from "./videos.mjs"; import * as WatermarksAPI from "./watermarks.mjs"; import { BaseWatermarks, Watermarks, } from "./watermarks.mjs"; import * as WebhooksAPI from "./webhooks.mjs"; import { BaseWebhooks, Webhooks, } from "./webhooks.mjs"; import * as CaptionsAPI from "./captions/captions.mjs"; import { BaseCaptions, Captions } from "./captions/captions.mjs"; import * as LiveInputsAPI from "./live-inputs/live-inputs.mjs"; import { BaseLiveInputs, LiveInputs, } from "./live-inputs/live-inputs.mjs"; import { SinglePage } from "../../core/pagination.mjs"; import { buildHeaders } from "../../internal/headers.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseStream = /* @__PURE__ */ (() => { class BaseStream extends 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(path `/accounts/${account_id}/stream`, { query: { direct_user }, ...options, headers: 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(path `/accounts/${account_id}/stream`, (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(path `/accounts/${account_id}/stream/${identifier}`, { ...options, headers: 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(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(path `/accounts/${account_id}/stream/${identifier}`, options)._thenUnwrap((obj) => obj.result); } } BaseStream._key = Object.freeze(['stream']); return BaseStream; })(); export 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 = AudioTracks; Stream.BaseAudioTracks = BaseAudioTracks; Stream.Videos = Videos; Stream.BaseVideos = BaseVideos; Stream.Clip = Clip; Stream.BaseClip = BaseClip; Stream.Copy = Copy; Stream.BaseCopy = BaseCopy; Stream.DirectUpload = DirectUpload; Stream.BaseDirectUpload = BaseDirectUpload; Stream.BaseKeys = BaseKeys; Stream.LiveInputs = LiveInputs; Stream.BaseLiveInputs = BaseLiveInputs; Stream.Watermarks = Watermarks; Stream.BaseWatermarks = BaseWatermarks; Stream.Webhooks = Webhooks; Stream.BaseWebhooks = BaseWebhooks; Stream.Captions = Captions; Stream.BaseCaptions = BaseCaptions; Stream.Downloads = Downloads; Stream.BaseDownloads = BaseDownloads; Stream.Embed = Embed; Stream.BaseEmbed = BaseEmbed; Stream.Token = Token; Stream.BaseToken = BaseToken; return Stream; })(); //# sourceMappingURL=stream.mjs.map