@reactionary/commercetools 0.7.0 → 0.7.4

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.
@@ -115,7 +115,7 @@ class CommercetoolsCategoryCapability extends CategoryCapability {
115
115
  storeProjection: this.context.storeIdentifier.key
116
116
  }
117
117
  }).execute();
118
- const result = this.factory.parseCategoryPaginatedResult(this.context, response.body);
118
+ const result = this.factory.parseCategoryPaginatedResult(this.context, response.body, payload);
119
119
  return success(result);
120
120
  } catch (error2) {
121
121
  console.error(
@@ -144,7 +144,7 @@ class CommercetoolsCategoryCapability extends CategoryCapability {
144
144
  storeProjection: this.context.storeIdentifier.key
145
145
  }
146
146
  }).execute();
147
- const result = this.factory.parseCategoryPaginatedResult(this.context, response.body);
147
+ const result = this.factory.parseCategoryPaginatedResult(this.context, response.body, payload);
148
148
  return success(result);
149
149
  } catch (error2) {
150
150
  console.error(`Error fetching category top categories:`, error2);
@@ -24,12 +24,12 @@ class CommercetoolsCategoryFactory {
24
24
  };
25
25
  return this.categorySchema.parse(result);
26
26
  }
27
- parseCategoryPaginatedResult(context, data) {
27
+ parseCategoryPaginatedResult(context, data, query) {
28
28
  const result = {
29
- pageNumber: Math.floor(data.offset / data.count) + 1,
30
- pageSize: data.count,
29
+ pageNumber: query.paginationOptions.pageNumber,
30
+ pageSize: query.paginationOptions.pageSize,
31
31
  totalCount: data.total || 0,
32
- totalPages: Math.ceil((data.total ?? 0) / data.count),
32
+ totalPages: Math.ceil((data.total ?? 0) / query.paginationOptions.pageSize),
33
33
  items: data.results.map((category) => this.parseCategory(context, category))
34
34
  };
35
35
  return this.categoryPaginatedResultSchema.parse(result);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@reactionary/commercetools",
3
- "version": "0.7.0",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
8
  "vitest": "^4.0.9",
9
9
  "@nx/vite": "22.4.5",
10
- "@reactionary/core": "0.7.0",
10
+ "@reactionary/core": "0.7.4",
11
11
  "zod": "4.1.9",
12
12
  "@commercetools/ts-client": "^4.9.1",
13
13
  "@commercetools/platform-sdk": "^8.25.0",
@@ -1,11 +1,11 @@
1
1
  import type { Category as CTCategory, CategoryPagedQueryResponse } from '@commercetools/platform-sdk';
2
2
  import type { CategoryPaginatedResultSchema, CategorySchema } from '@reactionary/core';
3
- import { type AnyCategoryPaginatedResultSchema, type AnyCategorySchema, type CategoryFactory, type RequestContext } from '@reactionary/core';
3
+ import { type AnyCategoryPaginatedResultSchema, type AnyCategorySchema, type CategoryFactory, type RequestContext, type CategoryQueryForTopCategories, type CategoryQueryForChildCategories } from '@reactionary/core';
4
4
  import type * as z from 'zod';
5
5
  export declare class CommercetoolsCategoryFactory<TCategorySchema extends AnyCategorySchema = typeof CategorySchema, TCategoryPaginatedSchema extends AnyCategoryPaginatedResultSchema = typeof CategoryPaginatedResultSchema> implements CategoryFactory<TCategorySchema, TCategoryPaginatedSchema> {
6
6
  readonly categorySchema: TCategorySchema;
7
7
  readonly categoryPaginatedResultSchema: TCategoryPaginatedSchema;
8
8
  constructor(categorySchema: TCategorySchema, categoryPaginatedResultSchema: TCategoryPaginatedSchema);
9
9
  parseCategory(context: RequestContext, data: CTCategory): z.output<TCategorySchema>;
10
- parseCategoryPaginatedResult(context: RequestContext, data: CategoryPagedQueryResponse): z.output<TCategoryPaginatedSchema>;
10
+ parseCategoryPaginatedResult(context: RequestContext, data: CategoryPagedQueryResponse, query: CategoryQueryForTopCategories | CategoryQueryForChildCategories): z.output<TCategoryPaginatedSchema>;
11
11
  }