43 Commits
Author SHA1 Message Date
Stevan Freeborn 90a559a7c8 Merge pull request #9 from StevanFreeborn/stevanfreeborn/chore/fix-publish-workflow
chore: use latest version of node for publish job
2024-03-23 15:09:30 -05:00
Stevan Freeborn 819b6fc550 chore: use latest version of node for publish job 2024-03-23 15:08:50 -05:00
Stevan Freeborn 3fc167c0df Merge pull request #8 from StevanFreeborn/stevanfreeborn/chore/update-dependencies
chore: update dependencies to address vulns
2024-03-23 15:02:51 -05:00
Stevan Freeborn 682eacf1ee fix: update workflow to include test for v20 of node 2024-03-23 14:53:09 -05:00
Stevan Freeborn 920d8bbdfd chore: update actions 2024-03-23 14:44:16 -05:00
Stevan Freeborn de940a189e chore: update dependencies to address vulns 2024-03-23 14:17:01 -05:00
Stevan Freeborn aafeba7d31 Merge pull request #5 from StevanFreeborn/docs-add-downloads-badge
docs: add downloads count
2023-11-02 15:44:45 -05:00
Stevan Freeborn e0b4f85b3d docs: add downloads count 2023-11-02 15:44:17 -05:00
Stevan Freeborn 67477023ad Merge pull request #4 from StevanFreeborn/stevan/docs/fix-usage-typos
docs: fix typo in usage examples
2023-06-12 12:39:15 -05:00
Stevan Freeborn 9292780007 docs: fix typo in usage examples 2023-06-12 12:36:39 -05:00
Stevan Freeborn e937d05490 Merge pull request #3 from StevanFreeborn/fix/update-documentation
fix: update documentation
2023-02-21 22:40:19 -06:00
StevanFreeborn eac881ec58 chore: update build script and build workflow 2023-02-21 22:35:57 -06:00
StevanFreeborn 9ff9f24d85 chore: update husky commit-msg 2023-02-21 22:25:27 -06:00
StevanFreeborn f412594338 chore: update publish coverage job with step to checkout repo 2023-02-21 22:21:38 -06:00
Stevan Freeborn 1bc5248781 chore: more work on coverage job 2023-02-21 22:07:06 -06:00
Stevan Freeborn 16fc7e2eae chore: more work on coverage job 2023-02-21 22:02:15 -06:00
Stevan Freeborn 8930bc2777 chore: update publish_test_coverage job 2023-02-21 21:58:01 -06:00
Stevan Freeborn 866774b5a5 chore: update publish_test_coverage job 2023-02-21 21:51:52 -06:00
Stevan Freeborn 74a1133e6f chore: update publish_test_coverage job 2023-02-21 21:47:22 -06:00
Stevan Freeborn 5938f28603 chore: update publish_test_coverage job 2023-02-21 21:40:56 -06:00
Stevan Freeborn bc44ed3a7a chore: update publish_test_coverage job 2023-02-21 21:34:45 -06:00
Stevan Freeborn 06ac0e91b0 chore: update publish_test_coverage job 2023-02-21 21:20:38 -06:00
Stevan Freeborn 0f58867c49 fix: incorrectly spelled variable name corrected 2023-02-21 21:13:51 -06:00
Stevan Freeborn 0aa840873c docs: update README.md 2023-02-21 21:12:57 -06:00
Stevan Freeborn ad9325a840 fix: finished updating README.md 2023-02-21 20:49:49 -06:00
Stevan Freeborn 1fcf72dca3 Merge branch 'master' into fix/update-documentation 2023-02-21 16:50:16 -06:00
Stevan Freeborn e393491bfc Merge pull request #2 from StevanFreeborn/fix/file-name-bug
fix: file name bug
2023-02-21 16:46:03 -06:00
Stevan Freeborn 522efb1f67 fix: file name bug
+ Addressed issue where file names were not being properly parsed
  from the response headers.
+ Updated tests to ensure that the file name is properly parsed from
  the response headers.
