Skip to content

Commit

Permalink
fix: Mux node SDK upgrade (#73)
Browse files Browse the repository at this point in the history
* fix: upgrade mux/mux-node to latest canary

* fix: type errors and tests from Mux sdk upgrade
  • Loading branch information
luwes authored Oct 17, 2023
1 parent ce28e48 commit fdb10c1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 55 deletions.
64 changes: 13 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
},
"dependencies": {
"@inquirer/prompts": "^3.2.0",
"@mux/mux-node": "https://github.com/stainless-sdks/mux-node.git#8.0.0-beta.1",
"@mux/mux-node": "8.0.0-canary.0",
"@mux/mux-player-react": "2.0.1",
"@next/env": "^13.5.4",
"chalk": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default async function handleVideoAdded(asset: Asset) {
const processingAsset = await updateAsset(src, {
status: 'processing',
externalIds: {
assetId: assetObj.id,
assetId: assetObj.id!,
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/local-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function pollForAssetReady(filePath: string, asset: Asset) {
const assetId = asset.externalIds?.assetId;

const muxAsset = await mux.video.assets.retrieve(assetId);
const playbackId = muxAsset.playback_ids?.[0].id;
const playbackId = muxAsset.playback_ids?.[0].id!;

let updatedAsset: Asset = asset;
if (asset.externalIds?.playbackId !== playbackId) {
Expand Down Expand Up @@ -156,7 +156,7 @@ export default async function uploadLocalFile(asset: Asset) {
const processingAsset = await updateAsset(src, {
status: 'processing',
externalIds: {
assetId: assetObj.id,
assetId: assetObj.id!,
},
});

Expand Down
9 changes: 9 additions & 0 deletions tests/utils/fake-mux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const get = (url: string, options: any = {}) => {

if (objectType === 'uploads') {
return {
_thenUnwrap(transform) {
return transform(this);
},
data: {
id: id,
asset_id: `fake-asset-id-${generateRandomString()}`,
Expand All @@ -16,6 +19,9 @@ export const get = (url: string, options: any = {}) => {

if (objectType === 'assets') {
return {
_thenUnwrap(transform) {
return transform(this);
},
data: {
id: id,
status: 'ready',
Expand All @@ -32,6 +38,9 @@ export const post = (url: string, options: any = {}) => {

if (objectType === 'uploads') {
return {
_thenUnwrap(transform) {
return transform(this);
},
data: {
id: `fake-upload-${fakeId}`,
url: `http://localhost:3123/fake-upload-url-${fakeId}`,
Expand Down

0 comments on commit fdb10c1

Please sign in to comment.