@salesforce/platform-sdk 11.45.9 → 11.45.11
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/data.d.ts +118 -8
- package/dist/core/data.d.ts.map +1 -1
- package/dist/data/gql.d.ts +16 -0
- package/dist/data/gql.d.ts.map +1 -1
- package/dist/data/index.d.ts +53 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +1 -1
- package/dist/data/mosaic/index.d.ts +12 -0
- package/dist/data/mosaic/index.d.ts.map +1 -1
- package/package.json +6 -3
package/dist/core/data.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* A single GraphQL error entry returned in a {@link GraphQLResponse}.
|
|
8
|
+
* Contains the error message and optional location/path information.
|
|
9
|
+
*/
|
|
6
10
|
export interface GraphQLError {
|
|
7
11
|
message: string;
|
|
8
12
|
locations?: {
|
|
@@ -11,6 +15,11 @@ export interface GraphQLError {
|
|
|
11
15
|
}[];
|
|
12
16
|
path?: string[];
|
|
13
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The raw GraphQL response envelope containing data and optional errors.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam T - The shape of the `data` field.
|
|
22
|
+
*/
|
|
14
23
|
export interface GraphQLResponse<T> {
|
|
15
24
|
data: T;
|
|
16
25
|
errors?: GraphQLError[];
|
|
@@ -28,6 +37,11 @@ export interface GraphQLResponse<T> {
|
|
|
28
37
|
* OpenAI surface delegates to an MCP tool that exposes no header channel.
|
|
29
38
|
*/
|
|
30
39
|
export type GraphQLRequestHeaders = HeadersInit;
|
|
40
|
+
/**
|
|
41
|
+
* A GraphQL request containing the operation source and optional variables.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam V - The shape of the `variables` object.
|
|
44
|
+
*/
|
|
31
45
|
export interface GraphQLRequest<V = Record<string, unknown>> {
|
|
32
46
|
query: string;
|
|
33
47
|
variables?: V;
|
|
@@ -58,6 +72,11 @@ export interface QuerySnapshot<T> {
|
|
|
58
72
|
data: T | undefined;
|
|
59
73
|
errors?: GraphQLError[];
|
|
60
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Callback invoked with each new {@link QuerySnapshot}.
|
|
77
|
+
*
|
|
78
|
+
* @typeParam T - The shape of the query result data.
|
|
79
|
+
*/
|
|
61
80
|
export type QuerySubscriber<T> = (snapshot: QuerySnapshot<T>) => void;
|
|
62
81
|
/**
|
|
63
82
|
* Reactive query handle resolved by {@link DataSDKGraphQL.query}.
|
|
@@ -68,11 +87,24 @@ export type QuerySubscriber<T> = (snapshot: QuerySnapshot<T>) => void;
|
|
|
68
87
|
* `refresh` re-issues the underlying request, bypassing the cache where one
|
|
69
88
|
* exists and propagating the result to subscribers.
|
|
70
89
|
*
|
|
90
|
+
* @remarks
|
|
71
91
|
* On uncached surfaces (Mosaic, OpenAI), `subscribe` only emits in response
|
|
72
92
|
* to `refresh()` — there is no cache to push background updates.
|
|
73
93
|
*/
|
|
74
94
|
export interface QueryResult<T> extends QuerySnapshot<T> {
|
|
75
95
|
subscribe(cb: QuerySubscriber<T>): Unsubscribe;
|
|
96
|
+
/**
|
|
97
|
+
* Re-fetch the query, bypassing the cache where one exists and
|
|
98
|
+
* propagating the result to subscribers.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* Never rejects. A failed re-fetch does not throw on the awaited
|
|
102
|
+
* `refresh()` call: on uncached surfaces (Mosaic, OpenAI) the failure is
|
|
103
|
+
* delivered to `subscribe()` callbacks as a {@link QuerySnapshot} with a
|
|
104
|
+
* populated `errors` array; on cached surfaces (WebApp) a failed re-fetch
|
|
105
|
+
* is not observable on the awaited call — subscribers receive the
|
|
106
|
+
* resulting cache state.
|
|
107
|
+
*/
|
|
76
108
|
refresh(): Promise<void>;
|
|
77
109
|
}
|
|
78
110
|
/**
|
|
@@ -98,12 +130,23 @@ export type CacheControlShorthand = "no-cache" | "only-if-cached";
|
|
|
98
130
|
/**
|
|
99
131
|
* Override the default TTL (300 seconds) with a custom max-age in seconds.
|
|
100
132
|
*
|
|
133
|
+
* @remarks
|
|
101
134
|
* - `maxAge: 0` — entry is written but immediately considered stale
|
|
102
135
|
* (always re-fetches, similar to `"no-cache"` but writes a 0s TTL).
|
|
103
136
|
* - Invalid values (NaN, Infinity, negative) fall back to the 300s default.
|
|
104
137
|
*/
|
|
105
138
|
export interface CacheControlMaxAge {
|
|
106
139
|
type: "max-age";
|
|
140
|
+
/**
|
|
141
|
+
* Cache TTL in seconds.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* Rule of thumb by data volatility: short (~30s) for frequently-changing
|
|
145
|
+
* records, longer (~15min, i.e. 900s) for stable object/metadata.
|
|
146
|
+
*
|
|
147
|
+
* @example 30
|
|
148
|
+
* @example 900
|
|
149
|
+
*/
|
|
107
150
|
maxAge: number;
|
|
108
151
|
}
|
|
109
152
|
/**
|
|
@@ -124,11 +167,16 @@ export interface QueryOptions<V = Record<string, unknown>> {
|
|
|
124
167
|
cacheControl?: CacheControl;
|
|
125
168
|
/**
|
|
126
169
|
* Extra HTTP headers for this request, merged over the surface's canonical
|
|
127
|
-
* header set.
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
170
|
+
* header set.
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* On cached surfaces (WebApp), `headers` is part of the cache key: two calls
|
|
174
|
+
* that differ only in `headers` resolve to different cache entries. This
|
|
175
|
+
* prevents a response scoped by a header — e.g. `Authorization` — from being
|
|
176
|
+
* served to a later caller that passed a different value, while calls with
|
|
177
|
+
* equivalent headers still share an entry.
|
|
178
|
+
*
|
|
179
|
+
* @see {@link GraphQLRequestHeaders}
|
|
132
180
|
*/
|
|
133
181
|
headers?: GraphQLRequestHeaders;
|
|
134
182
|
}
|
|
@@ -167,18 +215,79 @@ export interface DataSDKGraphQL {
|
|
|
167
215
|
* updates, so `refresh()` is the sole source of new snapshots and each
|
|
168
216
|
* call costs one network request.
|
|
169
217
|
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
218
|
+
* @remarks
|
|
219
|
+
* The Promise always resolves — it does not reject. All failures (parse
|
|
220
|
+
* errors, wrong operation kind, non-serializable variables, network errors)
|
|
221
|
+
* are funnelled into the resolved `result.errors` array. Mutations and
|
|
222
|
+
* subscriptions passed here are rejected via `result.errors`.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* import { createDataSDK, gql } from '@salesforce/platform-sdk';
|
|
227
|
+
*
|
|
228
|
+
* const sdk = await createDataSDK();
|
|
229
|
+
*
|
|
230
|
+
* // Narrow the optional `graphql` namespace once, then call without `?.`.
|
|
231
|
+
* if (!sdk.graphql) {
|
|
232
|
+
* throw new Error('GraphQL not supported on this surface');
|
|
233
|
+
* }
|
|
234
|
+
*
|
|
235
|
+
* const result = await sdk.graphql.query<{ account: { name: string } }>({
|
|
236
|
+
* query: gql`query GetAccount($id: ID!) { account(id: $id) { name } }`,
|
|
237
|
+
* variables: { id: '001xx000003DGb0AAG' }
|
|
238
|
+
* });
|
|
239
|
+
*
|
|
240
|
+
* if (result.errors) {
|
|
241
|
+
* console.error('GraphQL errors:', result.errors);
|
|
242
|
+
* } else {
|
|
243
|
+
* console.log('Account name:', result.data?.account?.name);
|
|
244
|
+
* }
|
|
245
|
+
* ```
|
|
173
246
|
*/
|
|
174
247
|
query<T, V = Record<string, unknown>>(options: QueryOptions<V>): Promise<QueryResult<T>>;
|
|
175
248
|
/**
|
|
176
249
|
* Run a GraphQL mutation. Pass-through to the underlying transport — does
|
|
177
250
|
* not read or write the cache. Queries and subscriptions passed here are
|
|
178
251
|
* rejected via the resolved `errors` field.
|
|
252
|
+
*
|
|
253
|
+
* @remarks
|
|
254
|
+
* The Promise always resolves — it does not reject. All failures (parse
|
|
255
|
+
* errors, wrong operation kind, non-serializable variables, network errors)
|
|
256
|
+
* are funnelled into the resolved `result.errors` array.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* import { createDataSDK, gql } from '@salesforce/platform-sdk';
|
|
261
|
+
*
|
|
262
|
+
* const sdk = await createDataSDK();
|
|
263
|
+
*
|
|
264
|
+
* // Narrow the optional `graphql` namespace once, then call without `?.`.
|
|
265
|
+
* if (!sdk.graphql) {
|
|
266
|
+
* throw new Error('GraphQL not supported on this surface');
|
|
267
|
+
* }
|
|
268
|
+
*
|
|
269
|
+
* const result = await sdk.graphql.mutate<{ updateAccount: { id: string; name: string } }>({
|
|
270
|
+
* mutation: gql`mutation UpdateAccount($id: ID!, $name: String!) {
|
|
271
|
+
* updateAccount(id: $id, name: $name) { id name }
|
|
272
|
+
* }`,
|
|
273
|
+
* variables: { id: '001xx000003DGb0AAG', name: 'Acme Corp' }
|
|
274
|
+
* });
|
|
275
|
+
*
|
|
276
|
+
* if (result.errors) {
|
|
277
|
+
* console.error('Mutation errors:', result.errors);
|
|
278
|
+
* } else {
|
|
279
|
+
* console.log('Updated account:', result.data?.updateAccount);
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
179
282
|
*/
|
|
180
283
|
mutate<T, V = Record<string, unknown>>(options: MutateOptions<V>): Promise<MutationResult<T>>;
|
|
181
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* The data SDK object returned by {@link createDataSDK}.
|
|
287
|
+
*
|
|
288
|
+
* May be a bare `{}` on unsupported surfaces — feature-detect `graphql` or
|
|
289
|
+
* `fetch` before use to avoid runtime errors.
|
|
290
|
+
*/
|
|
182
291
|
export interface DataSDK {
|
|
183
292
|
/** GraphQL namespace. Present when the surface supports data operations. */
|
|
184
293
|
graphql?: DataSDKGraphQL;
|
|
@@ -188,6 +297,7 @@ export interface DataSDK {
|
|
|
188
297
|
* @param input - The URL or Request object
|
|
189
298
|
* @param init - Optional RequestInit configuration
|
|
190
299
|
* @returns Promise resolving to Response
|
|
300
|
+
* @throws {TypeError} when the network request fails.
|
|
191
301
|
*/
|
|
192
302
|
fetch?: typeof fetch;
|
|
193
303
|
}
|
package/dist/core/data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/core/data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,YAAY;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAEhD,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,QAAQ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AW,cAAc;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9F;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACvB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACrB"}
|
package/dist/data/gql.d.ts
CHANGED
|
@@ -3,5 +3,21 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* A pass-through template tag for GraphQL query/mutation strings. Exists so IDE GraphQL
|
|
8
|
+
* integrations syntax-highlight and validate the embedded query. It performs no parsing —
|
|
9
|
+
* it simply interpolates values and returns the assembled string.
|
|
10
|
+
*
|
|
11
|
+
* @param strings - The template string segments.
|
|
12
|
+
* @param values - Interpolated values, stringified and spliced between segments.
|
|
13
|
+
* @returns The assembled GraphQL document string.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { gql } from '@salesforce/platform-sdk';
|
|
18
|
+
*
|
|
19
|
+
* const query = gql`query { account { name } }`;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
6
22
|
export declare function gql(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
7
23
|
//# sourceMappingURL=gql.d.ts.map
|
package/dist/data/gql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql.d.ts","sourceRoot":"","sources":["../../src/data/gql.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"gql.d.ts","sourceRoot":"","sources":["../../src/data/gql.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAM/E"}
|
package/dist/data/index.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { DataSDK, SDKOptions } from '../core';
|
|
2
2
|
import { MosaicDataSDKOptions } from './mosaic';
|
|
3
|
+
/**
|
|
4
|
+
* A callback the host invokes for a given HTTP status (see {@link WebAppDataSDKOptions.onStatus}).
|
|
5
|
+
* May be sync or async.
|
|
6
|
+
*/
|
|
3
7
|
export type StatusCallback = () => Promise<unknown> | void;
|
|
4
8
|
/**
|
|
5
9
|
* Options for creating a WebAppDataSDK
|
|
6
10
|
*/
|
|
7
11
|
export interface WebAppDataSDKOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The API base path prefix.
|
|
14
|
+
* @example "/services/data/v64.0"
|
|
15
|
+
*/
|
|
8
16
|
basePath?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Per-HTTP-status callbacks (e.g. re-auth on 401).
|
|
19
|
+
* @example { 401: () => reauthenticate() }
|
|
20
|
+
*/
|
|
9
21
|
onStatus?: Partial<Record<number, StatusCallback>>;
|
|
10
22
|
}
|
|
11
23
|
export type { MosaicDataSDKOptions };
|
|
@@ -13,19 +25,59 @@ export type { MosaicDataSDKOptions };
|
|
|
13
25
|
* Options for creating a DataSDK instance.
|
|
14
26
|
*/
|
|
15
27
|
export interface DataSDKOptions extends SDKOptions {
|
|
28
|
+
/**
|
|
29
|
+
* WebApp-surface options.
|
|
30
|
+
* @example { basePath: "/services/data/v64.0" }
|
|
31
|
+
*/
|
|
16
32
|
webapp?: WebAppDataSDKOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Mosaic-surface options.
|
|
35
|
+
* @example { instanceUrl: "https://my.salesforce.com", accessToken: "00D..." }
|
|
36
|
+
*/
|
|
17
37
|
mosaic?: MosaicDataSDKOptions;
|
|
18
38
|
}
|
|
19
39
|
/**
|
|
20
40
|
* Create and initialize a DataSDK instance based on the detected surface.
|
|
21
|
-
* Each call creates a new instance; options are applied to every call.
|
|
22
41
|
*
|
|
23
42
|
* @param options - Optional configuration including surface override and web app options
|
|
24
43
|
* @returns Promise resolving to an initialized DataSDK instance
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Each call creates a new instance; options are applied to every call.
|
|
47
|
+
*
|
|
48
|
+
* If the surface is unusable (e.g. MCPApps handshake never succeeded, or detection throws),
|
|
49
|
+
* the function resolves to a bare `{}` rather than rejecting, so the host still renders.
|
|
50
|
+
* Feature-detect `sdk.graphql` / `sdk.fetch` before use.
|
|
51
|
+
*
|
|
52
|
+
* @throws {TypeError} when the returned Promise is used without `await`
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { createDataSDK, gql } from '@salesforce/platform-sdk';
|
|
57
|
+
*
|
|
58
|
+
* const sdk = await createDataSDK();
|
|
59
|
+
* const result = await sdk.graphql?.query({
|
|
60
|
+
* query: gql`query { account { name } }`
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* if (!result) {
|
|
64
|
+
* console.error('GraphQL not supported on this surface');
|
|
65
|
+
* } else if (result.errors) {
|
|
66
|
+
* console.error('GraphQL errors:', result.errors);
|
|
67
|
+
* } else {
|
|
68
|
+
* console.log(result.data);
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
25
71
|
*/
|
|
26
72
|
export declare function createDataSDK(options?: DataSDKOptions): Promise<DataSDK>;
|
|
27
73
|
export { gql } from './gql';
|
|
28
74
|
export type { CacheControl, DataSDK, DataSDKGraphQL, GraphQLError, GraphQLRawDocument, GraphQLRequest, GraphQLRequestHeaders, GraphQLResponse, MutateOptions, MutationResult, QueryOptions, QueryResult, QuerySubscriber, SDKOptions, Unsubscribe, } from '../core';
|
|
75
|
+
/**
|
|
76
|
+
* A utility type that unwraps the `node` element type from a Relay-style
|
|
77
|
+
* `{ edges: [{ node }] }` connection. Resolves to `never` when `T` is not such a connection.
|
|
78
|
+
*
|
|
79
|
+
* @typeParam T - The connection type to unwrap.
|
|
80
|
+
*/
|
|
29
81
|
export type NodeOfConnection<T> = T extends {
|
|
30
82
|
edges?: (infer E)[] | null;
|
|
31
83
|
} | null ? E extends {
|
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;AACnD,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIpE,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CACnD;AAED,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC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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
|
@@ -245,7 +245,7 @@ const w = "Accept-Language", me = (r) => {
|
|
|
245
245
|
return u(r);
|
|
246
246
|
const [t, n] = r;
|
|
247
247
|
return (t instanceof Request && !n?.headers ? t.headers.has(w) : new Headers(n?.headers).has(w)) ? u(r) : u(b(w, e, r));
|
|
248
|
-
}, ye = "X-SFDC-Client-Name", be = "X-SFDC-Client-Version", ve = "@salesforce/platform-sdk", Se = "11.45.
|
|
248
|
+
}, ye = "X-SFDC-Client-Name", be = "X-SFDC-Client-Version", ve = "@salesforce/platform-sdk", Se = "11.45.11", ge = (r) => {
|
|
249
249
|
let e = b(ye, ve, r);
|
|
250
250
|
return e = b(be, Se, e), u(e);
|
|
251
251
|
}, we = "X-CSRF-Token";
|
|
@@ -3,8 +3,20 @@ import { DataSDK, DataSDKGraphQL } from '../../core';
|
|
|
3
3
|
* Options for creating a MosaicDataSDK
|
|
4
4
|
*/
|
|
5
5
|
export interface MosaicDataSDKOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The Salesforce instance URL.
|
|
8
|
+
* @example "https://my.salesforce.com"
|
|
9
|
+
*/
|
|
6
10
|
instanceUrl?: string;
|
|
11
|
+
/**
|
|
12
|
+
* An OAuth access token for server-side auth.
|
|
13
|
+
* @example "00Dxx0000001gP!AQ…"
|
|
14
|
+
*/
|
|
7
15
|
accessToken?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The Salesforce API version.
|
|
18
|
+
* @example "64.0"
|
|
19
|
+
*/
|
|
8
20
|
apiVersion?: string;
|
|
9
21
|
}
|
|
10
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAc3F;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;YAa5B,iBAAiB;CAc/B"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/data/mosaic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAmC,MAAM,YAAY,CAAC;AAc3F;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;gBAErB,OAAO,CAAC,EAAE,oBAAoB;YAa5B,iBAAiB;CAc/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.45.
|
|
3
|
+
"version": "11.45.11",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -111,7 +111,8 @@
|
|
|
111
111
|
"build": "vite build",
|
|
112
112
|
"clean": "rm -rf dist",
|
|
113
113
|
"dev": "vite build --watch",
|
|
114
|
-
"test": "vitest run",
|
|
114
|
+
"test": "vitest run && npm run test:examples",
|
|
115
|
+
"test:examples": "tsx scripts/check-examples.mts",
|
|
115
116
|
"test:watch": "vitest",
|
|
116
117
|
"test:coverage": "vitest run --coverage"
|
|
117
118
|
},
|
|
@@ -125,7 +126,7 @@
|
|
|
125
126
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
126
127
|
"@conduit-client/service-retry": "3.19.6",
|
|
127
128
|
"@conduit-client/utils": "3.19.6",
|
|
128
|
-
"@salesforce/jsonrpc": "^11.45.
|
|
129
|
+
"@salesforce/jsonrpc": "^11.45.11",
|
|
129
130
|
"@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
|
|
130
131
|
},
|
|
131
132
|
"peerDependencies": {
|
|
@@ -133,6 +134,8 @@
|
|
|
133
134
|
"o11y_schema": ">=264.85.0"
|
|
134
135
|
},
|
|
135
136
|
"devDependencies": {
|
|
137
|
+
"ts-morph": "^27.0.2",
|
|
138
|
+
"tsx": "^4.21.0",
|
|
136
139
|
"vite": "^7.3.5",
|
|
137
140
|
"vite-plugin-dts": "^4.5.4",
|
|
138
141
|
"vitest": "^4.0.6"
|