@salesforce/sdk-data 1.40.0 → 1.42.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/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/webapp/index.d.ts +7 -0
- package/dist/webapp/index.d.ts.map +1 -1
- package/dist/webapp/index.js +25 -27
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import type { DataSDK } from "@salesforce/sdk-core";
|
|
1
|
+
import type { DataSDK, SDKOptions } from "@salesforce/sdk-core";
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a DataSDK instance.
|
|
4
|
+
*/
|
|
5
|
+
export interface DataSDKOptions extends SDKOptions {
|
|
6
|
+
webapp?: {
|
|
7
|
+
basePath?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Create and initialize a DataSDK instance based on the detected surface
|
|
4
12
|
*
|
|
13
|
+
* @param options - Optional configuration including surface override
|
|
5
14
|
* @returns Promise resolving to an initialized DataSDK instance
|
|
6
15
|
*/
|
|
7
|
-
export declare function createDataSDK(): Promise<DataSDK>;
|
|
16
|
+
export declare function createDataSDK(options?: DataSDKOptions): Promise<DataSDK>;
|
|
8
17
|
export { gql } from "./gql.js";
|
|
9
|
-
export type { DataSDK, LabelRequest, ResourceUrlRequest, SchemaDescriptor, SchemaRequest, UserInfo, } from "@salesforce/sdk-core";
|
|
18
|
+
export type { DataSDK, LabelRequest, ResourceUrlRequest, SDKOptions, SchemaDescriptor, SchemaRequest, UserInfo, } from "@salesforce/sdk-core";
|
|
10
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGhE;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,MAAM,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACF;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAe9E;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EACX,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,QAAQ,GACR,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,16 +8,17 @@ import { WebAppDataSDK } from "./webapp/index.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Create and initialize a DataSDK instance based on the detected surface
|
|
10
10
|
*
|
|
11
|
+
* @param options - Optional configuration including surface override
|
|
11
12
|
* @returns Promise resolving to an initialized DataSDK instance
|
|
12
13
|
*/
|
|
13
|
-
export async function createDataSDK() {
|
|
14
|
-
const surface = getSurface();
|
|
14
|
+
export async function createDataSDK(options) {
|
|
15
|
+
const surface = getSurface(options?.surface);
|
|
15
16
|
switch (surface) {
|
|
16
17
|
case Surface.OpenAI:
|
|
17
18
|
return {};
|
|
18
19
|
case Surface.WebApp:
|
|
19
20
|
case Surface.MicroFrontend:
|
|
20
|
-
return new WebAppDataSDK();
|
|
21
|
+
return new WebAppDataSDK(options?.webapp?.basePath);
|
|
21
22
|
case Surface.SalesforceACC:
|
|
22
23
|
return {};
|
|
23
24
|
case Surface.MCPApps:
|
package/dist/webapp/index.d.ts
CHANGED
|
@@ -4,7 +4,14 @@ export declare const API_VERSION: string;
|
|
|
4
4
|
* Data SDK implementation for web apps, which is based on making `fetch` calls to REST endpoints
|
|
5
5
|
*/
|
|
6
6
|
export declare class WebAppDataSDK implements DataSDK {
|
|
7
|
+
private readonly base;
|
|
8
|
+
constructor(basePath?: string);
|
|
7
9
|
graphql<T, V>(query: string, variables?: V): Promise<GraphQLResponse<T>>;
|
|
8
10
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
11
|
+
/**
|
|
12
|
+
* If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
|
|
13
|
+
* Builder deployments structure the url for Salesforce
|
|
14
|
+
*/
|
|
15
|
+
private applySalesforceBase;
|
|
9
16
|
}
|
|
10
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webapp/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQrE,eAAO,MAAM,WAAW,QAA0E,CAAC;AAenG;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webapp/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQrE,eAAO,MAAM,WAAW,QAA0E,CAAC;AAenG;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAElB,QAAQ,CAAC,EAAE,MAAM;IAIvB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAaxE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBjF;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAqB3B"}
|
package/dist/webapp/index.js
CHANGED
|
@@ -22,6 +22,10 @@ const conduitClient = ConduitClient.instance();
|
|
|
22
22
|
* Data SDK implementation for web apps, which is based on making `fetch` calls to REST endpoints
|
|
23
23
|
*/
|
|
24
24
|
export class WebAppDataSDK {
|
|
25
|
+
base;
|
|
26
|
+
constructor(basePath) {
|
|
27
|
+
this.base = basePath ?? BASE;
|
|
28
|
+
}
|
|
25
29
|
async graphql(query, variables) {
|
|
26
30
|
const res = await this.fetch(`${PATH_DATA}/graphql`, {
|
|
27
31
|
method: "POST",
|
|
@@ -34,7 +38,7 @@ export class WebAppDataSDK {
|
|
|
34
38
|
return res.json();
|
|
35
39
|
}
|
|
36
40
|
async fetch(input, init) {
|
|
37
|
-
const updatedInput = applySalesforceBase(input);
|
|
41
|
+
const updatedInput = this.applySalesforceBase(input);
|
|
38
42
|
const response = await conduitClient.fetch(updatedInput, init);
|
|
39
43
|
// NOTE: In dev mode the server proxy owns authentication (adding, refreshing, etc., as needed). If it
|
|
40
44
|
// fails to do so properly then the result will be a reload infinite loop. As for deployed mode, reload
|
|
@@ -46,33 +50,27 @@ export class WebAppDataSDK {
|
|
|
46
50
|
}
|
|
47
51
|
return response;
|
|
48
52
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// already absolute, return as-is
|
|
61
|
-
return input;
|
|
53
|
+
/**
|
|
54
|
+
* If the url is relative, convert to it to an absolute Salesforce URL. This is due to the way Code
|
|
55
|
+
* Builder deployments structure the url for Salesforce
|
|
56
|
+
*/
|
|
57
|
+
applySalesforceBase(input) {
|
|
58
|
+
// Handle string input
|
|
59
|
+
if (typeof input === "string") {
|
|
60
|
+
if (input.startsWith("http")) {
|
|
61
|
+
return input;
|
|
62
|
+
}
|
|
63
|
+
return this.base + input;
|
|
62
64
|
}
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// already absolute, return as-is
|
|
71
|
-
return input;
|
|
65
|
+
// Handle Request input
|
|
66
|
+
if (input instanceof Request) {
|
|
67
|
+
const url = input.url;
|
|
68
|
+
if (url.startsWith("http")) {
|
|
69
|
+
return input;
|
|
70
|
+
}
|
|
71
|
+
return new Request(this.base + url, input);
|
|
72
72
|
}
|
|
73
|
-
//
|
|
74
|
-
return
|
|
73
|
+
// URLs require a protocol and domain, thus are already absolute
|
|
74
|
+
return input;
|
|
75
75
|
}
|
|
76
|
-
// URLs require a protocol and domain, thus are already absolute
|
|
77
|
-
return input;
|
|
78
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-data",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@conduit-client/salesforce-lightning-service-worker": "^3.7.0",
|
|
30
|
-
"@salesforce/sdk-core": "^1.
|
|
30
|
+
"@salesforce/sdk-core": "^1.42.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"vitest": "^4.0.6"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "5bb3d5e71e337e5eacad83240b8e344fdfd1d6c7"
|
|
39
39
|
}
|