@betterstore/sdk 0.3.69 → 0.3.71
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 +98 -47
- package/dist/index.d.ts +98 -47
- package/dist/index.js +99 -29
- package/dist/index.mjs +99 -29
- 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,6 +91,66 @@ interface Collection {
|
|
|
113
91
|
interface CollectionWithProducts extends Collection {
|
|
114
92
|
products: ProductWithoutVariants[];
|
|
115
93
|
}
|
|
94
|
+
type RetrieveCollectionParams = {
|
|
95
|
+
seoHandle: string;
|
|
96
|
+
} | {
|
|
97
|
+
id: string;
|
|
98
|
+
};
|
|
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$1 {
|
|
141
|
+
id: string;
|
|
142
|
+
title: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
images: string[];
|
|
145
|
+
seoPageTitle?: string;
|
|
146
|
+
seoDescription?: string;
|
|
147
|
+
seoHandle?: string;
|
|
148
|
+
}
|
|
149
|
+
type RetrieveDiscountParams = {
|
|
150
|
+
id: string;
|
|
151
|
+
} | {
|
|
152
|
+
code: string;
|
|
153
|
+
};
|
|
116
154
|
|
|
117
155
|
type ShippingRate = ZasilkovnaRate;
|
|
118
156
|
interface BaseRate {
|
|
@@ -326,6 +364,13 @@ declare class Client {
|
|
|
326
364
|
updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1>;
|
|
327
365
|
}
|
|
328
366
|
|
|
367
|
+
declare class Collections {
|
|
368
|
+
private apiClient;
|
|
369
|
+
constructor(apiKey: string, proxy?: string);
|
|
370
|
+
list(): Promise<Collection[]>;
|
|
371
|
+
retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
|
|
372
|
+
}
|
|
373
|
+
|
|
329
374
|
declare class Customer {
|
|
330
375
|
private apiClient;
|
|
331
376
|
constructor(apiKey: string, proxy?: string);
|
|
@@ -351,6 +396,13 @@ declare class Customer {
|
|
|
351
396
|
updateCustomerSubscription(stripeSubscriptionId: string, params: CustomerSubscriptionUpdateParams): Promise<CustomerSubscription>;
|
|
352
397
|
}
|
|
353
398
|
|
|
399
|
+
declare class Discounts {
|
|
400
|
+
private apiClient;
|
|
401
|
+
constructor(apiKey: string, proxy?: string);
|
|
402
|
+
list(): Promise<Discount$1[]>;
|
|
403
|
+
retrieve(params: RetrieveDiscountParams): Promise<Discount$1 | null>;
|
|
404
|
+
}
|
|
405
|
+
|
|
354
406
|
declare class Helpers {
|
|
355
407
|
proxy?: string;
|
|
356
408
|
constructor(proxy?: string);
|
|
@@ -362,11 +414,8 @@ declare class Helpers {
|
|
|
362
414
|
declare class Products {
|
|
363
415
|
private apiClient;
|
|
364
416
|
constructor(apiKey: string, proxy?: string);
|
|
365
|
-
list(): Promise<ProductWithoutVariants[]>;
|
|
366
|
-
retrieve(
|
|
367
|
-
listCollections(): Promise<Collection[]>;
|
|
368
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
|
|
369
|
-
retrieveCollectionById(collectionId: string): Promise<CollectionWithProducts>;
|
|
417
|
+
list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
|
|
418
|
+
retrieve(params: RetrieveProductParams): Promise<Product | null>;
|
|
370
419
|
}
|
|
371
420
|
|
|
372
421
|
declare function createBetterStore(config: {
|
|
@@ -374,8 +423,10 @@ declare function createBetterStore(config: {
|
|
|
374
423
|
proxy?: string;
|
|
375
424
|
}): {
|
|
376
425
|
checkout: Checkout;
|
|
377
|
-
products: Products;
|
|
378
426
|
customer: Customer;
|
|
427
|
+
discounts: Discounts;
|
|
428
|
+
collections: Collections;
|
|
429
|
+
products: Products;
|
|
379
430
|
};
|
|
380
431
|
declare function createStoreClient(config?: {
|
|
381
432
|
proxy?: string;
|
|
@@ -384,4 +435,4 @@ declare function createStoreHelpers(config?: {
|
|
|
384
435
|
proxy?: string;
|
|
385
436
|
}): Helpers;
|
|
386
437
|
|
|
387
|
-
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 Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
|
438
|
+
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$1 as 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,6 +91,66 @@ interface Collection {
|
|
|
113
91
|
interface CollectionWithProducts extends Collection {
|
|
114
92
|
products: ProductWithoutVariants[];
|
|
115
93
|
}
|
|
94
|
+
type RetrieveCollectionParams = {
|
|
95
|
+
seoHandle: string;
|
|
96
|
+
} | {
|
|
97
|
+
id: string;
|
|
98
|
+
};
|
|
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$1 {
|
|
141
|
+
id: string;
|
|
142
|
+
title: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
images: string[];
|
|
145
|
+
seoPageTitle?: string;
|
|
146
|
+
seoDescription?: string;
|
|
147
|
+
seoHandle?: string;
|
|
148
|
+
}
|
|
149
|
+
type RetrieveDiscountParams = {
|
|
150
|
+
id: string;
|
|
151
|
+
} | {
|
|
152
|
+
code: string;
|
|
153
|
+
};
|
|
116
154
|
|
|
117
155
|
type ShippingRate = ZasilkovnaRate;
|
|
118
156
|
interface BaseRate {
|
|
@@ -326,6 +364,13 @@ declare class Client {
|
|
|
326
364
|
updateCustomer(clientSecret: string, customerId: string, params: CustomerUpdateParams): Promise<Customer$1>;
|
|
327
365
|
}
|
|
328
366
|
|
|
367
|
+
declare class Collections {
|
|
368
|
+
private apiClient;
|
|
369
|
+
constructor(apiKey: string, proxy?: string);
|
|
370
|
+
list(): Promise<Collection[]>;
|
|
371
|
+
retrieve(params: RetrieveCollectionParams): Promise<CollectionWithProducts | null>;
|
|
372
|
+
}
|
|
373
|
+
|
|
329
374
|
declare class Customer {
|
|
330
375
|
private apiClient;
|
|
331
376
|
constructor(apiKey: string, proxy?: string);
|
|
@@ -351,6 +396,13 @@ declare class Customer {
|
|
|
351
396
|
updateCustomerSubscription(stripeSubscriptionId: string, params: CustomerSubscriptionUpdateParams): Promise<CustomerSubscription>;
|
|
352
397
|
}
|
|
353
398
|
|
|
399
|
+
declare class Discounts {
|
|
400
|
+
private apiClient;
|
|
401
|
+
constructor(apiKey: string, proxy?: string);
|
|
402
|
+
list(): Promise<Discount$1[]>;
|
|
403
|
+
retrieve(params: RetrieveDiscountParams): Promise<Discount$1 | null>;
|
|
404
|
+
}
|
|
405
|
+
|
|
354
406
|
declare class Helpers {
|
|
355
407
|
proxy?: string;
|
|
356
408
|
constructor(proxy?: string);
|
|
@@ -362,11 +414,8 @@ declare class Helpers {
|
|
|
362
414
|
declare class Products {
|
|
363
415
|
private apiClient;
|
|
364
416
|
constructor(apiKey: string, proxy?: string);
|
|
365
|
-
list(): Promise<ProductWithoutVariants[]>;
|
|
366
|
-
retrieve(
|
|
367
|
-
listCollections(): Promise<Collection[]>;
|
|
368
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle: string): Promise<CollectionWithProducts>;
|
|
369
|
-
retrieveCollectionById(collectionId: string): Promise<CollectionWithProducts>;
|
|
417
|
+
list(params?: ListProductsParams): Promise<ProductWithoutVariants[]>;
|
|
418
|
+
retrieve(params: RetrieveProductParams): Promise<Product | null>;
|
|
370
419
|
}
|
|
371
420
|
|
|
372
421
|
declare function createBetterStore(config: {
|
|
@@ -374,8 +423,10 @@ declare function createBetterStore(config: {
|
|
|
374
423
|
proxy?: string;
|
|
375
424
|
}): {
|
|
376
425
|
checkout: Checkout;
|
|
377
|
-
products: Products;
|
|
378
426
|
customer: Customer;
|
|
427
|
+
discounts: Discounts;
|
|
428
|
+
collections: Collections;
|
|
429
|
+
products: Products;
|
|
379
430
|
};
|
|
380
431
|
declare function createStoreClient(config?: {
|
|
381
432
|
proxy?: string;
|
|
@@ -384,4 +435,4 @@ declare function createStoreHelpers(config?: {
|
|
|
384
435
|
proxy?: string;
|
|
385
436
|
}): Helpers;
|
|
386
437
|
|
|
387
|
-
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 Product, type ProductBillingInterval, type ProductBillingType, type ProductOption, type ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
|
438
|
+
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$1 as 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",
|
|
@@ -509,41 +583,35 @@ var Products = class {
|
|
|
509
583
|
constructor(apiKey, proxy) {
|
|
510
584
|
this.apiClient = createApiClient(apiKey, proxy);
|
|
511
585
|
}
|
|
512
|
-
list() {
|
|
513
|
-
return __async(this, null, function* () {
|
|
514
|
-
const data = yield this.apiClient.get("/products");
|
|
515
|
-
return data;
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
retrieve(productId) {
|
|
586
|
+
list(params) {
|
|
519
587
|
return __async(this, null, function* () {
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
522
|
-
|
|
523
|
-
return null;
|
|
588
|
+
const queryParams = new URLSearchParams();
|
|
589
|
+
if (params) {
|
|
590
|
+
queryParams.set("params", JSON.stringify(params));
|
|
524
591
|
}
|
|
525
|
-
return data;
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
listCollections() {
|
|
529
|
-
return __async(this, null, function* () {
|
|
530
|
-
const data = yield this.apiClient.get("/collections");
|
|
531
|
-
return data;
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle) {
|
|
535
|
-
return __async(this, null, function* () {
|
|
536
592
|
const data = yield this.apiClient.get(
|
|
537
|
-
`/
|
|
593
|
+
`/products?${queryParams.toString()}`
|
|
538
594
|
);
|
|
539
595
|
return data;
|
|
540
596
|
});
|
|
541
597
|
}
|
|
542
|
-
|
|
598
|
+
retrieve(params) {
|
|
543
599
|
return __async(this, null, function* () {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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;
|
|
609
|
+
}
|
|
610
|
+
const data = yield this.apiClient.get(`/products/${params.id}`);
|
|
611
|
+
if (!data) {
|
|
612
|
+
console.error(`Product with id ${params.id} not found`);
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
547
615
|
return data;
|
|
548
616
|
});
|
|
549
617
|
}
|
|
@@ -557,8 +625,10 @@ function createBetterStore(config) {
|
|
|
557
625
|
}
|
|
558
626
|
return {
|
|
559
627
|
checkout: new checkout_default(config.apiKey, config.proxy),
|
|
560
|
-
|
|
561
|
-
|
|
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)
|
|
562
632
|
};
|
|
563
633
|
}
|
|
564
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",
|
|
@@ -472,41 +546,35 @@ var Products = class {
|
|
|
472
546
|
constructor(apiKey, proxy) {
|
|
473
547
|
this.apiClient = createApiClient(apiKey, proxy);
|
|
474
548
|
}
|
|
475
|
-
list() {
|
|
476
|
-
return __async(this, null, function* () {
|
|
477
|
-
const data = yield this.apiClient.get("/products");
|
|
478
|
-
return data;
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
retrieve(productId) {
|
|
549
|
+
list(params) {
|
|
482
550
|
return __async(this, null, function* () {
|
|
483
|
-
const
|
|
484
|
-
if (
|
|
485
|
-
|
|
486
|
-
return null;
|
|
551
|
+
const queryParams = new URLSearchParams();
|
|
552
|
+
if (params) {
|
|
553
|
+
queryParams.set("params", JSON.stringify(params));
|
|
487
554
|
}
|
|
488
|
-
return data;
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
listCollections() {
|
|
492
|
-
return __async(this, null, function* () {
|
|
493
|
-
const data = yield this.apiClient.get("/collections");
|
|
494
|
-
return data;
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
retrieveCollectionBySeoHandle(collectionSeoHandle) {
|
|
498
|
-
return __async(this, null, function* () {
|
|
499
555
|
const data = yield this.apiClient.get(
|
|
500
|
-
`/
|
|
556
|
+
`/products?${queryParams.toString()}`
|
|
501
557
|
);
|
|
502
558
|
return data;
|
|
503
559
|
});
|
|
504
560
|
}
|
|
505
|
-
|
|
561
|
+
retrieve(params) {
|
|
506
562
|
return __async(this, null, function* () {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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;
|
|
572
|
+
}
|
|
573
|
+
const data = yield this.apiClient.get(`/products/${params.id}`);
|
|
574
|
+
if (!data) {
|
|
575
|
+
console.error(`Product with id ${params.id} not found`);
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
510
578
|
return data;
|
|
511
579
|
});
|
|
512
580
|
}
|
|
@@ -520,8 +588,10 @@ function createBetterStore(config) {
|
|
|
520
588
|
}
|
|
521
589
|
return {
|
|
522
590
|
checkout: new checkout_default(config.apiKey, config.proxy),
|
|
523
|
-
|
|
524
|
-
|
|
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)
|
|
525
595
|
};
|
|
526
596
|
}
|
|
527
597
|
function createStoreClient(config) {
|