@betterstore/sdk 0.5.25 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,292 +1,8 @@
1
+ import { OTPSignupParams, OTPSignupResponse, OTPLoginParams, OTPLoginResponse, OTPVerifyParams, OTPVerifyResponse, CustomerSession, CheckoutCreateParams, CheckoutSession, CheckoutUpdateParams, GetShippingRatesResponse, CustomerCreateParams, CustomerResponse, CustomerUpdateParams, AutosuggestAddressResult, LookupAddressResult, ListCollectionsParams, ListCollectionsResponse, RetrieveCollectionParams, RetrieveCollectionResponse, CustomerSubscriptionUpdateParams, CustomerSubscription, ListDiscountsParams, ListDiscountsResponse, RetrieveDiscountParams, RetrieveDiscountResponse, ListProductsParams, ListProductsResponse, RetrieveProductParams, RetrieveProductResponse } from '@betterstore/bridge';
1
2
  import axios from 'axios';
2
- import { GetShippingRatesResponse, ListCollectionsParams, ListCollectionsResponse, RetrieveCollectionParams, RetrieveCollectionResponse, ListDiscountsParams, ListDiscountsResponse, RetrieveDiscountParams, RetrieveDiscountResponse, ListProductsParams, ListProductsResponse, RetrieveProductParams, RetrieveProductResponse } from '@betterstore/bridge';
3
3
 
4
4
  declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
5
5
 
