@sazito/client-sdk 1.2.7 → 1.2.8

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,69 @@ interface ShippingAssignment {
478
478
  * Order-related types
479
479
  */
480
480
 
481
+ type OrderPublicId = number | string;
482
+ interface OrderInvoiceItem {
483
+ productVariantId: OrderPublicId;
484
+ name: string;
485
+ image?: {
486
+ url?: string;
487
+ };
488
+ variantAttributes: Array<{
489
+ name: string;
490
+ value: string;
491
+ }>;
492
+ singleItemPrice: number;
493
+ noOfItems: number;
494
+ totalItemsPrice: number;
495
+ customerProfit?: number;
496
+ formAttributes?: unknown;
497
+ bookingAttributes?: unknown;
498
+ productVariant: {
499
+ commercialFiles?: Array<{
500
+ id: OrderPublicId;
501
+ }>;
502
+ product: {
503
+ productType: string;
504
+ };
505
+ };
506
+ }
507
+ interface OrderShippingItem {
508
+ id: OrderPublicId;
509
+ invoiceItemIds: OrderPublicId[];
510
+ rate: {
511
+ id?: OrderPublicId;
512
+ name: string;
513
+ price: number;
514
+ type?: string;
515
+ icon?: string;
516
+ color?: string;
517
+ };
518
+ }
519
+ interface OrderInvoice {
520
+ invoiceItems: OrderInvoiceItem[];
521
+ shippingItems: OrderShippingItem[];
522
+ netTotal: number;
523
+ finalTotal: number;
524
+ shippingTotal?: number;
525
+ discountTotal?: number;
526
+ creditTotal?: number;
527
+ vat?: number;
528
+ vatPercent?: number;
529
+ itemsTotalRawPrice?: number;
530
+ itemsDiscount?: number;
531
+ customerProfit?: number;
532
+ customerProfitPercentage?: number;
533
+ discountUsages?: Array<{
534
+ discountCode?: {
535
+ code?: string;
536
+ };
537
+ }>;
538
+ }
481
539
  interface Order {
482
- id: number;
483
- orderNumber: string;
540
+ id: OrderPublicId;
541
+ orderNumber: OrderPublicId;
484
542
  orderIdentifier: string;
485
- invoice: {
486
- shippingItems: JsonObject[];
487
- invoiceItems: InvoiceItem[];
488
- };
543
+ invoice: OrderInvoice;
489
544
  }
490
545
  interface OrdersListResponse {
491
546
  orders: Order[];
@@ -535,14 +590,33 @@ interface Payment {
535
590
  };
536
591
  amount: number;
537
592
  }
538
- interface PaymentAction {
539
- action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
540
- address?: string;
541
- payload?: JsonObject;
542
- order?: Order;
543
- time?: number;
593
+ interface PaymentActionBase {
544
594
  message?: string;
545
595
  }
596
+ type PaymentAction = PaymentActionBase & ({
597
+ action: 'POST';
598
+ address: string;
599
+ payload: Record<string, string | number>;
600
+ } | {
601
+ action: 'REDIRECT';
602
+ address: string;
603
+ } | {
604
+ action: 'UPLOAD';
605
+ time?: number;
606
+ } | {
607
+ action: 'show_otp_modal';
608
+ time?: number;
609
+ } | {
610
+ action: 'show_order';
611
+ order: Order;
612
+ } | {
613
+ action: 'pending';
614
+ order: Order;
615
+ } | {
616
+ action: 'payment_fail_error' | 'show_error' | 'FAIL';
617
+ } | {
618
+ action: 'StockViolated';
619
+ });
546
620
  interface PaymentCredentials {
547
621
  id: number;
548
622
  identifier: string;
@@ -863,7 +937,9 @@ declare class HttpClient {
863
937
  /**
864
938
  * POST request
865
939
  */
866
- post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
940
+ post<T>(endpoint: string, body?: any, options?: RequestOptions & {
941
+ skipRequestTransform?: boolean;
942
+ }): Promise<SazitoResponse<T>>;
867
943
  /**
868
944
  * PUT request
869
945
  */
@@ -1071,7 +1147,7 @@ declare class OrdersAPI {
1071
1147
  /**
1072
1148
  * Get single order by ID (requires authentication)
1073
1149
  */
1074
- get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1150
+ get(orderId: OrderPublicId, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1075
1151
  }
1076
1152
 
1077
1153
  /**
@@ -1204,14 +1280,14 @@ declare class PaymentsAPI {
1204
1280
  /**
1205
1281
  * Initialize payment: start the payment step before redirecting the user to
1206
1282
  * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1207
- * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1283
+ * POST for hosted gateways, or show_order for zero-amount/instant payments).
1208
1284
  */
1209
1285
  initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1210
1286
  /**
1211
1287
  * Verify payment after the user returns from the gateway. Forwards the
1212
1288
  * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1213
1289
  * `code`) to the same payment-step endpoint and returns the settled
1214
- * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1290
+ * {@link PaymentAction} (show_order on success, FAIL/StockViolated otherwise,
1215
1291
  * or pending if the gateway has not reported back yet).
1216
1292
  */
1217
1293
  verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
@@ -1240,6 +1316,7 @@ declare class PaymentsAPI {
1240
1316
  clearPayment(): void;
1241
1317
  private withExactJsonHeader;
1242
1318
  private buildProcessStepFormData;
1319
+ private buildProcessStepBody;
1243
1320
  private appendFormValue;
1244
1321
  /**
1245
1322
  * Post-process a `process_payment_step` response. The exact-JSON endpoint
@@ -1248,6 +1325,9 @@ declare class PaymentsAPI {
1248
1325
  */
1249
1326
  private finalizeStepResponse;
1250
1327
  private normalizeAction;
1328
+ private optionalNumber;
1329
+ private isPostPayload;
1330
+ private isCheckoutOrder;
1251
1331
  private callPinchAfterSuccessfulPayment;
1252
1332
  }
1253
1333
 
@@ -2316,4 +2396,4 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
2316
2396
  declare function transformCreateCartInput(input: TransformValue): TransformObject;
2317
2397
 
2318
2398
  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 };
2399
+ 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,69 @@ interface ShippingAssignment {
478
478
  * Order-related types
479
479
  */
480
480
 
481
+ type OrderPublicId = number | string;
482
+ interface OrderInvoiceItem {
483
+ productVariantId: OrderPublicId;
484
+ name: string;
485
+ image?: {
486
+ url?: string;
487
+ };
488
+ variantAttributes: Array<{
489
+ name: string;
490
+ value: string;
491
+ }>;
492
+ singleItemPrice: number;
493
+ noOfItems: number;
494
+ totalItemsPrice: number;
495
+ customerProfit?: number;
496
+ formAttributes?: unknown;
497
+ bookingAttributes?: unknown;
498
+ productVariant: {
499
+ commercialFiles?: Array<{
500
+ id: OrderPublicId;
501
+ }>;
502
+ product: {
503
+ productType: string;
504
+ };
505
+ };
506
+ }
507
+ interface OrderShippingItem {
508
+ id: OrderPublicId;
509
+ invoiceItemIds: OrderPublicId[];
510
+ rate: {
511
+ id?: OrderPublicId;
512
+ name: string;
513
+ price: number;
514
+ type?: string;
515
+ icon?: string;
516
+ color?: string;
517
+ };
518
+ }
519
+ interface OrderInvoice {
520
+ invoiceItems: OrderInvoiceItem[];
521
+ shippingItems: OrderShippingItem[];
522
+ netTotal: number;
523
+ finalTotal: number;
524
+ shippingTotal?: number;
525
+ discountTotal?: number;
526
+ creditTotal?: number;
527
+ vat?: number;
528
+ vatPercent?: number;
529
+ itemsTotalRawPrice?: number;
530
+ itemsDiscount?: number;
531
+ customerProfit?: number;
532
+ customerProfitPercentage?: number;
533
+ discountUsages?: Array<{
534
+ discountCode?: {
535
+ code?: string;
536
+ };
537
+ }>;
538
+ }
481
539
  interface Order {
482
- id: number;
483
- orderNumber: string;
540
+ id: OrderPublicId;
541
+ orderNumber: OrderPublicId;
484
542
  orderIdentifier: string;
485
- invoice: {
486
- shippingItems: JsonObject[];
487
- invoiceItems: InvoiceItem[];
488
- };
543
+ invoice: OrderInvoice;
489
544
  }
490
545
  interface OrdersListResponse {
491
546
  orders: Order[];
@@ -535,14 +590,33 @@ interface Payment {
535
590
  };
536
591
  amount: number;
537
592
  }
538
- interface PaymentAction {
539
- action: 'POST' | 'REDIRECT' | 'UPLOAD' | 'pending' | 'showOrder' | 'StockViolated' | 'FAIL';
540
- address?: string;
541
- payload?: JsonObject;
542
- order?: Order;
543
- time?: number;
593
+ interface PaymentActionBase {
544
594
  message?: string;
545
595
  }
596
+ type PaymentAction = PaymentActionBase & ({
597
+ action: 'POST';
598
+ address: string;
599
+ payload: Record<string, string | number>;
600
+ } | {
601
+ action: 'REDIRECT';
602
+ address: string;
603
+ } | {
604
+ action: 'UPLOAD';
605
+ time?: number;
606
+ } | {
607
+ action: 'show_otp_modal';
608
+ time?: number;
609
+ } | {
610
+ action: 'show_order';
611
+ order: Order;
612
+ } | {
613
+ action: 'pending';
614
+ order: Order;
615
+ } | {
616
+ action: 'payment_fail_error' | 'show_error' | 'FAIL';
617
+ } | {
618
+ action: 'StockViolated';
619
+ });
546
620
  interface PaymentCredentials {
547
621
  id: number;
548
622
  identifier: string;
@@ -863,7 +937,9 @@ declare class HttpClient {
863
937
  /**
864
938
  * POST request
865
939
  */
866
- post<T>(endpoint: string, body?: any, options?: RequestOptions): Promise<SazitoResponse<T>>;
940
+ post<T>(endpoint: string, body?: any, options?: RequestOptions & {
941
+ skipRequestTransform?: boolean;
942
+ }): Promise<SazitoResponse<T>>;
867
943
  /**
868
944
  * PUT request
869
945
  */
@@ -1071,7 +1147,7 @@ declare class OrdersAPI {
1071
1147
  /**
1072
1148
  * Get single order by ID (requires authentication)
1073
1149
  */
1074
- get(orderId: number, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1150
+ get(orderId: OrderPublicId, options?: RequestOptions): Promise<SazitoResponse<Order>>;
1075
1151
  }
1076
1152
 
1077
1153
  /**
@@ -1204,14 +1280,14 @@ declare class PaymentsAPI {
1204
1280
  /**
1205
1281
  * Initialize payment: start the payment step before redirecting the user to
1206
1282
  * the gateway. Returns the next {@link PaymentAction} (typically REDIRECT or
1207
- * POST for hosted gateways, or showOrder for zero-amount/instant payments).
1283
+ * POST for hosted gateways, or show_order for zero-amount/instant payments).
1208
1284
  */
1209
1285
  initialize(options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
1210
1286
  /**
1211
1287
  * Verify payment after the user returns from the gateway. Forwards the
1212
1288
  * gateway callback parameters (e.g. `tatoken`, `trackingData`, `isFailed`,
1213
1289
  * `code`) to the same payment-step endpoint and returns the settled
1214
- * {@link PaymentAction} (showOrder on success, FAIL/StockViolated otherwise,
1290
+ * {@link PaymentAction} (show_order on success, FAIL/StockViolated otherwise,
1215
1291
  * or pending if the gateway has not reported back yet).
1216
1292
  */
1217
1293
  verify(input?: PaymentStepInput, options?: RequestOptions): Promise<SazitoResponse<PaymentAction>>;
@@ -1240,6 +1316,7 @@ declare class PaymentsAPI {
1240
1316
  clearPayment(): void;
1241
1317
  private withExactJsonHeader;
1242
1318
  private buildProcessStepFormData;
1319
+ private buildProcessStepBody;
1243
1320
  private appendFormValue;
1244
1321
  /**
1245
1322
  * Post-process a `process_payment_step` response. The exact-JSON endpoint
@@ -1248,6 +1325,9 @@ declare class PaymentsAPI {
1248
1325
  */
1249
1326
  private finalizeStepResponse;
1250
1327
  private normalizeAction;
1328
+ private optionalNumber;
1329
+ private isPostPayload;
1330
+ private isCheckoutOrder;
1251
1331
  private callPinchAfterSuccessfulPayment;
1252
1332
  }
1253
1333
 
@@ -2316,4 +2396,4 @@ declare function transformAddToCartInput(variantId: number, quantity: number, fo
2316
2396
  declare function transformCreateCartInput(input: TransformValue): TransformObject;
2317
2397
 
2318
2398
  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 };
2399
+ 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 };