@salesforce/platform-sdk 11.53.0 → 11.54.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.
|
@@ -28,10 +28,11 @@ import { ExtendedSDK, PluginsFor } from './plugin-types';
|
|
|
28
28
|
* base type may attach. The returned type is {@link ExtendedSDK}<Base, Plugins>
|
|
29
29
|
* — the base plus each plugin's resolved namespace under its own key.
|
|
30
30
|
*
|
|
31
|
-
* Fail-loud: a name
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* error via
|
|
31
|
+
* Fail-loud: a name in `reservedNames` (names the caller declares off-limits),
|
|
32
|
+
* already present on the base (own or inherited), or mounted earlier in this
|
|
33
|
+
* same call throws before setup runs, and a `setup` that throws or rejects
|
|
34
|
+
* surfaces as an error naming the plugin, chaining the original error via
|
|
35
|
+
* `cause`.
|
|
35
36
|
*/
|
|
36
|
-
export declare function attachPlugins<Base extends object, const Plugins extends PluginsFor<Base>>(base: Base, plugins: Plugins): Promise<ExtendedSDK<Base, Plugins>>;
|
|
37
|
+
export declare function attachPlugins<Base extends object, const Plugins extends PluginsFor<Base>>(base: Base, plugins: Plugins, reservedNames?: ReadonlySet<string>): Promise<ExtendedSDK<Base, Plugins>>;
|
|
37
38
|
//# sourceMappingURL=plugin-attach.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-attach.d.ts","sourceRoot":"","sources":["../../src/core/plugin-attach.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"plugin-attach.d.ts","sourceRoot":"","sources":["../../src/core/plugin-attach.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,aAAa,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,UAAU,CAAC,IAAI,CAAC,EAC9F,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAIhB,aAAa,GAAE,WAAW,CAAC,MAAM,CAAqB,GACpD,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CA0DrC"}
|
package/dist/data/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAMpE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CACnD;AAED,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,GAAG,GAAG,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AAEpG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,sIAAiC,CAAC;AAE/D,iFAAiF;AACjF,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,aAAa,EAAE,IAAI,WAAW,CACrF,OAAO,EACP,OAAO,CACP,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD;;;OAGG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,OAAO,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACnC;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAkBH,wBAAgB,aAAa,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,aAAa,EAAE,GAAG,EAAE,EAChF,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAC5F,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAexC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EACX,YAAY,EACZ,OAAO,EACP,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,GACX,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS;IAC3C,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;CAC3B,GAAG,IAAI,GACL,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,GAClC,CAAC,GACD,KAAK,GACN,KAAK,CAAC"}
|
package/dist/data/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { g as V, S as y } from "../surface-Dd2tqrPi.js";
|
|
2
2
|
import { w as x } from "../sdk-promise-D0sy7OW1.js";
|
|
3
3
|
import { c as G } from "../plugin-factory-BC3b3BOy.js";
|
|
4
|
-
import { buildServiceDescriptor as
|
|
5
|
-
import { resolvedPromiseLike as u, ok as C, err as D, stableJSONStringify as Q, DataNotFoundError as
|
|
6
|
-
import { print as
|
|
4
|
+
import { buildServiceDescriptor as M, setHeader as b } from "@conduit-client/service-fetch-network/v1";
|
|
5
|
+
import { resolvedPromiseLike as u, ok as C, err as D, stableJSONStringify as Q, DataNotFoundError as j, UserVisibleError as z, deepFreeze as S, isUserVisibleError as W } from "@conduit-client/utils";
|
|
6
|
+
import { print as P, parse as B } from "@conduit-client/onestore-graphql-parser/v1";
|
|
7
7
|
import { RetryPolicy as J, buildServiceDescriptor as X } from "@conduit-client/service-retry/v1";
|
|
8
8
|
import { buildServiceDescriptor as Y } from "@conduit-client/service-cache/v1";
|
|
9
9
|
import { buildServiceDescriptor as Z } from "@conduit-client/service-cache-control/v1";
|
|
@@ -25,7 +25,7 @@ function se(r) {
|
|
|
25
25
|
}
|
|
26
26
|
function ae(r, e) {
|
|
27
27
|
const t = [];
|
|
28
|
-
return r && t.push(ne(r)), e && t.push(se(e)),
|
|
28
|
+
return r && t.push(ne(r)), e && t.push(se(e)), M({
|
|
29
29
|
request: t
|
|
30
30
|
}).service;
|
|
31
31
|
}
|
|
@@ -41,7 +41,7 @@ function ie(r) {
|
|
|
41
41
|
}
|
|
42
42
|
return Array.isArray(r) ? r.map(([e, t]) => [e, t]) : Object.entries(r);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function $(r, e) {
|
|
45
45
|
if (e === void 0) return { ...r };
|
|
46
46
|
const t = { ...r }, n = /* @__PURE__ */ new Map();
|
|
47
47
|
for (const a of Object.keys(t)) n.set(a.toLowerCase(), a);
|
|
@@ -52,8 +52,8 @@ function M(r, e) {
|
|
|
52
52
|
}
|
|
53
53
|
return t;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
return
|
|
55
|
+
function L(r) {
|
|
56
|
+
return $(oe, r);
|
|
57
57
|
}
|
|
58
58
|
function ce(r) {
|
|
59
59
|
if (r === void 0) return;
|
|
@@ -62,17 +62,17 @@ function ce(r) {
|
|
|
62
62
|
e[n] = t;
|
|
63
63
|
}), Object.keys(e).length > 0 ? e : void 0;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
},
|
|
65
|
+
const v = () => {
|
|
66
|
+
}, A = async () => {
|
|
67
67
|
};
|
|
68
|
-
function
|
|
68
|
+
function _(r) {
|
|
69
69
|
try {
|
|
70
70
|
return C(B(r));
|
|
71
71
|
} catch (e) {
|
|
72
72
|
return D(d(e));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function k(r, e) {
|
|
76
76
|
const t = r.definitions.filter(
|
|
77
77
|
(n) => n.kind === "OperationDefinition"
|
|
78
78
|
);
|
|
@@ -87,9 +87,9 @@ function d(r) {
|
|
|
87
87
|
return r instanceof Error ? [{ message: r.message }] : typeof r == "string" ? [{ message: r }] : [{ message: "Unknown error" }];
|
|
88
88
|
}
|
|
89
89
|
async function H(r, { mutation: e, variables: t, operationName: n, headers: s }) {
|
|
90
|
-
const a =
|
|
90
|
+
const a = _(e);
|
|
91
91
|
if (a.isErr()) return { data: void 0, errors: a.error };
|
|
92
|
-
const i = a.value, o =
|
|
92
|
+
const i = a.value, o = k(i, n);
|
|
93
93
|
if (o !== "mutation")
|
|
94
94
|
return {
|
|
95
95
|
data: void 0,
|
|
@@ -101,7 +101,7 @@ async function H(r, { mutation: e, variables: t, operationName: n, headers: s })
|
|
|
101
101
|
};
|
|
102
102
|
try {
|
|
103
103
|
const c = await r({
|
|
104
|
-
query:
|
|
104
|
+
query: P(i),
|
|
105
105
|
variables: t,
|
|
106
106
|
operationName: n,
|
|
107
107
|
headers: s
|
|
@@ -117,7 +117,7 @@ async function H(r, { mutation: e, variables: t, operationName: n, headers: s })
|
|
|
117
117
|
function I(r) {
|
|
118
118
|
function e(n, s, a, i) {
|
|
119
119
|
return r({
|
|
120
|
-
query:
|
|
120
|
+
query: P(n),
|
|
121
121
|
variables: s,
|
|
122
122
|
operationName: a,
|
|
123
123
|
headers: i
|
|
@@ -135,15 +135,15 @@ function I(r) {
|
|
|
135
135
|
operationName: a,
|
|
136
136
|
headers: i
|
|
137
137
|
}) {
|
|
138
|
-
const o =
|
|
138
|
+
const o = _(n);
|
|
139
139
|
if (o.isErr())
|
|
140
140
|
return {
|
|
141
141
|
data: void 0,
|
|
142
142
|
errors: o.error,
|
|
143
|
-
subscribe: () =>
|
|
144
|
-
refresh:
|
|
143
|
+
subscribe: () => v,
|
|
144
|
+
refresh: A
|
|
145
145
|
};
|
|
146
|
-
const c = o.value, f =
|
|
146
|
+
const c = o.value, f = k(c, a);
|
|
147
147
|
if (f !== "query")
|
|
148
148
|
return {
|
|
149
149
|
data: void 0,
|
|
@@ -152,8 +152,8 @@ function I(r) {
|
|
|
152
152
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
153
153
|
}
|
|
154
154
|
],
|
|
155
|
-
subscribe: () =>
|
|
156
|
-
refresh:
|
|
155
|
+
subscribe: () => v,
|
|
156
|
+
refresh: A
|
|
157
157
|
};
|
|
158
158
|
const h = /* @__PURE__ */ new Set(), p = s, m = await e(c, p, a, i);
|
|
159
159
|
return {
|
|
@@ -166,7 +166,7 @@ function I(r) {
|
|
|
166
166
|
},
|
|
167
167
|
async refresh() {
|
|
168
168
|
const l = await e(c, p, a, i);
|
|
169
|
-
for (const
|
|
169
|
+
for (const g of h) g(l);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
@@ -200,7 +200,7 @@ class le {
|
|
|
200
200
|
return (await this.clientFetch(`${this.pathData}/graphql`, {
|
|
201
201
|
method: "POST",
|
|
202
202
|
body: JSON.stringify({ query: e, variables: t, operationName: n }),
|
|
203
|
-
headers:
|
|
203
|
+
headers: $(he, s)
|
|
204
204
|
})).json();
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -240,45 +240,48 @@ class me {
|
|
|
240
240
|
})).structuredContent;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
const
|
|
243
|
+
const ye = {
|
|
244
|
+
graphql: !0,
|
|
245
|
+
fetch: !0
|
|
246
|
+
}, be = new Set(Object.keys(ye)), w = "Accept-Language", Se = (r) => {
|
|
244
247
|
const e = globalThis.SFDC_ENV?.language;
|
|
245
248
|
if (!e)
|
|
246
249
|
return u(r);
|
|
247
250
|
const [t, n] = r;
|
|
248
251
|
return (t instanceof Request && !n?.headers ? t.headers.has(w) : new Headers(n?.headers).has(w)) ? u(r) : u(b(w, e, r));
|
|
249
|
-
},
|
|
250
|
-
let e = b(
|
|
251
|
-
return e = b(
|
|
252
|
-
},
|
|
253
|
-
function
|
|
252
|
+
}, ve = "X-SFDC-Client-Name", ge = "X-SFDC-Client-Version", we = "@salesforce/platform-sdk", Ee = "11.54.0", Ce = (r) => {
|
|
253
|
+
let e = b(ve, we, r);
|
|
254
|
+
return e = b(ge, Ee, e), u(e);
|
|
255
|
+
}, De = "X-CSRF-Token";
|
|
256
|
+
function Ae(r, e = {}) {
|
|
254
257
|
const { protectedUrls: t = [], alwaysProtectedUrls: n = [] } = e;
|
|
255
258
|
return async (s) => {
|
|
256
259
|
const [a, i] = s, o = a instanceof Request ? a.url : a instanceof URL ? a.href : a, c = i?.method ?? (a instanceof Request ? a.method : void 0) ?? "GET";
|
|
257
|
-
if (
|
|
260
|
+
if (R(n, o) || Pe(c) && R(t, o)) {
|
|
258
261
|
const h = await r.getToken();
|
|
259
|
-
s = b(
|
|
262
|
+
s = b(De, h, s);
|
|
260
263
|
}
|
|
261
264
|
return u(s);
|
|
262
265
|
};
|
|
263
266
|
}
|
|
264
|
-
function
|
|
267
|
+
function Pe(r) {
|
|
265
268
|
const e = r.toLowerCase();
|
|
266
269
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
267
270
|
}
|
|
268
|
-
function
|
|
271
|
+
function R(r, e) {
|
|
269
272
|
const t = new URL(e, globalThis.location?.href ?? "http://localhost");
|
|
270
273
|
return r.some((n) => t.pathname.includes(n));
|
|
271
274
|
}
|
|
272
|
-
function
|
|
273
|
-
const t =
|
|
275
|
+
function _e(r, e = {}) {
|
|
276
|
+
const t = Ae(r, e);
|
|
274
277
|
async function n(s) {
|
|
275
278
|
const a = await t(s);
|
|
276
279
|
return fetch(a[0], a[1]);
|
|
277
280
|
}
|
|
278
281
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
279
282
|
}
|
|
280
|
-
const
|
|
281
|
-
class
|
|
283
|
+
const ke = [400, 401, 403];
|
|
284
|
+
class Re extends J {
|
|
282
285
|
constructor(e) {
|
|
283
286
|
super(e), this.csrfTokenManager = e;
|
|
284
287
|
}
|
|
@@ -286,7 +289,7 @@ class ke extends J {
|
|
|
286
289
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
287
290
|
*/
|
|
288
291
|
async shouldRetry(e, t) {
|
|
289
|
-
return t.attempt >= 1 ? !1 :
|
|
292
|
+
return t.attempt >= 1 ? !1 : ke.includes(e.status);
|
|
290
293
|
}
|
|
291
294
|
/**
|
|
292
295
|
* CSRF token refresh should happen immediately with no delay.
|
|
@@ -352,28 +355,28 @@ class qe {
|
|
|
352
355
|
return;
|
|
353
356
|
}
|
|
354
357
|
}
|
|
355
|
-
const
|
|
358
|
+
const q = /* @__PURE__ */ new Map();
|
|
356
359
|
function Oe(r) {
|
|
357
360
|
const { endpoint: e, cacheName: t, ...n } = r.csrf;
|
|
358
|
-
let s =
|
|
359
|
-
return s || (s = new qe(e, t),
|
|
361
|
+
let s = q.get(e);
|
|
362
|
+
return s || (s = new qe(e, t), q.set(e, s)), M(
|
|
360
363
|
{
|
|
361
|
-
retry:
|
|
362
|
-
request: [
|
|
364
|
+
retry: _e(s, n),
|
|
365
|
+
request: [Ce, Se]
|
|
363
366
|
},
|
|
364
|
-
X(new
|
|
367
|
+
X(new Re(s)).service
|
|
365
368
|
).service;
|
|
366
369
|
}
|
|
367
|
-
const
|
|
370
|
+
const O = /* @__PURE__ */ new Map();
|
|
368
371
|
function Te(r) {
|
|
369
|
-
let e =
|
|
372
|
+
let e = O.get(r);
|
|
370
373
|
if (!e) {
|
|
371
374
|
const t = Y().service, n = ee(t).service, s = Z(t, n).service, a = re().service;
|
|
372
|
-
e = { cache: t, cacheController: s, pubSub: a },
|
|
375
|
+
e = { cache: t, cacheController: s, pubSub: a }, O.set(r, e);
|
|
373
376
|
}
|
|
374
377
|
return e;
|
|
375
378
|
}
|
|
376
|
-
function
|
|
379
|
+
function Ne(r, e) {
|
|
377
380
|
const t = Te(r);
|
|
378
381
|
return {
|
|
379
382
|
shared: t,
|
|
@@ -384,8 +387,8 @@ function _e(r, e) {
|
|
|
384
387
|
}
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
|
-
const
|
|
388
|
-
function
|
|
390
|
+
const T = 300;
|
|
391
|
+
function Me(r, e) {
|
|
389
392
|
try {
|
|
390
393
|
return JSON.parse(JSON.stringify(r));
|
|
391
394
|
} catch (t) {
|
|
@@ -395,19 +398,19 @@ function Re(r, e) {
|
|
|
395
398
|
throw s.cause = t, s;
|
|
396
399
|
}
|
|
397
400
|
}
|
|
398
|
-
function
|
|
401
|
+
function $e(r) {
|
|
399
402
|
if (typeof r == "object" && r.type === "max-age") {
|
|
400
403
|
const e = r.maxAge;
|
|
401
|
-
return Number.isFinite(e) && e >= 0 ? e :
|
|
404
|
+
return Number.isFinite(e) && e >= 0 ? e : T;
|
|
402
405
|
}
|
|
403
|
-
return
|
|
406
|
+
return T;
|
|
404
407
|
}
|
|
405
408
|
class Le extends te {
|
|
406
409
|
constructor(e, t, n) {
|
|
407
|
-
super(t), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables =
|
|
410
|
+
super(t), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Me(
|
|
408
411
|
e.variables ?? {},
|
|
409
412
|
this.normalizedOperationName
|
|
410
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge =
|
|
413
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = $e(e.cacheControl), this.headers = e.headers, this.headersKey = ce(e.headers);
|
|
411
414
|
}
|
|
412
415
|
query;
|
|
413
416
|
normalizedVariables;
|
|
@@ -421,7 +424,7 @@ class Le extends te {
|
|
|
421
424
|
this.url,
|
|
422
425
|
{
|
|
423
426
|
method: "POST",
|
|
424
|
-
headers:
|
|
427
|
+
headers: L(this.headers),
|
|
425
428
|
body: JSON.stringify({
|
|
426
429
|
query: this.query,
|
|
427
430
|
variables: this.normalizedVariables,
|
|
@@ -453,7 +456,7 @@ class Le extends te {
|
|
|
453
456
|
*/
|
|
454
457
|
readFromCache(e) {
|
|
455
458
|
const t = this.buildKey(), n = e.get(t)?.value;
|
|
456
|
-
return n === void 0 ? u(D(new
|
|
459
|
+
return n === void 0 ? u(D(new j())) : u(C(n));
|
|
457
460
|
}
|
|
458
461
|
writeToCache(e, t) {
|
|
459
462
|
if (t.isOk() && t.value.data != null && Object.keys(t.value.data).length > 0) {
|
|
@@ -483,32 +486,32 @@ class Le extends te {
|
|
|
483
486
|
return e.errors && e.errors.length > 0;
|
|
484
487
|
}
|
|
485
488
|
processFetchReturnValue(e) {
|
|
486
|
-
return this.responseHasErrors(e) ? D(new
|
|
489
|
+
return this.responseHasErrors(e) ? D(new z(e)) : C(e);
|
|
487
490
|
}
|
|
488
491
|
}
|
|
489
|
-
function
|
|
492
|
+
function K(r) {
|
|
490
493
|
if (W(r) && r.data && typeof r.data == "object") {
|
|
491
494
|
const e = r.data;
|
|
492
495
|
if (e.data != null)
|
|
493
496
|
return e.data;
|
|
494
497
|
}
|
|
495
498
|
}
|
|
496
|
-
function
|
|
499
|
+
function He(r) {
|
|
497
500
|
return (e) => {
|
|
498
501
|
if (e.isOk()) {
|
|
499
502
|
const t = e.value;
|
|
500
|
-
|
|
503
|
+
S(t), r({ data: t, errors: void 0 });
|
|
501
504
|
} else {
|
|
502
|
-
const t =
|
|
503
|
-
t &&
|
|
505
|
+
const t = K(e.error);
|
|
506
|
+
t && S(t), r({ data: t, errors: d(e.error) });
|
|
504
507
|
}
|
|
505
508
|
};
|
|
506
509
|
}
|
|
507
|
-
async function
|
|
510
|
+
async function Ie(r) {
|
|
508
511
|
let e, t, n;
|
|
509
512
|
try {
|
|
510
513
|
const s = await r.execute();
|
|
511
|
-
s.isOk() ? (e = s.value.data,
|
|
514
|
+
s.isOk() ? (e = s.value.data, S(e), n = (a) => s.value.subscribe(a)) : (e = K(s.error.failure), e && S(e), t = d(s.error.failure), n = (a) => s.error.subscribe(a));
|
|
512
515
|
} catch (s) {
|
|
513
516
|
t = d(s);
|
|
514
517
|
}
|
|
@@ -516,7 +519,7 @@ async function $e(r) {
|
|
|
516
519
|
data: e,
|
|
517
520
|
errors: t,
|
|
518
521
|
subscribe(s) {
|
|
519
|
-
return n ? n(
|
|
522
|
+
return n ? n(He(s)) : v;
|
|
520
523
|
},
|
|
521
524
|
async refresh() {
|
|
522
525
|
await r.refresh();
|
|
@@ -527,11 +530,11 @@ function E(r) {
|
|
|
527
530
|
return {
|
|
528
531
|
data: void 0,
|
|
529
532
|
errors: r,
|
|
530
|
-
subscribe: () =>
|
|
531
|
-
refresh:
|
|
533
|
+
subscribe: () => v,
|
|
534
|
+
refresh: A
|
|
532
535
|
};
|
|
533
536
|
}
|
|
534
|
-
function
|
|
537
|
+
function Fe({
|
|
535
538
|
bundle: r,
|
|
536
539
|
url: e,
|
|
537
540
|
executeRaw: t
|
|
@@ -544,9 +547,9 @@ function He({
|
|
|
544
547
|
cacheControl: c,
|
|
545
548
|
headers: f
|
|
546
549
|
}) {
|
|
547
|
-
const h =
|
|
550
|
+
const h = _(a);
|
|
548
551
|
if (h.isErr()) return E(h.error);
|
|
549
|
-
const p = h.value, m =
|
|
552
|
+
const p = h.value, m = k(p, o);
|
|
550
553
|
if (m !== "query")
|
|
551
554
|
return E([
|
|
552
555
|
{
|
|
@@ -557,7 +560,7 @@ function He({
|
|
|
557
560
|
try {
|
|
558
561
|
l = new Le(
|
|
559
562
|
{
|
|
560
|
-
query:
|
|
563
|
+
query: P(p),
|
|
561
564
|
variables: i,
|
|
562
565
|
operationName: o,
|
|
563
566
|
cacheControl: c,
|
|
@@ -566,34 +569,34 @@ function He({
|
|
|
566
569
|
n,
|
|
567
570
|
e
|
|
568
571
|
);
|
|
569
|
-
} catch (
|
|
570
|
-
return E(d(
|
|
572
|
+
} catch (g) {
|
|
573
|
+
return E(d(g));
|
|
571
574
|
}
|
|
572
|
-
return
|
|
575
|
+
return Ie(l);
|
|
573
576
|
}
|
|
574
577
|
return {
|
|
575
578
|
query: s,
|
|
576
579
|
mutate: (a) => H(t, a)
|
|
577
580
|
};
|
|
578
581
|
}
|
|
579
|
-
const
|
|
580
|
-
class
|
|
582
|
+
const Ke = 1, Ue = `@salesforce/platform-sdk-data_v${Ke}`, U = F(), Ve = `${U}/ui-api`, N = `${U}/graphql`;
|
|
583
|
+
class xe {
|
|
581
584
|
baseUrl;
|
|
582
585
|
clientFetch;
|
|
583
586
|
onStatus;
|
|
584
587
|
graphql;
|
|
585
588
|
constructor(e) {
|
|
586
|
-
const t =
|
|
587
|
-
this.baseUrl =
|
|
589
|
+
const t = Ge();
|
|
590
|
+
this.baseUrl = Qe(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = Oe({
|
|
588
591
|
csrf: {
|
|
589
|
-
endpoint: `${this.baseUrl}${
|
|
590
|
-
cacheName:
|
|
592
|
+
endpoint: `${this.baseUrl}${Ve}/session/csrf`,
|
|
593
|
+
cacheName: Ue,
|
|
591
594
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
592
595
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
593
596
|
}
|
|
594
597
|
});
|
|
595
|
-
const n = (a, i) => this.fetch(a, i), s =
|
|
596
|
-
this.graphql =
|
|
598
|
+
const n = (a, i) => this.fetch(a, i), s = Ne(this.baseUrl, n);
|
|
599
|
+
this.graphql = Fe({
|
|
597
600
|
bundle: s,
|
|
598
601
|
url: N,
|
|
599
602
|
executeRaw: this.executeRawGraphQL.bind(this)
|
|
@@ -618,7 +621,7 @@ class Ke {
|
|
|
618
621
|
return (await this.fetch(N, {
|
|
619
622
|
method: "POST",
|
|
620
623
|
body: JSON.stringify({ query: e, variables: t, operationName: n }),
|
|
621
|
-
headers:
|
|
624
|
+
headers: L(s)
|
|
622
625
|
})).json();
|
|
623
626
|
}
|
|
624
627
|
/**
|
|
@@ -635,55 +638,59 @@ class Ke {
|
|
|
635
638
|
return e;
|
|
636
639
|
}
|
|
637
640
|
}
|
|
638
|
-
function
|
|
641
|
+
function Ge() {
|
|
639
642
|
return {
|
|
640
643
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
641
644
|
};
|
|
642
645
|
}
|
|
643
|
-
function
|
|
646
|
+
function Qe(r) {
|
|
644
647
|
if (!r || r === "/") return "";
|
|
645
648
|
let e = r;
|
|
646
649
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
647
650
|
}
|
|
648
|
-
async function
|
|
651
|
+
async function je(r, e, t = /* @__PURE__ */ new Set()) {
|
|
649
652
|
if (e.length === 0)
|
|
650
653
|
return r;
|
|
651
|
-
const
|
|
652
|
-
for (const
|
|
653
|
-
if (
|
|
654
|
+
const n = Object.create(r);
|
|
655
|
+
for (const s of e) {
|
|
656
|
+
if (t.has(s.name))
|
|
654
657
|
throw new Error(
|
|
655
|
-
`Plugin "${
|
|
658
|
+
`Plugin "${s.name}" cannot attach: "${s.name}" is a reserved SDK name.`
|
|
656
659
|
);
|
|
657
|
-
|
|
660
|
+
if (s.name in n)
|
|
661
|
+
throw new Error(
|
|
662
|
+
`Plugin "${s.name}" cannot attach: "${s.name}" is already defined on the SDK.`
|
|
663
|
+
);
|
|
664
|
+
let a;
|
|
658
665
|
try {
|
|
659
|
-
|
|
660
|
-
} catch (
|
|
661
|
-
throw new Error(`Plugin "${
|
|
666
|
+
a = await s.setup(n);
|
|
667
|
+
} catch (i) {
|
|
668
|
+
throw new Error(`Plugin "${s.name}" failed during setup.`, { cause: i });
|
|
662
669
|
}
|
|
663
|
-
Object.defineProperty(
|
|
664
|
-
value:
|
|
670
|
+
Object.defineProperty(n, s.name, {
|
|
671
|
+
value: a,
|
|
665
672
|
enumerable: !0,
|
|
666
673
|
writable: !0,
|
|
667
674
|
configurable: !0
|
|
668
675
|
});
|
|
669
676
|
}
|
|
670
|
-
return
|
|
677
|
+
return n;
|
|
671
678
|
}
|
|
672
|
-
function
|
|
679
|
+
function or(r, ...e) {
|
|
673
680
|
let t = r[0] ?? "";
|
|
674
681
|
for (let n = 0; n < e.length; n += 1)
|
|
675
682
|
t += String(e[n]) + (r[n + 1] ?? "");
|
|
676
683
|
return t;
|
|
677
684
|
}
|
|
678
|
-
const
|
|
679
|
-
async function
|
|
685
|
+
const ir = G();
|
|
686
|
+
async function ze(r) {
|
|
680
687
|
try {
|
|
681
688
|
switch (await V(r?.surface)) {
|
|
682
689
|
case y.OpenAI:
|
|
683
690
|
return new me();
|
|
684
691
|
case y.WebApp:
|
|
685
692
|
case y.MicroFrontend:
|
|
686
|
-
return new
|
|
693
|
+
return new xe(r?.webapp);
|
|
687
694
|
case y.Mosaic:
|
|
688
695
|
return new le(r?.mosaic);
|
|
689
696
|
case y.MCPApps:
|
|
@@ -695,17 +702,17 @@ async function Qe(r) {
|
|
|
695
702
|
return {};
|
|
696
703
|
}
|
|
697
704
|
}
|
|
698
|
-
function
|
|
705
|
+
function cr(r) {
|
|
699
706
|
return x(
|
|
700
707
|
(async () => {
|
|
701
|
-
const e = await
|
|
702
|
-
return
|
|
708
|
+
const e = await ze(r);
|
|
709
|
+
return je(e, r?.plugins ?? [], be);
|
|
703
710
|
})(),
|
|
704
711
|
"createDataSDK"
|
|
705
712
|
);
|
|
706
713
|
}
|
|
707
714
|
export {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
715
|
+
cr as createDataSDK,
|
|
716
|
+
ir as defineDataPlugin,
|
|
717
|
+
or as gql
|
|
711
718
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/data/reserved.ts"],"names":[],"mappings":"AAmBA,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAA2C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.54.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
127
127
|
"@conduit-client/service-retry": "3.19.6",
|
|
128
128
|
"@conduit-client/utils": "3.19.6",
|
|
129
|
-
"@salesforce/jsonrpc": "^11.
|
|
129
|
+
"@salesforce/jsonrpc": "^11.54.0",
|
|
130
130
|
"@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|