@salesforce/platform-sdk 7.1.0 → 8.0.1
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/README.md +2 -2
- package/dist/core/data.d.ts +109 -12
- package/dist/core/data.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data/mosaic/index.d.ts +3 -2
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/dist/data/openai/index.d.ts +4 -2
- package/dist/data/openai/index.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/command.d.ts +1 -2
- package/dist/data/shared/graphql/cache/command.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/invoker.d.ts +4 -0
- package/dist/data/shared/graphql/cache/invoker.d.ts.map +1 -0
- package/dist/data/shared/graphql/cache/services.d.ts +22 -0
- package/dist/data/shared/graphql/cache/services.d.ts.map +1 -0
- package/dist/data/shared/graphql/cached-graphql.d.ts +16 -0
- package/dist/data/shared/graphql/cached-graphql.d.ts.map +1 -0
- package/dist/data/shared/graphql/graphql-parse.d.ts +16 -0
- package/dist/data/shared/graphql/graphql-parse.d.ts.map +1 -0
- package/dist/data/shared/graphql/uncached-graphql.d.ts +13 -0
- package/dist/data/shared/graphql/uncached-graphql.d.ts.map +1 -0
- package/dist/data/webapp/index.d.ts +9 -2
- package/dist/data/webapp/index.d.ts.map +1 -1
- package/dist/index.js +709 -402
- package/package.json +9 -9
- package/dist/data/shared/graphql/cache/index.d.ts +0 -7
- package/dist/data/shared/graphql/cache/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { buildServiceDescriptor as
|
|
2
|
-
import { resolvedPromiseLike as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { buildServiceDescriptor as K, setHeader as _ } from "@conduit-client/service-fetch-network/v1";
|
|
2
|
+
import { resolvedPromiseLike as w, ok as I, err as D, stableJSONStringify as Z, DataNotFoundError as ee, UserVisibleError as te, deepFreeze as z } from "@conduit-client/utils";
|
|
3
|
+
import { print as R, parse as se } from "@conduit-client/onestore-graphql-parser/v1";
|
|
4
|
+
import { RetryPolicy as re, buildServiceDescriptor as ne } from "@conduit-client/service-retry/v1";
|
|
5
|
+
import { buildServiceDescriptor as ie } from "@conduit-client/service-cache/v1";
|
|
6
|
+
import { buildServiceDescriptor as oe } from "@conduit-client/service-cache-control/v1";
|
|
7
|
+
import { buildInMemoryCacheInclusionPolicyService as ae } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
8
|
+
import { buildServiceDescriptor as ce } from "@conduit-client/service-pubsub/v1";
|
|
9
|
+
import { HttpCacheControlCommand as le } from "@conduit-client/command-http-cache-control/v1";
|
|
10
|
+
import { encodeCoreEnvelopeContentsRaw as ue } from "o11y/collectors";
|
|
11
|
+
import { SimpleCollector as de } from "o11y/simple_collector";
|
|
12
|
+
import { registerInstrumentedApp as he } from "o11y/client";
|
|
13
|
+
import { analyticsContextSchema as fe, sessionSchema as pe, pageViewSchema as ge, errorContextSchema as me, interactionSchema as ye, customEventSchema as we } from "o11y_schema/sf_mcpanalytics";
|
|
14
|
+
var c = /* @__PURE__ */ ((s) => (s.WebApp = "WebApp", s.MicroFrontend = "Micro-Frontend", s.OpenAI = "OpenAI", s.SalesforceACC = "Salesforce-ACC", s.MCPApps = "MCP-Apps", s.Mosaic = "Mosaic", s))(c || {});
|
|
15
|
+
const be = ve();
|
|
16
|
+
function ve() {
|
|
11
17
|
if (typeof window > "u")
|
|
12
18
|
return "Mosaic";
|
|
13
19
|
if (window.openai)
|
|
@@ -21,28 +27,28 @@ function Y() {
|
|
|
21
27
|
const s = window;
|
|
22
28
|
return s.$A || s.Aura ? "Salesforce-ACC" : "WebApp";
|
|
23
29
|
}
|
|
24
|
-
function
|
|
25
|
-
return s ??
|
|
30
|
+
function C(s) {
|
|
31
|
+
return s ?? be;
|
|
26
32
|
}
|
|
27
|
-
function
|
|
33
|
+
function A(s) {
|
|
28
34
|
return typeof s == "object" && s !== null && "jsonrpc" in s && s.jsonrpc === "2.0";
|
|
29
35
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
36
|
+
function Ce(s) {
|
|
37
|
+
return A(s) && "id" in s && typeof s.id == "number" && "result" in s;
|
|
32
38
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
39
|
+
function B(s) {
|
|
40
|
+
return A(s) && "id" in s && typeof s.id == "number" && "error" in s;
|
|
35
41
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
42
|
+
function Se(s) {
|
|
43
|
+
return Ce(s) || B(s);
|
|
38
44
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
45
|
+
function Te(s) {
|
|
46
|
+
return A(s) && "method" in s && typeof s.method == "string" && !("id" in s);
|
|
41
47
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
48
|
+
function Zt(s) {
|
|
49
|
+
return A(s) && "id" in s && typeof s.id == "number" && "method" in s && typeof s.method == "string";
|
|
44
50
|
}
|
|
45
|
-
class
|
|
51
|
+
class _e {
|
|
46
52
|
targetOrigin;
|
|
47
53
|
/**
|
|
48
54
|
* @param targetOrigin - origin passed as the second argument to
|
|
@@ -57,13 +63,13 @@ class ee {
|
|
|
57
63
|
window.parent?.postMessage(e, this.targetOrigin);
|
|
58
64
|
}
|
|
59
65
|
onMessage(e) {
|
|
60
|
-
const t = (
|
|
61
|
-
e(
|
|
66
|
+
const t = (r) => {
|
|
67
|
+
e(r.data);
|
|
62
68
|
};
|
|
63
69
|
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
|
-
class
|
|
72
|
+
class Ee {
|
|
67
73
|
nextRequestId = 1;
|
|
68
74
|
pending = /* @__PURE__ */ new Map();
|
|
69
75
|
notificationHandlers = /* @__PURE__ */ new Map();
|
|
@@ -75,7 +81,7 @@ class te {
|
|
|
75
81
|
* `WindowPostMessageTransport`, which preserves the original
|
|
76
82
|
* `window.parent.postMessage` behaviour.
|
|
77
83
|
*/
|
|
78
|
-
constructor(e = new
|
|
84
|
+
constructor(e = new _e()) {
|
|
79
85
|
this.transport = e, this.transport.onMessage(this.onMessage);
|
|
80
86
|
}
|
|
81
87
|
/**
|
|
@@ -104,16 +110,16 @@ class te {
|
|
|
104
110
|
* multiple protocols without cross-talk.
|
|
105
111
|
*/
|
|
106
112
|
onMessage = (e) => {
|
|
107
|
-
if (
|
|
113
|
+
if (Se(e)) {
|
|
108
114
|
const t = this.pending.get(e.id);
|
|
109
115
|
if (!t)
|
|
110
116
|
return;
|
|
111
|
-
this.pending.delete(e.id),
|
|
117
|
+
this.pending.delete(e.id), B(e) ? t.reject(new Error(e.error.message || "Request failed")) : t.resolve(e.result);
|
|
112
118
|
return;
|
|
113
119
|
}
|
|
114
|
-
if (
|
|
120
|
+
if (Te(e)) {
|
|
115
121
|
const t = this.notificationHandlers.get(e.method);
|
|
116
|
-
t && t.forEach((
|
|
122
|
+
t && t.forEach((r) => r(e.params));
|
|
117
123
|
}
|
|
118
124
|
};
|
|
119
125
|
/**
|
|
@@ -130,17 +136,17 @@ class te {
|
|
|
130
136
|
* });
|
|
131
137
|
*/
|
|
132
138
|
request(e, t) {
|
|
133
|
-
const
|
|
139
|
+
const r = this.nextRequestId++, n = {
|
|
134
140
|
jsonrpc: "2.0",
|
|
135
|
-
id:
|
|
141
|
+
id: r,
|
|
136
142
|
method: e,
|
|
137
143
|
params: t
|
|
138
144
|
};
|
|
139
|
-
return new Promise((
|
|
140
|
-
this.pending.set(
|
|
141
|
-
resolve:
|
|
142
|
-
reject:
|
|
143
|
-
}), this.transport.post(
|
|
145
|
+
return new Promise((i, o) => {
|
|
146
|
+
this.pending.set(r, {
|
|
147
|
+
resolve: i,
|
|
148
|
+
reject: o
|
|
149
|
+
}), this.transport.post(n);
|
|
144
150
|
});
|
|
145
151
|
}
|
|
146
152
|
/**
|
|
@@ -167,21 +173,21 @@ class te {
|
|
|
167
173
|
* });
|
|
168
174
|
*/
|
|
169
175
|
sendNotification(e, t) {
|
|
170
|
-
const
|
|
176
|
+
const r = {
|
|
171
177
|
jsonrpc: "2.0",
|
|
172
178
|
method: e,
|
|
173
179
|
params: t
|
|
174
180
|
};
|
|
175
|
-
this.transport.post(
|
|
181
|
+
this.transport.post(r);
|
|
176
182
|
}
|
|
177
183
|
}
|
|
178
|
-
function
|
|
184
|
+
function Ae() {
|
|
179
185
|
}
|
|
180
|
-
class
|
|
186
|
+
class es {
|
|
181
187
|
#e;
|
|
182
188
|
#s = /* @__PURE__ */ new Set();
|
|
183
|
-
#i = !1;
|
|
184
189
|
#n = !1;
|
|
190
|
+
#r = !1;
|
|
185
191
|
/** Messages queued before `port.start()` has been called. Flushed on first subscribe. */
|
|
186
192
|
#t = [];
|
|
187
193
|
constructor(e) {
|
|
@@ -196,8 +202,8 @@ class Ct {
|
|
|
196
202
|
* flushed on first subscription.
|
|
197
203
|
*/
|
|
198
204
|
post(e) {
|
|
199
|
-
if (!this.#
|
|
200
|
-
if (!this.#
|
|
205
|
+
if (!this.#r) {
|
|
206
|
+
if (!this.#n) {
|
|
201
207
|
this.#t.push(e);
|
|
202
208
|
return;
|
|
203
209
|
}
|
|
@@ -218,9 +224,9 @@ class Ct {
|
|
|
218
224
|
* Returns an unsubscribe function. Calling it is idempotent.
|
|
219
225
|
*/
|
|
220
226
|
onMessage(e) {
|
|
221
|
-
if (this.#
|
|
222
|
-
return
|
|
223
|
-
this.#s.add(e), this.#
|
|
227
|
+
if (this.#r)
|
|
228
|
+
return Ae;
|
|
229
|
+
this.#s.add(e), this.#n || this.#o();
|
|
224
230
|
let t = !1;
|
|
225
231
|
return () => {
|
|
226
232
|
t || (t = !0, this.#s.delete(e));
|
|
@@ -235,10 +241,10 @@ class Ct {
|
|
|
235
241
|
* - subsequent `onMessage` calls return a no-op unsubscribe
|
|
236
242
|
*/
|
|
237
243
|
dispose() {
|
|
238
|
-
if (!this.#
|
|
239
|
-
this.#
|
|
244
|
+
if (!this.#r) {
|
|
245
|
+
this.#r = !0;
|
|
240
246
|
try {
|
|
241
|
-
this.#e.removeEventListener("message", this.#
|
|
247
|
+
this.#e.removeEventListener("message", this.#i);
|
|
242
248
|
} catch {
|
|
243
249
|
}
|
|
244
250
|
this.#s.clear(), this.#t.length = 0;
|
|
@@ -249,7 +255,7 @@ class Ct {
|
|
|
249
255
|
}
|
|
250
256
|
}
|
|
251
257
|
#o() {
|
|
252
|
-
this.#
|
|
258
|
+
this.#n = !0, this.#e.addEventListener("message", this.#i);
|
|
253
259
|
try {
|
|
254
260
|
this.#e.start();
|
|
255
261
|
} catch {
|
|
@@ -264,17 +270,17 @@ class Ct {
|
|
|
264
270
|
}
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
|
-
#
|
|
273
|
+
#i = (e) => {
|
|
268
274
|
const t = [...this.#s];
|
|
269
|
-
for (const
|
|
275
|
+
for (const r of t)
|
|
270
276
|
try {
|
|
271
|
-
|
|
277
|
+
r(e.data);
|
|
272
278
|
} catch {
|
|
273
279
|
}
|
|
274
280
|
};
|
|
275
281
|
}
|
|
276
|
-
const
|
|
277
|
-
class
|
|
282
|
+
const ke = 500, Me = "2026-01-26";
|
|
283
|
+
class y extends Ee {
|
|
278
284
|
static initPromise = null;
|
|
279
285
|
hostCtx = {};
|
|
280
286
|
_handshakeSucceeded = !1;
|
|
@@ -285,17 +291,17 @@ class g extends te {
|
|
|
285
291
|
* calls reuse the same session and handshake result.
|
|
286
292
|
*/
|
|
287
293
|
static async getInstance(e) {
|
|
288
|
-
return
|
|
289
|
-
const t = new
|
|
294
|
+
return y.initPromise || (y.initPromise = (async () => {
|
|
295
|
+
const t = new y();
|
|
290
296
|
return await t.handshake(e), t;
|
|
291
|
-
})()),
|
|
297
|
+
})()), y.initPromise;
|
|
292
298
|
}
|
|
293
299
|
/**
|
|
294
300
|
* Reset the singleton (for testing only).
|
|
295
301
|
* @internal
|
|
296
302
|
*/
|
|
297
303
|
static resetInstance() {
|
|
298
|
-
|
|
304
|
+
y.initPromise = null;
|
|
299
305
|
}
|
|
300
306
|
/**
|
|
301
307
|
* Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
|
|
@@ -305,20 +311,20 @@ class g extends te {
|
|
|
305
311
|
* still render (graceful degradation for non-SEP-1865 hosts).
|
|
306
312
|
*/
|
|
307
313
|
async handshake(e) {
|
|
308
|
-
const t = e?.handshakeTimeoutMs ??
|
|
314
|
+
const t = e?.handshakeTimeoutMs ?? ke, r = e?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
|
|
309
315
|
try {
|
|
310
|
-
const
|
|
316
|
+
const n = /* @__PURE__ */ Symbol("timeout"), i = await Promise.race([
|
|
311
317
|
this.request("ui/initialize", {
|
|
312
|
-
protocolVersion:
|
|
313
|
-
appInfo:
|
|
318
|
+
protocolVersion: Me,
|
|
319
|
+
appInfo: r,
|
|
314
320
|
appCapabilities: {}
|
|
315
321
|
}),
|
|
316
|
-
new Promise((
|
|
322
|
+
new Promise((o) => setTimeout(() => o(n), t))
|
|
317
323
|
]);
|
|
318
|
-
|
|
324
|
+
i !== n && (this.hostCtx = i.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (o) => {
|
|
319
325
|
this.hostCtx = {
|
|
320
326
|
...this.hostCtx,
|
|
321
|
-
...
|
|
327
|
+
...o
|
|
322
328
|
};
|
|
323
329
|
}), this.sendNotification("ui/notifications/initialized"));
|
|
324
330
|
} catch {
|
|
@@ -345,7 +351,7 @@ class g extends te {
|
|
|
345
351
|
super.registerNotificationHandler(e, t);
|
|
346
352
|
}
|
|
347
353
|
}
|
|
348
|
-
const
|
|
354
|
+
const Ie = {
|
|
349
355
|
callTool: !0,
|
|
350
356
|
sendMessageToHost: !0,
|
|
351
357
|
readResource: !0,
|
|
@@ -365,7 +371,7 @@ const re = {
|
|
|
365
371
|
// TODO
|
|
366
372
|
getTheme: !0,
|
|
367
373
|
resize: !0
|
|
368
|
-
},
|
|
374
|
+
}, De = {
|
|
369
375
|
callTool: !0,
|
|
370
376
|
sendMessageToHost: !0,
|
|
371
377
|
readResource: !1,
|
|
@@ -384,7 +390,7 @@ const re = {
|
|
|
384
390
|
displayModal: !0,
|
|
385
391
|
getTheme: !0,
|
|
386
392
|
resize: !1
|
|
387
|
-
},
|
|
393
|
+
}, Pe = {
|
|
388
394
|
callTool: !1,
|
|
389
395
|
sendMessageToHost: !0,
|
|
390
396
|
readResource: !1,
|
|
@@ -403,7 +409,7 @@ const re = {
|
|
|
403
409
|
displayModal: !1,
|
|
404
410
|
getTheme: !0,
|
|
405
411
|
resize: !1
|
|
406
|
-
},
|
|
412
|
+
}, Le = {
|
|
407
413
|
callTool: !1,
|
|
408
414
|
sendMessageToHost: !1,
|
|
409
415
|
readResource: !1,
|
|
@@ -423,28 +429,28 @@ const re = {
|
|
|
423
429
|
getTheme: !1,
|
|
424
430
|
resize: !1
|
|
425
431
|
};
|
|
426
|
-
function
|
|
432
|
+
function ts(s) {
|
|
427
433
|
switch (s) {
|
|
428
|
-
case
|
|
429
|
-
return { ...
|
|
430
|
-
case
|
|
431
|
-
return { ...
|
|
432
|
-
case
|
|
433
|
-
return { ...
|
|
434
|
-
case
|
|
435
|
-
case
|
|
436
|
-
case
|
|
434
|
+
case c.MCPApps:
|
|
435
|
+
return { ...Ie };
|
|
436
|
+
case c.OpenAI:
|
|
437
|
+
return { ...De };
|
|
438
|
+
case c.SalesforceACC:
|
|
439
|
+
return { ...Pe };
|
|
440
|
+
case c.Mosaic:
|
|
441
|
+
case c.WebApp:
|
|
442
|
+
case c.MicroFrontend:
|
|
437
443
|
default:
|
|
438
|
-
return { ...
|
|
444
|
+
return { ...Le };
|
|
439
445
|
}
|
|
440
446
|
}
|
|
441
|
-
const
|
|
442
|
-
function
|
|
447
|
+
const Re = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
|
|
448
|
+
function k(s, e) {
|
|
443
449
|
return new Proxy(s, {
|
|
444
|
-
get(t,
|
|
445
|
-
if (typeof
|
|
446
|
-
const
|
|
447
|
-
return typeof
|
|
450
|
+
get(t, r, n) {
|
|
451
|
+
if (typeof r == "symbol" || Re.has(r)) {
|
|
452
|
+
const i = Reflect.get(t, r, n);
|
|
453
|
+
return typeof i == "function" ? i.bind(t) : i;
|
|
448
454
|
}
|
|
449
455
|
throw new TypeError(
|
|
450
456
|
`\`${e}()\` returns a Promise — did you forget to await it?
|
|
@@ -453,7 +459,7 @@ Use \`const sdk = await ${e}();\` before accessing SDK methods.`
|
|
|
453
459
|
}
|
|
454
460
|
});
|
|
455
461
|
}
|
|
456
|
-
class
|
|
462
|
+
class xe {
|
|
457
463
|
constructor(e) {
|
|
458
464
|
this.session = e;
|
|
459
465
|
const t = e.getHostContext();
|
|
@@ -462,13 +468,13 @@ class ue {
|
|
|
462
468
|
() => this.notifySubscribers()
|
|
463
469
|
), e.registerNotificationHandler(
|
|
464
470
|
"ui/notifications/tool-result",
|
|
465
|
-
(
|
|
471
|
+
(r) => this.handleToolResult(r)
|
|
466
472
|
), e.registerNotificationHandler(
|
|
467
473
|
"ui/notifications/tool-input",
|
|
468
|
-
(
|
|
474
|
+
(r) => this.handleToolInput(r)
|
|
469
475
|
), e.registerNotificationHandler(
|
|
470
476
|
"ui/notifications/tool-cancelled",
|
|
471
|
-
(
|
|
477
|
+
(r) => this.handleToolCancelled(r)
|
|
472
478
|
);
|
|
473
479
|
}
|
|
474
480
|
globals = {};
|
|
@@ -480,8 +486,8 @@ class ue {
|
|
|
480
486
|
*/
|
|
481
487
|
handleToolResult(e) {
|
|
482
488
|
const t = e;
|
|
483
|
-
let
|
|
484
|
-
t.content !== void 0 && (this.globals.toolOutput = t.content,
|
|
489
|
+
let r = !1;
|
|
490
|
+
t.content !== void 0 && (this.globals.toolOutput = t.content, r = !0), t.structuredContent !== void 0 && (this.globals.toolStructuredContent = t.structuredContent, r = !0), t._meta !== void 0 && (this.globals.toolResponseMetadata = t._meta, r = !0), r && this.notifySubscribers();
|
|
485
491
|
}
|
|
486
492
|
/**
|
|
487
493
|
* Handle tool input notifications from the host
|
|
@@ -496,8 +502,8 @@ class ue {
|
|
|
496
502
|
* @param params - Tool cancellation data from the host
|
|
497
503
|
*/
|
|
498
504
|
handleToolCancelled(e) {
|
|
499
|
-
const
|
|
500
|
-
this.canceledCallbacks.forEach((
|
|
505
|
+
const r = e.reason ?? "";
|
|
506
|
+
this.canceledCallbacks.forEach((n) => n(r));
|
|
501
507
|
}
|
|
502
508
|
/**
|
|
503
509
|
* Request display mode change from host
|
|
@@ -568,8 +574,8 @@ class ue {
|
|
|
568
574
|
getHostContext() {
|
|
569
575
|
const e = this.session.getHostContext(), t = {};
|
|
570
576
|
if (e.theme !== void 0 && (t.theme = e.theme), e.displayMode !== void 0 && (t.displayMode = e.displayMode), e.containerDimensions !== void 0) {
|
|
571
|
-
const
|
|
572
|
-
|
|
577
|
+
const r = e.containerDimensions.maxHeight ?? e.containerDimensions.height;
|
|
578
|
+
r !== void 0 && (t.maxHeight = r);
|
|
573
579
|
}
|
|
574
580
|
return e.safeAreaInsets !== void 0 && (t.safeArea = e.safeAreaInsets), e.userAgent !== void 0 && (t.userAgent = e.userAgent), e.locale !== void 0 && (t.locale = e.locale), e.deviceCapabilities !== void 0 && (t.deviceCapabilities = e.deviceCapabilities), e.styles !== void 0 && (t.styles = e.styles), t;
|
|
575
581
|
}
|
|
@@ -587,8 +593,8 @@ class ue {
|
|
|
587
593
|
this.subscriptions.forEach((e) => e());
|
|
588
594
|
}
|
|
589
595
|
}
|
|
590
|
-
const
|
|
591
|
-
class
|
|
596
|
+
const N = "openai:set_globals";
|
|
597
|
+
class Oe {
|
|
592
598
|
sendMessageToHost(e) {
|
|
593
599
|
return window.openai.sendFollowUpMessage({ prompt: e.content });
|
|
594
600
|
}
|
|
@@ -623,12 +629,12 @@ class de {
|
|
|
623
629
|
}
|
|
624
630
|
subscribe(e) {
|
|
625
631
|
const t = () => e();
|
|
626
|
-
return window.addEventListener(
|
|
627
|
-
window.removeEventListener(
|
|
632
|
+
return window.addEventListener(N, t), () => {
|
|
633
|
+
window.removeEventListener(N, t);
|
|
628
634
|
};
|
|
629
635
|
}
|
|
630
636
|
}
|
|
631
|
-
class
|
|
637
|
+
class He {
|
|
632
638
|
async sendMessageToHost(e) {
|
|
633
639
|
throw console.warn("SalesforceACCChatSDK.sendMessageToHost: stub implementation", e), new Error("SalesforceACCChatSDK.sendMessageToHost not yet implemented");
|
|
634
640
|
}
|
|
@@ -636,31 +642,31 @@ class he {
|
|
|
636
642
|
return console.warn("SalesforceACCChatSDK.followUpActions: stub implementation"), [];
|
|
637
643
|
}
|
|
638
644
|
}
|
|
639
|
-
let
|
|
640
|
-
function
|
|
641
|
-
return
|
|
645
|
+
let S = null, x = null;
|
|
646
|
+
function qe(s) {
|
|
647
|
+
return S || (S = Ne(s).then((e) => (x = e, e))), S;
|
|
642
648
|
}
|
|
643
|
-
function
|
|
644
|
-
return
|
|
649
|
+
function ss() {
|
|
650
|
+
return x;
|
|
645
651
|
}
|
|
646
|
-
function
|
|
647
|
-
|
|
652
|
+
function rs() {
|
|
653
|
+
S = null, x = null;
|
|
648
654
|
}
|
|
649
|
-
function
|
|
650
|
-
return
|
|
655
|
+
function Ne(s) {
|
|
656
|
+
return k(
|
|
651
657
|
(async () => {
|
|
652
|
-
switch (
|
|
653
|
-
case
|
|
654
|
-
return new
|
|
655
|
-
case
|
|
656
|
-
case
|
|
658
|
+
switch (C(s?.surface)) {
|
|
659
|
+
case c.OpenAI:
|
|
660
|
+
return new Oe();
|
|
661
|
+
case c.WebApp:
|
|
662
|
+
case c.Mosaic:
|
|
657
663
|
return {};
|
|
658
|
-
case
|
|
659
|
-
return new
|
|
660
|
-
case
|
|
661
|
-
case
|
|
662
|
-
const t = await
|
|
663
|
-
return t.handshakeSucceeded ? new
|
|
664
|
+
case c.SalesforceACC:
|
|
665
|
+
return new He();
|
|
666
|
+
case c.MicroFrontend:
|
|
667
|
+
case c.MCPApps: {
|
|
668
|
+
const t = await y.getInstance(s?.mcpApps);
|
|
669
|
+
return t.handshakeSucceeded ? new xe(t) : {};
|
|
664
670
|
}
|
|
665
671
|
default:
|
|
666
672
|
return {};
|
|
@@ -669,7 +675,7 @@ function pe(s) {
|
|
|
669
675
|
"createChatSDK"
|
|
670
676
|
);
|
|
671
677
|
}
|
|
672
|
-
function
|
|
678
|
+
function Fe(s) {
|
|
673
679
|
switch (s) {
|
|
674
680
|
case "info":
|
|
675
681
|
return "ℹ️";
|
|
@@ -683,26 +689,26 @@ function ge(s) {
|
|
|
683
689
|
return "ℹ️";
|
|
684
690
|
}
|
|
685
691
|
}
|
|
686
|
-
function
|
|
687
|
-
return `${
|
|
692
|
+
function P(s, e) {
|
|
693
|
+
return `${Fe(e)} ${s}`;
|
|
688
694
|
}
|
|
689
|
-
function
|
|
695
|
+
function F(s, e) {
|
|
690
696
|
const t = s.trim();
|
|
691
697
|
if (t === "")
|
|
692
698
|
return { success: !0, value: void 0 };
|
|
693
|
-
const
|
|
694
|
-
if (!
|
|
699
|
+
const r = t.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
700
|
+
if (!r || !r[1])
|
|
695
701
|
return {
|
|
696
702
|
success: !1,
|
|
697
703
|
error: `Invalid ${e}: "${s}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
698
704
|
};
|
|
699
|
-
const
|
|
700
|
-
return
|
|
705
|
+
const n = parseFloat(r[1]);
|
|
706
|
+
return n < 0 || !isFinite(n) ? {
|
|
701
707
|
success: !1,
|
|
702
708
|
error: `Invalid ${e}: "${s}". Value must be a positive number.`
|
|
703
|
-
} : { success: !0, value:
|
|
709
|
+
} : { success: !0, value: n };
|
|
704
710
|
}
|
|
705
|
-
class
|
|
711
|
+
class Ue {
|
|
706
712
|
constructor(e) {
|
|
707
713
|
this.session = e;
|
|
708
714
|
}
|
|
@@ -712,13 +718,13 @@ class me {
|
|
|
712
718
|
* @param level - The message severity level (defaults to "info")
|
|
713
719
|
*/
|
|
714
720
|
async sendMessage(e, t = "info") {
|
|
715
|
-
const
|
|
721
|
+
const r = P(e, t);
|
|
716
722
|
await this.session.request("ui/message", {
|
|
717
723
|
role: "user",
|
|
718
724
|
content: [
|
|
719
725
|
{
|
|
720
726
|
type: "text",
|
|
721
|
-
text:
|
|
727
|
+
text: r
|
|
722
728
|
}
|
|
723
729
|
]
|
|
724
730
|
});
|
|
@@ -737,24 +743,24 @@ class me {
|
|
|
737
743
|
return e ? { mode: e } : null;
|
|
738
744
|
}
|
|
739
745
|
async resize(e, t) {
|
|
740
|
-
const
|
|
746
|
+
const r = F(e, "width");
|
|
747
|
+
if (!r.success)
|
|
748
|
+
return Promise.reject(new Error(r.error));
|
|
749
|
+
const n = F(t, "height");
|
|
741
750
|
if (!n.success)
|
|
742
751
|
return Promise.reject(new Error(n.error));
|
|
743
|
-
const i =
|
|
744
|
-
|
|
745
|
-
return Promise.reject(new Error(i.error));
|
|
746
|
-
const r = {};
|
|
747
|
-
return n.value !== void 0 && (r.width = n.value), i.value !== void 0 && (r.height = i.value), this.session.sendNotification("ui/notifications/size-changed", r), Promise.resolve();
|
|
752
|
+
const i = {};
|
|
753
|
+
return r.value !== void 0 && (i.width = r.value), n.value !== void 0 && (i.height = n.value), this.session.sendNotification("ui/notifications/size-changed", i), Promise.resolve();
|
|
748
754
|
}
|
|
749
755
|
}
|
|
750
|
-
class
|
|
756
|
+
class Ve {
|
|
751
757
|
async displayAlert(e) {
|
|
752
|
-
const t = e.level || "info",
|
|
753
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
758
|
+
const t = e.level || "info", r = P(e.message, t);
|
|
759
|
+
await window.openai.sendFollowUpMessage({ prompt: r });
|
|
754
760
|
}
|
|
755
761
|
async displayToast(e) {
|
|
756
|
-
const t = e.level || "info",
|
|
757
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
762
|
+
const t = e.level || "info", r = P(e.message, t);
|
|
763
|
+
await window.openai.sendFollowUpMessage({ prompt: r });
|
|
758
764
|
}
|
|
759
765
|
async displayModal(e) {
|
|
760
766
|
await window.openai.requestModal({
|
|
@@ -767,31 +773,31 @@ class we {
|
|
|
767
773
|
return e ? { mode: e } : null;
|
|
768
774
|
}
|
|
769
775
|
}
|
|
770
|
-
let
|
|
771
|
-
function
|
|
772
|
-
return
|
|
776
|
+
let T = null, O = null;
|
|
777
|
+
function ns(s) {
|
|
778
|
+
return T || (T = We(s).then((e) => (O = e, e))), T;
|
|
773
779
|
}
|
|
774
|
-
function
|
|
775
|
-
return
|
|
780
|
+
function is() {
|
|
781
|
+
return O;
|
|
776
782
|
}
|
|
777
|
-
function
|
|
778
|
-
|
|
783
|
+
function os() {
|
|
784
|
+
T = null, O = null;
|
|
779
785
|
}
|
|
780
|
-
function
|
|
781
|
-
return
|
|
786
|
+
function We(s) {
|
|
787
|
+
return k(
|
|
782
788
|
(async () => {
|
|
783
|
-
switch (
|
|
784
|
-
case
|
|
785
|
-
return new
|
|
786
|
-
case
|
|
787
|
-
case
|
|
789
|
+
switch (C(s?.surface)) {
|
|
790
|
+
case c.OpenAI:
|
|
791
|
+
return new Ve();
|
|
792
|
+
case c.WebApp:
|
|
793
|
+
case c.Mosaic:
|
|
788
794
|
return {};
|
|
789
|
-
case
|
|
795
|
+
case c.SalesforceACC:
|
|
790
796
|
return {};
|
|
791
|
-
case
|
|
792
|
-
case
|
|
793
|
-
const t = await
|
|
794
|
-
return t.handshakeSucceeded ? new
|
|
797
|
+
case c.MicroFrontend:
|
|
798
|
+
case c.MCPApps: {
|
|
799
|
+
const t = await y.getInstance(s?.mcpApps);
|
|
800
|
+
return t.handshakeSucceeded ? new Ue(t) : {};
|
|
795
801
|
}
|
|
796
802
|
default:
|
|
797
803
|
return {};
|
|
@@ -800,44 +806,155 @@ function ye(s) {
|
|
|
800
806
|
"createViewSDK"
|
|
801
807
|
);
|
|
802
808
|
}
|
|
803
|
-
function
|
|
809
|
+
function $e(s) {
|
|
804
810
|
return (e) => {
|
|
805
|
-
const [t,
|
|
811
|
+
const [t, r] = e;
|
|
806
812
|
if (typeof t == "string" && !t.startsWith("http")) {
|
|
807
|
-
const
|
|
808
|
-
return
|
|
813
|
+
const n = t.startsWith("/") ? t : `/${t}`;
|
|
814
|
+
return w([`${s}${n}`, r]);
|
|
809
815
|
}
|
|
810
|
-
return
|
|
816
|
+
return w(e);
|
|
811
817
|
};
|
|
812
818
|
}
|
|
813
|
-
function
|
|
814
|
-
return (e) =>
|
|
819
|
+
function Ke(s) {
|
|
820
|
+
return (e) => w(_("Authorization", `Bearer ${s}`, e));
|
|
815
821
|
}
|
|
816
|
-
function
|
|
822
|
+
function ze(s, e) {
|
|
817
823
|
const t = [];
|
|
818
|
-
return s && t.push(
|
|
824
|
+
return s && t.push($e(s)), e && t.push(Ke(e)), K({
|
|
819
825
|
request: t
|
|
820
826
|
}).service;
|
|
821
827
|
}
|
|
822
|
-
const
|
|
823
|
-
|
|
828
|
+
const E = () => {
|
|
829
|
+
}, L = async () => {
|
|
830
|
+
};
|
|
831
|
+
function H(s) {
|
|
832
|
+
try {
|
|
833
|
+
return I(se(s));
|
|
834
|
+
} catch (e) {
|
|
835
|
+
return D(b(e));
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function q(s, e) {
|
|
839
|
+
const t = s.definitions.filter(
|
|
840
|
+
(r) => r.kind === "OperationDefinition"
|
|
841
|
+
);
|
|
842
|
+
return t.length === 0 ? "unknown" : t.length === 1 ? e === void 0 || t[0].name?.value === e ? t[0].operation : "unknown" : e === void 0 ? "unknown" : t.find((r) => r.name?.value === e)?.operation ?? "unknown";
|
|
843
|
+
}
|
|
844
|
+
function b(s) {
|
|
845
|
+
if (s && typeof s == "object" && "data" in s) {
|
|
846
|
+
const e = s.data;
|
|
847
|
+
if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
|
|
848
|
+
return e.errors;
|
|
849
|
+
}
|
|
850
|
+
return s instanceof Error ? [{ message: s.message }] : typeof s == "string" ? [{ message: s }] : [{ message: "Unknown error" }];
|
|
851
|
+
}
|
|
852
|
+
async function j(s, { mutation: e, variables: t, operationName: r }) {
|
|
853
|
+
const n = H(e);
|
|
854
|
+
if (n.isErr()) return { data: void 0, errors: n.error };
|
|
855
|
+
const i = n.value, o = q(i, r);
|
|
856
|
+
if (o !== "mutation")
|
|
857
|
+
return {
|
|
858
|
+
data: void 0,
|
|
859
|
+
errors: [
|
|
860
|
+
{
|
|
861
|
+
message: `DataSDK.graphql.mutate() requires a GraphQL mutation, received ${o}.`
|
|
862
|
+
}
|
|
863
|
+
]
|
|
864
|
+
};
|
|
865
|
+
try {
|
|
866
|
+
const a = await s({
|
|
867
|
+
query: R(i),
|
|
868
|
+
variables: t,
|
|
869
|
+
operationName: r
|
|
870
|
+
});
|
|
871
|
+
return {
|
|
872
|
+
data: a.data ?? void 0,
|
|
873
|
+
errors: a.errors
|
|
874
|
+
};
|
|
875
|
+
} catch (a) {
|
|
876
|
+
return { data: void 0, errors: b(a) };
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function Q(s) {
|
|
880
|
+
function e(r, n, i) {
|
|
881
|
+
return s({
|
|
882
|
+
query: R(r),
|
|
883
|
+
variables: n,
|
|
884
|
+
operationName: i
|
|
885
|
+
}).then(
|
|
886
|
+
(o) => ({
|
|
887
|
+
data: o.data ?? void 0,
|
|
888
|
+
errors: o.errors
|
|
889
|
+
}),
|
|
890
|
+
(o) => ({ data: void 0, errors: b(o) })
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
async function t({
|
|
894
|
+
query: r,
|
|
895
|
+
variables: n,
|
|
896
|
+
operationName: i
|
|
897
|
+
}) {
|
|
898
|
+
const o = H(r);
|
|
899
|
+
if (o.isErr())
|
|
900
|
+
return {
|
|
901
|
+
data: void 0,
|
|
902
|
+
errors: o.error,
|
|
903
|
+
subscribe: () => E,
|
|
904
|
+
refresh: L
|
|
905
|
+
};
|
|
906
|
+
const a = o.value, u = q(a, i);
|
|
907
|
+
if (u !== "query")
|
|
908
|
+
return {
|
|
909
|
+
data: void 0,
|
|
910
|
+
errors: [
|
|
911
|
+
{
|
|
912
|
+
message: `DataSDK.graphql.query() requires a GraphQL query, received ${u}.`
|
|
913
|
+
}
|
|
914
|
+
],
|
|
915
|
+
subscribe: () => E,
|
|
916
|
+
refresh: L
|
|
917
|
+
};
|
|
918
|
+
const l = /* @__PURE__ */ new Set(), f = n, p = await e(a, f, i);
|
|
919
|
+
return {
|
|
920
|
+
data: p.data,
|
|
921
|
+
errors: p.errors,
|
|
922
|
+
subscribe(d) {
|
|
923
|
+
return l.add(d), () => {
|
|
924
|
+
l.delete(d);
|
|
925
|
+
};
|
|
926
|
+
},
|
|
927
|
+
async refresh() {
|
|
928
|
+
const d = await e(a, f, i);
|
|
929
|
+
for (const h of l) h(d);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
return {
|
|
934
|
+
query: t,
|
|
935
|
+
mutate: (r) => j(s, r)
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
const Be = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
939
|
+
function G(s = Be) {
|
|
824
940
|
return `/services/data/v${s}`;
|
|
825
941
|
}
|
|
826
|
-
class
|
|
942
|
+
class je {
|
|
827
943
|
clientFetch;
|
|
828
944
|
pathData;
|
|
945
|
+
graphql;
|
|
829
946
|
constructor(e) {
|
|
830
|
-
const t =
|
|
831
|
-
this.pathData =
|
|
947
|
+
const t = Qe(), r = Ge(e?.instanceUrl ?? t.instanceUrl), n = e?.accessToken ?? t.accessToken;
|
|
948
|
+
this.pathData = G(e?.apiVersion ?? t.apiVersion), this.clientFetch = ze(r || void 0, n), this.graphql = Q(this.executeRawGraphQL.bind(this));
|
|
832
949
|
}
|
|
833
|
-
async
|
|
950
|
+
async executeRawGraphQL({
|
|
834
951
|
query: e,
|
|
835
952
|
variables: t,
|
|
836
|
-
operationName:
|
|
953
|
+
operationName: r
|
|
837
954
|
}) {
|
|
838
955
|
return (await this.clientFetch(`${this.pathData}/graphql`, {
|
|
839
956
|
method: "POST",
|
|
840
|
-
body: JSON.stringify({ query: e, variables: t, operationName:
|
|
957
|
+
body: JSON.stringify({ query: e, variables: t, operationName: r }),
|
|
841
958
|
headers: {
|
|
842
959
|
"Content-Type": "application/json",
|
|
843
960
|
Accept: "application/json"
|
|
@@ -845,7 +962,7 @@ class Se {
|
|
|
845
962
|
})).json();
|
|
846
963
|
}
|
|
847
964
|
}
|
|
848
|
-
function
|
|
965
|
+
function Qe() {
|
|
849
966
|
const s = globalThis.MOSAIC_ENV;
|
|
850
967
|
return {
|
|
851
968
|
instanceUrl: s?.instanceUrl,
|
|
@@ -853,58 +970,62 @@ function _e() {
|
|
|
853
970
|
apiVersion: s?.apiVersion
|
|
854
971
|
};
|
|
855
972
|
}
|
|
856
|
-
function
|
|
973
|
+
function Ge(s) {
|
|
857
974
|
if (!s || s === "/") return "";
|
|
858
975
|
let e = s;
|
|
859
976
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
860
977
|
}
|
|
861
|
-
const
|
|
862
|
-
class
|
|
863
|
-
|
|
978
|
+
const Je = "graphqlQuery";
|
|
979
|
+
class Xe {
|
|
980
|
+
graphql;
|
|
981
|
+
constructor() {
|
|
982
|
+
this.graphql = Q(this.executeRawGraphQL.bind(this));
|
|
983
|
+
}
|
|
984
|
+
async executeRawGraphQL({
|
|
864
985
|
query: e,
|
|
865
986
|
variables: t,
|
|
866
|
-
operationName:
|
|
987
|
+
operationName: r
|
|
867
988
|
}) {
|
|
868
|
-
return (await window.openai.callTool(
|
|
989
|
+
return (await window.openai.callTool(Je, {
|
|
869
990
|
query: e,
|
|
870
991
|
...t != null ? { variables: t } : {},
|
|
871
|
-
...
|
|
992
|
+
...r != null ? { operationName: r } : {}
|
|
872
993
|
})).structuredContent;
|
|
873
994
|
}
|
|
874
995
|
}
|
|
875
|
-
const
|
|
876
|
-
let e =
|
|
877
|
-
return e =
|
|
878
|
-
},
|
|
879
|
-
function
|
|
880
|
-
const { protectedUrls: t = [], alwaysProtectedUrls:
|
|
881
|
-
return async (
|
|
882
|
-
const [
|
|
883
|
-
if (
|
|
884
|
-
const
|
|
885
|
-
|
|
996
|
+
const Ye = "X-SFDC-Client-Name", Ze = "X-SFDC-Client-Version", et = "@salesforce/platform-sdk", tt = "8.0.1", st = (s) => {
|
|
997
|
+
let e = _(Ye, et, s);
|
|
998
|
+
return e = _(Ze, tt, e), w(e);
|
|
999
|
+
}, rt = "X-CSRF-Token";
|
|
1000
|
+
function nt(s, e = {}) {
|
|
1001
|
+
const { protectedUrls: t = [], alwaysProtectedUrls: r = [] } = e;
|
|
1002
|
+
return async (n) => {
|
|
1003
|
+
const [i, o] = n, a = new Request(i, o);
|
|
1004
|
+
if (U(r, a.url) || it(a.method) && U(t, a.url)) {
|
|
1005
|
+
const l = await s.getToken();
|
|
1006
|
+
n = _(rt, l, n);
|
|
886
1007
|
}
|
|
887
|
-
return
|
|
1008
|
+
return w(n);
|
|
888
1009
|
};
|
|
889
1010
|
}
|
|
890
|
-
function
|
|
1011
|
+
function it(s) {
|
|
891
1012
|
const e = s.toLowerCase();
|
|
892
1013
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
893
1014
|
}
|
|
894
|
-
function
|
|
1015
|
+
function U(s, e) {
|
|
895
1016
|
const t = new URL(e);
|
|
896
|
-
return s.some((
|
|
1017
|
+
return s.some((r) => t.pathname.includes(r));
|
|
897
1018
|
}
|
|
898
|
-
function
|
|
899
|
-
const t =
|
|
900
|
-
async function n
|
|
901
|
-
const
|
|
902
|
-
return fetch(
|
|
1019
|
+
function ot(s, e = {}) {
|
|
1020
|
+
const t = nt(s, e);
|
|
1021
|
+
async function r(n) {
|
|
1022
|
+
const i = await t(n);
|
|
1023
|
+
return fetch(i[0], i[1]);
|
|
903
1024
|
}
|
|
904
|
-
return (
|
|
1025
|
+
return (n, i) => i ? i.applyRetry(async () => r(n)) : r(n);
|
|
905
1026
|
}
|
|
906
|
-
const
|
|
907
|
-
class
|
|
1027
|
+
const at = [400, 401, 403];
|
|
1028
|
+
class ct extends re {
|
|
908
1029
|
constructor(e) {
|
|
909
1030
|
super(e), this.csrfTokenManager = e;
|
|
910
1031
|
}
|
|
@@ -912,7 +1033,7 @@ class Ne extends N {
|
|
|
912
1033
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
913
1034
|
*/
|
|
914
1035
|
async shouldRetry(e, t) {
|
|
915
|
-
return t.attempt >= 1 ? !1 :
|
|
1036
|
+
return t.attempt >= 1 ? !1 : at.includes(e.status);
|
|
916
1037
|
}
|
|
917
1038
|
/**
|
|
918
1039
|
* CSRF token refresh should happen immediately with no delay.
|
|
@@ -930,7 +1051,7 @@ class Ne extends N {
|
|
|
930
1051
|
await this.csrfTokenManager.refreshToken();
|
|
931
1052
|
}
|
|
932
1053
|
}
|
|
933
|
-
class
|
|
1054
|
+
class lt {
|
|
934
1055
|
constructor(e, t) {
|
|
935
1056
|
this.endpoint = e, this.cacheName = t, this.tokenPromise = this.obtainToken();
|
|
936
1057
|
}
|
|
@@ -959,10 +1080,10 @@ class Ue {
|
|
|
959
1080
|
* @returns Promise that resolves to the CSRF token string
|
|
960
1081
|
*/
|
|
961
1082
|
async obtainToken() {
|
|
962
|
-
let e = await this.withCache((
|
|
1083
|
+
let e = await this.withCache((n) => n.match(this.endpoint)), t = !1;
|
|
963
1084
|
e || (e = await fetch(this.endpoint, { method: "get" }), t = !0);
|
|
964
|
-
const
|
|
965
|
-
return t && await this.withCache((
|
|
1085
|
+
const r = (await e.clone().json()).csrfToken;
|
|
1086
|
+
return t && await this.withCache((n) => n.put(this.endpoint, e)), r;
|
|
966
1087
|
}
|
|
967
1088
|
/**
|
|
968
1089
|
* Provides a safe way to interact with the Cache API with fallback for unsupported environments.
|
|
@@ -978,56 +1099,242 @@ class Ue {
|
|
|
978
1099
|
return;
|
|
979
1100
|
}
|
|
980
1101
|
}
|
|
981
|
-
const
|
|
982
|
-
function
|
|
983
|
-
const { endpoint: e, cacheName: t, ...
|
|
984
|
-
let
|
|
985
|
-
return
|
|
1102
|
+
const V = /* @__PURE__ */ new Map();
|
|
1103
|
+
function ut(s) {
|
|
1104
|
+
const { endpoint: e, cacheName: t, ...r } = s.csrf;
|
|
1105
|
+
let n = V.get(e);
|
|
1106
|
+
return n || (n = new lt(e, t), V.set(e, n)), K(
|
|
986
1107
|
{
|
|
987
|
-
retry:
|
|
988
|
-
request: [
|
|
1108
|
+
retry: ot(n, r),
|
|
1109
|
+
request: [st]
|
|
989
1110
|
},
|
|
990
|
-
|
|
1111
|
+
ne(new ct(n)).service
|
|
991
1112
|
).service;
|
|
992
1113
|
}
|
|
993
|
-
function
|
|
1114
|
+
function dt(s) {
|
|
1115
|
+
const e = ie().service, t = ae(e).service, r = oe(e, t).service, n = ce().service;
|
|
1116
|
+
return {
|
|
1117
|
+
cache: e,
|
|
1118
|
+
services: { cacheController: r, pubSub: n, fetch: s }
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
function J() {
|
|
994
1122
|
return {
|
|
995
1123
|
"Content-Type": "application/json",
|
|
996
1124
|
Accept: "application/json",
|
|
997
1125
|
"X-Chatter-Entity-Encoding": "false"
|
|
998
1126
|
};
|
|
999
1127
|
}
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1128
|
+
const W = 300;
|
|
1129
|
+
function ht(s, e) {
|
|
1130
|
+
try {
|
|
1131
|
+
return JSON.parse(JSON.stringify(s));
|
|
1132
|
+
} catch (t) {
|
|
1133
|
+
const r = e || "(anonymous)", n = new TypeError(
|
|
1134
|
+
`HttpGraphQLResourceCacheControlCommand: variables for operation "${r}" must be JSON-serializable. ${t.message}`
|
|
1135
|
+
);
|
|
1136
|
+
throw n.cause = t, n;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
class ft extends le {
|
|
1140
|
+
constructor(e, t, r) {
|
|
1141
|
+
super(t), this.url = r, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = ht(
|
|
1142
|
+
e.variables ?? {},
|
|
1143
|
+
this.normalizedOperationName
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
query;
|
|
1147
|
+
normalizedVariables;
|
|
1148
|
+
normalizedOperationName;
|
|
1149
|
+
get fetchParams() {
|
|
1150
|
+
return [
|
|
1151
|
+
this.url,
|
|
1152
|
+
{
|
|
1153
|
+
method: "POST",
|
|
1154
|
+
headers: J(),
|
|
1155
|
+
body: JSON.stringify({
|
|
1156
|
+
query: this.query,
|
|
1157
|
+
variables: this.normalizedVariables,
|
|
1158
|
+
operationName: this.normalizedOperationName
|
|
1159
|
+
})
|
|
1160
|
+
}
|
|
1161
|
+
];
|
|
1162
|
+
}
|
|
1163
|
+
buildKey() {
|
|
1164
|
+
return Z({
|
|
1165
|
+
query: this.query,
|
|
1166
|
+
variables: this.normalizedVariables,
|
|
1167
|
+
operationName: this.normalizedOperationName
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Reads from the cache and returns the cache result or error
|
|
1172
|
+
*
|
|
1173
|
+
* In case of a missing or partial result, this should return either a DataNotFoundError or
|
|
1174
|
+
* DataIncompleteError, respectively, in the Error response
|
|
1175
|
+
*
|
|
1176
|
+
* Note that any subclass should JUST try to read the data from the cache here; it should
|
|
1177
|
+
* NOT try to take metadata (eg cache control semantics) into account while reading the
|
|
1178
|
+
* data. The CacheController is responsible for enforcing those semantics.
|
|
1179
|
+
*
|
|
1180
|
+
* @param cache source of cached data
|
|
1181
|
+
* @returns result or error from the cache
|
|
1182
|
+
*/
|
|
1183
|
+
readFromCache(e) {
|
|
1184
|
+
const t = this.buildKey(), r = e.get(t)?.value;
|
|
1185
|
+
return r === void 0 ? w(D(new ee())) : w(I(r));
|
|
1186
|
+
}
|
|
1187
|
+
writeToCache(e, t) {
|
|
1188
|
+
if (t.isOk() && t.value.data != null && Object.keys(t.value.data).length > 0) {
|
|
1189
|
+
const r = Math.floor(Date.now() / 1e3);
|
|
1190
|
+
e.set(this.buildKey(), {
|
|
1191
|
+
value: t.value.data,
|
|
1192
|
+
metadata: {
|
|
1193
|
+
cacheControl: {
|
|
1194
|
+
type: "max-age",
|
|
1195
|
+
maxAge: W,
|
|
1196
|
+
generatedTime: r
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
return w(void 0);
|
|
1202
|
+
}
|
|
1203
|
+
get cacheControlStrategyConfig() {
|
|
1204
|
+
return {
|
|
1205
|
+
type: "max-age",
|
|
1206
|
+
requestMaxAge: W,
|
|
1207
|
+
now: Math.floor(Date.now() / 1e3)
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
responseHasErrors(e) {
|
|
1211
|
+
return e.errors && e.errors.length > 0;
|
|
1212
|
+
}
|
|
1213
|
+
processFetchReturnValue(e) {
|
|
1214
|
+
return this.responseHasErrors(e) ? D(new te(e)) : I(e);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function pt(s) {
|
|
1218
|
+
return (e) => {
|
|
1219
|
+
if (e.isOk()) {
|
|
1220
|
+
const t = e.value;
|
|
1221
|
+
z(t), s({ data: t, errors: void 0 });
|
|
1222
|
+
} else
|
|
1223
|
+
s({ data: void 0, errors: b(e.error) });
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
async function gt(s) {
|
|
1227
|
+
let e, t, r;
|
|
1228
|
+
try {
|
|
1229
|
+
const n = await s.execute();
|
|
1230
|
+
n.isOk() ? (e = n.value.data, z(e), r = (i) => n.value.subscribe(i)) : (t = b(n.error.failure), r = (i) => n.error.subscribe(i));
|
|
1231
|
+
} catch (n) {
|
|
1232
|
+
t = b(n);
|
|
1233
|
+
}
|
|
1234
|
+
return {
|
|
1235
|
+
data: e,
|
|
1236
|
+
errors: t,
|
|
1237
|
+
subscribe(n) {
|
|
1238
|
+
return r ? r(pt(n)) : E;
|
|
1239
|
+
},
|
|
1240
|
+
async refresh() {
|
|
1241
|
+
await s.refresh();
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
function M(s) {
|
|
1246
|
+
return {
|
|
1247
|
+
data: void 0,
|
|
1248
|
+
errors: s,
|
|
1249
|
+
subscribe: () => E,
|
|
1250
|
+
refresh: L
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
function mt({
|
|
1254
|
+
bundle: s,
|
|
1255
|
+
url: e,
|
|
1256
|
+
executeRaw: t
|
|
1257
|
+
}) {
|
|
1258
|
+
const { services: r } = s;
|
|
1259
|
+
async function n({
|
|
1260
|
+
query: i,
|
|
1261
|
+
variables: o,
|
|
1262
|
+
operationName: a
|
|
1263
|
+
}) {
|
|
1264
|
+
const u = H(i);
|
|
1265
|
+
if (u.isErr()) return M(u.error);
|
|
1266
|
+
const l = u.value, f = q(l, a);
|
|
1267
|
+
if (f !== "query")
|
|
1268
|
+
return M([
|
|
1269
|
+
{
|
|
1270
|
+
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
1271
|
+
}
|
|
1272
|
+
]);
|
|
1273
|
+
let p;
|
|
1274
|
+
try {
|
|
1275
|
+
p = new ft(
|
|
1276
|
+
{
|
|
1277
|
+
query: R(l),
|
|
1278
|
+
variables: o,
|
|
1279
|
+
operationName: a
|
|
1280
|
+
},
|
|
1281
|
+
r,
|
|
1282
|
+
e
|
|
1283
|
+
);
|
|
1284
|
+
} catch (d) {
|
|
1285
|
+
return M(b(d));
|
|
1286
|
+
}
|
|
1287
|
+
return gt(p);
|
|
1288
|
+
}
|
|
1289
|
+
return {
|
|
1290
|
+
query: n,
|
|
1291
|
+
mutate: (i) => j(t, i)
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
const yt = 1, wt = `@salesforce/platform-sdk-data_v${yt}`, X = G(), bt = `${X}/ui-api`, $ = `${X}/graphql`;
|
|
1295
|
+
class vt {
|
|
1002
1296
|
baseUrl;
|
|
1003
1297
|
clientFetch;
|
|
1004
1298
|
onStatus;
|
|
1299
|
+
graphql;
|
|
1005
1300
|
constructor(e) {
|
|
1006
|
-
const t =
|
|
1007
|
-
this.baseUrl =
|
|
1301
|
+
const t = Ct();
|
|
1302
|
+
this.baseUrl = St(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = ut({
|
|
1008
1303
|
csrf: {
|
|
1009
|
-
endpoint: `${this.baseUrl}${
|
|
1010
|
-
cacheName:
|
|
1304
|
+
endpoint: `${this.baseUrl}${bt}/session/csrf`,
|
|
1305
|
+
cacheName: wt,
|
|
1011
1306
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
1012
1307
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
1013
1308
|
}
|
|
1014
1309
|
});
|
|
1310
|
+
const n = dt((i, o) => this.fetch(i, o));
|
|
1311
|
+
this.graphql = mt({
|
|
1312
|
+
bundle: n,
|
|
1313
|
+
url: $,
|
|
1314
|
+
executeRaw: this.executeRawGraphQL.bind(this)
|
|
1315
|
+
});
|
|
1015
1316
|
}
|
|
1016
|
-
async
|
|
1317
|
+
async fetch(e, t) {
|
|
1318
|
+
const r = this.applySalesforceBase(e), n = await this.clientFetch(r, t);
|
|
1319
|
+
return await this.onStatus[n.status]?.(), n;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Raw GraphQL POST. Used internally by `graphql.mutate` (which has no
|
|
1323
|
+
* cache concern) and transitively by `graphql.query` on cache miss
|
|
1324
|
+
* (the OneStore cache command's fetch service is bound to this same
|
|
1325
|
+
* SDK's `fetch`, which in turn calls this method's caller patterns).
|
|
1326
|
+
*/
|
|
1327
|
+
async executeRawGraphQL({
|
|
1017
1328
|
query: e,
|
|
1018
1329
|
variables: t,
|
|
1019
|
-
operationName:
|
|
1330
|
+
operationName: r
|
|
1020
1331
|
}) {
|
|
1021
|
-
return (await this.fetch(
|
|
1332
|
+
return (await this.fetch($, {
|
|
1022
1333
|
method: "POST",
|
|
1023
|
-
body: JSON.stringify({ query: e, variables: t, operationName:
|
|
1024
|
-
headers:
|
|
1334
|
+
body: JSON.stringify({ query: e, variables: t, operationName: r }),
|
|
1335
|
+
headers: J()
|
|
1025
1336
|
})).json();
|
|
1026
1337
|
}
|
|
1027
|
-
async fetch(e, t) {
|
|
1028
|
-
const n = this.applySalesforceBase(e), i = await this.clientFetch(n, t);
|
|
1029
|
-
return await this.onStatus[i.status]?.(), i;
|
|
1030
|
-
}
|
|
1031
1338
|
/**
|
|
1032
1339
|
* If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
|
|
1033
1340
|
* Builder deployments structure the url for Salesforce
|
|
@@ -1042,35 +1349,35 @@ class Ke {
|
|
|
1042
1349
|
return e;
|
|
1043
1350
|
}
|
|
1044
1351
|
}
|
|
1045
|
-
function
|
|
1352
|
+
function Ct() {
|
|
1046
1353
|
return {
|
|
1047
1354
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
1048
1355
|
};
|
|
1049
1356
|
}
|
|
1050
|
-
function
|
|
1357
|
+
function St(s) {
|
|
1051
1358
|
if (!s || s === "/") return "";
|
|
1052
1359
|
let e = s;
|
|
1053
1360
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
1054
1361
|
}
|
|
1055
|
-
function
|
|
1362
|
+
function as(s, ...e) {
|
|
1056
1363
|
let t = s[0] ?? "";
|
|
1057
|
-
for (let
|
|
1058
|
-
t += String(e[
|
|
1364
|
+
for (let r = 0; r < e.length; r += 1)
|
|
1365
|
+
t += String(e[r]) + (s[r + 1] ?? "");
|
|
1059
1366
|
return t;
|
|
1060
1367
|
}
|
|
1061
|
-
function
|
|
1062
|
-
return
|
|
1368
|
+
function cs(s) {
|
|
1369
|
+
return k(
|
|
1063
1370
|
(async () => {
|
|
1064
|
-
switch (
|
|
1065
|
-
case
|
|
1066
|
-
return new
|
|
1067
|
-
case
|
|
1068
|
-
case
|
|
1069
|
-
return new
|
|
1070
|
-
case
|
|
1071
|
-
return new
|
|
1072
|
-
case
|
|
1073
|
-
case
|
|
1371
|
+
switch (C(s?.surface)) {
|
|
1372
|
+
case c.OpenAI:
|
|
1373
|
+
return new Xe();
|
|
1374
|
+
case c.WebApp:
|
|
1375
|
+
case c.MicroFrontend:
|
|
1376
|
+
return new vt(s?.webapp);
|
|
1377
|
+
case c.Mosaic:
|
|
1378
|
+
return new je(s?.mosaic);
|
|
1379
|
+
case c.SalesforceACC:
|
|
1380
|
+
case c.MCPApps:
|
|
1074
1381
|
return {};
|
|
1075
1382
|
default:
|
|
1076
1383
|
return {};
|
|
@@ -1079,21 +1386,21 @@ function Mt(s) {
|
|
|
1079
1386
|
"createDataSDK"
|
|
1080
1387
|
);
|
|
1081
1388
|
}
|
|
1082
|
-
function
|
|
1083
|
-
return
|
|
1389
|
+
function ls(s) {
|
|
1390
|
+
return k(
|
|
1084
1391
|
(async () => {
|
|
1085
|
-
switch (
|
|
1086
|
-
case
|
|
1392
|
+
switch (C(s?.surface)) {
|
|
1393
|
+
case c.OpenAI:
|
|
1087
1394
|
return {};
|
|
1088
|
-
case
|
|
1395
|
+
case c.WebApp:
|
|
1089
1396
|
return {};
|
|
1090
|
-
case
|
|
1397
|
+
case c.MicroFrontend:
|
|
1091
1398
|
return {};
|
|
1092
|
-
case
|
|
1399
|
+
case c.SalesforceACC:
|
|
1093
1400
|
return {};
|
|
1094
|
-
case
|
|
1401
|
+
case c.MCPApps:
|
|
1095
1402
|
return {};
|
|
1096
|
-
case
|
|
1403
|
+
case c.Mosaic:
|
|
1097
1404
|
return {};
|
|
1098
1405
|
default:
|
|
1099
1406
|
return {};
|
|
@@ -1102,7 +1409,7 @@ function Et(s) {
|
|
|
1102
1409
|
"createLightningSDK"
|
|
1103
1410
|
);
|
|
1104
1411
|
}
|
|
1105
|
-
class
|
|
1412
|
+
class Tt {
|
|
1106
1413
|
buffer;
|
|
1107
1414
|
constructor(e) {
|
|
1108
1415
|
this.buffer = e;
|
|
@@ -1114,13 +1421,13 @@ class Je {
|
|
|
1114
1421
|
return { ...e, _telemetry: t };
|
|
1115
1422
|
}
|
|
1116
1423
|
}
|
|
1117
|
-
function
|
|
1424
|
+
function _t(s) {
|
|
1118
1425
|
let e = "";
|
|
1119
|
-
for (let
|
|
1120
|
-
e += String.fromCharCode.apply(null, Array.from(s.subarray(
|
|
1426
|
+
for (let r = 0; r < s.length; r += 8192)
|
|
1427
|
+
e += String.fromCharCode.apply(null, Array.from(s.subarray(r, r + 8192)));
|
|
1121
1428
|
return btoa(e);
|
|
1122
1429
|
}
|
|
1123
|
-
class
|
|
1430
|
+
class Et {
|
|
1124
1431
|
entries = [];
|
|
1125
1432
|
totalBytes = 0;
|
|
1126
1433
|
maxBufferSize;
|
|
@@ -1135,14 +1442,14 @@ class Ye {
|
|
|
1135
1442
|
return this.entries.length === 0;
|
|
1136
1443
|
}
|
|
1137
1444
|
enqueue(e, t) {
|
|
1138
|
-
const
|
|
1139
|
-
data:
|
|
1445
|
+
const r = _t(e), n = {
|
|
1446
|
+
data: r,
|
|
1140
1447
|
traceId: t?.traceId,
|
|
1141
1448
|
instanceId: t?.instanceId,
|
|
1142
1449
|
componentRef: t?.componentRef,
|
|
1143
1450
|
timestamp: Date.now()
|
|
1144
|
-
},
|
|
1145
|
-
this.entries.push(
|
|
1451
|
+
}, i = r.length;
|
|
1452
|
+
this.entries.push(n), this.totalBytes += i, this.totalBytes > this.maxBufferSize && this.evict();
|
|
1146
1453
|
}
|
|
1147
1454
|
drain() {
|
|
1148
1455
|
const e = this.entries;
|
|
@@ -1157,7 +1464,7 @@ class Ye {
|
|
|
1157
1464
|
e > 0 && this.onError?.({ reason: "buffer_overflow", droppedCount: e });
|
|
1158
1465
|
}
|
|
1159
1466
|
}
|
|
1160
|
-
class
|
|
1467
|
+
class At {
|
|
1161
1468
|
buffer;
|
|
1162
1469
|
sdk;
|
|
1163
1470
|
timerId = null;
|
|
@@ -1168,8 +1475,8 @@ class Ge {
|
|
|
1168
1475
|
handlePageHide = () => {
|
|
1169
1476
|
this.flush();
|
|
1170
1477
|
};
|
|
1171
|
-
constructor(e, t,
|
|
1172
|
-
this.buffer = e, this.sdk = t, this.timerId = setInterval(() => this.flush(),
|
|
1478
|
+
constructor(e, t, r) {
|
|
1479
|
+
this.buffer = e, this.sdk = t, this.timerId = setInterval(() => this.flush(), r), document.addEventListener("visibilitychange", this.handleVisibilityChange), window.addEventListener("pagehide", this.handlePageHide);
|
|
1173
1480
|
}
|
|
1174
1481
|
flush() {
|
|
1175
1482
|
if (this.buffer.isEmpty || !this.sdk.setWidgetState)
|
|
@@ -1181,37 +1488,37 @@ class Ge {
|
|
|
1181
1488
|
this.disposed || (this.disposed = !0, this.timerId !== null && (clearInterval(this.timerId), this.timerId = null), document.removeEventListener("visibilitychange", this.handleVisibilityChange), window.removeEventListener("pagehide", this.handlePageHide), this.flush());
|
|
1182
1489
|
}
|
|
1183
1490
|
}
|
|
1184
|
-
const
|
|
1185
|
-
function
|
|
1491
|
+
const kt = 65536, Mt = 3e4;
|
|
1492
|
+
function us(s) {
|
|
1186
1493
|
const {
|
|
1187
1494
|
sdk: e,
|
|
1188
1495
|
flushOnAction: t = !0,
|
|
1189
|
-
maxBufferSize:
|
|
1190
|
-
flushInterval:
|
|
1191
|
-
onError:
|
|
1192
|
-
} = s,
|
|
1496
|
+
maxBufferSize: r = kt,
|
|
1497
|
+
flushInterval: n = Mt,
|
|
1498
|
+
onError: i
|
|
1499
|
+
} = s, o = new Et({ maxBufferSize: r, onError: i }), a = new Tt(o), u = new At(o, e, n);
|
|
1193
1500
|
return {
|
|
1194
|
-
enqueue(
|
|
1195
|
-
|
|
1501
|
+
enqueue(l, f) {
|
|
1502
|
+
o.enqueue(l, f);
|
|
1196
1503
|
},
|
|
1197
|
-
wrapAction(
|
|
1198
|
-
return t ?
|
|
1504
|
+
wrapAction(l) {
|
|
1505
|
+
return t ? a.wrapAction(l) : l;
|
|
1199
1506
|
},
|
|
1200
1507
|
dispose() {
|
|
1201
|
-
|
|
1508
|
+
u.dispose();
|
|
1202
1509
|
}
|
|
1203
1510
|
};
|
|
1204
1511
|
}
|
|
1205
|
-
const
|
|
1206
|
-
function
|
|
1512
|
+
const It = 1e4, Dt = 10, Pt = 10, Lt = 250, Rt = 1e3;
|
|
1513
|
+
function v(s, e) {
|
|
1207
1514
|
if (s !== void 0 && (typeof s != "number" || !Number.isFinite(s) || s <= 0))
|
|
1208
1515
|
throw new Error(`${e}, if defined, must be a finite number greater than 0`);
|
|
1209
1516
|
}
|
|
1210
|
-
function
|
|
1517
|
+
function xt(s, e) {
|
|
1211
1518
|
if (typeof s != "function")
|
|
1212
1519
|
throw new Error(`${e} must be a function`);
|
|
1213
1520
|
}
|
|
1214
|
-
class
|
|
1521
|
+
class Ot {
|
|
1215
1522
|
_collector;
|
|
1216
1523
|
_onEnvelope;
|
|
1217
1524
|
_onError;
|
|
@@ -1232,7 +1539,7 @@ class ot {
|
|
|
1232
1539
|
_lastClickTriggeredAt = 0;
|
|
1233
1540
|
_isDisposed = !1;
|
|
1234
1541
|
constructor(e) {
|
|
1235
|
-
|
|
1542
|
+
xt(e?.onEnvelope, "options.onEnvelope"), v(e.uploadInterval, "options.uploadInterval"), v(e.messagesLimit, "options.messagesLimit"), v(e.metricsLimit, "options.metricsLimit"), v(e.maxUniqueSchemas, "options.maxUniqueSchemas"), v(e.clickUploadDelay, "options.clickUploadDelay"), v(e.clickTriggerCooldown, "options.clickTriggerCooldown"), this._onEnvelope = e.onEnvelope, this._onError = e.onError, this._messagesLimit = e.messagesLimit ?? Dt, this._metricsLimit = e.metricsLimit ?? Pt, this._uploadInterval = e.uploadInterval ?? It, this._clickUploadDelay = e.clickUploadDelay ?? Lt, this._clickTriggerCooldown = e.clickTriggerCooldown ?? Rt, this._enableClickTrigger = e.enableClickTrigger !== !1, this._enableVisibilityTrigger = e.enableVisibilityTrigger !== !1, this._collector = new de({
|
|
1236
1543
|
environment: e.environment,
|
|
1237
1544
|
maxUniqueSchemas: e.maxUniqueSchemas
|
|
1238
1545
|
}), this._restartInterval(), this._attachWindowListeners();
|
|
@@ -1252,11 +1559,11 @@ class ot {
|
|
|
1252
1559
|
getIsCollectDisabled() {
|
|
1253
1560
|
return this._isDisposed;
|
|
1254
1561
|
}
|
|
1255
|
-
collect(e, t,
|
|
1562
|
+
collect(e, t, r) {
|
|
1256
1563
|
this._collector.collect(
|
|
1257
1564
|
e,
|
|
1258
1565
|
t,
|
|
1259
|
-
|
|
1566
|
+
r
|
|
1260
1567
|
), this._shouldFlushForThreshold() && this.flush("threshold");
|
|
1261
1568
|
}
|
|
1262
1569
|
receiveMetricsExtractors(e) {
|
|
@@ -1312,62 +1619,62 @@ class ot {
|
|
|
1312
1619
|
metricsCount: this.metricsCount,
|
|
1313
1620
|
estimatedByteSize: this.estimatedByteSize,
|
|
1314
1621
|
triggeredAt: Date.now()
|
|
1315
|
-
},
|
|
1622
|
+
}, r = this._collector.getRawContentsOfCoreEnvelope(), n = ue(r);
|
|
1316
1623
|
this._restartInterval();
|
|
1317
1624
|
try {
|
|
1318
|
-
await this._onEnvelope(
|
|
1319
|
-
} catch (
|
|
1320
|
-
const
|
|
1625
|
+
await this._onEnvelope(n, t);
|
|
1626
|
+
} catch (i) {
|
|
1627
|
+
const o = {
|
|
1321
1628
|
...t,
|
|
1322
|
-
error:
|
|
1629
|
+
error: i
|
|
1323
1630
|
};
|
|
1324
|
-
throw this._onError?.(
|
|
1631
|
+
throw this._onError?.(o), i;
|
|
1325
1632
|
}
|
|
1326
1633
|
}
|
|
1327
1634
|
}
|
|
1328
|
-
function
|
|
1635
|
+
function Ht(s, e) {
|
|
1329
1636
|
if (!s)
|
|
1330
1637
|
throw new Error("instrumentedApp is required");
|
|
1331
|
-
const t = new
|
|
1638
|
+
const t = new Ot(e);
|
|
1332
1639
|
return s.registerLogCollector(t), s.registerMetricsCollector(t), e.enableClickTrigger !== !1 && s.activateClickTracker?.(), t;
|
|
1333
1640
|
}
|
|
1334
|
-
function
|
|
1335
|
-
const e = (n, i,
|
|
1336
|
-
s.error(
|
|
1337
|
-
}, t = (
|
|
1338
|
-
s.error(
|
|
1641
|
+
function qt(s) {
|
|
1642
|
+
const e = (r, n, i, o, a) => {
|
|
1643
|
+
s.error(a ?? r);
|
|
1644
|
+
}, t = (r) => {
|
|
1645
|
+
s.error(r.reason);
|
|
1339
1646
|
};
|
|
1340
1647
|
return window.addEventListener("error", e), window.addEventListener("unhandledrejection", t), () => {
|
|
1341
1648
|
window.removeEventListener("error", e), window.removeEventListener("unhandledrejection", t);
|
|
1342
1649
|
};
|
|
1343
1650
|
}
|
|
1344
|
-
function
|
|
1651
|
+
function m(s, e) {
|
|
1345
1652
|
return { surface: e };
|
|
1346
1653
|
}
|
|
1347
|
-
const
|
|
1654
|
+
const Nt = {
|
|
1348
1655
|
callTool: {
|
|
1349
1656
|
isAsync: !0,
|
|
1350
1657
|
extractTags: (s, e) => ({ toolName: s[0]?.toolName ?? "unknown", surface: e })
|
|
1351
1658
|
},
|
|
1352
1659
|
setWidgetState: {
|
|
1353
1660
|
isAsync: !1,
|
|
1354
|
-
extractTags:
|
|
1661
|
+
extractTags: m
|
|
1355
1662
|
},
|
|
1356
1663
|
getWidgetState: {
|
|
1357
1664
|
isAsync: !1,
|
|
1358
|
-
extractTags:
|
|
1665
|
+
extractTags: m
|
|
1359
1666
|
},
|
|
1360
1667
|
sendMessageToHost: {
|
|
1361
1668
|
isAsync: !0,
|
|
1362
|
-
extractTags:
|
|
1669
|
+
extractTags: m
|
|
1363
1670
|
},
|
|
1364
1671
|
openLink: {
|
|
1365
1672
|
isAsync: !0,
|
|
1366
|
-
extractTags:
|
|
1673
|
+
extractTags: m
|
|
1367
1674
|
},
|
|
1368
1675
|
subscribe: {
|
|
1369
1676
|
isAsync: !1,
|
|
1370
|
-
extractTags:
|
|
1677
|
+
extractTags: m,
|
|
1371
1678
|
wrapArgs: (s, e) => {
|
|
1372
1679
|
const t = s[0];
|
|
1373
1680
|
return [
|
|
@@ -1387,126 +1694,126 @@ const lt = {
|
|
|
1387
1694
|
},
|
|
1388
1695
|
accessToolOutput: {
|
|
1389
1696
|
isAsync: !1,
|
|
1390
|
-
extractTags:
|
|
1697
|
+
extractTags: m
|
|
1391
1698
|
},
|
|
1392
1699
|
accessToolInput: {
|
|
1393
1700
|
isAsync: !1,
|
|
1394
|
-
extractTags:
|
|
1701
|
+
extractTags: m
|
|
1395
1702
|
},
|
|
1396
1703
|
accessToolMetadata: {
|
|
1397
1704
|
isAsync: !1,
|
|
1398
|
-
extractTags:
|
|
1705
|
+
extractTags: m
|
|
1399
1706
|
}
|
|
1400
1707
|
};
|
|
1401
|
-
function
|
|
1708
|
+
function Ft(s, e, t) {
|
|
1402
1709
|
return new Proxy(s, {
|
|
1403
|
-
get(n, i
|
|
1404
|
-
const
|
|
1405
|
-
return !
|
|
1406
|
-
const
|
|
1407
|
-
return
|
|
1710
|
+
get(r, n, i) {
|
|
1711
|
+
const o = Reflect.get(r, n, i), a = Nt[n];
|
|
1712
|
+
return !a || typeof o != "function" ? o : (...u) => {
|
|
1713
|
+
const l = a.extractTags(u, t), f = a.wrapArgs ? a.wrapArgs(u, e) : u, p = `sdk.${String(n)}`;
|
|
1714
|
+
return a.isAsync ? e.activityAsync(p, async () => {
|
|
1408
1715
|
try {
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
|
|
1716
|
+
const d = await o.apply(
|
|
1717
|
+
r,
|
|
1718
|
+
f
|
|
1412
1719
|
);
|
|
1413
|
-
return e.incrementCounter(
|
|
1414
|
-
} catch (
|
|
1415
|
-
throw e.incrementCounter(
|
|
1720
|
+
return e.incrementCounter(p, 1, !1, l), d;
|
|
1721
|
+
} catch (d) {
|
|
1722
|
+
throw e.incrementCounter(p, 1, !0, l), d;
|
|
1416
1723
|
}
|
|
1417
|
-
}) : (e.incrementCounter(
|
|
1724
|
+
}) : (e.incrementCounter(p, 1, !1, l), o.apply(r, f));
|
|
1418
1725
|
};
|
|
1419
1726
|
}
|
|
1420
1727
|
});
|
|
1421
1728
|
}
|
|
1422
|
-
async function
|
|
1423
|
-
const { appId: e, clientSessionId: t } = s,
|
|
1729
|
+
async function ds(s) {
|
|
1730
|
+
const { appId: e, clientSessionId: t } = s, r = C(), n = Date.now(), i = s.sdk ?? await qe(), o = he("mcp-widget", {
|
|
1424
1731
|
appPayloadProvider: {
|
|
1425
1732
|
getPayload: () => ({
|
|
1426
|
-
schema:
|
|
1427
|
-
payload: { appId: e, surface:
|
|
1733
|
+
schema: fe,
|
|
1734
|
+
payload: { appId: e, surface: r }
|
|
1428
1735
|
})
|
|
1429
1736
|
},
|
|
1430
1737
|
clientSessionId: t
|
|
1431
|
-
}),
|
|
1432
|
-
let
|
|
1738
|
+
}), a = o, u = Ft(i, a, r), l = qt(a);
|
|
1739
|
+
let f;
|
|
1433
1740
|
if (s.transport) {
|
|
1434
|
-
|
|
1435
|
-
onEnvelope: (
|
|
1436
|
-
s.transport.enqueue(
|
|
1741
|
+
f = Ht(o, {
|
|
1742
|
+
onEnvelope: (g) => {
|
|
1743
|
+
s.transport.enqueue(g);
|
|
1437
1744
|
}
|
|
1438
1745
|
});
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1441
|
-
const
|
|
1442
|
-
return
|
|
1443
|
-
...
|
|
1444
|
-
params:
|
|
1746
|
+
const h = u.callTool;
|
|
1747
|
+
h && (u.callTool = (g) => {
|
|
1748
|
+
const Y = s.transport.wrapAction(g.params ?? {});
|
|
1749
|
+
return h.call(u, {
|
|
1750
|
+
...g,
|
|
1751
|
+
params: Y
|
|
1445
1752
|
});
|
|
1446
1753
|
});
|
|
1447
1754
|
}
|
|
1448
|
-
let
|
|
1755
|
+
let p, d = !1;
|
|
1449
1756
|
return {
|
|
1450
|
-
instrumentedSDK:
|
|
1451
|
-
app:
|
|
1452
|
-
trackEvent(
|
|
1453
|
-
|
|
1454
|
-
eventName:
|
|
1455
|
-
properties:
|
|
1757
|
+
instrumentedSDK: u,
|
|
1758
|
+
app: o,
|
|
1759
|
+
trackEvent(h, g) {
|
|
1760
|
+
d || a.log(we, {
|
|
1761
|
+
eventName: h,
|
|
1762
|
+
properties: g ? JSON.stringify(g) : ""
|
|
1456
1763
|
});
|
|
1457
1764
|
},
|
|
1458
|
-
trackInteraction(
|
|
1459
|
-
|
|
1460
|
-
elementId:
|
|
1461
|
-
properties:
|
|
1765
|
+
trackInteraction(h, g) {
|
|
1766
|
+
d || a.log(ye, {
|
|
1767
|
+
elementId: h,
|
|
1768
|
+
properties: g ? JSON.stringify(g) : ""
|
|
1462
1769
|
});
|
|
1463
1770
|
},
|
|
1464
|
-
trackError(
|
|
1465
|
-
|
|
1466
|
-
properties:
|
|
1771
|
+
trackError(h, g) {
|
|
1772
|
+
d || a.error(h, me, {
|
|
1773
|
+
properties: g ? JSON.stringify(g) : ""
|
|
1467
1774
|
});
|
|
1468
1775
|
},
|
|
1469
|
-
trackPageView(
|
|
1470
|
-
|
|
1776
|
+
trackPageView(h) {
|
|
1777
|
+
d || h !== p && (p = h, a.log(ge, { componentRef: h }));
|
|
1471
1778
|
},
|
|
1472
1779
|
dispose() {
|
|
1473
|
-
if (
|
|
1474
|
-
|
|
1475
|
-
const
|
|
1476
|
-
|
|
1780
|
+
if (d) return;
|
|
1781
|
+
d = !0, l();
|
|
1782
|
+
const h = Date.now() - n;
|
|
1783
|
+
a.log(pe, { durationMs: h }), f?.dispose();
|
|
1477
1784
|
}
|
|
1478
1785
|
};
|
|
1479
1786
|
}
|
|
1480
1787
|
export {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1788
|
+
Ee as JsonRpcClient,
|
|
1789
|
+
xe as MCPAppsChatSDK,
|
|
1790
|
+
Ue as MCPAppsViewSDK,
|
|
1791
|
+
y as McpAppsSession,
|
|
1792
|
+
es as MessageChannelTransport,
|
|
1793
|
+
c as Surface,
|
|
1794
|
+
Ot as TelemetryUploader,
|
|
1795
|
+
_e as WindowPostMessageTransport,
|
|
1796
|
+
ds as createAnalytics,
|
|
1797
|
+
Ne as createChatSDK,
|
|
1798
|
+
cs as createDataSDK,
|
|
1799
|
+
ls as createLightningSDK,
|
|
1800
|
+
us as createTelemetryTransport,
|
|
1801
|
+
We as createViewSDK,
|
|
1802
|
+
qe as getChatSDK,
|
|
1803
|
+
ss as getChatSDKSync,
|
|
1804
|
+
C as getSurface,
|
|
1805
|
+
ts as getSurfaceCapabilities,
|
|
1806
|
+
ns as getViewSDK,
|
|
1807
|
+
is as getViewSDKSync,
|
|
1808
|
+
as as gql,
|
|
1809
|
+
A as isJsonRpcBase,
|
|
1810
|
+
B as isJsonRpcErrorResponse,
|
|
1811
|
+
Te as isJsonRpcNotification,
|
|
1812
|
+
Zt as isJsonRpcRequest,
|
|
1813
|
+
Se as isJsonRpcResponse,
|
|
1814
|
+
Ce as isJsonRpcSuccessResponse,
|
|
1815
|
+
Ht as registerTelemetryUploader,
|
|
1816
|
+
rs as resetChatSDK,
|
|
1817
|
+
os as resetViewSDK,
|
|
1818
|
+
k as wrapSDKPromise
|
|
1512
1819
|
};
|