@salesforce/sdk-core 1.131.1 → 1.131.3

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/dist/index.d.ts CHANGED
@@ -13,7 +13,8 @@ export type { LightningSDK, LMSMessage, LMSSubscription, MessageChannel } from '
13
13
  export type { OpenAISDK, SalesforceACCSDK } from './platforms';
14
14
  export type { JsonRpcBase, JsonRpcRequest, JsonRpcError, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcResponse, JsonRpcNotification, JsonRpcMessage, JsonRpcPendingRequest, JsonRpcPendingRequestMap, } from './jsonrpc';
15
15
  export { isJsonRpcBase, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, isJsonRpcResponse, isJsonRpcNotification, isJsonRpcRequest, } from './jsonrpc';
16
- export { JsonRpcClient } from './jsonrpc-client';
16
+ export { JsonRpcClient, WindowPostMessageTransport } from './jsonrpc-client';
17
+ export type { Transport } from './jsonrpc-client';
17
18
  export { McpAppsSession } from './mcpapps-session';
18
19
  export type { McpAppsHostContext, McpAppsSessionOptions } from './mcpapps-session';
19
20
  export { getSurfaceCapabilities } from './capabilities';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/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,S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MCPApps = "MCP-Apps", e.Mosaic = "Mosaic", e))(r || {});
1
+ var i = /* @__PURE__ */ ((e) => (e.WebApp = "WebApp", e.MicroFrontend = "Micro-Frontend", e.OpenAI = "OpenAI", e.SalesforceACC = "Salesforce-ACC", e.MCPApps = "MCP-Apps", e.Mosaic = "Mosaic", e))(i || {});
2
2
  const d = f();
