@commercelayer/sdk 4.7.3 → 4.7.6

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 (230) hide show
  1. package/README.md +37 -24
  2. package/lib/cjs/api.d.ts +1 -103
  3. package/lib/cjs/client.d.ts +1 -31
  4. package/lib/cjs/commercelayer.d.ts +1 -122
  5. package/lib/cjs/common.d.ts +1 -4
  6. package/lib/cjs/config.d.ts +1 -11
  7. package/lib/cjs/debug.d.ts +1 -3
  8. package/lib/cjs/error.d.ts +1 -26
  9. package/lib/cjs/index.d.ts +1 -7
  10. package/lib/cjs/interceptor.d.ts +1 -19
  11. package/lib/cjs/jsonapi.d.ts +1 -5
  12. package/lib/cjs/jsonapi.js +1 -1
  13. package/lib/cjs/model.d.ts +1 -101
  14. package/lib/cjs/query.d.ts +1 -23
  15. package/lib/cjs/resource.d.ts +1 -76
  16. package/lib/cjs/resources/addresses.d.ts +1 -88
  17. package/lib/cjs/resources/adjustments.d.ts +1 -35
  18. package/lib/cjs/resources/adyen_gateways.d.ts +1 -47
  19. package/lib/cjs/resources/adyen_payments.d.ts +1 -44
  20. package/lib/cjs/resources/application.d.ts +1 -21
  21. package/lib/cjs/resources/attachments.d.ts +1 -156
  22. package/lib/cjs/resources/authorizations.d.ts +1 -57
  23. package/lib/cjs/resources/avalara_accounts.d.ts +1 -52
  24. package/lib/cjs/resources/billing_info_validation_rules.d.ts +1 -32
  25. package/lib/cjs/resources/bing_geocoders.d.ts +1 -35
  26. package/lib/cjs/resources/braintree_gateways.d.ts +1 -56
  27. package/lib/cjs/resources/braintree_payments.d.ts +1 -47
  28. package/lib/cjs/resources/bundles.d.ts +1 -74
  29. package/lib/cjs/resources/captures.d.ts +1 -48
  30. package/lib/cjs/resources/carrier_accounts.d.ts +1 -26
  31. package/lib/cjs/resources/checkout_com_gateways.d.ts +1 -45
  32. package/lib/cjs/resources/checkout_com_payments.d.ts +1 -51
  33. package/lib/cjs/resources/coupon_codes_promotion_rules.d.ts +1 -59
  34. package/lib/cjs/resources/coupon_recipients.d.ts +1 -44
  35. package/lib/cjs/resources/coupons.d.ts +1 -45
  36. package/lib/cjs/resources/customer_addresses.d.ts +1 -41
  37. package/lib/cjs/resources/customer_groups.d.ts +1 -36
  38. package/lib/cjs/resources/customer_password_resets.d.ts +1 -33
  39. package/lib/cjs/resources/customer_payment_sources.d.ts +1 -70
  40. package/lib/cjs/resources/customer_subscriptions.d.ts +1 -28
  41. package/lib/cjs/resources/customers.d.ts +1 -60
  42. package/lib/cjs/resources/delivery_lead_times.d.ts +1 -51
  43. package/lib/cjs/resources/event_callbacks.d.ts +1 -24
  44. package/lib/cjs/resources/external_gateways.d.ts +1 -49
  45. package/lib/cjs/resources/external_payments.d.ts +1 -43
  46. package/lib/cjs/resources/external_promotions.d.ts +1 -86
  47. package/lib/cjs/resources/external_tax_calculators.d.ts +1 -44
  48. package/lib/cjs/resources/fixed_amount_promotions.d.ts +1 -88
  49. package/lib/cjs/resources/fixed_price_promotions.d.ts +1 -99
  50. package/lib/cjs/resources/free_gift_promotions.d.ts +1 -97
  51. package/lib/cjs/resources/free_shipping_promotions.d.ts +1 -83
  52. package/lib/cjs/resources/geocoders.d.ts +1 -24
  53. package/lib/cjs/resources/gift_card_recipients.d.ts +1 -44
  54. package/lib/cjs/resources/gift_cards.d.ts +1 -82
  55. package/lib/cjs/resources/google_geocoders.d.ts +1 -35
  56. package/lib/cjs/resources/imports.d.ts +1 -40
  57. package/lib/cjs/resources/in_stock_subscriptions.d.ts +1 -59
  58. package/lib/cjs/resources/inventory_models.d.ts +1 -42
  59. package/lib/cjs/resources/inventory_return_locations.d.ts +1 -43
  60. package/lib/cjs/resources/inventory_stock_locations.d.ts +1 -46
  61. package/lib/cjs/resources/klarna_gateways.d.ts +1 -44
  62. package/lib/cjs/resources/klarna_payments.d.ts +1 -41
  63. package/lib/cjs/resources/line_item_options.d.ts +1 -57
  64. package/lib/cjs/resources/line_items.d.ts +1 -125
  65. package/lib/cjs/resources/manual_gateways.d.ts +1 -33
  66. package/lib/cjs/resources/manual_tax_calculators.d.ts +1 -49
  67. package/lib/cjs/resources/markets.d.ts +1 -81
  68. package/lib/cjs/resources/merchants.d.ts +1 -38
  69. package/lib/cjs/resources/order_amount_promotion_rules.d.ts +1 -56
  70. package/lib/cjs/resources/order_copies.d.ts +1 -45
  71. package/lib/cjs/resources/order_subscriptions.d.ts +1 -67
  72. package/lib/cjs/resources/order_validation_rules.d.ts +1 -20
  73. package/lib/cjs/resources/orders.d.ts +1 -271
  74. package/lib/cjs/resources/organization.d.ts +1 -32
  75. package/lib/cjs/resources/packages.d.ts +1 -56
  76. package/lib/cjs/resources/parcel_line_items.d.ts +1 -49
  77. package/lib/cjs/resources/parcels.d.ts +1 -108
  78. package/lib/cjs/resources/payment_gateways.d.ts +1 -21
  79. package/lib/cjs/resources/payment_methods.d.ts +1 -59
  80. package/lib/cjs/resources/paypal_gateways.d.ts +1 -39
  81. package/lib/cjs/resources/paypal_payments.d.ts +1 -49
  82. package/lib/cjs/resources/percentage_discount_promotions.d.ts +1 -97
  83. package/lib/cjs/resources/price_lists.d.ts +1 -39
  84. package/lib/cjs/resources/prices.d.ts +1 -57
  85. package/lib/cjs/resources/promotion_rules.d.ts +1 -24
  86. package/lib/cjs/resources/promotions.d.ts +1 -41
  87. package/lib/cjs/resources/refunds.d.ts +1 -34
  88. package/lib/cjs/resources/return_line_items.d.ts +1 -49
  89. package/lib/cjs/resources/returns.d.ts +1 -72
  90. package/lib/cjs/resources/shipments.d.ts +1 -89
  91. package/lib/cjs/resources/shipping_categories.d.ts +1 -33
  92. package/lib/cjs/resources/shipping_methods.d.ts +1 -74
  93. package/lib/cjs/resources/shipping_zones.d.ts +1 -48
  94. package/lib/cjs/resources/sku_list_items.d.ts +1 -47
  95. package/lib/cjs/resources/sku_list_promotion_rules.d.ts +1 -68
  96. package/lib/cjs/resources/sku_lists.d.ts +1 -49
  97. package/lib/cjs/resources/sku_options.d.ts +1 -56
  98. package/lib/cjs/resources/skus.d.ts +1 -78
  99. package/lib/cjs/resources/stock_items.d.ts +1 -49
  100. package/lib/cjs/resources/stock_line_items.d.ts +1 -29
  101. package/lib/cjs/resources/stock_locations.d.ts +1 -57
  102. package/lib/cjs/resources/stock_transfers.d.ts +1 -71
  103. package/lib/cjs/resources/stripe_gateways.d.ts +1 -38
  104. package/lib/cjs/resources/stripe_payments.d.ts +1 -42
  105. package/lib/cjs/resources/tax_calculators.d.ts +1 -27
  106. package/lib/cjs/resources/tax_categories.d.ts +1 -59
  107. package/lib/cjs/resources/tax_rules.d.ts +1 -69
  108. package/lib/cjs/resources/taxjar_accounts.d.ts +1 -43
  109. package/lib/cjs/resources/transactions.d.ts +1 -31
  110. package/lib/cjs/resources/voids.d.ts +1 -34
  111. package/lib/cjs/resources/webhooks.d.ts +1 -42
  112. package/lib/cjs/resources/wire_transfers.d.ts +1 -32
  113. package/lib/cjs/static.d.ts +1 -6
  114. package/lib/cjs/util.d.ts +1 -2
  115. package/lib/esm/api.d.ts +1 -103
  116. package/lib/esm/client.d.ts +1 -31
  117. package/lib/esm/commercelayer.d.ts +1 -122
  118. package/lib/esm/common.d.ts +1 -4
  119. package/lib/esm/config.d.ts +1 -11
  120. package/lib/esm/debug.d.ts +1 -3
  121. package/lib/esm/error.d.ts +1 -26
  122. package/lib/esm/index.d.ts +1 -7
  123. package/lib/esm/interceptor.d.ts +1 -19
  124. package/lib/esm/jsonapi.d.ts +1 -5
  125. package/lib/esm/jsonapi.js +1 -1
  126. package/lib/esm/model.d.ts +1 -101
  127. package/lib/esm/query.d.ts +1 -23
  128. package/lib/esm/resource.d.ts +1 -76
  129. package/lib/esm/resources/addresses.d.ts +1 -88
  130. package/lib/esm/resources/adjustments.d.ts +1 -35
  131. package/lib/esm/resources/adyen_gateways.d.ts +1 -47
  132. package/lib/esm/resources/adyen_payments.d.ts +1 -44
  133. package/lib/esm/resources/application.d.ts +1 -21
  134. package/lib/esm/resources/attachments.d.ts +1 -156
  135. package/lib/esm/resources/authorizations.d.ts +1 -57
  136. package/lib/esm/resources/avalara_accounts.d.ts +1 -52
  137. package/lib/esm/resources/billing_info_validation_rules.d.ts +1 -32
  138. package/lib/esm/resources/bing_geocoders.d.ts +1 -35
  139. package/lib/esm/resources/braintree_gateways.d.ts +1 -56
  140. package/lib/esm/resources/braintree_payments.d.ts +1 -47
  141. package/lib/esm/resources/bundles.d.ts +1 -74
  142. package/lib/esm/resources/captures.d.ts +1 -48
  143. package/lib/esm/resources/carrier_accounts.d.ts +1 -26
  144. package/lib/esm/resources/checkout_com_gateways.d.ts +1 -45
  145. package/lib/esm/resources/checkout_com_payments.d.ts +1 -51
  146. package/lib/esm/resources/coupon_codes_promotion_rules.d.ts +1 -59
  147. package/lib/esm/resources/coupon_recipients.d.ts +1 -44
  148. package/lib/esm/resources/coupons.d.ts +1 -45
  149. package/lib/esm/resources/customer_addresses.d.ts +1 -41
  150. package/lib/esm/resources/customer_groups.d.ts +1 -36
  151. package/lib/esm/resources/customer_password_resets.d.ts +1 -33
  152. package/lib/esm/resources/customer_payment_sources.d.ts +1 -70
  153. package/lib/esm/resources/customer_subscriptions.d.ts +1 -28
  154. package/lib/esm/resources/customers.d.ts +1 -60
  155. package/lib/esm/resources/delivery_lead_times.d.ts +1 -51
  156. package/lib/esm/resources/event_callbacks.d.ts +1 -24
  157. package/lib/esm/resources/external_gateways.d.ts +1 -49
  158. package/lib/esm/resources/external_payments.d.ts +1 -43
  159. package/lib/esm/resources/external_promotions.d.ts +1 -86
  160. package/lib/esm/resources/external_tax_calculators.d.ts +1 -44
  161. package/lib/esm/resources/fixed_amount_promotions.d.ts +1 -88
  162. package/lib/esm/resources/fixed_price_promotions.d.ts +1 -99
  163. package/lib/esm/resources/free_gift_promotions.d.ts +1 -97
  164. package/lib/esm/resources/free_shipping_promotions.d.ts +1 -83
  165. package/lib/esm/resources/geocoders.d.ts +1 -24
  166. package/lib/esm/resources/gift_card_recipients.d.ts +1 -44
  167. package/lib/esm/resources/gift_cards.d.ts +1 -82
  168. package/lib/esm/resources/google_geocoders.d.ts +1 -35
  169. package/lib/esm/resources/imports.d.ts +1 -40
  170. package/lib/esm/resources/in_stock_subscriptions.d.ts +1 -59
  171. package/lib/esm/resources/inventory_models.d.ts +1 -42
  172. package/lib/esm/resources/inventory_return_locations.d.ts +1 -43
  173. package/lib/esm/resources/inventory_stock_locations.d.ts +1 -46
  174. package/lib/esm/resources/klarna_gateways.d.ts +1 -44
  175. package/lib/esm/resources/klarna_payments.d.ts +1 -41
  176. package/lib/esm/resources/line_item_options.d.ts +1 -57
  177. package/lib/esm/resources/line_items.d.ts +1 -125
  178. package/lib/esm/resources/manual_gateways.d.ts +1 -33
  179. package/lib/esm/resources/manual_tax_calculators.d.ts +1 -49
  180. package/lib/esm/resources/markets.d.ts +1 -81
  181. package/lib/esm/resources/merchants.d.ts +1 -38
  182. package/lib/esm/resources/order_amount_promotion_rules.d.ts +1 -56
  183. package/lib/esm/resources/order_copies.d.ts +1 -45
  184. package/lib/esm/resources/order_subscriptions.d.ts +1 -67
  185. package/lib/esm/resources/order_validation_rules.d.ts +1 -20
  186. package/lib/esm/resources/orders.d.ts +1 -271
  187. package/lib/esm/resources/organization.d.ts +1 -32
  188. package/lib/esm/resources/packages.d.ts +1 -56
  189. package/lib/esm/resources/parcel_line_items.d.ts +1 -49
  190. package/lib/esm/resources/parcels.d.ts +1 -108
  191. package/lib/esm/resources/payment_gateways.d.ts +1 -21
  192. package/lib/esm/resources/payment_methods.d.ts +1 -59
  193. package/lib/esm/resources/paypal_gateways.d.ts +1 -39
  194. package/lib/esm/resources/paypal_payments.d.ts +1 -49
  195. package/lib/esm/resources/percentage_discount_promotions.d.ts +1 -97
  196. package/lib/esm/resources/price_lists.d.ts +1 -39
  197. package/lib/esm/resources/prices.d.ts +1 -57
  198. package/lib/esm/resources/promotion_rules.d.ts +1 -24
  199. package/lib/esm/resources/promotions.d.ts +1 -41
  200. package/lib/esm/resources/refunds.d.ts +1 -34
  201. package/lib/esm/resources/return_line_items.d.ts +1 -49
  202. package/lib/esm/resources/returns.d.ts +1 -72
  203. package/lib/esm/resources/shipments.d.ts +1 -89
  204. package/lib/esm/resources/shipping_categories.d.ts +1 -33
  205. package/lib/esm/resources/shipping_methods.d.ts +1 -74
  206. package/lib/esm/resources/shipping_zones.d.ts +1 -48
  207. package/lib/esm/resources/sku_list_items.d.ts +1 -47
  208. package/lib/esm/resources/sku_list_promotion_rules.d.ts +1 -68
  209. package/lib/esm/resources/sku_lists.d.ts +1 -49
  210. package/lib/esm/resources/sku_options.d.ts +1 -56
  211. package/lib/esm/resources/skus.d.ts +1 -78
  212. package/lib/esm/resources/stock_items.d.ts +1 -49
  213. package/lib/esm/resources/stock_line_items.d.ts +1 -29
  214. package/lib/esm/resources/stock_locations.d.ts +1 -57
  215. package/lib/esm/resources/stock_transfers.d.ts +1 -71
  216. package/lib/esm/resources/stripe_gateways.d.ts +1 -38
  217. package/lib/esm/resources/stripe_payments.d.ts +1 -42
  218. package/lib/esm/resources/tax_calculators.d.ts +1 -27
  219. package/lib/esm/resources/tax_categories.d.ts +1 -59
  220. package/lib/esm/resources/tax_rules.d.ts +1 -69
  221. package/lib/esm/resources/taxjar_accounts.d.ts +1 -43
  222. package/lib/esm/resources/transactions.d.ts +1 -31
  223. package/lib/esm/resources/voids.d.ts +1 -34
  224. package/lib/esm/resources/webhooks.d.ts +1 -42
  225. package/lib/esm/resources/wire_transfers.d.ts +1 -32
  226. package/lib/esm/static.d.ts +1 -6
  227. package/lib/esm/util.d.ts +1 -2
  228. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  229. package/lib/tsconfig.tsbuildinfo +1 -1
  230. package/package.json +4 -6