6
- interface Discount {
7
- id: string;
8
- createdAt: Date;
9
- updatedAt: Date;
10
- type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
11
- method: "CODE" | "AUTOMATIC";
12
- code?: string | null;
13
- title?: string | null;
14
- value: number;
15
- valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
16
- discountScope: "PRODUCTS" | "COLLECTIONS";
17
- allowedProductIDs: string[];
18
- allowedCollectionIDs: string[];
19
- allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
20
- minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
21
- minimumRequirementsValue?: number | null;
22
- requiredProductIDs: string[];
23
- requiredCollectionIDs: string[];
24
- minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
25
- maxUses?: number | null;
26
- maxUsesPerCustomer?: number | null;
27
- maxAllowedProductQuantity?: number | null;
28
- uses: number;
29
- subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
30
- subscriptionDiscountDurationValue: number;
31
- stripeDiscountId?: string | null;
32
- startsAt: Date;
33
- expiresAt?: Date | null;
34
- status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
35
- organizationId: string;
36
- }
37
- interface VariantOption {
38
- name: string;
39
- value: string;
40
- }
41
- interface ProductVariant {
42
- title: string;
43
- description?: string;
44
- images: string[];
45
- sku?: string;
46
- barcode?: string;
47
- inventoryItem: {
48
- stockPolicy: "CONTINUE" | "DENY";
49
- trackInventory: boolean;
50
- };
51
- isPhysical: boolean;
52
- weightInGrams?: number;
53
- heightInCm?: number;
54
- widthInCm?: number;
55
- lengthInCm?: number;
56
- priceInCents: number;
57
- billingType: ProductBillingType;
58
- billingInterval: ProductBillingInterval;
59
- billingIntervalCount: number;
60
- metadata?: Record<string, any>;
61
- variantOptions: VariantOption[];
62
- }
63
- interface ProductOption {
64
- name: string;
65
- values: string[];
66
- }
67
- type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
68
- type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
69
- type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
70
- interface Product {
71
- id: string;
72
- createdAt: Date;
73
- updatedAt: Date;
74
- title: string;
75
- description?: string;
76
- images: string[];
77
- category: string;
78
- tags: string[];
79
- isPhysical: boolean;
80
- weightInGrams?: number;
81
- heightInCm?: number;
82
- widthInCm?: number;
83
- lengthInCm?: number;
84
- priceInCents: number;
85
- billingType: ProductBillingType;
86
- billingInterval: ProductBillingInterval;
87
- billingIntervalCount: number;
88
- sku?: string;
89
- barcode?: string;
90
- inventoryItem: {
91
- stockPolicy: "CONTINUE" | "DENY";
92
- trackInventory: boolean;
93
- };
94
- seoPageTitle?: string;
95
- seoDescription?: string;
96
- seoHandle?: string;
97
- vendor?: string;
98
- metadata?: Record<string, any>;
99
- status: ProductStatus;
100
- options: ProductOption[];
101
- productVariants: ProductVariant[];
102
- }
103
- interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
104
- }
105
-
106
- type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
107
- productId: string;
108
- selectedVariant: Pick<ProductVariant, "title" | "description" | "sku" | "barcode" | "images" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount" | "variantOptions" | "metadata">;
109
- };
110
- interface LineItem {
111
- quantity: number;
112
- variantOptions: {
113
- name: string;
114
- value: string;
115
- }[];
116
- productData: ProductData;
117
- metadata?: string;
118
- }
119
- interface LineItemCreate extends Omit<LineItem, "productData" | "product" | "metadata" | "variantOptions"> {
120
- variantOptions?: {
121
- name: string;
122
- value: string;
123
- }[];
124
- productId: string;
125
- product?: ProductWithoutVariants;
126
- metadata?: Record<string, any>;
127
- }
128
- type Currency = string;
129
- interface CheckoutCreateParams {
130
- type: "hosted" | "embed";
131
- customerId?: string;
132
- lineItems: LineItemCreate[];
133
- currency?: Currency;
134
- discountCodes?: string[];
135
- }
136
- interface CheckoutUpdateParams {
137
- customerId?: string;
138
- shipments?: CheckoutShipment[];
139
- }
140
- type ShipmentData = {
141
- rateId: string;
142
- providerId?: string;
143
- priceInCents: number;
144
- pickupPointId?: string;
145
- trackingId?: string;
146
- trackingUrl?: string;
147
- };
148
- type CheckoutShipment = {
149
- id: string;
150
- shipmentData?: ShipmentData | null;
151
- };
152
- interface CheckoutSession {
153
- id: string;
154
- testmode: boolean;
155
- clientSecret: string;
156
- customer?: {
157
- id: string;
158
- address?: Address;
159
- email?: string;
160
- };
161
- lineItems: LineItem[];
162
- tax: number | null;
163
- discountAmount: number | null;
164
- appliedDiscounts: {
165
- id: string;
166
- amount: number;
167
- allowedLineItems: {
168
- productId: string;
169
- quantity: number;
170
- }[];
171
- discount: Discount;
172
- }[];
173
- currency: string;
174
- exchangeRate: number | null;
175
- shipments: CheckoutShipment[];
176
- status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
177
- }
178
-
179
- type AutosuggestAddressResult = {
180
- id: string;
181
- title: string;
182
- address: {
183
- label: string;
184
- };
185
- position: {
186
- lat: number;
187
- lng: number;
188
- };
189
- };
190
- type LookupAddressResult = {
191
- id: string;
192
- title: string;
193
- address: Pick<Address, "line1" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
194
- };
195
-
196
- type Address = {
197
- name: string;
198
- phone: string;
199
- line1: string;
200
- line2?: string;
201
- city: string;
202
- province?: string;
203
- provinceCode?: string;
204
- country: string;
205
- countryCode: string;
206
- zipCode: string;
207
- };
208
- interface CustomerCreateParams {
209
- firstName?: string;
210
- lastName?: string;
211
- email: string;
212
- phone?: string;
213
- address?: Address;
214
- image?: string;
215
- password?: string;
216
- metadata?: Record<string, any>;
217
- tags?: string[];
218
- notes?: string;
219
- isSubscribedEmail?: boolean;
220
- isSubscribedSMS?: boolean;
221
- }
222
- interface CustomerUpdateParams extends Omit<CustomerCreateParams, "email"> {
223
- email?: string;
224
- }
225
- interface Customer$1 extends CustomerCreateParams {
226
- id: string;
227
- createdAt: string;
228
- updatedAt: string;
229
- }
230
- interface CustomerSubscription {
231
- cancelAtPeriodEnd: boolean;
232
- }
233
- type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
234
-
235
- interface CustomerSession {
236
- customerId: string;
237
- expiresAt: Date;
238
- testmode: boolean;
239
- token: string;
240
- customer: {
241
- createdAt: Date;
242
- updatedAt: Date;
243
- firstName: string;
244
- lastName: string;
245
- email: string;
246
- phone?: string;
247
- password?: string;
248
- image?: string;
249
- metadata?: string;
250
- stripeCustomerId: string;
251
- isSubscribedEmail: boolean;
252
- isSubscribedSMS: boolean;
253
- address: Address;
254
- };
255
- }
256
- interface OTPLoginParams {
257
- email: string;
258
- }
259
- interface OTPSignupParams extends CustomerCreateParams {
260
- }
261
- interface OTPVerifyParams {
262
- email: string;
263
- otp: string;
264
- }
265
- type OTPLoginResponse = {
266
- success: true;
267
- token: string;
268
- } | {
269
- success: false;
270
- code: "BAD_REQUEST" | "CUSTOMER_NOT_FOUND";
271
- error: string;
272
- };
273
- type OTPSignupResponse = {
274
- success: true;
275
- token: string;
276
- } | {
277
- success: false;
278
- code: "BAD_REQUEST" | "CUSTOMER_ALREADY_EXISTS";
279
- error: string;
280
- };
281
- type OTPVerifyResponse = {
282
- success: true;
283
- customerSession: CustomerSession;
284
- } | {
285
- success: false;
286
- code: "BAD_REQUEST";
287
- error: string;
288
- };
289
-
290
6
  declare class OTP {
291
7
  private apiClient;
292
8
  constructor(apiClient: ReturnType<typeof createApiClient>);
@@ -381,15 +97,15 @@ declare class Client {
381
97
  /**
382
98
  * Create a new customer
383
99
  */
384
- createCustomer(clientSecret: string, params: CustomerCreateParams): Promise<Customer$1>;
100
+ createCustomer(clientSecret: string, params: CustomerCreateParams): Promise<CustomerResponse>;
385
101
  /**
386
102
  * Retrieve a customer by ID or email
387
103
  */
388
- retrieveCustomer(clientSecret: string, idOrEmail: string): Promise<Customer$1 | null>;
104
+ retrieveCustomer(clientSecret: string, idOrEmail: string): Promise<CustomerResponse | null>;
389
105
  /**
390
106
  * Update a customer
391
107
  */
392
- updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
108
+ updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<CustomerResponse | null>;
393
109
  /**
394
110
  * Get exchange rate for a currency
395
111
  */
@@ -423,15 +139,15 @@ declare class Customer {
423
139
  /**
424
140
  * Create a new customer
425
141
  */
426
- create(params: CustomerCreateParams): Promise<Customer$1>;
142
+ create(params: CustomerCreateParams): Promise<CustomerResponse>;
427
143
  /**
428
144
  * Retrieve a customer by ID or email
429
145
  */
430
- retrieve(idOrEmail: string): Promise<Customer$1 | null>;
146
+ retrieve(idOrEmail: string): Promise<CustomerResponse | null>;
431
147
  /**
432
148
  * Update a customer
433
149
  */
434
- update(customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
150
+ update(customerId: string, params: CustomerUpdateParams): Promise<CustomerResponse | null>;
435
151
  /**
436
152
  * Delete a customer
437
153
  */
@@ -449,13 +165,6 @@ declare class Discounts {
449
165
  retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
450
166
  }
451
167
 
452
- declare class Helpers {
453
- proxy?: string;
454
- constructor(proxy?: string);
455
- formatCurrency(currency: string): string;
456
- formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
457
- }
458
-
459
168
  declare class Products {
460
169
  private apiClient;
461
170
  constructor(apiKey: string, proxy?: string);
@@ -477,8 +186,5 @@ declare function createBetterStore(config: {
477
186
  declare function createStoreClient(config?: {
478
187
  proxy?: string;
479
188
  }): Client;
480
- declare function createStoreHelpers(config?: {
481
- proxy?: string;
482
- }): Helpers;
483
189
 
484
- export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSession, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type LineItem, type LineItemCreate, type LookupAddressResult, type OTPLoginParams, type OTPLoginResponse, type OTPSignupParams, type OTPSignupResponse, type OTPVerifyParams, type OTPVerifyResponse, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
190
+ export { createStoreClient, createBetterStore as default };
package/dist/index.d.ts CHANGED
@@ -1,292 +1,8 @@
1
+ import { OTPSignupParams, OTPSignupResponse, OTPLoginParams, OTPLoginResponse, OTPVerifyParams, OTPVerifyResponse, CustomerSession, CheckoutCreateParams, CheckoutSession, CheckoutUpdateParams, GetShippingRatesResponse, CustomerCreateParams, CustomerResponse, CustomerUpdateParams, AutosuggestAddressResult, LookupAddressResult, ListCollectionsParams, ListCollectionsResponse, RetrieveCollectionParams, RetrieveCollectionResponse, CustomerSubscriptionUpdateParams, CustomerSubscription, ListDiscountsParams, ListDiscountsResponse, RetrieveDiscountParams, RetrieveDiscountResponse, ListProductsParams, ListProductsResponse, RetrieveProductParams, RetrieveProductResponse } from '@betterstore/bridge';
1
2
  import axios from 'axios';
2
- import { GetShippingRatesResponse, ListCollectionsParams, ListCollectionsResponse, RetrieveCollectionParams, RetrieveCollectionResponse, ListDiscountsParams, ListDiscountsResponse, RetrieveDiscountParams, RetrieveDiscountResponse, ListProductsParams, ListProductsResponse, RetrieveProductParams, RetrieveProductResponse } from '@betterstore/bridge';
3
3
 
4
4
  declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
5
5
 
6
- interface Discount {
7
- id: string;
8
- createdAt: Date;
9
- updatedAt: Date;
10
- type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
11
- method: "CODE" | "AUTOMATIC";
12
- code?: string | null;
13
- title?: string | null;
14
- value: number;
15
- valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
16
- discountScope: "PRODUCTS" | "COLLECTIONS";
17
- allowedProductIDs: string[];
18
- allowedCollectionIDs: string[];
19
- allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
20
- minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
21
- minimumRequirementsValue?: number | null;
22
- requiredProductIDs: string[];
23
- requiredCollectionIDs: string[];
24
- minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
25
- maxUses?: number | null;
26
- maxUsesPerCustomer?: number | null;
27
- maxAllowedProductQuantity?: number | null;
28
- uses: number;
29
- subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
30
- subscriptionDiscountDurationValue: number;
31
- stripeDiscountId?: string | null;
32
- startsAt: Date;
33
- expiresAt?: Date | null;
34
- status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
35
- organizationId: string;
36
- }
37
- interface VariantOption {
38
- name: string;
39
- value: string;
40
- }
41
- interface ProductVariant {
42
- title: string;
43
- description?: string;
44
- images: string[];
45
- sku?: string;
46
- barcode?: string;
47
- inventoryItem: {
48
- stockPolicy: "CONTINUE" | "DENY";
49
- trackInventory: boolean;
50
- };
51
- isPhysical: boolean;
52
- weightInGrams?: number;
53
- heightInCm?: number;
54
- widthInCm?: number;
55
- lengthInCm?: number;
56
- priceInCents: number;
57
- billingType: ProductBillingType;
58
- billingInterval: ProductBillingInterval;
59
- billingIntervalCount: number;
60
- metadata?: Record<string, any>;
61
- variantOptions: VariantOption[];
62
- }
63
- interface ProductOption {
64
- name: string;
65
- values: string[];
66
- }
67
- type ProductStatus = "DRAFT" | "ACTIVE" | "ARCHIVED";
68
- type ProductBillingInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
69
- type ProductBillingType = "ONE_TIME" | "SUBSCRIPTION";
70
- interface Product {
71
- id: string;
72
- createdAt: Date;
73
- updatedAt: Date;
74
- title: string;
75
- description?: string;
76
- images: string[];
77
- category: string;
78
- tags: string[];
79
- isPhysical: boolean;
80
- weightInGrams?: number;
81
- heightInCm?: number;
82
- widthInCm?: number;
83
- lengthInCm?: number;
84
- priceInCents: number;
85
- billingType: ProductBillingType;
86
- billingInterval: ProductBillingInterval;
87
- billingIntervalCount: number;
88
- sku?: string;
89
- barcode?: string;
90
- inventoryItem: {
91
- stockPolicy: "CONTINUE" | "DENY";
92
- trackInventory: boolean;
93
- };
94
- seoPageTitle?: string;
95
- seoDescription?: string;
96
- seoHandle?: string;
97
- vendor?: string;
98
- metadata?: Record<string, any>;
99
- status: ProductStatus;
100
- options: ProductOption[];
101
- productVariants: ProductVariant[];
102
- }
103
- interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
104
- }
105
-
106
- type ProductData = Pick<Product, "title" | "description" | "images" | "category" | "tags" | "sku" | "barcode" | "vendor" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount"> & {
107
- productId: string;
108
- selectedVariant: Pick<ProductVariant, "title" | "description" | "sku" | "barcode" | "images" | "isPhysical" | "weightInGrams" | "heightInCm" | "widthInCm" | "lengthInCm" | "priceInCents" | "billingType" | "billingInterval" | "billingIntervalCount" | "variantOptions" | "metadata">;
109
- };
110
- interface LineItem {
111
- quantity: number;
112
- variantOptions: {
113
- name: string;
114
- value: string;
115
- }[];
116
- productData: ProductData;
117
- metadata?: string;
118
- }
119
- interface LineItemCreate extends Omit<LineItem, "productData" | "product" | "metadata" | "variantOptions"> {
120
- variantOptions?: {
121
- name: string;
122
- value: string;
123
- }[];
124
- productId: string;
125
- product?: ProductWithoutVariants;
126
- metadata?: Record<string, any>;
127
- }
128
- type Currency = string;
129
- interface CheckoutCreateParams {
130
- type: "hosted" | "embed";
131
- customerId?: string;
132
- lineItems: LineItemCreate[];
133
- currency?: Currency;
134
- discountCodes?: string[];
135
- }
136
- interface CheckoutUpdateParams {
137
- customerId?: string;
138
- shipments?: CheckoutShipment[];
139
- }
140
- type ShipmentData = {
141
- rateId: string;
142
- providerId?: string;
143
- priceInCents: number;
144
- pickupPointId?: string;
145
- trackingId?: string;
146
- trackingUrl?: string;
147
- };
148
- type CheckoutShipment = {
149
- id: string;
150
- shipmentData?: ShipmentData | null;
151
- };
152
- interface CheckoutSession {
153
- id: string;
154
- testmode: boolean;
155
- clientSecret: string;
156
- customer?: {
157
- id: string;
158
- address?: Address;
159
- email?: string;
160
- };
161
- lineItems: LineItem[];
162
- tax: number | null;
163
- discountAmount: number | null;
164
- appliedDiscounts: {
165
- id: string;
166
- amount: number;
167
- allowedLineItems: {
168
- productId: string;
169
- quantity: number;
170
- }[];
171
- discount: Discount;
172
- }[];
173
- currency: string;
174
- exchangeRate: number | null;
175
- shipments: CheckoutShipment[];
176
- status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
177
- }
178
-
179
- type AutosuggestAddressResult = {
180
- id: string;
181
- title: string;
182
- address: {
183
- label: string;
184
- };
185
- position: {
186
- lat: number;
187
- lng: number;
188
- };
189
- };
190
- type LookupAddressResult = {
191
- id: string;
192
- title: string;
193
- address: Pick<Address, "line1" | "city" | "province" | "provinceCode" | "country" | "countryCode" | "zipCode">;
194
- };
195
-
196
- type Address = {
197
- name: string;
198
- phone: string;
199
- line1: string;
200
- line2?: string;
201
- city: string;
202
- province?: string;
203
- provinceCode?: string;
204
- country: string;
205
- countryCode: string;
206
- zipCode: string;
207
- };
208
- interface CustomerCreateParams {
209
- firstName?: string;
210
- lastName?: string;
211
- email: string;
212
- phone?: string;
213
- address?: Address;
214
- image?: string;
215
- password?: string;
216
- metadata?: Record<string, any>;
217
- tags?: string[];
218
- notes?: string;
219
- isSubscribedEmail?: boolean;
220
- isSubscribedSMS?: boolean;
221
- }
222
- interface CustomerUpdateParams extends Omit<CustomerCreateParams, "email"> {
223
- email?: string;
224
- }
225
- interface Customer$1 extends CustomerCreateParams {
226
- id: string;
227
- createdAt: string;
228
- updatedAt: string;
229
- }
230
- interface CustomerSubscription {
231
- cancelAtPeriodEnd: boolean;
232
- }
233
- type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
234
-
235
- interface CustomerSession {
236
- customerId: string;
237
- expiresAt: Date;
238
- testmode: boolean;
239
- token: string;
240
- customer: {
241
- createdAt: Date;
242
- updatedAt: Date;
243
- firstName: string;
244
- lastName: string;
245
- email: string;
246
- phone?: string;
247
- password?: string;
248
- image?: string;
249
- metadata?: string;
250
- stripeCustomerId: string;
251
- isSubscribedEmail: boolean;
252
- isSubscribedSMS: boolean;
253
- address: Address;
254
- };
255
- }
256
- interface OTPLoginParams {
257
- email: string;
258
- }
259
- interface OTPSignupParams extends CustomerCreateParams {
260
- }
261
- interface OTPVerifyParams {
262
- email: string;
263
- otp: string;
264
- }
265
- type OTPLoginResponse = {
266
- success: true;
267
- token: string;
268
- } | {
269
- success: false;
270
- code: "BAD_REQUEST" | "CUSTOMER_NOT_FOUND";
271
- error: string;
272
- };
273
- type OTPSignupResponse = {
274
- success: true;
275
- token: string;
276
- } | {
277
- success: false;
278
- code: "BAD_REQUEST" | "CUSTOMER_ALREADY_EXISTS";
279
- error: string;
280
- };
281
- type OTPVerifyResponse = {
282
- success: true;
283
- customerSession: CustomerSession;
284
- } | {
285
- success: false;
286
- code: "BAD_REQUEST";
287
- error: string;
288
- };
289
-
290
6
  declare class OTP {
291
7
  private apiClient;
292
8
  constructor(apiClient: ReturnType<typeof createApiClient>);
@@ -381,15 +97,15 @@ declare class Client {
381
97
  /**
382
98
  * Create a new customer
383
99
  */
384
- createCustomer(clientSecret: string, params: CustomerCreateParams): Promise<Customer$1>;
100
+ createCustomer(clientSecret: string, params: CustomerCreateParams): Promise<CustomerResponse>;
385
101
  /**
386
102
  * Retrieve a customer by ID or email
387
103
  */
388
- retrieveCustomer(clientSecret: string, idOrEmail: string): Promise<Customer$1 | null>;
104
+ retrieveCustomer(clientSecret: string, idOrEmail: string): Promise<CustomerResponse | null>;
389
105
  /**
390
106
  * Update a customer
391
107
  */
392
- updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
108
+ updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<CustomerResponse | null>;
393
109
  /**
394
110
  * Get exchange rate for a currency
395
111
  */
@@ -423,15 +139,15 @@ declare class Customer {
423
139
  /**
424
140
  * Create a new customer
425
141
  */
426
- create(params: CustomerCreateParams): Promise<Customer$1>;
142
+ create(params: CustomerCreateParams): Promise<CustomerResponse>;
427
143
  /**
428
144
  * Retrieve a customer by ID or email
429
145
  */
430
- retrieve(idOrEmail: string): Promise<Customer$1 | null>;
146
+ retrieve(idOrEmail: string): Promise<CustomerResponse | null>;
431
147
  /**
432
148
  * Update a customer
433
149
  */
434
- update(customerId: string, params: CustomerUpdateParams): Promise<Customer$1 | null>;
150
+ update(customerId: string, params: CustomerUpdateParams): Promise<CustomerResponse | null>;
435
151
  /**
436
152
  * Delete a customer
437
153
  */
@@ -449,13 +165,6 @@ declare class Discounts {
449
165
  retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
450
166
  }
451
167
 
452
- declare class Helpers {
453
- proxy?: string;
454
- constructor(proxy?: string);
455
- formatCurrency(currency: string): string;
456
- formatPrice(priceInCents: number, currency: string, exchangeRate?: number | null): string;
457
- }
458
-
459
168
  declare class Products {
460
169
  private apiClient;
461
170
  constructor(apiKey: string, proxy?: string);
@@ -477,8 +186,5 @@ declare function createBetterStore(config: {
477
186
  declare function createStoreClient(config?: {
478
187
  proxy?: string;
479
188
  }): Client;
480
- declare function createStoreHelpers(config?: {
481
- proxy?: string;
482
- }): Helpers;
483
189
 
484
- export { type Address, type AutosuggestAddressResult, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSession, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type LineItem, type LineItemCreate, type LookupAddressResult, type OTPLoginParams, type OTPLoginResponse, type OTPSignupParams, type OTPSignupResponse, type OTPVerifyParams, type OTPVerifyResponse, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
190
+ export { createStoreClient, createBetterStore as default };
package/dist/index.js CHANGED
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  createStoreClient: () => createStoreClient,
34
- createStoreHelpers: () => createStoreHelpers,
35
34
  default: () => createBetterStore
36
35
  });
37
36
  module.exports = __toCommonJS(index_exports);
@@ -556,101 +555,6 @@ var Discounts = class {
556
555
  };
557
556
  var discounts_default = Discounts;
558
557
 
559
- // src/helpers/index.ts
560
- var currencyLocales = {
561
- CZK: "cs-CZ",
562
- // Czech Koruna
563
- USD: "en-US",
564
- // US Dollar
565
- EUR: "de-DE",
566
- // Euro (Germany locale)
567
- GBP: "en-GB",
568
- // British Pound
569
- JPY: "ja-JP",
570
- // Japanese Yen
571
- AUD: "en-AU",
572
- // Australian Dollar
573
- CAD: "en-CA",
574
- // Canadian Dollar
575
- NZD: "en-NZ",
576
- // New Zealand Dollar
577
- SEK: "sv-SE",
578
- // Swedish Krona
579
- NOK: "nb-NO",
580
- // Norwegian Krone
581
- DKK: "da-DK",
582
- // Danish Krone
583
- CHF: "de-CH",
584
- // Swiss Franc (German Switzerland)
585
- HUF: "hu-HU",
586
- // Hungarian Forint
587
- PLN: "pl-PL",
588
- // Polish Zloty
589
- BGN: "bg-BG",
590
- // Bulgarian Lev
591
- RON: "ro-RO",
592
- // Romanian Leu
593
- RUB: "ru-RU",
594
- // Russian Ruble
595
- CNY: "zh-CN",
596
- // Chinese Yuan
597
- INR: "en-IN",
598
- // Indian Rupee
599
- BRL: "pt-BR",
600
- // Brazilian Real
601
- MXN: "es-MX",
602
- // Mexican Peso
603
- ZAR: "en-ZA",
604
- // South African Rand
605
- KRW: "ko-KR",
606
- // South Korean Won
607
- MYR: "ms-MY",
608
- // Malaysian Ringgit
609
- SGD: "en-SG",
610
- // Singapore Dollar
611
- TWD: "zh-TW",
612
- // Taiwanese Dollar
613
- THB: "th-TH",
614
- // Thai Baht
615
- IDR: "id-ID",
616
- // Indonesian Rupiah
617
- AED: "ar-AE",
618
- // UAE Dirham
619
- SAR: "ar-SA",
620
- // Saudi Riyal
621
- TRY: "tr-TR"
622
- // Turkish Lira
623
- };
624
- var Helpers = class {
625
- proxy;
626
- constructor(proxy) {
627
- this.proxy = proxy;
628
- }
629
- formatCurrency(currency) {
630
- const locale = currencyLocales[currency.toUpperCase()] ?? void 0;
631
- const formattedCurrency = new Intl.NumberFormat(locale, {
632
- style: "currency",
633
- currency,
634
- currencyDisplay: "symbol"
635
- });
636
- return formattedCurrency.format(0).replace(/[\d.,\s]/g, "").trim();
637
- }
638
- formatPrice(priceInCents, currency, exchangeRate) {
639
- const amount = priceInCents / 100 * (exchangeRate ?? 1);
640
- const isWhole = amount % 1 === 0;
641
- const locale = currencyLocales[currency.toUpperCase()] ?? void 0;
642
- const formattedPrice = new Intl.NumberFormat(locale, {
643
- style: "currency",
644
- currency,
645
- currencyDisplay: "symbol",
646
- minimumFractionDigits: isWhole ? 0 : 2,
647
- maximumFractionDigits: isWhole ? 0 : 2
648
- }).format(amount);
649
- return formattedPrice;
650
- }
651
- };
652
- var helpers_default = Helpers;
653
-
654
558
  // src/products/index.ts
655
559
  var Products = class {
656
560
  apiClient;
@@ -697,11 +601,7 @@ function createBetterStore(config) {
697
601
  function createStoreClient(config) {
698
602
  return new client_default(config?.proxy);
699
603
  }
700
- function createStoreHelpers(config) {
701
- return new helpers_default(config?.proxy);
702
- }
703
604
  // Annotate the CommonJS export names for ESM import in node:
704
605
  0 && (module.exports = {
705
- createStoreClient,
706
- createStoreHelpers
606
+ createStoreClient
707
607
  });
package/dist/index.mjs CHANGED
@@ -518,101 +518,6 @@ var Discounts = class {
518
518
  };
519
519
  var discounts_default = Discounts;
520
520
 
521
- // src/helpers/index.ts
522
- var currencyLocales = {
523
- CZK: "cs-CZ",
524
- // Czech Koruna
525
- USD: "en-US",
526
- // US Dollar
527
- EUR: "de-DE",
528
- // Euro (Germany locale)
529
- GBP: "en-GB",
530
- // British Pound
531
- JPY: "ja-JP",
532
- // Japanese Yen
533
- AUD: "en-AU",
534
- // Australian Dollar
535
- CAD: "en-CA",
536
- // Canadian Dollar
537
- NZD: "en-NZ",
538
- // New Zealand Dollar
539
- SEK: "sv-SE",
540
- // Swedish Krona
541
- NOK: "nb-NO",
542
- // Norwegian Krone
543
- DKK: "da-DK",
544
- // Danish Krone
545
- CHF: "de-CH",
546
- // Swiss Franc (German Switzerland)
547
- HUF: "hu-HU",
548
- // Hungarian Forint
549
- PLN: "pl-PL",
550
- // Polish Zloty
551
- BGN: "bg-BG",
552
- // Bulgarian Lev
553
- RON: "ro-RO",
554
- // Romanian Leu
555
- RUB: "ru-RU",
556
- // Russian Ruble
557
- CNY: "zh-CN",
558
- // Chinese Yuan
559
- INR: "en-IN",
560
- // Indian Rupee
561
- BRL: "pt-BR",
562
- // Brazilian Real
563
- MXN: "es-MX",
564
- // Mexican Peso
565
- ZAR: "en-ZA",
566
- // South African Rand
567
- KRW: "ko-KR",
568
- // South Korean Won
569
- MYR: "ms-MY",
570
- // Malaysian Ringgit
571
- SGD: "en-SG",
572
- // Singapore Dollar
573
- TWD: "zh-TW",
574
- // Taiwanese Dollar
575
- THB: "th-TH",
576
- // Thai Baht
577
- IDR: "id-ID",
578
- // Indonesian Rupiah
579
- AED: "ar-AE",
580
- // UAE Dirham
581
- SAR: "ar-SA",
582
- // Saudi Riyal
583
- TRY: "tr-TR"
584
- // Turkish Lira
585
- };
586
- var Helpers = class {
587
- proxy;
588
- constructor(proxy) {
589
- this.proxy = proxy;
590
- }
591
- formatCurrency(currency) {
592
- const locale = currencyLocales[currency.toUpperCase()] ?? void 0;
593
- const formattedCurrency = new Intl.NumberFormat(locale, {
594
- style: "currency",
595
- currency,
596
- currencyDisplay: "symbol"
597
- });
598
- return formattedCurrency.format(0).replace(/[\d.,\s]/g, "").trim();
599
- }
600
- formatPrice(priceInCents, currency, exchangeRate) {
601
- const amount = priceInCents / 100 * (exchangeRate ?? 1);
602
- const isWhole = amount % 1 === 0;
603
- const locale = currencyLocales[currency.toUpperCase()] ?? void 0;
604
- const formattedPrice = new Intl.NumberFormat(locale, {
605
- style: "currency",
606
- currency,
607
- currencyDisplay: "symbol",
608
- minimumFractionDigits: isWhole ? 0 : 2,
609
- maximumFractionDigits: isWhole ? 0 : 2
610
- }).format(amount);
611
- return formattedPrice;
612
- }
613
- };
614
- var helpers_default = Helpers;
615
-
616
521
  // src/products/index.ts
617
522
  var Products = class {
618
523
  apiClient;
@@ -659,11 +564,7 @@ function createBetterStore(config) {
659
564
  function createStoreClient(config) {
660
565
  return new client_default(config?.proxy);
661
566
  }
662
- function createStoreHelpers(config) {
663
- return new helpers_default(config?.proxy);
664
- }
665
567
  export {
666
568
  createStoreClient,
667
- createStoreHelpers,
668
569
  createBetterStore as default
669
570
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.5.25",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -18,7 +18,7 @@
18
18
  "@betterstore/typescript-config": "0.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "@betterstore/bridge": "^0.0.2",
21
+ "@betterstore/bridge": "^0.0.23",
22
22
  "axios": "^1.8.2",
23
23
  "zod": "^3.24.2"
24
24
  },