# trovir-javascript-sdk

Latest version **0.1.9** (published 2023-11-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install trovir-javascript-sdk
pnpm add trovir-javascript-sdk
yarn add trovir-javascript-sdk
bun add trovir-javascript-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2023-11-01 |
| First published | 2023-09-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Trovir - INTERNAL USE ONLY |
| Maintainers | trovirdeveloper |

## Links

- npm: https://www.npmjs.com/package/trovir-javascript-sdk
- Repository: https://github.com/trovirdeveloper/trovir-javascript-sdk
- Homepage: https://github.com/trovirdeveloper
- Issues: https://github.com/trovirdeveloper/trovir-javascript-sdk/issues
- npm.io page: https://npm.io/package/trovir-javascript-sdk

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.5.0

## Recent versions

- 0.1.9 (latest) — 2023-11-01
- 0.1.8 — 2023-11-01
- 0.1.7 — 2023-11-01
- 0.1.6 — 2023-11-01
- 0.1.5 — 2023-10-16
- 0.1.4 — 2023-09-22
- 0.1.3 — 2023-09-07
- 0.1.2 — 2023-09-06
- 0.1.1 — 2023-09-01
- 0.1.0 — 2023-09-01

## README

# TROVIR JAVASCRIPT SDK



### Installing
```sh
npm install trovir-javascript-sdk
```

All responses format
```js
{
	error:  if an error has occurred, more information will be here.  if no error, value will be null 
	status: status code of request.  200 if OK.  4XX if a permission/authorization issue.  5XX if error
	data: all data from response will be here. actual format will vary depending on the request.
}
```


## GET FILES
* `@return {Object} data.error` - if an error has occurred, more information will be here.  if no error, value will be null 
* `@return {Object} data.status` - status code of request.  200 if OK.  4XX if a permission/authorization issue.  5XX if error
* `@return {Object} data.files.id` - unique identifier of file
* `@return {Object} data.files.name` - name of file
* `@return {Object} data.files.size` - size of file in bytes
* `@return {Object} data.files.created_date` - date file was added to Trovir

```js
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFiles();

if (!res.error) {
	console.log('res.data',res.data.files);
} else {
	console.log('res.error', res.error);
}
```

## UPLOAD FILE

* `@return {string} id` - id of file that was uploaded

```js
const body = {
	base64: BASE64_ENCODED_FILE,
	mime_type: 'application/pdf',
	name: 'file_name',
	lastModified: '2023-08-31 03:00:00'
}

const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.uploadFile(body);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```

## GET FILE

This retrieves the information about a single file

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFile(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```

## GET FILE LINK

This retrieves a link to the raw file that was originally uploaded

* `@return {string} url` - path to file

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFileLink(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```


## GET FILE STATUS

This retrieves the status of file processing

* `@return {string} status` - current status of the file
* `@return {Object} history` - status history for the file.  includes the status and timestamp of when it was in the status

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFileStatus(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```

## GET FILE CONTENT

This retrieves the extracted content of the file

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFileContent(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```




## RECLASSIFY FILE

This overrides how a file was classified.  

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const body = { override_record_type: new_record_type_id }
const res = await trovir_client.reclassifyFile(my_file_id,body);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```

## ASK QUESTION OF FILE

Ask a user-defined question using the file for context

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const body = { prompt: 'My question', json_response: true, json_keys: [ 'field1','field2'] }
const res = await trovir_client.fileAskQuestion(my_file_id,body);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```

## DELETE FILE

Delete a file from Trovir 

```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.fileDelete(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}
```



## GET RECORD TYPES

Retrieve the list of record types available within Trovir.
* `@return {Object} record_types.id` - id of record type
* `@return {Object} record_types.name` - name of record type


```js
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getRecordTypes(my_file_id,body);

if (!res.error) {
	console.log('res.data',res.data.record_types);
} else {
	console.log('res.error', res.error);
}
```

---
_Source: https://npm.io/package/trovir-javascript-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
