brainerce 1.20.2 → 1.22.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 +20 -1
- package/dist/index.d.mts +122 -7
- package/dist/index.d.ts +122 -7
- package/dist/index.js +64 -2
- package/dist/index.mjs +64 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4176,10 +4176,12 @@ try {
|
|
|
4176
4176
|
|
|
4177
4177
|
---
|
|
4178
4178
|
|
|
4179
|
-
## Contact Inquiries
|
|
4179
|
+
## Contact Inquiries & Forms
|
|
4180
4180
|
|
|
4181
4181
|
Submit contact-form messages from your storefront. Inquiries show up for the merchant at `Customers → Inquiries` in the dashboard; the merchant's reply is emailed back to the customer.
|
|
4182
4182
|
|
|
4183
|
+
**Simple (legacy — always supported):**
|
|
4184
|
+
|
|
4183
4185
|
```typescript
|
|
4184
4186
|
await brainerce.createInquiry({
|
|
4185
4187
|
name: 'Jane Doe',
|
|
@@ -4191,6 +4193,23 @@ await brainerce.createInquiry({
|
|
|
4191
4193
|
// → { id, status: 'NEW', createdAt }
|
|
4192
4194
|
```
|
|
4193
4195
|
|
|
4196
|
+
**Flexible forms (SDK ≥ 1.21):** merchants can configure multiple forms with custom fields and per-locale translations from the dashboard. Fetch the schema at render time; submit a keyed payload:
|
|
4197
|
+
|
|
4198
|
+
```typescript
|
|
4199
|
+
const form = await brainerce.contactForms.get('main', 'he');
|
|
4200
|
+
// form.fields is the merchant-configured field list, localized.
|
|
4201
|
+
|
|
4202
|
+
await brainerce.createInquiry({
|
|
4203
|
+
formKey: 'main',
|
|
4204
|
+
fields: { email: 'jane@example.com', message: 'Hi!' },
|
|
4205
|
+
locale: 'he',
|
|
4206
|
+
});
|
|
4207
|
+
|
|
4208
|
+
// List all configured forms when a site has more than one:
|
|
4209
|
+
const forms = await brainerce.contactForms.list();
|
|
4210
|
+
// → [{ key, name, isDefault }, ...]
|
|
4211
|
+
```
|
|
4212
|
+
|
|
4194
4213
|
**Rate limit:** 3 submissions per 60 seconds per IP. Include a hidden honeypot field (and do not submit it) — bots that auto-fill every input will be rejected.
|
|
4195
4214
|
|
|
4196
4215
|
---
|
package/dist/index.d.mts
CHANGED
|
@@ -3851,12 +3851,50 @@ type CheckoutFieldPricing = {
|
|
|
3851
3851
|
interface SetCheckoutCustomFieldsDto {
|
|
3852
3852
|
fields: Record<string, unknown>;
|
|
3853
3853
|
}
|
|
3854
|
+
/**
|
|
3855
|
+
* Submit a contact inquiry to the store.
|
|
3856
|
+
*
|
|
3857
|
+
* **Legacy shape (kept working forever — any existing storefront keeps submitting):**
|
|
3858
|
+
* ```ts
|
|
3859
|
+
* await brainerce.createInquiry({
|
|
3860
|
+
* name: 'Jane',
|
|
3861
|
+
* email: 'jane@example.com',
|
|
3862
|
+
* subject: 'Hi',
|
|
3863
|
+
* message: 'Shipping to Canada?',
|
|
3864
|
+
* });
|
|
3865
|
+
* ```
|
|
3866
|
+
*
|
|
3867
|
+
* **Phase 2 (multi-form, custom fields):**
|
|
3868
|
+
* ```ts
|
|
3869
|
+
* await brainerce.createInquiry({
|
|
3870
|
+
* formKey: 'newsletter',
|
|
3871
|
+
* fields: {
|
|
3872
|
+
* email: 'jane@example.com',
|
|
3873
|
+
* source: 'homepage-hero',
|
|
3874
|
+
* },
|
|
3875
|
+
* locale: 'he',
|
|
3876
|
+
* sourceMetadata: { page: '/products/42' },
|
|
3877
|
+
* });
|
|
3878
|
+
* ```
|
|
3879
|
+
*
|
|
3880
|
+
* The two shapes may be mixed. If both a top-level `email` and `fields.email`
|
|
3881
|
+
* are present, `fields.email` wins. Unknown keys inside `fields` are stripped
|
|
3882
|
+
* server-side; every value is validated against the form's field schema.
|
|
3883
|
+
*/
|
|
3854
3884
|
interface CreateInquiryInput {
|
|
3855
|
-
name
|
|
3856
|
-
email
|
|
3857
|
-
subject
|
|
3858
|
-
message
|
|
3885
|
+
name?: string;
|
|
3886
|
+
email?: string;
|
|
3887
|
+
subject?: string;
|
|
3888
|
+
message?: string;
|
|
3859
3889
|
phone?: string;
|
|
3890
|
+
/** Target form identifier. Defaults to `"main"` when omitted. */
|
|
3891
|
+
formKey?: string;
|
|
3892
|
+
/** Arbitrary form payload keyed by ContactFormField.key. */
|
|
3893
|
+
fields?: Record<string, unknown>;
|
|
3894
|
+
/** Storefront locale (e.g. `"he"`, `"en"`). */
|
|
3895
|
+
locale?: string;
|
|
3896
|
+
/** Provenance metadata (referrer, UTM, origin page, etc.). */
|
|
3897
|
+
sourceMetadata?: Record<string, unknown>;
|
|
3860
3898
|
customerId?: string;
|
|
3861
3899
|
metadata?: Record<string, unknown>;
|
|
3862
3900
|
}
|
|
@@ -3865,6 +3903,43 @@ interface CreateInquiryResponse {
|
|
|
3865
3903
|
status: 'NEW';
|
|
3866
3904
|
createdAt: string;
|
|
3867
3905
|
}
|
|
3906
|
+
type ContactFormFieldType = 'TEXT' | 'TEXTAREA' | 'EMAIL' | 'PHONE' | 'NUMBER' | 'SELECT' | 'MULTI_SELECT' | 'CHECKBOX' | 'URL' | 'DATE';
|
|
3907
|
+
interface ContactFormFieldValidation {
|
|
3908
|
+
minLength?: number;
|
|
3909
|
+
maxLength?: number;
|
|
3910
|
+
min?: number;
|
|
3911
|
+
max?: number;
|
|
3912
|
+
pattern?: string;
|
|
3913
|
+
patternMessage?: string;
|
|
3914
|
+
}
|
|
3915
|
+
interface ContactFormPublicField {
|
|
3916
|
+
key: string;
|
|
3917
|
+
type: ContactFormFieldType;
|
|
3918
|
+
label: string;
|
|
3919
|
+
placeholder?: string;
|
|
3920
|
+
helpText?: string;
|
|
3921
|
+
isRequired: boolean;
|
|
3922
|
+
enumValues?: Array<{
|
|
3923
|
+
value: string;
|
|
3924
|
+
label: string;
|
|
3925
|
+
}>;
|
|
3926
|
+
validation?: ContactFormFieldValidation;
|
|
3927
|
+
defaultValue?: string;
|
|
3928
|
+
}
|
|
3929
|
+
interface ContactFormPublic {
|
|
3930
|
+
id: string;
|
|
3931
|
+
key: string;
|
|
3932
|
+
name: string;
|
|
3933
|
+
description?: string;
|
|
3934
|
+
submitButton: string;
|
|
3935
|
+
successMessage: string;
|
|
3936
|
+
fields: ContactFormPublicField[];
|
|
3937
|
+
}
|
|
3938
|
+
interface ContactFormSummary {
|
|
3939
|
+
key: string;
|
|
3940
|
+
name: string;
|
|
3941
|
+
isDefault: boolean;
|
|
3942
|
+
}
|
|
3868
3943
|
interface BrainerceApiError {
|
|
3869
3944
|
statusCode: number;
|
|
3870
3945
|
message: string;
|
|
@@ -4978,6 +5053,36 @@ declare class BrainerceClient {
|
|
|
4978
5053
|
page?: number;
|
|
4979
5054
|
limit?: number;
|
|
4980
5055
|
}): Promise<PaginatedResponse<Order>>;
|
|
5056
|
+
/**
|
|
5057
|
+
* List active contact forms configured for the store.
|
|
5058
|
+
*
|
|
5059
|
+
* Storefront (public) mode only. Useful when your site has multiple
|
|
5060
|
+
* forms (e.g. "main", "newsletter", "whatsapp_prechat") and you need
|
|
5061
|
+
* to pick the right one at render time.
|
|
5062
|
+
*
|
|
5063
|
+
* @example
|
|
5064
|
+
* ```typescript
|
|
5065
|
+
* const forms = await brainerce.contactForms.list();
|
|
5066
|
+
* // → [{ key: 'main', name: 'Main Contact', isDefault: true }, ...]
|
|
5067
|
+
* ```
|
|
5068
|
+
*/
|
|
5069
|
+
contactForms: {
|
|
5070
|
+
list: () => Promise<ContactFormSummary[]>;
|
|
5071
|
+
/**
|
|
5072
|
+
* Fetch the full schema for a single contact form, including all
|
|
5073
|
+
* visible fields + their localized labels/placeholders/help text.
|
|
5074
|
+
*
|
|
5075
|
+
* `locale` is the storefront locale at render time (e.g. `"he"`).
|
|
5076
|
+
* Falls back to the store's default language when omitted.
|
|
5077
|
+
*
|
|
5078
|
+
* @example
|
|
5079
|
+
* ```typescript
|
|
5080
|
+
* const form = await brainerce.contactForms.get('main', 'he');
|
|
5081
|
+
* // Render form.fields; submit via brainerce.createInquiry({ formKey: 'main', fields })
|
|
5082
|
+
* ```
|
|
5083
|
+
*/
|
|
5084
|
+
get: (formKey?: string, locale?: string) => Promise<ContactFormPublic>;
|
|
5085
|
+
};
|
|
4981
5086
|
/**
|
|
4982
5087
|
* Submit a contact inquiry from a storefront contact form.
|
|
4983
5088
|
*
|
|
@@ -4985,7 +5090,7 @@ declare class BrainerceClient {
|
|
|
4985
5090
|
* per IP on the server. Include an empty `honeypot` field on your form
|
|
4986
5091
|
* and do NOT send it — bots that auto-fill every input will be rejected.
|
|
4987
5092
|
*
|
|
4988
|
-
*
|
|
5093
|
+
* **Legacy shape (kept working forever):**
|
|
4989
5094
|
* ```typescript
|
|
4990
5095
|
* await brainerce.createInquiry({
|
|
4991
5096
|
* name: 'Jane Doe',
|
|
@@ -4995,6 +5100,16 @@ declare class BrainerceClient {
|
|
|
4995
5100
|
* phone: '+1-555-0100',
|
|
4996
5101
|
* });
|
|
4997
5102
|
* ```
|
|
5103
|
+
*
|
|
5104
|
+
* **Phase 2 (multi-form / custom fields):**
|
|
5105
|
+
* ```typescript
|
|
5106
|
+
* const form = await brainerce.contactForms.get('newsletter');
|
|
5107
|
+
* await brainerce.createInquiry({
|
|
5108
|
+
* formKey: 'newsletter',
|
|
5109
|
+
* fields: { email: 'jane@example.com', source: 'homepage' },
|
|
5110
|
+
* locale: 'he',
|
|
5111
|
+
* });
|
|
5112
|
+
* ```
|
|
4998
5113
|
*/
|
|
4999
5114
|
createInquiry(input: CreateInquiryInput): Promise<CreateInquiryResponse>;
|
|
5000
5115
|
/**
|
|
@@ -7142,7 +7257,7 @@ declare class BrainerceError extends Error {
|
|
|
7142
7257
|
constructor(message: string, statusCode: number, details?: unknown);
|
|
7143
7258
|
}
|
|
7144
7259
|
|
|
7145
|
-
declare const SDK_VERSION = "1.
|
|
7260
|
+
declare const SDK_VERSION = "1.21.0";
|
|
7146
7261
|
|
|
7147
7262
|
/**
|
|
7148
7263
|
* Verify a webhook signature from Brainerce
|
|
@@ -7216,4 +7331,4 @@ declare function enableDevGuards(options?: {
|
|
|
7216
7331
|
force?: boolean;
|
|
7217
7332
|
}): void;
|
|
7218
7333
|
|
|
7219
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, 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 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 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 CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, 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 FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, 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 PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, 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 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 UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, 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 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, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
7334
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, 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 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 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 CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, 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 FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, 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 PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, 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 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 UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, 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 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, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -3851,12 +3851,50 @@ type CheckoutFieldPricing = {
|
|
|
3851
3851
|
interface SetCheckoutCustomFieldsDto {
|
|
3852
3852
|
fields: Record<string, unknown>;
|
|
3853
3853
|
}
|
|
3854
|
+
/**
|
|
3855
|
+
* Submit a contact inquiry to the store.
|
|
3856
|
+
*
|
|
3857
|
+
* **Legacy shape (kept working forever — any existing storefront keeps submitting):**
|
|
3858
|
+
* ```ts
|
|
3859
|
+
* await brainerce.createInquiry({
|
|
3860
|
+
* name: 'Jane',
|
|
3861
|
+
* email: 'jane@example.com',
|
|
3862
|
+
* subject: 'Hi',
|
|
3863
|
+
* message: 'Shipping to Canada?',
|
|
3864
|
+
* });
|
|
3865
|
+
* ```
|
|
3866
|
+
*
|
|
3867
|
+
* **Phase 2 (multi-form, custom fields):**
|
|
3868
|
+
* ```ts
|
|
3869
|
+
* await brainerce.createInquiry({
|
|
3870
|
+
* formKey: 'newsletter',
|
|
3871
|
+
* fields: {
|
|
3872
|
+
* email: 'jane@example.com',
|
|
3873
|
+
* source: 'homepage-hero',
|
|
3874
|
+
* },
|
|
3875
|
+
* locale: 'he',
|
|
3876
|
+
* sourceMetadata: { page: '/products/42' },
|
|
3877
|
+
* });
|
|
3878
|
+
* ```
|
|
3879
|
+
*
|
|
3880
|
+
* The two shapes may be mixed. If both a top-level `email` and `fields.email`
|
|
3881
|
+
* are present, `fields.email` wins. Unknown keys inside `fields` are stripped
|
|
3882
|
+
* server-side; every value is validated against the form's field schema.
|
|
3883
|
+
*/
|
|
3854
3884
|
interface CreateInquiryInput {
|
|
3855
|
-
name
|
|
3856
|
-
email
|
|
3857
|
-
subject
|
|
3858
|
-
message
|
|
3885
|
+
name?: string;
|
|
3886
|
+
email?: string;
|
|
3887
|
+
subject?: string;
|
|
3888
|
+
message?: string;
|
|
3859
3889
|
phone?: string;
|
|
3890
|
+
/** Target form identifier. Defaults to `"main"` when omitted. */
|
|
3891
|
+
formKey?: string;
|
|
3892
|
+
/** Arbitrary form payload keyed by ContactFormField.key. */
|
|
3893
|
+
fields?: Record<string, unknown>;
|
|
3894
|
+
/** Storefront locale (e.g. `"he"`, `"en"`). */
|
|
3895
|
+
locale?: string;
|
|
3896
|
+
/** Provenance metadata (referrer, UTM, origin page, etc.). */
|
|
3897
|
+
sourceMetadata?: Record<string, unknown>;
|
|
3860
3898
|
customerId?: string;
|
|
3861
3899
|
metadata?: Record<string, unknown>;
|
|
3862
3900
|
}
|
|
@@ -3865,6 +3903,43 @@ interface CreateInquiryResponse {
|
|
|
3865
3903
|
status: 'NEW';
|
|
3866
3904
|
createdAt: string;
|
|
3867
3905
|
}
|
|
3906
|
+
type ContactFormFieldType = 'TEXT' | 'TEXTAREA' | 'EMAIL' | 'PHONE' | 'NUMBER' | 'SELECT' | 'MULTI_SELECT' | 'CHECKBOX' | 'URL' | 'DATE';
|
|
3907
|
+
interface ContactFormFieldValidation {
|
|
3908
|
+
minLength?: number;
|
|
3909
|
+
maxLength?: number;
|
|
3910
|
+
min?: number;
|
|
3911
|
+
max?: number;
|
|
3912
|
+
pattern?: string;
|
|
3913
|
+
patternMessage?: string;
|
|
3914
|
+
}
|
|
3915
|
+
interface ContactFormPublicField {
|
|
3916
|
+
key: string;
|
|
3917
|
+
type: ContactFormFieldType;
|
|
3918
|
+
label: string;
|
|
3919
|
+
placeholder?: string;
|
|
3920
|
+
helpText?: string;
|
|
3921
|
+
isRequired: boolean;
|
|
3922
|
+
enumValues?: Array<{
|
|
3923
|
+
value: string;
|
|
3924
|
+
label: string;
|
|
3925
|
+
}>;
|
|
3926
|
+
validation?: ContactFormFieldValidation;
|
|
3927
|
+
defaultValue?: string;
|
|
3928
|
+
}
|
|
3929
|
+
interface ContactFormPublic {
|
|
3930
|
+
id: string;
|
|
3931
|
+
key: string;
|
|
3932
|
+
name: string;
|
|
3933
|
+
description?: string;
|
|
3934
|
+
submitButton: string;
|
|
3935
|
+
successMessage: string;
|
|
3936
|
+
fields: ContactFormPublicField[];
|
|
3937
|
+
}
|
|
3938
|
+
interface ContactFormSummary {
|
|
3939
|
+
key: string;
|
|
3940
|
+
name: string;
|
|
3941
|
+
isDefault: boolean;
|
|
3942
|
+
}
|
|
3868
3943
|
interface BrainerceApiError {
|
|
3869
3944
|
statusCode: number;
|
|
3870
3945
|
message: string;
|
|
@@ -4978,6 +5053,36 @@ declare class BrainerceClient {
|
|
|
4978
5053
|
page?: number;
|
|
4979
5054
|
limit?: number;
|
|
4980
5055
|
}): Promise<PaginatedResponse<Order>>;
|
|
5056
|
+
/**
|
|
5057
|
+
* List active contact forms configured for the store.
|
|
5058
|
+
*
|
|
5059
|
+
* Storefront (public) mode only. Useful when your site has multiple
|
|
5060
|
+
* forms (e.g. "main", "newsletter", "whatsapp_prechat") and you need
|
|
5061
|
+
* to pick the right one at render time.
|
|
5062
|
+
*
|
|
5063
|
+
* @example
|
|
5064
|
+
* ```typescript
|
|
5065
|
+
* const forms = await brainerce.contactForms.list();
|
|
5066
|
+
* // → [{ key: 'main', name: 'Main Contact', isDefault: true }, ...]
|
|
5067
|
+
* ```
|
|
5068
|
+
*/
|
|
5069
|
+
contactForms: {
|
|
5070
|
+
list: () => Promise<ContactFormSummary[]>;
|
|
5071
|
+
/**
|
|
5072
|
+
* Fetch the full schema for a single contact form, including all
|
|
5073
|
+
* visible fields + their localized labels/placeholders/help text.
|
|
5074
|
+
*
|
|
5075
|
+
* `locale` is the storefront locale at render time (e.g. `"he"`).
|
|
5076
|
+
* Falls back to the store's default language when omitted.
|
|
5077
|
+
*
|
|
5078
|
+
* @example
|
|
5079
|
+
* ```typescript
|
|
5080
|
+
* const form = await brainerce.contactForms.get('main', 'he');
|
|
5081
|
+
* // Render form.fields; submit via brainerce.createInquiry({ formKey: 'main', fields })
|
|
5082
|
+
* ```
|
|
5083
|
+
*/
|
|
5084
|
+
get: (formKey?: string, locale?: string) => Promise<ContactFormPublic>;
|
|
5085
|
+
};
|
|
4981
5086
|
/**
|
|
4982
5087
|
* Submit a contact inquiry from a storefront contact form.
|
|
4983
5088
|
*
|
|
@@ -4985,7 +5090,7 @@ declare class BrainerceClient {
|
|
|
4985
5090
|
* per IP on the server. Include an empty `honeypot` field on your form
|
|
4986
5091
|
* and do NOT send it — bots that auto-fill every input will be rejected.
|
|
4987
5092
|
*
|
|
4988
|
-
*
|
|
5093
|
+
* **Legacy shape (kept working forever):**
|
|
4989
5094
|
* ```typescript
|
|
4990
5095
|
* await brainerce.createInquiry({
|
|
4991
5096
|
* name: 'Jane Doe',
|
|
@@ -4995,6 +5100,16 @@ declare class BrainerceClient {
|
|
|
4995
5100
|
* phone: '+1-555-0100',
|
|
4996
5101
|
* });
|
|
4997
5102
|
* ```
|
|
5103
|
+
*
|
|
5104
|
+
* **Phase 2 (multi-form / custom fields):**
|
|
5105
|
+
* ```typescript
|
|
5106
|
+
* const form = await brainerce.contactForms.get('newsletter');
|
|
5107
|
+
* await brainerce.createInquiry({
|
|
5108
|
+
* formKey: 'newsletter',
|
|
5109
|
+
* fields: { email: 'jane@example.com', source: 'homepage' },
|
|
5110
|
+
* locale: 'he',
|
|
5111
|
+
* });
|
|
5112
|
+
* ```
|
|
4998
5113
|
*/
|
|
4999
5114
|
createInquiry(input: CreateInquiryInput): Promise<CreateInquiryResponse>;
|
|
5000
5115
|
/**
|
|
@@ -7142,7 +7257,7 @@ declare class BrainerceError extends Error {
|
|
|
7142
7257
|
constructor(message: string, statusCode: number, details?: unknown);
|
|
7143
7258
|
}
|
|
7144
7259
|
|
|
7145
|
-
declare const SDK_VERSION = "1.
|
|
7260
|
+
declare const SDK_VERSION = "1.21.0";
|
|
7146
7261
|
|
|
7147
7262
|
/**
|
|
7148
7263
|
* Verify a webhook signature from Brainerce
|
|
@@ -7216,4 +7331,4 @@ declare function enableDevGuards(options?: {
|
|
|
7216
7331
|
force?: boolean;
|
|
7217
7332
|
}): void;
|
|
7218
7333
|
|
|
7219
|
-
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, 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 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 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 CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, 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 FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, 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 PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, 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 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 UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, 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 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, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
|
7334
|
+
export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, 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 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 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 CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, 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 FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, 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 PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, 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 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 UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, 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 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, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -176,7 +176,7 @@ function isDevGuardsEnabled() {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
// src/version.ts
|
|
179
|
-
var SDK_VERSION = "1.
|
|
179
|
+
var SDK_VERSION = "1.21.0";
|
|
180
180
|
|
|
181
181
|
// src/client.ts
|
|
182
182
|
var DEFAULT_BASE_URL = "https://api.brainerce.com";
|
|
@@ -202,6 +202,58 @@ var BrainerceClient = class {
|
|
|
202
202
|
* This is needed because Stripe redirects lose in-memory state.
|
|
203
203
|
*/
|
|
204
204
|
this.ACTIVE_CHECKOUT_KEY = "brainerce_active_checkout";
|
|
205
|
+
// -------------------- Contact Forms (schema) --------------------
|
|
206
|
+
/**
|
|
207
|
+
* List active contact forms configured for the store.
|
|
208
|
+
*
|
|
209
|
+
* Storefront (public) mode only. Useful when your site has multiple
|
|
210
|
+
* forms (e.g. "main", "newsletter", "whatsapp_prechat") and you need
|
|
211
|
+
* to pick the right one at render time.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* const forms = await brainerce.contactForms.list();
|
|
216
|
+
* // → [{ key: 'main', name: 'Main Contact', isDefault: true }, ...]
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
this.contactForms = {
|
|
220
|
+
list: async () => {
|
|
221
|
+
if (this.isVibeCodedMode()) {
|
|
222
|
+
return this.vibeCodedRequest("GET", "/contact-forms");
|
|
223
|
+
}
|
|
224
|
+
return this.storefrontRequest("GET", "/contact-forms");
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* Fetch the full schema for a single contact form, including all
|
|
228
|
+
* visible fields + their localized labels/placeholders/help text.
|
|
229
|
+
*
|
|
230
|
+
* `locale` is the storefront locale at render time (e.g. `"he"`).
|
|
231
|
+
* Falls back to the store's default language when omitted.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const form = await brainerce.contactForms.get('main', 'he');
|
|
236
|
+
* // Render form.fields; submit via brainerce.createInquiry({ formKey: 'main', fields })
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
get: async (formKey = "main", locale) => {
|
|
240
|
+
const query = locale ? { locale } : void 0;
|
|
241
|
+
if (this.isVibeCodedMode()) {
|
|
242
|
+
return this.vibeCodedRequest(
|
|
243
|
+
"GET",
|
|
244
|
+
`/contact-forms/${encodeURIComponent(formKey)}`,
|
|
245
|
+
void 0,
|
|
246
|
+
query
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return this.storefrontRequest(
|
|
250
|
+
"GET",
|
|
251
|
+
`/contact-forms/${encodeURIComponent(formKey)}`,
|
|
252
|
+
void 0,
|
|
253
|
+
query
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
205
257
|
// -------------------- Local Cart (Client-Side for Guests) --------------------
|
|
206
258
|
// These methods store cart data in localStorage - NO API calls!
|
|
207
259
|
// Use for guest users in vibe-coded sites
|
|
@@ -2070,7 +2122,7 @@ var BrainerceClient = class {
|
|
|
2070
2122
|
* per IP on the server. Include an empty `honeypot` field on your form
|
|
2071
2123
|
* and do NOT send it — bots that auto-fill every input will be rejected.
|
|
2072
2124
|
*
|
|
2073
|
-
*
|
|
2125
|
+
* **Legacy shape (kept working forever):**
|
|
2074
2126
|
* ```typescript
|
|
2075
2127
|
* await brainerce.createInquiry({
|
|
2076
2128
|
* name: 'Jane Doe',
|
|
@@ -2080,6 +2132,16 @@ var BrainerceClient = class {
|
|
|
2080
2132
|
* phone: '+1-555-0100',
|
|
2081
2133
|
* });
|
|
2082
2134
|
* ```
|
|
2135
|
+
*
|
|
2136
|
+
* **Phase 2 (multi-form / custom fields):**
|
|
2137
|
+
* ```typescript
|
|
2138
|
+
* const form = await brainerce.contactForms.get('newsletter');
|
|
2139
|
+
* await brainerce.createInquiry({
|
|
2140
|
+
* formKey: 'newsletter',
|
|
2141
|
+
* fields: { email: 'jane@example.com', source: 'homepage' },
|
|
2142
|
+
* locale: 'he',
|
|
2143
|
+
* });
|
|
2144
|
+
* ```
|
|
2083
2145
|
*/
|
|
2084
2146
|
async createInquiry(input) {
|
|
2085
2147
|
if (this.isVibeCodedMode()) {
|
package/dist/index.mjs
CHANGED
|
@@ -115,7 +115,7 @@ function isDevGuardsEnabled() {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// src/version.ts
|
|
118
|
-
var SDK_VERSION = "1.
|
|
118
|
+
var SDK_VERSION = "1.21.0";
|
|
119
119
|
|
|
120
120
|
// src/client.ts
|
|
121
121
|
var DEFAULT_BASE_URL = "https://api.brainerce.com";
|
|
@@ -141,6 +141,58 @@ var BrainerceClient = class {
|
|
|
141
141
|
* This is needed because Stripe redirects lose in-memory state.
|
|
142
142
|
*/
|
|
143
143
|
this.ACTIVE_CHECKOUT_KEY = "brainerce_active_checkout";
|
|
144
|
+
// -------------------- Contact Forms (schema) --------------------
|
|
145
|
+
/**
|
|
146
|
+
* List active contact forms configured for the store.
|
|
147
|
+
*
|
|
148
|
+
* Storefront (public) mode only. Useful when your site has multiple
|
|
149
|
+
* forms (e.g. "main", "newsletter", "whatsapp_prechat") and you need
|
|
150
|
+
* to pick the right one at render time.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const forms = await brainerce.contactForms.list();
|
|
155
|
+
* // → [{ key: 'main', name: 'Main Contact', isDefault: true }, ...]
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
this.contactForms = {
|
|
159
|
+
list: async () => {
|
|
160
|
+
if (this.isVibeCodedMode()) {
|
|
161
|
+
return this.vibeCodedRequest("GET", "/contact-forms");
|
|
162
|
+
}
|
|
163
|
+
return this.storefrontRequest("GET", "/contact-forms");
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* Fetch the full schema for a single contact form, including all
|
|
167
|
+
* visible fields + their localized labels/placeholders/help text.
|
|
168
|
+
*
|
|
169
|
+
* `locale` is the storefront locale at render time (e.g. `"he"`).
|
|
170
|
+
* Falls back to the store's default language when omitted.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const form = await brainerce.contactForms.get('main', 'he');
|
|
175
|
+
* // Render form.fields; submit via brainerce.createInquiry({ formKey: 'main', fields })
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
get: async (formKey = "main", locale) => {
|
|
179
|
+
const query = locale ? { locale } : void 0;
|
|
180
|
+
if (this.isVibeCodedMode()) {
|
|
181
|
+
return this.vibeCodedRequest(
|
|
182
|
+
"GET",
|
|
183
|
+
`/contact-forms/${encodeURIComponent(formKey)}`,
|
|
184
|
+
void 0,
|
|
185
|
+
query
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return this.storefrontRequest(
|
|
189
|
+
"GET",
|
|
190
|
+
`/contact-forms/${encodeURIComponent(formKey)}`,
|
|
191
|
+
void 0,
|
|
192
|
+
query
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
144
196
|
// -------------------- Local Cart (Client-Side for Guests) --------------------
|
|
145
197
|
// These methods store cart data in localStorage - NO API calls!
|
|
146
198
|
// Use for guest users in vibe-coded sites
|
|
@@ -2009,7 +2061,7 @@ var BrainerceClient = class {
|
|
|
2009
2061
|
* per IP on the server. Include an empty `honeypot` field on your form
|
|
2010
2062
|
* and do NOT send it — bots that auto-fill every input will be rejected.
|
|
2011
2063
|
*
|
|
2012
|
-
*
|
|
2064
|
+
* **Legacy shape (kept working forever):**
|
|
2013
2065
|
* ```typescript
|
|
2014
2066
|
* await brainerce.createInquiry({
|
|
2015
2067
|
* name: 'Jane Doe',
|
|
@@ -2019,6 +2071,16 @@ var BrainerceClient = class {
|
|
|
2019
2071
|
* phone: '+1-555-0100',
|
|
2020
2072
|
* });
|
|
2021
2073
|
* ```
|
|
2074
|
+
*
|
|
2075
|
+
* **Phase 2 (multi-form / custom fields):**
|
|
2076
|
+
* ```typescript
|
|
2077
|
+
* const form = await brainerce.contactForms.get('newsletter');
|
|
2078
|
+
* await brainerce.createInquiry({
|
|
2079
|
+
* formKey: 'newsletter',
|
|
2080
|
+
* fields: { email: 'jane@example.com', source: 'homepage' },
|
|
2081
|
+
* locale: 'he',
|
|
2082
|
+
* });
|
|
2083
|
+
* ```
|
|
2022
2084
|
*/
|
|
2023
2085
|
async createInquiry(input) {
|
|
2024
2086
|
if (this.isVibeCodedMode()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.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",
|