@djust-b2b/djust-front-sdk 2.11.0 → 2.13.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/lib/index.d.ts +2 -1
- package/lib/services/commercial-order/definitions.d.ts +24 -1
- package/lib/services/commercial-order/index.d.ts +42 -2
- package/lib/services/commercial-order/index.js +61 -1
- package/lib/services/incident/definitions.d.ts +9 -4
- package/lib/services/incident/index.d.ts +47 -41
- package/lib/services/incident/index.js +68 -60
- package/lib/settings/fetch-instance.d.ts +1 -0
- package/lib/settings/fetch-instance.js +12 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -27,13 +27,14 @@ export declare const DjustSDK: {
|
|
|
27
27
|
getPaginatedOfferInventoriesV2({ page, size, sort, variantExternalId, }: import("./services/offer-inventories/definitions").GetPaginatedOfferInventoriesV2Parameters): Promise<import("./services/offer-inventories/definitions").GetOfferInventoriesV2Response>;
|
|
28
28
|
getOfferInventoryCustomFields({ externalId, page, size, sort, locale, }: import("./services/offer-inventories/definitions").GetOfferInventoryCustomFieldsParameters): Promise<import("./services/offer-inventories/definitions").GetOfferInventoryCustomFieldsResponse>;
|
|
29
29
|
getIncidents({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
|
|
30
|
+
getIncidentsV2({ customerAccountIds, linkedType, ids, status, reasonCodes, supplierIds, customFields, idType, page, size, sort, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
|
|
30
31
|
getIncident({ incidentId, idType, }: import("./services/incident/definitions").getIncidentParameters): Promise<import("./services/incident/definitions").getIncidentResponse>;
|
|
31
32
|
createOrderLogisticIncident({ logisticOrderId, idType, customField, reasonCode, }: import("./services/incident/definitions").createOrderLogisticIncidentParameters): Promise<import("./services/incident/definitions").createOrderLogisticIncidentResponse>;
|
|
32
33
|
createOrderLogisticLineIncident({ logisticOrderId, idType, customFieldIdType, orderLines, reasonCode, }: import("./services/incident/definitions").createOrderLogisticLineIncidentParameters): Promise<import("./services/incident/definitions").createOrderLogisticLineIncidentResponse>;
|
|
33
34
|
createOrderLogisticIncidentThread({ logisticOrderId, incidentId, idType, customField, message, name, reasonCode, }: import("./services/incident/definitions").createOrderLogisticIncidentThreadParameters): Promise<import("./services/incident/definitions").createOrderLogisticIncidentThreadResponse>;
|
|
34
35
|
createIncident({ customField, externalId, logisticOrderId, reasonCodes, idType, }: import("./services/incident/definitions").createIncidentParameters): Promise<import("./services/incident/definitions").createIncidentResponse>;
|
|
35
|
-
getIncidentsV2({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, supplierIds, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
|
|
36
36
|
getCommercialOrders({ locale, nbPreviewLines, page, size, sort, connectedUserOnly, customerAccountIds, sourceTypes, isValidated, }: import("./interfaces").GetCommercialOrdersParameters): Promise<import("./interfaces").GetCommercialOrdersResponse>;
|
|
37
|
+
getCommercialOrdersV2({ page, size, sort, locale, connectedUserOnly, customerAccountIds, sourceTypes, sourceIds, isValidated, nbPreviewLines, }: import("./interfaces").GetCommercialOrdersV2Parameters): Promise<import("./interfaces").GetCommercialOrdersV2Response>;
|
|
37
38
|
createCommercialOrder({ nbPreviewLines, channel, customFields, locale, origin, originId, paymentInfo, }: import("./interfaces").CreateCommercialOrderParameters): Promise<import("./interfaces").CreateCommercialOrderResponse>;
|
|
38
39
|
createCommercialOrderV2({ customFieldIdType, customFields, isFull, sourceId, sourceType, }: import("./interfaces").CreateCommercialOrderV2Parameters): Promise<import("./interfaces").CreateCommercialOrderV2Response>;
|
|
39
40
|
getCommercialOrder({ orderId, idType, locale, nbPreviewLines, }: import("./interfaces").GetCommercialOrderParameters): Promise<import("./interfaces").GetCommercialOrderResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Channel, Currency, IdType } from "../../interfaces/models/common";
|
|
1
|
+
import { Channel, Currency, IdType, PageableObject, Order } from "../../interfaces/models/common";
|
|
2
2
|
import { CustomFieldValueRequest } from "../../interfaces/models/custom-field";
|
|
3
3
|
import { BrowserInfo, CardInformationDto, OrderCommercialDto, OrderIdType, OrderLogisticDto, OrderOrigin, PageOrderCommercialDto, PaymentCardInfo, PreauthorizationDto, OfferToDelete, OrderLogisticLineUpdate, PageOrderCommercialLinesDto } from "../../interfaces/models/order";
|
|
4
4
|
import { SingleWarningReportDto } from "../../interfaces/models/common";
|
|
@@ -17,6 +17,18 @@ export interface GetCommercialOrdersParameters {
|
|
|
17
17
|
sourceTypes?: string[];
|
|
18
18
|
isValidated?: boolean;
|
|
19
19
|
}
|
|
20
|
+
export interface GetCommercialOrdersV2Parameters {
|
|
21
|
+
page?: number;
|
|
22
|
+
size?: number;
|
|
23
|
+
sort?: string[];
|
|
24
|
+
locale: string;
|
|
25
|
+
connectedUserOnly?: boolean;
|
|
26
|
+
customerAccountIds?: string[];
|
|
27
|
+
sourceTypes?: string[];
|
|
28
|
+
sourceIds?: string[];
|
|
29
|
+
isValidated?: boolean;
|
|
30
|
+
nbPreviewLines?: number;
|
|
31
|
+
}
|
|
20
32
|
export interface GetOrderCommercialLinesParameters {
|
|
21
33
|
commercialOrderId: string;
|
|
22
34
|
page?: number;
|
|
@@ -113,6 +125,17 @@ export interface PunchoutOciCommercialOrderParameters {
|
|
|
113
125
|
*/
|
|
114
126
|
export interface GetCommercialOrdersResponse extends PageOrderCommercialDto {
|
|
115
127
|
}
|
|
128
|
+
export interface GetCommercialOrdersV2Response {
|
|
129
|
+
content: OrderCommercialDto[];
|
|
130
|
+
empty: boolean;
|
|
131
|
+
first: boolean;
|
|
132
|
+
last: boolean;
|
|
133
|
+
number: number;
|
|
134
|
+
numberOfElements: number;
|
|
135
|
+
pageable: PageableObject;
|
|
136
|
+
size: number;
|
|
137
|
+
sort: Order[];
|
|
138
|
+
}
|
|
116
139
|
export interface CreateCommercialOrderResponse extends OrderCommercialDto {
|
|
117
140
|
}
|
|
118
141
|
export interface CreateCommercialOrderV2Response {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateCommercialOrderCardRegistrationParameters, CreateCommercialOrderCardRegistrationResponse, CreateCommercialOrderParameters, CreateCommercialOrderResponse, CreateCommercialOrderV2Parameters, CreateCommercialOrderV2Response, UpdateCommercialOrderParameters, DeleteCommercialOrderLinesParameters, DeleteCommercialOrderLinesResponse, UpdateCommercialOrderLinesParameters, UpdateCommercialOrderLinesResponse, CreateCommercialOrderPreauthorizationParameters, CreateCommercialOrderPreauthorizationResponse, GetCommercialOrderParameters, GetCommercialOrderPaymentPageUrlParameters, GetCommercialOrderResponse, GetCommercialOrdersParameters, GetCommercialOrdersResponse, SetCommercialOrderStatusAsCreatedParameters, SetCommercialOrderStatusAsOnHoldParameters, UpdateCommercialOrderBillingInformationParameters, UpdateCommercialOrderShippingAddressParameters, UpdateCommercialOrderShippingInformationParameters, UpdateCommercialOrderShippingTypeParameters, GetOrderCommercialLinesParameters, GetOrderCommercialLinesResponse, PunchoutOciCommercialOrderParameters } from "./definitions";
|
|
1
|
+
import { CreateCommercialOrderCardRegistrationParameters, CreateCommercialOrderCardRegistrationResponse, CreateCommercialOrderParameters, CreateCommercialOrderResponse, CreateCommercialOrderV2Parameters, CreateCommercialOrderV2Response, UpdateCommercialOrderParameters, DeleteCommercialOrderLinesParameters, DeleteCommercialOrderLinesResponse, UpdateCommercialOrderLinesParameters, UpdateCommercialOrderLinesResponse, CreateCommercialOrderPreauthorizationParameters, CreateCommercialOrderPreauthorizationResponse, GetCommercialOrderParameters, GetCommercialOrdersV2Parameters, GetCommercialOrderPaymentPageUrlParameters, GetCommercialOrderResponse, GetCommercialOrdersParameters, GetCommercialOrdersResponse, GetCommercialOrdersV2Response, SetCommercialOrderStatusAsCreatedParameters, SetCommercialOrderStatusAsOnHoldParameters, UpdateCommercialOrderBillingInformationParameters, UpdateCommercialOrderShippingAddressParameters, UpdateCommercialOrderShippingInformationParameters, UpdateCommercialOrderShippingTypeParameters, GetOrderCommercialLinesParameters, GetOrderCommercialLinesResponse, PunchoutOciCommercialOrderParameters } from "./definitions";
|
|
2
2
|
/**
|
|
3
3
|
* COMMERCIAL ORDER ENDPOINT
|
|
4
4
|
*/
|
|
@@ -8,7 +8,7 @@ import { CreateCommercialOrderCardRegistrationParameters, CreateCommercialOrderC
|
|
|
8
8
|
* This function retrieves all commercial orders. The parameter locale is mandatory and validated
|
|
9
9
|
* before the request is executed.
|
|
10
10
|
*
|
|
11
|
-
* 🛠 **Endpoint**: `GET /v1/shop/commercial-orders [ORDER-560]`
|
|
11
|
+
* 🛠 **Endpoint**: `GET /v1/shop/commercial-orders [ORDER-560-v1]`
|
|
12
12
|
*
|
|
13
13
|
* | Parameter | Type | Required | Description |
|
|
14
14
|
* |------------------------|---------------------|----------|------------------------------------------|
|
|
@@ -41,6 +41,46 @@ import { CreateCommercialOrderCardRegistrationParameters, CreateCommercialOrderC
|
|
|
41
41
|
* @returns {Promise<GetCommercialOrdersResponse>} A promise resolving to the response containing page object.
|
|
42
42
|
*/
|
|
43
43
|
export declare function getCommercialOrders({ locale, nbPreviewLines, page, size, sort, connectedUserOnly, customerAccountIds, sourceTypes, isValidated, }: GetCommercialOrdersParameters): Promise<GetCommercialOrdersResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* 🚚 Gets commercial orders V2.
|
|
46
|
+
*
|
|
47
|
+
* This function retrieves all commercial orders (Version 2). The parameter locale is mandatory and validated
|
|
48
|
+
* before the request is executed.
|
|
49
|
+
*
|
|
50
|
+
* 🛠 **Endpoint**: `GET /v2/shop/commercial-orders [ORDER-560-v2]`
|
|
51
|
+
*
|
|
52
|
+
* | Parameter | Type | Required | Description |
|
|
53
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
54
|
+
* | `page` | `number` | ❌ | The page number to retrieve. |
|
|
55
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
56
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
57
|
+
* | `locale` | `string` | ✅ | The locale in which to return the commercial order. |
|
|
58
|
+
* | `connectedUserOnly` | `boolean` | ❌ | Filter to show only orders for the connected user. |
|
|
59
|
+
* | `customerAccountIds` | `string[]` | ❌ | Filter by customer account IDs. |
|
|
60
|
+
* | `sourceTypes` | `string[]` | ❌ | Filter by source types. |
|
|
61
|
+
* | `sourceIds` | `string[]` | ❌ | Filter by source IDs. |
|
|
62
|
+
* | `isValidated` | `boolean` | ❌ | Filter by validation status. |
|
|
63
|
+
* | `nbPreviewLines` | `number` | ❌ | The number of lines to display in the commercial order. |
|
|
64
|
+
*
|
|
65
|
+
* 📤 **Returns**:
|
|
66
|
+
* A `Promise` resolving to a single `GetCommercialOrdersV2Response` object representing the page of commercial orders.
|
|
67
|
+
*
|
|
68
|
+
* 🛠 **Example usage**:
|
|
69
|
+
* ```ts
|
|
70
|
+
* const orders = await getCommercialOrdersV2({
|
|
71
|
+
* locale: "fr",
|
|
72
|
+
* page: 0,
|
|
73
|
+
* size: 20,
|
|
74
|
+
* sort: ["createdAt,desc"],
|
|
75
|
+
* connectedUserOnly: true
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @param {GetCommercialOrdersV2Parameters} params - The parameters for the request.
|
|
80
|
+
* @throws {Error} If `locale` is missing.
|
|
81
|
+
* @returns {Promise<GetCommercialOrdersV2Response>} A promise resolving to the response containing page object.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getCommercialOrdersV2({ page, size, sort, locale, connectedUserOnly, customerAccountIds, sourceTypes, sourceIds, isValidated, nbPreviewLines, }: GetCommercialOrdersV2Parameters): Promise<GetCommercialOrdersV2Response>;
|
|
44
84
|
/**
|
|
45
85
|
* 🚚 Creates commercial orders.
|
|
46
86
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCommercialOrders = getCommercialOrders;
|
|
4
|
+
exports.getCommercialOrdersV2 = getCommercialOrdersV2;
|
|
4
5
|
exports.createCommercialOrder = createCommercialOrder;
|
|
5
6
|
exports.createCommercialOrderV2 = createCommercialOrderV2;
|
|
6
7
|
exports.getCommercialOrder = getCommercialOrder;
|
|
@@ -31,7 +32,7 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
|
31
32
|
* This function retrieves all commercial orders. The parameter locale is mandatory and validated
|
|
32
33
|
* before the request is executed.
|
|
33
34
|
*
|
|
34
|
-
* 🛠 **Endpoint**: `GET /v1/shop/commercial-orders [ORDER-560]`
|
|
35
|
+
* 🛠 **Endpoint**: `GET /v1/shop/commercial-orders [ORDER-560-v1]`
|
|
35
36
|
*
|
|
36
37
|
* | Parameter | Type | Required | Description |
|
|
37
38
|
* |------------------------|---------------------|----------|------------------------------------------|
|
|
@@ -82,6 +83,65 @@ async function getCommercialOrders({ locale, nbPreviewLines, page, size, sort, c
|
|
|
82
83
|
});
|
|
83
84
|
return data;
|
|
84
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* 🚚 Gets commercial orders V2.
|
|
88
|
+
*
|
|
89
|
+
* This function retrieves all commercial orders (Version 2). The parameter locale is mandatory and validated
|
|
90
|
+
* before the request is executed.
|
|
91
|
+
*
|
|
92
|
+
* 🛠 **Endpoint**: `GET /v2/shop/commercial-orders [ORDER-560-v2]`
|
|
93
|
+
*
|
|
94
|
+
* | Parameter | Type | Required | Description |
|
|
95
|
+
* |------------------------|---------------------|----------|------------------------------------------|
|
|
96
|
+
* | `page` | `number` | ❌ | The page number to retrieve. |
|
|
97
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
98
|
+
* | `sort` | `string[]` | ❌ | The sort to apply to the results. |
|
|
99
|
+
* | `locale` | `string` | ✅ | The locale in which to return the commercial order. |
|
|
100
|
+
* | `connectedUserOnly` | `boolean` | ❌ | Filter to show only orders for the connected user. |
|
|
101
|
+
* | `customerAccountIds` | `string[]` | ❌ | Filter by customer account IDs. |
|
|
102
|
+
* | `sourceTypes` | `string[]` | ❌ | Filter by source types. |
|
|
103
|
+
* | `sourceIds` | `string[]` | ❌ | Filter by source IDs. |
|
|
104
|
+
* | `isValidated` | `boolean` | ❌ | Filter by validation status. |
|
|
105
|
+
* | `nbPreviewLines` | `number` | ❌ | The number of lines to display in the commercial order. |
|
|
106
|
+
*
|
|
107
|
+
* 📤 **Returns**:
|
|
108
|
+
* A `Promise` resolving to a single `GetCommercialOrdersV2Response` object representing the page of commercial orders.
|
|
109
|
+
*
|
|
110
|
+
* 🛠 **Example usage**:
|
|
111
|
+
* ```ts
|
|
112
|
+
* const orders = await getCommercialOrdersV2({
|
|
113
|
+
* locale: "fr",
|
|
114
|
+
* page: 0,
|
|
115
|
+
* size: 20,
|
|
116
|
+
* sort: ["createdAt,desc"],
|
|
117
|
+
* connectedUserOnly: true
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param {GetCommercialOrdersV2Parameters} params - The parameters for the request.
|
|
122
|
+
* @throws {Error} If `locale` is missing.
|
|
123
|
+
* @returns {Promise<GetCommercialOrdersV2Response>} A promise resolving to the response containing page object.
|
|
124
|
+
*/
|
|
125
|
+
async function getCommercialOrdersV2({ page, size, sort, locale, connectedUserOnly, customerAccountIds, sourceTypes, sourceIds, isValidated, nbPreviewLines, }) {
|
|
126
|
+
(0, parameters_validation_1.required)({ locale });
|
|
127
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
128
|
+
method: "GET",
|
|
129
|
+
path: `/v2/shop/commercial-orders`,
|
|
130
|
+
params: {
|
|
131
|
+
page,
|
|
132
|
+
size,
|
|
133
|
+
sort,
|
|
134
|
+
locale,
|
|
135
|
+
connectedUserOnly,
|
|
136
|
+
customerAccountIds,
|
|
137
|
+
sourceTypes,
|
|
138
|
+
sourceIds,
|
|
139
|
+
isValidated,
|
|
140
|
+
nbPreviewLines,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
85
145
|
/**
|
|
86
146
|
* 🚚 Creates commercial orders.
|
|
87
147
|
*
|
|
@@ -4,15 +4,20 @@ import { CustomFieldValueRequest } from "../../interfaces/models/custom-field";
|
|
|
4
4
|
* Request parameters type definitions
|
|
5
5
|
*/
|
|
6
6
|
export interface getIncidentsParameters {
|
|
7
|
-
customerAccountIds: String[];
|
|
8
7
|
linkedType: IncidentLogisticOrder;
|
|
9
|
-
ids
|
|
10
|
-
status
|
|
8
|
+
ids?: String[];
|
|
9
|
+
status?: IncidentStatus[];
|
|
10
|
+
customerAccountIds?: String[];
|
|
11
|
+
supplierIds?: String[];
|
|
12
|
+
reasonCodes?: String[];
|
|
13
|
+
customFields?: {
|
|
14
|
+
customFieldId: string;
|
|
15
|
+
customFieldValue: string;
|
|
16
|
+
}[];
|
|
11
17
|
idType: IncidentIdType;
|
|
12
18
|
page: number;
|
|
13
19
|
size: number;
|
|
14
20
|
sort: String[];
|
|
15
|
-
supplierIds?: String[];
|
|
16
21
|
}
|
|
17
22
|
export interface getIncidentParameters {
|
|
18
23
|
incidentId: string;
|
|
@@ -37,6 +37,52 @@ import { getIncidentsParameters, getIncidentParameters, createOrderLogisticIncid
|
|
|
37
37
|
* @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
|
|
38
38
|
*/
|
|
39
39
|
export declare function getIncidents({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, }: getIncidentsParameters): Promise<getIncidentsResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* 🚚 Retrieves a list of filtered/sorted incidents based on various filter criteria.
|
|
42
|
+
*
|
|
43
|
+
* This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, status, and sorting preferences.
|
|
44
|
+
*
|
|
45
|
+
* 🛠 **Endpoint**: `GET /v1/shop/incidents`
|
|
46
|
+
*
|
|
47
|
+
* | Parameter | Type | Required | Description |
|
|
48
|
+
* |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
|
|
49
|
+
* | `customerAccountIds` | `string[]` | ❌ | List of customer account IDs to filter incidents by. |
|
|
50
|
+
* | `linkedType` | `string` | ✅ | Type of entity linked to the incident (e.g., ORDER or ORDER_LINES). |
|
|
51
|
+
* | `ids` | `string[]` | ❌ | Specific incident IDs to retrieve. |
|
|
52
|
+
* | `status` | `IncidentStatus[]`| ❌ | List of statuses to filter incidents by (e.g., OPEN, ON_GOING, CLOSED). |
|
|
53
|
+
* | `reasonCodes` | `string[]` | ❌ | List of reasons to filter incidents by (e.g., BROKEN, MISSING,ERROR_ORDER). |
|
|
54
|
+
* | `suppliersIds` | `string[]` | ❌ | List of suppliers to filter incidents by. |
|
|
55
|
+
* | `customerAccountIds` | `string[]` | ❌ | List of accounts to filter incidents by. |
|
|
56
|
+
* | `customFields` | `{ customFieldId: string, customFieldValue: string }[]`| ❌ | List of custom field values to filter incidents by. |
|
|
57
|
+
* | `idType` | `IncidentIdType` | ❌ | Type of ID used for filtering (e.g., DJUST_ID, EXTERNAL_ID). |
|
|
58
|
+
* | `page` | `number` | ❌ | Page number for paginated results (starting at 0). |
|
|
59
|
+
* | `size` | `number` | ❌ | Number of incidents per page. |
|
|
60
|
+
* | `sort` | `string[]` | ❌ | Sorting criteria in the format `field,(asc|desc)` (e.g., `status,desc`). |
|
|
61
|
+
*
|
|
62
|
+
* 📤 **Returns**:
|
|
63
|
+
* A `Promise<getIncidentsResponse>` containing a paginated list of incidents matching the filter criteria.
|
|
64
|
+
*
|
|
65
|
+
* 🛠 **Example usage**:
|
|
66
|
+
* ```ts
|
|
67
|
+
* const incidents = await getIncidents({
|
|
68
|
+
* linkedType: "ORDER",
|
|
69
|
+
* status: ["OPEN", "ON_GOING"],
|
|
70
|
+
* reasonCodes: ["BROKEN", "MISSING"],
|
|
71
|
+
* suppliersIds: ["sup123", "sup456"],
|
|
72
|
+
* customerAccountIds: ["acc123", "acc456"],
|
|
73
|
+
* customFields: [{ customFieldId: "field1", customFieldValue: "value1" }],
|
|
74
|
+
* idType: "EXTERNAL_ID",
|
|
75
|
+
* page: 0,
|
|
76
|
+
* size: 10,
|
|
77
|
+
* sort: ["createdAt,desc"],
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param {getIncidentsParameters} params - The parameters for filtering and retrieving incidents.
|
|
82
|
+
* @throws {Error} If the required `linkedType` is missing.
|
|
83
|
+
* @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getIncidentsV2({ customerAccountIds, linkedType, ids, status, reasonCodes, supplierIds, customFields, idType, page, size, sort, }: getIncidentsParameters): Promise<getIncidentsResponse>;
|
|
40
86
|
/**
|
|
41
87
|
* 🚚 Retrieves details of a specific incident.
|
|
42
88
|
*
|
|
@@ -188,7 +234,7 @@ export declare function createOrderLogisticIncidentThread({ logisticOrderId, inc
|
|
|
188
234
|
* This function allows the creation of a new incident with various parameters such as custom fields,
|
|
189
235
|
* external ID, logistic order ID, and reason codes.
|
|
190
236
|
*
|
|
191
|
-
* 🛠 **Endpoint**: `POST /v1/shop/incidents [ORDER-
|
|
237
|
+
* 🛠 **Endpoint**: `POST /v1/shop/incidents [ORDER-101]`
|
|
192
238
|
*
|
|
193
239
|
* | Parameter | Type | Required | Description |
|
|
194
240
|
* |------------------|-------------------------------------|------------|----------------------------------------------------------|
|
|
@@ -221,43 +267,3 @@ export declare function createOrderLogisticIncidentThread({ logisticOrderId, inc
|
|
|
221
267
|
* @returns {Promise<createIncidentResponse>} A promise that resolves to the created incident details.
|
|
222
268
|
*/
|
|
223
269
|
export declare function createIncident({ customField, externalId, logisticOrderId, reasonCodes, idType, }: createIncidentParameters): Promise<createIncidentResponse>;
|
|
224
|
-
/**
|
|
225
|
-
* 🚚 Retrieves a list of incidents based on various filter criteria.
|
|
226
|
-
*
|
|
227
|
-
* This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, supplier IDs, status, and sorting preferences.
|
|
228
|
-
*
|
|
229
|
-
* 🛠 **Endpoint**: `GET /v2/shop/incidents` [ORDER-559]
|
|
230
|
-
*
|
|
231
|
-
* | Parameter | Type | Required | Description |
|
|
232
|
-
* |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
|
|
233
|
-
* | `customerAccountIds` | `string[]` | ❌ | List of customer account IDs to filter incidents by. |
|
|
234
|
-
* | `linkedType` | `string` | ✅ | Type of entity linked to the incident (e.g., ORDER or ORDER_LINES). |
|
|
235
|
-
* | `ids` | `string[]` | ❌ | Specific incident IDs to retrieve. |
|
|
236
|
-
* | `status` | `IncidentStatus[]`| ❌ | List of statuses to filter incidents by (e.g., OPEN, ON_GOING, CLOSED). |
|
|
237
|
-
* | `idType` | `IncidentIdType` | ❌ | Type of ID used for filtering (e.g., DJUST_ID, EXTERNAL_ID). |
|
|
238
|
-
* | `page` | `number` | ❌ | Page number for paginated results (starting at 0). |
|
|
239
|
-
* | `size` | `number` | ❌ | Number of incidents per page. |
|
|
240
|
-
* | `sort` | `string[]` | ❌ | Sorting criteria in the format `field,(asc|desc)` (e.g., `status,desc`). |
|
|
241
|
-
* | `supplierIds` | `string[]` | ❌ | List of supplier IDs to filter incidents by. |
|
|
242
|
-
*
|
|
243
|
-
* 📤 **Returns**:
|
|
244
|
-
* A `Promise<getIncidentsResponse>` containing a paginated list of incidents matching the filter criteria.
|
|
245
|
-
*
|
|
246
|
-
* 🛠 **Example usage**:
|
|
247
|
-
* ```ts
|
|
248
|
-
* const incidents = await getIncidentsV2({
|
|
249
|
-
* customerAccountIds: ["acc123", "acc456"],
|
|
250
|
-
* linkedType: "ORDER",
|
|
251
|
-
* status: ["OPEN", "ON_GOING"],
|
|
252
|
-
* supplierIds: ["supplier1", "supplier2"],
|
|
253
|
-
* page: 0,
|
|
254
|
-
* size: 10,
|
|
255
|
-
* sort: ["createdAt,desc"],
|
|
256
|
-
* });
|
|
257
|
-
* ```
|
|
258
|
-
*
|
|
259
|
-
* @param {getIncidentsParameters} params - The parameters for filtering and retrieving incidents.
|
|
260
|
-
* @throws {Error} If the required `linkedType` is missing.
|
|
261
|
-
* @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
|
|
262
|
-
*/
|
|
263
|
-
export declare function getIncidentsV2({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, supplierIds, }: getIncidentsParameters): Promise<getIncidentsResponse>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getIncidents = getIncidents;
|
|
4
|
+
exports.getIncidentsV2 = getIncidentsV2;
|
|
4
5
|
exports.getIncident = getIncident;
|
|
5
6
|
exports.createOrderLogisticIncident = createOrderLogisticIncident;
|
|
6
7
|
exports.createOrderLogisticLineIncident = createOrderLogisticLineIncident;
|
|
7
8
|
exports.createOrderLogisticIncidentThread = createOrderLogisticIncidentThread;
|
|
8
9
|
exports.createIncident = createIncident;
|
|
9
|
-
exports.getIncidentsV2 = getIncidentsV2;
|
|
10
10
|
const parameters_validation_1 = require("../../helpers/parameters-validation");
|
|
11
11
|
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
12
12
|
/**
|
|
@@ -64,6 +64,72 @@ async function getIncidents({ customerAccountIds, linkedType, ids, status, idTyp
|
|
|
64
64
|
});
|
|
65
65
|
return data;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* 🚚 Retrieves a list of filtered/sorted incidents based on various filter criteria.
|
|
69
|
+
*
|
|
70
|
+
* This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, status, and sorting preferences.
|
|
71
|
+
*
|
|
72
|
+
* 🛠 **Endpoint**: `GET /v1/shop/incidents`
|
|
73
|
+
*
|
|
74
|
+
* | Parameter | Type | Required | Description |
|
|
75
|
+
* |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
|
|
76
|
+
* | `customerAccountIds` | `string[]` | ❌ | List of customer account IDs to filter incidents by. |
|
|
77
|
+
* | `linkedType` | `string` | ✅ | Type of entity linked to the incident (e.g., ORDER or ORDER_LINES). |
|
|
78
|
+
* | `ids` | `string[]` | ❌ | Specific incident IDs to retrieve. |
|
|
79
|
+
* | `status` | `IncidentStatus[]`| ❌ | List of statuses to filter incidents by (e.g., OPEN, ON_GOING, CLOSED). |
|
|
80
|
+
* | `reasonCodes` | `string[]` | ❌ | List of reasons to filter incidents by (e.g., BROKEN, MISSING,ERROR_ORDER). |
|
|
81
|
+
* | `suppliersIds` | `string[]` | ❌ | List of suppliers to filter incidents by. |
|
|
82
|
+
* | `customerAccountIds` | `string[]` | ❌ | List of accounts to filter incidents by. |
|
|
83
|
+
* | `customFields` | `{ customFieldId: string, customFieldValue: string }[]`| ❌ | List of custom field values to filter incidents by. |
|
|
84
|
+
* | `idType` | `IncidentIdType` | ❌ | Type of ID used for filtering (e.g., DJUST_ID, EXTERNAL_ID). |
|
|
85
|
+
* | `page` | `number` | ❌ | Page number for paginated results (starting at 0). |
|
|
86
|
+
* | `size` | `number` | ❌ | Number of incidents per page. |
|
|
87
|
+
* | `sort` | `string[]` | ❌ | Sorting criteria in the format `field,(asc|desc)` (e.g., `status,desc`). |
|
|
88
|
+
*
|
|
89
|
+
* 📤 **Returns**:
|
|
90
|
+
* A `Promise<getIncidentsResponse>` containing a paginated list of incidents matching the filter criteria.
|
|
91
|
+
*
|
|
92
|
+
* 🛠 **Example usage**:
|
|
93
|
+
* ```ts
|
|
94
|
+
* const incidents = await getIncidents({
|
|
95
|
+
* linkedType: "ORDER",
|
|
96
|
+
* status: ["OPEN", "ON_GOING"],
|
|
97
|
+
* reasonCodes: ["BROKEN", "MISSING"],
|
|
98
|
+
* suppliersIds: ["sup123", "sup456"],
|
|
99
|
+
* customerAccountIds: ["acc123", "acc456"],
|
|
100
|
+
* customFields: [{ customFieldId: "field1", customFieldValue: "value1" }],
|
|
101
|
+
* idType: "EXTERNAL_ID",
|
|
102
|
+
* page: 0,
|
|
103
|
+
* size: 10,
|
|
104
|
+
* sort: ["createdAt,desc"],
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param {getIncidentsParameters} params - The parameters for filtering and retrieving incidents.
|
|
109
|
+
* @throws {Error} If the required `linkedType` is missing.
|
|
110
|
+
* @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
|
|
111
|
+
*/
|
|
112
|
+
async function getIncidentsV2({ customerAccountIds, linkedType, ids, status, reasonCodes, supplierIds, customFields, idType, page, size, sort, }) {
|
|
113
|
+
var _a;
|
|
114
|
+
(0, parameters_validation_1.required)({ linkedType });
|
|
115
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
116
|
+
method: "GET",
|
|
117
|
+
path: `/v2/shop/incidents?customFields=${(_a = customFields === null || customFields === void 0 ? void 0 : customFields.map((cf) => `${cf.customFieldId}${encodeURIComponent("|")}${cf.customFieldValue}`).join("&customFields=")) !== null && _a !== void 0 ? _a : ""}`,
|
|
118
|
+
params: {
|
|
119
|
+
linkedType,
|
|
120
|
+
ids,
|
|
121
|
+
status,
|
|
122
|
+
idType,
|
|
123
|
+
reasonCodes,
|
|
124
|
+
supplierIds,
|
|
125
|
+
customerAccountIds,
|
|
126
|
+
page,
|
|
127
|
+
size,
|
|
128
|
+
sort,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
67
133
|
/**
|
|
68
134
|
* 🚚 Retrieves details of a specific incident.
|
|
69
135
|
*
|
|
@@ -270,7 +336,7 @@ async function createOrderLogisticIncidentThread({ logisticOrderId, incidentId,
|
|
|
270
336
|
* This function allows the creation of a new incident with various parameters such as custom fields,
|
|
271
337
|
* external ID, logistic order ID, and reason codes.
|
|
272
338
|
*
|
|
273
|
-
* 🛠 **Endpoint**: `POST /v1/shop/incidents [ORDER-
|
|
339
|
+
* 🛠 **Endpoint**: `POST /v1/shop/incidents [ORDER-101]`
|
|
274
340
|
*
|
|
275
341
|
* | Parameter | Type | Required | Description |
|
|
276
342
|
* |------------------|-------------------------------------|------------|----------------------------------------------------------|
|
|
@@ -319,61 +385,3 @@ async function createIncident({ customField, externalId, logisticOrderId, reason
|
|
|
319
385
|
});
|
|
320
386
|
return data;
|
|
321
387
|
}
|
|
322
|
-
/**
|
|
323
|
-
* 🚚 Retrieves a list of incidents based on various filter criteria.
|
|
324
|
-
*
|
|
325
|
-
* This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, supplier IDs, status, and sorting preferences.
|
|
326
|
-
*
|
|
327
|
-
* 🛠 **Endpoint**: `GET /v2/shop/incidents` [ORDER-559]
|
|
328
|
-
*
|
|
329
|
-
* | Parameter | Type | Required | Description |
|
|
330
|
-
* |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
|
|
331
|
-
* | `customerAccountIds` | `string[]` | ❌ | List of customer account IDs to filter incidents by. |
|
|
332
|
-
* | `linkedType` | `string` | ✅ | Type of entity linked to the incident (e.g., ORDER or ORDER_LINES). |
|
|
333
|
-
* | `ids` | `string[]` | ❌ | Specific incident IDs to retrieve. |
|
|
334
|
-
* | `status` | `IncidentStatus[]`| ❌ | List of statuses to filter incidents by (e.g., OPEN, ON_GOING, CLOSED). |
|
|
335
|
-
* | `idType` | `IncidentIdType` | ❌ | Type of ID used for filtering (e.g., DJUST_ID, EXTERNAL_ID). |
|
|
336
|
-
* | `page` | `number` | ❌ | Page number for paginated results (starting at 0). |
|
|
337
|
-
* | `size` | `number` | ❌ | Number of incidents per page. |
|
|
338
|
-
* | `sort` | `string[]` | ❌ | Sorting criteria in the format `field,(asc|desc)` (e.g., `status,desc`). |
|
|
339
|
-
* | `supplierIds` | `string[]` | ❌ | List of supplier IDs to filter incidents by. |
|
|
340
|
-
*
|
|
341
|
-
* 📤 **Returns**:
|
|
342
|
-
* A `Promise<getIncidentsResponse>` containing a paginated list of incidents matching the filter criteria.
|
|
343
|
-
*
|
|
344
|
-
* 🛠 **Example usage**:
|
|
345
|
-
* ```ts
|
|
346
|
-
* const incidents = await getIncidentsV2({
|
|
347
|
-
* customerAccountIds: ["acc123", "acc456"],
|
|
348
|
-
* linkedType: "ORDER",
|
|
349
|
-
* status: ["OPEN", "ON_GOING"],
|
|
350
|
-
* supplierIds: ["supplier1", "supplier2"],
|
|
351
|
-
* page: 0,
|
|
352
|
-
* size: 10,
|
|
353
|
-
* sort: ["createdAt,desc"],
|
|
354
|
-
* });
|
|
355
|
-
* ```
|
|
356
|
-
*
|
|
357
|
-
* @param {getIncidentsParameters} params - The parameters for filtering and retrieving incidents.
|
|
358
|
-
* @throws {Error} If the required `linkedType` is missing.
|
|
359
|
-
* @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
|
|
360
|
-
*/
|
|
361
|
-
async function getIncidentsV2({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, supplierIds, }) {
|
|
362
|
-
(0, parameters_validation_1.required)({ linkedType });
|
|
363
|
-
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
364
|
-
method: "GET",
|
|
365
|
-
path: `/v2/shop/incidents`,
|
|
366
|
-
params: {
|
|
367
|
-
customerAccountIds,
|
|
368
|
-
linkedType,
|
|
369
|
-
ids,
|
|
370
|
-
status,
|
|
371
|
-
idType,
|
|
372
|
-
page,
|
|
373
|
-
size,
|
|
374
|
-
sort,
|
|
375
|
-
supplierIds,
|
|
376
|
-
},
|
|
377
|
-
});
|
|
378
|
-
return data;
|
|
379
|
-
}
|
|
@@ -13,6 +13,7 @@ export type ClientConfig = {
|
|
|
13
13
|
clientName?: string;
|
|
14
14
|
env?: string;
|
|
15
15
|
dsn?: string;
|
|
16
|
+
logLevels?: ("log" | "info" | "warn" | "error")[];
|
|
16
17
|
};
|
|
17
18
|
export declare const initialize: (initConfig: ClientConfig) => void;
|
|
18
19
|
export declare const updateConfiguration: (newConfig: Partial<ClientConfig>) => void;
|
|
@@ -45,8 +45,10 @@ let clientConfig = {
|
|
|
45
45
|
dsn: "https://39ef5198e24fa0ec7b743c460bd1ca63@o1191347.ingest.us.sentry.io/4508879498575872",
|
|
46
46
|
env: "development",
|
|
47
47
|
clientName: "Djust",
|
|
48
|
+
logLevels: ["log", "info", "warn", "error"],
|
|
48
49
|
};
|
|
49
50
|
const initialize = (initConfig) => {
|
|
51
|
+
var _a;
|
|
50
52
|
clientConfig = {
|
|
51
53
|
...initConfig,
|
|
52
54
|
};
|
|
@@ -81,7 +83,9 @@ const initialize = (initConfig) => {
|
|
|
81
83
|
profilesSampleRate: 1.0,
|
|
82
84
|
sendDefaultPii: true,
|
|
83
85
|
});
|
|
84
|
-
|
|
86
|
+
if ((_a = clientConfig.logLevels) === null || _a === void 0 ? void 0 : _a.includes("info")) {
|
|
87
|
+
console.info(`[Djust SDK] Sentry initialized in ${clientConfig.clientName || "unknown"} environment: ${clientConfig.env || "unknown"}.`);
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
};
|
|
87
91
|
exports.initialize = initialize;
|
|
@@ -163,7 +167,7 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
163
167
|
const { status, headers } = response;
|
|
164
168
|
if (!response.ok) {
|
|
165
169
|
const errorMessage = await response.text();
|
|
166
|
-
const error = new Error(`[
|
|
170
|
+
const error = new Error(`[API] Error ${response.status}: ${errorMessage}`);
|
|
167
171
|
Sentry.captureException(error, {
|
|
168
172
|
extra: {
|
|
169
173
|
url: fullPath,
|
|
@@ -207,7 +211,12 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
207
211
|
}
|
|
208
212
|
catch (error) {
|
|
209
213
|
Sentry.captureException(error, { tags: { env: clientConfig.env } });
|
|
210
|
-
|
|
214
|
+
if (error instanceof Error) {
|
|
215
|
+
throw Error(error.message);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
throw new Error(`[Djust SDK] Unknown error occurred`);
|
|
219
|
+
}
|
|
211
220
|
}
|
|
212
221
|
};
|
|
213
222
|
exports.enhancedFetch = enhancedFetch;
|