@commercelayer/sdk 3.0.1 → 4.1.1

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.
Files changed (121) hide show
  1. package/lib/cjs/api.d.ts +1 -1
  2. package/lib/cjs/client.d.ts +1 -5
  3. package/lib/cjs/client.js +1 -1
  4. package/lib/cjs/commercelayer.d.ts +1 -0
  5. package/lib/cjs/commercelayer.js +1 -1
  6. package/lib/cjs/config.d.ts +1 -1
  7. package/lib/cjs/config.js +1 -1
  8. package/lib/cjs/debug.d.ts +3 -0
  9. package/lib/cjs/debug.js +1 -0
  10. package/lib/cjs/jsonapi.js +1 -1
  11. package/lib/cjs/model.d.ts +1 -1
  12. package/lib/cjs/query.js +1 -1
  13. package/lib/cjs/resource.d.ts +4 -2
  14. package/lib/cjs/resource.js +1 -1
  15. package/lib/cjs/resources/adyen_payments.d.ts +1 -1
  16. package/lib/cjs/resources/attachments.d.ts +1 -1
  17. package/lib/cjs/resources/billing_info_validation_rules.d.ts +1 -1
  18. package/lib/cjs/resources/braintree_payments.d.ts +1 -1
  19. package/lib/cjs/resources/bundles.d.ts +1 -1
  20. package/lib/cjs/resources/checkout_com_payments.d.ts +1 -1
  21. package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +1 -1
  22. package/lib/cjs/resources/coupons.d.ts +1 -1
  23. package/lib/cjs/resources/customer_addresses.d.ts +2 -2
  24. package/lib/cjs/resources/customer_payment_sources.d.ts +2 -2
  25. package/lib/cjs/resources/delivery_lead_times.d.ts +2 -2
  26. package/lib/cjs/resources/external_payments.d.ts +1 -1
  27. package/lib/cjs/resources/fixed_price_promotions.d.ts +1 -1
  28. package/lib/cjs/resources/free_gift_promotions.d.ts +1 -1
  29. package/lib/cjs/resources/in_stock_subscriptions.d.ts +3 -3
  30. package/lib/cjs/resources/inventory_return_locations.d.ts +2 -2
  31. package/lib/cjs/resources/inventory_stock_locations.d.ts +2 -2
  32. package/lib/cjs/resources/line_item_options.d.ts +2 -2
  33. package/lib/cjs/resources/line_items.d.ts +1 -1
  34. package/lib/cjs/resources/markets.d.ts +3 -3
  35. package/lib/cjs/resources/merchants.d.ts +1 -1
  36. package/lib/cjs/resources/order_amount_promotion_rules.d.ts +1 -1
  37. package/lib/cjs/resources/order_copies.d.ts +1 -1
  38. package/lib/cjs/resources/order_subscriptions.d.ts +1 -1
  39. package/lib/cjs/resources/packages.d.ts +1 -1
  40. package/lib/cjs/resources/parcel_line_items.d.ts +2 -2
  41. package/lib/cjs/resources/parcels.d.ts +2 -2
  42. package/lib/cjs/resources/payment_methods.d.ts +2 -2
  43. package/lib/cjs/resources/paypal_payments.d.ts +1 -1
  44. package/lib/cjs/resources/prices.d.ts +1 -1
  45. package/lib/cjs/resources/return_line_items.d.ts +2 -2
  46. package/lib/cjs/resources/returns.d.ts +1 -1
  47. package/lib/cjs/resources/shipping_methods.d.ts +3 -3
  48. package/lib/cjs/resources/sku_list_items.d.ts +2 -2
  49. package/lib/cjs/resources/sku_list_promotion_rules.d.ts +1 -1
  50. package/lib/cjs/resources/sku_options.d.ts +1 -1
  51. package/lib/cjs/resources/skus.d.ts +1 -1
  52. package/lib/cjs/resources/stock_items.d.ts +1 -1
  53. package/lib/cjs/resources/stock_locations.d.ts +1 -1
  54. package/lib/cjs/resources/stock_transfers.d.ts +3 -3
  55. package/lib/cjs/resources/stripe_payments.d.ts +1 -1
  56. package/lib/cjs/resources/tax_categories.d.ts +2 -2
  57. package/lib/cjs/resources/tax_rules.d.ts +1 -1
  58. package/lib/cjs/resources/wire_transfers.d.ts +1 -1
  59. package/lib/esm/api.d.ts +1 -1
  60. package/lib/esm/client.d.ts +1 -5
  61. package/lib/esm/client.js +1 -1
  62. package/lib/esm/commercelayer.d.ts +1 -0
  63. package/lib/esm/commercelayer.js +1 -1
  64. package/lib/esm/common.js +1 -1
  65. package/lib/esm/config.d.ts +1 -1
  66. package/lib/esm/config.js +1 -1
  67. package/lib/esm/debug.d.ts +3 -0
  68. package/lib/esm/debug.js +1 -0
  69. package/lib/esm/error.js +1 -1
  70. package/lib/esm/jsonapi.js +1 -1
  71. package/lib/esm/model.d.ts +1 -1
  72. package/lib/esm/query.js +1 -1
  73. package/lib/esm/resource.d.ts +4 -2
  74. package/lib/esm/resource.js +1 -1
  75. package/lib/esm/resources/adyen_payments.d.ts +1 -1
  76. package/lib/esm/resources/attachments.d.ts +1 -1
  77. package/lib/esm/resources/billing_info_validation_rules.d.ts +1 -1
  78. package/lib/esm/resources/braintree_payments.d.ts +1 -1
  79. package/lib/esm/resources/bundles.d.ts +1 -1
  80. package/lib/esm/resources/checkout_com_payments.d.ts +1 -1
  81. package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +1 -1
  82. package/lib/esm/resources/coupons.d.ts +1 -1
  83. package/lib/esm/resources/customer_addresses.d.ts +2 -2
  84. package/lib/esm/resources/customer_payment_sources.d.ts +2 -2
  85. package/lib/esm/resources/delivery_lead_times.d.ts +2 -2
  86. package/lib/esm/resources/external_payments.d.ts +1 -1
  87. package/lib/esm/resources/fixed_price_promotions.d.ts +1 -1
  88. package/lib/esm/resources/free_gift_promotions.d.ts +1 -1
  89. package/lib/esm/resources/in_stock_subscriptions.d.ts +3 -3
  90. package/lib/esm/resources/inventory_return_locations.d.ts +2 -2
  91. package/lib/esm/resources/inventory_stock_locations.d.ts +2 -2
  92. package/lib/esm/resources/line_item_options.d.ts +2 -2
  93. package/lib/esm/resources/line_items.d.ts +1 -1
  94. package/lib/esm/resources/markets.d.ts +3 -3
  95. package/lib/esm/resources/merchants.d.ts +1 -1
  96. package/lib/esm/resources/order_amount_promotion_rules.d.ts +1 -1
  97. package/lib/esm/resources/order_copies.d.ts +1 -1
  98. package/lib/esm/resources/order_subscriptions.d.ts +1 -1
  99. package/lib/esm/resources/packages.d.ts +1 -1
  100. package/lib/esm/resources/parcel_line_items.d.ts +2 -2
  101. package/lib/esm/resources/parcels.d.ts +2 -2
  102. package/lib/esm/resources/payment_methods.d.ts +2 -2
  103. package/lib/esm/resources/paypal_payments.d.ts +1 -1
  104. package/lib/esm/resources/prices.d.ts +1 -1
  105. package/lib/esm/resources/return_line_items.d.ts +2 -2
  106. package/lib/esm/resources/returns.d.ts +1 -1
  107. package/lib/esm/resources/shipping_methods.d.ts +3 -3
  108. package/lib/esm/resources/sku_list_items.d.ts +2 -2
  109. package/lib/esm/resources/sku_list_promotion_rules.d.ts +1 -1
  110. package/lib/esm/resources/sku_options.d.ts +1 -1
  111. package/lib/esm/resources/skus.d.ts +1 -1
  112. package/lib/esm/resources/stock_items.d.ts +1 -1
  113. package/lib/esm/resources/stock_locations.d.ts +1 -1
  114. package/lib/esm/resources/stock_transfers.d.ts +3 -3
  115. package/lib/esm/resources/stripe_payments.d.ts +1 -1
  116. package/lib/esm/resources/tax_categories.d.ts +2 -2
  117. package/lib/esm/resources/tax_rules.d.ts +1 -1
  118. package/lib/esm/resources/wire_transfers.d.ts +1 -1
  119. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  120. package/lib/tsconfig.tsbuildinfo +1 -1
  121. package/package.json +7 -2
