@gradientedge/commercetools-utils 4.23.3 → 4.25.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.
@@ -1,7 +1,7 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  import { CommercetoolsApiConfig, CommercetoolsRetryConfig } from './types';
3
3
  import { CommercetoolsAuth, PaymentDraft } from '../';
4
- import { RegionEndpoints } from '../types';
4
+ import { Logger, RegionEndpoints } from '../types';
5
5
  import type { Cart, CartDiscount, CartDiscountPagedQueryResponse, CartDraft, CartPagedQueryResponse, CartUpdateAction, Category, CategoryDraft, CategoryPagedQueryResponse, CategoryUpdate, Channel, ChannelPagedQueryResponse, Customer, CustomerCreatePasswordResetToken, CustomerDraft, CustomerGroup, CustomerGroupDraft, CustomerGroupPagedQueryResponse, CustomerGroupUpdate, CustomerPagedQueryResponse, CustomerResetPassword, CustomerSignin, CustomerSignInResult, CustomerToken, CustomerUpdate, CustomObject, CustomObjectDraft, DiscountCode, GraphQLRequest, GraphQLResponse, MyCartDraft, MyCartUpdateAction, MyCustomerDraft, MyPayment, MyPaymentDraft, MyPaymentPagedQueryResponse, MyPaymentUpdate, Order, OrderImportDraft, OrderPagedQueryResponse, OrderUpdate, Payment, PaymentPagedQueryResponse, PaymentUpdate, Product, ProductDraft, ProductProjection, ProductProjectionPagedQueryResponse, ProductsInStorePagedQueryResponse, ProductSelection, ProductSelectionDraft, ProductSelectionPagedQueryResponse, ProductSelectionUpdateAction, ProductType, ProductUpdate, ShippingMethod, ShippingMethodPagedQueryResponse, State, StatePagedQueryResponse, Store, StoreDraft, StorePagedQueryResponse, StoreUpdate, Type } from '../models';
6
6
  import { StandalonePrice, StandalonePriceDraft, StandalonePricePagedQueryResponse, StandalonePriceUpdate } from '../models/standalone-price';
7
7
  export interface FetchOptions<T = any> {
@@ -30,7 +30,9 @@ export declare class CommercetoolsApi {
30
30
  private readonly axios;
31
31
  private readonly retry;
32
32
  constructor(config: CommercetoolsApiConfig);
33
- createAxiosInstance(): AxiosInstance;
33
+ createAxiosInstance(options?: {
34
+ logFn?: Logger | null | undefined;
35
+ }): AxiosInstance;
34
36
  getStoreById(options: CommonRequestOptions & {
35
37
  id: string;
36
38
  }): Promise<Store>;
@@ -70,6 +72,9 @@ export declare class CommercetoolsApi {
70
72
  getChannelById(options: CommonRequestOptions & {
71
73
  id: string;
72
74
  }): Promise<Channel>;
75
+ getChannelByKey(options: CommonRequestOptions & {
76
+ key: string;
77
+ }): Promise<Channel>;
73
78
  getCategory(options: CommonRequestOptions & {
74
79
  id?: string;
75
80
  key?: string;
@@ -1,10 +1,15 @@
1
1
  import { CommercetoolsAuthApiConfig, CommercetoolsGrantResponse, LoginOptions, LogoutOptions, RevokeTokenOptions } from './types';
2
- import { RegionEndpoints } from '../types';
2
+ import { Logger, RegionEndpoints } from '../types';
3
+ import { AxiosInstance } from 'axios';
3
4
  export declare class CommercetoolsAuthApi {
4
5
  readonly config: CommercetoolsAuthApiConfig;
5
6
  readonly endpoints: RegionEndpoints;
6
7
  private readonly userAgent;
8
+ private readonly axios;
7
9
  constructor(config: CommercetoolsAuthApiConfig);
10
+ createAxiosInstance(options?: {
11
+ logFn?: Logger | null | undefined;
12
+ }): AxiosInstance;
8
13
  getClientGrant(scopes: string[]): Promise<CommercetoolsGrantResponse>;
9
14
  refreshGrant(refreshToken: string): Promise<CommercetoolsGrantResponse>;
10
15
  login(options: LoginOptions & {
@@ -1,4 +1,6 @@
1
- import { CommercetoolsBaseConfig, Region } from '../types';
1
+ /// <reference types="node" />
2
+ import { CommercetoolsBaseConfig, Logger, Region } from '../types';
3
+ import https from 'https';
2
4
  export interface CommercetoolsAuthConfig extends CommercetoolsBaseConfig {
3
5
  refreshIfWithinSecs?: number;
4
6
  customerScopes?: string[];
@@ -11,6 +13,8 @@ export interface CommercetoolsAuthApiConfig {
11
13
  timeoutMs?: number;
12
14
  systemIdentifier?: string;
13
15
  storeKey?: string;
16
+ httpsAgent?: https.Agent;
17
+ logFn?: Logger;
14
18
  }
15
19
  export interface CommercetoolsGrantResponse {
16
20
  access_token: string;
@@ -18,4 +18,14 @@ export interface CommercetoolsBaseConfig {
18
18
  clientScopes: string[];
19
19
  timeoutMs?: number;
20
20
  systemIdentifier?: string;
21
+ logFn?: Logger;
22
+ }
23
+ export interface Logger {
24
+ (options: LoggerParams): any;
25
+ }
26
+ export interface LoggerParams {
27
+ url: string;
28
+ params: any;
29
+ method: string;
30
+ headers?: Record<string, string | number | boolean>;
21
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/commercetools-utils",
3
- "version": "4.23.3",
3
+ "version": "4.25.0",
4
4
  "description": "Provide utility classes and functions for interacting with the commercetools API",
5
5
  "main": "./dist/ge-commercetools-utils-node.cjs.js",
6
6
  "module": "./dist/ge-commercetools-utils-node.esm.js",