@betterstore/sdk 0.6.1 → 0.6.2
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 +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +9 -15
- package/dist/index.mjs +9 -15
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -127,11 +127,17 @@ declare class Client {
|
|
|
127
127
|
}): Promise<LookupAddressResult>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
type FormatResponseForSDK<T extends object> = keyof T extends [
|
|
131
|
+
string,
|
|
132
|
+
string,
|
|
133
|
+
...string[]
|
|
134
|
+
] ? T : T[keyof T];
|
|
135
|
+
|
|
130
136
|
declare class Collections {
|
|
131
137
|
private apiClient;
|
|
132
138
|
constructor(apiKey: string, proxy?: string);
|
|
133
|
-
list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T
|
|
134
|
-
retrieve<T extends RetrieveCollectionParams>(params: T): Promise<RetrieveCollectionResponse<T
|
|
139
|
+
list<T extends ListCollectionsParams>(params?: T): Promise<FormatResponseForSDK<ListCollectionsResponse<T>>>;
|
|
140
|
+
retrieve<T extends RetrieveCollectionParams>(params: T): Promise<FormatResponseForSDK<RetrieveCollectionResponse<T>> | null>;
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
declare class Customer {
|
|
@@ -162,15 +168,15 @@ declare class Customer {
|
|
|
162
168
|
declare class Discounts {
|
|
163
169
|
private apiClient;
|
|
164
170
|
constructor(apiKey: string, proxy?: string);
|
|
165
|
-
list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse
|
|
166
|
-
retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
|
|
171
|
+
list<T extends ListDiscountsParams>(params?: T): Promise<FormatResponseForSDK<ListDiscountsResponse>>;
|
|
172
|
+
retrieve<T extends RetrieveDiscountParams>(params: T): Promise<FormatResponseForSDK<RetrieveDiscountResponse> | null>;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
declare class Products {
|
|
170
176
|
private apiClient;
|
|
171
177
|
constructor(apiKey: string, proxy?: string);
|
|
172
|
-
list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T
|
|
173
|
-
retrieve<T extends RetrieveProductParams>(params: T): Promise<RetrieveProductResponse<T
|
|
178
|
+
list<T extends ListProductsParams>(params?: T): Promise<FormatResponseForSDK<ListProductsResponse<T>>>;
|
|
179
|
+
retrieve<T extends RetrieveProductParams>(params: T): Promise<FormatResponseForSDK<RetrieveProductResponse<T>> | null>;
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
declare function createBetterStore(config: {
|
package/dist/index.d.ts
CHANGED
|
@@ -127,11 +127,17 @@ declare class Client {
|
|
|
127
127
|
}): Promise<LookupAddressResult>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
type FormatResponseForSDK<T extends object> = keyof T extends [
|
|
131
|
+
string,
|
|
132
|
+
string,
|
|
133
|
+
...string[]
|
|
134
|
+
] ? T : T[keyof T];
|
|
135
|
+
|
|
130
136
|
declare class Collections {
|
|
131
137
|
private apiClient;
|
|
132
138
|
constructor(apiKey: string, proxy?: string);
|
|
133
|
-
list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T
|
|
134
|
-
retrieve<T extends RetrieveCollectionParams>(params: T): Promise<RetrieveCollectionResponse<T
|
|
139
|
+
list<T extends ListCollectionsParams>(params?: T): Promise<FormatResponseForSDK<ListCollectionsResponse<T>>>;
|
|
140
|
+
retrieve<T extends RetrieveCollectionParams>(params: T): Promise<FormatResponseForSDK<RetrieveCollectionResponse<T>> | null>;
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
declare class Customer {
|
|
@@ -162,15 +168,15 @@ declare class Customer {
|
|
|
162
168
|
declare class Discounts {
|
|
163
169
|
private apiClient;
|
|
164
170
|
constructor(apiKey: string, proxy?: string);
|
|
165
|
-
list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse
|
|
166
|
-
retrieve<T extends RetrieveDiscountParams>(params: T): Promise<RetrieveDiscountResponse | null>;
|
|
171
|
+
list<T extends ListDiscountsParams>(params?: T): Promise<FormatResponseForSDK<ListDiscountsResponse>>;
|
|
172
|
+
retrieve<T extends RetrieveDiscountParams>(params: T): Promise<FormatResponseForSDK<RetrieveDiscountResponse> | null>;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
declare class Products {
|
|
170
176
|
private apiClient;
|
|
171
177
|
constructor(apiKey: string, proxy?: string);
|
|
172
|
-
list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T
|
|
173
|
-
retrieve<T extends RetrieveProductParams>(params: T): Promise<RetrieveProductResponse<T
|
|
178
|
+
list<T extends ListProductsParams>(params?: T): Promise<FormatResponseForSDK<ListProductsResponse<T>>>;
|
|
179
|
+
retrieve<T extends RetrieveProductParams>(params: T): Promise<FormatResponseForSDK<RetrieveProductResponse<T>> | null>;
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
declare function createBetterStore(config: {
|
package/dist/index.js
CHANGED
|
@@ -440,11 +440,9 @@ var Collections = class {
|
|
|
440
440
|
async list(params) {
|
|
441
441
|
const data = await this.apiClient.post(`/collections`, params);
|
|
442
442
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("collections" in data)) {
|
|
443
|
-
return
|
|
444
|
-
collections: []
|
|
445
|
-
};
|
|
443
|
+
return [];
|
|
446
444
|
}
|
|
447
|
-
return data;
|
|
445
|
+
return data.collections;
|
|
448
446
|
}
|
|
449
447
|
async retrieve(params) {
|
|
450
448
|
const data = await this.apiClient.post(`/collections/retrieve`, params);
|
|
@@ -452,7 +450,7 @@ var Collections = class {
|
|
|
452
450
|
console.error(`Collection not found`);
|
|
453
451
|
return null;
|
|
454
452
|
}
|
|
455
|
-
return data;
|
|
453
|
+
return data.collection;
|
|
456
454
|
}
|
|
457
455
|
};
|
|
458
456
|
var collections_default = Collections;
|
|
@@ -537,11 +535,9 @@ var Discounts = class {
|
|
|
537
535
|
params
|
|
538
536
|
);
|
|
539
537
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("discounts" in data)) {
|
|
540
|
-
return
|
|
541
|
-
discounts: []
|
|
542
|
-
};
|
|
538
|
+
return [];
|
|
543
539
|
}
|
|
544
|
-
return data;
|
|
540
|
+
return data.discounts;
|
|
545
541
|
}
|
|
546
542
|
async retrieve(params) {
|
|
547
543
|
const data = await this.apiClient.post(
|
|
@@ -552,7 +548,7 @@ var Discounts = class {
|
|
|
552
548
|
console.error(`Discount not found`);
|
|
553
549
|
return null;
|
|
554
550
|
}
|
|
555
|
-
return data;
|
|
551
|
+
return data.discount;
|
|
556
552
|
}
|
|
557
553
|
};
|
|
558
554
|
var discounts_default = Discounts;
|
|
@@ -569,11 +565,9 @@ var Products = class {
|
|
|
569
565
|
params
|
|
570
566
|
);
|
|
571
567
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("products" in data)) {
|
|
572
|
-
return
|
|
573
|
-
products: []
|
|
574
|
-
};
|
|
568
|
+
return [];
|
|
575
569
|
}
|
|
576
|
-
return data;
|
|
570
|
+
return data.products;
|
|
577
571
|
}
|
|
578
572
|
async retrieve(params) {
|
|
579
573
|
const data = await this.apiClient.post("/products/retrieve", params);
|
|
@@ -581,7 +575,7 @@ var Products = class {
|
|
|
581
575
|
console.error(`Product not found`);
|
|
582
576
|
return null;
|
|
583
577
|
}
|
|
584
|
-
return data;
|
|
578
|
+
return data.product;
|
|
585
579
|
}
|
|
586
580
|
};
|
|
587
581
|
var products_default = Products;
|
package/dist/index.mjs
CHANGED
|
@@ -401,11 +401,9 @@ var Collections = class {
|
|
|
401
401
|
async list(params) {
|
|
402
402
|
const data = await this.apiClient.post(`/collections`, params);
|
|
403
403
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("collections" in data)) {
|
|
404
|
-
return
|
|
405
|
-
collections: []
|
|
406
|
-
};
|
|
404
|
+
return [];
|
|
407
405
|
}
|
|
408
|
-
return data;
|
|
406
|
+
return data.collections;
|
|
409
407
|
}
|
|
410
408
|
async retrieve(params) {
|
|
411
409
|
const data = await this.apiClient.post(`/collections/retrieve`, params);
|
|
@@ -413,7 +411,7 @@ var Collections = class {
|
|
|
413
411
|
console.error(`Collection not found`);
|
|
414
412
|
return null;
|
|
415
413
|
}
|
|
416
|
-
return data;
|
|
414
|
+
return data.collection;
|
|
417
415
|
}
|
|
418
416
|
};
|
|
419
417
|
var collections_default = Collections;
|
|
@@ -498,11 +496,9 @@ var Discounts = class {
|
|
|
498
496
|
params
|
|
499
497
|
);
|
|
500
498
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("discounts" in data)) {
|
|
501
|
-
return
|
|
502
|
-
discounts: []
|
|
503
|
-
};
|
|
499
|
+
return [];
|
|
504
500
|
}
|
|
505
|
-
return data;
|
|
501
|
+
return data.discounts;
|
|
506
502
|
}
|
|
507
503
|
async retrieve(params) {
|
|
508
504
|
const data = await this.apiClient.post(
|
|
@@ -513,7 +509,7 @@ var Discounts = class {
|
|
|
513
509
|
console.error(`Discount not found`);
|
|
514
510
|
return null;
|
|
515
511
|
}
|
|
516
|
-
return data;
|
|
512
|
+
return data.discount;
|
|
517
513
|
}
|
|
518
514
|
};
|
|
519
515
|
var discounts_default = Discounts;
|
|
@@ -530,11 +526,9 @@ var Products = class {
|
|
|
530
526
|
params
|
|
531
527
|
);
|
|
532
528
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("products" in data)) {
|
|
533
|
-
return
|
|
534
|
-
products: []
|
|
535
|
-
};
|
|
529
|
+
return [];
|
|
536
530
|
}
|
|
537
|
-
return data;
|
|
531
|
+
return data.products;
|
|
538
532
|
}
|
|
539
533
|
async retrieve(params) {
|
|
540
534
|
const data = await this.apiClient.post("/products/retrieve", params);
|
|
@@ -542,7 +536,7 @@ var Products = class {
|
|
|
542
536
|
console.error(`Product not found`);
|
|
543
537
|
return null;
|
|
544
538
|
}
|
|
545
|
-
return data;
|
|
539
|
+
return data.product;
|
|
546
540
|
}
|
|
547
541
|
};
|
|
548
542
|
var products_default = Products;
|