@djust-b2b/djust-front-sdk 1.21.9 → 1.21.10

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/lib/index.d.ts CHANGED
@@ -1,34 +1,6 @@
1
1
  export declare const DjustSDK: {
2
- initialize: (initConfig: {
3
- baseUrl: string;
4
- clientId: string;
5
- apiKey: string;
6
- timeout?: number;
7
- locale?: string;
8
- headers?: Headers;
9
- accessToken?: string;
10
- storeId?: string;
11
- storeViewId?: string;
12
- customerAccountId?: string;
13
- clientName?: string;
14
- env?: string;
15
- dsn?: string;
16
- }) => void;
17
- updateConfiguration: (newConfig: Partial<{
18
- baseUrl: string;
19
- clientId: string;
20
- apiKey: string;
21
- timeout?: number;
22
- locale?: string;
23
- headers?: Headers;
24
- accessToken?: string;
25
- storeId?: string;
26
- storeViewId?: string;
27
- customerAccountId?: string;
28
- clientName?: string;
29
- env?: string;
30
- dsn?: string;
31
- }>) => void;
2
+ initialize: (initConfig: import("./settings/fetch-instance").ClientConfig) => void;
3
+ updateConfiguration: (newConfig: Partial<import("./settings/fetch-instance").ClientConfig>) => void;
32
4
  getIncidents({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
33
5
  getIncident({ incidentId, idType, }: import("./services/incident/definitions").getIncidentParameters): Promise<import("./services/incident/definitions").getIncidentResponse>;
34
6
  createOrderLogisticIncident({ logisticOrderId, idType, customField, reasonCode, }: import("./services/incident/definitions").createOrderLogisticIncidentParameters): Promise<import("./services/incident/definitions").createOrderLogisticIncidentResponse>;
@@ -1,5 +1,5 @@
1
1
  import { DjustConfig } from "../interfaces/models/common";
2
- type ClientConfig = {
2
+ export type ClientConfig = {
3
3
  baseUrl: string;
4
4
  clientId: string;
5
5
  apiKey: string;
@@ -25,4 +25,3 @@ export declare const enhancedFetch: <T = any>({ path, method, params, body, }: R
25
25
  headers: Headers;
26
26
  status: number;
27
27
  }>;
28
- export {};
@@ -133,8 +133,16 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
133
133
  "dj-api-key": apiKey,
134
134
  "Content-Type": "application/json",
135
135
  });
136
- if (!isPublicRoute(path, method) && accessToken)
137
- requestHeaders.append("Authorization", `Bearer ${accessToken}`);
136
+ if (!isPublicRoute(path, method)) {
137
+ if (accessToken) {
138
+ requestHeaders.append("Authorization", `Bearer ${accessToken}`);
139
+ }
140
+ else {
141
+ Sentry.captureException(new Error("[Djust SDK] Access token is missing for a private route."), {
142
+ tags: { env: clientConfig.env, clientName: clientConfig.clientName },
143
+ });
144
+ }
145
+ }
138
146
  if (locale)
139
147
  requestHeaders.append("locale", locale);
140
148
  // Use provided params or fallback to clientConfig defaults
@@ -172,6 +180,7 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
172
180
  url: fullPath,
173
181
  method,
174
182
  response: response,
183
+ errorMessage: errorMessage,
175
184
  status: response.status,
176
185
  env: clientConfig.env,
177
186
  headers: (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.21.9",
3
+ "version": "1.21.10",
4
4
  "description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK) ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",