@salesforce/platform-sdk 11.49.4 → 11.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -7
- package/dist/core/plugin-attach.d.ts +37 -0
- package/dist/core/plugin-attach.d.ts.map +1 -0
- package/dist/core/plugin-factory.d.ts +42 -0
- package/dist/core/plugin-factory.d.ts.map +1 -0
- package/dist/core/plugin-types.d.ts +158 -0
- package/dist/core/plugin-types.d.ts.map +1 -0
- package/dist/data/index.d.ts +31 -4
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +163 -132
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -32
- package/dist/plugin-factory-BC3b3BOy.js +8 -0
- package/package.json +4 -4
package/dist/core/index.d.ts
CHANGED
|
@@ -17,4 +17,6 @@ export type { McpAppsHostContext, McpAppsSessionOptions } from './mcpapps-sessio
|
|
|
17
17
|
export { getSurfaceCapabilities } from './capabilities';
|
|
18
18
|
export type { SurfaceCapabilities } from './capabilities';
|
|
19
19
|
export { wrapSDKPromise } from './sdk-promise';
|
|
20
|
+
export { createPluginFactory } from './plugin-factory';
|
|
21
|
+
export type { Plugin, AnyPlugin, PluginsFor, PluginEntry, ExtendedSDK, LiteralName, UniquePluginNames, } from './plugin-types';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,YAAY,GACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGnD,YAAY,EAAE,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X,iBAAiB,GACjB,MAAM,gBAAgB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { M as r, a as s, S as i, g as
|
|
2
|
-
import { g as
|
|
1
|
+
import { M as r, a as s, S as i, g as o, i as p, b as t, r as f } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { g as S } from "../capabilities-5BWkCbcP.js";
|
|
3
3
|
import { w as g } from "../sdk-promise-D0sy7OW1.js";
|
|
4
|
+
import { c as u } from "../plugin-factory-BC3b3BOy.js";
|
|
4
5
|
export {
|
|
5
6
|
r as McpAppsNotAvailableError,
|
|
6
7
|
s as McpAppsSession,
|
|
7
8
|
i as Surface,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
t as
|
|
9
|
+
u as createPluginFactory,
|
|
10
|
+
S as getSurfaceCapabilities,
|
|
11
|
+
o as getVerifiedSurface,
|
|
12
|
+
p as initialize,
|
|
13
|
+
t as isSfEmbeddingIframe,
|
|
14
|
+
f as resetSurface,
|
|
13
15
|
g as wrapSDKPromise
|
|
14
16
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ExtendedSDK, PluginsFor } from './plugin-types';
|
|
2
|
+
/**
|
|
3
|
+
* Run each plugin's `setup` in array order and mount the returned namespace
|
|
4
|
+
* under the plugin's `name`. `setup` may be sync or async; each is `await`ed
|
|
5
|
+
* before the next runs, so the ordering is deterministic.
|
|
6
|
+
*
|
|
7
|
+
* Each `setup` receives the base SDK, and that is all the type promises it:
|
|
8
|
+
* `setup(sdk)` is typed as `Base`, never the accumulating shape. Because every
|
|
9
|
+
* namespace mounts onto one shared object (below), a later plugin *can* reach
|
|
10
|
+
* an earlier plugin's namespace at runtime — but that reachability is an
|
|
11
|
+
* untyped byproduct, not a WI-1 contract to build on. Typed cross-plugin
|
|
12
|
+
* access (a plugin declaring the namespaces it needs and receiving them in
|
|
13
|
+
* `setup`) is WI-3, via the reserved `Deps` seam on {@link Plugin}; until then,
|
|
14
|
+
* author setups as independent.
|
|
15
|
+
*
|
|
16
|
+
* Atomic and non-mutating: namespaces mount onto a fresh object whose prototype
|
|
17
|
+
* is `base`, so the base's own and inherited members resolve through the
|
|
18
|
+
* prototype chain (and `instanceof` still holds) while `base` itself is never
|
|
19
|
+
* written to. If any `setup` throws, the half-built object is simply discarded
|
|
20
|
+
* and `base` is left pristine — there is nothing to roll back. This keeps
|
|
21
|
+
* attach safe against a memoized/shared instance (e.g. the chat/view
|
|
22
|
+
* singletons WI-4 introduces): each attach derives its own object, so a repeat
|
|
23
|
+
* attach can never collide with a prior one. The empty-plugin case returns the
|
|
24
|
+
* base instance unchanged.
|
|
25
|
+
*
|
|
26
|
+
* SDK-agnostic: `Base` is inferred from the passed instance, and `plugins` is
|
|
27
|
+
* constrained to {@link PluginsFor}<Base> so only plugins compatible with this
|
|
28
|
+
* base type may attach. The returned type is {@link ExtendedSDK}<Base, Plugins>
|
|
29
|
+
* — the base plus each plugin's resolved namespace under its own key.
|
|
30
|
+
*
|
|
31
|
+
* Fail-loud: a name already present on the base (own or inherited) or mounted
|
|
32
|
+
* earlier in this same call throws before setup runs, and a `setup` that throws
|
|
33
|
+
* or rejects surfaces as an error naming the plugin, chaining the original
|
|
34
|
+
* error via `cause`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function attachPlugins<Base extends object, const Plugins extends PluginsFor<Base>>(base: Base, plugins: Plugins): Promise<ExtendedSDK<Base, Plugins>>;
|
|
37
|
+
//# sourceMappingURL=plugin-attach.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,aAAa,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,UAAU,CAAC,IAAI,CAAC,EAC9F,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CA2DrC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LiteralName, Plugin } from './plugin-types';
|
|
2
|
+
/**
|
|
3
|
+
* Bind a plugin authoring helper to one SDK surface, so authors never annotate
|
|
4
|
+
* `setup`'s parameter. `createPluginFactory<Sdk>()` captures the base SDK once
|
|
5
|
+
* and returns a definer; each call to that definer infers only the plugin's
|
|
6
|
+
* literal `Name` and its `Api`, with `setup(sdk)` already typed as `Sdk`:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const defineDataPlugin = createPluginFactory<DataSDK>();
|
|
10
|
+
* const labels = defineDataPlugin({ name: "labels", setup: (sdk) => ({ ... }) });
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* `createDataSDK` exposes the DataSDK-bound definer as `defineDataPlugin`. This
|
|
14
|
+
* factory is also the public escape hatch for a surface with no first-party
|
|
15
|
+
* definer yet, or for an author's own SDK.
|
|
16
|
+
*
|
|
17
|
+
* ## Why a curried factory, and not a single `definePlugin<Sdk, Name, Api>`?
|
|
18
|
+
*
|
|
19
|
+
* The obvious alternative is one generic function whose caller fixes the SDK:
|
|
20
|
+
* `definePlugin<DataSDK>({ name, setup })`. TypeScript does not allow it —
|
|
21
|
+
* type-argument lists are all-or-nothing per call, so supplying `Sdk` forces
|
|
22
|
+
* you to also supply `Name` and `Api` (`Expected 3 type arguments, but got 1`),
|
|
23
|
+
* which throws away the very inference that makes the helper worth using. That
|
|
24
|
+
* leaves only one way to keep `Sdk` implicit at the value call: annotate the
|
|
25
|
+
* parameter (`setup: (sdk: DataSDK) => ...`) on every plugin. And a *forgotten*
|
|
26
|
+
* annotation does not error — it silently infers `Sdk = unknown`, a
|
|
27
|
+
* universally-attachable binding that slips a surface-specific plugin past the
|
|
28
|
+
* per-surface {@link PluginsFor} guard.
|
|
29
|
+
*
|
|
30
|
+
* Currying dodges both problems. The outer call takes `Sdk` as its only type
|
|
31
|
+
* argument and no value arguments, so nothing forces `Name`/`Api` to be spelled
|
|
32
|
+
* out; the inner call infers those from the plugin object. `Sdk` is fixed before
|
|
33
|
+
* any plugin is written, so it can be neither forgotten nor widened — the
|
|
34
|
+
* footgun is designed out rather than documented around.
|
|
35
|
+
*
|
|
36
|
+
* The returned definer is identity at runtime. It carries the {@link LiteralName}
|
|
37
|
+
* guard, which rejects a widened `string` name at definition time: without a
|
|
38
|
+
* concrete literal there is no key to accumulate onto the extended SDK, so
|
|
39
|
+
* failing loud here beats a silently dropped namespace downstream.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createPluginFactory<Sdk>(): <const Name extends string, Api>(plugin: Plugin<Sdk, LiteralName<Name>, Api>) => Plugin<Sdk, Name, Api>;
|
|
42
|
+
//# sourceMappingURL=plugin-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-factory.d.ts","sourceRoot":"","sources":["../../src/core/plugin-factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,MACT,KAAK,CAAC,IAAI,SAAS,MAAM,EAAE,GAAG,EAC1D,QAAQ,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,KACzC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAGzB"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A plugin: a named namespace factory bound to a base SDK instance at attach
|
|
8
|
+
* time. SDK-agnostic — `Sdk` is the base type this plugin's `setup` requires.
|
|
9
|
+
*
|
|
10
|
+
* The contract does not depend on any concrete SDK. Enforcement of a specific
|
|
11
|
+
* SDK happens at attach time via {@link PluginsFor}: a plugin is attachable to
|
|
12
|
+
* a base `B` only where `B` is assignable to `Sdk`. So authoring
|
|
13
|
+
* `setup(sdk: DataSDK)` type-checks the plugin against DataSDK when it is
|
|
14
|
+
* attached through `createDataSDK`, even though `Plugin` itself never imports
|
|
15
|
+
* DataSDK.
|
|
16
|
+
*
|
|
17
|
+
* Reserved — `Deps` (inert in WI-1): the trailing type parameter is the seam
|
|
18
|
+
* for WI-3 plugin dependencies. It defaults to `[]` and is referenced only
|
|
19
|
+
* through `setup`'s parameter, as `Sdk & Accumulate<Deps>`. With the default
|
|
20
|
+
* empty tuple `Accumulate<[]>` is `unknown`, and `Sdk & unknown` reduces to
|
|
21
|
+
* `Sdk`, so `setup` sees exactly the base SDK — a three-argument
|
|
22
|
+
* `Plugin<Sdk, Name, Api>` (see {@link AnyPlugin}, {@link PluginsFor}) is
|
|
23
|
+
* unchanged and no WI-1 plugin's type shifts. There is no `deps` field yet, so
|
|
24
|
+
* `attach` has no dependency to honor or silently drop.
|
|
25
|
+
*
|
|
26
|
+
* Threading it through `setup` (rather than leaving it dangling) is deliberate:
|
|
27
|
+
* an unreferenced reserved type parameter is not free — it trips
|
|
28
|
+
* `noUnusedLocals`. This makes the slot load-bearing while behaviorally a
|
|
29
|
+
* no-op. WI-3's add-back is then a pure superset: add a `deps?: Deps` field and
|
|
30
|
+
* populate the tuple, and the already-wired `setup` view lights up. The spike
|
|
31
|
+
* notes the superset holds with or without this slot, so it is kept as an
|
|
32
|
+
* explicit intent marker, not a forward-compat necessity.
|
|
33
|
+
*/
|
|
34
|
+
export interface Plugin<Sdk, Name extends string, Api, Deps extends readonly AnyPlugin[] = []> {
|
|
35
|
+
/** The single namespace key this plugin mounts under (e.g. "labels"). */
|
|
36
|
+
name: Name;
|
|
37
|
+
/**
|
|
38
|
+
* Build the plugin API. Runs at attach time with the fully-resolved,
|
|
39
|
+
* instance-bound base SDK. May be synchronous or async — return the API
|
|
40
|
+
* directly, or a promise of it (e.g. to `await` a dynamic import or a
|
|
41
|
+
* capability handshake). The resolved `Api` is what mounts under `name`.
|
|
42
|
+
*
|
|
43
|
+
* `sdk` is `Sdk & Accumulate<Deps>`; with the reserved `Deps = []` this is
|
|
44
|
+
* just `Sdk` today (see the `Deps` note above). WI-3 populates `Deps` so a
|
|
45
|
+
* plugin's declared dependencies' namespaces appear here.
|
|
46
|
+
*/
|
|
47
|
+
setup: (sdk: Sdk & Accumulate<Deps>) => Api | PromiseLike<Api>;
|
|
48
|
+
}
|
|
49
|
+
/** True iff `T` is a union of two or more members. */
|
|
50
|
+
type IsUnion<T, U = T> = T extends unknown ? ([U] extends [T] ? false : true) : never;
|
|
51
|
+
/**
|
|
52
|
+
* Reject a `name` that is not a single string literal. A concrete literal
|
|
53
|
+
* (`"labels"`) passes through unchanged; anything else collapses to `never`, so
|
|
54
|
+
* the authoring helpers error at definition time rather than silently losing key
|
|
55
|
+
* accumulation. See {@link createPluginFactory}.
|
|
56
|
+
*
|
|
57
|
+
* Two shapes are rejected, both of which would otherwise mount phantom keys:
|
|
58
|
+
* - a widened `string` (`string extends Name`) — no literal key to accumulate;
|
|
59
|
+
* - a union literal (`"a" | "b"`, e.g. from `name: cond ? "a" : "b"`) — this
|
|
60
|
+
* survives the `string extends Name` check, but {@link Accumulate}
|
|
61
|
+
* distributes over the union and types *both* `a` and `b` as present,
|
|
62
|
+
* non-optional members while `attach` mounts only one, leaving the other
|
|
63
|
+
* typed-present yet `undefined` at runtime. Requiring a single literal is
|
|
64
|
+
* what keeps the accumulated key set sound.
|
|
65
|
+
*/
|
|
66
|
+
export type LiteralName<Name extends string> = string extends Name ? never : IsUnion<Name> extends true ? never : Name;
|
|
67
|
+
/**
|
|
68
|
+
* Any plugin, for use in constraints. `never` in the (contravariant) `Sdk`
|
|
69
|
+
* slot makes every concrete `Plugin<...>` assignable to this — it is the top
|
|
70
|
+
* type over the SDK parameter.
|
|
71
|
+
*/
|
|
72
|
+
export type AnyPlugin = Plugin<never, string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* The `plugins: []` array constraint that enforces a concrete base SDK. A
|
|
75
|
+
* `Plugin<Sdk, Name, Api>` is a member iff a `Base` value is assignable
|
|
76
|
+
* to its `setup` parameter — i.e. the plugin asks for no more than `Base`
|
|
77
|
+
* provides (a plugin that ignores the SDK, `Sdk = unknown`, is universally
|
|
78
|
+
* attachable). `createDataSDK` binds `Base = DataSDK`; that is where
|
|
79
|
+
* DataSDK-specific enforcement occurs.
|
|
80
|
+
*/
|
|
81
|
+
export type PluginsFor<Base> = readonly Plugin<Base, string, unknown>[];
|
|
82
|
+
/**
|
|
83
|
+
* What may appear in the `plugins: []` array. A one-member alias today — bare
|
|
84
|
+
* plugins only — and deliberately the seam for WI-5 aliasing: that WI widens it
|
|
85
|
+
* to `AnyPlugin | AnyAliasedPlugin` so two uneditable third-party plugins that
|
|
86
|
+
* both want the same namespace (e.g. `sdk.labels`) each get a mount recourse.
|
|
87
|
+
* Everything downstream ({@link Accumulate}, {@link ExtendedSDK}) is written
|
|
88
|
+
* against `PluginEntry`, so the union lands here and nowhere else.
|
|
89
|
+
*/
|
|
90
|
+
export type PluginEntry = AnyPlugin;
|
|
91
|
+
/**
|
|
92
|
+
* The literal key a plugin mounts under. Today that is exactly its `name`;
|
|
93
|
+
* WI-5 aliasing resolves an entry's `as` over `name` here, so this stays the
|
|
94
|
+
* single place the effective mount key is computed. All mount-name-keyed logic
|
|
95
|
+
* ({@link Accumulate}, {@link DuplicateMountName}) routes through this rather
|
|
96
|
+
* than reading `name` directly, so aliased entries resolve correctly for free
|
|
97
|
+
* once WI-5 lands.
|
|
98
|
+
*/
|
|
99
|
+
type MountName<P extends AnyPlugin> = P["name"];
|
|
100
|
+
/**
|
|
101
|
+
* The resolved API a plugin's `setup` returns. `Awaited` unwraps the async
|
|
102
|
+
* case so the mounted namespace is the settled value, never a promise.
|
|
103
|
+
*/
|
|
104
|
+
type ApiOf<P extends AnyPlugin> = Awaited<ReturnType<P["setup"]>>;
|
|
105
|
+
/**
|
|
106
|
+
* Walk the plugin tuple left→right, intersecting `{ [name]: namespace }` per
|
|
107
|
+
* entry. Namespaces are non-optional: presence is a static attach fact.
|
|
108
|
+
*
|
|
109
|
+
* This intersects unconditionally: a duplicate mount name would collapse to
|
|
110
|
+
* `{ labels: A } & { labels: B }` here rather than erroring. Uniqueness is not
|
|
111
|
+
* this type's job — it is enforced up front by {@link UniquePluginNames} at the
|
|
112
|
+
* authoring boundary, with `attach`'s runtime guard as the backstop for tuples
|
|
113
|
+
* built dynamically past the static check.
|
|
114
|
+
*/
|
|
115
|
+
type Accumulate<Plugins extends readonly PluginEntry[]> = Plugins extends readonly [
|
|
116
|
+
infer Head extends PluginEntry,
|
|
117
|
+
...infer Tail extends readonly PluginEntry[]
|
|
118
|
+
] ? {
|
|
119
|
+
[K in MountName<Head>]: ApiOf<Head>;
|
|
120
|
+
} & Accumulate<Tail> : unknown;
|
|
121
|
+
/**
|
|
122
|
+
* The first mount name that repeats in the tuple, or `never` if all are
|
|
123
|
+
* distinct. Walks left→right accumulating seen names in `Seen`; the first
|
|
124
|
+
* {@link MountName} already in `Seen` is the duplicate. Keyed on `MountName`,
|
|
125
|
+
* not raw `name`, so WI-5 aliasing is a valid recourse: `[a, a]` (both mount
|
|
126
|
+
* `"labels"`) reports `"labels"`, but `[{ plugin: a, as: "x" }, { plugin: a, as:
|
|
127
|
+
* "y" }]` resolves to distinct mount names and reports `never`.
|
|
128
|
+
*/
|
|
129
|
+
type DuplicateMountName<Plugins extends readonly PluginEntry[], Seen = never> = Plugins extends readonly [
|
|
130
|
+
infer Head extends PluginEntry,
|
|
131
|
+
...infer Tail extends readonly PluginEntry[]
|
|
132
|
+
] ? [MountName<Head>] extends [Seen] ? MountName<Head> : DuplicateMountName<Tail, Seen | MountName<Head>> : never;
|
|
133
|
+
/**
|
|
134
|
+
* A constraint intersected into the `plugins` option to reject a tuple whose
|
|
135
|
+
* mount names are not unique. Resolves to `unknown` (a no-op intersection) when
|
|
136
|
+
* every mount name is distinct; otherwise to an object whose `plugins` field is
|
|
137
|
+
* a human-readable error string, which makes the supplied array inassignable
|
|
138
|
+
* and surfaces the message in the diagnostic.
|
|
139
|
+
*
|
|
140
|
+
* This moves the collision from a runtime throw (`attach` fail-loud) to a
|
|
141
|
+
* compile error at the call site. The two are complementary, not redundant:
|
|
142
|
+
* this catches statically-known tuples early with a clear message, while
|
|
143
|
+
* `attach` still guards tuples assembled dynamically (e.g. `[...a, ...b]`)
|
|
144
|
+
* whose duplicates a static check cannot see.
|
|
145
|
+
*/
|
|
146
|
+
export type UniquePluginNames<Plugins extends readonly PluginEntry[]> = [
|
|
147
|
+
DuplicateMountName<Plugins>
|
|
148
|
+
] extends [never] ? unknown : {
|
|
149
|
+
plugins: `Two plugins mount under "${DuplicateMountName<Plugins> & string}"; mount names must be unique.`;
|
|
150
|
+
};
|
|
151
|
+
/** Collapse an intersection into a single flat object type for readable hovers. */
|
|
152
|
+
type Flatten<T> = {
|
|
153
|
+
[K in keyof T]: T[K];
|
|
154
|
+
} & {};
|
|
155
|
+
/** The base SDK plus every attached plugin's namespace. */
|
|
156
|
+
export type ExtendedSDK<Base, Plugins extends readonly PluginEntry[]> = Flatten<Base & Accumulate<Plugins>>;
|
|
157
|
+
export {};
|
|
158
|
+
//# sourceMappingURL=plugin-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-types.d.ts","sourceRoot":"","sources":["../../src/core/plugin-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;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AAO,CAAC,CAC1B,CAAC"}
|
package/dist/data/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSDK, SDKOptions } from '../core';
|
|
1
|
+
import { DataSDK, ExtendedSDK, Plugin, SDKOptions, UniquePluginNames } from '../core';
|
|
2
2
|
import { MosaicDataSDKOptions } from './mosaic';
|
|
3
3
|
/**
|
|
4
4
|
* A callback the host invokes for a given HTTP status (see {@link WebAppDataSDKOptions.onStatus}).
|
|
@@ -21,6 +21,25 @@ export interface WebAppDataSDKOptions {
|
|
|
21
21
|
onStatus?: Partial<Record<number, StatusCallback>>;
|
|
22
22
|
}
|
|
23
23
|
export type { MosaicDataSDKOptions };
|
|
24
|
+
/**
|
|
25
|
+
* A plugin authored for the DataSDK surface: {@link Plugin} with the base SDK
|
|
26
|
+
* pre-applied to `DataSDK`. Author these with {@link defineDataPlugin}.
|
|
27
|
+
*/
|
|
28
|
+
export type DataSDKPlugin<Name extends string = string, Api = unknown> = Plugin<DataSDK, Name, Api>;
|
|
29
|
+
/**
|
|
30
|
+
* Author a DataSDK plugin without annotating `setup`'s parameter — the base
|
|
31
|
+
* SDK is bound to `DataSDK`, so `setup(sdk)` infers `sdk: DataSDK`. This is the
|
|
32
|
+
* recommended way to author DataSDK plugins.
|
|
33
|
+
*
|
|
34
|
+
* Because `DataSDK` is fixed here, an author can never forget the annotation
|
|
35
|
+
* and silently get `Sdk = unknown` — the universally-attachable binding that
|
|
36
|
+
* would slip a DataSDK-only plugin past the per-surface `PluginsFor` guard.
|
|
37
|
+
* Equivalent to the internal `definePlugin` with `Sdk = DataSDK` pre-applied;
|
|
38
|
+
* see {@link createPluginFactory} for the underlying mechanism.
|
|
39
|
+
*/
|
|
40
|
+
export declare const defineDataPlugin: <const Name extends string, Api>(plugin: Plugin<DataSDK, import('..').LiteralName<Name>, Api, []>) => Plugin<DataSDK, Name, Api, []>;
|
|
41
|
+
/** A DataSDK carrying every namespace contributed by an ordered plugin tuple. */
|
|
42
|
+
export type DataSDKWithPlugins<Plugins extends readonly DataSDKPlugin[]> = ExtendedSDK<DataSDK, Plugins>;
|
|
24
43
|
/**
|
|
25
44
|
* Options for creating a DataSDK instance.
|
|
26
45
|
*/
|
|
@@ -35,16 +54,22 @@ export interface DataSDKOptions extends SDKOptions {
|
|
|
35
54
|
* @example { instanceUrl: "https://my.salesforce.com", accessToken: "00D..." }
|
|
36
55
|
*/
|
|
37
56
|
mosaic?: MosaicDataSDKOptions;
|
|
57
|
+
plugins?: readonly DataSDKPlugin[];
|
|
38
58
|
}
|
|
39
59
|
/**
|
|
40
60
|
* Create and initialize a DataSDK instance based on the detected surface.
|
|
41
61
|
*
|
|
42
|
-
* @param options - Optional configuration including surface override
|
|
43
|
-
*
|
|
62
|
+
* @param options - Optional configuration including surface override, web app
|
|
63
|
+
* options, and plugins to attach
|
|
64
|
+
* @returns Promise resolving to an initialized DataSDK, extended per plugin
|
|
44
65
|
*
|
|
45
66
|
* @remarks
|
|
46
67
|
* Each call creates a new instance; options are applied to every call.
|
|
47
68
|
*
|
|
69
|
+
* When `plugins` is supplied, the result type accumulates each plugin's
|
|
70
|
+
* namespace under its own key (see {@link DataSDKWithPlugins}); otherwise it is
|
|
71
|
+
* a plain {@link DataSDK}.
|
|
72
|
+
*
|
|
48
73
|
* If the surface is unusable (e.g. MCPApps handshake never succeeded, or detection throws),
|
|
49
74
|
* the function resolves to a bare `{}` rather than rejecting, so the host still renders.
|
|
50
75
|
* Feature-detect `sdk.graphql` / `sdk.fetch` before use.
|
|
@@ -69,7 +94,9 @@ export interface DataSDKOptions extends SDKOptions {
|
|
|
69
94
|
* }
|
|
70
95
|
* ```
|
|
71
96
|
*/
|
|
72
|
-
export declare function createDataSDK(options?: DataSDKOptions
|
|
97
|
+
export declare function createDataSDK<const Plugins extends readonly DataSDKPlugin[] = []>(options?: Omit<DataSDKOptions, "plugins"> & {
|
|
98
|
+
plugins?: Plugins;
|
|
99
|
+
} & UniquePluginNames<Plugins>): Promise<DataSDKWithPlugins<Plugins>>;
|
|
73
100
|
export { gql } from './gql';
|
|
74
101
|
export type { CacheControl, DataSDK, DataSDKGraphQL, GraphQLError, GraphQLRawDocument, GraphQLRequest, GraphQLRequestHeaders, GraphQLResponse, MutateOptions, MutationResult, QueryOptions, QueryResult, QuerySubscriber, SDKOptions, Unsubscribe, } from '../core';
|
|
75
102
|
/**
|
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,UAAU,EAAE,MAAM,SAAS,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;AAKpE;;;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,M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 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
1
|
+
import { g as V, S as y } from "../surface-Dd2tqrPi.js";
|
|
2
|
+
import { w as x } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { c as G } from "../plugin-factory-BC3b3BOy.js";
|
|
3
4
|
import { buildServiceDescriptor as L, setHeader as b } from "@conduit-client/service-fetch-network/v1";
|
|
4
|
-
import { resolvedPromiseLike as u, ok as
|
|
5
|
-
import { print as
|
|
6
|
-
import { RetryPolicy as
|
|
7
|
-
import { buildServiceDescriptor as
|
|
8
|
-
import { buildServiceDescriptor as
|
|
9
|
-
import { buildInMemoryCacheInclusionPolicyService as
|
|
10
|
-
import { buildServiceDescriptor as
|
|
11
|
-
import { HttpCacheControlCommand as
|
|
12
|
-
function
|
|
5
|
+
import { resolvedPromiseLike as u, ok as C, err as D, stableJSONStringify as Q, DataNotFoundError as z, UserVisibleError as j, deepFreeze as v, isUserVisibleError as W } from "@conduit-client/utils";
|
|
6
|
+
import { print as A, parse as B } from "@conduit-client/onestore-graphql-parser/v1";
|
|
7
|
+
import { RetryPolicy as J, buildServiceDescriptor as X } from "@conduit-client/service-retry/v1";
|
|
8
|
+
import { buildServiceDescriptor as Y } from "@conduit-client/service-cache/v1";
|
|
9
|
+
import { buildServiceDescriptor as Z } from "@conduit-client/service-cache-control/v1";
|
|
10
|
+
import { buildInMemoryCacheInclusionPolicyService as ee } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
11
|
+
import { buildServiceDescriptor as re } from "@conduit-client/service-pubsub/v1";
|
|
12
|
+
import { HttpCacheControlCommand as te } from "@conduit-client/command-http-cache-control/v1";
|
|
13
|
+
function ne(r) {
|
|
13
14
|
return (e) => {
|
|
14
15
|
const [t, n] = e;
|
|
15
16
|
if (typeof t == "string" && !t.startsWith("http")) {
|
|
@@ -19,21 +20,21 @@ function te(r) {
|
|
|
19
20
|
return u(e);
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function se(r) {
|
|
23
24
|
return (e) => u(b("Authorization", `Bearer ${r}`, e));
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function ae(r, e) {
|
|
26
27
|
const t = [];
|
|
27
|
-
return r && t.push(
|
|
28
|
+
return r && t.push(ne(r)), e && t.push(se(e)), L({
|
|
28
29
|
request: t
|
|
29
30
|
}).service;
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
+
const oe = {
|
|
32
33
|
"Content-Type": "application/json",
|
|
33
34
|
Accept: "application/json",
|
|
34
35
|
"X-Chatter-Entity-Encoding": "false"
|
|
35
36
|
};
|
|
36
|
-
function
|
|
37
|
+
function ie(r) {
|
|
37
38
|
if (r instanceof Headers) {
|
|
38
39
|
const e = [];
|
|
39
40
|
return r.forEach((t, n) => e.push([n, t])), e;
|
|
@@ -45,33 +46,33 @@ function M(r, e) {
|
|
|
45
46
|
const t = { ...r }, n = /* @__PURE__ */ new Map();
|
|
46
47
|
for (const a of Object.keys(t)) n.set(a.toLowerCase(), a);
|
|
47
48
|
const s = /* @__PURE__ */ new Set();
|
|
48
|
-
for (const [a, i] of
|
|
49
|
+
for (const [a, i] of ie(e)) {
|
|
49
50
|
const o = a.toLowerCase(), c = n.get(o);
|
|
50
51
|
c === void 0 ? (t[a] = i, n.set(o, a), s.add(o)) : s.has(o) ? t[c] = `${t[c]}, ${i}` : (t[c] = i, s.add(o));
|
|
51
52
|
}
|
|
52
53
|
return t;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
-
return M(
|
|
55
|
+
function $(r) {
|
|
56
|
+
return M(oe, r);
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function ce(r) {
|
|
58
59
|
if (r === void 0) return;
|
|
59
60
|
const e = {};
|
|
60
61
|
return new Headers(r).forEach((t, n) => {
|
|
61
62
|
e[n] = t;
|
|
62
63
|
}), Object.keys(e).length > 0 ? e : void 0;
|
|
63
64
|
}
|
|
64
|
-
const
|
|
65
|
-
},
|
|
65
|
+
const g = () => {
|
|
66
|
+
}, P = async () => {
|
|
66
67
|
};
|
|
67
|
-
function
|
|
68
|
+
function k(r) {
|
|
68
69
|
try {
|
|
69
|
-
return
|
|
70
|
+
return C(B(r));
|
|
70
71
|
} catch (e) {
|
|
71
72
|
return D(d(e));
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
+
function q(r, e) {
|
|
75
76
|
const t = r.definitions.filter(
|
|
76
77
|
(n) => n.kind === "OperationDefinition"
|
|
77
78
|
);
|
|
@@ -85,10 +86,10 @@ function d(r) {
|
|
|
85
86
|
}
|
|
86
87
|
return r instanceof Error ? [{ message: r.message }] : typeof r == "string" ? [{ message: r }] : [{ message: "Unknown error" }];
|
|
87
88
|
}
|
|
88
|
-
async function
|
|
89
|
-
const a =
|
|
89
|
+
async function H(r, { mutation: e, variables: t, operationName: n, headers: s }) {
|
|
90
|
+
const a = k(e);
|
|
90
91
|
if (a.isErr()) return { data: void 0, errors: a.error };
|
|
91
|
-
const i = a.value, o =
|
|
92
|
+
const i = a.value, o = q(i, n);
|
|
92
93
|
if (o !== "mutation")
|
|
93
94
|
return {
|
|
94
95
|
data: void 0,
|
|
@@ -100,7 +101,7 @@ async function I(r, { mutation: e, variables: t, operationName: n, headers: s })
|
|
|
100
101
|
};
|
|
101
102
|
try {
|
|
102
103
|
const c = await r({
|
|
103
|
-
query:
|
|
104
|
+
query: A(i),
|
|
104
105
|
variables: t,
|
|
105
106
|
operationName: n,
|
|
106
107
|
headers: s
|
|
@@ -113,10 +114,10 @@ async function I(r, { mutation: e, variables: t, operationName: n, headers: s })
|
|
|
113
114
|
return { data: void 0, errors: d(c) };
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function I(r) {
|
|
117
118
|
function e(n, s, a, i) {
|
|
118
119
|
return r({
|
|
119
|
-
query:
|
|
120
|
+
query: A(n),
|
|
120
121
|
variables: s,
|
|
121
122
|
operationName: a,
|
|
122
123
|
headers: i
|
|
@@ -134,15 +135,15 @@ function $(r) {
|
|
|
134
135
|
operationName: a,
|
|
135
136
|
headers: i
|
|
136
137
|
}) {
|
|
137
|
-
const o =
|
|
138
|
+
const o = k(n);
|
|
138
139
|
if (o.isErr())
|
|
139
140
|
return {
|
|
140
141
|
data: void 0,
|
|
141
142
|
errors: o.error,
|
|
142
|
-
subscribe: () =>
|
|
143
|
-
refresh:
|
|
143
|
+
subscribe: () => g,
|
|
144
|
+
refresh: P
|
|
144
145
|
};
|
|
145
|
-
const c = o.value, f =
|
|
146
|
+
const c = o.value, f = q(c, a);
|
|
146
147
|
if (f !== "query")
|
|
147
148
|
return {
|
|
148
149
|
data: void 0,
|
|
@@ -151,8 +152,8 @@ function $(r) {
|
|
|
151
152
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
|
|
152
153
|
}
|
|
153
154
|
],
|
|
154
|
-
subscribe: () =>
|
|
155
|
-
refresh:
|
|
155
|
+
subscribe: () => g,
|
|
156
|
+
refresh: P
|
|
156
157
|
};
|
|
157
158
|
const h = /* @__PURE__ */ new Set(), p = s, m = await e(c, p, a, i);
|
|
158
159
|
return {
|
|
@@ -165,30 +166,30 @@ function $(r) {
|
|
|
165
166
|
},
|
|
166
167
|
async refresh() {
|
|
167
168
|
const l = await e(c, p, a, i);
|
|
168
|
-
for (const
|
|
169
|
+
for (const S of h) S(l);
|
|
169
170
|
}
|
|
170
171
|
};
|
|
171
172
|
}
|
|
172
173
|
return {
|
|
173
174
|
query: t,
|
|
174
|
-
mutate: (n) =>
|
|
175
|
+
mutate: (n) => H(r, n)
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
|
-
const
|
|
178
|
-
function F(r =
|
|
178
|
+
const ue = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
179
|
+
function F(r = ue) {
|
|
179
180
|
return `/services/data/v${r}`;
|
|
180
181
|
}
|
|
181
|
-
const
|
|
182
|
+
const he = {
|
|
182
183
|
"Content-Type": "application/json",
|
|
183
184
|
Accept: "application/json"
|
|
184
185
|
};
|
|
185
|
-
class
|
|
186
|
+
class le {
|
|
186
187
|
clientFetch;
|
|
187
188
|
pathData;
|
|
188
189
|
graphql;
|
|
189
190
|
constructor(e) {
|
|
190
|
-
const t =
|
|
191
|
-
this.pathData = F(e?.apiVersion ?? t.apiVersion), this.clientFetch =
|
|
191
|
+
const t = de(), n = fe(e?.instanceUrl ?? t.instanceUrl), s = e?.accessToken ?? t.accessToken;
|
|
192
|
+
this.pathData = F(e?.apiVersion ?? t.apiVersion), this.clientFetch = ae(n || void 0, s), this.graphql = I(this.executeRawGraphQL.bind(this));
|
|
192
193
|
}
|
|
193
194
|
async executeRawGraphQL({
|
|
194
195
|
query: e,
|
|
@@ -199,11 +200,11 @@ class he {
|
|
|
199
200
|
return (await this.clientFetch(`${this.pathData}/graphql`, {
|
|
200
201
|
method: "POST",
|
|
201
202
|
body: JSON.stringify({ query: e, variables: t, operationName: n }),
|
|
202
|
-
headers: M(
|
|
203
|
+
headers: M(he, s)
|
|
203
204
|
})).json();
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function de() {
|
|
207
208
|
const r = globalThis.MOSAIC_ENV;
|
|
208
209
|
return {
|
|
209
210
|
instanceUrl: r?.instanceUrl,
|
|
@@ -211,16 +212,16 @@ function le() {
|
|
|
211
212
|
apiVersion: r?.apiVersion
|
|
212
213
|
};
|
|
213
214
|
}
|
|
214
|
-
function
|
|
215
|
+
function fe(r) {
|
|
215
216
|
if (!r || r === "/") return "";
|
|
216
217
|
let e = r;
|
|
217
218
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
218
219
|
}
|
|
219
|
-
const
|
|
220
|
-
class
|
|
220
|
+
const pe = "graphqlQuery";
|
|
221
|
+
class me {
|
|
221
222
|
graphql;
|
|
222
223
|
constructor() {
|
|
223
|
-
this.graphql =
|
|
224
|
+
this.graphql = I(this.executeRawGraphQL.bind(this));
|
|
224
225
|
}
|
|
225
226
|
/**
|
|
226
227
|
* The `headers` request option is intentionally not forwarded: this surface
|
|
@@ -232,43 +233,43 @@ class pe {
|
|
|
232
233
|
variables: t,
|
|
233
234
|
operationName: n
|
|
234
235
|
}) {
|
|
235
|
-
return (await window.openai.callTool(
|
|
236
|
+
return (await window.openai.callTool(pe, {
|
|
236
237
|
query: e,
|
|
237
238
|
...t != null ? { variables: t } : {},
|
|
238
239
|
...n != null ? { operationName: n } : {}
|
|
239
240
|
})).structuredContent;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
|
-
const w = "Accept-Language",
|
|
243
|
+
const w = "Accept-Language", ye = (r) => {
|
|
243
244
|
const e = globalThis.SFDC_ENV?.language;
|
|
244
245
|
if (!e)
|
|
245
246
|
return u(r);
|
|
246
247
|
const [t, n] = r;
|
|
247
248
|
return (t instanceof Request && !n?.headers ? t.headers.has(w) : new Headers(n?.headers).has(w)) ? u(r) : u(b(w, e, r));
|
|
248
|
-
},
|
|
249
|
-
let e = b(
|
|
250
|
-
return e = b(
|
|
251
|
-
},
|
|
249
|
+
}, be = "X-SFDC-Client-Name", ve = "X-SFDC-Client-Version", ge = "@salesforce/platform-sdk", Se = "11.50.0", we = (r) => {
|
|
250
|
+
let e = b(be, ge, r);
|
|
251
|
+
return e = b(ve, Se, e), u(e);
|
|
252
|
+
}, Ee = "X-CSRF-Token";
|
|
252
253
|
function Ce(r, e = {}) {
|
|
253
254
|
const { protectedUrls: t = [], alwaysProtectedUrls: n = [] } = e;
|
|
254
255
|
return async (s) => {
|
|
255
256
|
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";
|
|
256
|
-
if (
|
|
257
|
+
if (O(n, o) || De(c) && O(t, o)) {
|
|
257
258
|
const h = await r.getToken();
|
|
258
|
-
s = b(
|
|
259
|
+
s = b(Ee, h, s);
|
|
259
260
|
}
|
|
260
261
|
return u(s);
|
|
261
262
|
};
|
|
262
263
|
}
|
|
263
|
-
function
|
|
264
|
+
function De(r) {
|
|
264
265
|
const e = r.toLowerCase();
|
|
265
266
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
266
267
|
}
|
|
267
|
-
function
|
|
268
|
+
function O(r, e) {
|
|
268
269
|
const t = new URL(e, globalThis.location?.href ?? "http://localhost");
|
|
269
270
|
return r.some((n) => t.pathname.includes(n));
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
+
function Pe(r, e = {}) {
|
|
272
273
|
const t = Ce(r, e);
|
|
273
274
|
async function n(s) {
|
|
274
275
|
const a = await t(s);
|
|
@@ -277,7 +278,7 @@ function De(r, e = {}) {
|
|
|
277
278
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
278
279
|
}
|
|
279
280
|
const Ae = [400, 401, 403];
|
|
280
|
-
class ke extends
|
|
281
|
+
class ke extends J {
|
|
281
282
|
constructor(e) {
|
|
282
283
|
super(e), this.csrfTokenManager = e;
|
|
283
284
|
}
|
|
@@ -351,29 +352,29 @@ class qe {
|
|
|
351
352
|
return;
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
|
-
const
|
|
355
|
-
function
|
|
355
|
+
const T = /* @__PURE__ */ new Map();
|
|
356
|
+
function Oe(r) {
|
|
356
357
|
const { endpoint: e, cacheName: t, ...n } = r.csrf;
|
|
357
|
-
let s =
|
|
358
|
-
return s || (s = new qe(e, t),
|
|
358
|
+
let s = T.get(e);
|
|
359
|
+
return s || (s = new qe(e, t), T.set(e, s)), L(
|
|
359
360
|
{
|
|
360
|
-
retry:
|
|
361
|
-
request: [
|
|
361
|
+
retry: Pe(s, n),
|
|
362
|
+
request: [we, ye]
|
|
362
363
|
},
|
|
363
|
-
|
|
364
|
+
X(new ke(s)).service
|
|
364
365
|
).service;
|
|
365
366
|
}
|
|
366
|
-
const
|
|
367
|
-
function
|
|
368
|
-
let e =
|
|
367
|
+
const _ = /* @__PURE__ */ new Map();
|
|
368
|
+
function Te(r) {
|
|
369
|
+
let e = _.get(r);
|
|
369
370
|
if (!e) {
|
|
370
|
-
const t =
|
|
371
|
-
e = { cache: t, cacheController: s, pubSub: a },
|
|
371
|
+
const t = Y().service, n = ee(t).service, s = Z(t, n).service, a = re().service;
|
|
372
|
+
e = { cache: t, cacheController: s, pubSub: a }, _.set(r, e);
|
|
372
373
|
}
|
|
373
374
|
return e;
|
|
374
375
|
}
|
|
375
|
-
function
|
|
376
|
-
const t =
|
|
376
|
+
function _e(r, e) {
|
|
377
|
+
const t = Te(r);
|
|
377
378
|
return {
|
|
378
379
|
shared: t,
|
|
379
380
|
services: {
|
|
@@ -384,7 +385,7 @@ function Oe(r, e) {
|
|
|
384
385
|
};
|
|
385
386
|
}
|
|
386
387
|
const R = 300;
|
|
387
|
-
function
|
|
388
|
+
function Re(r, e) {
|
|
388
389
|
try {
|
|
389
390
|
return JSON.parse(JSON.stringify(r));
|
|
390
391
|
} catch (t) {
|
|
@@ -394,19 +395,19 @@ function Pe(r, e) {
|
|
|
394
395
|
throw s.cause = t, s;
|
|
395
396
|
}
|
|
396
397
|
}
|
|
397
|
-
function
|
|
398
|
+
function Ne(r) {
|
|
398
399
|
if (typeof r == "object" && r.type === "max-age") {
|
|
399
400
|
const e = r.maxAge;
|
|
400
401
|
return Number.isFinite(e) && e >= 0 ? e : R;
|
|
401
402
|
}
|
|
402
403
|
return R;
|
|
403
404
|
}
|
|
404
|
-
class
|
|
405
|
+
class Le extends te {
|
|
405
406
|
constructor(e, t, n) {
|
|
406
|
-
super(t), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables =
|
|
407
|
+
super(t), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = Re(
|
|
407
408
|
e.variables ?? {},
|
|
408
409
|
this.normalizedOperationName
|
|
409
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge =
|
|
410
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Ne(e.cacheControl), this.headers = e.headers, this.headersKey = ce(e.headers);
|
|
410
411
|
}
|
|
411
412
|
query;
|
|
412
413
|
normalizedVariables;
|
|
@@ -420,7 +421,7 @@ class Ne extends re {
|
|
|
420
421
|
this.url,
|
|
421
422
|
{
|
|
422
423
|
method: "POST",
|
|
423
|
-
headers:
|
|
424
|
+
headers: $(this.headers),
|
|
424
425
|
body: JSON.stringify({
|
|
425
426
|
query: this.query,
|
|
426
427
|
variables: this.normalizedVariables,
|
|
@@ -435,7 +436,7 @@ class Ne extends re {
|
|
|
435
436
|
variables: this.normalizedVariables,
|
|
436
437
|
operationName: this.normalizedOperationName
|
|
437
438
|
};
|
|
438
|
-
return this.headersKey !== void 0 && (e.headers = this.headersKey),
|
|
439
|
+
return this.headersKey !== void 0 && (e.headers = this.headersKey), Q(e);
|
|
439
440
|
}
|
|
440
441
|
/**
|
|
441
442
|
* Reads from the cache and returns the cache result or error
|
|
@@ -452,7 +453,7 @@ class Ne extends re {
|
|
|
452
453
|
*/
|
|
453
454
|
readFromCache(e) {
|
|
454
455
|
const t = this.buildKey(), n = e.get(t)?.value;
|
|
455
|
-
return n === void 0 ? u(D(new
|
|
456
|
+
return n === void 0 ? u(D(new z())) : u(C(n));
|
|
456
457
|
}
|
|
457
458
|
writeToCache(e, t) {
|
|
458
459
|
if (t.isOk() && t.value.data != null && Object.keys(t.value.data).length > 0) {
|
|
@@ -482,17 +483,17 @@ class Ne extends re {
|
|
|
482
483
|
return e.errors && e.errors.length > 0;
|
|
483
484
|
}
|
|
484
485
|
processFetchReturnValue(e) {
|
|
485
|
-
return this.responseHasErrors(e) ? D(new
|
|
486
|
+
return this.responseHasErrors(e) ? D(new j(e)) : C(e);
|
|
486
487
|
}
|
|
487
488
|
}
|
|
488
489
|
function U(r) {
|
|
489
|
-
if (
|
|
490
|
+
if (W(r) && r.data && typeof r.data == "object") {
|
|
490
491
|
const e = r.data;
|
|
491
492
|
if (e.data != null)
|
|
492
493
|
return e.data;
|
|
493
494
|
}
|
|
494
495
|
}
|
|
495
|
-
function
|
|
496
|
+
function Me(r) {
|
|
496
497
|
return (e) => {
|
|
497
498
|
if (e.isOk()) {
|
|
498
499
|
const t = e.value;
|
|
@@ -503,7 +504,7 @@ function Le(r) {
|
|
|
503
504
|
}
|
|
504
505
|
};
|
|
505
506
|
}
|
|
506
|
-
async function
|
|
507
|
+
async function $e(r) {
|
|
507
508
|
let e, t, n;
|
|
508
509
|
try {
|
|
509
510
|
const s = await r.execute();
|
|
@@ -515,19 +516,19 @@ async function Me(r) {
|
|
|
515
516
|
data: e,
|
|
516
517
|
errors: t,
|
|
517
518
|
subscribe(s) {
|
|
518
|
-
return n ? n(
|
|
519
|
+
return n ? n(Me(s)) : g;
|
|
519
520
|
},
|
|
520
521
|
async refresh() {
|
|
521
522
|
await r.refresh();
|
|
522
523
|
}
|
|
523
524
|
};
|
|
524
525
|
}
|
|
525
|
-
function
|
|
526
|
+
function E(r) {
|
|
526
527
|
return {
|
|
527
528
|
data: void 0,
|
|
528
529
|
errors: r,
|
|
529
|
-
subscribe: () =>
|
|
530
|
-
refresh:
|
|
530
|
+
subscribe: () => g,
|
|
531
|
+
refresh: P
|
|
531
532
|
};
|
|
532
533
|
}
|
|
533
534
|
function He({
|
|
@@ -543,20 +544,20 @@ function He({
|
|
|
543
544
|
cacheControl: c,
|
|
544
545
|
headers: f
|
|
545
546
|
}) {
|
|
546
|
-
const h =
|
|
547
|
-
if (h.isErr()) return
|
|
548
|
-
const p = h.value, m =
|
|
547
|
+
const h = k(a);
|
|
548
|
+
if (h.isErr()) return E(h.error);
|
|
549
|
+
const p = h.value, m = q(p, o);
|
|
549
550
|
if (m !== "query")
|
|
550
|
-
return
|
|
551
|
+
return E([
|
|
551
552
|
{
|
|
552
553
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${m}.`
|
|
553
554
|
}
|
|
554
555
|
]);
|
|
555
556
|
let l;
|
|
556
557
|
try {
|
|
557
|
-
l = new
|
|
558
|
+
l = new Le(
|
|
558
559
|
{
|
|
559
|
-
query:
|
|
560
|
+
query: A(p),
|
|
560
561
|
variables: i,
|
|
561
562
|
operationName: o,
|
|
562
563
|
cacheControl: c,
|
|
@@ -565,33 +566,33 @@ function He({
|
|
|
565
566
|
n,
|
|
566
567
|
e
|
|
567
568
|
);
|
|
568
|
-
} catch (
|
|
569
|
-
return
|
|
569
|
+
} catch (S) {
|
|
570
|
+
return E(d(S));
|
|
570
571
|
}
|
|
571
|
-
return
|
|
572
|
+
return $e(l);
|
|
572
573
|
}
|
|
573
574
|
return {
|
|
574
575
|
query: s,
|
|
575
|
-
mutate: (a) =>
|
|
576
|
+
mutate: (a) => H(t, a)
|
|
576
577
|
};
|
|
577
578
|
}
|
|
578
|
-
const Ie = 1,
|
|
579
|
-
class
|
|
579
|
+
const Ie = 1, Fe = `@salesforce/platform-sdk-data_v${Ie}`, K = F(), Ue = `${K}/ui-api`, N = `${K}/graphql`;
|
|
580
|
+
class Ke {
|
|
580
581
|
baseUrl;
|
|
581
582
|
clientFetch;
|
|
582
583
|
onStatus;
|
|
583
584
|
graphql;
|
|
584
585
|
constructor(e) {
|
|
585
586
|
const t = Ve();
|
|
586
|
-
this.baseUrl = xe(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch =
|
|
587
|
+
this.baseUrl = xe(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = Oe({
|
|
587
588
|
csrf: {
|
|
588
|
-
endpoint: `${this.baseUrl}${
|
|
589
|
-
cacheName:
|
|
589
|
+
endpoint: `${this.baseUrl}${Ue}/session/csrf`,
|
|
590
|
+
cacheName: Fe,
|
|
590
591
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
591
592
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
592
593
|
}
|
|
593
594
|
});
|
|
594
|
-
const n = (a, i) => this.fetch(a, i), s =
|
|
595
|
+
const n = (a, i) => this.fetch(a, i), s = _e(this.baseUrl, n);
|
|
595
596
|
this.graphql = He({
|
|
596
597
|
bundle: s,
|
|
597
598
|
url: N,
|
|
@@ -617,7 +618,7 @@ class Ue {
|
|
|
617
618
|
return (await this.fetch(N, {
|
|
618
619
|
method: "POST",
|
|
619
620
|
body: JSON.stringify({ query: e, variables: t, operationName: n }),
|
|
620
|
-
headers:
|
|
621
|
+
headers: $(s)
|
|
621
622
|
})).json();
|
|
622
623
|
}
|
|
623
624
|
/**
|
|
@@ -644,37 +645,67 @@ function xe(r) {
|
|
|
644
645
|
let e = r;
|
|
645
646
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
646
647
|
}
|
|
647
|
-
function
|
|
648
|
+
async function Ge(r, e) {
|
|
649
|
+
if (e.length === 0)
|
|
650
|
+
return r;
|
|
651
|
+
const t = Object.create(r);
|
|
652
|
+
for (const n of e) {
|
|
653
|
+
if (n.name in t)
|
|
654
|
+
throw new Error(
|
|
655
|
+
`Plugin "${n.name}" cannot attach: "${n.name}" is already defined on the SDK.`
|
|
656
|
+
);
|
|
657
|
+
let s;
|
|
658
|
+
try {
|
|
659
|
+
s = await n.setup(t);
|
|
660
|
+
} catch (a) {
|
|
661
|
+
throw new Error(`Plugin "${n.name}" failed during setup.`, { cause: a });
|
|
662
|
+
}
|
|
663
|
+
Object.defineProperty(t, n.name, {
|
|
664
|
+
value: s,
|
|
665
|
+
enumerable: !0,
|
|
666
|
+
writable: !0,
|
|
667
|
+
configurable: !0
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
return t;
|
|
671
|
+
}
|
|
672
|
+
function sr(r, ...e) {
|
|
648
673
|
let t = r[0] ?? "";
|
|
649
674
|
for (let n = 0; n < e.length; n += 1)
|
|
650
675
|
t += String(e[n]) + (r[n + 1] ?? "");
|
|
651
676
|
return t;
|
|
652
677
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
case y.MCPApps:
|
|
666
|
-
return {};
|
|
667
|
-
default:
|
|
668
|
-
return {};
|
|
669
|
-
}
|
|
670
|
-
} catch {
|
|
678
|
+
const ar = G();
|
|
679
|
+
async function Qe(r) {
|
|
680
|
+
try {
|
|
681
|
+
switch (await V(r?.surface)) {
|
|
682
|
+
case y.OpenAI:
|
|
683
|
+
return new me();
|
|
684
|
+
case y.WebApp:
|
|
685
|
+
case y.MicroFrontend:
|
|
686
|
+
return new Ke(r?.webapp);
|
|
687
|
+
case y.Mosaic:
|
|
688
|
+
return new le(r?.mosaic);
|
|
689
|
+
case y.MCPApps:
|
|
671
690
|
return {};
|
|
672
|
-
|
|
691
|
+
default:
|
|
692
|
+
return {};
|
|
693
|
+
}
|
|
694
|
+
} catch {
|
|
695
|
+
return {};
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function or(r) {
|
|
699
|
+
return x(
|
|
700
|
+
(async () => {
|
|
701
|
+
const e = await Qe(r);
|
|
702
|
+
return Ge(e, r?.plugins ?? []);
|
|
673
703
|
})(),
|
|
674
704
|
"createDataSDK"
|
|
675
705
|
);
|
|
676
706
|
}
|
|
677
707
|
export {
|
|
678
|
-
|
|
679
|
-
|
|
708
|
+
or as createDataSDK,
|
|
709
|
+
ar as defineDataPlugin,
|
|
710
|
+
sr as gql
|
|
680
711
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export * from './core';
|
|
7
7
|
export { createChatSDK, type ChatSDKOptions, MCPAppsChatSDK, getChatSDK, getChatSDKSync, resetChatSDK, } from './chat';
|
|
8
8
|
export { createViewSDK, type ViewSDKOptions, MCPAppsViewSDK, getViewSDK, getViewSDKSync, resetViewSDK, } from './view';
|
|
9
|
-
export { createDataSDK, type DataSDKOptions, type WebAppDataSDKOptions, type MosaicDataSDKOptions, type StatusCallback, type NodeOfConnection, gql, } from './data';
|
|
9
|
+
export { createDataSDK, defineDataPlugin, type DataSDKOptions, type DataSDKPlugin, type DataSDKWithPlugins, type WebAppDataSDKOptions, type MosaicDataSDKOptions, type StatusCallback, type NodeOfConnection, gql, } from './data';
|
|
10
10
|
export { createLightningSDK, type LightningSDKOptions } from './lightning';
|
|
11
11
|
export { getCurrentApp, type CurrentAppOptions, type AppIdentity, type CurrentApp, WebAppCurrentApp, } from './app';
|
|
12
12
|
export { createTelemetryTransport, registerTelemetryUploader, TelemetryUploader, type TelemetryTransport, type TelemetryTransportOptions, type EnvelopeEntry, type EnvelopeMetadata, type TelemetryUploaderOptions, type OnEnvelopeCallback, type FlushReason, type TelemetryUploadContext, type TelemetryUploaderErrorContext, type InstrumentedAppLike, type DisposeOptions, } from './telemetry';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,QAAQ,CAAC;AAGvB,OAAO,EACN,aAAa,EACb,KAAK,cAAc,EACnB,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,GACZ,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,aAAa,EACb,KAAK,cAAc,EACnB,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,GACZ,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,GAAG,GACH,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG3E,OAAO,EACN,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,gBAAgB,GAChB,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B,EACvB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACN,eAAe,EACf,YAAY,EACZ,aAAa,EACb,KAAK,SAAS,EACd,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
|
-
import { M as
|
|
1
|
+
import { M as a, a as t, S as p, g as o, i as s, b as i, r as S } from "./surface-Dd2tqrPi.js";
|
|
2
2
|
import { g as c } from "./capabilities-5BWkCbcP.js";
|
|
3
3
|
import { w as g } from "./sdk-promise-D0sy7OW1.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { c as l } from "./plugin-factory-BC3b3BOy.js";
|
|
5
|
+
import { MCPAppsChatSDK as K, createChatSDK as x, getChatSDK as A, getChatSDKSync as C, resetChatSDK as d } from "./chat/index.js";
|
|
6
|
+
import { MCPAppsViewSDK as P, createViewSDK as w, getViewSDK as y, getViewSDKSync as T, resetViewSDK as h } from "./view/index.js";
|
|
7
|
+
import { createDataSDK as V, defineDataPlugin as b, gql as E } from "./data/index.js";
|
|
8
|
+
import { createLightningSDK as F } from "./lightning/index.js";
|
|
9
|
+
import { WebAppCurrentApp as U, getCurrentApp as _ } from "./app/index.js";
|
|
10
|
+
import { c as z } from "./transport-D9QstWle.js";
|
|
11
|
+
import { T as N, r as W } from "./TelemetryUploader-DKkdppe9.js";
|
|
12
|
+
import { P as j, c as k, v as B } from "./analytics-Dpz22kda.js";
|
|
12
13
|
export {
|
|
13
14
|
K as MCPAppsChatSDK,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
P as MCPAppsViewSDK,
|
|
16
|
+
a as McpAppsNotAvailableError,
|
|
17
|
+
t as McpAppsSession,
|
|
18
|
+
j as PFT_META_KEY,
|
|
18
19
|
p as Surface,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
N as TelemetryUploader,
|
|
21
|
+
U as WebAppCurrentApp,
|
|
22
|
+
k as createAnalytics,
|
|
23
|
+
x as createChatSDK,
|
|
24
|
+
V as createDataSDK,
|
|
25
|
+
F as createLightningSDK,
|
|
26
|
+
l as createPluginFactory,
|
|
27
|
+
z as createTelemetryTransport,
|
|
26
28
|
w as createViewSDK,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
b as defineDataPlugin,
|
|
30
|
+
A as getChatSDK,
|
|
31
|
+
C as getChatSDKSync,
|
|
32
|
+
_ as getCurrentApp,
|
|
30
33
|
c as getSurfaceCapabilities,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
o as getVerifiedSurface,
|
|
35
|
+
y as getViewSDK,
|
|
36
|
+
T as getViewSDKSync,
|
|
37
|
+
E as gql,
|
|
38
|
+
s as initialize,
|
|
36
39
|
i as isSfEmbeddingIframe,
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
W as registerTelemetryUploader,
|
|
41
|
+
d as resetChatSDK,
|
|
39
42
|
S as resetSurface,
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
h as resetViewSDK,
|
|
44
|
+
B as validatePftId,
|
|
42
45
|
g as wrapSDKPromise
|
|
43
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.50.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -111,10 +111,10 @@
|
|
|
111
111
|
"build": "vite build",
|
|
112
112
|
"clean": "rm -rf dist",
|
|
113
113
|
"dev": "vite build --watch",
|
|
114
|
-
"test": "vitest run && npm run test:examples",
|
|
114
|
+
"test": "vitest run --typecheck && npm run test:examples",
|
|
115
115
|
"test:examples": "tsx scripts/check-examples.mts",
|
|
116
116
|
"test:watch": "vitest",
|
|
117
|
-
"test:coverage": "vitest run --coverage"
|
|
117
|
+
"test:coverage": "vitest run --coverage --typecheck"
|
|
118
118
|
},
|
|
119
119
|
"dependencies": {
|
|
120
120
|
"@conduit-client/command-http-cache-control": "3.19.6",
|
|
@@ -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.50.0",
|
|
130
130
|
"@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|