@salesforce/sdk-data 1.103.6 → 1.104.1
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 +3 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -68
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -14,22 +14,15 @@ export interface DataSDKOptions extends SDKOptions {
|
|
|
14
14
|
webapp?: WebAppDataSDKOptions;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Create and initialize a DataSDK instance based on the detected surface
|
|
17
|
+
* Create and initialize a DataSDK instance based on the detected surface.
|
|
18
|
+
* Each call creates a new instance; options are applied to every call.
|
|
18
19
|
*
|
|
19
|
-
* @param options - Optional configuration including surface override
|
|
20
|
+
* @param options - Optional configuration including surface override and webapp options
|
|
20
21
|
* @returns Promise resolving to an initialized DataSDK instance
|
|
21
22
|
*/
|
|
22
23
|
export declare function createDataSDK(options?: DataSDKOptions): Promise<DataSDK>;
|
|
23
24
|
export { gql } from './gql';
|
|
24
25
|
export type { DataSDK, SDKOptions } from '@salesforce/sdk-core';
|
|
25
|
-
/**
|
|
26
|
-
* Get a lazily-initialized DataSDK singleton.
|
|
27
|
-
* Concurrent first calls await the same initialization promise so createDataSDK runs only once.
|
|
28
|
-
*
|
|
29
|
-
* @param options - Optional configuration passed to createDataSDK on first call
|
|
30
|
-
* @returns The shared DataSDK instance
|
|
31
|
-
*/
|
|
32
|
-
export declare function getDataSDK(options?: DataSDKOptions): Promise<DataSDK>;
|
|
33
26
|
export type NodeOfConnection<T> = T extends {
|
|
34
27
|
edges?: (infer E)[] | null;
|
|
35
28
|
} | null ? E extends {
|
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,sB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AG,IAAI,GAClC,CAAC,GACD,KAAK,GACN,KAAK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { getSurface as
|
|
2
|
-
const
|
|
3
|
-
class
|
|
1
|
+
import { getSurface as k, Surface as h } from "@salesforce/sdk-core";
|
|
2
|
+
const R = "salesforce_graphql";
|
|
3
|
+
class C {
|
|
4
4
|
async graphql(e, r) {
|
|
5
|
-
return (await window.openai.callTool(
|
|
5
|
+
return (await window.openai.callTool(R, {
|
|
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 _(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 _(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 _(t) {
|
|
36
36
|
return typeof t?.then == "function";
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function T(t = {
|
|
39
39
|
request: [],
|
|
40
40
|
retry: void 0,
|
|
41
41
|
response: [],
|
|
@@ -50,17 +50,17 @@ function I(t = {
|
|
|
50
50
|
request: a = [],
|
|
51
51
|
retry: c = void 0,
|
|
52
52
|
response: o = [],
|
|
53
|
-
finally:
|
|
54
|
-
} = t,
|
|
55
|
-
(i, l) => i.then((
|
|
53
|
+
finally: f = []
|
|
54
|
+
} = t, d = a.reduce(
|
|
55
|
+
(i, l) => i.then((p) => l(p, s)),
|
|
56
56
|
u(r)
|
|
57
57
|
);
|
|
58
|
-
return Promise.resolve(
|
|
59
|
-
(l,
|
|
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, p) => l.then((v) => p(v, s)),
|
|
60
60
|
u(i)
|
|
61
61
|
)).finally(() => {
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
62
|
+
if (f.length > 0)
|
|
63
|
+
return f.reduce(
|
|
64
64
|
(i, l) => i.then(() => l(s)),
|
|
65
65
|
Promise.resolve()
|
|
66
66
|
);
|
|
@@ -68,7 +68,7 @@ function I(t = {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function S(t, e, [r, n = {}], {
|
|
72
72
|
throwOnExisting: s = !1,
|
|
73
73
|
errorMessage: a = `Unexpected ${t} header encountered`
|
|
74
74
|
} = {}) {
|
|
@@ -92,7 +92,7 @@ function E(t, e, [r, n = {}], {
|
|
|
92
92
|
}
|
|
93
93
|
return [r, n];
|
|
94
94
|
}
|
|
95
|
-
class
|
|
95
|
+
class E {
|
|
96
96
|
constructor(e) {
|
|
97
97
|
this.defaultRetryPolicy = e;
|
|
98
98
|
}
|
|
@@ -122,44 +122,44 @@ class b {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
class
|
|
125
|
+
class I {
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function b(t) {
|
|
128
128
|
return {
|
|
129
129
|
version: "1.0",
|
|
130
|
-
service: new
|
|
130
|
+
service: new E(t),
|
|
131
131
|
type: "retry"
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
function
|
|
134
|
+
const w = "X-CSRF-Token";
|
|
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 (!o.headers.has(
|
|
140
|
-
const
|
|
141
|
-
s =
|
|
139
|
+
if (!o.headers.has(w) && (P(n, o.url) || D(o.method) && P(r, o.url))) {
|
|
140
|
+
const d = await t.getToken();
|
|
141
|
+
s = S(w, d, s);
|
|
142
142
|
}
|
|
143
143
|
return u(s);
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function D(t) {
|
|
147
147
|
const e = t.toLowerCase();
|
|
148
148
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function P(t, e) {
|
|
151
151
|
const r = new URL(e);
|
|
152
152
|
return t.some((n) => r.pathname.includes(n));
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
const r =
|
|
154
|
+
function $(t, e = {}) {
|
|
155
|
+
const r = A(t, e);
|
|
156
156
|
async function n(s) {
|
|
157
157
|
const a = await r(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
|
|
162
|
+
class g extends I {
|
|
163
163
|
constructor(e) {
|
|
164
164
|
super(e), this.csrfTokenManager = e;
|
|
165
165
|
}
|
|
@@ -167,7 +167,7 @@ class U extends D {
|
|
|
167
167
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
168
168
|
*/
|
|
169
169
|
async shouldRetry(e, r) {
|
|
170
|
-
return r.attempt >= 1 || e.status !== 400 ? !1 : await
|
|
170
|
+
return r.attempt >= 1 || e.status !== 400 ? !1 : await q(e);
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* CSRF token refresh should happen immediately with no delay.
|
|
@@ -185,14 +185,14 @@ class U extends D {
|
|
|
185
185
|
await this.csrfTokenManager.refreshToken();
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
async function
|
|
188
|
+
async function q(t) {
|
|
189
189
|
try {
|
|
190
190
|
return (await t.clone().json())[0]?.errorCode === "INVALID_ACCESS_TOKEN";
|
|
191
191
|
} catch {
|
|
192
192
|
return !1;
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
class
|
|
195
|
+
class U {
|
|
196
196
|
constructor(e, r) {
|
|
197
197
|
this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
|
|
198
198
|
}
|
|
@@ -236,32 +236,32 @@ class F {
|
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
const e = t.csrf, r = new
|
|
241
|
-
return
|
|
242
|
-
{ retry:
|
|
243
|
-
|
|
239
|
+
function M(t) {
|
|
240
|
+
const e = t.csrf, r = new U(e.endpoint, e.cacheName);
|
|
241
|
+
return T(
|
|
242
|
+
{ retry: $(r, e) },
|
|
243
|
+
b(new g(r)).service
|
|
244
244
|
).service;
|
|
245
245
|
}
|
|
246
|
-
const
|
|
247
|
-
class
|
|
246
|
+
const F = 1, N = `@salesforce/sdk-data_v${F}`, O = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0", m = `/services/data/v${O}`, H = `${m}/ui-api`;
|
|
247
|
+
class x {
|
|
248
248
|
baseUrl;
|
|
249
249
|
clientFetch;
|
|
250
250
|
on401;
|
|
251
251
|
on403;
|
|
252
252
|
constructor(e) {
|
|
253
|
-
const r =
|
|
254
|
-
this.baseUrl =
|
|
253
|
+
const r = L();
|
|
254
|
+
this.baseUrl = j(e?.basePath ?? r.apiPath), this.on401 = e?.on401, this.on403 = e?.on403, this.clientFetch = M({
|
|
255
255
|
csrf: {
|
|
256
|
-
endpoint: `${this.baseUrl}${
|
|
257
|
-
cacheName:
|
|
256
|
+
endpoint: `${this.baseUrl}${H}/session/csrf`,
|
|
257
|
+
cacheName: N,
|
|
258
258
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
259
259
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
263
|
async graphql(e, r) {
|
|
264
|
-
return (await this.fetch(`${
|
|
264
|
+
return (await this.fetch(`${m}/graphql`, {
|
|
265
265
|
method: "POST",
|
|
266
266
|
body: JSON.stringify({ query: e, variables: r }),
|
|
267
267
|
headers: {
|
|
@@ -296,29 +296,29 @@ class j {
|
|
|
296
296
|
return e;
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function L() {
|
|
300
300
|
return {
|
|
301
301
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function j(t) {
|
|
305
305
|
if (!t || t === "/") return "";
|
|
306
306
|
let e = t;
|
|
307
307
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function K(t, ...e) {
|
|
310
310
|
let r = t[0] ?? "";
|
|
311
311
|
for (let n = 0; n < e.length; n += 1)
|
|
312
312
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
313
313
|
return r;
|
|
314
314
|
}
|
|
315
315
|
async function V(t) {
|
|
316
|
-
switch (
|
|
316
|
+
switch (k(t?.surface)) {
|
|
317
317
|
case h.OpenAI:
|
|
318
|
-
return new
|
|
318
|
+
return new C();
|
|
319
319
|
case h.WebApp:
|
|
320
320
|
case h.MicroFrontend:
|
|
321
|
-
return new
|
|
321
|
+
return new x(t?.webapp);
|
|
322
322
|
case h.SalesforceACC:
|
|
323
323
|
return {};
|
|
324
324
|
case h.MCPApps:
|
|
@@ -327,19 +327,7 @@ async function V(t) {
|
|
|
327
327
|
return {};
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
let f = null, d = null;
|
|
331
|
-
async function J(t) {
|
|
332
|
-
if (f)
|
|
333
|
-
return f;
|
|
334
|
-
d || (d = V(t));
|
|
335
|
-
try {
|
|
336
|
-
return f = await d, f;
|
|
337
|
-
} catch (e) {
|
|
338
|
-
throw d = null, e;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
330
|
export {
|
|
342
331
|
V as createDataSDK,
|
|
343
|
-
|
|
344
|
-
z as gql
|
|
332
|
+
K as gql
|
|
345
333
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-data",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.104.1",
|
|
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.
|
|
31
|
+
"@salesforce/sdk-core": "^1.104.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"vite": "^7.3.1",
|