From 07ec44a0ad4f58f273b9448fc7010d1dbef2265c Mon Sep 17 00:00:00 2001 From: StevanFreeborn <=> Date: Mon, 20 Feb 2023 21:08:22 -0600 Subject: [PATCH] fix: add jsdoc comments to models --- src/models/ApiResponse.ts | 26 +++++++++++++++++++++++ src/models/ApiResponseFactory.ts | 4 +++- src/models/CreatedWithIdResponse.ts | 3 +++ src/models/DecimalRecordValue.ts | 9 ++++++++ src/models/DelegateListRecordValue.ts | 9 ++++++++ src/models/FileListRecordValue.ts | 9 ++++++++ src/models/GetRecordsByAppIdRequest.ts | 3 +++ src/models/GuidListRecordValue.ts | 9 ++++++++ src/models/GuidRecordValue.ts | 9 ++++++++ src/models/IntegerListRecordValue.ts | 9 ++++++++ src/models/OnspringClient.ts | 12 +++++++++++ src/models/QueryFilter.ts | 26 +++++++++++++++++++++++ src/models/Record.ts | 4 ++++ src/models/SaveRecordResponse.ts | 12 +++++++++++ src/models/ScoringGroupListRecordValue.ts | 9 ++++++++ src/models/StringListRecordValue.ts | 9 ++++++++ src/models/TimeSpanRecordValue.ts | 9 ++++++++ 17 files changed, 170 insertions(+), 1 deletion(-) diff --git a/src/models/ApiResponse.ts b/src/models/ApiResponse.ts index aae1260..cf42ac1 100644 --- a/src/models/ApiResponse.ts +++ b/src/models/ApiResponse.ts @@ -238,6 +238,10 @@ export class ApiResponse { ); } + /** + * @method asFileInfoType - Converts the ApiResponse to an ApiResponse. + * @returns {ApiResponse} - An ApiResponse. + */ public asFileInfoType(): ApiResponse { const apiResponse = this as ApiResponse; @@ -259,6 +263,10 @@ export class ApiResponse { ); } + /** + * @method asFileType - Converts the ApiResponse to an ApiResponse. + * @returns {ApiResponse} - An ApiResponse. + */ public asFileType(response: AxiosResponse): ApiResponse { const apiResponse = this as ApiResponse; @@ -411,6 +419,10 @@ export class ApiResponse { ); } + /** + * @method asRecordCollectionType - Converts the ApiResponse to an ApiResponse>. + * @returns {ApiResponse>} - An ApiResponse>. + */ public asRecordCollectionType(): ApiResponse> { const apiResponse = this as ApiResponse; @@ -434,6 +446,10 @@ export class ApiResponse { ); } + /** + * @method asSaveRecordResponseType - Converts the ApiResponse to an ApiResponse. + * @returns {ApiResponse} - An ApiResponse. + */ public asSaveRecordResponseType(): ApiResponse { const apiResponse = this as ApiResponse; const response = new SaveRecordResponse( @@ -447,6 +463,11 @@ export class ApiResponse { ); } + /** + * @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 { const type = RecordValueType[recordValueItem.type]; @@ -629,6 +650,11 @@ export class ApiResponse { } } + /** + * @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]; diff --git a/src/models/ApiResponseFactory.ts b/src/models/ApiResponseFactory.ts index 054751a..91292a2 100644 --- a/src/models/ApiResponseFactory.ts +++ b/src/models/ApiResponseFactory.ts @@ -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} - A promise that resolves to the data from the stream as a string */ private static async getStreamDataAsString( stream: Readable diff --git a/src/models/CreatedWithIdResponse.ts b/src/models/CreatedWithIdResponse.ts index 9907e65..993acaa 100644 --- a/src/models/CreatedWithIdResponse.ts +++ b/src/models/CreatedWithIdResponse.ts @@ -1,3 +1,6 @@ +/** + * @class CreatedWithIdResponse - Represents a response to a request to create a resource. + */ export class CreatedWithIdResponse { /** * @property {T} id - The id of the created object. diff --git a/src/models/DecimalRecordValue.ts b/src/models/DecimalRecordValue.ts index 06f45df..3c11e7d 100644 --- a/src/models/DecimalRecordValue.ts +++ b/src/models/DecimalRecordValue.ts @@ -1,7 +1,16 @@ import { RecordValue } from './RecordValue.js'; import { RecordValueType } from '../enums/RecordValueType.js'; +/** + * @class DecimalRecordValue - Represents a decimal record value + */ export class DecimalRecordValue extends RecordValue { + /** + * @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); } diff --git a/src/models/DelegateListRecordValue.ts b/src/models/DelegateListRecordValue.ts index 335d7c7..f8ffc85 100644 --- a/src/models/DelegateListRecordValue.ts +++ b/src/models/DelegateListRecordValue.ts @@ -2,7 +2,16 @@ 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 { + /** + * @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); } diff --git a/src/models/FileListRecordValue.ts b/src/models/FileListRecordValue.ts index c2b18b1..39e1bf2 100644 --- a/src/models/FileListRecordValue.ts +++ b/src/models/FileListRecordValue.ts @@ -2,7 +2,16 @@ 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 { + /** + * @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); } diff --git a/src/models/GetRecordsByAppIdRequest.ts b/src/models/GetRecordsByAppIdRequest.ts index 993b616..91d51be 100644 --- a/src/models/GetRecordsByAppIdRequest.ts +++ b/src/models/GetRecordsByAppIdRequest.ts @@ -1,6 +1,9 @@ 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. diff --git a/src/models/GuidListRecordValue.ts b/src/models/GuidListRecordValue.ts index fa61a6f..b27b15d 100644 --- a/src/models/GuidListRecordValue.ts +++ b/src/models/GuidListRecordValue.ts @@ -1,7 +1,16 @@ import { RecordValueType } from '../enums/RecordValueType.js'; import { RecordValue } from './RecordValue.js'; +/** + * @class GuidListRecordValue - Represents a guid list record value. + */ export class GuidListRecordValue extends RecordValue { + /** + * @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); } diff --git a/src/models/GuidRecordValue.ts b/src/models/GuidRecordValue.ts index 354ed79..76f82c1 100644 --- a/src/models/GuidRecordValue.ts +++ b/src/models/GuidRecordValue.ts @@ -1,7 +1,16 @@ import { RecordValueType } from '../enums/RecordValueType.js'; import { RecordValue } from './RecordValue.js'; +/** + * @class GuidRecordValue - Represents a guid record value. + */ export class GuidRecordValue extends RecordValue { + /** + * @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); } diff --git a/src/models/IntegerListRecordValue.ts b/src/models/IntegerListRecordValue.ts index 7160477..963e486 100644 --- a/src/models/IntegerListRecordValue.ts +++ b/src/models/IntegerListRecordValue.ts @@ -1,7 +1,16 @@ import { RecordValueType } from '../enums/RecordValueType.js'; import { RecordValue } from './RecordValue.js'; +/** + * @class IntegerListRecordValue - Represents an integer list record value. + */ export class IntegerListRecordValue extends RecordValue { + /** + * @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); } diff --git a/src/models/OnspringClient.ts b/src/models/OnspringClient.ts index c57e623..a957bba 100644 --- a/src/models/OnspringClient.ts +++ b/src/models/OnspringClient.ts @@ -282,6 +282,13 @@ export class OnspringClient { return apiResponse.asCreatedWithIdResponseType(); } + /** + * @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>} - A promise that resolves to an ApiResponse of type any. + */ public async deleteFileById( recordId: number, fieldId: number, @@ -416,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>} - A promise that resolves to an ApiResponse of type SaveRecordResponse. + */ public async saveRecord( request: Record | SaveRecordRequest ): Promise> { diff --git a/src/models/QueryFilter.ts b/src/models/QueryFilter.ts index fbd49e1..6de4679 100644 --- a/src/models/QueryFilter.ts +++ b/src/models/QueryFilter.ts @@ -1,10 +1,32 @@ 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}`; diff --git a/src/models/Record.ts b/src/models/Record.ts index 4379b50..929b6a6 100644 --- a/src/models/Record.ts +++ b/src/models/Record.ts @@ -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); diff --git a/src/models/SaveRecordResponse.ts b/src/models/SaveRecordResponse.ts index 8af03f0..b5a8cc2 100644 --- a/src/models/SaveRecordResponse.ts +++ b/src/models/SaveRecordResponse.ts @@ -1,8 +1,20 @@ import { CreatedWithIdResponse } from './CreatedWithIdResponse.js'; +/** + * @class SaveRecordResponse - Response from saving a record + */ export class SaveRecordResponse extends CreatedWithIdResponse { + /** + * @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; diff --git a/src/models/ScoringGroupListRecordValue.ts b/src/models/ScoringGroupListRecordValue.ts index 39cd571..64318e7 100644 --- a/src/models/ScoringGroupListRecordValue.ts +++ b/src/models/ScoringGroupListRecordValue.ts @@ -2,7 +2,16 @@ 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 { + /** + * @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); } diff --git a/src/models/StringListRecordValue.ts b/src/models/StringListRecordValue.ts index 943cf73..537c134 100644 --- a/src/models/StringListRecordValue.ts +++ b/src/models/StringListRecordValue.ts @@ -1,7 +1,16 @@ import { RecordValueType } from '../enums/RecordValueType.js'; import { RecordValue } from './RecordValue.js'; +/** + * @class StringListRecordValue - Represents a string list record value. + */ export class StringListRecordValue extends RecordValue { + /** + * @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); } diff --git a/src/models/TimeSpanRecordValue.ts b/src/models/TimeSpanRecordValue.ts index 186cba7..8b85272 100644 --- a/src/models/TimeSpanRecordValue.ts +++ b/src/models/TimeSpanRecordValue.ts @@ -2,7 +2,16 @@ 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 { + /** + * @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); }