From 339477c9f963cfec0aff935cabe9649033eacd23 Mon Sep 17 00:00:00 2001 From: Giles Roadnight <10414642+Roaders@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:10:47 +0000 Subject: [PATCH] Modify generate-type-predicates to only include interfaces that have the correct type --- .../generate-type-predicates.ts | 75 +- .../fdc3-schema/generated/api/BrowserTypes.ts | 978 ++++++++++++++++++ 2 files changed, 1044 insertions(+), 9 deletions(-) diff --git a/packages/fdc3-schema/code-generation/generate-type-predicates.ts b/packages/fdc3-schema/code-generation/generate-type-predicates.ts index 1ed5801a4..4be88346a 100644 --- a/packages/fdc3-schema/code-generation/generate-type-predicates.ts +++ b/packages/fdc3-schema/code-generation/generate-type-predicates.ts @@ -33,9 +33,47 @@ matchedInterfaces.forEach(matched => { writeTypeConstant(matched.matchingInterface) }); -writeUnionType("RequestMessage", interfaces, "Request"); -writeUnionType("ResponseMessage", interfaces, "Response"); -writeUnionType("EventMessage", interfaces, "Event"); +const typeAliases = sourceFile.getChildrenOfKind(SyntaxKind.TypeAliasDeclaration); + +/** + * Looks for a string union type in the form: + * export type NAME = "stringOne" | "stringTwo" | "stringThree"; + * and returns the string values + * if the union type is not found returns undefined + * @param name + * @returns + */ +function findUnionType(name: string): string[] | undefined { + const typeAlias = typeAliases.find(alias => { + const identifiers = alias.getChildrenOfKind(SyntaxKind.Identifier); + + return identifiers[0].getText() === name; + + }); + + return typeAlias?.getChildrenOfKind(SyntaxKind.UnionType)?.[0] + .getDescendantsOfKind(SyntaxKind.StringLiteral) + .map(literal => literal.getLiteralText()); +} + +// get the types listed in the types union type +// i.e. look for: export type RequestMessageType = "addContextListenerRequest" | "whatever" +const requestMessageUnion = findUnionType("RequestMessageType"); +if(requestMessageUnion != null){ + // Write a union type of all interfaces that have a type that extends RequestMessageType + writeUnionType("RequestMessage", interfaces, requestMessageUnion); +} + +const responseMessageUnion = findUnionType("ResponseMessageType"); +if(responseMessageUnion != null){ + writeUnionType("ResponseMessage", interfaces, responseMessageUnion); +} + +const eventMessageUnion = findUnionType("EventMessageType"); +if(eventMessageUnion != null){ + writeUnionType("EventMessage", interfaces, eventMessageUnion); +} + function writePredicate(matchingInterface: InterfaceDeclaration, func: MethodDeclaration): void { const predicateName = `is${matchingInterface.getName()}`; @@ -59,14 +97,33 @@ function writeTypeConstant(matchingInterface: InterfaceDeclaration): void { } - -function writeUnionType(unionName: string, interfaces: InterfaceDeclaration[], nameEndsWith: string): void { - const matchingInterfaces = interfaces - .map(currentInterface => currentInterface.getName()) - .filter(interfaceName => interfaceName.length > nameEndsWith.length && interfaceName.indexOf(nameEndsWith) === interfaceName.length - nameEndsWith.length); +/** + * Writes a union type of all the interfaces that have a type property that extends the type values passed in. + * For example: + * export type RequestMessage = AddContextListenerRequest | AddEventListenerRequest ... + * @param unionName + * @param interfaces + * @param typeValues + */ +function writeUnionType(unionName: string, interfaces: InterfaceDeclaration[], typeValues: string[]): void { + // look for interfaces that have a type property that extends one of the values in typeValues + const matchingInterfaces = interfaces.filter(currentInterface => { + const typeProperty = currentInterface.getChildrenOfKind(SyntaxKind.PropertySignature).filter(propertySignature => { + return propertySignature.getChildrenOfKind(SyntaxKind.Identifier).find(identifier => identifier.getText() === "type") != null; + })[0]; + + if(typeProperty == null){ + return false; + } + + const stringLiterals = typeProperty.getDescendantsOfKind(SyntaxKind.StringLiteral) + .map(literal => literal.getLiteralText()); + + return stringLiterals.some(literal => typeValues.some(typeValue => typeValue === literal)); + }) sourceFile.addStatements(` - export type ${unionName} = ${matchingInterfaces.join(" | ")}; `); + export type ${unionName} = ${matchingInterfaces.map(match => match.getName()).join(" | ")}; `); } sourceFile.formatText(); diff --git a/packages/fdc3-schema/generated/api/BrowserTypes.ts b/packages/fdc3-schema/generated/api/BrowserTypes.ts index a924b0bdf..9e017b15b 100644 --- a/packages/fdc3-schema/generated/api/BrowserTypes.ts +++ b/packages/fdc3-schema/generated/api/BrowserTypes.ts @@ -6755,6 +6755,984 @@ export type ResponseMessage = WebConnectionProtocol5ValidateAppIdentityFailedRes export type EventMessage = BroadcastEvent | ChannelChangedEvent | HeartbeatEvent | IntentEvent | PrivateChannelOnAddContextListenerEvent | PrivateChannelOnDisconnectEvent | PrivateChannelOnUnsubscribeEvent; +export function isWebConnectionProtocol1Hello(value: any): value is WebConnectionProtocol1Hello { + try { + Convert.webConnectionProtocol1HelloToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL1_HELLO_TYPE = "WebConnectionProtocol1Hello"; + +export function isWebConnectionProtocol2LoadURL(value: any): value is WebConnectionProtocol2LoadURL { + try { + Convert.webConnectionProtocol2LoadURLToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL2_LOAD_U_R_L_TYPE = "WebConnectionProtocol2LoadURL"; + +export function isWebConnectionProtocol3Handshake(value: any): value is WebConnectionProtocol3Handshake { + try { + Convert.webConnectionProtocol3HandshakeToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL3_HANDSHAKE_TYPE = "WebConnectionProtocol3Handshake"; + +export function isWebConnectionProtocol4ValidateAppIdentity(value: any): value is WebConnectionProtocol4ValidateAppIdentity { + try { + Convert.webConnectionProtocol4ValidateAppIdentityToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL4_VALIDATE_APP_IDENTITY_TYPE = "WebConnectionProtocol4ValidateAppIdentity"; + +export function isWebConnectionProtocol5ValidateAppIdentityFailedResponse(value: any): value is WebConnectionProtocol5ValidateAppIdentityFailedResponse { + try { + Convert.webConnectionProtocol5ValidateAppIdentityFailedResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL5_VALIDATE_APP_IDENTITY_FAILED_RESPONSE_TYPE = "WebConnectionProtocol5ValidateAppIdentityFailedResponse"; + +export function isWebConnectionProtocol5ValidateAppIdentitySuccessResponse(value: any): value is WebConnectionProtocol5ValidateAppIdentitySuccessResponse { + try { + Convert.webConnectionProtocol5ValidateAppIdentitySuccessResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL5_VALIDATE_APP_IDENTITY_SUCCESS_RESPONSE_TYPE = "WebConnectionProtocol5ValidateAppIdentitySuccessResponse"; + +export function isWebConnectionProtocol6Goodbye(value: any): value is WebConnectionProtocol6Goodbye { + try { + Convert.webConnectionProtocol6GoodbyeToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL6_GOODBYE_TYPE = "WebConnectionProtocol6Goodbye"; + +export function isWebConnectionProtocolMessage(value: any): value is WebConnectionProtocolMessage { + try { + Convert.webConnectionProtocolMessageToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const WEB_CONNECTION_PROTOCOL_MESSAGE_TYPE = "WebConnectionProtocolMessage"; + +export function isAddContextListenerRequest(value: any): value is AddContextListenerRequest { + try { + Convert.addContextListenerRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const ADD_CONTEXT_LISTENER_REQUEST_TYPE = "AddContextListenerRequest"; + +export function isAddContextListenerResponse(value: any): value is AddContextListenerResponse { + try { + Convert.addContextListenerResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const ADD_CONTEXT_LISTENER_RESPONSE_TYPE = "AddContextListenerResponse"; + +export function isAddEventListenerRequest(value: any): value is AddEventListenerRequest { + try { + Convert.addEventListenerRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const ADD_EVENT_LISTENER_REQUEST_TYPE = "AddEventListenerRequest"; + +export function isAddEventListenerResponse(value: any): value is AddEventListenerResponse { + try { + Convert.addEventListenerResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const ADD_EVENT_LISTENER_RESPONSE_TYPE = "AddEventListenerResponse"; + +export function isAddIntentListenerRequest(value: any): value is AddIntentListenerRequest { + try { + Convert.addIntentListenerRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const ADD_INTENT_LISTENER_REQUEST_TYPE = "AddIntentListenerRequest"; + +export function isAddIntentListenerResponse(value: any): value is AddIntentListenerResponse { + try { + Convert.addIntentListenerResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const ADD_INTENT_LISTENER_RESPONSE_TYPE = "AddIntentListenerResponse"; + +export function isAgentEventMessage(value: any): value is AgentEventMessage { + try { + Convert.agentEventMessageToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const AGENT_EVENT_MESSAGE_TYPE = "AgentEventMessage"; + +export function isAgentResponseMessage(value: any): value is AgentResponseMessage { + try { + Convert.agentResponseMessageToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const AGENT_RESPONSE_MESSAGE_TYPE = "AgentResponseMessage"; + +export function isAppRequestMessage(value: any): value is AppRequestMessage { + try { + Convert.appRequestMessageToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const APP_REQUEST_MESSAGE_TYPE = "AppRequestMessage"; + +export function isBroadcastEvent(value: any): value is BroadcastEvent { + try { + Convert.broadcastEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const BROADCAST_EVENT_TYPE = "BroadcastEvent"; + +export function isBroadcastRequest(value: any): value is BroadcastRequest { + try { + Convert.broadcastRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const BROADCAST_REQUEST_TYPE = "BroadcastRequest"; + +export function isBroadcastResponse(value: any): value is BroadcastResponse { + try { + Convert.broadcastResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const BROADCAST_RESPONSE_TYPE = "BroadcastResponse"; + +export function isChannelChangedEvent(value: any): value is ChannelChangedEvent { + try { + Convert.channelChangedEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const CHANNEL_CHANGED_EVENT_TYPE = "ChannelChangedEvent"; + +export function isContextListenerUnsubscribeRequest(value: any): value is ContextListenerUnsubscribeRequest { + try { + Convert.contextListenerUnsubscribeRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const CONTEXT_LISTENER_UNSUBSCRIBE_REQUEST_TYPE = "ContextListenerUnsubscribeRequest"; + +export function isContextListenerUnsubscribeResponse(value: any): value is ContextListenerUnsubscribeResponse { + try { + Convert.contextListenerUnsubscribeResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const CONTEXT_LISTENER_UNSUBSCRIBE_RESPONSE_TYPE = "ContextListenerUnsubscribeResponse"; + +export function isCreatePrivateChannelRequest(value: any): value is CreatePrivateChannelRequest { + try { + Convert.createPrivateChannelRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const CREATE_PRIVATE_CHANNEL_REQUEST_TYPE = "CreatePrivateChannelRequest"; + +export function isCreatePrivateChannelResponse(value: any): value is CreatePrivateChannelResponse { + try { + Convert.createPrivateChannelResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const CREATE_PRIVATE_CHANNEL_RESPONSE_TYPE = "CreatePrivateChannelResponse"; + +export function isEventListenerUnsubscribeRequest(value: any): value is EventListenerUnsubscribeRequest { + try { + Convert.eventListenerUnsubscribeRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const EVENT_LISTENER_UNSUBSCRIBE_REQUEST_TYPE = "EventListenerUnsubscribeRequest"; + +export function isEventListenerUnsubscribeResponse(value: any): value is EventListenerUnsubscribeResponse { + try { + Convert.eventListenerUnsubscribeResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const EVENT_LISTENER_UNSUBSCRIBE_RESPONSE_TYPE = "EventListenerUnsubscribeResponse"; + +export function isFdc3UserInterfaceChannelSelected(value: any): value is Fdc3UserInterfaceChannelSelected { + try { + Convert.fdc3UserInterfaceChannelSelectedToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_CHANNEL_SELECTED_TYPE = "Fdc3UserInterfaceChannelSelected"; + +export function isFdc3UserInterfaceChannels(value: any): value is Fdc3UserInterfaceChannels { + try { + Convert.fdc3UserInterfaceChannelsToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_CHANNELS_TYPE = "Fdc3UserInterfaceChannels"; + +export function isFdc3UserInterfaceDrag(value: any): value is Fdc3UserInterfaceDrag { + try { + Convert.fdc3UserInterfaceDragToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_DRAG_TYPE = "Fdc3UserInterfaceDrag"; + +export function isFdc3UserInterfaceHandshake(value: any): value is Fdc3UserInterfaceHandshake { + try { + Convert.fdc3UserInterfaceHandshakeToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_HANDSHAKE_TYPE = "Fdc3UserInterfaceHandshake"; + +export function isFdc3UserInterfaceHello(value: any): value is Fdc3UserInterfaceHello { + try { + Convert.fdc3UserInterfaceHelloToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_HELLO_TYPE = "Fdc3UserInterfaceHello"; + +export function isFdc3UserInterfaceMessage(value: any): value is Fdc3UserInterfaceMessage { + try { + Convert.fdc3UserInterfaceMessageToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_MESSAGE_TYPE = "Fdc3UserInterfaceMessage"; + +export function isFdc3UserInterfaceResolve(value: any): value is Fdc3UserInterfaceResolve { + try { + Convert.fdc3UserInterfaceResolveToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_RESOLVE_TYPE = "Fdc3UserInterfaceResolve"; + +export function isFdc3UserInterfaceResolveAction(value: any): value is Fdc3UserInterfaceResolveAction { + try { + Convert.fdc3UserInterfaceResolveActionToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_RESOLVE_ACTION_TYPE = "Fdc3UserInterfaceResolveAction"; + +export function isFdc3UserInterfaceRestyle(value: any): value is Fdc3UserInterfaceRestyle { + try { + Convert.fdc3UserInterfaceRestyleToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FDC3_USER_INTERFACE_RESTYLE_TYPE = "Fdc3UserInterfaceRestyle"; + +export function isFindInstancesRequest(value: any): value is FindInstancesRequest { + try { + Convert.findInstancesRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FIND_INSTANCES_REQUEST_TYPE = "FindInstancesRequest"; + +export function isFindInstancesResponse(value: any): value is FindInstancesResponse { + try { + Convert.findInstancesResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FIND_INSTANCES_RESPONSE_TYPE = "FindInstancesResponse"; + +export function isFindIntentRequest(value: any): value is FindIntentRequest { + try { + Convert.findIntentRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FIND_INTENT_REQUEST_TYPE = "FindIntentRequest"; + +export function isFindIntentResponse(value: any): value is FindIntentResponse { + try { + Convert.findIntentResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FIND_INTENT_RESPONSE_TYPE = "FindIntentResponse"; + +export function isFindIntentsByContextRequest(value: any): value is FindIntentsByContextRequest { + try { + Convert.findIntentsByContextRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FIND_INTENTS_BY_CONTEXT_REQUEST_TYPE = "FindIntentsByContextRequest"; + +export function isFindIntentsByContextResponse(value: any): value is FindIntentsByContextResponse { + try { + Convert.findIntentsByContextResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const FIND_INTENTS_BY_CONTEXT_RESPONSE_TYPE = "FindIntentsByContextResponse"; + +export function isGetAppMetadataRequest(value: any): value is GetAppMetadataRequest { + try { + Convert.getAppMetadataRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_APP_METADATA_REQUEST_TYPE = "GetAppMetadataRequest"; + +export function isGetAppMetadataResponse(value: any): value is GetAppMetadataResponse { + try { + Convert.getAppMetadataResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_APP_METADATA_RESPONSE_TYPE = "GetAppMetadataResponse"; + +export function isGetCurrentChannelRequest(value: any): value is GetCurrentChannelRequest { + try { + Convert.getCurrentChannelRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_CURRENT_CHANNEL_REQUEST_TYPE = "GetCurrentChannelRequest"; + +export function isGetCurrentChannelResponse(value: any): value is GetCurrentChannelResponse { + try { + Convert.getCurrentChannelResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_CURRENT_CHANNEL_RESPONSE_TYPE = "GetCurrentChannelResponse"; + +export function isGetCurrentContextRequest(value: any): value is GetCurrentContextRequest { + try { + Convert.getCurrentContextRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_CURRENT_CONTEXT_REQUEST_TYPE = "GetCurrentContextRequest"; + +export function isGetCurrentContextResponse(value: any): value is GetCurrentContextResponse { + try { + Convert.getCurrentContextResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_CURRENT_CONTEXT_RESPONSE_TYPE = "GetCurrentContextResponse"; + +export function isGetInfoRequest(value: any): value is GetInfoRequest { + try { + Convert.getInfoRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_INFO_REQUEST_TYPE = "GetInfoRequest"; + +export function isGetInfoResponse(value: any): value is GetInfoResponse { + try { + Convert.getInfoResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_INFO_RESPONSE_TYPE = "GetInfoResponse"; + +export function isGetOrCreateChannelRequest(value: any): value is GetOrCreateChannelRequest { + try { + Convert.getOrCreateChannelRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_OR_CREATE_CHANNEL_REQUEST_TYPE = "GetOrCreateChannelRequest"; + +export function isGetOrCreateChannelResponse(value: any): value is GetOrCreateChannelResponse { + try { + Convert.getOrCreateChannelResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_OR_CREATE_CHANNEL_RESPONSE_TYPE = "GetOrCreateChannelResponse"; + +export function isGetUserChannelsRequest(value: any): value is GetUserChannelsRequest { + try { + Convert.getUserChannelsRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_USER_CHANNELS_REQUEST_TYPE = "GetUserChannelsRequest"; + +export function isGetUserChannelsResponse(value: any): value is GetUserChannelsResponse { + try { + Convert.getUserChannelsResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const GET_USER_CHANNELS_RESPONSE_TYPE = "GetUserChannelsResponse"; + +export function isHeartbeatAcknowledgementRequest(value: any): value is HeartbeatAcknowledgementRequest { + try { + Convert.heartbeatAcknowledgementRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const HEARTBEAT_ACKNOWLEDGEMENT_REQUEST_TYPE = "HeartbeatAcknowledgementRequest"; + +export function isHeartbeatEvent(value: any): value is HeartbeatEvent { + try { + Convert.heartbeatEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const HEARTBEAT_EVENT_TYPE = "HeartbeatEvent"; + +export function isIntentEvent(value: any): value is IntentEvent { + try { + Convert.intentEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const INTENT_EVENT_TYPE = "IntentEvent"; + +export function isIntentListenerUnsubscribeRequest(value: any): value is IntentListenerUnsubscribeRequest { + try { + Convert.intentListenerUnsubscribeRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const INTENT_LISTENER_UNSUBSCRIBE_REQUEST_TYPE = "IntentListenerUnsubscribeRequest"; + +export function isIntentListenerUnsubscribeResponse(value: any): value is IntentListenerUnsubscribeResponse { + try { + Convert.intentListenerUnsubscribeResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const INTENT_LISTENER_UNSUBSCRIBE_RESPONSE_TYPE = "IntentListenerUnsubscribeResponse"; + +export function isIntentResultRequest(value: any): value is IntentResultRequest { + try { + Convert.intentResultRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const INTENT_RESULT_REQUEST_TYPE = "IntentResultRequest"; + +export function isIntentResultResponse(value: any): value is IntentResultResponse { + try { + Convert.intentResultResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const INTENT_RESULT_RESPONSE_TYPE = "IntentResultResponse"; + +export function isJoinUserChannelRequest(value: any): value is JoinUserChannelRequest { + try { + Convert.joinUserChannelRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const JOIN_USER_CHANNEL_REQUEST_TYPE = "JoinUserChannelRequest"; + +export function isJoinUserChannelResponse(value: any): value is JoinUserChannelResponse { + try { + Convert.joinUserChannelResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const JOIN_USER_CHANNEL_RESPONSE_TYPE = "JoinUserChannelResponse"; + +export function isLeaveCurrentChannelRequest(value: any): value is LeaveCurrentChannelRequest { + try { + Convert.leaveCurrentChannelRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const LEAVE_CURRENT_CHANNEL_REQUEST_TYPE = "LeaveCurrentChannelRequest"; + +export function isLeaveCurrentChannelResponse(value: any): value is LeaveCurrentChannelResponse { + try { + Convert.leaveCurrentChannelResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const LEAVE_CURRENT_CHANNEL_RESPONSE_TYPE = "LeaveCurrentChannelResponse"; + +export function isOpenRequest(value: any): value is OpenRequest { + try { + Convert.openRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const OPEN_REQUEST_TYPE = "OpenRequest"; + +export function isOpenResponse(value: any): value is OpenResponse { + try { + Convert.openResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const OPEN_RESPONSE_TYPE = "OpenResponse"; + +export function isPrivateChannelAddEventListenerRequest(value: any): value is PrivateChannelAddEventListenerRequest { + try { + Convert.privateChannelAddEventListenerRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_ADD_EVENT_LISTENER_REQUEST_TYPE = "PrivateChannelAddEventListenerRequest"; + +export function isPrivateChannelAddEventListenerResponse(value: any): value is PrivateChannelAddEventListenerResponse { + try { + Convert.privateChannelAddEventListenerResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_ADD_EVENT_LISTENER_RESPONSE_TYPE = "PrivateChannelAddEventListenerResponse"; + +export function isPrivateChannelDisconnectRequest(value: any): value is PrivateChannelDisconnectRequest { + try { + Convert.privateChannelDisconnectRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_DISCONNECT_REQUEST_TYPE = "PrivateChannelDisconnectRequest"; + +export function isPrivateChannelDisconnectResponse(value: any): value is PrivateChannelDisconnectResponse { + try { + Convert.privateChannelDisconnectResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_DISCONNECT_RESPONSE_TYPE = "PrivateChannelDisconnectResponse"; + +export function isPrivateChannelOnAddContextListenerEvent(value: any): value is PrivateChannelOnAddContextListenerEvent { + try { + Convert.privateChannelOnAddContextListenerEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_ON_ADD_CONTEXT_LISTENER_EVENT_TYPE = "PrivateChannelOnAddContextListenerEvent"; + +export function isPrivateChannelOnDisconnectEvent(value: any): value is PrivateChannelOnDisconnectEvent { + try { + Convert.privateChannelOnDisconnectEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_ON_DISCONNECT_EVENT_TYPE = "PrivateChannelOnDisconnectEvent"; + +export function isPrivateChannelOnUnsubscribeEvent(value: any): value is PrivateChannelOnUnsubscribeEvent { + try { + Convert.privateChannelOnUnsubscribeEventToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_ON_UNSUBSCRIBE_EVENT_TYPE = "PrivateChannelOnUnsubscribeEvent"; + +export function isPrivateChannelUnsubscribeEventListenerRequest(value: any): value is PrivateChannelUnsubscribeEventListenerRequest { + try { + Convert.privateChannelUnsubscribeEventListenerRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_UNSUBSCRIBE_EVENT_LISTENER_REQUEST_TYPE = "PrivateChannelUnsubscribeEventListenerRequest"; + +export function isPrivateChannelUnsubscribeEventListenerResponse(value: any): value is PrivateChannelUnsubscribeEventListenerResponse { + try { + Convert.privateChannelUnsubscribeEventListenerResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const PRIVATE_CHANNEL_UNSUBSCRIBE_EVENT_LISTENER_RESPONSE_TYPE = "PrivateChannelUnsubscribeEventListenerResponse"; + +export function isRaiseIntentForContextRequest(value: any): value is RaiseIntentForContextRequest { + try { + Convert.raiseIntentForContextRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const RAISE_INTENT_FOR_CONTEXT_REQUEST_TYPE = "RaiseIntentForContextRequest"; + +export function isRaiseIntentForContextResponse(value: any): value is RaiseIntentForContextResponse { + try { + Convert.raiseIntentForContextResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const RAISE_INTENT_FOR_CONTEXT_RESPONSE_TYPE = "RaiseIntentForContextResponse"; + +export function isRaiseIntentRequest(value: any): value is RaiseIntentRequest { + try { + Convert.raiseIntentRequestToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const RAISE_INTENT_REQUEST_TYPE = "RaiseIntentRequest"; + +export function isRaiseIntentResponse(value: any): value is RaiseIntentResponse { + try { + Convert.raiseIntentResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const RAISE_INTENT_RESPONSE_TYPE = "RaiseIntentResponse"; + +export function isRaiseIntentResultResponse(value: any): value is RaiseIntentResultResponse { + try { + Convert.raiseIntentResultResponseToJson(value); + return true; + } catch (_e: any) { + return false; + } +} + +export const RAISE_INTENT_RESULT_RESPONSE_TYPE = "RaiseIntentResultResponse"; + +export type RequestMessage = AddContextListenerRequest | AddEventListenerRequest | AddIntentListenerRequest | BroadcastRequest | ContextListenerUnsubscribeRequest | CreatePrivateChannelRequest | EventListenerUnsubscribeRequest | FindInstancesRequest | FindIntentRequest | FindIntentsByContextRequest | GetAppMetadataRequest | GetCurrentChannelRequest | GetCurrentContextRequest | GetInfoRequest | GetOrCreateChannelRequest | GetUserChannelsRequest | HeartbeatAcknowledgementRequest | IntentListenerUnsubscribeRequest | IntentResultRequest | JoinUserChannelRequest | LeaveCurrentChannelRequest | OpenRequest | PrivateChannelAddEventListenerRequest | PrivateChannelDisconnectRequest | PrivateChannelUnsubscribeEventListenerRequest | RaiseIntentForContextRequest | RaiseIntentRequest; + +export type ResponseMessage = AddContextListenerResponse | AddEventListenerResponse | AddIntentListenerResponse | BroadcastResponse | ContextListenerUnsubscribeResponse | CreatePrivateChannelResponse | EventListenerUnsubscribeResponse | FindInstancesResponse | FindIntentResponse | FindIntentsByContextResponse | GetAppMetadataResponse | GetCurrentChannelResponse | GetCurrentContextResponse | GetInfoResponse | GetOrCreateChannelResponse | GetUserChannelsResponse | IntentListenerUnsubscribeResponse | IntentResultResponse | JoinUserChannelResponse | LeaveCurrentChannelResponse | OpenResponse | PrivateChannelAddEventListenerResponse | PrivateChannelDisconnectResponse | PrivateChannelUnsubscribeEventListenerResponse | RaiseIntentForContextResponse | RaiseIntentResponse | RaiseIntentResultResponse; + +export type EventMessage = BroadcastEvent | ChannelChangedEvent | HeartbeatEvent | IntentEvent | PrivateChannelOnAddContextListenerEvent | PrivateChannelOnDisconnectEvent | PrivateChannelOnUnsubscribeEvent; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +