import mqtt from 'mqtt'; import { z } from 'zod'; /** * Raised when an interop client receives an aggregate of intents from other connected sessions * @public */ export declare type AggregateIntentDetailsEvent = { responses: IntentDetailsEvent[]; }; /** * Represents an app intent * @public */ export declare type AppIdentifier = z.infer; /** * Schema for an AppIdentifier * @public */ declare const appIdentifierSchema: z.ZodObject<{ appId: z.ZodString; instanceId: z.ZodOptional; }, "strip", z.ZodTypeAny, { appId: string; instanceId?: string | undefined; }, { appId: string; instanceId?: string | undefined; }>; /** * Represents an app intent * @public */ export declare type AppIntent = z.infer; /** * Schema for an app intent * @public */ declare const appIntentSchema: z.ZodObject<{ intent: z.ZodObject<{ displayName: z.ZodString; name: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; displayName: string; }, { name: string; displayName: string; }>; apps: z.ZodArray; icons: z.ZodOptional; src: z.ZodString; type: z.ZodOptional; }, "strip", z.ZodTypeAny, { src: string; type?: string | undefined; size?: string | undefined; }, { src: string; type?: string | undefined; size?: string | undefined; }>, "many">>; instanceMetadata: z.ZodOptional>; name: z.ZodOptional; resultType: z.ZodOptional>>; screenshots: z.ZodOptional; size: z.ZodOptional; src: z.ZodString; type: z.ZodOptional; }, "strip", z.ZodTypeAny, { src: string; type?: string | undefined; size?: string | undefined; label?: string | undefined; }, { src: string; type?: string | undefined; size?: string | undefined; label?: string | undefined; }>, "many">>; title: z.ZodOptional; tooltip: z.ZodOptional; version: z.ZodOptional; } & { appId: z.ZodString; instanceId: z.ZodOptional; }, "strip", z.ZodTypeAny, { appId: string; instanceId?: string | undefined; description?: string | undefined; icons?: { src: string; type?: string | undefined; size?: string | undefined; }[] | undefined; instanceMetadata?: Record | undefined; name?: string | undefined; resultType?: string | null | undefined; screenshots?: { src: string; type?: string | undefined; size?: string | undefined; label?: string | undefined; }[] | undefined; title?: string | undefined; tooltip?: string | undefined; version?: string | undefined; }, { appId: string; instanceId?: string | undefined; description?: string | undefined; icons?: { src: string; type?: string | undefined; size?: string | undefined; }[] | undefined; instanceMetadata?: Record | undefined; name?: string | undefined; resultType?: string | null | undefined; screenshots?: { src: string; type?: string | undefined; size?: string | undefined; label?: string | undefined; }[] | undefined; title?: string | undefined; tooltip?: string | undefined; version?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { intent: { name: string; displayName: string; }; apps: { appId: string; instanceId?: string | undefined; description?: string | undefined; icons?: { src: string; type?: string | undefined; size?: string | undefined; }[] | undefined; instanceMetadata?: Record | undefined; name?: string | undefined; resultType?: string | null | undefined; screenshots?: { src: string; type?: string | undefined; size?: string | undefined; label?: string | undefined; }[] | undefined; title?: string | undefined; tooltip?: string | undefined; version?: string | undefined; }[]; }, { intent: { name: string; displayName: string; }; apps: { appId: string; instanceId?: string | undefined; description?: string | undefined; icons?: { src: string; type?: string | undefined; size?: string | undefined; }[] | undefined; instanceMetadata?: Record | undefined; name?: string | undefined; resultType?: string | null | undefined; screenshots?: { src: string; type?: string | undefined; size?: string | undefined; label?: string | undefined; }[] | undefined; title?: string | undefined; tooltip?: string | undefined; version?: string | undefined; }[]; }>; export declare class AuthorizationError extends CloudInteropAPIError { constructor(message?: string, code?: string); } /** * Represents a base event for the cloud interop api * @public * @property {Source} source - The source of the event * @property {HistoryRecord} history - A trail of timestamps of when the context hit various points in the system */ export declare type BaseCloudInteropAPIEvent = { /** * The source of the event */ source: Source; /** * A trail of timestamps of when the event hit various points in the system * @internal */ history?: HistoryRecord; }; /** * Represents an Intent Discovery Event * @public */ export declare type BaseIntentDiscoveryEvent = BaseIntentEvent & { discoveryId: string; }; /** * Represents a base intent event * @public */ export declare type BaseIntentEvent = BaseCloudInteropAPIEvent & { /** * The session id of the interop client that initiated an intent action */ initiatingSessionId: string; }; /** * Represents a single connection to a Cloud Interop service * * @public * @class */ export declare class CloudInteropAPI { #private; constructor(cloudInteropSettings: CloudInteropSettings); get sessionDetails(): CreateSessionResponse | undefined; get mqttClient(): mqtt.MqttClient | undefined; /** * Connects and creates a session on the Cloud Interop service * * @param parameters - The parameters to use to connect * @returns Promise that resolves when connection is established * @memberof CloudInteropAPI * @throws CloudInteropAPIError - If an error occurs during connection * @throws AuthorizationError - If the connection is unauthorized */ connect(parameters: ConnectParameters): Promise; /** * Disconnects from the Cloud Interop service * * @returns Promise that resolves when disconnected * @memberof CloudInteropAPI * @throws CloudInteropAPIError - If an error occurs during disconnection */ disconnect(): Promise; /** * Publishes a new context for the given context group to the other connected sessions * * @param contextGroup - The context group to publish to * @param context - The context to publish * @returns Promise that resolves when context is published * @memberof CloudInteropAPI */ setContext(contextGroup: string, context: InferredContext): Promise; /** * Starts an intent discovery operation * * @returns Promise that resolves when intent discovery is started * @memberof CloudInteropAPI * @throws CloudInteropAPIError - If an error occurs during intent discovery */ startIntentDiscovery(options: StartIntentDiscoveryOptions): Promise; raiseIntent(options: RaiseIntentAPIOptions): Promise; reportAppIntents(discoveryId: string, intents: AppIntent[]): Promise; sendIntentResult(initiatingSessionId: string, result: IntentResult): Promise; parseSessionId(appId: AppIdentifier | string): string; parseAppId(appId: AppIdentifier | string): string; addEventListener(type: K, callback: EventMap[K]): void; removeEventListener(type: K, callback: EventMap[K]): void; once(type: K, callback: EventMap[K]): void; } export declare class CloudInteropAPIError extends Error { code: string; constructor(message?: string, code?: string, cause?: unknown); } /** * Represents a logging function to be used by the cloud interop client */ export declare type CloudInteropLogger = (level: LogLevel, message: string) => void; export declare type CloudInteropSettings = { url: string; }; /** * @internal */ export declare type CommandMessage = ReportIntentsCommand | IntentDetailsCommand | RaiseIntentCommand | IntentResultCommand; /** * Represents the parameters to use to connect to an interop server */ export declare type ConnectParameters = { /** * ID for a group of shared applications. * This acts as a namespace for the interop messages that allows separation of messages between different groups of applications for the same user */ platformId: string; /** * An user-friendly identifier for the source session e.g. Windows Desktop, Android Phone, etc. */ sourceId: string; /** * The maximum number of times to retry connecting to the cloud interop service when the connection is dropped * defaults to 30 */ reconnectRetryLimit?: number; /** * Specifies how often keep alive messages should be sent to the cloud interop service in seconds * defaults to 30 */ keepAliveIntervalSeconds?: number; /** * Optional function to call with any logging messages to allow integration with the host application's logging * * defaults to console.log */ logger?: CloudInteropLogger; /** * Determines the type of authentication to use with the service gateway * defaults to 'none' * * 'jwt' - Use JWT authentication, in this case jwtAuthenticationParameters must also be provided * 'basic' - Use basic authentication, in this case basicAuthenticationParameters must also be provided * 'default' - Authentication will be inherited from the current session */ authenticationType?: 'jwt' | 'basic' | 'default'; /** * Optional parameters for basic authentication */ basicAuthenticationParameters?: { /** * The username to use for basic authentication */ username: string; /** * The password to use for basic authentication */ password: string; }; /** * Optional parameters for JWT authentication */ jwtAuthenticationParameters?: { /** * When JWT authentication is being used, this will be invoked just whenever a JWT token is required for a request */ jwtRequestCallback: () => string | object | Promise; /** * The id of the service gateway JWT authentication definition to use * * Note: Contact Here support to to get your organization's authentication id */ authenticationId: string; }; }; /** * Represents a context received from another cloud interop publisher * @public * @property {string} contextGroup - The context group * @property {object} context - The context */ export declare type ContextEvent = BaseCloudInteropAPIEvent & { /** * The context group */ contextGroup: string; /** * The context object */ context?: InferredContext; }; /** * Schema for context object * @public */ declare const contextSchema: z.ZodIntersection; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>; export declare type CreateSessionResponse = { sessionId: string; sessionRootTopic: string; url: string; token: string; orgId: string; sub: string; platformId: string; sourceId: string; localSessionExpiryHandling?: boolean; }; declare const errorSchema: z.ZodObject<{ error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; }, { error: string; }>; export declare type EventListenersMap = Map) => void>>; export declare type EventMap = { reconnected: () => void; disconnected: () => void; context: (event: ContextEvent) => void; reconnecting: (attemptNo: number) => void; error: (error: Error) => void; 'session-expired': () => void; 'report-intents': (event: ReportIntentsEvent) => void; 'intent-details': (event: IntentDetailsEvent) => void; 'aggregate-intent-details': (event: AggregateIntentDetailsEvent) => void; 'raise-intent': (event: RaiseIntentEvent) => void; 'intent-result': (event: IntentResultEvent) => void; }; /** * Options for finding intents by intent name or context * @public */ export declare type FindIntentOptions = z.infer; /** * Schema for findOptions for the StartDiscovery operation * @public */ declare const findIntentOptionsSchema: z.ZodUnion<[z.ZodObject<{ type: z.ZodLiteral<"find-intent">; intent: z.ZodString; context: z.ZodOptional; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>>; resultType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "find-intent"; intent: string; resultType?: string | undefined; context?: ({ type: string; name?: string | undefined; id?: Record | undefined; } & Record) | undefined; }, { type: "find-intent"; intent: string; resultType?: string | undefined; context?: ({ type: string; name?: string | undefined; id?: Record | undefined; } & Record) | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"find-intents-by-context">; context: z.ZodIntersection; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>; resultType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "find-intents-by-context"; context: { type: string; name?: string | undefined; id?: Record | undefined; } & Record; resultType?: string | undefined; }, { type: "find-intents-by-context"; context: { type: string; name?: string | undefined; id?: Record | undefined; } & Record; resultType?: string | undefined; }>]>; /** * A trace record for performance monitoring * @internal */ declare type HistoryRecord = { /** * The time the context was sent by the client to the service * Note: This is reliant on the time being accurate on the client */ client?: number; /** * The time the context was received by the service */ received?: number; /** * The time the context was received and forward to the messaging backbone */ forwarded?: number; /** * The time the context was received by client api */ clientReceived?: number; }; /** * Represents a context object * @public */ export declare type InferredContext = z.infer; export declare type InferredError = z.infer; /** * @internal */ export declare type IntentDetailsCommand = IntentDetailsEvent & { command: 'intent-details'; }; /** * Raised when an interop client receives intents from other connected sessions * @public */ export declare type IntentDetailsEvent = BaseIntentDiscoveryEvent & { intents: AppIntent[]; }; /** * Represents an intent resolution * @public */ export declare type IntentResolution = z.infer; declare const intentResolutionSchema: z.ZodObject<{ source: z.ZodUnion<[z.ZodString, z.ZodObject<{ appId: z.ZodString; instanceId: z.ZodOptional; }, "strip", z.ZodTypeAny, { appId: string; instanceId?: string | undefined; }, { appId: string; instanceId?: string | undefined; }>]>; version: z.ZodOptional; intent: z.ZodString; getResult: z.ZodOptional; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>, z.ZodUndefined]>>; }, "strip", z.ZodTypeAny, { source: string | { appId: string; instanceId?: string | undefined; }; intent: string; version?: string | undefined; getResult?: ({ type: string; name?: string | undefined; id?: Record | undefined; } & Record) | undefined; }, { source: string | { appId: string; instanceId?: string | undefined; }; intent: string; version?: string | undefined; getResult?: ({ type: string; name?: string | undefined; id?: Record | undefined; } & Record) | undefined; }>; /** * Represents an intent result * @public */ export declare type IntentResult = z.infer; /** * @internal */ export declare type IntentResultCommand = IntentResultEvent & { command: 'intent-result'; }; /** * Raised when an interop client receives an intent result after raising an intent on a target session * @public */ export declare type IntentResultEvent = BaseIntentEvent & { result: IntentResult; }; /** * Schema for the result of an intent * @public */ declare const intentResultSchema: z.ZodUnion<[z.ZodObject<{ error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; }, { error: string; }>, z.ZodObject<{ source: z.ZodUnion<[z.ZodString, z.ZodObject<{ appId: z.ZodString; instanceId: z.ZodOptional; }, "strip", z.ZodTypeAny, { appId: string; instanceId?: string | undefined; }, { appId: string; instanceId?: string | undefined; }>]>; version: z.ZodOptional; intent: z.ZodString; getResult: z.ZodOptional; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>, z.ZodUndefined]>>; }, "strip", z.ZodTypeAny, { source: string | { appId: string; instanceId?: string | undefined; }; intent: string; version?: string | undefined; getResult?: ({ type: string; name?: string | undefined; id?: Record | undefined; } & Record) | undefined; }, { source: string | { appId: string; instanceId?: string | undefined; }; intent: string; version?: string | undefined; getResult?: ({ type: string; name?: string | undefined; id?: Record | undefined; } & Record) | undefined; }>]>; export declare type LogLevel = 'log' | 'debug' | 'info' | 'warn' | 'error'; /** * Options used to raise an Intent * @public */ export declare type RaiseIntentAPIOptions = { raiseOptions: RaiseIntentOptions; appId: AppIdentifier | string; }; /** * @internal */ export declare type RaiseIntentCommand = RaiseIntentEvent & { command: 'raise-intent'; }; /** * Raised when an interop client invokes an intent * @public */ export declare type RaiseIntentEvent = BaseIntentEvent & { targetSessionId: string; raiseOptions: RaiseIntentOptions; }; /** * Options for raising an intent by intent name or context * @public */ export declare type RaiseIntentOptions = z.infer; /** * Schema for raiseOptions for the RaiseIntent operation * @public */ declare const raiseIntentOptionsSchema: z.ZodUnion<[z.ZodObject<{ type: z.ZodLiteral<"raise-intent">; intent: z.ZodString; context: z.ZodIntersection; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>; }, "strip", z.ZodTypeAny, { type: "raise-intent"; intent: string; context: { type: string; name?: string | undefined; id?: Record | undefined; } & Record; }, { type: "raise-intent"; intent: string; context: { type: string; name?: string | undefined; id?: Record | undefined; } & Record; }>, z.ZodObject<{ type: z.ZodLiteral<"raise-intent-for-context">; context: z.ZodIntersection; id: z.ZodOptional>; }, "strip", z.ZodTypeAny, { type: string; name?: string | undefined; id?: Record | undefined; }, { type: string; name?: string | undefined; id?: Record | undefined; }>, z.ZodRecord>; }, "strip", z.ZodTypeAny, { type: "raise-intent-for-context"; context: { type: string; name?: string | undefined; id?: Record | undefined; } & Record; }, { type: "raise-intent-for-context"; context: { type: string; name?: string | undefined; id?: Record | undefined; } & Record; }>]>; /** * @internal */ export declare type ReportIntentsCommand = ReportIntentsEvent & { command: 'report-intents'; }; /** * Raised when an interop client requests intents from other connected sessions. * @public */ export declare type ReportIntentsEvent = BaseIntentDiscoveryEvent & { /** * Options qualifying how the session should respond to the request * - intent: when provided, filter the response to only include intents that match the specified intent name * - context: when provided, filter the response to only include intents that match the specified context * - resultType: when provided, filter the response to only include apps that match the specified result type */ findOptions: FindIntentOptions; /** * The number of connected sessions including the current session */ sessionCount: number; }; /** * Represents a source session * @public */ export declare type Source = { /** * Source session id */ sessionId: string; /** * Source environment id */ sourceId: string; /** * Source user id */ userId: string; /** * Source org id */ orgId: string; /** * Source platform id */ platformId: string; }; /** * Options used to start an Intent Discovery Operation, with possible constraints for the responses * @public */ export declare type StartIntentDiscoveryOptions = { findOptions: FindIntentOptions; /** * The timeout in ms. * * Discovery will wait for all connected sessions to respond or until the timeout is reached. * * Defaults to 3000ms if not provided, minimum value 500ms */ timeout?: number; }; export { }