@salesforce/platform-sdk 12.18.0 → 13.0.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 +18 -0
- package/dist/analytics/index.js +1 -1
- package/dist/{analytics-DtUm3Bhb.js → analytics-BqVdGxvp.js} +1 -1
- package/dist/app/index.js +1 -1
- package/dist/{capabilities-B3Raifjg.js → capabilities-Gf8lYbjH.js} +1 -2
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/index.js +26 -27
- package/dist/chat/mcpapps.d.ts.map +1 -1
- package/dist/core/capabilities.d.ts +2 -2
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/chat.d.ts +7 -1
- package/dist/core/chat.d.ts.map +1 -1
- package/dist/core/data.d.ts +4 -4
- package/dist/core/index.js +2 -2
- package/dist/core/mcpapps-session.d.ts +8 -9
- package/dist/core/mcpapps-session.d.ts.map +1 -1
- package/dist/core/surface.d.ts +8 -11
- package/dist/core/surface.d.ts.map +1 -1
- package/dist/data/index.d.ts +1 -22
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +368 -269
- package/dist/data/mcpapps/index.d.ts +2 -2
- package/dist/data/mcpapps/index.d.ts.map +1 -1
- package/dist/data/telemetry.d.ts +39 -0
- package/dist/data/telemetry.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/internal-telemetry/define.d.ts +55 -0
- package/dist/internal-telemetry/define.d.ts.map +1 -0
- package/dist/internal-telemetry/index.d.ts +24 -0
- package/dist/internal-telemetry/index.d.ts.map +1 -0
- package/dist/lightning/index.d.ts.map +1 -1
- package/dist/lightning/index.js +4 -5
- package/dist/{surface-Cg3eyRpj.js → surface-DyglgPiz.js} +43 -48
- package/dist/ui-embedding/session.js +1 -1
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +1 -2
- package/docs/data/02-caching-and-freshness.md +3 -3
- package/docs/data/03-reactive-handle-lifecycle.md +2 -2
- package/docs/data/04-surfaces-and-guards.md +20 -8
- package/package.json +12 -11
package/dist/data/index.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { w as
|
|
3
|
-
import { print as
|
|
4
|
-
import { ok as O, err 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(s) || Number(n) - Number(
|
|
16
|
-
}
|
|
17
|
-
function
|
|
1
|
+
import { c as te, S as y, g as re, a as ne } from "../surface-DyglgPiz.js";
|
|
2
|
+
import { w as se } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { print as N, parse as oe } from "@conduit-client/onestore-graphql-parser/v1";
|
|
4
|
+
import { ok as O, err as k, resolvedPromiseLike as l, stableJSONStringify as ae, DataNotFoundError as ie, UserVisibleError as ce, deepFreeze as S, isUserVisibleError as ue } from "@conduit-client/utils";
|
|
5
|
+
import { buildServiceDescriptor as J, setHeader as w } from "@conduit-client/service-fetch-network/v1";
|
|
6
|
+
import { RetryPolicy as he, buildServiceDescriptor as de } from "@conduit-client/service-retry/v1";
|
|
7
|
+
import { buildServiceDescriptor as pe } from "@conduit-client/service-cache/v1";
|
|
8
|
+
import { buildServiceDescriptor as le } from "@conduit-client/service-cache-control/v1";
|
|
9
|
+
import { buildInMemoryCacheInclusionPolicyService as fe } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
10
|
+
import { buildServiceDescriptor as ye } from "@conduit-client/service-pubsub/v1";
|
|
11
|
+
import { HttpCacheControlCommand as me } from "@conduit-client/command-http-cache-control/v1";
|
|
12
|
+
const v = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
13
|
+
function be(t, e) {
|
|
14
|
+
const [, r, n] = v.exec(t), [, s, o] = v.exec(e);
|
|
15
|
+
return Number(r) - Number(s) || Number(n) - Number(o);
|
|
16
|
+
}
|
|
17
|
+
function ge(t, e) {
|
|
18
18
|
for (const r of t) {
|
|
19
|
-
const n = r.extension, { label: s } = r,
|
|
20
|
-
if (
|
|
21
|
-
if (typeof
|
|
19
|
+
const n = r.extension, { label: s } = r, o = n.minApiVersion;
|
|
20
|
+
if (o !== void 0) {
|
|
21
|
+
if (typeof o != "string" || !v.test(o))
|
|
22
22
|
throw new TypeError(
|
|
23
|
-
`Extension ${s} declares invalid minApiVersion ${JSON.stringify(
|
|
23
|
+
`Extension ${s} declares invalid minApiVersion ${JSON.stringify(o)}; expected a Salesforce API version such as "64.0".`
|
|
24
24
|
);
|
|
25
25
|
if (e.apiVersion !== void 0) {
|
|
26
|
-
if (!
|
|
26
|
+
if (!v.test(e.apiVersion))
|
|
27
27
|
throw new Error(
|
|
28
|
-
`Extension ${s} requires Salesforce API version ${
|
|
28
|
+
`Extension ${s} requires Salesforce API version ${o} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
|
|
29
29
|
);
|
|
30
|
-
if (
|
|
30
|
+
if (be(e.apiVersion, o) < 0)
|
|
31
31
|
throw new Error(
|
|
32
|
-
`Extension ${s} requires Salesforce API version ${
|
|
32
|
+
`Extension ${s} requires Salesforce API version ${o} 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 D = () => {
|
|
39
|
+
}, T = async () => {
|
|
40
40
|
};
|
|
41
|
-
function
|
|
41
|
+
function P(t) {
|
|
42
42
|
try {
|
|
43
|
-
return O(
|
|
43
|
+
return O(oe(t));
|
|
44
44
|
} catch (e) {
|
|
45
|
-
return
|
|
45
|
+
return k(m(e));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function $(t, e) {
|
|
49
49
|
const r = t.definitions.filter(
|
|
50
50
|
(n) => n.kind === "OperationDefinition"
|
|
51
51
|
);
|
|
52
52
|
return r.length === 0 ? "unknown" : r.length === 1 ? e === void 0 || r[0].name?.value === e ? r[0].operation : "unknown" : e === void 0 ? "unknown" : r.find((n) => n.name?.value === e)?.operation ?? "unknown";
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function m(t) {
|
|
55
55
|
if (t && typeof t == "object" && "data" in t) {
|
|
56
56
|
const e = t.data;
|
|
57
57
|
if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
|
|
@@ -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
|
|
62
|
+
async function W(t, { mutation: e, variables: r, operationName: n, headers: s }) {
|
|
63
|
+
const o = P(e);
|
|
64
|
+
if (o.isErr()) return { data: void 0, errors: o.error };
|
|
65
|
+
const a = o.value, i = $(a, n);
|
|
66
66
|
if (i !== "mutation")
|
|
67
67
|
return {
|
|
68
68
|
data: void 0,
|
|
@@ -75,7 +75,7 @@ async function U(t, { mutation: e, variables: r, operationName: n, headers: s })
|
|
|
75
75
|
try {
|
|
76
76
|
const c = await t(
|
|
77
77
|
{
|
|
78
|
-
query:
|
|
78
|
+
query: N(a),
|
|
79
79
|
variables: r,
|
|
80
80
|
operationName: n,
|
|
81
81
|
headers: s
|
|
@@ -87,17 +87,17 @@ async function U(t, { mutation: e, variables: r, operationName: n, headers: s })
|
|
|
87
87
|
errors: c.errors
|
|
88
88
|
};
|
|
89
89
|
} catch (c) {
|
|
90
|
-
return { data: void 0, errors:
|
|
90
|
+
return { data: void 0, errors: m(c) };
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
function e(n, s,
|
|
93
|
+
function q(t) {
|
|
94
|
+
function e(n, s, o, a) {
|
|
95
95
|
return t(
|
|
96
96
|
{
|
|
97
|
-
query:
|
|
97
|
+
query: N(n),
|
|
98
98
|
variables: s,
|
|
99
|
-
operationName:
|
|
100
|
-
headers:
|
|
99
|
+
operationName: o,
|
|
100
|
+
headers: a
|
|
101
101
|
},
|
|
102
102
|
"query"
|
|
103
103
|
).then(
|
|
@@ -105,24 +105,24 @@ function T(t) {
|
|
|
105
105
|
data: i.data ?? void 0,
|
|
106
106
|
errors: i.errors
|
|
107
107
|
}),
|
|
108
|
-
(i) => ({ data: void 0, errors:
|
|
108
|
+
(i) => ({ data: void 0, errors: m(i) })
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
async function r({
|
|
112
112
|
query: n,
|
|
113
113
|
variables: s,
|
|
114
|
-
operationName:
|
|
115
|
-
headers:
|
|
114
|
+
operationName: o,
|
|
115
|
+
headers: a
|
|
116
116
|
}) {
|
|
117
|
-
const i =
|
|
117
|
+
const i = P(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: () => D,
|
|
123
|
+
refresh: T
|
|
124
124
|
};
|
|
125
|
-
const c = i.value, h =
|
|
125
|
+
const c = i.value, h = $(c, o);
|
|
126
126
|
if (h !== "query")
|
|
127
127
|
return {
|
|
128
128
|
data: void 0,
|
|
@@ -131,10 +131,10 @@ 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: () => D,
|
|
135
|
+
refresh: T
|
|
136
136
|
};
|
|
137
|
-
const u = /* @__PURE__ */ new Set(),
|
|
137
|
+
const u = /* @__PURE__ */ new Set(), d = s, p = await e(c, d, o, a);
|
|
138
138
|
return {
|
|
139
139
|
data: p.data,
|
|
140
140
|
errors: p.errors,
|
|
@@ -144,21 +144,21 @@ function T(t) {
|
|
|
144
144
|
};
|
|
145
145
|
},
|
|
146
146
|
async refresh() {
|
|
147
|
-
const f = await e(c,
|
|
148
|
-
for (const
|
|
147
|
+
const f = await e(c, d, o, a);
|
|
148
|
+
for (const E of u) E(f);
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
return {
|
|
153
153
|
query: r,
|
|
154
|
-
mutate: (n) =>
|
|
154
|
+
mutate: (n) => W(t, n)
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
const
|
|
158
|
-
function
|
|
157
|
+
const A = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
158
|
+
function x(t = A) {
|
|
159
159
|
return `/services/data/v${t}`;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function we(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 de(t) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Ee(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 V(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,122 +182,122 @@ function R(t) {
|
|
|
182
182
|
(r) => r !== null && typeof r == "object" && !Array.isArray(r) && typeof r.message == "string"
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
-
class
|
|
185
|
+
class Se {
|
|
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 ?? A, 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
|
-
this.graphql =
|
|
192
|
+
this.graphql = q(this.#t.bind(this));
|
|
193
193
|
}
|
|
194
194
|
async #t({ query: e, variables: r, operationName: n }, s) {
|
|
195
|
-
const
|
|
195
|
+
const o = {
|
|
196
196
|
query: e,
|
|
197
197
|
...r != null ? { variables: r } : {},
|
|
198
198
|
...n != null ? { operationName: n } : {}
|
|
199
|
-
},
|
|
199
|
+
}, a = s === "query" ? { method: "GET", queryParams: { queryInput: JSON.stringify(o) } } : { method: "POST", body: o }, i = await this.#e.request("tools/call", {
|
|
200
200
|
name: s === "query" ? "dispatch_readonly" : "dispatch",
|
|
201
201
|
arguments: {
|
|
202
|
-
url: `${
|
|
203
|
-
...
|
|
202
|
+
url: `${x(this.apiVersion)}/graphql`,
|
|
203
|
+
...a
|
|
204
204
|
}
|
|
205
205
|
}).catch((p) => {
|
|
206
206
|
throw new Error(
|
|
207
|
-
|
|
207
|
+
Ee(p) ? "Data SDK GraphQL dispatch tool is unavailable." : "Data SDK GraphQL request failed.",
|
|
208
208
|
{ cause: p }
|
|
209
209
|
);
|
|
210
|
-
}), c = i?.structuredContent ??
|
|
210
|
+
}), c = i?.structuredContent ?? we(i?.content), h = c?.status_code, u = c?.body, d = i?.isError || c?.error_code !== void 0;
|
|
211
211
|
if (typeof h != "number" || !Number.isInteger(h))
|
|
212
212
|
throw new Error(
|
|
213
|
-
|
|
213
|
+
d ? "Data SDK GraphQL request failed." : "Data SDK GraphQL response is malformed."
|
|
214
214
|
);
|
|
215
|
-
if (
|
|
216
|
-
throw u != null &&
|
|
215
|
+
if (d || h < 200 || h >= 300)
|
|
216
|
+
throw u != null && V(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 || !V(u))
|
|
221
221
|
throw new Error("Data SDK GraphQL response is malformed.");
|
|
222
222
|
return u;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function ve(t) {
|
|
226
226
|
return (e) => {
|
|
227
227
|
const [r, n] = e;
|
|
228
228
|
if (typeof r == "string" && !r.startsWith("http")) {
|
|
229
229
|
const s = r.startsWith("/") ? r : `/${r}`;
|
|
230
|
-
return
|
|
230
|
+
return l([`${t}${s}`, n]);
|
|
231
231
|
}
|
|
232
|
-
return
|
|
232
|
+
return l(e);
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return (e) =>
|
|
235
|
+
function De(t) {
|
|
236
|
+
return (e) => l(w("Authorization", `Bearer ${t}`, e));
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function Ae(t, e) {
|
|
239
239
|
const r = [];
|
|
240
|
-
return t && r.push(
|
|
240
|
+
return t && r.push(ve(t)), e && r.push(De(e)), J({
|
|
241
241
|
request: r
|
|
242
242
|
}).service;
|
|
243
243
|
}
|
|
244
|
-
const
|
|
244
|
+
const Ce = {
|
|
245
245
|
"Content-Type": "application/json",
|
|
246
246
|
Accept: "application/json",
|
|
247
247
|
"X-Chatter-Entity-Encoding": "false"
|
|
248
248
|
};
|
|
249
|
-
function
|
|
249
|
+
function _e(t) {
|
|
250
250
|
if (t instanceof Headers) {
|
|
251
251
|
const e = [];
|
|
252
252
|
return t.forEach((r, n) => e.push([n, r])), e;
|
|
253
253
|
}
|
|
254
254
|
return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function B(t, e) {
|
|
257
257
|
if (e === void 0) return { ...t };
|
|
258
258
|
const r = { ...t }, n = /* @__PURE__ */ new Map();
|
|
259
|
-
for (const
|
|
259
|
+
for (const o of Object.keys(r)) n.set(o.toLowerCase(), o);
|
|
260
260
|
const s = /* @__PURE__ */ new Set();
|
|
261
|
-
for (const [
|
|
262
|
-
const i =
|
|
263
|
-
c === void 0 ? (r[
|
|
261
|
+
for (const [o, a] of _e(e)) {
|
|
262
|
+
const i = o.toLowerCase(), c = n.get(i);
|
|
263
|
+
c === void 0 ? (r[o] = a, n.set(i, o), s.add(i)) : s.has(i) ? r[c] = `${r[c]}, ${a}` : (r[c] = a, s.add(i));
|
|
264
264
|
}
|
|
265
265
|
return r;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
return
|
|
267
|
+
function X(t) {
|
|
268
|
+
return B(Ce, t);
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function Oe(t) {
|
|
271
271
|
if (t === void 0) return;
|
|
272
272
|
const e = {};
|
|
273
273
|
return new Headers(t).forEach((r, n) => {
|
|
274
274
|
e[n] = r;
|
|
275
275
|
}), Object.keys(e).length > 0 ? e : void 0;
|
|
276
276
|
}
|
|
277
|
-
const
|
|
278
|
-
function
|
|
277
|
+
const ke = 512;
|
|
278
|
+
function Te(t) {
|
|
279
279
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
280
280
|
}
|
|
281
|
-
class
|
|
281
|
+
class R extends Error {
|
|
282
282
|
status;
|
|
283
283
|
url;
|
|
284
284
|
constructor(e) {
|
|
285
|
-
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(Te(e.body.slice(0, ke)))})`;
|
|
286
286
|
super(
|
|
287
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.`
|
|
288
288
|
), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
async function
|
|
291
|
+
async function Y(t, e, r) {
|
|
292
292
|
const n = await t.text();
|
|
293
293
|
let s;
|
|
294
294
|
try {
|
|
295
295
|
s = JSON.parse(n);
|
|
296
|
-
} catch (
|
|
297
|
-
throw new
|
|
296
|
+
} catch (o) {
|
|
297
|
+
throw new R({ surface: e, url: r, status: t.status, body: n, cause: o });
|
|
298
298
|
}
|
|
299
|
-
if (!
|
|
300
|
-
throw new
|
|
299
|
+
if (!Ne(s))
|
|
300
|
+
throw new R({
|
|
301
301
|
surface: e,
|
|
302
302
|
url: r,
|
|
303
303
|
status: t.status,
|
|
@@ -306,21 +306,21 @@ async function J(t, e, r) {
|
|
|
306
306
|
});
|
|
307
307
|
return s;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function Ne(t) {
|
|
310
310
|
return t === null || typeof t != "object" || Array.isArray(t) ? !1 : "data" in t || Array.isArray(t.errors);
|
|
311
311
|
}
|
|
312
|
-
const
|
|
312
|
+
const Pe = {
|
|
313
313
|
"Content-Type": "application/json",
|
|
314
314
|
Accept: "application/json"
|
|
315
315
|
};
|
|
316
|
-
class
|
|
316
|
+
class $e {
|
|
317
317
|
clientFetch;
|
|
318
318
|
pathData;
|
|
319
319
|
apiVersion;
|
|
320
320
|
graphql;
|
|
321
321
|
constructor(e) {
|
|
322
|
-
const r =
|
|
323
|
-
this.apiVersion = e?.apiVersion ?? r.apiVersion ??
|
|
322
|
+
const r = qe(), n = xe(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
|
|
323
|
+
this.apiVersion = e?.apiVersion ?? r.apiVersion ?? A, this.pathData = x(this.apiVersion), this.clientFetch = Ae(n || void 0, s), this.graphql = q(this.executeRawGraphQL.bind(this));
|
|
324
324
|
}
|
|
325
325
|
async executeRawGraphQL({
|
|
326
326
|
query: e,
|
|
@@ -328,15 +328,15 @@ class Ae {
|
|
|
328
328
|
operationName: n,
|
|
329
329
|
headers: s
|
|
330
330
|
}) {
|
|
331
|
-
const
|
|
331
|
+
const o = `${this.pathData}/graphql`, a = await this.clientFetch(o, {
|
|
332
332
|
method: "POST",
|
|
333
333
|
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
334
|
-
headers:
|
|
334
|
+
headers: B(Pe, s)
|
|
335
335
|
});
|
|
336
|
-
return
|
|
336
|
+
return Y(a, "Mosaic", o);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function qe() {
|
|
340
340
|
const t = globalThis.MOSAIC_ENV;
|
|
341
341
|
return {
|
|
342
342
|
instanceUrl: t?.instanceUrl,
|
|
@@ -344,16 +344,16 @@ function Oe() {
|
|
|
344
344
|
apiVersion: t?.apiVersion
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function xe(t) {
|
|
348
348
|
if (!t || t === "/") return "";
|
|
349
349
|
let e = t;
|
|
350
350
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
351
351
|
}
|
|
352
|
-
const
|
|
353
|
-
class
|
|
352
|
+
const Ve = "graphqlQuery";
|
|
353
|
+
class Re {
|
|
354
354
|
graphql;
|
|
355
355
|
constructor() {
|
|
356
|
-
this.graphql =
|
|
356
|
+
this.graphql = q(this.executeRawGraphQL.bind(this));
|
|
357
357
|
}
|
|
358
358
|
/**
|
|
359
359
|
* This method does not forward the `headers` request option, by design.
|
|
@@ -368,57 +368,158 @@ class ke {
|
|
|
368
368
|
variables: r,
|
|
369
369
|
operationName: n
|
|
370
370
|
}) {
|
|
371
|
-
return (await window.openai.callTool(
|
|
371
|
+
return (await window.openai.callTool(Ve, {
|
|
372
372
|
query: e,
|
|
373
373
|
...r != null ? { variables: r } : {},
|
|
374
374
|
...n != null ? { operationName: n } : {}
|
|
375
375
|
})).structuredContent;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
|
-
const
|
|
379
|
-
|
|
378
|
+
const Le = { namespace: "sf.pdp", name: "PdpEvent", pbjsSchema: { nested: { sf: { nested: { pdp: { nested: { PdpEvent: { oneofs: { _eventVolume: { oneof: ["eventVolume"] } }, fields: { contextName: { id: 5, type: "string" }, componentId: { id: 2, type: "string" }, productFeatureId: { id: 3, type: "string" }, channel: { id: 7, type: "string" }, eventName: { id: 1, type: "string" }, contextValue: { id: 6, type: "string" }, subType: { id: 8, type: "string" }, eventVolume: {
|
|
379
|
+
options: { proto3_optional: !0 },
|
|
380
|
+
id: 4,
|
|
381
|
+
type: "int32"
|
|
382
|
+
}, userId: { id: 9, type: "string" } } } } } } } } } }, Ie = 1, L = 256, I = "__SF_O11Y_QUEUE_1P__", Me = 1e3;
|
|
383
|
+
function Ge() {
|
|
384
|
+
const t = [], e = {
|
|
385
|
+
droppedCount: 0,
|
|
386
|
+
push(r) {
|
|
387
|
+
t.length >= Me && (t.shift(), e.droppedCount++), t.push(r);
|
|
388
|
+
},
|
|
389
|
+
drain() {
|
|
390
|
+
return t.splice(0, t.length);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
return e;
|
|
394
|
+
}
|
|
395
|
+
function b(t, e, r) {
|
|
396
|
+
if (!(typeof window > "u"))
|
|
397
|
+
try {
|
|
398
|
+
const n = window, s = n[I] ?? (n[I] = Ge()), o = { version: Ie, name: t, verb: e, args: r };
|
|
399
|
+
s.push(o);
|
|
400
|
+
} catch {
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function Ue(t) {
|
|
404
|
+
return {
|
|
405
|
+
log(e, r, n) {
|
|
406
|
+
b(t, "log", [e, r, n]);
|
|
407
|
+
},
|
|
408
|
+
error(e, r, n, s) {
|
|
409
|
+
b(t, "error", [e, r, n, s]);
|
|
410
|
+
},
|
|
411
|
+
incrementCounter(e, r, n, s) {
|
|
412
|
+
b(t, "incrementCounter", [e, r, n, s]);
|
|
413
|
+
},
|
|
414
|
+
trackValue(e, r, n, s) {
|
|
415
|
+
b(t, "trackValue", [e, r, n, s]);
|
|
416
|
+
},
|
|
417
|
+
bucketValue(e, r, n, s, o) {
|
|
418
|
+
b(t, "bucketValue", [e, r, n, s, o]);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function Qe(t) {
|
|
423
|
+
if (typeof t != "string" || t.length === 0 || t.length > L)
|
|
424
|
+
throw new TypeError(
|
|
425
|
+
`getInstrumentation(name): name must be a non-empty string of at most ${L} characters`
|
|
426
|
+
);
|
|
427
|
+
return Ue(t);
|
|
428
|
+
}
|
|
429
|
+
// @__NO_SIDE_EFFECTS__
|
|
430
|
+
function Fe(t) {
|
|
431
|
+
return Object.freeze({ kind: "log", ...t });
|
|
432
|
+
}
|
|
433
|
+
const Ke = /* @__PURE__ */ new Set([y.WebApp, y.MicroFrontend]), M = /* @__PURE__ */ new Set();
|
|
434
|
+
function G(t, e) {
|
|
435
|
+
const { namespace: r, name: n } = t.schema, s = `${t.area}/${r}.${n}/${e}`;
|
|
436
|
+
M.has(s) || (M.add(s), console.debug(
|
|
437
|
+
`[platform-sdk:telemetry] Dropped ${r}.${n} for area "${t.area}". ${e}`
|
|
438
|
+
));
|
|
439
|
+
}
|
|
440
|
+
const je = {
|
|
441
|
+
/**
|
|
442
|
+
* Emits a schema-backed log record.
|
|
443
|
+
*
|
|
444
|
+
* @remarks
|
|
445
|
+
* The payload type comes from the definition only. `NoInfer` stops `tsc` from also inferring
|
|
446
|
+
* it from the argument, which would let an out-of-domain value compile.
|
|
447
|
+
*/
|
|
448
|
+
log(t, e) {
|
|
449
|
+
try {
|
|
450
|
+
const r = te();
|
|
451
|
+
if (r === void 0) {
|
|
452
|
+
G(t, "The surface is not detected.");
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (!Ke.has(r)) return;
|
|
456
|
+
Qe(`platform-sdk-${t.area}`).log(t.schema, e);
|
|
457
|
+
} catch (r) {
|
|
458
|
+
try {
|
|
459
|
+
G(
|
|
460
|
+
t,
|
|
461
|
+
`The producer failed: ${r instanceof Error ? r.message : String(r)}`
|
|
462
|
+
);
|
|
463
|
+
} catch {
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}, He = "aJCEE000000fZZh4AM", ze = "dataSdk.used", Je = Object.freeze({
|
|
468
|
+
productFeatureId: He,
|
|
469
|
+
eventName: ze
|
|
470
|
+
}), We = /* @__PURE__ */ Fe({
|
|
471
|
+
area: "data",
|
|
472
|
+
description: "Data SDK adoption. Answers: how many distinct orgs use the Data SDK (PF MAT, trailing 28 days)?",
|
|
473
|
+
schema: Le
|
|
474
|
+
});
|
|
475
|
+
let U = !1;
|
|
476
|
+
function Be() {
|
|
477
|
+
U || (U = !0, je.log(We, Je));
|
|
478
|
+
}
|
|
479
|
+
const g = "Accept-Language";
|
|
480
|
+
function Z(t) {
|
|
380
481
|
return t ? void 0 : globalThis.SFDC_ENV?.language;
|
|
381
482
|
}
|
|
382
|
-
function
|
|
383
|
-
const e = new Headers(t), r =
|
|
384
|
-
return r ? (e.set(
|
|
385
|
-
}
|
|
386
|
-
const
|
|
387
|
-
const [e, r] = t, n = e instanceof Request && !r?.headers ? e.headers.has(
|
|
388
|
-
return s ?
|
|
389
|
-
},
|
|
390
|
-
let e = w(
|
|
391
|
-
return e = w(
|
|
392
|
-
},
|
|
393
|
-
function
|
|
483
|
+
function Xe(t) {
|
|
484
|
+
const e = new Headers(t), r = Z(e.has(g));
|
|
485
|
+
return r ? (e.set(g, r), e) : t;
|
|
486
|
+
}
|
|
487
|
+
const Ye = (t) => {
|
|
488
|
+
const [e, r] = t, n = e instanceof Request && !r?.headers ? e.headers.has(g) : new Headers(r?.headers).has(g), s = Z(n);
|
|
489
|
+
return s ? l(w(g, s, t)) : l(t);
|
|
490
|
+
}, Ze = "X-SFDC-Client-Name", et = "X-SFDC-Client-Version", tt = "@salesforce/platform-sdk", rt = "13.0.0", nt = (t) => {
|
|
491
|
+
let e = w(Ze, tt, t);
|
|
492
|
+
return e = w(et, rt, e), l(e);
|
|
493
|
+
}, st = "X-CSRF-Token";
|
|
494
|
+
function ot(t, e = {}) {
|
|
394
495
|
const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
|
|
395
496
|
return async (s) => {
|
|
396
|
-
const [
|
|
397
|
-
if (
|
|
497
|
+
const [o, a] = s, i = o instanceof Request ? o.url : o instanceof URL ? o.href : o, c = a?.method ?? (o instanceof Request ? o.method : void 0) ?? "GET";
|
|
498
|
+
if (Q(n, i) || at(c) && Q(r, i)) {
|
|
398
499
|
const u = await t.getToken();
|
|
399
|
-
s = w(
|
|
500
|
+
s = w(st, u, s);
|
|
400
501
|
}
|
|
401
|
-
return
|
|
502
|
+
return l(s);
|
|
402
503
|
};
|
|
403
504
|
}
|
|
404
|
-
function
|
|
505
|
+
function at(t) {
|
|
405
506
|
const e = t.toLowerCase();
|
|
406
507
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
407
508
|
}
|
|
408
|
-
function
|
|
509
|
+
function Q(t, e) {
|
|
409
510
|
const r = new URL(e, globalThis.location?.href ?? "http://localhost");
|
|
410
511
|
return t.some((n) => r.pathname.includes(n));
|
|
411
512
|
}
|
|
412
|
-
function
|
|
413
|
-
const r =
|
|
513
|
+
function it(t, e = {}) {
|
|
514
|
+
const r = ot(t, e);
|
|
414
515
|
async function n(s) {
|
|
415
|
-
const
|
|
416
|
-
return fetch(
|
|
516
|
+
const o = await r(s);
|
|
517
|
+
return fetch(o[0], o[1]);
|
|
417
518
|
}
|
|
418
|
-
return (s,
|
|
519
|
+
return (s, o) => o ? o.applyRetry(async () => n(s)) : n(s);
|
|
419
520
|
}
|
|
420
|
-
const
|
|
421
|
-
class
|
|
521
|
+
const ct = [400, 401, 403];
|
|
522
|
+
class ut extends he {
|
|
422
523
|
constructor(e) {
|
|
423
524
|
super(e), this.csrfTokenManager = e;
|
|
424
525
|
}
|
|
@@ -427,7 +528,7 @@ class je extends se {
|
|
|
427
528
|
* Returns true when a CSRF token issue caused the request to fail.
|
|
428
529
|
*/
|
|
429
530
|
async shouldRetry(e, r) {
|
|
430
|
-
return r.attempt >= 1 ? !1 :
|
|
531
|
+
return r.attempt >= 1 ? !1 : ct.includes(e.status);
|
|
431
532
|
}
|
|
432
533
|
/**
|
|
433
534
|
* Returns zero, so the CSRF token refresh happens immediately with no added delay.
|
|
@@ -446,7 +547,7 @@ class je extends se {
|
|
|
446
547
|
await this.csrfTokenManager.refreshToken();
|
|
447
548
|
}
|
|
448
549
|
}
|
|
449
|
-
class
|
|
550
|
+
class ht {
|
|
450
551
|
constructor(e, r) {
|
|
451
552
|
this.endpoint = e, this.cacheName = r, this.tokenPromise = this.startObtainToken();
|
|
452
553
|
}
|
|
@@ -501,16 +602,16 @@ class Fe {
|
|
|
501
602
|
async obtainToken() {
|
|
502
603
|
const e = await this.withCache((s) => s.match(this.endpoint));
|
|
503
604
|
if (e) {
|
|
504
|
-
const s = await
|
|
605
|
+
const s = await F(e).catch(() => {
|
|
505
606
|
});
|
|
506
607
|
if (s)
|
|
507
608
|
return s;
|
|
508
|
-
await this.withCache((
|
|
609
|
+
await this.withCache((o) => o.delete(this.endpoint));
|
|
509
610
|
}
|
|
510
611
|
const r = await fetch(this.endpoint, { method: "get" });
|
|
511
612
|
if (!r.ok)
|
|
512
613
|
throw new Error(`CSRF token request failed with status ${r.status}`);
|
|
513
|
-
const n = await
|
|
614
|
+
const n = await F(r);
|
|
514
615
|
if (!n)
|
|
515
616
|
throw new Error("CSRF token response did not contain a token");
|
|
516
617
|
return await this.withCache((s) => s.put(this.endpoint, r)), n;
|
|
@@ -529,36 +630,36 @@ class Fe {
|
|
|
529
630
|
return;
|
|
530
631
|
}
|
|
531
632
|
}
|
|
532
|
-
async function
|
|
633
|
+
async function F(t) {
|
|
533
634
|
const e = await t.clone().json();
|
|
534
635
|
if (typeof e != "object" || e === null || !("csrfToken" in e))
|
|
535
636
|
return;
|
|
536
637
|
const { csrfToken: r } = e;
|
|
537
638
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
538
639
|
}
|
|
539
|
-
const
|
|
540
|
-
function
|
|
640
|
+
const K = /* @__PURE__ */ new Map();
|
|
641
|
+
function dt(t) {
|
|
541
642
|
const { endpoint: e, cacheName: r, ...n } = t.csrf;
|
|
542
|
-
let s =
|
|
543
|
-
return s || (s = new
|
|
643
|
+
let s = K.get(e);
|
|
644
|
+
return s || (s = new ht(e, r), K.set(e, s)), J(
|
|
544
645
|
{
|
|
545
|
-
retry:
|
|
546
|
-
request: [
|
|
646
|
+
retry: it(s, n),
|
|
647
|
+
request: [nt, Ye]
|
|
547
648
|
},
|
|
548
|
-
|
|
649
|
+
de(new ut(s)).service
|
|
549
650
|
).service;
|
|
550
651
|
}
|
|
551
|
-
const
|
|
552
|
-
function
|
|
553
|
-
let e =
|
|
652
|
+
const j = /* @__PURE__ */ new Map();
|
|
653
|
+
function pt(t) {
|
|
654
|
+
let e = j.get(t);
|
|
554
655
|
if (!e) {
|
|
555
|
-
const r =
|
|
556
|
-
e = { cache: r, cacheController: s, pubSub:
|
|
656
|
+
const r = pe().service, n = fe(r).service, s = le(r, n).service, o = ye().service;
|
|
657
|
+
e = { cache: r, cacheController: s, pubSub: o }, j.set(t, e);
|
|
557
658
|
}
|
|
558
659
|
return e;
|
|
559
660
|
}
|
|
560
|
-
function
|
|
561
|
-
const r =
|
|
661
|
+
function lt(t, e) {
|
|
662
|
+
const r = pt(t);
|
|
562
663
|
return {
|
|
563
664
|
shared: r,
|
|
564
665
|
services: {
|
|
@@ -568,8 +669,8 @@ function Ke(t, e) {
|
|
|
568
669
|
}
|
|
569
670
|
};
|
|
570
671
|
}
|
|
571
|
-
const
|
|
572
|
-
function
|
|
672
|
+
const H = 300;
|
|
673
|
+
function ft(t, e) {
|
|
573
674
|
try {
|
|
574
675
|
return JSON.parse(JSON.stringify(t));
|
|
575
676
|
} catch (r) {
|
|
@@ -579,19 +680,19 @@ function ze(t, e) {
|
|
|
579
680
|
throw s.cause = r, s;
|
|
580
681
|
}
|
|
581
682
|
}
|
|
582
|
-
function
|
|
683
|
+
function yt(t) {
|
|
583
684
|
if (typeof t == "object" && t.type === "max-age") {
|
|
584
685
|
const e = t.maxAge;
|
|
585
|
-
return Number.isFinite(e) && e >= 0 ? e :
|
|
686
|
+
return Number.isFinite(e) && e >= 0 ? e : H;
|
|
586
687
|
}
|
|
587
|
-
return
|
|
688
|
+
return H;
|
|
588
689
|
}
|
|
589
|
-
class
|
|
690
|
+
class mt extends me {
|
|
590
691
|
constructor(e, r, n) {
|
|
591
|
-
super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables =
|
|
692
|
+
super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = ft(
|
|
592
693
|
e.variables ?? {},
|
|
593
694
|
this.normalizedOperationName
|
|
594
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge =
|
|
695
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = yt(e.cacheControl), this.headers = e.headers, this.headersKey = Oe(e.headers);
|
|
595
696
|
}
|
|
596
697
|
url;
|
|
597
698
|
query;
|
|
@@ -606,7 +707,7 @@ class We extends he {
|
|
|
606
707
|
this.url,
|
|
607
708
|
{
|
|
608
709
|
method: "POST",
|
|
609
|
-
headers:
|
|
710
|
+
headers: X(this.headers),
|
|
610
711
|
body: JSON.stringify({
|
|
611
712
|
query: this.query,
|
|
612
713
|
variables: this.normalizedVariables,
|
|
@@ -621,7 +722,7 @@ class We extends he {
|
|
|
621
722
|
variables: this.normalizedVariables,
|
|
622
723
|
operationName: this.normalizedOperationName
|
|
623
724
|
};
|
|
624
|
-
return this.headersKey !== void 0 && (e.headers = this.headersKey),
|
|
725
|
+
return this.headersKey !== void 0 && (e.headers = this.headersKey), ae(e);
|
|
625
726
|
}
|
|
626
727
|
/**
|
|
627
728
|
* Reads the cached result for this command, or returns an error.
|
|
@@ -639,9 +740,9 @@ class We extends he {
|
|
|
639
740
|
*/
|
|
640
741
|
readFromCache(e) {
|
|
641
742
|
const r = this.buildKey(), n = e.get(r)?.value;
|
|
642
|
-
return n === void 0 ?
|
|
643
|
-
|
|
644
|
-
) :
|
|
743
|
+
return n === void 0 ? l(
|
|
744
|
+
k(new ie("No cached entry found for this query."))
|
|
745
|
+
) : l(O(n));
|
|
645
746
|
}
|
|
646
747
|
writeToCache(e, r) {
|
|
647
748
|
if (r.isOk() && r.value.data != null && Object.keys(r.value.data).length > 0) {
|
|
@@ -657,7 +758,7 @@ class We extends he {
|
|
|
657
758
|
}
|
|
658
759
|
});
|
|
659
760
|
}
|
|
660
|
-
return
|
|
761
|
+
return l(void 0);
|
|
661
762
|
}
|
|
662
763
|
get cacheControlStrategyConfig() {
|
|
663
764
|
const e = Math.floor(Date.now() / 1e3);
|
|
@@ -671,112 +772,112 @@ class We extends he {
|
|
|
671
772
|
return e.errors && e.errors.length > 0;
|
|
672
773
|
}
|
|
673
774
|
processFetchReturnValue(e) {
|
|
674
|
-
return this.responseHasErrors(e) ?
|
|
775
|
+
return this.responseHasErrors(e) ? k(new ce(e)) : O(e);
|
|
675
776
|
}
|
|
676
777
|
}
|
|
677
|
-
const
|
|
678
|
-
function
|
|
778
|
+
const bt = "CACHE_MISS";
|
|
779
|
+
function gt() {
|
|
679
780
|
return [
|
|
680
781
|
{
|
|
681
782
|
message: "No cached entry found for this query (cacheControl: 'only-if-cached').",
|
|
682
|
-
extensions: { code:
|
|
783
|
+
extensions: { code: bt }
|
|
683
784
|
}
|
|
684
785
|
];
|
|
685
786
|
}
|
|
686
|
-
function
|
|
687
|
-
if (
|
|
787
|
+
function ee(t) {
|
|
788
|
+
if (ue(t) && t.data && typeof t.data == "object") {
|
|
688
789
|
const e = t.data;
|
|
689
790
|
if (e.data != null)
|
|
690
791
|
return e.data;
|
|
691
792
|
}
|
|
692
793
|
}
|
|
693
|
-
function
|
|
794
|
+
function wt(t) {
|
|
694
795
|
return (e) => {
|
|
695
796
|
if (e.isOk()) {
|
|
696
797
|
const r = e.value;
|
|
697
|
-
|
|
798
|
+
S(r), t({ data: r, errors: void 0 });
|
|
698
799
|
} else {
|
|
699
|
-
const r =
|
|
700
|
-
r &&
|
|
800
|
+
const r = ee(e.error);
|
|
801
|
+
r && S(r), t({ data: r, errors: m(e.error) });
|
|
701
802
|
}
|
|
702
803
|
};
|
|
703
804
|
}
|
|
704
|
-
async function
|
|
805
|
+
async function Et(t, e = !1) {
|
|
705
806
|
let r, n, s;
|
|
706
807
|
try {
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
-
} catch (
|
|
710
|
-
n =
|
|
808
|
+
const o = await t.execute();
|
|
809
|
+
o.isOk() ? (r = o.value.data, S(r), s = (a) => o.value.subscribe(a)) : (r = ee(o.error.failure), r && S(r), n = e && r === void 0 ? gt() : m(o.error.failure), s = (a) => o.error.subscribe(a));
|
|
810
|
+
} catch (o) {
|
|
811
|
+
n = m(o);
|
|
711
812
|
}
|
|
712
813
|
return {
|
|
713
814
|
data: r,
|
|
714
815
|
errors: n,
|
|
715
|
-
subscribe(
|
|
716
|
-
return s ? s(
|
|
816
|
+
subscribe(o) {
|
|
817
|
+
return s ? s(wt(o)) : D;
|
|
717
818
|
},
|
|
718
819
|
async refresh() {
|
|
719
820
|
await t.refresh();
|
|
720
821
|
}
|
|
721
822
|
};
|
|
722
823
|
}
|
|
723
|
-
function
|
|
824
|
+
function _(t) {
|
|
724
825
|
return {
|
|
725
826
|
data: void 0,
|
|
726
827
|
errors: t,
|
|
727
|
-
subscribe: () =>
|
|
728
|
-
refresh:
|
|
828
|
+
subscribe: () => D,
|
|
829
|
+
refresh: T
|
|
729
830
|
};
|
|
730
831
|
}
|
|
731
|
-
function
|
|
832
|
+
function St({
|
|
732
833
|
bundle: t,
|
|
733
834
|
url: e,
|
|
734
835
|
executeRaw: r,
|
|
735
836
|
resolveEffectiveHeaders: n
|
|
736
837
|
}) {
|
|
737
838
|
const { services: s } = t;
|
|
738
|
-
async function
|
|
739
|
-
query:
|
|
839
|
+
async function o({
|
|
840
|
+
query: a,
|
|
740
841
|
variables: i,
|
|
741
842
|
operationName: c,
|
|
742
843
|
cacheControl: h,
|
|
743
844
|
headers: u
|
|
744
845
|
}) {
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
const p =
|
|
846
|
+
const d = P(a);
|
|
847
|
+
if (d.isErr()) return _(d.error);
|
|
848
|
+
const p = d.value, f = $(p, c);
|
|
748
849
|
if (f !== "query")
|
|
749
|
-
return
|
|
850
|
+
return _([
|
|
750
851
|
{
|
|
751
852
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
752
853
|
}
|
|
753
854
|
]);
|
|
754
|
-
let
|
|
855
|
+
let E;
|
|
755
856
|
try {
|
|
756
|
-
const
|
|
757
|
-
|
|
857
|
+
const C = n ? n(u) : u;
|
|
858
|
+
E = new mt(
|
|
758
859
|
{
|
|
759
|
-
query:
|
|
860
|
+
query: N(p),
|
|
760
861
|
variables: i,
|
|
761
862
|
operationName: c,
|
|
762
863
|
cacheControl: h,
|
|
763
|
-
headers:
|
|
864
|
+
headers: C
|
|
764
865
|
},
|
|
765
866
|
s,
|
|
766
867
|
e
|
|
767
868
|
);
|
|
768
|
-
} catch (
|
|
769
|
-
return
|
|
869
|
+
} catch (C) {
|
|
870
|
+
return _(m(C));
|
|
770
871
|
}
|
|
771
|
-
return
|
|
872
|
+
return Et(E, h === "only-if-cached");
|
|
772
873
|
}
|
|
773
874
|
return {
|
|
774
|
-
query:
|
|
775
|
-
mutate: (
|
|
875
|
+
query: o,
|
|
876
|
+
mutate: (a) => W(r, a)
|
|
776
877
|
};
|
|
777
878
|
}
|
|
778
|
-
const
|
|
779
|
-
class
|
|
879
|
+
const vt = 1, Dt = `@salesforce/platform-sdk-data_v${vt}`;
|
|
880
|
+
class z {
|
|
780
881
|
baseUrl;
|
|
781
882
|
pathData;
|
|
782
883
|
clientFetch;
|
|
@@ -784,23 +885,23 @@ class F {
|
|
|
784
885
|
apiVersion;
|
|
785
886
|
graphql;
|
|
786
887
|
constructor(e) {
|
|
787
|
-
const r =
|
|
788
|
-
this.baseUrl =
|
|
888
|
+
const r = At();
|
|
889
|
+
this.baseUrl = Ct(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? A, this.pathData = x(this.apiVersion);
|
|
789
890
|
const n = `${this.pathData}/ui-api`, s = `${this.pathData}/graphql`;
|
|
790
|
-
this.onStatus = e?.onStatus ?? {}, this.clientFetch =
|
|
891
|
+
this.onStatus = e?.onStatus ?? {}, this.clientFetch = dt({
|
|
791
892
|
csrf: {
|
|
792
893
|
endpoint: `${this.baseUrl}${n}/session/csrf`,
|
|
793
|
-
cacheName:
|
|
894
|
+
cacheName: Dt,
|
|
794
895
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
795
896
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
796
897
|
}
|
|
797
898
|
});
|
|
798
|
-
const
|
|
799
|
-
this.graphql =
|
|
800
|
-
bundle:
|
|
899
|
+
const o = (i, c) => this.fetch(i, c), a = lt(`${this.baseUrl}${this.pathData}`, o);
|
|
900
|
+
this.graphql = St({
|
|
901
|
+
bundle: a,
|
|
801
902
|
url: s,
|
|
802
903
|
executeRaw: this.executeRawGraphQL.bind(this),
|
|
803
|
-
resolveEffectiveHeaders:
|
|
904
|
+
resolveEffectiveHeaders: Xe
|
|
804
905
|
});
|
|
805
906
|
}
|
|
806
907
|
async fetch(e, r) {
|
|
@@ -821,12 +922,12 @@ class F {
|
|
|
821
922
|
operationName: n,
|
|
822
923
|
headers: s
|
|
823
924
|
}) {
|
|
824
|
-
const
|
|
925
|
+
const o = `${this.pathData}/graphql`, a = await this.fetch(o, {
|
|
825
926
|
method: "POST",
|
|
826
927
|
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
827
|
-
headers:
|
|
928
|
+
headers: X(s)
|
|
828
929
|
});
|
|
829
|
-
return
|
|
930
|
+
return Y(a, "WebApp", o);
|
|
830
931
|
}
|
|
831
932
|
/**
|
|
832
933
|
* Converts a relative URL to an absolute Salesforce URL.
|
|
@@ -845,52 +946,52 @@ class F {
|
|
|
845
946
|
return e;
|
|
846
947
|
}
|
|
847
948
|
}
|
|
848
|
-
function
|
|
949
|
+
function At() {
|
|
849
950
|
return {
|
|
850
951
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
851
952
|
};
|
|
852
953
|
}
|
|
853
|
-
function
|
|
954
|
+
function Ct(t) {
|
|
854
955
|
if (!t || t === "/") return "";
|
|
855
956
|
let e = t;
|
|
856
957
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
857
958
|
}
|
|
858
|
-
function
|
|
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,
|
|
959
|
+
function _t(t) {
|
|
960
|
+
const e = t, r = typeof e == "object" && e !== null ? e : void 0, n = r !== void 0 && "setup" in r, s = n ? r : r?.extension, o = n ? s?.name : r?.as;
|
|
860
961
|
if (typeof s?.setup != "function")
|
|
861
962
|
throw new Error("Extension entry cannot attach: it is missing a setup function.");
|
|
862
|
-
if (typeof
|
|
963
|
+
if (typeof o != "string" || o.length === 0)
|
|
863
964
|
throw new Error(
|
|
864
965
|
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
966
|
);
|
|
866
967
|
return {
|
|
867
968
|
extension: s,
|
|
868
|
-
mountName:
|
|
869
|
-
label:
|
|
969
|
+
mountName: o,
|
|
970
|
+
label: o === s.name ? `"${s.name}"` : `"${s.name}" (aliased as "${o}")`
|
|
870
971
|
};
|
|
871
972
|
}
|
|
872
|
-
async function
|
|
973
|
+
async function Ot(t, e, r) {
|
|
873
974
|
if (e.length === 0)
|
|
874
975
|
return t;
|
|
875
976
|
if ("ext" in t)
|
|
876
977
|
throw new Error(
|
|
877
978
|
'Cannot attach extensions: the base SDK already declares an "ext" member, which the extension container reserves.'
|
|
878
979
|
);
|
|
879
|
-
const n = e.map(
|
|
980
|
+
const n = e.map(_t);
|
|
880
981
|
r?.preflight?.(n, t);
|
|
881
|
-
const s = Object.create(t),
|
|
982
|
+
const s = Object.create(t), o = /* @__PURE__ */ Object.create(null), a = (h) => {
|
|
882
983
|
throw new Error(`Cannot write "ext.${String(h)}" — ext is immutable once attached.`);
|
|
883
984
|
}, i = (h) => {
|
|
884
985
|
throw new Error(`Cannot ${h} "ext" — ext is immutable once attached.`);
|
|
885
|
-
}, c = new Proxy(
|
|
986
|
+
}, c = new Proxy(o, {
|
|
886
987
|
set(h, u) {
|
|
887
|
-
return
|
|
988
|
+
return a(u);
|
|
888
989
|
},
|
|
889
990
|
defineProperty(h, u) {
|
|
890
|
-
return
|
|
991
|
+
return a(u);
|
|
891
992
|
},
|
|
892
993
|
deleteProperty(h, u) {
|
|
893
|
-
return
|
|
994
|
+
return a(u);
|
|
894
995
|
},
|
|
895
996
|
// Without these two traps, `preventExtensions` and `setPrototypeOf`
|
|
896
997
|
// fall through to the real `store`, because no per-property trap
|
|
@@ -910,52 +1011,50 @@ async function ot(t, e, r) {
|
|
|
910
1011
|
writable: !1,
|
|
911
1012
|
configurable: !1
|
|
912
1013
|
});
|
|
913
|
-
for (const { extension: h, mountName: u, label:
|
|
914
|
-
if (Object.hasOwn(
|
|
1014
|
+
for (const { extension: h, mountName: u, label: d } of n) {
|
|
1015
|
+
if (Object.hasOwn(o, u))
|
|
915
1016
|
throw new Error(
|
|
916
|
-
`Extension ${
|
|
1017
|
+
`Extension ${d} cannot attach: "${u}" is already defined by another extension.`
|
|
917
1018
|
);
|
|
918
1019
|
let p;
|
|
919
1020
|
try {
|
|
920
1021
|
p = await h.setup(s);
|
|
921
1022
|
} catch (f) {
|
|
922
|
-
throw new Error(`Extension ${
|
|
1023
|
+
throw new Error(`Extension ${d} failed during setup.`, { cause: f });
|
|
923
1024
|
}
|
|
924
|
-
Object.defineProperty(
|
|
1025
|
+
Object.defineProperty(o, u, {
|
|
925
1026
|
value: p,
|
|
926
1027
|
enumerable: !0,
|
|
927
1028
|
writable: !1,
|
|
928
1029
|
configurable: !1
|
|
929
1030
|
});
|
|
930
1031
|
}
|
|
931
|
-
return Object.freeze(
|
|
1032
|
+
return Object.freeze(o), s;
|
|
932
1033
|
}
|
|
933
|
-
function
|
|
1034
|
+
function Gt(t, ...e) {
|
|
934
1035
|
let r = t[0] ?? "";
|
|
935
1036
|
for (let n = 0; n < e.length; n += 1)
|
|
936
1037
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
937
1038
|
return r;
|
|
938
1039
|
}
|
|
939
|
-
function
|
|
1040
|
+
function Ut(t) {
|
|
940
1041
|
return t;
|
|
941
1042
|
}
|
|
942
|
-
async function
|
|
1043
|
+
async function kt(t) {
|
|
943
1044
|
try {
|
|
944
|
-
switch (await
|
|
945
|
-
case
|
|
946
|
-
return new
|
|
947
|
-
case
|
|
948
|
-
return new
|
|
949
|
-
case
|
|
1045
|
+
switch (await re(t?.surface)) {
|
|
1046
|
+
case y.OpenAI:
|
|
1047
|
+
return new Re();
|
|
1048
|
+
case y.WebApp:
|
|
1049
|
+
return new z(t?.webapp);
|
|
1050
|
+
case y.MicroFrontend: {
|
|
950
1051
|
const r = globalThis.SFDC_ENV;
|
|
951
|
-
return typeof r == "object" && r !== null ? new
|
|
1052
|
+
return typeof r == "object" && r !== null ? new z(t?.webapp) : {};
|
|
952
1053
|
}
|
|
953
|
-
case
|
|
954
|
-
return new
|
|
955
|
-
case
|
|
956
|
-
return new
|
|
957
|
-
case m.MCPApps:
|
|
958
|
-
return new L(await _.getInstance(), t?.mcpApps);
|
|
1054
|
+
case y.Mosaic:
|
|
1055
|
+
return new $e(t?.mosaic);
|
|
1056
|
+
case y.MCPApps:
|
|
1057
|
+
return new Se(await ne.getInstance(), t?.mcpApps);
|
|
959
1058
|
default:
|
|
960
1059
|
return {};
|
|
961
1060
|
}
|
|
@@ -963,19 +1062,19 @@ async function it(t) {
|
|
|
963
1062
|
return {};
|
|
964
1063
|
}
|
|
965
1064
|
}
|
|
966
|
-
function
|
|
967
|
-
return
|
|
1065
|
+
function Qt(t) {
|
|
1066
|
+
return se(
|
|
968
1067
|
(async () => {
|
|
969
|
-
const e = await
|
|
970
|
-
|
|
971
|
-
preflight: pe
|
|
1068
|
+
const e = await kt(t), r = await Ot(e, t?.extensions ?? [], {
|
|
1069
|
+
preflight: ge
|
|
972
1070
|
});
|
|
1071
|
+
return Be(), r;
|
|
973
1072
|
})(),
|
|
974
1073
|
"createDataSDK"
|
|
975
1074
|
);
|
|
976
1075
|
}
|
|
977
1076
|
export {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1077
|
+
Qt as createDataSDK,
|
|
1078
|
+
Ut as defineDataExtension,
|
|
1079
|
+
Gt as gql
|
|
981
1080
|
};
|