@bacano/sdk 1.0.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/AUTHENTICATION.md +365 -0
- package/LICENSE +21 -0
- package/README.md +1357 -0
- package/client.d.ts +96 -0
- package/errors.d.ts +24 -0
- package/graphql.cjs +2057 -0
- package/graphql.d.ts +17 -0
- package/graphql.js +2034 -0
- package/index.cjs +4956 -0
- package/index.d.ts +8 -0
- package/index.js +4933 -0
- package/media.d.ts +9 -0
- package/modules/auth.d.ts +9 -0
- package/modules/availability.d.ts +6 -0
- package/modules/cart-session.d.ts +13 -0
- package/modules/cart.d.ts +16 -0
- package/modules/catalog.d.ts +24 -0
- package/modules/checkout.d.ts +42 -0
- package/modules/content.d.ts +9 -0
- package/modules/orders.d.ts +9 -0
- package/modules/profile.d.ts +8 -0
- package/modules/website.d.ts +3 -0
- package/package.json +52 -0
- package/react/context.d.ts +7 -0
- package/react/hooks.d.ts +74 -0
- package/react/provider.d.ts +7 -0
- package/react.cjs +5232 -0
- package/react.d.ts +23 -0
- package/react.js +5209 -0
- package/transport/documents.d.ts +83 -0
- package/transport/graphql.d.ts +7 -0
- package/types.d.ts +991 -0
package/client.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { BacanoClientConfig, BacanoClientContext, Brand, Cart, CartItem, CatalogAttributeList, CatalogPageResult, CatalogCategoryList, CheckoutResult, CheckoutSubmission, ContentEntry, ProductContentBlock, CustomerAddress, CustomerProfile, CustomerProfileUpdate, GetAttributeListOptions, GetCatalogPageOptions, GetCategoryListOptions, GetContentOptions, GetOrdersOptions, GetProductFiltersOptions, GetProductSeoEntriesOptions, GetProductRecommendationsOptions, ProductRecommendationsResult, GetProductsOptions, GetSearchSuggestionsOptions, Order, Product, ProductAvailability, ProductCategory, ProductFilters, ProductSeoEntriesResult, PublicOrder, PublicOrderLookupInput, WaitForPublicOrderPaymentInput, SearchSuggestion, StartGuestCheckoutInput, WebsiteCheckoutAddress, WebsiteCheckoutItem, WebsiteCouponActionResult, WebsiteDeliveryOption, WebsiteFreeShippingProgress, WebsiteFulfillmentFamily, WebsiteGuestContact, WebsiteLocationOptions, WebsitePaymentMethod, WebsitePaymentOption, WebsitePaymentSessionResult, WebsiteShippingQuote, WebsiteShippingPolicy } from "./types";
|
|
2
|
+
export interface BacanoClient {
|
|
3
|
+
/** Initialize the client and resolve its website context. */
|
|
4
|
+
init(): Promise<void>;
|
|
5
|
+
/** Get the resolved website context (company_id, chain_id, etc.) */
|
|
6
|
+
getContext(): BacanoClientContext;
|
|
7
|
+
auth: {
|
|
8
|
+
/** Returns the current token supplied by the storefront auth provider. */
|
|
9
|
+
getAccessToken(): Promise<string | null>;
|
|
10
|
+
/** Resolves whether the storefront currently has a buyer token. */
|
|
11
|
+
isAuthenticated(): Promise<boolean>;
|
|
12
|
+
};
|
|
13
|
+
catalog: {
|
|
14
|
+
getCatalogPage(opts: GetCatalogPageOptions): Promise<CatalogPageResult>;
|
|
15
|
+
getProductSeoEntries(opts?: GetProductSeoEntriesOptions): Promise<ProductSeoEntriesResult>;
|
|
16
|
+
getProductRecommendations(opts: GetProductRecommendationsOptions): Promise<ProductRecommendationsResult>;
|
|
17
|
+
getProducts(opts?: GetProductsOptions): Promise<Product[]>;
|
|
18
|
+
getProduct(productId: string): Promise<Product | null>;
|
|
19
|
+
getProductBySlug(slug: string): Promise<Product | null>;
|
|
20
|
+
getCategories(): Promise<ProductCategory[]>;
|
|
21
|
+
getCategoryList(opts: GetCategoryListOptions): Promise<CatalogCategoryList | null>;
|
|
22
|
+
getAttributeList(opts: GetAttributeListOptions): Promise<CatalogAttributeList | null>;
|
|
23
|
+
getBrands(): Promise<Brand[]>;
|
|
24
|
+
getProductFilters(opts?: GetProductFiltersOptions): Promise<ProductFilters>;
|
|
25
|
+
getSearchSuggestions(opts: GetSearchSuggestionsOptions): Promise<SearchSuggestion[]>;
|
|
26
|
+
checkAvailability(productVariantIds: string[]): Promise<ProductAvailability[]>;
|
|
27
|
+
};
|
|
28
|
+
content: {
|
|
29
|
+
getByKey(key: string, opts?: GetContentOptions): Promise<ContentEntry | null>;
|
|
30
|
+
getByCategory(categoryKey: string, opts?: GetContentOptions): Promise<ContentEntry[]>;
|
|
31
|
+
getByTag(tag: string, opts?: GetContentOptions): Promise<ContentEntry[]>;
|
|
32
|
+
getForProduct(productId: string, opts?: GetContentOptions): Promise<ProductContentBlock[]>;
|
|
33
|
+
};
|
|
34
|
+
cart: {
|
|
35
|
+
getOrCreate(contact?: WebsiteGuestContact, fulfillmentFamily?: WebsiteFulfillmentFamily): Promise<Cart>;
|
|
36
|
+
startCheckout(input: StartGuestCheckoutInput): Promise<Cart>;
|
|
37
|
+
get(): Promise<Cart | null>;
|
|
38
|
+
setItem(productVariantId: string, quantity: number): Promise<Cart>;
|
|
39
|
+
addItem(productVariantId: string, quantity: number): Promise<CartItem>;
|
|
40
|
+
updateItem(cartItemId: string, quantity: number): Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
quantity: number;
|
|
43
|
+
}>;
|
|
44
|
+
removeItem(cartItemId: string): Promise<Cart>;
|
|
45
|
+
};
|
|
46
|
+
checkout: {
|
|
47
|
+
getLocationOptions(): Promise<WebsiteLocationOptions>;
|
|
48
|
+
getDeliveryOptions(): Promise<WebsiteDeliveryOption[]>;
|
|
49
|
+
getShippingQuotes(input: {
|
|
50
|
+
address: WebsiteCheckoutAddress;
|
|
51
|
+
items?: WebsiteCheckoutItem[];
|
|
52
|
+
}): Promise<WebsiteShippingQuote[]>;
|
|
53
|
+
getShippingPolicy(): Promise<WebsiteShippingPolicy>;
|
|
54
|
+
getFreeShippingProgress(input: {
|
|
55
|
+
items: WebsiteCheckoutItem[];
|
|
56
|
+
}): Promise<WebsiteFreeShippingProgress>;
|
|
57
|
+
getPaymentMethods(): Promise<WebsitePaymentMethod[]>;
|
|
58
|
+
getPaymentOptions(input: {
|
|
59
|
+
fulfillmentFamily: "PICKUP" | "SHIPPING";
|
|
60
|
+
}): Promise<WebsitePaymentOption[]>;
|
|
61
|
+
validateCoupon(input: {
|
|
62
|
+
code: string;
|
|
63
|
+
}): Promise<WebsiteCouponActionResult>;
|
|
64
|
+
applyCoupon(input: {
|
|
65
|
+
code: string;
|
|
66
|
+
}): Promise<WebsiteCouponActionResult>;
|
|
67
|
+
removeCoupon(input: {
|
|
68
|
+
couponId: string;
|
|
69
|
+
}): Promise<WebsiteCouponActionResult>;
|
|
70
|
+
submit(input: CheckoutSubmission): Promise<CheckoutResult>;
|
|
71
|
+
createPaymentSession(input: {
|
|
72
|
+
orderId?: string;
|
|
73
|
+
publicOrderToken?: string;
|
|
74
|
+
paymentMethodId: string;
|
|
75
|
+
returnUrl: string;
|
|
76
|
+
}): Promise<WebsitePaymentSessionResult>;
|
|
77
|
+
reconcilePaymentSession(input: {
|
|
78
|
+
orderId: string;
|
|
79
|
+
publicOrderToken: string;
|
|
80
|
+
paymentSessionId: string;
|
|
81
|
+
gatewayTransactionId: string;
|
|
82
|
+
}): Promise<WebsitePaymentSessionResult>;
|
|
83
|
+
};
|
|
84
|
+
orders: {
|
|
85
|
+
list(opts?: GetOrdersOptions): Promise<Order[]>;
|
|
86
|
+
get(orderId: string): Promise<Order | null>;
|
|
87
|
+
getPublicOrder(input: PublicOrderLookupInput): Promise<PublicOrder | null>;
|
|
88
|
+
waitForPayment(input: WaitForPublicOrderPaymentInput): Promise<PublicOrder>;
|
|
89
|
+
};
|
|
90
|
+
profile: {
|
|
91
|
+
get(): Promise<CustomerProfile>;
|
|
92
|
+
getAddresses(): Promise<CustomerAddress[]>;
|
|
93
|
+
update(data: CustomerProfileUpdate): Promise<CustomerProfile>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export declare function createBacanoClient(config: BacanoClientConfig): BacanoClient;
|
package/errors.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class WebsiteError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(message: string, code?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class NotInitializedError extends WebsiteError {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare class AuthError extends WebsiteError {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class CheckoutError extends WebsiteError {
|
|
12
|
+
readonly errors: string[];
|
|
13
|
+
constructor(errors: string[]);
|
|
14
|
+
}
|
|
15
|
+
export declare class GraphQLRequestError extends WebsiteError {
|
|
16
|
+
readonly graphqlErrors: Array<{
|
|
17
|
+
message: string;
|
|
18
|
+
extensions?: Record<string, unknown>;
|
|
19
|
+
}>;
|
|
20
|
+
constructor(errors: Array<{
|
|
21
|
+
message: string;
|
|
22
|
+
extensions?: Record<string, unknown>;
|
|
23
|
+
}>);
|
|
24
|
+
}
|