UNPKG

@planet-a/affinity-node

Version:
802 lines (801 loc) 34.3 kB
export * from './Attendee.js'; export * from './AttendeesPreview.js'; export * from './AuthenticationError.js'; export * from './AuthorizationError.js'; export * from './AuthorizationErrors.js'; export * from './BadRequestError.js'; export * from './ChatMessage.js'; export * from './CompaniesValue.js'; export * from './CompaniesValueUpdate.js'; export * from './Company.js'; export * from './CompanyData.js'; export * from './CompanyDataPaged.js'; export * from './CompanyListEntry.js'; export * from './CompanyMergeRequest.js'; export * from './CompanyMergeResponse.js'; export * from './CompanyMergeState.js'; export * from './CompanyMergeStatePaged.js'; export * from './CompanyMergeTask.js'; export * from './CompanyMergeTaskPaged.js'; export * from './CompanyMergeTaskResultsSummary.js'; export * from './CompanyPaged.js'; export * from './CompanyReference.js'; export * from './CompanyValue.js'; export * from './CompanyValueUpdate.js'; export * from './ConflictError.js'; export * from './DateValue.js'; export * from './Dropdown.js'; export * from './DropdownReference.js'; export * from './DropdownValue.js'; export * from './DropdownValueUpdate.js'; export * from './DropdownsValue.js'; export * from './DropdownsValueUpdate.js'; export * from './Email.js'; export * from './Errors.js'; export * from './Field.js'; export * from './FieldMetadata.js'; export * from './FieldMetadataPaged.js'; export * from './FieldPaged.js'; export * from './FieldUpdate.js'; export * from './FieldValue.js'; export * from './FieldValueUpdate.js'; export * from './FloatValue.js'; export * from './FloatsValue.js'; export * from './FormulaNumber.js'; export * from './FormulaValue.js'; export * from './Grant.js'; export * from './Interaction.js'; export * from './InteractionValue.js'; export * from './InteractionsCall.js'; export * from './InteractionsCallPaged.js'; export * from './InteractionsChatMessage.js'; export * from './InteractionsChatMessagePaged.js'; export * from './InteractionsEmail.js'; export * from './InteractionsEmailPaged.js'; export * from './InteractionsMeeting.js'; export * from './InteractionsMeetingPaged.js'; export * from './List.js'; export * from './ListEntry.js'; export * from './ListEntryBatchOperationResponse.js'; export * from './ListEntryBatchOperationUpdateFields.js'; export * from './ListEntryBatchOperationUpdateFieldsUpdatesInner.js'; export * from './ListEntryBatchOperations.js'; export * from './ListEntryPaged.js'; export * from './ListEntryWithEntity.js'; export * from './ListEntryWithEntityPaged.js'; export * from './ListPaged.js'; export * from './ListWithType.js'; export * from './ListWithTypePaged.js'; export * from './Location.js'; export * from './LocationValue.js'; export * from './LocationsValue.js'; export * from './Meeting.js'; export * from './MethodNotAllowedError.js'; export * from './ModelError.js'; export * from './NotAcceptableError.js'; export * from './NotFoundError.js'; export * from './NotFoundErrors.js'; export * from './NotImplementedError.js'; export * from './NotesAiNotetakerReplyNote.js'; export * from './NotesAiNotetakerRootNote.js'; export * from './NotesBaseNote.js'; export * from './NotesBaseReply.js'; export * from './NotesBaseReplyParent.js'; export * from './NotesBaseRootNote.js'; export * from './NotesCallInteraction.js'; export * from './NotesChatMessageInteraction.js'; export * from './NotesCompaniesPreview.js'; export * from './NotesContent.js'; export * from './NotesEmailInteraction.js'; export * from './NotesEntitiesNote.js'; export * from './NotesInteraction.js'; export * from './NotesInteractionNote.js'; export * from './NotesMeetingInteraction.js'; export * from './NotesNote.js'; export * from './NotesNotesPaged.js'; export * from './NotesOpportunitiesPreview.js'; export * from './NotesPermissionSettings.js'; export * from './NotesPersonMention.js'; export * from './NotesPersonsPreview.js'; export * from './NotesRepliesPaged.js'; export * from './NotesReply.js'; export * from './NotesUserReplyNote.js'; export * from './Opportunity.js'; export * from './OpportunityListEntry.js'; export * from './OpportunityPaged.js'; export * from './OpportunityWithFields.js'; export * from './Pagination.js'; export * from './PaginationWithTotalCount.js'; export * from './Person.js'; export * from './PersonData.js'; export * from './PersonDataPaged.js'; export * from './PersonDataPreview.js'; export * from './PersonListEntry.js'; export * from './PersonMergeRequest.js'; export * from './PersonMergeResponse.js'; export * from './PersonMergeState.js'; export * from './PersonMergeStatePaged.js'; export * from './PersonMergeTask.js'; export * from './PersonMergeTaskPaged.js'; export * from './PersonPaged.js'; export * from './PersonReference.js'; export * from './PersonValue.js'; export * from './PersonValueUpdate.js'; export * from './PersonsValue.js'; export * from './PersonsValueUpdate.js'; export * from './PhoneCall.js'; export * from './RankedDropdown.js'; export * from './RankedDropdownReference.js'; export * from './RankedDropdownValue.js'; export * from './RankedDropdownValueUpdate.js'; export * from './RateLimitError.js'; export * from './Responses400.js'; export * from './Responses400ErrorsInner.js'; export * from './SavedView.js'; export * from './SavedViewPaged.js'; export * from './ServerError.js'; export * from './Tenant.js'; export * from './TextValue.js'; export * from './TextsValue.js'; export * from './UnprocessableEntityError.js'; export * from './UnsupportedMediaTypeError.js'; export * from './User.js'; export * from './ValidationError.js'; export * from './WhoAmI.js'; import { Attendee } from './Attendee.js'; import { AttendeesPreview } from './AttendeesPreview.js'; import { AuthenticationError } from './AuthenticationError.js'; import { AuthorizationError } from './AuthorizationError.js'; import { AuthorizationErrors } from './AuthorizationErrors.js'; import { BadRequestError } from './BadRequestError.js'; import { ChatMessage } from './ChatMessage.js'; import { CompaniesValue } from './CompaniesValue.js'; import { CompaniesValueUpdate } from './CompaniesValueUpdate.js'; import { Company } from './Company.js'; import { CompanyData } from './CompanyData.js'; import { CompanyDataPaged } from './CompanyDataPaged.js'; import { CompanyListEntry } from './CompanyListEntry.js'; import { CompanyMergeRequest } from './CompanyMergeRequest.js'; import { CompanyMergeResponse } from './CompanyMergeResponse.js'; import { CompanyMergeState } from './CompanyMergeState.js'; import { CompanyMergeStatePaged } from './CompanyMergeStatePaged.js'; import { CompanyMergeTask } from './CompanyMergeTask.js'; import { CompanyMergeTaskPaged } from './CompanyMergeTaskPaged.js'; import { CompanyMergeTaskResultsSummary } from './CompanyMergeTaskResultsSummary.js'; import { CompanyPaged } from './CompanyPaged.js'; import { CompanyReference } from './CompanyReference.js'; import { CompanyValue } from './CompanyValue.js'; import { CompanyValueUpdate } from './CompanyValueUpdate.js'; import { ConflictError } from './ConflictError.js'; import { DateValue } from './DateValue.js'; import { Dropdown } from './Dropdown.js'; import { DropdownReference } from './DropdownReference.js'; import { DropdownValue } from './DropdownValue.js'; import { DropdownValueUpdate } from './DropdownValueUpdate.js'; import { DropdownsValue } from './DropdownsValue.js'; import { DropdownsValueUpdate } from './DropdownsValueUpdate.js'; import { Email } from './Email.js'; import { Errors } from './Errors.js'; import { Field } from './Field.js'; import { FieldMetadata } from './FieldMetadata.js'; import { FieldMetadataPaged } from './FieldMetadataPaged.js'; import { FieldPaged } from './FieldPaged.js'; import { FieldUpdate } from './FieldUpdate.js'; import { FieldValueClass } from './FieldValue.js'; import { FieldValueUpdateClass } from './FieldValueUpdate.js'; import { FloatValue } from './FloatValue.js'; import { FloatsValue } from './FloatsValue.js'; import { FormulaNumber } from './FormulaNumber.js'; import { FormulaValue } from './FormulaValue.js'; import { Grant } from './Grant.js'; import { InteractionClass } from './Interaction.js'; import { InteractionValue } from './InteractionValue.js'; import { InteractionsCall } from './InteractionsCall.js'; import { InteractionsCallPaged } from './InteractionsCallPaged.js'; import { InteractionsChatMessage } from './InteractionsChatMessage.js'; import { InteractionsChatMessagePaged } from './InteractionsChatMessagePaged.js'; import { InteractionsEmail } from './InteractionsEmail.js'; import { InteractionsEmailPaged } from './InteractionsEmailPaged.js'; import { InteractionsMeeting } from './InteractionsMeeting.js'; import { InteractionsMeetingPaged } from './InteractionsMeetingPaged.js'; import { List } from './List.js'; import { ListEntry } from './ListEntry.js'; import { ListEntryBatchOperationResponse } from './ListEntryBatchOperationResponse.js'; import { ListEntryBatchOperationUpdateFields } from './ListEntryBatchOperationUpdateFields.js'; import { ListEntryBatchOperationUpdateFieldsUpdatesInner } from './ListEntryBatchOperationUpdateFieldsUpdatesInner.js'; import { ListEntryPaged } from './ListEntryPaged.js'; import { ListEntryWithEntityClass } from './ListEntryWithEntity.js'; import { ListEntryWithEntityPaged } from './ListEntryWithEntityPaged.js'; import { ListPaged } from './ListPaged.js'; import { ListWithType } from './ListWithType.js'; import { ListWithTypePaged } from './ListWithTypePaged.js'; import { Location } from './Location.js'; import { LocationValue } from './LocationValue.js'; import { LocationsValue } from './LocationsValue.js'; import { Meeting } from './Meeting.js'; import { MethodNotAllowedError } from './MethodNotAllowedError.js'; import { ModelErrorClass } from './ModelError.js'; import { NotAcceptableError } from './NotAcceptableError.js'; import { NotFoundError } from './NotFoundError.js'; import { NotFoundErrors } from './NotFoundErrors.js'; import { NotImplementedError } from './NotImplementedError.js'; import { NotesAiNotetakerReplyNote } from './NotesAiNotetakerReplyNote.js'; import { NotesAiNotetakerRootNote } from './NotesAiNotetakerRootNote.js'; import { NotesBaseNote } from './NotesBaseNote.js'; import { NotesBaseReply } from './NotesBaseReply.js'; import { NotesBaseReplyParent } from './NotesBaseReplyParent.js'; import { NotesBaseRootNote } from './NotesBaseRootNote.js'; import { NotesCallInteraction } from './NotesCallInteraction.js'; import { NotesChatMessageInteraction } from './NotesChatMessageInteraction.js'; import { NotesCompaniesPreview } from './NotesCompaniesPreview.js'; import { NotesContent } from './NotesContent.js'; import { NotesEmailInteraction } from './NotesEmailInteraction.js'; import { NotesEntitiesNote } from './NotesEntitiesNote.js'; import { NotesInteractionClass } from './NotesInteraction.js'; import { NotesInteractionNote } from './NotesInteractionNote.js'; import { NotesMeetingInteraction } from './NotesMeetingInteraction.js'; import { NotesNoteClass } from './NotesNote.js'; import { NotesNotesPaged } from './NotesNotesPaged.js'; import { NotesOpportunitiesPreview } from './NotesOpportunitiesPreview.js'; import { NotesPermissionSettings } from './NotesPermissionSettings.js'; import { NotesPersonMention } from './NotesPersonMention.js'; import { NotesPersonsPreview } from './NotesPersonsPreview.js'; import { NotesRepliesPaged } from './NotesRepliesPaged.js'; import { NotesReplyClass } from './NotesReply.js'; import { NotesUserReplyNote } from './NotesUserReplyNote.js'; import { Opportunity } from './Opportunity.js'; import { OpportunityListEntry } from './OpportunityListEntry.js'; import { OpportunityPaged } from './OpportunityPaged.js'; import { OpportunityWithFields } from './OpportunityWithFields.js'; import { Pagination } from './Pagination.js'; import { PaginationWithTotalCount } from './PaginationWithTotalCount.js'; import { Person } from './Person.js'; import { PersonData } from './PersonData.js'; import { PersonDataPaged } from './PersonDataPaged.js'; import { PersonDataPreview } from './PersonDataPreview.js'; import { PersonListEntry } from './PersonListEntry.js'; import { PersonMergeRequest } from './PersonMergeRequest.js'; import { PersonMergeResponse } from './PersonMergeResponse.js'; import { PersonMergeState } from './PersonMergeState.js'; import { PersonMergeStatePaged } from './PersonMergeStatePaged.js'; import { PersonMergeTask } from './PersonMergeTask.js'; import { PersonMergeTaskPaged } from './PersonMergeTaskPaged.js'; import { PersonPaged } from './PersonPaged.js'; import { PersonReference } from './PersonReference.js'; import { PersonValue } from './PersonValue.js'; import { PersonValueUpdate } from './PersonValueUpdate.js'; import { PersonsValue } from './PersonsValue.js'; import { PersonsValueUpdate } from './PersonsValueUpdate.js'; import { PhoneCall } from './PhoneCall.js'; import { RankedDropdown } from './RankedDropdown.js'; import { RankedDropdownReference } from './RankedDropdownReference.js'; import { RankedDropdownValue } from './RankedDropdownValue.js'; import { RankedDropdownValueUpdate } from './RankedDropdownValueUpdate.js'; import { RateLimitError } from './RateLimitError.js'; import { Responses400 } from './Responses400.js'; import { Responses400ErrorsInnerClass } from './Responses400ErrorsInner.js'; import { SavedView } from './SavedView.js'; import { SavedViewPaged } from './SavedViewPaged.js'; import { ServerError } from './ServerError.js'; import { Tenant } from './Tenant.js'; import { TextValue } from './TextValue.js'; import { TextsValue } from './TextsValue.js'; import { UnprocessableEntityError } from './UnprocessableEntityError.js'; import { UnsupportedMediaTypeError } from './UnsupportedMediaTypeError.js'; import { User } from './User.js'; import { ValidationError } from './ValidationError.js'; import { WhoAmI } from './WhoAmI.js'; /* tslint:disable:no-unused-variable */ let primitives = [ "string", "boolean", "double", "integer", "long", "float", "number", "any" ]; let enumsMap = new Set([ "AuthenticationErrorCodeEnum", "AuthorizationErrorCodeEnum", "BadRequestErrorCodeEnum", "ChatMessageTypeEnum", "ChatMessageDirectionEnum", "CompaniesValueTypeEnum", "CompaniesValueUpdateTypeEnum", "CompanyListEntryTypeEnum", "CompanyMergeStateStatusEnum", "CompanyMergeTaskStatusEnum", "CompanyValueTypeEnum", "CompanyValueUpdateTypeEnum", "ConflictErrorCodeEnum", "DateValueTypeEnum", "DropdownValueTypeEnum", "DropdownValueUpdateTypeEnum", "DropdownsValueTypeEnum", "DropdownsValueUpdateTypeEnum", "EmailTypeEnum", "FieldTypeEnum", "FieldEnrichmentSourceEnum", "FieldMetadataTypeEnum", "FieldMetadataEnrichmentSourceEnum", "FieldMetadataValueTypeEnum", "FieldValueTypeEnum", "FieldValueUpdateTypeEnum", "FloatValueTypeEnum", "FloatsValueTypeEnum", "FormulaValueTypeEnum", "GrantTypeEnum", "InteractionTypeEnum", "InteractionDirectionEnum", "InteractionValueTypeEnum", "InteractionsCallLoggingTypeEnum", "InteractionsChatMessageLoggingTypeEnum", "InteractionsChatMessageDirectionEnum", "InteractionsEmailLoggingTypeEnum", "InteractionsEmailDirectionEnum", "InteractionsMeetingLoggingTypeEnum", "ListEntryBatchOperationUpdateFieldsOperationEnum", "ListEntryBatchOperations", "ListEntryWithEntityTypeEnum", "ListWithTypeTypeEnum", "LocationValueTypeEnum", "LocationsValueTypeEnum", "MeetingTypeEnum", "MethodNotAllowedErrorCodeEnum", "ModelErrorCodeEnum", "NotAcceptableErrorCodeEnum", "NotFoundErrorCodeEnum", "NotImplementedErrorCodeEnum", "NotesAiNotetakerReplyNoteTypeEnum", "NotesAiNotetakerRootNoteTypeEnum", "NotesCallInteractionTypeEnum", "NotesChatMessageInteractionTypeEnum", "NotesEmailInteractionTypeEnum", "NotesEntitiesNoteTypeEnum", "NotesInteractionTypeEnum", "NotesInteractionNoteTypeEnum", "NotesMeetingInteractionTypeEnum", "NotesNoteTypeEnum", "NotesPermissionSettingsSharingTypeEnum", "NotesPersonMentionTypeEnum", "NotesReplyTypeEnum", "NotesUserReplyNoteTypeEnum", "OpportunityListEntryTypeEnum", "PersonTypeEnum", "PersonDataTypeEnum", "PersonListEntryTypeEnum", "PersonMergeStateStatusEnum", "PersonMergeTaskStatusEnum", "PersonValueTypeEnum", "PersonValueUpdateTypeEnum", "PersonsValueTypeEnum", "PersonsValueUpdateTypeEnum", "PhoneCallTypeEnum", "RankedDropdownValueTypeEnum", "RankedDropdownValueUpdateTypeEnum", "RateLimitErrorCodeEnum", "Responses400ErrorsInnerCodeEnum", "SavedViewTypeEnum", "ServerErrorCodeEnum", "TextValueTypeEnum", "TextsValueTypeEnum", "UnprocessableEntityErrorCodeEnum", "UnsupportedMediaTypeErrorCodeEnum", "ValidationErrorCodeEnum", ]); let typeMap = { "Attendee": Attendee, "AttendeesPreview": AttendeesPreview, "AuthenticationError": AuthenticationError, "AuthorizationError": AuthorizationError, "AuthorizationErrors": AuthorizationErrors, "BadRequestError": BadRequestError, "ChatMessage": ChatMessage, "CompaniesValue": CompaniesValue, "CompaniesValueUpdate": CompaniesValueUpdate, "Company": Company, "CompanyData": CompanyData, "CompanyDataPaged": CompanyDataPaged, "CompanyListEntry": CompanyListEntry, "CompanyMergeRequest": CompanyMergeRequest, "CompanyMergeResponse": CompanyMergeResponse, "CompanyMergeState": CompanyMergeState, "CompanyMergeStatePaged": CompanyMergeStatePaged, "CompanyMergeTask": CompanyMergeTask, "CompanyMergeTaskPaged": CompanyMergeTaskPaged, "CompanyMergeTaskResultsSummary": CompanyMergeTaskResultsSummary, "CompanyPaged": CompanyPaged, "CompanyReference": CompanyReference, "CompanyValue": CompanyValue, "CompanyValueUpdate": CompanyValueUpdate, "ConflictError": ConflictError, "DateValue": DateValue, "Dropdown": Dropdown, "DropdownReference": DropdownReference, "DropdownValue": DropdownValue, "DropdownValueUpdate": DropdownValueUpdate, "DropdownsValue": DropdownsValue, "DropdownsValueUpdate": DropdownsValueUpdate, "Email": Email, "Errors": Errors, "Field": Field, "FieldMetadata": FieldMetadata, "FieldMetadataPaged": FieldMetadataPaged, "FieldPaged": FieldPaged, "FieldUpdate": FieldUpdate, "FieldValue": FieldValueClass, "FieldValueUpdate": FieldValueUpdateClass, "FloatValue": FloatValue, "FloatsValue": FloatsValue, "FormulaNumber": FormulaNumber, "FormulaValue": FormulaValue, "Grant": Grant, "Interaction": InteractionClass, "InteractionValue": InteractionValue, "InteractionsCall": InteractionsCall, "InteractionsCallPaged": InteractionsCallPaged, "InteractionsChatMessage": InteractionsChatMessage, "InteractionsChatMessagePaged": InteractionsChatMessagePaged, "InteractionsEmail": InteractionsEmail, "InteractionsEmailPaged": InteractionsEmailPaged, "InteractionsMeeting": InteractionsMeeting, "InteractionsMeetingPaged": InteractionsMeetingPaged, "List": List, "ListEntry": ListEntry, "ListEntryBatchOperationResponse": ListEntryBatchOperationResponse, "ListEntryBatchOperationUpdateFields": ListEntryBatchOperationUpdateFields, "ListEntryBatchOperationUpdateFieldsUpdatesInner": ListEntryBatchOperationUpdateFieldsUpdatesInner, "ListEntryPaged": ListEntryPaged, "ListEntryWithEntity": ListEntryWithEntityClass, "ListEntryWithEntityPaged": ListEntryWithEntityPaged, "ListPaged": ListPaged, "ListWithType": ListWithType, "ListWithTypePaged": ListWithTypePaged, "Location": Location, "LocationValue": LocationValue, "LocationsValue": LocationsValue, "Meeting": Meeting, "MethodNotAllowedError": MethodNotAllowedError, "ModelError": ModelErrorClass, "NotAcceptableError": NotAcceptableError, "NotFoundError": NotFoundError, "NotFoundErrors": NotFoundErrors, "NotImplementedError": NotImplementedError, "NotesAiNotetakerReplyNote": NotesAiNotetakerReplyNote, "NotesAiNotetakerRootNote": NotesAiNotetakerRootNote, "NotesBaseNote": NotesBaseNote, "NotesBaseReply": NotesBaseReply, "NotesBaseReplyParent": NotesBaseReplyParent, "NotesBaseRootNote": NotesBaseRootNote, "NotesCallInteraction": NotesCallInteraction, "NotesChatMessageInteraction": NotesChatMessageInteraction, "NotesCompaniesPreview": NotesCompaniesPreview, "NotesContent": NotesContent, "NotesEmailInteraction": NotesEmailInteraction, "NotesEntitiesNote": NotesEntitiesNote, "NotesInteraction": NotesInteractionClass, "NotesInteractionNote": NotesInteractionNote, "NotesMeetingInteraction": NotesMeetingInteraction, "NotesNote": NotesNoteClass, "NotesNotesPaged": NotesNotesPaged, "NotesOpportunitiesPreview": NotesOpportunitiesPreview, "NotesPermissionSettings": NotesPermissionSettings, "NotesPersonMention": NotesPersonMention, "NotesPersonsPreview": NotesPersonsPreview, "NotesRepliesPaged": NotesRepliesPaged, "NotesReply": NotesReplyClass, "NotesUserReplyNote": NotesUserReplyNote, "Opportunity": Opportunity, "OpportunityListEntry": OpportunityListEntry, "OpportunityPaged": OpportunityPaged, "OpportunityWithFields": OpportunityWithFields, "Pagination": Pagination, "PaginationWithTotalCount": PaginationWithTotalCount, "Person": Person, "PersonData": PersonData, "PersonDataPaged": PersonDataPaged, "PersonDataPreview": PersonDataPreview, "PersonListEntry": PersonListEntry, "PersonMergeRequest": PersonMergeRequest, "PersonMergeResponse": PersonMergeResponse, "PersonMergeState": PersonMergeState, "PersonMergeStatePaged": PersonMergeStatePaged, "PersonMergeTask": PersonMergeTask, "PersonMergeTaskPaged": PersonMergeTaskPaged, "PersonPaged": PersonPaged, "PersonReference": PersonReference, "PersonValue": PersonValue, "PersonValueUpdate": PersonValueUpdate, "PersonsValue": PersonsValue, "PersonsValueUpdate": PersonsValueUpdate, "PhoneCall": PhoneCall, "RankedDropdown": RankedDropdown, "RankedDropdownReference": RankedDropdownReference, "RankedDropdownValue": RankedDropdownValue, "RankedDropdownValueUpdate": RankedDropdownValueUpdate, "RateLimitError": RateLimitError, "Responses400": Responses400, "Responses400ErrorsInner": Responses400ErrorsInnerClass, "SavedView": SavedView, "SavedViewPaged": SavedViewPaged, "ServerError": ServerError, "Tenant": Tenant, "TextValue": TextValue, "TextsValue": TextsValue, "UnprocessableEntityError": UnprocessableEntityError, "UnsupportedMediaTypeError": UnsupportedMediaTypeError, "User": User, "ValidationError": ValidationError, "WhoAmI": WhoAmI, }; /** * Every mime-type consists of a type, subtype, and optional parameters. * The subtype can be composite, including information about the content format. * For example: `application/json-patch+json`, `application/merge-patch+json`. * * This helper transforms a string mime-type into an internal representation. * This simplifies the implementation of predicates that in turn define common rules for parsing or stringifying * the payload. */ const parseMimeType = (mimeType) => { const [type = '', subtype = ''] = mimeType.split('/'); return { type, subtype, subtypeTokens: subtype.split('+'), }; }; // This factory creates a predicate function that checks a string mime-type against defined rules. const mimeTypePredicateFactory = (predicate) => (mimeType) => predicate(parseMimeType(mimeType)); // Use this factory when you need to define a simple predicate based only on type and, if applicable, subtype. const mimeTypeSimplePredicateFactory = (type, subtype) => mimeTypePredicateFactory((descriptor) => { if (descriptor.type !== type) return false; if (subtype != null && descriptor.subtype !== subtype) return false; return true; }); // Creating a set of named predicates that will help us determine how to handle different mime-types const isTextLikeMimeType = mimeTypeSimplePredicateFactory('text'); const isJsonMimeType = mimeTypeSimplePredicateFactory('application', 'json'); const isJsonLikeMimeType = mimeTypePredicateFactory((descriptor) => descriptor.type === 'application' && descriptor.subtypeTokens.some((item) => item === 'json')); const isOctetStreamMimeType = mimeTypeSimplePredicateFactory('application', 'octet-stream'); const isFormUrlencodedMimeType = mimeTypeSimplePredicateFactory('application', 'x-www-form-urlencoded'); // Defining a list of mime-types in the order of prioritization for handling. const supportedMimeTypePredicatesWithPriority = [ isJsonMimeType, isJsonLikeMimeType, isTextLikeMimeType, isOctetStreamMimeType, isFormUrlencodedMimeType, ]; const nullableSuffix = " | null"; const optionalSuffix = " | undefined"; const arrayPrefix = "Array<"; const arraySuffix = ">"; const mapPrefix = "{ [key: string]: "; const mapSuffix = "; }"; export class ObjectSerializer { static findCorrectType(data, expectedType) { if (data == undefined) { return expectedType; } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { return expectedType; } else if (expectedType === "Date") { return expectedType; } else { if (enumsMap.has(expectedType)) { return expectedType; } if (!typeMap[expectedType]) { return expectedType; // w/e we don't know the type } // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; let mapping = typeMap[expectedType].mapping; if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator } else if (typeMap[discriminatorType]) { return discriminatorType; } else { return expectedType; // discriminator did not map to a type } } else { return expectedType; // discriminator was not present (or an empty string) } } } } static serialize(data, type, format) { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; } else if (type.endsWith(nullableSuffix)) { let subType = type.slice(0, -nullableSuffix.length); // Type | null => Type return ObjectSerializer.serialize(data, subType, format); } else if (type.endsWith(optionalSuffix)) { let subType = type.slice(0, -optionalSuffix.length); // Type | undefined => Type return ObjectSerializer.serialize(data, subType, format); } else if (type.startsWith(arrayPrefix)) { let subType = type.slice(arrayPrefix.length, -arraySuffix.length); // Array<Type> => Type let transformedData = []; for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; } else if (type.startsWith(mapPrefix)) { let subType = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type let transformedData = {}; for (let key in data) { transformedData[key] = ObjectSerializer.serialize(data[key], subType, format); } return transformedData; } else if (type === "Date") { if (!(data instanceof Date)) { return data; } if (format == "date") { let month = data.getMonth() + 1; let monthStr = month < 10 ? "0" + month.toString() : month.toString(); let day = data.getDate(); let dayStr = day < 10 ? "0" + day.toString() : day.toString(); return data.getFullYear() + "-" + monthStr + "-" + dayStr; } else { return data.toISOString(); } } else { if (enumsMap.has(type)) { return data; } if (!typeMap[type]) { // in case we dont know the type return data; } // Get the actual type of this object type = this.findCorrectType(data, type); // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance = {}; for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; } } static deserialize(data, type, format) { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; } else if (type.endsWith(nullableSuffix)) { let subType = type.slice(0, -nullableSuffix.length); // Type | null => Type return ObjectSerializer.deserialize(data, subType, format); } else if (type.endsWith(optionalSuffix)) { let subType = type.slice(0, -optionalSuffix.length); // Type | undefined => Type return ObjectSerializer.deserialize(data, subType, format); } else if (type.startsWith(arrayPrefix)) { let subType = type.slice(arrayPrefix.length, -arraySuffix.length); // Array<Type> => Type let transformedData = []; for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; } else if (type.startsWith(mapPrefix)) { let subType = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type let transformedData = {}; for (let key in data) { transformedData[key] = ObjectSerializer.deserialize(data[key], subType, format); } return transformedData; } else if (type === "Date") { return new Date(data); } else { if (enumsMap.has(type)) { // is Enum return data; } if (!typeMap[type]) { // dont know the type return data; } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; } } return instance; } } /** * Normalize media type * * We currently do not handle any media types attributes, i.e. anything * after a semicolon. All content is assumed to be UTF-8 compatible. */ static normalizeMediaType(mediaType) { if (mediaType === undefined) { return undefined; } return (mediaType.split(";")[0] ?? '').trim().toLowerCase(); } /** * From a list of possible media types, choose the one we can handle best. * * The order of the given media types does not have any impact on the choice * made. */ static getPreferredMediaType(mediaTypes) { /** According to OAS 3 we should default to json */ if (mediaTypes.length === 0) { return "application/json"; } const normalMediaTypes = mediaTypes.map(ObjectSerializer.normalizeMediaType); for (const predicate of supportedMimeTypePredicatesWithPriority) { for (const mediaType of normalMediaTypes) { if (mediaType != null && predicate(mediaType)) { return mediaType; } } } throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); } /** * Convert data to a string according the given media type */ static stringify(data, mediaType) { if (isTextLikeMimeType(mediaType)) { return String(data); } if (isJsonLikeMimeType(mediaType)) { return JSON.stringify(data); } throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); } /** * Parse data from a string according to the given media type */ static parse(rawData, mediaType) { if (mediaType === undefined) { throw new Error("Cannot parse content. No Content-Type defined."); } if (isTextLikeMimeType(mediaType)) { return rawData; } if (isJsonLikeMimeType(mediaType)) { return JSON.parse(rawData); } throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); } }