package/README.md CHANGED
@@ -25,7 +25,7 @@ To get started with Commerce Layer JS SDK you need to install it and then get th
25
25
 
26
26
  Commerce Layer JS SDK is available as an [npm package](https://www.npmjs.com/package/@commercelayer/sdk):
27
27
 
28
- ```
28
+ ```shell
29
29
  // npm
30
30
  npm install @commercelayer/sdk
31
31
 
@@ -35,7 +35,9 @@ yarn add @commercelayer/sdk
35
35
 
36
36
  ## Authentication
37
37
 
38
- All requests to Commerce Layer API must be authenticated with an [OAuth2](https://oauth.net/2/) bearer token. Hence, before starting to use this SDK you need to get a valid access token. Check [our documentation](https://docs.commercelayer.io/developers/authentication) for more information about the available authorization flows.
38
+ All requests to Commerce Layer API must be authenticated with an [OAuth2](https://oauth.net/2/) bearer token.
39
+ Hence, before starting to use this SDK you need to get a valid access token.
40
+ Check [our documentation](https://docs.commercelayer.io/developers/authentication) for more information about the available authorization flows.
39
41
 
40
42
  > Feel free to use [Commerce Layer JS Auth](https://github.com/commercelayer/commercelayer-js-auth), a JavaScript library that helps you wrap our authentication API.
41
43
 
@@ -43,7 +45,7 @@ All requests to Commerce Layer API must be authenticated with an [OAuth2](https:
43
45
 
44
46
  You can use the ES6 default import with the SDK as follow:
45
47
 
46
- ```
48
+ ```typescript
47
49
  import CommerceLayer from '@commercelayer/sdk'
48
50
 
49
51
  const cl = CommerceLayer({
@@ -52,38 +54,47 @@ const cl = CommerceLayer({
52
54
  })
53
55
  ```
54
56
 
55
- > In the following examples, we will use only the the specific resources we're going to access (SKUs and shipping categories). Check our [API reference](https://docs.commercelayer.io/developers/v/api-reference/) for the complete list of available resources and their attributes.
57
+ > In the following examples, we will use only the the specific resources we're going to access (SKUs and shipping categories).
58
+ Check our [API reference](https://docs.commercelayer.io/developers/v/api-reference/) for the complete list of available
59
+ resources and their attributes.
56
60
 
57
61
  # Usage
58
62
 
59
63
  The code snippets below show how to use the Commerce Layer JS SDK when performing the standard CRUD operations provided by our REST API on the SKU resource.
60
64
 
61
65
  - ### Create
66
+
62
67
  - [How to create an SKU](#how-to-create-an-sku)
68
+
63
69
  - ### Retrieve / List
70
+
64
71
  - [How to fetch a single SKU](#how-to-fetch-a-single-sku)
65
72
  - [How to fetch a collection of SKUs](#how-to-fetch-a-collection-of-skus)
66
73
  - [How to paginate a collection of SKUs](#how-to-paginate-a-collection-of-skus)
67
74
  - [How to iterate through a collection of SKUs](#how-to-iterate-through-a-collection-of-skus)
68
75
  <!-- - [How to build complex queries](#how-to-build-complex-queries) -->
69
76
  - [How to fetch resource relationships](#how-to-fetch-resource-relationships)
77
+
70
78
  - ### Update
79
+
71
80
  - [How to update an existing SKU](#how-to-update-an-existing-sku)
81
+
72
82
  - ### Delete
83
+
73
84
  - [How to delete an existing SKU](#how-to-delete-an-existing-sku)
74
85
 
75
86
  ## Create
76
87
 
77
88
  ### How to create an SKU
78
89
 
79
- ```
90
+ ```typescript
80
91
  // selects the shipping category (it's a required relationship for the SKU resource)
81
92
  const shippingCategories = await cl.shipping_categories.list({ filters: { name_eq: 'Merchandising' } })
82
93
 
83
94
  const attributes = {
84
- code: 'TSHIRTMM000000FFFFFFXL',
85
- name: 'Black Men T-shirt with White Logo (XL)',
86
- shipping_category: cl.shipping_categories.relationship(shippingCategories[0].id), // assigns the relationship
95
+ code: 'TSHIRTMM000000FFFFFFXL',
96
+ name: 'Black Men T-shirt with White Logo (XL)',
97
+ shipping_category: cl.shipping_categories.relationship(shippingCategories[0].id), // assigns the relationship
87
98
  }
88
99
 
89
100
  const newSku = await cl.skus.create(attributes)
@@ -95,7 +106,7 @@ Check our API reference for more information on how to [create an SKU](https://d
95
106
 
96
107
  ### How to fetch a single SKU
97
108
 
98
- ```
109
+ ```typescript
99
110
  // Fetches the SKU by ID
100
111
  const sku = await cl.skus.retrieve('BxAkSVqKEn')
101
112
 
@@ -113,7 +124,7 @@ Check our API reference for more information on how to [retrieve an SKU](https:/
113
124
 
114
125
  ### How to fetch a collection of SKUs
115
126
 
116
- ```
127
+ ```typescript
117
128
  // LISTING RESULTS
118
129
 
119
130
  // Fetches all the SKUs
@@ -152,18 +163,21 @@ Check our API reference for more information on how to [retrieve an SKU](https:/
152
163
  const skus = await cl.skus.list({ filters: { name_cont: 'White Logo' } })
153
164
 
154
165
  // Filters all the SKUs fetching only the ones created between two specific dates
155
- const skus = await cl.skus.list({ filters: { created_at_gt: '2018-01-01', created_at_lt: '2018-01-31'} }) // filters combined according to an AND logic
166
+ // (filters combined according to an AND logic)
167
+ const skus = await cl.skus.list({ filters: { created_at_gt: '2018-01-01', created_at_lt: '2018-01-31'} })
156
168
 
157
169
  // Filters all the SKUs fetching only the ones created or updated after a specific date
158
- const skus = await cl.skus.list({ filters: { updated_at_or_created_at_gt: '2019-10-10' } }) // attributes combined according to an OR logic
170
+ // (attributes combined according to an OR logic)
171
+ const skus = await cl.skus.list({ filters: { updated_at_or_created_at_gt: '2019-10-10' } })
159
172
 
160
- // Filters all the SKUs fetching only the ones whose name contains the string "Black" and whose shipping category name starts with the string "MERCH"
173
+ // Filters all the SKUs fetching only the ones whose name contains the string "Black" and whose shipping category
174
+ // name starts with the string "MERCH"
161
175
  const skus = await cl.skus.list({ filters: { name_cont: 'Black', shipping_category_name_start: 'MERCH'} })
162
176
  ```
163
177
 
164
178
  When fetching a collection of resources you can leverage the `meta` attribute to get its `meta` information:
165
179
 
166
- ```
180
+ ```typescript
167
181
  const skus = await cl.skus.list()
168
182
  const meta = skus.meta
169
183
  ```
@@ -174,7 +188,7 @@ Check our API reference for more information on how to [list all SKUs](https://d
174
188
 
175
189
  When you fetch a collection of resources, you get paginated results:
176
190
 
177
- ```
191
+ ```typescript
178
192
  // Fetches the SKUs, setting the page number to 3 and the page size to 5
179
193
  const skus = await cl.skus.list({ pageNumber: 3, pageSize: 5 })
180
194
 
@@ -193,19 +207,18 @@ Check our API reference for more information on how [pagination](https://docs.co
193
207
 
194
208
  To execute a function for every item of a collection, use the `map()` method:
195
209
 
196
- ```
210
+ ```typescript
197
211
  // Fetches the whole list of SKUs (1st page) and prints their names and codes to console
198
212
  const skus = await cl.skus.list()
199
213
  skus.map(p => console.log('Product: ' + p.name + ' - Code: ' + p.code))
200
214
  ```
201
215
 
202
-
203
216
  ### How to fetch resource relationships
204
217
 
205
218
  Many resources have relationships with other resources and instead of including these associations as seen above, you can fetch them directly.
206
219
  In this way, in case of 1-to-N relationship, you can filter or sort the resulting collection as for standard resources.
207
220
 
208
- ```
221
+ ```typescript
209
222
  // Fetches 1-to-1 related resource: billing address of an order
210
223
  const billingAddress = cl.orders.billing_address('xYZkjABcde')
211
224
 
@@ -213,12 +226,11 @@ const billingAddress = cl.orders.billing_address('xYZkjABcde')
213
226
  const orders = cl.customers.orders('XyzKjAbCDe', { fields: ['status', 'number'] })
214
227
  ```
215
228
 
216
-
217
229
  ## Update
218
230
 
219
231
  ### How to update an existing SKU
220
232
 
221
- ```
233
+ ```typescript
222
234
  const sku = {
223
235
  id: 'xYZkjABcde',
224
236
  description: 'Updated description.',
@@ -234,7 +246,7 @@ Check our API reference for more information on how to [update an SKU](https://d
234
246
 
235
247
  ### How to delete an existing SKU
236
248
 
237
- ```
249
+ ```typescript
238
250
  cl.skus.delete('xYZkjABcde') // persisted deletion
239
251
  ```
240
252
 
@@ -242,9 +254,10 @@ Check our API reference for more information on how to [delete an SKU](https://d
242
254
 
243
255
  # Overriding credentials
244
256
 
245
- If needed, Commerce Layer JS SDK lets you change the client configuration set it at a request level. To do that, just use the `config()` method or pass the `options` parameter and authenticate the API call with the desired credentials:
257
+ If needed, Commerce Layer JS SDK lets you change the client configuration set it at a request level.
258
+ To do that, just use the `config()` method or pass the `options` parameter and authenticate the API call with the desired credentials:
246
259
 
247
- ```
260
+ ```typescript
248
261
  // Permanently change configuration at client level
249
262
  cl.config({ organization: 'you-organization-slug', accessToken: 'your-access-token' })
250
263
  const skus = await cl.skus.list()
@@ -259,7 +272,7 @@ If needed, Commerce Layer JS SDK lets you change the client configuration set it
259
272
 
260
273
  Commerce Layer API returns specific errors (with extra information) on each attribute of a single resource. You can inspect them to properly handle validation errors (if any). To do that, use the `errors` attribute of the catched error:
261
274
 
262
- ```
275
+ ```typescript
263
276
  // logs error messages to console:
264
277
 
265
278
  const attributes = { code: 'TSHIRTMM000000FFFFFFXL', name: '' }
package/lib/cjs/api.d.ts CHANGED
@@ -1,103 +1 @@
1
- /**
2
- * ©2022 Commerce Layer Inc.
3
- * OpenAPI schema, version 2.9.0
4
- **/
5
- export { default as Addresses } from './resources/addresses';
6
- export { default as Adjustments } from './resources/adjustments';
7
- export { default as AdyenGateways } from './resources/adyen_gateways';
8
- export { default as AdyenPayments } from './resources/adyen_payments';
9
- export { default as Applications } from './resources/application';
10
- export { default as Attachments } from './resources/attachments';
11
- export { default as Authorizations } from './resources/authorizations';
12
- export { default as AvalaraAccounts } from './resources/avalara_accounts';
13
- export { default as BillingInfoValidationRules } from './resources/billing_info_validation_rules';
14
- export { default as BingGeocoders } from './resources/bing_geocoders';
15
- export { default as BraintreeGateways } from './resources/braintree_gateways';
16
- export { default as BraintreePayments } from './resources/braintree_payments';
17
- export { default as Bundles } from './resources/bundles';
18
- export { default as Captures } from './resources/captures';
19
- export { default as CarrierAccounts } from './resources/carrier_accounts';
20
- export { default as CheckoutComGateways } from './resources/checkout_com_gateways';
21
- export { default as CheckoutComPayments } from './resources/checkout_com_payments';
22
- export { default as CouponCodesPromotionRules } from './resources/coupon_codes_promotion_rules';
23
- export { default as CouponRecipients } from './resources/coupon_recipients';
24
- export { default as Coupons } from './resources/coupons';
25
- export { default as CustomerAddresses } from './resources/customer_addresses';
26
- export { default as CustomerGroups } from './resources/customer_groups';
27
- export { default as CustomerPasswordResets } from './resources/customer_password_resets';
28
- export { default as CustomerPaymentSources } from './resources/customer_payment_sources';
29
- export { default as CustomerSubscriptions } from './resources/customer_subscriptions';
30
- export { default as Customers } from './resources/customers';
31
- export { default as DeliveryLeadTimes } from './resources/delivery_lead_times';
32
- export { default as EventCallbacks } from './resources/event_callbacks';
33
- export { default as ExternalGateways } from './resources/external_gateways';
34
- export { default as ExternalPayments } from './resources/external_payments';
35
- export { default as ExternalPromotions } from './resources/external_promotions';
36
- export { default as ExternalTaxCalculators } from './resources/external_tax_calculators';
37
- export { default as FixedAmountPromotions } from './resources/fixed_amount_promotions';
38
- export { default as FixedPricePromotions } from './resources/fixed_price_promotions';
39
- export { default as FreeGiftPromotions } from './resources/free_gift_promotions';
40
- export { default as FreeShippingPromotions } from './resources/free_shipping_promotions';
41
- export { default as Geocoders } from './resources/geocoders';
42
- export { default as GiftCardRecipients } from './resources/gift_card_recipients';
43
- export { default as GiftCards } from './resources/gift_cards';
44
- export { default as GoogleGeocoders } from './resources/google_geocoders';
45
- export { default as Imports } from './resources/imports';
46
- export { default as InStockSubscriptions } from './resources/in_stock_subscriptions';
47
- export { default as InventoryModels } from './resources/inventory_models';
48
- export { default as InventoryReturnLocations } from './resources/inventory_return_locations';
49
- export { default as InventoryStockLocations } from './resources/inventory_stock_locations';
50
- export { default as KlarnaGateways } from './resources/klarna_gateways';
51
- export { default as KlarnaPayments } from './resources/klarna_payments';
52
- export { default as LineItemOptions } from './resources/line_item_options';
53
- export { default as LineItems } from './resources/line_items';
54
- export { default as ManualGateways } from './resources/manual_gateways';
55
- export { default as ManualTaxCalculators } from './resources/manual_tax_calculators';
56
- export { default as Markets } from './resources/markets';
57
- export { default as Merchants } from './resources/merchants';
58
- export { default as OrderAmountPromotionRules } from './resources/order_amount_promotion_rules';
59
- export { default as OrderCopies } from './resources/order_copies';
60
- export { default as OrderSubscriptions } from './resources/order_subscriptions';
61
- export { default as OrderValidationRules } from './resources/order_validation_rules';
62
- export { default as Orders } from './resources/orders';
63
- export { default as Organizations } from './resources/organization';
64
- export { default as Packages } from './resources/packages';
65
- export { default as ParcelLineItems } from './resources/parcel_line_items';
66
- export { default as Parcels } from './resources/parcels';
67
- export { default as PaymentGateways } from './resources/payment_gateways';
68
- export { default as PaymentMethods } from './resources/payment_methods';
69
- export { default as PaypalGateways } from './resources/paypal_gateways';
70
- export { default as PaypalPayments } from './resources/paypal_payments';
71
- export { default as PercentageDiscountPromotions } from './resources/percentage_discount_promotions';
72
- export { default as PriceLists } from './resources/price_lists';
73
- export { default as Prices } from './resources/prices';
74
- export { default as PromotionRules } from './resources/promotion_rules';
75
- export { default as Promotions } from './resources/promotions';
76
- export { default as Refunds } from './resources/refunds';
77
- export { default as ReturnLineItems } from './resources/return_line_items';
78
- export { default as Returns } from './resources/returns';
79
- export { default as Shipments } from './resources/shipments';
80
- export { default as ShippingCategories } from './resources/shipping_categories';
81
- export { default as ShippingMethods } from './resources/shipping_methods';
82
- export { default as ShippingZones } from './resources/shipping_zones';
83
- export { default as SkuListItems } from './resources/sku_list_items';
84
- export { default as SkuListPromotionRules } from './resources/sku_list_promotion_rules';
85
- export { default as SkuLists } from './resources/sku_lists';
86
- export { default as SkuOptions } from './resources/sku_options';
87
- export { default as Skus } from './resources/skus';
88
- export { default as StockItems } from './resources/stock_items';
89
- export { default as StockLineItems } from './resources/stock_line_items';
90
- export { default as StockLocations } from './resources/stock_locations';
91
- export { default as StockTransfers } from './resources/stock_transfers';
92
- export { default as StripeGateways } from './resources/stripe_gateways';
93
- export { default as StripePayments } from './resources/stripe_payments';
94
- export { default as TaxCalculators } from './resources/tax_calculators';
95
- export { default as TaxCategories } from './resources/tax_categories';
96
- export { default as TaxRules } from './resources/tax_rules';
97
- export { default as TaxjarAccounts } from './resources/taxjar_accounts';
98
- export { default as Transactions } from './resources/transactions';
99
- export { default as Voids } from './resources/voids';
100
- export { default as Webhooks } from './resources/webhooks';
101
- export { default as WireTransfers } from './resources/wire_transfers';
102
- 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' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'event_callbacks' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'geocoders' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_subscriptions' | 'order_validation_rules' | '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';
103
- 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", "coupon_recipients", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "event_callbacks", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "fixed_price_promotions", "free_gift_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "klarna_gateways", "klarna_payments", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_subscriptions", "order_validation_rules", "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"];
1
+ export{default as Addresses}from'./resources/addresses';export{default as Adjustments}from'./resources/adjustments';export{default as AdyenGateways}from'./resources/adyen_gateways';export{default as AdyenPayments}from'./resources/adyen_payments';export{default as Applications}from'./resources/application';export{default as Attachments}from'./resources/attachments';export{default as Authorizations}from'./resources/authorizations';export{default as AvalaraAccounts}from'./resources/avalara_accounts';export{default as BillingInfoValidationRules}from'./resources/billing_info_validation_rules';export{default as BingGeocoders}from'./resources/bing_geocoders';export{default as BraintreeGateways}from'./resources/braintree_gateways';export{default as BraintreePayments}from'./resources/braintree_payments';export{default as Bundles}from'./resources/bundles';export{default as Captures}from'./resources/captures';export{default as CarrierAccounts}from'./resources/carrier_accounts';export{default as CheckoutComGateways}from'./resources/checkout_com_gateways';export{default as CheckoutComPayments}from'./resources/checkout_com_payments';export{default as CouponCodesPromotionRules}from'./resources/coupon_codes_promotion_rules';export{default as CouponRecipients}from'./resources/coupon_recipients';export{default as Coupons}from'./resources/coupons';export{default as CustomerAddresses}from'./resources/customer_addresses';export{default as CustomerGroups}from'./resources/customer_groups';export{default as CustomerPasswordResets}from'./resources/customer_password_resets';export{default as CustomerPaymentSources}from'./resources/customer_payment_sources';export{default as CustomerSubscriptions}from'./resources/customer_subscriptions';export{default as Customers}from'./resources/customers';export{default as DeliveryLeadTimes}from'./resources/delivery_lead_times';export{default as EventCallbacks}from'./resources/event_callbacks';export{default as ExternalGateways}from'./resources/external_gateways';export{default as ExternalPayments}from'./resources/external_payments';export{default as ExternalPromotions}from'./resources/external_promotions';export{default as ExternalTaxCalculators}from'./resources/external_tax_calculators';export{default as FixedAmountPromotions}from'./resources/fixed_amount_promotions';export{default as FixedPricePromotions}from'./resources/fixed_price_promotions';export{default as FreeGiftPromotions}from'./resources/free_gift_promotions';export{default as FreeShippingPromotions}from'./resources/free_shipping_promotions';export{default as Geocoders}from'./resources/geocoders';export{default as GiftCardRecipients}from'./resources/gift_card_recipients';export{default as GiftCards}from'./resources/gift_cards';export{default as GoogleGeocoders}from'./resources/google_geocoders';export{default as Imports}from'./resources/imports';export{default as InStockSubscriptions}from'./resources/in_stock_subscriptions';export{default as InventoryModels}from'./resources/inventory_models';export{default as InventoryReturnLocations}from'./resources/inventory_return_locations';export{default as InventoryStockLocations}from'./resources/inventory_stock_locations';export{default as KlarnaGateways}from'./resources/klarna_gateways';export{default as KlarnaPayments}from'./resources/klarna_payments';export{default as LineItemOptions}from'./resources/line_item_options';export{default as LineItems}from'./resources/line_items';export{default as ManualGateways}from'./resources/manual_gateways';export{default as ManualTaxCalculators}from'./resources/manual_tax_calculators';export{default as Markets}from'./resources/markets';export{default as Merchants}from'./resources/merchants';export{default as OrderAmountPromotionRules}from'./resources/order_amount_promotion_rules';export{default as OrderCopies}from'./resources/order_copies';export{default as OrderSubscriptions}from'./resources/order_subscriptions';export{default as OrderValidationRules}from'./resources/order_validation_rules';export{default as Orders}from'./resources/orders';export{default as Organizations}from'./resources/organization';export{default as Packages}from'./resources/packages';export{default as ParcelLineItems}from'./resources/parcel_line_items';export{default as Parcels}from'./resources/parcels';export{default as PaymentGateways}from'./resources/payment_gateways';export{default as PaymentMethods}from'./resources/payment_methods';export{default as PaypalGateways}from'./resources/paypal_gateways';export{default as PaypalPayments}from'./resources/paypal_payments';export{default as PercentageDiscountPromotions}from'./resources/percentage_discount_promotions';export{default as PriceLists}from'./resources/price_lists';export{default as Prices}from'./resources/prices';export{default as PromotionRules}from'./resources/promotion_rules';export{default as Promotions}from'./resources/promotions';export{default as Refunds}from'./resources/refunds';export{default as ReturnLineItems}from'./resources/return_line_items';export{default as Returns}from'./resources/returns';export{default as Shipments}from'./resources/shipments';export{default as ShippingCategories}from'./resources/shipping_categories';export{default as ShippingMethods}from'./resources/shipping_methods';export{default as ShippingZones}from'./resources/shipping_zones';export{default as SkuListItems}from'./resources/sku_list_items';export{default as SkuListPromotionRules}from'./resources/sku_list_promotion_rules';export{default as SkuLists}from'./resources/sku_lists';export{default as SkuOptions}from'./resources/sku_options';export{default as Skus}from'./resources/skus';export{default as StockItems}from'./resources/stock_items';export{default as StockLineItems}from'./resources/stock_line_items';export{default as StockLocations}from'./resources/stock_locations';export{default as StockTransfers}from'./resources/stock_transfers';export{default as StripeGateways}from'./resources/stripe_gateways';export{default as StripePayments}from'./resources/stripe_payments';export{default as TaxCalculators}from'./resources/tax_calculators';export{default as TaxCategories}from'./resources/tax_categories';export{default as TaxRules}from'./resources/tax_rules';export{default as TaxjarAccounts}from'./resources/taxjar_accounts';export{default as Transactions}from'./resources/transactions';export{default as Voids}from'./resources/voids';export{default as Webhooks}from'./resources/webhooks';export{default as WireTransfers}from'./resources/wire_transfers';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'|'coupon_recipients'|'coupons'|'customer_addresses'|'customer_groups'|'customer_password_resets'|'customer_payment_sources'|'customer_subscriptions'|'customers'|'delivery_lead_times'|'event_callbacks'|'external_gateways'|'external_payments'|'external_promotions'|'external_tax_calculators'|'fixed_amount_promotions'|'fixed_price_promotions'|'free_gift_promotions'|'free_shipping_promotions'|'geocoders'|'gift_card_recipients'|'gift_cards'|'google_geocoders'|'imports'|'in_stock_subscriptions'|'inventory_models'|'inventory_return_locations'|'inventory_stock_locations'|'klarna_gateways'|'klarna_payments'|'line_item_options'|'line_items'|'manual_gateways'|'manual_tax_calculators'|'markets'|'merchants'|'order_amount_promotion_rules'|'order_copies'|'order_subscriptions'|'order_validation_rules'|'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';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","coupon_recipients","coupons","customer_addresses","customer_groups","customer_password_resets","customer_payment_sources","customer_subscriptions","customers","delivery_lead_times","event_callbacks","external_gateways","external_payments","external_promotions","external_tax_calculators","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","geocoders","gift_card_recipients","gift_cards","google_geocoders","imports","in_stock_subscriptions","inventory_models","inventory_return_locations","inventory_stock_locations","klarna_gateways","klarna_payments","line_item_options","line_items","manual_gateways","manual_tax_calculators","markets","merchants","order_amount_promotion_rules","order_copies","order_subscriptions","order_validation_rules","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"];
@@ -1,32 +1,2 @@
1
1
  /// <reference types="node" />
2
- import { AxiosProxyConfig, Method } from 'axios';
3
- import type { InterceptorManager } from './interceptor';
4
- import type { Agent as HttpAgent } from 'http';
5
- import type { Agent as HttpsAgent } from 'https';
6
- declare type ProxyConfig = AxiosProxyConfig | false;
7
- declare type RequestConfig = {
8
- timeout?: number;
9
- params?: {
10
- [key: string]: string | number | boolean;
11
- };
12
- httpAgent?: HttpAgent;
13
- httpsAgent?: HttpsAgent;
14
- proxy?: ProxyConfig;
15
- };
16
- declare type ApiClientInitConfig = {
17
- organization: string;
18
- domain?: string;
19
- accessToken: string;
20
- } & RequestConfig;
21
- declare type ApiClientConfig = Partial<ApiClientInitConfig>;
22
- declare class ApiClient {
23
- #private;
24
- static create(options: ApiClientInitConfig): ApiClient;
25
- baseUrl: string;
26
- interceptors: InterceptorManager;
27
- private constructor();
28
- config(config: ApiClientConfig): void;
29
- request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
30
- }
31
- export default ApiClient;
32
- export { ApiClientInitConfig, ApiClientConfig, RequestConfig };
2
+ import{AxiosProxyConfig,Method}from'axios';import type{InterceptorManager}from'./interceptor';import type{Agent as HttpAgent}from'http';import type{Agent as HttpsAgent}from'https';declare type ProxyConfig=AxiosProxyConfig|false;declare type RequestConfig={timeout?:number;params?:{[key:string]:string|number|boolean;};httpAgent?:HttpAgent;httpsAgent?:HttpsAgent;proxy?:ProxyConfig;};declare type ApiClientInitConfig={organization:string;domain?:string;accessToken:string;}&RequestConfig;declare type ApiClientConfig=Partial<ApiClientInitConfig>;declare class ApiClient{#private;static create(options:ApiClientInitConfig):ApiClient;baseUrl:string;interceptors:InterceptorManager;private constructor();config(config:ApiClientConfig):void;request(method:Method,path:string,body?:any,options?:ApiClientConfig):Promise<any>;}export default ApiClient;export{ApiClientInitConfig,ApiClientConfig,RequestConfig};
@@ -1,122 +1 @@
1
- import * as api from './api';
2
- import { ApiError } from './error';
3
- import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
4
- import { ResourcesInitConfig } from './resource';
5
- declare type SdkConfig = {};
6
- declare type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
7
- declare type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
8
- declare class CommerceLayerClient {
9
- #private;
10
- static get openApiSchemaVersion(): string;
11
- addresses: api.Addresses;
12
- adjustments: api.Adjustments;
13
- adyen_gateways: api.AdyenGateways;
14
- adyen_payments: api.AdyenPayments;
15
- application: api.Applications;
16
- attachments: api.Attachments;
17
- authorizations: api.Authorizations;
18
- avalara_accounts: api.AvalaraAccounts;
19
- billing_info_validation_rules: api.BillingInfoValidationRules;
20
- bing_geocoders: api.BingGeocoders;
21
- braintree_gateways: api.BraintreeGateways;
22
- braintree_payments: api.BraintreePayments;
23
- bundles: api.Bundles;
24
- captures: api.Captures;
25
- carrier_accounts: api.CarrierAccounts;
26
- checkout_com_gateways: api.CheckoutComGateways;
27
- checkout_com_payments: api.CheckoutComPayments;
28
- coupon_codes_promotion_rules: api.CouponCodesPromotionRules;
29
- coupon_recipients: api.CouponRecipients;
30
- coupons: api.Coupons;
31
- customer_addresses: api.CustomerAddresses;
32
- customer_groups: api.CustomerGroups;
33
- customer_password_resets: api.CustomerPasswordResets;
34
- customer_payment_sources: api.CustomerPaymentSources;
35
- customer_subscriptions: api.CustomerSubscriptions;
36
- customers: api.Customers;
37
- delivery_lead_times: api.DeliveryLeadTimes;
38
- event_callbacks: api.EventCallbacks;
39
- external_gateways: api.ExternalGateways;
40
- external_payments: api.ExternalPayments;
41
- external_promotions: api.ExternalPromotions;
42
- external_tax_calculators: api.ExternalTaxCalculators;
43
- fixed_amount_promotions: api.FixedAmountPromotions;
44
- fixed_price_promotions: api.FixedPricePromotions;
45
- free_gift_promotions: api.FreeGiftPromotions;
46
- free_shipping_promotions: api.FreeShippingPromotions;
47
- geocoders: api.Geocoders;
48
- gift_card_recipients: api.GiftCardRecipients;
49
- gift_cards: api.GiftCards;
50
- google_geocoders: api.GoogleGeocoders;
51
- imports: api.Imports;
52
- in_stock_subscriptions: api.InStockSubscriptions;
53
- inventory_models: api.InventoryModels;
54
- inventory_return_locations: api.InventoryReturnLocations;
55
- inventory_stock_locations: api.InventoryStockLocations;
56
- klarna_gateways: api.KlarnaGateways;
57
- klarna_payments: api.KlarnaPayments;
58
- line_item_options: api.LineItemOptions;
59
- line_items: api.LineItems;
60
- manual_gateways: api.ManualGateways;
61
- manual_tax_calculators: api.ManualTaxCalculators;
62
- markets: api.Markets;
63
- merchants: api.Merchants;
64
- order_amount_promotion_rules: api.OrderAmountPromotionRules;
65
- order_copies: api.OrderCopies;
66
- order_subscriptions: api.OrderSubscriptions;
67
- order_validation_rules: api.OrderValidationRules;
68
- orders: api.Orders;
69
- organization: api.Organizations;
70
- packages: api.Packages;
71
- parcel_line_items: api.ParcelLineItems;
72
- parcels: api.Parcels;
73
- payment_gateways: api.PaymentGateways;
74
- payment_methods: api.PaymentMethods;
75
- paypal_gateways: api.PaypalGateways;
76
- paypal_payments: api.PaypalPayments;
77
- percentage_discount_promotions: api.PercentageDiscountPromotions;
78
- price_lists: api.PriceLists;
79
- prices: api.Prices;
80
- promotion_rules: api.PromotionRules;
81
- promotions: api.Promotions;
82
- refunds: api.Refunds;
83
- return_line_items: api.ReturnLineItems;
84
- returns: api.Returns;
85
- shipments: api.Shipments;
86
- shipping_categories: api.ShippingCategories;
87
- shipping_methods: api.ShippingMethods;
88
- shipping_zones: api.ShippingZones;
89
- sku_list_items: api.SkuListItems;
90
- sku_list_promotion_rules: api.SkuListPromotionRules;
91
- sku_lists: api.SkuLists;
92
- sku_options: api.SkuOptions;
93
- skus: api.Skus;
94
- stock_items: api.StockItems;
95
- stock_line_items: api.StockLineItems;
96
- stock_locations: api.StockLocations;
97
- stock_transfers: api.StockTransfers;
98
- stripe_gateways: api.StripeGateways;
99
- stripe_payments: api.StripePayments;
100
- tax_calculators: api.TaxCalculators;
101
- tax_categories: api.TaxCategories;
102
- tax_rules: api.TaxRules;
103
- taxjar_accounts: api.TaxjarAccounts;
104
- transactions: api.Transactions;
105
- voids: api.Voids;
106
- webhooks: api.Webhooks;
107
- wire_transfers: api.WireTransfers;
108
- constructor(config: CommerceLayerInitConfig);
109
- get currentOrganization(): string;
110
- private localConfig;
111
- config(config: CommerceLayerConfig): void;
112
- resources(): readonly string[];
113
- isApiError(error: any): error is ApiError;
114
- addRequestInterceptor(onFulfilled?: RequestInterceptor, onRejected?: ErrorInterceptor): number;
115
- addResponseInterceptor(onFulfilled?: ResponseInterceptor, onRejected?: ErrorInterceptor): number;
116
- removeInterceptor(type: InterceptorType, id: number): void;
117
- addRawResponseReader(): RawResponseReader;
118
- removeRawResponseReader(reader: number | RawResponseReader): void;
119
- }
120
- declare const CommerceLayer: (config: CommerceLayerInitConfig) => CommerceLayerClient;
121
- export default CommerceLayer;
122
- export type { CommerceLayerClient, CommerceLayerConfig, CommerceLayerInitConfig };
1
+ import*as api from'./api';import{ApiError}from'./error';import type{ErrorInterceptor,InterceptorType,RawResponseReader,RequestInterceptor,ResponseInterceptor}from'./interceptor';import{ResourcesInitConfig}from'./resource';declare type SdkConfig={};declare type CommerceLayerInitConfig=SdkConfig&ResourcesInitConfig;declare type CommerceLayerConfig=Partial<CommerceLayerInitConfig>;declare class CommerceLayerClient{#private;static get openApiSchemaVersion():string;addresses:api.Addresses;adjustments:api.Adjustments;adyen_gateways:api.AdyenGateways;adyen_payments:api.AdyenPayments;application:api.Applications;attachments:api.Attachments;authorizations:api.Authorizations;avalara_accounts:api.AvalaraAccounts;billing_info_validation_rules:api.BillingInfoValidationRules;bing_geocoders:api.BingGeocoders;braintree_gateways:api.BraintreeGateways;braintree_payments:api.BraintreePayments;bundles:api.Bundles;captures:api.Captures;carrier_accounts:api.CarrierAccounts;checkout_com_gateways:api.CheckoutComGateways;checkout_com_payments:api.CheckoutComPayments;coupon_codes_promotion_rules:api.CouponCodesPromotionRules;coupon_recipients:api.CouponRecipients;coupons:api.Coupons;customer_addresses:api.CustomerAddresses;customer_groups:api.CustomerGroups;customer_password_resets:api.CustomerPasswordResets;customer_payment_sources:api.CustomerPaymentSources;customer_subscriptions:api.CustomerSubscriptions;customers:api.Customers;delivery_lead_times:api.DeliveryLeadTimes;event_callbacks:api.EventCallbacks;external_gateways:api.ExternalGateways;external_payments:api.ExternalPayments;external_promotions:api.ExternalPromotions;external_tax_calculators:api.ExternalTaxCalculators;fixed_amount_promotions:api.FixedAmountPromotions;fixed_price_promotions:api.FixedPricePromotions;free_gift_promotions:api.FreeGiftPromotions;free_shipping_promotions:api.FreeShippingPromotions;geocoders:api.Geocoders;gift_card_recipients:api.GiftCardRecipients;gift_cards:api.GiftCards;google_geocoders:api.GoogleGeocoders;imports:api.Imports;in_stock_subscriptions:api.InStockSubscriptions;inventory_models:api.InventoryModels;inventory_return_locations:api.InventoryReturnLocations;inventory_stock_locations:api.InventoryStockLocations;klarna_gateways:api.KlarnaGateways;klarna_payments:api.KlarnaPayments;line_item_options:api.LineItemOptions;line_items:api.LineItems;manual_gateways:api.ManualGateways;manual_tax_calculators:api.ManualTaxCalculators;markets:api.Markets;merchants:api.Merchants;order_amount_promotion_rules:api.OrderAmountPromotionRules;order_copies:api.OrderCopies;order_subscriptions:api.OrderSubscriptions;order_validation_rules:api.OrderValidationRules;orders:api.Orders;organization:api.Organizations;packages:api.Packages;parcel_line_items:api.ParcelLineItems;parcels:api.Parcels;payment_gateways:api.PaymentGateways;payment_methods:api.PaymentMethods;paypal_gateways:api.PaypalGateways;paypal_payments:api.PaypalPayments;percentage_discount_promotions:api.PercentageDiscountPromotions;price_lists:api.PriceLists;prices:api.Prices;promotion_rules:api.PromotionRules;promotions:api.Promotions;refunds:api.Refunds;return_line_items:api.ReturnLineItems;returns:api.Returns;shipments:api.Shipments;shipping_categories:api.ShippingCategories;shipping_methods:api.ShippingMethods;shipping_zones:api.ShippingZones;sku_list_items:api.SkuListItems;sku_list_promotion_rules:api.SkuListPromotionRules;sku_lists:api.SkuLists;sku_options:api.SkuOptions;skus:api.Skus;stock_items:api.StockItems;stock_line_items:api.StockLineItems;stock_locations:api.StockLocations;stock_transfers:api.StockTransfers;stripe_gateways:api.StripeGateways;stripe_payments:api.StripePayments;tax_calculators:api.TaxCalculators;tax_categories:api.TaxCategories;tax_rules:api.TaxRules;taxjar_accounts:api.TaxjarAccounts;transactions:api.Transactions;voids:api.Voids;webhooks:api.Webhooks;wire_transfers:api.WireTransfers;constructor(config:CommerceLayerInitConfig);get currentOrganization():string;private localConfig;config(config:CommerceLayerConfig):void;resources():readonly string[];isApiError(error:any):error is ApiError;addRequestInterceptor(onFulfilled?:RequestInterceptor,onRejected?:ErrorInterceptor):number;addResponseInterceptor(onFulfilled?:ResponseInterceptor,onRejected?:ErrorInterceptor):number;removeInterceptor(type:InterceptorType,id:number):void;addRawResponseReader():RawResponseReader;removeRawResponseReader(reader:number|RawResponseReader):void;}declare const CommerceLayer:(config:CommerceLayerInitConfig)=>CommerceLayerClient;export default CommerceLayer;export type{CommerceLayerClient,CommerceLayerConfig,CommerceLayerInitConfig};
@@ -1,4 +1 @@
1
- import type { ResourceId, ResourceType } from './resource';
2
- declare const isResourceId: (resource: any) => resource is ResourceId;
3
- declare const isResourceType: (resource: any) => resource is ResourceType;
4
- export { isResourceId, isResourceType };
1
+ import type{ResourceId,ResourceType}from'./resource';declare const isResourceId:(resource:any)=>resource is ResourceId;declare const isResourceType:(resource:any)=>resource is ResourceType;export{isResourceId,isResourceType};
@@ -1,11 +1 @@
1
- declare const config: {
2
- readonly default: {
3
- readonly domain: "commercelayer.io";
4
- readonly pageNumber: 1;
5
- readonly pageSize: 10;
6
- };
7
- readonly client: {
8
- readonly timeout: 15000;
9
- };
10
- };
11
- export default config;
1
+ declare const config:{readonly default:{readonly domain:"commercelayer.io";readonly pageNumber:1;readonly pageSize:10;};readonly client:{readonly timeout:15000;};};export default config;
@@ -1,3 +1 @@
1
- declare type Debugger = (pattern: string, ...args: any[]) => void;
2
- declare const debug: (namespace: string) => Debugger;
3
- export default debug;
1
+ declare type Debugger=(pattern:string,...args:any[])=>void;declare const debug:(namespace:string)=>Debugger;export default debug;
@@ -1,26 +1 @@
1
- declare enum ErrorType {
2
- CLIENT = "client",
3
- REQUEST = "request",
4
- RESPONSE = "response",
5
- GENERIC = "generic",
6
- CANCEL = "cancel"
7
- }
8
- declare class SdkError extends Error {
9
- static isSdkError(error: any): error is ApiError;
10
- type: string;
11
- code?: string;
12
- source?: Error;
13
- request?: any;
14
- constructor(error: {
15
- message: string;
16
- type?: ErrorType;
17
- });
18
- }
19
- declare class ApiError extends SdkError {
20
- static isApiError(error: any): error is ApiError;
21
- errors: any[];
22
- status?: number;
23
- constructor(error: SdkError);
24
- first(): any;
25
- }
26
- export { SdkError, ApiError, ErrorType };
1
+ declare enum ErrorType{CLIENT="client",REQUEST="request",RESPONSE="response",GENERIC="generic",CANCEL="cancel"}declare class SdkError extends Error{static isSdkError(error:any):error is ApiError;type:string;code?:string;source?:Error;request?:any;constructor(error:{message:string;type?:ErrorType;});}declare class ApiError extends SdkError{static isApiError(error:any):error is ApiError;errors:any[];status?:number;constructor(error:SdkError);first():any;}export{SdkError,ApiError,ErrorType};
@@ -1,7 +1 @@
1
- export { default } from './commercelayer';
2
- export type { CommerceLayerClient } from './commercelayer';
3
- export { CommerceLayerStatic } from './static';
4
- export type { QueryParamsRetrieve, QueryParamsList, QueryParams } from './query';
5
- export * from './model';
6
- export type { RequestObj, ResponseObj, ErrorObj } from './interceptor';
7
- export type { SdkError, ApiError, ErrorType } from './error';
1
+ export{default}from'./commercelayer';export type{CommerceLayerClient}from'./commercelayer';export{CommerceLayerStatic}from'./static';export type{QueryParamsRetrieve,QueryParamsList,QueryParams}from'./query';export*from'./model';export type{RequestObj,ResponseObj,ErrorObj}from'./interceptor';export type{SdkError,ApiError,ErrorType}from'./error';
@@ -1,19 +1 @@
1
- import { AxiosError, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from "axios";
2
- declare type InterceptorManager = {
3
- request: AxiosInterceptorManager<AxiosRequestConfig>;
4
- response: AxiosInterceptorManager<any>;
5
- };
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;
12
- declare type InterceptorType = 'request' | 'response';
13
- export type { InterceptorManager, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, InterceptorType };
14
- export type { RequestObj, ResponseObj, ErrorObj };
15
- declare type RawResponseReader = {
16
- id: number | undefined;
17
- rawResponse: ResponseObj | undefined;
18
- };
19
- export type { RawResponseReader };
1
+ import{AxiosError,AxiosInterceptorManager,AxiosRequestConfig,AxiosResponse}from"axios";declare type InterceptorManager={request:AxiosInterceptorManager<AxiosRequestConfig>;response:AxiosInterceptorManager<any>;};declare type RequestObj=AxiosRequestConfig;declare type RequestInterceptor=(request:RequestObj)=>RequestObj|Promise<RequestObj>;declare type ResponseObj=AxiosResponse;declare type ResponseInterceptor=(response:ResponseObj)=>ResponseObj;declare type ErrorObj=AxiosError;declare type ErrorInterceptor=(error:ErrorObj)=>ErrorObj;declare type InterceptorType='request'|'response';export type{InterceptorManager,RequestInterceptor,ResponseInterceptor,ErrorInterceptor,InterceptorType};export type{RequestObj,ResponseObj,ErrorObj};declare type RawResponseReader={id:number|undefined;rawResponse:ResponseObj|undefined;};export type{RawResponseReader};
@@ -1,5 +1 @@
1
- import type { DocWithData, ResourceObject as JSONAPIObject } from 'jsonapi-typescript';
2
- import type { ResourceCreate, ResourceUpdate, ResourceId, ResourceType, Resource } from './resource';
3
- declare const denormalize: <R extends Resource>(response: DocWithData) => R | R[];
4
- declare const normalize: (resource: (ResourceCreate & ResourceType) | (ResourceUpdate & ResourceId)) => JSONAPIObject;
5
- export { denormalize, normalize };
1
+ import type{DocWithData,ResourceObject as JSONAPIObject}from'jsonapi-typescript';import type{ResourceCreate,ResourceUpdate,ResourceId,ResourceType,Resource}from'./resource';declare const denormalize:<R extends Resource>(response:DocWithData)=>R|R[];declare const normalize:(resource:(ResourceCreate&ResourceType)|(ResourceUpdate&ResourceId))=>JSONAPIObject;export{denormalize,normalize};
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalize=exports.denormalize=void 0;const common_1=require("./common"),debug_1=__importDefault(require("./debug")),debug=(0,debug_1.default)("jsonapi"),denormalize=e=>{let o;e.links&&delete e.links;const r=e.data,i=e.included;return Array.isArray(r)?o=r.map(t=>denormalizeResource(t,i)):o=denormalizeResource(r,i),o};exports.denormalize=denormalize;const findIncluded=(e,o=[])=>o.find(r=>e.id===r.id&&e.type===r.type)||e,denormalizeResource=(e,o)=>{debug("denormalize resource: %O, %o",e,o||{});const r=Object.assign({id:e.id,type:e.type},e.attributes);return e.relationships&&Object.keys(e.relationships).forEach(i=>{const t=e.relationships[i].data;t?Array.isArray(t)?r[i]=t.map(s=>denormalizeResource(findIncluded(s,o),o)):r[i]=denormalizeResource(findIncluded(t,o),o):t===null&&(r[i]=null)}),debug("denormalized resource: %O",r),r},normalize=e=>{debug("normalize resource: %O",e);const o={},r={};for(const t in e){if(["type","id"].includes(t))continue;const s=e[t];s&&(0,common_1.isResourceType)(s)&&s.id===null?r[t]={data:null}:s&&((0,common_1.isResourceId)(s)||Array.isArray(s)&&(0,common_1.isResourceId)(s[0]))?r[t]={data:s}:o[t]=s}const i={type:e.type,attributes:o,relationships:r};return(0,common_1.isResourceId)(e)&&(i.id=e.id),debug("normalized resource: %O",i),i};exports.normalize=normalize;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalize=exports.denormalize=void 0;const common_1=require("./common"),debug_1=__importDefault(require("./debug")),debug=(0,debug_1.default)("jsonapi"),denormalize=e=>{let t;e.links&&delete e.links;const i=e.data,o=e.included;return i?Array.isArray(i)?t=i.map(s=>denormalizeResource(s,o)):t=denormalizeResource(i,o):t=i,t};exports.denormalize=denormalize;const findIncluded=(e,t=[])=>t.find(i=>e.id===i.id&&e.type===i.type)||e,denormalizeResource=(e,t)=>{if(debug("denormalize resource: %O, %o",e,t||{}),!e)return e;const i=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)?i[o]=s.map(n=>denormalizeResource(findIncluded(n,t),t)):i[o]=denormalizeResource(findIncluded(s,t),t):s===null&&(i[o]=null)}),debug("denormalized resource: %O",i),i},normalize=e=>{debug("normalize resource: %O",e);const t={},i={};for(const s in e){if(["type","id"].includes(s))continue;const n=e[s];n&&(0,common_1.isResourceType)(n)&&n.id===null?i[s]={data:null}:n&&((0,common_1.isResourceId)(n)||Array.isArray(n)&&(0,common_1.isResourceId)(n[0]))?i[s]={data:n}:t[s]=n}const o={type:e.type,attributes:t,relationships:i};return(0,common_1.isResourceId)(e)&&(o.id=e.id),debug("normalized resource: %O",o),o};exports.normalize=normalize;