@salesforce/platform-sdk 12.6.2 → 12.6.3-canary.999.2.1.gd0b2ab15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,6 +47,12 @@ const result = await sdk.graphql?.query<GetAccountsQuery>({
47
47
 
48
48
  The chat, view, lightning, telemetry, and analytics surfaces follow the same pattern — see [Migrating from individual SDK packages](#migrating-from-individual-sdk-packages) for the full set of factories.
49
49
 
50
+ ## Data SDK extensions
51
+
52
+ Attach reusable APIs under `sdk.ext` with `createDataSDK({ extensions: [...] })`.
53
+ See [Data SDK extensions](./docs/data/06-extensions.md) for first-party labels,
54
+ custom extension authoring, aliases, and capability guards.
55
+
50
56
  ## Instrumenting a widget
51
57
 
52
58
  `createAnalytics` is the recommended entry point for Mosaic widget tiles and other MCP-embedded UI components. It wires an `o11y` instrumented app, a Proxy-wrapped `ChatSDK` for auto-instrumentation, global error listeners, and an optional upload transport — all from one call.
@@ -34,6 +34,8 @@ export type { MosaicDataSDKOptions };
34
34
  /**
35
35
  * A extension authored for the DataSDK surface: {@link Extension} with the base SDK
36
36
  * pre-applied to `DataSDK`. Author these with {@link defineDataExtension}.
37
+ *
38
+ * @see docs/data/06-extensions.md
37
39
  */
38
40
  export interface DataSDKExtension<Name extends string = string, Api = unknown> extends Extension<DataSDK, Name, Api> {
39
41
  /**
@@ -59,6 +61,8 @@ export interface DataSDKExtension<Name extends string = string, Api = unknown> e
59
61
  * The identity implementation is intentional: its value is contextual typing at
60
62
  * the extension object definition, plus literal-name and Data-specific
61
63
  * metadata validation while `Name` and `Api` remain inferred.
64
+ *
65
+ * @see docs/data/06-extensions.md
62
66
  */
63
67
  export declare function defineDataExtension<const Name extends string, Api>(extension: DataSDKExtension<LiteralName<Name>, Api>): DataSDKExtension<Name, Api>;
64
68
  /**
@@ -67,11 +71,13 @@ export declare function defineDataExtension<const Name extends string, Api>(exte
67
71
  * `{ extension, as }` aliases; each mounts under its effective key (the alias when
68
72
  * present) inside `ext`, so aliasing is reflected here for free. A extension-less
69
73
  * tuple resolves to a plain {@link DataSDK} with no `ext` key.
74
+ *
75
+ * @see docs/data/06-extensions.md
70
76
  */
71
77
  export type DataSDKWithExtensions<Extensions extends ExtensionsFor<DataSDK>> = ExtendedSDK<DataSDK, Extensions>;
72
78
  /**
73
79
  * Options for creating a DataSDK instance — surface selection plus the
74
- * per-surface option bags (`webapp`, `mosaic`) and any `plugins`.
80
+ * per-surface option bags (`webapp`, `mosaic`) and any `extensions`.
75
81
  *
76
82
  * @see docs/data/04-surfaces-and-guards.md
77
83
  */
@@ -138,6 +144,7 @@ export interface DataSDKOptions extends SDKOptions {
138
144
  * }
139
145
  * ```
140
146
  *
147
+ * @see docs/data/06-extensions.md
141
148
  * @see docs/data/01-grounding-and-precedence.md
142
149
  */
143
150
  export declare function createDataSDK<const Extensions extends ExtensionsFor<DataSDK> = []>(options?: Omit<DataSDKOptions, "extensions"> & {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKpE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;AAE3D;;;;;GAKG;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;IACnD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,YAAY,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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;;;;;;;GAOG;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"}
@@ -1,135 +1,149 @@
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) {
1
+ import { g as K, S as b } from "../surface-Dd2tqrPi.js";
2
+ import { w as z } from "../sdk-promise-D0sy7OW1.js";
3
+ import { buildServiceDescriptor as V, setHeader as y } from "@conduit-client/service-fetch-network/v1";
4
+ import { resolvedPromiseLike as l, ok as x, err as O, stableJSONStringify as J, DataNotFoundError as W, UserVisibleError as B, deepFreeze as w, isUserVisibleError as X } from "@conduit-client/utils";
5
+ import { print as $, parse as Y } from "@conduit-client/onestore-graphql-parser/v1";
6
+ import { RetryPolicy as Z, buildServiceDescriptor as ee } from "@conduit-client/service-retry/v1";
7
+ import { buildServiceDescriptor as te } from "@conduit-client/service-cache/v1";
8
+ import { buildServiceDescriptor as re } from "@conduit-client/service-cache-control/v1";
9
+ import { buildInMemoryCacheInclusionPolicyService as ne } from "@conduit-client/service-cache-inclusion-policy/v1";
10
+ import { buildServiceDescriptor as se } from "@conduit-client/service-pubsub/v1";
11
+ import { HttpCacheControlCommand as ae } from "@conduit-client/command-http-cache-control/v1";
12
+ const g = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
13
+ function oe(t, e) {
14
+ const [, r, n] = g.exec(t), [, a, s] = g.exec(e);
15
+ return Number(r) - Number(a) || Number(n) - Number(s);
16
+ }
17
+ function ie(t, e) {
18
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))
19
+ const n = r.extension, { label: a } = r, s = n.minApiVersion;
20
+ if (s !== void 0) {
21
+ if (typeof s != "string" || !g.test(s))
22
22
  throw new TypeError(
23
- `Extension ${s} declares invalid minApiVersion ${JSON.stringify(a)}; expected a Salesforce API version such as "64.0".`
23
+ `Extension ${a} declares invalid minApiVersion ${JSON.stringify(s)}; expected a Salesforce API version such as "64.0".`
24
24
  );
25
25
  if (e.apiVersion !== void 0) {
26
- if (!v.test(e.apiVersion))
26
+ if (!g.test(e.apiVersion))
27
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)}.`
28
+ `Extension ${a} requires Salesforce API version ${s} or later, but the Data SDK exposes invalid apiVersion ${JSON.stringify(e.apiVersion)}.`
29
29
  );
30
- if (se(e.apiVersion, a) < 0)
30
+ if (oe(e.apiVersion, s) < 0)
31
31
  throw new Error(
32
- `Extension ${s} requires Salesforce API version ${a} or later, but the Data SDK uses version ${e.apiVersion}.`
32
+ `Extension ${a} requires Salesforce API version ${s} or later, but the Data SDK uses version ${e.apiVersion}.`
33
33
  );
34
34
  }
35
35
  }
36
36
  }
37
37
  }
