Skip to content

Commit

Permalink
add more interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
chregu committed Mar 8, 2020
1 parent 234036e commit c9c30ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
37 changes: 31 additions & 6 deletions src/apis/sourceimages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,25 @@ interface GetQueryParams {
deleted?: boolean
}

interface MetaDataUser {
[key: string]: string | string[] | boolean | number
}

interface MetaDataDynamic {
[key: string]: { [key: string]: any } | undefined
version?: { text: string }
}

interface MetaDataOptions {
[key: string]: any
visual_binaryhash?: boolean
}

interface CreateMetadata {
[key: string]: any
meta_user?: any
meta_dynamic?: any
meta_user?: MetaDataUser
meta_dynamic?: MetaDataDynamic
options?: MetaDataUser
}

interface CreateOptions {
Expand All @@ -34,7 +49,13 @@ interface CreateOptions {
interface Sourceimage {
// we allow any key to keep it somehow compatible with changes in the backend
// gives less safety when TypeScript checking for wrong properties, but at least autocompletion
[key: string]: string | number | boolean | undefined
[key: string]:
| string
| number
| boolean
| undefined
| MetaDataDynamic
| MetaDataUser
hash: string
short_hash: string
binary_hash: string
Expand All @@ -47,14 +68,18 @@ interface Sourceimage {
height: number
organization: string
link: string
static_metadata?: any //FIXME
dynamic_metadata?: any //FIXME
user_metadata?: any //FIXME
static_metadata?: any
dynamic_metadata?: MetaDataDynamic
user_metadata?: MetaDataUser
opaque?: boolean
deleted?: boolean
}

interface SourceImagesListResponseBody extends RokkaListResponseBody {
items: Sourceimage[]
total: number
cursor: string
links: { prev?: { href: string }; next?: { href: string } }
}

interface SourceimagesListResponse extends RokkaListResponse {
Expand Down
2 changes: 1 addition & 1 deletion tests/apis/sourceimages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('sourceimages', () => {
expect(resp.body.items[0].hash).toBe(
'063c3dce6a528d8944a63185bd4c7b161454ee4f'
)
expect(resp.body.items[0].user_metadata.foo).toBe('bar')
expect(resp.body.items[0].user_metadata?.foo).toBe('bar')
})

it('sourceimages.delete', async () => {
Expand Down

0 comments on commit c9c30ff

Please sign in to comment.