@betterstore/sdk 0.6.0 → 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 +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +18 -17
- package/dist/index.mjs +15 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
export { Address, AutosuggestAddressResult, CheckoutCreateParams, CheckoutSession, CheckoutUpdateParams, CustomShippingVendorRate, CustomerCreateParams, CustomerResponse, CustomerSession, CustomerSubscription, CustomerSubscriptionUpdateParams, CustomerUpdateParams, GetShippingRatesResponse, ListCollectionsParams, ListCollectionsResponse, ListDiscountsParams, ListDiscountsResponse, ListProductsParams, ListProductsResponse, LookupAddressResult, OTPLoginParams, OTPLoginResponse, OTPSignupParams, OTPSignupResponse, OTPVerifyParams, OTPVerifyResponse, ProductVariant, RetrieveCollectionParams, RetrieveCollectionResponse, RetrieveDiscountParams, RetrieveDiscountResponse, RetrieveProductParams, RetrieveProductResponse, formatCurrency, formatPrice } from '@betterstore/bridge';
|
|
2
3
|
import axios from 'axios';
|
|
3
4
|
|
|
4
5
|
declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
|
|
@@ -126,11 +127,17 @@ declare class Client {
|
|
|
126
127
|
}): Promise<LookupAddressResult>;
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
type FormatResponseForSDK<T extends object> = keyof T extends [
|
|
131
|
+
string,
|
|
132
|
+
string,
|
|
133
|
+
...string[]
|
|
134
|
+
] ? T : T[keyof T];
|
|
135
|
+
|
|
129
136
|
declare class Collections {
|
|
130
137
|
private apiClient;
|
|
131
138
|
constructor(apiKey: string, proxy?: string);
|
|
132
|
-
list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T
|
|
133
|
-
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>;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
declare class Customer {
|
|
@@ -161,15 +168,15 @@ declare class Customer {
|
|
|
161
168
|
declare class Discounts {
|
|
162
169
|
private apiClient;
|
|
163
170
|
constructor(apiKey: string, proxy?: string);
|
|
164
|
-
list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse
|
|
165
|
-
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>;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
declare class Products {
|
|
169
176
|
private apiClient;
|
|
170
177
|
constructor(apiKey: string, proxy?: string);
|
|
171
|
-
list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T
|
|
172
|
-
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>;
|
|
173
180
|
}
|
|
174
181
|
|
|
175
182
|
declare function createBetterStore(config: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
export { Address, AutosuggestAddressResult, CheckoutCreateParams, CheckoutSession, CheckoutUpdateParams, CustomShippingVendorRate, CustomerCreateParams, CustomerResponse, CustomerSession, CustomerSubscription, CustomerSubscriptionUpdateParams, CustomerUpdateParams, GetShippingRatesResponse, ListCollectionsParams, ListCollectionsResponse, ListDiscountsParams, ListDiscountsResponse, ListProductsParams, ListProductsResponse, LookupAddressResult, OTPLoginParams, OTPLoginResponse, OTPSignupParams, OTPSignupResponse, OTPVerifyParams, OTPVerifyResponse, ProductVariant, RetrieveCollectionParams, RetrieveCollectionResponse, RetrieveDiscountParams, RetrieveDiscountResponse, RetrieveProductParams, RetrieveProductResponse, formatCurrency, formatPrice } from '@betterstore/bridge';
|
|
2
3
|
import axios from 'axios';
|
|
3
4
|
|
|
4
5
|
declare const createApiClient: (apiKey: string, proxy?: string) => axios.AxiosInstance;
|
|
@@ -126,11 +127,17 @@ declare class Client {
|
|
|
126
127
|
}): Promise<LookupAddressResult>;
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
type FormatResponseForSDK<T extends object> = keyof T extends [
|
|
131
|
+
string,
|
|
132
|
+
string,
|
|
133
|
+
...string[]
|
|
134
|
+
] ? T : T[keyof T];
|
|
135
|
+
|
|
129
136
|
declare class Collections {
|
|
130
137
|
private apiClient;
|
|
131
138
|
constructor(apiKey: string, proxy?: string);
|
|
132
|
-
list<T extends ListCollectionsParams>(params?: T): Promise<ListCollectionsResponse<T
|
|
133
|
-
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>;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
declare class Customer {
|
|
@@ -161,15 +168,15 @@ declare class Customer {
|
|
|
161
168
|
declare class Discounts {
|
|
162
169
|
private apiClient;
|
|
163
170
|
constructor(apiKey: string, proxy?: string);
|
|
164
|
-
list<T extends ListDiscountsParams>(params?: T): Promise<ListDiscountsResponse
|
|
165
|
-
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>;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
declare class Products {
|
|
169
176
|
private apiClient;
|
|
170
177
|
constructor(apiKey: string, proxy?: string);
|
|
171
|
-
list<T extends ListProductsParams>(params?: T): Promise<ListProductsResponse<T
|
|
172
|
-
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>;
|
|
173
180
|
}
|
|
174
181
|
|
|
175
182
|
declare function createBetterStore(config: {
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
createStoreClient: () => createStoreClient,
|
|
34
|
-
default: () => createBetterStore
|
|
34
|
+
default: () => createBetterStore,
|
|
35
|
+
formatCurrency: () => import_bridge.formatCurrency,
|
|
36
|
+
formatPrice: () => import_bridge.formatPrice
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(index_exports);
|
|
37
39
|
|
|
@@ -438,11 +440,9 @@ var Collections = class {
|
|
|
438
440
|
async list(params) {
|
|
439
441
|
const data = await this.apiClient.post(`/collections`, params);
|
|
440
442
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("collections" in data)) {
|
|
441
|
-
return
|
|
442
|
-
collections: []
|
|
443
|
-
};
|
|
443
|
+
return [];
|
|
444
444
|
}
|
|
445
|
-
return data;
|
|
445
|
+
return data.collections;
|
|
446
446
|
}
|
|
447
447
|
async retrieve(params) {
|
|
448
448
|
const data = await this.apiClient.post(`/collections/retrieve`, params);
|
|
@@ -450,7 +450,7 @@ var Collections = class {
|
|
|
450
450
|
console.error(`Collection not found`);
|
|
451
451
|
return null;
|
|
452
452
|
}
|
|
453
|
-
return data;
|
|
453
|
+
return data.collection;
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
456
|
var collections_default = Collections;
|
|
@@ -535,11 +535,9 @@ var Discounts = class {
|
|
|
535
535
|
params
|
|
536
536
|
);
|
|
537
537
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("discounts" in data)) {
|
|
538
|
-
return
|
|
539
|
-
discounts: []
|
|
540
|
-
};
|
|
538
|
+
return [];
|
|
541
539
|
}
|
|
542
|
-
return data;
|
|
540
|
+
return data.discounts;
|
|
543
541
|
}
|
|
544
542
|
async retrieve(params) {
|
|
545
543
|
const data = await this.apiClient.post(
|
|
@@ -550,7 +548,7 @@ var Discounts = class {
|
|
|
550
548
|
console.error(`Discount not found`);
|
|
551
549
|
return null;
|
|
552
550
|
}
|
|
553
|
-
return data;
|
|
551
|
+
return data.discount;
|
|
554
552
|
}
|
|
555
553
|
};
|
|
556
554
|
var discounts_default = Discounts;
|
|
@@ -567,11 +565,9 @@ var Products = class {
|
|
|
567
565
|
params
|
|
568
566
|
);
|
|
569
567
|
if (!data || !Array.isArray(data) || "isError" in data && data.isError || !("products" in data)) {
|
|
570
|
-
return
|
|
571
|
-
products: []
|
|
572
|
-
};
|
|
568
|
+
return [];
|
|
573
569
|
}
|
|
574
|
-
return data;
|
|
570
|
+
return data.products;
|
|
575
571
|
}
|
|
576
572
|
async retrieve(params) {
|
|
577
573
|
const data = await this.apiClient.post("/products/retrieve", params);
|
|
@@ -579,11 +575,14 @@ var Products = class {
|
|
|
579
575
|
console.error(`Product not found`);
|
|
580
576
|
return null;
|
|
581
577
|
}
|
|
582
|
-
return data;
|
|
578
|
+
return data.product;
|
|
583
579
|
}
|
|
584
580
|
};
|
|
585
581
|
var products_default = Products;
|
|
586
582
|
|
|
583
|
+
// src/types.ts
|
|
584
|
+
var import_bridge = require("@betterstore/bridge");
|
|
585
|
+
|
|
587
586
|
// src/index.ts
|
|
588
587
|
function createBetterStore(config) {
|
|
589
588
|
if (!config.apiKey) {
|
|
@@ -603,5 +602,7 @@ function createStoreClient(config) {
|
|
|
603
602
|
}
|
|
604
603
|
// Annotate the CommonJS export names for ESM import in node:
|
|
605
604
|
0 && (module.exports = {
|
|
606
|
-
createStoreClient
|
|
605
|
+
createStoreClient,
|
|
606
|
+
formatCurrency,
|
|
607
|
+
formatPrice
|
|
607
608
|
});
|
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,11 +536,14 @@ 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;
|
|
549
543
|
|
|
544
|
+
// src/types.ts
|
|
545
|
+
import { formatCurrency, formatPrice } from "@betterstore/bridge";
|
|
546
|
+
|
|
550
547
|
// src/index.ts
|
|
551
548
|
function createBetterStore(config) {
|
|
552
549
|
if (!config.apiKey) {
|
|
@@ -566,5 +563,7 @@ function createStoreClient(config) {
|
|
|
566
563
|
}
|
|
567
564
|
export {
|
|
568
565
|
createStoreClient,
|
|
569
|
-
createBetterStore as default
|
|
566
|
+
createBetterStore as default,
|
|
567
|
+
formatCurrency,
|
|
568
|
+
formatPrice
|
|
570
569
|
};
|