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