Skip to content

Commit

Permalink
chore: fix TS error
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Oct 10, 2022
1 parent dc5f61b commit 1860fdd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 77 deletions.
65 changes: 45 additions & 20 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,12 @@ import {createPlugin} from 'sanity'

import ErrorBoundaryCard from './components/ErrorBoundaryCard'
import {AspectRatioCard, InputFallback} from './components/Input.styled'
import muxVideo from './schema/mux.video'
import videoAsset from './schema/mux.videoAsset'
import {isMuxInputPreviewProps, isMuxInputProps} from './util/asserters'
import {type Config} from './util/types'

const Input = lazy(() => import('./components/Input'))
const Preview = lazy(() => import('./components/Preview'))

/*
// @TODO use declaration merging to allow correct typings for userland schemas when they use type: mux.video
declare module 'sanity' {
namespace Schema {
}
}
// */

/* @TODO export validation rules for: required (checks if the video asset is defined), and that it has a ready uploaded file
export const validation = {
required(Rule: Rule) {
return
}
}
// */

export const defaultConfig: Config = {
mp4_support: 'none',
}
Expand Down Expand Up @@ -63,7 +44,51 @@ export const muxInput = createPlugin<Partial<Config> | void>((userConfig) => {
return next(props)
},
},
schema: {types: [muxVideo, videoAsset]},
schema: {
types: [
{
name: 'mux.video',
type: 'object',
title: 'Video asset reference',
fields: [
{
title: 'Video',
name: 'asset',
type: 'reference',
weak: true,
to: [{type: 'mux.videoAsset'}],
},
],
},
{
name: 'mux.videoAsset',
type: 'object',
title: 'Video asset',
fields: [
{
type: 'string',
name: 'status',
},
{
type: 'string',
name: 'assetId',
},
{
type: 'string',
name: 'playbackId',
},
{
type: 'string',
name: 'filename',
},
{
type: 'number',
name: 'thumbTime',
},
],
},
],
},
}
})

Expand Down
22 changes: 0 additions & 22 deletions src/schema/mux.video.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/schema/mux.videoAsset.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/util/asserters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
isObjectSchemaType,
} from 'sanity'

import {name} from '../schema/mux.video'
import type {MuxInputPreviewProps, MuxInputProps} from './types'

export function isMuxInputProps(props: InputProps): props is MuxInputProps {
return (
isObjectSchemaType(props.schemaType) && props.schemaType.type?.name === name
isObjectSchemaType(props.schemaType) &&
props.schemaType.type?.name === 'mux.video'
)
}

Expand Down

2 comments on commit 1860fdd

@vercel
Copy link

@vercel vercel bot commented on 1860fdd Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sanity-plugin-mux-input-codesandbox – ./example

mux-player-codesandbox.sanity.build
sanity-plugin-mux-input-codesandbox.sanity.build
sanity-plugin-mux-input-codesandbox-git-main.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 1860fdd Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sanity-plugin-mux-input – ./

sanity-plugin-mux-input.sanity.build
sanity-plugin-mux-input-git-main.sanity.build

Please sign in to comment.