brainerce 1.58.1 → 1.59.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/README.md +299 -102
- package/dist/index.d.mts +154 -28
- package/dist/index.d.ts +154 -28
- package/dist/index.js +38 -18
- package/dist/index.mjs +38 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2665,7 +2665,8 @@ interface AddToCartDto {
|
|
|
2665
2665
|
* Modifier-group selections for restaurant / customizable products
|
|
2666
2666
|
* (e.g., toppings, sauces, sides). The server validates against effective
|
|
2667
2667
|
* group rules and rejects invalid payloads with a `MODIFIER_VALIDATION_FAILED`
|
|
2668
|
-
* envelope
|
|
2668
|
+
* envelope, readable at `BrainerceError.details` — see
|
|
2669
|
+
* {@link ModifierValidationFailedError}.
|
|
2669
2670
|
*/
|
|
2670
2671
|
selections?: ModifierSelection[];
|
|
2671
2672
|
/**
|
|
@@ -3889,19 +3890,99 @@ interface StockAvailabilityResponse {
|
|
|
3889
3890
|
allAvailable: boolean;
|
|
3890
3891
|
results: StockAvailabilityResult[];
|
|
3891
3892
|
}
|
|
3893
|
+
/**
|
|
3894
|
+
* Body of a `409`/`400` stock rejection, as it actually arrives on the wire.
|
|
3895
|
+
*
|
|
3896
|
+
* This is the shape of `BrainerceError.details` — the SDK puts the **whole
|
|
3897
|
+
* parsed response body** there, so you read `err.details.code` and the
|
|
3898
|
+
* quantities under `err.details.details`:
|
|
3899
|
+
*
|
|
3900
|
+
* ```typescript
|
|
3901
|
+
* try {
|
|
3902
|
+
* await client.addToCart(cartId, { productId, quantity: 5 });
|
|
3903
|
+
* } catch (err) {
|
|
3904
|
+
* const body = (err as BrainerceError).details as InsufficientStockError;
|
|
3905
|
+
* if (body?.code === 'INSUFFICIENT_STOCK') {
|
|
3906
|
+
* // single-line rejection (add-to-cart, reservation)
|
|
3907
|
+
* console.log(body.details.available, body.details.requested);
|
|
3908
|
+
* // multi-line rejection (checkout) — every offending line
|
|
3909
|
+
* body.details.items?.forEach((i) => console.log(i.productId, i.available));
|
|
3910
|
+
* }
|
|
3911
|
+
* }
|
|
3912
|
+
* ```
|
|
3913
|
+
*
|
|
3914
|
+
* Which keys are populated depends on where the error came from:
|
|
3915
|
+
* - Cart add/update and inventory reservation reject **one** line, so they
|
|
3916
|
+
* send `available` + `requested`.
|
|
3917
|
+
* - Checkout validates the **whole** cart, so it sends `items[]`.
|
|
3918
|
+
* Treat every key as optional and branch on what is present.
|
|
3919
|
+
*/
|
|
3892
3920
|
interface InsufficientStockError {
|
|
3893
3921
|
code: 'INSUFFICIENT_STOCK';
|
|
3894
3922
|
message: string;
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
productId
|
|
3901
|
-
variantId?: string;
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3923
|
+
details: {
|
|
3924
|
+
/** Units actually purchasable. Single-line rejections only. */
|
|
3925
|
+
available?: number;
|
|
3926
|
+
/** Units the request asked for. Single-line rejections only. */
|
|
3927
|
+
requested?: number;
|
|
3928
|
+
productId?: string;
|
|
3929
|
+
variantId?: string | null;
|
|
3930
|
+
/** Per-line breakdown. Checkout-time rejections only. */
|
|
3931
|
+
items?: Array<{
|
|
3932
|
+
productId: string;
|
|
3933
|
+
variantId?: string | null;
|
|
3934
|
+
available?: number;
|
|
3935
|
+
requested?: number;
|
|
3936
|
+
}>;
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
/**
|
|
3940
|
+
* Body of a `400` modifier-selection rejection (`MODIFIER_VALIDATION_FAILED`).
|
|
3941
|
+
*
|
|
3942
|
+
* Like every error body, this is what lands in `BrainerceError.details`, so
|
|
3943
|
+
* the issue list is `err.details.details.errors`. Render each entry inline
|
|
3944
|
+
* next to the group or modifier it names.
|
|
3945
|
+
*/
|
|
3946
|
+
interface ModifierValidationFailedError {
|
|
3947
|
+
code: 'MODIFIER_VALIDATION_FAILED';
|
|
3948
|
+
message: string;
|
|
3949
|
+
details: {
|
|
3950
|
+
errors: ModifierValidationError[];
|
|
3951
|
+
};
|
|
3952
|
+
}
|
|
3953
|
+
/**
|
|
3954
|
+
* Body of a `400` price-drift rejection (`PRICE_DRIFT`), raised by
|
|
3955
|
+
* `createCheckout` when a cart line's snapshot price no longer matches the
|
|
3956
|
+
* live price. Recover with `refreshCartSnapshots()` or by removing the lines.
|
|
3957
|
+
*/
|
|
3958
|
+
interface PriceDriftError {
|
|
3959
|
+
code: 'PRICE_DRIFT';
|
|
3960
|
+
message: string;
|
|
3961
|
+
details: {
|
|
3962
|
+
items: Array<{
|
|
3963
|
+
itemId: string;
|
|
3964
|
+
productId: string;
|
|
3965
|
+
variantId?: string | null;
|
|
3966
|
+
oldUnitPrice: string;
|
|
3967
|
+
newUnitPrice: string;
|
|
3968
|
+
delta: string;
|
|
3969
|
+
direction: 'increased' | 'decreased';
|
|
3970
|
+
}>;
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
/**
|
|
3974
|
+
* Body of a `400` `PRODUCT_UNAVAILABLE` rejection — a line's product was
|
|
3975
|
+
* deleted, unpublished, or has inventory tracking disabled.
|
|
3976
|
+
*/
|
|
3977
|
+
interface ProductUnavailableError {
|
|
3978
|
+
code: 'PRODUCT_UNAVAILABLE';
|
|
3979
|
+
message: string;
|
|
3980
|
+
details?: {
|
|
3981
|
+
items?: Array<{
|
|
3982
|
+
productId: string;
|
|
3983
|
+
variantId?: string | null;
|
|
3984
|
+
}>;
|
|
3985
|
+
};
|
|
3905
3986
|
}
|
|
3906
3987
|
interface PublishProductResponse {
|
|
3907
3988
|
productId: string;
|
|
@@ -4682,7 +4763,8 @@ interface ShippingRateConfig {
|
|
|
4682
4763
|
minDeliveryDays?: number | null;
|
|
4683
4764
|
maxDeliveryDays?: number | null;
|
|
4684
4765
|
handlingTime?: number | null;
|
|
4685
|
-
|
|
4766
|
+
/** Whether the delivery charge itself is taxed. `NONE` leaves postage untaxed; omitted (or `TAXABLE`) taxes it at the store's standard rate. */
|
|
4767
|
+
taxStatus: 'TAXABLE' | 'NONE';
|
|
4686
4768
|
minOrderAmount?: number | null;
|
|
4687
4769
|
maxCost?: number | null;
|
|
4688
4770
|
isActive: boolean;
|
|
@@ -4732,7 +4814,8 @@ interface CreateShippingRateDto {
|
|
|
4732
4814
|
minDeliveryDays?: number;
|
|
4733
4815
|
maxDeliveryDays?: number;
|
|
4734
4816
|
handlingTime?: number;
|
|
4735
|
-
|
|
4817
|
+
/** Whether the delivery charge itself is taxed. `NONE` leaves postage untaxed; omitted (or `TAXABLE`) taxes it at the store's standard rate. */
|
|
4818
|
+
taxStatus?: 'TAXABLE' | 'NONE';
|
|
4736
4819
|
minOrderAmount?: number;
|
|
4737
4820
|
maxCost?: number;
|
|
4738
4821
|
isActive?: boolean;
|
|
@@ -4745,7 +4828,8 @@ interface UpdateShippingRateDto {
|
|
|
4745
4828
|
minDeliveryDays?: number | null;
|
|
4746
4829
|
maxDeliveryDays?: number | null;
|
|
4747
4830
|
handlingTime?: number | null;
|
|
4748
|
-
|
|
4831
|
+
/** Whether the delivery charge itself is taxed. `NONE` leaves postage untaxed; omitted (or `TAXABLE`) taxes it at the store's standard rate. */
|
|
4832
|
+
taxStatus?: 'TAXABLE' | 'NONE';
|
|
4749
4833
|
minOrderAmount?: number | null;
|
|
4750
4834
|
maxCost?: number | null;
|
|
4751
4835
|
isActive?: boolean;
|
|
@@ -4767,16 +4851,29 @@ interface TaxRate {
|
|
|
4767
4851
|
accountId: string;
|
|
4768
4852
|
storeId: string;
|
|
4769
4853
|
name: string;
|
|
4770
|
-
/**
|
|
4854
|
+
/**
|
|
4855
|
+
* Tax rate as a **percentage**, e.g. `"8.5"` for 8.5%. Range 0–100.
|
|
4856
|
+
*
|
|
4857
|
+
* Note this differs from {@link TaxBreakdownItem.rate}, which is a decimal
|
|
4858
|
+
* fraction (`0.085`) because it is computed rather than stored.
|
|
4859
|
+
*/
|
|
4771
4860
|
rate: string;
|
|
4772
4861
|
/** ISO country code */
|
|
4773
4862
|
country?: string | null;
|
|
4774
4863
|
/** Region/state code */
|
|
4775
4864
|
region?: string | null;
|
|
4776
|
-
/**
|
|
4865
|
+
/**
|
|
4866
|
+
* Postal code, matched **exactly** (case-insensitive, spaces and hyphens
|
|
4867
|
+
* ignored). Wildcards, prefixes and ranges are NOT supported — `941*` and
|
|
4868
|
+
* `94100-94199` match nothing.
|
|
4869
|
+
*/
|
|
4777
4870
|
postalCode?: string | null;
|
|
4778
4871
|
taxType: string;
|
|
4779
|
-
/**
|
|
4872
|
+
/**
|
|
4873
|
+
* @deprecated Not implemented. There is no `isCompound` column, nothing
|
|
4874
|
+
* reads this value, and rates never compound. Sending it on a create or
|
|
4875
|
+
* update request is rejected with a 400.
|
|
4876
|
+
*/
|
|
4780
4877
|
isCompound: boolean;
|
|
4781
4878
|
/** Whether tax is included in prices */
|
|
4782
4879
|
isInclusive: boolean;
|
|
@@ -4791,11 +4888,17 @@ interface TaxRate {
|
|
|
4791
4888
|
}
|
|
4792
4889
|
interface CreateTaxRateDto {
|
|
4793
4890
|
name: string;
|
|
4891
|
+
/** Tax rate as a **percentage**, e.g. `8.5` for 8.5%. Range 0–100. */
|
|
4794
4892
|
rate: number;
|
|
4795
4893
|
country?: string;
|
|
4796
4894
|
region?: string;
|
|
4895
|
+
/** Matched exactly — wildcards, prefixes and ranges are NOT supported. */
|
|
4797
4896
|
postalCode?: string;
|
|
4798
4897
|
taxType?: string;
|
|
4898
|
+
/**
|
|
4899
|
+
* @deprecated Not implemented — the backend rejects this field with a 400.
|
|
4900
|
+
* Rates never compound. Omit it.
|
|
4901
|
+
*/
|
|
4799
4902
|
isCompound?: boolean;
|
|
4800
4903
|
isInclusive?: boolean;
|
|
4801
4904
|
/** Tax class this rate applies to. Omit/null = Standard. */
|
|
@@ -4806,11 +4909,17 @@ interface CreateTaxRateDto {
|
|
|
4806
4909
|
}
|
|
4807
4910
|
interface UpdateTaxRateDto {
|
|
4808
4911
|
name?: string;
|
|
4912
|
+
/** Tax rate as a **percentage**, e.g. `8.5` for 8.5%. Range 0–100. */
|
|
4809
4913
|
rate?: number;
|
|
4810
4914
|
country?: string | null;
|
|
4811
4915
|
region?: string | null;
|
|
4916
|
+
/** Matched exactly — wildcards, prefixes and ranges are NOT supported. */
|
|
4812
4917
|
postalCode?: string | null;
|
|
4813
4918
|
taxType?: string;
|
|
4919
|
+
/**
|
|
4920
|
+
* @deprecated Not implemented — the backend rejects this field with a 400.
|
|
4921
|
+
* Rates never compound. Omit it.
|
|
4922
|
+
*/
|
|
4814
4923
|
isCompound?: boolean;
|
|
4815
4924
|
isInclusive?: boolean;
|
|
4816
4925
|
priority?: number;
|
|
@@ -6637,11 +6746,13 @@ declare function getDirectionForLocale(locale: string | undefined | null): 'ltr'
|
|
|
6637
6746
|
*
|
|
6638
6747
|
* Three modes of operation:
|
|
6639
6748
|
*
|
|
6640
|
-
* **
|
|
6749
|
+
* **Sales-Channel Mode (Simplest)** - Use salesChannelId for vibe-coded sites:
|
|
6641
6750
|
* ```typescript
|
|
6642
|
-
* const client = new BrainerceClient({
|
|
6751
|
+
* const client = new BrainerceClient({ salesChannelId: 'vc_abc123...' });
|
|
6643
6752
|
* const products = await client.getProducts();
|
|
6644
6753
|
* ```
|
|
6754
|
+
* (`connectionId` is a deprecated alias of `salesChannelId`. It still works but
|
|
6755
|
+
* logs a deprecation warning on every construction and is removed in SDK 2.0.)
|
|
6645
6756
|
*
|
|
6646
6757
|
* **Storefront Mode (Frontend)** - Use storeId for public access:
|
|
6647
6758
|
* ```typescript
|
|
@@ -8852,7 +8963,9 @@ declare class BrainerceClient {
|
|
|
8852
8963
|
* try {
|
|
8853
8964
|
* await client.createCheckout(cartId);
|
|
8854
8965
|
* } catch (err) {
|
|
8855
|
-
*
|
|
8966
|
+
* // BrainerceError.details is the whole response body — the code lives
|
|
8967
|
+
* // there, NOT on the error object itself.
|
|
8968
|
+
* if ((err as BrainerceError).details?.code === 'PRICE_DRIFT') {
|
|
8856
8969
|
* // ask user to confirm new prices, then:
|
|
8857
8970
|
* await client.refreshCartSnapshots(cartId);
|
|
8858
8971
|
* await client.createCheckout(cartId);
|
|
@@ -9633,12 +9746,18 @@ declare class BrainerceClient {
|
|
|
9633
9746
|
* Get applicable custom field definitions for a checkout.
|
|
9634
9747
|
* Returns fields filtered by visibility conditions (delivery type, products in cart).
|
|
9635
9748
|
* Use these to render dynamic input fields in the checkout flow.
|
|
9749
|
+
*
|
|
9750
|
+
* **Vibe-coded or storefront mode only.** There is no checkout custom-field
|
|
9751
|
+
* route on the API-key `/v1` surface; in admin mode this throws.
|
|
9636
9752
|
*/
|
|
9637
9753
|
getCheckoutCustomFields(checkoutId: string): Promise<CheckoutCustomFieldDefinition[]>;
|
|
9638
9754
|
/**
|
|
9639
9755
|
* Set checkout custom field values and recalculate surcharges.
|
|
9640
9756
|
* The checkout total is automatically updated to include surcharges.
|
|
9641
9757
|
*
|
|
9758
|
+
* **Vibe-coded or storefront mode only.** There is no checkout custom-field
|
|
9759
|
+
* route on the API-key `/v1` surface; in admin mode this throws.
|
|
9760
|
+
*
|
|
9642
9761
|
* @example
|
|
9643
9762
|
* ```typescript
|
|
9644
9763
|
* const checkout = await client.setCheckoutCustomFields(checkoutId, {
|
|
@@ -11414,31 +11533,38 @@ declare class BrainerceClient {
|
|
|
11414
11533
|
key: string;
|
|
11415
11534
|
}>;
|
|
11416
11535
|
/**
|
|
11417
|
-
* @deprecated
|
|
11536
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `getStoreTeam`
|
|
11537
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11418
11538
|
*/
|
|
11419
11539
|
getTeamMembers(): Promise<TeamMembersResponse>;
|
|
11420
11540
|
/**
|
|
11421
|
-
* @deprecated
|
|
11541
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `getStoreTeam`
|
|
11542
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11422
11543
|
*/
|
|
11423
11544
|
getTeamInvitations(): Promise<TeamInvitationsResponse>;
|
|
11424
11545
|
/**
|
|
11425
|
-
* @deprecated
|
|
11546
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `inviteStoreMember`
|
|
11547
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11426
11548
|
*/
|
|
11427
11549
|
inviteTeamMember(data: InviteMemberDto): Promise<TeamInvitation>;
|
|
11428
11550
|
/**
|
|
11429
|
-
* @deprecated
|
|
11551
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `resendStoreInvitation`
|
|
11552
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11430
11553
|
*/
|
|
11431
11554
|
resendTeamInvitation(invitationId: string): Promise<TeamInvitation>;
|
|
11432
11555
|
/**
|
|
11433
|
-
* @deprecated
|
|
11556
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `revokeStoreInvitation`
|
|
11557
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11434
11558
|
*/
|
|
11435
11559
|
revokeTeamInvitation(invitationId: string): Promise<void>;
|
|
11436
11560
|
/**
|
|
11437
|
-
* @deprecated
|
|
11561
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `updateStoreMember`
|
|
11562
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11438
11563
|
*/
|
|
11439
11564
|
updateTeamMemberRole(memberId: string, data: UpdateMemberRoleDto): Promise<TeamMember>;
|
|
11440
11565
|
/**
|
|
11441
|
-
* @deprecated
|
|
11566
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `removeStoreMember`
|
|
11567
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
11442
11568
|
*/
|
|
11443
11569
|
removeTeamMember(memberId: string): Promise<void>;
|
|
11444
11570
|
/**
|
|
@@ -12153,4 +12279,4 @@ interface CategorySitemapOptions {
|
|
|
12153
12279
|
*/
|
|
12154
12280
|
declare function getCategorySitemapEntries(client: BrainerceClient, opts: CategorySitemapOptions): Promise<SitemapEntry[]>;
|
|
12155
12281
|
|
|
12156
|
-
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkCreateProductsDto, type BulkCreateProductsError, type BulkCreateProductsJob, type BulkCreateProductsStatus, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, 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 CategoryDetail, type CategoryNode, type CategorySitemapOptions, 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 DateAvailabilityConstraints, type DateFieldParseResult, 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 JsonLdOptions, 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 MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, 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 ParsedDateFieldValue, 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 ProductSitemapOptions, 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 ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, 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 TrackingEventItem, type TrackingEventName, type TrackingEventPayload, 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, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductFaqJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSitemapEntries, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
|
|
12282
|
+
export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkCreateProductsDto, type BulkCreateProductsError, type BulkCreateProductsJob, type BulkCreateProductsStatus, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, 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 CategoryDetail, type CategoryNode, type CategorySitemapOptions, 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 DateAvailabilityConstraints, type DateFieldParseResult, 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 JsonLdOptions, 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 MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type ModifierValidationFailedError, 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 ParsedDateFieldValue, 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 PriceDriftError, 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 ProductSitemapOptions, type ProductSuggestion, type ProductUnavailableError, 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 ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, 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 TrackingEventItem, type TrackingEventName, type TrackingEventPayload, 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, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductFaqJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSitemapEntries, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -4205,7 +4205,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
4205
4205
|
* try {
|
|
4206
4206
|
* await client.createCheckout(cartId);
|
|
4207
4207
|
* } catch (err) {
|
|
4208
|
-
*
|
|
4208
|
+
* // BrainerceError.details is the whole response body — the code lives
|
|
4209
|
+
* // there, NOT on the error object itself.
|
|
4210
|
+
* if ((err as BrainerceError).details?.code === 'PRICE_DRIFT') {
|
|
4209
4211
|
* // ask user to confirm new prices, then:
|
|
4210
4212
|
* await client.refreshCartSnapshots(cartId);
|
|
4211
4213
|
* await client.createCheckout(cartId);
|
|
@@ -6043,6 +6045,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
6043
6045
|
* Get applicable custom field definitions for a checkout.
|
|
6044
6046
|
* Returns fields filtered by visibility conditions (delivery type, products in cart).
|
|
6045
6047
|
* Use these to render dynamic input fields in the checkout flow.
|
|
6048
|
+
*
|
|
6049
|
+
* **Vibe-coded or storefront mode only.** There is no checkout custom-field
|
|
6050
|
+
* route on the API-key `/v1` surface; in admin mode this throws.
|
|
6046
6051
|
*/
|
|
6047
6052
|
async getCheckoutCustomFields(checkoutId) {
|
|
6048
6053
|
if (this.isVibeCodedMode()) {
|
|
@@ -6057,15 +6062,18 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
6057
6062
|
`/checkout/${encodePathSegment(checkoutId)}/custom-fields`
|
|
6058
6063
|
);
|
|
6059
6064
|
}
|
|
6060
|
-
|
|
6061
|
-
"
|
|
6062
|
-
|
|
6065
|
+
throw new BrainerceError(
|
|
6066
|
+
"getCheckoutCustomFields is only available in vibe-coded or storefront mode",
|
|
6067
|
+
400
|
|
6063
6068
|
);
|
|
6064
6069
|
}
|
|
6065
6070
|
/**
|
|
6066
6071
|
* Set checkout custom field values and recalculate surcharges.
|
|
6067
6072
|
* The checkout total is automatically updated to include surcharges.
|
|
6068
6073
|
*
|
|
6074
|
+
* **Vibe-coded or storefront mode only.** There is no checkout custom-field
|
|
6075
|
+
* route on the API-key `/v1` surface; in admin mode this throws.
|
|
6076
|
+
*
|
|
6069
6077
|
* @example
|
|
6070
6078
|
* ```typescript
|
|
6071
6079
|
* const checkout = await client.setCheckoutCustomFields(checkoutId, {
|
|
@@ -6093,10 +6101,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
6093
6101
|
data
|
|
6094
6102
|
);
|
|
6095
6103
|
}
|
|
6096
|
-
|
|
6097
|
-
"
|
|
6098
|
-
|
|
6099
|
-
data
|
|
6104
|
+
throw new BrainerceError(
|
|
6105
|
+
"setCheckoutCustomFields is only available in vibe-coded or storefront mode",
|
|
6106
|
+
400
|
|
6100
6107
|
);
|
|
6101
6108
|
}
|
|
6102
6109
|
/**
|
|
@@ -8362,8 +8369,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
8362
8369
|
// /api/stores/:storeId/products/:productId/modifier-groups[/:attachmentId]
|
|
8363
8370
|
//
|
|
8364
8371
|
// Server-side validation failures arrive as a structured 400 envelope:
|
|
8365
|
-
// { code: 'MODIFIER_VALIDATION_FAILED', errors:
|
|
8366
|
-
//
|
|
8372
|
+
// { code: 'MODIFIER_VALIDATION_FAILED', message, details: { errors: [...] } }
|
|
8373
|
+
// BrainerceError.details holds the WHOLE body, so the issue list is
|
|
8374
|
+
// `err.details.details.errors` — see ModifierValidationFailedError.
|
|
8367
8375
|
/**
|
|
8368
8376
|
* List modifier groups in a store, paginated.
|
|
8369
8377
|
* Requires Admin mode (apiKey).
|
|
@@ -9415,27 +9423,36 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9415
9423
|
throw new Error("uploadCustomizationFile requires storefront or vibe-coded mode");
|
|
9416
9424
|
}
|
|
9417
9425
|
// -------------------- Team Management (Admin) - DEPRECATED --------------------
|
|
9418
|
-
//
|
|
9426
|
+
// Account-level team methods. These are the ONLY team endpoints reachable with
|
|
9427
|
+
// a `brainerce_*` API key. The store-level equivalents (`getStoreTeam`,
|
|
9428
|
+
// `inviteStoreMember`, `updateStoreMember`, ...) sit behind
|
|
9429
|
+
// `DashboardOnlyGuard`, which rejects api_key principals by design — so they
|
|
9430
|
+
// return 403 from the SDK, not 404, and "fixing" their path would not help.
|
|
9431
|
+
// Do not migrate SDK code onto them.
|
|
9419
9432
|
/**
|
|
9420
|
-
* @deprecated
|
|
9433
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `getStoreTeam`
|
|
9434
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9421
9435
|
*/
|
|
9422
9436
|
async getTeamMembers() {
|
|
9423
9437
|
return this.adminRequest("GET", "/api/v1/team/members");
|
|
9424
9438
|
}
|
|
9425
9439
|
/**
|
|
9426
|
-
* @deprecated
|
|
9440
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `getStoreTeam`
|
|
9441
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9427
9442
|
*/
|
|
9428
9443
|
async getTeamInvitations() {
|
|
9429
9444
|
return this.adminRequest("GET", "/api/v1/team/invitations");
|
|
9430
9445
|
}
|
|
9431
9446
|
/**
|
|
9432
|
-
* @deprecated
|
|
9447
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `inviteStoreMember`
|
|
9448
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9433
9449
|
*/
|
|
9434
9450
|
async inviteTeamMember(data) {
|
|
9435
9451
|
return this.adminRequest("POST", "/api/v1/team/invitations", data);
|
|
9436
9452
|
}
|
|
9437
9453
|
/**
|
|
9438
|
-
* @deprecated
|
|
9454
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `resendStoreInvitation`
|
|
9455
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9439
9456
|
*/
|
|
9440
9457
|
async resendTeamInvitation(invitationId) {
|
|
9441
9458
|
return this.adminRequest(
|
|
@@ -9444,7 +9461,8 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9444
9461
|
);
|
|
9445
9462
|
}
|
|
9446
9463
|
/**
|
|
9447
|
-
* @deprecated
|
|
9464
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `revokeStoreInvitation`
|
|
9465
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9448
9466
|
*/
|
|
9449
9467
|
async revokeTeamInvitation(invitationId) {
|
|
9450
9468
|
await this.adminRequest(
|
|
@@ -9453,7 +9471,8 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9453
9471
|
);
|
|
9454
9472
|
}
|
|
9455
9473
|
/**
|
|
9456
|
-
* @deprecated
|
|
9474
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `updateStoreMember`
|
|
9475
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9457
9476
|
*/
|
|
9458
9477
|
async updateTeamMemberRole(memberId, data) {
|
|
9459
9478
|
return this.adminRequest(
|
|
@@ -9463,7 +9482,8 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9463
9482
|
);
|
|
9464
9483
|
}
|
|
9465
9484
|
/**
|
|
9466
|
-
* @deprecated
|
|
9485
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `removeStoreMember`
|
|
9486
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9467
9487
|
*/
|
|
9468
9488
|
async removeTeamMember(memberId) {
|
|
9469
9489
|
await this.adminRequest("DELETE", `/api/v1/team/members/${encodePathSegment(memberId)}`);
|
package/dist/index.mjs
CHANGED
|
@@ -4117,7 +4117,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
4117
4117
|
* try {
|
|
4118
4118
|
* await client.createCheckout(cartId);
|
|
4119
4119
|
* } catch (err) {
|
|
4120
|
-
*
|
|
4120
|
+
* // BrainerceError.details is the whole response body — the code lives
|
|
4121
|
+
* // there, NOT on the error object itself.
|
|
4122
|
+
* if ((err as BrainerceError).details?.code === 'PRICE_DRIFT') {
|
|
4121
4123
|
* // ask user to confirm new prices, then:
|
|
4122
4124
|
* await client.refreshCartSnapshots(cartId);
|
|
4123
4125
|
* await client.createCheckout(cartId);
|
|
@@ -5955,6 +5957,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
5955
5957
|
* Get applicable custom field definitions for a checkout.
|
|
5956
5958
|
* Returns fields filtered by visibility conditions (delivery type, products in cart).
|
|
5957
5959
|
* Use these to render dynamic input fields in the checkout flow.
|
|
5960
|
+
*
|
|
5961
|
+
* **Vibe-coded or storefront mode only.** There is no checkout custom-field
|
|
5962
|
+
* route on the API-key `/v1` surface; in admin mode this throws.
|
|
5958
5963
|
*/
|
|
5959
5964
|
async getCheckoutCustomFields(checkoutId) {
|
|
5960
5965
|
if (this.isVibeCodedMode()) {
|
|
@@ -5969,15 +5974,18 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
5969
5974
|
`/checkout/${encodePathSegment(checkoutId)}/custom-fields`
|
|
5970
5975
|
);
|
|
5971
5976
|
}
|
|
5972
|
-
|
|
5973
|
-
"
|
|
5974
|
-
|
|
5977
|
+
throw new BrainerceError(
|
|
5978
|
+
"getCheckoutCustomFields is only available in vibe-coded or storefront mode",
|
|
5979
|
+
400
|
|
5975
5980
|
);
|
|
5976
5981
|
}
|
|
5977
5982
|
/**
|
|
5978
5983
|
* Set checkout custom field values and recalculate surcharges.
|
|
5979
5984
|
* The checkout total is automatically updated to include surcharges.
|
|
5980
5985
|
*
|
|
5986
|
+
* **Vibe-coded or storefront mode only.** There is no checkout custom-field
|
|
5987
|
+
* route on the API-key `/v1` surface; in admin mode this throws.
|
|
5988
|
+
*
|
|
5981
5989
|
* @example
|
|
5982
5990
|
* ```typescript
|
|
5983
5991
|
* const checkout = await client.setCheckoutCustomFields(checkoutId, {
|
|
@@ -6005,10 +6013,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
6005
6013
|
data
|
|
6006
6014
|
);
|
|
6007
6015
|
}
|
|
6008
|
-
|
|
6009
|
-
"
|
|
6010
|
-
|
|
6011
|
-
data
|
|
6016
|
+
throw new BrainerceError(
|
|
6017
|
+
"setCheckoutCustomFields is only available in vibe-coded or storefront mode",
|
|
6018
|
+
400
|
|
6012
6019
|
);
|
|
6013
6020
|
}
|
|
6014
6021
|
/**
|
|
@@ -8274,8 +8281,9 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
8274
8281
|
// /api/stores/:storeId/products/:productId/modifier-groups[/:attachmentId]
|
|
8275
8282
|
//
|
|
8276
8283
|
// Server-side validation failures arrive as a structured 400 envelope:
|
|
8277
|
-
// { code: 'MODIFIER_VALIDATION_FAILED', errors:
|
|
8278
|
-
//
|
|
8284
|
+
// { code: 'MODIFIER_VALIDATION_FAILED', message, details: { errors: [...] } }
|
|
8285
|
+
// BrainerceError.details holds the WHOLE body, so the issue list is
|
|
8286
|
+
// `err.details.details.errors` — see ModifierValidationFailedError.
|
|
8279
8287
|
/**
|
|
8280
8288
|
* List modifier groups in a store, paginated.
|
|
8281
8289
|
* Requires Admin mode (apiKey).
|
|
@@ -9327,27 +9335,36 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9327
9335
|
throw new Error("uploadCustomizationFile requires storefront or vibe-coded mode");
|
|
9328
9336
|
}
|
|
9329
9337
|
// -------------------- Team Management (Admin) - DEPRECATED --------------------
|
|
9330
|
-
//
|
|
9338
|
+
// Account-level team methods. These are the ONLY team endpoints reachable with
|
|
9339
|
+
// a `brainerce_*` API key. The store-level equivalents (`getStoreTeam`,
|
|
9340
|
+
// `inviteStoreMember`, `updateStoreMember`, ...) sit behind
|
|
9341
|
+
// `DashboardOnlyGuard`, which rejects api_key principals by design — so they
|
|
9342
|
+
// return 403 from the SDK, not 404, and "fixing" their path would not help.
|
|
9343
|
+
// Do not migrate SDK code onto them.
|
|
9331
9344
|
/**
|
|
9332
|
-
* @deprecated
|
|
9345
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `getStoreTeam`
|
|
9346
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9333
9347
|
*/
|
|
9334
9348
|
async getTeamMembers() {
|
|
9335
9349
|
return this.adminRequest("GET", "/api/v1/team/members");
|
|
9336
9350
|
}
|
|
9337
9351
|
/**
|
|
9338
|
-
* @deprecated
|
|
9352
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `getStoreTeam`
|
|
9353
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9339
9354
|
*/
|
|
9340
9355
|
async getTeamInvitations() {
|
|
9341
9356
|
return this.adminRequest("GET", "/api/v1/team/invitations");
|
|
9342
9357
|
}
|
|
9343
9358
|
/**
|
|
9344
|
-
* @deprecated
|
|
9359
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `inviteStoreMember`
|
|
9360
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9345
9361
|
*/
|
|
9346
9362
|
async inviteTeamMember(data) {
|
|
9347
9363
|
return this.adminRequest("POST", "/api/v1/team/invitations", data);
|
|
9348
9364
|
}
|
|
9349
9365
|
/**
|
|
9350
|
-
* @deprecated
|
|
9366
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `resendStoreInvitation`
|
|
9367
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9351
9368
|
*/
|
|
9352
9369
|
async resendTeamInvitation(invitationId) {
|
|
9353
9370
|
return this.adminRequest(
|
|
@@ -9356,7 +9373,8 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9356
9373
|
);
|
|
9357
9374
|
}
|
|
9358
9375
|
/**
|
|
9359
|
-
* @deprecated
|
|
9376
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `revokeStoreInvitation`
|
|
9377
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9360
9378
|
*/
|
|
9361
9379
|
async revokeTeamInvitation(invitationId) {
|
|
9362
9380
|
await this.adminRequest(
|
|
@@ -9365,7 +9383,8 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9365
9383
|
);
|
|
9366
9384
|
}
|
|
9367
9385
|
/**
|
|
9368
|
-
* @deprecated
|
|
9386
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `updateStoreMember`
|
|
9387
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9369
9388
|
*/
|
|
9370
9389
|
async updateTeamMemberRole(memberId, data) {
|
|
9371
9390
|
return this.adminRequest(
|
|
@@ -9375,7 +9394,8 @@ var _BrainerceClient = class _BrainerceClient {
|
|
|
9375
9394
|
);
|
|
9376
9395
|
}
|
|
9377
9396
|
/**
|
|
9378
|
-
* @deprecated
|
|
9397
|
+
* @deprecated Retiring, but there is no API-key replacement yet: `removeStoreMember`
|
|
9398
|
+
* is dashboard-only (403 for api_key). Keep using this until one ships.
|
|
9379
9399
|
*/
|
|
9380
9400
|
async removeTeamMember(memberId) {
|
|
9381
9401
|
await this.adminRequest("DELETE", `/api/v1/team/members/${encodePathSegment(memberId)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.59.0",
|
|
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",
|