@salesforce/platform-sdk 11.8.4 → 11.10.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/README.md +1 -0
- package/dist/core/data.d.ts +29 -0
- package/dist/core/data.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +300 -258
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/dist/data/openai/index.d.ts +5 -0
- package/dist/data/openai/index.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/command.d.ts +12 -1
- package/dist/data/shared/graphql/cache/command.d.ts.map +1 -1
- package/dist/data/shared/graphql/cached-graphql.d.ts.map +1 -1
- package/dist/data/shared/graphql/graphql-parse.d.ts +1 -1
- package/dist/data/shared/graphql/graphql-parse.d.ts.map +1 -1
- package/dist/data/shared/graphql/headers.d.ts +39 -5
- package/dist/data/shared/graphql/headers.d.ts.map +1 -1
- package/dist/data/shared/graphql/uncached-graphql.d.ts.map +1 -1
- package/dist/data/webapp/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/tool-adapter.d.ts +1 -0
- package/dist/telemetry/tool-adapter.d.ts.map +1 -1
- package/dist/{transport-CdXFRgRc.js → transport-D9QstWle.js} +36 -23
- package/package.json +2 -2
package/dist/data/index.js
CHANGED
|
@@ -1,61 +1,94 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
3
|
-
import { buildServiceDescriptor as
|
|
4
|
-
import { resolvedPromiseLike as u, ok as
|
|
5
|
-
import { print as
|
|
6
|
-
import { RetryPolicy as
|
|
7
|
-
import { buildServiceDescriptor as
|
|
8
|
-
import { buildServiceDescriptor as
|
|
9
|
-
import { buildInMemoryCacheInclusionPolicyService as
|
|
10
|
-
import { buildServiceDescriptor as
|
|
11
|
-
import { HttpCacheControlCommand as
|
|
12
|
-
function
|
|
1
|
+
import { g as x, S as y } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { w as K } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { buildServiceDescriptor as R, setHeader as b } from "@conduit-client/service-fetch-network/v1";
|
|
4
|
+
import { resolvedPromiseLike as u, ok as C, err as E, stableJSONStringify as V, DataNotFoundError as Q, UserVisibleError as G, deepFreeze as v, isUserVisibleError as z } from "@conduit-client/utils";
|
|
5
|
+
import { print as A, parse as j } from "@conduit-client/onestore-graphql-parser/v1";
|
|
6
|
+
import { RetryPolicy as W, buildServiceDescriptor as B } from "@conduit-client/service-retry/v1";
|
|
7
|
+
import { buildServiceDescriptor as J } from "@conduit-client/service-cache/v1";
|
|
8
|
+
import { buildServiceDescriptor as X } from "@conduit-client/service-cache-control/v1";
|
|
9
|
+
import { buildInMemoryCacheInclusionPolicyService as Y } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
10
|
+
import { buildServiceDescriptor as Z } from "@conduit-client/service-pubsub/v1";
|
|
11
|
+
import { HttpCacheControlCommand as ee } from "@conduit-client/command-http-cache-control/v1";
|
|
12
|
+
function re(r) {
|
|
13
13
|
return (e) => {
|
|
14
|
-
const [
|
|
15
|
-
if (typeof
|
|
16
|
-
const s =
|
|
17
|
-
return u([`${
|
|
14
|
+
const [t, n] = e;
|
|
15
|
+
if (typeof t == "string" && !t.startsWith("http")) {
|
|
16
|
+
const s = t.startsWith("/") ? t : `/${t}`;
|
|
17
|
+
return u([`${r}${s}`, n]);
|
|
18
18
|
}
|
|
19
19
|
return u(e);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return (e) => u(
|
|
22
|
+
function te(r) {
|
|
23
|
+
return (e) => u(b("Authorization", `Bearer ${r}`, e));
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
request:
|
|
25
|
+
function ne(r, e) {
|
|
26
|
+
const t = [];
|
|
27
|
+
return r && t.push(re(r)), e && t.push(te(e)), R({
|
|
28
|
+
request: t
|
|
29
29
|
}).service;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const se = {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
"X-Chatter-Entity-Encoding": "false"
|
|
33
35
|
};
|
|
34
|
-
function
|
|
36
|
+
function ae(r) {
|
|
37
|
+
if (r instanceof Headers) {
|
|
38
|
+
const e = [];
|
|
39
|
+
return r.forEach((t, n) => e.push([n, t])), e;
|
|
40
|
+
}
|
|
41
|
+
return Array.isArray(r) ? r.map(([e, t]) => [e, t]) : Object.entries(r);
|
|
42
|
+
}
|
|
43
|
+
function M(r, e) {
|
|
44
|
+
if (e === void 0) return { ...r };
|
|
45
|
+
const t = { ...r }, n = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const a of Object.keys(t)) n.set(a.toLowerCase(), a);
|
|
47
|
+
const s = /* @__PURE__ */ new Set();
|
|
48
|
+
for (const [a, i] of ae(e)) {
|
|
49
|
+
const o = a.toLowerCase(), c = n.get(o);
|
|
50
|
+
c === void 0 ? (t[a] = i, n.set(o, a), s.add(o)) : s.has(o) ? t[c] = `${t[c]}, ${i}` : (t[c] = i, s.add(o));
|
|
51
|
+
}
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
function I(r) {
|
|
55
|
+
return M(se, r);
|
|
56
|
+
}
|
|
57
|
+
function oe(r) {
|
|
58
|
+
if (r === void 0) return;
|
|
59
|
+
const e = {};
|
|
60
|
+
return new Headers(r).forEach((t, n) => {
|
|
61
|
+
e[n] = t;
|
|
62
|
+
}), Object.keys(e).length > 0 ? e : void 0;
|
|
63
|
+
}
|
|
64
|
+
const S = () => {
|
|
65
|
+
}, D = async () => {
|
|
66
|
+
};
|
|
67
|
+
function k(r) {
|
|
35
68
|
try {
|
|
36
|
-
return
|
|
69
|
+
return C(j(r));
|
|
37
70
|
} catch (e) {
|
|
38
|
-
return
|
|
71
|
+
return E(d(e));
|
|
39
72
|
}
|
|
40
73
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
74
|
+
function q(r, e) {
|
|
75
|
+
const t = r.definitions.filter(
|
|
43
76
|
(n) => n.kind === "OperationDefinition"
|
|
44
77
|
);
|
|
45
|
-
return
|
|
78
|
+
return t.length === 0 ? "unknown" : t.length === 1 ? e === void 0 || t[0].name?.value === e ? t[0].operation : "unknown" : e === void 0 ? "unknown" : t.find((n) => n.name?.value === e)?.operation ?? "unknown";
|
|
46
79
|
}
|
|
47
|
-
function
|
|
48
|
-
if (
|
|
49
|
-
const e =
|
|
80
|
+
function d(r) {
|
|
81
|
+
if (r && typeof r == "object" && "data" in r) {
|
|
82
|
+
const e = r.data;
|
|
50
83
|
if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
|
|
51
84
|
return e.errors;
|
|
52
85
|
}
|
|
53
|
-
return
|
|
86
|
+
return r instanceof Error ? [{ message: r.message }] : typeof r == "string" ? [{ message: r }] : [{ message: "Unknown error" }];
|
|
54
87
|
}
|
|
55
|
-
async function
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
88
|
+
async function L(r, { mutation: e, variables: t, operationName: n, headers: s }) {
|
|
89
|
+
const a = k(e);
|
|
90
|
+
if (a.isErr()) return { data: void 0, errors: a.error };
|
|
91
|
+
const i = a.value, o = q(i, n);
|
|
59
92
|
if (o !== "mutation")
|
|
60
93
|
return {
|
|
61
94
|
data: void 0,
|
|
@@ -66,182 +99,192 @@ async function R(t, { mutation: e, variables: r, operationName: n }) {
|
|
|
66
99
|
]
|
|
67
100
|
};
|
|
68
101
|
try {
|
|
69
|
-
const
|
|
70
|
-
query:
|
|
71
|
-
variables:
|
|
72
|
-
operationName: n
|
|
102
|
+
const c = await r({
|
|
103
|
+
query: A(i),
|
|
104
|
+
variables: t,
|
|
105
|
+
operationName: n,
|
|
106
|
+
headers: s
|
|
73
107
|
});
|
|
74
108
|
return {
|
|
75
|
-
data:
|
|
76
|
-
errors:
|
|
109
|
+
data: c.data ?? void 0,
|
|
110
|
+
errors: c.errors
|
|
77
111
|
};
|
|
78
|
-
} catch (
|
|
79
|
-
return { data: void 0, errors:
|
|
112
|
+
} catch (c) {
|
|
113
|
+
return { data: void 0, errors: d(c) };
|
|
80
114
|
}
|
|
81
115
|
}
|
|
82
|
-
function
|
|
83
|
-
function e(n, s, a) {
|
|
84
|
-
return
|
|
85
|
-
query:
|
|
116
|
+
function $(r) {
|
|
117
|
+
function e(n, s, a, i) {
|
|
118
|
+
return r({
|
|
119
|
+
query: A(n),
|
|
86
120
|
variables: s,
|
|
87
|
-
operationName: a
|
|
121
|
+
operationName: a,
|
|
122
|
+
headers: i
|
|
88
123
|
}).then(
|
|
89
124
|
(o) => ({
|
|
90
125
|
data: o.data ?? void 0,
|
|
91
126
|
errors: o.errors
|
|
92
127
|
}),
|
|
93
|
-
(o) => ({ data: void 0, errors:
|
|
128
|
+
(o) => ({ data: void 0, errors: d(o) })
|
|
94
129
|
);
|
|
95
130
|
}
|
|
96
|
-
async function
|
|
131
|
+
async function t({
|
|
97
132
|
query: n,
|
|
98
133
|
variables: s,
|
|
99
|
-
operationName: a
|
|
134
|
+
operationName: a,
|
|
135
|
+
headers: i
|
|
100
136
|
}) {
|
|
101
|
-
const o =
|
|
137
|
+
const o = k(n);
|
|
102
138
|
if (o.isErr())
|
|
103
139
|
return {
|
|
104
140
|
data: void 0,
|
|
105
141
|
errors: o.error,
|
|
106
|
-
subscribe: () =>
|
|
107
|
-
refresh:
|
|
142
|
+
subscribe: () => S,
|
|
143
|
+
refresh: D
|
|
108
144
|
};
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
145
|
+
const c = o.value, f = q(c, a);
|
|
146
|
+
if (f !== "query")
|
|
111
147
|
return {
|
|
112
148
|
data: void 0,
|
|
113
149
|
errors: [
|
|
114
150
|
{
|
|
115
|
-
message: `DataSDK.graphql.query() requires a GraphQL query, received ${
|
|
151
|
+
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
116
152
|
}
|
|
117
153
|
],
|
|
118
|
-
subscribe: () =>
|
|
119
|
-
refresh:
|
|
154
|
+
subscribe: () => S,
|
|
155
|
+
refresh: D
|
|
120
156
|
};
|
|
121
|
-
const
|
|
157
|
+
const h = /* @__PURE__ */ new Set(), p = s, m = await e(c, p, a, i);
|
|
122
158
|
return {
|
|
123
|
-
data:
|
|
124
|
-
errors:
|
|
125
|
-
subscribe(
|
|
126
|
-
return
|
|
127
|
-
|
|
159
|
+
data: m.data,
|
|
160
|
+
errors: m.errors,
|
|
161
|
+
subscribe(l) {
|
|
162
|
+
return h.add(l), () => {
|
|
163
|
+
h.delete(l);
|
|
128
164
|
};
|
|
129
165
|
},
|
|
130
166
|
async refresh() {
|
|
131
|
-
const
|
|
132
|
-
for (const
|
|
167
|
+
const l = await e(c, p, a, i);
|
|
168
|
+
for (const w of h) w(l);
|
|
133
169
|
}
|
|
134
170
|
};
|
|
135
171
|
}
|
|
136
172
|
return {
|
|
137
|
-
query:
|
|
138
|
-
mutate: (n) =>
|
|
173
|
+
query: t,
|
|
174
|
+
mutate: (n) => L(r, n)
|
|
139
175
|
};
|
|
140
176
|
}
|
|
141
|
-
const
|
|
142
|
-
function
|
|
143
|
-
return `/services/data/v${
|
|
177
|
+
const ie = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
178
|
+
function H(r = ie) {
|
|
179
|
+
return `/services/data/v${r}`;
|
|
144
180
|
}
|
|
145
|
-
|
|
181
|
+
const ce = {
|
|
182
|
+
"Content-Type": "application/json",
|
|
183
|
+
Accept: "application/json"
|
|
184
|
+
};
|
|
185
|
+
class ue {
|
|
146
186
|
clientFetch;
|
|
147
187
|
pathData;
|
|
148
188
|
graphql;
|
|
149
189
|
constructor(e) {
|
|
150
|
-
const
|
|
151
|
-
this.pathData =
|
|
190
|
+
const t = he(), n = le(e?.instanceUrl ?? t.instanceUrl), s = e?.accessToken ?? t.accessToken;
|
|
191
|
+
this.pathData = H(e?.apiVersion ?? t.apiVersion), this.clientFetch = ne(n || void 0, s), this.graphql = $(this.executeRawGraphQL.bind(this));
|
|
152
192
|
}
|
|
153
193
|
async executeRawGraphQL({
|
|
154
194
|
query: e,
|
|
155
|
-
variables:
|
|
156
|
-
operationName: n
|
|
195
|
+
variables: t,
|
|
196
|
+
operationName: n,
|
|
197
|
+
headers: s
|
|
157
198
|
}) {
|
|
158
199
|
return (await this.clientFetch(`${this.pathData}/graphql`, {
|
|
159
200
|
method: "POST",
|
|
160
|
-
body: JSON.stringify({ query: e, variables:
|
|
161
|
-
headers:
|
|
162
|
-
"Content-Type": "application/json",
|
|
163
|
-
Accept: "application/json"
|
|
164
|
-
}
|
|
201
|
+
body: JSON.stringify({ query: e, variables: t, operationName: n }),
|
|
202
|
+
headers: M(ce, s)
|
|
165
203
|
})).json();
|
|
166
204
|
}
|
|
167
205
|
}
|
|
168
|
-
function
|
|
169
|
-
const
|
|
206
|
+
function he() {
|
|
207
|
+
const r = globalThis.MOSAIC_ENV;
|
|
170
208
|
return {
|
|
171
|
-
instanceUrl:
|
|
172
|
-
accessToken:
|
|
173
|
-
apiVersion:
|
|
209
|
+
instanceUrl: r?.instanceUrl,
|
|
210
|
+
accessToken: r?.accessToken,
|
|
211
|
+
apiVersion: r?.apiVersion
|
|
174
212
|
};
|
|
175
213
|
}
|
|
176
|
-
function
|
|
177
|
-
if (!
|
|
178
|
-
let e =
|
|
214
|
+
function le(r) {
|
|
215
|
+
if (!r || r === "/") return "";
|
|
216
|
+
let e = r;
|
|
179
217
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
180
218
|
}
|
|
181
|
-
const
|
|
182
|
-
class
|
|
219
|
+
const de = "graphqlQuery";
|
|
220
|
+
class fe {
|
|
183
221
|
graphql;
|
|
184
222
|
constructor() {
|
|
185
|
-
this.graphql =
|
|
223
|
+
this.graphql = $(this.executeRawGraphQL.bind(this));
|
|
186
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* The `headers` request option is intentionally not forwarded: this surface
|
|
227
|
+
* delegates to the `graphqlQuery` MCP tool over the ChatGPT bridge, which
|
|
228
|
+
* issues the HTTP request host-side and exposes no header channel.
|
|
229
|
+
*/
|
|
187
230
|
async executeRawGraphQL({
|
|
188
231
|
query: e,
|
|
189
|
-
variables:
|
|
232
|
+
variables: t,
|
|
190
233
|
operationName: n
|
|
191
234
|
}) {
|
|
192
|
-
return (await window.openai.callTool(
|
|
235
|
+
return (await window.openai.callTool(de, {
|
|
193
236
|
query: e,
|
|
194
|
-
...
|
|
237
|
+
...t != null ? { variables: t } : {},
|
|
195
238
|
...n != null ? { operationName: n } : {}
|
|
196
239
|
})).structuredContent;
|
|
197
240
|
}
|
|
198
241
|
}
|
|
199
|
-
const
|
|
200
|
-
let e =
|
|
201
|
-
return e =
|
|
202
|
-
},
|
|
203
|
-
function
|
|
204
|
-
const { protectedUrls:
|
|
242
|
+
const pe = "X-SFDC-Client-Name", me = "X-SFDC-Client-Version", ye = "@salesforce/platform-sdk", be = "11.10.0", ve = (r) => {
|
|
243
|
+
let e = b(pe, ye, r);
|
|
244
|
+
return e = b(me, be, e), u(e);
|
|
245
|
+
}, Se = "X-CSRF-Token";
|
|
246
|
+
function we(r, e = {}) {
|
|
247
|
+
const { protectedUrls: t = [], alwaysProtectedUrls: n = [] } = e;
|
|
205
248
|
return async (s) => {
|
|
206
|
-
const [a,
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
s =
|
|
249
|
+
const [a, i] = s, o = new Request(a, i);
|
|
250
|
+
if (O(n, o.url) || ge(o.method) && O(t, o.url)) {
|
|
251
|
+
const f = await r.getToken();
|
|
252
|
+
s = b(Se, f, s);
|
|
210
253
|
}
|
|
211
254
|
return u(s);
|
|
212
255
|
};
|
|
213
256
|
}
|
|
214
|
-
function
|
|
215
|
-
const e =
|
|
257
|
+
function ge(r) {
|
|
258
|
+
const e = r.toLowerCase();
|
|
216
259
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
217
260
|
}
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
-
return
|
|
261
|
+
function O(r, e) {
|
|
262
|
+
const t = new URL(e);
|
|
263
|
+
return r.some((n) => t.pathname.includes(n));
|
|
221
264
|
}
|
|
222
|
-
function
|
|
223
|
-
const
|
|
265
|
+
function Ce(r, e = {}) {
|
|
266
|
+
const t = we(r, e);
|
|
224
267
|
async function n(s) {
|
|
225
|
-
const a = await
|
|
268
|
+
const a = await t(s);
|
|
226
269
|
return fetch(a[0], a[1]);
|
|
227
270
|
}
|
|
228
271
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
229
272
|
}
|
|
230
|
-
const
|
|
231
|
-
class
|
|
273
|
+
const Ee = [400, 401, 403];
|
|
274
|
+
class De extends W {
|
|
232
275
|
constructor(e) {
|
|
233
276
|
super(e), this.csrfTokenManager = e;
|
|
234
277
|
}
|
|
235
278
|
/**
|
|
236
279
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
237
280
|
*/
|
|
238
|
-
async shouldRetry(e,
|
|
239
|
-
return
|
|
281
|
+
async shouldRetry(e, t) {
|
|
282
|
+
return t.attempt >= 1 ? !1 : Ee.includes(e.status);
|
|
240
283
|
}
|
|
241
284
|
/**
|
|
242
285
|
* CSRF token refresh should happen immediately with no delay.
|
|
243
286
|
*/
|
|
244
|
-
async calculateDelay(e,
|
|
287
|
+
async calculateDelay(e, t) {
|
|
245
288
|
return 0;
|
|
246
289
|
}
|
|
247
290
|
/**
|
|
@@ -250,13 +293,13 @@ class ve extends z {
|
|
|
250
293
|
* @param _result - The failed response that triggered the retry (unused, already validated)
|
|
251
294
|
* @param _context - Current retry context (unused but part of interface)
|
|
252
295
|
*/
|
|
253
|
-
async prepareRetry(e,
|
|
296
|
+
async prepareRetry(e, t) {
|
|
254
297
|
await this.csrfTokenManager.refreshToken();
|
|
255
298
|
}
|
|
256
299
|
}
|
|
257
|
-
class
|
|
258
|
-
constructor(e,
|
|
259
|
-
this.endpoint = e, this.cacheName =
|
|
300
|
+
class Ae {
|
|
301
|
+
constructor(e, t) {
|
|
302
|
+
this.endpoint = e, this.cacheName = t, this.tokenPromise = this.obtainToken();
|
|
260
303
|
}
|
|
261
304
|
tokenPromise;
|
|
262
305
|
refreshPromise;
|
|
@@ -283,10 +326,10 @@ class Se {
|
|
|
283
326
|
* @returns Promise that resolves to the CSRF token string
|
|
284
327
|
*/
|
|
285
328
|
async obtainToken() {
|
|
286
|
-
let e = await this.withCache((s) => s.match(this.endpoint)),
|
|
287
|
-
e || (e = await fetch(this.endpoint, { method: "get" }),
|
|
329
|
+
let e = await this.withCache((s) => s.match(this.endpoint)), t = !1;
|
|
330
|
+
e || (e = await fetch(this.endpoint, { method: "get" }), t = !0);
|
|
288
331
|
const n = (await e.clone().json()).csrfToken;
|
|
289
|
-
return
|
|
332
|
+
return t && await this.withCache((s) => s.put(this.endpoint, e)), n;
|
|
290
333
|
}
|
|
291
334
|
/**
|
|
292
335
|
* Provides a safe way to interact with the Cache API with fallback for unsupported environments.
|
|
@@ -296,87 +339,82 @@ class Se {
|
|
|
296
339
|
*/
|
|
297
340
|
async withCache(e) {
|
|
298
341
|
if (this.cacheName && caches) {
|
|
299
|
-
const
|
|
300
|
-
return e(
|
|
342
|
+
const t = await caches.open(this.cacheName);
|
|
343
|
+
return e(t);
|
|
301
344
|
} else
|
|
302
345
|
return;
|
|
303
346
|
}
|
|
304
347
|
}
|
|
305
|
-
const
|
|
306
|
-
function
|
|
307
|
-
const { endpoint: e, cacheName:
|
|
308
|
-
let s =
|
|
309
|
-
return s || (s = new
|
|
348
|
+
const P = /* @__PURE__ */ new Map();
|
|
349
|
+
function ke(r) {
|
|
350
|
+
const { endpoint: e, cacheName: t, ...n } = r.csrf;
|
|
351
|
+
let s = P.get(e);
|
|
352
|
+
return s || (s = new Ae(e, t), P.set(e, s)), R(
|
|
310
353
|
{
|
|
311
|
-
retry:
|
|
312
|
-
request: [
|
|
354
|
+
retry: Ce(s, n),
|
|
355
|
+
request: [ve]
|
|
313
356
|
},
|
|
314
|
-
|
|
357
|
+
B(new De(s)).service
|
|
315
358
|
).service;
|
|
316
359
|
}
|
|
317
|
-
const
|
|
318
|
-
function
|
|
319
|
-
let e =
|
|
360
|
+
const _ = /* @__PURE__ */ new Map();
|
|
361
|
+
function qe(r) {
|
|
362
|
+
let e = _.get(r);
|
|
320
363
|
if (!e) {
|
|
321
|
-
const
|
|
322
|
-
e = { cache:
|
|
364
|
+
const t = J().service, n = Y(t).service, s = X(t, n).service, a = Z().service;
|
|
365
|
+
e = { cache: t, cacheController: s, pubSub: a }, _.set(r, e);
|
|
323
366
|
}
|
|
324
367
|
return e;
|
|
325
368
|
}
|
|
326
|
-
function
|
|
327
|
-
const
|
|
369
|
+
function Oe(r, e) {
|
|
370
|
+
const t = qe(r);
|
|
328
371
|
return {
|
|
329
|
-
shared:
|
|
372
|
+
shared: t,
|
|
330
373
|
services: {
|
|
331
|
-
cacheController:
|
|
332
|
-
pubSub:
|
|
374
|
+
cacheController: t.cacheController,
|
|
375
|
+
pubSub: t.pubSub,
|
|
333
376
|
fetch: e
|
|
334
377
|
}
|
|
335
378
|
};
|
|
336
379
|
}
|
|
337
|
-
function I() {
|
|
338
|
-
return {
|
|
339
|
-
"Content-Type": "application/json",
|
|
340
|
-
Accept: "application/json",
|
|
341
|
-
"X-Chatter-Entity-Encoding": "false"
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
380
|
const N = 300;
|
|
345
|
-
function
|
|
381
|
+
function Pe(r, e) {
|
|
346
382
|
try {
|
|
347
|
-
return JSON.parse(JSON.stringify(
|
|
348
|
-
} catch (
|
|
383
|
+
return JSON.parse(JSON.stringify(r));
|
|
384
|
+
} catch (t) {
|
|
349
385
|
const n = e || "(anonymous)", s = new TypeError(
|
|
350
|
-
`HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${
|
|
386
|
+
`HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${t.message}`
|
|
351
387
|
);
|
|
352
|
-
throw s.cause =
|
|
388
|
+
throw s.cause = t, s;
|
|
353
389
|
}
|
|
354
390
|
}
|
|
355
|
-
function
|
|
356
|
-
if (typeof
|
|
357
|
-
const e =
|
|
391
|
+
function _e(r) {
|
|
392
|
+
if (typeof r == "object" && r.type === "max-age") {
|
|
393
|
+
const e = r.maxAge;
|
|
358
394
|
return Number.isFinite(e) && e >= 0 ? e : N;
|
|
359
395
|
}
|
|
360
396
|
return N;
|
|
361
397
|
}
|
|
362
|
-
class
|
|
363
|
-
constructor(e,
|
|
364
|
-
super(
|
|
398
|
+
class Ne extends ee {
|
|
399
|
+
constructor(e, t, n) {
|
|
400
|
+
super(t), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Pe(
|
|
365
401
|
e.variables ?? {},
|
|
366
402
|
this.normalizedOperationName
|
|
367
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge =
|
|
403
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = _e(e.cacheControl), this.headers = e.headers, this.headersKey = oe(e.headers);
|
|
368
404
|
}
|
|
369
405
|
query;
|
|
370
406
|
normalizedVariables;
|
|
371
407
|
normalizedOperationName;
|
|
372
408
|
cacheControl;
|
|
373
409
|
resolvedMaxAge;
|
|
410
|
+
headers;
|
|
411
|
+
headersKey;
|
|
374
412
|
get fetchParams() {
|
|
375
413
|
return [
|
|
376
414
|
this.url,
|
|
377
415
|
{
|
|
378
416
|
method: "POST",
|
|
379
|
-
headers: I(),
|
|
417
|
+
headers: I(this.headers),
|
|
380
418
|
body: JSON.stringify({
|
|
381
419
|
query: this.query,
|
|
382
420
|
variables: this.normalizedVariables,
|
|
@@ -386,11 +424,12 @@ class qe extends Y {
|
|
|
386
424
|
];
|
|
387
425
|
}
|
|
388
426
|
buildKey() {
|
|
389
|
-
|
|
427
|
+
const e = {
|
|
390
428
|
query: this.query,
|
|
391
429
|
variables: this.normalizedVariables,
|
|
392
430
|
operationName: this.normalizedOperationName
|
|
393
|
-
}
|
|
431
|
+
};
|
|
432
|
+
return this.headersKey !== void 0 && (e.headers = this.headersKey), V(e);
|
|
394
433
|
}
|
|
395
434
|
/**
|
|
396
435
|
* Reads from the cache and returns the cache result or error
|
|
@@ -406,14 +445,14 @@ class qe extends Y {
|
|
|
406
445
|
* @returns result or error from the cache
|
|
407
446
|
*/
|
|
408
447
|
readFromCache(e) {
|
|
409
|
-
const
|
|
410
|
-
return n === void 0 ? u(
|
|
448
|
+
const t = this.buildKey(), n = e.get(t)?.value;
|
|
449
|
+
return n === void 0 ? u(E(new Q())) : u(C(n));
|
|
411
450
|
}
|
|
412
|
-
writeToCache(e,
|
|
413
|
-
if (
|
|
451
|
+
writeToCache(e, t) {
|
|
452
|
+
if (t.isOk() && t.value.data != null && Object.keys(t.value.data).length > 0) {
|
|
414
453
|
const n = Math.floor(Date.now() / 1e3);
|
|
415
454
|
e.set(this.buildKey(), {
|
|
416
|
-
value:
|
|
455
|
+
value: t.value.data,
|
|
417
456
|
metadata: {
|
|
418
457
|
cacheControl: {
|
|
419
458
|
type: "max-age",
|
|
@@ -437,122 +476,124 @@ class qe extends Y {
|
|
|
437
476
|
return e.errors && e.errors.length > 0;
|
|
438
477
|
}
|
|
439
478
|
processFetchReturnValue(e) {
|
|
440
|
-
return this.responseHasErrors(e) ?
|
|
479
|
+
return this.responseHasErrors(e) ? E(new G(e)) : C(e);
|
|
441
480
|
}
|
|
442
481
|
}
|
|
443
|
-
function
|
|
444
|
-
if (
|
|
445
|
-
const e =
|
|
482
|
+
function F(r) {
|
|
483
|
+
if (z(r) && r.data && typeof r.data == "object") {
|
|
484
|
+
const e = r.data;
|
|
446
485
|
if (e.data != null)
|
|
447
486
|
return e.data;
|
|
448
487
|
}
|
|
449
488
|
}
|
|
450
|
-
function
|
|
489
|
+
function Te(r) {
|
|
451
490
|
return (e) => {
|
|
452
491
|
if (e.isOk()) {
|
|
453
|
-
const
|
|
454
|
-
|
|
492
|
+
const t = e.value;
|
|
493
|
+
v(t), r({ data: t, errors: void 0 });
|
|
455
494
|
} else {
|
|
456
|
-
const
|
|
457
|
-
|
|
495
|
+
const t = F(e.error);
|
|
496
|
+
t && v(t), r({ data: t, errors: d(e.error) });
|
|
458
497
|
}
|
|
459
498
|
};
|
|
460
499
|
}
|
|
461
|
-
async function
|
|
462
|
-
let e,
|
|
500
|
+
async function Re(r) {
|
|
501
|
+
let e, t, n;
|
|
463
502
|
try {
|
|
464
|
-
const s = await
|
|
465
|
-
s.isOk() ? (e = s.value.data,
|
|
503
|
+
const s = await r.execute();
|
|
504
|
+
s.isOk() ? (e = s.value.data, v(e), n = (a) => s.value.subscribe(a)) : (e = F(s.error.failure), e && v(e), t = d(s.error.failure), n = (a) => s.error.subscribe(a));
|
|
466
505
|
} catch (s) {
|
|
467
|
-
|
|
506
|
+
t = d(s);
|
|
468
507
|
}
|
|
469
508
|
return {
|
|
470
509
|
data: e,
|
|
471
|
-
errors:
|
|
510
|
+
errors: t,
|
|
472
511
|
subscribe(s) {
|
|
473
|
-
return n ? n(
|
|
512
|
+
return n ? n(Te(s)) : S;
|
|
474
513
|
},
|
|
475
514
|
async refresh() {
|
|
476
|
-
await
|
|
515
|
+
await r.refresh();
|
|
477
516
|
}
|
|
478
517
|
};
|
|
479
518
|
}
|
|
480
|
-
function g(
|
|
519
|
+
function g(r) {
|
|
481
520
|
return {
|
|
482
521
|
data: void 0,
|
|
483
|
-
errors:
|
|
484
|
-
subscribe: () =>
|
|
485
|
-
refresh:
|
|
522
|
+
errors: r,
|
|
523
|
+
subscribe: () => S,
|
|
524
|
+
refresh: D
|
|
486
525
|
};
|
|
487
526
|
}
|
|
488
|
-
function
|
|
489
|
-
bundle:
|
|
527
|
+
function Me({
|
|
528
|
+
bundle: r,
|
|
490
529
|
url: e,
|
|
491
|
-
executeRaw:
|
|
530
|
+
executeRaw: t
|
|
492
531
|
}) {
|
|
493
|
-
const { services: n } =
|
|
532
|
+
const { services: n } = r;
|
|
494
533
|
async function s({
|
|
495
534
|
query: a,
|
|
496
|
-
variables:
|
|
497
|
-
operationName:
|
|
498
|
-
cacheControl:
|
|
535
|
+
variables: i,
|
|
536
|
+
operationName: o,
|
|
537
|
+
cacheControl: c,
|
|
538
|
+
headers: f
|
|
499
539
|
}) {
|
|
500
|
-
const
|
|
501
|
-
if (
|
|
502
|
-
const p =
|
|
503
|
-
if (
|
|
540
|
+
const h = k(a);
|
|
541
|
+
if (h.isErr()) return g(h.error);
|
|
542
|
+
const p = h.value, m = q(p, o);
|
|
543
|
+
if (m !== "query")
|
|
504
544
|
return g([
|
|
505
545
|
{
|
|
506
|
-
message: `DataSDK.graphql.query() requires a GraphQL query, received ${
|
|
546
|
+
message: `DataSDK.graphql.query() requires a GraphQL query, received ${m}.`
|
|
507
547
|
}
|
|
508
548
|
]);
|
|
509
|
-
let
|
|
549
|
+
let l;
|
|
510
550
|
try {
|
|
511
|
-
|
|
551
|
+
l = new Ne(
|
|
512
552
|
{
|
|
513
|
-
query:
|
|
514
|
-
variables:
|
|
515
|
-
operationName:
|
|
516
|
-
cacheControl:
|
|
553
|
+
query: A(p),
|
|
554
|
+
variables: i,
|
|
555
|
+
operationName: o,
|
|
556
|
+
cacheControl: c,
|
|
557
|
+
headers: f
|
|
517
558
|
},
|
|
518
559
|
n,
|
|
519
560
|
e
|
|
520
561
|
);
|
|
521
|
-
} catch (
|
|
522
|
-
return g(
|
|
562
|
+
} catch (w) {
|
|
563
|
+
return g(d(w));
|
|
523
564
|
}
|
|
524
|
-
return
|
|
565
|
+
return Re(l);
|
|
525
566
|
}
|
|
526
567
|
return {
|
|
527
568
|
query: s,
|
|
528
|
-
mutate: (a) =>
|
|
569
|
+
mutate: (a) => L(t, a)
|
|
529
570
|
};
|
|
530
571
|
}
|
|
531
|
-
const
|
|
532
|
-
class
|
|
572
|
+
const Ie = 1, Le = `@salesforce/platform-sdk-data_v${Ie}`, U = H(), $e = `${U}/ui-api`, T = `${U}/graphql`;
|
|
573
|
+
class He {
|
|
533
574
|
baseUrl;
|
|
534
575
|
clientFetch;
|
|
535
576
|
onStatus;
|
|
536
577
|
graphql;
|
|
537
578
|
constructor(e) {
|
|
538
|
-
const
|
|
539
|
-
this.baseUrl =
|
|
579
|
+
const t = Fe();
|
|
580
|
+
this.baseUrl = Ue(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = ke({
|
|
540
581
|
csrf: {
|
|
541
|
-
endpoint: `${this.baseUrl}${
|
|
542
|
-
cacheName:
|
|
582
|
+
endpoint: `${this.baseUrl}${$e}/session/csrf`,
|
|
583
|
+
cacheName: Le,
|
|
543
584
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
544
585
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
545
586
|
}
|
|
546
587
|
});
|
|
547
|
-
const n = (a,
|
|
548
|
-
this.graphql =
|
|
588
|
+
const n = (a, i) => this.fetch(a, i), s = Oe(this.baseUrl, n);
|
|
589
|
+
this.graphql = Me({
|
|
549
590
|
bundle: s,
|
|
550
|
-
url:
|
|
591
|
+
url: T,
|
|
551
592
|
executeRaw: this.executeRawGraphQL.bind(this)
|
|
552
593
|
});
|
|
553
594
|
}
|
|
554
|
-
async fetch(e,
|
|
555
|
-
const n = this.applySalesforceBase(e), s = await this.clientFetch(n,
|
|
595
|
+
async fetch(e, t) {
|
|
596
|
+
const n = this.applySalesforceBase(e), s = await this.clientFetch(n, t);
|
|
556
597
|
return await this.onStatus[s.status]?.(), s;
|
|
557
598
|
}
|
|
558
599
|
/**
|
|
@@ -563,13 +604,14 @@ class _e {
|
|
|
563
604
|
*/
|
|
564
605
|
async executeRawGraphQL({
|
|
565
606
|
query: e,
|
|
566
|
-
variables:
|
|
567
|
-
operationName: n
|
|
607
|
+
variables: t,
|
|
608
|
+
operationName: n,
|
|
609
|
+
headers: s
|
|
568
610
|
}) {
|
|
569
|
-
return (await this.fetch(
|
|
611
|
+
return (await this.fetch(T, {
|
|
570
612
|
method: "POST",
|
|
571
|
-
body: JSON.stringify({ query: e, variables:
|
|
572
|
-
headers: I()
|
|
613
|
+
body: JSON.stringify({ query: e, variables: t, operationName: n }),
|
|
614
|
+
headers: I(s)
|
|
573
615
|
})).json();
|
|
574
616
|
}
|
|
575
617
|
/**
|
|
@@ -580,41 +622,41 @@ class _e {
|
|
|
580
622
|
if (typeof e == "string") {
|
|
581
623
|
if (e.startsWith("http"))
|
|
582
624
|
return e;
|
|
583
|
-
const
|
|
584
|
-
return `${this.baseUrl}${
|
|
625
|
+
const t = e.startsWith("/") ? e : `/${e}`;
|
|
626
|
+
return `${this.baseUrl}${t}`;
|
|
585
627
|
}
|
|
586
628
|
return e;
|
|
587
629
|
}
|
|
588
630
|
}
|
|
589
|
-
function
|
|
631
|
+
function Fe() {
|
|
590
632
|
return {
|
|
591
633
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
592
634
|
};
|
|
593
635
|
}
|
|
594
|
-
function
|
|
595
|
-
if (!
|
|
596
|
-
let e =
|
|
636
|
+
function Ue(r) {
|
|
637
|
+
if (!r || r === "/") return "";
|
|
638
|
+
let e = r;
|
|
597
639
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
598
640
|
}
|
|
599
|
-
function
|
|
600
|
-
let
|
|
641
|
+
function Ye(r, ...e) {
|
|
642
|
+
let t = r[0] ?? "";
|
|
601
643
|
for (let n = 0; n < e.length; n += 1)
|
|
602
|
-
|
|
603
|
-
return
|
|
644
|
+
t += String(e[n]) + (r[n + 1] ?? "");
|
|
645
|
+
return t;
|
|
604
646
|
}
|
|
605
|
-
function
|
|
606
|
-
return
|
|
647
|
+
function Ze(r) {
|
|
648
|
+
return K(
|
|
607
649
|
(async () => {
|
|
608
650
|
try {
|
|
609
|
-
switch (await
|
|
610
|
-
case
|
|
611
|
-
return new
|
|
612
|
-
case
|
|
613
|
-
case
|
|
614
|
-
return new
|
|
615
|
-
case
|
|
616
|
-
return new
|
|
617
|
-
case
|
|
651
|
+
switch (await x(r?.surface)) {
|
|
652
|
+
case y.OpenAI:
|
|
653
|
+
return new fe();
|
|
654
|
+
case y.WebApp:
|
|
655
|
+
case y.MicroFrontend:
|
|
656
|
+
return new He(r?.webapp);
|
|
657
|
+
case y.Mosaic:
|
|
658
|
+
return new ue(r?.mosaic);
|
|
659
|
+
case y.MCPApps:
|
|
618
660
|
return {};
|
|
619
661
|
default:
|
|
620
662
|
return {};
|
|
@@ -627,6 +669,6 @@ function We(t) {
|
|
|
627
669
|
);
|
|
628
670
|
}
|
|
629
671
|
export {
|
|
630
|
-
|
|
631
|
-
|
|
672
|
+
Ze as createDataSDK,
|
|
673
|
+
Ye as gql
|
|
632
674
|
};
|