diff --git a/.nycrc b/.nycrc index 7451837..80f4ea0 100644 --- a/.nycrc +++ b/.nycrc @@ -2,18 +2,8 @@ "extends": "@istanbuljs/nyc-config-typescript", "check-coverage": true, "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" -} \ No newline at end of file +} diff --git a/src/OnspringClient.ts b/src/OnspringClient.ts index baf7461..521868f 100644 --- a/src/OnspringClient.ts +++ b/src/OnspringClient.ts @@ -37,7 +37,10 @@ export class OnspringClient { throw new Error('apiKey cannot be null/empty/whitespace.'); } - this._client = axios.create({ baseURL: baseUrl, headers: { 'x-apikey': apiKey, 'x-api-version': '2',},}); + this._client = axios.create({ + baseURL: baseUrl, + headers: { 'x-apikey': apiKey, 'x-api-version': '2' }, + }); } /** @@ -95,9 +98,12 @@ export class OnspringClient { * @param {string} endpoint - The endpoint that will be used to make the request. * @returns {Promise>} - A promise that resolves to an ApiResponse of type T. */ - private async get(endpoint: string, config: AxiosRequestConfig = {}): Promise> { -const response = await this._client.get(endpoint, config); -const apiResponse = ApiResponseFactory.getApiResponse(response); -return apiResponse; + private async get( + endpoint: string, + config: AxiosRequestConfig = {} + ): Promise> { + const response = await this._client.get(endpoint, config); + const apiResponse = ApiResponseFactory.getApiResponse(response); + return apiResponse; } } diff --git a/src/enums/FieldType.ts b/src/enums/FieldType.ts index 6d267bc..581099e 100644 --- a/src/enums/FieldType.ts +++ b/src/enums/FieldType.ts @@ -19,7 +19,7 @@ export enum FieldType { * @type {string} */ AutoNumber = 'AutoNumber', - + /** * @constant Date - The field is a date field. * @type {string} diff --git a/src/enums/ResultValueType.ts b/src/enums/ResultValueType.ts index d2fe242..5361dd3 100644 --- a/src/enums/ResultValueType.ts +++ b/src/enums/ResultValueType.ts @@ -13,7 +13,7 @@ export enum ResultValueType { * @type {string} */ Integer = 'Integer', - + /** * @constant Decimal - The result value is a decimal. * @type {string} diff --git a/src/models/EndpointFactory.ts b/src/models/EndpointFactory.ts index fe8a16f..f83553f 100644 --- a/src/models/EndpointFactory.ts +++ b/src/models/EndpointFactory.ts @@ -1,4 +1,4 @@ -import { PagingRequest } from "./PagingRequest"; +import { PagingRequest } from './PagingRequest'; /** * @class EndpointFactory - A factory class for creating endpoints. @@ -16,7 +16,10 @@ export class EndpointFactory { * @param {string} baseUrl - The base url that will be used to create the apps endpoint. * @returns {string} - The apps endpoint. */ - public static getAppsEndpoint(baseUrl: string, pagingRequest: PagingRequest): string { + public static getAppsEndpoint( + baseUrl: string, + pagingRequest: PagingRequest + ): string { return `${baseUrl}/Apps?pageSize=${pagingRequest.pageSize}&pageNumber=${pagingRequest.pageNumber}`; } diff --git a/src/models/GetPagedAppsResponse.ts b/src/models/GetPagedAppsResponse.ts index 371e0b5..375dcf0 100644 --- a/src/models/GetPagedAppsResponse.ts +++ b/src/models/GetPagedAppsResponse.ts @@ -1,8 +1,14 @@ -import { PagedResponse } from "./PagedResponse"; -import { App } from "./App"; +import { PagedResponse } from './PagedResponse'; +import { App } from './App'; export class GetPagedAppsResponse extends PagedResponse { - constructor(items: App[], pageNumber: number, pageSize: number, totalPages: number, totalRecords: number) { + constructor( + items: App[], + pageNumber: number, + pageSize: number, + totalPages: number, + totalRecords: number + ) { super(items, pageNumber, pageSize, totalPages, totalRecords); } -} \ No newline at end of file +} diff --git a/src/models/PagedResponse.ts b/src/models/PagedResponse.ts index 11b89ee..7ed259e 100644 --- a/src/models/PagedResponse.ts +++ b/src/models/PagedResponse.ts @@ -5,11 +5,17 @@ export class PagedResponse { public totalPages: number; public totalRecords: number; - constructor(items: T[], pageNumber: number, pageSize: number, totalPages: number, totalRecords: number) { + constructor( + items: T[], + pageNumber: number, + pageSize: number, + totalPages: number, + totalRecords: number + ) { this.items = items; this.pageNumber = pageNumber; this.pageSize = pageSize; this.totalPages = totalPages; this.totalRecords = totalRecords; } -} \ No newline at end of file +} diff --git a/src/models/PagingRequest.ts b/src/models/PagingRequest.ts index a7cb8c9..ed44410 100644 --- a/src/models/PagingRequest.ts +++ b/src/models/PagingRequest.ts @@ -1,4 +1,4 @@ -import { ArgumentValidator } from "./ArgumentValidator"; +import { ArgumentValidator } from './ArgumentValidator'; /** * @class PagingRequest - Paging request model @@ -24,11 +24,11 @@ export class PagingRequest { */ constructor(pageNumber: number, pageSize: number) { if (ArgumentValidator.isValidPageNumber(pageNumber) === false) { - throw new Error("pageNumber must be greater than 0."); + throw new Error('pageNumber must be greater than 0.'); } if (ArgumentValidator.isValidPageSize(pageSize) === false) { - throw new Error("pageSize must be greater than 0 and less than 1001."); + throw new Error('pageSize must be greater than 0 and less than 1001.'); } this.pageNumber = pageNumber; diff --git a/tests/ApiResponseFactory.spec.ts b/tests/ApiResponseFactory.spec.ts index ca3b611..00df2a9 100644 --- a/tests/ApiResponseFactory.spec.ts +++ b/tests/ApiResponseFactory.spec.ts @@ -59,7 +59,7 @@ describe('ApiResponseFactory', function () { it('should return an ApiResponse object when request is forbidden and the response contains a message property', function () { const response: AxiosResponse = { data: { - message: 'Does not have permission to access this resource.' + message: 'Does not have permission to access this resource.', }, status: 403, statusText: 'Forbidden', @@ -74,7 +74,9 @@ describe('ApiResponseFactory', function () { expect(apiResponse).to.have.property('message'); expect(apiResponse).to.have.property('data'); expect(apiResponse.statusCode).to.equal(403); - expect(apiResponse.message).to.equal('Does not have permission to access this resource.'); + expect(apiResponse.message).to.equal( + 'Does not have permission to access this resource.' + ); expect(apiResponse.data).to.equal(null); }); @@ -101,7 +103,7 @@ describe('ApiResponseFactory', function () { it('should return an ApiResponse object with a message value when request is not found and the response contains a message property', function () { const response: AxiosResponse = { data: { - message: 'Resource not found.' + message: 'Resource not found.', }, status: 404, statusText: 'Not Found', @@ -143,7 +145,7 @@ describe('ApiResponseFactory', function () { it('should return an ApiResponse object with a message when request is unauthorized and the response contains a message property', function () { const response: AxiosResponse = { data: { - message: 'Unauthorized.' + message: 'Unauthorized.', }, status: 401, statusText: 'Unauthorized', @@ -165,7 +167,7 @@ describe('ApiResponseFactory', function () { it('should return an ApiResponse object with a message when request is a bad request', function () { const response: AxiosResponse = { data: { - field: 'Invalid input.' + field: 'Invalid input.', }, status: 400, statusText: 'Bad Request', @@ -184,4 +186,4 @@ describe('ApiResponseFactory', function () { expect(apiResponse.data).to.equal(null); }); }); -}); \ No newline at end of file +}); diff --git a/tests/App.spec.ts b/tests/App.spec.ts index e4050bd..f5b4d24 100644 --- a/tests/App.spec.ts +++ b/tests/App.spec.ts @@ -28,4 +28,4 @@ describe('App', function () { expect(app.id).to.equal(1); expect(app.name).to.equal('name'); }); -}); \ No newline at end of file +}); diff --git a/tests/ArgumentValidator.spec.ts b/tests/ArgumentValidator.spec.ts index 786800a..fcf7e9d 100644 --- a/tests/ArgumentValidator.spec.ts +++ b/tests/ArgumentValidator.spec.ts @@ -187,23 +187,23 @@ describe('ArgumentValidator', function () { expect(ArgumentValidator.isValidPageSize(undefined)).to.be.false; }); - it('should return false when the value is greater than 1000', function (){ + it('should return false when the value is greater than 1000', function () { expect(ArgumentValidator.isValidPageSize(1001)).to.be.false; }); - it('should return false when the value is less than 1', function (){ + it('should return false when the value is less than 1', function () { expect(ArgumentValidator.isValidPageSize(0)).to.be.false; }); - it('should return true when the value is 1', function (){ + it('should return true when the value is 1', function () { expect(ArgumentValidator.isValidPageSize(1)).to.be.true; }); - it('should return true when the value is 1000', function (){ + it('should return true when the value is 1000', function () { expect(ArgumentValidator.isValidPageSize(1000)).to.be.true; }); - it('should return true when the value is 500', function (){ + it('should return true when the value is 500', function () { expect(ArgumentValidator.isValidPageSize(500)).to.be.true; }); }); @@ -225,11 +225,11 @@ describe('ArgumentValidator', function () { expect(ArgumentValidator.isValidPageNumber(undefined)).to.be.false; }); - it('should return false when the value is less than 1', function (){ + it('should return false when the value is less than 1', function () { expect(ArgumentValidator.isValidPageNumber(0)).to.be.false; }); - it('should return true when the value is 1', function (){ + it('should return true when the value is 1', function () { expect(ArgumentValidator.isValidPageNumber(1)).to.be.true; }); }); diff --git a/tests/DataFormat.spec.ts b/tests/DataFormat.spec.ts index a87d12d..0622277 100644 --- a/tests/DataFormat.spec.ts +++ b/tests/DataFormat.spec.ts @@ -15,4 +15,4 @@ describe('DataFormat', function () { expect(result).to.equal('Formatted'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/EndpointFactory.spec.ts b/tests/EndpointFactory.spec.ts index 2375c14..1776be0 100644 --- a/tests/EndpointFactory.spec.ts +++ b/tests/EndpointFactory.spec.ts @@ -14,7 +14,10 @@ describe('EndpointFactory', function () { describe('getAppsEndpoint', function () { it('should return the correct apps endpoint with paging params based on paging request parameter passed', function () { - const result = EndpointFactory.getAppsEndpoint(baseUrl, new PagingRequest(2, 1000)); + const result = EndpointFactory.getAppsEndpoint( + baseUrl, + new PagingRequest(2, 1000) + ); expect(result).to.equal(`${baseUrl}/Apps?pageSize=1000&pageNumber=2`); }); }); @@ -139,8 +142,8 @@ describe('EndpointFactory', function () { }); }); - describe('getQueryRecordsEndpoint', function(){ - it('should return the correct query records endpoint', function(){ + describe('getQueryRecordsEndpoint', function () { + it('should return the correct query records endpoint', function () { const result = EndpointFactory.getQueryRecordsEndpoint(baseUrl); expect(result).to.equal(`${baseUrl}/Records/query`); }); diff --git a/tests/FieldStatus.spec.ts b/tests/FieldStatus.spec.ts index 0ecaf55..eb1d46a 100644 --- a/tests/FieldStatus.spec.ts +++ b/tests/FieldStatus.spec.ts @@ -22,4 +22,4 @@ describe('FieldStatus', function () { expect(result).to.equal('Invalid'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/FieldType.spec.ts b/tests/FieldType.spec.ts index 722541e..6466af2 100644 --- a/tests/FieldType.spec.ts +++ b/tests/FieldType.spec.ts @@ -85,4 +85,4 @@ describe('FieldType', function () { expect(result).to.equal('Attachment'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/FileStorageSite.spec.ts b/tests/FileStorageSite.spec.ts index f6778ff..c4e2ddd 100644 --- a/tests/FileStorageSite.spec.ts +++ b/tests/FileStorageSite.spec.ts @@ -22,4 +22,4 @@ describe('FileStorageSite', function () { expect(result).to.equal('Internal'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/FormulaOutputType.spec.ts b/tests/FormulaOutputType.spec.ts index 394a820..0d47360 100644 --- a/tests/FormulaOutputType.spec.ts +++ b/tests/FormulaOutputType.spec.ts @@ -29,4 +29,4 @@ describe('FormulaOutputType', function () { expect(result).to.equal('ListValue'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/GetPagedAppsResponse.spec.ts b/tests/GetPagedAppsResponse.spec.ts index 72ec4d4..03c8b48 100644 --- a/tests/GetPagedAppsResponse.spec.ts +++ b/tests/GetPagedAppsResponse.spec.ts @@ -16,14 +16,35 @@ describe('GetPagedAppsResponse', function () { }); it('should construct a new instance of GetPagedAppsResponse', function () { - const getPagedAppsResponse = new GetPagedAppsResponse([new App('test', 1, 'test'), new App('test', 1, 'test')], 1, 10, 100, 100); + const getPagedAppsResponse = new GetPagedAppsResponse( + [new App('test', 1, 'test'), new App('test', 1, 'test')], + 1, + 10, + 100, + 100 + ); expect(getPagedAppsResponse).to.not.be.undefined; expect(getPagedAppsResponse).to.be.instanceOf(GetPagedAppsResponse); - expect(getPagedAppsResponse).to.have.property('items').to.be.an('array').to.have.lengthOf(2); - expect(getPagedAppsResponse).to.have.property('pageNumber').to.be.a('number').to.equal(1); - expect(getPagedAppsResponse).to.have.property('pageSize').to.be.a('number').to.equal(10); - expect(getPagedAppsResponse).to.have.property('totalPages').to.be.a('number').to.equal(100); - expect(getPagedAppsResponse).to.have.property('totalRecords').to.be.a('number').to.equal(100); + expect(getPagedAppsResponse) + .to.have.property('items') + .to.be.an('array') + .to.have.lengthOf(2); + expect(getPagedAppsResponse) + .to.have.property('pageNumber') + .to.be.a('number') + .to.equal(1); + expect(getPagedAppsResponse) + .to.have.property('pageSize') + .to.be.a('number') + .to.equal(10); + expect(getPagedAppsResponse) + .to.have.property('totalPages') + .to.be.a('number') + .to.equal(100); + expect(getPagedAppsResponse) + .to.have.property('totalRecords') + .to.be.a('number') + .to.equal(100); }); -}); \ No newline at end of file +}); diff --git a/tests/HttpStatusCode.spec.ts b/tests/HttpStatusCode.spec.ts index 92c2107..da481db 100644 --- a/tests/HttpStatusCode.spec.ts +++ b/tests/HttpStatusCode.spec.ts @@ -106,4 +106,4 @@ describe('HttpStatusCode', () => { expect(result).to.equal(504); }); }); -}); \ No newline at end of file +}); diff --git a/tests/Multiplicity.spec.ts b/tests/Multiplicity.spec.ts index 0f6b5f0..9907b61 100644 --- a/tests/Multiplicity.spec.ts +++ b/tests/Multiplicity.spec.ts @@ -15,4 +15,4 @@ describe('Multiplicity', function () { expect(result).to.equal('MultiSelect'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/OnspringClient.spec.ts b/tests/OnspringClient.spec.ts index 7c91cf7..1aff329 100644 --- a/tests/OnspringClient.spec.ts +++ b/tests/OnspringClient.spec.ts @@ -305,7 +305,10 @@ describe('OnspringClient', function () { expect(result).to.be.instanceOf(ApiResponse); expect(result).to.have.property('statusCode', 400); expect(result).to.have.property('isSuccessful', false); - expect(result).to.have.property('message', '{"PageSize":["The field PageSize must be between 0 and 1000."]}'); + expect(result).to.have.property( + 'message', + '{"PageSize":["The field PageSize must be between 0 and 1000."]}' + ); expect(result).to.have.property('data'); expect(result.data).to.be.null; }); @@ -344,19 +347,26 @@ describe('OnspringClient', function () { describe('getAppById', function () { it('should be defined', function () { - expect(new OnspringClient(baseUrl, apiKey).getAppById).to.not.be.undefined; + expect(new OnspringClient(baseUrl, apiKey).getAppById).to.not.be + .undefined; }); it('should be a function', function () { - expect(new OnspringClient(baseUrl, apiKey).getAppById).to.be.a('function'); + expect(new OnspringClient(baseUrl, apiKey).getAppById).to.be.a( + 'function' + ); }); it('should have 1 parameter', function () { - expect(new OnspringClient(baseUrl, apiKey).getAppById).to.have.lengthOf(1); + expect(new OnspringClient(baseUrl, apiKey).getAppById).to.have.lengthOf( + 1 + ); }); it('should return a promise', function () { - expect(new OnspringClient(baseUrl, apiKey).getAppById(1)).to.be.a('promise'); + expect(new OnspringClient(baseUrl, apiKey).getAppById(1)).to.be.a( + 'promise' + ); }); it('should return a promise that resolves to an api response of an app when request is successful', async function () { diff --git a/tests/PagedResponse.spec.ts b/tests/PagedResponse.spec.ts index f791a49..5d9188f 100644 --- a/tests/PagedResponse.spec.ts +++ b/tests/PagedResponse.spec.ts @@ -15,14 +15,35 @@ describe('PagedResponse', function () { }); it('should construct a new instance of PagedResponse', function () { - const pagedResponse = new PagedResponse([1, 2, 3, 4], 1, 10, 100, 100); + const pagedResponse = new PagedResponse( + [1, 2, 3, 4], + 1, + 10, + 100, + 100 + ); expect(pagedResponse).to.not.be.undefined; expect(pagedResponse).to.be.instanceOf(PagedResponse); - expect(pagedResponse).to.have.property('items').to.be.an('array').to.have.lengthOf(4); - expect(pagedResponse).to.have.property('pageNumber').to.be.a('number').to.equal(1); - expect(pagedResponse).to.have.property('pageSize').to.be.a('number').to.equal(10); - expect(pagedResponse).to.have.property('totalPages').to.be.a('number').to.equal(100); - expect(pagedResponse).to.have.property('totalRecords').to.be.a('number').to.equal(100); + expect(pagedResponse) + .to.have.property('items') + .to.be.an('array') + .to.have.lengthOf(4); + expect(pagedResponse) + .to.have.property('pageNumber') + .to.be.a('number') + .to.equal(1); + expect(pagedResponse) + .to.have.property('pageSize') + .to.be.a('number') + .to.equal(10); + expect(pagedResponse) + .to.have.property('totalPages') + .to.be.a('number') + .to.equal(100); + expect(pagedResponse) + .to.have.property('totalRecords') + .to.be.a('number') + .to.equal(100); }); }); diff --git a/tests/PagingRequest.spec.ts b/tests/PagingRequest.spec.ts index decb9dc..bdf8c1b 100644 --- a/tests/PagingRequest.spec.ts +++ b/tests/PagingRequest.spec.ts @@ -15,15 +15,21 @@ describe('PagingRequest', function () { }); it('should throw an error when the pageNumber is less than 1', function () { - expect(() => new PagingRequest(0, 1)).to.throw('pageNumber must be greater than 0.'); + expect(() => new PagingRequest(0, 1)).to.throw( + 'pageNumber must be greater than 0.' + ); }); it('should throw an error when the pageSize is less than 1', function () { - expect(() => new PagingRequest(1, 0)).to.throw('pageSize must be greater than 0 and less than 1001.'); + expect(() => new PagingRequest(1, 0)).to.throw( + 'pageSize must be greater than 0 and less than 1001.' + ); }); it('should throw an error when the pageSize is greater than 1000', function () { - expect(() => new PagingRequest(1, 1001)).to.throw('pageSize must be greater than 0 and less than 1001.'); + expect(() => new PagingRequest(1, 1001)).to.throw( + 'pageSize must be greater than 0 and less than 1001.' + ); }); it('should create a new instance of the PagingRequest class when the pageNumber is greater than 0 and the pageSize is between 1 and 1000', function () { @@ -38,4 +44,4 @@ describe('PagingRequest', function () { expect(pagingRequest.pageNumber).to.equal(1); expect(pagingRequest.pageSize).to.equal(1); }); -}); \ No newline at end of file +}); diff --git a/tests/ReportDataType.spec.ts b/tests/ReportDataType.spec.ts index 3c80dcc..366ea9a 100644 --- a/tests/ReportDataType.spec.ts +++ b/tests/ReportDataType.spec.ts @@ -15,4 +15,4 @@ describe('ReportDataType', function () { expect(result).to.equal('ChartData'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/ResultValueType.spec.ts b/tests/ResultValueType.spec.ts index 0b94727..cab8c7b 100644 --- a/tests/ResultValueType.spec.ts +++ b/tests/ResultValueType.spec.ts @@ -85,4 +85,4 @@ describe('ResultValueType', function () { expect(result).to.equal('FileList'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/TimeSpanIncrement.spec.ts b/tests/TimeSpanIncrement.spec.ts index a343577..32cd943 100644 --- a/tests/TimeSpanIncrement.spec.ts +++ b/tests/TimeSpanIncrement.spec.ts @@ -50,4 +50,4 @@ describe('TimeSpanIncrement', function () { expect(result).to.equal('Years'); }); }); -}); \ No newline at end of file +}); diff --git a/tests/TimeSpanRecurrenceType.spec.ts b/tests/TimeSpanRecurrenceType.spec.ts index 071aa33..211eac2 100644 --- a/tests/TimeSpanRecurrenceType.spec.ts +++ b/tests/TimeSpanRecurrenceType.spec.ts @@ -22,4 +22,4 @@ describe('TimeSpanRecurrenceType', function () { expect(result).to.equal('EndAfterOccurrences'); }); }); -}); \ No newline at end of file +});