Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e937d05490 | ||
|
|
eac881ec58 | ||
|
|
9ff9f24d85 | ||
|
|
f412594338 | ||
|
|
1bc5248781 | ||
|
|
16fc7e2eae | ||
|
|
8930bc2777 | ||
|
|
866774b5a5 | ||
|
|
74a1133e6f | ||
|
|
5938f28603 | ||
|
|
bc44ed3a7a | ||
|
|
06ac0e91b0 | ||
|
|
0f58867c49 | ||
|
|
0aa840873c | ||
|
|
ad9325a840 | ||
|
|
1fcf72dca3 | ||
|
|
e393491bfc | ||
|
|
522efb1f67 | ||
|
|
77edd0a1fa | ||
|
|
d700c4fe4c | ||
|
|
52b5d36ddd | ||
|
|
dbdd3e1895 | ||
|
|
d8b6bf0b7b | ||
|
|
07ec44a0ad | ||
|
|
e97ee15387 | ||
|
|
2000a860a4 | ||
|
|
b989adc01d | ||
|
|
7e33c5ecaa | ||
|
|
f48189a881 | ||
|
|
396660e801 | ||
|
|
f3c69d3a34 | ||
|
|
377469ab6b | ||
|
|
a9725fcbaf |
+2
-1
@@ -3,4 +3,5 @@
|
||||
coverage/
|
||||
dist/
|
||||
node_modules/
|
||||
.github/
|
||||
.github/
|
||||
scripts/
|
||||
+10
-4
@@ -3,7 +3,7 @@
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
},
|
||||
"plugins": ["@typescript-eslint", "mocha"],
|
||||
"plugins": ["@typescript-eslint", "mocha", "import"],
|
||||
"extends": [
|
||||
"standard-with-typescript",
|
||||
"eslint:recommended",
|
||||
@@ -13,11 +13,16 @@
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["tests/**/*.spec.ts", "integrationTests/**/*.spec.ts"],
|
||||
"files": [
|
||||
"tests/**/*.spec.ts",
|
||||
"integrationTests/**/*.spec.ts",
|
||||
"integrationTests/utils/**"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-expressions": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "off",
|
||||
"no-new": "off"
|
||||
"no-new": "off",
|
||||
"import/extensions": "off"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -30,6 +35,7 @@
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
||||
"@typescript-eslint/no-useless-constructor": "off",
|
||||
"@typescript-eslint/no-extraneous-class": "off"
|
||||
"@typescript-eslint/no-extraneous-class": "off",
|
||||
"import/extensions": ["error", "always", { "ignorePackages": true }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ on:
|
||||
- src/**
|
||||
branches:
|
||||
- master
|
||||
- beta
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -51,6 +52,10 @@ jobs:
|
||||
TEST_SURVEY_ID: ${{ vars.TEST_SURVEY_ID }}
|
||||
TEST_SURVEY_RECORD_ID: ${{ vars.TEST_SURVEY_RECORD_ID }}
|
||||
TEST_TEXT_FIELD: ${{ vars.TEST_TEXT_FIELD }}
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
@@ -69,8 +74,6 @@ jobs:
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Install semantic-release extra plugins
|
||||
run: npm install --save-dev @semantic-release/changelog
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v3.0.2
|
||||
with:
|
||||
|
||||
@@ -8,6 +8,7 @@ on:
|
||||
- '**/README.md'
|
||||
branches:
|
||||
- master
|
||||
- beta
|
||||
jobs:
|
||||
lint:
|
||||
name: lint
|
||||
@@ -112,10 +113,24 @@ jobs:
|
||||
TEST_SURVEY_ID: ${{ vars.TEST_SURVEY_ID }}
|
||||
TEST_SURVEY_RECORD_ID: ${{ vars.TEST_SURVEY_RECORD_ID }}
|
||||
TEST_TEXT_FIELD: ${{ vars.TEST_TEXT_FIELD }}
|
||||
- name: Upload test coverage artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: coverage
|
||||
path: ./coverage
|
||||
publish_test_coverage:
|
||||
needs: test
|
||||
name: publish_test_coverage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Download test coverage artifact
|
||||
uses: actions/download-artifact@v3.0.2
|
||||
with:
|
||||
name: coverage
|
||||
path: ./coverage
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
Regular → Executable
@@ -6,8 +6,18 @@
|
||||
"functions": 100,
|
||||
"statements": 100,
|
||||
"all": true,
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["src/index.ts", "**/*.spec.ts"],
|
||||
"reporter": ["html", "lcov", "text", "text-summary"],
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"src/index.ts",
|
||||
"**/*.spec.ts"
|
||||
],
|
||||
"reporter": [
|
||||
"html",
|
||||
"lcov",
|
||||
"text",
|
||||
"text-summary"
|
||||
],
|
||||
"report-dir": "coverage"
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,6 @@
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
[
|
||||
"@semantic-release/changelog",
|
||||
{
|
||||
"changelogFile": "docs/CHANGELOG.md"
|
||||
}
|
||||
],
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github"
|
||||
]
|
||||
|
||||
@@ -3,5 +3,625 @@
|
||||
[](https://github.com/StevanFreeborn/onspring-api-sdk-javascript/actions/workflows/lint_format_test.yaml)
|
||||
[](https://codecov.io/github/StevanFreeborn/onspring-api-sdk-javascript)
|
||||
[](https://github.com/StevanFreeborn/onspring-api-sdk-javascript/actions/workflows/build_publish.yml)
|
||||
[](https://github.com/semantic-release/semantic-release)
|
||||
[](License.txt)
|
||||

|
||||
|
||||
A javascript SDK for interacting with version 2 of the Onspring API.
|
||||
The Javascript SDK for the Onspring API is meant to simplify development in Javascript for Onspring customers who want to build integrations with their Onspring instance.
|
||||
|
||||
**Note:** This is an unofficial SDK for the Onspring API. It was not built in consultation with Onspring Technologies LLC or a member of their development team.
|
||||
|
||||
This SDK was developed independently using Onspring's existing [C# SDK](https://github.com/onspring-technologies/onspring-api-sdk), the Onspring API's [swagger page](https://api.onspring.com/swagger/index.html), and [api documentation](https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf) as the starting point with the intention of making development of integrations done in Javascript with an Onspring instance quicker and more convenient.
|
||||
|
||||
## 🛠️ Dependencies
|
||||
|
||||
### Node.js
|
||||
|
||||

|
||||
|
||||
Requires use of [Node.js](https://nodejs.org/en/) 14.x or later.
|
||||
|
||||
### Axios
|
||||
|
||||

|
||||
|
||||
All methods for the `OnspringClient` make use of the [Axios](https://axios-http.com/) http client to interact with the Onspring API.
|
||||
|
||||
### Form-Data
|
||||
|
||||

|
||||
|
||||
When it is necessary to send requests to the Onspring API using `multi-part/form-data` the [Form-Data](https://www.npmjs.com/package/form-data) package is used.
|
||||
|
||||
## 💾 Installation
|
||||
|
||||
Install the SDK using [npm](https://www.npmjs.com/):
|
||||
|
||||
`npm install onspring-api-sdk`
|
||||
|
||||
## 🔑 API Key
|
||||
|
||||
In order to successfully interact with the Onspring Api you will need an API key. API keys are obtained by an Onspring user with permissions to at least **Read** API Keys for your instance via the following steps:
|
||||
|
||||
1. Login to the Onspring instance.
|
||||
2. Navigate to **Administration** > **Security** > **API Keys**
|
||||
3. On the list page, add a new API Key - this will require **Create** permissions - or click an existing API key to view its details.
|
||||
4. Click on the **Developer Information** tab.
|
||||
5. Copy the **X-ApiKey Header** value from this tab.
|
||||
|
||||
**Important:**
|
||||
|
||||
- An API Key must have a status of `Enabled` in order to make authorized requests.
|
||||
- Each API Key must have an assigned Role. This role controls the permissions for requests made. If the API Key used does not have sufficient permissions the requests made won't be successful.
|
||||
|
||||
### 🔒 Permission Considerations
|
||||
|
||||
You can think of any API Key as another user in your Onspring instance and therefore it is subject to all the same permission considerations as any other user when it comes to its ability to access data in your instance. The API Key you use needs to have all the correct permissions within your instance to access the data requested. Things to think about in this context are `role security`, `content security`, and `field security`.
|
||||
|
||||
## 🧑🏻💻 Start Coding
|
||||
|
||||
### `OnspringClient`
|
||||
|
||||
The most common way to use the SDK is to create an `OnspringClient` instance and call its methods. Its constructor requires two parameters:
|
||||
|
||||
- `baseUrl` - currently this should always be: `https://api.onspring.com`
|
||||
- `apiKey` - the value obtained by following the steps in the **API Key** section
|
||||
|
||||
It is best practice to read these values in from a configuration file for both flexibility and security purposes.
|
||||
|
||||
Example `.env` file:
|
||||
|
||||
```env
|
||||
API_KEY=000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000
|
||||
BASE_URL=https://api.onspring.com
|
||||
```
|
||||
|
||||
Example constructing `OnspringClient`:
|
||||
|
||||
`CommonJS`
|
||||
|
||||
```js
|
||||
const { OnspringClient } = require('onspring-api-sdk');
|
||||
const dotenv = require('dotenv');
|
||||
dotenv.config();
|
||||
|
||||
const client = new OnspringClient(process.env.BASE_URL, process.env.API_KEY);
|
||||
```
|
||||
|
||||
`ES Module`
|
||||
|
||||
```js
|
||||
import dotenv from 'dotenv';
|
||||
import { OnspringClient } from 'onspring-api-sdk';
|
||||
dotenv.config();
|
||||
|
||||
const client = new OnspringClient(process.env.BASE_URL, process.env.API_KEY);
|
||||
```
|
||||
|
||||
### `Axios` Instance Configuration
|
||||
|
||||
By default when you construct an instance of the `OnspringClient` the a new `Axios` instance will also be created. Its `baseURL` property will always be set to the `baseUrl` parameter based to the `OnspringClient`'s constructor and its headers will always contain the proper `x-api-key` header.
|
||||
|
||||
You can though pass a third optional argument to the `OnspringClient` constructor that specifies additional configuration options for the `Axios` instance used to make requests.
|
||||
|
||||
```js
|
||||
import dotenv from 'dotenv';
|
||||
import { OnspringClient } from 'onspring-api-sdk';
|
||||
dotenv.config();
|
||||
|
||||
const configs = {
|
||||
timeout: 5000,
|
||||
};
|
||||
|
||||
const client = new OnspringClient(
|
||||
process.env.BASE_URL,
|
||||
process.env.API_KEY,
|
||||
configs
|
||||
);
|
||||
```
|
||||
|
||||
### `ApiResponse`
|
||||
|
||||
Each `OnspringClient` method - aside from `canConnect` - returns an `ApiResponse` object which will have the following properties:
|
||||
|
||||
- `statusCode` - The http status code of the response.
|
||||
- `isSuccessful` - Indicates whether the request succeeded.
|
||||
- `data` - If the request was successful will contain the response data deserialized to custom classes.
|
||||
- `message` - A message that may provide more detail about the request when no successful
|
||||
|
||||
### CommonJS or ES Modules
|
||||
|
||||
There is support for using either CommonJS or ES Modules depending upon your preference. This documentation will use the later in the usage examples.
|
||||
|
||||
### Types
|
||||
|
||||
The package is written in typescript and all types are exported and available for you to use.
|
||||
|
||||
### Full API Documentation
|
||||
|
||||
You may wish to refer to the full [Onspring API documentation](https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf) when determining which values to pass as parameters to some of the `OnspringClient` methods. There is also a [swagger page](https://api.onspring.com/swagger/index.html) that you can use for making exploratory requests.
|
||||
|
||||
## 📋 Examples
|
||||
|
||||
Note the following code snippets assume you've already instantiated an `OnspringClient` as shown in the [OnspringClient](#onspringclient) section.
|
||||
|
||||
### Connectivity
|
||||
|
||||
#### Verify connectivity
|
||||
|
||||
```js
|
||||
const res = await client.canConnect();
|
||||
console.log(res); // true or false
|
||||
```
|
||||
|
||||
### Apps
|
||||
|
||||
#### Get Apps
|
||||
|
||||
Returns a paged collection of apps and/or surveys that can be paged through. By default the page size is 50 and page number is 1.
|
||||
|
||||
```js
|
||||
const res = await client.getApps();
|
||||
const apps = res.data.items;
|
||||
|
||||
for (const app of apps) {
|
||||
console.log(app);
|
||||
}
|
||||
```
|
||||
|
||||
You can set your own page size and page number (max is 1,000) as well.
|
||||
|
||||
```js
|
||||
import { PagingRequest } from 'onspring-api-sdk';
|
||||
|
||||
const res = await client.getApps(new PagingRequest(1, 1));
|
||||
const apps = res.data.items;
|
||||
|
||||
for (const app of apps) {
|
||||
console.log(app);
|
||||
}
|
||||
```
|
||||
|
||||
#### Get App By Id
|
||||
|
||||
Returns an Onspring app or survey according to provided id.
|
||||
|
||||
```js
|
||||
const res = await client.getAppById(130);
|
||||
const app = res.data;
|
||||
|
||||
console.log(app);
|
||||
```
|
||||
|
||||
#### Get Apps By Ids
|
||||
|
||||
Returns a collection of Onspring apps and/or surveys according to provided ids.
|
||||
|
||||
```js
|
||||
const res = await client.getAppsByIds([130, 131]);
|
||||
const apps = res.data.items;
|
||||
|
||||
for (const app of apps) {
|
||||
console.log(app);
|
||||
}
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
#### Get Field By Id
|
||||
|
||||
Returns an Onspring field according to provided id.
|
||||
|
||||
```js
|
||||
const res = await client.getFieldById(4793);
|
||||
const field = res.data;
|
||||
|
||||
console.log(field);
|
||||
```
|
||||
|
||||
#### Get Fields By Ids
|
||||
|
||||
Returns a collection of Onspring fields according to provided ids.
|
||||
|
||||
```js
|
||||
const res = await client.getFieldsByIds([4793, 4801]);
|
||||
const fields = res.data.items;
|
||||
|
||||
for (const field of fields) {
|
||||
console.log(field);
|
||||
}
|
||||
```
|
||||
|
||||
#### Get Fields By App Id
|
||||
|
||||
Returns a paged collection of fields that can be paged through. By default the page size is 50 and page number is 1.
|
||||
|
||||
```js
|
||||
const res = await client.getFieldsByAppId(132);
|
||||
const fields = res.data.items;
|
||||
|
||||
for (const field of fields) {
|
||||
console.log(field);
|
||||
}
|
||||
```
|
||||
|
||||
You can set your own page size and page number (max is 1,000) as well.
|
||||
|
||||
```js
|
||||
import { PagingRequest } from 'onspring-api-sdk';
|
||||
|
||||
const res = await client.getFieldsByAppId(132, new PagingRequest(1, 1));
|
||||
const fields = res.data.items;
|
||||
|
||||
for (const field of fields) {
|
||||
console.log(field);
|
||||
}
|
||||
```
|
||||
|
||||
### Files
|
||||
|
||||
#### Get File Info By Id
|
||||
|
||||
Returns the Onspring file's metadata.
|
||||
|
||||
```js
|
||||
const res = await client.getFileInfoById(1, 4806, 909);
|
||||
const fileInfo = res.data;
|
||||
|
||||
console.log(fileInfo);
|
||||
```
|
||||
|
||||
#### Get File By Id
|
||||
|
||||
Returns the file itself.
|
||||
|
||||
```js
|
||||
import fs from 'fs';
|
||||
|
||||
const res = await client.getFileById(1, 4806, 909);
|
||||
const file = res.data;
|
||||
|
||||
console.log(file.contentLength);
|
||||
console.log(file.contentType);
|
||||
console.log(file.fileName);
|
||||
file.stream.pipe(fs.createWriteStream(file.fileName));
|
||||
```
|
||||
|
||||
#### Save File
|
||||
|
||||
```js
|
||||
import fs from 'fs';
|
||||
import { SaveFileRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new SaveFileRequest(
|
||||
1,
|
||||
4806,
|
||||
'notes',
|
||||
new Date(),
|
||||
'test-attachment.txt',
|
||||
'text/plain',
|
||||
fs.createReadStream('test-attachment.txt')
|
||||
);
|
||||
|
||||
const res = await client.saveFile(request);
|
||||
const fileId = res.data.id;
|
||||
|
||||
console.log(fileId);
|
||||
```
|
||||
|
||||
#### Delete File By Id
|
||||
|
||||
```js
|
||||
const res = await client.deleteFileById(1, 4806, 1505);
|
||||
|
||||
res.statusCode === 204
|
||||
? console.log('File deleted')
|
||||
: console.log('Error deleting file');
|
||||
```
|
||||
|
||||
### Lists
|
||||
|
||||
#### Add Or Update List Value
|
||||
|
||||
To add a list value don't provide an id value.
|
||||
|
||||
```js
|
||||
import { ListItemRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new ListItemRequest(638, null, 'New Value', 1, '#000000');
|
||||
const res = await client.addOrUpdateListItem(request);
|
||||
const itemId = res.data.id;
|
||||
|
||||
console.log(itemId);
|
||||
```
|
||||
|
||||
To update a list value provide an id value.
|
||||
|
||||
```js
|
||||
import { ListItemRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new ListItemRequest(
|
||||
638,
|
||||
'35c79a46-04b8-4069-bbc1-161a175f962c',
|
||||
'Updated Value',
|
||||
1,
|
||||
'#000000'
|
||||
);
|
||||
|
||||
const res = await client.addOrUpdateListItem(request);
|
||||
const itemId = res.data.id;
|
||||
|
||||
console.log(itemId);
|
||||
```
|
||||
|
||||
#### Delete List Value
|
||||
|
||||
```js
|
||||
const res = await client.deleteListItemById(
|
||||
638,
|
||||
'35c79a46-04b8-4069-bbc1-161a175f962c'
|
||||
);
|
||||
|
||||
res.statusCode === 204
|
||||
? console.log('List item deleted')
|
||||
: console.log('Error deleting list item');
|
||||
```
|
||||
|
||||
### Records
|
||||
|
||||
#### Get Records By App Id
|
||||
|
||||
Returns a paged collection of records that can be paged through. By default the page size is 50 and page number is 1.
|
||||
|
||||
```js
|
||||
import { GetRecordsByAppIdRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new GetRecordsByAppIdRequest(130);
|
||||
const res = await client.getRecordsByAppId(request);
|
||||
const apps = res.data.items;
|
||||
|
||||
for (const app of apps) {
|
||||
console.log(app);
|
||||
}
|
||||
```
|
||||
|
||||
You can set your own page size and page number (max is 1,000) as well. In addition to specifying what field values to return and in what format (Raw vs. Formatted) to return them.
|
||||
|
||||
```js
|
||||
import {
|
||||
DataFormat,
|
||||
GetRecordsByAppIdRequest,
|
||||
PagingRequest,
|
||||
} from 'onspring-api-sdk';
|
||||
|
||||
const request = new GetRecordsByAppIdRequest(
|
||||
130,
|
||||
[4804],
|
||||
DataFormat.Raw,
|
||||
new PagingRequest(1, 1)
|
||||
);
|
||||
|
||||
const res = await client.getRecordsByAppId(request);
|
||||
const apps = res.data.items;
|
||||
|
||||
for (const app of apps) {
|
||||
console.log(app);
|
||||
}
|
||||
```
|
||||
|
||||
#### Get Record By Id
|
||||
|
||||
Returns an onspring record based on the provided app and record ids.
|
||||
|
||||
```js
|
||||
import { GetRecordRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new GetRecordRequest(130, 1);
|
||||
const res = await client.getRecordById(request);
|
||||
const record = res.data;
|
||||
|
||||
console.log(record);
|
||||
```
|
||||
|
||||
You can also specify what field values to return and in what format (Raw vs. Formatted) to return them.
|
||||
|
||||
```js
|
||||
import { DataFormat, GetRecordRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new GetRecordRequest(130, 1, [4804], DataFormat.Raw);
|
||||
const res = await client.getRecordById(request);
|
||||
const record = res.data;
|
||||
|
||||
console.log(record);
|
||||
```
|
||||
|
||||
#### Get Records By Ids
|
||||
|
||||
Returns a collection of Onspring records based on the provided appId and recordIds.
|
||||
|
||||
```js
|
||||
import { GetRecordsRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new GetRecordsRequest(130, [1]);
|
||||
const res = await client.getRecordsByIds(request);
|
||||
const records = res.data.items;
|
||||
|
||||
for (const record of records) {
|
||||
console.log(record);
|
||||
}
|
||||
```
|
||||
|
||||
You can also specify what field values to return and in what format (Raw vs. Formatted) to return them.
|
||||
|
||||
```js
|
||||
import { DataFormat, GetRecordsRequest } from 'onspring-api-sdk';
|
||||
|
||||
const request = new GetRecordsRequest(130, [1], [4804], DataFormat.Formatted);
|
||||
const res = await client.getRecordsByIds(request);
|
||||
const records = res.data.items;
|
||||
|
||||
for (const record of records) {
|
||||
console.log(record);
|
||||
}
|
||||
```
|
||||
|
||||
#### Query Records
|
||||
|
||||
Returns a paged collection of records based on a criteria that can be paged through. By default the page size is 50 and page number is 1.
|
||||
|
||||
```js
|
||||
import {
|
||||
FilterOperators,
|
||||
QueryFilter,
|
||||
QueryRecordsRequest,
|
||||
} from 'onspring-api-sdk';
|
||||
|
||||
const filter = new QueryFilter(4745, FilterOperators.GreaterThan, 0);
|
||||
const request = new QueryRecordsRequest(130, filter);
|
||||
const res = await client.queryRecords(request);
|
||||
const records = res.data.items;
|
||||
|
||||
for (const record of records) {
|
||||
console.log(record);
|
||||
}
|
||||
```
|
||||
|
||||
You can set your own page size and page number (max is 1,000) as well. In addition to specifying what field values to return and in what format (Raw vs. Formatted) to return them.
|
||||
|
||||
```js
|
||||
import {
|
||||
DataFormat,
|
||||
FilterOperators,
|
||||
PagingRequest,
|
||||
QueryFilter,
|
||||
QueryRecordsRequest,
|
||||
} from 'onspring-api-sdk';
|
||||
|
||||
const filter = new QueryFilter(4745, FilterOperators.GreaterThan, 0);
|
||||
const request = new QueryRecordsRequest(
|
||||
130,
|
||||
filter,
|
||||
[4804],
|
||||
DataFormat.Formatted,
|
||||
new PagingRequest(1, 1)
|
||||
);
|
||||
|
||||
const res = await client.queryRecords(request);
|
||||
const records = res.data.items;
|
||||
|
||||
for (const record of records) {
|
||||
console.log(record);
|
||||
}
|
||||
```
|
||||
|
||||
For further details on constructing the `filter` parameter please refer to the [documentation](https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf) for the Onspring API.
|
||||
|
||||
#### Add or Update A Record
|
||||
|
||||
You can add a record by not providing a record id value. If successful will return the id of the added record.
|
||||
|
||||
```js
|
||||
import { Record, StringRecordValue } from 'onspring-api-sdk';
|
||||
|
||||
const record = new Record(130, null);
|
||||
const fieldValue = new StringRecordValue(4804, 'Test');
|
||||
record.addValue(fieldValue);
|
||||
|
||||
const res = await client.saveRecord(record);
|
||||
const newRecordId = res.data.id;
|
||||
|
||||
console.log(newRecordId);
|
||||
```
|
||||
|
||||
You can update a record by providing its id. If successful will return the id of record updated.
|
||||
|
||||
```js
|
||||
import { Record, StringRecordValue } from 'onspring-api-sdk';
|
||||
|
||||
const record = new Record(130, 607);
|
||||
const fieldValue = new StringRecordValue(4804, 'Updated');
|
||||
record.addValue(fieldValue);
|
||||
|
||||
const res = await client.saveRecord(record);
|
||||
const updatedRecordId = res.data.id;
|
||||
|
||||
console.log(updatedRecordId);
|
||||
```
|
||||
|
||||
#### Delete Record By Id
|
||||
|
||||
Delete an individual record based upon its id.
|
||||
|
||||
```js
|
||||
const res = await client.deleteRecordById(130, 607);
|
||||
|
||||
res.statusCode === 204
|
||||
? console.log('Record deleted')
|
||||
: console.log('Error deleting record');
|
||||
```
|
||||
|
||||
#### Delete Records By Ids
|
||||
|
||||
Delete a batch of records based upon their ids.
|
||||
|
||||
```js
|
||||
const res = await client.deleteRecordsByIds(130, [608, 609]);
|
||||
|
||||
res.statusCode === 204
|
||||
? console.log('Records deleted')
|
||||
: console.log('Error deleting records');
|
||||
```
|
||||
|
||||
### Reports
|
||||
|
||||
#### Get Report By Id
|
||||
|
||||
Returns the report for the provided id.
|
||||
|
||||
```js
|
||||
const res = await client.getReportById(408);
|
||||
const report = res.data;
|
||||
|
||||
console.log(report);
|
||||
```
|
||||
|
||||
You can also specify the format of the data in the report as well as whether you are requesting the report's data or its chart data.
|
||||
|
||||
```js
|
||||
import { DataFormat, ReportDataType } from 'onspring-api-sdk';
|
||||
|
||||
const res = await client.getReportById(
|
||||
409,
|
||||
DataFormat.Formatted,
|
||||
ReportDataType.ChartData
|
||||
);
|
||||
const report = res.data;
|
||||
|
||||
console.log(report);
|
||||
```
|
||||
|
||||
#### Get Reports By App Id
|
||||
|
||||
Returns a paged collection of reports that can be paged through. By default the page size is 50 and page number is 1.
|
||||
|
||||
```js
|
||||
const res = await client.getReportsByAppId(130);
|
||||
const reports = res.data.items;
|
||||
|
||||
for (const report of reports) {
|
||||
console.log(report);
|
||||
}
|
||||
```
|
||||
|
||||
You can set your own page size and page number (max is 1,000) as well.
|
||||
|
||||
```js
|
||||
import { PagingRequest } from 'onspring-api-sdk';
|
||||
|
||||
const res = await client.getReportsByAppId(130, new PagingRequest(1, 1));
|
||||
const reports = res.data.items;
|
||||
|
||||
for (const report of reports) {
|
||||
console.log(report);
|
||||
}
|
||||
```
|
||||
|
||||
+8
-5
@@ -32,12 +32,15 @@
|
||||
"License.txt",
|
||||
"package.json"
|
||||
],
|
||||
"main": "dist/cjs/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"exports": {
|
||||
"import": "./dist/esm/index.js",
|
||||
"require": "./dist/cjs/index.js",
|
||||
"default": "./dist/cjs/index.js"
|
||||
".": {
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"import": "./dist/esm/index.js",
|
||||
"require": "./dist/cjs/index.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
@@ -45,7 +48,7 @@
|
||||
"lint-fix": "eslint --fix --ignore-path .eslintignore --ext .js,.ts . --max-warnings=0",
|
||||
"format-staged": "pretty-quick --staged",
|
||||
"format": "pretty-quick",
|
||||
"build": "npm run tests && npm run clean && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
|
||||
"build": "npm run test-coverage:ci && npm run clean && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json && node ./scripts/create_dist_package_json.js",
|
||||
"test:unit": "mocha -r ts-node/register",
|
||||
"test:integration": "mocha -r ts-node/register -r integrationTests/mochaRootHooks.ts",
|
||||
"tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts",
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const esmPackageJson = `{
|
||||
"type": "module"
|
||||
}`;
|
||||
|
||||
const cjsPackageJson = `{
|
||||
"type": "commonjs"
|
||||
}`;
|
||||
|
||||
const parentDir = path.resolve(__dirname, '..');
|
||||
|
||||
fs.writeFileSync(path.join(parentDir, 'dist/esm/package.json'), esmPackageJson);
|
||||
fs.writeFileSync(path.join(parentDir, 'dist/cjs/package.json'), cjsPackageJson);
|
||||
@@ -1,4 +1,16 @@
|
||||
export enum DelegateType {
|
||||
External = 'External',
|
||||
Internal = 'Internal',
|
||||
}
|
||||
/**
|
||||
* @enum DelegateType - The type of delegate
|
||||
*/
|
||||
export enum DelegateType {
|
||||
/**
|
||||
* @constant External - The delegate is external.
|
||||
* @type {string}
|
||||
*/
|
||||
External = 'External',
|
||||
|
||||
/**
|
||||
* @constant Internal - The delegate is internal.
|
||||
* @type {string}
|
||||
*/
|
||||
Internal = 'Internal',
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @enum FileStorageSite - The site where the file is stored.
|
||||
*/
|
||||
export enum FileStorageSite {
|
||||
/**
|
||||
* @constant Internal - The file is stored in the internal file storage.
|
||||
|
||||
@@ -4,60 +4,70 @@
|
||||
export enum FilterOperators {
|
||||
/**
|
||||
* @constant Equal - The equal operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with text, auto-number, date, and number fields as well as their formula equivalents.
|
||||
*/
|
||||
Equal = 'eq',
|
||||
|
||||
/**
|
||||
* @constant NotEqual - The not equal operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with text, auto-number, date, and number fields as well as their formula equivalents.
|
||||
*/
|
||||
NotEqual = 'ne',
|
||||
|
||||
/**
|
||||
* @constant Contains - The contains operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with list fields as well as their formula equivalents.
|
||||
*/
|
||||
Contains = 'contains',
|
||||
|
||||
/**
|
||||
* @constant IsNull - The is null operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with text, date, and number fields as well as their formula equivalents.
|
||||
*/
|
||||
IsNull = 'isnull',
|
||||
|
||||
/**
|
||||
* @constant NotNull - The not null operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with text, date, and number fields as well as their formula equivalents.
|
||||
*/
|
||||
NotNull = 'notnull',
|
||||
|
||||
/**
|
||||
* @constant GreaterThan - The greater than operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with auto-number, date, and number fields as well as their formula equivalents.
|
||||
*/
|
||||
GreaterThan = 'gt',
|
||||
|
||||
/**
|
||||
* @constant LessThan - The less than operator
|
||||
* @type {string}
|
||||
* @remarks Can be used with auto-number, date, and number fields as well as their formula equivalents.
|
||||
*/
|
||||
LessThan = 'lt',
|
||||
|
||||
/**
|
||||
* @constant And - The and operator
|
||||
* @type {string}
|
||||
* @remarks Can be used to create compound filters.
|
||||
*/
|
||||
And = 'and',
|
||||
|
||||
/**
|
||||
* @constant Or - The or operator
|
||||
* @type {string}
|
||||
* @remarks Can be used to create compound filters.
|
||||
*/
|
||||
Or = 'or',
|
||||
|
||||
/**
|
||||
* @constant Not - The not operator
|
||||
* @type {string}
|
||||
* @remarks Can be used to negate a filter and create compound filters.
|
||||
*/
|
||||
Not = 'not',
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @enum FormulaOutputType - The type of the formula output.
|
||||
*/
|
||||
export enum FormulaOutputType {
|
||||
/**
|
||||
* @constant Text - The formula output is a text value.
|
||||
|
||||
+64
-65
@@ -1,73 +1,72 @@
|
||||
// Models
|
||||
import { ApiResponse } from './models/ApiResponse';
|
||||
import { App } from './models/App';
|
||||
import { Attachment } from './models/Attachment';
|
||||
import { AttachmentListRecordValue } from './models/AttachmentListRecordValue';
|
||||
import { CollectionResponse } from './models/CollectionResponse';
|
||||
import { CreatedWithIdResponse } from './models/CreatedWithIdResponse';
|
||||
import { DateRecordValue } from './models/DateRecordValue';
|
||||
import { DecimalRecordValue } from './models/DecimalRecordValue';
|
||||
import { Delegate } from './models/Delegate';
|
||||
import { DelegateListRecordValue } from './models/DelegateListRecordValue';
|
||||
import { EndpointFactory } from './models/EndpointFactory';
|
||||
import { Field } from './models/Field';
|
||||
import { File } from './models/File';
|
||||
import { FileInfo } from './models/FileInfo';
|
||||
import { FileListRecordValue } from './models/FileListRecordValue';
|
||||
import { FormulaField } from './models/FormulaField';
|
||||
import { GetPagedAppsResponse } from './models/GetPagedAppsResponse';
|
||||
import { GetPagedFieldsResponse } from './models/GetPagedFieldsResponse';
|
||||
import { GetPagedRecordsResponse } from './models/GetPagedRecordsResponse';
|
||||
import { GetPagedReportsResponse } from './models/GetPagedReportsResponse';
|
||||
import { GetRecordRequest } from './models/GetRecordRequest';
|
||||
import { GetRecordsByAppIdRequest } from './models/GetRecordsByAppIdRequest';
|
||||
import { GetRecordsRequest } from './models/GetRecordsRequest';
|
||||
import { GuidListRecordValue } from './models/GuidListRecordValue';
|
||||
import { GuidRecordValue } from './models/GuidRecordValue';
|
||||
import { IntegerListRecordValue } from './models/IntegerListRecordValue';
|
||||
import { IntegerRecordValue } from './models/IntegerRecordValue';
|
||||
import { ListField } from './models/ListField';
|
||||
import { ListItemRequest } from './models/ListItemRequest';
|
||||
import { ListItemResponse } from './models/ListItemResponse';
|
||||
import { ListValue } from './models/ListValue';
|
||||
import { OnspringClient } from './models/OnspringClient';
|
||||
import { PagedResponse } from './models/PagedResponse';
|
||||
import { PagingRequest } from './models/PagingRequest';
|
||||
import { QueryFilter } from './models/QueryFilter';
|
||||
import { QueryRecordsRequest } from './models/QueryRecordsRequest';
|
||||
import { Record } from './models/Record';
|
||||
import { RecordValue } from './models/RecordValue';
|
||||
import { ReferenceField } from './models/ReferenceField';
|
||||
import { Report } from './models/Report';
|
||||
import { ReportData } from './models/ReportData';
|
||||
import { Row } from './models/Row';
|
||||
import { SaveFileRequest } from './models/SaveFileRequest';
|
||||
import { SaveRecordRequest } from './models/SaveRecordRequest';
|
||||
import { SaveRecordResponse } from './models/SaveRecordResponse';
|
||||
import { ScoringGroup } from './models/ScoringGroup';
|
||||
import { ScoringGroupListRecordValue } from './models/ScoringGroupListRecordValue';
|
||||
import { StringListRecordValue } from './models/StringListRecordValue';
|
||||
import { StringRecordValue } from './models/StringRecordValue';
|
||||
import { TimeSpanData } from './models/TimeSpanData';
|
||||
import { TimeSpanRecordValue } from './models/TimeSpanRecordValue';
|
||||
import { ApiResponse } from './models/ApiResponse.js';
|
||||
import { App } from './models/App.js';
|
||||
import { Attachment } from './models/Attachment.js';
|
||||
import { AttachmentListRecordValue } from './models/AttachmentListRecordValue.js';
|
||||
import { CollectionResponse } from './models/CollectionResponse.js';
|
||||
import { CreatedWithIdResponse } from './models/CreatedWithIdResponse.js';
|
||||
import { DateRecordValue } from './models/DateRecordValue.js';
|
||||
import { DecimalRecordValue } from './models/DecimalRecordValue.js';
|
||||
import { Delegate } from './models/Delegate.js';
|
||||
import { DelegateListRecordValue } from './models/DelegateListRecordValue.js';
|
||||
import { EndpointFactory } from './models/EndpointFactory.js';
|
||||
import { Field } from './models/Field.js';
|
||||
import { File } from './models/File.js';
|
||||
import { FileInfo } from './models/FileInfo.js';
|
||||
import { FileListRecordValue } from './models/FileListRecordValue.js';
|
||||
import { FormulaField } from './models/FormulaField.js';
|
||||
import { GetPagedAppsResponse } from './models/GetPagedAppsResponse.js';
|
||||
import { GetPagedFieldsResponse } from './models/GetPagedFieldsResponse.js';
|
||||
import { GetPagedRecordsResponse } from './models/GetPagedRecordsResponse.js';
|
||||
import { GetPagedReportsResponse } from './models/GetPagedReportsResponse.js';
|
||||
import { GetRecordRequest } from './models/GetRecordRequest.js';
|
||||
import { GetRecordsByAppIdRequest } from './models/GetRecordsByAppIdRequest.js';
|
||||
import { GetRecordsRequest } from './models/GetRecordsRequest.js';
|
||||
import { GuidListRecordValue } from './models/GuidListRecordValue.js';
|
||||
import { GuidRecordValue } from './models/GuidRecordValue.js';
|
||||
import { IntegerListRecordValue } from './models/IntegerListRecordValue.js';
|
||||
import { IntegerRecordValue } from './models/IntegerRecordValue.js';
|
||||
import { ListField } from './models/ListField.js';
|
||||
import { ListItemRequest } from './models/ListItemRequest.js';
|
||||
import { ListItemResponse } from './models/ListItemResponse.js';
|
||||
import { ListValue } from './models/ListValue.js';
|
||||
import { OnspringClient } from './models/OnspringClient.js';
|
||||
import { PagedResponse } from './models/PagedResponse.js';
|
||||
import { PagingRequest } from './models/PagingRequest.js';
|
||||
import { QueryFilter } from './models/QueryFilter.js';
|
||||
import { QueryRecordsRequest } from './models/QueryRecordsRequest.js';
|
||||
import { Record } from './models/Record.js';
|
||||
import { RecordValue } from './models/RecordValue.js';
|
||||
import { ReferenceField } from './models/ReferenceField.js';
|
||||
import { Report } from './models/Report.js';
|
||||
import { ReportData } from './models/ReportData.js';
|
||||
import { Row } from './models/Row.js';
|
||||
import { SaveFileRequest } from './models/SaveFileRequest.js';
|
||||
import { SaveRecordRequest } from './models/SaveRecordRequest.js';
|
||||
import { SaveRecordResponse } from './models/SaveRecordResponse.js';
|
||||
import { ScoringGroup } from './models/ScoringGroup.js';
|
||||
import { ScoringGroupListRecordValue } from './models/ScoringGroupListRecordValue.js';
|
||||
import { StringListRecordValue } from './models/StringListRecordValue.js';
|
||||
import { StringRecordValue } from './models/StringRecordValue.js';
|
||||
import { TimeSpanData } from './models/TimeSpanData.js';
|
||||
import { TimeSpanRecordValue } from './models/TimeSpanRecordValue.js';
|
||||
|
||||
// Enums
|
||||
import { DataFormat } from './enums/DataFormat';
|
||||
import { DelegateType } from './enums/DelegateType';
|
||||
import { FieldStatus } from './enums/FieldStatus';
|
||||
import { FieldType } from './enums/FieldType';
|
||||
import { FileStorageSite } from './enums/FileStorageSite';
|
||||
import { FilterOperators } from './enums/FilterOperators';
|
||||
import { FormulaOutputType } from './enums/FormulaOutputType';
|
||||
import { HttpStatusCode } from './enums/HttpStatusCode';
|
||||
import { Multiplicity } from './enums/Multiplicity';
|
||||
import { RecordValueType } from './enums/RecordValueType';
|
||||
import { ReportDataType } from './enums/ReportDataType';
|
||||
import { TimeSpanIncrement } from './enums/TimeSpanIncrement';
|
||||
import { TimeSpanRecurrenceType } from './enums/TimeSpanRecurrenceType';
|
||||
import { DataFormat } from './enums/DataFormat.js';
|
||||
import { DelegateType } from './enums/DelegateType.js';
|
||||
import { FieldStatus } from './enums/FieldStatus.js';
|
||||
import { FieldType } from './enums/FieldType.js';
|
||||
import { FileStorageSite } from './enums/FileStorageSite.js';
|
||||
import { FilterOperators } from './enums/FilterOperators.js';
|
||||
import { FormulaOutputType } from './enums/FormulaOutputType.js';
|
||||
import { HttpStatusCode } from './enums/HttpStatusCode.js';
|
||||
import { Multiplicity } from './enums/Multiplicity.js';
|
||||
import { RecordValueType } from './enums/RecordValueType.js';
|
||||
import { ReportDataType } from './enums/ReportDataType.js';
|
||||
import { TimeSpanIncrement } from './enums/TimeSpanIncrement.js';
|
||||
import { TimeSpanRecurrenceType } from './enums/TimeSpanRecurrenceType.js';
|
||||
|
||||
export {
|
||||
// Models
|
||||
ApiResponse,
|
||||
App,
|
||||
Attachment,
|
||||
|
||||
+87
-64
@@ -1,51 +1,51 @@
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import { DelegateType } from '../enums/DelegateType';
|
||||
import { FieldStatus } from '../enums/FieldStatus';
|
||||
import { FieldType } from '../enums/FieldType';
|
||||
import { FileStorageSite } from '../enums/FileStorageSite';
|
||||
import { FormulaOutputType } from '../enums/FormulaOutputType';
|
||||
import { Multiplicity } from '../enums/Multiplicity';
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { TimeSpanIncrement } from '../enums/TimeSpanIncrement';
|
||||
import { TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType';
|
||||
import { App } from './App';
|
||||
import { Attachment } from './Attachment';
|
||||
import { AttachmentListRecordValue } from './AttachmentListRecordValue';
|
||||
import { CollectionResponse } from './CollectionResponse';
|
||||
import { CreatedWithIdResponse } from './CreatedWithIdResponse';
|
||||
import { DateRecordValue } from './DateRecordValue';
|
||||
import { DecimalRecordValue } from './DecimalRecordValue';
|
||||
import { Delegate } from './Delegate';
|
||||
import { DelegateListRecordValue } from './DelegateListRecordValue';
|
||||
import { Field } from './Field';
|
||||
import { File } from './File';
|
||||
import { FileInfo } from './FileInfo';
|
||||
import { FileListRecordValue } from './FileListRecordValue';
|
||||
import { FormulaField } from './FormulaField';
|
||||
import { GetPagedAppsResponse } from './GetPagedAppsResponse';
|
||||
import { GetPagedFieldsResponse } from './GetPagedFieldsResponse';
|
||||
import { GetPagedRecordsResponse } from './GetPagedRecordsResponse';
|
||||
import { GetPagedReportsResponse } from './GetPagedReportsResponse';
|
||||
import { GuidListRecordValue } from './GuidListRecordValue';
|
||||
import { GuidRecordValue } from './GuidRecordValue';
|
||||
import { IntegerListRecordValue } from './IntegerListRecordValue';
|
||||
import { IntegerRecordValue } from './IntegerRecordValue';
|
||||
import { ListField } from './ListField';
|
||||
import { ListItemResponse } from './ListItemResponse';
|
||||
import { ListValue } from './ListValue';
|
||||
import { Record } from './Record';
|
||||
import { ReferenceField } from './ReferenceField';
|
||||
import { Report } from './Report';
|
||||
import { ReportData } from './ReportData';
|
||||
import { Row } from './Row';
|
||||
import { ScoringGroup } from './ScoringGroup';
|
||||
import { ScoringGroupListRecordValue } from './ScoringGroupListRecordValue';
|
||||
import { StringListRecordValue } from './StringListRecordValue';
|
||||
import { StringRecordValue } from './StringRecordValue';
|
||||
import { TimeSpanData } from './TimeSpanData';
|
||||
import { TimeSpanRecordValue } from './TimeSpanRecordValue';
|
||||
import { type RecordValue } from './RecordValue';
|
||||
import { SaveRecordResponse } from './SaveRecordResponse';
|
||||
import { DelegateType } from '../enums/DelegateType.js';
|
||||
import { FieldStatus } from '../enums/FieldStatus.js';
|
||||
import { FieldType } from '../enums/FieldType.js';
|
||||
import { FileStorageSite } from '../enums/FileStorageSite.js';
|
||||
import { FormulaOutputType } from '../enums/FormulaOutputType.js';
|
||||
import { Multiplicity } from '../enums/Multiplicity.js';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { TimeSpanIncrement } from '../enums/TimeSpanIncrement.js';
|
||||
import { TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType.js';
|
||||
import { App } from './App.js';
|
||||
import { Attachment } from './Attachment.js';
|
||||
import { AttachmentListRecordValue } from './AttachmentListRecordValue.js';
|
||||
import { CollectionResponse } from './CollectionResponse.js';
|
||||
import { CreatedWithIdResponse } from './CreatedWithIdResponse.js';
|
||||
import { DateRecordValue } from './DateRecordValue.js';
|
||||
import { DecimalRecordValue } from './DecimalRecordValue.js';
|
||||
import { Delegate } from './Delegate.js';
|
||||
import { DelegateListRecordValue } from './DelegateListRecordValue.js';
|
||||
import { Field } from './Field.js';
|
||||
import { File } from './File.js';
|
||||
import { FileInfo } from './FileInfo.js';
|
||||
import { FileListRecordValue } from './FileListRecordValue.js';
|
||||
import { FormulaField } from './FormulaField.js';
|
||||
import { GetPagedAppsResponse } from './GetPagedAppsResponse.js';
|
||||
import { GetPagedFieldsResponse } from './GetPagedFieldsResponse.js';
|
||||
import { GetPagedRecordsResponse } from './GetPagedRecordsResponse.js';
|
||||
import { GetPagedReportsResponse } from './GetPagedReportsResponse.js';
|
||||
import { GuidListRecordValue } from './GuidListRecordValue.js';
|
||||
import { GuidRecordValue } from './GuidRecordValue.js';
|
||||
import { IntegerListRecordValue } from './IntegerListRecordValue.js';
|
||||
import { IntegerRecordValue } from './IntegerRecordValue.js';
|
||||
import { ListField } from './ListField.js';
|
||||
import { ListItemResponse } from './ListItemResponse.js';
|
||||
import { ListValue } from './ListValue.js';
|
||||
import { Record } from './Record.js';
|
||||
import { type RecordValue } from './RecordValue.js';
|
||||
import { ReferenceField } from './ReferenceField.js';
|
||||
import { Report } from './Report.js';
|
||||
import { ReportData } from './ReportData.js';
|
||||
import { Row } from './Row.js';
|
||||
import { SaveRecordResponse } from './SaveRecordResponse.js';
|
||||
import { ScoringGroup } from './ScoringGroup.js';
|
||||
import { ScoringGroupListRecordValue } from './ScoringGroupListRecordValue.js';
|
||||
import { StringListRecordValue } from './StringListRecordValue.js';
|
||||
import { StringRecordValue } from './StringRecordValue.js';
|
||||
import { TimeSpanData } from './TimeSpanData.js';
|
||||
import { TimeSpanRecordValue } from './TimeSpanRecordValue.js';
|
||||
|
||||
/**
|
||||
* @class ApiResponse - A generic response object for API requests.
|
||||
@@ -92,17 +92,17 @@ export class ApiResponse<T> {
|
||||
public asGetPagedAppsResponseType(): ApiResponse<GetPagedAppsResponse> {
|
||||
const apiResponse = this as ApiResponse<any>;
|
||||
|
||||
const apps = apiResponse.data.items.map((item: any) => {
|
||||
return new App(item.href, item.id, item.name);
|
||||
});
|
||||
const apps = apiResponse.data.items.map((item: any) => {
|
||||
return new App(item.href, item.id, item.name);
|
||||
});
|
||||
|
||||
const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
apps,
|
||||
apiResponse.data.pageNumber,
|
||||
apiResponse.data.pageSize,
|
||||
apiResponse.data.totalPages,
|
||||
apiResponse.data.totalRecords
|
||||
);
|
||||
const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
apps,
|
||||
apiResponse.data.pageNumber,
|
||||
apiResponse.data.pageSize,
|
||||
apiResponse.data.totalPages,
|
||||
apiResponse.data.totalRecords
|
||||
);
|
||||
|
||||
return new ApiResponse<GetPagedAppsResponse>(
|
||||
apiResponse.statusCode,
|
||||
@@ -238,6 +238,10 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method asFileInfoType - Converts the ApiResponse to an ApiResponse<FileInfo>.
|
||||
* @returns {ApiResponse<FileInfo>} - An ApiResponse<FileInfo>.
|
||||
*/
|
||||
public asFileInfoType(): ApiResponse<FileInfo> {
|
||||
const apiResponse = this as ApiResponse<any>;
|
||||
|
||||
@@ -259,15 +263,16 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method asFileType - Converts the ApiResponse to an ApiResponse<File>.
|
||||
* @returns {ApiResponse<File>} - An ApiResponse<File>.
|
||||
*/
|
||||
public asFileType(response: AxiosResponse): ApiResponse<File> {
|
||||
const apiResponse = this as ApiResponse<any>;
|
||||
|
||||
let fileName = response.headers['content-disposition']
|
||||
const fileName = response.headers['content-disposition']
|
||||
.split(';')[1]
|
||||
.split('=')[1];
|
||||
|
||||
fileName = fileName.substring(1, fileName.length - 1);
|
||||
|
||||
const contentType =
|
||||
response.headers['content-type'] ??
|
||||
response.headers['Content-Type'] ??
|
||||
@@ -411,6 +416,10 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method asRecordCollectionType - Converts the ApiResponse to an ApiResponse<CollectionResponse<Record>>.
|
||||
* @returns {ApiResponse<CollectionResponse<Record>>} - An ApiResponse<CollectionResponse<Record>>.
|
||||
*/
|
||||
public asRecordCollectionType(): ApiResponse<CollectionResponse<Record>> {
|
||||
const apiResponse = this as ApiResponse<any>;
|
||||
|
||||
@@ -434,6 +443,10 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method asSaveRecordResponseType - Converts the ApiResponse to an ApiResponse<SaveRecordResponse>.
|
||||
* @returns {ApiResponse<SaveRecordResponse>} - An ApiResponse<SaveRecordResponse>.
|
||||
*/
|
||||
public asSaveRecordResponseType(): ApiResponse<SaveRecordResponse> {
|
||||
const apiResponse = this as ApiResponse<any>;
|
||||
const response = new SaveRecordResponse(
|
||||
@@ -447,6 +460,11 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method getRecordValueByType - Gets the RecordValue by by type.
|
||||
* @param {RecordValue} recordValueItem - The record value item.
|
||||
* @returns {RecordValue} - The RecordValue.
|
||||
*/
|
||||
private static getRecordValueByType(recordValueItem: any): RecordValue<any> {
|
||||
const type = RecordValueType[recordValueItem.type];
|
||||
|
||||
@@ -629,6 +647,11 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @method convertToDelegate - Converts the delegate item to a Delegate object.
|
||||
* @param {any} delegateItem - The delegate item to convert.
|
||||
* @returns {Delegate} - The converted Delegate object.
|
||||
*/
|
||||
private static convertToDelegate(delegateItem: any): Delegate {
|
||||
const delegateType = DelegateType[delegateItem.delegateType];
|
||||
|
||||
@@ -715,7 +738,7 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
const hasRecurrence =
|
||||
timeSpanItem.recurrence !== null && timeSpanItem.recurrence !== undefined;
|
||||
|
||||
const recurrene = hasRecurrence
|
||||
const recurrence = hasRecurrence
|
||||
? TimeSpanRecurrenceType[timeSpanItem.recurrence]
|
||||
: null;
|
||||
|
||||
@@ -738,7 +761,7 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
);
|
||||
}
|
||||
|
||||
if (recurrene === undefined) {
|
||||
if (recurrence === undefined) {
|
||||
throw new Error(
|
||||
`${
|
||||
timeSpanItem.recurrence as string
|
||||
@@ -749,7 +772,7 @@ const getAppsPagedResponse = new GetPagedAppsResponse(
|
||||
return new TimeSpanData(
|
||||
timeSpanItem.quantity,
|
||||
increment,
|
||||
recurrene,
|
||||
recurrence,
|
||||
endAfterOccurrences,
|
||||
endByDate
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import { HttpStatusCode } from '../enums/HttpStatusCode';
|
||||
import { ApiResponse } from './ApiResponse';
|
||||
import { type Readable } from 'stream';
|
||||
import { HttpStatusCode } from '../enums/HttpStatusCode.js';
|
||||
import { ApiResponse } from './ApiResponse.js';
|
||||
|
||||
/**
|
||||
* @class ApiResponseFactory - Factory class for creating ApiResponse objects
|
||||
@@ -60,7 +60,9 @@ export class ApiResponseFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method getStreamDataAsString - Gets the data from a stream as a string
|
||||
* @param {Readable} stream - The stream that will be used to get the data
|
||||
* @returns {Promise<string>} - A promise that resolves to the data from the stream as a string
|
||||
*/
|
||||
private static async getStreamDataAsString(
|
||||
stream: Readable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type FileStorageSite } from '../enums/FileStorageSite';
|
||||
import { type FileStorageSite } from '../enums/FileStorageSite.js';
|
||||
|
||||
/**
|
||||
* @class Attachment - Represents an attachment.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { type Attachment } from './Attachment';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { type Attachment } from './Attachment.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class AttachmentListRecordValue - A record value represented by a list of attachments.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* @class CreatedWithIdResponse<T> - Represents a response to a request to create a resource.
|
||||
*/
|
||||
export class CreatedWithIdResponse<T> {
|
||||
/**
|
||||
* @property {T} id - The id of the created object.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class DateRecordValue - A value for a date field in a record.
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
|
||||
/**
|
||||
* @class DecimalRecordValue - Represents a decimal record value
|
||||
*/
|
||||
export class DecimalRecordValue extends RecordValue<number> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of DecimalRecordValue
|
||||
* @param {number} fieldId - The id of the field
|
||||
* @param {number} value - The value of the field
|
||||
* @returns {DecimalRecordValue} - A new instance of DecimalRecordValue
|
||||
*/
|
||||
constructor(fieldId: number, value: number) {
|
||||
super(RecordValueType.Decimal, fieldId, value);
|
||||
}
|
||||
|
||||
+54
-54
@@ -1,54 +1,54 @@
|
||||
import { type DelegateType } from '../enums/DelegateType';
|
||||
|
||||
/**
|
||||
* @class Delegate - Represents a delegate.
|
||||
*/
|
||||
export class Delegate {
|
||||
/**
|
||||
* @property {DelegateType} delegateType - The type of delegate.
|
||||
*/
|
||||
public delegateType: DelegateType;
|
||||
|
||||
/**
|
||||
* @property {string | null} name - The name of the delegate.
|
||||
*/
|
||||
public name: string | null;
|
||||
|
||||
/**
|
||||
* @property {string} emailAddress - The email address of the delegate.
|
||||
*/
|
||||
public emailAddress: string;
|
||||
|
||||
/**
|
||||
* @property {Date} delegationDateTime - The date and time the delegate was assigned.
|
||||
*/
|
||||
public delegationDateTime: Date;
|
||||
|
||||
/**
|
||||
* @property {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
|
||||
*/
|
||||
public delegationCompletedDateTime: Date | null;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of Delegate.
|
||||
* @param {DelegateType} delegateType - The type of delegate.
|
||||
* @param {string | null} name - The name of the delegate.
|
||||
* @param {string} emailAddress - The email address of the delegate.
|
||||
* @param {Date} delegationDateTime - The date and time the delegate was assigned.
|
||||
* @param {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
|
||||
* @returns {Delegate} - A new instance of Delegate.
|
||||
*/
|
||||
constructor(
|
||||
delegateType: DelegateType,
|
||||
name: string | null,
|
||||
emailAddress: string,
|
||||
delegationDateTime: Date,
|
||||
delegationCompletedDateTime: Date | null
|
||||
) {
|
||||
this.delegateType = delegateType;
|
||||
this.name = name;
|
||||
this.emailAddress = emailAddress;
|
||||
this.delegationDateTime = delegationDateTime;
|
||||
this.delegationCompletedDateTime = delegationCompletedDateTime;
|
||||
}
|
||||
}
|
||||
import { type DelegateType } from '../enums/DelegateType.js';
|
||||
|
||||
/**
|
||||
* @class Delegate - Represents a delegate.
|
||||
*/
|
||||
export class Delegate {
|
||||
/**
|
||||
* @property {DelegateType} delegateType - The type of delegate.
|
||||
*/
|
||||
public delegateType: DelegateType;
|
||||
|
||||
/**
|
||||
* @property {string | null} name - The name of the delegate.
|
||||
*/
|
||||
public name: string | null;
|
||||
|
||||
/**
|
||||
* @property {string} emailAddress - The email address of the delegate.
|
||||
*/
|
||||
public emailAddress: string;
|
||||
|
||||
/**
|
||||
* @property {Date} delegationDateTime - The date and time the delegate was assigned.
|
||||
*/
|
||||
public delegationDateTime: Date;
|
||||
|
||||
/**
|
||||
* @property {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
|
||||
*/
|
||||
public delegationCompletedDateTime: Date | null;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of Delegate.
|
||||
* @param {DelegateType} delegateType - The type of delegate.
|
||||
* @param {string | null} name - The name of the delegate.
|
||||
* @param {string} emailAddress - The email address of the delegate.
|
||||
* @param {Date} delegationDateTime - The date and time the delegate was assigned.
|
||||
* @param {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
|
||||
* @returns {Delegate} - A new instance of Delegate.
|
||||
*/
|
||||
constructor(
|
||||
delegateType: DelegateType,
|
||||
name: string | null,
|
||||
emailAddress: string,
|
||||
delegationDateTime: Date,
|
||||
delegationCompletedDateTime: Date | null
|
||||
) {
|
||||
this.delegateType = delegateType;
|
||||
this.name = name;
|
||||
this.emailAddress = emailAddress;
|
||||
this.delegationDateTime = delegationDateTime;
|
||||
this.delegationCompletedDateTime = delegationCompletedDateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { type Delegate } from './Delegate';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { type Delegate } from './Delegate.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class DelegateListRecordValue - Represents a delegate list record value.
|
||||
*/
|
||||
export class DelegateListRecordValue extends RecordValue<Delegate[]> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of DelegateListRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {Delegate[]} value - The value of the field.
|
||||
* @returns {DelegateListRecordValue} - A new instance of DelegateListRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: Delegate[]) {
|
||||
super(RecordValueType.DelegateList, fieldId, value);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { type FieldStatus } from '../enums/FieldStatus';
|
||||
import { type FieldType } from '../enums/FieldType';
|
||||
import { type FieldStatus } from '../enums/FieldStatus.js';
|
||||
import { type FieldType } from '../enums/FieldType.js';
|
||||
|
||||
/**
|
||||
* @class Field - Represents a Field.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FieldType } from '../enums/FieldType';
|
||||
import { FieldType } from '../enums/FieldType.js';
|
||||
|
||||
/**
|
||||
* @class FileInfo - Represents a file info.
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { type File } from './File';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { type File } from './File.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class FileListRecordValue - Represents a file list record value.
|
||||
*/
|
||||
export class FileListRecordValue extends RecordValue<File[]> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of FileListRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {File[]} value - The value of the field.
|
||||
* @returns {FileListRecordValue} - A new instance of FileListRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: File[]) {
|
||||
super(RecordValueType.FileList, fieldId, value);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { type FieldStatus } from '../enums/FieldStatus';
|
||||
import { type FieldType } from '../enums/FieldType';
|
||||
import { type FormulaOutputType } from '../enums/FormulaOutputType';
|
||||
import { Field } from './Field';
|
||||
import { type ListValue } from './ListValue';
|
||||
import { type FieldStatus } from '../enums/FieldStatus.js';
|
||||
import { type FieldType } from '../enums/FieldType.js';
|
||||
import { type FormulaOutputType } from '../enums/FormulaOutputType.js';
|
||||
import { Field } from './Field.js';
|
||||
import { type ListValue } from './ListValue.js';
|
||||
|
||||
/**
|
||||
* @class FormulaField - Represents a formula field.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PagedResponse } from './PagedResponse';
|
||||
import { type App } from './App';
|
||||
import { type App } from './App.js';
|
||||
import { PagedResponse } from './PagedResponse.js';
|
||||
|
||||
/**
|
||||
* @class GetPagedAppsResponse - A paged response model for the GetApps method.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type Field } from './Field';
|
||||
import { PagedResponse } from './PagedResponse';
|
||||
import { type Field } from './Field.js';
|
||||
import { PagedResponse } from './PagedResponse.js';
|
||||
|
||||
/**
|
||||
* @class GetPagedFieldsResponse - A response containing a paged collection of fields.
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import { type Record } from './Record';
|
||||
import { PagedResponse } from './PagedResponse';
|
||||
|
||||
/**
|
||||
* @class GetPagedRecordsResponse - A response containing a paged collection of records.
|
||||
*/
|
||||
export class GetPagedRecordsResponse extends PagedResponse<Record> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of the GetPagedRecordsResponse class.
|
||||
* @param {Record[]} items - The items in the collection.
|
||||
* @param {number} pageNumber - The page number of the response.
|
||||
* @param {number} pageSize - The page size of the response.
|
||||
* @param {number} totalPages - The total number of pages in the response.
|
||||
* @param {number} totalRecords - The total number of records in the response.
|
||||
* @returns {GetPagedRecordsResponse} - A new instance of the GetPagedRecordsResponse class.
|
||||
*/
|
||||
constructor(
|
||||
items: Record[],
|
||||
pageNumber: number,
|
||||
pageSize: number,
|
||||
totalPages: number,
|
||||
totalRecords: number
|
||||
) {
|
||||
super(items, pageNumber, pageSize, totalPages, totalRecords);
|
||||
}
|
||||
}
|
||||
import { PagedResponse } from './PagedResponse.js';
|
||||
import { type Record } from './Record.js';
|
||||
|
||||
/**
|
||||
* @class GetPagedRecordsResponse - A response containing a paged collection of records.
|
||||
*/
|
||||
export class GetPagedRecordsResponse extends PagedResponse<Record> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of the GetPagedRecordsResponse class.
|
||||
* @param {Record[]} items - The items in the collection.
|
||||
* @param {number} pageNumber - The page number of the response.
|
||||
* @param {number} pageSize - The page size of the response.
|
||||
* @param {number} totalPages - The total number of pages in the response.
|
||||
* @param {number} totalRecords - The total number of records in the response.
|
||||
* @returns {GetPagedRecordsResponse} - A new instance of the GetPagedRecordsResponse class.
|
||||
*/
|
||||
constructor(
|
||||
items: Record[],
|
||||
pageNumber: number,
|
||||
pageSize: number,
|
||||
totalPages: number,
|
||||
totalRecords: number
|
||||
) {
|
||||
super(items, pageNumber, pageSize, totalPages, totalRecords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PagedResponse } from './PagedResponse';
|
||||
import { type Report } from './Report';
|
||||
import { PagedResponse } from './PagedResponse.js';
|
||||
import { type Report } from './Report.js';
|
||||
|
||||
/**
|
||||
* @class GetPagedReportsResponse - Represents a response containing a paged list of reports.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
import { DataFormat } from '../enums/DataFormat.js';
|
||||
|
||||
/**
|
||||
* @class GetRecordRequest - A request to get a record.
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
import { PagingRequest } from './PagingRequest';
|
||||
import { DataFormat } from '../enums/DataFormat.js';
|
||||
import { PagingRequest } from './PagingRequest.js';
|
||||
|
||||
/**
|
||||
* @class GetRecordsByAppIdRequest - Represents a request to get records by app id.
|
||||
*/
|
||||
export class GetRecordsByAppIdRequest {
|
||||
/**
|
||||
* @property {number} appId - The id of the app that the records belong to.
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
|
||||
/**
|
||||
* @class GetRecordsRequest - Request to get records by their ids
|
||||
*/
|
||||
export class GetRecordsRequest {
|
||||
/**
|
||||
* @property {number} appId - The id of the app the records belong to.
|
||||
*/
|
||||
appId: number;
|
||||
|
||||
/**
|
||||
* @property {number[]} recordIds - The ids of the records to get.
|
||||
*/
|
||||
recordIds: number[];
|
||||
|
||||
/**
|
||||
* @property {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
*/
|
||||
fieldIds: number[];
|
||||
|
||||
/**
|
||||
* @property {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
dataFormat: DataFormat;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of GetRecordsRequest
|
||||
* @param {number} appId - The id of the app the records belong to.
|
||||
* @param {number[]} recordIds - The ids of the records to get.
|
||||
* @param {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
* @param {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
constructor(
|
||||
appId: number,
|
||||
recordIds: number[],
|
||||
fieldIds: number[] = [],
|
||||
dataFormat: DataFormat = DataFormat.Raw
|
||||
) {
|
||||
this.appId = appId;
|
||||
this.recordIds = recordIds;
|
||||
this.fieldIds = fieldIds;
|
||||
this.dataFormat = dataFormat;
|
||||
}
|
||||
}
|
||||
import { DataFormat } from '../enums/DataFormat.js';
|
||||
|
||||
/**
|
||||
* @class GetRecordsRequest - Request to get records by their ids
|
||||
*/
|
||||
export class GetRecordsRequest {
|
||||
/**
|
||||
* @property {number} appId - The id of the app the records belong to.
|
||||
*/
|
||||
appId: number;
|
||||
|
||||
/**
|
||||
* @property {number[]} recordIds - The ids of the records to get.
|
||||
*/
|
||||
recordIds: number[];
|
||||
|
||||
/**
|
||||
* @property {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
*/
|
||||
fieldIds: number[];
|
||||
|
||||
/**
|
||||
* @property {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
dataFormat: DataFormat;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of GetRecordsRequest
|
||||
* @param {number} appId - The id of the app the records belong to.
|
||||
* @param {number[]} recordIds - The ids of the records to get.
|
||||
* @param {number[]} fieldIds - The ids of the fields to include in the response.
|
||||
* @param {DataFormat} dataFormat - The format of the data in the response.
|
||||
*/
|
||||
constructor(
|
||||
appId: number,
|
||||
recordIds: number[],
|
||||
fieldIds: number[] = [],
|
||||
dataFormat: DataFormat = DataFormat.Raw
|
||||
) {
|
||||
this.appId = appId;
|
||||
this.recordIds = recordIds;
|
||||
this.fieldIds = fieldIds;
|
||||
this.dataFormat = dataFormat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class GuidListRecordValue - Represents a guid list record value.
|
||||
*/
|
||||
export class GuidListRecordValue extends RecordValue<string[]> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of GuidListRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {string[]} value - The value of the field.
|
||||
* @returns {GuidListRecordValue} - A new instance of GuidListRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: string[]) {
|
||||
super(RecordValueType.GuidList, fieldId, value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class GuidRecordValue - Represents a guid record value.
|
||||
*/
|
||||
export class GuidRecordValue extends RecordValue<string> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of GuidRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {string} value - The value of the field.
|
||||
* @returns {GuidRecordValue} - A new instance of GuidRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: string) {
|
||||
super(RecordValueType.Guid, fieldId, value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class IntegerListRecordValue - Represents an integer list record value.
|
||||
*/
|
||||
export class IntegerListRecordValue extends RecordValue<number[]> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of IntegerListRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {number[]} value - The value of the field.
|
||||
* @returns {IntegerListRecordValue} - A new instance of IntegerListRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: number[]) {
|
||||
super(RecordValueType.IntegerList, fieldId, value);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class IntegerRecordValue - A record value represented by an integer.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { type FieldStatus } from '../enums/FieldStatus';
|
||||
import { type FieldType } from '../enums/FieldType';
|
||||
import { type Multiplicity } from '../enums/Multiplicity';
|
||||
import { Field } from './Field';
|
||||
import { type ListValue } from './ListValue';
|
||||
import { type FieldStatus } from '../enums/FieldStatus.js';
|
||||
import { type FieldType } from '../enums/FieldType.js';
|
||||
import { type Multiplicity } from '../enums/Multiplicity.js';
|
||||
import { Field } from './Field.js';
|
||||
import { type ListValue } from './ListValue.js';
|
||||
|
||||
/**
|
||||
* @class ListField - Represents a list field.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CreatedWithIdResponse } from './CreatedWithIdResponse';
|
||||
import { CreatedWithIdResponse } from './CreatedWithIdResponse.js';
|
||||
/**
|
||||
* @class ListItemResponse - Represents a respons when a list item is created or updated.
|
||||
*/
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
import axios, {
|
||||
type CreateAxiosDefaults,
|
||||
type AxiosInstance,
|
||||
type AxiosRequestConfig,
|
||||
type CreateAxiosDefaults,
|
||||
} from 'axios';
|
||||
import { PagingRequest } from './PagingRequest';
|
||||
import { ArgumentValidator } from './ArgumentValidator';
|
||||
import { EndpointFactory } from './EndpointFactory';
|
||||
import { ApiResponseFactory } from './ApiResponseFactory';
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
import { ReportDataType } from '../enums/ReportDataType';
|
||||
import { Record } from './Record';
|
||||
import { type ApiResponse } from './ApiResponse';
|
||||
import { type GetPagedAppsResponse } from './GetPagedAppsResponse';
|
||||
import { type App } from './App';
|
||||
import { type CollectionResponse } from './CollectionResponse';
|
||||
import { type Field } from './Field';
|
||||
import { type GetPagedFieldsResponse } from './GetPagedFieldsResponse';
|
||||
import { type SaveFileRequest } from './SaveFileRequest';
|
||||
import { type CreatedWithIdResponse } from './CreatedWithIdResponse';
|
||||
import { type FileInfo } from './FileInfo';
|
||||
import { type File } from './File';
|
||||
import { type ListItemResponse } from './ListItemResponse';
|
||||
import { type ListItemRequest } from './ListItemRequest';
|
||||
import { type GetPagedReportsResponse } from './GetPagedReportsResponse';
|
||||
import { type ReportData } from './ReportData';
|
||||
import { type GetRecordRequest } from './GetRecordRequest';
|
||||
import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest';
|
||||
import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse';
|
||||
import { type GetRecordsRequest } from './GetRecordsRequest';
|
||||
import { type QueryRecordsRequest } from './QueryRecordsRequest';
|
||||
import { type SaveRecordResponse } from './SaveRecordResponse';
|
||||
import { type SaveRecordRequest } from './SaveRecordRequest';
|
||||
import { DataFormat } from '../enums/DataFormat.js';
|
||||
import { ReportDataType } from '../enums/ReportDataType.js';
|
||||
import { type ApiResponse } from './ApiResponse.js';
|
||||
import { ApiResponseFactory } from './ApiResponseFactory.js';
|
||||
import { type App } from './App.js';
|
||||
import { ArgumentValidator } from './ArgumentValidator.js';
|
||||
import { type CollectionResponse } from './CollectionResponse.js';
|
||||
import { type CreatedWithIdResponse } from './CreatedWithIdResponse.js';
|
||||
import { EndpointFactory } from './EndpointFactory.js';
|
||||
import { type Field } from './Field.js';
|
||||
import { type File } from './File.js';
|
||||
import { type FileInfo } from './FileInfo.js';
|
||||
import { type GetPagedAppsResponse } from './GetPagedAppsResponse.js';
|
||||
import { type GetPagedFieldsResponse } from './GetPagedFieldsResponse.js';
|
||||
import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse.js';
|
||||
import { type GetPagedReportsResponse } from './GetPagedReportsResponse.js';
|
||||
import { type GetRecordRequest } from './GetRecordRequest.js';
|
||||
import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest.js';
|
||||
import { type GetRecordsRequest } from './GetRecordsRequest.js';
|
||||
import { type ListItemRequest } from './ListItemRequest.js';
|
||||
import { type ListItemResponse } from './ListItemResponse.js';
|
||||
import { PagingRequest } from './PagingRequest.js';
|
||||
import { type QueryRecordsRequest } from './QueryRecordsRequest.js';
|
||||
import { Record } from './Record.js';
|
||||
import { type ReportData } from './ReportData.js';
|
||||
import { type SaveFileRequest } from './SaveFileRequest.js';
|
||||
import { type SaveRecordRequest } from './SaveRecordRequest.js';
|
||||
import { type SaveRecordResponse } from './SaveRecordResponse.js';
|
||||
|
||||
/**
|
||||
* @class OnspringClient - A client that can communicate with the Onspring API.
|
||||
@@ -49,7 +49,11 @@ export class OnspringClient {
|
||||
* @throws {Error} - Thrown when the apiKey is null/undefined/empty/whitespace.
|
||||
* @returns {OnspringClient} - A new instance of the OnspringClient class.
|
||||
*/
|
||||
constructor(baseUrl: string | undefined | null, apiKey: string | undefined | null, config: CreateAxiosDefaults = {}) {
|
||||
constructor(
|
||||
baseUrl: string | undefined | null,
|
||||
apiKey: string | undefined | null,
|
||||
config: CreateAxiosDefaults = {}
|
||||
) {
|
||||
if (ArgumentValidator.isValidUrl(baseUrl) === false || baseUrl === null) {
|
||||
throw new Error('baseUrl must be an absolute and well-formed URI.');
|
||||
}
|
||||
@@ -278,6 +282,13 @@ export class OnspringClient {
|
||||
return apiResponse.asCreatedWithIdResponseType<number>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @method deleteFileById - Deletes a file by its id.
|
||||
* @param {number} recordId - The id of the record that the file is held on.
|
||||
* @param {number} fieldId - The id of the field that the file is held in.
|
||||
* @param {number} fileId - The id of the file to delete.
|
||||
* @returns {Promise<ApiResponse<any>>} - A promise that resolves to an ApiResponse of type any.
|
||||
*/
|
||||
public async deleteFileById(
|
||||
recordId: number,
|
||||
fieldId: number,
|
||||
@@ -412,6 +423,11 @@ export class OnspringClient {
|
||||
return apiResponse.asGetPagedRecordsResponseType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @method saveRecord - Saves a record.
|
||||
* @param {Record | SaveRecordRequest} request - The record or request that will be used to save the record.
|
||||
* @returns {Promise<ApiResponse<SaveRecordResponse>>} - A promise that resolves to an ApiResponse of type SaveRecordResponse.
|
||||
*/
|
||||
public async saveRecord(
|
||||
request: Record | SaveRecordRequest
|
||||
): Promise<ApiResponse<SaveRecordResponse>> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ArgumentValidator } from './ArgumentValidator';
|
||||
import { ArgumentValidator } from './ArgumentValidator.js';
|
||||
|
||||
/**
|
||||
* @class PagingRequest - Paging request model
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
import { FilterOperators } from '../enums/FilterOperators';
|
||||
import { FilterOperators } from '../enums/FilterOperators.js';
|
||||
|
||||
/**
|
||||
* @class QueryFilter - Represents a query filter.
|
||||
*/
|
||||
export class QueryFilter {
|
||||
/**
|
||||
* @property {number} fieldId - The id of the field to filter on.
|
||||
*/
|
||||
public fieldId: number;
|
||||
|
||||
/**
|
||||
* @property {FilterOperators} operator - The operator for the filter.
|
||||
*/
|
||||
public operator: FilterOperators;
|
||||
|
||||
/**
|
||||
* @property {string | number | Date | null} value - The value for the filter.
|
||||
*/
|
||||
public value: string | number | Date | null;
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of the QueryFilter class.
|
||||
* @param {number} fieldId - The id of the field to filter on.
|
||||
* @param {FilterOperators} operator - The operator for the filter.
|
||||
* @param {string | number | Date | null} value - The value for the filter.
|
||||
* @returns {QueryFilter} - A new instance of the QueryFilter class.
|
||||
* @throws {Error} - If the value is null and the operator is not IsNull or NotNull.
|
||||
*/
|
||||
constructor(
|
||||
fieldId: number,
|
||||
operator: FilterOperators,
|
||||
@@ -23,6 +45,10 @@ export class QueryFilter {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method toString - Converts the filter to a string.
|
||||
* @returns {string} - The filter as a string.
|
||||
*/
|
||||
public toString(): string {
|
||||
if (this.value == null) {
|
||||
return `${this.fieldId} ${this.operator}`;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DataFormat } from '../enums/DataFormat';
|
||||
import { PagingRequest } from './PagingRequest';
|
||||
import { type QueryFilter } from './QueryFilter';
|
||||
import { DataFormat } from '../enums/DataFormat.js';
|
||||
import { PagingRequest } from './PagingRequest.js';
|
||||
import { type QueryFilter } from './QueryFilter.js';
|
||||
|
||||
/**
|
||||
* @class QueryRecordsRequest - Request to query for records.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type RecordValue } from './RecordValue';
|
||||
import { SaveRecordRequest } from './SaveRecordRequest';
|
||||
import { type RecordValue } from './RecordValue.js';
|
||||
import { SaveRecordRequest } from './SaveRecordRequest.js';
|
||||
|
||||
/**
|
||||
* @class Record - A record in an app.
|
||||
@@ -55,6 +55,10 @@ export class Record {
|
||||
this.fieldData = this.fieldData.concat(fieldData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method convertToSaveRecordRequest - Converts the record to a SaveRecordRequest.
|
||||
* @returns {SaveRecordRequest} - A SaveRecordRequest.
|
||||
*/
|
||||
public convertToSaveRecordRequest(): SaveRecordRequest {
|
||||
const fields = this.fieldData.reduce((acc, cur) => {
|
||||
acc.set(cur.fieldId, cur.value);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { type Attachment } from './Attachment';
|
||||
import { type AttachmentListRecordValue } from './AttachmentListRecordValue';
|
||||
import { type Delegate } from './Delegate';
|
||||
import { type DelegateListRecordValue } from './DelegateListRecordValue';
|
||||
import { type ScoringGroup } from './ScoringGroup';
|
||||
import { type ScoringGroupListRecordValue } from './ScoringGroupListRecordValue';
|
||||
import { type TimeSpanData } from './TimeSpanData';
|
||||
import { type TimeSpanRecordValue } from './TimeSpanRecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { type Attachment } from './Attachment.js';
|
||||
import { type AttachmentListRecordValue } from './AttachmentListRecordValue.js';
|
||||
import { type Delegate } from './Delegate.js';
|
||||
import { type DelegateListRecordValue } from './DelegateListRecordValue.js';
|
||||
import { type ScoringGroup } from './ScoringGroup.js';
|
||||
import { type ScoringGroupListRecordValue } from './ScoringGroupListRecordValue.js';
|
||||
import { type TimeSpanData } from './TimeSpanData.js';
|
||||
import { type TimeSpanRecordValue } from './TimeSpanRecordValue.js';
|
||||
|
||||
/**
|
||||
* @class RecordValue - A value for a field in a record.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type FieldStatus } from '../enums/FieldStatus';
|
||||
import { type FieldType } from '../enums/FieldType';
|
||||
import { type Multiplicity } from '../enums/Multiplicity';
|
||||
import { Field } from './Field';
|
||||
import { type FieldStatus } from '../enums/FieldStatus.js';
|
||||
import { type FieldType } from '../enums/FieldType.js';
|
||||
import { type Multiplicity } from '../enums/Multiplicity.js';
|
||||
import { Field } from './Field.js';
|
||||
|
||||
/**
|
||||
* @class ReferenceField - Represents a reference field.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Row } from './Row';
|
||||
import { type Row } from './Row.js';
|
||||
|
||||
/**
|
||||
* @class ReportData - Represents the data for a report.
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
import { CreatedWithIdResponse } from './CreatedWithIdResponse';
|
||||
import { CreatedWithIdResponse } from './CreatedWithIdResponse.js';
|
||||
|
||||
/**
|
||||
* @class SaveRecordResponse - Response from saving a record
|
||||
*/
|
||||
export class SaveRecordResponse extends CreatedWithIdResponse<number> {
|
||||
/**
|
||||
* @property {string[]} warnings - The warnings from saving the record.
|
||||
*/
|
||||
public warnings: string[];
|
||||
|
||||
/**
|
||||
* @constructor - Creates a new instance of SaveRecordResponse.
|
||||
* @param {number} id - The id of the record.
|
||||
* @param {string[]} warnings - The warnings from saving the record.
|
||||
* @returns {SaveRecordResponse} - A new instance of SaveRecordResponse.s
|
||||
*/
|
||||
constructor(id: number, warnings: string[] = []) {
|
||||
super(id);
|
||||
this.warnings = warnings;
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { type ScoringGroup } from './ScoringGroup';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
import { type ScoringGroup } from './ScoringGroup.js';
|
||||
|
||||
/**
|
||||
* @class ScoringGroupListRecordValue - Represents a scoring group list record value.
|
||||
*/
|
||||
export class ScoringGroupListRecordValue extends RecordValue<ScoringGroup[]> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of ScoringGroupListRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {ScoringGroup[]} value - The value of the field.
|
||||
* @returns {ScoringGroupListRecordValue} - A new instance of ScoringGroupListRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: ScoringGroup[]) {
|
||||
super(RecordValueType.ScoringGroupList, fieldId, value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class StringListRecordValue - Represents a string list record value.
|
||||
*/
|
||||
export class StringListRecordValue extends RecordValue<string[]> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of StringListRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {string[]} value - The value of the field.
|
||||
* @returns {StringListRecordValue} - A new instance of StringListRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: string[]) {
|
||||
super(RecordValueType.StringList, fieldId, value);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
|
||||
/**
|
||||
* @class StringRecordValue - A record value represented by a string.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type TimeSpanIncrement } from '../enums/TimeSpanIncrement';
|
||||
import { type TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType';
|
||||
import { type TimeSpanIncrement } from '../enums/TimeSpanIncrement.js';
|
||||
import { type TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType.js';
|
||||
|
||||
export class TimeSpanData {
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { RecordValueType } from '../enums/RecordValueType';
|
||||
import { RecordValue } from './RecordValue';
|
||||
import { type TimeSpanData } from './TimeSpanData';
|
||||
import { RecordValueType } from '../enums/RecordValueType.js';
|
||||
import { RecordValue } from './RecordValue.js';
|
||||
import { type TimeSpanData } from './TimeSpanData.js';
|
||||
|
||||
/**
|
||||
* @class TimeSpanRecordValue - Represents a time span record value.
|
||||
*/
|
||||
export class TimeSpanRecordValue extends RecordValue<TimeSpanData> {
|
||||
/**
|
||||
* @constructor - Creates a new instance of TimeSpanRecordValue.
|
||||
* @param {number} fieldId - The id of the field.
|
||||
* @param {TimeSpanData} value - The value of the field.
|
||||
* @returns {TimeSpanRecordValue} - A new instance of TimeSpanRecordValue.
|
||||
*/
|
||||
constructor(fieldId: number, value: TimeSpanData) {
|
||||
super(RecordValueType.TimeSpan, fieldId, value);
|
||||
}
|
||||
|
||||
+23
-21
@@ -1,33 +1,33 @@
|
||||
import { ApiResponse } from '../src/models/ApiResponse';
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import { expect } from 'chai';
|
||||
import { GetPagedAppsResponse } from '../src/models/GetPagedAppsResponse';
|
||||
import { App } from '../src/models/App';
|
||||
import { CollectionResponse } from '../src/models/CollectionResponse';
|
||||
import { Field } from '../src/models/Field';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { GetPagedFieldsResponse } from '../src/models/GetPagedFieldsResponse';
|
||||
import { CreatedWithIdResponse } from '../src/models/CreatedWithIdResponse';
|
||||
import { FormulaField } from '../src/models/FormulaField';
|
||||
import { FormulaOutputType } from '../src/enums/FormulaOutputType';
|
||||
import { ListValue } from '../src/models/ListValue';
|
||||
import { ReferenceField } from '../src/models/ReferenceField';
|
||||
import { Multiplicity } from '../src/enums/Multiplicity';
|
||||
import { ListField } from '../src/models/ListField';
|
||||
import { ApiResponse } from '../src/models/ApiResponse';
|
||||
import { App } from '../src/models/App';
|
||||
import { CollectionResponse } from '../src/models/CollectionResponse';
|
||||
import { CreatedWithIdResponse } from '../src/models/CreatedWithIdResponse';
|
||||
import { Field } from '../src/models/Field';
|
||||
import { File } from '../src/models/File';
|
||||
import { ListItemResponse } from '../src/models/ListItemResponse';
|
||||
import { FormulaField } from '../src/models/FormulaField';
|
||||
import { GetPagedAppsResponse } from '../src/models/GetPagedAppsResponse';
|
||||
import { GetPagedFieldsResponse } from '../src/models/GetPagedFieldsResponse';
|
||||
import { GetPagedRecordsResponse } from '../src/models/GetPagedRecordsResponse';
|
||||
import { GetPagedReportsResponse } from '../src/models/GetPagedReportsResponse';
|
||||
import { ListField } from '../src/models/ListField';
|
||||
import { ListItemResponse } from '../src/models/ListItemResponse';
|
||||
import { ListValue } from '../src/models/ListValue';
|
||||
import { Record } from '../src/models/Record';
|
||||
import { RecordValue } from '../src/models/RecordValue';
|
||||
import { ReferenceField } from '../src/models/ReferenceField';
|
||||
import { Report } from '../src/models/Report';
|
||||
import { ReportData } from '../src/models/ReportData';
|
||||
import { Row } from '../src/models/Row';
|
||||
import { Record } from '../src/models/Record';
|
||||
import { RecordValue } from '../src/models/RecordValue';
|
||||
import { GetPagedRecordsResponse } from '../src/models/GetPagedRecordsResponse';
|
||||
import { testFieldData } from './testData/testFieldData';
|
||||
import { type AxiosResponse } from 'axios';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { SaveRecordResponse } from '../src/models/SaveRecordResponse';
|
||||
import { testFieldData } from './testData/testFieldData';
|
||||
|
||||
describe('ApiResponse', function () {
|
||||
it('should be defined', function () {
|
||||
@@ -807,7 +807,8 @@ describe('ApiResponse', function () {
|
||||
const mockResponse = {
|
||||
headers: {
|
||||
'content-type': 'text/plain',
|
||||
'content-disposition': 'attachment; filename="test-attachment.txt"',
|
||||
'content-disposition':
|
||||
"attachment; filename=test-attachment.txt; filename*=UTF-8''test-attachment.txt",
|
||||
'Content-Length': '13',
|
||||
} as AxiosResponse['headers'],
|
||||
} as AxiosResponse;
|
||||
@@ -837,7 +838,8 @@ describe('ApiResponse', function () {
|
||||
const mockResponse = {
|
||||
headers: {
|
||||
'content-type': 'image/jpeg',
|
||||
'content-disposition': 'attachment; filename="test-image.jpeg"',
|
||||
'content-disposition':
|
||||
"attachment; filename=test-image.jpeg; filename*=UTF-8''test-image.jpeg",
|
||||
'Content-Length': '98897',
|
||||
} as AxiosResponse['headers'],
|
||||
} as AxiosResponse;
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
import { OnspringClient } from '../src/models/OnspringClient';
|
||||
import { ApiResponse } from '../src/models/ApiResponse';
|
||||
import axios, {
|
||||
type AxiosResponse,
|
||||
type InternalAxiosRequestConfig,
|
||||
} from 'axios';
|
||||
import { expect } from 'chai';
|
||||
import { GetPagedAppsResponse } from '../src/models/GetPagedAppsResponse';
|
||||
import { App } from '../src/models/App';
|
||||
import { CollectionResponse } from '../src/models/CollectionResponse';
|
||||
import { Field } from '../src/models/Field';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { GetPagedFieldsResponse } from '../src/models/GetPagedFieldsResponse';
|
||||
import { SaveFileRequest } from '../src/models/SaveFileRequest';
|
||||
import { Readable } from 'stream';
|
||||
import { CreatedWithIdResponse } from '../src/models/CreatedWithIdResponse';
|
||||
import { FileInfo } from '../src/models/FileInfo';
|
||||
import { File } from '../src/models/File';
|
||||
import { ListItemRequest } from '../src/models/ListItemRequest';
|
||||
import { ListItemResponse } from '../src/models/ListItemResponse';
|
||||
import { Report } from '../src/models/Report';
|
||||
import { GetPagedReportsResponse } from '../src/models/GetPagedReportsResponse';
|
||||
import { ReportData } from '../src/models/ReportData';
|
||||
import { GetRecordRequest } from '../src/models/GetRecordRequest';
|
||||
import { Record } from '../src/models/Record';
|
||||
import { RecordValue } from '../src/models/RecordValue';
|
||||
import { GetRecordsByAppIdRequest } from '../src/models/GetRecordsByAppIdRequest';
|
||||
import { GetPagedRecordsResponse } from '../src/models/GetPagedRecordsResponse';
|
||||
import { GetRecordsRequest } from '../src/models/GetRecordsRequest';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import * as sinon from 'sinon';
|
||||
import { Readable } from 'stream';
|
||||
import { FieldStatus } from '../src/enums/FieldStatus';
|
||||
import { FieldType } from '../src/enums/FieldType';
|
||||
import { ApiResponse } from '../src/models/ApiResponse';
|
||||
import { App } from '../src/models/App';
|
||||
import { CollectionResponse } from '../src/models/CollectionResponse';
|
||||
import { CreatedWithIdResponse } from '../src/models/CreatedWithIdResponse';
|
||||
import { Field } from '../src/models/Field';
|
||||
import { File } from '../src/models/File';
|
||||
import { FileInfo } from '../src/models/FileInfo';
|
||||
import { GetPagedAppsResponse } from '../src/models/GetPagedAppsResponse';
|
||||
import { GetPagedFieldsResponse } from '../src/models/GetPagedFieldsResponse';
|
||||
import { GetPagedRecordsResponse } from '../src/models/GetPagedRecordsResponse';
|
||||
import { GetPagedReportsResponse } from '../src/models/GetPagedReportsResponse';
|
||||
import { GetRecordRequest } from '../src/models/GetRecordRequest';
|
||||
import { GetRecordsByAppIdRequest } from '../src/models/GetRecordsByAppIdRequest';
|
||||
import { GetRecordsRequest } from '../src/models/GetRecordsRequest';
|
||||
import { ListItemRequest } from '../src/models/ListItemRequest';
|
||||
import { ListItemResponse } from '../src/models/ListItemResponse';
|
||||
import { OnspringClient } from '../src/models/OnspringClient';
|
||||
import { QueryRecordsRequest } from '../src/models/QueryRecordsRequest';
|
||||
import { Record } from '../src/models/Record';
|
||||
import { RecordValue } from '../src/models/RecordValue';
|
||||
import { Report } from '../src/models/Report';
|
||||
import { ReportData } from '../src/models/ReportData';
|
||||
import { SaveFileRequest } from '../src/models/SaveFileRequest';
|
||||
import { SaveRecordRequest } from '../src/models/SaveRecordRequest';
|
||||
|
||||
describe('OnspringClient', function () {
|
||||
@@ -1796,7 +1796,8 @@ describe('OnspringClient', function () {
|
||||
statusText: 'OK',
|
||||
data: file,
|
||||
headers: {
|
||||
'content-disposition': 'attachment; filename="test-attachment.txt"',
|
||||
'content-disposition':
|
||||
"attachment; filename=test-attachment.txt; filename*=UTF-8''test-attachment.txt",
|
||||
'content-length': 14,
|
||||
'content-type': 'text/plain',
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"module": "commonjs",
|
||||
"target": "ES6"
|
||||
},
|
||||
"experimentalResolver": true,
|
||||
"moduleTypes": {
|
||||
"*.ts": "cjs"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user