@betterstore/sdk 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - proxy option added
8
+
3
9
  ## 0.3.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -138,7 +138,7 @@ interface CheckoutSession {
138
138
 
139
139
  declare class Checkout {
140
140
  private apiClient;
141
- constructor(apiKey: string);
141
+ constructor(apiKey: string, proxy?: string);
142
142
  /**
143
143
  * Create a new checkout session
144
144
  */
@@ -162,6 +162,8 @@ declare class Checkout {
162
162
  }
163
163
 
164
164
  declare class Client {
165
+ private proxy?;
166
+ constructor(proxy?: string);
165
167
  /**
166
168
  * Retrieve a checkout session by ID
167
169
  */
@@ -194,7 +196,7 @@ declare class Client {
194
196
 
195
197
  declare class Customer {
196
198
  private apiClient;
197
- constructor(apiKey: string);
199
+ constructor(apiKey: string, proxy?: string);
198
200
  /**
199
201
  * Create a new customer
200
202
  */
@@ -215,18 +217,21 @@ declare class Customer {
215
217
 
216
218
  declare class Products {
217
219
  private apiClient;
218
- constructor(apiKey: string);
220
+ constructor(apiKey: string, proxy?: string);
219
221
  list(): Promise<Omit<Product, "productVariants">[]>;
220
222
  retrieve(productId: string): Promise<Product>;
221
223
  }
222
224
 
223
225
  declare function betterStore(config: {
224
226
  apiKey: string;
227
+ proxy?: string;
225
228
  }): {
226
229
  checkout: Checkout;
227
230
  products: Products;
228
231
  customer: Customer;
229
232
  };
230
- declare function createStoreClient(): Client;
233
+ declare function createStoreClient(config: {
234
+ proxy?: string;
235
+ }): Client;
231
236
 
232
237
  export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type ShippingRate, type VariantOption, createStoreClient, betterStore as default };
package/dist/index.d.ts CHANGED
@@ -138,7 +138,7 @@ interface CheckoutSession {
138
138
 
139
139
  declare class Checkout {
140
140
  private apiClient;
141
- constructor(apiKey: string);
141
+ constructor(apiKey: string, proxy?: string);
142
142
  /**
143
143
  * Create a new checkout session
144
144
  */
@@ -162,6 +162,8 @@ declare class Checkout {
162
162
  }
163
163
 
164
164
  declare class Client {
165
+ private proxy?;
166
+ constructor(proxy?: string);
165
167
  /**
166
168
  * Retrieve a checkout session by ID
167
169
  */
@@ -194,7 +196,7 @@ declare class Client {
194
196
 
195
197
  declare class Customer {
196
198
  private apiClient;
197
- constructor(apiKey: string);
199
+ constructor(apiKey: string, proxy?: string);
198
200
  /**
199
201
  * Create a new customer
200
202
  */
@@ -215,18 +217,21 @@ declare class Customer {
215
217
 
216
218
  declare class Products {
217
219
  private apiClient;
218
- constructor(apiKey: string);
220
+ constructor(apiKey: string, proxy?: string);
219
221
  list(): Promise<Omit<Product, "productVariants">[]>;
220
222
  retrieve(productId: string): Promise<Product>;
221
223
  }
222
224
 
223
225
  declare function betterStore(config: {
224
226
  apiKey: string;
227
+ proxy?: string;
225
228
  }): {
226
229
  checkout: Checkout;
227
230
  products: Products;
228
231
  customer: Customer;
229
232
  };
230
- declare function createStoreClient(): Client;
233
+ declare function createStoreClient(config: {
234
+ proxy?: string;
235
+ }): Client;
231
236
 
232
237
  export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type ShippingRate, type VariantOption, createStoreClient, betterStore as default };
package/dist/index.js CHANGED
@@ -59,9 +59,9 @@ module.exports = __toCommonJS(index_exports);
59
59
  // src/utils/axios.ts
60
60
  var import_axios = __toESM(require("axios"));
61
61
  var API_BASE_URL = "https://api.betterstore.io/v1";
62
- var createApiClient = (apiKey) => {
62
+ var createApiClient = (apiKey, proxy) => {
63
63
  const client = import_axios.default.create({
64
- baseURL: API_BASE_URL,
64
+ baseURL: proxy != null ? proxy : API_BASE_URL,
65
65
  headers: {
66
66
  "Content-Type": "application/json",
67
67
  Authorization: `Bearer ${apiKey}`,
@@ -102,8 +102,8 @@ var createApiClient = (apiKey) => {
102
102
 
103
103
  // src/checkout/index.ts
104
104
  var Checkout = class {
105
- constructor(apiKey) {
106
- this.apiClient = createApiClient(apiKey);
105
+ constructor(apiKey, proxy) {
106
+ this.apiClient = createApiClient(apiKey, proxy);
107
107
  }
108
108
  /**
109
109
  * Create a new checkout session
@@ -167,12 +167,15 @@ var checkout_default = Checkout;
167
167
 
168
168
  // src/client/index.ts
169
169
  var Client = class {
170
+ constructor(proxy) {
171
+ this.proxy = proxy;
172
+ }
170
173
  /**
171
174
  * Retrieve a checkout session by ID
172
175
  */
173
176
  retrieveCheckout(checkoutId) {
174
177
  return __async(this, null, function* () {
175
- const apiClient = createApiClient("");
178
+ const apiClient = createApiClient("", this.proxy);
176
179
  const data = yield apiClient.get(
177
180
  `/checkout/${checkoutId}`
178
181
  );
@@ -184,7 +187,7 @@ var Client = class {
184
187
  */
185
188
  updateCheckout(clientSecret, checkoutId, params) {
186
189
  return __async(this, null, function* () {
187
- const apiClient = createApiClient(clientSecret);
190
+ const apiClient = createApiClient(clientSecret, this.proxy);
188
191
  const data = yield apiClient.put(
189
192
  `/checkout/${checkoutId}`,
190
193
  params
@@ -197,7 +200,7 @@ var Client = class {
197
200
  */
198
201
  getCheckoutShippingRates(clientSecret, checkoutId) {
199
202
  return __async(this, null, function* () {
200
- const apiClient = createApiClient(clientSecret);
203
+ const apiClient = createApiClient(clientSecret, this.proxy);
201
204
  const data = yield apiClient.get(
202
205
  `/checkout/shipping/${checkoutId}`
203
206
  );
@@ -209,7 +212,7 @@ var Client = class {
209
212
  */
210
213
  generateCheckoutsPaymentSecret(clientSecret, checkoutId) {
211
214
  return __async(this, null, function* () {
212
- const apiClient = createApiClient(clientSecret);
215
+ const apiClient = createApiClient(clientSecret, this.proxy);
213
216
  const data = yield apiClient.post(
214
217
  `/checkout/payment/${checkoutId}`
215
218
  );
@@ -221,7 +224,7 @@ var Client = class {
221
224
  */
222
225
  createCustomer(clientSecret, params) {
223
226
  return __async(this, null, function* () {
224
- const apiClient = createApiClient(clientSecret);
227
+ const apiClient = createApiClient(clientSecret, this.proxy);
225
228
  const data = yield apiClient.post("/customers", params);
226
229
  return data;
227
230
  });
@@ -231,7 +234,7 @@ var Client = class {
231
234
  */
232
235
  retrieveCustomer(clientSecret, idOrEmail) {
233
236
  return __async(this, null, function* () {
234
- const apiClient = createApiClient(clientSecret);
237
+ const apiClient = createApiClient(clientSecret, this.proxy);
235
238
  const data = yield apiClient.get(`/customers/${idOrEmail}`);
236
239
  if (!data) {
237
240
  throw new Error("Customer not found");
@@ -244,7 +247,7 @@ var Client = class {
244
247
  */
245
248
  updateCustomer(clientSecret, customerId, params) {
246
249
  return __async(this, null, function* () {
247
- const apiClient = createApiClient(clientSecret);
250
+ const apiClient = createApiClient(clientSecret, this.proxy);
248
251
  const data = yield apiClient.put(
249
252
  `/customers/${customerId}`,
250
253
  params
@@ -257,8 +260,8 @@ var client_default = Client;
257
260
 
258
261
  // src/customer/index.ts
259
262
  var Customer = class {
260
- constructor(apiKey) {
261
- this.apiClient = createApiClient(apiKey);
263
+ constructor(apiKey, proxy) {
264
+ this.apiClient = createApiClient(apiKey, proxy);
262
265
  }
263
266
  /**
264
267
  * Create a new customer
@@ -308,8 +311,8 @@ var customer_default = Customer;
308
311
 
309
312
  // src/products/index.ts
310
313
  var Products = class {
311
- constructor(apiKey) {
312
- this.apiClient = createApiClient(apiKey);
314
+ constructor(apiKey, proxy) {
315
+ this.apiClient = createApiClient(apiKey, proxy);
313
316
  }
314
317
  list() {
315
318
  return __async(this, null, function* () {
@@ -343,13 +346,13 @@ function betterStore(config) {
343
346
  throw new Error("API key is required.");
344
347
  }
345
348
  return {
346
- checkout: new checkout_default(config.apiKey),
347
- products: new products_default(config.apiKey),
348
- customer: new customer_default(config.apiKey)
349
+ checkout: new checkout_default(config.apiKey, config.proxy),
350
+ products: new products_default(config.apiKey, config.proxy),
351
+ customer: new customer_default(config.apiKey, config.proxy)
349
352
  };
350
353
  }
351
- function createStoreClient() {
352
- return new client_default();
354
+ function createStoreClient(config) {
355
+ return new client_default(config.proxy);
353
356
  }
354
357
  // Annotate the CommonJS export names for ESM import in node:
355
358
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -22,9 +22,9 @@ var __async = (__this, __arguments, generator) => {
22
22
  // src/utils/axios.ts
23
23
  import axios from "axios";
24
24
  var API_BASE_URL = "https://api.betterstore.io/v1";
25
- var createApiClient = (apiKey) => {
25
+ var createApiClient = (apiKey, proxy) => {
26
26
  const client = axios.create({
27
- baseURL: API_BASE_URL,
27
+ baseURL: proxy != null ? proxy : API_BASE_URL,
28
28
  headers: {
29
29
  "Content-Type": "application/json",
30
30
  Authorization: `Bearer ${apiKey}`,
@@ -65,8 +65,8 @@ var createApiClient = (apiKey) => {
65
65
 
66
66
  // src/checkout/index.ts
67
67
  var Checkout = class {
68
- constructor(apiKey) {
69
- this.apiClient = createApiClient(apiKey);
68
+ constructor(apiKey, proxy) {
69
+ this.apiClient = createApiClient(apiKey, proxy);
70
70
  }
71
71
  /**
72
72
  * Create a new checkout session
@@ -130,12 +130,15 @@ var checkout_default = Checkout;
130
130
 
131
131
  // src/client/index.ts
132
132
  var Client = class {
133
+ constructor(proxy) {
134
+ this.proxy = proxy;
135
+ }
133
136
  /**
134
137
  * Retrieve a checkout session by ID
135
138
  */
136
139
  retrieveCheckout(checkoutId) {
137
140
  return __async(this, null, function* () {
138
- const apiClient = createApiClient("");
141
+ const apiClient = createApiClient("", this.proxy);
139
142
  const data = yield apiClient.get(
140
143
  `/checkout/${checkoutId}`
141
144
  );
@@ -147,7 +150,7 @@ var Client = class {
147
150
  */
148
151
  updateCheckout(clientSecret, checkoutId, params) {
149
152
  return __async(this, null, function* () {
150
- const apiClient = createApiClient(clientSecret);
153
+ const apiClient = createApiClient(clientSecret, this.proxy);
151
154
  const data = yield apiClient.put(
152
155
  `/checkout/${checkoutId}`,
153
156
  params
@@ -160,7 +163,7 @@ var Client = class {
160
163
  */
161
164
  getCheckoutShippingRates(clientSecret, checkoutId) {
162
165
  return __async(this, null, function* () {
163
- const apiClient = createApiClient(clientSecret);
166
+ const apiClient = createApiClient(clientSecret, this.proxy);
164
167
  const data = yield apiClient.get(
165
168
  `/checkout/shipping/${checkoutId}`
166
169
  );
@@ -172,7 +175,7 @@ var Client = class {
172
175
  */
173
176
  generateCheckoutsPaymentSecret(clientSecret, checkoutId) {
174
177
  return __async(this, null, function* () {
175
- const apiClient = createApiClient(clientSecret);
178
+ const apiClient = createApiClient(clientSecret, this.proxy);
176
179
  const data = yield apiClient.post(
177
180
  `/checkout/payment/${checkoutId}`
178
181
  );
@@ -184,7 +187,7 @@ var Client = class {
184
187
  */
185
188
  createCustomer(clientSecret, params) {
186
189
  return __async(this, null, function* () {
187
- const apiClient = createApiClient(clientSecret);
190
+ const apiClient = createApiClient(clientSecret, this.proxy);
188
191
  const data = yield apiClient.post("/customers", params);
189
192
  return data;
190
193
  });
@@ -194,7 +197,7 @@ var Client = class {
194
197
  */
195
198
  retrieveCustomer(clientSecret, idOrEmail) {
196
199
  return __async(this, null, function* () {
197
- const apiClient = createApiClient(clientSecret);
200
+ const apiClient = createApiClient(clientSecret, this.proxy);
198
201
  const data = yield apiClient.get(`/customers/${idOrEmail}`);
199
202
  if (!data) {
200
203
  throw new Error("Customer not found");
@@ -207,7 +210,7 @@ var Client = class {
207
210
  */
208
211
  updateCustomer(clientSecret, customerId, params) {
209
212
  return __async(this, null, function* () {
210
- const apiClient = createApiClient(clientSecret);
213
+ const apiClient = createApiClient(clientSecret, this.proxy);
211
214
  const data = yield apiClient.put(
212
215
  `/customers/${customerId}`,
213
216
  params
@@ -220,8 +223,8 @@ var client_default = Client;
220
223
 
221
224
  // src/customer/index.ts
222
225
  var Customer = class {
223
- constructor(apiKey) {
224
- this.apiClient = createApiClient(apiKey);
226
+ constructor(apiKey, proxy) {
227
+ this.apiClient = createApiClient(apiKey, proxy);
225
228
  }
226
229
  /**
227
230
  * Create a new customer
@@ -271,8 +274,8 @@ var customer_default = Customer;
271
274
 
272
275
  // src/products/index.ts
273
276
  var Products = class {
274
- constructor(apiKey) {
275
- this.apiClient = createApiClient(apiKey);
277
+ constructor(apiKey, proxy) {
278
+ this.apiClient = createApiClient(apiKey, proxy);
276
279
  }
277
280
  list() {
278
281
  return __async(this, null, function* () {
@@ -306,13 +309,13 @@ function betterStore(config) {
306
309
  throw new Error("API key is required.");
307
310
  }
308
311
  return {
309
- checkout: new checkout_default(config.apiKey),
310
- products: new products_default(config.apiKey),
311
- customer: new customer_default(config.apiKey)
312
+ checkout: new checkout_default(config.apiKey, config.proxy),
313
+ products: new products_default(config.apiKey, config.proxy),
314
+ customer: new customer_default(config.apiKey, config.proxy)
312
315
  };
313
316
  }
314
- function createStoreClient() {
315
- return new client_default();
317
+ function createStoreClient(config) {
318
+ return new client_default(config.proxy);
316
319
  }
317
320
  export {
318
321
  ProductStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {