brainerce 1.45.0 → 1.46.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/README.md +39 -0
- package/dist/index.d.mts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +96 -0
- package/dist/index.mjs +96 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -874,6 +874,45 @@ console.log('Order created:', orderId);
|
|
|
874
874
|
|
|
875
875
|
> **WARNING:** Do NOT use `submitGuestOrder()` for logged-in customers! Their orders won't be linked to their account and won't appear in their order history.
|
|
876
876
|
|
|
877
|
+
### Address Autocomplete (optional, for the `line1` field)
|
|
878
|
+
|
|
879
|
+
Turn the shipping address's `line1` input into a typeahead instead of free
|
|
880
|
+
text. Suggestions come from Google Places; each resolved address is flagged
|
|
881
|
+
`inZone` against the store's configured shipping zones — a soft signal for a
|
|
882
|
+
warning banner, never a hard block.
|
|
883
|
+
|
|
884
|
+
```typescript
|
|
885
|
+
const sessionToken = crypto.randomUUID(); // one per address-entry attempt
|
|
886
|
+
|
|
887
|
+
// Debounce (~300ms) as the shopper types
|
|
888
|
+
const suggestions = await client.getAddressSuggestions('Rothschild 1', sessionToken);
|
|
889
|
+
// [{ placeId: 'ChIJ...', description: 'Rothschild Blvd 1, Tel Aviv-Yafo' }, ...]
|
|
890
|
+
|
|
891
|
+
// On picking a suggestion — reuse the SAME sessionToken to end the session
|
|
892
|
+
const { address, inZone } = await client.getAddressDetails(suggestions[0].placeId, sessionToken);
|
|
893
|
+
// address: { line1, city, region, postalCode, country, lat, lng, formattedAddress }
|
|
894
|
+
|
|
895
|
+
// address.region is Google's own administrative-area code — usually (not
|
|
896
|
+
// guaranteed) the same ISO 3166-2 subdivision code this store's own region
|
|
897
|
+
// lists use. Validate against destinations.regions before trusting it;
|
|
898
|
+
// never assign a code the region <select> wouldn't recognize.
|
|
899
|
+
const destinations = await client.getShippingDestinations();
|
|
900
|
+
const validRegions = destinations.regions[address.country] ?? [];
|
|
901
|
+
const region = validRegions.some((r) => r.code === address.region) ? address.region : '';
|
|
902
|
+
|
|
903
|
+
await client.setShippingAddress(checkout.id, {
|
|
904
|
+
firstName: 'John',
|
|
905
|
+
lastName: 'Doe',
|
|
906
|
+
...address,
|
|
907
|
+
region,
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
if (!inZone) {
|
|
911
|
+
// Non-blocking: "This address is outside our regular delivery zones.
|
|
912
|
+
// You can still continue — we'll confirm delivery by phone."
|
|
913
|
+
}
|
|
914
|
+
```
|
|
915
|
+
|
|
877
916
|
---
|
|
878
917
|
|
|
879
918
|
## Cart (Unified for All Users)
|
package/dist/index.d.mts
CHANGED
|
@@ -2958,6 +2958,52 @@ interface ShippingDestinations {
|
|
|
2958
2958
|
name: string;
|
|
2959
2959
|
}>>;
|
|
2960
2960
|
}
|
|
2961
|
+
/** One predicted address from `getAddressSuggestions()`. */
|
|
2962
|
+
interface AddressSuggestion {
|
|
2963
|
+
/** Opaque id — pass to `getAddressDetails()` to resolve the full address. */
|
|
2964
|
+
placeId: string;
|
|
2965
|
+
/** Human-readable prediction text to render in the dropdown. */
|
|
2966
|
+
description: string;
|
|
2967
|
+
}
|
|
2968
|
+
/**
|
|
2969
|
+
* A resolved address + whether it falls inside any of the store's shipping
|
|
2970
|
+
* zones. `inZone: false` doesn't mean the order can't ship there — it's a
|
|
2971
|
+
* soft signal for a UI banner like "outside our regular delivery zones,
|
|
2972
|
+
* we'll confirm by phone" (see `getAddressDetails()`), never a hard block.
|
|
2973
|
+
*
|
|
2974
|
+
* This check intentionally ignores region-restricted zones (only
|
|
2975
|
+
* country/postal/drawn-shape coverage is considered) — Google's resolved
|
|
2976
|
+
* region text doesn't reliably match a store's own region codes (see
|
|
2977
|
+
* `address.region`'s doc comment below), so factoring it in here could
|
|
2978
|
+
* silently produce a false "outside zone". The authoritative, region-aware
|
|
2979
|
+
* check happens once the shopper picks their actual region from the
|
|
2980
|
+
* dropdown and rates are calculated — this field is a preview, not a
|
|
2981
|
+
* substitute for that.
|
|
2982
|
+
*/
|
|
2983
|
+
interface AddressDetailsResult {
|
|
2984
|
+
address: {
|
|
2985
|
+
line1: string;
|
|
2986
|
+
city: string;
|
|
2987
|
+
/**
|
|
2988
|
+
* Google's own administrative-area code for the resolved place (e.g.
|
|
2989
|
+
* `"D"` for an Israeli address in the Southern District). Usually — but
|
|
2990
|
+
* not guaranteed — the same ISO 3166-2 subdivision code this platform's
|
|
2991
|
+
* own region lists use (`getShippingDestinations()`'s `regions`), since
|
|
2992
|
+
* both ultimately derive from the same standard. Before assigning this
|
|
2993
|
+
* into a `SetShippingAddressDto.region` field, validate it against the
|
|
2994
|
+
* store's own `destinations.regions[country]` list (matching by `code`)
|
|
2995
|
+
* — if it's not one of the known codes, leave the field for the shopper
|
|
2996
|
+
* to pick manually rather than assigning an unrecognized value.
|
|
2997
|
+
*/
|
|
2998
|
+
region: string;
|
|
2999
|
+
postalCode: string;
|
|
3000
|
+
country: string;
|
|
3001
|
+
lat: number;
|
|
3002
|
+
lng: number;
|
|
3003
|
+
formattedAddress: string;
|
|
3004
|
+
};
|
|
3005
|
+
inZone: boolean;
|
|
3006
|
+
}
|
|
2961
3007
|
interface CompleteCheckoutResponse {
|
|
2962
3008
|
orderId: string;
|
|
2963
3009
|
}
|
|
@@ -8218,6 +8264,47 @@ declare class BrainerceClient {
|
|
|
8218
8264
|
* ```
|
|
8219
8265
|
*/
|
|
8220
8266
|
getShippingRates(checkoutId: string): Promise<ShippingRate[]>;
|
|
8267
|
+
/**
|
|
8268
|
+
* Address autocomplete predictions for a checkout address field.
|
|
8269
|
+
*
|
|
8270
|
+
* `sessionToken` groups one address-entry attempt together for billing —
|
|
8271
|
+
* generate a fresh id (e.g. `crypto.randomUUID()`) when the field is
|
|
8272
|
+
* focused, reuse it for every keystroke, then pass the same value once more
|
|
8273
|
+
* to `getAddressDetails()` when the shopper picks a suggestion. Debounce
|
|
8274
|
+
* calls to this method (e.g. 300ms) rather than firing on every keystroke.
|
|
8275
|
+
*
|
|
8276
|
+
* @example
|
|
8277
|
+
* ```typescript
|
|
8278
|
+
* const sessionToken = crypto.randomUUID();
|
|
8279
|
+
* const suggestions = await client.getAddressSuggestions('123 Main', sessionToken);
|
|
8280
|
+
* ```
|
|
8281
|
+
*/
|
|
8282
|
+
getAddressSuggestions(query: string, sessionToken: string, near?: {
|
|
8283
|
+
lat: number;
|
|
8284
|
+
lng: number;
|
|
8285
|
+
}): Promise<AddressSuggestion[]>;
|
|
8286
|
+
/**
|
|
8287
|
+
* Resolve a predicted place (from `getAddressSuggestions()`) to a full
|
|
8288
|
+
* postal address + coordinates, and whether it falls inside any of the
|
|
8289
|
+
* store's shipping zones. Pass the SAME `sessionToken` used for the
|
|
8290
|
+
* preceding suggestion calls — this is the billed call that ends the
|
|
8291
|
+
* autocomplete session.
|
|
8292
|
+
*
|
|
8293
|
+
* `inZone: false` is a soft signal, not a rejection — pair it with a
|
|
8294
|
+
* banner like "outside our regular delivery zones, we'll confirm by phone"
|
|
8295
|
+
* and still let the shopper continue.
|
|
8296
|
+
*
|
|
8297
|
+
* @example
|
|
8298
|
+
* ```typescript
|
|
8299
|
+
* const details = await client.getAddressDetails(suggestion.placeId, sessionToken);
|
|
8300
|
+
* if (!details.inZone) {
|
|
8301
|
+
* showOutsideZoneBanner();
|
|
8302
|
+
* }
|
|
8303
|
+
* ```
|
|
8304
|
+
*/
|
|
8305
|
+
getAddressDetails(placeId: string, sessionToken: string, options?: {
|
|
8306
|
+
regionId?: string;
|
|
8307
|
+
}): Promise<AddressDetailsResult>;
|
|
8221
8308
|
/**
|
|
8222
8309
|
* Select a shipping method for checkout
|
|
8223
8310
|
*
|
|
@@ -10366,4 +10453,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
|
|
|
10366
10453
|
/** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
|
|
10367
10454
|
declare function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
10368
10455
|
|
|
10369
|
-
export { type AddToCartDto, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SubmitProductReviewInput, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
|
|
10456
|
+
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SubmitProductReviewInput, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -2958,6 +2958,52 @@ interface ShippingDestinations {
|
|
|
2958
2958
|
name: string;
|
|
2959
2959
|
}>>;
|
|
2960
2960
|
}
|
|
2961
|
+
/** One predicted address from `getAddressSuggestions()`. */
|
|
2962
|
+
interface AddressSuggestion {
|
|
2963
|
+
/** Opaque id — pass to `getAddressDetails()` to resolve the full address. */
|
|
2964
|
+
placeId: string;
|
|
2965
|
+
/** Human-readable prediction text to render in the dropdown. */
|
|
2966
|
+
description: string;
|
|
2967
|
+
}
|
|
2968
|
+
/**
|
|
2969
|
+
* A resolved address + whether it falls inside any of the store's shipping
|
|
2970
|
+
* zones. `inZone: false` doesn't mean the order can't ship there — it's a
|
|
2971
|
+
* soft signal for a UI banner like "outside our regular delivery zones,
|
|
2972
|
+
* we'll confirm by phone" (see `getAddressDetails()`), never a hard block.
|
|
2973
|
+
*
|
|
2974
|
+
* This check intentionally ignores region-restricted zones (only
|
|
2975
|
+
* country/postal/drawn-shape coverage is considered) — Google's resolved
|
|
2976
|
+
* region text doesn't reliably match a store's own region codes (see
|
|
2977
|
+
* `address.region`'s doc comment below), so factoring it in here could
|
|
2978
|
+
* silently produce a false "outside zone". The authoritative, region-aware
|
|
2979
|
+
* check happens once the shopper picks their actual region from the
|
|
2980
|
+
* dropdown and rates are calculated — this field is a preview, not a
|
|
2981
|
+
* substitute for that.
|
|
2982
|
+
*/
|
|
2983
|
+
interface AddressDetailsResult {
|
|
2984
|
+
address: {
|
|
2985
|
+
line1: string;
|
|
2986
|
+
city: string;
|
|
2987
|
+
/**
|
|
2988
|
+
* Google's own administrative-area code for the resolved place (e.g.
|
|
2989
|
+
* `"D"` for an Israeli address in the Southern District). Usually — but
|
|
2990
|
+
* not guaranteed — the same ISO 3166-2 subdivision code this platform's
|
|
2991
|
+
* own region lists use (`getShippingDestinations()`'s `regions`), since
|
|
2992
|
+
* both ultimately derive from the same standard. Before assigning this
|
|
2993
|
+
* into a `SetShippingAddressDto.region` field, validate it against the
|
|
2994
|
+
* store's own `destinations.regions[country]` list (matching by `code`)
|
|
2995
|
+
* — if it's not one of the known codes, leave the field for the shopper
|
|
2996
|
+
* to pick manually rather than assigning an unrecognized value.
|
|
2997
|
+
*/
|
|
2998
|
+
region: string;
|
|
2999
|
+
postalCode: string;
|
|
3000
|
+
country: string;
|
|
3001
|
+
lat: number;
|
|
3002
|
+
lng: number;
|
|
3003
|
+
formattedAddress: string;
|
|
3004
|
+
};
|
|
3005
|
+
inZone: boolean;
|
|
3006
|
+
}
|
|
2961
3007
|
interface CompleteCheckoutResponse {
|
|
2962
3008
|
orderId: string;
|
|
2963
3009
|
}
|
|
@@ -8218,6 +8264,47 @@ declare class BrainerceClient {
|
|
|
8218
8264
|
* ```
|
|
8219
8265
|
*/
|
|
8220
8266
|
getShippingRates(checkoutId: string): Promise<ShippingRate[]>;
|
|
8267
|
+
/**
|
|
8268
|
+
* Address autocomplete predictions for a checkout address field.
|
|
8269
|
+
*
|
|
8270
|
+
* `sessionToken` groups one address-entry attempt together for billing —
|
|
8271
|
+
* generate a fresh id (e.g. `crypto.randomUUID()`) when the field is
|
|
8272
|
+
* focused, reuse it for every keystroke, then pass the same value once more
|
|
8273
|
+
* to `getAddressDetails()` when the shopper picks a suggestion. Debounce
|
|
8274
|
+
* calls to this method (e.g. 300ms) rather than firing on every keystroke.
|
|
8275
|
+
*
|
|
8276
|
+
* @example
|
|
8277
|
+
* ```typescript
|
|
8278
|
+
* const sessionToken = crypto.randomUUID();
|
|
8279
|
+
* const suggestions = await client.getAddressSuggestions('123 Main', sessionToken);
|
|
8280
|
+
* ```
|
|
8281
|
+
*/
|
|
8282
|
+
getAddressSuggestions(query: string, sessionToken: string, near?: {
|
|
8283
|
+
lat: number;
|
|
8284
|
+
lng: number;
|
|
8285
|
+
}): Promise<AddressSuggestion[]>;
|
|
8286
|
+
/**
|
|
8287
|
+
* Resolve a predicted place (from `getAddressSuggestions()`) to a full
|
|
8288
|
+
* postal address + coordinates, and whether it falls inside any of the
|
|
8289
|
+
* store's shipping zones. Pass the SAME `sessionToken` used for the
|
|
8290
|
+
* preceding suggestion calls — this is the billed call that ends the
|
|
8291
|
+
* autocomplete session.
|
|
8292
|
+
*
|
|
8293
|
+
* `inZone: false` is a soft signal, not a rejection — pair it with a
|
|
8294
|
+
* banner like "outside our regular delivery zones, we'll confirm by phone"
|
|
8295
|
+
* and still let the shopper continue.
|
|
8296
|
+
*
|
|
8297
|
+
* @example
|
|
8298
|
+
* ```typescript
|
|
8299
|
+
* const details = await client.getAddressDetails(suggestion.placeId, sessionToken);
|
|
8300
|
+
* if (!details.inZone) {
|
|
8301
|
+
* showOutsideZoneBanner();
|
|
8302
|
+
* }
|
|
8303
|
+
* ```
|
|
8304
|
+
*/
|
|
8305
|
+
getAddressDetails(placeId: string, sessionToken: string, options?: {
|
|
8306
|
+
regionId?: string;
|
|
8307
|
+
}): Promise<AddressDetailsResult>;
|
|
8221
8308
|
/**
|
|
8222
8309
|
* Select a shipping method for checkout
|
|
8223
8310
|
*
|
|
@@ -10366,4 +10453,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
|
|
|
10366
10453
|
/** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
|
|
10367
10454
|
declare function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
10368
10455
|
|
|
10369
|
-
export { type AddToCartDto, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SubmitProductReviewInput, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
|
|
10456
|
+
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SubmitProductReviewInput, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -4924,6 +4924,102 @@ var BrainerceClient = class {
|
|
|
4924
4924
|
`/api/v1/checkout/${encodePathSegment(checkoutId)}/shipping-rates`
|
|
4925
4925
|
);
|
|
4926
4926
|
}
|
|
4927
|
+
/**
|
|
4928
|
+
* Address autocomplete predictions for a checkout address field.
|
|
4929
|
+
*
|
|
4930
|
+
* `sessionToken` groups one address-entry attempt together for billing —
|
|
4931
|
+
* generate a fresh id (e.g. `crypto.randomUUID()`) when the field is
|
|
4932
|
+
* focused, reuse it for every keystroke, then pass the same value once more
|
|
4933
|
+
* to `getAddressDetails()` when the shopper picks a suggestion. Debounce
|
|
4934
|
+
* calls to this method (e.g. 300ms) rather than firing on every keystroke.
|
|
4935
|
+
*
|
|
4936
|
+
* @example
|
|
4937
|
+
* ```typescript
|
|
4938
|
+
* const sessionToken = crypto.randomUUID();
|
|
4939
|
+
* const suggestions = await client.getAddressSuggestions('123 Main', sessionToken);
|
|
4940
|
+
* ```
|
|
4941
|
+
*/
|
|
4942
|
+
async getAddressSuggestions(query, sessionToken, near) {
|
|
4943
|
+
const queryParams = {
|
|
4944
|
+
q: query,
|
|
4945
|
+
sessionToken,
|
|
4946
|
+
lat: near?.lat,
|
|
4947
|
+
lng: near?.lng
|
|
4948
|
+
};
|
|
4949
|
+
if (this.isVibeCodedMode()) {
|
|
4950
|
+
const result2 = await this.vibeCodedRequest(
|
|
4951
|
+
"GET",
|
|
4952
|
+
"/checkout/address-suggestions",
|
|
4953
|
+
void 0,
|
|
4954
|
+
queryParams
|
|
4955
|
+
);
|
|
4956
|
+
return result2.suggestions;
|
|
4957
|
+
}
|
|
4958
|
+
if (this.storeId && !this.apiKey) {
|
|
4959
|
+
const result2 = await this.storefrontRequest(
|
|
4960
|
+
"GET",
|
|
4961
|
+
"/checkout/address-suggestions",
|
|
4962
|
+
void 0,
|
|
4963
|
+
queryParams
|
|
4964
|
+
);
|
|
4965
|
+
return result2.suggestions;
|
|
4966
|
+
}
|
|
4967
|
+
const result = await this.adminRequest(
|
|
4968
|
+
"GET",
|
|
4969
|
+
"/api/v1/checkout/address-suggestions",
|
|
4970
|
+
void 0,
|
|
4971
|
+
queryParams
|
|
4972
|
+
);
|
|
4973
|
+
return result.suggestions;
|
|
4974
|
+
}
|
|
4975
|
+
/**
|
|
4976
|
+
* Resolve a predicted place (from `getAddressSuggestions()`) to a full
|
|
4977
|
+
* postal address + coordinates, and whether it falls inside any of the
|
|
4978
|
+
* store's shipping zones. Pass the SAME `sessionToken` used for the
|
|
4979
|
+
* preceding suggestion calls — this is the billed call that ends the
|
|
4980
|
+
* autocomplete session.
|
|
4981
|
+
*
|
|
4982
|
+
* `inZone: false` is a soft signal, not a rejection — pair it with a
|
|
4983
|
+
* banner like "outside our regular delivery zones, we'll confirm by phone"
|
|
4984
|
+
* and still let the shopper continue.
|
|
4985
|
+
*
|
|
4986
|
+
* @example
|
|
4987
|
+
* ```typescript
|
|
4988
|
+
* const details = await client.getAddressDetails(suggestion.placeId, sessionToken);
|
|
4989
|
+
* if (!details.inZone) {
|
|
4990
|
+
* showOutsideZoneBanner();
|
|
4991
|
+
* }
|
|
4992
|
+
* ```
|
|
4993
|
+
*/
|
|
4994
|
+
async getAddressDetails(placeId, sessionToken, options) {
|
|
4995
|
+
const queryParams = {
|
|
4996
|
+
placeId,
|
|
4997
|
+
sessionToken,
|
|
4998
|
+
regionId: options?.regionId
|
|
4999
|
+
};
|
|
5000
|
+
if (this.isVibeCodedMode()) {
|
|
5001
|
+
return this.vibeCodedRequest(
|
|
5002
|
+
"GET",
|
|
5003
|
+
"/checkout/address-details",
|
|
5004
|
+
void 0,
|
|
5005
|
+
queryParams
|
|
5006
|
+
);
|
|
5007
|
+
}
|
|
5008
|
+
if (this.storeId && !this.apiKey) {
|
|
5009
|
+
return this.storefrontRequest(
|
|
5010
|
+
"GET",
|
|
5011
|
+
"/checkout/address-details",
|
|
5012
|
+
void 0,
|
|
5013
|
+
queryParams
|
|
5014
|
+
);
|
|
5015
|
+
}
|
|
5016
|
+
return this.adminRequest(
|
|
5017
|
+
"GET",
|
|
5018
|
+
"/api/v1/checkout/address-details",
|
|
5019
|
+
void 0,
|
|
5020
|
+
queryParams
|
|
5021
|
+
);
|
|
5022
|
+
}
|
|
4927
5023
|
/**
|
|
4928
5024
|
* Select a shipping method for checkout
|
|
4929
5025
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -4854,6 +4854,102 @@ var BrainerceClient = class {
|
|
|
4854
4854
|
`/api/v1/checkout/${encodePathSegment(checkoutId)}/shipping-rates`
|
|
4855
4855
|
);
|
|
4856
4856
|
}
|
|
4857
|
+
/**
|
|
4858
|
+
* Address autocomplete predictions for a checkout address field.
|
|
4859
|
+
*
|
|
4860
|
+
* `sessionToken` groups one address-entry attempt together for billing —
|
|
4861
|
+
* generate a fresh id (e.g. `crypto.randomUUID()`) when the field is
|
|
4862
|
+
* focused, reuse it for every keystroke, then pass the same value once more
|
|
4863
|
+
* to `getAddressDetails()` when the shopper picks a suggestion. Debounce
|
|
4864
|
+
* calls to this method (e.g. 300ms) rather than firing on every keystroke.
|
|
4865
|
+
*
|
|
4866
|
+
* @example
|
|
4867
|
+
* ```typescript
|
|
4868
|
+
* const sessionToken = crypto.randomUUID();
|
|
4869
|
+
* const suggestions = await client.getAddressSuggestions('123 Main', sessionToken);
|
|
4870
|
+
* ```
|
|
4871
|
+
*/
|
|
4872
|
+
async getAddressSuggestions(query, sessionToken, near) {
|
|
4873
|
+
const queryParams = {
|
|
4874
|
+
q: query,
|
|
4875
|
+
sessionToken,
|
|
4876
|
+
lat: near?.lat,
|
|
4877
|
+
lng: near?.lng
|
|
4878
|
+
};
|
|
4879
|
+
if (this.isVibeCodedMode()) {
|
|
4880
|
+
const result2 = await this.vibeCodedRequest(
|
|
4881
|
+
"GET",
|
|
4882
|
+
"/checkout/address-suggestions",
|
|
4883
|
+
void 0,
|
|
4884
|
+
queryParams
|
|
4885
|
+
);
|
|
4886
|
+
return result2.suggestions;
|
|
4887
|
+
}
|
|
4888
|
+
if (this.storeId && !this.apiKey) {
|
|
4889
|
+
const result2 = await this.storefrontRequest(
|
|
4890
|
+
"GET",
|
|
4891
|
+
"/checkout/address-suggestions",
|
|
4892
|
+
void 0,
|
|
4893
|
+
queryParams
|
|
4894
|
+
);
|
|
4895
|
+
return result2.suggestions;
|
|
4896
|
+
}
|
|
4897
|
+
const result = await this.adminRequest(
|
|
4898
|
+
"GET",
|
|
4899
|
+
"/api/v1/checkout/address-suggestions",
|
|
4900
|
+
void 0,
|
|
4901
|
+
queryParams
|
|
4902
|
+
);
|
|
4903
|
+
return result.suggestions;
|
|
4904
|
+
}
|
|
4905
|
+
/**
|
|
4906
|
+
* Resolve a predicted place (from `getAddressSuggestions()`) to a full
|
|
4907
|
+
* postal address + coordinates, and whether it falls inside any of the
|
|
4908
|
+
* store's shipping zones. Pass the SAME `sessionToken` used for the
|
|
4909
|
+
* preceding suggestion calls — this is the billed call that ends the
|
|
4910
|
+
* autocomplete session.
|
|
4911
|
+
*
|
|
4912
|
+
* `inZone: false` is a soft signal, not a rejection — pair it with a
|
|
4913
|
+
* banner like "outside our regular delivery zones, we'll confirm by phone"
|
|
4914
|
+
* and still let the shopper continue.
|
|
4915
|
+
*
|
|
4916
|
+
* @example
|
|
4917
|
+
* ```typescript
|
|
4918
|
+
* const details = await client.getAddressDetails(suggestion.placeId, sessionToken);
|
|
4919
|
+
* if (!details.inZone) {
|
|
4920
|
+
* showOutsideZoneBanner();
|
|
4921
|
+
* }
|
|
4922
|
+
* ```
|
|
4923
|
+
*/
|
|
4924
|
+
async getAddressDetails(placeId, sessionToken, options) {
|
|
4925
|
+
const queryParams = {
|
|
4926
|
+
placeId,
|
|
4927
|
+
sessionToken,
|
|
4928
|
+
regionId: options?.regionId
|
|
4929
|
+
};
|
|
4930
|
+
if (this.isVibeCodedMode()) {
|
|
4931
|
+
return this.vibeCodedRequest(
|
|
4932
|
+
"GET",
|
|
4933
|
+
"/checkout/address-details",
|
|
4934
|
+
void 0,
|
|
4935
|
+
queryParams
|
|
4936
|
+
);
|
|
4937
|
+
}
|
|
4938
|
+
if (this.storeId && !this.apiKey) {
|
|
4939
|
+
return this.storefrontRequest(
|
|
4940
|
+
"GET",
|
|
4941
|
+
"/checkout/address-details",
|
|
4942
|
+
void 0,
|
|
4943
|
+
queryParams
|
|
4944
|
+
);
|
|
4945
|
+
}
|
|
4946
|
+
return this.adminRequest(
|
|
4947
|
+
"GET",
|
|
4948
|
+
"/api/v1/checkout/address-details",
|
|
4949
|
+
void 0,
|
|
4950
|
+
queryParams
|
|
4951
|
+
);
|
|
4952
|
+
}
|
|
4857
4953
|
/**
|
|
4858
4954
|
* Select a shipping method for checkout
|
|
4859
4955
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.2",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with Brainerce Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|