@salesforce/platform-sdk 11.54.1 → 11.55.1
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 +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/plugin-attach.d.ts +10 -2
- package/dist/core/plugin-attach.d.ts.map +1 -1
- package/dist/core/plugin-types.d.ts +78 -28
- package/dist/core/plugin-types.d.ts.map +1 -1
- package/dist/data/index.d.ts +16 -6
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +217 -208
- package/package.json +2 -2
package/dist/core/index.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export { getSurfaceCapabilities } from './capabilities';
|
|
|
18
18
|
export type { SurfaceCapabilities } from './capabilities';
|
|
19
19
|
export { wrapSDKPromise } from './sdk-promise';
|
|
20
20
|
export { createPluginFactory } from './plugin-factory';
|
|
21
|
-
export type { Plugin, AnyPlugin, PluginsFor, PluginEntry, ExtendedSDK, LiteralName, UniquePluginNames, } from './plugin-types';
|
|
21
|
+
export type { Plugin, AnyPlugin, AliasedPlugin, PluginsFor, PluginEntry, ExtendedSDK, LiteralName, UniquePluginNames, ValidAliasNames, } from './plugin-types';
|
|
22
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,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGrD,YAAY,EACX,WAAW,EACX,UAAU,E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W,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,eAAe,GACf,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { ExtendedSDK, PluginsFor } from './plugin-types';
|
|
2
2
|
/**
|
|
3
3
|
* Run each plugin's `setup` in array order and mount the returned namespace
|
|
4
|
-
* under the
|
|
4
|
+
* under the entry's effective mount name — its `name`, or its `as` alias when
|
|
5
|
+
* the entry is `{ plugin, as }`. `setup` may be sync or async; each is `await`ed
|
|
5
6
|
* before the next runs, so the ordering is deterministic.
|
|
6
7
|
*
|
|
8
|
+
* Aliasing rebinds only the mount key: `setup` still runs on the underlying
|
|
9
|
+
* plugin, so two plugins that both declare `name: "labels"` can attach under
|
|
10
|
+
* distinct keys (`{ plugin: a, as: "x" }`, `{ plugin: b, as: "y" }`). See
|
|
11
|
+
* {@link resolveEntry} for the bare-vs-aliased narrowing and the loud guard
|
|
12
|
+
* against a malformed entry from untyped JavaScript.
|
|
13
|
+
*
|
|
7
14
|
* Each `setup` receives the base SDK, and that is all the type promises it:
|
|
8
15
|
* `setup(sdk)` is typed as `Base`, never the accumulating shape. Because every
|
|
9
16
|
* namespace mounts onto one shared object (below), a later plugin *can* reach
|
|
@@ -28,7 +35,8 @@ import { ExtendedSDK, PluginsFor } from './plugin-types';
|
|
|
28
35
|
* base type may attach. The returned type is {@link ExtendedSDK}<Base, Plugins>
|
|
29
36
|
* — the base plus each plugin's resolved namespace under its own key.
|
|
30
37
|
*
|
|
31
|
-
* Fail-loud: a
|
|
38
|
+
* Fail-loud: a malformed entry (no `setup`, or a non-string/empty mount name),
|
|
39
|
+
* a mount name in `reservedNames` (names the caller declares off-limits),
|
|
32
40
|
* already present on the base (own or inherited), or mounted earlier in this
|
|
33
41
|
* same call throws before setup runs, and a `setup` that throws or rejects
|
|
34
42
|
* surfaces as an error naming the plugin, chaining the original error via
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-attach.d.ts","sourceRoot":"","sources":["../../src/core/plugin-attach.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin-attach.d.ts","sourceRoot":"","sources":["../../src/core/plugin-attach.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAiB,WAAW,EAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA0CrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,aAAa,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,UAAU,CAAC,IAAI,CAAC,EAC9F,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAIhB,aAAa,GAAE,WAAW,CAAC,MAAM,CAAqB,GACpD,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAoErC"}
|
|
@@ -71,37 +71,74 @@ export type LiteralName<Name extends string> = string extends Name ? never : IsU
|
|
|
71
71
|
*/
|
|
72
72
|
export type AnyPlugin = Plugin<never, string, unknown>;
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* `
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
74
|
+
* Rebind a plugin's mount point: attach `plugin` under `as` instead of its own
|
|
75
|
+
* `name`. This is the consumer's recourse for a collision they didn't cause —
|
|
76
|
+
* two uneditable third-party plugins that both mount `sdk.labels` can each be
|
|
77
|
+
* aliased to a distinct key. Aliasing rebinds the mount *key* only, never the
|
|
78
|
+
* plugin's identity, which is what keeps identity-based dependency resolution
|
|
79
|
+
* (a later WI) robust to it.
|
|
80
|
+
*
|
|
81
|
+
* `As` is intentionally the raw alias literal, NOT `LiteralName<As>`: pinning
|
|
82
|
+
* `LiteralName` here would collapse the constraint form `AliasedPlugin<_,
|
|
83
|
+
* string>` (used in {@link PluginsFor}) to `as: never` and reject every alias.
|
|
84
|
+
* The widened/union-`as` guard is instead applied at the call boundary by
|
|
85
|
+
* {@link ValidAliasNames}, exactly as {@link UniquePluginNames} guards mount
|
|
86
|
+
* uniqueness there — the entry type stays permissive; the boundary validates.
|
|
87
|
+
*
|
|
88
|
+
* `name?: never; setup?: never` reject the mixed shape structurally, mirroring
|
|
89
|
+
* the runtime discriminator. An object carrying a bare plugin's defining
|
|
90
|
+
* members *and* `{ plugin, as }` satisfies both arms of {@link PluginEntry};
|
|
91
|
+
* without these guards {@link MountName} (which tests the aliased arm first)
|
|
92
|
+
* would key it under `as`, while `attach` — discriminating on `"setup" in
|
|
93
|
+
* entry` — mounts the bare plugin under `name`. The `never` fields fail the
|
|
94
|
+
* aliased arm for such an object, so it matches only {@link Plugin} and both
|
|
95
|
+
* sides agree on `name`. Unlike the `LiteralName` case above, these are fixed
|
|
96
|
+
* optional-never fields independent of `P`/`As`, so a real `{ plugin, as }`
|
|
97
|
+
* entry (which omits them) leaves the `PluginsFor` constraint form intact.
|
|
98
|
+
*/
|
|
99
|
+
export interface AliasedPlugin<P extends AnyPlugin, As extends string> {
|
|
100
|
+
plugin: P;
|
|
101
|
+
as: As;
|
|
102
|
+
name?: never;
|
|
103
|
+
setup?: never;
|
|
104
|
+
}
|
|
105
|
+
/** Any aliased entry, for use in unions/constraints (cf. {@link AnyPlugin}). */
|
|
106
|
+
type AnyAliasedPlugin = AliasedPlugin<AnyPlugin, string>;
|
|
107
|
+
/**
|
|
108
|
+
* The `plugins: []` array constraint that enforces a concrete base SDK. A bare
|
|
109
|
+
* `Plugin<Sdk, Name, Api>` — or an {@link AliasedPlugin} wrapping one — is a
|
|
110
|
+
* member iff a `Base` value is assignable to the (inner) plugin's `setup`
|
|
111
|
+
* parameter, i.e. the plugin asks for no more than `Base` provides (a plugin
|
|
112
|
+
* that ignores the SDK, `Sdk = unknown`, is universally attachable).
|
|
113
|
+
* `createDataSDK` binds `Base = DataSDK`; that is where DataSDK-specific
|
|
114
|
+
* enforcement occurs.
|
|
80
115
|
*/
|
|
81
|
-
export type PluginsFor<Base> = readonly Plugin<Base, string, unknown>[];
|
|
116
|
+
export type PluginsFor<Base> = readonly (Plugin<Base, string, unknown> | AliasedPlugin<Plugin<Base, string, unknown>, string>)[];
|
|
82
117
|
/**
|
|
83
|
-
* What may appear in the `plugins: []` array
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
118
|
+
* What may appear in the `plugins: []` array: a bare plugin, or a bare plugin
|
|
119
|
+
* wrapped with an `{ as }` alias. Everything downstream ({@link Accumulate},
|
|
120
|
+
* {@link DuplicateMountName}, {@link ExtendedSDK}) is written against
|
|
121
|
+
* `PluginEntry` and routes through {@link PluginOf}/{@link MountName}, so the
|
|
122
|
+
* bare-vs-aliased distinction is resolved in exactly those two helpers and
|
|
123
|
+
* nowhere else.
|
|
89
124
|
*/
|
|
90
|
-
export type PluginEntry = AnyPlugin;
|
|
125
|
+
export type PluginEntry = AnyPlugin | AnyAliasedPlugin;
|
|
126
|
+
/** The underlying plugin of an entry, whether it was passed bare or aliased. */
|
|
127
|
+
type PluginOf<E extends PluginEntry> = E extends AnyAliasedPlugin ? E["plugin"] : E;
|
|
91
128
|
/**
|
|
92
|
-
* The literal key
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
129
|
+
* The literal key an entry mounts under: its alias `as` when aliased, else the
|
|
130
|
+
* plugin's own `name`. This is the single place the effective mount key is
|
|
131
|
+
* computed — all mount-name-keyed logic ({@link Accumulate},
|
|
132
|
+
* {@link DuplicateMountName}) routes through it, so aliasing is transparent to
|
|
133
|
+
* them: `[a, a]` (both mount `"labels"`) collides, but `[{ plugin: a, as: "x"
|
|
134
|
+
* }, { plugin: a, as: "y" }]` resolves to distinct keys and does not.
|
|
98
135
|
*/
|
|
99
|
-
type MountName<
|
|
136
|
+
type MountName<E extends PluginEntry> = E extends AnyAliasedPlugin ? E["as"] : PluginOf<E>["name"];
|
|
100
137
|
/**
|
|
101
|
-
* The resolved API
|
|
102
|
-
* case so the mounted namespace is the settled value, never a promise.
|
|
138
|
+
* The resolved API an entry's plugin `setup` returns. `Awaited` unwraps the
|
|
139
|
+
* async case so the mounted namespace is the settled value, never a promise.
|
|
103
140
|
*/
|
|
104
|
-
type ApiOf<
|
|
141
|
+
type ApiOf<E extends PluginEntry> = Awaited<ReturnType<PluginOf<E>["setup"]>>;
|
|
105
142
|
/**
|
|
106
143
|
* Walk the plugin tuple left→right, intersecting `{ [name]: namespace }` per
|
|
107
144
|
* entry. Namespaces are non-optional: presence is a static attach fact.
|
|
@@ -121,10 +158,8 @@ type Accumulate<Plugins extends readonly PluginEntry[]> = Plugins extends readon
|
|
|
121
158
|
/**
|
|
122
159
|
* The first mount name that repeats in the tuple, or `never` if all are
|
|
123
160
|
* distinct. Walks left→right accumulating seen names in `Seen`; the first
|
|
124
|
-
* {@link MountName} already in `Seen` is the duplicate. Keyed on
|
|
125
|
-
*
|
|
126
|
-
* `"labels"`) reports `"labels"`, but `[{ plugin: a, as: "x" }, { plugin: a, as:
|
|
127
|
-
* "y" }]` resolves to distinct mount names and reports `never`.
|
|
161
|
+
* {@link MountName} already in `Seen` is the duplicate. Keyed on
|
|
162
|
+
* {@link MountName}, so aliasing a clash apart is a valid recourse (see there).
|
|
128
163
|
*/
|
|
129
164
|
type DuplicateMountName<Plugins extends readonly PluginEntry[], Seen = never> = Plugins extends readonly [
|
|
130
165
|
infer Head extends PluginEntry,
|
|
@@ -148,6 +183,21 @@ export type UniquePluginNames<Plugins extends readonly PluginEntry[]> = [
|
|
|
148
183
|
] extends [never] ? unknown : {
|
|
149
184
|
plugins: `Two plugins mount under "${DuplicateMountName<Plugins> & string}"; mount names must be unique.`;
|
|
150
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* A constraint intersected into the `plugins` option to reject an aliased entry
|
|
188
|
+
* whose `as` is not a single string literal — the same soundness bar
|
|
189
|
+
* {@link LiteralName} applies to a plugin's `name` (see there for why a widened
|
|
190
|
+
* or union `as` would mount a phantom namespace). Applied at the boundary rather
|
|
191
|
+
* than on {@link AliasedPlugin} for the reason that type documents. Resolves to
|
|
192
|
+
* `unknown` or an inassignable `{ plugins }` error exactly as
|
|
193
|
+
* {@link UniquePluginNames} does.
|
|
194
|
+
*/
|
|
195
|
+
export type ValidAliasNames<Plugins extends readonly PluginEntry[]> = Plugins extends readonly [
|
|
196
|
+
infer Head extends PluginEntry,
|
|
197
|
+
...infer Tail extends readonly PluginEntry[]
|
|
198
|
+
] ? Head extends AnyAliasedPlugin ? [LiteralName<Head["as"]>] extends [never] ? {
|
|
199
|
+
plugins: `An alias "as" must be a single string literal, not a widened or union type.`;
|
|
200
|
+
} : ValidAliasNames<Tail> : ValidAliasNames<Tail> : unknown;
|
|
151
201
|
/** Collapse an intersection into a single flat object type for readable hovers. */
|
|
152
202
|
type Flatten<T> = {
|
|
153
203
|
[K in keyof T]: T[K];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-types.d.ts","sourceRoot":"","sources":["../../src/core/plugin-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,MAAM,CAAC,GAAG,EAAE,IAAI,SAAS,MAAM,EAAE,GAAG,EAAE,IAAI,SAAS,SAAS,SAAS,EAAE,GAAG,EAAE;IAC5F,yEAAyE;IACzE,IAAI,EAAE,IAAI,CAAC;IACX;;;;;;;;;OASG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;CAC/D;AAED,sDAAsD;AACtD,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,C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AC,IAAI,CAAC,GACtB,eAAe,CAAC,IAAI,CAAC,GACtB,OAAO,CAAC;AAEX,mFAAmF;AACnF,KAAK,OAAO,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAEhD,2DAA2D;AAC3D,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,SAAS,SAAS,WAAW,EAAE,IAAI,OAAO,CAC9E,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAC1B,CAAC"}
|
package/dist/data/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSDK, ExtendedSDK, Plugin, SDKOptions, UniquePluginNames } from '../core';
|
|
1
|
+
import { DataSDK, ExtendedSDK, Plugin, PluginsFor, SDKOptions, UniquePluginNames, ValidAliasNames } 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}).
|
|
@@ -38,8 +38,12 @@ export type DataSDKPlugin<Name extends string = string, Api = unknown> = Plugin<
|
|
|
38
38
|
* see {@link createPluginFactory} for the underlying mechanism.
|
|
39
39
|
*/
|
|
40
40
|
export declare const defineDataPlugin: <const Name extends string, Api>(plugin: Plugin<DataSDK, import('..').LiteralName<Name>, Api, []>) => Plugin<DataSDK, Name, Api, []>;
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* A DataSDK carrying every namespace contributed by an ordered plugin tuple.
|
|
43
|
+
* Entries may be bare plugins or `{ plugin, as }` aliases; each mounts under its
|
|
44
|
+
* effective key (the alias when present), so aliasing is reflected here for free.
|
|
45
|
+
*/
|
|
46
|
+
export type DataSDKWithPlugins<Plugins extends PluginsFor<DataSDK>> = ExtendedSDK<DataSDK, Plugins>;
|
|
43
47
|
/**
|
|
44
48
|
* Options for creating a DataSDK instance.
|
|
45
49
|
*/
|
|
@@ -54,7 +58,13 @@ export interface DataSDKOptions extends SDKOptions {
|
|
|
54
58
|
* @example { instanceUrl: "https://my.salesforce.com", accessToken: "00D..." }
|
|
55
59
|
*/
|
|
56
60
|
mosaic?: MosaicDataSDKOptions;
|
|
57
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Plugins to attach. Each entry is a bare {@link DataSDKPlugin} (mounts under
|
|
63
|
+
* its own `name`) or a `{ plugin, as }` alias (mounts under `as`). Aliasing
|
|
64
|
+
* is the recourse when two plugins want the same key — e.g. two third-party
|
|
65
|
+
* labels plugins the consumer can't edit.
|
|
66
|
+
*/
|
|
67
|
+
plugins?: PluginsFor<DataSDK>;
|
|
58
68
|
}
|
|
59
69
|
/**
|
|
60
70
|
* Create and initialize a DataSDK instance based on the detected surface.
|
|
@@ -94,9 +104,9 @@ export interface DataSDKOptions extends SDKOptions {
|
|
|
94
104
|
* }
|
|
95
105
|
* ```
|
|
96
106
|
*/
|
|
97
|
-
export declare function createDataSDK<const Plugins extends
|
|
107
|
+
export declare function createDataSDK<const Plugins extends PluginsFor<DataSDK> = []>(options?: Omit<DataSDKOptions, "plugins"> & {
|
|
98
108
|
plugins?: Plugins;
|
|
99
|
-
} & UniquePluginNames<Plugins>): Promise<DataSDKWithPlugins<Plugins>>;
|
|
109
|
+
} & UniquePluginNames<Plugins> & ValidAliasNames<Plugins>): Promise<DataSDKWithPlugins<Plugins>>;
|
|
100
110
|
export { gql } from './gql';
|
|
101
111
|
export type { CacheControl, DataSDK, DataSDKGraphQL, GraphQLError, GraphQLRawDocument, GraphQLRequest, GraphQLRequestHeaders, GraphQLResponse, MutateOptions, MutationResult, QueryOptions, QueryResult, QuerySubscriber, SDKOptions, Unsubscribe, } from '../core';
|
|
102
112
|
/**
|
package/dist/data/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mapp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;;;;;;GAqCG;AAiBH,wBAAgB,aAAa,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,EAC3E,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAC7F,eAAe,CAAC,OAAO,CAAC,GACvB,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAexC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EACX,YAAY,EACZ,OAAO,EACP,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,GACX,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS;IAC3C,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;CAC3B,GAAG,IAAI,GACL,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,GAClC,CAAC,GACD,KAAK,GACN,KAAK,CAAC"}
|
package/dist/data/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { g as V, S as y } from "../surface-Dd2tqrPi.js";
|
|
2
2
|
import { w as x } from "../sdk-promise-D0sy7OW1.js";
|
|
3
3
|
import { c as G } from "../plugin-factory-BC3b3BOy.js";
|
|
4
|
-
import { buildServiceDescriptor as
|
|
5
|
-
import { resolvedPromiseLike as u, ok as C, err as D, stableJSONStringify as Q, DataNotFoundError as j, UserVisibleError as z, deepFreeze as
|
|
4
|
+
import { buildServiceDescriptor as $, setHeader as b } from "@conduit-client/service-fetch-network/v1";
|
|
5
|
+
import { resolvedPromiseLike as u, ok as C, err as D, stableJSONStringify as Q, DataNotFoundError as j, UserVisibleError as z, deepFreeze as g, isUserVisibleError as W } from "@conduit-client/utils";
|
|
6
6
|
import { print as P, parse as B } from "@conduit-client/onestore-graphql-parser/v1";
|
|
7
7
|
import { RetryPolicy as J, buildServiceDescriptor as X } from "@conduit-client/service-retry/v1";
|
|
8
8
|
import { buildServiceDescriptor as Y } from "@conduit-client/service-cache/v1";
|
|
9
9
|
import { buildServiceDescriptor as Z } from "@conduit-client/service-cache-control/v1";
|
|
10
10
|
import { buildInMemoryCacheInclusionPolicyService as ee } from "@conduit-client/service-cache-inclusion-policy/v1";
|
|
11
|
-
import { buildServiceDescriptor as
|
|
12
|
-
import { HttpCacheControlCommand as
|
|
13
|
-
function ne(
|
|
11
|
+
import { buildServiceDescriptor as te } from "@conduit-client/service-pubsub/v1";
|
|
12
|
+
import { HttpCacheControlCommand as re } from "@conduit-client/command-http-cache-control/v1";
|
|
13
|
+
function ne(t) {
|
|
14
14
|
return (e) => {
|
|
15
|
-
const [
|
|
16
|
-
if (typeof
|
|
17
|
-
const s =
|
|
18
|
-
return u([`${
|
|
15
|
+
const [r, n] = e;
|
|
16
|
+
if (typeof r == "string" && !r.startsWith("http")) {
|
|
17
|
+
const s = r.startsWith("/") ? r : `/${r}`;
|
|
18
|
+
return u([`${t}${s}`, n]);
|
|
19
19
|
}
|
|
20
20
|
return u(e);
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function se(
|
|
24
|
-
return (e) => u(b("Authorization", `Bearer ${
|
|
23
|
+
function se(t) {
|
|
24
|
+
return (e) => u(b("Authorization", `Bearer ${t}`, e));
|
|
25
25
|
}
|
|
26
|
-
function ae(
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
request:
|
|
26
|
+
function ae(t, e) {
|
|
27
|
+
const r = [];
|
|
28
|
+
return t && r.push(ne(t)), e && r.push(se(e)), $({
|
|
29
|
+
request: r
|
|
30
30
|
}).service;
|
|
31
31
|
}
|
|
32
32
|
const oe = {
|
|
@@ -34,59 +34,59 @@ const oe = {
|
|
|
34
34
|
Accept: "application/json",
|
|
35
35
|
"X-Chatter-Entity-Encoding": "false"
|
|
36
36
|
};
|
|
37
|
-
function ie(
|
|
38
|
-
if (
|
|
37
|
+
function ie(t) {
|
|
38
|
+
if (t instanceof Headers) {
|
|
39
39
|
const e = [];
|
|
40
|
-
return
|
|
40
|
+
return t.forEach((r, n) => e.push([n, r])), e;
|
|
41
41
|
}
|
|
42
|
-
return Array.isArray(
|
|
42
|
+
return Array.isArray(t) ? t.map(([e, r]) => [e, r]) : Object.entries(t);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
if (e === void 0) return { ...
|
|
46
|
-
const
|
|
47
|
-
for (const a of Object.keys(
|
|
44
|
+
function M(t, e) {
|
|
45
|
+
if (e === void 0) return { ...t };
|
|
46
|
+
const r = { ...t }, n = /* @__PURE__ */ new Map();
|
|
47
|
+
for (const a of Object.keys(r)) n.set(a.toLowerCase(), a);
|
|
48
48
|
const s = /* @__PURE__ */ new Set();
|
|
49
49
|
for (const [a, i] of ie(e)) {
|
|
50
50
|
const o = a.toLowerCase(), c = n.get(o);
|
|
51
|
-
c === void 0 ? (
|
|
51
|
+
c === void 0 ? (r[a] = i, n.set(o, a), s.add(o)) : s.has(o) ? r[c] = `${r[c]}, ${i}` : (r[c] = i, s.add(o));
|
|
52
52
|
}
|
|
53
|
-
return
|
|
53
|
+
return r;
|
|
54
54
|
}
|
|
55
|
-
function L(
|
|
56
|
-
return
|
|
55
|
+
function L(t) {
|
|
56
|
+
return M(oe, t);
|
|
57
57
|
}
|
|
58
|
-
function ce(
|
|
59
|
-
if (
|
|
58
|
+
function ce(t) {
|
|
59
|
+
if (t === void 0) return;
|
|
60
60
|
const e = {};
|
|
61
|
-
return new Headers(
|
|
62
|
-
e[n] =
|
|
61
|
+
return new Headers(t).forEach((r, n) => {
|
|
62
|
+
e[n] = r;
|
|
63
63
|
}), Object.keys(e).length > 0 ? e : void 0;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const S = () => {
|
|
66
66
|
}, A = async () => {
|
|
67
67
|
};
|
|
68
|
-
function _(
|
|
68
|
+
function _(t) {
|
|
69
69
|
try {
|
|
70
|
-
return C(B(
|
|
70
|
+
return C(B(t));
|
|
71
71
|
} catch (e) {
|
|
72
|
-
return D(
|
|
72
|
+
return D(f(e));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function k(
|
|
76
|
-
const
|
|
75
|
+
function k(t, e) {
|
|
76
|
+
const r = t.definitions.filter(
|
|
77
77
|
(n) => n.kind === "OperationDefinition"
|
|
78
78
|
);
|
|
79
|
-
return
|
|
79
|
+
return r.length === 0 ? "unknown" : r.length === 1 ? e === void 0 || r[0].name?.value === e ? r[0].operation : "unknown" : e === void 0 ? "unknown" : r.find((n) => n.name?.value === e)?.operation ?? "unknown";
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
if (
|
|
83
|
-
const e =
|
|
81
|
+
function f(t) {
|
|
82
|
+
if (t && typeof t == "object" && "data" in t) {
|
|
83
|
+
const e = t.data;
|
|
84
84
|
if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
|
|
85
85
|
return e.errors;
|
|
86
86
|
}
|
|
87
|
-
return
|
|
87
|
+
return t instanceof Error ? [{ message: t.message }] : typeof t == "string" ? [{ message: t }] : [{ message: "Unknown error" }];
|
|
88
88
|
}
|
|
89
|
-
async function H(
|
|
89
|
+
async function H(t, { mutation: e, variables: r, operationName: n, headers: s }) {
|
|
90
90
|
const a = _(e);
|
|
91
91
|
if (a.isErr()) return { data: void 0, errors: a.error };
|
|
92
92
|
const i = a.value, o = k(i, n);
|
|
@@ -100,9 +100,9 @@ async function H(r, { mutation: e, variables: t, operationName: n, headers: s })
|
|
|
100
100
|
]
|
|
101
101
|
};
|
|
102
102
|
try {
|
|
103
|
-
const c = await
|
|
103
|
+
const c = await t({
|
|
104
104
|
query: P(i),
|
|
105
|
-
variables:
|
|
105
|
+
variables: r,
|
|
106
106
|
operationName: n,
|
|
107
107
|
headers: s
|
|
108
108
|
});
|
|
@@ -111,12 +111,12 @@ async function H(r, { mutation: e, variables: t, operationName: n, headers: s })
|
|
|
111
111
|
errors: c.errors
|
|
112
112
|
};
|
|
113
113
|
} catch (c) {
|
|
114
|
-
return { data: void 0, errors:
|
|
114
|
+
return { data: void 0, errors: f(c) };
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
function I(
|
|
117
|
+
function I(t) {
|
|
118
118
|
function e(n, s, a, i) {
|
|
119
|
-
return
|
|
119
|
+
return t({
|
|
120
120
|
query: P(n),
|
|
121
121
|
variables: s,
|
|
122
122
|
operationName: a,
|
|
@@ -126,10 +126,10 @@ function I(r) {
|
|
|
126
126
|
data: o.data ?? void 0,
|
|
127
127
|
errors: o.errors
|
|
128
128
|
}),
|
|
129
|
-
(o) => ({ data: void 0, errors:
|
|
129
|
+
(o) => ({ data: void 0, errors: f(o) })
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
132
|
+
async function r({
|
|
133
133
|
query: n,
|
|
134
134
|
variables: s,
|
|
135
135
|
operationName: a,
|
|
@@ -140,44 +140,44 @@ function I(r) {
|
|
|
140
140
|
return {
|
|
141
141
|
data: void 0,
|
|
142
142
|
errors: o.error,
|
|
143
|
-
subscribe: () =>
|
|
143
|
+
subscribe: () => S,
|
|
144
144
|
refresh: A
|
|
145
145
|
};
|
|
146
|
-
const c = o.value,
|
|
147
|
-
if (
|
|
146
|
+
const c = o.value, l = k(c, a);
|
|
147
|
+
if (l !== "query")
|
|
148
148
|
return {
|
|
149
149
|
data: void 0,
|
|
150
150
|
errors: [
|
|
151
151
|
{
|
|
152
|
-
message: `DataSDK.graphql.query() requires a GraphQL query, received ${
|
|
152
|
+
message: `DataSDK.graphql.query() requires a GraphQL query, received ${l}.`
|
|
153
153
|
}
|
|
154
154
|
],
|
|
155
|
-
subscribe: () =>
|
|
155
|
+
subscribe: () => S,
|
|
156
156
|
refresh: A
|
|
157
157
|
};
|
|
158
158
|
const h = /* @__PURE__ */ new Set(), p = s, m = await e(c, p, a, i);
|
|
159
159
|
return {
|
|
160
160
|
data: m.data,
|
|
161
161
|
errors: m.errors,
|
|
162
|
-
subscribe(
|
|
163
|
-
return h.add(
|
|
164
|
-
h.delete(
|
|
162
|
+
subscribe(d) {
|
|
163
|
+
return h.add(d), () => {
|
|
164
|
+
h.delete(d);
|
|
165
165
|
};
|
|
166
166
|
},
|
|
167
167
|
async refresh() {
|
|
168
|
-
const
|
|
169
|
-
for (const
|
|
168
|
+
const d = await e(c, p, a, i);
|
|
169
|
+
for (const v of h) v(d);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
return {
|
|
174
|
-
query:
|
|
175
|
-
mutate: (n) => H(
|
|
174
|
+
query: r,
|
|
175
|
+
mutate: (n) => H(t, n)
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
const ue = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0";
|
|
179
|
-
function F(
|
|
180
|
-
return `/services/data/v${
|
|
179
|
+
function F(t = ue) {
|
|
180
|
+
return `/services/data/v${t}`;
|
|
181
181
|
}
|
|
182
182
|
const he = {
|
|
183
183
|
"Content-Type": "application/json",
|
|
@@ -188,33 +188,33 @@ class le {
|
|
|
188
188
|
pathData;
|
|
189
189
|
graphql;
|
|
190
190
|
constructor(e) {
|
|
191
|
-
const
|
|
192
|
-
this.pathData = F(e?.apiVersion ??
|
|
191
|
+
const r = de(), n = fe(e?.instanceUrl ?? r.instanceUrl), s = e?.accessToken ?? r.accessToken;
|
|
192
|
+
this.pathData = F(e?.apiVersion ?? r.apiVersion), this.clientFetch = ae(n || void 0, s), this.graphql = I(this.executeRawGraphQL.bind(this));
|
|
193
193
|
}
|
|
194
194
|
async executeRawGraphQL({
|
|
195
195
|
query: e,
|
|
196
|
-
variables:
|
|
196
|
+
variables: r,
|
|
197
197
|
operationName: n,
|
|
198
198
|
headers: s
|
|
199
199
|
}) {
|
|
200
200
|
return (await this.clientFetch(`${this.pathData}/graphql`, {
|
|
201
201
|
method: "POST",
|
|
202
|
-
body: JSON.stringify({ query: e, variables:
|
|
203
|
-
headers:
|
|
202
|
+
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
203
|
+
headers: M(he, s)
|
|
204
204
|
})).json();
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
function de() {
|
|
208
|
-
const
|
|
208
|
+
const t = globalThis.MOSAIC_ENV;
|
|
209
209
|
return {
|
|
210
|
-
instanceUrl:
|
|
211
|
-
accessToken:
|
|
212
|
-
apiVersion:
|
|
210
|
+
instanceUrl: t?.instanceUrl,
|
|
211
|
+
accessToken: t?.accessToken,
|
|
212
|
+
apiVersion: t?.apiVersion
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function fe(
|
|
216
|
-
if (!
|
|
217
|
-
let e =
|
|
215
|
+
function fe(t) {
|
|
216
|
+
if (!t || t === "/") return "";
|
|
217
|
+
let e = t;
|
|
218
218
|
return !e.startsWith("/") && !e.startsWith("http") && (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
219
219
|
}
|
|
220
220
|
const pe = "graphqlQuery";
|
|
@@ -230,12 +230,12 @@ class me {
|
|
|
230
230
|
*/
|
|
231
231
|
async executeRawGraphQL({
|
|
232
232
|
query: e,
|
|
233
|
-
variables:
|
|
233
|
+
variables: r,
|
|
234
234
|
operationName: n
|
|
235
235
|
}) {
|
|
236
236
|
return (await window.openai.callTool(pe, {
|
|
237
237
|
query: e,
|
|
238
|
-
...
|
|
238
|
+
...r != null ? { variables: r } : {},
|
|
239
239
|
...n != null ? { operationName: n } : {}
|
|
240
240
|
})).structuredContent;
|
|
241
241
|
}
|
|
@@ -243,39 +243,39 @@ class me {
|
|
|
243
243
|
const ye = {
|
|
244
244
|
graphql: !0,
|
|
245
245
|
fetch: !0
|
|
246
|
-
}, be = new Set(Object.keys(ye)), w = "Accept-Language",
|
|
246
|
+
}, be = new Set(Object.keys(ye)), w = "Accept-Language", ge = (t) => {
|
|
247
247
|
const e = globalThis.SFDC_ENV?.language;
|
|
248
248
|
if (!e)
|
|
249
|
-
return u(
|
|
250
|
-
const [
|
|
251
|
-
return (
|
|
252
|
-
},
|
|
253
|
-
let e = b(
|
|
254
|
-
return e = b(
|
|
249
|
+
return u(t);
|
|
250
|
+
const [r, n] = t;
|
|
251
|
+
return (r instanceof Request && !n?.headers ? r.headers.has(w) : new Headers(n?.headers).has(w)) ? u(t) : u(b(w, e, t));
|
|
252
|
+
}, Se = "X-SFDC-Client-Name", ve = "X-SFDC-Client-Version", we = "@salesforce/platform-sdk", Ee = "11.55.1", Ce = (t) => {
|
|
253
|
+
let e = b(Se, we, t);
|
|
254
|
+
return e = b(ve, Ee, e), u(e);
|
|
255
255
|
}, De = "X-CSRF-Token";
|
|
256
|
-
function Ae(
|
|
257
|
-
const { protectedUrls:
|
|
256
|
+
function Ae(t, e = {}) {
|
|
257
|
+
const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
|
|
258
258
|
return async (s) => {
|
|
259
259
|
const [a, i] = s, o = a instanceof Request ? a.url : a instanceof URL ? a.href : a, c = i?.method ?? (a instanceof Request ? a.method : void 0) ?? "GET";
|
|
260
|
-
if (R(n, o) || Pe(c) && R(
|
|
261
|
-
const h = await
|
|
260
|
+
if (R(n, o) || Pe(c) && R(r, o)) {
|
|
261
|
+
const h = await t.getToken();
|
|
262
262
|
s = b(De, h, s);
|
|
263
263
|
}
|
|
264
264
|
return u(s);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
function Pe(
|
|
268
|
-
const e =
|
|
267
|
+
function Pe(t) {
|
|
268
|
+
const e = t.toLowerCase();
|
|
269
269
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
270
270
|
}
|
|
271
|
-
function R(
|
|
272
|
-
const
|
|
273
|
-
return
|
|
271
|
+
function R(t, e) {
|
|
272
|
+
const r = new URL(e, globalThis.location?.href ?? "http://localhost");
|
|
273
|
+
return t.some((n) => r.pathname.includes(n));
|
|
274
274
|
}
|
|
275
|
-
function _e(
|
|
276
|
-
const
|
|
275
|
+
function _e(t, e = {}) {
|
|
276
|
+
const r = Ae(t, e);
|
|
277
277
|
async function n(s) {
|
|
278
|
-
const a = await
|
|
278
|
+
const a = await r(s);
|
|
279
279
|
return fetch(a[0], a[1]);
|
|
280
280
|
}
|
|
281
281
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
@@ -288,13 +288,13 @@ class Re extends J {
|
|
|
288
288
|
/**
|
|
289
289
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
290
290
|
*/
|
|
291
|
-
async shouldRetry(e,
|
|
292
|
-
return
|
|
291
|
+
async shouldRetry(e, r) {
|
|
292
|
+
return r.attempt >= 1 ? !1 : ke.includes(e.status);
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
295
|
* CSRF token refresh should happen immediately with no delay.
|
|
296
296
|
*/
|
|
297
|
-
async calculateDelay(e,
|
|
297
|
+
async calculateDelay(e, r) {
|
|
298
298
|
return 0;
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -303,13 +303,13 @@ class Re extends J {
|
|
|
303
303
|
* @param _result - The failed response that triggered the retry (unused, already validated)
|
|
304
304
|
* @param _context - Current retry context (unused but part of interface)
|
|
305
305
|
*/
|
|
306
|
-
async prepareRetry(e,
|
|
306
|
+
async prepareRetry(e, r) {
|
|
307
307
|
await this.csrfTokenManager.refreshToken();
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
class qe {
|
|
311
|
-
constructor(e,
|
|
312
|
-
this.endpoint = e, this.cacheName =
|
|
311
|
+
constructor(e, r) {
|
|
312
|
+
this.endpoint = e, this.cacheName = r, this.tokenPromise = this.obtainToken();
|
|
313
313
|
}
|
|
314
314
|
tokenPromise;
|
|
315
315
|
refreshPromise;
|
|
@@ -336,10 +336,10 @@ class qe {
|
|
|
336
336
|
* @returns Promise that resolves to the CSRF token string
|
|
337
337
|
*/
|
|
338
338
|
async obtainToken() {
|
|
339
|
-
let e = await this.withCache((s) => s.match(this.endpoint)),
|
|
340
|
-
e || (e = await fetch(this.endpoint, { method: "get" }),
|
|
339
|
+
let e = await this.withCache((s) => s.match(this.endpoint)), r = !1;
|
|
340
|
+
e || (e = await fetch(this.endpoint, { method: "get" }), r = !0);
|
|
341
341
|
const n = (await e.clone().json()).csrfToken;
|
|
342
|
-
return
|
|
342
|
+
return r && await this.withCache((s) => s.put(this.endpoint, e)), n;
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
345
345
|
* Provides a safe way to interact with the Cache API with fallback for unsupported environments.
|
|
@@ -349,68 +349,68 @@ class qe {
|
|
|
349
349
|
*/
|
|
350
350
|
async withCache(e) {
|
|
351
351
|
if (this.cacheName && caches) {
|
|
352
|
-
const
|
|
353
|
-
return e(
|
|
352
|
+
const r = await caches.open(this.cacheName);
|
|
353
|
+
return e(r);
|
|
354
354
|
} else
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
const q = /* @__PURE__ */ new Map();
|
|
359
|
-
function Oe(
|
|
360
|
-
const { endpoint: e, cacheName:
|
|
359
|
+
function Oe(t) {
|
|
360
|
+
const { endpoint: e, cacheName: r, ...n } = t.csrf;
|
|
361
361
|
let s = q.get(e);
|
|
362
|
-
return s || (s = new qe(e,
|
|
362
|
+
return s || (s = new qe(e, r), q.set(e, s)), $(
|
|
363
363
|
{
|
|
364
364
|
retry: _e(s, n),
|
|
365
|
-
request: [Ce,
|
|
365
|
+
request: [Ce, ge]
|
|
366
366
|
},
|
|
367
367
|
X(new Re(s)).service
|
|
368
368
|
).service;
|
|
369
369
|
}
|
|
370
370
|
const O = /* @__PURE__ */ new Map();
|
|
371
|
-
function Te(
|
|
372
|
-
let e = O.get(
|
|
371
|
+
function Te(t) {
|
|
372
|
+
let e = O.get(t);
|
|
373
373
|
if (!e) {
|
|
374
|
-
const
|
|
375
|
-
e = { cache:
|
|
374
|
+
const r = Y().service, n = ee(r).service, s = Z(r, n).service, a = te().service;
|
|
375
|
+
e = { cache: r, cacheController: s, pubSub: a }, O.set(t, e);
|
|
376
376
|
}
|
|
377
377
|
return e;
|
|
378
378
|
}
|
|
379
|
-
function Ne(
|
|
380
|
-
const
|
|
379
|
+
function Ne(t, e) {
|
|
380
|
+
const r = Te(t);
|
|
381
381
|
return {
|
|
382
|
-
shared:
|
|
382
|
+
shared: r,
|
|
383
383
|
services: {
|
|
384
|
-
cacheController:
|
|
385
|
-
pubSub:
|
|
384
|
+
cacheController: r.cacheController,
|
|
385
|
+
pubSub: r.pubSub,
|
|
386
386
|
fetch: e
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
390
|
const T = 300;
|
|
391
|
-
function
|
|
391
|
+
function $e(t, e) {
|
|
392
392
|
try {
|
|
393
|
-
return JSON.parse(JSON.stringify(
|
|
394
|
-
} catch (
|
|
393
|
+
return JSON.parse(JSON.stringify(t));
|
|
394
|
+
} catch (r) {
|
|
395
395
|
const n = e || "(anonymous)", s = new TypeError(
|
|
396
|
-
`HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${
|
|
396
|
+
`HttpGraphQLResourceCacheControlCommand: variables for operation "${n}" must be JSON-serializable. ${r.message}`
|
|
397
397
|
);
|
|
398
|
-
throw s.cause =
|
|
398
|
+
throw s.cause = r, s;
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
function
|
|
402
|
-
if (typeof
|
|
403
|
-
const e =
|
|
401
|
+
function Me(t) {
|
|
402
|
+
if (typeof t == "object" && t.type === "max-age") {
|
|
403
|
+
const e = t.maxAge;
|
|
404
404
|
return Number.isFinite(e) && e >= 0 ? e : T;
|
|
405
405
|
}
|
|
406
406
|
return T;
|
|
407
407
|
}
|
|
408
|
-
class Le extends
|
|
409
|
-
constructor(e,
|
|
410
|
-
super(
|
|
408
|
+
class Le extends re {
|
|
409
|
+
constructor(e, r, n) {
|
|
410
|
+
super(r), this.url = n, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = $e(
|
|
411
411
|
e.variables ?? {},
|
|
412
412
|
this.normalizedOperationName
|
|
413
|
-
), this.cacheControl = e.cacheControl, this.resolvedMaxAge =
|
|
413
|
+
), this.cacheControl = e.cacheControl, this.resolvedMaxAge = Me(e.cacheControl), this.headers = e.headers, this.headersKey = ce(e.headers);
|
|
414
414
|
}
|
|
415
415
|
query;
|
|
416
416
|
normalizedVariables;
|
|
@@ -455,14 +455,14 @@ class Le extends te {
|
|
|
455
455
|
* @returns result or error from the cache
|
|
456
456
|
*/
|
|
457
457
|
readFromCache(e) {
|
|
458
|
-
const
|
|
458
|
+
const r = this.buildKey(), n = e.get(r)?.value;
|
|
459
459
|
return n === void 0 ? u(D(new j())) : u(C(n));
|
|
460
460
|
}
|
|
461
|
-
writeToCache(e,
|
|
462
|
-
if (
|
|
461
|
+
writeToCache(e, r) {
|
|
462
|
+
if (r.isOk() && r.value.data != null && Object.keys(r.value.data).length > 0) {
|
|
463
463
|
const n = Math.floor(Date.now() / 1e3);
|
|
464
464
|
e.set(this.buildKey(), {
|
|
465
|
-
value:
|
|
465
|
+
value: r.value.data,
|
|
466
466
|
metadata: {
|
|
467
467
|
cacheControl: {
|
|
468
468
|
type: "max-age",
|
|
@@ -489,63 +489,63 @@ class Le extends te {
|
|
|
489
489
|
return this.responseHasErrors(e) ? D(new z(e)) : C(e);
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
function K(
|
|
493
|
-
if (W(
|
|
494
|
-
const e =
|
|
492
|
+
function K(t) {
|
|
493
|
+
if (W(t) && t.data && typeof t.data == "object") {
|
|
494
|
+
const e = t.data;
|
|
495
495
|
if (e.data != null)
|
|
496
496
|
return e.data;
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
|
-
function He(
|
|
499
|
+
function He(t) {
|
|
500
500
|
return (e) => {
|
|
501
501
|
if (e.isOk()) {
|
|
502
|
-
const
|
|
503
|
-
|
|
502
|
+
const r = e.value;
|
|
503
|
+
g(r), t({ data: r, errors: void 0 });
|
|
504
504
|
} else {
|
|
505
|
-
const
|
|
506
|
-
|
|
505
|
+
const r = K(e.error);
|
|
506
|
+
r && g(r), t({ data: r, errors: f(e.error) });
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
|
-
async function Ie(
|
|
511
|
-
let e,
|
|
510
|
+
async function Ie(t) {
|
|
511
|
+
let e, r, n;
|
|
512
512
|
try {
|
|
513
|
-
const s = await
|
|
514
|
-
s.isOk() ? (e = s.value.data,
|
|
513
|
+
const s = await t.execute();
|
|
514
|
+
s.isOk() ? (e = s.value.data, g(e), n = (a) => s.value.subscribe(a)) : (e = K(s.error.failure), e && g(e), r = f(s.error.failure), n = (a) => s.error.subscribe(a));
|
|
515
515
|
} catch (s) {
|
|
516
|
-
|
|
516
|
+
r = f(s);
|
|
517
517
|
}
|
|
518
518
|
return {
|
|
519
519
|
data: e,
|
|
520
|
-
errors:
|
|
520
|
+
errors: r,
|
|
521
521
|
subscribe(s) {
|
|
522
|
-
return n ? n(He(s)) :
|
|
522
|
+
return n ? n(He(s)) : S;
|
|
523
523
|
},
|
|
524
524
|
async refresh() {
|
|
525
|
-
await
|
|
525
|
+
await t.refresh();
|
|
526
526
|
}
|
|
527
527
|
};
|
|
528
528
|
}
|
|
529
|
-
function E(
|
|
529
|
+
function E(t) {
|
|
530
530
|
return {
|
|
531
531
|
data: void 0,
|
|
532
|
-
errors:
|
|
533
|
-
subscribe: () =>
|
|
532
|
+
errors: t,
|
|
533
|
+
subscribe: () => S,
|
|
534
534
|
refresh: A
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
function Fe({
|
|
538
|
-
bundle:
|
|
538
|
+
bundle: t,
|
|
539
539
|
url: e,
|
|
540
|
-
executeRaw:
|
|
540
|
+
executeRaw: r
|
|
541
541
|
}) {
|
|
542
|
-
const { services: n } =
|
|
542
|
+
const { services: n } = t;
|
|
543
543
|
async function s({
|
|
544
544
|
query: a,
|
|
545
545
|
variables: i,
|
|
546
546
|
operationName: o,
|
|
547
547
|
cacheControl: c,
|
|
548
|
-
headers:
|
|
548
|
+
headers: l
|
|
549
549
|
}) {
|
|
550
550
|
const h = _(a);
|
|
551
551
|
if (h.isErr()) return E(h.error);
|
|
@@ -556,27 +556,27 @@ function Fe({
|
|
|
556
556
|
message: `DataSDK.graphql.query() requires a GraphQL query, received ${m}.`
|
|
557
557
|
}
|
|
558
558
|
]);
|
|
559
|
-
let
|
|
559
|
+
let d;
|
|
560
560
|
try {
|
|
561
|
-
|
|
561
|
+
d = new Le(
|
|
562
562
|
{
|
|
563
563
|
query: P(p),
|
|
564
564
|
variables: i,
|
|
565
565
|
operationName: o,
|
|
566
566
|
cacheControl: c,
|
|
567
|
-
headers:
|
|
567
|
+
headers: l
|
|
568
568
|
},
|
|
569
569
|
n,
|
|
570
570
|
e
|
|
571
571
|
);
|
|
572
|
-
} catch (
|
|
573
|
-
return E(
|
|
572
|
+
} catch (v) {
|
|
573
|
+
return E(f(v));
|
|
574
574
|
}
|
|
575
|
-
return Ie(
|
|
575
|
+
return Ie(d);
|
|
576
576
|
}
|
|
577
577
|
return {
|
|
578
578
|
query: s,
|
|
579
|
-
mutate: (a) => H(
|
|
579
|
+
mutate: (a) => H(r, a)
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
582
|
const Ke = 1, Ue = `@salesforce/platform-sdk-data_v${Ke}`, U = F(), Ve = `${U}/ui-api`, N = `${U}/graphql`;
|
|
@@ -586,8 +586,8 @@ class xe {
|
|
|
586
586
|
onStatus;
|
|
587
587
|
graphql;
|
|
588
588
|
constructor(e) {
|
|
589
|
-
const
|
|
590
|
-
this.baseUrl = Qe(e?.basePath ??
|
|
589
|
+
const r = Ge();
|
|
590
|
+
this.baseUrl = Qe(e?.basePath ?? r.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = Oe({
|
|
591
591
|
csrf: {
|
|
592
592
|
endpoint: `${this.baseUrl}${Ve}/session/csrf`,
|
|
593
593
|
cacheName: Ue,
|
|
@@ -602,8 +602,8 @@ class xe {
|
|
|
602
602
|
executeRaw: this.executeRawGraphQL.bind(this)
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
|
-
async fetch(e,
|
|
606
|
-
const n = this.applySalesforceBase(e), s = await this.clientFetch(n,
|
|
605
|
+
async fetch(e, r) {
|
|
606
|
+
const n = this.applySalesforceBase(e), s = await this.clientFetch(n, r);
|
|
607
607
|
return await this.onStatus[s.status]?.(), s;
|
|
608
608
|
}
|
|
609
609
|
/**
|
|
@@ -614,13 +614,13 @@ class xe {
|
|
|
614
614
|
*/
|
|
615
615
|
async executeRawGraphQL({
|
|
616
616
|
query: e,
|
|
617
|
-
variables:
|
|
617
|
+
variables: r,
|
|
618
618
|
operationName: n,
|
|
619
619
|
headers: s
|
|
620
620
|
}) {
|
|
621
621
|
return (await this.fetch(N, {
|
|
622
622
|
method: "POST",
|
|
623
|
-
body: JSON.stringify({ query: e, variables:
|
|
623
|
+
body: JSON.stringify({ query: e, variables: r, operationName: n }),
|
|
624
624
|
headers: L(s)
|
|
625
625
|
})).json();
|
|
626
626
|
}
|
|
@@ -632,8 +632,8 @@ class xe {
|
|
|
632
632
|
if (typeof e == "string") {
|
|
633
633
|
if (e.startsWith("http"))
|
|
634
634
|
return e;
|
|
635
|
-
const
|
|
636
|
-
return `${this.baseUrl}${
|
|
635
|
+
const r = e.startsWith("/") ? e : `/${e}`;
|
|
636
|
+
return `${this.baseUrl}${r}`;
|
|
637
637
|
}
|
|
638
638
|
return e;
|
|
639
639
|
}
|
|
@@ -643,32 +643,41 @@ function Ge() {
|
|
|
643
643
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
-
function Qe(
|
|
647
|
-
if (!
|
|
648
|
-
let e =
|
|
646
|
+
function Qe(t) {
|
|
647
|
+
if (!t || t === "/") return "";
|
|
648
|
+
let e = t;
|
|
649
649
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
650
650
|
}
|
|
651
|
-
|
|
651
|
+
function je(t) {
|
|
652
|
+
const e = typeof t == "object" && t !== null && "setup" in t, r = e ? t : t.plugin, n = e ? r?.name : t.as;
|
|
653
|
+
if (typeof r?.setup != "function")
|
|
654
|
+
throw new Error("Plugin entry cannot attach: it is missing a setup function.");
|
|
655
|
+
if (typeof n != "string" || n.length === 0)
|
|
656
|
+
throw new Error(
|
|
657
|
+
e ? 'Plugin entry cannot attach: "name" must be a non-empty string.' : 'Plugin entry cannot attach: alias "as" must be a non-empty string.'
|
|
658
|
+
);
|
|
659
|
+
return { plugin: r, mountName: n };
|
|
660
|
+
}
|
|
661
|
+
async function ze(t, e, r = /* @__PURE__ */ new Set()) {
|
|
652
662
|
if (e.length === 0)
|
|
653
|
-
return
|
|
654
|
-
const n = Object.create(
|
|
663
|
+
return t;
|
|
664
|
+
const n = Object.create(t);
|
|
655
665
|
for (const s of e) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
if (s.name in n)
|
|
666
|
+
const { plugin: a, mountName: i } = je(s), o = i === a.name ? `"${a.name}"` : `"${a.name}" (aliased as "${i}")`;
|
|
667
|
+
if (r.has(i))
|
|
668
|
+
throw new Error(`Plugin ${o} cannot attach: "${i}" is a reserved SDK name.`);
|
|
669
|
+
if (i in n)
|
|
661
670
|
throw new Error(
|
|
662
|
-
`Plugin
|
|
671
|
+
`Plugin ${o} cannot attach: "${i}" is already defined on the SDK.`
|
|
663
672
|
);
|
|
664
|
-
let
|
|
673
|
+
let c;
|
|
665
674
|
try {
|
|
666
|
-
|
|
667
|
-
} catch (
|
|
668
|
-
throw new Error(`Plugin
|
|
675
|
+
c = await a.setup(n);
|
|
676
|
+
} catch (l) {
|
|
677
|
+
throw new Error(`Plugin ${o} failed during setup.`, { cause: l });
|
|
669
678
|
}
|
|
670
|
-
Object.defineProperty(n,
|
|
671
|
-
value:
|
|
679
|
+
Object.defineProperty(n, i, {
|
|
680
|
+
value: c,
|
|
672
681
|
enumerable: !0,
|
|
673
682
|
writable: !0,
|
|
674
683
|
configurable: !0
|
|
@@ -676,23 +685,23 @@ async function je(r, e, t = /* @__PURE__ */ new Set()) {
|
|
|
676
685
|
}
|
|
677
686
|
return n;
|
|
678
687
|
}
|
|
679
|
-
function
|
|
680
|
-
let
|
|
688
|
+
function it(t, ...e) {
|
|
689
|
+
let r = t[0] ?? "";
|
|
681
690
|
for (let n = 0; n < e.length; n += 1)
|
|
682
|
-
|
|
683
|
-
return
|
|
691
|
+
r += String(e[n]) + (t[n + 1] ?? "");
|
|
692
|
+
return r;
|
|
684
693
|
}
|
|
685
|
-
const
|
|
686
|
-
async function
|
|
694
|
+
const ct = G();
|
|
695
|
+
async function We(t) {
|
|
687
696
|
try {
|
|
688
|
-
switch (await V(
|
|
697
|
+
switch (await V(t?.surface)) {
|
|
689
698
|
case y.OpenAI:
|
|
690
699
|
return new me();
|
|
691
700
|
case y.WebApp:
|
|
692
701
|
case y.MicroFrontend:
|
|
693
|
-
return new xe(
|
|
702
|
+
return new xe(t?.webapp);
|
|
694
703
|
case y.Mosaic:
|
|
695
|
-
return new le(
|
|
704
|
+
return new le(t?.mosaic);
|
|
696
705
|
case y.MCPApps:
|
|
697
706
|
return {};
|
|
698
707
|
default:
|
|
@@ -702,17 +711,17 @@ async function ze(r) {
|
|
|
702
711
|
return {};
|
|
703
712
|
}
|
|
704
713
|
}
|
|
705
|
-
function
|
|
714
|
+
function ut(t) {
|
|
706
715
|
return x(
|
|
707
716
|
(async () => {
|
|
708
|
-
const e = await
|
|
709
|
-
return
|
|
717
|
+
const e = await We(t);
|
|
718
|
+
return ze(e, t?.plugins ?? [], be);
|
|
710
719
|
})(),
|
|
711
720
|
"createDataSDK"
|
|
712
721
|
);
|
|
713
722
|
}
|
|
714
723
|
export {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
724
|
+
ut as createDataSDK,
|
|
725
|
+
ct as defineDataPlugin,
|
|
726
|
+
it as gql
|
|
718
727
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.55.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
127
127
|
"@conduit-client/service-retry": "3.19.6",
|
|
128
128
|
"@conduit-client/utils": "3.19.6",
|
|
129
|
-
"@salesforce/jsonrpc": "^11.
|
|
129
|
+
"@salesforce/jsonrpc": "^11.55.1",
|
|
130
130
|
"@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|