@salesforce/sdk-data 1.95.0 → 1.96.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.
package/dist/index.js CHANGED
@@ -1,41 +1,41 @@
1
- import { getSurface as T, Surface as h } from "@salesforce/sdk-core";
2
- const m = "salesforce_graphql";
3
- class C {
4
- async graphql(e, r) {
5
- return (await window.openai.callTool(m, {
1
+ import { getSurface as R, Surface as h } from "@salesforce/sdk-core";
2
+ const S = "salesforce_graphql";
3
+ class T {
4
+ async graphql(e, t) {
5
+ return (await window.openai.callTool(S, {
6
6
  query: e,
7
- ...r != null ? { variables: r } : {}
7
+ ...t != null ? { variables: t } : {}
8
8
  })).structuredContent;
9
9
  }
10
10
  }
11
- function u(t) {
12
- return S(t) ? t.then((e) => e) : {
13
- then: (e, r) => {
11
+ function u(r) {
12
+ return v(r) ? r.then((e) => e) : {
13
+ then: (e, t) => {
14
14
  try {
15
- return u(e(t));
15
+ return u(e(r));
16
16
  } catch (n) {
17
- return e === void 0 ? u(t) : _(n);
17
+ return e === void 0 ? u(r) : P(n);
18
18
  }
19
19
  }
20
20
  };
21
21
  }
22
- function _(t) {
23
- return S(t) ? t.then((e) => e) : {
24
- then: (e, r) => {
25
- if (typeof r == "function")
22
+ function P(r) {
23
+ return v(r) ? r.then((e) => e) : {
24
+ then: (e, t) => {
25
+ if (typeof t == "function")
26
26
  try {
27
- return u(r(t));
27
+ return u(t(r));
28
28
  } catch (n) {
29
- return _(n);
29
+ return P(n);
30
30
  }
31
- return _(t);
31
+ return P(r);
32
32
  }
33
33
  };
34
34
  }
35
- function S(t) {
36
- return typeof t?.then == "function";
35
+ function v(r) {
36
+ return typeof r?.then == "function";
37
37
  }
38
- function A(t = {
38
+ function I(r = {
39
39
  request: [],
40
40
  retry: void 0,
41
41
  response: [],
@@ -44,19 +44,19 @@ function A(t = {
44
44
  return {
45
45
  type: "fetch",
46
46
  version: "1.0",
47
- service: function(...r) {
47
+ service: function(...t) {
48
48
  var n;
49
- const s = (n = t.createContext) == null ? void 0 : n.call(t), {
49
+ const s = (n = r.createContext) == null ? void 0 : n.call(r), {
50
50
  request: a = [],
51
51
  retry: c = void 0,
52
52
  response: o = [],
53
53
  finally: y = []
54
- } = t, p = a.reduce(
54
+ } = r, p = a.reduce(
55
55
  (i, l) => i.then((w) => l(w, s)),
56
- u(r)
56
+ u(t)
57
57
  );
58
58
  return Promise.resolve(p).then((i) => c ? c(i, e, s) : e ? e.applyRetry(() => fetch(...i)) : fetch(...i)).then((i) => o.reduce(
59
- (l, w) => l.then((v) => w(v, s)),
59
+ (l, w) => l.then((C) => w(C, s)),
60
60
  u(i)
61
61
  )).finally(() => {
62
62
  if (y.length > 0)
@@ -68,47 +68,47 @@ function A(t = {
68
68
  }
69
69
  };
70
70
  }
71
- function E(t, e, [r, n = {}], {
71
+ function b(r, e, [t, n = {}], {
72
72
  throwOnExisting: s = !1,
73
- errorMessage: a = `Unexpected ${t} header encountered`
73
+ errorMessage: a = `Unexpected ${r} header encountered`
74
74
  } = {}) {
75
75
  let c = !1;
76
- if (r instanceof Request && !n?.headers) {
77
- if (s && r.headers.has(t))
76
+ if (t instanceof Request && !n?.headers) {
77
+ if (s && t.headers.has(r))
78
78
  throw new Error(a);
79
- r.headers.set(t, e), c = !0;
79
+ t.headers.set(r, e), c = !0;
80
80
  }
81
81
  if (n?.headers instanceof Headers) {
82
- if (s && n.headers.has(t))
82
+ if (s && n.headers.has(r))
83
83
  throw new Error(a);
84
- n.headers.set(t, e);
84
+ n.headers.set(r, e);
85
85
  } else {
86
- if (s && n?.headers && Reflect.has(n.headers, t))
86
+ if (s && n?.headers && Reflect.has(n.headers, r))
87
87
  throw new Error(a);
88
88
  c || (n.headers = {
89
89
  ...n?.headers,
90
- [t]: e
90
+ [r]: e
91
91
  });
92
92
  }
93
- return [r, n];
93
+ return [t, n];
94
94
  }
95
- class I {
95
+ class A {
96
96
  constructor(e) {
97
97
  this.defaultRetryPolicy = e;
98
98
  }
99
- applyRetry(e, r) {
100
- return this.retry(e, r || this.defaultRetryPolicy);
99
+ applyRetry(e, t) {
100
+ return this.retry(e, t || this.defaultRetryPolicy);
101
101
  }
102
- async retry(e, r) {
102
+ async retry(e, t) {
103
103
  const n = Date.now();
104
104
  let s = 0, a = await e(), c = {
105
105
  attempt: s,
106
106
  totalElapsedMs: Date.now() - n,
107
107
  lastResult: a
108
108
  };
109
- for (; await r.shouldRetry(a, c); ) {
110
- const o = await r.calculateDelay(a, c);
111
- await this.delay(o), r.prepareRetry && await r.prepareRetry(a, c), s++, a = await e(), c = {
109
+ for (; await t.shouldRetry(a, c); ) {
110
+ const o = await t.calculateDelay(a, c);
111
+ await this.delay(o), t.prepareRetry && await t.prepareRetry(a, c), s++, a = await e(), c = {
112
112
  attempt: s,
113
113
  totalElapsedMs: Date.now() - n,
114
114
  lastResult: a
@@ -117,62 +117,62 @@ class I {
117
117
  return a;
118
118
  }
119
119
  delay(e) {
120
- return new Promise((r) => {
121
- setTimeout(r, e);
120
+ return new Promise((t) => {
121
+ setTimeout(t, e);
122
122
  });
123
123
  }
124
124
  }
125
- class b {
125
+ class D {
126
126
  }
127
- function D(t) {
127
+ function E(r) {
128
128
  return {
129
129
  version: "1.0",
130
- service: new I(t),
130
+ service: new A(r),
131
131
  type: "retry"
132
132
  };
133
133
  }
134
- const P = "X-CSRF-Token";
135
- function q(t, e = {}) {
136
- const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
134
+ const _ = "X-CSRF-Token";
135
+ function q(r, e = {}) {
136
+ const { protectedUrls: t = [], alwaysProtectedUrls: n = [] } = e;
137
137
  return async (s) => {
138
138
  const [a, c] = s, o = new Request(a, c);
139
- if (!o.headers.has(P) && (R(n, o.url) || g(o.method) && R(r, o.url))) {
140
- const p = await t.getToken();
141
- s = E(P, p, s);
139
+ if (!o.headers.has(_) && (k(n, o.url) || g(o.method) && k(t, o.url))) {
140
+ const p = await r.getToken();
141
+ s = b(_, p, s);
142
142
  }
143
143
  return u(s);
144
144
  };
145
145
  }
146
- function g(t) {
147
- const e = t.toLowerCase();
146
+ function g(r) {
147
+ const e = r.toLowerCase();
148
148
  return e === "post" || e === "put" || e === "patch" || e === "delete";
149
149
  }
150
- function R(t, e) {
151
- const r = new URL(e);
152
- return t.some((n) => r.pathname.includes(n));
150
+ function k(r, e) {
151
+ const t = new URL(e);
152
+ return r.some((n) => t.pathname.includes(n));
153
153
  }
154
- function F(t, e = {}) {
155
- const r = q(t, e);
154
+ function M(r, e = {}) {
155
+ const t = q(r, e);
156
156
  async function n(s) {
157
- const a = await r(s);
157
+ const a = await t(s);
158
158
  return fetch(a[0], a[1]);
159
159
  }
160
160
  return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
161
161
  }
162
- class H extends b {
162
+ class $ extends D {
163
163
  constructor(e) {
164
164
  super(e), this.csrfTokenManager = e;
165
165
  }
166
166
  /**
167
167
  * Determines if a failed request should be retried due to CSRF token issues.
168
168
  */
169
- async shouldRetry(e, r) {
170
- return r.attempt >= 1 || e.status !== 400 ? !1 : await M(e);
169
+ async shouldRetry(e, t) {
170
+ return t.attempt >= 1 || e.status !== 400 ? !1 : await F(e);
171
171
  }
172
172
  /**
173
173
  * CSRF token refresh should happen immediately with no delay.
174
174
  */
175
- async calculateDelay(e, r) {
175
+ async calculateDelay(e, t) {
176
176
  return 0;
177
177
  }
178
178
  /**
@@ -181,20 +181,20 @@ class H extends b {
181
181
  * @param _result - The failed response that triggered the retry (unused, already validated)
182
182
  * @param _context - Current retry context (unused but part of interface)
183
183
  */
184
- async prepareRetry(e, r) {
184
+ async prepareRetry(e, t) {
185
185
  await this.csrfTokenManager.refreshToken();
186
186
  }
187
187
  }
188
- async function M(t) {
188
+ async function F(r) {
189
189
  try {
190
- return (await t.clone().json())[0]?.errorCode === "INVALID_ACCESS_TOKEN";
190
+ return (await r.clone().json())[0]?.errorCode === "INVALID_ACCESS_TOKEN";
191
191
  } catch {
192
192
  return !1;
193
193
  }
194
194
  }
195
- class O {
196
- constructor(e, r) {
197
- this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
195
+ class N {
196
+ constructor(e, t) {
197
+ this.endpoint = e, this.cacheName = t, this.tokenPromise = this.obtainToken();
198
198
  }
199
199
  tokenPromise;
200
200
  /**
@@ -217,10 +217,10 @@ class O {
217
217
  * @returns Promise that resolves to the CSRF token string
218
218
  */
219
219
  async obtainToken() {
220
- let e = await this.withCache((s) => s.match(this.endpoint)), r = !1;
221
- e || (e = await fetch(this.endpoint, { method: "get" }), r = !0);
220
+ let e = await this.withCache((s) => s.match(this.endpoint)), t = !1;
221
+ e || (e = await fetch(this.endpoint, { method: "get" }), t = !0);
222
222
  const n = (await e.clone().json()).csrfToken;
223
- return r && await this.withCache((s) => s.put(this.endpoint, e)), n;
223
+ return t && await this.withCache((s) => s.put(this.endpoint, e)), n;
224
224
  }
225
225
  /**
226
226
  * Provides a safe way to interact with the Cache API with fallback for unsupported environments.
@@ -230,47 +230,52 @@ class O {
230
230
  */
231
231
  async withCache(e) {
232
232
  if (this.cacheName && caches) {
233
- const r = await caches.open(this.cacheName);
234
- return e(r);
233
+ const t = await caches.open(this.cacheName);
234
+ return e(t);
235
235
  } else
236
236
  return;
237
237
  }
238
238
  }
239
- function $(t) {
240
- const e = t.csrf, r = new O(e.endpoint, e.cacheName);
241
- return A(
242
- { retry: F(r, e) },
243
- D(new H(r)).service
239
+ function O(r) {
240
+ const e = r.csrf, t = new N(e.endpoint, e.cacheName);
241
+ return I(
242
+ { retry: M(t, e) },
243
+ E(new $(t)).service
244
244
  ).service;
245
245
  }
246
- const N = 1, U = `@salesforce/sdk-data_v${N}`, x = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0", L = typeof __SF_SERVER_BASE_PATH__ < "u" ? __SF_SERVER_BASE_PATH__ : "", k = `/services/data/v${x}`, j = `${k}/ui-api`;
247
- class B {
246
+ const H = 1, U = `@salesforce/sdk-data_v${H}`, x = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0", m = `/services/data/v${x}`, L = `${m}/ui-api`, j = (() => {
247
+ const r = globalThis.SFDC_ENV;
248
+ if (!r) return "";
249
+ const e = (t) => (t.startsWith("/") || (t = `/${t}`), t.endsWith("/") && (t = t.slice(0, -1)), t);
250
+ return e(r.basePath) + e(r.apiPath);
251
+ })();
252
+ class K {
248
253
  base;
249
254
  clientFetch;
250
255
  on401;
251
256
  on403;
252
257
  constructor(e) {
253
- this.base = e?.basePath ?? L, this.on401 = e?.on401, this.on403 = e?.on403, this.clientFetch = $({
258
+ this.base = e?.basePath ?? j, this.on401 = e?.on401, this.on403 = e?.on403, this.clientFetch = O({
254
259
  csrf: {
255
- endpoint: `${this.base}${j}/session/csrf`,
260
+ endpoint: `${this.base}${L}/session/csrf`,
256
261
  cacheName: U,
257
262
  protectedUrls: ["/services/data/v", "/services/apexrest"],
258
263
  alwaysProtectedUrls: ["/services/apexrest"]
259
264
  }
260
265
  });
261
266
  }
262
- async graphql(e, r) {
263
- return (await this.fetch(`${k}/graphql`, {
267
+ async graphql(e, t) {
268
+ return (await this.fetch(`${m}/graphql`, {
264
269
  method: "POST",
265
- body: JSON.stringify({ query: e, variables: r }),
270
+ body: JSON.stringify({ query: e, variables: t }),
266
271
  headers: {
267
272
  "Content-Type": "application/json",
268
273
  Accept: "application/json"
269
274
  }
270
275
  })).json();
271
276
  }
272
- async fetch(e, r) {
273
- const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
277
+ async fetch(e, t) {
278
+ const n = this.applySalesforceBase(e), s = await this.clientFetch(n, t);
274
279
  switch (s.status) {
275
280
  case 401:
276
281
  await this.on401?.();
@@ -289,19 +294,19 @@ class B {
289
294
  return typeof e == "string" ? e.startsWith("http") ? e : this.base + e : e;
290
295
  }
291
296
  }
292
- function W(t, ...e) {
293
- let r = t[0] ?? "";
297
+ function V(r, ...e) {
298
+ let t = r[0] ?? "";
294
299
  for (let n = 0; n < e.length; n += 1)
295
- r += String(e[n]) + (t[n + 1] ?? "");
296
- return r;
300
+ t += String(e[n]) + (r[n + 1] ?? "");
301
+ return t;
297
302
  }
298
- async function K(t) {
299
- switch (T(t?.surface)) {
303
+ async function W(r) {
304
+ switch (R(r?.surface)) {
300
305
  case h.OpenAI:
301
- return new C();
306
+ return new T();
302
307
  case h.WebApp:
303
308
  case h.MicroFrontend:
304
- return new B(t?.webapp);
309
+ return new K(r?.webapp);
305
310
  case h.SalesforceACC:
306
311
  return {};
307
312
  case h.MCPApps:
@@ -311,10 +316,10 @@ async function K(t) {
311
316
  }
312
317
  }
313
318
  let f = null, d = null;
314
- async function z(t) {
319
+ async function z(r) {
315
320
  if (f)
316
321
  return f;
317
- d || (d = K(t));
322
+ d || (d = W(r));
318
323
  try {
319
324
  return f = await d, f;
320
325
  } catch (e) {
@@ -322,7 +327,7 @@ async function z(t) {
322
327
  }
323
328
  }
324
329
  export {
325
- K as createDataSDK,
330
+ W as createDataSDK,
326
331
  z as getDataSDK,
327
- W as gql
332
+ V as gql
328
333
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webapp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AASrD,eAAO,MAAM,WAAW,QAA0E,CAAC;AAKnG;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAgC;gBAE3C,OAAO,CAAC,EAAE,oBAAoB;IAepC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAaxE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBjF;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAY3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webapp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAMrD,eAAO,MAAM,WAAW,QAA0E,CAAC;AAenG;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAgC;gBAE3C,OAAO,CAAC,EAAE,oBAAoB;IAepC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAaxE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBjF;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAY3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sdk-data",
3
- "version": "1.95.0",
3
+ "version": "1.96.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@conduit-client/service-fetch-network": "3.17.0",
30
30
  "@conduit-client/utils": "3.17.0",
31
- "@salesforce/sdk-core": "^1.95.0"
31
+ "@salesforce/sdk-core": "^1.96.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "vite": "^7.3.1",