sanity-plugin-mux-input 3.0.5 → 4.0.0

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.
Files changed (123) hide show
  1. package/dist/index.js +28 -28
  2. package/dist/index.js.map +1 -1
  3. package/package.json +5 -15
  4. package/dist/index.cjs +0 -5746
  5. package/dist/index.cjs.map +0 -1
  6. package/dist/index.d.cts +0 -288
  7. package/dist/index.d.cts.map +0 -1
  8. package/sanity.json +0 -8
  9. package/src/_exports/index.ts +0 -73
  10. package/src/actions/assets.ts +0 -152
  11. package/src/actions/secrets.ts +0 -110
  12. package/src/actions/upload.ts +0 -308
  13. package/src/clients/upChunkObservable.ts +0 -54
  14. package/src/components/AddCaptionDialog.tsx +0 -440
  15. package/src/components/CaptionsDialog.tsx +0 -23
  16. package/src/components/ConfigureApi.styled.tsx +0 -19
  17. package/src/components/ConfigureApi.tsx +0 -296
  18. package/src/components/DraggableWatermark.tsx +0 -885
  19. package/src/components/EditCaptionDialog.tsx +0 -511
  20. package/src/components/EditThumbnailDialog.tsx +0 -121
  21. package/src/components/ErrorBoundaryCard.tsx +0 -97
  22. package/src/components/FileInputButton.tsx +0 -54
  23. package/src/components/FileInputMenuItem.styled.tsx +0 -36
  24. package/src/components/FileInputMenuItem.tsx +0 -85
  25. package/src/components/FormField.tsx +0 -38
  26. package/src/components/IconInfo.tsx +0 -22
  27. package/src/components/ImportVideosFromMux.tsx +0 -339
  28. package/src/components/Input.styled.tsx +0 -22
  29. package/src/components/Input.tsx +0 -78
  30. package/src/components/InputBrowser.tsx +0 -41
  31. package/src/components/MuxLogo.tsx +0 -42
  32. package/src/components/Onboard.tsx +0 -65
  33. package/src/components/PageSelector.tsx +0 -54
  34. package/src/components/Player.styled.tsx +0 -11
  35. package/src/components/Player.tsx +0 -117
  36. package/src/components/PlayerActionsMenu.tsx +0 -191
  37. package/src/components/ResyncMetadata.tsx +0 -278
  38. package/src/components/SelectAsset.tsx +0 -39
  39. package/src/components/SelectSortOptions.tsx +0 -45
  40. package/src/components/SpinnerBox.tsx +0 -16
  41. package/src/components/StudioTool.tsx +0 -24
  42. package/src/components/TextTracksEditor.tsx +0 -117
  43. package/src/components/TextTracksManager.tsx +0 -738
  44. package/src/components/UploadConfiguration.tsx +0 -696
  45. package/src/components/UploadPlaceholder.tsx +0 -88
  46. package/src/components/UploadProgress.tsx +0 -80
  47. package/src/components/Uploader.styled.tsx +0 -65
  48. package/src/components/Uploader.tsx +0 -499
  49. package/src/components/VideoDetails/DeleteDialog.tsx +0 -148
  50. package/src/components/VideoDetails/VideoDetails.tsx +0 -358
  51. package/src/components/VideoDetails/VideoReferences.tsx +0 -63
  52. package/src/components/VideoDetails/useVideoDetails.ts +0 -103
  53. package/src/components/VideoInBrowser.tsx +0 -245
  54. package/src/components/VideoMetadata.tsx +0 -45
  55. package/src/components/VideoPlayer.tsx +0 -241
  56. package/src/components/VideoThumbnail.tsx +0 -139
  57. package/src/components/VideosBrowser.tsx +0 -100
  58. package/src/components/documentPreview/DocumentPreview.tsx +0 -84
  59. package/src/components/documentPreview/DraftStatus.tsx +0 -34
  60. package/src/components/documentPreview/MissingSchemaType.tsx +0 -32
  61. package/src/components/documentPreview/PaneItemPreview.tsx +0 -67
  62. package/src/components/documentPreview/PublishedStatus.tsx +0 -35
  63. package/src/components/documentPreview/TimeAgo.tsx +0 -12
  64. package/src/components/icons/Audio.tsx +0 -13
  65. package/src/components/icons/Resolution.tsx +0 -12
  66. package/src/components/icons/StopWatch.tsx +0 -20
  67. package/src/components/icons/ToolIcon.tsx +0 -19
  68. package/src/components/uploadConfiguration/PlaybackPolicy.tsx +0 -133
  69. package/src/components/uploadConfiguration/PlaybackPolicyOption.tsx +0 -76
  70. package/src/components/uploadConfiguration/PlaybackPolicyWarning.tsx +0 -29
  71. package/src/components/uploadConfiguration/ResolutionTierSelector.tsx +0 -72
  72. package/src/components/uploadConfiguration/StaticRenditionSelector.tsx +0 -180
  73. package/src/components/withFocusRing/helpers.ts +0 -24
  74. package/src/components/withFocusRing/index.ts +0 -1
  75. package/src/components/withFocusRing/withFocusRing.ts +0 -30
  76. package/src/context/DialogStateContext.tsx +0 -33
  77. package/src/context/DrmPlaybackWarningContext.tsx +0 -97
  78. package/src/hooks/useAccessControl.ts +0 -13
  79. package/src/hooks/useAssetDocumentValues.ts +0 -11
  80. package/src/hooks/useAssets.ts +0 -73
  81. package/src/hooks/useCancelUpload.ts +0 -22
  82. package/src/hooks/useClient.ts +0 -8
  83. package/src/hooks/useDialogState.ts +0 -11
  84. package/src/hooks/useDocReferences.ts +0 -21
  85. package/src/hooks/useFetchFileSize.ts +0 -55
  86. package/src/hooks/useImportMuxAssets.ts +0 -132
  87. package/src/hooks/useInView.ts +0 -41
  88. package/src/hooks/useMediaMetadata.ts +0 -104
  89. package/src/hooks/useMuxAssets.ts +0 -179
  90. package/src/hooks/useMuxPolling.ts +0 -52
  91. package/src/hooks/useResyncAsset.ts +0 -110
  92. package/src/hooks/useResyncMuxMetadata.ts +0 -169
  93. package/src/hooks/useSaveSecrets.ts +0 -78
  94. package/src/hooks/useSecretsDocumentValues.ts +0 -38
  95. package/src/hooks/useSecretsFormState.ts +0 -47
  96. package/src/plugin.tsx +0 -31
  97. package/src/sanity-ui.d.ts +0 -5
  98. package/src/schema.ts +0 -196
  99. package/src/util/addKeysToMuxData.ts +0 -30
  100. package/src/util/asserters.ts +0 -23
  101. package/src/util/assetTitlePlaceholder.ts +0 -31
  102. package/src/util/constants.ts +0 -15
  103. package/src/util/convertWatermarkToMux.ts +0 -160
  104. package/src/util/createSearchFilter.ts +0 -76
  105. package/src/util/createUrlParamsObject.ts +0 -29
  106. package/src/util/extractFiles.ts +0 -67
  107. package/src/util/formatBytes.ts +0 -31
  108. package/src/util/formatDriveShareLink.ts +0 -64
  109. package/src/util/formatSeconds.ts +0 -48
  110. package/src/util/generateJwt.ts +0 -57
  111. package/src/util/getAnimatedPosterSrc.ts +0 -26
  112. package/src/util/getPlaybackPolicy.ts +0 -69
  113. package/src/util/getPosterSrc.ts +0 -28
  114. package/src/util/getVideoMetadata.ts +0 -23
  115. package/src/util/getVideoSrc.ts +0 -23
  116. package/src/util/parsers.ts +0 -5
  117. package/src/util/pluginVersion.ts +0 -5
  118. package/src/util/readSecrets.ts +0 -38
  119. package/src/util/roundPxString.ts +0 -16
  120. package/src/util/textTracks.ts +0 -222
  121. package/src/util/tryWithSuspend.ts +0 -22
  122. package/src/util/types.ts +0 -566
  123. package/v2-incompatible.js +0 -11