3
3
  function f() {
4
4
  if (typeof window > "u")
@@ -32,15 +32,44 @@ function h(e) {
32
32
  function g(e) {
33
33
  return l(e) && "method" in e && typeof e.method == "string" && !("id" in e);
34
34
  }
35
- function P(e) {
35
+ function b(e) {
36
36
  return l(e) && "id" in e && typeof e.id == "number" && "method" in e && typeof e.method == "string";
37
37
  }
38
38
  class T {
39
+ targetOrigin;
40
+ /**
41
+ * @param targetOrigin - origin passed as the second argument to
42
+ * `window.parent.postMessage`. Defaults to `"*"` for backwards
43
+ * compatibility. Pin to the known parent origin when possible to
44
+ * prevent leaking messages to a cross-origin navigated parent.
45
+ */
46
+ constructor(t = "*") {
47
+ this.targetOrigin = t;
48
+ }
49
+ post(t) {
50
+ window.parent?.postMessage(t, this.targetOrigin);
51
+ }
52
+ onMessage(t) {
53
+ const s = (n) => {
54
+ t(n.data);
55
+ };
56
+ return window.addEventListener("message", s), () => window.removeEventListener("message", s);
57
+ }
58
+ }
59
+ class M {
39
60
  nextRequestId = 1;
40
61
  pending = /* @__PURE__ */ new Map();
41
62
  notificationHandlers = /* @__PURE__ */ new Map();
42
- constructor() {
43
- window.addEventListener("message", this.onMessage);
63
+ transport;
64
+ /**
65
+ * Construct a JSON-RPC client bound to the given transport.
66
+ *
67
+ * @param transport - the transport to use; defaults to a
68
+ * `WindowPostMessageTransport`, which preserves the original
69
+ * `window.parent.postMessage` behaviour.
70
+ */
71
+ constructor(t = new T()) {
72
+ this.transport = t, this.transport.onMessage(this.onMessage);
44
73
  }
45
74
  /**
46
75
  * Register a handler for a specific JSON-RPC notification method
@@ -49,7 +78,7 @@ class T {
49
78
  * When a notification with the registered method is received, the handler
50
79
  * will be invoked with the notification params.
51
80
  *
52
- * @param method - The notification method to handle (e.g., "ui/notifications/host-context-changed")
81
+ * @param method - The notification method to handle (e.g. "ui/notifications/host-context-changed")
53
82
  * @param handler - Callback function to process the notification params
54
83
  *
55
84
  * @example
@@ -57,29 +86,31 @@ class T {
57
86
  * this.handleHostContextChanged(params);
58
87
  * });
59
88
  */
60
- registerNotificationHandler(s, t) {
61
- this.notificationHandlers.has(s) || this.notificationHandlers.set(s, /* @__PURE__ */ new Set()), this.notificationHandlers.get(s).add(t);
89
+ registerNotificationHandler(t, s) {
90
+ this.notificationHandlers.has(t) || this.notificationHandlers.set(t, /* @__PURE__ */ new Set()), this.notificationHandlers.get(t).add(s);
62
91
  }
63
92
  /**
64
- * Handle incoming JSON-RPC messages from parent window
65
- * Processes both responses (for requests) and notifications
93
+ * Handle inbound JSON-RPC messages from the transport.
94
+ *
95
+ * Processes both responses (for requests) and notifications. Non-JSON-RPC
96
+ * payloads are silently ignored so that a shared transport can be used for
97
+ * multiple protocols without cross-talk.
66
98
  */
67
- onMessage = (s) => {
68
- const t = s.data;
99
+ onMessage = (t) => {
69
100
  if (h(t)) {
70
- const n = this.pending.get(t.id);
71
- if (!n)
101
+ const s = this.pending.get(t.id);
102
+ if (!s)
72
103
  return;
73
- this.pending.delete(t.id), u(t) ? n.reject(new Error(t.error.message || "Request failed")) : n.resolve(t.result);
104
+ this.pending.delete(t.id), u(t) ? s.reject(new Error(t.error.message || "Request failed")) : s.resolve(t.result);
74
105
  return;
75
106
  }
76
107
  if (g(t)) {
77
- const n = this.notificationHandlers.get(t.method);
78
- n && n.forEach((o) => o(t.params));
108
+ const s = this.notificationHandlers.get(t.method);
109
+ s && s.forEach((n) => n(t.params));
79
110
  }
80
111
  };
81
112
  /**
82
- * Send a JSON-RPC request to the parent window
113
+ * Send a JSON-RPC request to the peer.
83
114
  *
84
115
  * @param method - The JSON-RPC method name
85
116
  * @param params - The method parameters
@@ -91,22 +122,22 @@ class T {
91
122
  * content: { type: "text", text: "Hello" }
92
123
  * });
93
124
  */
94
- request(s, t) {
95
- const n = this.nextRequestId++, o = {
125
+ request(t, s) {
126
+ const n = this.nextRequestId++, r = {
96
127
  jsonrpc: "2.0",
97
128
  id: n,
98
- method: s,
99
- params: t
129
+ method: t,
130
+ params: s
100
131
  };
101
- return new Promise((i, c) => {
132
+ return new Promise((o, c) => {
102
133
  this.pending.set(n, {
103
- resolve: i,
134
+ resolve: o,
104
135
  reject: c
105
- }), window.parent?.postMessage(o, "*");
136
+ }), this.transport.post(r);
106
137
  });
107
138
  }
108
139
  /**
109
- * Send a JSON-RPC notification to the parent window
140
+ * Send a JSON-RPC notification to the peer.
110
141
  *
111
142
  * Notifications are one-way messages that do not expect a response.
112
143
  * Use notifications for:
@@ -128,17 +159,17 @@ class T {
128
159
  * height: 600
129
160
  * });
130
161
  */
131
- sendNotification(s, t) {
162
+ sendNotification(t, s) {
132
163
  const n = {
133
164
  jsonrpc: "2.0",
134
- method: s,
135
- params: t
165
+ method: t,
166
+ params: s
136
167
  };
137
- window.parent?.postMessage(n, "*");
168
+ this.transport.post(n);
138
169
  }
139
170
  }
140
- const M = 500, C = "2026-01-26";
141
- class a extends T {
171
+ const C = 500, w = "2026-01-26";
172
+ class a extends M {
142
173
  static initPromise = null;
143
174
  hostCtx = {};
144
175
  _handshakeSucceeded = !1;
@@ -148,10 +179,10 @@ class a extends T {
148
179
  * The first call performs the SEP-1865 handshake. Concurrent and subsequent
149
180
  * calls reuse the same session and handshake result.
150
181
  */
151
- static async getInstance(s) {
182
+ static async getInstance(t) {
152
183
  return a.initPromise || (a.initPromise = (async () => {
153
- const t = new a();
154
- return await t.handshake(s), t;
184
+ const s = new a();
185
+ return await s.handshake(t), s;
155
186
  })()), a.initPromise;
156
187
  }
157
188
  /**
@@ -168,18 +199,18 @@ class a extends T {
168
199
  * On timeout or error, falls back to an empty host context so the app can
169
200
  * still render (graceful degradation for non-SEP-1865 hosts).
170
201
  */
171
- async handshake(s) {
172
- const t = s?.handshakeTimeoutMs ?? M, n = s?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
202
+ async handshake(t) {
203
+ const s = t?.handshakeTimeoutMs ?? C, n = t?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
173
204
  try {
174
- const o = /* @__PURE__ */ Symbol("timeout"), i = await Promise.race([
205
+ const r = /* @__PURE__ */ Symbol("timeout"), o = await Promise.race([
175
206
  this.request("ui/initialize", {
176
- protocolVersion: C,
207
+ protocolVersion: w,
177
208
  appInfo: n,
178
209
  appCapabilities: {}
179
210
  }),
180
- new Promise((c) => setTimeout(() => c(o), t))
211
+ new Promise((c) => setTimeout(() => c(r), s))
181
212
  ]);
182
- i !== o && (this.hostCtx = i.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (c) => {
213
+ o !== r && (this.hostCtx = o.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (c) => {
183
214
  this.hostCtx = {
184
215
  ...this.hostCtx,
185
216
  ...c
@@ -199,17 +230,17 @@ class a extends T {
199
230
  // ── Public wrappers ──────────────────────────────────────────────────
200
231
  // Widen access from protected to public so SDK classes can use the
201
232
  // shared transport without extending JsonRpcClient themselves.
202
- request(s, t) {
203
- return super.request(s, t);
233
+ request(t, s) {
234
+ return super.request(t, s);
204
235
  }
205
- sendNotification(s, t) {
206
- super.sendNotification(s, t);
236
+ sendNotification(t, s) {
237
+ super.sendNotification(t, s);
207
238
  }
208
- registerNotificationHandler(s, t) {
209
- super.registerNotificationHandler(s, t);
239
+ registerNotificationHandler(t, s) {
240
+ super.registerNotificationHandler(t, s);
210
241
  }
211
242
  }
212
- const y = {
243
+ const m = {
213
244
  callTool: !0,
214
245
  sendMessageToHost: !0,
215
246
  readResource: !0,
@@ -229,7 +260,7 @@ const y = {
229
260
  // TODO
230
261
  getTheme: !0,
231
262
  resize: !0
232
- }, w = {
263
+ }, y = {
233
264
  callTool: !0,
234
265
  sendMessageToHost: !0,
235
266
  readResource: !1,
@@ -248,7 +279,7 @@ const y = {
248
279
  displayModal: !0,
249
280
  getTheme: !0,
250
281
  resize: !1
251
- }, m = {
282
+ }, A = {
252
283
  callTool: !1,
253
284
  sendMessageToHost: !0,
254
285
  readResource: !1,
@@ -267,7 +298,7 @@ const y = {
267
298
  displayModal: !1,
268
299
  getTheme: !0,
269
300
  resize: !1
270
- }, A = {
301
+ }, I = {
271
302
  callTool: !1,
272
303
  sendMessageToHost: !1,
273
304
  readResource: !1,
@@ -287,47 +318,48 @@ const y = {
287
318
  getTheme: !1,
288
319
  resize: !1
289
320
  };
290
- function b(e) {
321
+ function R(e) {
291
322
  switch (e) {
292
- case r.MCPApps:
293
- return { ...y };
294
- case r.OpenAI:
295
- return { ...w };
296
- case r.SalesforceACC:
323
+ case i.MCPApps:
297
324
  return { ...m };
298
- case r.Mosaic:
299
- case r.WebApp:
300
- case r.MicroFrontend:
301
- default:
325
+ case i.OpenAI:
326
+ return { ...y };
327
+ case i.SalesforceACC:
302
328
  return { ...A };
329
+ case i.Mosaic:
330
+ case i.WebApp:
331
+ case i.MicroFrontend:
332
+ default:
333
+ return { ...I };
303
334
  }
304
335
  }
305
- const I = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
306
- function R(e, s) {
336
+ const P = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
337
+ function H(e, t) {
307
338
  return new Proxy(e, {
308
- get(t, n, o) {
309
- if (typeof n == "symbol" || I.has(n)) {
310
- const i = Reflect.get(t, n, o);
311
- return typeof i == "function" ? i.bind(t) : i;
339
+ get(s, n, r) {
340
+ if (typeof n == "symbol" || P.has(n)) {
341
+ const o = Reflect.get(s, n, r);
342
+ return typeof o == "function" ? o.bind(s) : o;
312
343
  }
313
344
  throw new TypeError(
314
- `\`${s}()\` returns a Promise — did you forget to await it?
315
- Use \`const sdk = await ${s}();\` before accessing SDK methods.`
345
+ `\`${t}()\` returns a Promise — did you forget to await it?
346
+ Use \`const sdk = await ${t}();\` before accessing SDK methods.`
316
347
  );
317
348
  }
318
349
  });
319
350
  }
320
351
  export {
321
- T as JsonRpcClient,
352
+ M as JsonRpcClient,
322
353
  a as McpAppsSession,
323
- r as Surface,
354
+ i as Surface,
355
+ T as WindowPostMessageTransport,
324
356
  S as getSurface,
325
- b as getSurfaceCapabilities,
357
+ R as getSurfaceCapabilities,
326
358
  l as isJsonRpcBase,
327
359
  u as isJsonRpcErrorResponse,
328
360
  g as isJsonRpcNotification,
329
- P as isJsonRpcRequest,
361
+ b as isJsonRpcRequest,
330
362
  h as isJsonRpcResponse,
331
363
  p as isJsonRpcSuccessResponse,
332
- R as wrapSDKPromise
364
+ H as wrapSDKPromise
333
365
  };
@@ -1,11 +1,76 @@
1
1
  /**
2
- * Base class for JSON-RPC 2.0 clients using postMessage
2
+ * Abstract transport for a JSON-RPC 2.0 client.
3
3
  *
4
- * This class provides core JSON-RPC client functionality for MCP Apps implementations.
5
- * It handles request/response correlation, message validation, and error handling.
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.
6
71
  *
7
72
  * Subclasses should extend this class and use the protected `request()` method
8
- * to send JSON-RPC requests to the parent window.
73
+ * to send JSON-RPC requests to the peer.
9
74
  *
10
75
  * @example
11
76
  * export class MCPAppsViewSDK extends JsonRpcClient implements ViewSDK {
@@ -16,12 +81,26 @@
16
81
  * });
17
82
  * }
18
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
+ * }
19
90
  */
20
91
  export declare class JsonRpcClient {
21
92
  private nextRequestId;
22
93
  private pending;
23
94
  private notificationHandlers;
24
- constructor();
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);
25
104
  /**
26
105
  * Register a handler for a specific JSON-RPC notification method
27
106
  *
@@ -29,7 +108,7 @@ export declare class JsonRpcClient {
29
108
  * When a notification with the registered method is received, the handler
30
109
  * will be invoked with the notification params.
31
110
  *
32
- * @param method - The notification method to handle (e.g., "ui/notifications/host-context-changed")
111
+ * @param method - The notification method to handle (e.g. "ui/notifications/host-context-changed")
33
112
  * @param handler - Callback function to process the notification params
34
113
  *
35
114
  * @example
@@ -39,12 +118,15 @@ export declare class JsonRpcClient {
39
118
  */
40
119
  protected registerNotificationHandler(method: string, handler: (params: unknown) => void): void;
41
120
  /**
42
- * Handle incoming JSON-RPC messages from parent window
43
- * Processes both responses (for requests) and notifications
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.
44
126
  */
45
127
  private onMessage;
46
128
  /**
47
- * Send a JSON-RPC request to the parent window
129
+ * Send a JSON-RPC request to the peer.
48
130
  *
49
131
  * @param method - The JSON-RPC method name
50
132
  * @param params - The method parameters
@@ -58,7 +140,7 @@ export declare class JsonRpcClient {
58
140
  */
59
141
  protected request<TParams = unknown, TResult = unknown>(method: string, params: TParams): Promise<TResult>;
60
142
  /**
61
- * Send a JSON-RPC notification to the parent window
143
+ * Send a JSON-RPC notification to the peer.
62
144
  *
63
145
  * Notifications are one-way messages that do not expect a response.
64
146
  * Use notifications for:
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc-client.d.ts","sourceRoot":"","sources":["../src/jsonrpc-client.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,oBAAoB,CAAqD;;IAOjF;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAO/F;;;OAGG;IACH,OAAO,CAAC,SAAS,CA4Bf;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"}
1
+ {"version":3,"file":"jsonrpc-client.d.ts","sourceRoot":"","sources":["../src/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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sdk-core",
3
- "version": "1.131.1",
3
+ "version": "1.131.3",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",