@sazito/client-sdk 1.2.7 → 1.2.9

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/dist/index.d.mts CHANGED
@@ -478,14 +478,65 @@ interface ShippingAssignment {
478
478
  * Order-related types
479
479
  */
480
480
 
481
+ type OrderPublicId = number | string;
482
+ /**
483
+ * Keeps the established InvoiceItem contract for patch-level compatibility,
484
+ * while exposing direct camelCase checkout fields when the endpoint provides them.
485
+ */
486
+ interface OrderInvoiceItem extends InvoiceItem {
487
+ variantAttributes?: Array<{
488
+ name: string;
489
+ value: string;
490
+ }>;
491
+ singleItemPrice?: number;
492
+ noOfItems?: number;
493
+ totalItemsPrice?: number;
494
+ productVariant?: {
495
+ commercialFiles?: Array<{
496
+ id: OrderPublicId;
497
+ }>;
498
+ product: {
499
+ productType: string;
500
+ };
501
+ };
502
+ }
503
+ interface OrderShippingItem {
504
+ id: OrderPublicId;
505
+ invoiceItemIds: OrderPublicId[];
506
+ rate: {
507
+ id?: OrderPublicId;
508
+ name: string;
509
+ price: number;
510
+ type?: string;
511
+ icon?: string;
512
+ color?: string;
513
+ };
514
+ }
515
+ interface OrderInvoice {
516
+ invoiceItems: OrderInvoiceItem[];
517
+ shippingItems: OrderShippingItem[];
518
+ netTotal: number;
519
+ finalTotal: number;
520
+ shippingTotal?: number;
521
+ discountTotal?: number;
522
+ creditTotal?: number;
523
+ vat?: number;
524
+ vatPercent?: number;
525
+ itemsTotalRawPrice?: number;
526
+ itemsDiscount?: number;
527
+ customerProfit?: number;
528
+ customerProfitPercentage?: number;
529
+ discountUsages?: Array<{
530
+ discountCode?: {
531
+ code?: string;
532
+ };
533
+ }>;
534
+ }
481
535
  interface Order {
482
- id: number;
483
- orderNumber: string;
536
+ id: OrderPublicId;
537
+ orderNumber: OrderPublicId;
484
538
  orderIdentifier: string;
485
- invoice: {
486
- shippingItems: JsonObject[];
487
- invoiceItems: InvoiceItem[];
488
- };
539
+ invoice: OrderInvoice;
489
540
  }
490
541
  interface OrdersListResponse {
491
542
  orders: Order[];
@@ -535,14 +586,33 @@ interface Payment {
535
586
  };
536
587
  amount: number;
537
588
  }
538
- interface PaymentAction {
539
- action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
540
- address?: string;
541
- payload?: JsonObject;
542
- order?: Order;
543
- time?: number;
589
+ interface PaymentActionBase {
544
590
  message?: string;
545
591
  }
592
+ type PaymentAction = PaymentActionBase & ({
593
+ action: 'POST';
594
+ address: string;
595
+ payload: Record<string, string | number>;
596
+ } | {
597
+ action: 'REDIRECT';
598
+ address: string;
599
+ } | {
600
+ action: 'UPLOAD';
601
+ time?: number;
602
+ } | {
603
+ action: 'show_otp_modal';
604
+ time?: number;
605
+ } | {
606
+ action: 'show_order';
607
+ order: Order;
608
+ } | {
609
+ action: 'pending';
610
+ order: Order;
611
+ } | {
612
+ action: 'payment_fail_error' | 'show_error' | 'FAIL';
613
+ } | {
614
+ action: 'StockViolated';
615
+ });
546
616
  interface PaymentCredentials {
547
617
  id: number;
548
618
  identifier: string;
@@ -863,7 +933,9 @@ declare class HttpClient {
863
933
  /**
864
934
  * POST request
865
935
  */
866
- post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
936
+ post<T>(endpoint: string, body?: any, options?: RequestOptions & {
937
+ skipRequestTransform?: boolean;
938
+ }): Promise<SazitoResponse<T>>;
867
939
  /**
868
940
  * PUT request
869
941
  */
@@ -1071,7 +1143,7 @@ declare class OrdersAPI {
1071
1143
  /**
1072
1144
  * Get single order by ID (requires authentication)
1073
1145
  */
1074
- get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1146
+ get(orderId: OrderPublicId, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1075
1147
  }
1076
1148
 
1077
1149
  /**
@@ -1204,14 +1276,14 @@ declare class PaymentsAPI {
1204
1276
  /**
1205
1277
  * Initialize payment: start the payment step before redirecting the user to
1206
1278
  * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1207
- * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1279
+ * POST for hosted gateways, or show_order for zero-amount/instant payments).
1208
1280
  */
1209
1281
  initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1210
1282
  /**
1211
1283
  * Verify payment after the user returns from the gateway. Forwards the
1212
1284
  * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1213
1285
  * `code`) to the same payment-step endpoint and returns the settled
1214
- * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1286
+ * {@link PaymentAction} (show_order on success, FAIL/StockViolated otherwise,
1215
1287
  * or pending if the gateway has not reported back yet).
1216
1288
  */
1217
1289
  verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
@@ -1240,6 +1312,7 @@ declare class PaymentsAPI {
1240
1312
  clearPayment(): void;
1241
1313
  private withExactJsonHeader;
1242
1314
  private buildProcessStepFormData;
1315
+ private buildProcessStepBody;
1243
1316
  private appendFormValue;
1244
1317
  /**
1245
1318
  * Post-process a `process_payment_step` response. The exact-JSON endpoint
@@ -1248,6 +1321,9 @@ declare class PaymentsAPI {
1248
1321
  */
1249
1322
  private finalizeStepResponse;
1250
1323
  private normalizeAction;
1324
+ private optionalNumber;
1325
+ private isPostPayload;
1326
+ private isCheckoutOrder;
1251
1327
  private callPinchAfterSuccessfulPayment;
1252
1328
  }
1253
1329
 
@@ -2316,4 +2392,4 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
2316
2392
  declare function transformCreateCartInput(input: TransformValue): TransformObject;
2317
2393
 
2318
2394
  export { CredentialsManager, HttpClient, MemoryStorage, SazitoClient, TokenStorage, createBookingAPI as booking, createCartAPI as cart, createCategoriesAPI as categories, createCMSAPI as cms, createBookingAPI, createCMSAPI, createCartAPI, createCategoriesAPI, createDynamicFormsAPI, createEntityRoutesAPI, createFeedbacksAPI, createGeneralAPI, createImagesAPI, createInvoicesAPI, createMenuAPI, createOrdersAPI, createPaymentsAPI, createProductsAPI, createRegionsAPI, createSazitoClient, createSearchAPI, createShippingAPI, createUsersAPI, createVisitsAPI, createWalletAPI, createDynamicFormsAPI as dynamicForms, createEntityRoutesAPI as entityRoutes, createFeedbacksAPI as feedbacks, createGeneralAPI as general, createImagesAPI as images, createInvoicesAPI as invoices, createMenuAPI as menu, createOrdersAPI as orders, createPaymentsAPI as payments, createProductsAPI as products, createRegionsAPI as regions, createSearchAPI as search, createShippingAPI as shipping, toEnglishDigits, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
2319
- export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
2395
+ export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrderInvoice, OrderInvoiceItem, OrderPublicId, OrderShippingItem, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
package/dist/index.d.ts CHANGED
@@ -478,14 +478,65 @@ interface ShippingAssignment {
478
478
  * Order-related types
479
479
  */
480
480
 
481
+ type OrderPublicId = number | string;
482
+ /**
483
+ * Keeps the established InvoiceItem contract for patch-level compatibility,
484
+ * while exposing direct camelCase checkout fields when the endpoint provides them.
485
+ */
486
+ interface OrderInvoiceItem extends InvoiceItem {
487
+ variantAttributes?: Array<{
488
+ name: string;
489
+ value: string;
490
+ }>;
491
+ singleItemPrice?: number;
492
+ noOfItems?: number;
493
+ totalItemsPrice?: number;
494
+ productVariant?: {
495
+ commercialFiles?: Array<{
496
+ id: OrderPublicId;
497
+ }>;
498
+ product: {
499
+ productType: string;
500
+ };
501
+ };
502
+ }
503
+ interface OrderShippingItem {
504
+ id: OrderPublicId;
505
+ invoiceItemIds: OrderPublicId[];
506
+ rate: {
507
+ id?: OrderPublicId;
508
+ name: string;
509
+ price: number;
510
+ type?: string;
511
+ icon?: string;
512
+ color?: string;
513
+ };
514
+ }
515
+ interface OrderInvoice {
516
+ invoiceItems: OrderInvoiceItem[];
517
+ shippingItems: OrderShippingItem[];
518
+ netTotal: number;
519
+ finalTotal: number;
520
+ shippingTotal?: number;
521
+ discountTotal?: number;
522
+ creditTotal?: number;
523
+ vat?: number;
524
+ vatPercent?: number;
525
+ itemsTotalRawPrice?: number;
526
+ itemsDiscount?: number;
527
+ customerProfit?: number;
528
+ customerProfitPercentage?: number;
529
+ discountUsages?: Array<{
530
+ discountCode?: {
531
+ code?: string;
532
+ };
533
+ }>;
534
+ }
481
535
  interface Order {
482
- id: number;
483
- orderNumber: string;
536
+ id: OrderPublicId;
537
+ orderNumber: OrderPublicId;
484
538
  orderIdentifier: string;
485
- invoice: {
486
- shippingItems: JsonObject[];
487
- invoiceItems: InvoiceItem[];
488
- };
539
+ invoice: OrderInvoice;
489
540
  }
490
541
  interface OrdersListResponse {
491
542
  orders: Order[];
@@ -535,14 +586,33 @@ interface Payment {
535
586
  };
536
587
  amount: number;
537
588
  }
538
- interface PaymentAction {
539
- action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
540
- address?: string;
541
- payload?: JsonObject;
542
- order?: Order;
543
- time?: number;
589
+ interface PaymentActionBase {
544
590
  message?: string;
545
591
  }
592
+ type PaymentAction = PaymentActionBase & ({
593
+ action: 'POST';
594
+ address: string;
595
+ payload: Record<string, string | number>;
596
+ } | {
597
+ action: 'REDIRECT';
598
+ address: string;
599
+ } | {
600
+ action: 'UPLOAD';
601
+ time?: number;
602
+ } | {
603
+ action: 'show_otp_modal';
604
+ time?: number;
605
+ } | {
606
+ action: 'show_order';
607
+ order: Order;
608
+ } | {
609
+ action: 'pending';
610
+ order: Order;
611
+ } | {
612
+ action: 'payment_fail_error' | 'show_error' | 'FAIL';
613
+ } | {
614
+ action: 'StockViolated';
615
+ });
546
616
  interface PaymentCredentials {
547
617
  id: number;
548
618
  identifier: string;
@@ -863,7 +933,9 @@ declare class HttpClient {
863
933
  /**
864
934
  * POST request
865
935
  */
866
- post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
936
+ post<T>(endpoint: string, body?: any, options?: RequestOptions & {
937
+ skipRequestTransform?: boolean;
938
+ }): Promise<SazitoResponse<T>>;
867
939
  /**
868
940
  * PUT request
869
941
  */
@@ -1071,7 +1143,7 @@ declare class OrdersAPI {
1071
1143
  /**
1072
1144
  * Get single order by ID (requires authentication)
1073
1145
  */
1074
- get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1146
+ get(orderId: OrderPublicId, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1075
1147
  }
1076
1148
 
1077
1149
  /**
@@ -1204,14 +1276,14 @@ declare class PaymentsAPI {
1204
1276
  /**
1205
1277
  * Initialize payment: start the payment step before redirecting the user to
1206
1278
  * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1207
- * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1279
+ * POST for hosted gateways, or show_order for zero-amount/instant payments).
1208
1280
  */
1209
1281
  initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1210
1282
  /**
1211
1283
  * Verify payment after the user returns from the gateway. Forwards the
1212
1284
  * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1213
1285
  * `code`) to the same payment-step endpoint and returns the settled
1214
- * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1286
+ * {@link PaymentAction} (show_order on success, FAIL/StockViolated otherwise,
1215
1287
  * or pending if the gateway has not reported back yet).
1216
1288
  */
1217
1289
  verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
@@ -1240,6 +1312,7 @@ declare class PaymentsAPI {
1240
1312
  clearPayment(): void;
1241
1313
  private withExactJsonHeader;
1242
1314
  private buildProcessStepFormData;
1315
+ private buildProcessStepBody;
1243
1316
  private appendFormValue;
1244
1317
  /**
1245
1318
  * Post-process a `process_payment_step` response. The exact-JSON endpoint
@@ -1248,6 +1321,9 @@ declare class PaymentsAPI {
1248
1321
  */
1249
1322
  private finalizeStepResponse;
1250
1323
  private normalizeAction;
1324
+ private optionalNumber;
1325
+ private isPostPayload;
1326
+ private isCheckoutOrder;
1251
1327
  private callPinchAfterSuccessfulPayment;
1252
1328
  }
1253
1329
 
@@ -2316,4 +2392,4 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
2316
2392
  declare function transformCreateCartInput(input: TransformValue): TransformObject;
2317
2393
 
2318
2394
  export { CredentialsManager, HttpClient, MemoryStorage, SazitoClient, TokenStorage, createBookingAPI as booking, createCartAPI as cart, createCategoriesAPI as categories, createCMSAPI as cms, createBookingAPI, createCMSAPI, createCartAPI, createCategoriesAPI, createDynamicFormsAPI, createEntityRoutesAPI, createFeedbacksAPI, createGeneralAPI, createImagesAPI, createInvoicesAPI, createMenuAPI, createOrdersAPI, createPaymentsAPI, createProductsAPI, createRegionsAPI, createSazitoClient, createSearchAPI, createShippingAPI, createUsersAPI, createVisitsAPI, createWalletAPI, createDynamicFormsAPI as dynamicForms, createEntityRoutesAPI as entityRoutes, createFeedbacksAPI as feedbacks, createGeneralAPI as general, createImagesAPI as images, createInvoicesAPI as invoices, createMenuAPI as menu, createOrdersAPI as orders, createPaymentsAPI as payments, createProductsAPI as products, createRegionsAPI as regions, createSearchAPI as search, createShippingAPI as shipping, toEnglishDigits, transformAddToCartInput, transformApiResponse, transformCartResponse, transformCreateCartInput, transformInvoiceResponse, transformProductListResponse, transformRequestKeys, transformResponseKeys, transformShippingAddressInput, createUsersAPI as users, createVisitsAPI as visits, createWalletAPI as wallet };
2319
- export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };
2395
+ export type { AddToCartInput, ApplicableShippingMethods, BlogPage, BlogPageEntityRoute, CMSPageEntityRoute, CMSPageType, CacheConfig, Cart, CartCredentials, CartProduct, CheckoutProductSnapshot, City$1 as City, CmsPage, CookieOptions, CreateCartInput, CreateInvoiceInput, CreatePaymentInput, EntityRoute, EntityRouteResponse, EntityType, FormAttributeValue, Image, Invoice, InvoiceCredentials, InvoiceItem, InvoiceItemFormAttributes, InvoiceShippingAddress, InvoiceShippingAddressRegion, ItemShippingRate, JsonArray, JsonObject, JsonPrimitive, JsonValue, MenuItem, MenuNode, MenuTree, Order, OrderFilters, OrderInvoice, OrderInvoiceItem, OrderPublicId, OrderShippingItem, OrdersListResponse, PaginatedResponse, Payment, PaymentAction, PaymentCredentials, PaymentGateway, PaymentMethod, PaymentStatus, PaymentStepFormFields, PaymentStepFormValue, PaymentStepInput, Product, ProductAttribute, ProductAttributeValueObject, ProductCategory, ProductCategoryEntityRoute, ProductEntityRoute, ProductFilters, ProductSort, ProductVariant, RefreshInvoiceInput, Region$1 as Region, RequestOptions, RetryConfig, SazitoConfig, SazitoError, SazitoResponse, SchedulerBookingAttributes, SearchFilters, SearchResponse, ShippingAddress, ShippingAddressCity, ShippingAddressCredentials, ShippingAddressInput, ShippingAddressRegion, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate, StorageAdapter, Tag, UnknownEntityRoute, UploadedFormFileAttribute, User };