@salesforce/sdk-data 1.120.1 → 1.120.3
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.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -57
- package/dist/ui-bundle/csrf/retry.policy.d.ts +0 -7
- package/dist/ui-bundle/csrf/retry.policy.d.ts.map +1 -1
- package/dist/ui-bundle/index.d.ts +1 -2
- package/dist/ui-bundle/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DataSDK, SDKOptions } from '@salesforce/sdk-core';
|
|
2
|
+
export type StatusCallback = () => Promise<unknown> | void;
|
|
2
3
|
/**
|
|
3
4
|
* Options for creating a UIBundleDataSDK
|
|
4
5
|
*/
|
|
5
6
|
export interface UIBundleDataSDKOptions {
|
|
6
7
|
basePath?: string;
|
|
7
|
-
|
|
8
|
-
on403?: () => Promise<unknown> | void;
|
|
8
|
+
onStatus?: Partial<Record<number, StatusCallback>>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Options for creating a DataSDK instance.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIhE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIhE,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAe9E;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS;IAC3C,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;CAC3B,GAAG,IAAI,GACL,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,GAClC,CAAC,GACD,KAAK,GACN,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { getSurface as v, Surface as h } from "@salesforce/sdk-core";
|
|
2
|
-
const
|
|
3
|
-
class
|
|
2
|
+
const _ = "graphqlQuery";
|
|
3
|
+
class T {
|
|
4
4
|
async graphql(e, r) {
|
|
5
|
-
return (await window.openai.callTool(
|
|
5
|
+
return (await window.openai.callTool(_, {
|
|
6
6
|
query: e,
|
|
7
7
|
...r != null ? { variables: r } : {}
|
|
8
8
|
})).structuredContent;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
function u(t) {
|
|
12
|
-
return
|
|
12
|
+
return R(t) ? t.then((e) => e) : {
|
|
13
13
|
then: (e, r) => {
|
|
14
14
|
try {
|
|
15
15
|
return u(e(t));
|
|
16
16
|
} catch (n) {
|
|
17
|
-
return e === void 0 ? u(t) :
|
|
17
|
+
return e === void 0 ? u(t) : y(n);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
22
|
+
function y(t) {
|
|
23
|
+
return R(t) ? t.then((e) => e) : {
|
|
24
24
|
then: (e, r) => {
|
|
25
25
|
if (typeof r == "function")
|
|
26
26
|
try {
|
|
27
27
|
return u(r(t));
|
|
28
28
|
} catch (n) {
|
|
29
|
-
return
|
|
29
|
+
return y(n);
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return y(t);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function R(t) {
|
|
36
36
|
return typeof t?.then == "function";
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function k(t = {
|
|
39
39
|
request: [],
|
|
40
40
|
retry: void 0,
|
|
41
41
|
response: [],
|
|
@@ -52,11 +52,11 @@ function T(t = {
|
|
|
52
52
|
response: o = [],
|
|
53
53
|
finally: f = []
|
|
54
54
|
} = t, d = a.reduce(
|
|
55
|
-
(i, l) => i.then((
|
|
55
|
+
(i, l) => i.then((p) => l(p, s)),
|
|
56
56
|
u(r)
|
|
57
57
|
);
|
|
58
58
|
return Promise.resolve(d).then((i) => c ? c(i, e, s) : e ? e.applyRetry(() => fetch(...i)) : fetch(...i)).then((i) => o.reduce(
|
|
59
|
-
(l,
|
|
59
|
+
(l, p) => l.then((S) => p(S, s)),
|
|
60
60
|
u(i)
|
|
61
61
|
)).finally(() => {
|
|
62
62
|
if (f.length > 0)
|
|
@@ -68,7 +68,7 @@ function T(t = {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function C(t, e, [r, n = {}], {
|
|
72
72
|
throwOnExisting: s = !1,
|
|
73
73
|
errorMessage: a = `Unexpected ${t} header encountered`
|
|
74
74
|
} = {}) {
|
|
@@ -124,26 +124,26 @@ class I {
|
|
|
124
124
|
}
|
|
125
125
|
class E {
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function D(t) {
|
|
128
128
|
return {
|
|
129
129
|
version: "1.0",
|
|
130
130
|
service: new I(t),
|
|
131
131
|
type: "retry"
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
const
|
|
134
|
+
const g = "X-CSRF-Token";
|
|
135
135
|
function A(t, e = {}) {
|
|
136
136
|
const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
|
|
137
137
|
return async (s) => {
|
|
138
138
|
const [a, c] = s, o = new Request(a, c);
|
|
139
|
-
if (w(n, o.url) ||
|
|
139
|
+
if (w(n, o.url) || U(o.method) && w(r, o.url)) {
|
|
140
140
|
const d = await t.getToken();
|
|
141
|
-
s =
|
|
141
|
+
s = C(g, d, s);
|
|
142
142
|
}
|
|
143
143
|
return u(s);
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function U(t) {
|
|
147
147
|
const e = t.toLowerCase();
|
|
148
148
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
149
149
|
}
|
|
@@ -151,7 +151,7 @@ function w(t, e) {
|
|
|
151
151
|
const r = new URL(e);
|
|
152
152
|
return t.some((n) => r.pathname.includes(n));
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function b(t, e = {}) {
|
|
155
155
|
const r = A(t, e);
|
|
156
156
|
async function n(s) {
|
|
157
157
|
const a = await r(s);
|
|
@@ -159,7 +159,8 @@ function U(t, e = {}) {
|
|
|
159
159
|
}
|
|
160
160
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
const $ = [400, 401, 403];
|
|
163
|
+
class q extends E {
|
|
163
164
|
constructor(e) {
|
|
164
165
|
super(e), this.csrfTokenManager = e;
|
|
165
166
|
}
|
|
@@ -167,7 +168,7 @@ class $ extends E {
|
|
|
167
168
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
168
169
|
*/
|
|
169
170
|
async shouldRetry(e, r) {
|
|
170
|
-
return r.attempt >= 1
|
|
171
|
+
return r.attempt >= 1 ? !1 : $.includes(e.status);
|
|
171
172
|
}
|
|
172
173
|
/**
|
|
173
174
|
* CSRF token refresh should happen immediately with no delay.
|
|
@@ -185,13 +186,6 @@ class $ extends E {
|
|
|
185
186
|
await this.csrfTokenManager.refreshToken();
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
|
-
async function q(t) {
|
|
189
|
-
try {
|
|
190
|
-
return (await t.clone().json())[0]?.errorCode === "INVALID_ACCESS_TOKEN";
|
|
191
|
-
} catch {
|
|
192
|
-
return !1;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
189
|
class M {
|
|
196
190
|
constructor(e, r) {
|
|
197
191
|
this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
|
|
@@ -240,22 +234,21 @@ const P = /* @__PURE__ */ new Map();
|
|
|
240
234
|
function F(t) {
|
|
241
235
|
const { endpoint: e, cacheName: r, ...n } = t.csrf;
|
|
242
236
|
let s = P.get(e);
|
|
243
|
-
return s || (s = new M(e, r), P.set(e, s)),
|
|
244
|
-
{ retry:
|
|
245
|
-
|
|
237
|
+
return s || (s = new M(e, r), P.set(e, s)), k(
|
|
238
|
+
{ retry: b(s, n) },
|
|
239
|
+
D(new q(s)).service
|
|
246
240
|
).service;
|
|
247
241
|
}
|
|
248
|
-
const
|
|
249
|
-
class
|
|
242
|
+
const H = 1, O = `@salesforce/sdk-data_v${H}`, x = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0", m = `/services/data/v${x}`, N = `${m}/ui-api`;
|
|
243
|
+
class B {
|
|
250
244
|
baseUrl;
|
|
251
245
|
clientFetch;
|
|
252
|
-
|
|
253
|
-
on403;
|
|
246
|
+
onStatus;
|
|
254
247
|
constructor(e) {
|
|
255
|
-
const r =
|
|
256
|
-
this.baseUrl =
|
|
248
|
+
const r = L();
|
|
249
|
+
this.baseUrl = j(e?.basePath ?? r.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = F({
|
|
257
250
|
csrf: {
|
|
258
|
-
endpoint: `${this.baseUrl}${
|
|
251
|
+
endpoint: `${this.baseUrl}${N}/session/csrf`,
|
|
259
252
|
cacheName: O,
|
|
260
253
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
261
254
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
@@ -263,7 +256,7 @@ class L {
|
|
|
263
256
|
});
|
|
264
257
|
}
|
|
265
258
|
async graphql(e, r) {
|
|
266
|
-
return (await this.fetch(`${
|
|
259
|
+
return (await this.fetch(`${m}/graphql`, {
|
|
267
260
|
method: "POST",
|
|
268
261
|
body: JSON.stringify({ query: e, variables: r }),
|
|
269
262
|
headers: {
|
|
@@ -274,15 +267,7 @@ class L {
|
|
|
274
267
|
}
|
|
275
268
|
async fetch(e, r) {
|
|
276
269
|
const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
|
|
277
|
-
|
|
278
|
-
case 401:
|
|
279
|
-
await this.on401?.();
|
|
280
|
-
break;
|
|
281
|
-
case 403:
|
|
282
|
-
await this.on403?.();
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
return s;
|
|
270
|
+
return await this.onStatus[s.status]?.(), s;
|
|
286
271
|
}
|
|
287
272
|
/**
|
|
288
273
|
* If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
|
|
@@ -298,29 +283,29 @@ class L {
|
|
|
298
283
|
return e;
|
|
299
284
|
}
|
|
300
285
|
}
|
|
301
|
-
function
|
|
286
|
+
function L() {
|
|
302
287
|
return {
|
|
303
288
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
304
289
|
};
|
|
305
290
|
}
|
|
306
|
-
function
|
|
291
|
+
function j(t) {
|
|
307
292
|
if (!t || t === "/") return "";
|
|
308
293
|
let e = t;
|
|
309
294
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
310
295
|
}
|
|
311
|
-
function
|
|
296
|
+
function K(t, ...e) {
|
|
312
297
|
let r = t[0] ?? "";
|
|
313
298
|
for (let n = 0; n < e.length; n += 1)
|
|
314
299
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
315
300
|
return r;
|
|
316
301
|
}
|
|
317
|
-
async function
|
|
302
|
+
async function V(t) {
|
|
318
303
|
switch (v(t?.surface)) {
|
|
319
304
|
case h.OpenAI:
|
|
320
|
-
return new
|
|
305
|
+
return new T();
|
|
321
306
|
case h.UIBundle:
|
|
322
307
|
case h.MicroFrontend:
|
|
323
|
-
return new
|
|
308
|
+
return new B(t?.uiBundle);
|
|
324
309
|
case h.SalesforceACC:
|
|
325
310
|
return {};
|
|
326
311
|
case h.MCPApps:
|
|
@@ -330,6 +315,6 @@ async function W(t) {
|
|
|
330
315
|
}
|
|
331
316
|
}
|
|
332
317
|
export {
|
|
333
|
-
|
|
334
|
-
|
|
318
|
+
V as createDataSDK,
|
|
319
|
+
K as gql
|
|
335
320
|
};
|
|
@@ -28,11 +28,4 @@ export declare class CsrfTokenRetryPolicy extends RetryPolicy<Response> {
|
|
|
28
28
|
*/
|
|
29
29
|
prepareRetry(_result: Response, _context: RetryContext<Response>): Promise<void>;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Helper to check if a response indicates a CSRF token error.
|
|
33
|
-
*
|
|
34
|
-
* @param response - The response to check
|
|
35
|
-
* @returns true if the response indicates a CSRF token error (INVALID_ACCESS_TOKEN)
|
|
36
|
-
*/
|
|
37
|
-
export declare function isCsrfError(response: Response): Promise<boolean>;
|
|
38
31
|
//# sourceMappingURL=retry.policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.policy.d.ts","sourceRoot":"","sources":["../../../src/ui-bundle/csrf/retry.policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"retry.policy.d.ts","sourceRoot":"","sources":["../../../src/ui-bundle/csrf/retry.policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,WAAW,CAAC,QAAQ,CAAC;IAClD,OAAO,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,gBAAgB;IAKtD;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAUtF;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1F;;;;;OAKG;IACY,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/F"}
|
|
@@ -7,8 +7,7 @@ export declare const API_VERSION: string;
|
|
|
7
7
|
export declare class UIBundleDataSDK implements DataSDK {
|
|
8
8
|
private readonly baseUrl;
|
|
9
9
|
private readonly clientFetch;
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly on403?;
|
|
10
|
+
private readonly onStatus;
|
|
12
11
|
constructor(options?: UIBundleDataSDKOptions);
|
|
13
12
|
graphql<T, V>(query: string, variables?: V): Promise<GraphQLResponse<T>>;
|
|
14
13
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui-bundle/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMvD,eAAO,MAAM,WAAW,QAA0E,CAAC;AAInG;;GAEG;AACH,qBAAa,eAAgB,YAAW,OAAO;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui-bundle/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAMvD,eAAO,MAAM,WAAW,QAA0E,CAAC;AAInG;;GAEG;AACH,qBAAa,eAAgB,YAAW,OAAO;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyD;gBAEtE,OAAO,CAAC,EAAE,sBAAsB;IAiBtC,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;IAUjF;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAa3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-data",
|
|
3
|
-
"version": "1.120.
|
|
3
|
+
"version": "1.120.3",
|
|
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.120.
|
|
31
|
+
"@salesforce/sdk-core": "^1.120.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"vite": "^7.3.1",
|