@betterstore/sdk 0.3.70 → 0.3.72
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 +12 -0
- package/dist/index.d.mts +116 -87
- package/dist/index.d.ts +116 -87
- package/dist/index.js +90 -38
- package/dist/index.mjs +90 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
type Address = {
|
|
2
|
-
name: string;
|
|
3
|
-
company?: string;
|
|
4
|
-
line1: string;
|
|
5
|
-
line2?: string;
|
|
6
|
-
city: string;
|
|
7
|
-
state?: string;
|
|
8
|
-
country: string;
|
|
9
|
-
countryCode: string;
|
|
10
|
-
zipCode: string;
|
|
11
|
-
phone: string;
|
|
12
|
-
};
|
|
13
|
-
interface CustomerCreateParams {
|
|
14
|
-
firstName: string;
|
|
15
|
-
lastName: string;
|
|
16
|
-
email: string;
|
|
17
|
-
phone?: string;
|
|
18
|
-
address?: Address;
|
|
19
|
-
isSubscribedEmail?: boolean;
|
|
20
|
-
isSubscribedSMS?: boolean;
|
|
21
|
-
}
|
|
22
|
-
interface CustomerUpdateParams {
|
|
23
|
-
firstName?: string;
|
|
24
|
-
lastName?: string;
|
|
25
|
-
email?: string;
|
|
26
|
-
phone?: string;
|
|
27
|
-
address?: Address;
|
|
28
|
-
isSubscribedEmail?: boolean;
|
|
29
|
-
isSubscribedSMS?: boolean;
|
|
30
|
-
}
|
|
31
|
-
interface Customer$1 extends CustomerCreateParams {
|
|
32
|
-
id: string;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
updatedAt: string;
|
|
35
|
-
}
|
|
36
|
-
interface CustomerSubscription {
|
|
37
|
-
cancelAtPeriodEnd: boolean;
|
|
38
|
-
}
|
|
39
|
-
type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
|
|
40
|
-
|
|
41
1
|
interface VariantOption {
|
|
42
2
|
name: string;
|
|
43
3
|
value: string;
|
|
@@ -101,6 +61,24 @@ interface Product {
|
|
|
101
61
|
}
|
|
102
62
|
interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
|
|
103
63
|
}
|
|
64
|
+
type ListProductsQuery = {
|
|
65
|
+
collectionId: string;
|
|
66
|
+
} | {
|
|
67
|
+
collectionSeoHandle: string;
|
|
68
|
+
};
|
|
69
|
+
type SortBy = "createdAt" | "updatedAt";
|
|
70
|
+
type SortOrder = "asc" | "desc";
|
|
71
|
+
type ListProductsParams = {
|
|
72
|
+
sortBy?: SortBy;
|
|
73
|
+
sortOrder?: SortOrder;
|
|
74
|
+
query?: string;
|
|
75
|
+
};
|
|
76
|
+
type RetrieveProductParams = {
|
|
77
|
+
seoHandle: string;
|
|
78
|
+
} | {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
104
82
|
interface Collection {
|
|
105
83
|
id: string;
|
|
106
84
|
title: string;
|
|
@@ -113,17 +91,87 @@ interface Collection {
|
|
|
113
91
|
interface CollectionWithProducts extends Collection {
|
|
114
92
|
products: ProductWithoutVariants[];
|
|
115
93
|
}
|
|
116
|
-
type
|
|
117
|
-
|
|
94
|
+
type RetrieveCollectionParams = {
|
|
95
|
+
seoHandle: string;
|
|
118
96
|
} | {
|
|
119
|
-
|
|
97
|
+
id: string;
|
|
120
98
|
};
|
|
121
|
-
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
99
|
+
|
|
100
|
+
type Address = {
|
|
101
|
+
name: string;
|
|
102
|
+
company?: string;
|
|
103
|
+
line1: string;
|
|
104
|
+
line2?: string;
|
|
105
|
+
city: string;
|
|
106
|
+
state?: string;
|
|
107
|
+
country: string;
|
|
108
|
+
countryCode: string;
|
|
109
|
+
zipCode: string;
|
|
110
|
+
phone: string;
|
|
111
|
+
};
|
|
112
|
+
interface CustomerCreateParams {
|
|
113
|
+
firstName: string;
|
|
114
|
+
lastName: string;
|
|
115
|
+
email: string;
|
|
116
|
+
phone?: string;
|
|
117
|
+
address?: Address;
|
|
118
|
+
isSubscribedEmail?: boolean;
|
|
119
|
+
isSubscribedSMS?: boolean;
|
|
120
|
+
}
|
|
121
|
+
interface CustomerUpdateParams {
|
|
122
|
+
firstName?: string;
|
|
123
|
+
lastName?: string;
|
|
124
|
+
email?: string;
|
|
125
|
+
phone?: string;
|
|
126
|
+
address?: Address;
|
|
127
|
+
isSubscribedEmail?: boolean;
|
|
128
|
+
isSubscribedSMS?: boolean;
|
|
129
|
+
}
|
|
130
|
+
interface Customer$1 extends CustomerCreateParams {
|
|
131
|
+
id: string;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
}
|
|
135
|
+
interface CustomerSubscription {
|
|
136
|
+
cancelAtPeriodEnd: boolean;
|
|
137
|
+
}
|
|
138
|
+
type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
|
|
139
|
+
|
|
140
|
+
interface Discount {
|
|
141
|
+
id: string;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
|
|
145
|
+
method: "CODE" | "AUTOMATIC";
|
|
146
|
+
code?: string | null;
|
|
147
|
+
title?: string | null;
|
|
148
|
+
value: number;
|
|
149
|
+
valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
|
|
150
|
+
discountScope: "PRODUCTS" | "COLLECTIONS";
|
|
151
|
+
allowedProductIDs: string[];
|
|
152
|
+
allowedCollectionIDs: string[];
|
|
153
|
+
allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
|
|
154
|
+
minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
|
|
155
|
+
minimumRequirementsValue?: number | null;
|
|
156
|
+
requiredProductIDs: string[];
|
|
157
|
+
requiredCollectionIDs: string[];
|
|
158
|
+
minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
|
|
159
|
+
maxUses?: number | null;
|
|
160
|
+
maxUsesPerCustomer?: number | null;
|
|
161
|
+
maxAllowedProductQuantity?: number | null;
|
|
162
|
+
uses: number;
|
|
163
|
+
subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
|
|
164
|
+
subscriptionDiscountDurationValue: number;
|
|
165
|
+
stripeDiscountId?: string | null;
|
|
166
|
+
startsAt: Date;
|
|
167
|
+
expiresAt?: Date | null;
|
|
168
|
+
status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
|
|
169
|
+
organizationId: string;
|
|
170
|
+
}
|
|
171
|
+
type RetrieveDiscountParams = {
|
|
172
|
+
id: string;
|
|
173
|
+
} | {
|
|
174
|
+
code: string;
|
|
127
175
|
};
|
|
128
176
|
|
|
129
177
|
type ShippingRate = ZasilkovnaRate;
|
|
@@ -186,37 +234,6 @@ type ShipmentData = {
|
|
|
186
234
|
trackingId?: string;
|
|
187
235
|
trackingUrl?: string;
|
|
188
236
|
};
|
|
189
|
-
type Discount = {
|
|
190
|
-
id: string;
|
|
191
|
-
createdAt: Date;
|
|
192
|
-
updatedAt: Date;
|
|
193
|
-
type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
|
|
194
|
-
method: "CODE" | "AUTOMATIC";
|
|
195
|
-
code?: string | null;
|
|
196
|
-
title?: string | null;
|
|
197
|
-
value: number;
|
|
198
|
-
valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
|
|
199
|
-
discountScope: "PRODUCTS" | "COLLECTIONS";
|
|
200
|
-
allowedProductIDs: string[];
|
|
201
|
-
allowedCollectionIDs: string[];
|
|
202
|
-
allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
|
|
203
|
-
minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
|
|
204
|
-
minimumRequirementsValue?: number | null;
|
|
205
|
-
requiredProductIDs: string[];
|
|
206
|
-
requiredCollectionIDs: string[];
|
|
207
|
-
minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
|
|
208
|
-
maxUses?: number | null;
|
|
209
|
-
maxUsesPerCustomer?: number | null;
|
|
210
|
-
maxAllowedProductQuantity?: number | null;
|
|
211
|
-
uses: number;
|
|
212
|
-
subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
|
|
213
|
-
subscriptionDiscountDurationValue: number;
|
|
214
|
-
stripeDiscountId?: string | null;
|
|
215
|
-
startsAt: Date;
|
|
216
|
-
expiresAt?: Date | null;
|
|
217
|
-
status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
|
|
218
|
-
organizationId: string;
|
|
219
|
-
};
|
|
220
237
|
interface CheckoutSession {
|
|
221
238
|
id: string;
|
|
222
239
|
testmode: boolean;
|
|
@@ -338,6 +355,13 @@ declare class Client {
|
|
|
338
355
|
updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1>;
|
|
339
356
|
}
|
|
340
357
|
|
|
358
|
+
declare class Collections {
|
|
359
|
+
private apiClient;
|
|
360
|
+
constructor(apiKey: string, proxy?: string);
|
|
361
|
+
list(): Promise<Collection[]>;
|
|
362
|
+
retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
|
|
363
|
+
}
|
|
364
|
+
|
|
341
365
|
declare class Customer {
|
|
342
366
|
private apiClient;
|
|
343
367
|
constructor(apiKey: string, proxy?: string);
|
|
@@ -363,6 +387,13 @@ declare class Customer {
|
|
|
363
387
|
updateCustomerSubscription(stripeSubscriptionId: string, params: CustomerSubscriptionUpdateParams): Promise<CustomerSubscription>;
|
|
364
388
|
}
|
|
365
389
|
|
|
390
|
+
declare class Discounts {
|
|
391
|
+
private apiClient;
|
|
392
|
+
constructor(apiKey: string, proxy?: string);
|
|
393
|
+
list(): Promise<Discount[]>;
|
|
394
|
+
retrieve(params: RetrieveDiscountParams): Promise<Discount | null>;
|
|
395
|
+
}
|
|
396
|
+
|
|
366
397
|
declare class Helpers {
|
|
367
398
|
proxy?: string;
|
|
368
399
|
constructor(proxy?: string);
|
|
@@ -375,11 +406,7 @@ declare class Products {
|
|
|
375
406
|
private apiClient;
|
|
376
407
|
constructor(apiKey: string, proxy?: string);
|
|
377
408
|
list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
|
|
378
|
-
retrieve(
|
|
379
|
-
retrieveBySeoHandle(seoHandle: string): Promise<Product | null>;
|
|
380
|
-
listCollections(): Promise<Collection[]>;
|
|
381
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
|
|
382
|
-
retrieveCollection(collectionId: string): Promise<CollectionWithProducts>;
|
|
409
|
+
retrieve(params: RetrieveProductParams): Promise<Product | null>;
|
|
383
410
|
}
|
|
384
411
|
|
|
385
412
|
declare function createBetterStore(config: {
|
|
@@ -387,8 +414,10 @@ declare function createBetterStore(config: {
|
|
|
387
414
|
proxy?: string;
|
|
388
415
|
}): {
|
|
389
416
|
checkout: Checkout;
|
|
390
|
-
products: Products;
|
|
391
417
|
customer: Customer;
|
|
418
|
+
discounts: Discounts;
|
|
419
|
+
collections: Collections;
|
|
420
|
+
products: Products;
|
|
392
421
|
};
|
|
393
422
|
declare function createStoreClient(config?: {
|
|
394
423
|
proxy?: string;
|
|
@@ -397,4 +426,4 @@ declare function createStoreHelpers(config?: {
|
|
|
397
426
|
proxy?: string;
|
|
398
427
|
}): Helpers;
|
|
399
428
|
|
|
400
|
-
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
|
429
|
+
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type RetrieveCollectionParams, type RetrieveDiscountParams, type RetrieveProductParams, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
type Address = {
|
|
2
|
-
name: string;
|
|
3
|
-
company?: string;
|
|
4
|
-
line1: string;
|
|
5
|
-
line2?: string;
|
|
6
|
-
city: string;
|
|
7
|
-
state?: string;
|
|
8
|
-
country: string;
|
|
9
|
-
countryCode: string;
|
|
10
|
-
zipCode: string;
|
|
11
|
-
phone: string;
|
|
12
|
-
};
|
|
13
|
-
interface CustomerCreateParams {
|
|
14
|
-
firstName: string;
|
|
15
|
-
lastName: string;
|
|
16
|
-
email: string;
|
|
17
|
-
phone?: string;
|
|
18
|
-
address?: Address;
|
|
19
|
-
isSubscribedEmail?: boolean;
|
|
20
|
-
isSubscribedSMS?: boolean;
|
|
21
|
-
}
|
|
22
|
-
interface CustomerUpdateParams {
|
|
23
|
-
firstName?: string;
|
|
24
|
-
lastName?: string;
|
|
25
|
-
email?: string;
|
|
26
|
-
phone?: string;
|
|
27
|
-
address?: Address;
|
|
28
|
-
isSubscribedEmail?: boolean;
|
|
29
|
-
isSubscribedSMS?: boolean;
|
|
30
|
-
}
|
|
31
|
-
interface Customer$1 extends CustomerCreateParams {
|
|
32
|
-
id: string;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
updatedAt: string;
|
|
35
|
-
}
|
|
36
|
-
interface CustomerSubscription {
|
|
37
|
-
cancelAtPeriodEnd: boolean;
|
|
38
|
-
}
|
|
39
|
-
type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
|
|
40
|
-
|
|
41
1
|
interface VariantOption {
|
|
42
2
|
name: string;
|
|
43
3
|
value: string;
|
|
@@ -101,6 +61,24 @@ interface Product {
|
|
|
101
61
|
}
|
|
102
62
|
interface ProductWithoutVariants extends Omit<Product, "productVariants"> {
|
|
103
63
|
}
|
|
64
|
+
type ListProductsQuery = {
|
|
65
|
+
collectionId: string;
|
|
66
|
+
} | {
|
|
67
|
+
collectionSeoHandle: string;
|
|
68
|
+
};
|
|
69
|
+
type SortBy = "createdAt" | "updatedAt";
|
|
70
|
+
type SortOrder = "asc" | "desc";
|
|
71
|
+
type ListProductsParams = {
|
|
72
|
+
sortBy?: SortBy;
|
|
73
|
+
sortOrder?: SortOrder;
|
|
74
|
+
query?: string;
|
|
75
|
+
};
|
|
76
|
+
type RetrieveProductParams = {
|
|
77
|
+
seoHandle: string;
|
|
78
|
+
} | {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
104
82
|
interface Collection {
|
|
105
83
|
id: string;
|
|
106
84
|
title: string;
|
|
@@ -113,17 +91,87 @@ interface Collection {
|
|
|
113
91
|
interface CollectionWithProducts extends Collection {
|
|
114
92
|
products: ProductWithoutVariants[];
|
|
115
93
|
}
|
|
116
|
-
type
|
|
117
|
-
|
|
94
|
+
type RetrieveCollectionParams = {
|
|
95
|
+
seoHandle: string;
|
|
118
96
|
} | {
|
|
119
|
-
|
|
97
|
+
id: string;
|
|
120
98
|
};
|
|
121
|
-
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
99
|
+
|
|
100
|
+
type Address = {
|
|
101
|
+
name: string;
|
|
102
|
+
company?: string;
|
|
103
|
+
line1: string;
|
|
104
|
+
line2?: string;
|
|
105
|
+
city: string;
|
|
106
|
+
state?: string;
|
|
107
|
+
country: string;
|
|
108
|
+
countryCode: string;
|
|
109
|
+
zipCode: string;
|
|
110
|
+
phone: string;
|
|
111
|
+
};
|
|
112
|
+
interface CustomerCreateParams {
|
|
113
|
+
firstName: string;
|
|
114
|
+
lastName: string;
|
|
115
|
+
email: string;
|
|
116
|
+
phone?: string;
|
|
117
|
+
address?: Address;
|
|
118
|
+
isSubscribedEmail?: boolean;
|
|
119
|
+
isSubscribedSMS?: boolean;
|
|
120
|
+
}
|
|
121
|
+
interface CustomerUpdateParams {
|
|
122
|
+
firstName?: string;
|
|
123
|
+
lastName?: string;
|
|
124
|
+
email?: string;
|
|
125
|
+
phone?: string;
|
|
126
|
+
address?: Address;
|
|
127
|
+
isSubscribedEmail?: boolean;
|
|
128
|
+
isSubscribedSMS?: boolean;
|
|
129
|
+
}
|
|
130
|
+
interface Customer$1 extends CustomerCreateParams {
|
|
131
|
+
id: string;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
}
|
|
135
|
+
interface CustomerSubscription {
|
|
136
|
+
cancelAtPeriodEnd: boolean;
|
|
137
|
+
}
|
|
138
|
+
type CustomerSubscriptionUpdateParams = Partial<Pick<CustomerSubscription, "cancelAtPeriodEnd">>;
|
|
139
|
+
|
|
140
|
+
interface Discount {
|
|
141
|
+
id: string;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
|
|
145
|
+
method: "CODE" | "AUTOMATIC";
|
|
146
|
+
code?: string | null;
|
|
147
|
+
title?: string | null;
|
|
148
|
+
value: number;
|
|
149
|
+
valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
|
|
150
|
+
discountScope: "PRODUCTS" | "COLLECTIONS";
|
|
151
|
+
allowedProductIDs: string[];
|
|
152
|
+
allowedCollectionIDs: string[];
|
|
153
|
+
allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
|
|
154
|
+
minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
|
|
155
|
+
minimumRequirementsValue?: number | null;
|
|
156
|
+
requiredProductIDs: string[];
|
|
157
|
+
requiredCollectionIDs: string[];
|
|
158
|
+
minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
|
|
159
|
+
maxUses?: number | null;
|
|
160
|
+
maxUsesPerCustomer?: number | null;
|
|
161
|
+
maxAllowedProductQuantity?: number | null;
|
|
162
|
+
uses: number;
|
|
163
|
+
subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
|
|
164
|
+
subscriptionDiscountDurationValue: number;
|
|
165
|
+
stripeDiscountId?: string | null;
|
|
166
|
+
startsAt: Date;
|
|
167
|
+
expiresAt?: Date | null;
|
|
168
|
+
status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
|
|
169
|
+
organizationId: string;
|
|
170
|
+
}
|
|
171
|
+
type RetrieveDiscountParams = {
|
|
172
|
+
id: string;
|
|
173
|
+
} | {
|
|
174
|
+
code: string;
|
|
127
175
|
};
|
|
128
176
|
|
|
129
177
|
type ShippingRate = ZasilkovnaRate;
|
|
@@ -186,37 +234,6 @@ type ShipmentData = {
|
|
|
186
234
|
trackingId?: string;
|
|
187
235
|
trackingUrl?: string;
|
|
188
236
|
};
|
|
189
|
-
type Discount = {
|
|
190
|
-
id: string;
|
|
191
|
-
createdAt: Date;
|
|
192
|
-
updatedAt: Date;
|
|
193
|
-
type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
|
|
194
|
-
method: "CODE" | "AUTOMATIC";
|
|
195
|
-
code?: string | null;
|
|
196
|
-
title?: string | null;
|
|
197
|
-
value: number;
|
|
198
|
-
valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
|
|
199
|
-
discountScope: "PRODUCTS" | "COLLECTIONS";
|
|
200
|
-
allowedProductIDs: string[];
|
|
201
|
-
allowedCollectionIDs: string[];
|
|
202
|
-
allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
|
|
203
|
-
minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
|
|
204
|
-
minimumRequirementsValue?: number | null;
|
|
205
|
-
requiredProductIDs: string[];
|
|
206
|
-
requiredCollectionIDs: string[];
|
|
207
|
-
minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
|
|
208
|
-
maxUses?: number | null;
|
|
209
|
-
maxUsesPerCustomer?: number | null;
|
|
210
|
-
maxAllowedProductQuantity?: number | null;
|
|
211
|
-
uses: number;
|
|
212
|
-
subscriptionDiscountDurationType: "ONE_TIME" | "RECURRING" | "FOREVER";
|
|
213
|
-
subscriptionDiscountDurationValue: number;
|
|
214
|
-
stripeDiscountId?: string | null;
|
|
215
|
-
startsAt: Date;
|
|
216
|
-
expiresAt?: Date | null;
|
|
217
|
-
status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
|
|
218
|
-
organizationId: string;
|
|
219
|
-
};
|
|
220
237
|
interface CheckoutSession {
|
|
221
238
|
id: string;
|
|
222
239
|
testmode: boolean;
|
|
@@ -338,6 +355,13 @@ declare class Client {
|
|
|
338
355
|
updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1>;
|
|
339
356
|
}
|
|
340
357
|
|
|
358
|
+
declare class Collections {
|
|
359
|
+
private apiClient;
|
|
360
|
+
constructor(apiKey: string, proxy?: string);
|
|
361
|
+
list(): Promise<Collection[]>;
|
|
362
|
+
retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
|
|
363
|
+
}
|
|
364
|
+
|
|
341
365
|
declare class Customer {
|
|
342
366
|
private apiClient;
|
|
343
367
|
constructor(apiKey: string, proxy?: string);
|
|
@@ -363,6 +387,13 @@ declare class Customer {
|
|
|
363
387
|
updateCustomerSubscription(stripeSubscriptionId: string, params: CustomerSubscriptionUpdateParams): Promise<CustomerSubscription>;
|
|
364
388
|
}
|
|
365
389
|
|
|
390
|
+
declare class Discounts {
|
|
391
|
+
private apiClient;
|
|
392
|
+
constructor(apiKey: string, proxy?: string);
|
|
393
|
+
list(): Promise<Discount[]>;
|
|
394
|
+
retrieve(params: RetrieveDiscountParams): Promise<Discount | null>;
|
|
395
|
+
}
|
|
396
|
+
|
|
366
397
|
declare class Helpers {
|
|
367
398
|
proxy?: string;
|
|
368
399
|
constructor(proxy?: string);
|
|
@@ -375,11 +406,7 @@ declare class Products {
|
|
|
375
406
|
private apiClient;
|
|
376
407
|
constructor(apiKey: string, proxy?: string);
|
|
377
408
|
list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
|
|
378
|
-
retrieve(
|
|
379
|
-
retrieveBySeoHandle(seoHandle: string): Promise<Product | null>;
|
|
380
|
-
listCollections(): Promise<Collection[]>;
|
|
381
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
|
|
382
|
-
retrieveCollection(collectionId: string): Promise<CollectionWithProducts>;
|
|
409
|
+
retrieve(params: RetrieveProductParams): Promise<Product | null>;
|
|
383
410
|
}
|
|
384
411
|
|
|
385
412
|
declare function createBetterStore(config: {
|
|
@@ -387,8 +414,10 @@ declare function createBetterStore(config: {
|
|
|
387
414
|
proxy?: string;
|
|
388
415
|
}): {
|
|
389
416
|
checkout: Checkout;
|
|
390
|
-
products: Products;
|
|
391
417
|
customer: Customer;
|
|
418
|
+
discounts: Discounts;
|
|
419
|
+
collections: Collections;
|
|
420
|
+
products: Products;
|
|
392
421
|
};
|
|
393
422
|
declare function createStoreClient(config?: {
|
|
394
423
|
proxy?: string;
|
|
@@ -397,4 +426,4 @@ declare function createStoreHelpers(config?: {
|
|
|
397
426
|
proxy?: string;
|
|
398
427
|
}): Helpers;
|
|
399
428
|
|
|
400
|
-
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
|
429
|
+
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Collection, type CollectionWithProducts, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerSubscription, type CustomerSubscriptionUpdateParams, type CustomerUpdateParams, type Discount, type LineItem, type LineItemCreate, type ListProductsParams, type ListProductsQuery, type Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type RetrieveCollectionParams, type RetrieveDiscountParams, type RetrieveProductParams, type ShippingRate, type SortBy, type SortOrder, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
package/dist/index.js
CHANGED
|
@@ -334,6 +334,44 @@ var Client = class {
|
|
|
334
334
|
};
|
|
335
335
|
var client_default = Client;
|
|
336
336
|
|
|
337
|
+
// src/collections/index.ts
|
|
338
|
+
var Collections = class {
|
|
339
|
+
constructor(apiKey, proxy) {
|
|
340
|
+
this.apiClient = createApiClient(apiKey, proxy);
|
|
341
|
+
}
|
|
342
|
+
list() {
|
|
343
|
+
return __async(this, null, function* () {
|
|
344
|
+
const data = yield this.apiClient.get("/collections");
|
|
345
|
+
return data;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
retrieve(params) {
|
|
349
|
+
return __async(this, null, function* () {
|
|
350
|
+
if ("seoHandle" in params) {
|
|
351
|
+
const data2 = yield this.apiClient.get(
|
|
352
|
+
`/collections/${params.seoHandle}`
|
|
353
|
+
);
|
|
354
|
+
if (!data2) {
|
|
355
|
+
console.error(
|
|
356
|
+
`Collection with seoHandle ${params.seoHandle} not found`
|
|
357
|
+
);
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
return data2;
|
|
361
|
+
}
|
|
362
|
+
const data = yield this.apiClient.get(
|
|
363
|
+
`/collections/id/${params.id}`
|
|
364
|
+
);
|
|
365
|
+
if (!data) {
|
|
366
|
+
console.error(`Collection with id ${params.id} not found`);
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
return data;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
var collections_default = Collections;
|
|
374
|
+
|
|
337
375
|
// src/customer/index.ts
|
|
338
376
|
var Customer = class {
|
|
339
377
|
constructor(apiKey, proxy) {
|
|
@@ -397,6 +435,42 @@ var Customer = class {
|
|
|
397
435
|
};
|
|
398
436
|
var customer_default = Customer;
|
|
399
437
|
|
|
438
|
+
// src/discounts/index.ts
|
|
439
|
+
var Discounts = class {
|
|
440
|
+
constructor(apiKey, proxy) {
|
|
441
|
+
this.apiClient = createApiClient(apiKey, proxy);
|
|
442
|
+
}
|
|
443
|
+
list() {
|
|
444
|
+
return __async(this, null, function* () {
|
|
445
|
+
const data = yield this.apiClient.get("/discounts");
|
|
446
|
+
return data;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
retrieve(params) {
|
|
450
|
+
return __async(this, null, function* () {
|
|
451
|
+
if ("code" in params) {
|
|
452
|
+
const data2 = yield this.apiClient.get(
|
|
453
|
+
`/discounts/code/${params.code}`
|
|
454
|
+
);
|
|
455
|
+
if (!data2) {
|
|
456
|
+
console.error(`Discount with code ${params.code} not found`);
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
return data2;
|
|
460
|
+
}
|
|
461
|
+
const data = yield this.apiClient.get(
|
|
462
|
+
`/discounts/id/${params.id}`
|
|
463
|
+
);
|
|
464
|
+
if (!data) {
|
|
465
|
+
console.error(`Discount with id ${params.id} not found`);
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
return data;
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
var discounts_default = Discounts;
|
|
473
|
+
|
|
400
474
|
// src/helpers/index.ts
|
|
401
475
|
var currencyLocales = {
|
|
402
476
|
CZK: "cs-CZ",
|
|
@@ -521,50 +595,26 @@ var Products = class {
|
|
|
521
595
|
return data;
|
|
522
596
|
});
|
|
523
597
|
}
|
|
524
|
-
retrieve(
|
|
598
|
+
retrieve(params) {
|
|
525
599
|
return __async(this, null, function* () {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
600
|
+
if ("seoHandle" in params) {
|
|
601
|
+
const data2 = yield this.apiClient.get(
|
|
602
|
+
`/products/${params.seoHandle}`
|
|
603
|
+
);
|
|
604
|
+
if (!data2) {
|
|
605
|
+
console.error(`Product with seoHandle ${params.seoHandle} not found`);
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
return data2;
|
|
530
609
|
}
|
|
531
|
-
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
retrieveBySeoHandle(seoHandle) {
|
|
535
|
-
return __async(this, null, function* () {
|
|
536
|
-
const data = yield this.apiClient.get(
|
|
537
|
-
`/products/seoHandle/${seoHandle}`
|
|
538
|
-
);
|
|
610
|
+
const data = yield this.apiClient.get(`/products/${params.id}`);
|
|
539
611
|
if (!data) {
|
|
540
|
-
console.error(`Product with
|
|
612
|
+
console.error(`Product with id ${params.id} not found`);
|
|
541
613
|
return null;
|
|
542
614
|
}
|
|
543
615
|
return data;
|
|
544
616
|
});
|
|
545
617
|
}
|
|
546
|
-
listCollections() {
|
|
547
|
-
return __async(this, null, function* () {
|
|
548
|
-
const data = yield this.apiClient.get("/collections");
|
|
549
|
-
return data;
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle) {
|
|
553
|
-
return __async(this, null, function* () {
|
|
554
|
-
const data = yield this.apiClient.get(
|
|
555
|
-
`/collections/${collectionSeoHandle}`
|
|
556
|
-
);
|
|
557
|
-
return data;
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
retrieveCollection(collectionId) {
|
|
561
|
-
return __async(this, null, function* () {
|
|
562
|
-
const data = yield this.apiClient.get(
|
|
563
|
-
`/collections/id/${collectionId}`
|
|
564
|
-
);
|
|
565
|
-
return data;
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
618
|
};
|
|
569
619
|
var products_default = Products;
|
|
570
620
|
|
|
@@ -575,8 +625,10 @@ function createBetterStore(config) {
|
|
|
575
625
|
}
|
|
576
626
|
return {
|
|
577
627
|
checkout: new checkout_default(config.apiKey, config.proxy),
|
|
578
|
-
|
|
579
|
-
|
|
628
|
+
customer: new customer_default(config.apiKey, config.proxy),
|
|
629
|
+
discounts: new discounts_default(config.apiKey, config.proxy),
|
|
630
|
+
collections: new collections_default(config.apiKey, config.proxy),
|
|
631
|
+
products: new products_default(config.apiKey, config.proxy)
|
|
580
632
|
};
|
|
581
633
|
}
|
|
582
634
|
function createStoreClient(config) {
|
package/dist/index.mjs
CHANGED
|
@@ -297,6 +297,44 @@ var Client = class {
|
|
|
297
297
|
};
|
|
298
298
|
var client_default = Client;
|
|
299
299
|
|
|
300
|
+
// src/collections/index.ts
|
|
301
|
+
var Collections = class {
|
|
302
|
+
constructor(apiKey, proxy) {
|
|
303
|
+
this.apiClient = createApiClient(apiKey, proxy);
|
|
304
|
+
}
|
|
305
|
+
list() {
|
|
306
|
+
return __async(this, null, function* () {
|
|
307
|
+
const data = yield this.apiClient.get("/collections");
|
|
308
|
+
return data;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
retrieve(params) {
|
|
312
|
+
return __async(this, null, function* () {
|
|
313
|
+
if ("seoHandle" in params) {
|
|
314
|
+
const data2 = yield this.apiClient.get(
|
|
315
|
+
`/collections/${params.seoHandle}`
|
|
316
|
+
);
|
|
317
|
+
if (!data2) {
|
|
318
|
+
console.error(
|
|
319
|
+
`Collection with seoHandle ${params.seoHandle} not found`
|
|
320
|
+
);
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
return data2;
|
|
324
|
+
}
|
|
325
|
+
const data = yield this.apiClient.get(
|
|
326
|
+
`/collections/id/${params.id}`
|
|
327
|
+
);
|
|
328
|
+
if (!data) {
|
|
329
|
+
console.error(`Collection with id ${params.id} not found`);
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
return data;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
var collections_default = Collections;
|
|
337
|
+
|
|
300
338
|
// src/customer/index.ts
|
|
301
339
|
var Customer = class {
|
|
302
340
|
constructor(apiKey, proxy) {
|
|
@@ -360,6 +398,42 @@ var Customer = class {
|
|
|
360
398
|
};
|
|
361
399
|
var customer_default = Customer;
|
|
362
400
|
|
|
401
|
+
// src/discounts/index.ts
|
|
402
|
+
var Discounts = class {
|
|
403
|
+
constructor(apiKey, proxy) {
|
|
404
|
+
this.apiClient = createApiClient(apiKey, proxy);
|
|
405
|
+
}
|
|
406
|
+
list() {
|
|
407
|
+
return __async(this, null, function* () {
|
|
408
|
+
const data = yield this.apiClient.get("/discounts");
|
|
409
|
+
return data;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
retrieve(params) {
|
|
413
|
+
return __async(this, null, function* () {
|
|
414
|
+
if ("code" in params) {
|
|
415
|
+
const data2 = yield this.apiClient.get(
|
|
416
|
+
`/discounts/code/${params.code}`
|
|
417
|
+
);
|
|
418
|
+
if (!data2) {
|
|
419
|
+
console.error(`Discount with code ${params.code} not found`);
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
return data2;
|
|
423
|
+
}
|
|
424
|
+
const data = yield this.apiClient.get(
|
|
425
|
+
`/discounts/id/${params.id}`
|
|
426
|
+
);
|
|
427
|
+
if (!data) {
|
|
428
|
+
console.error(`Discount with id ${params.id} not found`);
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
return data;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
var discounts_default = Discounts;
|
|
436
|
+
|
|
363
437
|
// src/helpers/index.ts
|
|
364
438
|
var currencyLocales = {
|
|
365
439
|
CZK: "cs-CZ",
|
|
@@ -484,50 +558,26 @@ var Products = class {
|
|
|
484
558
|
return data;
|
|
485
559
|
});
|
|
486
560
|
}
|
|
487
|
-
retrieve(
|
|
561
|
+
retrieve(params) {
|
|
488
562
|
return __async(this, null, function* () {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
563
|
+
if ("seoHandle" in params) {
|
|
564
|
+
const data2 = yield this.apiClient.get(
|
|
565
|
+
`/products/${params.seoHandle}`
|
|
566
|
+
);
|
|
567
|
+
if (!data2) {
|
|
568
|
+
console.error(`Product with seoHandle ${params.seoHandle} not found`);
|
|
569
|
+
return null;
|
|
570
|
+
}
|
|
571
|
+
return data2;
|
|
493
572
|
}
|
|
494
|
-
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
retrieveBySeoHandle(seoHandle) {
|
|
498
|
-
return __async(this, null, function* () {
|
|
499
|
-
const data = yield this.apiClient.get(
|
|
500
|
-
`/products/seoHandle/${seoHandle}`
|
|
501
|
-
);
|
|
573
|
+
const data = yield this.apiClient.get(`/products/${params.id}`);
|
|
502
574
|
if (!data) {
|
|
503
|
-
console.error(`Product with
|
|
575
|
+
console.error(`Product with id ${params.id} not found`);
|
|
504
576
|
return null;
|
|
505
577
|
}
|
|
506
578
|
return data;
|
|
507
579
|
});
|
|
508
580
|
}
|
|
509
|
-
listCollections() {
|
|
510
|
-
return __async(this, null, function* () {
|
|
511
|
-
const data = yield this.apiClient.get("/collections");
|
|
512
|
-
return data;
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle) {
|
|
516
|
-
return __async(this, null, function* () {
|
|
517
|
-
const data = yield this.apiClient.get(
|
|
518
|
-
`/collections/${collectionSeoHandle}`
|
|
519
|
-
);
|
|
520
|
-
return data;
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
retrieveCollection(collectionId) {
|
|
524
|
-
return __async(this, null, function* () {
|
|
525
|
-
const data = yield this.apiClient.get(
|
|
526
|
-
`/collections/id/${collectionId}`
|
|
527
|
-
);
|
|
528
|
-
return data;
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
581
|
};
|
|
532
582
|
var products_default = Products;
|
|
533
583
|
|
|
@@ -538,8 +588,10 @@ function createBetterStore(config) {
|
|
|
538
588
|
}
|
|
539
589
|
return {
|
|
540
590
|
checkout: new checkout_default(config.apiKey, config.proxy),
|
|
541
|
-
|
|
542
|
-
|
|
591
|
+
customer: new customer_default(config.apiKey, config.proxy),
|
|
592
|
+
discounts: new discounts_default(config.apiKey, config.proxy),
|
|
593
|
+
collections: new collections_default(config.apiKey, config.proxy),
|
|
594
|
+
products: new products_default(config.apiKey, config.proxy)
|
|
543
595
|
};
|
|
544
596
|
}
|
|
545
597
|
function createStoreClient(config) {
|