38
- function oe(t) {
39
- return (e) => {
40
- const [r, n] = e;
41
- if (typeof r == "string" && !r.startsWith("http")) {
42
- const s = r.startsWith("/") ? r : `/${r}`;
43
- return l([`${t}${s}`, n]);
38
+ const ce = "X-Salesforce-First-Party";
39
+ function ue(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 he(t, e, r) {
45
+ return !e || !r ? !1 : ue(t?.headers, ce);
46
+ }
47
+ function S(t, e, r) {
48
+ return e ? r ? y("Cookie", `sid=${e}`, t) : y("Authorization", `Bearer ${e}`, t) : t;
49
+ }
50
+ function le({
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 he(o, n, r) ? l(
61
+ S([`${r}${i}`, o], e, !0)
62
+ ) : l(S([`${t}${i}`, o], e, !1));
44
63
  }
45
- return l(e);
64
+ return l(S(a, e, !1));
46
65
  };
47
66
  }
48
- function ie(t) {
49
- return (e) => l(b("Authorization", `Bearer ${t}`, e));
50
- }
51
- function ce(t, e) {
52
- const r = [];
53
- return t && r.push(oe(t)), e && r.push(ie(e)), M({
54
- request: r
55
- }).service;
67
+ function de(t) {
68
+ const e = t.baseUrl || t.accessToken ? [le(t)] : [];
69
+ return V({ request: e }).service;
56
70
  }
57
- const ue = {
71
+ const pe = {
58
72
  "Content-Type": "application/json",
59
73
  Accept: "application/json",
60
74
  "X-Chatter-Entity-Encoding": "false"
61
75
  };
62
- function he(t) {
76
+ function fe(t) {
63
77
  if (t instanceof Headers) {
64
78
  const e = [];
65
79
  return t.forEach((r, n) => e.push([n, r])), e;
66
80
  }
67
81
  return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
68
82
  }
69
- function V(t, e) {
83
+ function I(t, e) {
70
84
  if (e === void 0) return { ...t };
71
85
  const r = { ...t }, n = /* @__PURE__ */ new Map();
72
- for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
73
- const s = /* @__PURE__ */ new Set();
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));
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 fe(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));
77
91
  }
78
92
  return r;
79
93
  }
80
- function L(t) {
81
- return V(ue, t);
94
+ function H(t) {
95
+ return I(pe, t);
82
96
  }
83
- function le(t) {
97
+ function me(t) {
84
98
  if (t === void 0) return;
85
99
  const e = {};
86
100
  return new Headers(t).forEach((r, n) => {
87
101
  e[n] = r;
88
102
  }), Object.keys(e).length > 0 ? e : void 0;
89
103
  }
90
- const pe = 512;
91
- function de(t) {
104
+ const ye = 512;
105
+ function be(t) {
92
106
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
93
107
  }
94
- class P extends Error {
108
+ class _ extends Error {
95
109
  status;
96
110
  url;
97
111
  constructor(e) {
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)))})`;
112
+ const r = e.body.length === 0 ? "empty response body" : "unparseable response body", n = e.body.length === 0 ? "" : ` (starts with: ${JSON.stringify(be(e.body.slice(0, ye)))})`;
99
113
  super(
100
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.`
101
115
  ), this.name = "GraphQLTransportError", this.status = e.status, this.url = e.url, this.cause = e.cause;
102
116
  }
103
117
  }
104
- async function I(t, e, r) {
118
+ async function G(t, e, r) {
105
119
  const n = await t.text();
106
- let s;
120
+ let a;
107
121
  try {
108
- s = JSON.parse(n);
109
- } catch (a) {
110
- throw new P({ surface: e, url: r, status: t.status, body: n, cause: a });
122
+ a = JSON.parse(n);
123
+ } catch (s) {
124
+ throw new _({ surface: e, url: r, status: t.status, body: n, cause: s });
111
125
  }
112
- if (s === null || typeof s != "object")
113
- throw new P({
126
+ if (a === null || typeof a != "object")
127
+ throw new _({
114
128
  surface: e,
115
129
  url: r,
116
130
  status: t.status,
117
131
  body: n,
118
132
  cause: new Error("Parsed GraphQL response body was not a JSON object")
119
133
  });
120
- return s;
134
+ return a;
121
135
  }
122
- const g = () => {
123
- }, O = async () => {
136
+ const v = () => {
137
+ }, N = async () => {
124
138
  };
125
- function $(t) {
139
+ function A(t) {
126
140
  try {
127
- return x(B(t));
141
+ return x(Y(t));
128
142
  } catch (e) {
129
- return D(m(e));
143
+ return O(m(e));
130
144
  }
131
145
  }
132
- function q(t, e) {
146
+ function P(t, e) {
133
147
  const r = t.definitions.filter(
134
148
  (n) => n.kind === "OperationDefinition"
135
149
  );
@@ -143,10 +157,10 @@ function m(t) {
143
157
  }
144
158
  return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
145
159
  }
146
- async function G(t, { mutation: e, variables: r, operationName: n, headers: s }) {
147
- const a = $(e);
148
- if (a.isErr()) return { data: void 0, errors: a.error };
149
- const o = a.value, i = q(o, n);
160
+ async function F(t, { mutation: e, variables: r, operationName: n, headers: a }) {
161
+ const s = A(e);
162
+ if (s.isErr()) return { data: void 0, errors: s.error };
163
+ const o = s.value, i = P(o, n);
150
164
  if (i !== "mutation")
151
165
  return {
152
166
  data: void 0,
@@ -158,10 +172,10 @@ async function G(t, { mutation: e, variables: r, operationName: n, headers: s })
158
172
  };
159
173
  try {
160
174
  const c = await t({
161
- query: N(o),
175
+ query: $(o),
162
176
  variables: r,
163
177
  operationName: n,
164
- headers: s
178
+ headers: a
165
179
  });
166
180
  return {
167
181
  data: c.data ?? void 0,
@@ -171,12 +185,12 @@ async function G(t, { mutation: e, variables: r, operationName: n, headers: s })
171
185
  return { data: void 0, errors: m(c) };
172
186
  }
173
187
  }
174
- function H(t) {
175
- function e(n, s, a, o) {
188
+ function U(t) {
189
+ function e(n, a, s, o) {
176
190
  return t({
177
- query: N(n),
178
- variables: s,
179
- operationName: a,
191
+ query: $(n),
192
+ variables: a,
193
+ operationName: s,
180
194
  headers: o
181
195
  }).then(
182
196
  (i) => ({
@@ -188,19 +202,19 @@ function H(t) {
188
202
  }
189
203
  async function r({
190
204
  query: n,
191
- variables: s,
192
- operationName: a,
205
+ variables: a,
206
+ operationName: s,
193
207
  headers: o
194
208
  }) {
195
- const i = $(n);
209
+ const i = A(n);
196
210
  if (i.isErr())
197
211
  return {
198
212
  data: void 0,
199
213
  errors: i.error,
200
- subscribe: () => g,
201
- refresh: O
214
+ subscribe: () => v,
215
+ refresh: N
202
216
  };
203
- const c = i.value, h = q(c, a);
217
+ const c = i.value, h = P(c, s);
204
218
  if (h !== "query")
205
219
  return {
206
220
  data: void 0,
@@ -209,78 +223,87 @@ function H(t) {
209
223
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${h}.`
210
224
  }
211
225
  ],
212
- subscribe: () => g,
213
- refresh: O
226
+ subscribe: () => v,
227
+ refresh: N
214
228
  };
215
- const u = /* @__PURE__ */ new Set(), d = s, f = await e(c, d, a, o);
229
+ const u = /* @__PURE__ */ new Set(), p = a, f = await e(c, p, s, o);
216
230
  return {
217
231
  data: f.data,
218
232
  errors: f.errors,
219
- subscribe(p) {
220
- return u.add(p), () => {
221
- u.delete(p);
233
+ subscribe(d) {
234
+ return u.add(d), () => {
235
+ u.delete(d);
222
236
  };
223
237
  },
224
238
  async refresh() {
225
- const p = await e(c, d, a, o);
226
- for (const E of u) E(p);
239
+ const d = await e(c, p, s, o);
240
+ for (const E of u) E(d);
227
241
  }
228
242
  };
229
243
  }
230
244
  return {
231
245
  query: r,
232
- mutate: (n) => G(t, n)
246
+ mutate: (n) => F(t, n)
233
247
  };
234
248
  }
235
- const A = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
236
- function U(t = A) {
249
+ const q = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
250
+ function j(t = q) {
237
251
  return `/services/data/v${t}`;
238
252
  }
239
- const fe = {
253
+ const we = {
240
254
  "Content-Type": "application/json",
241
255
  Accept: "application/json"
242
256
  };
243
- class me {
257
+ class ge {
244
258
  clientFetch;
245
259
  pathData;
246
260
  apiVersion;
247
261
  graphql;
248
262
  constructor(e) {
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));
263
+ const r = ve(), n = k(e?.instanceUrl ?? r.instanceUrl), a = e?.accessToken ?? r.accessToken, s = k(
264
+ e?.lightningDomain ?? r.lightningDomain
265
+ ), o = e?.isInternal ?? r.isInternal ?? !1;
266
+ this.apiVersion = e?.apiVersion ?? r.apiVersion ?? q, this.pathData = j(this.apiVersion), this.clientFetch = de({
267
+ baseUrl: n || void 0,
268
+ accessToken: a,
269
+ lightningDomain: s || void 0,
270
+ isInternal: o
271
+ }), this.graphql = U(this.executeRawGraphQL.bind(this));
251
272
  }
252
273
  async executeRawGraphQL({
253
274
  query: e,
254
275
  variables: r,
255
276
  operationName: n,
256
- headers: s
277
+ headers: a
257
278
  }) {
258
- const a = `${this.pathData}/graphql`, o = await this.clientFetch(a, {
279
+ const s = `${this.pathData}/graphql`, o = await this.clientFetch(s, {
259
280
  method: "POST",
260
281
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
261
- headers: V(fe, s)
282
+ headers: I(we, a)
262
283
  });
263
- return I(o, "Mosaic", a);
284
+ return G(o, "Mosaic", s);
264
285
  }
265
286
  }
266
- function ye() {
287
+ function ve() {
267
288
  const t = globalThis.MOSAIC_ENV;
268
289
  return {
269
290
  instanceUrl: t?.instanceUrl,
270
291
  accessToken: t?.accessToken,
271
- apiVersion: t?.apiVersion
292
+ apiVersion: t?.apiVersion,
293
+ lightningDomain: t?.lightningDomain,
294
+ isInternal: t?.isInternal
272
295
  };
273
296
  }
274
- function be(t) {
297
+ function k(t) {
275
298
  if (!t || t === "/") return "";
276
299
  let e = t;
277
300
  return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
278
301
  }
279
- const we = "graphqlQuery";
280
- class ve {
302
+ const Ee = "graphqlQuery";
303
+ class Se {
281
304
  graphql;
282
305
  constructor() {
283
- this.graphql = H(this.executeRawGraphQL.bind(this));
306
+ this.graphql = U(this.executeRawGraphQL.bind(this));
284
307
  }
285
308
  /**
286
309
  * The `headers` request option is intentionally not forwarded: this surface
@@ -292,52 +315,52 @@ class ve {
292
315
  variables: r,
293
316
  operationName: n
294
317
  }) {
295
- return (await window.openai.callTool(we, {
318
+ return (await window.openai.callTool(Ee, {
296
319
  query: e,
297
320
  ...r != null ? { variables: r } : {},
298
321
  ...n != null ? { operationName: n } : {}
299
322
  })).structuredContent;
300
323
  }
301
324
  }
302
- const S = "Accept-Language", ge = (t) => {
325
+ const C = "Accept-Language", Ce = (t) => {
303
326
  const e = globalThis.SFDC_ENV?.language;
304
327
  if (!e)
305
328
  return l(t);
306
329
  const [r, n] = t;
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.6.2", 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 = {}) {
330
+ return (r instanceof Request && !n?.headers ? r.headers.has(C) : new Headers(n?.headers).has(C)) ? l(t) : l(y(C, e, t));
331
+ }, De = "X-SFDC-Client-Name", xe = "X-SFDC-Client-Version", Oe = "@salesforce/platform-sdk", Ne = "12.6.3-canary.999.2.1.gd0b2ab15", $e = (t) => {
332
+ let e = y(De, Oe, t);
333
+ return e = y(xe, Ne, e), l(e);
334
+ }, Ae = "X-CSRF-Token";
335
+ function Pe(t, e = {}) {
313
336
  const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
314
- return async (s) => {
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)) {
337
+ return async (a) => {
338
+ const [s, o] = a, i = s instanceof Request ? s.url : s instanceof URL ? s.href : s, c = o?.method ?? (s instanceof Request ? s.method : void 0) ?? "GET";
339
+ if (R(n, i) || qe(c) && R(r, i)) {
317
340
  const u = await t.getToken();
318
- s = b(Oe, u, s);
341
+ a = y(Ae, u, a);
319
342
  }
320
- return l(s);
343
+ return l(a);
321
344
  };
322
345
  }
323
- function $e(t) {
346
+ function qe(t) {
324
347
  const e = t.toLowerCase();
325
348
  return e === "post" || e === "put" || e === "patch" || e === "delete";
326
349
  }
327
- function _(t, e) {
350
+ function R(t, e) {
328
351
  const r = new URL(e, globalThis.location?.href ?? "http://localhost");
329
352
  return t.some((n) => r.pathname.includes(n));
330
353
  }
331
- function qe(t, e = {}) {
332
- const r = Ne(t, e);
333
- async function n(s) {
334
- const a = await r(s);
335
- return fetch(a[0], a[1]);
354
+ function _e(t, e = {}) {
355
+ const r = Pe(t, e);
356
+ async function n(a) {
357
+ const s = await r(a);
358
+ return fetch(s[0], s[1]);
336
359
  }
337
- return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
360
+ return (a, s) => s ? s.applyRetry(async () => n(a)) : n(a);
338
361
  }
339
- const Ae = [400, 401, 403];
340
- class Pe extends X {
362
+ const ke = [400, 401, 403];
363
+ class Re extends Z {
341
364
  constructor(e) {
342
365
  super(e), this.csrfTokenManager = e;
343
366
  }
@@ -345,7 +368,7 @@ class Pe extends X {
345
368
  * Determines if a failed request should be retried due to CSRF token issues.
346
369
  */
347
370
  async shouldRetry(e, r) {
348
- return r.attempt >= 1 ? !1 : Ae.includes(e.status);
371
+ return r.attempt >= 1 ? !1 : ke.includes(e.status);
349
372
  }
350
373
  /**
351
374
  * CSRF token refresh should happen immediately with no delay.
@@ -363,7 +386,7 @@ class Pe extends X {
363
386
  await this.csrfTokenManager.refreshToken();
364
387
  }
365
388
  }
366
- class _e {
389
+ class Te {
367
390
  constructor(e, r) {
368
391
  this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
369
392
  }
@@ -392,10 +415,10 @@ class _e {
392
415
  * @returns Promise that resolves to the CSRF token string
393
416
  */
394
417
  async obtainToken() {
395
- let e = await this.withCache((s) => s.match(this.endpoint)), r = !1;
418
+ let e = await this.withCache((a) => a.match(this.endpoint)), r = !1;
396
419
  e || (e = await fetch(this.endpoint, { method: "get" }), r = !0);
397
420
  const n = (await e.clone().json()).csrfToken;
398
- return r && await this.withCache((s) => s.put(this.endpoint, e)), n;
421
+ return r && await this.withCache((a) => a.put(this.endpoint, e)), n;
399
422
  }
400
423
  /**
401
424
  * Provides a safe way to interact with the Cache API with fallback for unsupported environments.
@@ -411,29 +434,29 @@ class _e {
411
434
  return;
412
435
  }
413
436
  }
414
- const k = /* @__PURE__ */ new Map();
415
- function ke(t) {
437
+ const T = /* @__PURE__ */ new Map();
438
+ function Me(t) {
416
439
  const { endpoint: e, cacheName: r, ...n } = t.csrf;
417
- let s = k.get(e);
418
- return s || (s = new _e(e, r), k.set(e, s)), M(
440
+ let a = T.get(e);
441
+ return a || (a = new Te(e, r), T.set(e, a)), V(
419
442
  {
420
- retry: qe(s, n),
421
- request: [De, ge]
443
+ retry: _e(a, n),
444
+ request: [$e, Ce]
422
445
  },
423
- Y(new Pe(s)).service
446
+ ee(new Re(a)).service
424
447
  ).service;
425
448
  }
426
- const T = /* @__PURE__ */ new Map();
427
- function Te(t) {
428
- let e = T.get(t);
449
+ const M = /* @__PURE__ */ new Map();
450
+ function Le(t) {
451
+ let e = M.get(t);
429
452
  if (!e) {
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);
453
+ const r = te().service, n = ne(r).service, a = re(r, n).service, s = se().service;
454
+ e = { cache: r, cacheController: a, pubSub: s }, M.set(t, e);
432
455
  }
433
456
  return e;
434
457
  }
435
- function Re(t, e) {
436
- const r = Te(t);
458
+ function Ve(t, e) {
459
+ const r = Le(t);
437
460
  return {
438
461
  shared: r,
439
462
  services: {
@@ -443,30 +466,30 @@ function Re(t, e) {
443
466
  }
444
467
  };
445
468
  }
446
- const R = 300;
447
- function Me(t, e) {
469
+ const L = 300;
470
+ function Ie(t, e) {
448
471
  try {
449
472
  return JSON.parse(JSON.stringify(t));
450
473
  } catch (r) {
451
- const n = e || "(anonymous)", s = new TypeError(
474
+ const n = e || "(anonymous)", a = new TypeError(
452
475
  `HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${r.message}`
453
476
  );
454
- throw s.cause = r, s;
477
+ throw a.cause = r, a;
455
478
  }
456
479
  }
457
- function Ve(t) {
480
+ function He(t) {
458
481
  if (typeof t == "object" && t.type === "max-age") {
459
482
  const e = t.maxAge;
460
- return Number.isFinite(e) && e >= 0 ? e : R;
483
+ return Number.isFinite(e) && e >= 0 ? e : L;
461
484
  }
462
- return R;
485
+ return L;
463
486
  }
464
- class Le extends ne {
487
+ class Ge extends ae {
465
488
  constructor(e, r, n) {
466
- super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Me(
489
+ super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Ie(
467
490
  e.variables ?? {},
468
491
  this.normalizedOperationName
469
- ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Ve(e.cacheControl), this.headers = e.headers, this.headersKey = le(e.headers);
492
+ ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = He(e.cacheControl), this.headers = e.headers, this.headersKey = me(e.headers);
470
493
  }
471
494
  query;
472
495
  normalizedVariables;
@@ -480,7 +503,7 @@ class Le extends ne {
480
503
  this.url,
481
504
  {
482
505
  method: "POST",
483
- headers: L(this.headers),
506
+ headers: H(this.headers),
484
507
  body: JSON.stringify({
485
508
  query: this.query,
486
509
  variables: this.normalizedVariables,
@@ -495,7 +518,7 @@ class Le extends ne {
495
518
  variables: this.normalizedVariables,
496
519
  operationName: this.normalizedOperationName
497
520
  };
498
- return this.headersKey !== void 0 && (e.headers = this.headersKey), K(e);
521
+ return this.headersKey !== void 0 && (e.headers = this.headersKey), J(e);
499
522
  }
500
523
  /**
501
524
  * Reads from the cache and returns the cache result or error
@@ -513,7 +536,7 @@ class Le extends ne {
513
536
  readFromCache(e) {
514
537
  const r = this.buildKey(), n = e.get(r)?.value;
515
538
  return n === void 0 ? l(
516
- D(new z("No cached entry found for this query."))
539
+ O(new W("No cached entry found for this query."))
517
540
  ) : l(x(n));
518
541
  }
519
542
  writeToCache(e, r) {
@@ -544,90 +567,90 @@ class Le extends ne {
544
567
  return e.errors && e.errors.length > 0;
545
568
  }
546
569
  processFetchReturnValue(e) {
547
- return this.responseHasErrors(e) ? D(new J(e)) : x(e);
570
+ return this.responseHasErrors(e) ? O(new B(e)) : x(e);
548
571
  }
549
572
  }
550
- const Ie = "CACHE_MISS";
551
- function Ge() {
573
+ const Fe = "CACHE_MISS";
574
+ function Ue() {
552
575
  return [
553
576
  {
554
577
  message: "No cached entry found for this query (cacheControl: 'only-if-cached').",
555
- extensions: { code: Ie }
578
+ extensions: { code: Fe }
556
579
  }
557
580
  ];
558
581
  }
559
- function F(t) {
560
- if (W(t) && t.data && typeof t.data == "object") {
582
+ function Q(t) {
583
+ if (X(t) && t.data && typeof t.data == "object") {
561
584
  const e = t.data;
562
585
  if (e.data != null)
563
586
  return e.data;
564
587
  }
565
588
  }
566
- function He(t) {
589
+ function je(t) {
567
590
  return (e) => {
568
591
  if (e.isOk()) {
569
592
  const r = e.value;
570
593
  w(r), t({ data: r, errors: void 0 });
571
594
  } else {
572
- const r = F(e.error);
595
+ const r = Q(e.error);
573
596
  r && w(r), t({ data: r, errors: m(e.error) });
574
597
  }
575
598
  };
576
599
  }
577
- async function Ue(t, e = !1) {
578
- let r, n, s;
600
+ async function Qe(t, e = !1) {
601
+ let r, n, a;
579
602
  try {
580
- const a = await t.execute();
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));
582
- } catch (a) {
583
- n = m(a);
603
+ const s = await t.execute();
604
+ s.isOk() ? (r = s.value.data, w(r), a = (o) => s.value.subscribe(o)) : (r = Q(s.error.failure), r && w(r), n = e && r === void 0 ? Ue() : m(s.error.failure), a = (o) => s.error.subscribe(o));
605
+ } catch (s) {
606
+ n = m(s);
584
607
  }
585
608
  return {
586
609
  data: r,
587
610
  errors: n,
588
- subscribe(a) {
589
- return s ? s(He(a)) : g;
611
+ subscribe(s) {
612
+ return a ? a(je(s)) : v;
590
613
  },
591
614
  async refresh() {
592
615
  await t.refresh();
593
616
  }
594
617
  };
595
618
  }
596
- function C(t) {
619
+ function D(t) {
597
620
  return {
598
621
  data: void 0,
599
622
  errors: t,
600
- subscribe: () => g,
601
- refresh: O
623
+ subscribe: () => v,
624
+ refresh: N
602
625
  };
603
626
  }
604
- function Fe({
627
+ function Ke({
605
628
  bundle: t,
606
629
  url: e,
607
630
  executeRaw: r
608
631
  }) {
609
632
  const { services: n } = t;
610
- async function s({
611
- query: a,
633
+ async function a({
634
+ query: s,
612
635
  variables: o,
613
636
  operationName: i,
614
637
  cacheControl: c,
615
638
  headers: h
616
639
  }) {
617
- const u = $(a);
618
- if (u.isErr()) return C(u.error);
619
- const d = u.value, f = q(d, i);
640
+ const u = A(s);
641
+ if (u.isErr()) return D(u.error);
642
+ const p = u.value, f = P(p, i);
620
643
  if (f !== "query")
621
- return C([
644
+ return D([
622
645
  {
623
646
  message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
624
647
  }
625
648
  ]);
626
- let p;
649
+ let d;
627
650
  try {
628
- p = new Le(
651
+ d = new Ge(
629
652
  {
630
- query: N(d),
653
+ query: $(p),
631
654
  variables: o,
632
655
  operationName: i,
633
656
  cacheControl: c,
@@ -637,17 +660,17 @@ function Fe({
637
660
  e
638
661
  );
639
662
  } catch (E) {
640
- return C(m(E));
663
+ return D(m(E));
641
664
  }
642
- return Ue(p, c === "only-if-cached");
665
+ return Qe(d, c === "only-if-cached");
643
666
  }
644
667
  return {
645
- query: s,
646
- mutate: (a) => G(r, a)
668
+ query: a,
669
+ mutate: (s) => F(r, s)
647
670
  };
648
671
  }
649
- const Qe = 1, je = `@salesforce/platform-sdk-data_v${Qe}`;
650
- class Ke {
672
+ const ze = 1, Je = `@salesforce/platform-sdk-data_v${ze}`;
673
+ class We {
651
674
  baseUrl;
652
675
  pathData;
653
676
  clientFetch;
@@ -655,27 +678,27 @@ class Ke {
655
678
  apiVersion;
656
679
  graphql;
657
680
  constructor(e) {
658
- const r = ze();
659
- this.baseUrl = Je(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? A, this.pathData = U(this.apiVersion);
660
- const n = `${this.pathData}/ui-api`, s = `${this.pathData}/graphql`;
661
- this.onStatus = e?.onStatus ?? {}, this.clientFetch = ke({
681
+ const r = Be();
682
+ this.baseUrl = Xe(e?.basePath ?? r.apiPath), this.apiVersion = e?.apiVersion ?? q, this.pathData = j(this.apiVersion);
683
+ const n = `${this.pathData}/ui-api`, a = `${this.pathData}/graphql`;
684
+ this.onStatus = e?.onStatus ?? {}, this.clientFetch = Me({
662
685
  csrf: {
663
686
  endpoint: `${this.baseUrl}${n}/session/csrf`,
664
- cacheName: je,
687
+ cacheName: Je,
665
688
  protectedUrls: ["services/data/v", "services/apexrest"],
666
689
  alwaysProtectedUrls: ["services/apexrest"]
667
690
  }
668
691
  });
669
- const a = (i, c) => this.fetch(i, c), o = Re(`${this.baseUrl}${this.pathData}`, a);
670
- this.graphql = Fe({
692
+ const s = (i, c) => this.fetch(i, c), o = Ve(`${this.baseUrl}${this.pathData}`, s);
693
+ this.graphql = Ke({
671
694
  bundle: o,
672
- url: s,
695
+ url: a,
673
696
  executeRaw: this.executeRawGraphQL.bind(this)
674
697
  });
675
698
  }
676
699
  async fetch(e, r) {
677
- const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
678
- return await this.onStatus[s.status]?.(), s;
700
+ const n = this.applySalesforceBase(e), a = await this.clientFetch(n, r);
701
+ return await this.onStatus[a.status]?.(), a;
679
702
  }
680
703
  /**
681
704
  * Raw GraphQL POST. On the WebApp surface this is the mutate-only path:
@@ -687,14 +710,14 @@ class Ke {
687
710
  query: e,
688
711
  variables: r,
689
712
  operationName: n,
690
- headers: s
713
+ headers: a
691
714
  }) {
692
- const a = `${this.pathData}/graphql`, o = await this.fetch(a, {
715
+ const s = `${this.pathData}/graphql`, o = await this.fetch(s, {
693
716
  method: "POST",
694
717
  body: JSON.stringify({ query: e, variables: r, operationName: n }),
695
- headers: L(s)
718
+ headers: H(a)
696
719
  });
697
- return I(o, "WebApp", a);
720
+ return G(o, "WebApp", s);
698
721
  }
699
722
  /**
700
723
  * If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
@@ -710,44 +733,44 @@ class Ke {
710
733
  return e;
711
734
  }
712
735
  }
713
- function ze() {
736
+ function Be() {
714
737
  return {
715
738
  apiPath: globalThis.SFDC_ENV?.apiPath
716
739
  };
717
740
  }
718
- function Je(t) {
741
+ function Xe(t) {
719
742
  if (!t || t === "/") return "";
720
743
  let e = t;
721
744
  return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
722
745
  }
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")
746
+ function Ye(t) {
747
+ const e = t, r = typeof e == "object" && e !== null ? e : void 0, n = r !== void 0 && "setup" in r, a = n ? r : r?.extension, s = n ? a?.name : r?.as;
748
+ if (typeof a?.setup != "function")
726
749
  throw new Error("Extension entry cannot attach: it is missing a setup function.");
727
- if (typeof a != "string" || a.length === 0)
750
+ if (typeof s != "string" || s.length === 0)
728
751
  throw new Error(
729
752
  n ? 'Extension entry cannot attach: "name" must be a non-empty string.' : 'Extension entry cannot attach: alias "as" must be a non-empty string.'
730
753
  );
731
754
  return {
732
- extension: s,
733
- mountName: a,
734
- label: a === s.name ? `"${s.name}"` : `"${s.name}" (aliased as "${a}")`
755
+ extension: a,
756
+ mountName: s,
757
+ label: s === a.name ? `"${a.name}"` : `"${a.name}" (aliased as "${s}")`
735
758
  };
736
759
  }
737
- async function Be(t, e, r) {
760
+ async function Ze(t, e, r) {
738
761
  if (e.length === 0)
739
762
  return t;
740
763
  if ("ext" in t)
741
764
  throw new Error(
742
765
  'Cannot attach extensions: the base SDK already declares an "ext" member, which the extension container reserves.'
743
766
  );
744
- const n = e.map(We);
767
+ const n = e.map(Ye);
745
768
  r?.preflight?.(n, t);
746
- const s = Object.create(t), a = /* @__PURE__ */ Object.create(null), o = (h) => {
769
+ const a = Object.create(t), s = /* @__PURE__ */ Object.create(null), o = (h) => {
747
770
  throw new Error(`Cannot write "ext.${String(h)}" — ext is immutable once attached.`);
748
771
  }, i = (h) => {
749
772
  throw new Error(`Cannot ${h} "ext" — ext is immutable once attached.`);
750
- }, c = new Proxy(a, {
773
+ }, c = new Proxy(s, {
751
774
  set(h, u) {
752
775
  return o(u);
753
776
  },
@@ -768,52 +791,52 @@ async function Be(t, e, r) {
768
791
  return i("change the prototype of");
769
792
  }
770
793
  });
771
- Object.defineProperty(s, "ext", {
794
+ Object.defineProperty(a, "ext", {
772
795
  value: c,
773
796
  enumerable: !0,
774
797
  writable: !1,
775
798
  configurable: !1
776
799
  });
777
- for (const { extension: h, mountName: u, label: d } of n) {
778
- if (Object.hasOwn(a, u))
800
+ for (const { extension: h, mountName: u, label: p } of n) {
801
+ if (Object.hasOwn(s, u))
779
802
  throw new Error(
780
- `Extension ${d} cannot attach: "${u}" is already defined by another extension.`
803
+ `Extension ${p} cannot attach: "${u}" is already defined by another extension.`
781
804
  );
782
805
  let f;
783
806
  try {
784
- f = await h.setup(s);
785
- } catch (p) {
786
- throw new Error(`Extension ${d} failed during setup.`, { cause: p });
807
+ f = await h.setup(a);
808
+ } catch (d) {
809
+ throw new Error(`Extension ${p} failed during setup.`, { cause: d });
787
810
  }
788
- Object.defineProperty(a, u, {
811
+ Object.defineProperty(s, u, {
789
812
  value: f,
790
813
  enumerable: !0,
791
814
  writable: !1,
792
815
  configurable: !1
793
816
  });
794
817
  }
795
- return Object.freeze(a), s;
818
+ return Object.freeze(s), a;
796
819
  }
797
- function ut(t, ...e) {
820
+ function dt(t, ...e) {
798
821
  let r = t[0] ?? "";
799
822
  for (let n = 0; n < e.length; n += 1)
800
823
  r += String(e[n]) + (t[n + 1] ?? "");
801
824
  return r;
802
825
  }
803
- function ht(t) {
826
+ function pt(t) {
804
827
  return t;
805
828
  }
806
- async function Xe(t) {
829
+ async function et(t) {
807
830
  try {
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:
831
+ switch (await K(t?.surface)) {
832
+ case b.OpenAI:
833
+ return new Se();
834
+ case b.WebApp:
835
+ case b.MicroFrontend:
836
+ return new We(t?.webapp);
837
+ case b.Mosaic:
838
+ return new ge(t?.mosaic);
839
+ case b.MCPApps:
817
840
  return {};
818
841
  default:
819
842
  return {};
@@ -822,19 +845,19 @@ async function Xe(t) {
822
845
  return {};
823
846
  }
824
847
  }
825
- function lt(t) {
826
- return j(
848
+ function ft(t) {
849
+ return z(
827
850
  (async () => {
828
- const e = await Xe(t);
829
- return Be(e, t?.extensions ?? [], {
830
- preflight: ae
851
+ const e = await et(t);
852
+ return Ze(e, t?.extensions ?? [], {
853
+ preflight: ie
831
854
  });
832
855
  })(),
833
856
  "createDataSDK"
834
857
  );
835
858
  }
836
859
  export {
837
- lt as createDataSDK,
838
- ht as defineDataExtension,
839
- ut as gql
860
+ ft as createDataSDK,
861
+ pt as defineDataExtension,
862
+ dt as gql
840
863
  };
@@ -1,21 +1,25 @@
1
1
  import { FetchService, RequestInterceptor } from '@conduit-client/service-fetch-network/v1';
2
+ /** Configuration for the Mosaic fetch transport. */
3
+ interface MosaicFetchConfig {
4
+ /** My-domain base URL for resolving relative paths (e.g., "https://myorg.salesforce.com"). */
5
+ baseUrl?: string;
6
+ /** Access token; sent as a bearer header, or as the sid cookie on a lightning pivot. */
7
+ accessToken?: string;
8
+ /** Lightning-domain base URL for UITier (first-party) requests. */
9
+ lightningDomain?: string;
10
+ /** Whether this widget is trusted to pivot first-party requests to the lightning domain. */
11
+ isInternal?: boolean;
12
+ }
2
13
  /**
3
- * Creates a request interceptor that prepends a base URL to relative string URLs.
4
- *
5
- * @param baseUrl - The base URL to prepend (e.g. "https://myorg.salesforce.com")
14
+ * The single request interceptor for the Mosaic transport. Routing and auth are
15
+ * resolved together so they cannot diverge: a first-party request from a trusted
16
+ * widget is routed to the lightning domain with sid-cookie auth; everything else
17
+ * goes to my-domain with bearer auth. The pivot only fires for a relative URL
18
+ * being rewritten against `baseUrl`, so the sid cookie can never attach unless
19
+ * the request is actually bound for the lightning domain.
6
20
  */
7
- export declare function createBaseUrlInterceptor(baseUrl: string): RequestInterceptor;
8
- /**
9
- * Creates a request interceptor that adds an Authorization Bearer header.
10
- *
11
- * @param accessToken - The access token to use for authentication
12
- */
13
- export declare function createAuthInterceptor(accessToken: string): RequestInterceptor;
14
- /**
15
- * Creates a fetch service configured with optional base URL and auth interceptors.
16
- *
17
- * @param baseUrl - Optional base URL for resolving relative paths
18
- * @param accessToken - Optional access token for Bearer authentication
19
- */
20
- export declare function createMosaicFetchService(baseUrl?: string, accessToken?: string): FetchService;
21
+ export declare function createMosaicInterceptor({ baseUrl, accessToken, lightningDomain, isInternal, }: MosaicFetchConfig): RequestInterceptor;
22
+ /** Creates a fetch service configured with the Mosaic request interceptor. */
23
+ export declare function createMosaicFetchService(config: MosaicFetchConfig): FetchService;
24
+ export {};
21
25
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,MAAM,0CAA0C,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAS5E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,kBAAkB,CAI7E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAY7F"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,MAAM,0CAA0C,CAAC;AA0ClD,oDAAoD;AACpD,UAAU,iBAAiB;IAC1B,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,EACvC,OAAO,EACP,WAAW,EACX,eAAe,EACf,UAAkB,GAClB,EAAE,iBAAiB,GAAG,kBAAkB,CAkBxC;AAED,8EAA8E;AAC9E,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,GAAG,YAAY,CAKhF"}
@@ -21,6 +21,17 @@ export interface MosaicDataSDKOptions {
21
21
  * @example "64.0"
22
22
  */
23
23
  apiVersion?: string;
24
+ /**
25
+ * The lightning domain base URL used for UITier (first-party) requests
26
+ * when the widget is trusted as internal.
27
+ * @example "https://my-domain.lightning.force.com"
28
+ */
29
+ lightningDomain?: string;
30
+ /**
31
+ * Marks this widget as internal/trusted, enabling the lightning-domain
32
+ * pivot for first-party (UITier) requests. Defaults to false.
33
+ */
34
+ isInternal?: boolean;
24
35
  }
25
36
  /**
26
37
  * Data SDK implementation for the Mosaic surface (Node.js / server-side).
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAe3F;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;YAc5B,iBAAiB;CAe/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAe3F;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;YAuB5B,iBAAiB;CAe/B"}
@@ -73,6 +73,8 @@ contract, per-surface behaviour, and examples live in
73
73
  `sdk.graphql!` vs guard, reading `errors`, the `.fetch` escape hatch, per-surface options.
74
74
  - [05-migration-from-sdk-data.md](./05-migration-from-sdk-data.md) — old callable API → new
75
75
  namespace API.
76
+ - [06-extensions.md](./06-extensions.md) — consuming and authoring extensions, aliases,
77
+ capability guards, and setup lifecycle.
76
78
 
77
79
  ## Deep-path `.d.ts` are for reading, not importing
78
80
 
@@ -0,0 +1,147 @@
1
+ <!-- sdk-symbols
2
+ DataSDK: dist/core/data.d.ts
3
+ createDataSDK: dist/data/index.d.ts
4
+ defineDataExtension: dist/data/index.d.ts
5
+ DataSDKExtension: dist/data/index.d.ts
6
+ DataSDKWithExtensions: dist/data/index.d.ts
7
+ DataSDKOptions: dist/data/index.d.ts
8
+ Extension: dist/core/extension-types.d.ts
9
+ ExtendedSDK: dist/core/extension-types.d.ts
10
+ labels: dist/data/extensions/labels/index.d.ts
11
+ LabelsApi: dist/data/extensions/labels/index.d.ts
12
+ LabelsOptions: dist/data/extensions/labels/index.d.ts
13
+ -->
14
+
15
+ # Data SDK extensions
16
+
17
+ Extensions add an instance-bound API under `sdk.ext.<name>`. Use an existing extension
18
+ when it provides the operation you need; author one when you need a reusable domain API
19
+ built on the DataSDK. An extension does not add a new host capability or make an
20
+ unsupported data-access member available.
21
+
22
+ Read `createDataSDK`, `defineDataExtension`, `DataSDKExtension`, and
23
+ `DataSDKWithExtensions` in `dist/data/index.d.ts` for the attachment and authoring
24
+ signatures. `Extension` and `ExtendedSDK` in `dist/core/extension-types.d.ts` own the
25
+ shared contract and namespace inference. `DataSDK` in `dist/core/data.d.ts` owns the
26
+ base capabilities that an extension can use. These are paths to read, not deep imports.
27
+ Follow [grounding and precedence](./01-grounding-and-precedence.md): the installed
28
+ `.d.ts` wins if this narrative disagrees with it.
29
+
30
+ ## Consume an extension
31
+
32
+ Import the factory from `@salesforce/platform-sdk/data` and first-party extensions
33
+ from the exported `@salesforce/platform-sdk/data/extensions` catalog:
34
+
35
+ ```ts
36
+ import { createDataSDK } from "@salesforce/platform-sdk/data";
37
+ import { labels } from "@salesforce/platform-sdk/data/extensions";
38
+
39
+ const sdk = await createDataSDK({
40
+ extensions: [labels({ namespace: "MyApp" })],
41
+ });
42
+ const greeting = (await sdk.ext.labels.get?.("greeting")) ?? "Hello";
43
+ ```
44
+
45
+ The namespace is present because the extension was attached. Its methods can still be
46
+ optional: `labels` mounts an empty API on a surface without `graphql`. Guard the method
47
+ before calling, or use optional chaining and an application fallback as above. A missing
48
+ method and an unresolved label are different conditions even if the UI uses the same
49
+ fallback. Request failures still reject; `??` does not catch errors.
50
+
51
+ The labels extension requires Salesforce API v64.0 or later. See `labels`, `LabelsApi`,
52
+ and `LabelsOptions` in `dist/data/extensions/labels/index.d.ts` for locale, namespace,
53
+ translation fallback, per-call overrides, and batched reads. Prefer `getAll` for a bounded
54
+ set of labels instead of issuing a separate request for every label.
55
+
56
+ ## Preserve inference and resolve collisions
57
+
58
+ Keep the extensions array inline, or preserve it as a tuple with `as const` when extracting
59
+ options. A widened `DataSDKExtension[]` loses the known names and does not promise `ext`
60
+ in the result type. With no extensions (or an empty tuple), the factory returns the base
61
+ SDK without an `ext` container.
62
+
63
+ Each effective mount name must be unique. Use aliases when consuming two extensions
64
+ with the same name; an alias changes the key under `ext`, not the underlying extension:
65
+
66
+ ```ts
67
+ import { createDataSDK } from "@salesforce/platform-sdk/data";
68
+ import { labels } from "@salesforce/platform-sdk/data/extensions";
69
+
70
+ const options = {
71
+ extensions: [
72
+ { extension: labels({ namespace: "Sales" }), as: "salesLabels" },
73
+ { extension: labels({ namespace: "Support" }), as: "supportLabels" },
74
+ ] as const,
75
+ };
76
+ const sdk = await createDataSDK(options);
77
+ const title = (await sdk.ext.salesLabels.get?.("title")) ?? "Sales";
78
+ ```
79
+
80
+ Use one concrete string literal for each name or alias. Do not widen it to `string` or
81
+ use a union of possible names: that would claim namespaces the runtime may not mount.
82
+ Do not assign to `sdk.ext` or add, replace, or delete its namespace bindings. The
83
+ container is immutable; this does not imply that every object returned by an extension
84
+ is deeply frozen.
85
+
86
+ ## Author an extension
87
+
88
+ Use `defineDataExtension` to infer the base SDK parameter and preserve the literal name.
89
+ Keep configuration in a factory closure and put instance-specific work in `setup`.
90
+ This example exposes an authenticated JSON request helper only where `fetch` is available:
91
+
92
+ ```ts
93
+ import { createDataSDK, defineDataExtension } from "@salesforce/platform-sdk/data";
94
+
95
+ interface JsonApi {
96
+ get?(path: string): Promise<unknown>;
97
+ }
98
+
99
+ const json = defineDataExtension({
100
+ name: "json",
101
+ setup(sdk): JsonApi {
102
+ const sdkFetch = sdk.fetch?.bind(sdk);
103
+ if (!sdkFetch) return {};
104
+ return {
105
+ async get(path) {
106
+ const response = await sdkFetch(path);
107
+ if (!response.ok) throw new Error(`Request failed: ${response.status}`);
108
+ return response.json();
109
+ },
110
+ };
111
+ },
112
+ });
113
+
114
+ // Attach and call the newly created extension.
115
+ const sdk = await createDataSDK({ extensions: [json] });
116
+ const versions = await sdk.ext.json.get?.("/services/data/");
117
+ ```
118
+
119
+ Choose an endpoint supported by the active surface before calling this helper. Prefer
120
+ `graphql` for schema-supported operations and SDK `fetch` for other supported endpoints;
121
+ see [04-surfaces-and-guards.md](./04-surfaces-and-guards.md). Reuse the bound SDK's auth
122
+ and caching behavior instead of constructing another transport or a parallel GraphQL
123
+ cache inside the extension.
124
+
125
+ Declare `minApiVersion` when an extension requires a Salesforce API capability introduced
126
+ in a particular version. On versioned surfaces, the factory checks every declared minimum
127
+ against the resolved SDK API version before running any setup. Surfaces without a comparable
128
+ version skip that comparison, so version metadata does not replace capability guards.
129
+
130
+ ## Setup, failure, and lifecycle
131
+
132
+ - Setup runs in array order and may return an API synchronously or asynchronously. Await
133
+ `createDataSDK` before accessing the mounted APIs.
134
+ - Each attachment uses a fresh SDK view. A setup failure rejects creation without returning
135
+ a partially extended SDK or mounting namespaces on the original base instance. This is
136
+ not a rollback of network requests, subscriptions, or other side effects performed by setup.
137
+ - Keep setups independent. Typed cross-extension dependencies are not supported by this
138
+ version; do not cast the base SDK to access another extension or rely on attachment order
139
+ as a dependency mechanism. The reserved `Deps` type parameter is not a usable dependency API.
140
+ - There is no automatic extension teardown hook. If your API creates subscriptions or other
141
+ resources, expose and invoke its cleanup explicitly. For GraphQL subscriptions, follow
142
+ [03-reactive-handle-lifecycle.md](./03-reactive-handle-lifecycle.md).
143
+
144
+ Use `extensions`, `defineDataExtension`, `DataSDKExtension`, and `DataSDKWithExtensions`
145
+ for this API. Older references to `plugins`, `defineDataPlugin`, `DataSDKPlugin`, or
146
+ `DataSDKWithPlugins` do not describe the current names. Extension methods live under
147
+ `sdk.ext`, not on the SDK root.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/platform-sdk",
3
- "version": "12.6.2",
3
+ "version": "12.6.3-canary.999.2.1.gd0b2ab15",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -147,7 +147,7 @@
147
147
  "@conduit-client/service-pubsub": "3.19.6",
148
148
  "@conduit-client/service-retry": "3.19.6",
149
149
  "@conduit-client/utils": "3.19.6",
150
- "@salesforce/jsonrpc": "^12.6.2",
150
+ "@salesforce/jsonrpc": "12.6.3-canary.999.2.1.gd0b2ab15",
151
151
  "@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
152
152
  },
153
153
  "peerDependencies": {