@salesforce/platform-sdk 11.71.4 → 12.0.0

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