2023-02-21 16:41:06 -06:00
Stevan Freeborn 77edd0a1fa docs: add code examples to README.md
+ Added code example for configuring onspring client
+ Added code examples for field methods
+ Added code example for getFileInfoById method
2023-02-21 16:27:05 -06:00
Stevan Freeborn d700c4fe4c docs: added example usages for canConnect, getApps, getAppById, and getAppsByIds methods 2023-02-21 14:28:02 -06:00
Stevan Freeborn 52b5d36ddd chore: fix merge conflict 2023-02-21 13:54:33 -06:00
Stevan Freeborn dbdd3e1895 docs: begin working on code snippets 2023-02-21 13:48:32 -06:00
StevanFreeborn d8b6bf0b7b docs: stub out README.md 2023-02-21 13:48:32 -06:00
StevanFreeborn 07ec44a0ad fix: add jsdoc comments to models 2023-02-21 13:48:32 -06:00
StevanFreeborn e97ee15387 fix: update jsdoc comments for enums 2023-02-21 13:48:32 -06:00
Stevan Freeborn 2000a860a4 Merge pull request #1 from StevanFreeborn/fix/import-issue
Fix: ESM Import Issue
2023-02-21 13:39:27 -06:00
Stevan Freeborn b989adc01d fix: make changes to allow esm imports to work properly 2023-02-21 13:23:07 -06:00
Stevan Freeborn 7e33c5ecaa fix: update package.json to properly handle bringing in exports with import or require 2023-02-21 11:10:09 -06:00
StevanFreeborn f48189a881 docs: stub out README.md 2023-02-21 08:59:14 -06:00
StevanFreeborn 396660e801 fix: add jsdoc comments to models 2023-02-20 21:08:22 -06:00
StevanFreeborn f3c69d3a34 fix: update jsdoc comments for enums 2023-02-20 19:12:15 -06:00
Stevan Freeborn 377469ab6b docs: update README.md 2023-02-20 17:22:55 -06:00
Stevan Freeborn a9725fcbaf ci: update release configuration and workflows 2023-02-20 17:22:15 -06:00
59 changed files with 1546 additions and 572 deletions
+1
View File
@@ -4,3 +4,4 @@ coverage/
dist/
node_modules/
.github/
scripts/
+10 -4
View File
@@ -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 }]
}
}
+10 -7
View File
@@ -7,14 +7,15 @@ on:
- src/**
branches:
- master
- beta
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install dependencies
@@ -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:
@@ -61,16 +66,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: latest
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:
+23 -8
View File
@@ -8,17 +8,18 @@ on:
- '**/README.md'
branches:
- master
- beta
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_PAT }}
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install dependencies
@@ -41,11 +42,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_PAT }}
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install dependencies
@@ -69,13 +70,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x, 20.x]
fail-fast: false
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
@@ -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@v4
- 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
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Regular → Executable
View File
+13 -3
View File
@@ -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"
}
-6
View File
@@ -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"
]
+622 -1
View File
@@ -3,5 +3,626 @@
[![lint_format_test](https://github.com/StevanFreeborn/onspring-api-sdk-javascript/actions/workflows/lint_format_test.yaml/badge.svg?branch=master)](https://github.com/StevanFreeborn/onspring-api-sdk-javascript/actions/workflows/lint_format_test.yaml)
[![codecov](https://codecov.io/github/StevanFreeborn/onspring-api-sdk-javascript/branch/master/graph/badge.svg?token=G1L3GKE0LV)](https://codecov.io/github/StevanFreeborn/onspring-api-sdk-javascript)
[![build_publish](https://github.com/StevanFreeborn/onspring-api-sdk-javascript/actions/workflows/build_publish.yml/badge.svg?branch=master)](https://github.com/StevanFreeborn/onspring-api-sdk-javascript/actions/workflows/build_publish.yml)
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
[![NPM](https://img.shields.io/npm/l/onspring-api-sdk)](License.txt)
![npm](https://img.shields.io/npm/v/onspring-api-sdk)
![npm](https://img.shields.io/npm/dt/onspring-api-sdk)
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
![node-current](https://img.shields.io/node/v/onspring-api-sdk)
Requires use of [Node.js](https://nodejs.org/en/) 14.x or later.
### Axios
![npm (prod) dependency version](https://img.shields.io/npm/dependency-version/onspring-api-sdk/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
![npm (prod) dependency version](https://img.shields.io/npm/dependency-version/onspring-api-sdk/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` 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 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,
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 records = res.data.items;
for (const record of records) {
console.log(record);
}
```
#### 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);
}
```
+223 -119
View File
@@ -38,6 +38,7 @@
"pretty-quick": "^3.1.3",
"sinon": "^15.0.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.12",
"typescript": "^4.9.5"
},
"engines": {
@@ -58,12 +59,13 @@
}
},
"node_modules/@babel/code-frame": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
"integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
"version": "7.24.2",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.2.tgz",
"integrity": "sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==",
"dev": true,
"dependencies": {
"@babel/highlight": "^7.18.6"
"@babel/highlight": "^7.24.2",
"picocolors": "^1.0.0"
},
"engines": {
"node": ">=6.9.0"
@@ -109,13 +111,14 @@
}
},
"node_modules/@babel/generator": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.7.tgz",
"integrity": "sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw==",
"version": "7.24.1",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.1.tgz",
"integrity": "sha512-DfCRfZsBcrPEHUfuBMgbJ1Ut01Y/itOs+hY2nFLgqsqXd52/iSiVq5TITtUasIUgm+IIKdY2/1I7auiQOEeC9A==",
"dev": true,
"dependencies": {
"@babel/types": "^7.20.7",
"@jridgewell/gen-mapping": "^0.3.2",
"@babel/types": "^7.24.0",
"@jridgewell/gen-mapping": "^0.3.5",
"@jridgewell/trace-mapping": "^0.3.25",
"jsesc": "^2.5.1"
},
"engines": {
@@ -123,19 +126,29 @@
}
},
"node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
"integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==",
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz",
"integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==",
"dev": true,
"dependencies": {
"@jridgewell/set-array": "^1.0.1",
"@jridgewell/set-array": "^1.2.1",
"@jridgewell/sourcemap-codec": "^1.4.10",
"@jridgewell/trace-mapping": "^0.3.9"
"@jridgewell/trace-mapping": "^0.3.24"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/generator/node_modules/@jridgewell/trace-mapping": {
"version": "0.3.25",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",
"integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
"dev": true,
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@babel/helper-compilation-targets": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz",
@@ -156,34 +169,34 @@
}
},
"node_modules/@babel/helper-environment-visitor": {
"version": "7.18.9",
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz",
"integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==",
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz",
"integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-function-name": {
"version": "7.19.0",
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz",
"integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==",
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz",
"integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==",
"dev": true,
"dependencies": {
"@babel/template": "^7.18.10",
"@babel/types": "^7.19.0"
"@babel/template": "^7.22.15",
"@babel/types": "^7.23.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-hoist-variables": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz",
"integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==",
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz",
"integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==",
"dev": true,
"dependencies": {
"@babel/types": "^7.18.6"
"@babel/types": "^7.22.5"
},
"engines": {
"node": ">=6.9.0"
@@ -233,30 +246,30 @@
}
},
"node_modules/@babel/helper-split-export-declaration": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz",
"integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==",
"version": "7.22.6",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz",
"integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==",
"dev": true,
"dependencies": {
"@babel/types": "^7.18.6"
"@babel/types": "^7.22.5"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.19.4",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz",
"integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==",
"version": "7.24.1",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz",
"integrity": "sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.19.1",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz",
"integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==",
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
"integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
"dev": true,
"engines": {
"node": ">=6.9.0"
@@ -286,14 +299,15 @@
}
},
"node_modules/@babel/highlight": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz",
"integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==",
"version": "7.24.2",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.2.tgz",
"integrity": "sha512-Yac1ao4flkTxTteCDZLEvdxg2fZfz1v8M4QpaGypq/WPDqg3ijHYbDfs+LG5hvzSoqaSZ9/Z9lKSP3CjZjv+pA==",
"dev": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.18.6",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
"@babel/helper-validator-identifier": "^7.22.20",
"chalk": "^2.4.2",
"js-tokens": "^4.0.0",
"picocolors": "^1.0.0"
},
"engines": {
"node": ">=6.9.0"
@@ -371,9 +385,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.20.13",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.13.tgz",
"integrity": "sha512-gFDLKMfpiXCsjt4za2JA9oTMn70CeseCehb11kRZgvd7+F67Hih3OHOK24cRrWECJ/ljfPGac6ygXAs/C8kIvw==",
"version": "7.24.1",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz",
"integrity": "sha512-Zo9c7N3xdOIQrNip7Lc9wvRPzlRtovHVE4lkz8WEDr7uYh/GMQhSiIgFxGIArRHYdJE5kxtZjAf8rT0xhdLCzg==",
"dev": true,
"bin": {
"parser": "bin/babel-parser.js"
@@ -383,34 +397,34 @@
}
},
"node_modules/@babel/template": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz",
"integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==",
"version": "7.24.0",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.0.tgz",
"integrity": "sha512-Bkf2q8lMB0AFpX0NFEqSbx1OkTHf0f+0j82mkw+ZpzBnkk7e9Ql0891vlfgi+kHwOk8tQjiQHpqh4LaSa0fKEA==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.18.6",
"@babel/parser": "^7.20.7",
"@babel/types": "^7.20.7"
"@babel/code-frame": "^7.23.5",
"@babel/parser": "^7.24.0",
"@babel/types": "^7.24.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/traverse": {
"version": "7.20.13",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.13.tgz",
"integrity": "sha512-kMJXfF0T6DIS9E8cgdLCSAL+cuCK+YEZHWiLK0SXpTo8YRj5lpJu3CDNKiIBCne4m9hhTIqUg6SYTAI39tAiVQ==",
"version": "7.24.1",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.24.1.tgz",
"integrity": "sha512-xuU6o9m68KeqZbQuDt2TcKSxUw/mrsvavlEqQ1leZ/B+C9tk6E4sRWy97WaXgvq5E+nU3cXMxv3WKOCanVMCmQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.18.6",
"@babel/generator": "^7.20.7",
"@babel/helper-environment-visitor": "^7.18.9",
"@babel/helper-function-name": "^7.19.0",
"@babel/helper-hoist-variables": "^7.18.6",
"@babel/helper-split-export-declaration": "^7.18.6",
"@babel/parser": "^7.20.13",
"@babel/types": "^7.20.7",
"debug": "^4.1.0",
"@babel/code-frame": "^7.24.1",
"@babel/generator": "^7.24.1",
"@babel/helper-environment-visitor": "^7.22.20",
"@babel/helper-function-name": "^7.23.0",
"@babel/helper-hoist-variables": "^7.22.5",
"@babel/helper-split-export-declaration": "^7.22.6",
"@babel/parser": "^7.24.1",
"@babel/types": "^7.24.0",
"debug": "^4.3.1",
"globals": "^11.1.0"
},
"engines": {
@@ -418,13 +432,13 @@
}
},
"node_modules/@babel/types": {
"version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.7.tgz",
"integrity": "sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg==",
"version": "7.24.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
"integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
"dev": true,
"dependencies": {
"@babel/helper-string-parser": "^7.19.4",
"@babel/helper-validator-identifier": "^7.19.1",
"@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0"
},
"engines": {
@@ -627,13 +641,13 @@
}
},
"node_modules/@commitlint/is-ignored": {
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.4.4.tgz",
"integrity": "sha512-Y3eo1SFJ2JQDik4rWkBC4tlRIxlXEFrRWxcyrzb1PUT2k3kZ/XGNuCDfk/u0bU2/yS0tOA/mTjFsV+C4qyACHw==",
"version": "17.8.1",
"resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.8.1.tgz",
"integrity": "sha512-UshMi4Ltb4ZlNn4F7WtSEugFDZmctzFpmbqvpyxD3la510J+PLcnyhf9chs7EryaRFJMdAKwsEKfNK0jL/QM4g==",
"dev": true,
"dependencies": {
"@commitlint/types": "^17.4.4",
"semver": "7.3.8"
"@commitlint/types": "^17.8.1",
"semver": "7.5.4"
},
"engines": {
"node": ">=v14"
@@ -652,9 +666,9 @@
}
},
"node_modules/@commitlint/is-ignored/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -850,9 +864,9 @@
}
},
"node_modules/@commitlint/types": {
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.4.4.tgz",
"integrity": "sha512-amRN8tRLYOsxRr6mTnGGGvB5EmW/4DDjLMgiwK3CCVEmN6Sr/6xePGEpWaspKkckILuUORCwe6VfDBw6uj4axQ==",
"version": "17.8.1",
"resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.8.1.tgz",
"integrity": "sha512-PXDQXkAmiMEG162Bqdh9ChML/GJZo6vU+7F03ALKDK8zYc6SuAr47LjG7hGYRqUOz+WK0dU7bQ0xzuqFMdxzeQ==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0"
@@ -1146,9 +1160,9 @@
}
},
"node_modules/@jridgewell/set-array": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz",
"integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz",
"integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",
"dev": true,
"engines": {
"node": ">=6.0.0"
@@ -1380,9 +1394,9 @@
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -1524,9 +1538,9 @@
}
},
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -1583,9 +1597,9 @@
}
},
"node_modules/@typescript-eslint/utils/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -1697,6 +1711,12 @@
"node": ">=8"
}
},
"node_modules/ansi-sequence-parser": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz",
"integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==",
"dev": true
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
@@ -1870,11 +1890,11 @@
}
},
"node_modules/axios": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.2.4.tgz",
"integrity": "sha512-lIQuCfBJvZB/Bv7+RWUqEJqNShGOVpk9v7P0ZWx5Ip0qY6u7JBAU6dzQPMLasU9vHL2uD8av/1FDJXj7n6c39w==",
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
"integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
"dependencies": {
"follow-redirects": "^1.15.0",
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
@@ -1971,9 +1991,9 @@
}
},
"node_modules/builtins/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -3021,9 +3041,9 @@
}
},
"node_modules/eslint-plugin-n/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -3427,9 +3447,9 @@
"dev": true
},
"node_modules/follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
@@ -3572,9 +3592,9 @@
}
},
"node_modules/get-func-name": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
"integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz",
"integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==",
"dev": true,
"engines": {
"node": "*"
@@ -4570,6 +4590,12 @@
"node": ">=6"
}
},
"node_modules/jsonc-parser": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz",
"integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==",
"dev": true
},
"node_modules/jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
@@ -4768,6 +4794,12 @@
"yallist": "^3.0.2"
}
},
"node_modules/lunr": {
"version": "2.3.9",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
"dev": true
},
"node_modules/make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@@ -4801,6 +4833,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/marked": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",
"integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",
"dev": true,
"bin": {
"marked": "bin/marked.js"
},
"engines": {
"node": ">= 12"
}
},
"node_modules/meow": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/meow/-/meow-8.1.2.tgz",
@@ -5132,9 +5176,9 @@
}
},
"node_modules/normalize-package-data/node_modules/semver": {
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
@@ -5999,9 +6043,9 @@
}
},
"node_modules/read-pkg/node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
"dev": true,
"bin": {
"semver": "bin/semver"
@@ -6241,9 +6285,9 @@
}
},
"node_modules/semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"dev": true,
"bin": {
"semver": "bin/semver.js"
@@ -6285,6 +6329,18 @@
"node": ">=8"
}
},
"node_modules/shiki": {
"version": "0.14.7",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz",
"integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==",
"dev": true,
"dependencies": {
"ansi-sequence-parser": "^1.1.0",
"jsonc-parser": "^3.2.0",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^8.0.0"
}
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@@ -6804,6 +6860,42 @@
"is-typedarray": "^1.0.0"
}
},
"node_modules/typedoc": {
"version": "0.25.12",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.12.tgz",
"integrity": "sha512-F+qhkK2VoTweDXd1c42GS/By2DvI2uDF4/EpG424dTexSHdtCH52C6IcAvMA6jR3DzAWZjHpUOW+E02kyPNUNw==",
"dev": true,
"dependencies": {
"lunr": "^2.3.9",
"marked": "^4.3.0",
"minimatch": "^9.0.3",
"shiki": "^0.14.7"
},
"bin": {
"typedoc": "bin/typedoc"
},
"engines": {
"node": ">= 16"
},
"peerDependencies": {
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x"
}
},
"node_modules/typedoc/node_modules/minimatch": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
"integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==",
"dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/typescript": {
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
@@ -6907,6 +6999,18 @@
"spdx-expression-parse": "^3.0.0"
}
},
"node_modules/vscode-oniguruma": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
"integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==",
"dev": true
},
"node_modules/vscode-textmate": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
"integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==",
"dev": true
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@@ -6965,9 +7069,9 @@
}
},
"node_modules/word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
"integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==",
"dev": true,
"engines": {
"node": ">=0.10.0"
+8 -4
View File
@@ -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": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"default": "./dist/cjs/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",
@@ -81,6 +84,7 @@
"pretty-quick": "^3.1.3",
"sinon": "^15.0.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.12",
"typescript": "^4.9.5"
},
"dependencies": {
+15
View File
@@ -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);
+12
View File
@@ -1,4 +1,16 @@
/**
* @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',
}
+3
View File
@@ -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.
+10
View File
@@ -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',
+3
View File
@@ -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
View File
@@ -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,
+77 -54
View File
@@ -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.
@@ -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
);
+5 -3
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { type FileStorageSite } from '../enums/FileStorageSite';
import { type FileStorageSite } from '../enums/FileStorageSite.js';
/**
* @class Attachment - Represents an attachment.
+3 -3
View File
@@ -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.
+3
View File
@@ -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.
+2 -2
View File
@@ -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.
+11 -2
View File
@@ -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);
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { type DelegateType } from '../enums/DelegateType';
import { type DelegateType } from '../enums/DelegateType.js';
/**
* @class Delegate - Represents a delegate.
+12 -3
View File
@@ -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
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { FieldType } from '../enums/FieldType';
import { FieldType } from '../enums/FieldType.js';
/**
* @class FileInfo - Represents a file info.
+12 -3
View File
@@ -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);
}
+5 -5
View File
@@ -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.
+2 -2
View File
@@ -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.
+2 -2
View File
@@ -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.
+2 -2
View File
@@ -1,5 +1,5 @@
import { type Record } from './Record';
import { PagedResponse } from './PagedResponse';
import { PagedResponse } from './PagedResponse.js';
import { type Record } from './Record.js';
/**
* @class GetPagedRecordsResponse - A response containing a paged collection of records.
+2 -2
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { DataFormat } from '../enums/DataFormat';
import { DataFormat } from '../enums/DataFormat.js';
/**
* @class GetRecordRequest - A request to get a record.
+5 -2
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { DataFormat } from '../enums/DataFormat';
import { DataFormat } from '../enums/DataFormat.js';
/**
* @class GetRecordsRequest - Request to get records by their ids
+11 -2
View File
@@ -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);
}
+11 -2
View File
@@ -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);
}
+11 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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.
+5 -5
View File
@@ -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 -1
View File
@@ -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.
*/
+46 -30
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { ArgumentValidator } from './ArgumentValidator';
import { ArgumentValidator } from './ArgumentValidator.js';
/**
* @class PagingRequest - Paging request model
+27 -1
View File
@@ -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}`;
+3 -3
View File
@@ -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.
+6 -2
View File
@@ -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);
+9 -9
View File
@@ -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.
+4 -4
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { type Row } from './Row';
import { type Row } from './Row.js';
/**
* @class ReportData - Represents the data for a report.
+13 -1
View File
@@ -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;
+12 -3
View File
@@ -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);
}
+11 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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.
+2 -2
View File
@@ -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 {
/**
+12 -3
View File
@@ -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
View File
@@ -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;
+27 -26
View File
@@ -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',
},
+1
View File
@@ -13,6 +13,7 @@
"module": "commonjs",
"target": "ES6"
},
"experimentalResolver": true,
"moduleTypes": {
"*.ts": "cjs"
}