@salesforce/platform-sdk 12.6.3 → 12.7.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.
@@ -1,135 +1,149 @@
1
- import { g as Q, S as y } from "../surface-Dd2tqrPi.js";
2
- import { w as j } from "../sdk-promise-D0sy7OW1.js";
3
- import { buildServiceDescriptor as M, setHeader as b } from "@conduit-client/service-fetch-network/v1";
4
- import { resolvedPromiseLike as l, ok as x, err as D, stableJSONStringify as K, DataNotFoundError as z, UserVisibleError as J, deepFreeze as w, isUserVisibleError as W } from "@conduit-client/utils";
5
- import { print as N, parse as B } from "@conduit-client/onestore-graphql-parser/v1";
6
- import { RetryPolicy as X, buildServiceDescriptor as Y } from "@conduit-client/service-retry/v1";
7
- import { buildServiceDescriptor as Z } from "@conduit-client/service-cache/v1";
8
- import { buildServiceDescriptor as ee } from "@conduit-client/service-cache-control/v1";
9
- import { buildInMemoryCacheInclusionPolicyService as te } from "@conduit-client/service-cache-inclusion-policy/v1";
10
- import { buildServiceDescriptor as re } from "@conduit-client/service-pubsub/v1";
11
- import { HttpCacheControlCommand as ne } from "@conduit-client/command-http-cache-control/v1";
12
- const v = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
13
- function se(t, e) {
14
- const [, r, n] = v.exec(t), [, s, a] = v.exec(e);
15
- return Number(r) - Number(s) || Number(n) - Number(a);
16
- }
17
- function ae(t, e) {
1
+ import { g as K, S as b } from "../surface-Dd2tqrPi.js";
2
+ import { w as z } from "../sdk-promise-D0sy7OW1.js";
3
+ import { buildServiceDescriptor as V, setHeader as y } from "@conduit-client/service-fetch-network/v1";
4
+ import { resolvedPromiseLike as l, ok as x, err as O, stableJSONStringify as J, DataNotFoundError as W, UserVisibleError as B, deepFreeze as w, isUserVisibleError as X } from "@conduit-client/utils";
5
+ import { print as $, parse as Y } from "@conduit-client/onestore-graphql-parser/v1";
6
+ import { RetryPolicy as Z, buildServiceDescriptor as ee } from "@conduit-client/service-retry/v1";
7
+ import { buildServiceDescriptor as te } from "@conduit-client/service-cache/v1";
8
+ import { buildServiceDescriptor as re } from "@conduit-client/service-cache-control/v1";
9
+ import { buildInMemoryCacheInclusionPolicyService as ne } from "@conduit-client/service-cache-inclusion-policy/v1";
10
+ import { buildServiceDescriptor as se } from "@conduit-client/service-pubsub/v1";
11
+ import { HttpCacheControlCommand as ae } from "@conduit-client/command-http-cache-control/v1";
12
+ const g = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
13
+ function oe(t, e) {
14
+ const [, r, n] = g.exec(t), [, a, s] = g.exec(e);
15
+ return Number(r) - Number(a) || Number(n) - Number(s);
16
+ }
17
+ function ie(t, e) {
18
18
  for (const r of t) {
19
- const n = r.extension, { label: s } = r, a = n.minApiVersion;
20
- if (a !== void 0) {
21
- if (typeof a != "string" || !v.test(a))
19
+ const n = r.extension, { label: a } = r, s = n.minApiVersion;
20
+ if (s !== void 0) {
21
+ if (typeof s != "string" || !g.test(s))
22
22
  throw new TypeError(
23
- `Extension ${s} declares invalid minApiVersion ${JSON.stringify(a)}; expected a Salesforce API version such as "64.0".`
23
+ `Extension ${a} declares invalid minApiVersion ${JSON.stringify(s)}; expected a Salesforce API version such as "64.0".`
24
24
  );
25
25
  if (e.apiVersion !== void 0) {
26
- if (!v.test(e.apiVersion))
26
+ if (!g.test(e.apiVersion))
27
27
  throw new Error(
28
- `Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
28
+ `Extension ${a} requires Salesforce API version ${s} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
29
29
  );
30
- if (se(e.apiVersion, a) < 0)
30
+ if (oe(e.apiVersion, s) < 0)
31
31
  throw new Error(
32
- `Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK uses version ${e.apiVersion}.`
32
+ `Extension ${a} requires Salesforce API version ${s} or later, but the Data SDK uses version ${e.apiVersion}.`
33
33
  );
34
34
  }
35
35
  }
36
36
  }
37
37
  }
38
- function oe(t) {
39
- return (e) => {
40
- const [r, n] = e;
41
- if (typeof r == "string" && !r.startsWith("http")) {
42
- const s = r.startsWith("/") ? r : `/${r}`;
43
- return l([`${t}${s}`, n]);
38
+ const ce = "X-Salesforce-First-Party";
39
+ function ue(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 he(t, e, r) {
45
+ return !e || !r ? !1 : ue(t?.headers, ce);
46
+ }
47
+ function S(t, e, r) {
48
+ return e ? r ? y("Cookie", `sid=${e}`, t) : y("Authorization", `Bearer ${e}`, t) : t;
49
+ }
50
+ function le({
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 he(o, n, r) ? l(
61
+ S([`${r}${i}`, o], e, !0)
62
+ ) : l(S([`${t}${i}`, o], e, !1));
44
63
  }
45
- return l(e);
64
+ return l(S(a, e, !1));
46
65
  };
47
66
  }
48
- function ie(t) {
49
- return (e) => l(b("Authorization", `Bearer ${t}`, e));
50
- }
51
- function ce(t, e) {
52
- const r = [];
53
- return t && r.push(oe(t)), e && r.push(ie(e)), M({
54
- request: r
55
- }).service;
67
+ function de(t) {
68
+ const e = t.baseUrl || t.accessToken ? [le(t)] : [];
69
+ return V({ request: e }).service;
56
70
  }
57
- const ue = {
71
+ const pe = {
58
72
  "Content-Type": "application/json",
59
73
  Accept: "application/json",
60
74
  "X-Chatter-Entity-Encoding": "false"
61
75
  };
62
- function he(t) {
76
+ function fe(t) {
63
77
  if (t instanceof Headers) {
64
78
  const e = [];
65
79
  return t.forEach((r, n) => e.push([n, r])), e;
66
80
  }
67
81
  return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
68
82
  }
69
- function V(t, e) {
83
+ function I(t, e) {
70
84
  if (e === void 0) return { ...t };
71
85
  const r = { ...t }, n = /* @__PURE__ */ new Map();
72
- for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
73
- const s = /* @__PURE__ */ new Set();
74
- for (const [a, o] of he(e)) {
75
- const i = a.toLowerCase(), c = n.get(i);
76
- 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));
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 fe(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));
77
91
  }
78
92
  return r;
79
93
  }
80
- function L(t) {
81
- return V(ue, t);
94
+ function H(t) {
95
+ return I(pe, t);
82
96
  }
83
- function le(t) {
97
+ function me(t) {
84
98
  if (t === void 0) return;
85
99
  const e = {};
86
100
  return new Headers(t).forEach((r, n) => {
87
101
  e[n] = r;
88
102
  }), Object.keys(e).length > 0 ? e : void 0;
89
103
  }
90
- const pe = 512;
91
- function de(t) {
104
+ const ye = 512;
105
+ function be(t) {
92
106
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
93
107
  }
94
- class P extends Error {
108
+ class _ extends Error {
95
109
  status;
96
110
  url;
97
111
  constructor(e) {
98
- const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(de(e.body.slice(0, pe)))})`;
112
+ const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(be(e.body.slice(0, ye)))})`;
99
113
  super(
100
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.`
101
115
  ), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
102
116
  }
103
117
  }
104
- async function I(t, e, r) {
118
+ async function G(t, e, r) {
105
119
  const n = await t.text();
106
- let s;
120
+ let a;
107
121
  try {
108
- s = JSON.parse(n);
109
- } catch (a) {
110
- throw new P({ surface: e, url: r, status: t.status, body: n, cause: a });
122
+ a = JSON.parse(n);
123
+ } catch (s) {
124
+ throw new _({ surface: e, url: r, status: t.status, body: n, cause: s });
111
125
  }
112
- if (s === null || typeof s != "object")
113
- throw new P({
126
+ if (a === null || typeof a != "object")
127
+ throw new _({
114
128
  surface: e,
115
129
  url: r,
116
130
  status: t.status,
117
131
  body: n,
118
132
  cause: new Error("Parsed GraphQL response body was not a JSON object")
119
133
  });
120
- return s;
134
+ return a;
121
135
  }
122
- const g = () => {
123
- }, O = async () => {
136
+ const v = () => {
137
+ }, N = async () => {
124
138
  };
125
- function $(t) {
139
+ function A(t) {
126
140
  try {
127
- return x(B(t));
141
+ return x(Y(t));
128
142
  } catch (e) {
129
- return D(m(e));
143
+ return O(m(e));
130
144
  }
131
145
  }
132
- function q(t, e) {
146
+ function P(t, e) {
133
147
  const r = t.definitions.filter(
134
148
  (n) => n.kind === "OperationDefinition"
135
149
  );
@@ -143,10 +157,10 @@ function m(t) {
143
157
  }
144
158
  return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
145
159
  }
146
- async function G(t, { mutation: e, variables: r, operationName: n, headers: s }) {
147
- const a = $(e);
148
- if (a.isErr()) return { data: void 0, errors: a.error };
149
- const o = a.value, i = q(o, n);
160
+ async function F(t, { mutation: e, variables: r, operationName: n, headers: a }) {
161
+ const s = A(e);
162
+ if (s.isErr()) return { data: void 0, errors: s.error };
163
+ const o = s.value, i = P(o, n);
150
164
  if (i !== "mutation")
151
165
  return {
152
166
  data: void 0,
@@ -158,10 +172,10 @@ async function G(t, { mutation: e, variables: r, operationName: n, headers: s })
158
172
  };
159
173
  try {
160
174
  const c = await t({
161
- query: N(o),
175
+ query: $(o),
162
176
  variables: r,
163
177
  operationName: n,
164
- headers: s
178
+ headers: a
165
179
  });
166
180
  return {
167
181
  data: c.data ?? void 0,
@@ -171,12 +185,12 @@ async function G(t, { mutation: e, variables: r, operationName: n, headers: s })
171
185
  return { data: void 0, errors: m(c) };
172
186
  }
173
187
  }
174
- function H(t) {
175
- function e(n, s, a, o) {
188
+ function U(t) {
189
+ function e(n, a, s, o) {
176
190
  return t({
177
- query: N(n),
178
- variables: s,
179
- operationName: a,
191
+ query: $(n),
192
+ variables: a,
193
+ operationName: s,
180
194
  headers: o
181
195
  }).then(
182
196
  (i) => ({
@@ -188,19 +202,19 @@ function H(t) {
188
202
  }
189
203
  async function r({
190
204
  query: n,
191
- variables: s,
192
- operationName: a,
205
+ variables: a,
206
+ operationName: s,
193
207
  headers: o
194
208
  }) {
195
- const i = $(n);
209
+ const i = A(n);
196
210
  if (i.isErr())
197
211
  return {
198
212
  data: void 0,
199
213
  errors: i.error,
200
- subscribe: () => g,
201
- refresh: O
214
+ subscribe: () => v,
215
+ refresh: N
202
216
  };
203
- const c = i.value, h = q(c, a);
217
+ const c = i.value, h = P(c, s);
204
218
  if (h !== "query")
205
219
  return {
206
220
  data: void 0,
@@ -209,78 +223,87 @@ function H(t) {
209
223
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${h}.`
210
224
  }
211
225
  ],
212
- subscribe: () => g,
213
- refresh: O
226
+ subscribe: () => v,
227
+ refresh: N
214
228
  };
215
- const u = /* @__PURE__ */ new Set(), d = s, f = await e(c, d, a, o);
229
+ const u = /* @__PURE__ */ new Set(), p = a, f = await e(c, p, s, o);
216
230
  return {
217
231
  data: f.data,
218
232
  errors: f.errors,
219
- subscribe(p) {
220
- return u.add(p), () => {
221
- u.delete(p);
233
+ subscribe(d) {
234
+ return u.add(d), () => {
235
+ u.delete(d);
222
236
  };
223
237
  },
224
238
  async refresh() {
225
- const p = await e(c, d, a, o);
226
- for (const E of u) E(p);
239
+ const d = await e(c, p, s, o);
240
+ for (const E of u) E(d);
227
241
  }
228
242
  };
229
243
  }
230
244
  return {
231
245
  query: r,
232
- mutate: (n) => G(t, n)
246
+ mutate: (n) => F(t, n)
233
247
  };
234
248
  }
235
- const A = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
236
- function U(t = A) {
249
+ const q = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
250
+ function j(t = q) {
237
251
  return `/services/data/v${t}`;
238
252
  }
239
- const fe = {
253
+ const we = {
240
254
  "Content-Type": "application/json",
241
255
  Accept: "application/json"
242
256
  };
243
- class me {
257
+ class ge {
244
258
  clientFetch;
245
259
  pathData;
246
260
  apiVersion;
247
261
  graphql;
248
262
  constructor(e) {
249
- const r = ye(), n = be(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
250
- this.apiVersion = e?.apiVersion ?? r.apiVersion ?? A, this.pathData = U(this.apiVersion), this.clientFetch = ce(n || void 0, s), this.graphql = H(this.executeRawGraphQL.bind(this));
263
+ const r = ve(), n = k(e?.instanceUrl ?? r.instanceUrl), a = e?.accessToken ?? r.accessToken, s = k(
264
+ e?.lightningDomain ?? r.lightningDomain
265
+ ), o = e?.isInternal ?? r.isInternal ?? !1;
266
+ this.apiVersion = e?.apiVersion ?? r.apiVersion ?? q, this.pathData = j(this.apiVersion), this.clientFetch = de({
267
+ baseUrl: n || void 0,
268
+ accessToken: a,
269
+ lightningDomain: s || void 0,
270
+ isInternal: o
271
+ }), this.graphql = U(this.executeRawGraphQL.bind(this));
251
272
  }
252
273
  async executeRawGraphQL({
253
274
  query: e,
254
275
  variables: r,
255
276
  operationName: n,
256
- headers: s
277
+ headers: a
257
278
  }) {
258
- const a = `${this.pathData}/graphql`, o = await this.clientFetch(a, {
279
+ const s = `${this.pathData}/graphql`, o = await this.clientFetch(s, {
259
280
  method: "POST",
260
281
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
261
- headers: V(fe, s)
282
+ headers: I(we, a)
262
283
  });
263
- return I(o, "Mosaic", a);
284
+ return G(o, "Mosaic", s);
264
285
  }
265
286
  }
266
- function ye() {
287
+ function ve() {
267
288
  const t = globalThis.MOSAIC_ENV;
268
289
  return {
269
290
  instanceUrl: t?.instanceUrl,
270
291
  accessToken: t?.accessToken,
271
- apiVersion: t?.apiVersion
292
+ apiVersion: t?.apiVersion,
293
+ lightningDomain: t?.lightningDomain,
294
+ isInternal: t?.isInternal
272
295
  };
273
296
  }
274
- function be(t) {
297
+ function k(t) {
275
298
  if (!t || t === "/") return "";
276
299
  let e = t;
277
300
  return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
278
301
  }
279
- const we = "graphqlQuery";
280
- class ve {
302
+ const Ee = "graphqlQuery";
303
+ class Se {
281
304
  graphql;
282
305
  constructor() {
283
- this.graphql = H(this.executeRawGraphQL.bind(this));
306
+ this.graphql = U(this.executeRawGraphQL.bind(this));
284
307
  }
285
308
  /**
286
309
  * The `headers` request option is intentionally not forwarded: this surface
@@ -292,60 +315,61 @@ class ve {
292
315
  variables: r,
293
316
  operationName: n
294
317
  }) {
295
- return (await window.openai.callTool(we, {
318
+ return (await window.openai.callTool(Ee, {
296
319
  query: e,
297
320
  ...r != null ? { variables: r } : {},
298
321
  ...n != null ? { operationName: n } : {}
299
322
  })).structuredContent;
300
323
  }
301
324
  }
302
- const S = "Accept-Language", ge = (t) => {
325
+ const C = "Accept-Language", Ce = (t) => {
303
326
  const e = globalThis.SFDC_ENV?.language;
304
327
  if (!e)
305
328
  return l(t);
306
329
  const [r, n] = t;
307
- return (r instanceof Request && !n?.headers ? r.headers.has(S) : new Headers(n?.headers).has(S)) ? l(t) : l(b(S, e, t));
308
- }, Ee = "X-SFDC-Client-Name", Se = "X-SFDC-Client-Version", Ce = "@salesforce/platform-sdk", xe = "12.6.3", De = (t) => {
309
- let e = b(Ee, Ce, t);
310
- return e = b(Se, xe, e), l(e);
311
- }, Oe = "X-CSRF-Token";
312
- function Ne(t, e = {}) {
330
+ return (r instanceof Request && !n?.headers ? r.headers.has(C) : new Headers(n?.headers).has(C)) ? l(t) : l(y(C, e, t));
331
+ }, De = "X-SFDC-Client-Name", xe = "X-SFDC-Client-Version", Oe = "@salesforce/platform-sdk", Ne = "12.7.0", $e = (t) => {
332
+ let e = y(De, Oe, t);
333
+ return e = y(xe, Ne, e), l(e);
334
+ }, Ae = "X-CSRF-Token";
335
+ function Pe(t, e = {}) {
313
336
  const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
314
- return async (s) => {
315
- 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";
316
- if (_(n, i) || $e(c) && _(r, i)) {
337
+ return async (a) => {
338
+ 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";
339
+ if (T(n, i) || qe(c) && T(r, i)) {
317
340
  const u = await t.getToken();
318
- s = b(Oe, u, s);
341
+ a = y(Ae, u, a);
319
342
  }
320
- return l(s);
343
+ return l(a);
321
344
  };
322
345
  }
323
- function $e(t) {
346
+ function qe(t) {
324
347
  const e = t.toLowerCase();
325
348
  return e === "post" || e === "put" || e === "patch" || e === "delete";
326
349
  }
327
- function _(t, e) {
350
+ function T(t, e) {
328
351
  const r = new URL(e, globalThis.location?.href ?? "http://localhost");
329
352
  return t.some((n) => r.pathname.includes(n));
330
353
  }
331
- function qe(t, e = {}) {
332
- const r = Ne(t, e);
333
- async function n(s) {
334
- const a = await r(s);
335
- return fetch(a[0], a[1]);
354
+ function _e(t, e = {}) {
355
+ const r = Pe(t, e);
356
+ async function n(a) {
357
+ const s = await r(a);
358
+ return fetch(s[0], s[1]);
336
359
  }
337
- return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
360
+ return (a, s) => s ? s.applyRetry(async () => n(a)) : n(a);
338
361
  }
339
- const Ae = [400, 401, 403];
340
- class Pe extends X {
362
+ const ke = [400, 401, 403];
363
+ class Te extends Z {
341
364
  constructor(e) {
342
365
  super(e), this.csrfTokenManager = e;
343
366
  }
367
+ csrfTokenManager;
344
368
  /**
345
369
  * Determines if a failed request should be retried due to CSRF token issues.
346
370
  */
347
371
  async shouldRetry(e, r) {
348
- return r.attempt >= 1 ? !1 : Ae.includes(e.status);
372
+ return r.attempt >= 1 ? !1 : ke.includes(e.status);
349
373
  }
350
374
  /**
351
375
  * CSRF token refresh should happen immediately with no delay.
@@ -363,10 +387,12 @@ class Pe extends X {
363
387
  await this.csrfTokenManager.refreshToken();
364
388
  }
365
389
  }
366
- class _e {
390
+ class Re {
367
391
  constructor(e, r) {
368
392
  this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
369
393
  }
394
+ endpoint;
395
+ cacheName;
370
396
  tokenPromise;
371
397
  refreshPromise;
372
398
  /**
@@ -392,10 +418,10 @@ class _e {
392
418
  * @returns Promise that resolves to the CSRF token string
393
419
  */
394
420
  async obtainToken() {
395
- let e = await this.withCache((s) => s.match(this.endpoint)), r = !1;
421
+ let e = await this.withCache((a) => a.match(this.endpoint)), r = !1;
396
422
  e || (e = await fetch(this.endpoint, { method: "get" }), r = !0);
397
423
  const n = (await e.clone().json()).csrfToken;
398
- return r && await this.withCache((s) => s.put(this.endpoint, e)), n;
424
+ return r && await this.withCache((a) => a.put(this.endpoint, e)), n;
399
425
  }
400
426
  /**
401
427
  * Provides a safe way to interact with the Cache API with fallback for unsupported environments.
@@ -411,29 +437,29 @@ class _e {
411
437
  return;
412
438
  }
413
439
  }
414
- const k = /* @__PURE__ */ new Map();
415
- function ke(t) {
440
+ const R = /* @__PURE__ */ new Map();
441
+ function Me(t) {
416
442
  const { endpoint: e, cacheName: r, ...n } = t.csrf;
417
- let s = k.get(e);
418
- return s || (s = new _e(e, r), k.set(e, s)), M(
443
+ let a = R.get(e);
444
+ return a || (a = new Re(e, r), R.set(e, a)), V(
419
445
  {
420
- retry: qe(s, n),
421
- request: [De, ge]
446
+ retry: _e(a, n),
447
+ request: [$e, Ce]
422
448
  },
423
- Y(new Pe(s)).service
449
+ ee(new Te(a)).service
424
450
  ).service;
425
451
  }
426
- const T = /* @__PURE__ */ new Map();
427
- function Te(t) {
428
- let e = T.get(t);
452
+ const M = /* @__PURE__ */ new Map();
453
+ function Le(t) {
454
+ let e = M.get(t);
429
455
  if (!e) {
430
- const r = Z().service, n = te(r).service, s = ee(r, n).service, a = re().service;
431
- e = { cache: r, cacheController: s, pubSub: a }, T.set(t, e);
456
+ const r = te().service, n = ne(r).service, a = re(r, n).service, s = se().service;
457
+ e = { cache: r, cacheController: a, pubSub: s }, M.set(t, e);
432
458
  }
433
459
  return e;
434
460
  }
435
- function Re(t, e) {
436
- const r = Te(t);
461
+ function Ve(t, e) {
462
+ const r = Le(t);
437
463
  return {
438
464
  shared: r,
439
465
  services: {
@@ -443,31 +469,32 @@ function Re(t, e) {
443
469
  }
444
470
  };
445
471
  }
446
- const R = 300;
447
- function Me(t, e) {
472
+ const L = 300;
473
+ function Ie(t, e) {
448
474
  try {
449
475
  return JSON.parse(JSON.stringify(t));
450
476
  } catch (r) {
451
- const n = e || "(anonymous)", s = new TypeError(
477
+ const n = e || "(anonymous)", a = new TypeError(
452
478
  `HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${r.message}`
453
479
  );
454
- throw s.cause = r, s;
480
+ throw a.cause = r, a;
455
481
  }
456
482
  }
457
- function Ve(t) {
483
+ function He(t) {
458
484
  if (typeof t == "object" && t.type === "max-age") {
459
485
  const e = t.maxAge;
460
- return Number.isFinite(e) && e >= 0 ? e : R;
486
+ return Number.isFinite(e) && e >= 0 ? e : L;
461
487
  }
462
- return R;
488
+ return L;
463
489
  }
464
- class Le extends ne {
490
+ class Ge extends ae {
465
491
  constructor(e, r, n) {
466
- super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Me(
492
+ super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Ie(
467
493
  e.variables ?? {},
468
494
  this.normalizedOperationName
469
- ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Ve(e.cacheControl), this.headers = e.headers, this.headersKey = le(e.headers);
495
+ ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = He(e.cacheControl), this.headers = e.headers, this.headersKey = me(e.headers);
470
496
  }
497
+ url;
471
498
  query;
472
499
  normalizedVariables;
473
500
  normalizedOperationName;
@@ -480,7 +507,7 @@ class Le extends ne {
480
507
  this.url,
481
508
  {
482
509
  method: "POST",
483
- headers: L(this.headers),
510
+ headers: H(this.headers),
484
511
  body: JSON.stringify({
485
512
  query: this.query,
486
513
  variables: this.normalizedVariables,
@@ -495,7 +522,7 @@ class Le extends ne {
495
522
  variables: this.normalizedVariables,
496
523
  operationName: this.normalizedOperationName
497
524
  };
498
- return this.headersKey !== void 0 && (e.headers = this.headersKey), K(e);
525
+ return this.headersKey !== void 0 && (e.headers = this.headersKey), J(e);
499
526
  }
500
527
  /**
501
528
  * Reads from the cache and returns the cache result or error
@@ -513,7 +540,7 @@ class Le extends ne {
513
540
  readFromCache(e) {
514
541
  const r = this.buildKey(), n = e.get(r)?.value;
515
542
  return n === void 0 ? l(
516
- D(new z("No cached entry found for this query."))
543
+ O(new W("No cached entry found for this query."))
517
544
  ) : l(x(n));
518
545
  }
519
546
  writeToCache(e, r) {
@@ -544,90 +571,90 @@ class Le extends ne {
544
571
  return e.errors && e.errors.length > 0;
545
572
  }
546
573
  processFetchReturnValue(e) {
547
- return this.responseHasErrors(e) ? D(new J(e)) : x(e);
574
+ return this.responseHasErrors(e) ? O(new B(e)) : x(e);
548
575
  }
549
576
  }
550
- const Ie = "CACHE_MISS";
551
- function Ge() {
577
+ const Fe = "CACHE_MISS";
578
+ function Ue() {
552
579
  return [
553
580
  {
554
581
  message: "No cached entry found for this query (cacheControl: 'only-if-cached').",
555
- extensions: { code: Ie }
582
+ extensions: { code: Fe }
556
583
  }
557
584
  ];
558
585
  }
559
- function F(t) {
560
- if (W(t) && t.data && typeof t.data == "object") {
586
+ function Q(t) {
587
+ if (X(t) && t.data && typeof t.data == "object") {
561
588
  const e = t.data;
562
589
  if (e.data != null)
563
590
  return e.data;
564
591
  }
565
592
  }
566
- function He(t) {
593
+ function je(t) {
567
594
  return (e) => {
568
595
  if (e.isOk()) {
569
596
  const r = e.value;
570
597
  w(r), t({ data: r, errors: void 0 });
571
598
  } else {
572
- const r = F(e.error);
599
+ const r = Q(e.error);
573
600
  r && w(r), t({ data: r, errors: m(e.error) });
574
601
  }
575
602
  };
576
603
  }
577
- async function Ue(t, e = !1) {
578
- let r, n, s;
604
+ async function Qe(t, e = !1) {
605
+ let r, n, a;
579
606
  try {
580
- const a = await t.execute();
581
- a.isOk() ? (r = a.value.data, w(r), s = (o) => a.value.subscribe(o)) : (r = F(a.error.failure), r && w(r), n = e && r === void 0 ? Ge() : m(a.error.failure), s = (o) => a.error.subscribe(o));
582
- } catch (a) {
583
- n = m(a);
607
+ const s = await t.execute();
608
+ s.isOk() ? (r = s.value.data, w(r), a = (o) => s.value.subscribe(o)) : (r = Q(s.error.failure), r && w(r), n = e && r === void 0 ? Ue() : m(s.error.failure), a = (o) => s.error.subscribe(o));
609
+ } catch (s) {
610
+ n = m(s);
584
611
  }
585
612
  return {
586
613
  data: r,
587
614
  errors: n,
588
- subscribe(a) {
589
- return s ? s(He(a)) : g;
615
+ subscribe(s) {
616
+ return a ? a(je(s)) : v;
590
617
  },
591
618
  async refresh() {
592
619
  await t.refresh();
593
620
  }
594
621
  };
595
622
  }
596
- function C(t) {
623
+ function D(t) {
597
624
  return {
598
625
  data: void 0,
599
626
  errors: t,
600
- subscribe: () => g,
601
- refresh: O
627
+ subscribe: () => v,
628
+ refresh: N
602
629
  };
603
630
  }
604
- function Fe({
631
+ function Ke({
605
632
  bundle: t,
606
633
  url: e,
607
634
  executeRaw: r
608
635
  }) {
609
636
  const { services: n } = t;
610
- async function s({
611
- query: a,
637
+ async function a({
638
+ query: s,
612
639
  variables: o,
613
640
  operationName: i,
614
641
  cacheControl: c,
615
642
  headers: h
616
643
  }) {
617
- const u = $(a);
618
- if (u.isErr()) return C(u.error);
619
- const d = u.value, f = q(d, i);
644
+ const u = A(s);
645
+ if (u.isErr()) return D(u.error);
646
+ const p = u.value, f = P(p, i);
620
647
  if (f !== "query")
621
- return C([
648
+ return D([
622
649
  {
623
650
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
624
651
  }
625
652
  ]);
626
- let p;
653
+ let d;
627
654
  try {
628
- p = new Le(
655
+ d = new Ge(
629
656
  {
630
- query: N(d),
657
+ query: $(p),
631
658
  variables: o,
632
659
  operationName: i,
633
660
  cacheControl: c,
@@ -637,17 +664,17 @@ function Fe({
637
664
  e
638
665
  );
639
666
  } catch (E) {
640
- return C(m(E));
667
+ return D(m(E));
641
668
  }
642
- return Ue(p, c === "only-if-cached");
669
+ return Qe(d, c === "only-if-cached");
643
670
  }
644
671
  return {
645
- query: s,
646
- mutate: (a) => G(r, a)
672
+ query: a,
673
+ mutate: (s) => F(r, s)
647
674
  };
648
675
  }
649
- const Qe = 1, je = `@salesforce/platform-sdk-data_v${Qe}`;
650
- class Ke {
676
+ const ze = 1, Je = `@salesforce/platform-sdk-data_v${ze}`;
677
+ class We {
651
678
  baseUrl;
652
679
  pathData;
653
680
  clientFetch;
@@ -655,27 +682,27 @@ class Ke {
655
682
  apiVersion;
656
683
  graphql;
657
684
  constructor(e) {
658
- const r = ze();
659
- this.baseUrl = Je(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? A, this.pathData = U(this.apiVersion);
660
- const n = `${this.pathData}/ui-api`, s = `${this.pathData}/graphql`;
661
- this.onStatus = e?.onStatus ?? {}, this.clientFetch = ke({
685
+ const r = Be();
686
+ this.baseUrl = Xe(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? q, this.pathData = j(this.apiVersion);
687
+ const n = `${this.pathData}/ui-api`, a = `${this.pathData}/graphql`;
688
+ this.onStatus = e?.onStatus ?? {}, this.clientFetch = Me({
662
689
  csrf: {
663
690
  endpoint: `${this.baseUrl}${n}/session/csrf`,
664
- cacheName: je,
691
+ cacheName: Je,
665
692
  protectedUrls: ["services/data/v", "services/apexrest"],
666
693
  alwaysProtectedUrls: ["services/apexrest"]
667
694
  }
668
695
  });
669
- const a = (i, c) => this.fetch(i, c), o = Re(`${this.baseUrl}${this.pathData}`, a);
670
- this.graphql = Fe({
696
+ const s = (i, c) => this.fetch(i, c), o = Ve(`${this.baseUrl}${this.pathData}`, s);
697
+ this.graphql = Ke({
671
698
  bundle: o,
672
- url: s,
699
+ url: a,
673
700
  executeRaw: this.executeRawGraphQL.bind(this)
674
701
  });
675
702
  }
676
703
  async fetch(e, r) {
677
- const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
678
- return await this.onStatus[s.status]?.(), s;
704
+ const n = this.applySalesforceBase(e), a = await this.clientFetch(n, r);
705
+ return await this.onStatus[a.status]?.(), a;
679
706
  }
680
707
  /**
681
708
  * Raw GraphQL POST. On the WebApp surface this is the mutate-only path:
@@ -687,14 +714,14 @@ class Ke {
687
714
  query: e,
688
715
  variables: r,
689
716
  operationName: n,
690
- headers: s
717
+ headers: a
691
718
  }) {
692
- const a = `${this.pathData}/graphql`, o = await this.fetch(a, {
719
+ const s = `${this.pathData}/graphql`, o = await this.fetch(s, {
693
720
  method: "POST",
694
721
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
695
- headers: L(s)
722
+ headers: H(a)
696
723
  });
697
- return I(o, "WebApp", a);
724
+ return G(o, "WebApp", s);
698
725
  }
699
726
  /**
700
727
  * If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
@@ -710,44 +737,44 @@ class Ke {
710
737
  return e;
711
738
  }
712
739
  }
713
- function ze() {
740
+ function Be() {
714
741
  return {
715
742
  apiPath: globalThis.SFDC_ENV?.apiPath
716
743
  };
717
744
  }
718
- function Je(t) {
745
+ function Xe(t) {
719
746
  if (!t || t === "/") return "";
720
747
  let e = t;
721
748
  return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
722
749
  }
723
- function We(t) {
724
- 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;
725
- if (typeof s?.setup != "function")
750
+ function Ye(t) {
751
+ 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;
752
+ if (typeof a?.setup != "function")
726
753
  throw new Error("Extension entry cannot attach: it is missing a setup function.");
727
- if (typeof a != "string" || a.length === 0)
754
+ if (typeof s != "string" || s.length === 0)
728
755
  throw new Error(
729
756
  n ? 'Extension entry cannot attach: "name" must be a non-empty string.' : 'Extension entry cannot attach: alias "as" must be a non-empty string.'
730
757
  );
731
758
  return {
732
- extension: s,
733
- mountName: a,
734
- label: a === s.name ? `"${s.name}"` : `"${s.name}" (aliased as "${a}")`
759
+ extension: a,
760
+ mountName: s,
761
+ label: s === a.name ? `"${a.name}"` : `"${a.name}" (aliased as "${s}")`
735
762
  };
736
763
  }
737
- async function Be(t, e, r) {
764
+ async function Ze(t, e, r) {
738
765
  if (e.length === 0)
739
766
  return t;
740
767
  if ("ext" in t)
741
768
  throw new Error(
742
769
  'Cannot attach extensions: the base SDK already declares an "ext" member, which the extension container reserves.'
743
770
  );
744
- const n = e.map(We);
771
+ const n = e.map(Ye);
745
772
  r?.preflight?.(n, t);
746
- const s = Object.create(t), a = /* @__PURE__ */ Object.create(null), o = (h) => {
773
+ const a = Object.create(t), s = /* @__PURE__ */ Object.create(null), o = (h) => {
747
774
  throw new Error(`Cannot write "ext.${String(h)}" — ext is immutable once attached.`);
748
775
  }, i = (h) => {
749
776
  throw new Error(`Cannot ${h} "ext" — ext is immutable once attached.`);
750
- }, c = new Proxy(a, {
777
+ }, c = new Proxy(s, {
751
778
  set(h, u) {
752
779
  return o(u);
753
780
  },
@@ -768,52 +795,52 @@ async function Be(t, e, r) {
768
795
  return i("change the prototype of");
769
796
  }
770
797
  });
771
- Object.defineProperty(s, "ext", {
798
+ Object.defineProperty(a, "ext", {
772
799
  value: c,
773
800
  enumerable: !0,
774
801
  writable: !1,
775
802
  configurable: !1
776
803
  });
777
- for (const { extension: h, mountName: u, label: d } of n) {
778
- if (Object.hasOwn(a, u))
804
+ for (const { extension: h, mountName: u, label: p } of n) {
805
+ if (Object.hasOwn(s, u))
779
806
  throw new Error(
780
- `Extension ${d} cannot attach: "${u}" is already defined by another extension.`
807
+ `Extension ${p} cannot attach: "${u}" is already defined by another extension.`
781
808
  );
782
809
  let f;
783
810
  try {
784
- f = await h.setup(s);
785
- } catch (p) {
786
- throw new Error(`Extension ${d} failed during setup.`, { cause: p });
811
+ f = await h.setup(a);
812
+ } catch (d) {
813
+ throw new Error(`Extension ${p} failed during setup.`, { cause: d });
787
814
  }
788
- Object.defineProperty(a, u, {
815
+ Object.defineProperty(s, u, {
789
816
  value: f,
790
817
  enumerable: !0,
791
818
  writable: !1,
792
819
  configurable: !1
793
820
  });
794
821
  }
795
- return Object.freeze(a), s;
822
+ return Object.freeze(s), a;
796
823
  }
797
- function ut(t, ...e) {
824
+ function dt(t, ...e) {
798
825
  let r = t[0] ?? "";
799
826
  for (let n = 0; n < e.length; n += 1)
800
827
  r += String(e[n]) + (t[n + 1] ?? "");
801
828
  return r;
802
829
  }
803
- function ht(t) {
830
+ function pt(t) {
804
831
  return t;
805
832
  }
806
- async function Xe(t) {
833
+ async function et(t) {
807
834
  try {
808
- switch (await Q(t?.surface)) {
809
- case y.OpenAI:
810
- return new ve();
811
- case y.WebApp:
812
- case y.MicroFrontend:
813
- return new Ke(t?.webapp);
814
- case y.Mosaic:
815
- return new me(t?.mosaic);
816
- case y.MCPApps:
835
+ switch (await K(t?.surface)) {
836
+ case b.OpenAI:
837
+ return new Se();
838
+ case b.WebApp:
839
+ case b.MicroFrontend:
840
+ return new We(t?.webapp);
841
+ case b.Mosaic:
842
+ return new ge(t?.mosaic);
843
+ case b.MCPApps:
817
844
  return {};
818
845
  default:
819
846
  return {};
@@ -822,19 +849,19 @@ async function Xe(t) {
822
849
  return {};
823
850
  }
824
851
  }
825
- function lt(t) {
826
- return j(
852
+ function ft(t) {
853
+ return z(
827
854
  (async () => {
828
- const e = await Xe(t);
829
- return Be(e, t?.extensions ?? [], {
830
- preflight: ae
855
+ const e = await et(t);
856
+ return Ze(e, t?.extensions ?? [], {
857
+ preflight: ie
831
858
  });
832
859
  })(),
833
860
  "createDataSDK"
834
861
  );
835
862
  }
836
863
  export {
837
- lt as createDataSDK,
838
- ht as defineDataExtension,
839
- ut as gql
864
+ ft as createDataSDK,
865
+ pt as defineDataExtension,
866
+ dt as gql
840
867
  };