@salesforce/sdk-data 1.55.0 → 1.56.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/index.d.ts CHANGED
@@ -3,6 +3,8 @@ import type { DataSDK, SDKOptions } from "@salesforce/sdk-core";
3
3
  * Options for creating a DataSDK instance.
4
4
  */
5
5
  export interface DataSDKOptions extends SDKOptions {
6
+ handleUnauthorized?: () => void;
7
+ handleNoAccess?: () => void;
6
8
  webapp?: {
7
9
  basePath?: string;
8
10
  };
@@ -1 +1 @@
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;AAIhE;;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,EAAE,OAAO,EAAE,UAAU,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;AAIhE;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,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,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ export async function createDataSDK(options) {
19
19
  return new OpenAIDataSDK();
20
20
  case Surface.WebApp:
21
21
  case Surface.MicroFrontend:
22
- return new WebAppDataSDK(options?.webapp?.basePath);
22
+ return new WebAppDataSDK(options);
23
23
  case Surface.SalesforceACC:
24
24
  return {};
25
25
  case Surface.MCPApps:
@@ -1,4 +1,5 @@
1
1
  import type { DataSDK, GraphQLResponse } from "@salesforce/sdk-core";
2
+ import { type DataSDKOptions } from "../index.js";
2
3
  export declare const API_VERSION: string;
3
4
  /**
4
5
  * Data SDK implementation for web apps, which is based on making `fetch` calls to REST endpoints
@@ -6,7 +7,8 @@ export declare const API_VERSION: string;
6
7
  export declare class WebAppDataSDK implements DataSDK {
7
8
  private readonly base;
8
9
  private readonly conduitClient;
9
- constructor(basePath?: string);
10
+ private readonly options?;
11
+ constructor(options?: DataSDKOptions);
10
12
  graphql<T, V>(query: string, variables?: V): Promise<GraphQLResponse<T>>;
11
13
  fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
12
14
  /**
@@ -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;AAKnG;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;gBAElC,QAAQ,CAAC,EAAE,MAAM;IAcvB,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"}
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;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,eAAO,MAAM,WAAW,QAA0E,CAAC;AAKnG;;GAEG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAiB;gBAE9B,OAAO,CAAC,EAAE,cAAc;IAe9B,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;CAY3B"}
@@ -16,8 +16,10 @@ const PATH_UIAPI = `${PATH_DATA}/ui-api`;
16
16
  export class WebAppDataSDK {
17
17
  base;
18
18
  conduitClient;
19
- constructor(basePath) {
20
- this.base = basePath ?? BASE;
19
+ options;
20
+ constructor(options) {
21
+ this.options = options;
22
+ this.base = options?.webapp?.basePath ?? BASE;
21
23
  ConduitClient.initialize({
22
24
  csrf: {
23
25
  endpoint: `${this.base}${PATH_UIAPI}/session/csrf`,
@@ -41,13 +43,13 @@ export class WebAppDataSDK {
41
43
  async fetch(input, init) {
42
44
  const updatedInput = this.applySalesforceBase(input);
43
45
  const response = await this.conduitClient.fetch(updatedInput, init);
44
- // NOTE: In dev mode the server proxy owns authentication (adding, refreshing, etc., as needed). If it
45
- // fails to do so properly then the result will be a reload infinite loop. As for deployed mode, reload
46
- // triggers the standard Salesforce authentication checks/flow.
47
- if (response.status === 401 || response.status === 403) {
48
- if (import.meta.env.PROD) {
49
- window.location.reload();
50
- }
46
+ switch (response.status) {
47
+ case 401:
48
+ this.options?.handleUnauthorized?.();
49
+ break;
50
+ case 403:
51
+ this.options?.handleNoAccess?.();
52
+ break;
51
53
  }
52
54
  return response;
53
55
  }
@@ -63,14 +65,6 @@ export class WebAppDataSDK {
63
65
  }
64
66
  return this.base + input;
65
67
  }
66
- // Handle Request input
67
- if (input instanceof Request) {
68
- const url = input.url;
69
- if (url.startsWith("http")) {
70
- return input;
71
- }
72
- return new Request(this.base + url, input);
73
- }
74
68
  // URLs require a protocol and domain, thus are already absolute
75
69
  return input;
76
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sdk-data",
3
- "version": "1.55.0",
3
+ "version": "1.56.1",
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.55.0"
30
+ "@salesforce/sdk-core": "^1.56.1"
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": "1c1e2f3f2de3f9ef18a3efec5f477775ccf72d31"
38
+ "gitHead": "c900d757a03250a770c5312dbef2013de91e7bb3"
39
39
  }