@@ -22,8 +22,8 @@ interface SkuListItemCreate extends ResourceCreate {
22
22
  position?: number;
23
23
  sku_code?: string;
24
24
  quantity?: number;
25
- sku_list?: SkuListRel;
26
- sku?: SkuRel;
25
+ sku_list: SkuListRel;
26
+ sku: SkuRel;
27
27
  }
28
28
  interface SkuListItemUpdate extends ResourceUpdate {
29
29
  position?: number;
@@ -42,7 +42,7 @@ interface SkuListPromotionRule extends Resource {
42
42
  interface SkuListPromotionRuleCreate extends ResourceCreate {
43
43
  all_skus?: boolean;
44
44
  min_quantity?: number;
45
- promotion?: PercentageDiscountPromotionRel | FreeShippingPromotionRel | FixedAmountPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel;
45
+ promotion: PercentageDiscountPromotionRel | FreeShippingPromotionRel | FixedAmountPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel;
46
46
  sku_list?: SkuListRel;
47
47
  }
48
48
  interface SkuListPromotionRuleUpdate extends ResourceUpdate {
@@ -26,7 +26,7 @@ interface SkuOptionCreate extends ResourceCreate {
26
26
  price_amount_cents?: number;
27
27
  delay_hours?: number;
28
28
  sku_code_regex?: string;
29
- market?: MarketRel;
29
+ market: MarketRel;
30
30
  }
31
31
  interface SkuOptionUpdate extends ResourceUpdate {
32
32
  name?: string;
@@ -42,7 +42,7 @@ interface SkuCreate extends ResourceCreate {
42
42
  hs_tariff_number?: string;
43
43
  do_not_ship?: boolean;
44
44
  do_not_track?: boolean;
45
- shipping_category?: ShippingCategoryRel;
45
+ shipping_category: ShippingCategoryRel;
46
46
  }
47
47
  interface SkuUpdate extends ResourceUpdate {
48
48
  code?: string;
@@ -22,7 +22,7 @@ interface StockItem extends Resource {
22
22
  interface StockItemCreate extends ResourceCreate {
23
23
  sku_code?: string;
24
24
  quantity: number;
25
- stock_location?: StockLocationRel;
25
+ stock_location: StockLocationRel;
26
26
  sku?: SkuRel;
27
27
  }
28
28
  interface StockItemUpdate extends ResourceUpdate {
@@ -28,7 +28,7 @@ interface StockLocationCreate extends ResourceCreate {
28
28
  name: string;
29
29
  label_format?: string;
30
30
  suppress_etd?: boolean;
31
- address?: AddressRel;
31
+ address: AddressRel;
32
32
  }
33
33
  interface StockLocationUpdate extends ResourceUpdate {
34
34
  name?: string;
@@ -34,9 +34,9 @@ interface StockTransfer extends Resource {
34
34
  interface StockTransferCreate extends ResourceCreate {
35
35
  sku_code?: string;
36
36
  quantity: number;
37
- sku?: SkuRel;
38
- origin_stock_location?: StockLocationRel;
39
- destination_stock_location?: StockLocationRel;
37
+ sku: SkuRel;
38
+ origin_stock_location: StockLocationRel;
39
+ destination_stock_location: StockLocationRel;
40
40
  shipment?: ShipmentRel;
41
41
  line_item?: LineItemRel;
42
42
  }
@@ -18,7 +18,7 @@ interface StripePayment extends Resource {
18
18
  }
19
19
  interface StripePaymentCreate extends ResourceCreate {
20
20
  options?: object;
21
- order?: OrderRel;
21
+ order: OrderRel;
22
22
  }
23
23
  interface StripePaymentUpdate extends ResourceUpdate {
24
24
  options?: object;
@@ -34,8 +34,8 @@ interface TaxCategory extends Resource {
34
34
  interface TaxCategoryCreate extends ResourceCreate {
35
35
  code: string;
36
36
  sku_code?: string;
37
- sku?: SkuRel;
38
- tax_calculator?: AvalaraAccountRel | TaxjarAccountRel | ManualTaxCalculatorRel | ExternalTaxCalculatorRel;
37
+ sku: SkuRel;
38
+ tax_calculator: AvalaraAccountRel | TaxjarAccountRel | ManualTaxCalculatorRel | ExternalTaxCalculatorRel;
39
39
  }
40
40
  interface TaxCategoryUpdate extends ResourceUpdate {
41
41
  code?: string;
@@ -36,7 +36,7 @@ interface TaxRuleCreate extends ResourceCreate {
36
36
  payment_method_taxable?: boolean;
37
37
  gift_card_taxable?: boolean;
38
38
  adjustment_taxable?: boolean;
39
- manual_tax_calculator?: ManualTaxCalculatorRel;
39
+ manual_tax_calculator: ManualTaxCalculatorRel;
40
40
  }
41
41
  interface TaxRuleUpdate extends ResourceUpdate {
42
42
  name?: string;
@@ -11,7 +11,7 @@ interface WireTransfer extends Resource {
11
11
  order?: Order;
12
12
  }
13
13
  interface WireTransferCreate extends ResourceCreate {
14
- order?: OrderRel;
14
+ order: OrderRel;
15
15
  }
16
16
  interface WireTransferUpdate extends ResourceUpdate {
17
17
  order?: OrderRel;
package/lib/esm/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ©2021 Commerce Layer Inc.
2
+ * ©2022 Commerce Layer Inc.
3
3
  * OpenAPI schema, version 2.7.6
4
4
  **/
5
5
  export { default as Addresses } from './resources/addresses';
@@ -12,11 +12,7 @@ declare type ApiClientInitConfig = {
12
12
  domain?: string;
13
13
  accessToken: string;
14
14
  } & RequestConfig;
15
- declare type ApiClientConfig = {
16
- organization?: string;
17
- domain?: string;
18
- accessToken?: string;
19
- } & RequestConfig;
15
+ declare type ApiClientConfig = Partial<ApiClientInitConfig>;
20
16
  declare class ApiClient {
21
17
  #private;
22
18
  static create(options: ApiClientInitConfig): ApiClient;
package/lib/esm/client.js CHANGED
@@ -1 +1 @@
1
- var h=this&&this.__classPrivateFieldSet||function(t,e,r,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},c=this&&this.__classPrivateFieldGet||function(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)},a,i;import u from"axios";import{SdkError as T,ApiError as g,ErrorType as n}from"./error";import l from"./config";const p=(t,e)=>`https://${t.toLowerCase()}.${e||l.default.domain}/api`,y=t=>{let e=new T({message:t.message,type:n.GENERIC});if(u.isAxiosError(t))if(t.response){const r=new g(e);r.type=n.RESPONSE,r.status=t.response.status,r.code=String(r.status),r.errors=t.response.data.errors,e=r}else t.request?(e.type=n.REQUEST,e.request=t.request):e.type=n.CLIENT;else u.isCancel(t)?e.type=n.CANCEL:e.source=t;throw e};class f{constructor(e){a.set(this,void 0),i.set(this,void 0),this.baseUrl=p(e.organization,e.domain),h(this,a,e.accessToken,"f");const r={timeout:e.timeout||l.client.timeout};h(this,i,u.create(Object.assign({baseURL:this.baseUrl,timeout:l.client.timeout,headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json",Authorization:"Bearer "+c(this,a,"f")}},r)),"f"),this.interceptors=c(this,i,"f").interceptors}static create(e){if(!(e==null?void 0:e.organization))throw new Error("Undefined 'organization' parameter");if(!(e==null?void 0:e.accessToken))throw new Error("Undefined 'accessToken' parameter");return new f(e)}config(e){const r=c(this,i,"f").defaults;e.timeout&&(r.timeout=e.timeout),e.organization&&(this.baseUrl=p(e.organization,e.domain)),e.accessToken&&h(this,a,e.accessToken,"f")}async request(e,r,s,o){const m=s?{data:s}:void 0,w=r,v=(o==null?void 0:o.organization)?p(o.organization,o.domain):void 0,E=(o==null?void 0:o.accessToken)?{Authorization:"Bearer "+o.accessToken}:void 0;return c(this,i,"f").request(Object.assign({method:e,baseURL:v,url:w,data:m,headers:E},o)).then(d=>d.data).catch(d=>y(d))}}a=new WeakMap,i=new WeakMap;export default f;
1
+ var u=this&&this.__classPrivateFieldSet||function(s,e,t,a,r){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?r.call(s,t):r?r.value=t:e.set(s,t),t},o=this&&this.__classPrivateFieldGet||function(s,e,t,a){if(t==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!a:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(s):a?a.value:e.get(s)},i,n;import p from"axios";import{SdkError as b,ApiError as z,ErrorType as c}from"./error";import l from"./config";import k from"./debug";const d=k(),f=(s,e)=>`https://${s.toLowerCase()}.${e||l.default.domain}/api`,C=s=>{let e=new b({message:s.message,type:c.GENERIC});if(p.isAxiosError(s))if(s.response){const t=new z(e);t.type=c.RESPONSE,t.status=s.response.status,t.code=String(t.status),t.errors=s.response.data.errors,e=t}else s.request?(e.type=c.REQUEST,e.request=s.request):e.type=c.CLIENT;else p.isCancel(s)?e.type=c.CANCEL:e.source=s;throw e};class m{constructor(e){i.set(this,void 0),n.set(this,void 0),d("new client instance %O",e),this.baseUrl=f(e.organization,e.domain),u(this,i,e.accessToken,"f");const t={timeout:e.timeout||l.client.timeout},a=Object.assign({baseURL:this.baseUrl,timeout:l.client.timeout,headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json",Authorization:"Bearer "+o(this,i,"f")}},t);d("axios options: %O",a),u(this,n,p.create(a),"f"),this.interceptors=o(this,n,"f").interceptors}static create(e){if(!(e==null?void 0:e.organization))throw new Error("Undefined 'organization' parameter");if(!(e==null?void 0:e.accessToken))throw new Error("Undefined 'accessToken' parameter");return new m(e)}config(e){d("config %o",e);const t=o(this,n,"f").defaults;e.timeout&&(t.timeout=e.timeout),e.organization&&(this.baseUrl=f(e.organization,e.domain)),e.accessToken&&(u(this,i,e.accessToken,"f"),t.headers.common.Authorization="Bearer "+o(this,i,"f"))}async request(e,t,a,r){d("request %s %s, %O, %O",e,t,a||{},r||{});const E=a?{data:a}:void 0,g=t,y=(r==null?void 0:r.organization)?f(r.organization,r.domain):void 0,w=(r==null?void 0:r.accessToken)||o(this,i,"f"),T=w?{Authorization:"Bearer "+w}:void 0,v=Object.assign({method:e,baseURL:y,url:g,data:E,headers:T},r);return d("request params: %O",v),o(this,n,"f").request(v).then(h=>h.data).catch(h=>C(h))}}i=new WeakMap,n=new WeakMap;export default m;
@@ -105,6 +105,7 @@ declare class CommerceLayerClient {
105
105
  wire_transfers: api.WireTransfers;
106
106
  constructor(config: CommerceLayerInitConfig);
107
107
  get currentOrganization(): string;
108
+ private localConfig;
108
109
  config(config: CommerceLayerConfig): void;
109
110
  resources(): readonly string[];
110
111
  isApiError(error: any): error is ApiError;
@@ -1 +1 @@
1
- var c=this&&this.__classPrivateFieldSet||function(o,i,n,r,a){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof i=="function"?o!==i||!a:!i.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?a.call(o,n):a?a.value=n:i.set(o,n),n},s=this&&this.__classPrivateFieldGet||function(o,i,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?o!==i||!r:!i.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(o):r?r.value:i.get(o)},t,h;import*as e from"./api";import{CommerceLayerStatic as f}from"./static";import w from"./resource";const u="2.7.6";class p{constructor(i){t.set(this,void 0),h.set(this,void 0),c(this,t,new w(i),"f"),c(this,h,i.organization,"f"),this.addresses=new e.Addresses(s(this,t,"f")),this.adjustments=new e.Adjustments(s(this,t,"f")),this.adyen_gateways=new e.AdyenGateways(s(this,t,"f")),this.adyen_payments=new e.AdyenPayments(s(this,t,"f")),this.application=new e.Applications(s(this,t,"f")),this.attachments=new e.Attachments(s(this,t,"f")),this.authorizations=new e.Authorizations(s(this,t,"f")),this.avalara_accounts=new e.AvalaraAccounts(s(this,t,"f")),this.billing_info_validation_rules=new e.BillingInfoValidationRules(s(this,t,"f")),this.bing_geocoders=new e.BingGeocoders(s(this,t,"f")),this.braintree_gateways=new e.BraintreeGateways(s(this,t,"f")),this.braintree_payments=new e.BraintreePayments(s(this,t,"f")),this.bundles=new e.Bundles(s(this,t,"f")),this.captures=new e.Captures(s(this,t,"f")),this.carrier_accounts=new e.CarrierAccounts(s(this,t,"f")),this.checkout_com_gateways=new e.CheckoutComGateways(s(this,t,"f")),this.checkout_com_payments=new e.CheckoutComPayments(s(this,t,"f")),this.coupon_codes_promotion_rules=new e.CouponCodesPromotionRules(s(this,t,"f")),this.coupon_recipients=new e.CouponRecipients(s(this,t,"f")),this.coupons=new e.Coupons(s(this,t,"f")),this.customer_addresses=new e.CustomerAddresses(s(this,t,"f")),this.customer_groups=new e.CustomerGroups(s(this,t,"f")),this.customer_password_resets=new e.CustomerPasswordResets(s(this,t,"f")),this.customer_payment_sources=new e.CustomerPaymentSources(s(this,t,"f")),this.customer_subscriptions=new e.CustomerSubscriptions(s(this,t,"f")),this.customers=new e.Customers(s(this,t,"f")),this.delivery_lead_times=new e.DeliveryLeadTimes(s(this,t,"f")),this.event_callbacks=new e.EventCallbacks(s(this,t,"f")),this.external_gateways=new e.ExternalGateways(s(this,t,"f")),this.external_payments=new e.ExternalPayments(s(this,t,"f")),this.external_promotions=new e.ExternalPromotions(s(this,t,"f")),this.external_tax_calculators=new e.ExternalTaxCalculators(s(this,t,"f")),this.fixed_amount_promotions=new e.FixedAmountPromotions(s(this,t,"f")),this.fixed_price_promotions=new e.FixedPricePromotions(s(this,t,"f")),this.free_gift_promotions=new e.FreeGiftPromotions(s(this,t,"f")),this.free_shipping_promotions=new e.FreeShippingPromotions(s(this,t,"f")),this.geocoders=new e.Geocoders(s(this,t,"f")),this.gift_card_recipients=new e.GiftCardRecipients(s(this,t,"f")),this.gift_cards=new e.GiftCards(s(this,t,"f")),this.google_geocoders=new e.GoogleGeocoders(s(this,t,"f")),this.imports=new e.Imports(s(this,t,"f")),this.in_stock_subscriptions=new e.InStockSubscriptions(s(this,t,"f")),this.inventory_models=new e.InventoryModels(s(this,t,"f")),this.inventory_return_locations=new e.InventoryReturnLocations(s(this,t,"f")),this.inventory_stock_locations=new e.InventoryStockLocations(s(this,t,"f")),this.line_item_options=new e.LineItemOptions(s(this,t,"f")),this.line_items=new e.LineItems(s(this,t,"f")),this.manual_gateways=new e.ManualGateways(s(this,t,"f")),this.manual_tax_calculators=new e.ManualTaxCalculators(s(this,t,"f")),this.markets=new e.Markets(s(this,t,"f")),this.merchants=new e.Merchants(s(this,t,"f")),this.order_amount_promotion_rules=new e.OrderAmountPromotionRules(s(this,t,"f")),this.order_copies=new e.OrderCopies(s(this,t,"f")),this.order_subscriptions=new e.OrderSubscriptions(s(this,t,"f")),this.order_validation_rules=new e.OrderValidationRules(s(this,t,"f")),this.orders=new e.Orders(s(this,t,"f")),this.organization=new e.Organizations(s(this,t,"f")),this.packages=new e.Packages(s(this,t,"f")),this.parcel_line_items=new e.ParcelLineItems(s(this,t,"f")),this.parcels=new e.Parcels(s(this,t,"f")),this.payment_gateways=new e.PaymentGateways(s(this,t,"f")),this.payment_methods=new e.PaymentMethods(s(this,t,"f")),this.paypal_gateways=new e.PaypalGateways(s(this,t,"f")),this.paypal_payments=new e.PaypalPayments(s(this,t,"f")),this.percentage_discount_promotions=new e.PercentageDiscountPromotions(s(this,t,"f")),this.price_lists=new e.PriceLists(s(this,t,"f")),this.prices=new e.Prices(s(this,t,"f")),this.promotion_rules=new e.PromotionRules(s(this,t,"f")),this.promotions=new e.Promotions(s(this,t,"f")),this.refunds=new e.Refunds(s(this,t,"f")),this.return_line_items=new e.ReturnLineItems(s(this,t,"f")),this.returns=new e.Returns(s(this,t,"f")),this.shipments=new e.Shipments(s(this,t,"f")),this.shipping_categories=new e.ShippingCategories(s(this,t,"f")),this.shipping_methods=new e.ShippingMethods(s(this,t,"f")),this.shipping_zones=new e.ShippingZones(s(this,t,"f")),this.sku_list_items=new e.SkuListItems(s(this,t,"f")),this.sku_list_promotion_rules=new e.SkuListPromotionRules(s(this,t,"f")),this.sku_lists=new e.SkuLists(s(this,t,"f")),this.sku_options=new e.SkuOptions(s(this,t,"f")),this.skus=new e.Skus(s(this,t,"f")),this.stock_items=new e.StockItems(s(this,t,"f")),this.stock_line_items=new e.StockLineItems(s(this,t,"f")),this.stock_locations=new e.StockLocations(s(this,t,"f")),this.stock_transfers=new e.StockTransfers(s(this,t,"f")),this.stripe_gateways=new e.StripeGateways(s(this,t,"f")),this.stripe_payments=new e.StripePayments(s(this,t,"f")),this.tax_calculators=new e.TaxCalculators(s(this,t,"f")),this.tax_categories=new e.TaxCategories(s(this,t,"f")),this.tax_rules=new e.TaxRules(s(this,t,"f")),this.taxjar_accounts=new e.TaxjarAccounts(s(this,t,"f")),this.transactions=new e.Transactions(s(this,t,"f")),this.voids=new e.Voids(s(this,t,"f")),this.webhooks=new e.Webhooks(s(this,t,"f")),this.wire_transfers=new e.WireTransfers(s(this,t,"f"))}static get openApiSchemaVersion(){return u}get currentOrganization(){return s(this,h,"f")}config(i){!i||(i.organization&&c(this,h,i.organization,"f"),s(this,t,"f").config(i))}resources(){return f.resources()}isApiError(i){return f.isApiError(i)}addRequestInterceptor(i,n){return s(this,t,"f").interceptors.request.use(i,n)}addResponseInterceptor(i,n){return s(this,t,"f").interceptors.response.use(i,n)}removeInterceptor(i,n){return s(this,t,"f").interceptors[i].eject(n)}addRawResponseReader(){const i={id:void 0,rawResponse:void 0};function n(a){return i.rawResponse=a==null?void 0:a.data,a}const r=this.addResponseInterceptor(n);return i.id=r,i}removeRawResponseReader(i){const n=typeof i=="number"?i:i.id;if(n)return this.removeInterceptor("response",n)}}t=new WeakMap,h=new WeakMap;const m=o=>new p(o);export default m;
1
+ var c=this&&this.__classPrivateFieldSet||function(o,i,n,r,a){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof i=="function"?o!==i||!a:!i.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?a.call(o,n):a?a.value=n:i.set(o,n),n},s=this&&this.__classPrivateFieldGet||function(o,i,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?o!==i||!r:!i.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(o):r?r.value:i.get(o)},t,h;import*as e from"./api";import{CommerceLayerStatic as f}from"./static";import u from"./resource";import p from"./debug";const w=p(),m="2.7.6";class l{constructor(i){t.set(this,void 0),h.set(this,void 0),w("new commercelayer instance %O",i),c(this,t,new u(i),"f"),c(this,h,i.organization,"f"),this.addresses=new e.Addresses(s(this,t,"f")),this.adjustments=new e.Adjustments(s(this,t,"f")),this.adyen_gateways=new e.AdyenGateways(s(this,t,"f")),this.adyen_payments=new e.AdyenPayments(s(this,t,"f")),this.application=new e.Applications(s(this,t,"f")),this.attachments=new e.Attachments(s(this,t,"f")),this.authorizations=new e.Authorizations(s(this,t,"f")),this.avalara_accounts=new e.AvalaraAccounts(s(this,t,"f")),this.billing_info_validation_rules=new e.BillingInfoValidationRules(s(this,t,"f")),this.bing_geocoders=new e.BingGeocoders(s(this,t,"f")),this.braintree_gateways=new e.BraintreeGateways(s(this,t,"f")),this.braintree_payments=new e.BraintreePayments(s(this,t,"f")),this.bundles=new e.Bundles(s(this,t,"f")),this.captures=new e.Captures(s(this,t,"f")),this.carrier_accounts=new e.CarrierAccounts(s(this,t,"f")),this.checkout_com_gateways=new e.CheckoutComGateways(s(this,t,"f")),this.checkout_com_payments=new e.CheckoutComPayments(s(this,t,"f")),this.coupon_codes_promotion_rules=new e.CouponCodesPromotionRules(s(this,t,"f")),this.coupon_recipients=new e.CouponRecipients(s(this,t,"f")),this.coupons=new e.Coupons(s(this,t,"f")),this.customer_addresses=new e.CustomerAddresses(s(this,t,"f")),this.customer_groups=new e.CustomerGroups(s(this,t,"f")),this.customer_password_resets=new e.CustomerPasswordResets(s(this,t,"f")),this.customer_payment_sources=new e.CustomerPaymentSources(s(this,t,"f")),this.customer_subscriptions=new e.CustomerSubscriptions(s(this,t,"f")),this.customers=new e.Customers(s(this,t,"f")),this.delivery_lead_times=new e.DeliveryLeadTimes(s(this,t,"f")),this.event_callbacks=new e.EventCallbacks(s(this,t,"f")),this.external_gateways=new e.ExternalGateways(s(this,t,"f")),this.external_payments=new e.ExternalPayments(s(this,t,"f")),this.external_promotions=new e.ExternalPromotions(s(this,t,"f")),this.external_tax_calculators=new e.ExternalTaxCalculators(s(this,t,"f")),this.fixed_amount_promotions=new e.FixedAmountPromotions(s(this,t,"f")),this.fixed_price_promotions=new e.FixedPricePromotions(s(this,t,"f")),this.free_gift_promotions=new e.FreeGiftPromotions(s(this,t,"f")),this.free_shipping_promotions=new e.FreeShippingPromotions(s(this,t,"f")),this.geocoders=new e.Geocoders(s(this,t,"f")),this.gift_card_recipients=new e.GiftCardRecipients(s(this,t,"f")),this.gift_cards=new e.GiftCards(s(this,t,"f")),this.google_geocoders=new e.GoogleGeocoders(s(this,t,"f")),this.imports=new e.Imports(s(this,t,"f")),this.in_stock_subscriptions=new e.InStockSubscriptions(s(this,t,"f")),this.inventory_models=new e.InventoryModels(s(this,t,"f")),this.inventory_return_locations=new e.InventoryReturnLocations(s(this,t,"f")),this.inventory_stock_locations=new e.InventoryStockLocations(s(this,t,"f")),this.line_item_options=new e.LineItemOptions(s(this,t,"f")),this.line_items=new e.LineItems(s(this,t,"f")),this.manual_gateways=new e.ManualGateways(s(this,t,"f")),this.manual_tax_calculators=new e.ManualTaxCalculators(s(this,t,"f")),this.markets=new e.Markets(s(this,t,"f")),this.merchants=new e.Merchants(s(this,t,"f")),this.order_amount_promotion_rules=new e.OrderAmountPromotionRules(s(this,t,"f")),this.order_copies=new e.OrderCopies(s(this,t,"f")),this.order_subscriptions=new e.OrderSubscriptions(s(this,t,"f")),this.order_validation_rules=new e.OrderValidationRules(s(this,t,"f")),this.orders=new e.Orders(s(this,t,"f")),this.organization=new e.Organizations(s(this,t,"f")),this.packages=new e.Packages(s(this,t,"f")),this.parcel_line_items=new e.ParcelLineItems(s(this,t,"f")),this.parcels=new e.Parcels(s(this,t,"f")),this.payment_gateways=new e.PaymentGateways(s(this,t,"f")),this.payment_methods=new e.PaymentMethods(s(this,t,"f")),this.paypal_gateways=new e.PaypalGateways(s(this,t,"f")),this.paypal_payments=new e.PaypalPayments(s(this,t,"f")),this.percentage_discount_promotions=new e.PercentageDiscountPromotions(s(this,t,"f")),this.price_lists=new e.PriceLists(s(this,t,"f")),this.prices=new e.Prices(s(this,t,"f")),this.promotion_rules=new e.PromotionRules(s(this,t,"f")),this.promotions=new e.Promotions(s(this,t,"f")),this.refunds=new e.Refunds(s(this,t,"f")),this.return_line_items=new e.ReturnLineItems(s(this,t,"f")),this.returns=new e.Returns(s(this,t,"f")),this.shipments=new e.Shipments(s(this,t,"f")),this.shipping_categories=new e.ShippingCategories(s(this,t,"f")),this.shipping_methods=new e.ShippingMethods(s(this,t,"f")),this.shipping_zones=new e.ShippingZones(s(this,t,"f")),this.sku_list_items=new e.SkuListItems(s(this,t,"f")),this.sku_list_promotion_rules=new e.SkuListPromotionRules(s(this,t,"f")),this.sku_lists=new e.SkuLists(s(this,t,"f")),this.sku_options=new e.SkuOptions(s(this,t,"f")),this.skus=new e.Skus(s(this,t,"f")),this.stock_items=new e.StockItems(s(this,t,"f")),this.stock_line_items=new e.StockLineItems(s(this,t,"f")),this.stock_locations=new e.StockLocations(s(this,t,"f")),this.stock_transfers=new e.StockTransfers(s(this,t,"f")),this.stripe_gateways=new e.StripeGateways(s(this,t,"f")),this.stripe_payments=new e.StripePayments(s(this,t,"f")),this.tax_calculators=new e.TaxCalculators(s(this,t,"f")),this.tax_categories=new e.TaxCategories(s(this,t,"f")),this.tax_rules=new e.TaxRules(s(this,t,"f")),this.taxjar_accounts=new e.TaxjarAccounts(s(this,t,"f")),this.transactions=new e.Transactions(s(this,t,"f")),this.voids=new e.Voids(s(this,t,"f")),this.webhooks=new e.Webhooks(s(this,t,"f")),this.wire_transfers=new e.WireTransfers(s(this,t,"f"))}static get openApiSchemaVersion(){return m}get currentOrganization(){return s(this,h,"f")}localConfig(i){i.organization&&c(this,h,i.organization,"f")}config(i){w("config %o",i),this.localConfig(i),s(this,t,"f").config(i)}resources(){return f.resources()}isApiError(i){return f.isApiError(i)}addRequestInterceptor(i,n){return s(this,t,"f").interceptors.request.use(i,n)}addResponseInterceptor(i,n){return s(this,t,"f").interceptors.response.use(i,n)}removeInterceptor(i,n){return s(this,t,"f").interceptors[i].eject(n)}addRawResponseReader(){const i={id:void 0,rawResponse:void 0};function n(a){return i.rawResponse=a==null?void 0:a.data,a}const r=this.addResponseInterceptor(n);return i.id=r,i}removeRawResponseReader(i){const n=typeof i=="number"?i:i.id;if(n)return this.removeInterceptor("response",n)}}t=new WeakMap,h=new WeakMap;const _=o=>new l(o);export default _;
package/lib/esm/common.js CHANGED
@@ -1 +1 @@
1
- import{resourceList as s}from"./api";const t=e=>e&&e.type&&e.id&&s.includes(e.type),p=e=>e&&typeof e.type!="undefined"&&e.type&&s.includes(e.type);export{t as isResourceId,p as isResourceType};
1
+ import{resourceList as e}from"./api";const p=s=>s&&s.type&&s.id&&e.includes(s.type),t=s=>s&&typeof s.type!="undefined"&&s.type&&e.includes(s.type);export{p as isResourceId,t as isResourceType};
@@ -5,7 +5,7 @@ declare const config: {
5
5
  readonly pageSize: 10;
6
6
  };
7
7
  readonly client: {
8
- readonly timeout: 3000;
8
+ readonly timeout: 15000;
9
9
  };
10
10
  };
11
11
  export default config;
package/lib/esm/config.js CHANGED
@@ -1 +1 @@
1
- const e={default:{domain:"commercelayer.io",pageNumber:1,pageSize:10},client:{timeout:3e3}};export default e;
1
+ const e={default:{domain:"commercelayer.io",pageNumber:1,pageSize:10},client:{timeout:15e3}};export default e;
@@ -0,0 +1,3 @@
1
+ declare type Debugger = (pattern: string, ...args: any[]) => void;
2
+ declare const debug: (namespace?: string | undefined) => Debugger;
3
+ export default debug;
@@ -0,0 +1 @@
1
+ const a=(e,...r)=>{};let t=e=>a;try{const e=require("debug");e&&typeof e=="function"&&(t=e)}catch{}const o="clsdk",n=()=>{const e=new Error;Error.prepareStackTrace=(s,c)=>c;const r=e.stack;return Error.prepareStackTrace=void 0,(r[2].getFileName()||"/").replace(/^.*[\\/]/,"").replace(".ts","")},p=e=>t(`${o}:${e||n()}`);export default p;
package/lib/esm/error.js CHANGED
@@ -1 +1 @@
1
- var s;(function(e){e.CLIENT="client",e.REQUEST="request",e.RESPONSE="response",e.GENERIC="generic",e.CANCEL="cancel"})(s||(s={}));class t extends Error{constructor(r){super(r.message);this.name=this.constructor.name,this.type=r.type||s.GENERIC}static isSdkError(r){return r&&["SdkError","ApiError"].includes(r.name)&&Object.values(s).includes(r.type)}}class i extends t{constructor(r){super(Object.assign(Object.assign({},r),{type:s.RESPONSE}));this.errors=[],this.name=this.constructor.name}static isApiError(r){return t.isSdkError(r)&&r.name==="ApiError"&&r.type===s.RESPONSE}first(){var r;return((r=this.errors)===null||r===void 0?void 0:r.length)>0?this.errors[0]:void 0}}export{t as SdkError,i as ApiError,s as ErrorType};
1
+ var t;(function(s){s.CLIENT="client",s.REQUEST="request",s.RESPONSE="response",s.GENERIC="generic",s.CANCEL="cancel"})(t||(t={}));class e extends Error{constructor(r){super(r.message);this.name=this.constructor.name,this.type=r.type||t.GENERIC}static isSdkError(r){return r&&["SdkError","ApiError"].includes(r.name)&&Object.values(t).includes(r.type)}}class i extends e{constructor(r){super(Object.assign(Object.assign({},r),{type:t.RESPONSE}));this.errors=[],this.name=this.constructor.name}static isApiError(r){return e.isSdkError(r)&&r.name==="ApiError"&&r.type===t.RESPONSE}first(){var r;return((r=this.errors)===null||r===void 0?void 0:r.length)>0?this.errors[0]:void 0}}export{e as SdkError,i as ApiError,t as ErrorType};
@@ -1 +1 @@
1
- import{isResourceId as i}from"./common";const l=t=>{let s;t.links&&delete t.links;const r=t.data,n=t.included;return Array.isArray(r)?s=r.map(e=>o(e,n)):s=o(r,n),s},d=(t,s=[])=>s.find(r=>t.id===r.id&&t.type===r.type)||t,o=(t,s)=>{const r=Object.assign({id:t.id,type:t.type},t.attributes);return t.relationships&&Object.keys(t.relationships).forEach(n=>{const e=t.relationships[n].data;e?Array.isArray(e)?r[n]=e.map(a=>o(d(a,s),s)):r[n]=o(d(e,s),s):e===null&&(r[n]=null)}),r},c=t=>{const s={},r={};for(const e in t){if(["type","id"].includes(e))continue;const a=t[e];a&&(i(a)||Array.isArray(a)&&i(a[0]))?r[e]={data:a}:s[e]=a}const n={type:t.type,attributes:s,relationships:r};return i(t)&&(n.id=t.id),n};export{l as denormalize,c as normalize};
1
+ import{isResourceId as d}from"./common";import c from"./debug";const n=c(),p=e=>{let i;e.links&&delete e.links;const t=e.data,o=e.included;return Array.isArray(t)?i=t.map(s=>r(s,o)):i=r(t,o),i},l=(e,i=[])=>i.find(t=>e.id===t.id&&e.type===t.type)||e,r=(e,i)=>{n("denormalize resource: %O, %o",e,i||{});const t=Object.assign({id:e.id,type:e.type},e.attributes);return e.relationships&&Object.keys(e.relationships).forEach(o=>{const s=e.relationships[o].data;s?Array.isArray(s)?t[o]=s.map(a=>r(l(a,i),i)):t[o]=r(l(s,i),i):s===null&&(t[o]=null)}),n("denormalized resource: %O",t),t},u=e=>{n("normalize resource: %O",e);const i={},t={};for(const s in e){if(["type","id"].includes(s))continue;const a=e[s];a&&(d(a)||Array.isArray(a)&&d(a[0]))?t[s]={data:a}:i[s]=a}const o={type:e.type,attributes:i,relationships:t};return d(e)&&(o.id=e.id),n("normalized resource: %O",o),o};export{p as denormalize,u as normalize};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ©2021 Commerce Layer Inc.
2
+ * ©2022 Commerce Layer Inc.
3
3
  * OpenAPI schema, version 2.7.6
4
4
  **/
5
5
  export type { Address, AddressCreate, AddressUpdate } from './resources/addresses';
package/lib/esm/query.js CHANGED
@@ -1 +1 @@
1
- const a=r=>r.filters||r.pageNumber||r.pageSize||r.sort,n=(r,e)=>{const i={};return r&&(r.include&&(i.include=r.include.join(",")),r.fields&&(Array.isArray(r.fields)&&(r.fields={[e.type]:r.fields}),Object.entries(r.fields).forEach(([s,t])=>{i[`fields[${s}]`]=t.join(",")})),a(r)&&(r.sort&&(Array.isArray(r.sort)?i.sort=r.sort.join(","):i.sort=Object.entries(r.sort).map(([s,t])=>`${t==="desc"?"-":""}${s}`).join(",")),r.pageNumber&&(i["page[number]"]=String(r.pageNumber)),r.pageSize&&(i["page[size]"]=String(r.pageSize)),r.filters&&Object.entries(r.filters).forEach(([s,t])=>{i[`filter[q][${s}]`]=String(t)}))),i};export{n as generateQueryStringParams};
1
+ import n from"./debug";const r=n(),o=e=>e.filters||e.pageNumber||e.pageSize||e.sort,g=(e,a)=>{r("generate query string params: %O, %O",e,a);const i={};return e&&(e.include&&(i.include=e.include.join(",")),e.fields&&(Array.isArray(e.fields)&&(e.fields={[a.type]:e.fields}),Object.entries(e.fields).forEach(([s,t])=>{i[`fields[${s}]`]=t.join(",")})),o(e)&&(e.sort&&(Array.isArray(e.sort)?i.sort=e.sort.join(","):i.sort=Object.entries(e.sort).map(([s,t])=>`${t==="desc"?"-":""}${s}`).join(",")),e.pageNumber&&(i["page[number]"]=String(e.pageNumber)),e.pageSize&&(i["page[size]"]=String(e.pageSize)),e.filters&&Object.entries(e.filters).forEach(([s,t])=>{i[`filter[q][${s}]`]=String(t)})),r("query string params: %O",i)),i};export{g as generateQueryStringParams};
@@ -1,4 +1,4 @@
1
- import { ApiClientConfig, ApiClientInitConfig } from './client';
1
+ import { ApiClientInitConfig } from './client';
2
2
  import { QueryParamsRetrieve, QueryParamsList } from './query';
3
3
  import { ResourceTypeLock } from './api';
4
4
  import { InterceptorManager } from './interceptor';
@@ -46,11 +46,12 @@ declare class ListResponse<R> extends Array<R> {
46
46
  export type { Metadata, ResourceType, ResourceId, Resource, ResourceCreate, ResourceUpdate, ListResponse };
47
47
  declare type ResourceAdapterConfig = {};
48
48
  declare type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
49
- declare type ResourcesConfig = ResourceAdapterConfig & ApiClientConfig;
49
+ declare type ResourcesConfig = Partial<ResourcesInitConfig>;
50
50
  declare class ResourceAdapter {
51
51
  #private;
52
52
  constructor(config: ResourcesInitConfig);
53
53
  get interceptors(): InterceptorManager;
54
+ private localConfig;
54
55
  config(config: ResourcesConfig): void;
55
56
  singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
56
57
  retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
@@ -64,6 +65,7 @@ declare abstract class ApiResource {
64
65
  protected resources: ResourceAdapter;
65
66
  constructor(adapter: ResourceAdapter);
66
67
  abstract relationship(id: string | ResourceId): ResourceId;
68
+ abstract type(): string;
67
69
  }
68
70
  export default ResourceAdapter;
69
71
  export { ApiResource, ResourcesConfig, ResourcesInitConfig };
@@ -1 +1 @@
1
- var f=this&&this.__classPrivateFieldSet||function(a,t,r,e,s){if(e==="m")throw new TypeError("Private method is not writable");if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?a!==t||!s:!t.has(a))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e==="a"?s.call(a,r):s?s.value=r:t.set(a,r),r},o=this&&this.__classPrivateFieldGet||function(a,t,r,e){if(r==="a"&&!e)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?a!==t||!e:!t.has(a))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?e:r==="a"?e.call(a):e?e.value:t.get(a)},n,p;import w from"./client";import{denormalize as l,normalize as h}from"./jsonapi";import{generateQueryStringParams as u}from"./query";import m from"./config";class b extends Array{constructor(t,r){super(...r||[]);this.meta=t}first(){return this.length?this[0]:void 0}last(){return this.length?this[this.length-1]:void 0}get(t){return this.length&&t>=0?this[t]:void 0}}class y{constructor(t){n.set(this,void 0),p.set(this,{}),f(this,n,w.create(t),"f"),this.config(t)}get interceptors(){return o(this,n,"f").interceptors}config(t){!t||o(this,n,"f").config(t)}async singleton(t,r,e){const s=u(r,t);(e==null?void 0:e.params)&&Object.assign(s,e==null?void 0:e.params);const i=await o(this,n,"f").request("get",`${t.type}`,void 0,Object.assign(Object.assign({},e),{params:s}));return l(i)}async retrieve(t,r,e){const s=u(r,t);(e==null?void 0:e.params)&&Object.assign(s,e==null?void 0:e.params);const i=await o(this,n,"f").request("get",`${t.type}/${t.id}`,void 0,Object.assign(Object.assign({},e),{params:s}));return l(i)}async list(t,r,e){var s,i;const c=u(r,t);(e==null?void 0:e.params)&&Object.assign(c,e==null?void 0:e.params);const d=await o(this,n,"f").request("get",`${t.type}`,void 0,Object.assign(Object.assign({},e),{params:c})),g=l(d),v={pageCount:Number((s=d.meta)===null||s===void 0?void 0:s.page_count),recordCount:Number((i=d.meta)===null||i===void 0?void 0:i.record_count),currentPage:(r==null?void 0:r.pageNumber)||m.default.pageNumber,recordsPerPage:(r==null?void 0:r.pageSize)||m.default.pageSize};return new b(v,g)}async create(t,r,e){const s=u(r,t);(e==null?void 0:e.params)&&Object.assign(s,e==null?void 0:e.params);const i=h(t),c=await o(this,n,"f").request("post",t.type,i,Object.assign(Object.assign({},e),{params:s}));return l(c)}async update(t,r,e){const s=u(r,t);(e==null?void 0:e.params)&&Object.assign(s,e==null?void 0:e.params);const i=h(t),c=await o(this,n,"f").request("patch",`${t.type}/${t.id}`,i,Object.assign(Object.assign({},e),{params:s}));return l(c)}async delete(t,r){await o(this,n,"f").request("delete",`${t.type}/${t.id}`,void 0,r)}}n=new WeakMap,p=new WeakMap;class j{constructor(t){this.resources=t}}export default y;export{j as ApiResource};
1
+ var w=this&&this.__classPrivateFieldSet||function(i,t,r,e,a){if(e==="m")throw new TypeError("Private method is not writable");if(e==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!a:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e==="a"?a.call(i,r):a?a.value=r:t.set(i,r),r},n=this&&this.__classPrivateFieldGet||function(i,t,r,e){if(r==="a"&&!e)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!e:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?e:r==="a"?e.call(i):e?e.value:t.get(i)},o,g;import O from"./client";import{denormalize as u,normalize as h}from"./jsonapi";import{generateQueryStringParams as d}from"./query";import m from"./config";import b from"./debug";const c=b();class y extends Array{constructor(t,r){super(...r||[]);this.meta=t}first(){return this.length?this[0]:void 0}last(){return this.length?this[this.length-1]:void 0}get(t){return this.length&&t>=0?this[t]:void 0}}class j{constructor(t){o.set(this,void 0),g.set(this,{}),w(this,o,O.create(t),"f"),this.localConfig(t)}get interceptors(){return n(this,o,"f").interceptors}localConfig(t){}config(t){c("config %o",t),this.localConfig(t),n(this,o,"f").config(t)}async singleton(t,r,e){c("singleton: %o, %O, %O",t,r||{},e||{});const a=d(r,t);(e==null?void 0:e.params)&&Object.assign(a,e==null?void 0:e.params);const s=await n(this,o,"f").request("get",`${t.type}`,void 0,Object.assign(Object.assign({},e),{params:a}));return u(s)}async retrieve(t,r,e){c("retrieve: %o, %O, %O",t,r||{},e||{});const a=d(r,t);(e==null?void 0:e.params)&&Object.assign(a,e==null?void 0:e.params);const s=await n(this,o,"f").request("get",`${t.type}/${t.id}`,void 0,Object.assign(Object.assign({},e),{params:a}));return u(s)}async list(t,r,e){var a,s;c("list: %o, %O, %O",t,r||{},e||{});const l=d(r,t);(e==null?void 0:e.params)&&Object.assign(l,e==null?void 0:e.params);const p=await n(this,o,"f").request("get",`${t.type}`,void 0,Object.assign(Object.assign({},e),{params:l})),f=u(p),v={pageCount:Number((a=p.meta)===null||a===void 0?void 0:a.page_count),recordCount:Number((s=p.meta)===null||s===void 0?void 0:s.record_count),currentPage:(r==null?void 0:r.pageNumber)||m.default.pageNumber,recordsPerPage:(r==null?void 0:r.pageSize)||m.default.pageSize};return new y(v,f)}async create(t,r,e){c("create: %o, %O, %O",t,r||{},e||{});const a=d(r,t);(e==null?void 0:e.params)&&Object.assign(a,e==null?void 0:e.params);const s=h(t),l=await n(this,o,"f").request("post",t.type,s,Object.assign(Object.assign({},e),{params:a}));return u(l)}async update(t,r,e){c("update: %o, %O, %O",t,r||{},e||{});const a=d(r,t);(e==null?void 0:e.params)&&Object.assign(a,e==null?void 0:e.params);const s=h(t),l=await n(this,o,"f").request("patch",`${t.type}/${t.id}`,s,Object.assign(Object.assign({},e),{params:a}));return u(l)}async delete(t,r){c("delete: %o, %O",t,r||{}),await n(this,o,"f").request("delete",`${t.type}/${t.id}`,void 0,r)}}o=new WeakMap,g=new WeakMap;class P{constructor(t){c("new resource instance: %s",this.type()),this.resources=t}}export default j;export{P as ApiResource};
@@ -18,7 +18,7 @@ interface AdyenPayment extends Resource {
18
18
  payment_gateway?: PaymentGateway;
19
19
  }
20
20
  interface AdyenPaymentCreate extends ResourceCreate {
21
- order?: OrderRel;
21
+ order: OrderRel;
22
22
  }
23
23
  interface AdyenPaymentUpdate extends ResourceUpdate {
24
24
  payment_request_data?: object;
@@ -133,7 +133,7 @@ interface AttachmentCreate extends ResourceCreate {
133
133
  name: string;
134
134
  description?: string;
135
135
  url?: string;
136
- attachable?: BundleRel | CarrierAccountRel | CustomerGroupRel | CustomerRel | DeliveryLeadTimeRel | GeocoderRel | GiftCardRecipientRel | GiftCardRel | InventoryModelRel | MarketRel | MerchantRel | BillingInfoValidationRuleRel | OrderRel | PackageRel | ParcelRel | PaymentMethodRel | PriceListRel | PriceRel | PromotionRel | ReturnRel | ShipmentRel | ShippingCategoryRel | ShippingMethodRel | ShippingZoneRel | SkuOptionRel | SkuRel | StockItemRel | StockLocationRel | TaxCalculatorRel | TaxCategoryRel;
136
+ attachable: BundleRel | CarrierAccountRel | CustomerGroupRel | CustomerRel | DeliveryLeadTimeRel | GeocoderRel | GiftCardRecipientRel | GiftCardRel | InventoryModelRel | MarketRel | MerchantRel | BillingInfoValidationRuleRel | OrderRel | PackageRel | ParcelRel | PaymentMethodRel | PriceListRel | PriceRel | PromotionRel | ReturnRel | ShipmentRel | ShippingCategoryRel | ShippingMethodRel | ShippingZoneRel | SkuOptionRel | SkuRel | StockItemRel | StockLocationRel | TaxCalculatorRel | TaxCategoryRel;
137
137
  }
138
138
  interface AttachmentUpdate extends ResourceUpdate {
139
139
  name?: string;
@@ -11,7 +11,7 @@ interface BillingInfoValidationRule extends Resource {
11
11
  market?: Market;
12
12
  }
13
13
  interface BillingInfoValidationRuleCreate extends ResourceCreate {
14
- market?: MarketRel;
14
+ market: MarketRel;
15
15
  }
16
16
  interface BillingInfoValidationRuleUpdate extends ResourceUpdate {
17
17
  market?: MarketRel;
@@ -21,7 +21,7 @@ interface BraintreePaymentCreate extends ResourceCreate {
21
21
  payment_id?: string;
22
22
  local?: boolean;
23
23
  options?: object;
24
- order?: OrderRel;
24
+ order: OrderRel;
25
25
  }
26
26
  interface BraintreePaymentUpdate extends ResourceUpdate {
27
27
  payment_method_nonce?: string;
@@ -39,7 +39,7 @@ interface BundleCreate extends ResourceCreate {
39
39
  compare_at_amount_cents: number;
40
40
  _compute_compare_at_amount?: boolean;
41
41
  market?: MarketRel;
42
- sku_list?: SkuListRel;
42
+ sku_list: SkuListRel;
43
43
  }
44
44
  interface BundleUpdate extends ResourceUpdate {
45
45
  code?: string;
@@ -23,7 +23,7 @@ interface CheckoutComPaymentCreate extends ResourceCreate {
23
23
  payment_type: string;
24
24
  token: string;
25
25
  session_id?: string;
26
- order?: OrderRel;
26
+ order: OrderRel;
27
27
  }
28
28
  interface CheckoutComPaymentUpdate extends ResourceUpdate {
29
29
  payment_type?: string;
@@ -36,7 +36,7 @@ interface CouponCodesPromotionRule extends Resource {
36
36
  coupons?: Coupon[];
37
37
  }
38
38
  interface CouponCodesPromotionRuleCreate extends ResourceCreate {
39
- promotion?: PercentageDiscountPromotionRel | FreeShippingPromotionRel | FixedAmountPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel;
39
+ promotion: PercentageDiscountPromotionRel | FreeShippingPromotionRel | FixedAmountPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel;
40
40
  coupons?: CouponRel[];
41
41
  }
42
42
  interface CouponCodesPromotionRuleUpdate extends ResourceUpdate {
@@ -20,7 +20,7 @@ interface CouponCreate extends ResourceCreate {
20
20
  customer_single_use?: boolean;
21
21
  usage_limit: number;
22
22
  recipient_email?: string;
23
- promotion_rule?: CouponCodesPromotionRuleRel;
23
+ promotion_rule: CouponCodesPromotionRuleRel;
24
24
  }
25
25
  interface CouponUpdate extends ResourceUpdate {
26
26
  code?: string;
@@ -17,8 +17,8 @@ interface CustomerAddress extends Resource {
17
17
  address?: Address;
18
18
  }
19
19
  interface CustomerAddressCreate extends ResourceCreate {
20
- customer?: CustomerRel;
21
- address?: AddressRel;
20
+ customer: CustomerRel;
21
+ address: AddressRel;
22
22
  }
23
23
  interface CustomerAddressUpdate extends ResourceUpdate {
24
24
  customer?: CustomerRel;
@@ -43,8 +43,8 @@ interface CustomerPaymentSource extends Resource {
43
43
  payment_source?: AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
44
44
  }
45
45
  interface CustomerPaymentSourceCreate extends ResourceCreate {
46
- customer?: CustomerRel;
47
- payment_source?: AdyenPaymentRel | BraintreePaymentRel | CheckoutComPaymentRel | ExternalPaymentRel | PaypalPaymentRel | StripePaymentRel | WireTransferRel;
46
+ customer: CustomerRel;
47
+ payment_source: AdyenPaymentRel | BraintreePaymentRel | CheckoutComPaymentRel | ExternalPaymentRel | PaypalPaymentRel | StripePaymentRel | WireTransferRel;
48
48
  }
49
49
  interface CustomerPaymentSourceUpdate extends ResourceUpdate {
50
50
  customer?: CustomerRel;
@@ -24,8 +24,8 @@ interface DeliveryLeadTime extends Resource {
24
24
  interface DeliveryLeadTimeCreate extends ResourceCreate {
25
25
  min_hours: number;
26
26
  max_hours: number;
27
- stock_location?: StockLocationRel;
28
- shipping_method?: ShippingMethodRel;
27
+ stock_location: StockLocationRel;
28
+ shipping_method: ShippingMethodRel;
29
29
  }
30
30
  interface DeliveryLeadTimeUpdate extends ResourceUpdate {
31
31
  min_hours?: number;
@@ -17,7 +17,7 @@ interface ExternalPayment extends Resource {
17
17
  interface ExternalPaymentCreate extends ResourceCreate {
18
18
  payment_source_token: string;
19
19
  options?: object;
20
- order?: OrderRel;
20
+ order: OrderRel;
21
21
  }
22
22
  interface ExternalPaymentUpdate extends ResourceUpdate {
23
23
  options?: object;
@@ -59,7 +59,7 @@ interface FixedPricePromotionCreate extends ResourceCreate {
59
59
  order_amount_promotion_rule?: OrderAmountPromotionRuleRel;
60
60
  sku_list_promotion_rule?: SkuListPromotionRuleRel;
61
61
  coupon_codes_promotion_rule?: CouponCodesPromotionRuleRel;
62
- sku_list?: SkuListRel;
62
+ sku_list: SkuListRel;
63
63
  }
64
64
  interface FixedPricePromotionUpdate extends ResourceUpdate {
65
65
  name?: string;
@@ -57,7 +57,7 @@ interface FreeGiftPromotionCreate extends ResourceCreate {
57
57
  order_amount_promotion_rule?: OrderAmountPromotionRuleRel;
58
58
  sku_list_promotion_rule?: SkuListPromotionRuleRel;
59
59
  coupon_codes_promotion_rule?: CouponCodesPromotionRuleRel;
60
- sku_list?: SkuListRel;
60
+ sku_list: SkuListRel;
61
61
  }
62
62
  interface FreeGiftPromotionUpdate extends ResourceUpdate {
63
63
  name?: string;
@@ -28,9 +28,9 @@ interface InStockSubscriptionCreate extends ResourceCreate {
28
28
  customer_email?: string;
29
29
  sku_code?: string;
30
30
  stock_threshold?: number;
31
- market?: MarketRel;
32
- customer?: CustomerRel;
33
- sku?: SkuRel;
31
+ market: MarketRel;
32
+ customer: CustomerRel;
33
+ sku: SkuRel;
34
34
  }
35
35
  interface InStockSubscriptionUpdate extends ResourceUpdate {
36
36
  sku_code?: string;
@@ -18,8 +18,8 @@ interface InventoryReturnLocation extends Resource {
18
18
  }
19
19
  interface InventoryReturnLocationCreate extends ResourceCreate {
20
20
  priority: number;
21
- stock_location?: StockLocationRel;
22
- inventory_model?: InventoryModelRel;
21
+ stock_location: StockLocationRel;
22
+ inventory_model: InventoryModelRel;
23
23
  }
24
24
  interface InventoryReturnLocationUpdate extends ResourceUpdate {
25
25
  priority?: number;
@@ -20,8 +20,8 @@ interface InventoryStockLocation extends Resource {
20
20
  interface InventoryStockLocationCreate extends ResourceCreate {
21
21
  priority: number;
22
22
  on_hold?: boolean;
23
- stock_location?: StockLocationRel;
24
- inventory_model?: InventoryModelRel;
23
+ stock_location: StockLocationRel;
24
+ inventory_model: InventoryModelRel;
25
25
  }
26
26
  interface InventoryStockLocationUpdate extends ResourceUpdate {
27
27
  priority?: number;
@@ -31,8 +31,8 @@ interface LineItemOptionCreate extends ResourceCreate {
31
31
  name?: string;
32
32
  quantity: number;
33
33
  options: object;
34
- line_item?: LineItemRel;
35
- sku_option?: SkuOptionRel;
34
+ line_item: LineItemRel;
35
+ sku_option: SkuOptionRel;
36
36
  }
37
37
  interface LineItemOptionUpdate extends ResourceUpdate {
38
38
  name?: string;
@@ -96,7 +96,7 @@ interface LineItemCreate extends ResourceCreate {
96
96
  name?: string;
97
97
  image_url?: string;
98
98
  item_type?: string;
99
- order?: OrderRel;
99
+ order: OrderRel;
100
100
  item?: AdjustmentRel | BundleRel | ExternalPromotionRel | FixedAmountPromotionRel | FreeShippingPromotionRel | GiftCardRel | PaymentMethodRel | PercentageDiscountPromotionRel | ShipmentRel | SkuRel;
101
101
  }
102
102
  interface LineItemUpdate extends ResourceUpdate {
@@ -43,9 +43,9 @@ interface MarketCreate extends ResourceCreate {
43
43
  facebook_pixel_id?: string;
44
44
  checkout_url?: string;
45
45
  external_prices_url?: string;
46
- merchant?: MerchantRel;
47
- price_list?: PriceListRel;
48
- inventory_model?: InventoryModelRel;
46
+ merchant: MerchantRel;
47
+ price_list: PriceListRel;
48
+ inventory_model: InventoryModelRel;
49
49
  tax_calculator?: TaxCalculatorRel;
50
50
  customer_group?: CustomerGroupRel;
51
51
  }
@@ -15,7 +15,7 @@ interface Merchant extends Resource {
15
15
  }
16
16
  interface MerchantCreate extends ResourceCreate {
17
17
  name: string;
18
- address?: AddressRel;
18
+ address: AddressRel;
19
19
  }
20
20
  interface MerchantUpdate extends ResourceUpdate {
21
21
  name?: string;
@@ -35,7 +35,7 @@ interface OrderAmountPromotionRule extends Resource {
35
35
  }
36
36
  interface OrderAmountPromotionRuleCreate extends ResourceCreate {
37
37
  order_amount_cents?: number;
38
- promotion?: PercentageDiscountPromotionRel | FreeShippingPromotionRel | FixedAmountPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel;
38
+ promotion: PercentageDiscountPromotionRel | FreeShippingPromotionRel | FixedAmountPromotionRel | FreeGiftPromotionRel | FixedPricePromotionRel | ExternalPromotionRel;
39
39
  }
40
40
  interface OrderAmountPromotionRuleUpdate extends ResourceUpdate {
41
41
  order_amount_cents?: number;
@@ -26,7 +26,7 @@ interface OrderCopyCreate extends ResourceCreate {
26
26
  place_target_order?: boolean;
27
27
  cancel_source_order?: boolean;
28
28
  reuse_wallet?: boolean;
29
- source_order?: OrderRel;
29
+ source_order: OrderRel;
30
30
  }
31
31
  declare class OrderCopies extends ApiResource {
32
32
  static readonly TYPE: 'order_copies';
@@ -39,7 +39,7 @@ interface OrderSubscriptionCreate extends ResourceCreate {
39
39
  expires_at?: string;
40
40
  options?: object;
41
41
  market?: MarketRel;
42
- source_order?: OrderRel;
42
+ source_order: OrderRel;
43
43
  }
44
44
  interface OrderSubscriptionUpdate extends ResourceUpdate {
45
45
  expires_at?: string;
@@ -27,7 +27,7 @@ interface PackageCreate extends ResourceCreate {
27
27
  width: number;
28
28
  height: number;
29
29
  unit_of_length: string;
30
- stock_location?: StockLocationRel;
30
+ stock_location: StockLocationRel;
31
31
  }
32
32
  interface PackageUpdate extends ResourceUpdate {
33
33
  name?: string;