@salesforce/platform-sdk 11.71.4 → 12.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/dist/core/data.d.ts +7 -0
- package/dist/core/data.d.ts.map +1 -1
- package/dist/core/extension-attach.d.ts +12 -5
- package/dist/core/extension-attach.d.ts.map +1 -1
- package/dist/core/extension-types.d.ts +26 -12
- package/dist/core/extension-types.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -9
- package/dist/data/extensions/api-version.d.ts +11 -0
- package/dist/data/extensions/api-version.d.ts.map +1 -0
- package/dist/data/extensions/index.js +5 -4
- package/dist/data/extensions/labels/index.d.ts +2 -3
- package/dist/data/extensions/labels/index.d.ts.map +1 -1
- package/dist/data/index.d.ts +19 -6
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +250 -214
- package/dist/data/mosaic/index.d.ts +1 -0
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/dist/data/webapp/index.d.ts +1 -0
- package/dist/data/webapp/index.d.ts.map +1 -1
- package/dist/index.js +36 -38
- package/docs/data/04-surfaces-and-guards.md +15 -4
- package/package.json +2 -2
- package/dist/core/extension-factory.d.ts +0 -42
- package/dist/core/extension-factory.d.ts.map +0 -1
- package/dist/extension-factory-CJkfM4km.js +0 -8
package/dist/data/index.js
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { buildServiceDescriptor as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
function
|
|
1
|
+
import { g as Q, S as y } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { w as j } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { buildServiceDescriptor as M, setHeader as b } from "@conduit-client/service-fetch-network/v1";
|
|
4
|
+
import { resolvedPromiseLike as l, ok as x, err as D, stableJSONStringify as K, DataNotFoundError as z, UserVisibleError as J, deepFreeze as w, isUserVisibleError as W } from "@conduit-client/utils";
|
|
5
|
+
import { print as N, parse as B } from "@conduit-client/onestore-graphql-parser/v1";
|
|
6
|
+
import { RetryPolicy as X, buildServiceDescriptor as Y } from "@conduit-client/service-retry/v1";
|
|
7
|
+
import { buildServiceDescriptor as Z } from "@conduit-client/service-cache/v1";
|
|
8
|
+
import { buildServiceDescriptor as ee } from "@conduit-client/service-cache-control/v1";
|
|
9
|
+
import { buildInMemoryCacheInclusionPolicyService as te } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
10
|
+
import { buildServiceDescriptor as re } from "@conduit-client/service-pubsub/v1";
|
|
11
|
+
import { HttpCacheControlCommand as ne } from "@conduit-client/command-http-cache-control/v1";
|
|
12
|
+
const v = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
13
|
+
function se(t, e) {
|
|
14
|
+
const [, r, n] = v.exec(t), [, s, a] = v.exec(e);
|
|
15
|
+
return Number(r) - Number(s) || Number(n) - Number(a);
|
|
16
|
+
}
|
|
17
|
+
function ae(t, e) {
|
|
18
|
+
for (const r of t) {
|
|
19
|
+
const n = r.extension, { label: s } = r, a = n.minApiVersion;
|
|
20
|
+
if (a !== void 0) {
|
|
21
|
+
if (typeof a != "string" || !v.test(a))
|
|
22
|
+
throw new TypeError(
|
|
23
|
+
`Extension ${s} declares invalid minApiVersion ${JSON.stringify(a)}; expected a Salesforce API version such as "64.0".`
|
|
24
|
+
);
|
|
25
|
+
if (e.apiVersion !== void 0) {
|
|
26
|
+
if (!v.test(e.apiVersion))
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
|
|
29
|
+
);
|
|
30
|
+
if (se(e.apiVersion, a) < 0)
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK uses version ${e.apiVersion}.`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function oe(t) {
|
|
14
39
|
return (e) => {
|
|
15
40
|
const [r, n] = e;
|
|
16
41
|
if (typeof r == "string" && !r.startsWith("http")) {
|
|
@@ -20,63 +45,63 @@ function ne(t) {
|
|
|
20
45
|
return l(e);
|
|
21
46
|
};
|
|
22
47
|
}
|
|
23
|
-
function
|
|
48
|
+
function ie(t) {
|
|
24
49
|
return (e) => l(b("Authorization", `Bearer ${t}`, e));
|
|
25
50
|
}
|
|
26
|
-
function
|
|
51
|
+
function ce(t, e) {
|
|
27
52
|
const r = [];
|
|
28
|
-
return t && r.push(
|
|
53
|
+
return t && r.push(oe(t)), e && r.push(ie(e)), M({
|
|
29
54
|
request: r
|
|
30
55
|
}).service;
|
|
31
56
|
}
|
|
32
|
-
const
|
|
57
|
+
const ue = {
|
|
33
58
|
"Content-Type": "application/json",
|
|
34
59
|
Accept: "application/json",
|
|
35
60
|
"X-Chatter-Entity-Encoding": "false"
|
|
36
61
|
};
|
|
37
|
-
function
|
|
62
|
+
function he(t) {
|
|
38
63
|
if (t instanceof Headers) {
|
|
39
64
|
const e = [];
|
|
40
65
|
return t.forEach((r, n) => e.push([n, r])), e;
|
|
41
66
|
}
|
|
42
67
|
return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
|
|
43
68
|
}
|
|
44
|
-
function
|
|
69
|
+
function V(t, e) {
|
|
45
70
|
if (e === void 0) return { ...t };
|
|
46
71
|
const r = { ...t }, n = /* @__PURE__ */ new Map();
|
|
47
72
|
for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
|
|
48
73
|
const s = /* @__PURE__ */ new Set();
|
|
49
|
-
for (const [a,
|
|
50
|
-
const
|
|
51
|
-
|
|
74
|
+
for (const [a, o] of he(e)) {
|
|
75
|
+
const i = a.toLowerCase(), c = n.get(i);
|
|
76
|
+
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));
|
|
52
77
|
}
|
|
53
78
|
return r;
|
|
54
79
|
}
|
|
55
80
|
function L(t) {
|
|
56
|
-
return
|
|
81
|
+
return V(ue, t);
|
|
57
82
|
}
|
|
58
|
-
function
|
|
83
|
+
function le(t) {
|
|
59
84
|
if (t === void 0) return;
|
|
60
85
|
const e = {};
|
|
61
86
|
return new Headers(t).forEach((r, n) => {
|
|
62
87
|
e[n] = r;
|
|
63
88
|
}), Object.keys(e).length > 0 ? e : void 0;
|
|
64
89
|
}
|
|
65
|
-
const
|
|
66
|
-
function
|
|
90
|
+
const pe = 512;
|
|
91
|
+
function de(t) {
|
|
67
92
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
68
93
|
}
|
|
69
94
|
class P extends Error {
|
|
70
95
|
status;
|
|
71
96
|
url;
|
|
72
97
|
constructor(e) {
|
|
73
|
-
const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(
|
|
98
|
+
const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(de(e.body.slice(0, pe)))})`;
|
|
74
99
|
super(
|
|
75
100
|
`${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.`
|
|
76
101
|
), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
|
|
77
102
|
}
|
|
78
103
|
}
|
|
79
|
-
async function
|
|
104
|
+
async function I(t, e, r) {
|
|
80
105
|
const n = await t.text();
|
|
81
106
|
let s;
|
|
82
107
|
try {
|
|
@@ -94,23 +119,23 @@ async function M(t, e, r) {
|
|
|
94
119
|
});
|
|
95
120
|
return s;
|
|
96
121
|
}
|
|
97
|
-
const
|
|
122
|
+
const g = () => {
|
|
98
123
|
}, O = async () => {
|
|
99
124
|
};
|
|
100
|
-
function
|
|
125
|
+
function $(t) {
|
|
101
126
|
try {
|
|
102
|
-
return
|
|
127
|
+
return x(B(t));
|
|
103
128
|
} catch (e) {
|
|
104
|
-
return D(
|
|
129
|
+
return D(m(e));
|
|
105
130
|
}
|
|
106
131
|
}
|
|
107
|
-
function
|
|
132
|
+
function q(t, e) {
|
|
108
133
|
const r = t.definitions.filter(
|
|
109
134
|
(n) => n.kind === "OperationDefinition"
|
|
110
135
|
);
|
|
111
136
|
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";
|
|
112
137
|
}
|
|
113
|
-
function
|
|
138
|
+
function m(t) {
|
|
114
139
|
if (t && typeof t == "object" && "data" in t) {
|
|
115
140
|
const e = t.data;
|
|
116
141
|
if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
|
|
@@ -118,64 +143,64 @@ function y(t) {
|
|
|
118
143
|
}
|
|
119
144
|
return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
|
|
120
145
|
}
|
|
121
|
-
async function
|
|
122
|
-
const a =
|
|
146
|
+
async function G(t, { mutation: e, variables: r, operationName: n, headers: s }) {
|
|
147
|
+
const a = $(e);
|
|
123
148
|
if (a.isErr()) return { data: void 0, errors: a.error };
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
149
|
+
const o = a.value, i = q(o, n);
|
|
150
|
+
if (i !== "mutation")
|
|
126
151
|
return {
|
|
127
152
|
data: void 0,
|
|
128
153
|
errors: [
|
|
129
154
|
{
|
|
130
|
-
message: `DataSDK.graphql.mutate() requires a GraphQL mutation, received ${
|
|
155
|
+
message: `DataSDK.graphql.mutate() requires a GraphQL mutation, received ${i}.`
|
|
131
156
|
}
|
|
132
157
|
]
|
|
133
158
|
};
|
|
134
159
|
try {
|
|
135
|
-
const
|
|
136
|
-
query:
|
|
160
|
+
const c = await t({
|
|
161
|
+
query: N(o),
|
|
137
162
|
variables: r,
|
|
138
163
|
operationName: n,
|
|
139
164
|
headers: s
|
|
140
165
|
});
|
|
141
166
|
return {
|
|
142
|
-
data:
|
|
143
|
-
errors:
|
|
167
|
+
data: c.data ?? void 0,
|
|
168
|
+
errors: c.errors
|
|
144
169
|
};
|
|
145
|
-
} catch (
|
|
146
|
-
return { data: void 0, errors:
|
|
170
|
+
} catch (c) {
|
|
171
|
+
return { data: void 0, errors: m(c) };
|
|
147
172
|
}
|
|
148
173
|
}
|
|
149
|
-
function
|
|
150
|
-
function e(n, s, a,
|
|
174
|
+
function H(t) {
|
|
175
|
+
function e(n, s, a, o) {
|
|
151
176
|
return t({
|
|
152
|
-
query:
|
|
177
|
+
query: N(n),
|
|
153
178
|
variables: s,
|
|
154
179
|
operationName: a,
|
|
155
|
-
headers:
|
|
180
|
+
headers: o
|
|
156
181
|
}).then(
|
|
157
|
-
(
|
|
158
|
-
data:
|
|
159
|
-
errors:
|
|
182
|
+
(i) => ({
|
|
183
|
+
data: i.data ?? void 0,
|
|
184
|
+
errors: i.errors
|
|
160
185
|
}),
|
|
161
|
-
(
|
|
186
|
+
(i) => ({ data: void 0, errors: m(i) })
|
|
162
187
|
);
|
|
163
188
|
}
|
|
164
189
|
async function r({
|
|
165
190
|
query: n,
|
|
166
191
|
variables: s,
|
|
167
192
|
operationName: a,
|
|
168
|
-
headers:
|
|
193
|
+
headers: o
|
|
169
194
|
}) {
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
195
|
+
const i = $(n);
|
|
196
|
+
if (i.isErr())
|
|
172
197
|
return {
|
|
173
198
|
data: void 0,
|
|
174
|
-
errors:
|
|
175
|
-
subscribe: () =>
|
|
199
|
+
errors: i.error,
|
|
200
|
+
subscribe: () => g,
|
|
176
201
|
refresh: O
|
|
177
202
|
};
|
|
178
|
-
const
|
|
203
|
+
const c = i.value, h = q(c, a);
|
|
179
204
|
if (h !== "query")
|
|
180
205
|
return {
|
|
181
206
|
data: void 0,
|
|
@@ -184,44 +209,45 @@ function G(t) {
|
|
|
184
209
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${h}.`
|
|
185
210
|
}
|
|
186
211
|
],
|
|
187
|
-
subscribe: () =>
|
|
212
|
+
subscribe: () => g,
|
|
188
213
|
refresh: O
|
|
189
214
|
};
|
|
190
|
-
const u = /* @__PURE__ */ new Set(), d = s,
|
|
215
|
+
const u = /* @__PURE__ */ new Set(), d = s, f = await e(c, d, a, o);
|
|
191
216
|
return {
|
|
192
|
-
data:
|
|
193
|
-
errors:
|
|
194
|
-
subscribe(
|
|
195
|
-
return u.add(
|
|
196
|
-
u.delete(
|
|
217
|
+
data: f.data,
|
|
218
|
+
errors: f.errors,
|
|
219
|
+
subscribe(p) {
|
|
220
|
+
return u.add(p), () => {
|
|
221
|
+
u.delete(p);
|
|
197
222
|
};
|
|
198
223
|
},
|
|
199
224
|
async refresh() {
|
|
200
|
-
const
|
|
201
|
-
for (const
|
|
225
|
+
const p = await e(c, d, a, o);
|
|
226
|
+
for (const E of u) E(p);
|
|
202
227
|
}
|
|
203
228
|
};
|
|
204
229
|
}
|
|
205
230
|
return {
|
|
206
231
|
query: r,
|
|
207
|
-
mutate: (n) =>
|
|
232
|
+
mutate: (n) => G(t, n)
|
|
208
233
|
};
|
|
209
234
|
}
|
|
210
|
-
const
|
|
211
|
-
function
|
|
235
|
+
const A = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
236
|
+
function U(t = A) {
|
|
212
237
|
return `/services/data/v${t}`;
|
|
213
238
|
}
|
|
214
|
-
const
|
|
239
|
+
const fe = {
|
|
215
240
|
"Content-Type": "application/json",
|
|
216
241
|
Accept: "application/json"
|
|
217
242
|
};
|
|
218
|
-
class
|
|
243
|
+
class me {
|
|
219
244
|
clientFetch;
|
|
220
245
|
pathData;
|
|
246
|
+
apiVersion;
|
|
221
247
|
graphql;
|
|
222
248
|
constructor(e) {
|
|
223
|
-
const r =
|
|
224
|
-
this.
|
|
249
|
+
const r = ye(), n = be(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
|
|
250
|
+
this.apiVersion = e?.apiVersion ?? r.apiVersion ?? A, this.pathData = U(this.apiVersion), this.clientFetch = ce(n || void 0, s), this.graphql = H(this.executeRawGraphQL.bind(this));
|
|
225
251
|
}
|
|
226
252
|
async executeRawGraphQL({
|
|
227
253
|
query: e,
|
|
@@ -229,15 +255,15 @@ class pe {
|
|
|
229
255
|
operationName: n,
|
|
230
256
|
headers: s
|
|
231
257
|
}) {
|
|
232
|
-
const a = `${this.pathData}/graphql`,
|
|
258
|
+
const a = `${this.pathData}/graphql`, o = await this.clientFetch(a, {
|
|
233
259
|
method: "POST",
|
|
234
260
|
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
235
|
-
headers:
|
|
261
|
+
headers: V(fe, s)
|
|
236
262
|
});
|
|
237
|
-
return
|
|
263
|
+
return I(o, "Mosaic", a);
|
|
238
264
|
}
|
|
239
265
|
}
|
|
240
|
-
function
|
|
266
|
+
function ye() {
|
|
241
267
|
const t = globalThis.MOSAIC_ENV;
|
|
242
268
|
return {
|
|
243
269
|
instanceUrl: t?.instanceUrl,
|
|
@@ -245,16 +271,16 @@ function fe() {
|
|
|
245
271
|
apiVersion: t?.apiVersion
|
|
246
272
|
};
|
|
247
273
|
}
|
|
248
|
-
function
|
|
274
|
+
function be(t) {
|
|
249
275
|
if (!t || t === "/") return "";
|
|
250
276
|
let e = t;
|
|
251
277
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
252
278
|
}
|
|
253
|
-
const
|
|
254
|
-
class
|
|
279
|
+
const we = "graphqlQuery";
|
|
280
|
+
class ve {
|
|
255
281
|
graphql;
|
|
256
282
|
constructor() {
|
|
257
|
-
this.graphql =
|
|
283
|
+
this.graphql = H(this.executeRawGraphQL.bind(this));
|
|
258
284
|
}
|
|
259
285
|
/**
|
|
260
286
|
* The `headers` request option is intentionally not forwarded: this surface
|
|
@@ -266,35 +292,35 @@ class be {
|
|
|
266
292
|
variables: r,
|
|
267
293
|
operationName: n
|
|
268
294
|
}) {
|
|
269
|
-
return (await window.openai.callTool(
|
|
295
|
+
return (await window.openai.callTool(we, {
|
|
270
296
|
query: e,
|
|
271
297
|
...r != null ? { variables: r } : {},
|
|
272
298
|
...n != null ? { operationName: n } : {}
|
|
273
299
|
})).structuredContent;
|
|
274
300
|
}
|
|
275
301
|
}
|
|
276
|
-
const
|
|
302
|
+
const S = "Accept-Language", ge = (t) => {
|
|
277
303
|
const e = globalThis.SFDC_ENV?.language;
|
|
278
304
|
if (!e)
|
|
279
305
|
return l(t);
|
|
280
306
|
const [r, n] = t;
|
|
281
|
-
return (r instanceof Request && !n?.headers ? r.headers.has(
|
|
282
|
-
},
|
|
283
|
-
let e = b(
|
|
284
|
-
return e = b(
|
|
285
|
-
},
|
|
286
|
-
function
|
|
307
|
+
return (r instanceof Request && !n?.headers ? r.headers.has(S) : new Headers(n?.headers).has(S)) ? l(t) : l(b(S, e, t));
|
|
308
|
+
}, Ee = "X-SFDC-Client-Name", Se = "X-SFDC-Client-Version", Ce = "@salesforce/platform-sdk", xe = "12.0.0", De = (t) => {
|
|
309
|
+
let e = b(Ee, Ce, t);
|
|
310
|
+
return e = b(Se, xe, e), l(e);
|
|
311
|
+
}, Oe = "X-CSRF-Token";
|
|
312
|
+
function Ne(t, e = {}) {
|
|
287
313
|
const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
|
|
288
314
|
return async (s) => {
|
|
289
|
-
const [a,
|
|
290
|
-
if (_(n,
|
|
315
|
+
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";
|
|
316
|
+
if (_(n, i) || $e(c) && _(r, i)) {
|
|
291
317
|
const u = await t.getToken();
|
|
292
|
-
s = b(
|
|
318
|
+
s = b(Oe, u, s);
|
|
293
319
|
}
|
|
294
320
|
return l(s);
|
|
295
321
|
};
|
|
296
322
|
}
|
|
297
|
-
function
|
|
323
|
+
function $e(t) {
|
|
298
324
|
const e = t.toLowerCase();
|
|
299
325
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
300
326
|
}
|
|
@@ -302,16 +328,16 @@ function _(t, e) {
|
|
|
302
328
|
const r = new URL(e, globalThis.location?.href ?? "http://localhost");
|
|
303
329
|
return t.some((n) => r.pathname.includes(n));
|
|
304
330
|
}
|
|
305
|
-
function
|
|
306
|
-
const r =
|
|
331
|
+
function qe(t, e = {}) {
|
|
332
|
+
const r = Ne(t, e);
|
|
307
333
|
async function n(s) {
|
|
308
334
|
const a = await r(s);
|
|
309
335
|
return fetch(a[0], a[1]);
|
|
310
336
|
}
|
|
311
337
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
312
338
|
}
|
|
313
|
-
const
|
|
314
|
-
class Pe extends
|
|
339
|
+
const Ae = [400, 401, 403];
|
|
340
|
+
class Pe extends X {
|
|
315
341
|
constructor(e) {
|
|
316
342
|
super(e), this.csrfTokenManager = e;
|
|
317
343
|
}
|
|
@@ -319,7 +345,7 @@ class Pe extends B {
|
|
|
319
345
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
320
346
|
*/
|
|
321
347
|
async shouldRetry(e, r) {
|
|
322
|
-
return r.attempt >= 1 ? !1 :
|
|
348
|
+
return r.attempt >= 1 ? !1 : Ae.includes(e.status);
|
|
323
349
|
}
|
|
324
350
|
/**
|
|
325
351
|
* CSRF token refresh should happen immediately with no delay.
|
|
@@ -389,25 +415,25 @@ const k = /* @__PURE__ */ new Map();
|
|
|
389
415
|
function ke(t) {
|
|
390
416
|
const { endpoint: e, cacheName: r, ...n } = t.csrf;
|
|
391
417
|
let s = k.get(e);
|
|
392
|
-
return s || (s = new _e(e, r), k.set(e, s)),
|
|
418
|
+
return s || (s = new _e(e, r), k.set(e, s)), M(
|
|
393
419
|
{
|
|
394
|
-
retry:
|
|
395
|
-
request: [
|
|
420
|
+
retry: qe(s, n),
|
|
421
|
+
request: [De, ge]
|
|
396
422
|
},
|
|
397
|
-
|
|
423
|
+
Y(new Pe(s)).service
|
|
398
424
|
).service;
|
|
399
425
|
}
|
|
400
|
-
const
|
|
401
|
-
function
|
|
402
|
-
let e =
|
|
426
|
+
const T = /* @__PURE__ */ new Map();
|
|
427
|
+
function Te(t) {
|
|
428
|
+
let e = T.get(t);
|
|
403
429
|
if (!e) {
|
|
404
|
-
const r =
|
|
405
|
-
e = { cache: r, cacheController: s, pubSub: a },
|
|
430
|
+
const r = Z().service, n = te(r).service, s = ee(r, n).service, a = re().service;
|
|
431
|
+
e = { cache: r, cacheController: s, pubSub: a }, T.set(t, e);
|
|
406
432
|
}
|
|
407
433
|
return e;
|
|
408
434
|
}
|
|
409
|
-
function
|
|
410
|
-
const r =
|
|
435
|
+
function Re(t, e) {
|
|
436
|
+
const r = Te(t);
|
|
411
437
|
return {
|
|
412
438
|
shared: r,
|
|
413
439
|
services: {
|
|
@@ -417,8 +443,8 @@ function Te(t, e) {
|
|
|
417
443
|
}
|
|
418
444
|
};
|
|
419
445
|
}
|
|
420
|
-
const
|
|
421
|
-
function
|
|
446
|
+
const R = 300;
|
|
447
|
+
function Me(t, e) {
|
|
422
448
|
try {
|
|
423
449
|
return JSON.parse(JSON.stringify(t));
|
|
424
450
|
} catch (r) {
|
|
@@ -428,19 +454,19 @@ function $e(t, e) {
|
|
|
428
454
|
throw s.cause = r, s;
|
|
429
455
|
}
|
|
430
456
|
}
|
|
431
|
-
function
|
|
457
|
+
function Ve(t) {
|
|
432
458
|
if (typeof t == "object" && t.type === "max-age") {
|
|
433
459
|
const e = t.maxAge;
|
|
434
|
-
return Number.isFinite(e) && e >= 0 ? e :
|
|
460
|
+
return Number.isFinite(e) && e >= 0 ? e : R;
|
|
435
461
|
}
|
|
436
|
-
return
|
|
462
|
+
return R;
|
|
437
463
|
}
|
|
438
|
-
class Le extends
|
|
464
|
+
class Le extends ne {
|
|
439
465
|
constructor(e, r, n) {
|
|
440
|
-
super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables =
|
|
466
|
+
super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Me(
|
|
441
467
|
e.variables ?? {},
|
|
442
468
|
this.normalizedOperationName
|
|
443
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge =
|
|
469
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Ve(e.cacheControl), this.headers = e.headers, this.headersKey = le(e.headers);
|
|
444
470
|
}
|
|
445
471
|
query;
|
|
446
472
|
normalizedVariables;
|
|
@@ -469,7 +495,7 @@ class Le extends re {
|
|
|
469
495
|
variables: this.normalizedVariables,
|
|
470
496
|
operationName: this.normalizedOperationName
|
|
471
497
|
};
|
|
472
|
-
return this.headersKey !== void 0 && (e.headers = this.headersKey),
|
|
498
|
+
return this.headersKey !== void 0 && (e.headers = this.headersKey), K(e);
|
|
473
499
|
}
|
|
474
500
|
/**
|
|
475
501
|
* Reads from the cache and returns the cache result or error
|
|
@@ -487,8 +513,8 @@ class Le extends re {
|
|
|
487
513
|
readFromCache(e) {
|
|
488
514
|
const r = this.buildKey(), n = e.get(r)?.value;
|
|
489
515
|
return n === void 0 ? l(
|
|
490
|
-
D(new
|
|
491
|
-
) : l(
|
|
516
|
+
D(new z("No cached entry found for this query."))
|
|
517
|
+
) : l(x(n));
|
|
492
518
|
}
|
|
493
519
|
writeToCache(e, r) {
|
|
494
520
|
if (r.isOk() && r.value.data != null && Object.keys(r.value.data).length > 0) {
|
|
@@ -518,15 +544,15 @@ class Le extends re {
|
|
|
518
544
|
return e.errors && e.errors.length > 0;
|
|
519
545
|
}
|
|
520
546
|
processFetchReturnValue(e) {
|
|
521
|
-
return this.responseHasErrors(e) ? D(new
|
|
547
|
+
return this.responseHasErrors(e) ? D(new J(e)) : x(e);
|
|
522
548
|
}
|
|
523
549
|
}
|
|
524
|
-
const
|
|
525
|
-
function
|
|
550
|
+
const Ie = "CACHE_MISS";
|
|
551
|
+
function Ge() {
|
|
526
552
|
return [
|
|
527
553
|
{
|
|
528
554
|
message: "No cached entry found for this query (cacheControl: 'only-if-cached').",
|
|
529
|
-
extensions: { code:
|
|
555
|
+
extensions: { code: Ie }
|
|
530
556
|
}
|
|
531
557
|
];
|
|
532
558
|
}
|
|
@@ -537,41 +563,41 @@ function F(t) {
|
|
|
537
563
|
return e.data;
|
|
538
564
|
}
|
|
539
565
|
}
|
|
540
|
-
function
|
|
566
|
+
function He(t) {
|
|
541
567
|
return (e) => {
|
|
542
568
|
if (e.isOk()) {
|
|
543
569
|
const r = e.value;
|
|
544
570
|
w(r), t({ data: r, errors: void 0 });
|
|
545
571
|
} else {
|
|
546
572
|
const r = F(e.error);
|
|
547
|
-
r && w(r), t({ data: r, errors:
|
|
573
|
+
r && w(r), t({ data: r, errors: m(e.error) });
|
|
548
574
|
}
|
|
549
575
|
};
|
|
550
576
|
}
|
|
551
|
-
async function
|
|
577
|
+
async function Ue(t, e = !1) {
|
|
552
578
|
let r, n, s;
|
|
553
579
|
try {
|
|
554
580
|
const a = await t.execute();
|
|
555
|
-
a.isOk() ? (r = a.value.data, w(r), s = (
|
|
581
|
+
a.isOk() ? (r = a.value.data, w(r), s = (o) => a.value.subscribe(o)) : (r = F(a.error.failure), r && w(r), n = e && r === void 0 ? Ge() : m(a.error.failure), s = (o) => a.error.subscribe(o));
|
|
556
582
|
} catch (a) {
|
|
557
|
-
n =
|
|
583
|
+
n = m(a);
|
|
558
584
|
}
|
|
559
585
|
return {
|
|
560
586
|
data: r,
|
|
561
587
|
errors: n,
|
|
562
588
|
subscribe(a) {
|
|
563
|
-
return s ? s(
|
|
589
|
+
return s ? s(He(a)) : g;
|
|
564
590
|
},
|
|
565
591
|
async refresh() {
|
|
566
592
|
await t.refresh();
|
|
567
593
|
}
|
|
568
594
|
};
|
|
569
595
|
}
|
|
570
|
-
function
|
|
596
|
+
function C(t) {
|
|
571
597
|
return {
|
|
572
598
|
data: void 0,
|
|
573
599
|
errors: t,
|
|
574
|
-
subscribe: () =>
|
|
600
|
+
subscribe: () => g,
|
|
575
601
|
refresh: O
|
|
576
602
|
};
|
|
577
603
|
}
|
|
@@ -583,65 +609,66 @@ function Fe({
|
|
|
583
609
|
const { services: n } = t;
|
|
584
610
|
async function s({
|
|
585
611
|
query: a,
|
|
586
|
-
variables:
|
|
587
|
-
operationName:
|
|
588
|
-
cacheControl:
|
|
612
|
+
variables: o,
|
|
613
|
+
operationName: i,
|
|
614
|
+
cacheControl: c,
|
|
589
615
|
headers: h
|
|
590
616
|
}) {
|
|
591
|
-
const u =
|
|
592
|
-
if (u.isErr()) return
|
|
593
|
-
const d = u.value,
|
|
594
|
-
if (
|
|
595
|
-
return
|
|
617
|
+
const u = $(a);
|
|
618
|
+
if (u.isErr()) return C(u.error);
|
|
619
|
+
const d = u.value, f = q(d, i);
|
|
620
|
+
if (f !== "query")
|
|
621
|
+
return C([
|
|
596
622
|
{
|
|
597
|
-
message: `DataSDK.graphql.query() requires a GraphQL query, received ${
|
|
623
|
+
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
598
624
|
}
|
|
599
625
|
]);
|
|
600
|
-
let
|
|
626
|
+
let p;
|
|
601
627
|
try {
|
|
602
|
-
|
|
628
|
+
p = new Le(
|
|
603
629
|
{
|
|
604
|
-
query:
|
|
605
|
-
variables:
|
|
606
|
-
operationName:
|
|
607
|
-
cacheControl:
|
|
630
|
+
query: N(d),
|
|
631
|
+
variables: o,
|
|
632
|
+
operationName: i,
|
|
633
|
+
cacheControl: c,
|
|
608
634
|
headers: h
|
|
609
635
|
},
|
|
610
636
|
n,
|
|
611
637
|
e
|
|
612
638
|
);
|
|
613
|
-
} catch (
|
|
614
|
-
return
|
|
639
|
+
} catch (E) {
|
|
640
|
+
return C(m(E));
|
|
615
641
|
}
|
|
616
|
-
return
|
|
642
|
+
return Ue(p, c === "only-if-cached");
|
|
617
643
|
}
|
|
618
644
|
return {
|
|
619
645
|
query: s,
|
|
620
|
-
mutate: (a) =>
|
|
646
|
+
mutate: (a) => G(r, a)
|
|
621
647
|
};
|
|
622
648
|
}
|
|
623
|
-
const
|
|
624
|
-
class
|
|
649
|
+
const Qe = 1, je = `@salesforce/platform-sdk-data_v${Qe}`;
|
|
650
|
+
class Ke {
|
|
625
651
|
baseUrl;
|
|
626
652
|
pathData;
|
|
627
653
|
clientFetch;
|
|
628
654
|
onStatus;
|
|
655
|
+
apiVersion;
|
|
629
656
|
graphql;
|
|
630
657
|
constructor(e) {
|
|
631
|
-
const r =
|
|
632
|
-
this.baseUrl =
|
|
658
|
+
const r = ze();
|
|
659
|
+
this.baseUrl = Je(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? A, this.pathData = U(this.apiVersion);
|
|
633
660
|
const n = `${this.pathData}/ui-api`, s = `${this.pathData}/graphql`;
|
|
634
661
|
this.onStatus = e?.onStatus ?? {}, this.clientFetch = ke({
|
|
635
662
|
csrf: {
|
|
636
663
|
endpoint: `${this.baseUrl}${n}/session/csrf`,
|
|
637
|
-
cacheName:
|
|
664
|
+
cacheName: je,
|
|
638
665
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
639
666
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
640
667
|
}
|
|
641
668
|
});
|
|
642
|
-
const a = (
|
|
669
|
+
const a = (i, c) => this.fetch(i, c), o = Re(`${this.baseUrl}${this.pathData}`, a);
|
|
643
670
|
this.graphql = Fe({
|
|
644
|
-
bundle:
|
|
671
|
+
bundle: o,
|
|
645
672
|
url: s,
|
|
646
673
|
executeRaw: this.executeRawGraphQL.bind(this)
|
|
647
674
|
});
|
|
@@ -662,12 +689,12 @@ class Ve {
|
|
|
662
689
|
operationName: n,
|
|
663
690
|
headers: s
|
|
664
691
|
}) {
|
|
665
|
-
const a = `${this.pathData}/graphql`,
|
|
692
|
+
const a = `${this.pathData}/graphql`, o = await this.fetch(a, {
|
|
666
693
|
method: "POST",
|
|
667
694
|
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
668
695
|
headers: L(s)
|
|
669
696
|
});
|
|
670
|
-
return
|
|
697
|
+
return I(o, "WebApp", a);
|
|
671
698
|
}
|
|
672
699
|
/**
|
|
673
700
|
* If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
|
|
@@ -683,103 +710,110 @@ class Ve {
|
|
|
683
710
|
return e;
|
|
684
711
|
}
|
|
685
712
|
}
|
|
686
|
-
function
|
|
713
|
+
function ze() {
|
|
687
714
|
return {
|
|
688
715
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
689
716
|
};
|
|
690
717
|
}
|
|
691
|
-
function
|
|
718
|
+
function Je(t) {
|
|
692
719
|
if (!t || t === "/") return "";
|
|
693
720
|
let e = t;
|
|
694
721
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
695
722
|
}
|
|
696
|
-
function
|
|
697
|
-
const e = typeof
|
|
698
|
-
if (typeof
|
|
723
|
+
function We(t) {
|
|
724
|
+
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;
|
|
725
|
+
if (typeof s?.setup != "function")
|
|
699
726
|
throw new Error("Extension entry cannot attach: it is missing a setup function.");
|
|
700
|
-
if (typeof
|
|
727
|
+
if (typeof a != "string" || a.length === 0)
|
|
701
728
|
throw new Error(
|
|
702
|
-
|
|
729
|
+
n ? 'Extension entry cannot attach: "name" must be a non-empty string.' : 'Extension entry cannot attach: alias "as" must be a non-empty string.'
|
|
703
730
|
);
|
|
704
|
-
return {
|
|
731
|
+
return {
|
|
732
|
+
extension: s,
|
|
733
|
+
mountName: a,
|
|
734
|
+
label: a === s.name ? `"${s.name}"` : `"${s.name}" (aliased as "${a}")`
|
|
735
|
+
};
|
|
705
736
|
}
|
|
706
|
-
async function
|
|
737
|
+
async function Be(t, e, r) {
|
|
707
738
|
if (e.length === 0)
|
|
708
739
|
return t;
|
|
709
740
|
if ("ext" in t)
|
|
710
741
|
throw new Error(
|
|
711
742
|
'Cannot attach extensions: the base SDK already declares an "ext" member, which the extension container reserves.'
|
|
712
743
|
);
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
throw new Error(`Cannot
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
|
|
744
|
+
const n = e.map(We);
|
|
745
|
+
r?.preflight?.(n, t);
|
|
746
|
+
const s = Object.create(t), a = /* @__PURE__ */ Object.create(null), o = (h) => {
|
|
747
|
+
throw new Error(`Cannot write "ext.${String(h)}" — ext is immutable once attached.`);
|
|
748
|
+
}, i = (h) => {
|
|
749
|
+
throw new Error(`Cannot ${h} "ext" — ext is immutable once attached.`);
|
|
750
|
+
}, c = new Proxy(a, {
|
|
751
|
+
set(h, u) {
|
|
752
|
+
return o(u);
|
|
720
753
|
},
|
|
721
|
-
defineProperty(
|
|
722
|
-
return
|
|
754
|
+
defineProperty(h, u) {
|
|
755
|
+
return o(u);
|
|
723
756
|
},
|
|
724
|
-
deleteProperty(
|
|
725
|
-
return
|
|
757
|
+
deleteProperty(h, u) {
|
|
758
|
+
return o(u);
|
|
726
759
|
},
|
|
727
760
|
// Without these two, `preventExtensions`/`setPrototypeOf` fall through to the
|
|
728
761
|
// real `store` (no per-property trap catches them) — the first would silently
|
|
729
762
|
// block later extensions from mounting, the second could inject a readable
|
|
730
763
|
// property via the prototype chain that no extension ever returned.
|
|
731
764
|
preventExtensions() {
|
|
732
|
-
return
|
|
765
|
+
return i("prevent extensions on");
|
|
733
766
|
},
|
|
734
767
|
setPrototypeOf() {
|
|
735
|
-
return
|
|
768
|
+
return i("change the prototype of");
|
|
736
769
|
}
|
|
737
770
|
});
|
|
738
|
-
Object.defineProperty(
|
|
771
|
+
Object.defineProperty(s, "ext", {
|
|
739
772
|
value: c,
|
|
740
773
|
enumerable: !0,
|
|
741
774
|
writable: !1,
|
|
742
775
|
configurable: !1
|
|
743
776
|
});
|
|
744
|
-
for (const
|
|
745
|
-
|
|
746
|
-
if (Object.hasOwn(n, h))
|
|
777
|
+
for (const { extension: h, mountName: u, label: d } of n) {
|
|
778
|
+
if (Object.hasOwn(a, u))
|
|
747
779
|
throw new Error(
|
|
748
|
-
`Extension ${
|
|
780
|
+
`Extension ${d} cannot attach: "${u}" is already defined by another extension.`
|
|
749
781
|
);
|
|
750
|
-
let
|
|
782
|
+
let f;
|
|
751
783
|
try {
|
|
752
|
-
|
|
784
|
+
f = await h.setup(s);
|
|
753
785
|
} catch (p) {
|
|
754
|
-
throw new Error(`Extension ${
|
|
786
|
+
throw new Error(`Extension ${d} failed during setup.`, { cause: p });
|
|
755
787
|
}
|
|
756
|
-
Object.defineProperty(
|
|
757
|
-
value:
|
|
788
|
+
Object.defineProperty(a, u, {
|
|
789
|
+
value: f,
|
|
758
790
|
enumerable: !0,
|
|
759
791
|
writable: !1,
|
|
760
792
|
configurable: !1
|
|
761
793
|
});
|
|
762
794
|
}
|
|
763
|
-
return Object.freeze(
|
|
795
|
+
return Object.freeze(a), s;
|
|
764
796
|
}
|
|
765
|
-
function
|
|
797
|
+
function ut(t, ...e) {
|
|
766
798
|
let r = t[0] ?? "";
|
|
767
799
|
for (let n = 0; n < e.length; n += 1)
|
|
768
800
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
769
801
|
return r;
|
|
770
802
|
}
|
|
771
|
-
|
|
772
|
-
|
|
803
|
+
function ht(t) {
|
|
804
|
+
return t;
|
|
805
|
+
}
|
|
806
|
+
async function Xe(t) {
|
|
773
807
|
try {
|
|
774
|
-
switch (await
|
|
775
|
-
case
|
|
776
|
-
return new
|
|
777
|
-
case
|
|
778
|
-
case
|
|
779
|
-
return new
|
|
780
|
-
case
|
|
781
|
-
return new
|
|
782
|
-
case
|
|
808
|
+
switch (await Q(t?.surface)) {
|
|
809
|
+
case y.OpenAI:
|
|
810
|
+
return new ve();
|
|
811
|
+
case y.WebApp:
|
|
812
|
+
case y.MicroFrontend:
|
|
813
|
+
return new Ke(t?.webapp);
|
|
814
|
+
case y.Mosaic:
|
|
815
|
+
return new me(t?.mosaic);
|
|
816
|
+
case y.MCPApps:
|
|
783
817
|
return {};
|
|
784
818
|
default:
|
|
785
819
|
return {};
|
|
@@ -788,17 +822,19 @@ async function Je(t) {
|
|
|
788
822
|
return {};
|
|
789
823
|
}
|
|
790
824
|
}
|
|
791
|
-
function
|
|
792
|
-
return
|
|
825
|
+
function lt(t) {
|
|
826
|
+
return j(
|
|
793
827
|
(async () => {
|
|
794
|
-
const e = await
|
|
795
|
-
return
|
|
828
|
+
const e = await Xe(t);
|
|
829
|
+
return Be(e, t?.extensions ?? [], {
|
|
830
|
+
preflight: ae
|
|
831
|
+
});
|
|
796
832
|
})(),
|
|
797
833
|
"createDataSDK"
|
|
798
834
|
);
|
|
799
835
|
}
|
|
800
836
|
export {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
837
|
+
lt as createDataSDK,
|
|
838
|
+
ht as defineDataExtension,
|
|
839
|
+
ut as gql
|
|
804
840
|
};
|