@salesforce/platform-sdk 12.12.1 → 12.14.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.
Files changed (59) hide show
  1. package/dist/analytics/index.js +1 -1
  2. package/dist/{analytics-wESbWdca.js → analytics-TRyVm9Ub.js} +1 -1
  3. package/dist/app/index.js +1 -1
  4. package/dist/{capabilities-B0mU0_G0.js → capabilities-B3Raifjg.js} +2 -1
  5. package/dist/chat/index.d.ts.map +1 -1
  6. package/dist/chat/index.js +11 -10
  7. package/dist/core/capabilities.d.ts +2 -2
  8. package/dist/core/capabilities.d.ts.map +1 -1
  9. package/dist/core/data.d.ts +5 -5
  10. package/dist/core/index.d.ts +2 -2
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +2 -2
  13. package/dist/core/mcpapps-session.d.ts +19 -8
  14. package/dist/core/mcpapps-session.d.ts.map +1 -1
  15. package/dist/core/surface.d.ts +12 -10
  16. package/dist/core/surface.d.ts.map +1 -1
  17. package/dist/core/view.d.ts +118 -4
  18. package/dist/core/view.d.ts.map +1 -1
  19. package/dist/data/index.d.ts +49 -4
  20. package/dist/data/index.d.ts.map +1 -1
  21. package/dist/data/index.js +435 -366
  22. package/dist/data/mcpapps/index.d.ts +9 -0
  23. package/dist/data/mcpapps/index.d.ts.map +1 -0
  24. package/dist/data/mosaic/fetch.d.ts +13 -33
  25. package/dist/data/mosaic/fetch.d.ts.map +1 -1
  26. package/dist/data/mosaic/index.d.ts +0 -14
  27. package/dist/data/mosaic/index.d.ts.map +1 -1
  28. package/dist/data/shared/graphql/parse-response.d.ts +4 -36
  29. package/dist/data/shared/graphql/parse-response.d.ts.map +1 -1
  30. package/dist/data/webapp/csrf/token-manager.d.ts +14 -1
  31. package/dist/data/webapp/csrf/token-manager.d.ts.map +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +3 -3
  35. package/dist/lightning/index.d.ts.map +1 -1
  36. package/dist/lightning/index.js +5 -4
  37. package/dist/observability/vendor/index.d.ts +17 -0
  38. package/dist/observability/vendor/index.d.ts.map +1 -0
  39. package/dist/observability/vendor/names.d.ts +11 -0
  40. package/dist/observability/vendor/names.d.ts.map +1 -0
  41. package/dist/observability/vendor/protocol.d.ts +25 -0
  42. package/dist/observability/vendor/protocol.d.ts.map +1 -0
  43. package/dist/observability/vendor/queue.d.ts +16 -0
  44. package/dist/observability/vendor/queue.d.ts.map +1 -0
  45. package/dist/observability/vendor/verbs.d.ts +19 -0
  46. package/dist/observability/vendor/verbs.d.ts.map +1 -0
  47. package/dist/{surface-DWDgqdpN.js → surface-Cg3eyRpj.js} +44 -26
  48. package/dist/ui-embedding/session.js +1 -1
  49. package/dist/view/embedding.d.ts +18 -1
  50. package/dist/view/embedding.d.ts.map +1 -1
  51. package/dist/view/index.d.ts +1 -1
  52. package/dist/view/index.d.ts.map +1 -1
  53. package/dist/view/index.js +79 -35
  54. package/dist/view/utils.d.ts +5 -0
  55. package/dist/view/utils.d.ts.map +1 -1
  56. package/docs/data/02-caching-and-freshness.md +3 -3
  57. package/docs/data/03-reactive-handle-lifecycle.md +2 -2
  58. package/docs/data/04-surfaces-and-guards.md +60 -6
  59. package/package.json +3 -3
@@ -1,155 +1,57 @@
1
- import { g as W, S as b } from "../surface-DWDgqdpN.js";
2
- import { w as B } from "../sdk-promise-D0sy7OW1.js";
3
- import { buildServiceDescriptor as V, setHeader as y } from "@conduit-client/service-fetch-network/v1";
4
- import { resolvedPromiseLike as p, ok as x, err as A, stableJSONStringify as X, DataNotFoundError as Y, UserVisibleError as Z, deepFreeze as v, isUserVisibleError as ee } from "@conduit-client/utils";
5
- import { print as N, parse as te } from "@conduit-client/onestore-graphql-parser/v1";
6
- import { RetryPolicy as re, buildServiceDescriptor as ne } from "@conduit-client/service-retry/v1";
7
- import { buildServiceDescriptor as se } from "@conduit-client/service-cache/v1";
8
- import { buildServiceDescriptor as ae } from "@conduit-client/service-cache-control/v1";
9
- import { buildInMemoryCacheInclusionPolicyService as oe } from "@conduit-client/service-cache-inclusion-policy/v1";
10
- import { buildServiceDescriptor as ie } from "@conduit-client/service-pubsub/v1";
11
- import { HttpCacheControlCommand as ce } from "@conduit-client/command-http-cache-control/v1";
1
+ import { g as X, S as m, a as _ } from "../surface-Cg3eyRpj.js";
2
+ import { w as Y } from "../sdk-promise-D0sy7OW1.js";
3
+ import { print as k, parse as Z } from "@conduit-client/onestore-graphql-parser/v1";
4
+ import { ok as O, err as q, resolvedPromiseLike as d, stableJSONStringify as ee, DataNotFoundError as te, UserVisibleError as re, deepFreeze as v, isUserVisibleError as ne } from "@conduit-client/utils";
5
+ import { buildServiceDescriptor as H, setHeader as w } from "@conduit-client/service-fetch-network/v1";
6
+ import { RetryPolicy as se, buildServiceDescriptor as ae } from "@conduit-client/service-retry/v1";
7
+ import { buildServiceDescriptor as oe } from "@conduit-client/service-cache/v1";
8
+ import { buildServiceDescriptor as ie } from "@conduit-client/service-cache-control/v1";
9
+ import { buildInMemoryCacheInclusionPolicyService as ce } from "@conduit-client/service-cache-inclusion-policy/v1";
10
+ import { buildServiceDescriptor as ue } from "@conduit-client/service-pubsub/v1";
11
+ import { HttpCacheControlCommand as he } from "@conduit-client/command-http-cache-control/v1";
12
12
  const E = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
