brainerce 1.46.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 +9 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -892,10 +892,19 @@ const suggestions = await client.getAddressSuggestions('Rothschild 1', sessionTo
|
|
|
892
892
|
const { address, inZone } = await client.getAddressDetails(suggestions[0].placeId, sessionToken);
|
|
893
893
|
// address: { line1, city, region, postalCode, country, lat, lng, formattedAddress }
|
|
894
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
|
+
|
|
895
903
|
await client.setShippingAddress(checkout.id, {
|
|
896
904
|
firstName: 'John',
|
|
897
905
|
lastName: 'Doe',
|
|
898
906
|
...address,
|
|
907
|
+
region,
|
|
899
908
|
});
|
|
900
909
|
|
|
901
910
|
if (!inZone) {
|
package/dist/index.d.mts
CHANGED
|
@@ -2970,11 +2970,31 @@ interface AddressSuggestion {
|
|
|
2970
2970
|
* zones. `inZone: false` doesn't mean the order can't ship there — it's a
|
|
2971
2971
|
* soft signal for a UI banner like "outside our regular delivery zones,
|
|
2972
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.
|
|
2973
2982
|
*/
|
|
2974
2983
|
interface AddressDetailsResult {
|
|
2975
2984
|
address: {
|
|
2976
2985
|
line1: string;
|
|
2977
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
|
+
*/
|
|
2978
2998
|
region: string;
|
|
2979
2999
|
postalCode: string;
|
|
2980
3000
|
country: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2970,11 +2970,31 @@ interface AddressSuggestion {
|
|
|
2970
2970
|
* zones. `inZone: false` doesn't mean the order can't ship there — it's a
|
|
2971
2971
|
* soft signal for a UI banner like "outside our regular delivery zones,
|
|
2972
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.
|
|
2973
2982
|
*/
|
|
2974
2983
|
interface AddressDetailsResult {
|
|
2975
2984
|
address: {
|
|
2976
2985
|
line1: string;
|
|
2977
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
|
+
*/
|
|
2978
2998
|
region: string;
|
|
2979
2999
|
postalCode: string;
|
|
2980
3000
|
country: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.46.
|
|
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",
|