Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta_static interface and autodescription method to sourceimages API #85

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,19 @@ rokka.sourceimages.autolabel('myorg', 'c421f4e8cefe0fd3aab22832f51e85bacda0a47a'
.catch(function(err) {});
```

#### rokka.sourceimages.autodescription(organization, hash, languages, force)

Autodescribes an image. Can be used for alt attributes in img tags.

You need to be a paying customer to be able to use this.

```js
rokka.sourceimages.autodescription('myorg', 'c421f4e8cefe
0fd3aab22832f51e85bacda0a47a', ['en', 'de'], false)
.then(function(result) {})
.catch(function(err) {});
```

#### rokka.sourceimages.create(organization, fileName, binaryData, [metadata=null], [options={}]) → Promise

Upload an image.
Expand Down
42 changes: 42 additions & 0 deletions src/apis/sourceimages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface MetaDataUser {
[key: string]: string | string[] | boolean | number
}

export interface MetaStatic {
[key: string]: { [key: string]: any }
}

export interface MetaDataDynamic {
[key: string]: { [key: string]: any } | undefined
version?: { text: string }
Expand All @@ -45,6 +49,7 @@ interface CreateMetadata {
[key: string]: any
meta_user?: MetaDataUser
meta_dynamic?: MetaDataDynamic
meta_static?: MetaStatic
options?: MetaDataOptions
}

Expand Down Expand Up @@ -131,6 +136,12 @@ export interface APISourceimages {
hash: string,
) => Promise<RokkaDownloadAsBufferResponse>
autolabel: (organization: string, hash: string) => Promise<RokkaResponse>
autodescription: (
organization: string,
hash: string,
languages: string[],
force: boolean,
) => Promise<RokkaResponse>
create: (
organization: string,
fileName: string,
Expand Down Expand Up @@ -502,6 +513,37 @@ export default (state: State): { sourceimages: APISourceimages } => {
)
},

/**
* Autodescribes an image. Can be used for alt attributes in img tags.
*
* You need to be a paying customer to be able to use this.
*
* ```js
* rokka.sourceimages.autodescription('myorg', 'c421f4e8cefe
* 0fd3aab22832f51e85bacda0a47a', ['en', 'de'], false)
* .then(function(result) {})
* .catch(function(err) {});
* ```
*
* @authenticated
* @param {string} organization name
* @param {string} hash image hash
* @param {string[]} languages languages to autodescribe the image
* @param {boolean} force If it should be generated, even if already exists
*/
autodescription: (
organization: string,
hash: string,
languages: string[],
force = false,
): Promise<RokkaResponse> => {
return state.request(
'POST',
`sourceimages/${organization}/${hash}/autodescription`,
{ languages, force },
)
},

/**
* Upload an image.
*
Expand Down
Loading