13
- function ue(t, e) {
14
- const [, r, n] = E.exec(t), [, a, s] = E.exec(e);
15
- return Number(r) - Number(a) || Number(n) - Number(s);
13
+ function le(t, e) {
14
+ const [, r, n] = E.exec(t), [, s, a] = E.exec(e);
15
+ return Number(r) - Number(s) || Number(n) - Number(a);
16
16
  }
17
- function he(t, e) {
17
+ function pe(t, e) {
18
18
  for (const r of t) {
19
- const n = r.extension, { label: a } = r, s = n.minApiVersion;
20
- if (s !== void 0) {
21
- if (typeof s != "string" || !E.test(s))
19
+ const n = r.extension, { label: s } = r, a = n.minApiVersion;
20
+ if (a !== void 0) {
21
+ if (typeof a != "string" || !E.test(a))
22
22
  throw new TypeError(
23
- `Extension ${a} declares invalid minApiVersion ${JSON.stringify(s)}; expected a Salesforce API version such as "64.0".`
23
+ `Extension ${s} declares invalid minApiVersion ${JSON.stringify(a)}; expected a Salesforce API version such as "64.0".`
24
24
  );
25
25
  if (e.apiVersion !== void 0) {
26
26
  if (!E.test(e.apiVersion))
27
27
  throw new Error(
28
- `Extension ${a} requires Salesforce API version ${s} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
28
+ `Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
29
29
  );
30
- if (ue(e.apiVersion, s) < 0)
30
+ if (le(e.apiVersion, a) < 0)
31
31
  throw new Error(
32
- `Extension ${a} requires Salesforce API version ${s} or later, but the Data SDK uses version ${e.apiVersion}.`
32
+ `Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK uses version ${e.apiVersion}.`
33
33
  );
34
34
  }
35
35
  }
36
36
  }
37
37
  }
38
- const le = "X-Salesforce-First-Party";
39
- function de(t, e) {
40
- if (!t) return !1;
41
- const r = e.toLowerCase();
42
- return t instanceof Headers ? t.has(e) : Array.isArray(t) ? t.some(([n]) => n.toLowerCase() === r) : Object.keys(t).some((n) => n.toLowerCase() === r);
43
- }
44
- function H(t, e, r) {
45
- return !e || !r ? !1 : de(t?.headers, le);
46
- }
47
- function D(t, e, r) {
48
- return e ? r ? y("Cookie", `sid=${e}`, t) : y("Authorization", `Bearer ${e}`, t) : t;
49
- }
50
- function pe({
51
- baseUrl: t,
52
- accessToken: e,
53
- lightningDomain: r,
54
- isInternal: n = !1
55
- }) {
56
- return (a) => {
57
- const [s, o] = a;
58
- if (typeof s == "string" && !s.startsWith("http") && t) {
59
- const i = s.startsWith("/") ? s : `/${s}`;
60
- return H(o, n, r) ? p(
61
- D([`${r}${i}`, o], e, !0)
62
- ) : p(D([`${t}${i}`, o], e, !1));
63
- }
64
- return p(D(a, e, !1));
65
- };
66
- }
67
- function fe(t) {
68
- const e = t.baseUrl || t.accessToken ? [pe(t)] : [];
69
- return V({ request: e }).service;
70
- }
71
- const me = {
72
- "Content-Type": "application/json",
73
- Accept: "application/json",
74
- "X-Chatter-Entity-Encoding": "false"
75
- };
76
- function ye(t) {
77
- if (t instanceof Headers) {
78
- const e = [];
79
- return t.forEach((r, n) => e.push([n, r])), e;
80
- }
81
- return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
82
- }
83
- function U(t, e) {
84
- if (e === void 0) return { ...t };
85
- const r = { ...t }, n = /* @__PURE__ */ new Map();
86
- for (const s of Object.keys(r)) n.set(s.toLowerCase(), s);
87
- const a = /* @__PURE__ */ new Set();
88
- for (const [s, o] of ye(e)) {
89
- const i = s.toLowerCase(), c = n.get(i);
90
- c === void 0 ? (r[s] = o, n.set(i, s), a.add(i)) : a.has(i) ? r[c] = `${r[c]}, ${o}` : (r[c] = o, a.add(i));
91
- }
92
- return r;
93
- }
94
- function G(t) {
95
- return U(me, t);
96
- }
97
- function be(t) {
98
- if (t === void 0) return;
99
- const e = {};
100
- return new Headers(t).forEach((r, n) => {
101
- e[n] = r;
102
- }), Object.keys(e).length > 0 ? e : void 0;
103
- }
104
- const ge = 512;
105
- function we(t) {
106
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
107
- }
108
- class T extends Error {
109
- status;
110
- url;
111
- constructor(e) {
112
- const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(we(e.body.slice(0, ge)))})`;
113
- super(
114
- `${e.surface} GraphQL request to ${e.url} returned HTTP ${e.status} with an ${r}${n}. Expected a JSON GraphQL response; the transport (proxy/gateway/auth) likely did not return one.`
115
- ), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
116
- }
117
- }
118
- async function F(t, e, r) {
119
- const n = await t.text();
120
- let a;
121
- try {
122
- a = JSON.parse(n);
123
- } catch (s) {
124
- throw new T({ surface: e, url: r, status: t.status, body: n, cause: s });
125
- }
126
- if (a === null || typeof a != "object")
127
- throw new T({
128
- surface: e,
129
- url: r,
130
- status: t.status,
131
- body: n,
132
- cause: new Error("Parsed GraphQL response body was not a JSON object")
133
- });
134
- return a;
135
- }
136
38
  const S = () => {
137
- }, $ = async () => {
39
+ }, x = async () => {
138
40
  };
139
- function P(t) {
41
+ function N(t) {
140
42
  try {
141
- return x(te(t));
43
+ return O(Z(t));
142
44
  } catch (e) {
143
- return A(m(e));
45
+ return q(y(e));
144
46
  }
145
47
  }
146
- function q(t, e) {
48
+ function P(t, e) {
147
49
  const r = t.definitions.filter(
148
50
  (n) => n.kind === "OperationDefinition"
149
51
  );
150
52
  return r.length === 0 ? "unknown" : r.length === 1 ? e === void 0 || r[0].name?.value === e ? r[0].operation : "unknown" : e === void 0 ? "unknown" : r.find((n) => n.name?.value === e)?.operation ?? "unknown";
151
53
  }
152
- function m(t) {
54
+ function y(t) {
153
55
  if (t && typeof t == "object" && "data" in t) {
154
56
  const e = t.data;
155
57
  if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
@@ -157,10 +59,10 @@ function m(t) {
157
59
  }
158
60
  return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
159
61
  }
160
- async function Q(t, { mutation: e, variables: r, operationName: n, headers: a }) {
161
- const s = P(e);
162
- if (s.isErr()) return { data: void 0, errors: s.error };
163
- const o = s.value, i = q(o, n);
62
+ async function U(t, { mutation: e, variables: r, operationName: n, headers: s }) {
63
+ const a = N(e);
64
+ if (a.isErr()) return { data: void 0, errors: a.error };
65
+ const o = a.value, i = P(o, n);
164
66
  if (i !== "mutation")
165
67
  return {
166
68
  data: void 0,
@@ -173,10 +75,10 @@ async function Q(t, { mutation: e, variables: r, operationName: n, headers: a })
173
75
  try {
174
76
  const c = await t(
175
77
  {
176
- query: N(o),
78
+ query: k(o),
177
79
  variables: r,
178
80
  operationName: n,
179
- headers: a
81
+ headers: s
180
82
  },
181
83
  "mutation"
182
84
  );
@@ -185,16 +87,16 @@ async function Q(t, { mutation: e, variables: r, operationName: n, headers: a })
185
87
  errors: c.errors
186
88
  };
187
89
  } catch (c) {
188
- return { data: void 0, errors: m(c) };
90
+ return { data: void 0, errors: y(c) };
189
91
  }
190
92
  }
191
- function j(t) {
192
- function e(n, a, s, o) {
93
+ function T(t) {
94
+ function e(n, s, a, o) {
193
95
  return t(
194
96
  {
195
- query: N(n),
196
- variables: a,
197
- operationName: s,
97
+ query: k(n),
98
+ variables: s,
99
+ operationName: a,
198
100
  headers: o
199
101
  },
200
102
  "query"
@@ -203,24 +105,24 @@ function j(t) {
203
105
  data: i.data ?? void 0,
204
106
  errors: i.errors
205
107
  }),
206
- (i) => ({ data: void 0, errors: m(i) })
108
+ (i) => ({ data: void 0, errors: y(i) })
207
109
  );
208
110
  }
209
111
  async function r({
210
112
  query: n,
211
- variables: a,
212
- operationName: s,
113
+ variables: s,
114
+ operationName: a,
213
115
  headers: o
214
116
  }) {
215
- const i = P(n);
117
+ const i = N(n);
216
118
  if (i.isErr())
217
119
  return {
218
120
  data: void 0,
219
121
  errors: i.error,
220
122
  subscribe: () => S,
221
- refresh: $
123
+ refresh: x
222
124
  };
223
- const c = i.value, h = q(c, s);
125
+ const c = i.value, h = P(c, a);
224
126
  if (h !== "query")
225
127
  return {
226
128
  data: void 0,
@@ -230,102 +132,228 @@ function j(t) {
230
132
  }
231
133
  ],
232
134
  subscribe: () => S,
233
- refresh: $
135
+ refresh: x
234
136
  };
235
- const u = /* @__PURE__ */ new Set(), l = a, d = await e(c, l, s, o);
137
+ const u = /* @__PURE__ */ new Set(), l = s, p = await e(c, l, a, o);
236
138
  return {
237
- data: d.data,
238
- errors: d.errors,
139
+ data: p.data,
140
+ errors: p.errors,
239
141
  subscribe(f) {
240
142
  return u.add(f), () => {
241
143
  u.delete(f);
242
144
  };
243
145
  },
244
146
  async refresh() {
245
- const f = await e(c, l, s, o);
246
- for (const w of u) w(f);
147
+ const f = await e(c, l, a, o);
148
+ for (const g of u) g(f);
247
149
  }
248
150
  };
249
151
  }
250
152
  return {
251
153
  query: r,
252
- mutate: (n) => Q(t, n)
154
+ mutate: (n) => U(t, n)
253
155
  };
254
156
  }
255
- const _ = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
256
- function K(t = _) {
157
+ const C = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
158
+ function $(t = C) {
257
159
  return `/services/data/v${t}`;
258
160
  }
259
- const ve = {
161
+ function de(t) {
162
+ if (Array.isArray(t)) {
163
+ for (const e of t)
164
+ if (!(e?.type !== "text" || !e.text))
165
+ try {
166
+ const r = JSON.parse(e.text);
167
+ if (r?.status_code !== void 0 || r?.error_code !== void 0)
168
+ return r;
169
+ } catch {
170
+ }
171
+ }
172
+ }
173
+ function fe(t) {
174
+ const e = t;
175
+ return e?.code === -32601 || e?.code === -32602 && typeof e.message == "string" && /^Unknown tool\b/i.test(e.message);
176
+ }
177
+ function R(t) {
178
+ if (typeof t != "object" || Array.isArray(t)) return !1;
179
+ if (!Object.hasOwn(t, "errors")) return Object.hasOwn(t, "data");
180
+ const { errors: e } = t;
181
+ return Array.isArray(e) && e.every(
182
+ (r) => r !== null && typeof r == "object" && !Array.isArray(r) && typeof r.message == "string"
183
+ );
184
+ }
185
+ class L {
186
+ graphql;
187
+ apiVersion;
188
+ #e;
189
+ constructor(e, r) {
190
+ if (this.#e = e, this.apiVersion = r?.apiVersion ?? C, typeof this.apiVersion != "string" || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)(?![\s\S])/.test(this.apiVersion))
191
+ throw new TypeError("Invalid Data SDK API version.");
192
+ this.graphql = T(this.#t.bind(this));
193
+ }
194
+ async #t({ query: e, variables: r, operationName: n }, s) {
195
+ const a = {
196
+ query: e,
197
+ ...r != null ? { variables: r } : {},
198
+ ...n != null ? { operationName: n } : {}
199
+ }, o = s === "query" ? { method: "GET", queryParams: { queryInput: JSON.stringify(a) } } : { method: "POST", body: a }, i = await this.#e.request("tools/call", {
200
+ name: s === "query" ? "dispatch_readonly" : "dispatch",
201
+ arguments: {
202
+ url: `${$(this.apiVersion)}/graphql`,
203
+ ...o
204
+ }
205
+ }).catch((p) => {
206
+ throw new Error(
207
+ fe(p) ? "Data SDK GraphQL dispatch tool is unavailable." : "Data SDK GraphQL request failed.",
208
+ { cause: p }
209
+ );
210
+ }), c = i?.structuredContent ?? de(i?.content), h = c?.status_code, u = c?.body, l = i?.isError || c?.error_code !== void 0;
211
+ if (typeof h != "number" || !Number.isInteger(h))
212
+ throw new Error(
213
+ l ? "Data SDK GraphQL request failed." : "Data SDK GraphQL response is malformed."
214
+ );
215
+ if (l || h < 200 || h >= 300)
216
+ throw u != null && R(u) && u.errors?.length ? (
217
+ // This method is wrapped by `buildUncachedGraphQL`, which handles thrown {data} errors
218
+ { data: { errors: u.errors } }
219
+ ) : new Error("Data SDK GraphQL request failed.");
220
+ if (u == null || !R(u))
221
+ throw new Error("Data SDK GraphQL response is malformed.");
222
+ return u;
223
+ }
224
+ }
225
+ function ye(t) {
226
+ return (e) => {
227
+ const [r, n] = e;
228
+ if (typeof r == "string" && !r.startsWith("http")) {
229
+ const s = r.startsWith("/") ? r : `/${r}`;
230
+ return d([`${t}${s}`, n]);
231
+ }
232
+ return d(e);
233
+ };
234
+ }
235
+ function me(t) {
236
+ return (e) => d(w("Authorization", `Bearer ${t}`, e));
237
+ }
238
+ function be(t, e) {
239
+ const r = [];
240
+ return t && r.push(ye(t)), e && r.push(me(e)), H({
241
+ request: r
242
+ }).service;
243
+ }
244
+ const we = {
245
+ "Content-Type": "application/json",
246
+ Accept: "application/json",
247
+ "X-Chatter-Entity-Encoding": "false"
248
+ };
249
+ function ge(t) {
250
+ if (t instanceof Headers) {
251
+ const e = [];
252
+ return t.forEach((r, n) => e.push([n, r])), e;
253
+ }
254
+ return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
255
+ }
256
+ function K(t, e) {
257
+ if (e === void 0) return { ...t };
258
+ const r = { ...t }, n = /* @__PURE__ */ new Map();
259
+ for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
260
+ const s = /* @__PURE__ */ new Set();
261
+ for (const [a, o] of ge(e)) {
262
+ const i = a.toLowerCase(), c = n.get(i);
263
+ c === void 0 ? (r[a] = o, n.set(i, a), s.add(i)) : s.has(i) ? r[c] = `${r[c]}, ${o}` : (r[c] = o, s.add(i));
264
+ }
265
+ return r;
266
+ }
267
+ function z(t) {
268
+ return K(we, t);
269
+ }
270
+ function ve(t) {
271
+ if (t === void 0) return;
272
+ const e = {};
273
+ return new Headers(t).forEach((r, n) => {
274
+ e[n] = r;
275
+ }), Object.keys(e).length > 0 ? e : void 0;
276
+ }
277
+ const Ee = 512;
278
+ function Se(t) {
279
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
280
+ }
281
+ class V extends Error {
282
+ status;
283
+ url;
284
+ constructor(e) {
285
+ const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(Se(e.body.slice(0, Ee)))})`;
286
+ super(
287
+ `${e.surface} GraphQL request to ${e.url} returned HTTP ${e.status} with an ${r}${n}. Expected a JSON GraphQL response; the transport (proxy/gateway/auth) likely did not return one.`
288
+ ), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
289
+ }
290
+ }
291
+ async function J(t, e, r) {
292
+ const n = await t.text();
293
+ let s;
294
+ try {
295
+ s = JSON.parse(n);
296
+ } catch (a) {
297
+ throw new V({ surface: e, url: r, status: t.status, body: n, cause: a });
298
+ }
299
+ if (!Ce(s))
300
+ throw new V({
301
+ surface: e,
302
+ url: r,
303
+ status: t.status,
304
+ body: n,
305
+ cause: new Error("Parsed response body was not a GraphQL response")
306
+ });
307
+ return s;
308
+ }
309
+ function Ce(t) {
310
+ return t === null || typeof t != "object" || Array.isArray(t) ? !1 : "data" in t || Array.isArray(t.errors);
311
+ }
312
+ const De = {
260
313
  "Content-Type": "application/json",
261
314
  Accept: "application/json"
262
315
  };
263
- class Ee {
316
+ class Ae {
264
317
  clientFetch;
265
318
  pathData;
266
- baseUrl;
267
- lightningDomain;
268
- isInternal;
269
319
  apiVersion;
270
320
  graphql;
271
321
  constructor(e) {
272
- const r = Se(), n = k(e?.instanceUrl ?? r.instanceUrl), a = e?.accessToken ?? r.accessToken, s = k(
273
- e?.lightningDomain ?? r.lightningDomain
274
- ), o = e?.isInternal ?? r.isInternal ?? !1;
275
- this.apiVersion = e?.apiVersion ?? r.apiVersion ?? _, this.pathData = K(this.apiVersion), this.baseUrl = n || void 0, this.lightningDomain = s || void 0, this.isInternal = o, this.clientFetch = fe({
276
- baseUrl: n || void 0,
277
- accessToken: a,
278
- lightningDomain: this.lightningDomain,
279
- isInternal: o
280
- }), this.graphql = j(this.executeRawGraphQL.bind(this));
281
- }
282
- async executeRawGraphQL({ query: e, variables: r, operationName: n, headers: a }, s) {
283
- const o = `${this.pathData}/graphql`, i = U(ve, a), c = H({ headers: i }, this.isInternal, this.lightningDomain) && !!this.baseUrl;
284
- if (c && s === "mutation")
285
- return {
286
- data: void 0,
287
- errors: [
288
- {
289
- message: "GraphQL mutations are not supported on the lightning domain for the Mosaic surface."
290
- }
291
- ]
292
- };
293
- const { resource: h, init: u } = c ? {
294
- resource: `${o}?queryInput=${encodeURIComponent(
295
- JSON.stringify({ query: e, variables: r, operationName: n })
296
- )}`,
297
- init: { method: "GET", headers: i }
298
- } : {
299
- resource: o,
300
- init: {
301
- method: "POST",
302
- body: JSON.stringify({ query: e, variables: r, operationName: n }),
303
- headers: i
304
- }
305
- }, l = await this.clientFetch(h, u), d = c ? `${o}?queryInput=<redacted>` : h;
306
- return F(l, "Mosaic", d);
322
+ const r = Oe(), n = qe(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
323
+ this.apiVersion = e?.apiVersion ?? r.apiVersion ?? C, this.pathData = $(this.apiVersion), this.clientFetch = be(n || void 0, s), this.graphql = T(this.executeRawGraphQL.bind(this));
324
+ }
325
+ async executeRawGraphQL({
326
+ query: e,
327
+ variables: r,
328
+ operationName: n,
329
+ headers: s
330
+ }) {
331
+ const a = `${this.pathData}/graphql`, o = await this.clientFetch(a, {
332
+ method: "POST",
333
+ body: JSON.stringify({ query: e, variables: r, operationName: n }),
334
+ headers: K(De, s)
335
+ });
336
+ return J(o, "Mosaic", a);
307
337
  }
308
338
  }
309
- function Se() {
339
+ function Oe() {
310
340
  const t = globalThis.MOSAIC_ENV;
311
341
  return {
312
342
  instanceUrl: t?.instanceUrl,
313
343
  accessToken: t?.accessToken,
314
- apiVersion: t?.apiVersion,
315
- lightningDomain: t?.lightningDomain,
316
- isInternal: t?.isInternal
344
+ apiVersion: t?.apiVersion
317
345
  };
318
346
  }
319
- function k(t) {
347
+ function qe(t) {
320
348
  if (!t || t === "/") return "";
321
349
  let e = t;
322
350
  return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
323
351
  }
324
- const Ce = "graphqlQuery";
325
- class De {
352
+ const xe = "graphqlQuery";
353
+ class ke {
326
354
  graphql;
327
355
  constructor() {
328
- this.graphql = j(this.executeRawGraphQL.bind(this));
356
+ this.graphql = T(this.executeRawGraphQL.bind(this));
329
357
  }
330
358
  /**
331
359
  * This method does not forward the `headers` request option, by design.
@@ -340,57 +368,57 @@ class De {
340
368
  variables: r,
341
369
  operationName: n
342
370
  }) {
343
- return (await window.openai.callTool(Ce, {
371
+ return (await window.openai.callTool(xe, {
344
372
  query: e,
345
373
  ...r != null ? { variables: r } : {},
346
374
  ...n != null ? { operationName: n } : {}
347
375
  })).structuredContent;
348
376
  }
349
377
  }
350
- const g = "Accept-Language";
351
- function z(t) {
378
+ const b = "Accept-Language";
379
+ function W(t) {
352
380
  return t ? void 0 : globalThis.SFDC_ENV?.language;
353
381
  }
354
- function Oe(t) {
355
- const e = new Headers(t), r = z(e.has(g));
356
- return r ? (e.set(g, r), e) : t;
357
- }
358
- const xe = (t) => {
359
- const [e, r] = t, n = e instanceof Request && !r?.headers ? e.headers.has(g) : new Headers(r?.headers).has(g), a = z(n);
360
- return a ? p(y(g, a, t)) : p(t);
361
- }, Ae = "X-SFDC-Client-Name", $e = "X-SFDC-Client-Version", Ne = "@salesforce/platform-sdk", Pe = "12.12.1", qe = (t) => {
362
- let e = y(Ae, Ne, t);
363
- return e = y($e, Pe, e), p(e);
364
- }, _e = "X-CSRF-Token";
365
- function Te(t, e = {}) {
382
+ function Ne(t) {
383
+ const e = new Headers(t), r = W(e.has(b));
384
+ return r ? (e.set(b, r), e) : t;
385
+ }
386
+ const Pe = (t) => {
387
+ const [e, r] = t, n = e instanceof Request && !r?.headers ? e.headers.has(b) : new Headers(r?.headers).has(b), s = W(n);
388
+ return s ? d(w(b, s, t)) : d(t);
389
+ }, Te = "X-SFDC-Client-Name", $e = "X-SFDC-Client-Version", _e = "@salesforce/platform-sdk", Re = "12.14.0", Le = (t) => {
390
+ let e = w(Te, _e, t);
391
+ return e = w($e, Re, e), d(e);
392
+ }, Ve = "X-CSRF-Token";
393
+ function Me(t, e = {}) {
366
394
  const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
367
- return async (a) => {
368
- const [s, o] = a, i = s instanceof Request ? s.url : s instanceof URL ? s.href : s, c = o?.method ?? (s instanceof Request ? s.method : void 0) ?? "GET";
369
- if (R(n, i) || ke(c) && R(r, i)) {
395
+ return async (s) => {
396
+ const [a, o] = s, i = a instanceof Request ? a.url : a instanceof URL ? a.href : a, c = o?.method ?? (a instanceof Request ? a.method : void 0) ?? "GET";
397
+ if (M(n, i) || Ie(c) && M(r, i)) {
370
398
  const u = await t.getToken();
371
- a = y(_e, u, a);
399
+ s = w(Ve, u, s);
372
400
  }
373
- return p(a);
401
+ return d(s);
374
402
  };
375
403
  }
376
- function ke(t) {
404
+ function Ie(t) {
377
405
  const e = t.toLowerCase();
378
406
  return e === "post" || e === "put" || e === "patch" || e === "delete";
379
407
  }
380
- function R(t, e) {
408
+ function M(t, e) {
381
409
  const r = new URL(e, globalThis.location?.href ?? "http://localhost");
382
410
  return t.some((n) => r.pathname.includes(n));
383
411
  }
384
- function Re(t, e = {}) {
385
- const r = Te(t, e);
386
- async function n(a) {
387
- const s = await r(a);
388
- return fetch(s[0], s[1]);
412
+ function Ge(t, e = {}) {
413
+ const r = Me(t, e);
414
+ async function n(s) {
415
+ const a = await r(s);
416
+ return fetch(a[0], a[1]);
389
417
  }
390
- return (a, s) => s ? s.applyRetry(async () => n(a)) : n(a);
418
+ return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
391
419
  }
392
- const Ie = [400, 401, 403];
393
- class Le extends re {
420
+ const Qe = [400, 401, 403];
421
+ class je extends se {
394
422
  constructor(e) {
395
423
  super(e), this.csrfTokenManager = e;
396
424
  }
@@ -399,7 +427,7 @@ class Le extends re {
399
427
  * Returns true when a CSRF token issue caused the request to fail.
400
428
  */
401
429
  async shouldRetry(e, r) {
402
- return r.attempt >= 1 ? !1 : Ie.includes(e.status);
430
+ return r.attempt >= 1 ? !1 : Qe.includes(e.status);
403
431
  }
404
432
  /**
405
433
  * Returns zero, so the CSRF token refresh happens immediately with no added delay.
@@ -418,9 +446,9 @@ class Le extends re {
418
446
  await this.csrfTokenManager.refreshToken();
419
447
  }
420
448
  }
421
- class Me {
449
+ class Fe {
422
450
  constructor(e, r) {
423
- this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
451
+ this.endpoint = e, this.cacheName = r, this.tokenPromise = this.startObtainToken();
424
452
  }
425
453
  endpoint;
426
454
  cacheName;
@@ -430,10 +458,11 @@ class Me {
430
458
  * Returns the current CSRF token.
431
459
  *
432
460
  * @remarks
433
- * The first call loads the token lazily, either from the cache or with a fetch request.
461
+ * The token loads from the cache or with a fetch request. When the last attempt failed, this
462
+ * call starts a new attempt, so a transient failure does not block later requests.
434
463
  */
435
464
  async getToken() {
436
- return this.tokenPromise;
465
+ return this.tokenPromise ??= this.startObtainToken(), this.tokenPromise;
437
466
  }
438
467
  /**
439
468
  * Clears the cached CSRF token and fetches a fresh one.
@@ -443,20 +472,48 @@ class Me {
443
472
  * every caller shares the same in-flight promise.
444
473
  */
445
474
  refreshToken() {
446
- return this.refreshPromise || (this.refreshPromise = this.withCache((e) => e.delete(this.endpoint)).then(() => (this.tokenPromise = this.obtainToken(), this.tokenPromise)).finally(() => {
475
+ return this.refreshPromise || (this.refreshPromise = this.withCache((e) => e.delete(this.endpoint)).then(() => (this.tokenPromise = this.startObtainToken(), this.tokenPromise)).finally(() => {
447
476
  this.refreshPromise = void 0;
448
477
  })), this.refreshPromise;
449
478
  }
479
+ /**
480
+ * Starts a token attempt that is forgotten when it fails.
481
+ *
482
+ * @remarks
483
+ * The manager lives for the page lifetime. If it kept a rejected promise, every later protected
484
+ * request would fail without a network call until the page reloads.
485
+ */
486
+ startObtainToken() {
487
+ const e = this.obtainToken();
488
+ return e.catch(() => {
489
+ this.tokenPromise === e && (this.tokenPromise = void 0);
490
+ }), e;
491
+ }
450
492
  /**
451
493
  * Returns a CSRF token from the cache, or fetches a new one when the cache has none.
452
494
  *
495
+ * @remarks
496
+ * Only a response that contains a token goes into the cache. The cache persists across page
497
+ * loads, so a cached error response would otherwise fail every attempt.
498
+ *
453
499
  * @returns The CSRF token.
454
500
  */
455
501
  async obtainToken() {
456
- let e = await this.withCache((a) => a.match(this.endpoint)), r = !1;
457
- e || (e = await fetch(this.endpoint, { method: "get" }), r = !0);
458
- const n = (await e.clone().json()).csrfToken;
459
- return r && await this.withCache((a) => a.put(this.endpoint, e)), n;
502
+ const e = await this.withCache((s) => s.match(this.endpoint));
503
+ if (e) {
504
+ const s = await I(e).catch(() => {
505
+ });
506
+ if (s)
507
+ return s;
508
+ await this.withCache((a) => a.delete(this.endpoint));
509
+ }
510
+ const r = await fetch(this.endpoint, { method: "get" });
511
+ if (!r.ok)
512
+ throw new Error(`CSRF token request failed with status ${r.status}`);
513
+ const n = await I(r);
514
+ if (!n)
515
+ throw new Error("CSRF token response did not contain a token");
516
+ return await this.withCache((s) => s.put(this.endpoint, r)), n;
460
517
  }
461
518
  /**
462
519
  * Runs a callback against the Cache API, and returns `undefined` when the API is unavailable.
@@ -472,29 +529,36 @@ class Me {
472
529
  return;
473
530
  }
474
531
  }
475
- const I = /* @__PURE__ */ new Map();
476
- function Ve(t) {
532
+ async function I(t) {
533
+ const e = await t.clone().json();
534
+ if (typeof e != "object" || e === null || !("csrfToken" in e))
535
+ return;
536
+ const { csrfToken: r } = e;
537
+ return typeof r == "string" && r !== "" ? r : void 0;
538
+ }
539
+ const G = /* @__PURE__ */ new Map();
540
+ function He(t) {
477
541
  const { endpoint: e, cacheName: r, ...n } = t.csrf;
478
- let a = I.get(e);
479
- return a || (a = new Me(e, r), I.set(e, a)), V(
542
+ let s = G.get(e);
543
+ return s || (s = new Fe(e, r), G.set(e, s)), H(
480
544
  {
481
- retry: Re(a, n),
482
- request: [qe, xe]
545
+ retry: Ge(s, n),
546
+ request: [Le, Pe]
483
547
  },
484
- ne(new Le(a)).service
548
+ ae(new je(s)).service
485
549
  ).service;
486
550
  }
487
- const L = /* @__PURE__ */ new Map();
488
- function He(t) {
489
- let e = L.get(t);
551
+ const Q = /* @__PURE__ */ new Map();
552
+ function Ue(t) {
553
+ let e = Q.get(t);
490
554
  if (!e) {
491
- const r = se().service, n = oe(r).service, a = ae(r, n).service, s = ie().service;
492
- e = { cache: r, cacheController: a, pubSub: s }, L.set(t, e);
555
+ const r = oe().service, n = ce(r).service, s = ie(r, n).service, a = ue().service;
556
+ e = { cache: r, cacheController: s, pubSub: a }, Q.set(t, e);
493
557
  }
494
558
  return e;
495
559
  }
496
- function Ue(t, e) {
497
- const r = He(t);
560
+ function Ke(t, e) {
561
+ const r = Ue(t);
498
562
  return {
499
563
  shared: r,
500
564
  services: {
@@ -504,30 +568,30 @@ function Ue(t, e) {
504
568
  }
505
569
  };
506
570
  }
507
- const M = 300;
508
- function Ge(t, e) {
571
+ const j = 300;
572
+ function ze(t, e) {
509
573
  try {
510
574
  return JSON.parse(JSON.stringify(t));
511
575
  } catch (r) {
512
- const n = e || "(anonymous)", a = new TypeError(
576
+ const n = e || "(anonymous)", s = new TypeError(
513
577
  `HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${r.message}`
514
578
  );
515
- throw a.cause = r, a;
579
+ throw s.cause = r, s;
516
580
  }
517
581
  }
518
- function Fe(t) {
582
+ function Je(t) {
519
583
  if (typeof t == "object" && t.type === "max-age") {
520
584
  const e = t.maxAge;
521
- return Number.isFinite(e) && e >= 0 ? e : M;
585
+ return Number.isFinite(e) && e >= 0 ? e : j;
522
586
  }
523
- return M;
587
+ return j;
524
588
  }
525
- class Qe extends ce {
589
+ class We extends he {
526
590
  constructor(e, r, n) {
527
- super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Ge(
591
+ super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = ze(
528
592
  e.variables ?? {},
529
593
  this.normalizedOperationName
530
- ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Fe(e.cacheControl), this.headers = e.headers, this.headersKey = be(e.headers);
594
+ ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Je(e.cacheControl), this.headers = e.headers, this.headersKey = ve(e.headers);
531
595
  }
532
596
  url;
533
597
  query;
@@ -542,7 +606,7 @@ class Qe extends ce {
542
606
  this.url,
543
607
  {
544
608
  method: "POST",
545
- headers: G(this.headers),
609
+ headers: z(this.headers),
546
610
  body: JSON.stringify({
547
611
  query: this.query,
548
612
  variables: this.normalizedVariables,
@@ -557,7 +621,7 @@ class Qe extends ce {
557
621
  variables: this.normalizedVariables,
558
622
  operationName: this.normalizedOperationName
559
623
  };
560
- return this.headersKey !== void 0 && (e.headers = this.headersKey), X(e);
624
+ return this.headersKey !== void 0 && (e.headers = this.headersKey), ee(e);
561
625
  }
562
626
  /**
563
627
  * Reads the cached result for this command, or returns an error.
@@ -575,9 +639,9 @@ class Qe extends ce {
575
639
  */
576
640
  readFromCache(e) {
577
641
  const r = this.buildKey(), n = e.get(r)?.value;
578
- return n === void 0 ? p(
579
- A(new Y("No cached entry found for this query."))
580
- ) : p(x(n));
642
+ return n === void 0 ? d(
643
+ q(new te("No cached entry found for this query."))
644
+ ) : d(O(n));
581
645
  }
582
646
  writeToCache(e, r) {
583
647
  if (r.isOk() && r.value.data != null && Object.keys(r.value.data).length > 0) {
@@ -593,7 +657,7 @@ class Qe extends ce {
593
657
  }
594
658
  });
595
659
  }
596
- return p(void 0);
660
+ return d(void 0);
597
661
  }
598
662
  get cacheControlStrategyConfig() {
599
663
  const e = Math.floor(Date.now() / 1e3);
@@ -607,112 +671,112 @@ class Qe extends ce {
607
671
  return e.errors && e.errors.length > 0;
608
672
  }
609
673
  processFetchReturnValue(e) {
610
- return this.responseHasErrors(e) ? A(new Z(e)) : x(e);
674
+ return this.responseHasErrors(e) ? q(new re(e)) : O(e);
611
675
  }
612
676
  }
613
- const je = "CACHE_MISS";
614
- function Ke() {
677
+ const Be = "CACHE_MISS";
678
+ function Xe() {
615
679
  return [
616
680
  {
617
681
  message: "No cached entry found for this query (cacheControl: 'only-if-cached').",
618
- extensions: { code: je }
682
+ extensions: { code: Be }
619
683
  }
620
684
  ];
621
685
  }
622
- function J(t) {
623
- if (ee(t) && t.data && typeof t.data == "object") {
686
+ function B(t) {
687
+ if (ne(t) && t.data && typeof t.data == "object") {
624
688
  const e = t.data;
625
689
  if (e.data != null)
626
690
  return e.data;
627
691
  }
628
692
  }
629
- function ze(t) {
693
+ function Ye(t) {
630
694
  return (e) => {
631
695
  if (e.isOk()) {
632
696
  const r = e.value;
633
697
  v(r), t({ data: r, errors: void 0 });
634
698
  } else {
635
- const r = J(e.error);
636
- r && v(r), t({ data: r, errors: m(e.error) });
699
+ const r = B(e.error);
700
+ r && v(r), t({ data: r, errors: y(e.error) });
637
701
  }
638
702
  };
639
703
  }
640
- async function Je(t, e = !1) {
641
- let r, n, a;
704
+ async function Ze(t, e = !1) {
705
+ let r, n, s;
642
706
  try {
643
- const s = await t.execute();
644
- s.isOk() ? (r = s.value.data, v(r), a = (o) => s.value.subscribe(o)) : (r = J(s.error.failure), r && v(r), n = e && r === void 0 ? Ke() : m(s.error.failure), a = (o) => s.error.subscribe(o));
645
- } catch (s) {
646
- n = m(s);
707
+ const a = await t.execute();
708
+ a.isOk() ? (r = a.value.data, v(r), s = (o) => a.value.subscribe(o)) : (r = B(a.error.failure), r && v(r), n = e && r === void 0 ? Xe() : y(a.error.failure), s = (o) => a.error.subscribe(o));
709
+ } catch (a) {
710
+ n = y(a);
647
711
  }
648
712
  return {
649
713
  data: r,
650
714
  errors: n,
651
- subscribe(s) {
652
- return a ? a(ze(s)) : S;
715
+ subscribe(a) {
716
+ return s ? s(Ye(a)) : S;
653
717
  },
654
718
  async refresh() {
655
719
  await t.refresh();
656
720
  }
657
721
  };
658
722
  }
659
- function O(t) {
723
+ function A(t) {
660
724
  return {
661
725
  data: void 0,
662
726
  errors: t,
663
727
  subscribe: () => S,
664
- refresh: $
728
+ refresh: x
665
729
  };
666
730
  }
667
- function We({
731
+ function et({
668
732
  bundle: t,
669
733
  url: e,
670
734
  executeRaw: r,
671
735
  resolveEffectiveHeaders: n
672
736
  }) {
673
- const { services: a } = t;
674
- async function s({
737
+ const { services: s } = t;
738
+ async function a({
675
739
  query: o,
676
740
  variables: i,
677
741
  operationName: c,
678
742
  cacheControl: h,
679
743
  headers: u
680
744
  }) {
681
- const l = P(o);
682
- if (l.isErr()) return O(l.error);
683
- const d = l.value, f = q(d, c);
745
+ const l = N(o);
746
+ if (l.isErr()) return A(l.error);
747
+ const p = l.value, f = P(p, c);
684
748
  if (f !== "query")
685
- return O([
749
+ return A([
686
750
  {
687
751
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
688
752
  }
689
753
  ]);
690
- let w;
754
+ let g;
691
755
  try {
692
- const C = n ? n(u) : u;
693
- w = new Qe(
756
+ const D = n ? n(u) : u;
757
+ g = new We(
694
758
  {
695
- query: N(d),
759
+ query: k(p),
696
760
  variables: i,
697
761
  operationName: c,
698
762
  cacheControl: h,
699
- headers: C
763
+ headers: D
700
764
  },
701
- a,
765
+ s,
702
766
  e
703
767
  );
704
- } catch (C) {
705
- return O(m(C));
768
+ } catch (D) {
769
+ return A(y(D));
706
770
  }
707
- return Je(w, h === "only-if-cached");
771
+ return Ze(g, h === "only-if-cached");
708
772
  }
709
773
  return {
710
- query: s,
711
- mutate: (o) => Q(r, o)
774
+ query: a,
775
+ mutate: (o) => U(r, o)
712
776
  };
713
777
  }
714
- const Be = 1, Xe = `@salesforce/platform-sdk-data_v${Be}`;
715
- class Ye {
778
+ const tt = 1, rt = `@salesforce/platform-sdk-data_v${tt}`;
779
+ class F {
716
780
  baseUrl;
717
781
  pathData;
718
782
  clientFetch;
@@ -720,28 +784,28 @@ class Ye {
720
784
  apiVersion;
721
785
  graphql;
722
786
  constructor(e) {
723
- const r = Ze();
724
- this.baseUrl = et(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? _, this.pathData = K(this.apiVersion);
725
- const n = `${this.pathData}/ui-api`, a = `${this.pathData}/graphql`;
726
- this.onStatus = e?.onStatus ?? {}, this.clientFetch = Ve({
787
+ const r = nt();
788
+ this.baseUrl = st(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? C, this.pathData = $(this.apiVersion);
789
+ const n = `${this.pathData}/ui-api`, s = `${this.pathData}/graphql`;
790
+ this.onStatus = e?.onStatus ?? {}, this.clientFetch = He({
727
791
  csrf: {
728
792
  endpoint: `${this.baseUrl}${n}/session/csrf`,
729
- cacheName: Xe,
793
+ cacheName: rt,
730
794
  protectedUrls: ["services/data/v", "services/apexrest"],
731
795
  alwaysProtectedUrls: ["services/apexrest"]
732
796
  }
733
797
  });
734
- const s = (i, c) => this.fetch(i, c), o = Ue(`${this.baseUrl}${this.pathData}`, s);
735
- this.graphql = We({
798
+ const a = (i, c) => this.fetch(i, c), o = Ke(`${this.baseUrl}${this.pathData}`, a);
799
+ this.graphql = et({
736
800
  bundle: o,
737
- url: a,
801
+ url: s,
738
802
  executeRaw: this.executeRawGraphQL.bind(this),
739
- resolveEffectiveHeaders: Oe
803
+ resolveEffectiveHeaders: Ne
740
804
  });
741
805
  }
742
806
  async fetch(e, r) {
743
- const n = this.applySalesforceBase(e), a = await this.clientFetch(n, r);
744
- return await this.onStatus[a.status]?.(), a;
807
+ const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
808
+ return await this.onStatus[s.status]?.(), s;
745
809
  }
746
810
  /**
747
811
  * Sends a raw GraphQL POST request.
@@ -755,14 +819,14 @@ class Ye {
755
819
  query: e,
756
820
  variables: r,
757
821
  operationName: n,
758
- headers: a
822
+ headers: s
759
823
  }) {
760
- const s = `${this.pathData}/graphql`, o = await this.fetch(s, {
824
+ const a = `${this.pathData}/graphql`, o = await this.fetch(a, {
761
825
  method: "POST",
762
826
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
763
- headers: G(a)
827
+ headers: z(s)
764
828
  });
765
- return F(o, "WebApp", s);
829
+ return J(o, "WebApp", a);
766
830
  }
767
831
  /**
768
832
  * Converts a relative URL to an absolute Salesforce URL.
@@ -781,44 +845,44 @@ class Ye {
781
845
  return e;
782
846
  }
783
847
  }
784
- function Ze() {
848
+ function nt() {
785
849
  return {
786
850
  apiPath: globalThis.SFDC_ENV?.apiPath
787
851
  };
788
852
  }
789
- function et(t) {
853
+ function st(t) {
790
854
  if (!t || t === "/") return "";
791
855
  let e = t;
792
856
  return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
793
857
  }
794
- function tt(t) {
795
- const e = t, r = typeof e == "object" && e !== null ? e : void 0, n = r !== void 0 && "setup" in r, a = n ? r : r?.extension, s = n ? a?.name : r?.as;
796
- if (typeof a?.setup != "function")
858
+ function at(t) {
859
+ const e = t, r = typeof e == "object" && e !== null ? e : void 0, n = r !== void 0 && "setup" in r, s = n ? r : r?.extension, a = n ? s?.name : r?.as;
860
+ if (typeof s?.setup != "function")
797
861
  throw new Error("Extension entry cannot attach: it is missing a setup function.");
798
- if (typeof s != "string" || s.length === 0)
862
+ if (typeof a != "string" || a.length === 0)
799
863
  throw new Error(
800
864
  n ? 'Extension entry cannot attach: "name" must be a non-empty string.' : 'Extension entry cannot attach: alias "as" must be a non-empty string.'
801
865
  );
802
866
  return {
803
- extension: a,
804
- mountName: s,
805
- label: s === a.name ? `"${a.name}"` : `"${a.name}" (aliased as "${s}")`
867
+ extension: s,
868
+ mountName: a,
869
+ label: a === s.name ? `"${s.name}"` : `"${s.name}" (aliased as "${a}")`
806
870
  };
807
871
  }
808
- async function rt(t, e, r) {
872
+ async function ot(t, e, r) {
809
873
  if (e.length === 0)
810
874
  return t;
811
875
  if ("ext" in t)
812
876
  throw new Error(
813
877
  'Cannot attach extensions: the base SDK already declares an "ext" member, which the extension container reserves.'
814
878
  );
815
- const n = e.map(tt);
879
+ const n = e.map(at);
816
880
  r?.preflight?.(n, t);
817
- const a = Object.create(t), s = /* @__PURE__ */ Object.create(null), o = (h) => {
881
+ const s = Object.create(t), a = /* @__PURE__ */ Object.create(null), o = (h) => {
818
882
  throw new Error(`Cannot write "ext.${String(h)}" — ext is immutable once attached.`);
819
883
  }, i = (h) => {
820
884
  throw new Error(`Cannot ${h} "ext" — ext is immutable once attached.`);
821
- }, c = new Proxy(s, {
885
+ }, c = new Proxy(a, {
822
886
  set(h, u) {
823
887
  return o(u);
824
888
  },
@@ -840,53 +904,58 @@ async function rt(t, e, r) {
840
904
  return i("change the prototype of");
841
905
  }
842
906
  });
843
- Object.defineProperty(a, "ext", {
907
+ Object.defineProperty(s, "ext", {
844
908
  value: c,
845
909
  enumerable: !0,
846
910
  writable: !1,
847
911
  configurable: !1
848
912
  });
849
913
  for (const { extension: h, mountName: u, label: l } of n) {
850
- if (Object.hasOwn(s, u))
914
+ if (Object.hasOwn(a, u))
851
915
  throw new Error(
852
916
  `Extension ${l} cannot attach: "${u}" is already defined by another extension.`
853
917
  );
854
- let d;
918
+ let p;
855
919
  try {
856
- d = await h.setup(a);
920
+ p = await h.setup(s);
857
921
  } catch (f) {
858
922
  throw new Error(`Extension ${l} failed during setup.`, { cause: f });
859
923
  }
860
- Object.defineProperty(s, u, {
861
- value: d,
924
+ Object.defineProperty(a, u, {
925
+ value: p,
862
926
  enumerable: !0,
863
927
  writable: !1,
864
928
  configurable: !1
865
929
  });
866
930
  }
867
- return Object.freeze(s), a;
931
+ return Object.freeze(a), s;
868
932
  }
869
- function mt(t, ...e) {
933
+ function gt(t, ...e) {
870
934
  let r = t[0] ?? "";
871
935
  for (let n = 0; n < e.length; n += 1)
872
936
  r += String(e[n]) + (t[n + 1] ?? "");
873
937
  return r;
874
938
  }
875
- function yt(t) {
939
+ function vt(t) {
876
940
  return t;
877
941
  }
878
- async function nt(t) {
942
+ async function it(t) {
879
943
  try {
880
- switch (await W(t?.surface)) {
881
- case b.OpenAI:
882
- return new De();
883
- case b.WebApp:
884
- case b.MicroFrontend:
885
- return new Ye(t?.webapp);
886
- case b.Mosaic:
887
- return new Ee(t?.mosaic);
888
- case b.MCPApps:
889
- return {};
944
+ switch (await X(t?.surface)) {
945
+ case m.OpenAI:
946
+ return new ke();
947
+ case m.WebApp:
948
+ return new F(t?.webapp);
949
+ case m.MicroFrontend: {
950
+ const r = globalThis.SFDC_ENV;
951
+ return typeof r == "object" && r !== null ? new F(t?.webapp) : {};
952
+ }
953
+ case m.Mosaic:
954
+ return new Ae(t?.mosaic);
955
+ case m.Claude:
956
+ return new L(await _.getInstance(), t?.claude);
957
+ case m.MCPApps:
958
+ return new L(await _.getInstance(), t?.mcpApps);
890
959
  default:
891
960
  return {};
892
961
  }
@@ -894,19 +963,19 @@ async function nt(t) {
894
963
  return {};
895
964
  }
896
965
  }
897
- function bt(t) {
898
- return B(
966
+ function Et(t) {
967
+ return Y(
899
968
  (async () => {
900
- const e = await nt(t);
901
- return rt(e, t?.extensions ?? [], {
902
- preflight: he
969
+ const e = await it(t);
970
+ return ot(e, t?.extensions ?? [], {
971
+ preflight: pe
903
972
  });
904
973
  })(),
905
974
  "createDataSDK"
906
975
  );
907
976
  }
908
977
  export {
909
- bt as createDataSDK,
910
- yt as defineDataExtension,
911
- mt as gql
978
+ Et as createDataSDK,
979
+ vt as defineDataExtension,
980
+ gt as gql
912
981
  };