@commercelayer/sdk 2.1.0-alpha.3 → 2.1.0-alpha.7

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/api.d.ts CHANGED
@@ -94,11 +94,3 @@ export { default as Webhooks } from './resources/webhooks';
94
94
  export { default as WireTransfers } from './resources/wire_transfers';
95
95
  export declare type ResourceTypeLock = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'application' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'coupon_codes_promotion_rules' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'free_shipping_promotions' | 'geocoders' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscriptions' | 'orders' | 'organization' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_lists' | 'prices' | 'promotion_rules' | 'promotions' | 'refunds' | 'return_line_items' | 'returns' | 'shipments' | 'shipping_categories' | 'shipping_methods' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'voids' | 'webhooks' | 'wire_transfers';
96
96
  export declare const resourceList: readonly ["addresses", "adjustments", "adyen_gateways", "adyen_payments", "application", "attachments", "authorizations", "avalara_accounts", "billing_info_validation_rules", "bing_geocoders", "braintree_gateways", "braintree_payments", "bundles", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "coupon_codes_promotion_rules", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_subscriptions", "orders", "organization", "packages", "parcel_line_items", "parcels", "payment_gateways", "payment_methods", "paypal_gateways", "paypal_payments", "percentage_discount_promotions", "price_lists", "prices", "promotion_rules", "promotions", "refunds", "return_line_items", "returns", "shipments", "shipping_categories", "shipping_methods", "shipping_zones", "sku_list_items", "sku_list_promotion_rules", "sku_lists", "sku_options", "skus", "stock_items", "stock_line_items", "stock_locations", "stock_transfers", "stripe_gateways", "stripe_payments", "tax_calculators", "tax_categories", "tax_rules", "taxjar_accounts", "transactions", "voids", "webhooks", "wire_transfers"];
97
- export declare type ResourceInfo = {
98
- name: string;
99
- type: string;
100
- api: string;
101
- };
102
- export declare const resourceMap: {
103
- [res: string]: ResourceInfo;
104
- };
@@ -1,6 +1,6 @@
1
1
  import * as api from './api';
2
2
  import ApiError from './error';
3
- import { ErrorInterceptor, InterceptorType, RequestInterceptor, ResponseInterceptor } from './interceptor';
3
+ import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
4
4
  import { ResourcesConfig, ResourcesInitConfig } from './resource';
5
5
  declare type SdkConfig = {};
6
6
  declare type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
@@ -105,14 +105,9 @@ declare class CommerceLayerClient {
105
105
  addRequestInterceptor(onFulfilled?: RequestInterceptor, onRejected?: ErrorInterceptor): number;
106
106
  addResponseInterceptor(onFulfilled?: ResponseInterceptor, onRejected?: ErrorInterceptor): number;
107
107
  removeInterceptor(type: InterceptorType, id: number): void;
108
+ addRawResponseReader(): RawResponseReader;
109
+ removeRawResponseReader(reader: number | RawResponseReader): void;
108
110
  }
109
111
  declare const CommerceLayer: (config: CommerceLayerInitConfig) => CommerceLayerClient;
110
112
  export default CommerceLayer;
111
113
  export type { CommerceLayerClient, CommerceLayerConfig, CommerceLayerInitConfig };
112
- export declare const CommerceLayerStatic: {
113
- resourceList: readonly ["addresses", "adjustments", "adyen_gateways", "adyen_payments", "application", "attachments", "authorizations", "avalara_accounts", "billing_info_validation_rules", "bing_geocoders", "braintree_gateways", "braintree_payments", "bundles", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "coupon_codes_promotion_rules", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_subscriptions", "orders", "organization", "packages", "parcel_line_items", "parcels", "payment_gateways", "payment_methods", "paypal_gateways", "paypal_payments", "percentage_discount_promotions", "price_lists", "prices", "promotion_rules", "promotions", "refunds", "return_line_items", "returns", "shipments", "shipping_categories", "shipping_methods", "shipping_zones", "sku_list_items", "sku_list_promotion_rules", "sku_lists", "sku_options", "skus", "stock_items", "stock_line_items", "stock_locations", "stock_transfers", "stripe_gateways", "stripe_payments", "tax_calculators", "tax_categories", "tax_rules", "taxjar_accounts", "transactions", "voids", "webhooks", "wire_transfers"];
114
- resourceMap: {
115
- [res: string]: api.ResourceInfo;
116
- };
117
- isApiError: (error: any) => error is ApiError;
118
- };
package/lib/error.d.ts CHANGED
@@ -14,6 +14,7 @@ declare class ApiError extends Error {
14
14
  message: string;
15
15
  type?: ErrorType;
16
16
  });
17
+ first(): any;
17
18
  }
18
19
  export default ApiError;
19
20
  export { ErrorType };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export { default, CommerceLayerStatic } from './commercelayer';
1
+ export { default } from './commercelayer';
2
2
  export type { CommerceLayerClient } from './commercelayer';
3
+ export { CommerceLayerStatic } from './static';
3
4
  export type { QueryParamsRetrieve, QueryParamsList } from './query';
4
5
  export * from './model';
5
- export type { ResourceInfo } from './api';
6
+ export type { RawResponseReader } from './interceptor';
@@ -1,10 +1,18 @@
1
- import type { AxiosInterceptorManager, AxiosRequestConfig } from "axios";
1
+ import type { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from "axios";
2
2
  declare type InterceptorManager = {
3
3
  request: AxiosInterceptorManager<AxiosRequestConfig>;
4
4
  response: AxiosInterceptorManager<any>;
5
5
  };
6
- declare type RequestInterceptor = (config: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>;
7
- declare type ResponseInterceptor = (response: unknown) => unknown;
8
- declare type ErrorInterceptor = (error: unknown) => unknown;
6
+ declare type RequestObj = AxiosRequestConfig;
7
+ declare type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
8
+ declare type ResponseObj = AxiosResponse;
9
+ declare type ResponseInterceptor = (response: ResponseObj) => ResponseObj;
10
+ declare type ErrorObj = AxiosError;
11
+ declare type ErrorInterceptor = (error: ErrorObj) => ErrorObj;
9
12
  declare type InterceptorType = 'request' | 'response';
10
13
  export type { InterceptorManager, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, InterceptorType };
14
+ declare type RawResponseReader = {
15
+ id: number | undefined;
16
+ rawResponse: ResponseObj | undefined;
17
+ };
18
+ export type { RawResponseReader, ResponseObj };
package/lib/resource.d.ts CHANGED
@@ -50,8 +50,8 @@ declare type ResourcesConfig = ResourceAdapterConfig & ApiClientConfig;
50
50
  declare class ResourceAdapter {
51
51
  #private;
52
52
  constructor(config: ResourcesInitConfig);
53
- config(config: ResourcesConfig): void;
54
53
  get interceptors(): InterceptorManager;
54
+ config(config: ResourcesConfig): void;
55
55
  singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
56
56
  retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
57
57
  list<R extends Resource>(resource: ResourceType, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;