@djust-b2b/djust-front-sdk 1.22.3 → 1.23.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/README.md +41 -10
- package/lib/{src/helpers → helpers}/parameters-validation.js +2 -2
- package/lib/{src/index.d.ts → index.d.ts} +18 -31
- package/lib/{src/index.js → index.js} +1 -2
- package/lib/{src/interfaces → interfaces}/models/common.d.ts +2 -2
- package/lib/{src/interfaces → interfaces}/models/customer-user.d.ts +1 -1
- package/lib/{src/interfaces → interfaces}/models/order.d.ts +90 -3
- package/lib/{src/services → services}/auth/definitions.requests.js +3 -0
- package/lib/{src/services → services}/cart/index.d.ts +2 -2
- package/lib/{src/services → services}/cart/index.js +2 -2
- package/lib/{src/services → services}/commercial-order/definitions.d.ts +33 -2
- package/lib/{src/services → services}/commercial-order/index.d.ts +167 -1
- package/lib/{src/services → services}/commercial-order/index.js +225 -4
- package/lib/{src/services → services}/customer-account/definitions.d.ts +14 -1
- package/lib/{src/services → services}/customer-account/index.d.ts +28 -2
- package/lib/{src/services → services}/customer-account/index.js +38 -0
- package/lib/{src/services → services}/customer-user/definitions.d.ts +1 -1
- package/lib/{src/services → services}/logistic-order/definitions.d.ts +94 -4
- package/lib/{src/services → services}/logistic-order/index.d.ts +423 -9
- package/lib/{src/services → services}/logistic-order/index.js +534 -8
- package/lib/{src/services → services}/navigation-category/definitions.d.ts +0 -3
- package/lib/{src/services → services}/product/definitions.d.ts +1 -2
- package/lib/{src/services → services}/product-variant/definitions.d.ts +1 -2
- package/lib/{src/settings → settings}/fetch-instance.d.ts +2 -3
- package/lib/{src/settings → settings}/fetch-instance.js +67 -33
- package/package.json +5 -6
- package/lib/instrument.d.ts +0 -1
- package/lib/instrument.js +0 -15
- /package/lib/{src/helpers → helpers}/parameters-validation.d.ts +0 -0
- /package/lib/{src/helpers → helpers}/utils.d.ts +0 -0
- /package/lib/{src/helpers → helpers}/utils.js +0 -0
- /package/lib/{src/interfaces → interfaces}/index.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/index.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/address.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/address.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/attribute.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/attribute.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/auth.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/auth.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/buying-list.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/buying-list.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/cart.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/cart.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/common.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/custom-field.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/custom-field.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/customer-account.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/customer-account.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/customer-organisation.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/customer-organisation.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/customer-user.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/incident.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/incident.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/navigation-category.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/navigation-category.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/offer.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/offer.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/order.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/payment.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/payment.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/price.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/price.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/product.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/product.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/quote.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/quote.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/searchProduct.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/searchProduct.js +0 -0
- /package/lib/{src/interfaces → interfaces}/models/supplier.d.ts +0 -0
- /package/lib/{src/interfaces → interfaces}/models/supplier.js +0 -0
- /package/lib/{src/services → services}/auth/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/auth/definitions.js +0 -0
- /package/lib/{src/services → services}/auth/definitions.requests.d.ts +0 -0
- /package/lib/{src/services → services}/auth/index.d.ts +0 -0
- /package/lib/{src/services → services}/auth/index.js +0 -0
- /package/lib/{src/services → services}/buying-list/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/buying-list/definitions.js +0 -0
- /package/lib/{src/services → services}/buying-list/index.d.ts +0 -0
- /package/lib/{src/services → services}/buying-list/index.js +0 -0
- /package/lib/{src/services → services}/cart/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/cart/definitions.js +0 -0
- /package/lib/{src/services → services}/commercial-order/definitions.js +0 -0
- /package/lib/{src/services → services}/custom-field/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/custom-field/definitions.js +0 -0
- /package/lib/{src/services → services}/custom-field/index.d.ts +0 -0
- /package/lib/{src/services → services}/custom-field/index.js +0 -0
- /package/lib/{src/services → services}/customer-account/definitions.js +0 -0
- /package/lib/{src/services → services}/customer-user/definitions.js +0 -0
- /package/lib/{src/services → services}/customer-user/index.d.ts +0 -0
- /package/lib/{src/services → services}/customer-user/index.js +0 -0
- /package/lib/{src/services → services}/incident/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/incident/definitions.js +0 -0
- /package/lib/{src/services → services}/incident/index.d.ts +0 -0
- /package/lib/{src/services → services}/incident/index.js +0 -0
- /package/lib/{src/services → services}/logistic-order/definitions.js +0 -0
- /package/lib/{src/services → services}/navigation-category/definitions.js +0 -0
- /package/lib/{src/services → services}/navigation-category/index.d.ts +0 -0
- /package/lib/{src/services → services}/navigation-category/index.js +0 -0
- /package/lib/{src/services → services}/product/definitions.js +0 -0
- /package/lib/{src/services → services}/product/index.d.ts +0 -0
- /package/lib/{src/services → services}/product/index.js +0 -0
- /package/lib/{src/services → services}/product-variant/definitions.js +0 -0
- /package/lib/{src/services → services}/product-variant/index.d.ts +0 -0
- /package/lib/{src/services → services}/product-variant/index.js +0 -0
- /package/lib/{src/services → services}/quote/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/quote/definitions.js +0 -0
- /package/lib/{src/services → services}/quote/index.d.ts +0 -0
- /package/lib/{src/services → services}/quote/index.js +0 -0
- /package/lib/{src/services → services}/supplier/definitions.d.ts +0 -0
- /package/lib/{src/services → services}/supplier/definitions.js +0 -0
- /package/lib/{src/services → services}/supplier/index.d.ts +0 -0
- /package/lib/{src/services → services}/supplier/index.js +0 -0
|
@@ -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;
|
|
@@ -11,8 +11,8 @@ type ClientConfig = {
|
|
|
11
11
|
storeViewId?: string;
|
|
12
12
|
customerAccountId?: string;
|
|
13
13
|
clientName?: string;
|
|
14
|
-
dsn?: string;
|
|
15
14
|
env?: string;
|
|
15
|
+
dsn?: string;
|
|
16
16
|
};
|
|
17
17
|
export declare const initialize: (initConfig: ClientConfig) => void;
|
|
18
18
|
export declare const updateConfiguration: (newConfig: Partial<ClientConfig>) => void;
|
|
@@ -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 {};
|
|
@@ -34,24 +34,54 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.enhancedFetch = exports.updateConfiguration = exports.initialize = void 0;
|
|
37
|
-
const Sentry = __importStar(require("@sentry/node"));
|
|
38
37
|
const qs = __importStar(require("query-string"));
|
|
38
|
+
const Sentry = __importStar(require("@sentry/browser"));
|
|
39
39
|
require("isomorphic-fetch");
|
|
40
|
+
const SDK_VERSION = require("../../package.json").version || "unknown";
|
|
40
41
|
let clientConfig = {
|
|
41
42
|
baseUrl: "",
|
|
42
43
|
clientId: "",
|
|
43
44
|
apiKey: "",
|
|
44
45
|
dsn: "https://39ef5198e24fa0ec7b743c460bd1ca63@o1191347.ingest.us.sentry.io/4508879498575872",
|
|
46
|
+
env: "development",
|
|
47
|
+
clientName: "Djust",
|
|
45
48
|
};
|
|
46
|
-
let isSDKInitialized = false;
|
|
47
49
|
const initialize = (initConfig) => {
|
|
48
50
|
clientConfig = {
|
|
49
51
|
...initConfig,
|
|
50
52
|
};
|
|
51
|
-
if (
|
|
52
|
-
Sentry.init(
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
if (clientConfig.dsn) {
|
|
54
|
+
Sentry.init({
|
|
55
|
+
dsn: clientConfig.dsn ||
|
|
56
|
+
"https://39ef5198e24fa0ec7b743c460bd1ca63@o1191347.ingest.us.sentry.io/4508879498575872",
|
|
57
|
+
environment: `${clientConfig.clientName}-${clientConfig.env}`,
|
|
58
|
+
release: `${SDK_VERSION || "unknown"}`,
|
|
59
|
+
integrations: [
|
|
60
|
+
Sentry.browserTracingIntegration(),
|
|
61
|
+
Sentry.replayIntegration(),
|
|
62
|
+
Sentry.httpClientIntegration(),
|
|
63
|
+
Sentry.breadcrumbsIntegration({
|
|
64
|
+
console: true,
|
|
65
|
+
dom: true,
|
|
66
|
+
fetch: true,
|
|
67
|
+
history: true,
|
|
68
|
+
xhr: true,
|
|
69
|
+
}),
|
|
70
|
+
Sentry.browserApiErrorsIntegration({
|
|
71
|
+
setTimeout: true,
|
|
72
|
+
setInterval: true,
|
|
73
|
+
requestAnimationFrame: true,
|
|
74
|
+
XMLHttpRequest: true,
|
|
75
|
+
eventTarget: true,
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
78
|
+
tracesSampleRate: 1.0,
|
|
79
|
+
replaysSessionSampleRate: 0.1,
|
|
80
|
+
replaysOnErrorSampleRate: 1.0,
|
|
81
|
+
profilesSampleRate: 1.0,
|
|
82
|
+
sendDefaultPii: true,
|
|
83
|
+
});
|
|
84
|
+
console.log(`[Djust SDK] Sentry initialized in ${clientConfig.clientName || "unknown"} environment: ${clientConfig.env || "unknown"}.`);
|
|
55
85
|
}
|
|
56
86
|
};
|
|
57
87
|
exports.initialize = initialize;
|
|
@@ -98,8 +128,10 @@ const isPublicRoute = (path, method) => {
|
|
|
98
128
|
const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
99
129
|
var _a, _b, _c, _d, _e, _f;
|
|
100
130
|
if (!isClientInitialized(clientConfig)) {
|
|
101
|
-
const error = new Error(
|
|
102
|
-
Sentry.captureException(error
|
|
131
|
+
const error = new Error("[Djust SDK] SDK not initialized.");
|
|
132
|
+
Sentry.captureException(error, {
|
|
133
|
+
tags: { env: clientConfig.env },
|
|
134
|
+
});
|
|
103
135
|
throw error;
|
|
104
136
|
}
|
|
105
137
|
const { clientId, apiKey, accessToken, locale, headers } = clientConfig;
|
|
@@ -108,8 +140,11 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
108
140
|
"dj-api-key": apiKey,
|
|
109
141
|
"Content-Type": "application/json",
|
|
110
142
|
});
|
|
111
|
-
if (!isPublicRoute(path, method)
|
|
112
|
-
|
|
143
|
+
if (!isPublicRoute(path, method)) {
|
|
144
|
+
if (accessToken) {
|
|
145
|
+
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
113
148
|
if (locale)
|
|
114
149
|
requestHeaders.append("locale", locale);
|
|
115
150
|
// Use provided params or fallback to clientConfig defaults
|
|
@@ -141,22 +176,31 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
141
176
|
const { status, headers } = response;
|
|
142
177
|
if (!response.ok) {
|
|
143
178
|
const errorMessage = await response.text();
|
|
144
|
-
const error = new Error(`[Djust SDK]
|
|
145
|
-
Sentry.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
179
|
+
const error = new Error(`[Djust SDK] HTTP error ${response.status}: ${errorMessage}`);
|
|
180
|
+
Sentry.captureException(error, {
|
|
181
|
+
extra: {
|
|
182
|
+
url: fullPath,
|
|
183
|
+
method,
|
|
184
|
+
response: response,
|
|
185
|
+
errorMessage: errorMessage,
|
|
186
|
+
status: response.status,
|
|
187
|
+
env: clientConfig.env,
|
|
188
|
+
headers: (() => {
|
|
189
|
+
const headersObj = {};
|
|
190
|
+
requestHeaders.forEach((value, key) => {
|
|
191
|
+
headersObj[key] = value;
|
|
192
|
+
});
|
|
193
|
+
return headersObj;
|
|
194
|
+
})(),
|
|
195
|
+
body: body ? body : null,
|
|
196
|
+
params,
|
|
197
|
+
},
|
|
155
198
|
});
|
|
156
199
|
throw error;
|
|
157
200
|
}
|
|
158
201
|
const isJsonResponse = (_d = headers
|
|
159
202
|
.get("content-type")) === null || _d === void 0 ? void 0 : _d.includes("application/json");
|
|
203
|
+
// Additional check: ensure the response has content before attempting to parse JSON
|
|
160
204
|
let responseText = await response.text();
|
|
161
205
|
function isJsonString(str) {
|
|
162
206
|
if (typeof str !== "string")
|
|
@@ -184,18 +228,8 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
184
228
|
return { data, headers, status };
|
|
185
229
|
}
|
|
186
230
|
catch (error) {
|
|
187
|
-
Sentry.
|
|
188
|
-
|
|
189
|
-
scope.setExtra("method", method);
|
|
190
|
-
scope.setExtra("params", params);
|
|
191
|
-
scope.setExtra("body", body);
|
|
192
|
-
scope.setExtra("headers", headers);
|
|
193
|
-
scope.setExtra("clientName", clientConfig.clientName);
|
|
194
|
-
scope.setExtra("env", clientConfig.env);
|
|
195
|
-
Sentry.captureException(error);
|
|
196
|
-
});
|
|
197
|
-
console.error("[Djust SDK] Erreur Fetch: ", error);
|
|
198
|
-
throw new Error(`[Djust SDK] ${error.message || "Une erreur inconnue est survenue."}`);
|
|
231
|
+
Sentry.captureException(error, { tags: { env: clientConfig.env } });
|
|
232
|
+
throw new Error(`[Djust SDK] ${error || "Unknown error occurred"}`);
|
|
199
233
|
}
|
|
200
234
|
};
|
|
201
235
|
exports.enhancedFetch = enhancedFetch;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djust-b2b/djust-front-sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK)
|
|
3
|
+
"version": "1.23.0",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"ts-jest": "^29.0.0",
|
|
41
41
|
"tslint": "^6.1.3",
|
|
42
42
|
"tslint-config-prettier": "^1.18.0",
|
|
43
|
-
"typedoc": "
|
|
44
|
-
"typedoc-plugin-markdown": "
|
|
43
|
+
"typedoc": "0.27.3",
|
|
44
|
+
"typedoc-plugin-markdown": "4.3.1",
|
|
45
45
|
"typescript": "^5.6.3",
|
|
46
46
|
"vitest": "latest"
|
|
47
47
|
},
|
|
@@ -50,8 +50,7 @@
|
|
|
50
50
|
"lib/**/**.d.ts"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@sentry/
|
|
54
|
-
"@sentry/profiling-node": "^9.2.0",
|
|
53
|
+
"@sentry/browser": "^9.2.0",
|
|
55
54
|
"isomorphic-fetch": "^3.0.0",
|
|
56
55
|
"query-string": "^7.1.1"
|
|
57
56
|
},
|
package/lib/instrument.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/instrument.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const Sentry = require("@sentry/node");
|
|
3
|
-
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
|
|
4
|
-
const SDK_VERSION = require("../package.json").version;
|
|
5
|
-
const dsn = "https://39ef5198e24fa0ec7b743c460bd1ca63@o1191347.ingest.us.sentry.io/4508879498575872"; // Replace with your actual DSN
|
|
6
|
-
const clientName = "djust"; // Replace with your actual client name
|
|
7
|
-
const env = "preprod"; // Replace with your actual environment
|
|
8
|
-
Sentry.init({
|
|
9
|
-
dsn,
|
|
10
|
-
environment: `${clientName}-${env}`,
|
|
11
|
-
release: `${clientName}-${env}-${SDK_VERSION}`, // Replace with your SDK version
|
|
12
|
-
integrations: [nodeProfilingIntegration(), Sentry.nativeNodeFetchIntegration()],
|
|
13
|
-
tracesSampleRate: 1.0, // Adjust for production
|
|
14
|
-
profilesSampleRate: 1.0,
|
|
15
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|