@salesforce/platform-sdk 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/README.md +62 -0
- package/dist/analytics/analytics.d.ts +21 -0
- package/dist/analytics/analytics.d.ts.map +1 -0
- package/dist/analytics/error-listener.d.ts +9 -0
- package/dist/analytics/error-listener.d.ts.map +1 -0
- package/dist/analytics/index.d.ts +8 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/method-configs.d.ts +11 -0
- package/dist/analytics/method-configs.d.ts.map +1 -0
- package/dist/analytics/proxy.d.ts +14 -0
- package/dist/analytics/proxy.d.ts.map +1 -0
- package/dist/analytics/schemas.d.ts +7 -0
- package/dist/analytics/schemas.d.ts.map +1 -0
- package/dist/analytics/subscribe-wrapper.d.ts +7 -0
- package/dist/analytics/subscribe-wrapper.d.ts.map +1 -0
- package/dist/analytics/types.d.ts +90 -0
- package/dist/analytics/types.d.ts.map +1 -0
- package/dist/chat/index.d.ts +22 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/mcpapps.d.ts +61 -0
- package/dist/chat/mcpapps.d.ts.map +1 -0
- package/dist/chat/openai.d.ts +25 -0
- package/dist/chat/openai.d.ts.map +1 -0
- package/dist/chat/salesforce-acc.d.ts +13 -0
- package/dist/chat/salesforce-acc.d.ts.map +1 -0
- package/dist/chat/singleton.d.ts +32 -0
- package/dist/chat/singleton.d.ts.map +1 -0
- package/dist/core/acc-types.d.ts +49 -0
- package/dist/core/acc-types.d.ts.map +1 -0
- package/dist/core/capabilities.d.ts +40 -0
- package/dist/core/capabilities.d.ts.map +1 -0
- package/dist/core/chat.d.ts +203 -0
- package/dist/core/chat.d.ts.map +1 -0
- package/dist/core/data.d.ts +38 -0
- package/dist/core/data.d.ts.map +1 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/jsonrpc-client.d.ts +167 -0
- package/dist/core/jsonrpc-client.d.ts.map +1 -0
- package/dist/core/jsonrpc.d.ts +123 -0
- package/dist/core/jsonrpc.d.ts.map +1 -0
- package/dist/core/lightning.d.ts +42 -0
- package/dist/core/lightning.d.ts.map +1 -0
- package/dist/core/mcpapps-session.d.ts +107 -0
- package/dist/core/mcpapps-session.d.ts.map +1 -0
- package/dist/core/mfe-protocol/message-channel-transport.d.ts +79 -0
- package/dist/core/mfe-protocol/message-channel-transport.d.ts.map +1 -0
- package/dist/core/options.d.ts +16 -0
- package/dist/core/options.d.ts.map +1 -0
- package/dist/core/platforms.d.ts +229 -0
- package/dist/core/platforms.d.ts.map +1 -0
- package/dist/core/sdk-promise.d.ts +14 -0
- package/dist/core/sdk-promise.d.ts.map +1 -0
- package/dist/core/surface.d.ts +24 -0
- package/dist/core/surface.d.ts.map +1 -0
- package/dist/core/view.d.ts +308 -0
- package/dist/core/view.d.ts.map +1 -0
- package/dist/data/gql.d.ts +7 -0
- package/dist/data/gql.d.ts.map +1 -0
- package/dist/data/index.d.ts +34 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/mosaic/fetch.d.ts +21 -0
- package/dist/data/mosaic/fetch.d.ts.map +1 -0
- package/dist/data/mosaic/index.d.ts +22 -0
- package/dist/data/mosaic/index.d.ts.map +1 -0
- package/dist/data/openai/index.d.ts +9 -0
- package/dist/data/openai/index.d.ts.map +1 -0
- package/dist/data/shared/graphql/cache/command.d.ts +93 -0
- package/dist/data/shared/graphql/cache/command.d.ts.map +1 -0
- package/dist/data/shared/graphql/cache/index.d.ts +7 -0
- package/dist/data/shared/graphql/cache/index.d.ts.map +1 -0
- package/dist/data/shared/graphql/headers.d.ts +13 -0
- package/dist/data/shared/graphql/headers.d.ts.map +1 -0
- package/dist/data/shared/url-utils.d.ts +9 -0
- package/dist/data/shared/url-utils.d.ts.map +1 -0
- package/dist/data/webapp/client-headers.interceptor.d.ts +12 -0
- package/dist/data/webapp/client-headers.interceptor.d.ts.map +1 -0
- package/dist/data/webapp/csrf/header.interceptor.d.ts +19 -0
- package/dist/data/webapp/csrf/header.interceptor.d.ts.map +1 -0
- package/dist/data/webapp/csrf/retry.interceptor.d.ts +8 -0
- package/dist/data/webapp/csrf/retry.interceptor.d.ts.map +1 -0
- package/dist/data/webapp/csrf/retry.policy.d.ts +31 -0
- package/dist/data/webapp/csrf/retry.policy.d.ts.map +1 -0
- package/dist/data/webapp/csrf/token-manager.d.ts +42 -0
- package/dist/data/webapp/csrf/token-manager.d.ts.map +1 -0
- package/dist/data/webapp/fetch.d.ts +27 -0
- package/dist/data/webapp/fetch.d.ts.map +1 -0
- package/dist/data/webapp/index.d.ts +19 -0
- package/dist/data/webapp/index.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1506 -0
- package/dist/lightning/index.d.ts +15 -0
- package/dist/lightning/index.d.ts.map +1 -0
- package/dist/telemetry/action-piggyback.d.ts +7 -0
- package/dist/telemetry/action-piggyback.d.ts.map +1 -0
- package/dist/telemetry/buffer.d.ts +22 -0
- package/dist/telemetry/buffer.d.ts.map +1 -0
- package/dist/telemetry/index.d.ts +10 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/transport.d.ts +3 -0
- package/dist/telemetry/transport.d.ts.map +1 -0
- package/dist/telemetry/types.d.ts +32 -0
- package/dist/telemetry/types.d.ts.map +1 -0
- package/dist/telemetry/uploader/TelemetryUploader.d.ts +43 -0
- package/dist/telemetry/uploader/TelemetryUploader.d.ts.map +1 -0
- package/dist/telemetry/uploader/interfaces.d.ts +61 -0
- package/dist/telemetry/uploader/interfaces.d.ts.map +1 -0
- package/dist/telemetry/widget-state-flush.d.ts +14 -0
- package/dist/telemetry/widget-state-flush.d.ts.map +1 -0
- package/dist/view/index.d.ts +22 -0
- package/dist/view/index.d.ts.map +1 -0
- package/dist/view/mcpapps.d.ts +24 -0
- package/dist/view/mcpapps.d.ts.map +1 -0
- package/dist/view/openai.d.ts +11 -0
- package/dist/view/openai.d.ts.map +1 -0
- package/dist/view/singleton.d.ts +32 -0
- package/dist/view/singleton.d.ts.map +1 -0
- package/dist/view/utils.d.ts +59 -0
- package/dist/view/utils.d.ts.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { ThemeMode } from './view';
|
|
2
|
+
/**
|
|
3
|
+
* Message payload for chat stream
|
|
4
|
+
*/
|
|
5
|
+
export interface ChatMessage {
|
|
6
|
+
content: string;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Tool execution payload
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolCall {
|
|
13
|
+
toolName: string;
|
|
14
|
+
params?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resource read request
|
|
18
|
+
*/
|
|
19
|
+
export interface ResourceRequest {
|
|
20
|
+
uri: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tool input/output state
|
|
24
|
+
*/
|
|
25
|
+
export interface ToolState<T = unknown> {
|
|
26
|
+
data: T;
|
|
27
|
+
timestamp?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Display modes
|
|
31
|
+
* - inline: Normal embedded view in chat
|
|
32
|
+
* - fullscreen: Expanded full-screen view
|
|
33
|
+
* - pip: Picture-in-Picture (floating panel)
|
|
34
|
+
*/
|
|
35
|
+
export type DisplayMode = "inline" | "fullscreen" | "pip";
|
|
36
|
+
/**
|
|
37
|
+
* Safe area insets describing the non-occluded region of the viewport.
|
|
38
|
+
* Values are in CSS pixels.
|
|
39
|
+
*/
|
|
40
|
+
export interface SafeAreaInsets {
|
|
41
|
+
top: number;
|
|
42
|
+
right: number;
|
|
43
|
+
bottom: number;
|
|
44
|
+
left: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Device interaction capabilities.
|
|
48
|
+
*/
|
|
49
|
+
export interface DeviceCapabilities {
|
|
50
|
+
/** Whether the device supports touch input */
|
|
51
|
+
touch?: boolean;
|
|
52
|
+
/** Whether the device supports hover (pointer) input */
|
|
53
|
+
hover?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Styles provided by the host for theming and font loading.
|
|
57
|
+
*/
|
|
58
|
+
export interface HostStyles {
|
|
59
|
+
/** CSS variables for theming */
|
|
60
|
+
variables?: Record<string, string | undefined>;
|
|
61
|
+
/** CSS blocks that Views can inject */
|
|
62
|
+
css?: {
|
|
63
|
+
/** CSS for font loading (@font-face rules or @import statements) */
|
|
64
|
+
fonts?: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Protocol-agnostic host context exposed to Chat SDK consumers.
|
|
69
|
+
*
|
|
70
|
+
* Contains environment information provided by the host. All fields are
|
|
71
|
+
* optional because availability depends on the host surface and its
|
|
72
|
+
* configuration.
|
|
73
|
+
*/
|
|
74
|
+
export interface HostContext {
|
|
75
|
+
/** Current theme mode */
|
|
76
|
+
theme?: ThemeMode;
|
|
77
|
+
/** Current display mode of the widget */
|
|
78
|
+
displayMode?: DisplayMode;
|
|
79
|
+
/** Maximum height available for the widget, in CSS pixels */
|
|
80
|
+
maxHeight?: number;
|
|
81
|
+
/** Safe area insets (e.g. for notch, system bars) */
|
|
82
|
+
safeArea?: SafeAreaInsets;
|
|
83
|
+
/** Host user agent string */
|
|
84
|
+
userAgent?: string;
|
|
85
|
+
/** BCP 47 locale tag (e.g. "en-US") */
|
|
86
|
+
locale?: string;
|
|
87
|
+
/** Device interaction capabilities */
|
|
88
|
+
deviceCapabilities?: DeviceCapabilities;
|
|
89
|
+
/** Styles provided by the host for theming and font loading */
|
|
90
|
+
styles?: HostStyles;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Chat SDK API with optional methods based on surface capabilities
|
|
94
|
+
*/
|
|
95
|
+
export interface ChatSDK {
|
|
96
|
+
/**
|
|
97
|
+
* Send a message to the host
|
|
98
|
+
*
|
|
99
|
+
* @param message - The message to send
|
|
100
|
+
*/
|
|
101
|
+
sendMessageToHost?: (message: ChatMessage) => Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Execute a tool on the MCP Server
|
|
104
|
+
*
|
|
105
|
+
* @param toolCall - The tool to call with parameters
|
|
106
|
+
*/
|
|
107
|
+
callTool?: <T>(toolCall: ToolCall) => Promise<T>;
|
|
108
|
+
/**
|
|
109
|
+
* Access the current tool input data
|
|
110
|
+
*
|
|
111
|
+
* @returns The tool input data or null if not available
|
|
112
|
+
*/
|
|
113
|
+
accessToolInput?: <T>() => ToolState<T> | null;
|
|
114
|
+
/**
|
|
115
|
+
* Access the current tool output data
|
|
116
|
+
*
|
|
117
|
+
* @returns The tool output data or null if not available
|
|
118
|
+
*/
|
|
119
|
+
accessToolOutput?: <T>() => ToolState<T> | null;
|
|
120
|
+
/**
|
|
121
|
+
* Access metadata about the current tool
|
|
122
|
+
*
|
|
123
|
+
* @returns Tool metadata including schema, description, etc.
|
|
124
|
+
*/
|
|
125
|
+
accessToolMetadata?: <T>() => T | null;
|
|
126
|
+
/**
|
|
127
|
+
* Get the current widget state
|
|
128
|
+
*
|
|
129
|
+
* @returns The widget state or null if not available
|
|
130
|
+
*/
|
|
131
|
+
getWidgetState?: <T>() => T | null;
|
|
132
|
+
/**
|
|
133
|
+
* Set the widget state
|
|
134
|
+
*
|
|
135
|
+
* @param state - The widget state to persist
|
|
136
|
+
*/
|
|
137
|
+
setWidgetState?: <T>(state: T) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Read resource content by URI
|
|
140
|
+
*
|
|
141
|
+
* @param request - The resource request with URI
|
|
142
|
+
*/
|
|
143
|
+
readResource?: <T>(request: ResourceRequest) => Promise<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Open a URL in a new window or tab
|
|
146
|
+
*
|
|
147
|
+
* @param url - The URL to open
|
|
148
|
+
*/
|
|
149
|
+
openLink?: (url: string) => Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Register a callback for when tool execution is canceled
|
|
152
|
+
*
|
|
153
|
+
* @param callback - Function to call when tool is canceled
|
|
154
|
+
*/
|
|
155
|
+
onToolCanceled?: (callback: () => void) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Get available follow-up actions
|
|
158
|
+
*
|
|
159
|
+
* @returns Array of available actions
|
|
160
|
+
*/
|
|
161
|
+
followUpActions?: <T>() => T[];
|
|
162
|
+
/**
|
|
163
|
+
* Set the display mode for the widget
|
|
164
|
+
*
|
|
165
|
+
* @param mode - The desired display mode
|
|
166
|
+
* @returns Promise resolving to the applied display mode
|
|
167
|
+
*/
|
|
168
|
+
setDisplayMode?: (mode: DisplayMode) => Promise<{
|
|
169
|
+
mode: DisplayMode;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Get the current host context
|
|
173
|
+
*
|
|
174
|
+
* Returns environment information from the host surface including
|
|
175
|
+
* display mode, theme, locale, dimensions, and device capabilities.
|
|
176
|
+
* Returns an empty object if the host has not provided context information.
|
|
177
|
+
*
|
|
178
|
+
* @returns The current host context (empty object if not available)
|
|
179
|
+
*/
|
|
180
|
+
getHostContext?: () => HostContext;
|
|
181
|
+
/**
|
|
182
|
+
* Subscribe to data changes from the host
|
|
183
|
+
*
|
|
184
|
+
* This method provides a platform-agnostic way to listen for changes to
|
|
185
|
+
* tool input, output, metadata, and other SDK data. It's designed to work
|
|
186
|
+
* with React's useSyncExternalStore and other reactive patterns.
|
|
187
|
+
*
|
|
188
|
+
* @param callback - Function to call when data changes
|
|
189
|
+
* @returns Cleanup function to unsubscribe
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const unsubscribe = sdk.subscribe?.(() => {
|
|
194
|
+
* console.log('SDK data changed');
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* // Later, cleanup
|
|
198
|
+
* unsubscribe?.();
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
subscribe?: (callback: () => void) => () => void;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/core/chat.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export interface GraphQLResponse<T> {
|
|
7
|
+
data: T;
|
|
8
|
+
errors?: {
|
|
9
|
+
message: string;
|
|
10
|
+
locations?: {
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
}[];
|
|
14
|
+
path?: string[];
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
export interface GraphQLRequest<V = Record<string, unknown>> {
|
|
18
|
+
query: string;
|
|
19
|
+
variables?: V;
|
|
20
|
+
operationName?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DataSDK {
|
|
23
|
+
/**
|
|
24
|
+
* Run a GraphQL query
|
|
25
|
+
*
|
|
26
|
+
* @param request - The GraphQL request options (query, variables, operationName)
|
|
27
|
+
*/
|
|
28
|
+
graphql?: <T, V = Record<string, unknown>>(request: GraphQLRequest<V>) => Promise<GraphQLResponse<T>>;
|
|
29
|
+
/**
|
|
30
|
+
* Make a request using the Fetch API.
|
|
31
|
+
*
|
|
32
|
+
* @param input - The URL or Request object
|
|
33
|
+
* @param init - Optional RequestInit configuration
|
|
34
|
+
* @returns Promise resolving to Response
|
|
35
|
+
*/
|
|
36
|
+
fetch?: typeof fetch;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/core/data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB,EAAE,CAAC;CACJ;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,OAAO;IACvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,KACtB,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACrB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export { Surface, getSurface } from './surface';
|
|
7
|
+
export type { ACCConnection, ACCPanelCallbacks, ACCPreReceiveArgs } from './acc-types';
|
|
8
|
+
export type { SDKOptions } from './options';
|
|
9
|
+
export type { HostContext, HostStyles, ChatMessage, ChatSDK, DeviceCapabilities, DisplayMode, ResourceRequest, SafeAreaInsets, ToolCall, ToolState, } from './chat';
|
|
10
|
+
export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, ViewSDK, } from './view';
|
|
11
|
+
export type { DataSDK, GraphQLRequest, GraphQLResponse } from './data';
|
|
12
|
+
export type { LightningSDK, LMSMessage, LMSSubscription, MessageChannel } from './lightning';
|
|
13
|
+
export type { OpenAISDK, SalesforceACCSDK } from './platforms';
|
|
14
|
+
export type { JsonRpcBase, JsonRpcRequest, JsonRpcError, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcResponse, JsonRpcNotification, JsonRpcMessage, JsonRpcPendingRequest, JsonRpcPendingRequestMap, } from './jsonrpc';
|
|
15
|
+
export { isJsonRpcBase, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, isJsonRpcResponse, isJsonRpcNotification, isJsonRpcRequest, } from './jsonrpc';
|
|
16
|
+
export { JsonRpcClient, WindowPostMessageTransport } from './jsonrpc-client';
|
|
17
|
+
export type { Transport } from './jsonrpc-client';
|
|
18
|
+
export { MessageChannelTransport, type MessageChannelTransportListener, } from './mfe-protocol/message-channel-transport';
|
|
19
|
+
export { McpAppsSession } from './mcpapps-session';
|
|
20
|
+
export type { McpAppsHostContext, McpAppsSessionOptions } from './mcpapps-session';
|
|
21
|
+
export { getSurfaceCapabilities } from './capabilities';
|
|
22
|
+
export type { SurfaceCapabilities } from './capabilities';
|
|
23
|
+
export { wrapSDKPromise } from './sdk-promise';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGhD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGvF,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,YAAY,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,EACd,QAAQ,EACR,SAAS,GACT,MAAM,QAAQ,CAAC;AAGhB,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,SAAS,EACT,OAAO,GACP,MAAM,QAAQ,CAAC;AAGhB,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGvE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7F,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/D,YAAY,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EACN,uBAAuB,EACvB,KAAK,+BAA+B,GACpC,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract transport for a JSON-RPC 2.0 client.
|
|
3
|
+
*
|
|
4
|
+
* A `Transport` is a bidirectional, structured-message pipe. The `JsonRpcClient`
|
|
5
|
+
* uses it to send JSON-RPC messages (`post`) and subscribe to inbound ones
|
|
6
|
+
* (`onMessage`). The transport itself is agnostic to the JSON-RPC framing —
|
|
7
|
+
* it simply moves `unknown` payloads between two endpoints.
|
|
8
|
+
*
|
|
9
|
+
* This abstraction exists so `JsonRpcClient` can be driven by either the
|
|
10
|
+
* `window.parent.postMessage` channel (default, preserved for existing MCP
|
|
11
|
+
* Apps iframes) or a `MessagePort`-backed transport (used by newer
|
|
12
|
+
* microfrontend containers that receive a dedicated channel during
|
|
13
|
+
* bootstrap).
|
|
14
|
+
*/
|
|
15
|
+
export interface Transport {
|
|
16
|
+
/**
|
|
17
|
+
* Deliver a single structured message to the peer. Implementations MUST NOT
|
|
18
|
+
* throw on transient conditions (a closed port, a missing parent window,
|
|
19
|
+
* etc.) — drop the message silently instead, matching the prior
|
|
20
|
+
* `window.parent?.postMessage` behaviour.
|
|
21
|
+
*/
|
|
22
|
+
post(message: unknown): void;
|
|
23
|
+
/**
|
|
24
|
+
* Subscribe to inbound structured messages from the peer. The callback
|
|
25
|
+
* receives the already-unwrapped message payload (never a `MessageEvent`).
|
|
26
|
+
*
|
|
27
|
+
* @returns an unsubscribe function that removes this listener.
|
|
28
|
+
*/
|
|
29
|
+
onMessage(callback: (message: unknown) => void): () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Default `Transport` backing the JSON-RPC client in an iframe context.
|
|
33
|
+
*
|
|
34
|
+
* Outbound messages go to `window.parent` via `postMessage(msg, targetOrigin)`,
|
|
35
|
+
* and inbound messages come from `window.addEventListener("message", ...)`
|
|
36
|
+
* with only the `event.data` payload forwarded to subscribers.
|
|
37
|
+
*
|
|
38
|
+
* The `targetOrigin` passed to `postMessage` is configurable and defaults to
|
|
39
|
+
* `"*"` to preserve the pre-refactor wire behaviour. Callers embedding the
|
|
40
|
+
* iframe should pin this to the expected parent origin when it is known, so
|
|
41
|
+
* that messages cannot leak to a parent that has been navigated to a
|
|
42
|
+
* different origin since the iframe loaded.
|
|
43
|
+
*
|
|
44
|
+
* Missing `window.parent` (e.g. top-level document) is tolerated: `post` is a
|
|
45
|
+
* no-op, matching the prior optional-chaining behaviour.
|
|
46
|
+
*/
|
|
47
|
+
export declare class WindowPostMessageTransport implements Transport {
|
|
48
|
+
private readonly targetOrigin;
|
|
49
|
+
/**
|
|
50
|
+
* @param targetOrigin - origin passed as the second argument to
|
|
51
|
+
* `window.parent.postMessage`. Defaults to `"*"` for backwards
|
|
52
|
+
* compatibility. Pin to the known parent origin when possible to
|
|
53
|
+
* prevent leaking messages to a cross-origin navigated parent.
|
|
54
|
+
*/
|
|
55
|
+
constructor(targetOrigin?: string);
|
|
56
|
+
post(message: unknown): void;
|
|
57
|
+
onMessage(callback: (message: unknown) => void): () => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Base class for JSON-RPC 2.0 clients.
|
|
61
|
+
*
|
|
62
|
+
* This class provides core JSON-RPC client functionality for MCP Apps and
|
|
63
|
+
* sf-mfe implementations. It handles request/response correlation, message
|
|
64
|
+
* validation, and error handling.
|
|
65
|
+
*
|
|
66
|
+
* The transport layer is pluggable via the `Transport` interface. By default
|
|
67
|
+
* the client uses `WindowPostMessageTransport`, which preserves the original
|
|
68
|
+
* `window.parent.postMessage` wire behaviour. Callers can inject a different
|
|
69
|
+
* transport (e.g. a `MessageChannelTransport`) without changing any of the
|
|
70
|
+
* request/response semantics below.
|
|
71
|
+
*
|
|
72
|
+
* Subclasses should extend this class and use the protected `request()` method
|
|
73
|
+
* to send JSON-RPC requests to the peer.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* export class MCPAppsViewSDK extends JsonRpcClient implements ViewSDK {
|
|
77
|
+
* async displayAlert(options: AlertOptions): Promise<void> {
|
|
78
|
+
* await this.request("ui/message", {
|
|
79
|
+
* role: "user",
|
|
80
|
+
* content: { type: "text", text: options.message }
|
|
81
|
+
* });
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // Injecting a custom transport (e.g. for a MessageChannel-based flow).
|
|
87
|
+
* class MyClient extends JsonRpcClient {
|
|
88
|
+
* constructor(transport: Transport) { super(transport); }
|
|
89
|
+
* }
|
|
90
|
+
*/
|
|
91
|
+
export declare class JsonRpcClient {
|
|
92
|
+
private nextRequestId;
|
|
93
|
+
private pending;
|
|
94
|
+
private notificationHandlers;
|
|
95
|
+
private readonly transport;
|
|
96
|
+
/**
|
|
97
|
+
* Construct a JSON-RPC client bound to the given transport.
|
|
98
|
+
*
|
|
99
|
+
* @param transport - the transport to use; defaults to a
|
|
100
|
+
* `WindowPostMessageTransport`, which preserves the original
|
|
101
|
+
* `window.parent.postMessage` behaviour.
|
|
102
|
+
*/
|
|
103
|
+
constructor(transport?: Transport);
|
|
104
|
+
/**
|
|
105
|
+
* Register a handler for a specific JSON-RPC notification method
|
|
106
|
+
*
|
|
107
|
+
* Subclasses can register handlers to process specific notification types.
|
|
108
|
+
* When a notification with the registered method is received, the handler
|
|
109
|
+
* will be invoked with the notification params.
|
|
110
|
+
*
|
|
111
|
+
* @param method - The notification method to handle (e.g. "ui/notifications/host-context-changed")
|
|
112
|
+
* @param handler - Callback function to process the notification params
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* this.registerNotificationHandler("ui/notifications/host-context-changed", (params) => {
|
|
116
|
+
* this.handleHostContextChanged(params);
|
|
117
|
+
* });
|
|
118
|
+
*/
|
|
119
|
+
protected registerNotificationHandler(method: string, handler: (params: unknown) => void): void;
|
|
120
|
+
/**
|
|
121
|
+
* Handle inbound JSON-RPC messages from the transport.
|
|
122
|
+
*
|
|
123
|
+
* Processes both responses (for requests) and notifications. Non-JSON-RPC
|
|
124
|
+
* payloads are silently ignored so that a shared transport can be used for
|
|
125
|
+
* multiple protocols without cross-talk.
|
|
126
|
+
*/
|
|
127
|
+
private onMessage;
|
|
128
|
+
/**
|
|
129
|
+
* Send a JSON-RPC request to the peer.
|
|
130
|
+
*
|
|
131
|
+
* @param method - The JSON-RPC method name
|
|
132
|
+
* @param params - The method parameters
|
|
133
|
+
* @returns Promise that resolves with the result or rejects with error
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* const result = await this.request("ui/message", {
|
|
137
|
+
* role: "user",
|
|
138
|
+
* content: { type: "text", text: "Hello" }
|
|
139
|
+
* });
|
|
140
|
+
*/
|
|
141
|
+
protected request<TParams = unknown, TResult = unknown>(method: string, params: TParams): Promise<TResult>;
|
|
142
|
+
/**
|
|
143
|
+
* Send a JSON-RPC notification to the peer.
|
|
144
|
+
*
|
|
145
|
+
* Notifications are one-way messages that do not expect a response.
|
|
146
|
+
* Use notifications for:
|
|
147
|
+
* - Informing the host of state changes
|
|
148
|
+
* - Fire-and-forget operations
|
|
149
|
+
* - Events that don't require confirmation
|
|
150
|
+
*
|
|
151
|
+
* Use request() instead when you need:
|
|
152
|
+
* - A response from the host
|
|
153
|
+
* - Confirmation of success/failure
|
|
154
|
+
* - Return values from the operation
|
|
155
|
+
*
|
|
156
|
+
* @param method - The JSON-RPC method name
|
|
157
|
+
* @param params - Optional method parameters
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* this.sendNotification("ui/notifications/size-changed", {
|
|
161
|
+
* width: 800,
|
|
162
|
+
* height: 600
|
|
163
|
+
* });
|
|
164
|
+
*/
|
|
165
|
+
protected sendNotification<TParams = unknown>(method: string, params?: TParams): void;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=jsonrpc-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc-client.d.ts","sourceRoot":"","sources":["../../src/core/jsonrpc-client.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;OAKG;IAEH,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAE7B;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC5D;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,0BAA2B,YAAW,SAAS;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;;OAKG;gBACS,YAAY,SAAM;IAI9B,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI5B,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI;CAO3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,oBAAoB,CAAqD;IACjF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAEtC;;;;;;OAMG;gBACS,SAAS,GAAE,SAA4C;IAMnE;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAO/F;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,CA0Bf;IAEF;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EACrD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACb,OAAO,CAAC,OAAO,CAAC;IAkBnB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,CAAC,gBAAgB,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;CAQrF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* JSON-RPC 2.0 Protocol Types
|
|
8
|
+
*
|
|
9
|
+
* This module provides TypeScript types and utilities for implementing
|
|
10
|
+
* JSON-RPC 2.0 protocol as specified in https://www.jsonrpc.org/specification
|
|
11
|
+
*
|
|
12
|
+
* JSON-RPC 2.0 is a stateless, light-weight remote procedure call (RPC) protocol.
|
|
13
|
+
* Used for iframe communication via postMessage in MCP Apps surface.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Creating a request
|
|
17
|
+
* const request: JsonRpcRequest = {
|
|
18
|
+
* jsonrpc: "2.0",
|
|
19
|
+
* id: 1,
|
|
20
|
+
* method: "ui/message",
|
|
21
|
+
* params: { role: "user", content: { type: "text", text: "Hello" } }
|
|
22
|
+
* };
|
|
23
|
+
* window.parent.postMessage(request, "*");
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Validating a response
|
|
27
|
+
* window.addEventListener("message", (event) => {
|
|
28
|
+
* if (isJsonRpcResponse(event.data)) {
|
|
29
|
+
* if (isJsonRpcErrorResponse(event.data)) {
|
|
30
|
+
* console.error("Error:", event.data.error.message);
|
|
31
|
+
* } else {
|
|
32
|
+
* console.log("Result:", event.data.result);
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* JSON-RPC 2.0 base message with required version field
|
|
39
|
+
*/
|
|
40
|
+
export interface JsonRpcBase {
|
|
41
|
+
jsonrpc: "2.0";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* JSON-RPC 2.0 Request with numeric ID (per spec)
|
|
45
|
+
*/
|
|
46
|
+
export interface JsonRpcRequest<TParams = unknown> extends JsonRpcBase {
|
|
47
|
+
id: number;
|
|
48
|
+
method: string;
|
|
49
|
+
params?: TParams;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* JSON-RPC 2.0 Error object structure
|
|
53
|
+
*/
|
|
54
|
+
export interface JsonRpcError {
|
|
55
|
+
code: number;
|
|
56
|
+
message?: string;
|
|
57
|
+
data?: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* JSON-RPC 2.0 Success Response
|
|
61
|
+
*/
|
|
62
|
+
export interface JsonRpcSuccessResponse<TResult = unknown> extends JsonRpcBase {
|
|
63
|
+
id: number;
|
|
64
|
+
result: TResult;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* JSON-RPC 2.0 Error Response
|
|
68
|
+
*/
|
|
69
|
+
export interface JsonRpcErrorResponse extends JsonRpcBase {
|
|
70
|
+
id: number;
|
|
71
|
+
error: JsonRpcError;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* JSON-RPC 2.0 Notification (no id, no response expected)
|
|
75
|
+
*/
|
|
76
|
+
export interface JsonRpcNotification<TParams = unknown> extends JsonRpcBase {
|
|
77
|
+
method: string;
|
|
78
|
+
params?: TParams;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Union of all JSON-RPC response types
|
|
82
|
+
*/
|
|
83
|
+
export type JsonRpcResponse<TResult = unknown> = JsonRpcSuccessResponse<TResult> | JsonRpcErrorResponse;
|
|
84
|
+
/**
|
|
85
|
+
* Union of all JSON-RPC message types
|
|
86
|
+
*/
|
|
87
|
+
export type JsonRpcMessage<TRequest = unknown, TResponse = unknown> = JsonRpcRequest<TRequest> | JsonRpcResponse<TResponse> | JsonRpcNotification;
|
|
88
|
+
/**
|
|
89
|
+
* Pending request resolver functions
|
|
90
|
+
*/
|
|
91
|
+
export interface JsonRpcPendingRequest {
|
|
92
|
+
resolve: (value: unknown) => void;
|
|
93
|
+
reject: (error: unknown) => void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Map of pending JSON-RPC requests by numeric ID
|
|
97
|
+
*/
|
|
98
|
+
export type JsonRpcPendingRequestMap = Map<number, JsonRpcPendingRequest>;
|
|
99
|
+
/**
|
|
100
|
+
* Type guard to check if message is valid JSON-RPC 2.0 base
|
|
101
|
+
*/
|
|
102
|
+
export declare function isJsonRpcBase(data: unknown): data is JsonRpcBase;
|
|
103
|
+
/**
|
|
104
|
+
* Type guard for JSON-RPC success response
|
|
105
|
+
*/
|
|
106
|
+
export declare function isJsonRpcSuccessResponse(data: unknown): data is JsonRpcSuccessResponse;
|
|
107
|
+
/**
|
|
108
|
+
* Type guard for JSON-RPC error response
|
|
109
|
+
*/
|
|
110
|
+
export declare function isJsonRpcErrorResponse(data: unknown): data is JsonRpcErrorResponse;
|
|
111
|
+
/**
|
|
112
|
+
* Type guard for any JSON-RPC response (success or error)
|
|
113
|
+
*/
|
|
114
|
+
export declare function isJsonRpcResponse(data: unknown): data is JsonRpcResponse;
|
|
115
|
+
/**
|
|
116
|
+
* Type guard for JSON-RPC notification
|
|
117
|
+
*/
|
|
118
|
+
export declare function isJsonRpcNotification(data: unknown): data is JsonRpcNotification;
|
|
119
|
+
/**
|
|
120
|
+
* Type guard for JSON-RPC request
|
|
121
|
+
*/
|
|
122
|
+
export declare function isJsonRpcRequest(data: unknown): data is JsonRpcRequest;
|
|
123
|
+
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/core/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,KAAK,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,OAAO,CAAE,SAAQ,WAAW;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,OAAO,GAAG,OAAO,CAAE,SAAQ,WAAW;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,OAAO,GAAG,OAAO,CAAE,SAAQ,WAAW;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,GAAG,OAAO,IAC1C,sBAAsB,CAAC,OAAO,CAAC,GAC/B,oBAAoB,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,QAAQ,GAAG,OAAO,EAAE,SAAS,GAAG,OAAO,IAC/D,cAAc,CAAC,QAAQ,CAAC,GACxB,eAAe,CAAC,SAAS,CAAC,GAC1B,mBAAmB,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAE1E;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,WAAW,CAOhE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,sBAAsB,CAOtF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAOlF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,eAAe,CAExE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,mBAAmB,CAOhF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,cAAc,CAQtE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Lightning Message Service message payload
|
|
8
|
+
*/
|
|
9
|
+
export type LMSMessage = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Lightning Message Service subscription
|
|
12
|
+
*/
|
|
13
|
+
export interface LMSSubscription {
|
|
14
|
+
unsubscribe: () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Lightning Message Service channel configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface MessageChannel {
|
|
20
|
+
channelName: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Lightning SDK interface for Lightning Web Component runtime integration
|
|
24
|
+
*/
|
|
25
|
+
export interface LightningSDK {
|
|
26
|
+
/**
|
|
27
|
+
* Publish a message to a Lightning Message Service channel
|
|
28
|
+
*
|
|
29
|
+
* @param channel - Message channel configuration
|
|
30
|
+
* @param message - Message payload to publish
|
|
31
|
+
*/
|
|
32
|
+
publishLmsMessage?: <M extends LMSMessage>(channel: MessageChannel, message: M) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe to a Lightning Message Service channel
|
|
35
|
+
*
|
|
36
|
+
* @param channel - Message channel configuration
|
|
37
|
+
* @param callback - Callback function to handle received messages
|
|
38
|
+
* @returns Subscription object with unsubscribe method
|
|
39
|
+
*/
|
|
40
|
+
subscribeToLmsChannel?: <M extends LMSMessage>(channel: MessageChannel, callback: (message: M) => void) => LMSSubscription;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=lightning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightning.d.ts","sourceRoot":"","sources":["../../src/core/lightning.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,WAAW,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IAExF;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,CAAC,CAAC,SAAS,UAAU,EAC5C,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,KAC1B,eAAe,CAAC;CACrB"}
|