@salesforce/platform-sdk 11.56.1 → 11.56.2

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,16 @@
1
- import { g as V, S as y } from "../surface-Dd2tqrPi.js";
2
- import { w as x } from "../sdk-promise-D0sy7OW1.js";
3
- import { c as G } from "../plugin-factory-BC3b3BOy.js";
4
- import { buildServiceDescriptor as $, setHeader as b } from "@conduit-client/service-fetch-network/v1";
5
- import { resolvedPromiseLike as u, ok as C, err as D, stableJSONStringify as Q, DataNotFoundError as j, UserVisibleError as z, deepFreeze as g, isUserVisibleError as W } from "@conduit-client/utils";
6
- import { print as P, parse as B } from "@conduit-client/onestore-graphql-parser/v1";
7
- import { RetryPolicy as J, 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 U, S as y } from "../surface-Dd2tqrPi.js";
2
+ import { w as V } from "../sdk-promise-D0sy7OW1.js";
3
+ import { c as j } from "../plugin-factory-BC3b3BOy.js";
4
+ import { buildServiceDescriptor as L, setHeader as b } from "@conduit-client/service-fetch-network/v1";
5
+ import { resolvedPromiseLike as u, ok as D, err as P, stableJSONStringify as z, DataNotFoundError as W, UserVisibleError as J, deepFreeze as g, isUserVisibleError as B } from "@conduit-client/utils";
6
+ import { print as O, parse as X } from "@conduit-client/onestore-graphql-parser/v1";
7
+ import { RetryPolicy as Y, buildServiceDescriptor as Z } from "@conduit-client/service-retry/v1";
8
+ import { buildServiceDescriptor as ee } from "@conduit-client/service-cache/v1";
9
+ import { buildServiceDescriptor as te } from "@conduit-client/service-cache-control/v1";
10
+ import { buildInMemoryCacheInclusionPolicyService as re } from "@conduit-client/service-cache-inclusion-policy/v1";
11
+ import { buildServiceDescriptor as ne } from "@conduit-client/service-pubsub/v1";
12
+ import { HttpCacheControlCommand as se } from "@conduit-client/command-http-cache-control/v1";
13
+ function ae(t) {
14
14
  return (e) => {
15
15
  const [r, n] = e;
16
16
  if (typeof r == "string" && !r.startsWith("http")) {
@@ -20,21 +20,21 @@ function ne(t) {
20
20
  return u(e);
21
21
  };
22
22
  }
23
- function se(t) {
23
+ function oe(t) {
24
24
  return (e) => u(b("Authorization", `Bearer ${t}`, e));
25
25
  }
26
- function ae(t, e) {
26
+ function ie(t, e) {
27
27
  const r = [];
28
- return t && r.push(ne(t)), e && r.push(se(e)), $({
28
+ return t && r.push(ae(t)), e && r.push(oe(e)), L({
29
29
  request: r
30
30
  }).service;
31
31
  }
32
- const oe = {
32
+ const ce = {
33
33
  "Content-Type": "application/json",
34
34
  Accept: "application/json",
35
35
  "X-Chatter-Entity-Encoding": "false"
36
36
  };
37
- function ie(t) {
37
+ function ue(t) {
38
38
  if (t instanceof Headers) {
39
39
  const e = [];
40
40
  return t.forEach((r, n) => e.push([n, r])), e;
@@ -46,39 +46,71 @@ function M(t, e) {
46
46
  const r = { ...t }, n = /* @__PURE__ */ new Map();
47
47
  for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
48
48
  const s = /* @__PURE__ */ new Set();
49
- for (const [a, i] of ie(e)) {
50
- const o = a.toLowerCase(), c = n.get(o);
51
- c === void 0 ? (r[a] = i, n.set(o, a), s.add(o)) : s.has(o) ? r[c] = `${r[c]}, ${i}` : (r[c] = i, s.add(o));
49
+ for (const [a, o] of ue(e)) {
50
+ const i = a.toLowerCase(), c = n.get(i);
51
+ 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
52
  }
53
53
  return r;
54
54
  }
55
- function L(t) {
56
- return M(oe, t);
55
+ function H(t) {
56
+ return M(ce, t);
57
57
  }
58
- function ce(t) {
58
+ function he(t) {
59
59
  if (t === void 0) return;
60
60
  const e = {};
61
61
  return new Headers(t).forEach((r, n) => {
62
62
  e[n] = r;
63
63
  }), Object.keys(e).length > 0 ? e : void 0;
64
64
  }
65
- const S = () => {
65
+ const le = 512;
66
+ function de(t) {
67
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
68
+ }
69
+ class N extends Error {
70
+ status;
71
+ url;
72
+ constructor(e) {
73
+ 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, le)))})`;
74
+ super(
75
+ `${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
+ ), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
77
+ }
78
+ }
79
+ async function I(t, e, r) {
80
+ const n = await t.text();
81
+ let s;
82
+ try {
83
+ s = JSON.parse(n);
84
+ } catch (a) {
85
+ throw new N({ surface: e, url: r, status: t.status, body: n, cause: a });
86
+ }
87
+ if (s === null || typeof s != "object")
88
+ throw new N({
89
+ surface: e,
90
+ url: r,
91
+ status: t.status,
92
+ body: n,
93
+ cause: new Error("Parsed GraphQL response body was not a JSON object")
94
+ });
95
+ return s;
96
+ }
97
+ const w = () => {
66
98
  }, A = async () => {
67
99
  };
68
- function _(t) {
100
+ function T(t) {
69
101
  try {
70
- return C(B(t));
102
+ return D(X(t));
71
103
  } catch (e) {
72
- return D(f(e));
104
+ return P(p(e));
73
105
  }
74
106
  }
75
- function k(t, e) {
107
+ function _(t, e) {
76
108
  const r = t.definitions.filter(
77
109
  (n) => n.kind === "OperationDefinition"
78
110
  );
79
111
  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";
80
112
  }
81
- function f(t) {
113
+ function p(t) {
82
114
  if (t && typeof t == "object" && "data" in t) {
83
115
  const e = t.data;
84
116
  if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
@@ -86,22 +118,22 @@ function f(t) {
86
118
  }
87
119
  return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
88
120
  }
89
- async function H(t, { mutation: e, variables: r, operationName: n, headers: s }) {
90
- const a = _(e);
121
+ async function G(t, { mutation: e, variables: r, operationName: n, headers: s }) {
122
+ const a = T(e);
91
123
  if (a.isErr()) return { data: void 0, errors: a.error };
92
- const i = a.value, o = k(i, n);
93
- if (o !== "mutation")
124
+ const o = a.value, i = _(o, n);
125
+ if (i !== "mutation")
94
126
  return {
95
127
  data: void 0,
96
128
  errors: [
97
129
  {
98
- message: `DataSDK.graphql.mutate() requires a GraphQL mutation, received ${o}.`
130
+ message: `DataSDK.graphql.mutate() requires a GraphQL mutation, received ${i}.`
99
131
  }
100
132
  ]
101
133
  };
102
134
  try {
103
135
  const c = await t({
104
- query: P(i),
136
+ query: O(o),
105
137
  variables: r,
106
138
  operationName: n,
107
139
  headers: s
@@ -111,39 +143,39 @@ async function H(t, { mutation: e, variables: r, operationName: n, headers: s })
111
143
  errors: c.errors
112
144
  };
113
145
  } catch (c) {
114
- return { data: void 0, errors: f(c) };
146
+ return { data: void 0, errors: p(c) };
115
147
  }
116
148
  }
117
- function I(t) {
118
- function e(n, s, a, i) {
149
+ function F(t) {
150
+ function e(n, s, a, o) {
119
151
  return t({
120
- query: P(n),
152
+ query: O(n),
121
153
  variables: s,
122
154
  operationName: a,
123
- headers: i
155
+ headers: o
124
156
  }).then(
125
- (o) => ({
126
- data: o.data ?? void 0,
127
- errors: o.errors
157
+ (i) => ({
158
+ data: i.data ?? void 0,
159
+ errors: i.errors
128
160
  }),
129
- (o) => ({ data: void 0, errors: f(o) })
161
+ (i) => ({ data: void 0, errors: p(i) })
130
162
  );
131
163
  }
132
164
  async function r({
133
165
  query: n,
134
166
  variables: s,
135
167
  operationName: a,
136
- headers: i
168
+ headers: o
137
169
  }) {
138
- const o = _(n);
139
- if (o.isErr())
170
+ const i = T(n);
171
+ if (i.isErr())
140
172
  return {
141
173
  data: void 0,
142
- errors: o.error,
143
- subscribe: () => S,
174
+ errors: i.error,
175
+ subscribe: () => w,
144
176
  refresh: A
145
177
  };
146
- const c = o.value, l = k(c, a);
178
+ const c = i.value, l = _(c, a);
147
179
  if (l !== "query")
148
180
  return {
149
181
  data: void 0,
@@ -152,10 +184,10 @@ function I(t) {
152
184
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${l}.`
153
185
  }
154
186
  ],
155
- subscribe: () => S,
187
+ subscribe: () => w,
156
188
  refresh: A
157
189
  };
158
- const h = /* @__PURE__ */ new Set(), p = s, m = await e(c, p, a, i);
190
+ const h = /* @__PURE__ */ new Set(), f = s, m = await e(c, f, a, o);
159
191
  return {
160
192
  data: m.data,
161
193
  errors: m.errors,
@@ -165,31 +197,31 @@ function I(t) {
165
197
  };
166
198
  },
167
199
  async refresh() {
168
- const d = await e(c, p, a, i);
169
- for (const v of h) v(d);
200
+ const d = await e(c, f, a, o);
201
+ for (const S of h) S(d);
170
202
  }
171
203
  };
172
204
  }
173
205
  return {
174
206
  query: r,
175
- mutate: (n) => H(t, n)
207
+ mutate: (n) => G(t, n)
176
208
  };
177
209
  }
178
- const ue = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
179
- function F(t = ue) {
210
+ const pe = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
211
+ function Q(t = pe) {
180
212
  return `/services/data/v${t}`;
181
213
  }
182
- const he = {
214
+ const fe = {
183
215
  "Content-Type": "application/json",
184
216
  Accept: "application/json"
185
217
  };
186
- class le {
218
+ class me {
187
219
  clientFetch;
188
220
  pathData;
189
221
  graphql;
190
222
  constructor(e) {
191
- const r = de(), n = fe(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
192
- this.pathData = F(e?.apiVersion ?? r.apiVersion), this.clientFetch = ae(n || void 0, s), this.graphql = I(this.executeRawGraphQL.bind(this));
223
+ const r = ye(), n = be(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
224
+ this.pathData = Q(e?.apiVersion ?? r.apiVersion), this.clientFetch = ie(n || void 0, s), this.graphql = F(this.executeRawGraphQL.bind(this));
193
225
  }
194
226
  async executeRawGraphQL({
195
227
  query: e,
@@ -197,14 +229,15 @@ class le {
197
229
  operationName: n,
198
230
  headers: s
199
231
  }) {
200
- return (await this.clientFetch(`${this.pathData}/graphql`, {
232
+ const a = `${this.pathData}/graphql`, o = await this.clientFetch(a, {
201
233
  method: "POST",
202
234
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
203
- headers: M(he, s)
204
- })).json();
235
+ headers: M(fe, s)
236
+ });
237
+ return I(o, "Mosaic", a);
205
238
  }
206
239
  }
207
- function de() {
240
+ function ye() {
208
241
  const t = globalThis.MOSAIC_ENV;
209
242
  return {
210
243
  instanceUrl: t?.instanceUrl,
@@ -212,16 +245,16 @@ function de() {
212
245
  apiVersion: t?.apiVersion
213
246
  };
214
247
  }
215
- function fe(t) {
248
+ function be(t) {
216
249
  if (!t || t === "/") return "";
217
250
  let e = t;
218
251
  return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
219
252
  }
220
- const pe = "graphqlQuery";
221
- class me {
253
+ const ge = "graphqlQuery";
254
+ class we {
222
255
  graphql;
223
256
  constructor() {
224
- this.graphql = I(this.executeRawGraphQL.bind(this));
257
+ this.graphql = F(this.executeRawGraphQL.bind(this));
225
258
  }
226
259
  /**
227
260
  * The `headers` request option is intentionally not forwarded: this surface
@@ -233,55 +266,55 @@ class me {
233
266
  variables: r,
234
267
  operationName: n
235
268
  }) {
236
- return (await window.openai.callTool(pe, {
269
+ return (await window.openai.callTool(ge, {
237
270
  query: e,
238
271
  ...r != null ? { variables: r } : {},
239
272
  ...n != null ? { operationName: n } : {}
240
273
  })).structuredContent;
241
274
  }
242
275
  }
243
- const ye = {
276
+ const Se = {
244
277
  graphql: !0,
245
278
  fetch: !0
246
- }, be = new Set(Object.keys(ye)), w = "Accept-Language", ge = (t) => {
279
+ }, ve = new Set(Object.keys(Se)), v = "Accept-Language", Ee = (t) => {
247
280
  const e = globalThis.SFDC_ENV?.language;
248
281
  if (!e)
249
282
  return u(t);
250
283
  const [r, n] = t;
251
- return (r instanceof Request && !n?.headers ? r.headers.has(w) : new Headers(n?.headers).has(w)) ? u(t) : u(b(w, e, t));
252
- }, Se = "X-SFDC-Client-Name", ve = "X-SFDC-Client-Version", we = "@salesforce/platform-sdk", Ee = "11.56.1", Ce = (t) => {
253
- let e = b(Se, we, t);
254
- return e = b(ve, Ee, e), u(e);
255
- }, De = "X-CSRF-Token";
256
- function Ae(t, e = {}) {
284
+ return (r instanceof Request && !n?.headers ? r.headers.has(v) : new Headers(n?.headers).has(v)) ? u(t) : u(b(v, e, t));
285
+ }, Ce = "X-SFDC-Client-Name", De = "X-SFDC-Client-Version", Pe = "@salesforce/platform-sdk", Ae = "11.56.2", Oe = (t) => {
286
+ let e = b(Ce, Pe, t);
287
+ return e = b(De, Ae, e), u(e);
288
+ }, Te = "X-CSRF-Token";
289
+ function _e(t, e = {}) {
257
290
  const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
258
291
  return async (s) => {
259
- const [a, i] = s, o = a instanceof Request ? a.url : a instanceof URL ? a.href : a, c = i?.method ?? (a instanceof Request ? a.method : void 0) ?? "GET";
260
- if (R(n, o) || Pe(c) && R(r, o)) {
292
+ 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";
293
+ if (k(n, i) || Ne(c) && k(r, i)) {
261
294
  const h = await t.getToken();
262
- s = b(De, h, s);
295
+ s = b(Te, h, s);
263
296
  }
264
297
  return u(s);
265
298
  };
266
299
  }
267
- function Pe(t) {
300
+ function Ne(t) {
268
301
  const e = t.toLowerCase();
269
302
  return e === "post" || e === "put" || e === "patch" || e === "delete";
270
303
  }
271
- function R(t, e) {
304
+ function k(t, e) {
272
305
  const r = new URL(e, globalThis.location?.href ?? "http://localhost");
273
306
  return t.some((n) => r.pathname.includes(n));
274
307
  }
275
- function _e(t, e = {}) {
276
- const r = Ae(t, e);
308
+ function ke(t, e = {}) {
309
+ const r = _e(t, e);
277
310
  async function n(s) {
278
311
  const a = await r(s);
279
312
  return fetch(a[0], a[1]);
280
313
  }
281
314
  return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
282
315
  }
283
- const ke = [400, 401, 403];
284
- class Re extends J {
316
+ const qe = [400, 401, 403];
317
+ class Re extends Y {
285
318
  constructor(e) {
286
319
  super(e), this.csrfTokenManager = e;
287
320
  }
@@ -289,7 +322,7 @@ class Re extends J {
289
322
  * Determines if a failed request should be retried due to CSRF token issues.
290
323
  */
291
324
  async shouldRetry(e, r) {
292
- return r.attempt >= 1 ? !1 : ke.includes(e.status);
325
+ return r.attempt >= 1 ? !1 : qe.includes(e.status);
293
326
  }
294
327
  /**
295
328
  * CSRF token refresh should happen immediately with no delay.
@@ -307,7 +340,7 @@ class Re extends J {
307
340
  await this.csrfTokenManager.refreshToken();
308
341
  }
309
342
  }
310
- class qe {
343
+ class $e {
311
344
  constructor(e, r) {
312
345
  this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
313
346
  }
@@ -356,28 +389,28 @@ class qe {
356
389
  }
357
390
  }
358
391
  const q = /* @__PURE__ */ new Map();
359
- function Oe(t) {
392
+ function Le(t) {
360
393
  const { endpoint: e, cacheName: r, ...n } = t.csrf;
361
394
  let s = q.get(e);
362
- return s || (s = new qe(e, r), q.set(e, s)), $(
395
+ return s || (s = new $e(e, r), q.set(e, s)), L(
363
396
  {
364
- retry: _e(s, n),
365
- request: [Ce, ge]
397
+ retry: ke(s, n),
398
+ request: [Oe, Ee]
366
399
  },
367
- X(new Re(s)).service
400
+ Z(new Re(s)).service
368
401
  ).service;
369
402
  }
370
- const O = /* @__PURE__ */ new Map();
371
- function Te(t) {
372
- let e = O.get(t);
403
+ const R = /* @__PURE__ */ new Map();
404
+ function Me(t) {
405
+ let e = R.get(t);
373
406
  if (!e) {
374
- const r = Y().service, n = ee(r).service, s = Z(r, n).service, a = te().service;
375
- e = { cache: r, cacheController: s, pubSub: a }, O.set(t, e);
407
+ const r = ee().service, n = re(r).service, s = te(r, n).service, a = ne().service;
408
+ e = { cache: r, cacheController: s, pubSub: a }, R.set(t, e);
376
409
  }
377
410
  return e;
378
411
  }
379
- function Ne(t, e) {
380
- const r = Te(t);
412
+ function He(t, e) {
413
+ const r = Me(t);
381
414
  return {
382
415
  shared: r,
383
416
  services: {
@@ -387,8 +420,8 @@ function Ne(t, e) {
387
420
  }
388
421
  };
389
422
  }
390
- const T = 300;
391
- function $e(t, e) {
423
+ const $ = 300;
424
+ function Ie(t, e) {
392
425
  try {
393
426
  return JSON.parse(JSON.stringify(t));
394
427
  } catch (r) {
@@ -398,19 +431,19 @@ function $e(t, e) {
398
431
  throw s.cause = r, s;
399
432
  }
400
433
  }
401
- function Me(t) {
434
+ function Ge(t) {
402
435
  if (typeof t == "object" && t.type === "max-age") {
403
436
  const e = t.maxAge;
404
- return Number.isFinite(e) && e >= 0 ? e : T;
437
+ return Number.isFinite(e) && e >= 0 ? e : $;
405
438
  }
406
- return T;
439
+ return $;
407
440
  }
408
- class Le extends re {
441
+ class Fe extends se {
409
442
  constructor(e, r, n) {
410
- super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = $e(
443
+ super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Ie(
411
444
  e.variables ?? {},
412
445
  this.normalizedOperationName
413
- ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Me(e.cacheControl), this.headers = e.headers, this.headersKey = ce(e.headers);
446
+ ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Ge(e.cacheControl), this.headers = e.headers, this.headersKey = he(e.headers);
414
447
  }
415
448
  query;
416
449
  normalizedVariables;
@@ -424,7 +457,7 @@ class Le extends re {
424
457
  this.url,
425
458
  {
426
459
  method: "POST",
427
- headers: L(this.headers),
460
+ headers: H(this.headers),
428
461
  body: JSON.stringify({
429
462
  query: this.query,
430
463
  variables: this.normalizedVariables,
@@ -439,7 +472,7 @@ class Le extends re {
439
472
  variables: this.normalizedVariables,
440
473
  operationName: this.normalizedOperationName
441
474
  };
442
- return this.headersKey !== void 0 && (e.headers = this.headersKey), Q(e);
475
+ return this.headersKey !== void 0 && (e.headers = this.headersKey), z(e);
443
476
  }
444
477
  /**
445
478
  * Reads from the cache and returns the cache result or error
@@ -456,7 +489,7 @@ class Le extends re {
456
489
  */
457
490
  readFromCache(e) {
458
491
  const r = this.buildKey(), n = e.get(r)?.value;
459
- return n === void 0 ? u(D(new j())) : u(C(n));
492
+ return n === void 0 ? u(P(new W())) : u(D(n));
460
493
  }
461
494
  writeToCache(e, r) {
462
495
  if (r.isOk() && r.value.data != null && Object.keys(r.value.data).length > 0) {
@@ -486,40 +519,40 @@ class Le extends re {
486
519
  return e.errors && e.errors.length > 0;
487
520
  }
488
521
  processFetchReturnValue(e) {
489
- return this.responseHasErrors(e) ? D(new z(e)) : C(e);
522
+ return this.responseHasErrors(e) ? P(new J(e)) : D(e);
490
523
  }
491
524
  }
492
- function K(t) {
493
- if (W(t) && t.data && typeof t.data == "object") {
525
+ function x(t) {
526
+ if (B(t) && t.data && typeof t.data == "object") {
494
527
  const e = t.data;
495
528
  if (e.data != null)
496
529
  return e.data;
497
530
  }
498
531
  }
499
- function He(t) {
532
+ function Qe(t) {
500
533
  return (e) => {
501
534
  if (e.isOk()) {
502
535
  const r = e.value;
503
536
  g(r), t({ data: r, errors: void 0 });
504
537
  } else {
505
- const r = K(e.error);
506
- r && g(r), t({ data: r, errors: f(e.error) });
538
+ const r = x(e.error);
539
+ r && g(r), t({ data: r, errors: p(e.error) });
507
540
  }
508
541
  };
509
542
  }
510
- async function Ie(t) {
543
+ async function xe(t) {
511
544
  let e, r, n;
512
545
  try {
513
546
  const s = await t.execute();
514
- s.isOk() ? (e = s.value.data, g(e), n = (a) => s.value.subscribe(a)) : (e = K(s.error.failure), e && g(e), r = f(s.error.failure), n = (a) => s.error.subscribe(a));
547
+ s.isOk() ? (e = s.value.data, g(e), n = (a) => s.value.subscribe(a)) : (e = x(s.error.failure), e && g(e), r = p(s.error.failure), n = (a) => s.error.subscribe(a));
515
548
  } catch (s) {
516
- r = f(s);
549
+ r = p(s);
517
550
  }
518
551
  return {
519
552
  data: e,
520
553
  errors: r,
521
554
  subscribe(s) {
522
- return n ? n(He(s)) : S;
555
+ return n ? n(Qe(s)) : w;
523
556
  },
524
557
  async refresh() {
525
558
  await t.refresh();
@@ -530,11 +563,11 @@ function E(t) {
530
563
  return {
531
564
  data: void 0,
532
565
  errors: t,
533
- subscribe: () => S,
566
+ subscribe: () => w,
534
567
  refresh: A
535
568
  };
536
569
  }
537
- function Fe({
570
+ function Ke({
538
571
  bundle: t,
539
572
  url: e,
540
573
  executeRaw: r
@@ -542,14 +575,14 @@ function Fe({
542
575
  const { services: n } = t;
543
576
  async function s({
544
577
  query: a,
545
- variables: i,
546
- operationName: o,
578
+ variables: o,
579
+ operationName: i,
547
580
  cacheControl: c,
548
581
  headers: l
549
582
  }) {
550
- const h = _(a);
583
+ const h = T(a);
551
584
  if (h.isErr()) return E(h.error);
552
- const p = h.value, m = k(p, o);
585
+ const f = h.value, m = _(f, i);
553
586
  if (m !== "query")
554
587
  return E([
555
588
  {
@@ -558,47 +591,47 @@ function Fe({
558
591
  ]);
559
592
  let d;
560
593
  try {
561
- d = new Le(
594
+ d = new Fe(
562
595
  {
563
- query: P(p),
564
- variables: i,
565
- operationName: o,
596
+ query: O(f),
597
+ variables: o,
598
+ operationName: i,
566
599
  cacheControl: c,
567
600
  headers: l
568
601
  },
569
602
  n,
570
603
  e
571
604
  );
572
- } catch (v) {
573
- return E(f(v));
605
+ } catch (S) {
606
+ return E(p(S));
574
607
  }
575
- return Ie(d);
608
+ return xe(d);
576
609
  }
577
610
  return {
578
611
  query: s,
579
- mutate: (a) => H(r, a)
612
+ mutate: (a) => G(r, a)
580
613
  };
581
614
  }
582
- const Ke = 1, Ue = `@salesforce/platform-sdk-data_v${Ke}`, U = F(), Ve = `${U}/ui-api`, N = `${U}/graphql`;
583
- class xe {
615
+ const Ue = 1, Ve = `@salesforce/platform-sdk-data_v${Ue}`, K = Q(), je = `${K}/ui-api`, C = `${K}/graphql`;
616
+ class ze {
584
617
  baseUrl;
585
618
  clientFetch;
586
619
  onStatus;
587
620
  graphql;
588
621
  constructor(e) {
589
- const r = Ge();
590
- this.baseUrl = Qe(e?.basePath ?? r.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = Oe({
622
+ const r = We();
623
+ this.baseUrl = Je(e?.basePath ?? r.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = Le({
591
624
  csrf: {
592
- endpoint: `${this.baseUrl}${Ve}/session/csrf`,
593
- cacheName: Ue,
625
+ endpoint: `${this.baseUrl}${je}/session/csrf`,
626
+ cacheName: Ve,
594
627
  protectedUrls: ["services/data/v", "services/apexrest"],
595
628
  alwaysProtectedUrls: ["services/apexrest"]
596
629
  }
597
630
  });
598
- const n = (a, i) => this.fetch(a, i), s = Ne(this.baseUrl, n);
599
- this.graphql = Fe({
631
+ const n = (a, o) => this.fetch(a, o), s = He(this.baseUrl, n);
632
+ this.graphql = Ke({
600
633
  bundle: s,
601
- url: N,
634
+ url: C,
602
635
  executeRaw: this.executeRawGraphQL.bind(this)
603
636
  });
604
637
  }
@@ -607,10 +640,10 @@ class xe {
607
640
  return await this.onStatus[s.status]?.(), s;
608
641
  }
609
642
  /**
610
- * Raw GraphQL POST. Used internally by `graphql.mutate` (which has no
611
- * cache concern) and transitively by `graphql.query` on cache miss
612
- * (the OneStore cache command's fetch service is bound to this same
613
- * SDK's `fetch`, which in turn calls this method's caller patterns).
643
+ * Raw GraphQL POST. On the WebApp surface this is the mutate-only path:
644
+ * `graphql.mutate` calls it directly. The `graphql.query` (cache) path does
645
+ * NOT route through here the OneStore cache command in `@conduit-client`
646
+ * issues its own fetch and parses the response itself.
614
647
  */
615
648
  async executeRawGraphQL({
616
649
  query: e,
@@ -618,11 +651,12 @@ class xe {
618
651
  operationName: n,
619
652
  headers: s
620
653
  }) {
621
- return (await this.fetch(N, {
654
+ const a = await this.fetch(C, {
622
655
  method: "POST",
623
656
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
624
- headers: L(s)
625
- })).json();
657
+ headers: H(s)
658
+ });
659
+ return I(a, "WebApp", C);
626
660
  }
627
661
  /**
628
662
  * If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
@@ -638,17 +672,17 @@ class xe {
638
672
  return e;
639
673
  }
640
674
  }
641
- function Ge() {
675
+ function We() {
642
676
  return {
643
677
  apiPath: globalThis.SFDC_ENV?.apiPath
644
678
  };
645
679
  }
646
- function Qe(t) {
680
+ function Je(t) {
647
681
  if (!t || t === "/") return "";
648
682
  let e = t;
649
683
  return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
650
684
  }
651
- function je(t) {
685
+ function Be(t) {
652
686
  const e = typeof t == "object" && t !== null && "setup" in t, r = e ? t : t.plugin, n = e ? r?.name : t.as;
653
687
  if (typeof r?.setup != "function")
654
688
  throw new Error("Plugin entry cannot attach: it is missing a setup function.");
@@ -658,25 +692,25 @@ function je(t) {
658
692
  );
659
693
  return { plugin: r, mountName: n };
660
694
  }
661
- async function ze(t, e, r = /* @__PURE__ */ new Set()) {
695
+ async function Xe(t, e, r = /* @__PURE__ */ new Set()) {
662
696
  if (e.length === 0)
663
697
  return t;
664
698
  const n = Object.create(t);
665
699
  for (const s of e) {
666
- const { plugin: a, mountName: i } = je(s), o = i === a.name ? `"${a.name}"` : `"${a.name}" (aliased as "${i}")`;
667
- if (r.has(i))
668
- throw new Error(`Plugin ${o} cannot attach: "${i}" is a reserved SDK name.`);
669
- if (i in n)
700
+ const { plugin: a, mountName: o } = Be(s), i = o === a.name ? `"${a.name}"` : `"${a.name}" (aliased as "${o}")`;
701
+ if (r.has(o))
702
+ throw new Error(`Plugin ${i} cannot attach: "${o}" is a reserved SDK name.`);
703
+ if (o in n)
670
704
  throw new Error(
671
- `Plugin ${o} cannot attach: "${i}" is already defined on the SDK.`
705
+ `Plugin ${i} cannot attach: "${o}" is already defined on the SDK.`
672
706
  );
673
707
  let c;
674
708
  try {
675
709
  c = await a.setup(n);
676
710
  } catch (l) {
677
- throw new Error(`Plugin ${o} failed during setup.`, { cause: l });
711
+ throw new Error(`Plugin ${i} failed during setup.`, { cause: l });
678
712
  }
679
- Object.defineProperty(n, i, {
713
+ Object.defineProperty(n, o, {
680
714
  value: c,
681
715
  enumerable: !0,
682
716
  writable: !0,
@@ -685,23 +719,23 @@ async function ze(t, e, r = /* @__PURE__ */ new Set()) {
685
719
  }
686
720
  return n;
687
721
  }
688
- function it(t, ...e) {
722
+ function lt(t, ...e) {
689
723
  let r = t[0] ?? "";
690
724
  for (let n = 0; n < e.length; n += 1)
691
725
  r += String(e[n]) + (t[n + 1] ?? "");
692
726
  return r;
693
727
  }
694
- const ct = G();
695
- async function We(t) {
728
+ const dt = j();
729
+ async function Ye(t) {
696
730
  try {
697
- switch (await V(t?.surface)) {
731
+ switch (await U(t?.surface)) {
698
732
  case y.OpenAI:
699
- return new me();
733
+ return new we();
700
734
  case y.WebApp:
701
735
  case y.MicroFrontend:
702
- return new xe(t?.webapp);
736
+ return new ze(t?.webapp);
703
737
  case y.Mosaic:
704
- return new le(t?.mosaic);
738
+ return new me(t?.mosaic);
705
739
  case y.MCPApps:
706
740
  return {};
707
741
  default:
@@ -711,17 +745,17 @@ async function We(t) {
711
745
  return {};
712
746
  }
713
747
  }
714
- function ut(t) {
715
- return x(
748
+ function pt(t) {
749
+ return V(
716
750
  (async () => {
717
- const e = await We(t);
718
- return ze(e, t?.plugins ?? [], be);
751
+ const e = await Ye(t);
752
+ return Xe(e, t?.plugins ?? [], ve);
719
753
  })(),
720
754
  "createDataSDK"
721
755
  );
722
756
  }
723
757
  export {
724
- ut as createDataSDK,
725
- ct as defineDataPlugin,
726
- it as gql
758
+ pt as createDataSDK,
759
+ dt as defineDataPlugin,
760
+ lt as gql
727
761
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAc3F;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;YAa5B,iBAAiB;CAc/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAe3F;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;YAa5B,iBAAiB;CAe/B"}
@@ -0,0 +1,46 @@
1
+ import { GraphQLResponse } from '../../../core';
2
+ /**
3
+ * Thrown when a GraphQL transport response body cannot be parsed as JSON.
4
+ *
5
+ * The raw `JSON.parse` failure ("Unexpected end of JSON input", "Unexpected
6
+ * token < in JSON at position 0", …) is a bare engine message with no transport
7
+ * context, so a caller who surfaces it — via `toErrors` in `../graphql-parse`,
8
+ * into `result.errors` — has nothing to act on. This error keeps the surface,
9
+ * request URL, HTTP status, and a bounded body snippet on the message (and the
10
+ * original parse failure as `cause`) so the failure is diagnosable from the
11
+ * error text alone.
12
+ */
13
+ export declare class GraphQLTransportError extends Error {
14
+ readonly status: number;
15
+ readonly url: string;
16
+ constructor(args: {
17
+ surface: string;
18
+ url: string;
19
+ status: number;
20
+ body: string;
21
+ cause: unknown;
22
+ });
23
+ }
24
+ /**
25
+ * Parse a raw GraphQL transport {@link Response} into a {@link GraphQLResponse},
26
+ * replacing an unguarded `res.json()`.
27
+ *
28
+ * A non-2xx response can still carry a valid GraphQL error body (`{ errors:
29
+ * [...] }`), so this does NOT gate on `res.ok`: the body is read and parsed
30
+ * regardless of status, and a successfully parsed body is returned as-is. Only
31
+ * when the body is empty, not valid JSON, or valid JSON that is not an object
32
+ * (a bare scalar or `null`) — the cases that otherwise surface as the
33
+ * contextless "Unexpected end of JSON input" downstream, or escape as a
34
+ * `TypeError` when a caller reads `.data`/`.errors` off a non-object — is a
35
+ * {@link GraphQLTransportError} thrown carrying the surface, URL, status, and a
36
+ * body snippet.
37
+ *
38
+ * The body is read once via `res.text()` (rather than `res.json()`) so the raw
39
+ * text is available for the diagnostic snippet on parse failure.
40
+ *
41
+ * @param res the fetch response for a GraphQL POST
42
+ * @param surface human-readable transport surface, e.g. `"WebApp"` / `"Mosaic"`
43
+ * @param url the request URL, for the diagnostic message
44
+ */
45
+ export declare function parseGraphQLResponse<T>(res: Response, surface: string, url: string): Promise<GraphQLResponse<T>>;
46
+ //# sourceMappingURL=parse-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-response.d.ts","sourceRoot":"","sources":["../../../../src/data/shared/graphql/parse-response.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA8BrD;;;;;;;;;;GAUG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,IAAI,EAAE;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,OAAO,CAAC;KACf;CAeD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC3C,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAuB7B"}
@@ -11,10 +11,10 @@ export declare class WebAppDataSDK implements DataSDK {
11
11
  constructor(options?: WebAppDataSDKOptions);
12
12
  fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
13
13
  /**
14
- * Raw GraphQL POST. Used internally by `graphql.mutate` (which has no
15
- * cache concern) and transitively by `graphql.query` on cache miss
16
- * (the OneStore cache command's fetch service is bound to this same
17
- * SDK's `fetch`, which in turn calls this method's caller patterns).
14
+ * Raw GraphQL POST. On the WebApp surface this is the mutate-only path:
15
+ * `graphql.mutate` calls it directly. The `graphql.query` (cache) path does
16
+ * NOT route through here the OneStore cache command in `@conduit-client`
17
+ * issues its own fetch and parses the response itself.
18
18
  */
19
19
  private executeRawGraphQL;
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/webapp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAcrD;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyD;IAClF,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;IA2BpC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUjF;;;;;OAKG;YACW,iBAAiB;IAe/B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAa3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/webapp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAerD;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyD;IAClF,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;IA2BpC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUjF;;;;;OAKG;YACW,iBAAiB;IAe/B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAa3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/platform-sdk",
3
- "version": "11.56.1",
3
+ "version": "11.56.2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -126,7 +126,7 @@
126
126
  "@conduit-client/service-pubsub": "3.19.6",
127
127
  "@conduit-client/service-retry": "3.19.6",
128
128
  "@conduit-client/utils": "3.19.6",
129
- "@salesforce/jsonrpc": "^11.56.1",
129
+ "@salesforce/jsonrpc": "^11.56.2",
130
130
  "@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
131
131
  },
132
132
  "peerDependencies": {