package/dist/index.d.cts DELETED
@@ -1,288 +0,0 @@
1
- import MuxPlayerElement from "@mux/mux-player";
2
- import { PartialDeep } from "type-fest";
3
- /**
4
- * All static rendition resolution options supported by Mux
5
- */
6
- type StaticRenditionResolution = 'highest' | 'audio-only' | '270p' | '360p' | '480p' | '540p' | '720p' | '1080p' | '1440p' | '2160p';
7
- interface MuxInputConfig {
8
- /**
9
- * Enable static renditions by default. Can be overwritten on a per-asset basis.
10
- * Supports:
11
- * - Standard mode: 'highest' (up to 4K MP4) and/or 'audio-only' (M4A)
12
- * - Advanced mode: Specific resolutions ('270p', '360p', '480p', '540p', '720p', '1080p', '1440p', '2160p') and/or 'audio-only'
13
- *
14
- * **Important**: 'highest' cannot be mixed with specific resolutions. If both are provided, only 'highest' will be used.
15
- *
16
- * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions}
17
- * @defaultValue []
18
- */
19
- static_renditions: StaticRenditionResolution[];
20
- /**
21
- * @deprecated Use `static_renditions` instead. This field is kept for backward compatibility.
22
- * Enable static renditions by setting this to 'standard'. Can be overwritten on a per-asset basis.
23
- * Requires `"video_quality": "plus"`
24
- * @see {@link https://docs.mux.com/guides/video/enable-static-mp4-renditions#why-enable-mp4-support}
25
- * @defaultValue 'none'
26
- */
27
- mp4_support: 'none' | 'standard';
28
- /**
29
- * Max resolution tier can be used to control the maximum resolution_tier your asset is encoded, stored, and streamed at.
30
- * Requires `"video_quality": "plus"`
31
- * @see {@link https://docs.mux.com/guides/stream-videos-in-4k}
32
- * @defaultValue '1080p'
33
- */
34
- max_resolution_tier: '2160p' | '1440p' | '1080p';
35
- /**
36
- * @deprecated Use {@link video_quality}
37
- * <br>
38
- * The encoding tier informs the cost, quality, and available platform features for the asset.
39
- * @see {@link https://docs.mux.com/guides/use-encoding-tiers}
40
- * @defaultValue 'smart'
41
- */
42
- encoding_tier?: 'baseline' | 'smart';
43
- /**
44
- * The video quality level informs the cost, quality, and available platform features for the asset.
45
- * @see {@link https://www.mux.com/docs/guides/use-video-quality-levels}
46
- * @defaultValue 'plus'
47
- */
48
- video_quality: 'basic' | 'plus' | 'premium';
49
- /**
50
- * Normalize the audio track loudness level.
51
- * @see {@link https://docs.mux.com/guides/adjust-audio-levels#how-to-turn-on-audio-normalization}
52
- * @defaultValue false
53
- */
54
- normalize_audio: boolean;
55
- /**
56
- * Enables signed URLs by default, if you configured them with your API token.
57
- * @see {@link https://docs.mux.com/guides/secure-video-playback}
58
- * @defaultValue false
59
- */
60
- defaultSigned?: boolean;
61
- /**
62
- * Enables public URLs by default.
63
- * @defaultValue true
64
- */
65
- defaultPublic?: boolean;
66
- /**
67
- * Enables DRM Protection by default, if you configured your DRM Configuration Id.
68
- * @see {@link https://www.mux.com/docs/guides/protect-videos-with-drm}
69
- * @defaultValue true
70
- */
71
- defaultDrm?: boolean;
72
- /**
73
- * Auto-generate captions for these languages by default.
74
- * Requires `"video_quality": "plus"`
75
- *
76
- * @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
77
- * @deprecated use `defaultAutogeneratedSubtitleLang` instead. Only a single autogenerated
78
- */
79
- defaultAutogeneratedSubtitleLangs?: SupportedMuxLanguage[];
80
- /**
81
- * Auto-generate captions for this language by default. Users can still
82
- * Requires `"video_quality": "plus"`
83
- *
84
- * @see {@link https://docs.mux.com/guides/add-autogenerated-captions-and-use-transcripts}
85
- */
86
- defaultAutogeneratedSubtitleLang?: SupportedMuxLanguage;
87
- /**
88
- * Whether or not to allow content editors to override asset upload
89
- * configuration settings when uploading a video to Mux.
90
- *
91
- * @see {@link https://docs.mux.com/guides/secure-video-playback}
92
- * @defaultValue false
93
- */
94
- disableUploadConfig?: boolean;
95
- /**
96
- * Whether or not to allow content editors to add text tracks alongside their
97
- * asset when uploading a video to Mux.
98
- *
99
- * @see {@link https://docs.mux.com/guides/secure-video-playback}
100
- * @defaultValue false
101
- */
102
- disableTextTrackConfig?: boolean;
103
- /**
104
- * Whether or not to show the playback warning when trying to watch DRM content for the first time.
105
- *
106
- * @defaultValue false
107
- */
108
- disableDrmPlaybackWarning?: boolean;
109
- /**
110
- * The mime types that are accepted by the input.
111
- *
112
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept}
113
- * @defaultValue ['video/*','audio/*']
114
- */
115
- acceptedMimeTypes?: ('audio/*' | 'video/*')[];
116
- /**
117
- * Maximum file size allowed for video uploads in bytes.
118
- * If not specified, no file size validation will be performed.
119
- *
120
- * @example 1024 * 1024 * 1024 // 1 GB
121
- * @defaultValue undefined
122
- */
123
- maxAssetFileSize?: number;
124
- /**
125
- * Maximum video duration allowed in seconds.
126
- * If not specified, no duration validation will be performed.
127
- *
128
- * @example 2 * 60 * 60 // 2 hours
129
- * @defaultValue undefined
130
- */
131
- maxAssetDuration?: number;
132
- /**
133
- * HLS.js configuration options to be passed to the Mux Player.
134
- * These options allow you to customize the underlying HLS.js playback engine behavior.
135
- *
136
- * @see {@link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning}
137
- * @defaultValue undefined
138
- * @example
139
- * ```ts
140
- * {
141
- * maxBufferLength: 30,
142
- * lowLatencyMode: true,
143
- * capLevelToPlayerSize: true
144
- * }
145
- * ```
146
- */
147
- hlsConfig?: MuxPlayerElement['_hlsConfig'];
148
- }
149
- interface PluginConfig extends MuxInputConfig {
150
- /**
151
- * How the videos browser should appear as a studio tool in Sanity's top navigation
152
- *
153
- * Pass `false` if you want to disable it.
154
- * @defaultValue {title: 'Videos', icon: VideoIcon}
155
- **/
156
- tool: false | {
157
- title?: string;
158
- icon?: React.ComponentType;
159
- };
160
- /**
161
- * The roles that are allowed to configure the plugin.
162
- *
163
- * If not set, all roles will be allowed to configure the plugin.
164
- * @defaultValue []
165
- */
166
- allowedRolesForConfiguration: string[];
167
- }
168
- declare const SUPPORTED_MUX_LANGUAGES_VALUES: ("en" | "es" | "it" | "pt" | "de" | "fr" | "pl" | "ru" | "nl" | "ca" | "tr" | "sv" | "uk" | "no" | "fi" | "sk" | "el" | "cs" | "hr" | "da" | "ro" | "bg")[];
169
- type SupportedMuxLanguage = (typeof SUPPORTED_MUX_LANGUAGES_VALUES)[number];
170
- type PlaybackPolicy = 'signed' | 'public' | 'drm';
171
- interface MuxErrors {
172
- type: string;
173
- messages: string[];
174
- }
175
- interface MuxPlaybackId {
176
- id: string;
177
- policy: PlaybackPolicy;
178
- }
179
- interface MuxVideoTrack {
180
- type: 'video';
181
- id: string;
182
- max_width: number;
183
- max_height: number;
184
- max_frame_rate: -1 | number;
185
- duration?: number;
186
- }
187
- interface MuxAudioTrack {
188
- type: 'audio';
189
- id: string;
190
- duration?: number;
191
- max_channels: number;
192
- max_channel_layout: 'stereo' | string;
193
- }
194
- interface MuxTextTrack {
195
- type: 'text';
196
- id: string;
197
- text_type?: 'subtitles';
198
- text_source?: 'uploaded' | 'embedded' | 'generated_live' | 'generated_live_final' | 'generated_vod';
199
- language_code?: 'en' | 'en-US' | string;
200
- name?: 'English' | string;
201
- closed_captions?: boolean;
202
- passthrough?: string;
203
- status: 'preparing' | 'ready' | 'errored';
204
- error?: {
205
- type: string;
206
- messages?: string[];
207
- };
208
- }
209
- type MuxTrack = MuxVideoTrack | MuxAudioTrack | MuxTextTrack;
210
- interface MuxAsset {
211
- id: string;
212
- /** In seconds (instead of JS's default milliseconds) */
213
- created_at: string;
214
- status: 'preparing' | 'ready' | 'errored';
215
- duration: number;
216
- max_stored_resolution: 'Audio only' | 'SD' | 'HD' | 'FHD' | 'UHD';
217
- max_stored_frame_rate: -1 | number;
218
- aspect_ratio: `${number}:${number}`;
219
- playback_ids: MuxPlaybackId[];
220
- tracks: MuxTrack[];
221
- errors?: MuxErrors;
222
- upload_id: string;
223
- is_live?: boolean;
224
- passthrough: string;
225
- live_stream_id?: string;
226
- master?: {
227
- status: 'ready' | 'preparing' | 'errored';
228
- url: string;
229
- };
230
- master_access: 'temporary' | 'none';
231
- mp4_support: 'standard' | 'none';
232
- source_asset_id?: string;
233
- normalize_audio?: boolean;
234
- static_renditions?: {
235
- status: 'ready' | 'preparing' | 'disabled' | 'errored';
236
- files: {
237
- name: string;
238
- ext: 'mp4' | 'm4a';
239
- height: number;
240
- width: number;
241
- bitrate: number;
242
- filesize: string;
243
- type: 'standard' | 'advanced';
244
- status: 'ready' | 'preparing' | 'skipped' | 'errored';
245
- resolution_tier?: string;
246
- resolution?: string;
247
- id: string;
248
- passthrough?: string;
249
- }[];
250
- };
251
- recording_times?: {
252
- started_at: string;
253
- duration: number;
254
- type: 'content' | 'slate';
255
- }[];
256
- non_standard_input_reasons?: {
257
- video_codec?: string;
258
- audio_codec?: string;
259
- video_gop_size?: 'high';
260
- video_frame_rate?: string;
261
- video_resolution?: string;
262
- video_bitrate?: 'high';
263
- pixel_aspect_ratio?: string;
264
- video_edit_list?: 'non-standard';
265
- audio_edit_list?: 'non-standard';
266
- unexpected_media_file_parameters?: 'non-standard';
267
- test?: boolean;
268
- };
269
- meta?: {
270
- title?: string;
271
- };
272
- }
273
- interface VideoAssetDocument {
274
- _id: string;
275
- _type: 'mux.videoAsset';
276
- _createdAt: string;
277
- _updatedAt?: string;
278
- status?: string;
279
- assetId?: string;
280
- playbackId?: string;
281
- filename?: string;
282
- thumbTime?: number;
283
- data?: PartialDeep<MuxAsset>;
284
- }
285
- declare const defaultConfig: PluginConfig;
286
- declare const muxInput: import("sanity").Plugin<void | Partial<PluginConfig>>;
287
- export { type VideoAssetDocument, defaultConfig, muxInput };
288
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,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}
package/sanity.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "parts": [
3
- {
4
- "implements": "part:@sanity/base/sanity-root",
5
- "path": "./v2-incompatible.js"
6
- }
7
- ]
8
- }
@@ -1,73 +0,0 @@
1
- import {definePlugin} from 'sanity'
2
-
3
- import createStudioTool, {DEFAULT_TOOL_CONFIG} from '../components/StudioTool'
4
- import {muxVideoCustomRendering} from '../plugin'
5
- import {muxVideoSchema, schemaTypes} from '../schema'
6
- import type {PluginConfig, StaticRenditionResolution} from '../util/types'
7
- export type {VideoAssetDocument} from '../util/types'
8
-
9
- export const defaultConfig: PluginConfig = {
10
- static_renditions: [],
11
- mp4_support: 'none',
12
- video_quality: 'plus',
13
- max_resolution_tier: '1080p',
14
- normalize_audio: false,
15
- defaultPublic: true,
16
- defaultSigned: false,
17
- defaultDrm: false,
18
- tool: DEFAULT_TOOL_CONFIG,
19
- allowedRolesForConfiguration: [],
20
- acceptedMimeTypes: ['video/*', 'audio/*'],
21
- }
22
-
23
- /**
24
- * Converts legacy mp4_support configuration to static_renditions format
25
- */
26
- function convertLegacyConfig(config: Partial<PluginConfig>): {
27
- static_renditions: StaticRenditionResolution[]
28
- } {
29
- // If static_renditions is already provided, use it
30
- if (config.static_renditions && config.static_renditions.length > 0) {
31
- return {static_renditions: config.static_renditions}
32
- }
33
-
34
- // Convert legacy mp4_support to static_renditions
35
- if (config.mp4_support === 'standard') {
36
- return {static_renditions: ['highest']}
37
- }
38
-
39
- return {static_renditions: []}
40
- }
41
-
42
- export const muxInput = definePlugin<Partial<PluginConfig> | void>((userConfig) => {
43
- // TODO: Remove this on next major version when we end support for encoding_tier
44
- if (typeof userConfig === 'object' && 'encoding_tier' in userConfig) {
45
- const deprecated_encoding_tier = userConfig.encoding_tier
46
- if (!userConfig.video_quality) {
47
- if (deprecated_encoding_tier === 'baseline') {
48
- userConfig.video_quality = 'basic'
49
- }
50
- if (deprecated_encoding_tier === 'smart') {
51
- userConfig.video_quality = 'plus'
52
- }
53
- }
54
- }
55
- const config: PluginConfig = {
56
- ...defaultConfig,
57
- ...userConfig,
58
- ...convertLegacyConfig(userConfig || {}),
59
- }
60
- return {
61
- name: 'mux-input',
62
- schema: {
63
- types: [
64
- ...schemaTypes,
65
- {
66
- ...muxVideoSchema,
67
- ...muxVideoCustomRendering(config),
68
- },
69
- ],
70
- },
71
- tools: config.tool === false ? undefined : [createStudioTool(config)],
72
- }
73
- })
@@ -1,152 +0,0 @@
1
- import type {SanityClient} from 'sanity'
2
-
3
- import {PLUGIN_VERSION_QUERY} from '../util/pluginVersion'
4
- import type {MuxAsset, VideoAssetDocument} from '../util/types'
5
-
6
- export function deleteAssetOnMux(client: SanityClient, assetId: string) {
7
- const {dataset} = client.config()
8
- return client.request<void>({
9
- url: `/addons/mux/assets/${dataset}/${assetId}`,
10
- withCredentials: true,
11
- method: 'DELETE',
12
- query: PLUGIN_VERSION_QUERY,
13
- })
14
- }
15
-
16
- export async function deleteAsset({
17
- client,
18
- asset,
19
- deleteOnMux,
20
- }: {
21
- client: SanityClient
22
- asset: VideoAssetDocument
23
- deleteOnMux: boolean
24
- }) {
25
- if (!asset?._id) return true
26
-
27
- try {
28
- await client.delete(asset._id)
29
- } catch {
30
- return 'failed-sanity'
31
- }
32
-
33
- if (deleteOnMux && asset?.assetId) {
34
- try {
35
- await deleteAssetOnMux(client, asset.assetId)
36
- } catch {
37
- return 'failed-mux'
38
- }
39
- }
40
-
41
- return true
42
- }
43
-
44
- export function getAsset(client: SanityClient, assetId: string) {
45
- const {dataset} = client.config()
46
- return client.request<{data: MuxAsset}>({
47
- url: `/addons/mux/assets/${dataset}/data/${assetId}`,
48
- withCredentials: true,
49
- method: 'GET',
50
- query: PLUGIN_VERSION_QUERY,
51
- })
52
- }
53
-
54
- export function listAssets(
55
- client: SanityClient,
56
- options: {limit?: number; cursor?: string | null},
57
- ) {
58
- const {dataset} = client.config()
59
- const query: {limit?: string; cursor?: string} = {}
60
-
61
- if (options.limit) {
62
- query.limit = options.limit.toString()
63
- }
64
- if (options.cursor) {
65
- query.cursor = options.cursor
66
- }
67
-
68
- return client.request<{data: MuxAsset[]; next_cursor?: string | null}>({
69
- url: `/addons/mux/assets/${dataset}/data/list`,
70
- withCredentials: true,
71
- method: 'GET',
72
- query: {...query, ...PLUGIN_VERSION_QUERY},
73
- })
74
- }
75
-
76
- /**
77
- * Adds a new text track to an existing asset using a VTT file URL
78
- */
79
- export function addTextTrackFromUrl(
80
- client: SanityClient,
81
- assetId: string,
82
- vttUrl: string,
83
- options: {
84
- language_code: string
85
- name: string
86
- text_type?: 'subtitles'
87
- },
88
- ) {
89
- const {dataset} = client.config()
90
-
91
- return client.request<{data: MuxAsset}>({
92
- url: `/addons/mux/assets/${dataset}/${assetId}/tracks`,
93
- withCredentials: true,
94
- method: 'POST',
95
- body: {
96
- url: vttUrl,
97
- type: 'text',
98
- language_code: options.language_code,
99
- name: options.name,
100
- text_type: options.text_type || 'subtitles',
101
- },
102
- headers: {
103
- 'Content-Type': 'application/json',
104
- },
105
- query: PLUGIN_VERSION_QUERY,
106
- })
107
- }
108
-
109
- /**
110
- * Generates subtitles automatically for an audio track
111
- */
112
- export function generateSubtitles(
113
- client: SanityClient,
114
- assetId: string,
115
- audioTrackId: string,
116
- options: {
117
- language_code: string
118
- name: string
119
- },
120
- ) {
121
- const {dataset} = client.config()
122
- return client.request<{data: MuxAsset}>({
123
- url: `/addons/mux/assets/${dataset}/${assetId}/tracks/${audioTrackId}/generate-subtitles`,
124
- withCredentials: true,
125
- method: 'POST',
126
- body: {
127
- generated_subtitles: [
128
- {
129
- language_code: options.language_code,
130
- name: options.name,
131
- },
132
- ],
133
- },
134
- headers: {
135
- 'Content-Type': 'application/json',
136
- },
137
- query: PLUGIN_VERSION_QUERY,
138
- })
139
- }
140
-
141
- /**
142
- * Deletes a text track from an asset
143
- */
144
- export function deleteTextTrack(client: SanityClient, assetId: string, trackId: string) {
145
- const {dataset} = client.config()
146
- return client.request<{data: MuxAsset}>({
147
- url: `/addons/mux/assets/${dataset}/${assetId}/tracks/${trackId}`,
148
- withCredentials: true,
149
- method: 'DELETE',
150
- query: PLUGIN_VERSION_QUERY,
151
- })
152
- }
@@ -1,110 +0,0 @@
1
- import {defer} from 'rxjs'
2
- import type {SanityClient} from 'sanity'
3
-
4
- import {PLUGIN_VERSION_QUERY} from '../util/pluginVersion'
5
-
6
- interface SecretsDocument {
7
- _id: 'secrets.mux'
8
- _type: 'mux.apiKey'
9
- token: string
10
- secretKey: string
11
- enableSignedUrls: boolean
12
- signingKeyId: string
13
- signingKeyPrivate: string
14
- drmConfigId: string
15
- }
16
- export function saveSecrets(
17
- client: SanityClient,
18
- token: string,
19
- secretKey: string,
20
- enableSignedUrls: boolean,
21
- signingKeyId: string,
22
- signingKeyPrivate: string,
23
- drmConfigId: string,
24
- ): Promise<SecretsDocument> {
25
- const doc: SecretsDocument = {
26
- _id: 'secrets.mux',
27
- _type: 'mux.apiKey',
28
- token,
29
- secretKey,
30
- enableSignedUrls,
31
- signingKeyId,
32
- signingKeyPrivate,
33
- drmConfigId,
34
- }
35
- doc.signingKeyId = enableSignedUrls ? signingKeyId : ''
36
- doc.signingKeyPrivate = enableSignedUrls ? signingKeyPrivate : ''
37
-
38
- return client.createOrReplace(doc)
39
- }
40
-
41
- export async function createSigningKeys(client: SanityClient) {
42
- try {
43
- const {dataset} = client.config()
44
- const res = await client.request<{
45
- data: {private_key: string; id: string; created_at: string}
46
- }>({
47
- url: `/addons/mux/signing-keys/${dataset}`,
48
- withCredentials: true,
49
- method: 'POST',
50
- query: PLUGIN_VERSION_QUERY,
51
- })
52
- return res
53
- } catch (error: any) {
54
- console.error('Error creating signing keys', error)
55
- const message =
56
- error.response?.statusCode === 401
57
- ? 'Unauthorized - Failed to create the Signing Key. Please ensure that the token has "System" permissions'
58
- : error.message
59
- throw new Error(message, {cause: error})
60
- }
61
- }
62
-
63
- export function testSecrets(client: SanityClient) {
64
- const {dataset} = client.config()
65
- return client.request<{status: boolean}>({
66
- url: `/addons/mux/secrets/${dataset}/test`,
67
- withCredentials: true,
68
- method: 'GET',
69
- query: PLUGIN_VERSION_QUERY,
70
- })
71
- }
72
-
73
- export async function haveValidSigningKeys(
74
- client: SanityClient,
75
- signingKeyId: string,
76
- signingKeyPrivate: string,
77
- ) {
78
- if (!(signingKeyId && signingKeyPrivate)) {
79
- return false
80
- }
81
-
82
- const {dataset} = client.config()
83
- try {
84
- const res = await client.request<{data: {id: string; created_at: string}}>({
85
- url: `/addons/mux/signing-keys/${dataset}/${signingKeyId}`,
86
- withCredentials: true,
87
- method: 'GET',
88
- query: PLUGIN_VERSION_QUERY,
89
- })
90
- //
91
- // if this signing key is valid it will return { data: { id: 'xxxx' } }
92
- //
93
- return !!(res.data && res.data.id)
94
- } catch (e) {
95
- console.error('Error fetching signingKeyId', signingKeyId, 'assuming it is not valid', e)
96
- return false
97
- }
98
- }
99
-
100
- export function testSecretsObservable(client: SanityClient) {
101
- const {dataset} = client.config()
102
- return defer(() =>
103
- client.observable.request<{status: boolean}>({
104
- url: `/addons/mux/secrets/${dataset}/test`,
105
- withCredentials: true,
106
- method: 'GET',
107
- query: PLUGIN_VERSION_QUERY,
108
- }),
109
- )
110
- }