@djust-b2b/djust-front-sdk 1.6.3 → 1.7.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 CHANGED
@@ -82,6 +82,7 @@ export declare const DjustSDK: {
82
82
  getProductVariantAttributes({ productIdentifier, productIdType, locale, }: import("./interfaces").GetProductVariantAttributesParameters): Promise<import("./interfaces").GetProductVariantAttributesResponse>;
83
83
  createProductReview({ message, productSku, rating, }: import("./interfaces").CreateProductReviewParameters): Promise<import("./interfaces").CreateProductReviewResponse>;
84
84
  updateProductReview({ productReviewId, message, rating, }: import("./interfaces").UpdateProductReviewParameters): Promise<import("./interfaces").UpdateProductReviewResponse>;
85
+ getProductPaginatedOffers({ productIdentifier, productIdType, currency, locale, withoutPrices, pageable, }: import("./interfaces").GetProductPaginatedOffersParameters): Promise<import("./interfaces").GetProductPaginatedOffersResponse>;
85
86
  getNavigationCategories({ locale, }: import("./interfaces").GetNavigationCategoriesParameters): Promise<import("./interfaces").GetNavigationCategoriesResponse>;
86
87
  getNavigationCategory({ locale, idType, navigationCategoryId, }: import("./interfaces").GetNavigationCategoryParameters): Promise<import("./interfaces").GetNavigationCategoryResponse>;
87
88
  getNavigationCategoryBreadcrumbs({ locale, idType, navigationCategoryId, }: import("./interfaces").GetNavigationCategoryBreadcrumbsParameters): Promise<import("./interfaces").GetNavigationCategoryBreadcrumbsResponse>;
@@ -130,7 +131,7 @@ export declare const DjustSDK: {
130
131
  isTokenValid({ token, }: import("./interfaces").IsTokenValidParameters): Promise<boolean>;
131
132
  refreshToken({ refreshToken, }: import("./interfaces").RefreshTokenParameters): Promise<import("./interfaces").RefreshTokenResponse>;
132
133
  resetPassword({ newPassword, resetPasswordToken, }: import("./interfaces").ResetPasswordParameters): Promise<void>;
133
- sendResetPasswordEmail({ email, redirectUrl, }: import("./interfaces").SendResetPasswordEmailParameters): Promise<void>;
134
+ sendResetPasswordEmail({ email, }: import("./interfaces").SendResetPasswordEmailParameters): Promise<void>;
134
135
  login({ username, password, }: import("./interfaces").LoginParameters): Promise<import("./interfaces").LoginResponse>;
135
136
  logout(): Promise<void>;
136
137
  };
@@ -6,6 +6,7 @@ export interface AttributeValue {
6
6
  }
7
7
  export interface Attribute {
8
8
  id: string;
9
+ externalId: string;
9
10
  name: string;
10
11
  status: string;
11
12
  type: AttributeType;
@@ -22,7 +22,7 @@ export declare function resetPassword({ newPassword, resetPasswordToken, }: Rese
22
22
  * @param {SendResetPasswordEmailParameters} params - The parameters for the function
23
23
  * @returns {Promise<void>} - A promise that resolves when the email is sent
24
24
  */
25
- export declare function sendResetPasswordEmail({ email, redirectUrl, }: SendResetPasswordEmailParameters): Promise<void>;
25
+ export declare function sendResetPasswordEmail({ email, }: SendResetPasswordEmailParameters): Promise<void>;
26
26
  /**
27
27
  * Login a user
28
28
  * @param {LoginParameters} params - The parameters for the function
@@ -61,14 +61,13 @@ async function resetPassword({ newPassword, resetPasswordToken, }) {
61
61
  * @param {SendResetPasswordEmailParameters} params - The parameters for the function
62
62
  * @returns {Promise<void>} - A promise that resolves when the email is sent
63
63
  */
64
- async function sendResetPasswordEmail({ email, redirectUrl, }) {
65
- (0, parameters_validation_1.required)({ email, redirectUrl });
64
+ async function sendResetPasswordEmail({ email, }) {
65
+ (0, parameters_validation_1.required)({ email });
66
66
  await (0, fetch_instance_1.enhancedFetch)({
67
67
  method: "POST",
68
68
  path: `/auth/send-reset-password-email`,
69
69
  body: JSON.stringify({
70
70
  email,
71
- redirectUrl,
72
71
  }),
73
72
  });
74
73
  }
@@ -4,6 +4,7 @@ import { OfferResponse } from "../../interfaces/models/offer";
4
4
  import { PageProductVariantResponse, Product, ProductAutocomplete, ProductReviewDto, ProductReviewRatings, ProductReviewsSummary, SearchThumbnailsAndAggregation } from "../../interfaces/models/product";
5
5
  import { SearchProduct } from "../../interfaces/models/searchProduct";
6
6
  import { SupplierSimpleView } from "../../interfaces/models/supplier";
7
+ import { Order, PageableObject } from "../../interfaces/models/common";
7
8
  /**
8
9
  * Requests parameters type definitions
9
10
  */
@@ -120,4 +121,25 @@ export interface GetProductVariantOffersResponse extends Array<OfferResponse> {
120
121
  }
121
122
  export interface GetRelatedProductsResponse extends SearchThumbnailsAndAggregation {
122
123
  }
124
+ export interface GetProductPaginatedOffersParameters {
125
+ productIdentifier: string;
126
+ productIdType?: string;
127
+ locale?: string;
128
+ currency?: string;
129
+ withoutPrices?: boolean;
130
+ pageable?: PageableParameters;
131
+ }
132
+ export interface GetProductPaginatedOffersResponse {
133
+ content: OfferResponse[];
134
+ empty: boolean;
135
+ first: boolean;
136
+ last: boolean;
137
+ number: number;
138
+ numberOfElements: number;
139
+ pageable: PageableObject;
140
+ size: number;
141
+ sort: Order[];
142
+ totalElements: number;
143
+ totalPages: number;
144
+ }
123
145
  export {};
@@ -1,4 +1,4 @@
1
- import { CreateProductReviewParameters, CreateProductReviewResponse, GetProductOffersParameters, GetProductOffersResponse, GetProductParameters, GetProductReviewsParameters, GetProductReviewsResponse, GetProductStatReviewsParameters, GetProductStatReviewsResponse, GetProductVariantAttributesParameters, GetProductVariantAttributesResponse, GetProductVariantOffersParameters, GetProductVariantOffersResponse, GetProductVariantSuppliersParameters, GetProductVariantSuppliersResponse, GetProductVariantsListParameters, GetProductVariantsListResponse, GetProductsListParameters, GetProductsListResponse, GetRelatedProductsParameters, AutoCompleteSearchProductsParameters, SearchProductsResponse, UpdateProductReviewParameters, UpdateProductReviewResponse } from "./definitions";
1
+ import { CreateProductReviewParameters, CreateProductReviewResponse, GetProductOffersParameters, GetProductOffersResponse, GetProductParameters, GetProductReviewsParameters, GetProductReviewsResponse, GetProductStatReviewsParameters, GetProductStatReviewsResponse, GetProductVariantAttributesParameters, GetProductVariantAttributesResponse, GetProductVariantOffersParameters, GetProductVariantOffersResponse, GetProductVariantSuppliersParameters, GetProductVariantSuppliersResponse, GetProductVariantsListParameters, GetProductVariantsListResponse, GetProductsListParameters, GetProductsListResponse, GetRelatedProductsParameters, AutoCompleteSearchProductsParameters, SearchProductsResponse, UpdateProductReviewParameters, UpdateProductReviewResponse, GetProductPaginatedOffersParameters, GetProductPaginatedOffersResponse } from "./definitions";
2
2
  /**
3
3
  * Search product with text expression for search and autocomplete
4
4
  */
@@ -51,3 +51,7 @@ export declare function createProductReview({ message, productSku, rating, }: Cr
51
51
  * Update a review for a product
52
52
  */
53
53
  export declare function updateProductReview({ productReviewId, message, rating, }: UpdateProductReviewParameters): Promise<UpdateProductReviewResponse>;
54
+ /**
55
+ * Get paginated offers of a product by sku, id or externalId
56
+ */
57
+ export declare function getProductPaginatedOffers({ productIdentifier, productIdType, currency, locale, withoutPrices, pageable, }: GetProductPaginatedOffersParameters): Promise<GetProductPaginatedOffersResponse>;
@@ -13,6 +13,7 @@ exports.getProductStatReviews = getProductStatReviews;
13
13
  exports.getProductVariantAttributes = getProductVariantAttributes;
14
14
  exports.createProductReview = createProductReview;
15
15
  exports.updateProductReview = updateProductReview;
16
+ exports.getProductPaginatedOffers = getProductPaginatedOffers;
16
17
  const parameters_validation_1 = require("../../helpers/parameters-validation");
17
18
  const fetch_instance_1 = require("../../settings/fetch-instance");
18
19
  /**
@@ -222,3 +223,23 @@ async function updateProductReview({ productReviewId, message, rating, }) {
222
223
  });
223
224
  return data;
224
225
  }
226
+ /**
227
+ * Get paginated offers of a product by sku, id or externalId
228
+ */
229
+ async function getProductPaginatedOffers({ productIdentifier, productIdType, currency, locale, withoutPrices, pageable, }) {
230
+ (0, parameters_validation_1.required)({ productIdentifier, productIdType });
231
+ const { data } = await (0, fetch_instance_1.enhancedFetch)({
232
+ method: "GET",
233
+ path: `/v1/shop/products/${productIdentifier}/paginated-offers`,
234
+ params: {
235
+ productIdType,
236
+ currency,
237
+ locale,
238
+ withoutPrices,
239
+ page: pageable === null || pageable === void 0 ? void 0 : pageable.page,
240
+ size: pageable === null || pageable === void 0 ? void 0 : pageable.size,
241
+ sort: pageable === null || pageable === void 0 ? void 0 : pageable.sort,
242
+ },
243
+ });
244
+ return data;
245
+ }
@@ -91,8 +91,10 @@ const enhancedFetch = async ({ path, method, params, body, }) => {
91
91
  }
92
92
  const isJsonResponse = (_a = headers
93
93
  .get("content-type")) === null || _a === void 0 ? void 0 : _a.includes("application/json");
94
- const data = isJsonResponse && response.status !== 204
95
- ? (await response.json())
94
+ // Additional check: ensure the response has content before attempting to parse JSON
95
+ const responseText = await response.text();
96
+ const data = isJsonResponse && responseText
97
+ ? JSON.parse(responseText)
96
98
  : {};
97
99
  return { data, headers, status };
98
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.6.3",
3
+ "version": "1.7.0",
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",