@salesforce/platform-sdk 12.6.3 → 12.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/chat/index.js +12 -10
- package/dist/core/extension-attach.d.ts.map +1 -1
- package/dist/core/extension-types.d.ts.map +1 -1
- package/dist/data/index.d.ts +8 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +283 -256
- package/dist/data/mosaic/fetch.d.ts +21 -17
- package/dist/data/mosaic/fetch.d.ts.map +1 -1
- package/dist/data/mosaic/index.d.ts +11 -0
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/dist/data/shared/graphql/cache/invoker.d.ts.map +1 -1
- package/dist/lightning/index.js +5 -4
- package/dist/telemetry/uploader/interfaces.d.ts.map +1 -1
- package/dist/view/index.js +55 -53
- package/dist/view/utils.d.ts.map +1 -1
- package/docs/data/01-grounding-and-precedence.md +2 -0
- package/docs/data/06-extensions.md +147 -0
- package/package.json +3 -3
|
@@ -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
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
8
|
-
/**
|
|
9
|
-
|
|
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;
|
|
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;
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../../../../src/data/shared/graphql/cache/invoker.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,KAAK,EAAgB,WAAW,EAAmB,MAAM,uBAAuB,CAAC;AAuDxF,wBAAsB,qBAAqB,CAAC,CAAC,EAC5C,OAAO,EAAE,sCAAsC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACxE,YAAY,UAAQ,GAClB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../../../../src/data/shared/graphql/cache/invoker.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,KAAK,EAAgB,WAAW,EAAmB,MAAM,uBAAuB,CAAC;AAuDxF,wBAAsB,qBAAqB,CAAC,CAAC,EAC5C,OAAO,EAAE,sCAAsC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACxE,YAAY,UAAQ,GAClB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAsCzB"}
|
package/dist/lightning/index.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
1
|
+
import { g as n, S as r } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { w as a } from "../sdk-promise-D0sy7OW1.js";
|
|
3
3
|
import { requireSharedSession as c } from "../ui-embedding/session.js";
|
|
4
4
|
class t {
|
|
5
5
|
// @ts-expect-error TS6138: `session` is unread until the first method body lands
|
|
6
6
|
constructor(e) {
|
|
7
7
|
this.session = e;
|
|
8
8
|
}
|
|
9
|
+
session;
|
|
9
10
|
static async create() {
|
|
10
11
|
const e = await c("EmbeddingLightningSDK");
|
|
11
12
|
return new t(e);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
function f(s) {
|
|
15
|
-
return
|
|
16
|
+
return a(
|
|
16
17
|
(async () => {
|
|
17
18
|
let e;
|
|
18
19
|
try {
|
|
19
|
-
e = await
|
|
20
|
+
e = await n(s?.surface);
|
|
20
21
|
} catch {
|
|
21
22
|
return {};
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/telemetry/uploader/interfaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/telemetry/uploader/interfaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACtB,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,kBAAkB,GAAG,UAAU,GAAG,SAAS,CAAC;AAE7F,MAAM,WAAW,oBAAoB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,WAAW,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAChC,YAAY,EAAE,UAAU,EACxB,OAAO,EAAE,sBAAsB,KAC3B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,WAAW,6BAA8B,SAAQ,sBAAsB;IAC5E,KAAK,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACxC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,6BAA6B,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,WAAW,2BAA2B;IAC3C,sBAAsB,IAAI,OAAO,EAAE,CAAC;IACpC,gBAAgB,IAAI,OAAO,EAAE,CAAC;IAC9B,oBAAoB,IAAI,OAAO,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAChC,oBAAoB,CAAC,IAAI,OAAO,CAAC;IACjC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAChE;AAED,MAAM,WAAW,oBAAoB;IACpC,wBAAwB,CAAC,UAAU,EAAE,2BAA2B,GAAG,IAAI,CAAC;CACxE;AAED,MAAM,WAAW,mBAAmB;IACnC,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7F,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAChE,oBAAoB,CAAC,IAAI,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB"}
|
package/dist/view/index.js
CHANGED
|
@@ -19,16 +19,16 @@ function u(i, e) {
|
|
|
19
19
|
return `${f(e)} ${i}`;
|
|
20
20
|
}
|
|
21
21
|
function o(i, e) {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
22
|
+
const s = i.trim();
|
|
23
|
+
if (s === "")
|
|
24
24
|
return { success: !0, value: void 0 };
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
25
|
+
const t = s.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
26
|
+
if (!t || !t[1])
|
|
27
27
|
return {
|
|
28
28
|
success: !1,
|
|
29
29
|
error: `Invalid ${e}: "${i}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
30
30
|
};
|
|
31
|
-
const r = parseFloat(
|
|
31
|
+
const r = parseFloat(t[1]);
|
|
32
32
|
return r < 0 || !isFinite(r) ? {
|
|
33
33
|
success: !1,
|
|
34
34
|
error: `Invalid ${e}: "${i}". Value must be a positive number.`
|
|
@@ -39,9 +39,10 @@ class l extends EventTarget {
|
|
|
39
39
|
constructor(e) {
|
|
40
40
|
super(), this.session = e;
|
|
41
41
|
}
|
|
42
|
+
session;
|
|
42
43
|
static async create() {
|
|
43
|
-
const e = await m("EmbeddingViewSDK"),
|
|
44
|
-
return await Promise.all([
|
|
44
|
+
const e = await m("EmbeddingViewSDK"), s = new l(e);
|
|
45
|
+
return await Promise.all([s.subscribeToHostEvent(), s.subscribeToUiState()]), s;
|
|
45
46
|
}
|
|
46
47
|
// Latest snapshot, refreshed on every host push. Session-scoped — the wire subscription
|
|
47
48
|
// is opened once at create() and never torn down.
|
|
@@ -73,10 +74,10 @@ class l extends EventTarget {
|
|
|
73
74
|
composed: e.composed,
|
|
74
75
|
cancelable: e.cancelable
|
|
75
76
|
});
|
|
76
|
-
} catch (
|
|
77
|
+
} catch (s) {
|
|
77
78
|
console.warn(
|
|
78
79
|
`[EmbeddingViewSDK] wire dispatch failed for "${e.type}"; local listeners will still fire`,
|
|
79
|
-
|
|
80
|
+
s
|
|
80
81
|
);
|
|
81
82
|
}
|
|
82
83
|
return super.dispatchEvent(e);
|
|
@@ -101,9 +102,9 @@ class l extends EventTarget {
|
|
|
101
102
|
return {
|
|
102
103
|
state: this.currentUiState,
|
|
103
104
|
subscribe: (e) => {
|
|
104
|
-
const
|
|
105
|
-
return this.uiStateListeners.add(
|
|
106
|
-
this.uiStateListeners.delete(
|
|
105
|
+
const s = e;
|
|
106
|
+
return this.uiStateListeners.add(s), () => {
|
|
107
|
+
this.uiStateListeners.delete(s);
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
};
|
|
@@ -115,13 +116,13 @@ class l extends EventTarget {
|
|
|
115
116
|
this.setDirty(!1, e);
|
|
116
117
|
}
|
|
117
118
|
/** Resize the embedded surface. Pass `""` for either axis to leave it unchanged; both empty is a no-op. */
|
|
118
|
-
async resize(e,
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
const r = o(
|
|
119
|
+
async resize(e, s) {
|
|
120
|
+
const t = o(e, "width");
|
|
121
|
+
if (!t.success) throw new Error(t.error);
|
|
122
|
+
const r = o(s, "height");
|
|
122
123
|
if (!r.success) throw new Error(r.error);
|
|
123
|
-
|
|
124
|
-
...
|
|
124
|
+
t.value === void 0 && r.value === void 0 || this.session.bridge.sendResize({
|
|
125
|
+
...t.value !== void 0 ? { width: t.value } : {},
|
|
125
126
|
...r.value !== void 0 ? { height: r.value } : {}
|
|
126
127
|
});
|
|
127
128
|
}
|
|
@@ -130,8 +131,8 @@ class l extends EventTarget {
|
|
|
130
131
|
* entry point is {@link dispatchEvent}, which calls this in addition to notifying
|
|
131
132
|
* local listeners.
|
|
132
133
|
*/
|
|
133
|
-
dispatchHostEvent(e,
|
|
134
|
-
this.session.bridge.sendEventDispatch(e,
|
|
134
|
+
dispatchHostEvent(e, s, t) {
|
|
135
|
+
this.session.bridge.sendEventDispatch(e, s, t);
|
|
135
136
|
}
|
|
136
137
|
/**
|
|
137
138
|
* Open the host's event stream and pipe inbound host-pushed events onto this
|
|
@@ -151,22 +152,22 @@ class l extends EventTarget {
|
|
|
151
152
|
*/
|
|
152
153
|
async subscribeToHostEvent() {
|
|
153
154
|
const e = this.session.bridge;
|
|
154
|
-
e.onEventDispatch((
|
|
155
|
+
e.onEventDispatch((s) => {
|
|
155
156
|
super.dispatchEvent(
|
|
156
|
-
new CustomEvent(
|
|
157
|
-
detail:
|
|
158
|
-
bubbles:
|
|
159
|
-
composed:
|
|
160
|
-
cancelable:
|
|
157
|
+
new CustomEvent(s.eventType, {
|
|
158
|
+
detail: s.detail,
|
|
159
|
+
bubbles: s.bubbles ?? !0,
|
|
160
|
+
composed: s.composed ?? !0,
|
|
161
|
+
cancelable: s.cancelable ?? !1
|
|
161
162
|
})
|
|
162
163
|
);
|
|
163
164
|
});
|
|
164
165
|
try {
|
|
165
166
|
await e.sendEventSubscribe();
|
|
166
|
-
} catch (
|
|
167
|
+
} catch (s) {
|
|
167
168
|
console.warn(
|
|
168
169
|
"[EmbeddingViewSDK] host event subscription failed; inbound host events will not be delivered",
|
|
169
|
-
|
|
170
|
+
s
|
|
170
171
|
);
|
|
171
172
|
}
|
|
172
173
|
}
|
|
@@ -181,11 +182,11 @@ class l extends EventTarget {
|
|
|
181
182
|
*/
|
|
182
183
|
async subscribeToUiState() {
|
|
183
184
|
const e = this.session.bridge;
|
|
184
|
-
e.onUiStateChanged((
|
|
185
|
-
this.currentUiState =
|
|
186
|
-
for (const
|
|
185
|
+
e.onUiStateChanged((s) => {
|
|
186
|
+
this.currentUiState = s.current;
|
|
187
|
+
for (const t of this.uiStateListeners)
|
|
187
188
|
try {
|
|
188
|
-
s
|
|
189
|
+
t(s.current);
|
|
189
190
|
} catch (r) {
|
|
190
191
|
console.error(
|
|
191
192
|
"[EmbeddingViewSDK] ui-state listener threw; continuing to notify remaining listeners",
|
|
@@ -194,20 +195,20 @@ class l extends EventTarget {
|
|
|
194
195
|
}
|
|
195
196
|
});
|
|
196
197
|
try {
|
|
197
|
-
const { current:
|
|
198
|
-
this.currentUiState =
|
|
199
|
-
} catch (
|
|
198
|
+
const { current: s } = await e.sendUiStateSubscribe();
|
|
199
|
+
this.currentUiState = s;
|
|
200
|
+
} catch (s) {
|
|
200
201
|
console.warn(
|
|
201
202
|
"[EmbeddingViewSDK] ui-state subscription failed; getUiState will return an empty snapshot",
|
|
202
|
-
|
|
203
|
+
s
|
|
203
204
|
);
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
setDirty(e,
|
|
207
|
+
setDirty(e, s) {
|
|
207
208
|
this.session.bridge.sendEventDispatch(b, {
|
|
208
209
|
isDirty: e,
|
|
209
210
|
instanceId: this.session.hostMetaData.instanceId,
|
|
210
|
-
label:
|
|
211
|
+
label: s ?? ""
|
|
211
212
|
});
|
|
212
213
|
}
|
|
213
214
|
}
|
|
@@ -215,19 +216,20 @@ class g {
|
|
|
215
216
|
constructor(e) {
|
|
216
217
|
this.session = e;
|
|
217
218
|
}
|
|
219
|
+
session;
|
|
218
220
|
/**
|
|
219
221
|
* Send a formatted message to the host via ui/message
|
|
220
222
|
* @param message - The message text
|
|
221
223
|
* @param level - The message severity level (defaults to "info")
|
|
222
224
|
*/
|
|
223
|
-
async sendMessage(e,
|
|
224
|
-
const
|
|
225
|
+
async sendMessage(e, s = "info") {
|
|
226
|
+
const t = u(e, s);
|
|
225
227
|
await this.session.request("ui/message", {
|
|
226
228
|
role: "user",
|
|
227
229
|
content: [
|
|
228
230
|
{
|
|
229
231
|
type: "text",
|
|
230
|
-
text:
|
|
232
|
+
text: t
|
|
231
233
|
}
|
|
232
234
|
]
|
|
233
235
|
});
|
|
@@ -245,25 +247,25 @@ class g {
|
|
|
245
247
|
const e = this.session.getHostContext().theme;
|
|
246
248
|
return e ? { mode: e } : null;
|
|
247
249
|
}
|
|
248
|
-
async resize(e,
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
251
|
-
return Promise.reject(new Error(
|
|
252
|
-
const r = o(
|
|
250
|
+
async resize(e, s) {
|
|
251
|
+
const t = o(e, "width");
|
|
252
|
+
if (!t.success)
|
|
253
|
+
return Promise.reject(new Error(t.error));
|
|
254
|
+
const r = o(s, "height");
|
|
253
255
|
if (!r.success)
|
|
254
256
|
return Promise.reject(new Error(r.error));
|
|
255
257
|
const c = {};
|
|
256
|
-
return
|
|
258
|
+
return t.value !== void 0 && (c.width = t.value), r.value !== void 0 && (c.height = r.value), this.session.sendNotification("ui/notifications/size-changed", c), Promise.resolve();
|
|
257
259
|
}
|
|
258
260
|
}
|
|
259
261
|
class v {
|
|
260
262
|
async displayAlert(e) {
|
|
261
|
-
const
|
|
262
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
263
|
+
const s = e.level || "info", t = u(e.message, s);
|
|
264
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
263
265
|
}
|
|
264
266
|
async displayToast(e) {
|
|
265
|
-
const
|
|
266
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
267
|
+
const s = e.level || "info", t = u(e.message, s);
|
|
268
|
+
await window.openai.sendFollowUpMessage({ prompt: t });
|
|
267
269
|
}
|
|
268
270
|
async displayModal(e) {
|
|
269
271
|
await window.openai.requestModal({
|
|
@@ -299,8 +301,8 @@ function y(i) {
|
|
|
299
301
|
case n.MicroFrontend:
|
|
300
302
|
return await l.create();
|
|
301
303
|
case n.MCPApps: {
|
|
302
|
-
const
|
|
303
|
-
return new g(
|
|
304
|
+
const s = await w.getInstance();
|
|
305
|
+
return new g(s);
|
|
304
306
|
}
|
|
305
307
|
default:
|
|
306
308
|
return {};
|
package/dist/view/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/view/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAa3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAGnF;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/view/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAa3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAGnF;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC/B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,oBAAoB,CAiCzF"}
|
|
@@ -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.
|
|
3
|
+
"version": "12.7.0",
|
|
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.
|
|
150
|
+
"@salesforce/jsonrpc": "^12.7.0",
|
|
151
151
|
"@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"tsx": "^4.21.0",
|
|
160
160
|
"vite": "^7.3.5",
|
|
161
161
|
"vite-plugin-dts": "^4.5.4",
|
|
162
|
-
"vitest": "^4.
|
|
162
|
+
"vitest": "^4.1.11"
|
|
163
163
|
},
|
|
164
164
|
"publishConfig": {
|
|
165
165
|
"access": "public"
|