@salesforce/platform-sdk 12.13.0 → 12.14.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/data/index.d.ts +5 -2
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +309 -306
- package/dist/data/mosaic/fetch.d.ts +13 -33
- package/dist/data/mosaic/fetch.d.ts.map +1 -1
- package/dist/data/mosaic/index.d.ts +0 -14
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/dist/data/shared/graphql/parse-response.d.ts +4 -36
- package/dist/data/shared/graphql/parse-response.d.ts.map +1 -1
- package/dist/data/webapp/csrf/token-manager.d.ts +14 -1
- package/dist/data/webapp/csrf/token-manager.d.ts.map +1 -1
- package/dist/observability/vendor/index.d.ts +17 -0
- package/dist/observability/vendor/index.d.ts.map +1 -0
- package/dist/observability/vendor/names.d.ts +11 -0
- package/dist/observability/vendor/names.d.ts.map +1 -0
- package/dist/observability/vendor/protocol.d.ts +25 -0
- package/dist/observability/vendor/protocol.d.ts.map +1 -0
- package/dist/observability/vendor/queue.d.ts +16 -0
- package/dist/observability/vendor/queue.d.ts.map +1 -0
- package/dist/observability/vendor/verbs.d.ts +19 -0
- package/dist/observability/vendor/verbs.d.ts.map +1 -0
- package/docs/data/04-surfaces-and-guards.md +25 -2
- package/package.json +2 -2
package/dist/data/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
3
|
-
import { print as
|
|
4
|
-
import { ok as
|
|
5
|
-
import { buildServiceDescriptor 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
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const [, r, n] =
|
|
15
|
-
return Number(r) - Number(
|
|
1
|
+
import { g as X, S as m, a as _ } from "../surface-Cg3eyRpj.js";
|
|
2
|
+
import { w as Y } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { print as k, parse as Z } from "@conduit-client/onestore-graphql-parser/v1";
|
|
4
|
+
import { ok as O, err as q, resolvedPromiseLike as d, stableJSONStringify as ee, DataNotFoundError as te, UserVisibleError as re, deepFreeze as v, isUserVisibleError as ne } from "@conduit-client/utils";
|
|
5
|
+
import { buildServiceDescriptor as H, setHeader as w } from "@conduit-client/service-fetch-network/v1";
|
|
6
|
+
import { RetryPolicy as se, buildServiceDescriptor as ae } from "@conduit-client/service-retry/v1";
|
|
7
|
+
import { buildServiceDescriptor as oe } from "@conduit-client/service-cache/v1";
|
|
8
|
+
import { buildServiceDescriptor as ie } from "@conduit-client/service-cache-control/v1";
|
|
9
|
+
import { buildInMemoryCacheInclusionPolicyService as ce } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
10
|
+
import { buildServiceDescriptor as ue } from "@conduit-client/service-pubsub/v1";
|
|
11
|
+
import { HttpCacheControlCommand as he } from "@conduit-client/command-http-cache-control/v1";
|
|
12
|
+
const E = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
13
|
+
function le(t, e) {
|
|
14
|
+
const [, r, n] = E.exec(t), [, s, a] = E.exec(e);
|
|
15
|
+
return Number(r) - Number(s) || Number(n) - Number(a);
|
|
16
16
|
}
|
|
17
17
|
function pe(t, e) {
|
|
18
18
|
for (const r of t) {
|
|
19
|
-
const n = r.extension, { label:
|
|
20
|
-
if (
|
|
21
|
-
if (typeof
|
|
19
|
+
const n = r.extension, { label: s } = r, a = n.minApiVersion;
|
|
20
|
+
if (a !== void 0) {
|
|
21
|
+
if (typeof a != "string" || !E.test(a))
|
|
22
22
|
throw new TypeError(
|
|
23
|
-
`Extension ${
|
|
23
|
+
`Extension ${s} declares invalid minApiVersion ${JSON.stringify(a)}; expected a Salesforce API version such as "64.0".`
|
|
24
24
|
);
|
|
25
25
|
if (e.apiVersion !== void 0) {
|
|
26
|
-
if (!
|
|
26
|
+
if (!E.test(e.apiVersion))
|
|
27
27
|
throw new Error(
|
|
28
|
-
`Extension ${
|
|
28
|
+
`Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
|
|
29
29
|
);
|
|
30
|
-
if (
|
|
30
|
+
if (le(e.apiVersion, a) < 0)
|
|
31
31
|
throw new Error(
|
|
32
|
-
`Extension ${
|
|
32
|
+
`Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK uses version ${e.apiVersion}.`
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
},
|
|
38
|
+
const S = () => {
|
|
39
|
+
}, x = async () => {
|
|
40
40
|
};
|
|
41
|
-
function
|
|
41
|
+
function N(t) {
|
|
42
42
|
try {
|
|
43
|
-
return
|
|
43
|
+
return O(Z(t));
|
|
44
44
|
} catch (e) {
|
|
45
|
-
return
|
|
45
|
+
return q(y(e));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function P(t, e) {
|
|
49
49
|
const r = t.definitions.filter(
|
|
50
50
|
(n) => n.kind === "OperationDefinition"
|
|
51
51
|
);
|
|
@@ -59,10 +59,10 @@ function y(t) {
|
|
|
59
59
|
}
|
|
60
60
|
return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
|
|
61
61
|
}
|
|
62
|
-
async function
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
const o =
|
|
62
|
+
async function U(t, { mutation: e, variables: r, operationName: n, headers: s }) {
|
|
63
|
+
const a = N(e);
|
|
64
|
+
if (a.isErr()) return { data: void 0, errors: a.error };
|
|
65
|
+
const o = a.value, i = P(o, n);
|
|
66
66
|
if (i !== "mutation")
|
|
67
67
|
return {
|
|
68
68
|
data: void 0,
|
|
@@ -75,10 +75,10 @@ async function F(t, { mutation: e, variables: r, operationName: n, headers: a })
|
|
|
75
75
|
try {
|
|
76
76
|
const c = await t(
|
|
77
77
|
{
|
|
78
|
-
query:
|
|
78
|
+
query: k(o),
|
|
79
79
|
variables: r,
|
|
80
80
|
operationName: n,
|
|
81
|
-
headers:
|
|
81
|
+
headers: s
|
|
82
82
|
},
|
|
83
83
|
"mutation"
|
|
84
84
|
);
|
|
@@ -91,12 +91,12 @@ async function F(t, { mutation: e, variables: r, operationName: n, headers: a })
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function T(t) {
|
|
94
|
-
function e(n,
|
|
94
|
+
function e(n, s, a, o) {
|
|
95
95
|
return t(
|
|
96
96
|
{
|
|
97
|
-
query:
|
|
98
|
-
variables:
|
|
99
|
-
operationName:
|
|
97
|
+
query: k(n),
|
|
98
|
+
variables: s,
|
|
99
|
+
operationName: a,
|
|
100
100
|
headers: o
|
|
101
101
|
},
|
|
102
102
|
"query"
|
|
@@ -110,19 +110,19 @@ function T(t) {
|
|
|
110
110
|
}
|
|
111
111
|
async function r({
|
|
112
112
|
query: n,
|
|
113
|
-
variables:
|
|
114
|
-
operationName:
|
|
113
|
+
variables: s,
|
|
114
|
+
operationName: a,
|
|
115
115
|
headers: o
|
|
116
116
|
}) {
|
|
117
|
-
const i =
|
|
117
|
+
const i = N(n);
|
|
118
118
|
if (i.isErr())
|
|
119
119
|
return {
|
|
120
120
|
data: void 0,
|
|
121
121
|
errors: i.error,
|
|
122
|
-
subscribe: () =>
|
|
123
|
-
refresh:
|
|
122
|
+
subscribe: () => S,
|
|
123
|
+
refresh: x
|
|
124
124
|
};
|
|
125
|
-
const c = i.value, h =
|
|
125
|
+
const c = i.value, h = P(c, a);
|
|
126
126
|
if (h !== "query")
|
|
127
127
|
return {
|
|
128
128
|
data: void 0,
|
|
@@ -131,34 +131,34 @@ function T(t) {
|
|
|
131
131
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${h}.`
|
|
132
132
|
}
|
|
133
133
|
],
|
|
134
|
-
subscribe: () =>
|
|
135
|
-
refresh:
|
|
134
|
+
subscribe: () => S,
|
|
135
|
+
refresh: x
|
|
136
136
|
};
|
|
137
|
-
const u = /* @__PURE__ */ new Set(), l =
|
|
137
|
+
const u = /* @__PURE__ */ new Set(), l = s, p = await e(c, l, a, o);
|
|
138
138
|
return {
|
|
139
|
-
data:
|
|
140
|
-
errors:
|
|
139
|
+
data: p.data,
|
|
140
|
+
errors: p.errors,
|
|
141
141
|
subscribe(f) {
|
|
142
142
|
return u.add(f), () => {
|
|
143
143
|
u.delete(f);
|
|
144
144
|
};
|
|
145
145
|
},
|
|
146
146
|
async refresh() {
|
|
147
|
-
const f = await e(c, l,
|
|
148
|
-
for (const
|
|
147
|
+
const f = await e(c, l, a, o);
|
|
148
|
+
for (const g of u) g(f);
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
return {
|
|
153
153
|
query: r,
|
|
154
|
-
mutate: (n) =>
|
|
154
|
+
mutate: (n) => U(t, n)
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
const
|
|
158
|
-
function
|
|
157
|
+
const C = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
158
|
+
function $(t = C) {
|
|
159
159
|
return `/services/data/v${t}`;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function de(t) {
|
|
162
162
|
if (Array.isArray(t)) {
|
|
163
163
|
for (const e of t)
|
|
164
164
|
if (!(e?.type !== "text" || !e.text))
|
|
@@ -170,11 +170,11 @@ function fe(t) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function fe(t) {
|
|
174
174
|
const e = t;
|
|
175
175
|
return e?.code === -32601 || e?.code === -32602 && typeof e.message == "string" && /^Unknown tool\b/i.test(e.message);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function R(t) {
|
|
178
178
|
if (typeof t != "object" || Array.isArray(t)) return !1;
|
|
179
179
|
if (!Object.hasOwn(t, "errors")) return Object.hasOwn(t, "data");
|
|
180
180
|
const { errors: e } = t;
|
|
@@ -182,211 +182,175 @@ function k(t) {
|
|
|
182
182
|
(r) => r !== null && typeof r == "object" && !Array.isArray(r) && typeof r.message == "string"
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
-
class
|
|
185
|
+
class L {
|
|
186
186
|
graphql;
|
|
187
187
|
apiVersion;
|
|
188
188
|
#e;
|
|
189
189
|
constructor(e, r) {
|
|
190
|
-
if (this.#e = e, this.apiVersion = r?.apiVersion ??
|
|
190
|
+
if (this.#e = e, this.apiVersion = r?.apiVersion ?? C, typeof this.apiVersion != "string" || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)(?![\s\S])/.test(this.apiVersion))
|
|
191
191
|
throw new TypeError("Invalid Data SDK API version.");
|
|
192
192
|
this.graphql = T(this.#t.bind(this));
|
|
193
193
|
}
|
|
194
|
-
async #t({ query: e, variables: r, operationName: n },
|
|
195
|
-
const
|
|
194
|
+
async #t({ query: e, variables: r, operationName: n }, s) {
|
|
195
|
+
const a = {
|
|
196
196
|
query: e,
|
|
197
197
|
...r != null ? { variables: r } : {},
|
|
198
198
|
...n != null ? { operationName: n } : {}
|
|
199
|
-
}, o =
|
|
200
|
-
name:
|
|
199
|
+
}, o = s === "query" ? { method: "GET", queryParams: { queryInput: JSON.stringify(a) } } : { method: "POST", body: a }, i = await this.#e.request("tools/call", {
|
|
200
|
+
name: s === "query" ? "dispatch_readonly" : "dispatch",
|
|
201
201
|
arguments: {
|
|
202
|
-
url: `${
|
|
202
|
+
url: `${$(this.apiVersion)}/graphql`,
|
|
203
203
|
...o
|
|
204
204
|
}
|
|
205
|
-
}).catch((
|
|
205
|
+
}).catch((p) => {
|
|
206
206
|
throw new Error(
|
|
207
|
-
|
|
208
|
-
{ cause:
|
|
207
|
+
fe(p) ? "Data SDK GraphQL dispatch tool is unavailable." : "Data SDK GraphQL request failed.",
|
|
208
|
+
{ cause: p }
|
|
209
209
|
);
|
|
210
|
-
}), c = i?.structuredContent ??
|
|
210
|
+
}), c = i?.structuredContent ?? de(i?.content), h = c?.status_code, u = c?.body, l = i?.isError || c?.error_code !== void 0;
|
|
211
211
|
if (typeof h != "number" || !Number.isInteger(h))
|
|
212
212
|
throw new Error(
|
|
213
213
|
l ? "Data SDK GraphQL request failed." : "Data SDK GraphQL response is malformed."
|
|
214
214
|
);
|
|
215
215
|
if (l || h < 200 || h >= 300)
|
|
216
|
-
throw u != null &&
|
|
216
|
+
throw u != null && R(u) && u.errors?.length ? (
|
|
217
217
|
// This method is wrapped by `buildUncachedGraphQL`, which handles thrown {data} errors
|
|
218
218
|
{ data: { errors: u.errors } }
|
|
219
219
|
) : new Error("Data SDK GraphQL request failed.");
|
|
220
|
-
if (u == null || !
|
|
220
|
+
if (u == null || !R(u))
|
|
221
221
|
throw new Error("Data SDK GraphQL response is malformed.");
|
|
222
222
|
return u;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
function K(t, e, r) {
|
|
232
|
-
return !e || !r ? !1 : be(t?.headers, me);
|
|
233
|
-
}
|
|
234
|
-
function A(t, e, r) {
|
|
235
|
-
return e ? r ? b("Cookie", `sid=${e}`, t) : b("Authorization", `Bearer ${e}`, t) : t;
|
|
236
|
-
}
|
|
237
|
-
function ge({
|
|
238
|
-
baseUrl: t,
|
|
239
|
-
accessToken: e,
|
|
240
|
-
lightningDomain: r,
|
|
241
|
-
isInternal: n = !1
|
|
242
|
-
}) {
|
|
243
|
-
return (a) => {
|
|
244
|
-
const [s, o] = a;
|
|
245
|
-
if (typeof s == "string" && !s.startsWith("http") && t) {
|
|
246
|
-
const i = s.startsWith("/") ? s : `/${s}`;
|
|
247
|
-
return K(o, n, r) ? p(
|
|
248
|
-
A([`${r}${i}`, o], e, !0)
|
|
249
|
-
) : p(A([`${t}${i}`, o], e, !1));
|
|
225
|
+
function ye(t) {
|
|
226
|
+
return (e) => {
|
|
227
|
+
const [r, n] = e;
|
|
228
|
+
if (typeof r == "string" && !r.startsWith("http")) {
|
|
229
|
+
const s = r.startsWith("/") ? r : `/${r}`;
|
|
230
|
+
return d([`${t}${s}`, n]);
|
|
250
231
|
}
|
|
251
|
-
return
|
|
232
|
+
return d(e);
|
|
252
233
|
};
|
|
253
234
|
}
|
|
254
|
-
function
|
|
255
|
-
|
|
256
|
-
return j({ request: e }).service;
|
|
235
|
+
function me(t) {
|
|
236
|
+
return (e) => d(w("Authorization", `Bearer ${t}`, e));
|
|
257
237
|
}
|
|
258
|
-
|
|
238
|
+
function be(t, e) {
|
|
239
|
+
const r = [];
|
|
240
|
+
return t && r.push(ye(t)), e && r.push(me(e)), H({
|
|
241
|
+
request: r
|
|
242
|
+
}).service;
|
|
243
|
+
}
|
|
244
|
+
const we = {
|
|
259
245
|
"Content-Type": "application/json",
|
|
260
246
|
Accept: "application/json",
|
|
261
247
|
"X-Chatter-Entity-Encoding": "false"
|
|
262
248
|
};
|
|
263
|
-
function
|
|
249
|
+
function ge(t) {
|
|
264
250
|
if (t instanceof Headers) {
|
|
265
251
|
const e = [];
|
|
266
252
|
return t.forEach((r, n) => e.push([n, r])), e;
|
|
267
253
|
}
|
|
268
254
|
return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
|
|
269
255
|
}
|
|
270
|
-
function
|
|
256
|
+
function K(t, e) {
|
|
271
257
|
if (e === void 0) return { ...t };
|
|
272
258
|
const r = { ...t }, n = /* @__PURE__ */ new Map();
|
|
273
|
-
for (const
|
|
274
|
-
const
|
|
275
|
-
for (const [
|
|
276
|
-
const i =
|
|
277
|
-
c === void 0 ? (r[
|
|
259
|
+
for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
|
|
260
|
+
const s = /* @__PURE__ */ new Set();
|
|
261
|
+
for (const [a, o] of ge(e)) {
|
|
262
|
+
const i = a.toLowerCase(), c = n.get(i);
|
|
263
|
+
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));
|
|
278
264
|
}
|
|
279
265
|
return r;
|
|
280
266
|
}
|
|
281
|
-
function
|
|
282
|
-
return
|
|
267
|
+
function z(t) {
|
|
268
|
+
return K(we, t);
|
|
283
269
|
}
|
|
284
|
-
function
|
|
270
|
+
function ve(t) {
|
|
285
271
|
if (t === void 0) return;
|
|
286
272
|
const e = {};
|
|
287
273
|
return new Headers(t).forEach((r, n) => {
|
|
288
274
|
e[n] = r;
|
|
289
275
|
}), Object.keys(e).length > 0 ? e : void 0;
|
|
290
276
|
}
|
|
291
|
-
const
|
|
292
|
-
function
|
|
277
|
+
const Ee = 512;
|
|
278
|
+
function Se(t) {
|
|
293
279
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
294
280
|
}
|
|
295
|
-
class
|
|
281
|
+
class V extends Error {
|
|
296
282
|
status;
|
|
297
283
|
url;
|
|
298
284
|
constructor(e) {
|
|
299
|
-
const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(
|
|
285
|
+
const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(Se(e.body.slice(0, Ee)))})`;
|
|
300
286
|
super(
|
|
301
287
|
`${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.`
|
|
302
288
|
), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
|
|
303
289
|
}
|
|
304
290
|
}
|
|
305
|
-
async function
|
|
291
|
+
async function J(t, e, r) {
|
|
306
292
|
const n = await t.text();
|
|
307
|
-
let
|
|
293
|
+
let s;
|
|
308
294
|
try {
|
|
309
|
-
|
|
310
|
-
} catch (
|
|
311
|
-
throw new
|
|
295
|
+
s = JSON.parse(n);
|
|
296
|
+
} catch (a) {
|
|
297
|
+
throw new V({ surface: e, url: r, status: t.status, body: n, cause: a });
|
|
312
298
|
}
|
|
313
|
-
if (
|
|
314
|
-
throw new
|
|
299
|
+
if (!Ce(s))
|
|
300
|
+
throw new V({
|
|
315
301
|
surface: e,
|
|
316
302
|
url: r,
|
|
317
303
|
status: t.status,
|
|
318
304
|
body: n,
|
|
319
|
-
cause: new Error("Parsed
|
|
305
|
+
cause: new Error("Parsed response body was not a GraphQL response")
|
|
320
306
|
});
|
|
321
|
-
return
|
|
307
|
+
return s;
|
|
308
|
+
}
|
|
309
|
+
function Ce(t) {
|
|
310
|
+
return t === null || typeof t != "object" || Array.isArray(t) ? !1 : "data" in t || Array.isArray(t.errors);
|
|
322
311
|
}
|
|
323
|
-
const
|
|
312
|
+
const De = {
|
|
324
313
|
"Content-Type": "application/json",
|
|
325
314
|
Accept: "application/json"
|
|
326
315
|
};
|
|
327
|
-
class
|
|
316
|
+
class Ae {
|
|
328
317
|
clientFetch;
|
|
329
318
|
pathData;
|
|
330
|
-
baseUrl;
|
|
331
|
-
lightningDomain;
|
|
332
|
-
isInternal;
|
|
333
319
|
apiVersion;
|
|
334
320
|
graphql;
|
|
335
321
|
constructor(e) {
|
|
336
|
-
const r =
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
errors: [
|
|
352
|
-
{
|
|
353
|
-
message: "GraphQL mutations are not supported on the lightning domain for the Mosaic surface."
|
|
354
|
-
}
|
|
355
|
-
]
|
|
356
|
-
};
|
|
357
|
-
const { resource: h, init: u } = c ? {
|
|
358
|
-
resource: `${o}?queryInput=${encodeURIComponent(
|
|
359
|
-
JSON.stringify({ query: e, variables: r, operationName: n })
|
|
360
|
-
)}`,
|
|
361
|
-
init: { method: "GET", headers: i }
|
|
362
|
-
} : {
|
|
363
|
-
resource: o,
|
|
364
|
-
init: {
|
|
365
|
-
method: "POST",
|
|
366
|
-
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
367
|
-
headers: i
|
|
368
|
-
}
|
|
369
|
-
}, l = await this.clientFetch(h, u), d = c ? `${o}?queryInput=<redacted>` : h;
|
|
370
|
-
return W(l, "Mosaic", d);
|
|
322
|
+
const r = Oe(), n = qe(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
|
|
323
|
+
this.apiVersion = e?.apiVersion ?? r.apiVersion ?? C, this.pathData = $(this.apiVersion), this.clientFetch = be(n || void 0, s), this.graphql = T(this.executeRawGraphQL.bind(this));
|
|
324
|
+
}
|
|
325
|
+
async executeRawGraphQL({
|
|
326
|
+
query: e,
|
|
327
|
+
variables: r,
|
|
328
|
+
operationName: n,
|
|
329
|
+
headers: s
|
|
330
|
+
}) {
|
|
331
|
+
const a = `${this.pathData}/graphql`, o = await this.clientFetch(a, {
|
|
332
|
+
method: "POST",
|
|
333
|
+
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
334
|
+
headers: K(De, s)
|
|
335
|
+
});
|
|
336
|
+
return J(o, "Mosaic", a);
|
|
371
337
|
}
|
|
372
338
|
}
|
|
373
|
-
function
|
|
339
|
+
function Oe() {
|
|
374
340
|
const t = globalThis.MOSAIC_ENV;
|
|
375
341
|
return {
|
|
376
342
|
instanceUrl: t?.instanceUrl,
|
|
377
343
|
accessToken: t?.accessToken,
|
|
378
|
-
apiVersion: t?.apiVersion
|
|
379
|
-
lightningDomain: t?.lightningDomain,
|
|
380
|
-
isInternal: t?.isInternal
|
|
344
|
+
apiVersion: t?.apiVersion
|
|
381
345
|
};
|
|
382
346
|
}
|
|
383
|
-
function
|
|
347
|
+
function qe(t) {
|
|
384
348
|
if (!t || t === "/") return "";
|
|
385
349
|
let e = t;
|
|
386
350
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
387
351
|
}
|
|
388
352
|
const xe = "graphqlQuery";
|
|
389
|
-
class
|
|
353
|
+
class ke {
|
|
390
354
|
graphql;
|
|
391
355
|
constructor() {
|
|
392
356
|
this.graphql = T(this.executeRawGraphQL.bind(this));
|
|
@@ -411,50 +375,50 @@ class $e {
|
|
|
411
375
|
})).structuredContent;
|
|
412
376
|
}
|
|
413
377
|
}
|
|
414
|
-
const
|
|
415
|
-
function
|
|
378
|
+
const b = "Accept-Language";
|
|
379
|
+
function W(t) {
|
|
416
380
|
return t ? void 0 : globalThis.SFDC_ENV?.language;
|
|
417
381
|
}
|
|
418
382
|
function Ne(t) {
|
|
419
|
-
const e = new Headers(t), r =
|
|
420
|
-
return r ? (e.set(
|
|
383
|
+
const e = new Headers(t), r = W(e.has(b));
|
|
384
|
+
return r ? (e.set(b, r), e) : t;
|
|
421
385
|
}
|
|
422
386
|
const Pe = (t) => {
|
|
423
|
-
const [e, r] = t, n = e instanceof Request && !r?.headers ? e.headers.has(
|
|
424
|
-
return
|
|
425
|
-
},
|
|
426
|
-
let e =
|
|
427
|
-
return e =
|
|
428
|
-
},
|
|
387
|
+
const [e, r] = t, n = e instanceof Request && !r?.headers ? e.headers.has(b) : new Headers(r?.headers).has(b), s = W(n);
|
|
388
|
+
return s ? d(w(b, s, t)) : d(t);
|
|
389
|
+
}, Te = "X-SFDC-Client-Name", $e = "X-SFDC-Client-Version", _e = "@salesforce/platform-sdk", Re = "12.14.0", Le = (t) => {
|
|
390
|
+
let e = w(Te, _e, t);
|
|
391
|
+
return e = w($e, Re, e), d(e);
|
|
392
|
+
}, Ve = "X-CSRF-Token";
|
|
429
393
|
function Me(t, e = {}) {
|
|
430
394
|
const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
|
|
431
|
-
return async (
|
|
432
|
-
const [
|
|
433
|
-
if (
|
|
395
|
+
return async (s) => {
|
|
396
|
+
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";
|
|
397
|
+
if (M(n, i) || Ie(c) && M(r, i)) {
|
|
434
398
|
const u = await t.getToken();
|
|
435
|
-
|
|
399
|
+
s = w(Ve, u, s);
|
|
436
400
|
}
|
|
437
|
-
return
|
|
401
|
+
return d(s);
|
|
438
402
|
};
|
|
439
403
|
}
|
|
440
|
-
function
|
|
404
|
+
function Ie(t) {
|
|
441
405
|
const e = t.toLowerCase();
|
|
442
406
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
443
407
|
}
|
|
444
|
-
function
|
|
408
|
+
function M(t, e) {
|
|
445
409
|
const r = new URL(e, globalThis.location?.href ?? "http://localhost");
|
|
446
410
|
return t.some((n) => r.pathname.includes(n));
|
|
447
411
|
}
|
|
448
412
|
function Ge(t, e = {}) {
|
|
449
413
|
const r = Me(t, e);
|
|
450
|
-
async function n(
|
|
451
|
-
const
|
|
452
|
-
return fetch(
|
|
414
|
+
async function n(s) {
|
|
415
|
+
const a = await r(s);
|
|
416
|
+
return fetch(a[0], a[1]);
|
|
453
417
|
}
|
|
454
|
-
return (
|
|
418
|
+
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
455
419
|
}
|
|
456
420
|
const Qe = [400, 401, 403];
|
|
457
|
-
class
|
|
421
|
+
class je extends se {
|
|
458
422
|
constructor(e) {
|
|
459
423
|
super(e), this.csrfTokenManager = e;
|
|
460
424
|
}
|
|
@@ -482,9 +446,9 @@ class Ue extends ae {
|
|
|
482
446
|
await this.csrfTokenManager.refreshToken();
|
|
483
447
|
}
|
|
484
448
|
}
|
|
485
|
-
class
|
|
449
|
+
class Fe {
|
|
486
450
|
constructor(e, r) {
|
|
487
|
-
this.endpoint = e, this.cacheName = r, this.tokenPromise = this.
|
|
451
|
+
this.endpoint = e, this.cacheName = r, this.tokenPromise = this.startObtainToken();
|
|
488
452
|
}
|
|
489
453
|
endpoint;
|
|
490
454
|
cacheName;
|
|
@@ -494,10 +458,11 @@ class He {
|
|
|
494
458
|
* Returns the current CSRF token.
|
|
495
459
|
*
|
|
496
460
|
* @remarks
|
|
497
|
-
* The
|
|
461
|
+
* The token loads from the cache or with a fetch request. When the last attempt failed, this
|
|
462
|
+
* call starts a new attempt, so a transient failure does not block later requests.
|
|
498
463
|
*/
|
|
499
464
|
async getToken() {
|
|
500
|
-
return this.tokenPromise;
|
|
465
|
+
return this.tokenPromise ??= this.startObtainToken(), this.tokenPromise;
|
|
501
466
|
}
|
|
502
467
|
/**
|
|
503
468
|
* Clears the cached CSRF token and fetches a fresh one.
|
|
@@ -507,20 +472,48 @@ class He {
|
|
|
507
472
|
* every caller shares the same in-flight promise.
|
|
508
473
|
*/
|
|
509
474
|
refreshToken() {
|
|
510
|
-
return this.refreshPromise || (this.refreshPromise = this.withCache((e) => e.delete(this.endpoint)).then(() => (this.tokenPromise = this.
|
|
475
|
+
return this.refreshPromise || (this.refreshPromise = this.withCache((e) => e.delete(this.endpoint)).then(() => (this.tokenPromise = this.startObtainToken(), this.tokenPromise)).finally(() => {
|
|
511
476
|
this.refreshPromise = void 0;
|
|
512
477
|
})), this.refreshPromise;
|
|
513
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Starts a token attempt that is forgotten when it fails.
|
|
481
|
+
*
|
|
482
|
+
* @remarks
|
|
483
|
+
* The manager lives for the page lifetime. If it kept a rejected promise, every later protected
|
|
484
|
+
* request would fail without a network call until the page reloads.
|
|
485
|
+
*/
|
|
486
|
+
startObtainToken() {
|
|
487
|
+
const e = this.obtainToken();
|
|
488
|
+
return e.catch(() => {
|
|
489
|
+
this.tokenPromise === e && (this.tokenPromise = void 0);
|
|
490
|
+
}), e;
|
|
491
|
+
}
|
|
514
492
|
/**
|
|
515
493
|
* Returns a CSRF token from the cache, or fetches a new one when the cache has none.
|
|
516
494
|
*
|
|
495
|
+
* @remarks
|
|
496
|
+
* Only a response that contains a token goes into the cache. The cache persists across page
|
|
497
|
+
* loads, so a cached error response would otherwise fail every attempt.
|
|
498
|
+
*
|
|
517
499
|
* @returns The CSRF token.
|
|
518
500
|
*/
|
|
519
501
|
async obtainToken() {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
502
|
+
const e = await this.withCache((s) => s.match(this.endpoint));
|
|
503
|
+
if (e) {
|
|
504
|
+
const s = await I(e).catch(() => {
|
|
505
|
+
});
|
|
506
|
+
if (s)
|
|
507
|
+
return s;
|
|
508
|
+
await this.withCache((a) => a.delete(this.endpoint));
|
|
509
|
+
}
|
|
510
|
+
const r = await fetch(this.endpoint, { method: "get" });
|
|
511
|
+
if (!r.ok)
|
|
512
|
+
throw new Error(`CSRF token request failed with status ${r.status}`);
|
|
513
|
+
const n = await I(r);
|
|
514
|
+
if (!n)
|
|
515
|
+
throw new Error("CSRF token response did not contain a token");
|
|
516
|
+
return await this.withCache((s) => s.put(this.endpoint, r)), n;
|
|
524
517
|
}
|
|
525
518
|
/**
|
|
526
519
|
* Runs a callback against the Cache API, and returns `undefined` when the API is unavailable.
|
|
@@ -536,29 +529,36 @@ class He {
|
|
|
536
529
|
return;
|
|
537
530
|
}
|
|
538
531
|
}
|
|
539
|
-
|
|
540
|
-
|
|
532
|
+
async function I(t) {
|
|
533
|
+
const e = await t.clone().json();
|
|
534
|
+
if (typeof e != "object" || e === null || !("csrfToken" in e))
|
|
535
|
+
return;
|
|
536
|
+
const { csrfToken: r } = e;
|
|
537
|
+
return typeof r == "string" && r !== "" ? r : void 0;
|
|
538
|
+
}
|
|
539
|
+
const G = /* @__PURE__ */ new Map();
|
|
540
|
+
function He(t) {
|
|
541
541
|
const { endpoint: e, cacheName: r, ...n } = t.csrf;
|
|
542
|
-
let
|
|
543
|
-
return
|
|
542
|
+
let s = G.get(e);
|
|
543
|
+
return s || (s = new Fe(e, r), G.set(e, s)), H(
|
|
544
544
|
{
|
|
545
|
-
retry: Ge(
|
|
546
|
-
request: [
|
|
545
|
+
retry: Ge(s, n),
|
|
546
|
+
request: [Le, Pe]
|
|
547
547
|
},
|
|
548
|
-
|
|
548
|
+
ae(new je(s)).service
|
|
549
549
|
).service;
|
|
550
550
|
}
|
|
551
|
-
const
|
|
552
|
-
function
|
|
553
|
-
let e =
|
|
551
|
+
const Q = /* @__PURE__ */ new Map();
|
|
552
|
+
function Ue(t) {
|
|
553
|
+
let e = Q.get(t);
|
|
554
554
|
if (!e) {
|
|
555
|
-
const r =
|
|
556
|
-
e = { cache: r, cacheController:
|
|
555
|
+
const r = oe().service, n = ce(r).service, s = ie(r, n).service, a = ue().service;
|
|
556
|
+
e = { cache: r, cacheController: s, pubSub: a }, Q.set(t, e);
|
|
557
557
|
}
|
|
558
558
|
return e;
|
|
559
559
|
}
|
|
560
560
|
function Ke(t, e) {
|
|
561
|
-
const r =
|
|
561
|
+
const r = Ue(t);
|
|
562
562
|
return {
|
|
563
563
|
shared: r,
|
|
564
564
|
services: {
|
|
@@ -568,30 +568,30 @@ function Ke(t, e) {
|
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
|
-
const
|
|
571
|
+
const j = 300;
|
|
572
572
|
function ze(t, e) {
|
|
573
573
|
try {
|
|
574
574
|
return JSON.parse(JSON.stringify(t));
|
|
575
575
|
} catch (r) {
|
|
576
|
-
const n = e || "(anonymous)",
|
|
576
|
+
const n = e || "(anonymous)", s = new TypeError(
|
|
577
577
|
`HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${r.message}`
|
|
578
578
|
);
|
|
579
|
-
throw
|
|
579
|
+
throw s.cause = r, s;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
function Je(t) {
|
|
583
583
|
if (typeof t == "object" && t.type === "max-age") {
|
|
584
584
|
const e = t.maxAge;
|
|
585
|
-
return Number.isFinite(e) && e >= 0 ? e :
|
|
585
|
+
return Number.isFinite(e) && e >= 0 ? e : j;
|
|
586
586
|
}
|
|
587
|
-
return
|
|
587
|
+
return j;
|
|
588
588
|
}
|
|
589
|
-
class We extends
|
|
589
|
+
class We extends he {
|
|
590
590
|
constructor(e, r, n) {
|
|
591
591
|
super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = ze(
|
|
592
592
|
e.variables ?? {},
|
|
593
593
|
this.normalizedOperationName
|
|
594
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Je(e.cacheControl), this.headers = e.headers, this.headersKey =
|
|
594
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Je(e.cacheControl), this.headers = e.headers, this.headersKey = ve(e.headers);
|
|
595
595
|
}
|
|
596
596
|
url;
|
|
597
597
|
query;
|
|
@@ -606,7 +606,7 @@ class We extends le {
|
|
|
606
606
|
this.url,
|
|
607
607
|
{
|
|
608
608
|
method: "POST",
|
|
609
|
-
headers:
|
|
609
|
+
headers: z(this.headers),
|
|
610
610
|
body: JSON.stringify({
|
|
611
611
|
query: this.query,
|
|
612
612
|
variables: this.normalizedVariables,
|
|
@@ -621,7 +621,7 @@ class We extends le {
|
|
|
621
621
|
variables: this.normalizedVariables,
|
|
622
622
|
operationName: this.normalizedOperationName
|
|
623
623
|
};
|
|
624
|
-
return this.headersKey !== void 0 && (e.headers = this.headersKey),
|
|
624
|
+
return this.headersKey !== void 0 && (e.headers = this.headersKey), ee(e);
|
|
625
625
|
}
|
|
626
626
|
/**
|
|
627
627
|
* Reads the cached result for this command, or returns an error.
|
|
@@ -639,9 +639,9 @@ class We extends le {
|
|
|
639
639
|
*/
|
|
640
640
|
readFromCache(e) {
|
|
641
641
|
const r = this.buildKey(), n = e.get(r)?.value;
|
|
642
|
-
return n === void 0 ?
|
|
643
|
-
|
|
644
|
-
) :
|
|
642
|
+
return n === void 0 ? d(
|
|
643
|
+
q(new te("No cached entry found for this query."))
|
|
644
|
+
) : d(O(n));
|
|
645
645
|
}
|
|
646
646
|
writeToCache(e, r) {
|
|
647
647
|
if (r.isOk() && r.value.data != null && Object.keys(r.value.data).length > 0) {
|
|
@@ -657,7 +657,7 @@ class We extends le {
|
|
|
657
657
|
}
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
|
-
return
|
|
660
|
+
return d(void 0);
|
|
661
661
|
}
|
|
662
662
|
get cacheControlStrategyConfig() {
|
|
663
663
|
const e = Math.floor(Date.now() / 1e3);
|
|
@@ -671,7 +671,7 @@ class We extends le {
|
|
|
671
671
|
return e.errors && e.errors.length > 0;
|
|
672
672
|
}
|
|
673
673
|
processFetchReturnValue(e) {
|
|
674
|
-
return this.responseHasErrors(e) ?
|
|
674
|
+
return this.responseHasErrors(e) ? q(new re(e)) : O(e);
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
const Be = "CACHE_MISS";
|
|
@@ -683,8 +683,8 @@ function Xe() {
|
|
|
683
683
|
}
|
|
684
684
|
];
|
|
685
685
|
}
|
|
686
|
-
function
|
|
687
|
-
if (
|
|
686
|
+
function B(t) {
|
|
687
|
+
if (ne(t) && t.data && typeof t.data == "object") {
|
|
688
688
|
const e = t.data;
|
|
689
689
|
if (e.data != null)
|
|
690
690
|
return e.data;
|
|
@@ -696,36 +696,36 @@ function Ye(t) {
|
|
|
696
696
|
const r = e.value;
|
|
697
697
|
v(r), t({ data: r, errors: void 0 });
|
|
698
698
|
} else {
|
|
699
|
-
const r =
|
|
699
|
+
const r = B(e.error);
|
|
700
700
|
r && v(r), t({ data: r, errors: y(e.error) });
|
|
701
701
|
}
|
|
702
702
|
};
|
|
703
703
|
}
|
|
704
704
|
async function Ze(t, e = !1) {
|
|
705
|
-
let r, n,
|
|
705
|
+
let r, n, s;
|
|
706
706
|
try {
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
-
} catch (
|
|
710
|
-
n = y(
|
|
707
|
+
const a = await t.execute();
|
|
708
|
+
a.isOk() ? (r = a.value.data, v(r), s = (o) => a.value.subscribe(o)) : (r = B(a.error.failure), r && v(r), n = e && r === void 0 ? Xe() : y(a.error.failure), s = (o) => a.error.subscribe(o));
|
|
709
|
+
} catch (a) {
|
|
710
|
+
n = y(a);
|
|
711
711
|
}
|
|
712
712
|
return {
|
|
713
713
|
data: r,
|
|
714
714
|
errors: n,
|
|
715
|
-
subscribe(
|
|
716
|
-
return
|
|
715
|
+
subscribe(a) {
|
|
716
|
+
return s ? s(Ye(a)) : S;
|
|
717
717
|
},
|
|
718
718
|
async refresh() {
|
|
719
719
|
await t.refresh();
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
}
|
|
723
|
-
function
|
|
723
|
+
function A(t) {
|
|
724
724
|
return {
|
|
725
725
|
data: void 0,
|
|
726
726
|
errors: t,
|
|
727
|
-
subscribe: () =>
|
|
728
|
-
refresh:
|
|
727
|
+
subscribe: () => S,
|
|
728
|
+
refresh: x
|
|
729
729
|
};
|
|
730
730
|
}
|
|
731
731
|
function et({
|
|
@@ -734,49 +734,49 @@ function et({
|
|
|
734
734
|
executeRaw: r,
|
|
735
735
|
resolveEffectiveHeaders: n
|
|
736
736
|
}) {
|
|
737
|
-
const { services:
|
|
738
|
-
async function
|
|
737
|
+
const { services: s } = t;
|
|
738
|
+
async function a({
|
|
739
739
|
query: o,
|
|
740
740
|
variables: i,
|
|
741
741
|
operationName: c,
|
|
742
742
|
cacheControl: h,
|
|
743
743
|
headers: u
|
|
744
744
|
}) {
|
|
745
|
-
const l =
|
|
746
|
-
if (l.isErr()) return
|
|
747
|
-
const
|
|
745
|
+
const l = N(o);
|
|
746
|
+
if (l.isErr()) return A(l.error);
|
|
747
|
+
const p = l.value, f = P(p, c);
|
|
748
748
|
if (f !== "query")
|
|
749
|
-
return
|
|
749
|
+
return A([
|
|
750
750
|
{
|
|
751
751
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
752
752
|
}
|
|
753
753
|
]);
|
|
754
|
-
let
|
|
754
|
+
let g;
|
|
755
755
|
try {
|
|
756
|
-
const
|
|
757
|
-
|
|
756
|
+
const D = n ? n(u) : u;
|
|
757
|
+
g = new We(
|
|
758
758
|
{
|
|
759
|
-
query:
|
|
759
|
+
query: k(p),
|
|
760
760
|
variables: i,
|
|
761
761
|
operationName: c,
|
|
762
762
|
cacheControl: h,
|
|
763
|
-
headers:
|
|
763
|
+
headers: D
|
|
764
764
|
},
|
|
765
|
-
|
|
765
|
+
s,
|
|
766
766
|
e
|
|
767
767
|
);
|
|
768
|
-
} catch (
|
|
769
|
-
return
|
|
768
|
+
} catch (D) {
|
|
769
|
+
return A(y(D));
|
|
770
770
|
}
|
|
771
|
-
return Ze(
|
|
771
|
+
return Ze(g, h === "only-if-cached");
|
|
772
772
|
}
|
|
773
773
|
return {
|
|
774
|
-
query:
|
|
775
|
-
mutate: (o) =>
|
|
774
|
+
query: a,
|
|
775
|
+
mutate: (o) => U(r, o)
|
|
776
776
|
};
|
|
777
777
|
}
|
|
778
778
|
const tt = 1, rt = `@salesforce/platform-sdk-data_v${tt}`;
|
|
779
|
-
class
|
|
779
|
+
class F {
|
|
780
780
|
baseUrl;
|
|
781
781
|
pathData;
|
|
782
782
|
clientFetch;
|
|
@@ -784,10 +784,10 @@ class nt {
|
|
|
784
784
|
apiVersion;
|
|
785
785
|
graphql;
|
|
786
786
|
constructor(e) {
|
|
787
|
-
const r =
|
|
788
|
-
this.baseUrl =
|
|
789
|
-
const n = `${this.pathData}/ui-api`,
|
|
790
|
-
this.onStatus = e?.onStatus ?? {}, this.clientFetch =
|
|
787
|
+
const r = nt();
|
|
788
|
+
this.baseUrl = st(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? C, this.pathData = $(this.apiVersion);
|
|
789
|
+
const n = `${this.pathData}/ui-api`, s = `${this.pathData}/graphql`;
|
|
790
|
+
this.onStatus = e?.onStatus ?? {}, this.clientFetch = He({
|
|
791
791
|
csrf: {
|
|
792
792
|
endpoint: `${this.baseUrl}${n}/session/csrf`,
|
|
793
793
|
cacheName: rt,
|
|
@@ -795,17 +795,17 @@ class nt {
|
|
|
795
795
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
796
796
|
}
|
|
797
797
|
});
|
|
798
|
-
const
|
|
798
|
+
const a = (i, c) => this.fetch(i, c), o = Ke(`${this.baseUrl}${this.pathData}`, a);
|
|
799
799
|
this.graphql = et({
|
|
800
800
|
bundle: o,
|
|
801
|
-
url:
|
|
801
|
+
url: s,
|
|
802
802
|
executeRaw: this.executeRawGraphQL.bind(this),
|
|
803
803
|
resolveEffectiveHeaders: Ne
|
|
804
804
|
});
|
|
805
805
|
}
|
|
806
806
|
async fetch(e, r) {
|
|
807
|
-
const n = this.applySalesforceBase(e),
|
|
808
|
-
return await this.onStatus[
|
|
807
|
+
const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
|
|
808
|
+
return await this.onStatus[s.status]?.(), s;
|
|
809
809
|
}
|
|
810
810
|
/**
|
|
811
811
|
* Sends a raw GraphQL POST request.
|
|
@@ -819,14 +819,14 @@ class nt {
|
|
|
819
819
|
query: e,
|
|
820
820
|
variables: r,
|
|
821
821
|
operationName: n,
|
|
822
|
-
headers:
|
|
822
|
+
headers: s
|
|
823
823
|
}) {
|
|
824
|
-
const
|
|
824
|
+
const a = `${this.pathData}/graphql`, o = await this.fetch(a, {
|
|
825
825
|
method: "POST",
|
|
826
826
|
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
827
|
-
headers:
|
|
827
|
+
headers: z(s)
|
|
828
828
|
});
|
|
829
|
-
return
|
|
829
|
+
return J(o, "WebApp", a);
|
|
830
830
|
}
|
|
831
831
|
/**
|
|
832
832
|
* Converts a relative URL to an absolute Salesforce URL.
|
|
@@ -845,44 +845,44 @@ class nt {
|
|
|
845
845
|
return e;
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
function
|
|
848
|
+
function nt() {
|
|
849
849
|
return {
|
|
850
850
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
851
851
|
};
|
|
852
852
|
}
|
|
853
|
-
function
|
|
853
|
+
function st(t) {
|
|
854
854
|
if (!t || t === "/") return "";
|
|
855
855
|
let e = t;
|
|
856
856
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
857
857
|
}
|
|
858
|
-
function
|
|
859
|
-
const e = t, r = typeof e == "object" && e !== null ? e : void 0, n = r !== void 0 && "setup" in r,
|
|
860
|
-
if (typeof
|
|
858
|
+
function at(t) {
|
|
859
|
+
const e = t, r = typeof e == "object" && e !== null ? e : void 0, n = r !== void 0 && "setup" in r, s = n ? r : r?.extension, a = n ? s?.name : r?.as;
|
|
860
|
+
if (typeof s?.setup != "function")
|
|
861
861
|
throw new Error("Extension entry cannot attach: it is missing a setup function.");
|
|
862
|
-
if (typeof
|
|
862
|
+
if (typeof a != "string" || a.length === 0)
|
|
863
863
|
throw new Error(
|
|
864
864
|
n ? 'Extension entry cannot attach: "name" must be a non-empty string.' : 'Extension entry cannot attach: alias "as" must be a non-empty string.'
|
|
865
865
|
);
|
|
866
866
|
return {
|
|
867
|
-
extension:
|
|
868
|
-
mountName:
|
|
869
|
-
label:
|
|
867
|
+
extension: s,
|
|
868
|
+
mountName: a,
|
|
869
|
+
label: a === s.name ? `"${s.name}"` : `"${s.name}" (aliased as "${a}")`
|
|
870
870
|
};
|
|
871
871
|
}
|
|
872
|
-
async function
|
|
872
|
+
async function ot(t, e, r) {
|
|
873
873
|
if (e.length === 0)
|
|
874
874
|
return t;
|
|
875
875
|
if ("ext" in t)
|
|
876
876
|
throw new Error(
|
|
877
877
|
'Cannot attach extensions: the base SDK already declares an "ext" member, which the extension container reserves.'
|
|
878
878
|
);
|
|
879
|
-
const n = e.map(
|
|
879
|
+
const n = e.map(at);
|
|
880
880
|
r?.preflight?.(n, t);
|
|
881
|
-
const
|
|
881
|
+
const s = Object.create(t), a = /* @__PURE__ */ Object.create(null), o = (h) => {
|
|
882
882
|
throw new Error(`Cannot write "ext.${String(h)}" — ext is immutable once attached.`);
|
|
883
883
|
}, i = (h) => {
|
|
884
884
|
throw new Error(`Cannot ${h} "ext" — ext is immutable once attached.`);
|
|
885
|
-
}, c = new Proxy(
|
|
885
|
+
}, c = new Proxy(a, {
|
|
886
886
|
set(h, u) {
|
|
887
887
|
return o(u);
|
|
888
888
|
},
|
|
@@ -904,55 +904,58 @@ async function it(t, e, r) {
|
|
|
904
904
|
return i("change the prototype of");
|
|
905
905
|
}
|
|
906
906
|
});
|
|
907
|
-
Object.defineProperty(
|
|
907
|
+
Object.defineProperty(s, "ext", {
|
|
908
908
|
value: c,
|
|
909
909
|
enumerable: !0,
|
|
910
910
|
writable: !1,
|
|
911
911
|
configurable: !1
|
|
912
912
|
});
|
|
913
913
|
for (const { extension: h, mountName: u, label: l } of n) {
|
|
914
|
-
if (Object.hasOwn(
|
|
914
|
+
if (Object.hasOwn(a, u))
|
|
915
915
|
throw new Error(
|
|
916
916
|
`Extension ${l} cannot attach: "${u}" is already defined by another extension.`
|
|
917
917
|
);
|
|
918
|
-
let
|
|
918
|
+
let p;
|
|
919
919
|
try {
|
|
920
|
-
|
|
920
|
+
p = await h.setup(s);
|
|
921
921
|
} catch (f) {
|
|
922
922
|
throw new Error(`Extension ${l} failed during setup.`, { cause: f });
|
|
923
923
|
}
|
|
924
|
-
Object.defineProperty(
|
|
925
|
-
value:
|
|
924
|
+
Object.defineProperty(a, u, {
|
|
925
|
+
value: p,
|
|
926
926
|
enumerable: !0,
|
|
927
927
|
writable: !1,
|
|
928
928
|
configurable: !1
|
|
929
929
|
});
|
|
930
930
|
}
|
|
931
|
-
return Object.freeze(
|
|
931
|
+
return Object.freeze(a), s;
|
|
932
932
|
}
|
|
933
|
-
function
|
|
933
|
+
function gt(t, ...e) {
|
|
934
934
|
let r = t[0] ?? "";
|
|
935
935
|
for (let n = 0; n < e.length; n += 1)
|
|
936
936
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
937
937
|
return r;
|
|
938
938
|
}
|
|
939
|
-
function
|
|
939
|
+
function vt(t) {
|
|
940
940
|
return t;
|
|
941
941
|
}
|
|
942
|
-
async function
|
|
942
|
+
async function it(t) {
|
|
943
943
|
try {
|
|
944
|
-
switch (await
|
|
944
|
+
switch (await X(t?.surface)) {
|
|
945
945
|
case m.OpenAI:
|
|
946
|
-
return new
|
|
946
|
+
return new ke();
|
|
947
947
|
case m.WebApp:
|
|
948
|
-
|
|
949
|
-
|
|
948
|
+
return new F(t?.webapp);
|
|
949
|
+
case m.MicroFrontend: {
|
|
950
|
+
const r = globalThis.SFDC_ENV;
|
|
951
|
+
return typeof r == "object" && r !== null ? new F(t?.webapp) : {};
|
|
952
|
+
}
|
|
950
953
|
case m.Mosaic:
|
|
951
|
-
return new
|
|
954
|
+
return new Ae(t?.mosaic);
|
|
952
955
|
case m.Claude:
|
|
953
|
-
return new
|
|
956
|
+
return new L(await _.getInstance(), t?.claude);
|
|
954
957
|
case m.MCPApps:
|
|
955
|
-
return new
|
|
958
|
+
return new L(await _.getInstance(), t?.mcpApps);
|
|
956
959
|
default:
|
|
957
960
|
return {};
|
|
958
961
|
}
|
|
@@ -961,10 +964,10 @@ async function ct(t) {
|
|
|
961
964
|
}
|
|
962
965
|
}
|
|
963
966
|
function Et(t) {
|
|
964
|
-
return
|
|
967
|
+
return Y(
|
|
965
968
|
(async () => {
|
|
966
|
-
const e = await
|
|
967
|
-
return
|
|
969
|
+
const e = await it(t);
|
|
970
|
+
return ot(e, t?.extensions ?? [], {
|
|
968
971
|
preflight: pe
|
|
969
972
|
});
|
|
970
973
|
})(),
|
|
@@ -973,6 +976,6 @@ function Et(t) {
|
|
|
973
976
|
}
|
|
974
977
|
export {
|
|
975
978
|
Et as createDataSDK,
|
|
976
|
-
|
|
977
|
-
|
|
979
|
+
vt as defineDataExtension,
|
|
980
|
+
gt as gql
|
|
978
981
|
};
|