Skip to content

Commit b09ee8b

Browse files
committed
chore: clean up blob variant types & naming
1 parent b918ce1 commit b09ee8b

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

lib/blob-store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LiveDownload } from './live-download.js'
99

1010
// prop = blob type name
1111
// value = array of blob variants supported for that type
12-
export const SUPPORTED_BLOB_TYPES = /** @type {const} */ ({
12+
export const SUPPORTED_BLOB_VARIANTS = /** @type {const} */ ({
1313
photo: ['original', 'preview', 'thumbnail'],
1414
audio: ['original'],
1515
video: ['original']

lib/types.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import type {
44
ValueOf,
55
RequireAtLeastOne,
66
} from 'type-fest'
7-
import { SUPPORTED_BLOB_TYPES } from './blob-store/index.js'
7+
import { SUPPORTED_BLOB_VARIANTS } from './blob-store/index.js'
88

9-
type SupportedBlobTypes = typeof SUPPORTED_BLOB_TYPES
10-
type BlobType = keyof SupportedBlobTypes
11-
type BlobVariant = TupleToUnion<SupportedBlobTypes[BlobType]>
9+
type SupportedBlobVariants = typeof SUPPORTED_BLOB_VARIANTS
10+
type BlobType = keyof SupportedBlobVariants
11+
type BlobVariant<TBlobType extends BlobType> = TupleToUnion<SupportedBlobVariants[TBlobType]>
1212

1313
type BlobIdBase<T extends BlobType> = {
1414
/** Type of blob */
1515
type: T
1616
/** Blob variant (some blob types have smaller previews and thumbnails available) */
17-
variant: TupleToUnion<SupportedBlobTypes[T]>
17+
variant: BlobVariant<T>
1818
/** unique identifier for blob (e.g. hash of content) */
1919
name: string
2020
/** public key as hex string of hyperdrive where blob is stored */
@@ -32,6 +32,6 @@ type ArrayAtLeastOne<T> = [T, ...T[]]
3232

3333
export type BlobFilter = RequireAtLeastOne<{
3434
[KeyType in BlobType]: ArrayAtLeastOne<
35-
TupleToUnion<SupportedBlobTypes[KeyType]>
35+
BlobVariant<KeyType>
3636
>
3737
}>

0 commit comments

Comments
 (0)