Changeset View
Changeset View
Standalone View
Standalone View
lib/types/media-types.js
Show First 20 Lines • Show All 633 Lines • ▼ Show 20 Lines | export type MediaMission = { | ||||
+totalTime: number, | +totalTime: number, | ||||
}; | }; | ||||
export type Image = { | export type Image = { | ||||
+id: string, | +id: string, | ||||
+uri: string, | +uri: string, | ||||
+type: 'photo', | +type: 'photo', | ||||
+dimensions: Dimensions, | +dimensions: Dimensions, | ||||
+thumbHash: ?string, | |||||
// stored on native only during creation in case retry needed after state lost | // stored on native only during creation in case retry needed after state lost | ||||
+localMediaSelection?: NativeMediaSelection, | +localMediaSelection?: NativeMediaSelection, | ||||
}; | }; | ||||
export const imageValidator: TInterface<Image> = tShape<Image>({ | export const imageValidator: TInterface<Image> = tShape<Image>({ | ||||
id: tID, | id: tID, | ||||
uri: t.String, | uri: t.String, | ||||
type: tString('photo'), | type: tString('photo'), | ||||
dimensions: dimensionsValidator, | dimensions: dimensionsValidator, | ||||
thumbHash: t.maybe(t.String), | |||||
localMediaSelection: t.maybe(nativeMediaSelectionValidator), | localMediaSelection: t.maybe(nativeMediaSelectionValidator), | ||||
}); | }); | ||||
export type EncryptedImage = { | export type EncryptedImage = { | ||||
+id: string, | +id: string, | ||||
// a media URI for keyserver uploads / blob holder for Blob service uploads | // a media URI for keyserver uploads / blob holder for Blob service uploads | ||||
+holder: string, | +holder: string, | ||||
+encryptionKey: string, | +encryptionKey: string, | ||||
+type: 'encrypted_photo', | +type: 'encrypted_photo', | ||||
+dimensions: Dimensions, | +dimensions: Dimensions, | ||||
+thumbHash: ?string, | |||||
}; | }; | ||||
export const encryptedImageValidator: TInterface<EncryptedImage> = | export const encryptedImageValidator: TInterface<EncryptedImage> = | ||||
tShape<EncryptedImage>({ | tShape<EncryptedImage>({ | ||||
id: tID, | id: tID, | ||||
holder: t.String, | holder: t.String, | ||||
encryptionKey: t.String, | encryptionKey: t.String, | ||||
type: tString('encrypted_photo'), | type: tString('encrypted_photo'), | ||||
dimensions: dimensionsValidator, | dimensions: dimensionsValidator, | ||||
thumbHash: t.maybe(t.String), | |||||
}); | }); | ||||
export type Video = { | export type Video = { | ||||
+id: string, | +id: string, | ||||
+uri: string, | +uri: string, | ||||
+type: 'video', | +type: 'video', | ||||
+dimensions: Dimensions, | +dimensions: Dimensions, | ||||
+loop?: boolean, | +loop?: boolean, | ||||
+thumbnailID: string, | +thumbnailID: string, | ||||
+thumbnailURI: string, | +thumbnailURI: string, | ||||
+thumbnailThumbHash: ?string, | |||||
// stored on native only during creation in case retry needed after state lost | // stored on native only during creation in case retry needed after state lost | ||||
+localMediaSelection?: NativeMediaSelection, | +localMediaSelection?: NativeMediaSelection, | ||||
}; | }; | ||||
export const videoValidator: TInterface<Video> = tShape<Video>({ | export const videoValidator: TInterface<Video> = tShape<Video>({ | ||||
id: tID, | id: tID, | ||||
uri: t.String, | uri: t.String, | ||||
type: tString('video'), | type: tString('video'), | ||||
dimensions: dimensionsValidator, | dimensions: dimensionsValidator, | ||||
loop: t.maybe(t.Boolean), | loop: t.maybe(t.Boolean), | ||||
thumbnailID: tID, | thumbnailID: tID, | ||||
thumbnailURI: t.String, | thumbnailURI: t.String, | ||||
thumbnailThumbHash: t.maybe(t.String), | |||||
localMediaSelection: t.maybe(nativeMediaSelectionValidator), | localMediaSelection: t.maybe(nativeMediaSelectionValidator), | ||||
}); | }); | ||||
export type EncryptedVideo = { | export type EncryptedVideo = { | ||||
+id: string, | +id: string, | ||||
// a media URI for keyserver uploads / blob holder for Blob service uploads | // a media URI for keyserver uploads / blob holder for Blob service uploads | ||||
+holder: string, | +holder: string, | ||||
+encryptionKey: string, | +encryptionKey: string, | ||||
+type: 'encrypted_video', | +type: 'encrypted_video', | ||||
+dimensions: Dimensions, | +dimensions: Dimensions, | ||||
+loop?: boolean, | +loop?: boolean, | ||||
+thumbnailID: string, | +thumbnailID: string, | ||||
+thumbnailHolder: string, | +thumbnailHolder: string, | ||||
+thumbnailEncryptionKey: string, | +thumbnailEncryptionKey: string, | ||||
+thumbnailThumbHash: ?string, | |||||
}; | }; | ||||
export const encryptedVideoValidator: TInterface<EncryptedVideo> = | export const encryptedVideoValidator: TInterface<EncryptedVideo> = | ||||
tShape<EncryptedVideo>({ | tShape<EncryptedVideo>({ | ||||
id: tID, | id: tID, | ||||
holder: t.String, | holder: t.String, | ||||
encryptionKey: t.String, | encryptionKey: t.String, | ||||
type: tString('encrypted_video'), | type: tString('encrypted_video'), | ||||
dimensions: dimensionsValidator, | dimensions: dimensionsValidator, | ||||
loop: t.maybe(t.Boolean), | loop: t.maybe(t.Boolean), | ||||
thumbnailID: tID, | thumbnailID: tID, | ||||
thumbnailHolder: t.String, | thumbnailHolder: t.String, | ||||
thumbnailEncryptionKey: t.String, | thumbnailEncryptionKey: t.String, | ||||
thumbnailThumbHash: t.maybe(t.String), | |||||
}); | }); | ||||
export type Media = Image | Video | EncryptedImage | EncryptedVideo; | export type Media = Image | Video | EncryptedImage | EncryptedVideo; | ||||
export const mediaValidator: TUnion<Media> = t.union([ | export const mediaValidator: TUnion<Media> = t.union([ | ||||
imageValidator, | imageValidator, | ||||
videoValidator, | videoValidator, | ||||
encryptedImageValidator, | encryptedImageValidator, | ||||
encryptedVideoValidator, | encryptedVideoValidator, | ||||
]); | ]); |