@djust-b2b/djust-front-sdk 1.22.2 → 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 -30
- package/package.json +5 -6
- package/lib/instrument.d.ts +0 -2
- package/lib/instrument.js +0 -33
- /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 instrument_1 = require("../../instrument");
|
|
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
|
-
|
|
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
|
-
(
|
|
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,20 +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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
+
},
|
|
153
198
|
});
|
|
154
199
|
throw error;
|
|
155
200
|
}
|
|
156
201
|
const isJsonResponse = (_d = headers
|
|
157
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
|
|
158
204
|
let responseText = await response.text();
|
|
159
205
|
function isJsonString(str) {
|
|
160
206
|
if (typeof str !== "string")
|
|
@@ -182,17 +228,8 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
182
228
|
return { data, headers, status };
|
|
183
229
|
}
|
|
184
230
|
catch (error) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
method,
|
|
188
|
-
params: JSON.stringify(params, null, 2),
|
|
189
|
-
body: JSON.stringify(body, null, 2),
|
|
190
|
-
headers: headers ? headers : undefined,
|
|
191
|
-
clientName: clientConfig.clientName,
|
|
192
|
-
env: clientConfig.env,
|
|
193
|
-
});
|
|
194
|
-
console.error("[Djust SDK] Erreur Fetch: ", error);
|
|
195
|
-
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"}`);
|
|
196
233
|
}
|
|
197
234
|
};
|
|
198
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
package/lib/instrument.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const Sentry = require("@sentry/node");
|
|
3
|
-
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
|
|
4
|
-
let isSentryInitialized = false;
|
|
5
|
-
const SDK_VERSION = require("../package.json").version;
|
|
6
|
-
function initSentry(clientConfig) {
|
|
7
|
-
const { clientName, env, dsn } = clientConfig;
|
|
8
|
-
if (!clientName || !env || !dsn) {
|
|
9
|
-
console.warn("[Sentry] Missing clientName, env, or DSN. Sentry is not initialized.");
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (!isSentryInitialized) {
|
|
13
|
-
Sentry.init({
|
|
14
|
-
dsn,
|
|
15
|
-
environment: `${clientName}-${env}`,
|
|
16
|
-
release: `${clientName}-${env}-${SDK_VERSION}`, // Replace with your SDK version
|
|
17
|
-
integrations: [nodeProfilingIntegration(), Sentry.nativeNodeFetchIntegration()],
|
|
18
|
-
tracesSampleRate: 1.0, // Adjust for production
|
|
19
|
-
profilesSampleRate: 1.0,
|
|
20
|
-
});
|
|
21
|
-
isSentryInitialized = true;
|
|
22
|
-
console.log(`[Sentry] Initialized for ${clientName}-${env}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function captureError(error, context = {}) {
|
|
26
|
-
Sentry.withScope((scope) => {
|
|
27
|
-
Object.entries(context).forEach(([key, value]) => {
|
|
28
|
-
scope.setExtra(key, value);
|
|
29
|
-
});
|
|
30
|
-
Sentry.captureException(error);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
module.exports = { initSentry, captureError };
|
|
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
|