@bacano/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types.d.ts ADDED
@@ -0,0 +1,991 @@
1
+ export interface BacanoClientConfig {
2
+ /** Bacano public API URL (e.g., https://api.bacanoerp.com) */
3
+ apiUrl: string;
4
+ /** Website slug — required tenant context for every storefront request. */
5
+ websiteSlug: string;
6
+ /** Cart session storage strategy (default: 'localStorage') */
7
+ tokenStorage?: "localStorage" | "cookie" | "memory";
8
+ /**
9
+ * Returns the current buyer access token.
10
+ *
11
+ * For Clerk storefronts pass `() => getToken()`. The SDK invokes this
12
+ * provider for every request, so token refresh remains owned by Clerk and
13
+ * passwords never pass through Bacano.
14
+ */
15
+ getAccessToken?: AccessTokenProvider;
16
+ }
17
+ export type AccessTokenProvider = () => string | null | Promise<string | null>;
18
+ export interface WebsitePublicConfig {
19
+ websiteId: string;
20
+ companyId: string;
21
+ slug: string;
22
+ name: string;
23
+ domain: string | null;
24
+ buyerAccountsEnabled: boolean;
25
+ clerkPublishableKey: string | null;
26
+ customerIdentification: WebsiteCustomerIdentificationPolicy;
27
+ }
28
+ export type WebsiteCustomerIdentifierType = "AUTO" | "EMAIL" | "PHONE" | "DOCUMENT";
29
+ export interface WebsiteCustomerDocumentType {
30
+ code: string;
31
+ name: string;
32
+ shortLabel: string;
33
+ isDefault: boolean;
34
+ }
35
+ export interface WebsiteCustomerIdentificationPolicy {
36
+ primaryIdentifier: WebsiteCustomerIdentifierType;
37
+ requireEmail: boolean;
38
+ requirePhone: boolean;
39
+ requireDocument: boolean;
40
+ documentTypes: WebsiteCustomerDocumentType[];
41
+ }
42
+ export interface GetWebsitePublicConfigOptions {
43
+ /** Bacano public API URL (e.g., https://api.bacanoerp.com). */
44
+ apiUrl: string;
45
+ /** Website slug configured in Bacano. */
46
+ websiteSlug: string;
47
+ /**
48
+ * Storefront origin. Required during SSR; browsers send their Origin
49
+ * header automatically and should omit this option.
50
+ */
51
+ origin?: string;
52
+ }
53
+ export interface BacanoClientContext {
54
+ websiteId: string;
55
+ companyId: string;
56
+ chainId: string | null;
57
+ name: string;
58
+ slug: string;
59
+ domain: string | null;
60
+ config: Record<string, unknown> | null;
61
+ }
62
+ export interface Product {
63
+ id: string;
64
+ name: string;
65
+ description: string | null;
66
+ longDescription: Record<string, unknown> | null;
67
+ slug: string | null;
68
+ seoTitle: string | null;
69
+ seoDescription: string | null;
70
+ seoImage: ProductMedia | null;
71
+ color: string | null;
72
+ category: string;
73
+ subcategory: string | null;
74
+ brand: {
75
+ id: string;
76
+ name: string;
77
+ } | null;
78
+ measurementUnit: string | null;
79
+ createdAt: string;
80
+ updatedAt: string;
81
+ variants: ProductVariant[];
82
+ media: ProductMedia[];
83
+ attributes: ProductAttribute[];
84
+ relatedProducts: ProductRelatedProduct[];
85
+ }
86
+ export interface ProductRelatedProduct {
87
+ id: string;
88
+ productId: string;
89
+ slug: string | null;
90
+ name: string;
91
+ sku: string | null;
92
+ displayLabel: string | null;
93
+ sortOrder: number;
94
+ media: ProductMedia[];
95
+ }
96
+ export interface ProductVariant {
97
+ id: string;
98
+ sku: string;
99
+ barcode: string | null;
100
+ order: number;
101
+ weight: number | null;
102
+ depth: number | null;
103
+ height: number | null;
104
+ length: number | null;
105
+ prices: ProductPrice[];
106
+ /** Storefront-ready price interpretation for this website and chain. */
107
+ pricing: ProductVariantPricing;
108
+ attributes: VariantAttribute[];
109
+ }
110
+ export type ProductPriceType = "CLIENT" | "SALE" | "WHOLESALE" | "WHOLESALE_2";
111
+ export interface ProductPrice {
112
+ id: string;
113
+ price: number;
114
+ priceType: ProductPriceType;
115
+ chainId: string | null;
116
+ }
117
+ export interface ProductVariantPricing {
118
+ /** Price Bacano will use for a regular public checkout. */
119
+ currentPrice: number | null;
120
+ /** Regular CLIENT price before a valid offer. */
121
+ regularPrice: number | null;
122
+ /** Valid SALE price, only when it is lower than regularPrice. */
123
+ salePrice: number | null;
124
+ hasDiscount: boolean;
125
+ discountPercentage: number | null;
126
+ /** Optional company-enabled wholesale tiers; informational for now. */
127
+ wholesalePrice: number | null;
128
+ wholesale2Price: number | null;
129
+ }
130
+ export type ProductMediaKind = "image" | "video" | "document" | "file";
131
+ export interface ProductMedia {
132
+ id: string;
133
+ fileId: string;
134
+ order: number;
135
+ /** @deprecated Use originalUrl/cardUrl/detailUrl based on the rendering context. */
136
+ url: string;
137
+ originalUrl: string;
138
+ thumbnailUrl: string;
139
+ cardUrl: string;
140
+ detailUrl: string;
141
+ mediaKind: ProductMediaKind;
142
+ mimeType: string | null;
143
+ fileName: string | null;
144
+ alt: string | null;
145
+ }
146
+ export interface ProductAttribute {
147
+ id: string;
148
+ /** Public label ready for storefront UI, e.g. "Talla". */
149
+ name: string;
150
+ /** Public value label ready for storefront UI, e.g. "6 a 12 meses". */
151
+ value: string;
152
+ attributeValueId?: string | null;
153
+ /** Technical attribute code/name, e.g. "CLOTHING_SIZE". */
154
+ code?: string | null;
155
+ /** Technical attribute value code, e.g. "SIX_TWELVE_MONTHS". */
156
+ valueCode?: string | null;
157
+ metadata?: Record<string, unknown> | null;
158
+ sortOrder?: number | null;
159
+ }
160
+ export interface VariantAttribute {
161
+ id: string;
162
+ /** Public label ready for storefront UI, e.g. "Talla". */
163
+ name: string;
164
+ /** Public value label ready for storefront UI, e.g. "6 a 12 meses". */
165
+ value: string;
166
+ order: number | null;
167
+ attributeValueId?: string | null;
168
+ /** Technical attribute code/name, e.g. "CLOTHING_SIZE". */
169
+ code?: string | null;
170
+ /** Technical attribute value code, e.g. "SIX_TWELVE_MONTHS". */
171
+ valueCode?: string | null;
172
+ metadata?: Record<string, unknown> | null;
173
+ sortOrder?: number | null;
174
+ }
175
+ export interface ProductCategory {
176
+ name: string;
177
+ description: string | null;
178
+ subcategories: ProductSubcategory[];
179
+ }
180
+ export interface ProductSubcategory {
181
+ id: string;
182
+ name: string;
183
+ description: string | null;
184
+ }
185
+ export type CatalogCategoryListItemSourceType = "category" | "subcategory";
186
+ export interface CatalogCategoryListItem {
187
+ id: string;
188
+ sourceType: CatalogCategoryListItemSourceType;
189
+ productCategory: string | null;
190
+ productSubcategoryId: string | null;
191
+ label: string;
192
+ slug: string;
193
+ sortOrder: number;
194
+ category: {
195
+ name: string;
196
+ description: string | null;
197
+ } | null;
198
+ subcategory: {
199
+ id: string;
200
+ name: string;
201
+ description: string | null;
202
+ category: string;
203
+ } | null;
204
+ /**
205
+ * Present for subcategory items. It points to the parent category item in the
206
+ * same public list, so storefronts do not need to infer hierarchy by order.
207
+ */
208
+ parentCategory: string | null;
209
+ parentId: string | null;
210
+ parentSlug: string | null;
211
+ }
212
+ export interface CatalogCategoryListCategory {
213
+ id: string;
214
+ productCategory: string | null;
215
+ label: string;
216
+ slug: string;
217
+ sortOrder: number;
218
+ category: {
219
+ name: string;
220
+ description: string | null;
221
+ } | null;
222
+ subcategories: CatalogCategoryListItem[];
223
+ }
224
+ export interface CatalogCategoryList {
225
+ id: string;
226
+ key: string;
227
+ name: string;
228
+ description: string | null;
229
+ status: "published";
230
+ items: CatalogCategoryListItem[];
231
+ categories: CatalogCategoryListCategory[];
232
+ }
233
+ export interface GetCategoryListOptions {
234
+ key: string;
235
+ /**
236
+ * When true, Bacano returns only categories/subcategories with active,
237
+ * available products in the current website catalog context.
238
+ */
239
+ onlyApplicable?: boolean;
240
+ filters?: CatalogCategoryListFilters;
241
+ }
242
+ export interface CatalogCategoryListFilters {
243
+ tags?: string[];
244
+ search?: string;
245
+ brandId?: string;
246
+ minPrice?: number;
247
+ maxPrice?: number;
248
+ attributes?: Record<string, string[]>;
249
+ }
250
+ export interface CatalogAttributeListValue {
251
+ id: string;
252
+ attributeValueId: string;
253
+ code: string;
254
+ label: string;
255
+ slug: string;
256
+ sortOrder: number;
257
+ metadata: Record<string, unknown> | null;
258
+ }
259
+ export interface CatalogAttributeListItem {
260
+ id: string;
261
+ attributeId: string;
262
+ attributeName: string;
263
+ attributeType: string;
264
+ label: string;
265
+ slug: string;
266
+ sortOrder: number;
267
+ values: CatalogAttributeListValue[];
268
+ }
269
+ export interface CatalogAttributeList {
270
+ id: string;
271
+ key: string;
272
+ name: string;
273
+ description: string | null;
274
+ status: "published";
275
+ items: CatalogAttributeListItem[];
276
+ }
277
+ export interface CatalogAttributeListFilters {
278
+ categoryName?: string;
279
+ subcategoryId?: string;
280
+ tags?: string[];
281
+ search?: string;
282
+ brandId?: string;
283
+ minPrice?: number;
284
+ maxPrice?: number;
285
+ }
286
+ export interface GetAttributeListOptions {
287
+ key: string;
288
+ /**
289
+ * When true, Bacano returns only attributes/values with active, available
290
+ * products in the current website catalog context.
291
+ */
292
+ onlyApplicable?: boolean;
293
+ filters?: CatalogAttributeListFilters;
294
+ }
295
+ export interface Brand {
296
+ id: string;
297
+ name: string;
298
+ }
299
+ export interface ProductAvailability {
300
+ productVariantId: string;
301
+ inStock: boolean;
302
+ label: string;
303
+ }
304
+ export type ProductSortBy = "name_asc" | "name_desc" | "price_asc" | "price_desc" | "newest";
305
+ export interface GetProductsOptions {
306
+ categoryName?: string;
307
+ subcategoryId?: string;
308
+ brandId?: string;
309
+ search?: string;
310
+ limit?: number;
311
+ offset?: number;
312
+ /** Filter by color values (any match) */
313
+ colors?: string[];
314
+ /** Minimum price across any variant's CLIENT/SALE prices */
315
+ minPrice?: number;
316
+ /** Maximum price across any variant's CLIENT/SALE prices */
317
+ maxPrice?: number;
318
+ /** Only products with stock > 0 */
319
+ inStock?: boolean;
320
+ /** Filter by reusable tag keys, e.g. ['bebe-nina'] */
321
+ tags?: string[];
322
+ /** Filter by dynamic attributes, e.g. { Size: ['M', 'L'], Material: ['Cotton'] } */
323
+ attributes?: Record<string, string[]>;
324
+ /** Sort order */
325
+ sortBy?: ProductSortBy;
326
+ }
327
+ export interface AttributeFilter {
328
+ id: string;
329
+ name: string;
330
+ values: Array<{
331
+ value: string;
332
+ count: number;
333
+ attributeValueId?: string | null;
334
+ code?: string | null;
335
+ metadata?: Record<string, unknown> | null;
336
+ sortOrder?: number | null;
337
+ }>;
338
+ }
339
+ export interface ProductFilters {
340
+ categories: Array<{
341
+ name: string;
342
+ count: number;
343
+ }>;
344
+ brands: Array<{
345
+ id: string;
346
+ name: string;
347
+ count: number;
348
+ }>;
349
+ colors: Array<{
350
+ value: string;
351
+ count: number;
352
+ }>;
353
+ priceRange: {
354
+ min: number;
355
+ max: number;
356
+ };
357
+ /** Category-specific dynamic attributes — populated when categoryName is provided */
358
+ attributes: AttributeFilter[];
359
+ }
360
+ export interface GetProductFiltersOptions {
361
+ /** When set, includes category-specific attribute facets */
362
+ categoryName?: string;
363
+ /** When set with categoryName, narrows subcategory-specific facets and counts */
364
+ subcategoryId?: string;
365
+ /**
366
+ * Public catalog attribute list used to resolve attribute filter labels.
367
+ * Defaults to "atributos".
368
+ */
369
+ attributeListKey?: string;
370
+ }
371
+ export interface CatalogPageIncludeOptions {
372
+ products?: boolean;
373
+ categories?: boolean;
374
+ attributes?: boolean;
375
+ filters?: boolean;
376
+ brands?: boolean;
377
+ debug?: boolean;
378
+ }
379
+ export interface GetCatalogPageOptions {
380
+ categoryListKey: string;
381
+ attributeListKey: string;
382
+ categorySlug?: string;
383
+ subcategorySlug?: string;
384
+ tags?: string[];
385
+ search?: string;
386
+ brandId?: string;
387
+ minPrice?: number;
388
+ maxPrice?: number;
389
+ attributesBySlug?: Record<string, string[]>;
390
+ sortBy?: ProductSortBy;
391
+ limit?: number;
392
+ offset?: number;
393
+ include?: CatalogPageIncludeOptions;
394
+ }
395
+ export interface GetProductSeoEntriesOptions {
396
+ /**
397
+ * Number of entries to load. The SDK fetches one extra item internally to
398
+ * calculate hasMore without requiring GraphQL aggregate permissions.
399
+ */
400
+ limit?: number;
401
+ offset?: number;
402
+ }
403
+ export interface ProductSeoEntry {
404
+ id: string;
405
+ name: string;
406
+ slug: string;
407
+ createdAt: string;
408
+ updatedAt: string;
409
+ seoTitle: string | null;
410
+ seoDescription: string | null;
411
+ seoImage: ProductMedia | null;
412
+ primaryImage: ProductMedia | null;
413
+ category: string;
414
+ subcategory: string | null;
415
+ }
416
+ export interface ProductSeoEntriesResult {
417
+ entries: ProductSeoEntry[];
418
+ pagination: {
419
+ limit: number;
420
+ offset: number;
421
+ hasMore: boolean;
422
+ };
423
+ }
424
+ export interface CatalogPagePagination {
425
+ limit: number;
426
+ offset: number;
427
+ total: number;
428
+ hasMore: boolean;
429
+ }
430
+ export interface CatalogPageDebug {
431
+ timings?: Record<string, number>;
432
+ availabilityChecks?: number;
433
+ candidateProducts?: number;
434
+ candidateVariants?: number;
435
+ }
436
+ export interface CatalogPageResult {
437
+ products: Product[];
438
+ categories: CatalogCategoryList | null;
439
+ attributes: CatalogAttributeList | null;
440
+ filters: ProductFilters | null;
441
+ brands: Brand[];
442
+ pagination: CatalogPagePagination;
443
+ appliedFilters: Record<string, unknown>;
444
+ debug: CatalogPageDebug | null;
445
+ }
446
+ export type ProductRecommendationSource = "manual" | "subcategory" | "category" | "attributes" | "fallback";
447
+ export interface ProductRecommendationPricing {
448
+ currentPriceMin: number;
449
+ currentPriceMax: number;
450
+ regularPriceMin: number;
451
+ regularPriceMax: number;
452
+ hasDiscount: boolean;
453
+ }
454
+ export interface ProductRecommendation {
455
+ id: string;
456
+ name: string;
457
+ slug: string;
458
+ category: string;
459
+ subcategory: string | null;
460
+ brand: Brand | null;
461
+ primaryImage: ProductMedia | null;
462
+ pricing: ProductRecommendationPricing;
463
+ source: ProductRecommendationSource;
464
+ }
465
+ export interface GetProductRecommendationsOptions {
466
+ productId: string;
467
+ /** Number of recommendations. Defaults to 16; maximum is 32. */
468
+ limit?: number;
469
+ }
470
+ export interface ProductRecommendationsResult {
471
+ products: ProductRecommendation[];
472
+ strategy: string;
473
+ }
474
+ export interface ContentMedia {
475
+ fileId: string;
476
+ name: string | null;
477
+ mediaKind: ProductMediaKind;
478
+ mimeType: string | null;
479
+ sizeBytes: number | null;
480
+ alt?: string | null;
481
+ originalUrl?: string | null;
482
+ thumbnailUrl?: string | null;
483
+ cardUrl?: string | null;
484
+ detailUrl?: string | null;
485
+ /** @deprecated Use originalUrl/cardUrl/detailUrl based on the rendering context. */
486
+ url?: string | null;
487
+ }
488
+ export type ContentJson = Record<string, unknown>;
489
+ export type ContentResolvedFields = Record<string, unknown>;
490
+ export type ContentLink = {
491
+ type: "link";
492
+ href: string;
493
+ openInNewTab: boolean;
494
+ } | {
495
+ type: "email";
496
+ email: string;
497
+ href: string;
498
+ } | {
499
+ type: "phone";
500
+ phone: string;
501
+ href: string;
502
+ } | {
503
+ type: "whatsapp";
504
+ phone: string;
505
+ message?: string;
506
+ href: string;
507
+ };
508
+ /** `YYYY-MM-DD` for dates or an ISO-8601 UTC string for date-times. */
509
+ export type ContentDateValue = string;
510
+ export interface ContentProductReference {
511
+ referenceId: string;
512
+ type: "product";
513
+ id: string;
514
+ label: string;
515
+ name: string;
516
+ slug: string | null;
517
+ sku: string | null;
518
+ priceRange: {
519
+ min: number;
520
+ max: number;
521
+ };
522
+ media: ProductMedia[];
523
+ }
524
+ export interface ContentEntryReference {
525
+ referenceId: string;
526
+ type: "content_entry";
527
+ id: string;
528
+ key: string;
529
+ label: string;
530
+ categoryKey: string;
531
+ contentTypeKey: string;
532
+ contentTypeName: string;
533
+ status: string;
534
+ }
535
+ export interface ContentTypeSummary {
536
+ id: string;
537
+ key: string;
538
+ name: string;
539
+ kind: "entry" | "component";
540
+ }
541
+ export interface ContentEntry {
542
+ id: string;
543
+ key: string | null;
544
+ categoryKey: string;
545
+ name: string;
546
+ locale: string;
547
+ /** Public Content APIs only return published entries. */
548
+ status: "published";
549
+ tags: string[];
550
+ contentJson: ContentJson;
551
+ /**
552
+ * Public labels resolved by Bacano for fields that store technical values,
553
+ * such as select fields backed by reusable option lists.
554
+ */
555
+ resolvedFields: ContentResolvedFields;
556
+ publishedAt: string | null;
557
+ updatedAt: string;
558
+ contentType: ContentTypeSummary;
559
+ }
560
+ export interface ProductContentBlock {
561
+ id: string;
562
+ productId: string;
563
+ locale: string;
564
+ contentJson: ContentJson;
565
+ resolvedFields: ContentResolvedFields;
566
+ sortOrder: number;
567
+ updatedAt: string;
568
+ contentType: ContentTypeSummary;
569
+ }
570
+ export interface GetContentOptions {
571
+ locale?: string;
572
+ }
573
+ export interface SearchSuggestion {
574
+ type: "product" | "brand" | "category";
575
+ text: string;
576
+ /** Product or brand ID when applicable */
577
+ id?: string;
578
+ }
579
+ export interface GetSearchSuggestionsOptions {
580
+ query: string;
581
+ /** Maximum number of suggestions (default: 8) */
582
+ limit?: number;
583
+ }
584
+ export interface Cart {
585
+ id: string;
586
+ cartToken?: string;
587
+ items: CartItem[];
588
+ totals: {
589
+ subtotal: number;
590
+ tax: number;
591
+ discount: number;
592
+ total: number;
593
+ };
594
+ status: string;
595
+ createdAt: string;
596
+ updatedAt: string;
597
+ }
598
+ export interface CartItem {
599
+ id: string;
600
+ productVariantId: string;
601
+ quantity: number;
602
+ productVariant: {
603
+ sku: string;
604
+ product: {
605
+ id: string;
606
+ name: string;
607
+ };
608
+ prices: ProductPrice[];
609
+ };
610
+ }
611
+ export interface WebsiteGuestContact {
612
+ name?: string;
613
+ firstName?: string;
614
+ lastName?: string;
615
+ email?: string;
616
+ phone?: string;
617
+ cellphone?: string;
618
+ documentType?: string;
619
+ documentNumber?: string;
620
+ address?: Record<string, unknown>;
621
+ }
622
+ export type WebsiteFulfillmentFamily = "PICKUP" | "SHIPPING";
623
+ export interface WebsiteCheckoutItem {
624
+ productVariantId: string;
625
+ quantity: number;
626
+ }
627
+ export interface StartGuestCheckoutInput {
628
+ contact: WebsiteGuestContact;
629
+ items: WebsiteCheckoutItem[];
630
+ fulfillmentFamily?: WebsiteFulfillmentFamily;
631
+ }
632
+ export interface CheckoutSubmission {
633
+ contact: WebsiteGuestContact;
634
+ fulfillmentFamily?: WebsiteFulfillmentFamily;
635
+ address?: WebsiteCheckoutAddress;
636
+ shippingQuoteId?: string;
637
+ paymentMode?: WebsitePaymentMode;
638
+ paymentMethodId?: string;
639
+ /**
640
+ * Request an account activation email after Bacano creates a valid guest order.
641
+ * Delivery does not depend on the order being paid.
642
+ * Ignored when the buyer already has an authenticated Clerk session.
643
+ */
644
+ buyerAccountOptIn?: boolean;
645
+ initialPayment?: {
646
+ amount: number;
647
+ paymentMethodId: string;
648
+ };
649
+ }
650
+ export interface WebsiteCheckoutAddress {
651
+ departmentId?: string;
652
+ departmentName?: string;
653
+ municipalityId?: string;
654
+ municipalityName?: string;
655
+ line1?: string;
656
+ line2?: string;
657
+ notes?: string;
658
+ }
659
+ export interface WebsiteMunicipalityOption {
660
+ municipalityId: string;
661
+ municipalityName: string;
662
+ municipalityCode: string;
663
+ departmentId: string;
664
+ departmentCode: string;
665
+ }
666
+ export interface WebsiteDepartmentOption {
667
+ departmentId: string;
668
+ departmentName: string;
669
+ departmentCode: string;
670
+ municipalities: WebsiteMunicipalityOption[];
671
+ }
672
+ export interface WebsiteLocationOptions {
673
+ countryCode: string | null;
674
+ departments: WebsiteDepartmentOption[];
675
+ }
676
+ export interface WebsitePickupInfo {
677
+ label: string;
678
+ address: string | null;
679
+ schedule: string | null;
680
+ notes: string | null;
681
+ }
682
+ export interface WebsiteDeliveryOption {
683
+ id: "shipping" | "pickup" | string;
684
+ fulfillmentFamily: WebsiteFulfillmentFamily;
685
+ label: string;
686
+ description: string | null;
687
+ isEnabled: boolean;
688
+ pickupInfo: WebsitePickupInfo | null;
689
+ }
690
+ export interface WebsiteShippingQuote {
691
+ quoteId: string;
692
+ shippingServiceId: string;
693
+ label: string;
694
+ serviceName: string;
695
+ baseAmount: number;
696
+ amount: number;
697
+ currency: string;
698
+ collectionMode: string;
699
+ totalPolicy: string;
700
+ estimatedDelivery: string | null;
701
+ freeShippingEligible: boolean;
702
+ freeShippingApplied: boolean;
703
+ freeShippingThreshold: number | null;
704
+ freeShippingRemaining: number | null;
705
+ freeShippingEligibleSubtotal: number | null;
706
+ }
707
+ export interface WebsiteShippingPolicy {
708
+ freeShippingEnabled: boolean;
709
+ freeShippingThreshold: number | null;
710
+ currency: string;
711
+ }
712
+ export interface WebsiteFreeShippingProgress {
713
+ enabled: boolean;
714
+ threshold: number | null;
715
+ remaining: number | null;
716
+ eligibleSubtotal: number | null;
717
+ thresholdReached: boolean;
718
+ currency: string;
719
+ }
720
+ export interface WebsitePaymentMethod {
721
+ id: string;
722
+ code: string;
723
+ label: string;
724
+ paymentMethodType: string;
725
+ gatewayCode: string | null;
726
+ description: string | null;
727
+ isEnabled: boolean;
728
+ sortOrder: number;
729
+ requiresPaymentSession: boolean;
730
+ publicConfig: Record<string, unknown> | null;
731
+ }
732
+ export type WebsitePaymentMode = "pay_now" | "partial" | "pay_later" | "cash_on_delivery";
733
+ export type WebsiteInitialPaymentPolicy = "none" | "optional" | "required";
734
+ export interface WebsitePaymentOptionMethod {
735
+ id: string;
736
+ paymentMethodId: string;
737
+ code: string;
738
+ label: string;
739
+ paymentMethodType: string;
740
+ gatewayCode: string | null;
741
+ description: string | null;
742
+ instructions: string | null;
743
+ qrFileId: string | null;
744
+ requiresPaymentSession: boolean;
745
+ publicConfig: Record<string, unknown>;
746
+ sortOrder: number;
747
+ }
748
+ export interface WebsitePaymentOption {
749
+ id: string;
750
+ mode: WebsitePaymentMode;
751
+ fulfillmentFamily: WebsiteFulfillmentFamily;
752
+ label: string;
753
+ description: string | null;
754
+ requiresPaymentMethod: boolean;
755
+ allowsInitialPayment: boolean;
756
+ initialPaymentPolicy: WebsiteInitialPaymentPolicy;
757
+ requiresInitialPayment: boolean;
758
+ minInitialAmount: number | null;
759
+ suggestedInitialAmount: number | null;
760
+ sortOrder: number;
761
+ methods: WebsitePaymentOptionMethod[];
762
+ }
763
+ export interface WebsiteCouponActionResult {
764
+ success: boolean;
765
+ orderId: string | null;
766
+ couponId: string | null;
767
+ code: string | null;
768
+ name: string | null;
769
+ couponType: string | null;
770
+ discountAmount: number;
771
+ eligibleSubtotal: number;
772
+ message: string | null;
773
+ cart: Cart | null;
774
+ errors: string[] | null;
775
+ }
776
+ export interface WebsitePaymentSessionResult {
777
+ success: boolean;
778
+ orderId: string | null;
779
+ paymentMethodId: string | null;
780
+ paymentSessionId: string | null;
781
+ gatewayCode: string | null;
782
+ integrationMode: "redirect" | null;
783
+ status: string | null;
784
+ redirectUrl: string | null;
785
+ /** @deprecated Provider-specific checkout payloads are no longer public. */
786
+ publicPayload: Record<string, unknown> | null;
787
+ errors: string[] | null;
788
+ }
789
+ export interface CheckoutResult {
790
+ success: boolean;
791
+ orderId: string | null;
792
+ orderNumber: string | null;
793
+ paymentMethodId: string | null;
794
+ publicOrderToken: string | null;
795
+ requiresPaymentSession: boolean;
796
+ buyerAccountInvitationRequested: boolean;
797
+ errors: string[] | null;
798
+ }
799
+ export interface PublicOrderLookupInput {
800
+ orderId: string;
801
+ token: string;
802
+ }
803
+ export interface WaitForPublicOrderPaymentInput extends PublicOrderLookupInput {
804
+ intervalMs?: number;
805
+ timeoutMs?: number;
806
+ }
807
+ export interface PublicOrderDeliverySummary {
808
+ fulfillmentFamily: WebsiteFulfillmentFamily | string;
809
+ shipping: {
810
+ label: string | null;
811
+ amount: number;
812
+ methodType: string;
813
+ collectionMode: string;
814
+ totalPolicy: string;
815
+ address: Record<string, unknown> | null;
816
+ } | null;
817
+ pickup: {
818
+ label: string;
819
+ } | null;
820
+ }
821
+ export interface PublicOrderPaymentSummary {
822
+ mode: WebsitePaymentMode | string | null;
823
+ label: string | null;
824
+ method: {
825
+ id: string | null;
826
+ label: string | null;
827
+ paymentMethodType: string | null;
828
+ gatewayCode: string | null;
829
+ requiresPaymentSession: boolean;
830
+ } | null;
831
+ requiresPaymentSession: boolean;
832
+ nextAction: PublicOrderPaymentNextAction;
833
+ initialPayment: {
834
+ amount: number;
835
+ paymentMethodId: string | null;
836
+ methodLabel: string | null;
837
+ paymentMethodType: string | null;
838
+ gatewayCode: string | null;
839
+ requiresPaymentSession: boolean;
840
+ } | null;
841
+ session: {
842
+ id: string;
843
+ gatewayCode: string;
844
+ integrationMode: string;
845
+ status: string;
846
+ reference: string;
847
+ amount: number;
848
+ currency: string;
849
+ gatewayTransactionId: string | null;
850
+ errorMessage: string | null;
851
+ expiresAt: string;
852
+ createdAt: string;
853
+ updatedAt: string;
854
+ } | null;
855
+ }
856
+ export type PublicOrderPaymentNextAction = "NONE" | "CREATE_PAYMENT_SESSION" | "WAIT_FOR_PAYMENT" | "RETRY_PAYMENT" | "PAY_ON_DELIVERY" | "PAY_AT_PICKUP" | "WAIT_FOR_ORDER_CONFIRMATION";
857
+ export interface PublicOrderItem {
858
+ id: string;
859
+ productVariantId: string;
860
+ sku: string;
861
+ name: string;
862
+ imageFileId: string | null;
863
+ quantity: number;
864
+ unitPrice: number | null;
865
+ lineTotal: number | null;
866
+ }
867
+ export interface PublicOrder {
868
+ orderId: string;
869
+ orderNumber: string | null;
870
+ status: string;
871
+ paymentStatus: string;
872
+ fulfillmentFamily: WebsiteFulfillmentFamily | string;
873
+ delivery: PublicOrderDeliverySummary;
874
+ payment: PublicOrderPaymentSummary;
875
+ totals: {
876
+ subtotal: number;
877
+ tax: number;
878
+ discount: number;
879
+ total: number;
880
+ totalWithDiscount: number;
881
+ };
882
+ items: PublicOrderItem[];
883
+ nextSteps: string[];
884
+ createdAt: string;
885
+ updatedAt: string;
886
+ }
887
+ export interface Order {
888
+ id: string;
889
+ orderNumber: string | null;
890
+ status: string;
891
+ fulfillmentFamily: string;
892
+ discount: number;
893
+ tax: number;
894
+ subtotal: number;
895
+ total: number;
896
+ totalWithDiscount: number;
897
+ items: OrderItem[];
898
+ createdAt: string;
899
+ updatedAt: string;
900
+ }
901
+ export interface OrderItem {
902
+ id: string;
903
+ productVariantId: string;
904
+ quantity: number;
905
+ productVariant: {
906
+ sku: string;
907
+ product: {
908
+ id: string;
909
+ name: string;
910
+ };
911
+ };
912
+ }
913
+ export interface GetOrdersOptions {
914
+ limit?: number;
915
+ offset?: number;
916
+ }
917
+ export type CustomerAddressType = "PRIMARY" | "SHIPPING";
918
+ export interface CustomerAddress {
919
+ /**
920
+ * Bacano source identifier. For PRIMARY this is the business party id; for
921
+ * SHIPPING it is the saved shipping-address id.
922
+ */
923
+ id: string;
924
+ type: CustomerAddressType;
925
+ label: string | null;
926
+ /**
927
+ * Recommended checkout default. A saved primary shipping address wins;
928
+ * otherwise a complete commercial profile address is the fallback.
929
+ */
930
+ isPrimary: boolean;
931
+ recipientName: string | null;
932
+ cellphone: string | null;
933
+ line1: string;
934
+ line2: string | null;
935
+ notes: string | null;
936
+ countryCode: string;
937
+ countryName: string;
938
+ /** Canonical geographic code accepted by checkout quote requests. */
939
+ departmentId: string;
940
+ departmentCode: string;
941
+ departmentName: string;
942
+ /** Canonical geographic code accepted by checkout quote requests. */
943
+ municipalityId: string;
944
+ municipalityCode: string;
945
+ municipalityName: string;
946
+ }
947
+ export interface CustomerProfile {
948
+ id: string;
949
+ name: string | null;
950
+ lastname: string | null;
951
+ /** Verified primary email synchronized from Clerk. Read-only in Bacano. */
952
+ email: string | null;
953
+ /** Canonical mobile/WhatsApp contact in E.164 format, e.g. +573001234567. */
954
+ cellphone: string | null;
955
+ /** Optional secondary or national-format phone number. */
956
+ phone: string | null;
957
+ address: string | null;
958
+ city: string | null;
959
+ state: string | null;
960
+ country: string | null;
961
+ birthday: string | null;
962
+ companyName: string | null;
963
+ }
964
+ export interface CustomerProfileUpdate {
965
+ name?: string;
966
+ lastname?: string;
967
+ /** Canonical mobile/WhatsApp contact in E.164 format, e.g. +573001234567. */
968
+ cellphone?: string;
969
+ /** Optional secondary or national-format phone number. */
970
+ phone?: string;
971
+ address?: string;
972
+ addressComplement?: string;
973
+ /** Canonical country code, normally `CO`. */
974
+ countryCode?: string;
975
+ /** Canonical department code returned by checkout location options. */
976
+ departmentId?: string;
977
+ /** Canonical municipality code returned by checkout location options. */
978
+ municipalityId?: string;
979
+ /** @deprecated Display text is read-only; use municipalityId instead. */
980
+ city?: string;
981
+ /** @deprecated Display text is read-only; use departmentId instead. */
982
+ state?: string;
983
+ /** @deprecated Display text is read-only; use countryCode instead. */
984
+ country?: string;
985
+ birthday?: string;
986
+ }
987
+ export interface AsyncState<T> {
988
+ data: T | null;
989
+ loading: boolean;
990
+ error: Error | null;
991
+ }