diff --git a/code-generation/generate-type-predicates.ts b/code-generation/generate-type-predicates.ts new file mode 100644 index 000000000..c5726fd0b --- /dev/null +++ b/code-generation/generate-type-predicates.ts @@ -0,0 +1,50 @@ +import { InterfaceDeclaration, MethodDeclaration, Project, SyntaxKind } from "ts-morph" + +// open a new project with just BrowserTypes as the only source file +const project = new Project(); +const sourceFile = project.addSourceFileAtPath("../src/api/BrowserTypes.ts") + +//get a list of all interfaces in the file +const interfaces = sourceFile.getChildrenOfKind(SyntaxKind.InterfaceDeclaration); + +// get a list of all conversion functions in the Convert class +const convert = sourceFile.getClass("Convert"); +const convertFunctions = (convert?.getChildrenOfKind(SyntaxKind.MethodDeclaration) ?? []).filter(func => func.getReturnType().getText() === "string"); + +// generate a list of Interfaces that have an associated conversion function +const matchedInterfaces = convertFunctions.map(func => { + const valueParameter = func.getParameter("value"); + + const matchingInterface = interfaces.find(interfaceNode => { + return valueParameter?.getType().getText(valueParameter) === interfaceNode.getName(); + }); + + + if(matchingInterface != null) { + return {func, matchingInterface}; + } + + return undefined; +}).filter(((value => value != null) as (value: T | null | undefined) => value is T)); + +// write a type predicate for each matched interface +matchedInterfaces.forEach(matched => writePredicate(matched.matchingInterface, matched.func)); + + +function writePredicate(matchingInterface: InterfaceDeclaration, func: MethodDeclaration): void{ + const predicateName = `is${matchingInterface.getName()}`; + + sourceFile.addStatements(`export function ${predicateName}(value: any): value is ${matchingInterface.getName()} { + try{ + Convert.${func.getName()}(value); + return true; + } catch(e: any){ + return false; + } +}`); + +} + +sourceFile.formatText(); + +project.saveSync(); diff --git a/code-generation/tsconfig.json b/code-generation/tsconfig.json new file mode 100644 index 000000000..7153e3e16 --- /dev/null +++ b/code-generation/tsconfig.json @@ -0,0 +1,37 @@ +{ + // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs + "files": ["generate-type-predicates.ts"], + "compilerOptions": { + "module": "CommonJS", + "lib": ["dom", "esnext"], + "importHelpers": true, + // output .d.ts declaration files for consumers + "declaration": true, + "outDir": "dist", + // output .js.map sourcemap files for consumers + "sourceMap": true, + // match output dir to input dir. e.g. dist/index instead of dist/src/index + "rootDir": "./", + // stricter type-checking for stronger correctness. Recommended by TS + "strict": true, + // linter checks for common issues + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative + "noUnusedLocals": true, + "noUnusedParameters": true, + // use Node's module resolution algorithm, instead of the legacy TS one + "moduleResolution": "node", + // transpile JSX to React.createElement + "jsx": "react", + // interop between ESM and CJS modules. Recommended by TS + "esModuleInterop": true, + // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS + "skipLibCheck": true, + // error out if import and file system have a casing mismatch. Recommended by TS + "forceConsistentCasingInFileNames": true, + // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` + "noEmit": true, + } + } + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2bcf47239..73deb5c5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,8 @@ "rimraf": "^5.0.5", "rollup": "4.12.1", "ts-jest": "29.1.2", + "ts-morph": "^23.0.0", + "ts-node": "^10.9.2", "tslib": "^2.0.1", "typescript": "^4.0.3" }, @@ -1859,6 +1861,35 @@ "node": ">= 10" } }, + "node_modules/@ts-morph/common": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.24.0.tgz", + "integrity": "sha512-c1xMmNHWpNselmpIqursHeOHHBTIsJLbB+NuovbTTRCNiTLEr/U9dbJ8qy0jd/O2x5pc3seWuOUN5R2IoOTp8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-glob": "^3.3.2", + "minimatch": "^9.0.4", + "mkdirp": "^3.0.1", + "path-browserify": "^1.0.1" + } + }, + "node_modules/@ts-morph/common/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@tsconfig/node10": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", @@ -3130,6 +3161,13 @@ "node": ">= 0.12.0" } }, + "node_modules/code-block-writer": { + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-13.0.1.tgz", + "integrity": "sha512-c5or4P6erEA69TxaxTNcHUNcIn+oyxSRTOWV+pSYF+z4epXqNvwvJ70XPGjPNgue83oAFAPBRQYwpAJ/Hpe/Sg==", + "dev": true, + "license": "MIT" + }, "node_modules/collect-v8-coverage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", @@ -6657,6 +6695,22 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/moment": { "version": "2.30.1", "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", @@ -6981,6 +7035,13 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true, + "license": "MIT" + }, "node_modules/path-equal": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/path-equal/-/path-equal-1.2.5.tgz", @@ -8377,11 +8438,23 @@ } } }, + "node_modules/ts-morph": { + "version": "23.0.0", + "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-23.0.0.tgz", + "integrity": "sha512-FcvFx7a9E8TUe6T3ShihXJLiJOiqyafzFKUO4aqIHDUCIvADdGNShcbc2W5PMr3LerXRv7mafvFZ9lRENxJmug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ts-morph/common": "~0.24.0", + "code-block-writer": "^13.0.1" + } + }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, + "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", diff --git a/package.json b/package.json index 0194a400c..ffecb63ce 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,8 @@ "rimraf": "^5.0.5", "rollup": "4.12.1", "ts-jest": "29.1.2", + "ts-morph": "^23.0.0", + "ts-node": "^10.9.2", "tslib": "^2.0.1", "typescript": "^4.0.3" }, diff --git a/src/api/BrowserTypes.ts b/src/api/BrowserTypes.ts index 5f067387f..c758119fb 100644 --- a/src/api/BrowserTypes.ts +++ b/src/api/BrowserTypes.ts @@ -110,7 +110,7 @@ export interface AppRequestMessageMeta { * purposes but a Desktop Agent should make its own determination of the source of a message * to avoid spoofing. */ - source?: AppIdentifier; + source?: AppIdentifier; timestamp: Date; } @@ -191,13 +191,13 @@ export interface AgentResponseMessage { * Metadata for messages sent by a Desktop Agent to an App in response to an API call */ export interface AgentResponseMessageMeta { - requestUuid: string; + requestUuid: string; responseUuid: string; /** * Field that represents the source application that the request being responded to was * received from, for debugging purposes. */ - source?: AppIdentifier; + source?: AppIdentifier; timestamp: Date; } @@ -293,7 +293,7 @@ export interface AddContextListenerRequestMeta { * purposes but a Desktop Agent should make its own determination of the source of a message * to avoid spoofing. */ - source?: AppIdentifier; + source?: AppIdentifier; timestamp: Date; } @@ -346,13 +346,13 @@ export interface AddContextListenerResponse { * Metadata for messages sent by a Desktop Agent to an App in response to an API call */ export interface AddContextListenerResponseMeta { - requestUuid: string; + requestUuid: string; responseUuid: string; /** * Field that represents the source application that the request being responded to was * received from, for debugging purposes. */ - source?: AppIdentifier; + source?: AppIdentifier; timestamp: Date; } @@ -362,7 +362,7 @@ export interface AddContextListenerResponseMeta { * unsuccessful. */ export interface AddContextListenerResponsePayload { - error?: PurpleError; + error?: PurpleError; listenerUUID?: string; } @@ -447,7 +447,7 @@ export interface AddIntentListenerResponse { * unsuccessful. */ export interface AddIntentListenerResponsePayload { - error?: FluffyError; + error?: FluffyError; listenerUUID?: string; [property: string]: any; } @@ -818,7 +818,7 @@ export interface CreatePrivateChannelResponse { * unsuccessful. */ export interface CreatePrivateChannelResponsePayload { - error?: PurpleError; + error?: PurpleError; privateChannel?: Channel; } @@ -959,7 +959,7 @@ export interface FindInstancesResponse { * resulted in an error and including a standardized error message. */ export interface FindInstancesResponsePayload { - error?: FindInstancesErrors; + error?: FindInstancesErrors; appIdentifiers?: AppMetadata[]; } @@ -1134,8 +1134,8 @@ export interface FindIntentRequest { * The message payload typically contains the arguments to FDC3 API functions. */ export interface FindIntentRequestPayload { - context?: Context; - intent: string; + context?: Context; + intent: string; resultType?: string; } @@ -1174,7 +1174,7 @@ export interface FindIntentResponse { * unsuccessful. */ export interface FindIntentResponsePayload { - error?: FindInstancesErrors; + error?: FindInstancesErrors; appIntent?: AppIntent; } @@ -1239,7 +1239,7 @@ export interface FindIntentsByContextRequest { * The message payload typically contains the arguments to FDC3 API functions. */ export interface FindIntentsByContextRequestPayload { - context: Context; + context: Context; resultType?: string; } @@ -1278,7 +1278,7 @@ export interface FindIntentsByContextsByContextResponse { * unsuccessful. */ export interface FindIntentsByContextsByContextResponsePayload { - error?: FindInstancesErrors; + error?: FindInstancesErrors; appIntents?: AppIntent[]; } @@ -1350,7 +1350,7 @@ export interface GetAppMetadataResponse { * unsuccessful. */ export interface GetAppMetadataResponsePayload { - error?: FindInstancesErrors; + error?: FindInstancesErrors; appMetadata?: AppMetadata; } @@ -1422,7 +1422,7 @@ export interface GetCurrentChannelResponse { * unsuccessful. */ export interface GetCurrentChannelResponsePayload { - error?: ResponsePayloadError; + error?: ResponsePayloadError; channel?: Channel | null; } @@ -1580,7 +1580,7 @@ export interface GetInfoResponse { * unsuccessful. */ export interface GetInfoResponsePayload { - error?: ResponsePayloadError; + error?: ResponsePayloadError; implementationMetadata?: ImplementationMetadata; } @@ -1714,7 +1714,7 @@ export interface GetOrCreateChannelResponse { * unsuccessful. */ export interface GetOrCreateChannelResponsePayload { - error?: PurpleError; + error?: PurpleError; channel?: Channel; } @@ -1785,7 +1785,7 @@ export interface GetUserChannelsResponse { * unsuccessful. */ export interface GetUserChannelsResponsePayload { - error?: PurpleError; + error?: PurpleError; userChannels?: Channel[]; } @@ -1877,7 +1877,7 @@ export interface IframeChannelResizePayload { */ export interface DimensionsClass { height: number; - width: number; + width: number; } /** @@ -2094,7 +2094,7 @@ export interface IframeResolvePayload { * An array of AppIntent objects defining the resolution options. */ appIntents: AppIntent[]; - context: Context; + context: Context; } /** @@ -2455,7 +2455,7 @@ export interface OpenResponse { * unsuccessful. */ export interface OpenResponsePayload { - error?: OpenErrorResponsePayload; + error?: OpenErrorResponsePayload; appIdentifier?: AppIdentifier; } @@ -2546,7 +2546,7 @@ export interface PrivateChannelAddEventListenerResponse { * unsuccessful. */ export interface PrivateChannelAddEventListenerResponsePayload { - error?: PurpleError; + error?: PurpleError; listenerUUID?: string; [property: string]: any; } @@ -2839,7 +2839,7 @@ export interface RaiseIntentForContextRequest { * The message payload typically contains the arguments to FDC3 API functions. */ export interface RaiseIntentForContextRequestPayload { - app?: AppIdentifier; + app?: AppIdentifier; context: Context; } @@ -2885,9 +2885,9 @@ export interface RaiseIntentForContextResponse { * Response to a raiseIntent request that resulted in an error */ export interface RaiseIntentForContextResponsePayload { - error?: FindInstancesErrors; + error?: FindInstancesErrors; intentResolution?: IntentResolution; - appIntents?: AppIntent[]; + appIntents?: AppIntent[]; } /** @@ -2960,9 +2960,9 @@ export interface RaiseIntentRequest { * The message payload typically contains the arguments to FDC3 API functions. */ export interface RaiseIntentRequestPayload { - app?: AppIdentifier; + app?: AppIdentifier; context: Context; - intent: string; + intent: string; } /** @@ -3007,9 +3007,9 @@ export interface RaiseIntentResponse { * Response to a raiseIntent request that resulted in an error */ export interface RaiseIntentResponsePayload { - error?: FindInstancesErrors; + error?: FindInstancesErrors; intentResolution?: IntentResolution; - appIntent?: AppIntent; + appIntent?: AppIntent; } /** @@ -3047,7 +3047,7 @@ export interface RaiseIntentResultResponse { * unsuccessful. */ export interface ResponsePayload { - error?: ResponsePayloadError; + error?: ResponsePayloadError; intentResult?: IntentResult; } @@ -3085,7 +3085,7 @@ export interface WebConnectionProtocol1Hello { */ export interface ConnectionStepMetadata { connectionAttemptUuid: string; - timestamp: Date; + timestamp: Date; } /** @@ -3987,7 +3987,7 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any const typ = typs[i]; try { return transform(val, typ, getProps); - } catch (_) {} + } catch (_) { } } return invalidValue(typs, val, key, parent); } @@ -4046,9 +4046,9 @@ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any if (Array.isArray(typ)) return transformEnum(typ, val); if (typeof typ === "object") { return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val) - : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val) - : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val) - : invalidValue(typ, val, key, parent); + : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val) + : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val) + : invalidValue(typ, val, key, parent); } // Numbers can be parsed by Date but shouldn't be. if (typ === Date && typeof val !== "number") return transformDate(val); @@ -5165,3 +5165,579 @@ const typeMap: any = { "WCP5ValidateAppIdentityResponse", ], }; +export function isAppRequestMessage(value: any): value is AppRequestMessage { + try { + Convert.appRequestMessageToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isAgentResponseMessage(value: any): value is AgentResponseMessage { + try { + Convert.agentResponseMessageToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isAgentEventMessage(value: any): value is AgentEventMessage { + try { + Convert.agentEventMessageToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isAddContextListenerRequest(value: any): value is AddContextListenerRequest { + try { + Convert.addContextListenerRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isAddContextListenerResponse(value: any): value is AddContextListenerResponse { + try { + Convert.addContextListenerResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isAddIntentListenerRequest(value: any): value is AddIntentListenerRequest { + try { + Convert.addIntentListenerRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isAddIntentListenerResponse(value: any): value is AddIntentListenerResponse { + try { + Convert.addIntentListenerResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isBroadcastEvent(value: any): value is BroadcastEvent { + try { + Convert.broadcastEventToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isBroadcastRequest(value: any): value is BroadcastRequest { + try { + Convert.broadcastRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isBroadcastResponse(value: any): value is BroadcastResponse { + try { + Convert.broadcastResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isChannelChangedEvent(value: any): value is ChannelChangedEvent { + try { + Convert.channelChangedEventToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isContextListenerUnsubscribeRequest(value: any): value is ContextListenerUnsubscribeRequest { + try { + Convert.contextListenerUnsubscribeRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isContextListenerUnsubscribeResponse(value: any): value is ContextListenerUnsubscribeResponse { + try { + Convert.contextListenerUnsubscribeResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isCreatePrivateChannelRequest(value: any): value is CreatePrivateChannelRequest { + try { + Convert.createPrivateChannelRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isCreatePrivateChannelResponse(value: any): value is CreatePrivateChannelResponse { + try { + Convert.createPrivateChannelResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isFindInstancesRequest(value: any): value is FindInstancesRequest { + try { + Convert.findInstancesRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isFindInstancesResponse(value: any): value is FindInstancesResponse { + try { + Convert.findInstancesResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isFindIntentRequest(value: any): value is FindIntentRequest { + try { + Convert.findIntentRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isFindIntentResponse(value: any): value is FindIntentResponse { + try { + Convert.findIntentResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isFindIntentsByContextRequest(value: any): value is FindIntentsByContextRequest { + try { + Convert.findIntentsByContextRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isFindIntentsByContextsByContextResponse(value: any): value is FindIntentsByContextsByContextResponse { + try { + Convert.findIntentsByContextsByContextResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetAppMetadataRequest(value: any): value is GetAppMetadataRequest { + try { + Convert.getAppMetadataRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetAppMetadataResponse(value: any): value is GetAppMetadataResponse { + try { + Convert.getAppMetadataResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetCurrentChannelRequest(value: any): value is GetCurrentChannelRequest { + try { + Convert.getCurrentChannelRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetCurrentChannelResponse(value: any): value is GetCurrentChannelResponse { + try { + Convert.getCurrentChannelResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetCurrentContextRequest(value: any): value is GetCurrentContextRequest { + try { + Convert.getCurrentContextRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetCurrentContextResponse(value: any): value is GetCurrentContextResponse { + try { + Convert.getCurrentContextResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetInfoRequest(value: any): value is GetInfoRequest { + try { + Convert.getInfoRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetInfoResponse(value: any): value is GetInfoResponse { + try { + Convert.getInfoResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetOrCreateChannelRequest(value: any): value is GetOrCreateChannelRequest { + try { + Convert.getOrCreateChannelRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetOrCreateChannelResponse(value: any): value is GetOrCreateChannelResponse { + try { + Convert.getOrCreateChannelResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetUserChannelsRequest(value: any): value is GetUserChannelsRequest { + try { + Convert.getUserChannelsRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isGetUserChannelsResponse(value: any): value is GetUserChannelsResponse { + try { + Convert.getUserChannelsResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeChannelDrag(value: any): value is IframeChannelDrag { + try { + Convert.iframeChannelDragToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeChannelResize(value: any): value is IframeChannelResize { + try { + Convert.iframeChannelResizeToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeChannels(value: any): value is IframeChannels { + try { + Convert.iframeChannelsToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeChannelSelected(value: any): value is IframeChannelSelected { + try { + Convert.iframeChannelSelectedToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeHandshake(value: any): value is IframeHandshake { + try { + Convert.iframeHandshakeToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeHello(value: any): value is IframeHello { + try { + Convert.iframeHelloToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeMessage(value: any): value is IframeMessage { + try { + Convert.iframeMessageToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeResolve(value: any): value is IframeResolve { + try { + Convert.iframeResolveToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIframeResolveAction(value: any): value is IframeResolveAction { + try { + Convert.iframeResolveActionToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIntentEvent(value: any): value is IntentEvent { + try { + Convert.intentEventToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIntentListenerUnsubscribeRequest(value: any): value is IntentListenerUnsubscribeRequest { + try { + Convert.intentListenerUnsubscribeRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isIntentListenerUnsubscribeResponse(value: any): value is IntentListenerUnsubscribeResponse { + try { + Convert.intentListenerUnsubscribeResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isJoinUserChannelRequest(value: any): value is JoinUserChannelRequest { + try { + Convert.joinUserChannelRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isJoinUserChannelResponse(value: any): value is JoinUserChannelResponse { + try { + Convert.joinUserChannelResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isLeaveCurrentChannelRequest(value: any): value is LeaveCurrentChannelRequest { + try { + Convert.leaveCurrentChannelRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isLeaveCurrentChannelResponse(value: any): value is LeaveCurrentChannelResponse { + try { + Convert.leaveCurrentChannelResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isOpenRequest(value: any): value is OpenRequest { + try { + Convert.openRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isOpenResponse(value: any): value is OpenResponse { + try { + Convert.openResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelAddEventListenerRequest(value: any): value is PrivateChannelAddEventListenerRequest { + try { + Convert.privateChannelAddEventListenerRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelAddEventListenerResponse(value: any): value is PrivateChannelAddEventListenerResponse { + try { + Convert.privateChannelAddEventListenerResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelDisconnectRequest(value: any): value is PrivateChannelDisconnectRequest { + try { + Convert.privateChannelDisconnectRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelDisconnectResponse(value: any): value is PrivateChannelDisconnectResponse { + try { + Convert.privateChannelDisconnectResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelOnAddContextListenerEvent(value: any): value is PrivateChannelOnAddContextListenerEvent { + try { + Convert.privateChannelOnAddContextListenerEventToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelOnDisconnectEvent(value: any): value is PrivateChannelOnDisconnectEvent { + try { + Convert.privateChannelOnDisconnectEventToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelOnUnsubscribeEventEvent(value: any): value is PrivateChannelOnUnsubscribeEventEvent { + try { + Convert.privateChannelOnUnsubscribeEventEventToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelUnsubscribeEventListenerRequest(value: any): value is PrivateChannelUnsubscribeEventListenerRequest { + try { + Convert.privateChannelUnsubscribeEventListenerRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isPrivateChannelUnsubscribeEventListenerResponse(value: any): value is PrivateChannelUnsubscribeEventListenerResponse { + try { + Convert.privateChannelUnsubscribeEventListenerResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isRaiseIntentForContextRequest(value: any): value is RaiseIntentForContextRequest { + try { + Convert.raiseIntentForContextRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isRaiseIntentForContextResponse(value: any): value is RaiseIntentForContextResponse { + try { + Convert.raiseIntentForContextResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isRaiseIntentRequest(value: any): value is RaiseIntentRequest { + try { + Convert.raiseIntentRequestToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isRaiseIntentResponse(value: any): value is RaiseIntentResponse { + try { + Convert.raiseIntentResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isRaiseIntentResultResponse(value: any): value is RaiseIntentResultResponse { + try { + Convert.raiseIntentResultResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocol1Hello(value: any): value is WebConnectionProtocol1Hello { + try { + Convert.webConnectionProtocol1HelloToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocol2LoadURL(value: any): value is WebConnectionProtocol2LoadURL { + try { + Convert.webConnectionProtocol2LoadURLToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocol3Handshake(value: any): value is WebConnectionProtocol3Handshake { + try { + Convert.webConnectionProtocol3HandshakeToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocol4ValidateAppIdentity(value: any): value is WebConnectionProtocol4ValidateAppIdentity { + try { + Convert.webConnectionProtocol4ValidateAppIdentityToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocol5ValidateAppIdentityFailedResponse(value: any): value is WebConnectionProtocol5ValidateAppIdentityFailedResponse { + try { + Convert.webConnectionProtocol5ValidateAppIdentityFailedResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocol5ValidateAppIdentitySuccessResponse(value: any): value is WebConnectionProtocol5ValidateAppIdentitySuccessResponse { + try { + Convert.webConnectionProtocol5ValidateAppIdentitySuccessResponseToJson(value); + return true; + } catch (e: any) { + return false; + } +} +export function isWebConnectionProtocolMessage(value: any): value is WebConnectionProtocolMessage { + try { + Convert.webConnectionProtocolMessageToJson(value); + return true; + } catch (e: any) { + return false; + } +}