diff --git a/src/enums/RecordValueType.ts b/src/enums/RecordValueType.ts index 0f6ef19..8a0e940 100644 --- a/src/enums/RecordValueType.ts +++ b/src/enums/RecordValueType.ts @@ -72,4 +72,10 @@ export enum RecordValueType { * @type {string} */ FileList = 'FileList', + + /** + * @constant DelegateList - The record value is a list of delegates. + * @type {string} + */ + DelegateList = 'DelegateList', } diff --git a/src/models/ApiResponse.ts b/src/models/ApiResponse.ts index c50d0dd..7744668 100644 --- a/src/models/ApiResponse.ts +++ b/src/models/ApiResponse.ts @@ -1,28 +1,50 @@ 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 { RecordValue } from './RecordValue'; 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'; /** * @class ApiResponse - A generic response object for API requests. @@ -339,13 +361,10 @@ export class ApiResponse { const apiResponse = this as ApiResponse; const records = apiResponse.data.items.map((item: any) => { - const recordValues = item.fieldData.map((fieldData: any) => { - return new RecordValue( - fieldData.type, - fieldData.fieldId, - fieldData.value - ); - }); + const recordValues = item.fieldData.map((recordValueItem: any) => + ApiResponse.getRecordValueByType(recordValueItem) + ); + return new Record(item.appId, item.recordId, recordValues); }); @@ -371,13 +390,10 @@ export class ApiResponse { public asRecordType(): ApiResponse { const apiResponse = this as ApiResponse; - const recordValues = apiResponse.data.fieldData.map((fieldData: any) => { - return new RecordValue( - fieldData.type, - fieldData.fieldId, - fieldData.value - ); - }); + const recordValues = apiResponse.data.fieldData.map( + (recordValueItem: any) => + ApiResponse.getRecordValueByType(recordValueItem) + ); const record = new Record( apiResponse.data.appId, @@ -396,13 +412,10 @@ export class ApiResponse { const apiResponse = this as ApiResponse; const records = apiResponse.data.items.map((item: any) => { - const recordValues = item.fieldData.map((fieldData: any) => { - return new RecordValue( - fieldData.type, - fieldData.fieldId, - fieldData.value - ); - }); + const recordValues = item.fieldData.map((recordValueItem: any) => + ApiResponse.getRecordValueByType(recordValueItem) + ); + return new Record(item.appId, item.recordId, recordValues); }); @@ -418,8 +431,113 @@ export class ApiResponse { ); } + private static getRecordValueByType(recordValueItem: any): RecordValue { + const type = RecordValueType[recordValueItem.type]; + + switch (type) { + case RecordValueType.String: { + return new StringRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.Integer: { + return new IntegerRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.Decimal: { + return new DecimalRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.Date: { + const date = new Date(recordValueItem.value); + return new DateRecordValue(recordValueItem.fieldId, date); + } + case RecordValueType.TimeSpan: { + const timeSpan = ApiResponse.convertToTimeSpanData( + recordValueItem.value + ); + return new TimeSpanRecordValue(recordValueItem.fieldId, timeSpan); + } + case RecordValueType.Guid: { + return new GuidRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.StringList: { + return new StringListRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.IntegerList: { + return new IntegerListRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.GuidList: { + return new GuidListRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + case RecordValueType.AttachmentList: { + const attachments = recordValueItem.value.map((attachmentItem: any) => + ApiResponse.convertToAttachment(attachmentItem) + ); + + return new AttachmentListRecordValue( + recordValueItem.fieldId, + attachments + ); + } + case RecordValueType.ScoringGroupList: { + const array = recordValueItem.value as any[]; + const isDelegateList = array[0].delegateType !== undefined; + + if (isDelegateList) { + const delegates = recordValueItem.value.map((delegateItem: any) => + ApiResponse.convertToDelegate(delegateItem) + ); + + return new DelegateListRecordValue( + recordValueItem.fieldId, + delegates + ); + } + + const scoringGroups = recordValueItem.value.map( + (scoringGroupItem: any) => + ApiResponse.convertToScoringGroup(scoringGroupItem) + ); + + return new ScoringGroupListRecordValue( + recordValueItem.fieldId, + scoringGroups + ); + } + case RecordValueType.FileList: { + return new FileListRecordValue( + recordValueItem.fieldId, + recordValueItem.value + ); + } + default: { + throw new Error( + `Unknown record value type: ${recordValueItem.type as string}` + ); + } + } + } + /** - * @method asFileCollectionType - Converts the field item to the appropriate field object based upon the field item's type. + * @method getFieldByType - Converts the field item to the appropriate field object based upon the field item's type. * @param {any} fieldItem - The field item to convert. * @returns {Field} - The converted field object. * @throws {Error} - If the field item's type is unknown. @@ -495,6 +613,132 @@ export class ApiResponse { } } + private static convertToDelegate(delegateItem: any): Delegate { + const delegateType = DelegateType[delegateItem.delegateType]; + + if (delegateType === undefined) { + throw new Error( + `${delegateItem.delegateType as string} is not a valid DelegateType.` + ); + } + + const delegationDateTime = new Date(delegateItem.delegationDateTime); + + const hasName = + delegateItem.name !== null && delegateItem.name !== undefined; + const name = hasName ? delegateItem.name : null; + + const hasCompletionDate = + delegateItem.delegationCompletedDateTime !== null && + delegateItem.delegationCompletedDateTime !== undefined; + + const delegationCompletedDateTime = hasCompletionDate + ? new Date(delegateItem.delegationCompletedDateTime) + : null; + + return new Delegate( + delegateItem.delegateType, + name, + delegateItem.emailAddress, + delegationDateTime, + delegationCompletedDateTime + ); + } + + /** + * @method convertToScoringGroup - Converts the scoring group item to the appropriate scoring group object. + * @param {any} scoringGroupItem - The scoring group item to convert. + * @returns {ScoringGroup} - The converted scoring group object. + */ + private static convertToScoringGroup(scoringGroupItem: any): ScoringGroup { + return new ScoringGroup( + scoringGroupItem.id, + scoringGroupItem.name, + scoringGroupItem.score, + scoringGroupItem.maximumScore + ); + } + + /** + * @method convertToAttachment - Converts the attachment item to the appropriate attachment object. + * @param {any} attachmentItem - The attachment item to convert. + * @returns {Attachment} - The converted attachment object. + */ + private static convertToAttachment(attachmentItem: any): Attachment { + const storageLocation = FileStorageSite[attachmentItem.storageLocation]; + + if (storageLocation === undefined) { + throw new Error( + `${ + attachmentItem.storageLocation as string + } is not a valid FileStorageSite.` + ); + } + + const hasNotes = + attachmentItem.notes !== null && attachmentItem.notes !== undefined; + + const notes = hasNotes ? attachmentItem.notes : null; + + return new Attachment( + attachmentItem.fileId, + attachmentItem.fileName, + notes, + storageLocation + ); + } + + /** + * @method convertToTimeSpanData - Converts the time span item to the appropriate time span data object. + * @param {any} timeSpanItem - The time span item to convert. + * @returns {TimeSpanData} - The converted time span data object. + */ + private static convertToTimeSpanData(timeSpanItem: any): TimeSpanData { + const increment = TimeSpanIncrement[timeSpanItem.increment]; + + const hasRecurrence = + timeSpanItem.recurrence !== null && timeSpanItem.recurrence !== undefined; + + const recurrene = hasRecurrence + ? TimeSpanRecurrenceType[timeSpanItem.recurrence] + : null; + + const hasEndAfterOccurrences = + timeSpanItem.endAfterOccurrences !== null && + timeSpanItem.endAfterOccurrences !== undefined; + + const endAfterOccurrences = hasEndAfterOccurrences + ? timeSpanItem.endAfterOccurrences + : null; + + const hasEndByDate = + timeSpanItem.endByDate !== null && timeSpanItem.endByDate !== undefined; + + const endByDate = hasEndByDate ? new Date(timeSpanItem.endByDate) : null; + + if (increment === undefined) { + throw new Error( + `${timeSpanItem.increment as string} is not a valid TimeSpanIncrement.` + ); + } + + if (recurrene === undefined) { + throw new Error( + `${ + timeSpanItem.recurrence as string + } is not a valid TimeSpanRecurrenceType.` + ); + } + + return new TimeSpanData( + timeSpanItem.quantity, + increment, + recurrene, + endAfterOccurrences, + endByDate + ); + } + /** * @method getListValues - Converts the field items list values to a ListValue[]. * @param fieldItem - The field item whose values should be converted. diff --git a/src/models/AttachmentListRecordValue.ts b/src/models/AttachmentListRecordValue.ts new file mode 100644 index 0000000..5db3593 --- /dev/null +++ b/src/models/AttachmentListRecordValue.ts @@ -0,0 +1,18 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { type Attachment } from './Attachment'; +import { RecordValue } from './RecordValue'; + +/** + * @class AttachmentListRecordValue - A record value represented by a list of attachments. + */ +export class AttachmentListRecordValue extends RecordValue { + /** + * @constructor - Creates a new instance of AttachmentListRecordValue. + * @param {number} fieldId - The id of the field. + * @param {Attachment[]} value - The value of the field. + * @returns {AttachmentListRecordValue} - A new instance of AttachmentListRecordValue. + */ + constructor(fieldId: number, value: Attachment[]) { + super(RecordValueType.AttachmentList, fieldId, value); + } +} diff --git a/src/models/DateRecordValue.ts b/src/models/DateRecordValue.ts new file mode 100644 index 0000000..577436e --- /dev/null +++ b/src/models/DateRecordValue.ts @@ -0,0 +1,17 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +/** + * @class DateRecordValue - A value for a date field in a record. + */ +export class DateRecordValue extends RecordValue { + /** + * @constructor - Creates a new instance of DateRecordValue. + * @param {number} fieldId - The id of the field. + * @param {Date} value - The value of the field. + * @returns {DateRecordValue} - A new instance of DateRecordValue. + */ + constructor(fieldId: number, value: Date) { + super(RecordValueType.Date, fieldId, value); + } +} diff --git a/src/models/DecimalRecordValue.ts b/src/models/DecimalRecordValue.ts new file mode 100644 index 0000000..38d206b --- /dev/null +++ b/src/models/DecimalRecordValue.ts @@ -0,0 +1,8 @@ +import { RecordValue } from './RecordValue'; +import { RecordValueType } from '../enums/RecordValueType'; + +export class DecimalRecordValue extends RecordValue { + constructor(fieldId: number, value: number) { + super(RecordValueType.Decimal, fieldId, value); + } +} diff --git a/src/models/DelegateListRecordValue.ts b/src/models/DelegateListRecordValue.ts new file mode 100644 index 0000000..1ac9a6f --- /dev/null +++ b/src/models/DelegateListRecordValue.ts @@ -0,0 +1,9 @@ +import { RecordValue } from './RecordValue'; +import { RecordValueType } from '../enums/RecordValueType'; +import { type Delegate } from './Delegate'; + +export class DelegateListRecordValue extends RecordValue { + constructor(fieldId: number, value: Delegate[]) { + super(RecordValueType.DelegateList, fieldId, value); + } +} diff --git a/src/models/FileListRecordValue.ts b/src/models/FileListRecordValue.ts new file mode 100644 index 0000000..bd49bc5 --- /dev/null +++ b/src/models/FileListRecordValue.ts @@ -0,0 +1,9 @@ +import { RecordValue } from './RecordValue'; +import { RecordValueType } from '../enums/RecordValueType'; +import { type File } from './File'; + +export class FileListRecordValue extends RecordValue { + constructor(fieldId: number, value: File[]) { + super(RecordValueType.FileList, fieldId, value); + } +} diff --git a/src/models/GuidListRecordValue.ts b/src/models/GuidListRecordValue.ts new file mode 100644 index 0000000..7e9a064 --- /dev/null +++ b/src/models/GuidListRecordValue.ts @@ -0,0 +1,8 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +export class GuidListRecordValue extends RecordValue { + constructor(fieldId: number, value: string[]) { + super(RecordValueType.GuidList, fieldId, value); + } +} diff --git a/src/models/GuidRecordValue.ts b/src/models/GuidRecordValue.ts new file mode 100644 index 0000000..9af101c --- /dev/null +++ b/src/models/GuidRecordValue.ts @@ -0,0 +1,8 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +export class GuidRecordValue extends RecordValue { + constructor(fieldId: number, value: string) { + super(RecordValueType.Guid, fieldId, value); + } +} diff --git a/src/models/IntegerListRecordValue.ts b/src/models/IntegerListRecordValue.ts new file mode 100644 index 0000000..0fce22b --- /dev/null +++ b/src/models/IntegerListRecordValue.ts @@ -0,0 +1,8 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +export class IntegerListRecordValue extends RecordValue { + constructor(fieldId: number, value: number[]) { + super(RecordValueType.IntegerList, fieldId, value); + } +} diff --git a/src/models/IntegerRecordValue.ts b/src/models/IntegerRecordValue.ts new file mode 100644 index 0000000..a1be6ab --- /dev/null +++ b/src/models/IntegerRecordValue.ts @@ -0,0 +1,17 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +/** + * @class IntegerRecordValue - A record value represented by an integer. + */ +export class IntegerRecordValue extends RecordValue { + /** + * @constructor - Creates a new instance of IntegerRecordValue. + * @param {number} fieldId - The id of the field. + * @param {number} value - The value of the field. + * @returns {IntgerRecordValue} - A new instance of IntegerRecordValue. + */ + constructor(fieldId: number, value: number) { + super(RecordValueType.Integer, fieldId, value); + } +} diff --git a/src/models/RecordValue.ts b/src/models/RecordValue.ts index 72ec850..3c5c99b 100644 --- a/src/models/RecordValue.ts +++ b/src/models/RecordValue.ts @@ -1,12 +1,12 @@ -import { DelegateType } from '../enums/DelegateType'; -import { FileStorageSite } from '../enums/FileStorageSite'; import { RecordValueType } from '../enums/RecordValueType'; -import { TimeSpanIncrement } from '../enums/TimeSpanIncrement'; -import { TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType'; -import { Attachment } from './Attachment'; -import { Delegate } from './Delegate'; -import { ScoringGroup } from './ScoringGroup'; -import { TimeSpanData } from './TimeSpanData'; +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'; /** * @class RecordValue - A value for a field in a record. @@ -23,9 +23,9 @@ export class RecordValue { public fieldId: number; /** - * @property {T | any} value - The value of the field. + * @property {T} value - The value of the field. */ - public value: T | any; + public value: T; /** * @constructor - Creates a new instance of RecordValue. @@ -34,7 +34,7 @@ export class RecordValue { * @param {any} value - The value of the field. * @returns {RecordValue} - A new instance of RecordValue. */ - constructor(type: RecordValueType, fieldId: number, value: T | any) { + constructor(type: RecordValueType, fieldId: number, value: T) { this.type = type; this.fieldId = fieldId; this.value = value; @@ -47,7 +47,7 @@ export class RecordValue { */ public asString(): string { this.validateType([RecordValueType.String, RecordValueType.Guid]); - return this.value; + return this.value as string; } /** @@ -57,7 +57,7 @@ export class RecordValue { */ public asNumber(): number { this.validateType([RecordValueType.Integer, RecordValueType.Decimal]); - return this.value; + return this.value as number; } /** @@ -67,7 +67,7 @@ export class RecordValue { */ public asDate(): Date { this.validateType([RecordValueType.Date]); - return new Date(this.value); + return this.value as Date; } /** @@ -78,29 +78,7 @@ export class RecordValue { */ public asAttachmentArray(): Attachment[] { this.validateType([RecordValueType.AttachmentList]); - return this.value.map((attachment: any) => { - const storageLocation = FileStorageSite[attachment.storageLocation]; - - if (storageLocation === undefined) { - throw new Error( - `${ - this.value.storageLocation as string - } is not a valid FileStorageSite.` - ); - } - - const hasNotes = - attachment.notes !== null && attachment.notes !== undefined; - - const notes = hasNotes ? attachment.notes : null; - - return new Attachment( - attachment.fileId, - attachment.fileName, - notes, - storageLocation - ); - }); + return (this as AttachmentListRecordValue).value; } /** @@ -110,7 +88,7 @@ export class RecordValue { */ public asNumberArray(): number[] { this.validateType([RecordValueType.FileList, RecordValueType.IntegerList]); - return this.value; + return this.value as number[]; } /** @@ -120,47 +98,17 @@ export class RecordValue { */ public asStringArray(): string[] { this.validateType([RecordValueType.StringList, RecordValueType.GuidList]); - return this.value; + return this.value as string[]; } /** * @method asDelegateArray - Gets the value as an array of delegates. * @returns {Delegate[]} - The value as an array of delegates. * @throws {Error} - If the value is not an array of delegates. - * @throws {Error} - If a delegate type is not valid. */ public asDelegateArray(): Delegate[] { - this.validateType([RecordValueType.ScoringGroupList]); - return this.value.map((delegate: any) => { - const delegateType = DelegateType[delegate.delegateType]; - - if (delegateType === undefined) { - throw new Error( - `${delegate.delegateType as string} is not a valid DelegateType.` - ); - } - - const delegationDateTime = new Date(delegate.delegationDateTime); - - const hasName = delegate.name !== null && delegate.name !== undefined; - const name = hasName ? delegate.name : null; - - const hasCompletionDate = - delegate.delegationCompletedDateTime !== null && - delegate.delegationCompletedDateTime !== undefined; - - const delegationCompletedDateTime = hasCompletionDate - ? new Date(delegate.delegationCompletedDateTime) - : null; - - return new Delegate( - delegate.delegateType, - name, - delegate.emailAddress, - delegationDateTime, - delegationCompletedDateTime - ); - }); + this.validateType([RecordValueType.DelegateList]); + return (this as DelegateListRecordValue).value; } /** @@ -170,70 +118,17 @@ export class RecordValue { */ public asScoringGroupArray(): ScoringGroup[] { this.validateType([RecordValueType.ScoringGroupList]); - return this.value.map( - (scoringGroup: any) => - new ScoringGroup( - scoringGroup.listValueId, - scoringGroup.name, - scoringGroup.score, - scoringGroup.maximumScore - ) - ); + return (this as ScoringGroupListRecordValue).value; } /** * @method asTimeSpanData - Gets the value as a TimeSpanData object. * @returns {TimeSpanData} - The value as a TimeSpanData object. * @throws {Error} - If the value is not a TimeSpanData object. - * @throws {Error} - If the increment is not valid. - * @throws {Error} - If the recurrence is not valid. */ public asTimeSpanData(): TimeSpanData { this.validateType([RecordValueType.TimeSpan]); - - const increment = TimeSpanIncrement[this.value.increment]; - - const hasRecurrence = - this.value.recurrence !== null && this.value.recurrence !== undefined; - - const recurrene = hasRecurrence - ? TimeSpanRecurrenceType[this.value.recurrence] - : null; - - const hasEndAfterOccurrences = - this.value.endAfterOccurrences !== null && - this.value.endAfterOccurrences !== undefined; - - const endAfterOccurrences = hasEndAfterOccurrences - ? this.value.endAfterOccurrences - : null; - - const hasEndByDate = - this.value.endByDate !== null && this.value.endByDate !== undefined; - - const endByDate = hasEndByDate ? new Date(this.value.endByDate) : null; - - if (increment === undefined) { - throw new Error( - `${this.value.increment as string} is not a valid TimeSpanIncrement.` - ); - } - - if (recurrene === undefined) { - throw new Error( - `${ - this.value.recurrence as string - } is not a valid TimeSpanRecurrenceType.` - ); - } - - return new TimeSpanData( - this.value.quantity, - increment, - recurrene, - endAfterOccurrences, - endByDate - ); + return (this as TimeSpanRecordValue).value; } /** diff --git a/src/models/ScoringGroupListRecordValue.ts b/src/models/ScoringGroupListRecordValue.ts new file mode 100644 index 0000000..67b4859 --- /dev/null +++ b/src/models/ScoringGroupListRecordValue.ts @@ -0,0 +1,9 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; +import { type ScoringGroup } from './ScoringGroup'; + +export class ScoringGroupListRecordValue extends RecordValue { + constructor(fieldId: number, value: ScoringGroup[]) { + super(RecordValueType.ScoringGroupList, fieldId, value); + } +} diff --git a/src/models/StringListRecordValue.ts b/src/models/StringListRecordValue.ts new file mode 100644 index 0000000..674dadb --- /dev/null +++ b/src/models/StringListRecordValue.ts @@ -0,0 +1,8 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +export class StringListRecordValue extends RecordValue { + constructor(fieldId: number, value: string[]) { + super(RecordValueType.StringList, fieldId, value); + } +} diff --git a/src/models/StringRecordValue.ts b/src/models/StringRecordValue.ts new file mode 100644 index 0000000..ee59dd7 --- /dev/null +++ b/src/models/StringRecordValue.ts @@ -0,0 +1,17 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; + +/** + * @class StringRecordValue - A record value represented by a string. + */ +export class StringRecordValue extends RecordValue { + /** + * @constructor - Creates a new instance of StringRecordValue. + * @param {number} fieldId - The id of the field. + * @param {string} value - The value of the field. + * @returns {StringRecordValue} - A new instance of StringRecordValue. + */ + constructor(fieldId: number, value: string) { + super(RecordValueType.String, fieldId, value); + } +} diff --git a/src/models/TimeSpanRecordValue.ts b/src/models/TimeSpanRecordValue.ts new file mode 100644 index 0000000..cead1dc --- /dev/null +++ b/src/models/TimeSpanRecordValue.ts @@ -0,0 +1,9 @@ +import { RecordValueType } from '../enums/RecordValueType'; +import { RecordValue } from './RecordValue'; +import { type TimeSpanData } from './TimeSpanData'; + +export class TimeSpanRecordValue extends RecordValue { + constructor(fieldId: number, value: TimeSpanData) { + super(RecordValueType.TimeSpan, fieldId, value); + } +} diff --git a/tests/ApiResponse.spec.ts b/tests/ApiResponse.spec.ts index 7915b81..49e5b6b 100644 --- a/tests/ApiResponse.spec.ts +++ b/tests/ApiResponse.spec.ts @@ -15,9 +15,6 @@ import { ReferenceField } from '../src/models/ReferenceField'; import { Multiplicity } from '../src/enums/Multiplicity'; import { ListField } from '../src/models/ListField'; import { File } from '../src/models/File'; -import fs from 'fs'; -import { type AxiosResponse } from 'axios'; -import path from 'path'; import { ListItemResponse } from '../src/models/ListItemResponse'; import { GetPagedReportsResponse } from '../src/models/GetPagedReportsResponse'; import { Report } from '../src/models/Report'; @@ -26,6 +23,10 @@ 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'; describe('ApiResponse', function () { it('should be defined', function () { @@ -1142,36 +1143,172 @@ describe('ApiResponse', function () { }); it('should return an ApiResponse', function () { + testFieldData.forEach((recordValue) => { + const mockResponseData = { + appId: 1, + recordId: 1, + fieldData: [recordValue], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + const record = apiResponse.asRecordType(); + + expect(record).to.be.an.instanceof(ApiResponse); + expect(record.data).to.be.an.instanceof(Record); + expect(record.data).to.have.property('appId', 1); + expect(record.data).to.have.property('recordId', 1); + expect(record.data).to.have.property('fieldData').that.is.an('array'); + expect(record.data).to.not.be.null; + + if (record.data != null) { + record.data.fieldData.forEach((recordValue) => { + expect(recordValue).to.be.an.instanceof(RecordValue); + expect(recordValue).to.have.property('type'); + expect(recordValue).to.have.property('fieldId'); + expect(recordValue).to.have.property('value'); + }); + } + }); + }); + + it('should throw an error if a record value contains an unknown type', function () { const mockResponseData = { appId: 1, recordId: 1, fieldData: [ { - type: 'Text', - fieldId: 'field 1', - value: 'field value 1', + type: 'Unknown', + fieldId: 1, + value: 'value', }, ], }; const apiResponse = new ApiResponse(200, 'OK', mockResponseData); - const record = apiResponse.asRecordType(); - expect(record).to.be.an.instanceof(ApiResponse); - expect(record.data).to.be.an.instanceof(Record); - expect(record.data).to.have.property('appId', 1); - expect(record.data).to.have.property('recordId', 1); - expect(record.data).to.have.property('fieldData').that.is.an('array'); - expect(record.data).to.not.be.null; + expect(() => { + apiResponse.asRecordType(); + }).to.throw(); + }); - if (record.data != null) { - record.data.fieldData.forEach((recordValue) => { - expect(recordValue).to.be.an.instanceof(RecordValue); - expect(recordValue).to.have.property('type'); - expect(recordValue).to.have.property('fieldId'); - expect(recordValue).to.have.property('value'); - }); - } + it('should throw an error if a record value for a survey delegate field contains an unknown delegate type', function () { + const mockResponseData = { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'ScoringGroupList', + fieldId: 12167, + value: [ + { + delegateType: 'Unknown', + name: 'test_delegate', + emailAddress: 'test@test.com', + delegationType: 'AllPages', + pageIds: [], + answeredPageIds: [], + canReadOtherPages: false, + delegationDateTime: '2023-01-17T05:52:53.781Z', + delegationCompletedDateTime: '2023-01-17T05:53:12.617Z', + status: 'Pending', + isDeleted: false, + messagingDisplayText: + 'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM', + guid: '00000000-0000-0000-0000-000000000000', + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordType(); + }).to.throw(); + }); + + it('should throw an error if record value for an attachment field contains an unknown file storage site type', function () { + const mockResponseData = { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'AttachmentList', + fieldId: 12888, + value: [ + { + fileId: 1348, + fileName: 'onspring-api-playground.py', + notes: '', + storageLocation: 'Unknown', + }, + { + fileId: 1349, + fileName: 'core_isolation_warning.png', + notes: '', + storageLocation: 'Internal', + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordType(); + }).to.throw(); + }); + + it('should throw an error if record value for a timespan field contains an unknown increment type', function () { + const mockResponseData = { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Unknown', + recurrence: 'EndByDate', + endByDate: '2023-02-16T06:00:00Z', + }, + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordType(); + }).to.throw(); + }); + + it('should throw an error if record value for a timespan field contains an unknown recurrence type', function () { + const mockResponseData = { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Days', + recurrence: 'Unknown', + endByDate: '2023-02-16T06:00:00Z', + }, + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordType(); + }).to.throw(); }); }); @@ -1203,24 +1340,12 @@ describe('ApiResponse', function () { { appId: 1, recordId: 1, - fieldData: [ - { - type: 'Text', - fieldId: 'field 1', - value: 'field value 1', - }, - ], + fieldData: testFieldData, }, { appId: 2, recordId: 2, - fieldData: [ - { - type: 'Text', - fieldId: 'field 1', - value: 'field value 1', - }, - ], + fieldData: testFieldData, }, ], }; @@ -1250,9 +1375,203 @@ describe('ApiResponse', function () { if (getPagedRecordsResponse.data != null) { getPagedRecordsResponse.data.items.forEach((record) => { expect(record).to.be.an.instanceof(Record); + + expect(record).to.have.property('appId'); + expect(record).to.have.property('recordId'); + expect(record).to.have.property('fieldData').that.is.an('array'); + expect(record).to.not.be.null; + + if (record != null) { + record.fieldData.forEach((recordValue) => { + expect(recordValue).to.be.an.instanceof(RecordValue); + expect(recordValue).to.have.property('type'); + expect(recordValue).to.have.property('fieldId'); + expect(recordValue).to.have.property('value'); + }); + } }); } }); + + it('should throw an error if a record value contains an unknown type', function () { + const mockResponseData = { + pageSize: 1, + pageNumber: 1, + totalRecords: 1, + totalPages: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'Unknown', + fieldId: 1, + value: 'value', + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asGetPagedRecordsResponseType(); + }).to.throw(); + }); + + it('should throw an error if a record value for a survey delegate field contains an unknown delegate type', function () { + const mockResponseData = { + pageSize: 1, + pageNumber: 1, + totalRecords: 1, + totalPages: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'ScoringGroupList', + fieldId: 12167, + value: [ + { + delegateType: 'Unknown', + name: 'test_delegate', + emailAddress: 'test@test.com', + delegationType: 'AllPages', + pageIds: [], + answeredPageIds: [], + canReadOtherPages: false, + delegationDateTime: '2023-01-17T05:52:53.781Z', + delegationCompletedDateTime: '2023-01-17T05:53:12.617Z', + status: 'Pending', + isDeleted: false, + messagingDisplayText: + 'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM', + guid: '00000000-0000-0000-0000-000000000000', + }, + ], + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asGetPagedRecordsResponseType(); + }).to.throw(); + }); + + it('should throw an error if record value for an attachment field contains an unknown file storage site type', function () { + const mockResponseData = { + pageSize: 1, + pageNumber: 1, + totalRecords: 1, + totalPages: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'AttachmentList', + fieldId: 12888, + value: [ + { + fileId: 1348, + fileName: 'onspring-api-playground.py', + notes: '', + storageLocation: 'Unknown', + }, + { + fileId: 1349, + fileName: 'core_isolation_warning.png', + notes: '', + storageLocation: 'Internal', + }, + ], + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asGetPagedRecordsResponseType(); + }).to.throw(); + }); + + it('should throw an error if record value for a timespan field contains an unknown increment type', function () { + const mockResponseData = { + pageSize: 1, + pageNumber: 1, + totalRecords: 1, + totalPages: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Unknown', + recurrence: 'EndByDate', + endByDate: '2023-02-16T06:00:00Z', + }, + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asGetPagedRecordsResponseType(); + }).to.throw(); + }); + + it('should throw an error if record value for a timespan field contains an unknown recurrence type', function () { + const mockResponseData = { + pageSize: 1, + pageNumber: 1, + totalRecords: 1, + totalPages: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Days', + recurrence: 'Unknown', + endByDate: '2023-02-16T06:00:00Z', + }, + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asGetPagedRecordsResponseType(); + }).to.throw(); + }); }); describe('asRecordCollectionType', function () { @@ -1275,13 +1594,7 @@ describe('ApiResponse', function () { { appId: 1, recordId: 1, - fieldData: [ - { - type: 'Text', - fieldId: 'field 1', - value: 'field value 1', - }, - ], + fieldData: testFieldData, }, ], }; @@ -1322,5 +1635,170 @@ describe('ApiResponse', function () { }); } }); + + it('should throw an error if a record value contains an unknown type', function () { + const mockResponseData = { + count: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'Unknown', + fieldId: 1, + value: 'value', + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordCollectionType(); + }).to.throw(); + }); + + it('should throw an error if a record value for a survey delegate field contains an unknown delegate type', function () { + const mockResponseData = { + count: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'ScoringGroupList', + fieldId: 12167, + value: [ + { + delegateType: 'Unknown', + name: 'test_delegate', + emailAddress: 'test@test.com', + delegationType: 'AllPages', + pageIds: [], + answeredPageIds: [], + canReadOtherPages: false, + delegationDateTime: '2023-01-17T05:52:53.781Z', + delegationCompletedDateTime: '2023-01-17T05:53:12.617Z', + status: 'Pending', + isDeleted: false, + messagingDisplayText: + 'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM', + guid: '00000000-0000-0000-0000-000000000000', + }, + ], + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordCollectionType(); + }).to.throw(); + }); + + it('should throw an error if record value for an attachment field contains an unknown file storage site type', function () { + const mockResponseData = { + count: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'AttachmentList', + fieldId: 12888, + value: [ + { + fileId: 1348, + fileName: 'onspring-api-playground.py', + notes: '', + storageLocation: 'Unknown', + }, + { + fileId: 1349, + fileName: 'core_isolation_warning.png', + notes: '', + storageLocation: 'Internal', + }, + ], + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordCollectionType(); + }).to.throw(); + }); + + it('should throw an error if record value for a timespan field contains an unknown increment type', function () { + const mockResponseData = { + count: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Unknown', + recurrence: 'EndByDate', + endByDate: '2023-02-16T06:00:00Z', + }, + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordCollectionType(); + }).to.throw(); + }); + + it('should throw an error if record value for a timespan field contains an unknown recurrence type', function () { + const mockResponseData = { + count: 1, + items: [ + { + appId: 1, + recordId: 1, + fieldData: [ + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Days', + recurrence: 'Unknown', + endByDate: '2023-02-16T06:00:00Z', + }, + }, + ], + }, + ], + }; + + const apiResponse = new ApiResponse(200, 'OK', mockResponseData); + + expect(() => { + apiResponse.asRecordCollectionType(); + }).to.throw(); + }); }); }); diff --git a/tests/AttachmentListRecordValue.spec.ts b/tests/AttachmentListRecordValue.spec.ts new file mode 100644 index 0000000..d1ff154 --- /dev/null +++ b/tests/AttachmentListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { AttachmentListRecordValue } from '../src/models/AttachmentListRecordValue'; +import { expect } from 'chai'; + +describe('AttachmentListRecordValue', function () { + it('should be defined', function () { + expect(AttachmentListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(AttachmentListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(AttachmentListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const attachmentListRecordValue = new AttachmentListRecordValue(1, []); + expect(attachmentListRecordValue).to.have.property('fieldId'); + expect(attachmentListRecordValue).to.have.property('value'); + expect(attachmentListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const attachmentListRecordValue = new AttachmentListRecordValue(1, []); + expect(attachmentListRecordValue.fieldId).to.equal(1); + expect(attachmentListRecordValue.value).to.deep.equal([]); + expect(attachmentListRecordValue.type).to.equal('AttachmentList'); + }); +}); diff --git a/tests/DateRecordValue.spec.ts b/tests/DateRecordValue.spec.ts new file mode 100644 index 0000000..03c4978 --- /dev/null +++ b/tests/DateRecordValue.spec.ts @@ -0,0 +1,31 @@ +import { DateRecordValue } from '../src/models/DateRecordValue'; +import { expect } from 'chai'; + +describe('DateRecordValue', function () { + it('should be defined', function () { + expect(DateRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(DateRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(DateRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const dateRecordValue = new DateRecordValue(1, new Date()); + expect(dateRecordValue).to.have.property('fieldId'); + expect(dateRecordValue).to.have.property('value'); + expect(dateRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const date = new Date(); + const dateRecordValue = new DateRecordValue(1, date); + expect(dateRecordValue.fieldId).to.equal(1); + expect(dateRecordValue.value).to.deep.equal(date); + expect(dateRecordValue.type).to.equal('Date'); + }); +}); diff --git a/tests/DecimalRecordValue.spec.ts b/tests/DecimalRecordValue.spec.ts new file mode 100644 index 0000000..05b6c9a --- /dev/null +++ b/tests/DecimalRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { DecimalRecordValue } from '../src/models/DecimalRecordValue'; +import { expect } from 'chai'; + +describe('DecimalRecordValue', function () { + it('should be defined', function () { + expect(DecimalRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(DecimalRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(DecimalRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const decimalRecordValue = new DecimalRecordValue(1, 1); + expect(decimalRecordValue).to.have.property('fieldId'); + expect(decimalRecordValue).to.have.property('value'); + expect(decimalRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const decimalRecordValue = new DecimalRecordValue(1, 1); + expect(decimalRecordValue.fieldId).to.equal(1); + expect(decimalRecordValue.value).to.deep.equal(1); + expect(decimalRecordValue.type).to.equal('Decimal'); + }); +}); diff --git a/tests/DelegateListRecordValue.spec.ts b/tests/DelegateListRecordValue.spec.ts new file mode 100644 index 0000000..4d10cbc --- /dev/null +++ b/tests/DelegateListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { DelegateListRecordValue } from '../src/models/DelegateListRecordValue'; +import { expect } from 'chai'; + +describe('DelegateListRecordValue', function () { + it('should be defined', function () { + expect(DelegateListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(DelegateListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(DelegateListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const delegateListRecordValue = new DelegateListRecordValue(1, []); + expect(delegateListRecordValue).to.have.property('fieldId'); + expect(delegateListRecordValue).to.have.property('value'); + expect(delegateListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const delegateListRecordValue = new DelegateListRecordValue(1, []); + expect(delegateListRecordValue.fieldId).to.equal(1); + expect(delegateListRecordValue.value).to.deep.equal([]); + expect(delegateListRecordValue.type).to.equal('DelegateList'); + }); +}); diff --git a/tests/FileListRecordValue.spec.ts b/tests/FileListRecordValue.spec.ts new file mode 100644 index 0000000..29bb0aa --- /dev/null +++ b/tests/FileListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { FileListRecordValue } from '../src/models/FileListRecordValue'; +import { expect } from 'chai'; + +describe('FileListRecordValue', function () { + it('should be defined', function () { + expect(FileListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(FileListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(FileListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const fileListRecordValue = new FileListRecordValue(1, []); + expect(fileListRecordValue).to.have.property('fieldId'); + expect(fileListRecordValue).to.have.property('value'); + expect(fileListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const fileListRecordValue = new FileListRecordValue(1, []); + expect(fileListRecordValue.fieldId).to.equal(1); + expect(fileListRecordValue.value).to.deep.equal([]); + expect(fileListRecordValue.type).to.equal('FileList'); + }); +}); diff --git a/tests/GuidListRecordValue.spec.ts b/tests/GuidListRecordValue.spec.ts new file mode 100644 index 0000000..ea0e58e --- /dev/null +++ b/tests/GuidListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { GuidListRecordValue } from '../src/models/GuidListRecordValue'; +import { expect } from 'chai'; + +describe('GuidListRecordValue', function () { + it('should be defined', function () { + expect(GuidListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(GuidListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(GuidListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const guidListRecordValue = new GuidListRecordValue(1, []); + expect(guidListRecordValue).to.have.property('fieldId'); + expect(guidListRecordValue).to.have.property('value'); + expect(guidListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const guidListRecordValue = new GuidListRecordValue(1, []); + expect(guidListRecordValue.fieldId).to.equal(1); + expect(guidListRecordValue.value).to.deep.equal([]); + expect(guidListRecordValue.type).to.equal('GuidList'); + }); +}); diff --git a/tests/GuidRecordValue.spec.ts b/tests/GuidRecordValue.spec.ts new file mode 100644 index 0000000..c9b1e3a --- /dev/null +++ b/tests/GuidRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { GuidRecordValue } from '../src/models/GuidRecordValue'; +import { expect } from 'chai'; + +describe('GuidRecordValue', function () { + it('should be defined', function () { + expect(GuidRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(GuidRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(GuidRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const guidRecordValue = new GuidRecordValue(1, 'test'); + expect(guidRecordValue).to.have.property('fieldId'); + expect(guidRecordValue).to.have.property('value'); + expect(guidRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const guidRecordValue = new GuidRecordValue(1, 'test'); + expect(guidRecordValue.fieldId).to.equal(1); + expect(guidRecordValue.value).to.deep.equal('test'); + expect(guidRecordValue.type).to.equal('Guid'); + }); +}); diff --git a/tests/IntegerListRecordValue.spec.ts b/tests/IntegerListRecordValue.spec.ts new file mode 100644 index 0000000..bbfc65f --- /dev/null +++ b/tests/IntegerListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { IntegerListRecordValue } from '../src/models/IntegerListRecordValue'; +import { expect } from 'chai'; + +describe('IntegerListRecordValue', function () { + it('should be defined', function () { + expect(IntegerListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(IntegerListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(IntegerListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const integerListRecordValue = new IntegerListRecordValue(1, []); + expect(integerListRecordValue).to.have.property('fieldId'); + expect(integerListRecordValue).to.have.property('value'); + expect(integerListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const integerListRecordValue = new IntegerListRecordValue(1, []); + expect(integerListRecordValue.fieldId).to.equal(1); + expect(integerListRecordValue.value).to.deep.equal([]); + expect(integerListRecordValue.type).to.equal('IntegerList'); + }); +}); diff --git a/tests/IntegerRecordValue.spec.ts b/tests/IntegerRecordValue.spec.ts new file mode 100644 index 0000000..8b66b2d --- /dev/null +++ b/tests/IntegerRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { IntegerRecordValue } from '../src/models/IntegerRecordValue'; +import { expect } from 'chai'; + +describe('IntegerRecordValue', function () { + it('should be defined', function () { + expect(IntegerRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(IntegerRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(IntegerRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const integerRecordValue = new IntegerRecordValue(1, 1); + expect(integerRecordValue).to.have.property('fieldId'); + expect(integerRecordValue).to.have.property('value'); + expect(integerRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const integerRecordValue = new IntegerRecordValue(1, 1); + expect(integerRecordValue.fieldId).to.equal(1); + expect(integerRecordValue.value).to.deep.equal(1); + expect(integerRecordValue.type).to.equal('Integer'); + }); +}); diff --git a/tests/OnspringClient.spec.ts b/tests/OnspringClient.spec.ts index 8849e22..8c305aa 100644 --- a/tests/OnspringClient.spec.ts +++ b/tests/OnspringClient.spec.ts @@ -2867,12 +2867,12 @@ describe('OnspringClient', function () { recordId: 1, fieldData: [ { - type: 'Text', + type: 'String', fieldId: 1, value: 'Test', }, { - type: 'Text', + type: 'String', fieldId: 2, value: 'Test', }, @@ -3047,12 +3047,12 @@ describe('OnspringClient', function () { recordId: 1, fieldData: [ { - type: 'Text', + type: 'String', fieldId: 1, value: 'Test', }, { - type: 'Text', + type: 'String', fieldId: 2, value: 'Test', }, @@ -3250,12 +3250,12 @@ describe('OnspringClient', function () { recordId: 1, fieldData: [ { - type: 'text', + type: 'String', fieldId: 1, value: 'Test', }, { - type: 'text', + type: 'String', fieldId: 2, value: 'Test', }, @@ -3450,12 +3450,12 @@ describe('OnspringClient', function () { recordId: 1, fieldData: [ { - type: 'text', + type: 'String', fieldId: 1, value: 'value', }, { - type: 'text', + type: 'String', fieldId: 2, value: 'value', }, diff --git a/tests/RecordValue.spec.ts b/tests/RecordValue.spec.ts index 486fe49..5ee1e33 100644 --- a/tests/RecordValue.spec.ts +++ b/tests/RecordValue.spec.ts @@ -5,6 +5,10 @@ import { Attachment } from '../src/models/Attachment'; import { Delegate } from '../src/models/Delegate'; import { ScoringGroup } from '../src/models/ScoringGroup'; import { TimeSpanData } from '../src/models/TimeSpanData'; +import { FileStorageSite } from '../src/enums/FileStorageSite'; +import { DelegateType } from '../src/enums/DelegateType'; +import { TimeSpanRecurrenceType } from '../src/enums/TimeSpanRecurrenceType'; +import { TimeSpanIncrement } from '../src/enums/TimeSpanIncrement'; describe('RecordValue', function () { it('should be defined', function () { @@ -112,9 +116,9 @@ describe('RecordValue', function () { }); it('should return the value as a date for valid type', function () { - const value = new Date().toUTCString(); + const value = new Date(); expect(new RecordValue(RecordValueType.Date, 2, value).asDate()) - .to.deep.equal(new Date(value)) + .to.deep.equal(value) .and.to.be.a('date'); }); @@ -136,23 +140,9 @@ describe('RecordValue', function () { it('should return the value as an array of attachments for valid type', function () { const value = [ - { - fileId: 1, - fileName: 'test', - notes: 'test', - storageLocation: 'Internal', - }, - { - fileId: 1, - fileName: 'test', - storageLocation: 'Internal', - }, - { - fileId: 1, - fileName: 'test', - notes: null, - storageLocation: 'Internal', - }, + new Attachment(1, 'test', 'test', FileStorageSite.Internal), + new Attachment(1, 'test', 'test', FileStorageSite.Internal), + new Attachment(1, 'test', null, FileStorageSite.Internal), ]; const attachmentArray = new RecordValue( @@ -172,25 +162,6 @@ describe('RecordValue', function () { }); }); - it('should throw an error if attachment has incorrect storage location', function () { - const value = [ - { - fileId: 1, - fileName: 'test', - notes: 'test', - storageLocation: 'Invalid', - }, - ]; - - expect(() => - new RecordValue( - RecordValueType.AttachmentList, - 2, - value - ).asAttachmentArray() - ).to.throw(); - }); - it('should throw an error if called on record value with incorrect type', function () { expect(() => new RecordValue(RecordValueType.Integer, 2, []).asAttachmentArray() @@ -272,29 +243,31 @@ describe('RecordValue', function () { it('should return the value as an array of delegates for valid type', function () { const value = [ - { - delegateType: 'External', - name: 'test', - emailAddress: 'test@test.com', - delegationDateTime: '2019-01-01T00:00:00.000Z', - delegationCompletedDateTime: '2019-01-01T00:00:00.000Z', - }, - { - delegateType: 'External', - name: null, - emailAddress: 'test@test.com', - delegationDateTime: '2019-01-01T00:00:00.000Z', - delegationCompletedDateTime: null, - }, - { - delegateType: 'External', - emailAddress: 'test@test.com', - delegationDateTime: '2019-01-01T00:00:00.000Z', - }, + new Delegate( + DelegateType.External, + 'test', + 'test@test.com', + new Date(), + new Date() + ), + new Delegate( + DelegateType.External, + null, + 'test@test.com', + new Date(), + null + ), + new Delegate( + DelegateType.External, + 'test', + 'test@test.com', + new Date(), + new Date() + ), ]; const recordValue = new RecordValue( - RecordValueType.ScoringGroupList, + RecordValueType.DelegateList, 2, value ).asDelegateArray(); @@ -315,26 +288,6 @@ describe('RecordValue', function () { new RecordValue(RecordValueType.Integer, 2, []).asDelegateArray() ).to.throw(); }); - - it('should throw an error if delegate has incorrect delegate type', function () { - const value = [ - { - delegateType: 'Invalid', - name: 'test', - emailAddress: 'test@test.com', - delegationDateTime: '2019-01-01T00:00:00.000Z', - delegationCompletedDateTime: '2019-01-01T00:00:00.000Z', - }, - ]; - - expect(() => - new RecordValue( - RecordValueType.ScoringGroupList, - 2, - value - ).asDelegateArray() - ).to.throw(); - }); }); describe('asScoringGroupArray', function () { @@ -347,14 +300,7 @@ describe('RecordValue', function () { }); it('should return the value as an array of scoring groups for valid type', function () { - const value = [ - { - listValueId: 'test', - name: 'test', - score: 1, - maximumScore: 1, - }, - ]; + const value = [new ScoringGroup('1', 'test', 1, 1)]; const recordValue = new RecordValue( RecordValueType.ScoringGroupList, @@ -391,24 +337,21 @@ describe('RecordValue', function () { it('should return the value as a TimeSpanData for valid type', function () { const cases = [ - { - quantity: 1, - increment: 'Days', - recurrence: 'None', - endAfterOccurrences: 1, - endByDate: '2019-01-01T00:00:00.000Z', - }, - { - quantity: 1, - increment: 'Days', - recurrence: null, - endAfterOccurrences: null, - endByDate: null, - }, - { - quantity: 1, - increment: 'Days', - }, + new TimeSpanData( + 1, + TimeSpanIncrement.Days, + TimeSpanRecurrenceType.None, + 1, + new Date() + ), + new TimeSpanData(1, TimeSpanIncrement.Days, null, null, null), + new TimeSpanData( + 1, + TimeSpanIncrement.Days, + TimeSpanRecurrenceType.None, + 1, + new Date() + ), ]; cases.forEach((value) => { @@ -432,33 +375,5 @@ describe('RecordValue', function () { new RecordValue(RecordValueType.Integer, 2, []).asTimeSpanData() ).to.throw(); }); - - it('should throw an error if timespan has incorrect increment', function () { - const value = { - quantity: 1, - increment: 'Invalid', - recurrence: 'None', - endAfterOccurrences: 1, - endByDate: '2019-01-01T00:00:00.000Z', - }; - - expect(() => - new RecordValue(RecordValueType.TimeSpan, 2, value).asTimeSpanData() - ).to.throw(); - }); - - it('should throw an error if timespan has incorrect recurrence', function () { - const value = { - quantity: 1, - increment: 'Days', - recurrence: 'Invalid', - endAfterOccurrences: 1, - endByDate: '2019-01-01T00:00:00.000Z', - }; - - expect(() => - new RecordValue(RecordValueType.TimeSpan, 2, value).asTimeSpanData() - ).to.throw(); - }); }); }); diff --git a/tests/ScoringGroupListRecordValue.spec.ts b/tests/ScoringGroupListRecordValue.spec.ts new file mode 100644 index 0000000..6d4cc61 --- /dev/null +++ b/tests/ScoringGroupListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { ScoringGroupListRecordValue } from '../src/models/ScoringGroupListRecordValue'; +import { expect } from 'chai'; + +describe('ScoringGroupListRecordValue', function () { + it('should be defined', function () { + expect(ScoringGroupListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(ScoringGroupListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(ScoringGroupListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const scoringGroupListRecordValue = new ScoringGroupListRecordValue(1, []); + expect(scoringGroupListRecordValue).to.have.property('fieldId'); + expect(scoringGroupListRecordValue).to.have.property('value'); + expect(scoringGroupListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const scoringGroupListRecordValue = new ScoringGroupListRecordValue(1, []); + expect(scoringGroupListRecordValue.fieldId).to.equal(1); + expect(scoringGroupListRecordValue.value).to.deep.equal([]); + expect(scoringGroupListRecordValue.type).to.equal('ScoringGroupList'); + }); +}); diff --git a/tests/StringListRecordValue.spec.ts b/tests/StringListRecordValue.spec.ts new file mode 100644 index 0000000..abf37eb --- /dev/null +++ b/tests/StringListRecordValue.spec.ts @@ -0,0 +1,30 @@ +import { StringListRecordValue } from '../src/models/StringListRecordValue'; +import { expect } from 'chai'; + +describe('StringListRecordValue', function () { + it('should be defined', function () { + expect(StringListRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(StringListRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(StringListRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const stringListRecordValue = new StringListRecordValue(1, []); + expect(stringListRecordValue).to.have.property('fieldId'); + expect(stringListRecordValue).to.have.property('value'); + expect(stringListRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const stringListRecordValue = new StringListRecordValue(1, []); + expect(stringListRecordValue.fieldId).to.equal(1); + expect(stringListRecordValue.value).to.deep.equal([]); + expect(stringListRecordValue.type).to.equal('StringList'); + }); +}); diff --git a/tests/TimeSpanRecordValue.spec.ts b/tests/TimeSpanRecordValue.spec.ts new file mode 100644 index 0000000..7a37c4c --- /dev/null +++ b/tests/TimeSpanRecordValue.spec.ts @@ -0,0 +1,48 @@ +import { TimeSpanRecordValue } from '../src/models/TimeSpanRecordValue'; +import { expect } from 'chai'; +import { TimeSpanData } from '../src/models/TimeSpanData'; +import { TimeSpanIncrement } from '../src/enums/TimeSpanIncrement'; +import { TimeSpanRecurrenceType } from '../src/enums/TimeSpanRecurrenceType'; + +describe('TimeSpanRecordValue', function () { + it('should be defined', function () { + expect(TimeSpanRecordValue).to.not.be.undefined; + }); + + it('should have a constructor', function () { + expect(TimeSpanRecordValue).to.have.property('constructor'); + }); + + it('should hav a constructor that takes a fieldId and value', function () { + expect(TimeSpanRecordValue).to.have.lengthOf(2); + }); + + it('should have fieldId, value, and type properties', function () { + const timeSpanData = new TimeSpanData( + 1, + TimeSpanIncrement.Days, + TimeSpanRecurrenceType.None, + null, + null + ); + const timeSpanRecordValue = new TimeSpanRecordValue(1, timeSpanData); + expect(timeSpanRecordValue).to.have.property('fieldId'); + expect(timeSpanRecordValue).to.have.property('value'); + expect(timeSpanRecordValue).to.have.property('type'); + }); + + it('should have a constructor that sets its properties correctly', function () { + const timeSpanData = new TimeSpanData( + 1, + TimeSpanIncrement.Days, + TimeSpanRecurrenceType.None, + null, + null + ); + const timeSpanRecordValue = new TimeSpanRecordValue(1, timeSpanData); + + expect(timeSpanRecordValue.fieldId).to.equal(1); + expect(timeSpanRecordValue.value).to.deep.equal(timeSpanData); + expect(timeSpanRecordValue.type).to.equal('TimeSpan'); + }); +}); diff --git a/tests/testData/testFieldData.ts b/tests/testData/testFieldData.ts new file mode 100644 index 0000000..c45e428 --- /dev/null +++ b/tests/testData/testFieldData.ts @@ -0,0 +1,416 @@ +/* +This file represents an exhaustive list of possible record value +objects that can be returned from the API. It is used in the +ApiResponse.spec.ts file to test the ApiResponse class when it returns +types involving records. + */ +export const testFieldData: object[] = [ + { + type: 'StringList', + fieldId: 12891, + value: ['list_value_1', 'list_value_2'], + }, + { + type: 'Integer', + fieldId: 12144, + value: 1, + }, + { + type: 'Date', + fieldId: 12145, + value: '2023-01-17T05:52:07.251Z', + }, + { + type: 'Date', + fieldId: 12146, + value: '2023-02-10T01:19:46.63Z', + }, + { + type: 'String', + fieldId: 12152, + value: 'stevan.freeborn@onspring.com', + }, + { + type: 'Date', + fieldId: 12153, + value: '2023-01-17T05:53:12.104Z', + }, + { + type: 'Integer', + fieldId: 12160, + value: 69, + }, + { + type: 'String', + fieldId: 12165, + value: 'stevan.freeborn+delegate@onspring.com', + }, + { + type: 'String', + fieldId: 12166, + value: 'stevan_delegate', + }, + { + type: 'ScoringGroupList', + fieldId: 12167, + value: [ + { + delegateType: 'External', + name: 'test_delegate', + emailAddress: 'test@test.com', + delegationType: 'AllPages', + pageIds: [], + answeredPageIds: [], + canReadOtherPages: false, + delegationDateTime: '2023-01-17T05:52:53.781Z', + delegationCompletedDateTime: '2023-01-17T05:53:12.617Z', + status: 'Pending', + isDeleted: false, + messagingDisplayText: + 'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM', + guid: '00000000-0000-0000-0000-000000000000', + }, + { + delegateType: 'External', + name: undefined, + emailAddress: 'test@test.com', + delegationType: 'AllPages', + pageIds: [], + answeredPageIds: [], + canReadOtherPages: false, + delegationDateTime: '2023-01-17T05:52:53.781Z', + delegationCompletedDateTime: undefined, + status: 'Pending', + isDeleted: false, + messagingDisplayText: + 'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM', + guid: '00000000-0000-0000-0000-000000000000', + }, + { + delegateType: 'External', + name: null, + emailAddress: 'test@test.com', + delegationType: 'AllPages', + pageIds: [], + answeredPageIds: [], + canReadOtherPages: false, + delegationDateTime: '2023-01-17T05:52:53.781Z', + delegationCompletedDateTime: null, + status: 'Pending', + isDeleted: false, + messagingDisplayText: + 'Delegate Name: test_delegate -- Delegate Completed On: 1/17/2023 5:53 AM', + guid: '00000000-0000-0000-0000-000000000000', + }, + ], + }, + { + type: 'IntegerList', + fieldId: 12191, + value: [1], + }, + { + type: 'IntegerList', + fieldId: 12192, + value: [925], + }, + { + type: 'String', + fieldId: 12894, + value: 'test', + }, + { + type: 'Decimal', + fieldId: 12895, + value: 10, + }, + { + type: 'Guid', + fieldId: 12896, + value: '2b70ebb9-af45-4165-9a23-da44acce7bf7', + }, + { + type: 'Date', + fieldId: 12897, + value: '2023-02-10T07:19:46.629Z', + }, + { + type: 'Integer', + fieldId: 12144, + value: 2, + }, + { + type: 'Date', + fieldId: 12145, + value: '2023-01-24T04:03:06.13Z', + }, + { + type: 'Date', + fieldId: 12146, + value: '2023-02-10T04:06:29.985Z', + }, + { + type: 'Date', + fieldId: 12147, + value: '2023-02-10T04:06:29.985Z', + }, + { + type: 'Integer', + fieldId: 12148, + value: 2, + }, + { + type: 'Integer', + fieldId: 12149, + value: 2, + }, + { + type: 'Integer', + fieldId: 12150, + value: 2, + }, + { + type: 'String', + fieldId: 12151, + value: 'Stevan Freeborn', + }, + { + type: 'String', + fieldId: 12152, + value: 'stevan.freeborn@onspring.com', + }, + { + type: 'Date', + fieldId: 12153, + value: '2023-01-24T04:03:06.128Z', + }, + { + type: 'Decimal', + fieldId: 12155, + value: 6, + }, + { + type: 'Decimal', + fieldId: 12156, + value: 9, + }, + { + type: 'Decimal', + fieldId: 12157, + value: 66.66666666666667, + }, + { + type: 'Integer', + fieldId: 12160, + value: 73, + }, + { + type: 'ScoringGroupList', + fieldId: 12161, + value: [ + { + listValueId: '0eac7224-f4bc-4121-8ca5-1fe75f5cd576', + name: 'group_one', + score: 2, + maximumScore: 3, + }, + { + listValueId: '743ddd0d-702d-414d-87d4-0aa4fe0c265e', + name: 'group_two', + score: 2, + maximumScore: 4, + }, + { + listValueId: '4ff35205-bfe8-4639-8574-d0458fa7f85e', + name: 'group_three', + score: 2, + maximumScore: 2, + }, + ], + }, + { + type: 'Decimal', + fieldId: 12162, + value: 9, + }, + { + type: 'Decimal', + fieldId: 12163, + value: 66.66666666666667, + }, + { + type: 'ScoringGroupList', + fieldId: 12164, + value: [ + { + listValueId: '0eac7224-f4bc-4121-8ca5-1fe75f5cd576', + name: 'group_one', + score: 2, + maximumScore: 3, + }, + { + listValueId: '743ddd0d-702d-414d-87d4-0aa4fe0c265e', + name: 'group_two', + score: 2, + maximumScore: 4, + }, + { + listValueId: '4ff35205-bfe8-4639-8574-d0458fa7f85e', + name: 'group_three', + score: 2, + maximumScore: 2, + }, + ], + }, + { + type: 'String', + fieldId: 12165, + value: 'stevan.freeborn@onspring.com', + }, + { + type: 'String', + fieldId: 12166, + value: 'Stevan Freeborn', + }, + { + type: 'IntegerList', + fieldId: 12191, + value: [2, 3, 4, 5, 6, 7], + }, + { + type: 'IntegerList', + fieldId: 12192, + value: [925], + }, + { + type: 'String', + fieldId: 12263, + value: '2', + }, + { + type: 'Date', + fieldId: 12884, + value: '2023-02-09T06:00:00Z', + }, + { + type: 'Guid', + fieldId: 12885, + value: 'e75b49cf-adb7-4b8e-a7e5-93ebf1948dba', + }, + { + type: 'Decimal', + fieldId: 12886, + value: 100, + }, + { + type: 'String', + fieldId: 12887, + value: 'this is a test', + }, + { + type: 'AttachmentList', + fieldId: 12888, + value: [ + { + fileId: 1348, + fileName: 'onspring-api-playground.py', + notes: '', + storageLocation: 'Internal', + }, + { + fileId: 1349, + fileName: 'core_isolation_warning.png', + notes: '', + storageLocation: 'Internal', + }, + { + fileId: 1349, + fileName: 'core_isolation_warning.png', + notes: null, + storageLocation: 'Internal', + }, + { + fileId: 1349, + fileName: 'core_isolation_warning.png', + notes: undefined, + storageLocation: 'Internal', + }, + ], + }, + { + type: 'FileList', + fieldId: 12889, + value: [1350, 1351], + }, + { + type: 'Integer', + fieldId: 12890, + value: 2, + }, + { + type: 'GuidList', + fieldId: 12891, + value: [ + 'd7471a5f-6718-4368-8734-3e3e712bacd9', + '3b3de61f-fa44-4e51-b70d-35992c2a1a6e', + ], + }, + { + type: 'IntegerList', + fieldId: 12892, + value: [4, 5], + }, + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Days', + recurrence: 'EndByDate', + endAfterOccurrences: 10, + endByDate: '2023-02-16T06:00:00Z', + }, + }, + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Days', + recurrence: null, + endAfterOccurrences: null, + endByDate: null, + }, + }, + { + type: 'TimeSpan', + fieldId: 12893, + value: { + quantity: 10, + increment: 'Days', + recurrence: undefined, + endAfterOccurrences: undefined, + endByDate: undefined, + }, + }, + { + type: 'String', + fieldId: 12894, + value: 'test', + }, + { + type: 'Decimal', + fieldId: 12895, + value: 10, + }, + { + type: 'Guid', + fieldId: 12896, + value: '2b70ebb9-af45-4165-9a23-da44acce7bf7', + }, + { + type: 'Date', + fieldId: 12897, + value: '2023-02-10T07:19:47.002Z', + }, +];