@rovela-ai/sdk 0.1.55 → 0.1.57
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/admin/api/index.d.ts +1 -1
- package/dist/admin/api/index.d.ts.map +1 -1
- package/dist/admin/api/index.js +1 -1
- package/dist/admin/api/index.js.map +1 -1
- package/dist/admin/api/orders.d.ts +32 -0
- package/dist/admin/api/orders.d.ts.map +1 -1
- package/dist/admin/api/orders.js +122 -1
- package/dist/admin/api/orders.js.map +1 -1
- package/dist/admin/api/shipping.d.ts +105 -3
- package/dist/admin/api/shipping.d.ts.map +1 -1
- package/dist/admin/api/shipping.js +277 -3
- package/dist/admin/api/shipping.js.map +1 -1
- package/dist/admin/components/OrderDetails.d.ts.map +1 -1
- package/dist/admin/components/OrderDetails.js +71 -3
- package/dist/admin/components/OrderDetails.js.map +1 -1
- package/dist/admin/components/ShippingSettings.d.ts.map +1 -1
- package/dist/admin/components/ShippingSettings.js +220 -28
- package/dist/admin/components/ShippingSettings.js.map +1 -1
- package/dist/admin/index.d.ts +1 -1
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/types.d.ts +111 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/cart/components/CartDrawer.d.ts.map +1 -1
- package/dist/cart/components/CartDrawer.js +11 -2
- package/dist/cart/components/CartDrawer.js.map +1 -1
- package/dist/checkout/api/index.d.ts +1 -0
- package/dist/checkout/api/index.d.ts.map +1 -1
- package/dist/checkout/api/index.js +1 -0
- package/dist/checkout/api/index.js.map +1 -1
- package/dist/checkout/api/shipping.d.ts +34 -0
- package/dist/checkout/api/shipping.d.ts.map +1 -0
- package/dist/checkout/api/shipping.js +187 -0
- package/dist/checkout/api/shipping.js.map +1 -0
- package/dist/checkout/components/CheckoutFlow.d.ts +53 -0
- package/dist/checkout/components/CheckoutFlow.d.ts.map +1 -0
- package/dist/checkout/components/CheckoutFlow.js +232 -0
- package/dist/checkout/components/CheckoutFlow.js.map +1 -0
- package/dist/checkout/components/ShippingOptions.d.ts +51 -0
- package/dist/checkout/components/ShippingOptions.d.ts.map +1 -0
- package/dist/checkout/components/ShippingOptions.js +93 -0
- package/dist/checkout/components/ShippingOptions.js.map +1 -0
- package/dist/checkout/components/index.d.ts +2 -0
- package/dist/checkout/components/index.d.ts.map +1 -1
- package/dist/checkout/components/index.js +2 -0
- package/dist/checkout/components/index.js.map +1 -1
- package/dist/checkout/hooks/useCheckout.d.ts.map +1 -1
- package/dist/checkout/hooks/useCheckout.js +5 -0
- package/dist/checkout/hooks/useCheckout.js.map +1 -1
- package/dist/checkout/index.d.ts +2 -2
- package/dist/checkout/index.d.ts.map +1 -1
- package/dist/checkout/index.js +1 -1
- package/dist/checkout/index.js.map +1 -1
- package/dist/checkout/server/create-checkout-session.d.ts.map +1 -1
- package/dist/checkout/server/create-checkout-session.js +155 -35
- package/dist/checkout/server/create-checkout-session.js.map +1 -1
- package/dist/checkout/types.d.ts +178 -4
- package/dist/checkout/types.d.ts.map +1 -1
- package/dist/core/db/index.d.ts +1 -1
- package/dist/core/db/index.d.ts.map +1 -1
- package/dist/core/db/index.js +1 -1
- package/dist/core/db/index.js.map +1 -1
- package/dist/core/db/queries.d.ts +228 -5
- package/dist/core/db/queries.d.ts.map +1 -1
- package/dist/core/db/queries.js +223 -8
- package/dist/core/db/queries.js.map +1 -1
- package/dist/core/db/schema.d.ts +394 -2
- package/dist/core/db/schema.d.ts.map +1 -1
- package/dist/core/db/schema.js +42 -1
- package/dist/core/db/schema.js.map +1 -1
- package/dist/shipping/index.d.ts +8 -0
- package/dist/shipping/index.d.ts.map +1 -0
- package/dist/shipping/index.js +8 -0
- package/dist/shipping/index.js.map +1 -0
- package/dist/shipping/shippo.d.ts +85 -0
- package/dist/shipping/shippo.d.ts.map +1 -0
- package/dist/shipping/shippo.js +270 -0
- package/dist/shipping/shippo.js.map +1 -0
- package/package.json +1 -1
|
@@ -180,6 +180,12 @@ export declare function findOrders(options?: FindOrdersOptions): Promise<{
|
|
|
180
180
|
phone?: string;
|
|
181
181
|
} | null;
|
|
182
182
|
stripePaymentIntentId: string | null;
|
|
183
|
+
trackingNumber: string | null;
|
|
184
|
+
trackingUrl: string | null;
|
|
185
|
+
carrier: string | null;
|
|
186
|
+
labelUrl: string | null;
|
|
187
|
+
shippoRateId: string | null;
|
|
188
|
+
shippingMethod: string | null;
|
|
183
189
|
createdAt: Date;
|
|
184
190
|
updatedAt: Date;
|
|
185
191
|
}[]>;
|
|
@@ -230,6 +236,12 @@ export declare function findOrderById(id: string): Promise<{
|
|
|
230
236
|
phone?: string;
|
|
231
237
|
} | null;
|
|
232
238
|
stripePaymentIntentId: string | null;
|
|
239
|
+
trackingNumber: string | null;
|
|
240
|
+
trackingUrl: string | null;
|
|
241
|
+
carrier: string | null;
|
|
242
|
+
labelUrl: string | null;
|
|
243
|
+
shippoRateId: string | null;
|
|
244
|
+
shippingMethod: string | null;
|
|
233
245
|
createdAt: Date;
|
|
234
246
|
updatedAt: Date;
|
|
235
247
|
} | null>;
|
|
@@ -383,6 +395,12 @@ export declare function getRecentOrders(limit?: number): Promise<{
|
|
|
383
395
|
phone?: string;
|
|
384
396
|
} | null;
|
|
385
397
|
stripePaymentIntentId: string | null;
|
|
398
|
+
trackingNumber: string | null;
|
|
399
|
+
trackingUrl: string | null;
|
|
400
|
+
carrier: string | null;
|
|
401
|
+
labelUrl: string | null;
|
|
402
|
+
shippoRateId: string | null;
|
|
403
|
+
shippingMethod: string | null;
|
|
386
404
|
createdAt: Date;
|
|
387
405
|
updatedAt: Date;
|
|
388
406
|
}[]>;
|
|
@@ -390,8 +408,8 @@ export declare function getRecentOrders(limit?: number): Promise<{
|
|
|
390
408
|
* Create a new order
|
|
391
409
|
*/
|
|
392
410
|
export declare function createOrder(data: schema.NewOrder): Promise<{
|
|
393
|
-
status: "pending" | "paid" | "shipped" | "delivered" | "cancelled" | "refunded";
|
|
394
411
|
id: string;
|
|
412
|
+
status: "pending" | "paid" | "shipped" | "delivered" | "cancelled" | "refunded";
|
|
395
413
|
createdAt: Date;
|
|
396
414
|
updatedAt: Date;
|
|
397
415
|
customerId: string | null;
|
|
@@ -424,13 +442,19 @@ export declare function createOrder(data: schema.NewOrder): Promise<{
|
|
|
424
442
|
phone?: string;
|
|
425
443
|
} | null;
|
|
426
444
|
stripePaymentIntentId: string | null;
|
|
445
|
+
trackingNumber: string | null;
|
|
446
|
+
trackingUrl: string | null;
|
|
447
|
+
carrier: string | null;
|
|
448
|
+
labelUrl: string | null;
|
|
449
|
+
shippoRateId: string | null;
|
|
450
|
+
shippingMethod: string | null;
|
|
427
451
|
}>;
|
|
428
452
|
/**
|
|
429
453
|
* Create order items for an order
|
|
430
454
|
*/
|
|
431
455
|
export declare function createOrderItems(items: schema.NewOrderItem[]): Promise<{
|
|
432
|
-
name: string;
|
|
433
456
|
id: string;
|
|
457
|
+
name: string;
|
|
434
458
|
price: string;
|
|
435
459
|
createdAt: Date;
|
|
436
460
|
productId: string;
|
|
@@ -475,6 +499,65 @@ export declare function updateOrderStatus(orderId: string, status: 'pending' | '
|
|
|
475
499
|
phone?: string;
|
|
476
500
|
} | null;
|
|
477
501
|
stripePaymentIntentId: string | null;
|
|
502
|
+
trackingNumber: string | null;
|
|
503
|
+
trackingUrl: string | null;
|
|
504
|
+
carrier: string | null;
|
|
505
|
+
labelUrl: string | null;
|
|
506
|
+
shippoRateId: string | null;
|
|
507
|
+
shippingMethod: string | null;
|
|
508
|
+
createdAt: Date;
|
|
509
|
+
updatedAt: Date;
|
|
510
|
+
}>;
|
|
511
|
+
/**
|
|
512
|
+
* Update order shipping information (for Shippo integration)
|
|
513
|
+
*/
|
|
514
|
+
export declare function updateOrderShipping(orderId: string, shippingData: {
|
|
515
|
+
trackingNumber?: string;
|
|
516
|
+
trackingUrl?: string;
|
|
517
|
+
carrier?: string;
|
|
518
|
+
labelUrl?: string;
|
|
519
|
+
shippoRateId?: string;
|
|
520
|
+
shippingMethod?: string;
|
|
521
|
+
status?: 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';
|
|
522
|
+
}): Promise<{
|
|
523
|
+
id: string;
|
|
524
|
+
customerId: string | null;
|
|
525
|
+
email: string;
|
|
526
|
+
status: "pending" | "paid" | "shipped" | "delivered" | "cancelled" | "refunded";
|
|
527
|
+
subtotal: string;
|
|
528
|
+
tax: string;
|
|
529
|
+
shipping: string;
|
|
530
|
+
total: string;
|
|
531
|
+
refundAmount: string | null;
|
|
532
|
+
shippingAddress: {
|
|
533
|
+
firstName: string;
|
|
534
|
+
lastName: string;
|
|
535
|
+
line1: string;
|
|
536
|
+
line2?: string;
|
|
537
|
+
city: string;
|
|
538
|
+
state: string;
|
|
539
|
+
postalCode: string;
|
|
540
|
+
country: string;
|
|
541
|
+
phone?: string;
|
|
542
|
+
} | null;
|
|
543
|
+
billingAddress: {
|
|
544
|
+
firstName: string;
|
|
545
|
+
lastName: string;
|
|
546
|
+
line1: string;
|
|
547
|
+
line2?: string;
|
|
548
|
+
city: string;
|
|
549
|
+
state: string;
|
|
550
|
+
postalCode: string;
|
|
551
|
+
country: string;
|
|
552
|
+
phone?: string;
|
|
553
|
+
} | null;
|
|
554
|
+
stripePaymentIntentId: string | null;
|
|
555
|
+
trackingNumber: string | null;
|
|
556
|
+
trackingUrl: string | null;
|
|
557
|
+
carrier: string | null;
|
|
558
|
+
labelUrl: string | null;
|
|
559
|
+
shippoRateId: string | null;
|
|
560
|
+
shippingMethod: string | null;
|
|
478
561
|
createdAt: Date;
|
|
479
562
|
updatedAt: Date;
|
|
480
563
|
}>;
|
|
@@ -515,6 +598,12 @@ export declare function findOrderByPaymentIntent(paymentIntentId: string): Promi
|
|
|
515
598
|
phone?: string;
|
|
516
599
|
} | null;
|
|
517
600
|
stripePaymentIntentId: string | null;
|
|
601
|
+
trackingNumber: string | null;
|
|
602
|
+
trackingUrl: string | null;
|
|
603
|
+
carrier: string | null;
|
|
604
|
+
labelUrl: string | null;
|
|
605
|
+
shippoRateId: string | null;
|
|
606
|
+
shippingMethod: string | null;
|
|
518
607
|
createdAt: Date;
|
|
519
608
|
updatedAt: Date;
|
|
520
609
|
}>;
|
|
@@ -625,6 +714,12 @@ export declare function findCustomerOrders(customerId: string): Promise<{
|
|
|
625
714
|
phone?: string;
|
|
626
715
|
} | null;
|
|
627
716
|
stripePaymentIntentId: string | null;
|
|
717
|
+
trackingNumber: string | null;
|
|
718
|
+
trackingUrl: string | null;
|
|
719
|
+
carrier: string | null;
|
|
720
|
+
labelUrl: string | null;
|
|
721
|
+
shippoRateId: string | null;
|
|
722
|
+
shippingMethod: string | null;
|
|
628
723
|
createdAt: Date;
|
|
629
724
|
updatedAt: Date;
|
|
630
725
|
}[]>;
|
|
@@ -677,6 +772,26 @@ export interface StoreSettingsData {
|
|
|
677
772
|
shippingEnabled: boolean | null;
|
|
678
773
|
freeShippingThreshold: number | null;
|
|
679
774
|
shippingCountries: string[] | null;
|
|
775
|
+
shippingMode: 'manual' | 'shippo' | null;
|
|
776
|
+
shippoTestMode: boolean | null;
|
|
777
|
+
shippoFromAddress: {
|
|
778
|
+
name: string;
|
|
779
|
+
company?: string;
|
|
780
|
+
street1: string;
|
|
781
|
+
street2?: string;
|
|
782
|
+
city: string;
|
|
783
|
+
state: string;
|
|
784
|
+
zip: string;
|
|
785
|
+
country: string;
|
|
786
|
+
phone?: string;
|
|
787
|
+
email?: string;
|
|
788
|
+
} | null;
|
|
789
|
+
shippoDefaultParcel: {
|
|
790
|
+
length: number;
|
|
791
|
+
width: number;
|
|
792
|
+
height: number;
|
|
793
|
+
weight: number;
|
|
794
|
+
} | null;
|
|
680
795
|
}
|
|
681
796
|
/**
|
|
682
797
|
* Find store settings.
|
|
@@ -689,11 +804,76 @@ export declare function findSettings(): Promise<StoreSettingsData | null>;
|
|
|
689
804
|
* Each store has only one settings row.
|
|
690
805
|
*/
|
|
691
806
|
export declare function upsertSettings(data: Partial<StoreSettingsData>): Promise<StoreSettingsData>;
|
|
807
|
+
/**
|
|
808
|
+
* Shipping carrier data for API responses
|
|
809
|
+
*/
|
|
810
|
+
export interface ShippingCarrierData {
|
|
811
|
+
id: string;
|
|
812
|
+
name: string;
|
|
813
|
+
code: string;
|
|
814
|
+
description: string | null;
|
|
815
|
+
isActive: boolean;
|
|
816
|
+
sortOrder: number;
|
|
817
|
+
createdAt: Date;
|
|
818
|
+
updatedAt: Date;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Shipping carrier with nested zones and rates for full hierarchy
|
|
822
|
+
*/
|
|
823
|
+
export interface ShippingCarrierWithZones extends ShippingCarrierData {
|
|
824
|
+
zones: ShippingZoneWithRates[];
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Find all shipping carriers
|
|
828
|
+
*/
|
|
829
|
+
export declare function findShippingCarriers(): Promise<ShippingCarrierData[]>;
|
|
830
|
+
/**
|
|
831
|
+
* Find active shipping carriers only
|
|
832
|
+
*/
|
|
833
|
+
export declare function findActiveShippingCarriers(): Promise<ShippingCarrierData[]>;
|
|
834
|
+
/**
|
|
835
|
+
* Find a shipping carrier by ID
|
|
836
|
+
*/
|
|
837
|
+
export declare function findShippingCarrierById(id: string): Promise<ShippingCarrierData | null>;
|
|
838
|
+
/**
|
|
839
|
+
* Create a new shipping carrier
|
|
840
|
+
*/
|
|
841
|
+
export declare function createShippingCarrier(data: {
|
|
842
|
+
name: string;
|
|
843
|
+
code: string;
|
|
844
|
+
description?: string;
|
|
845
|
+
isActive?: boolean;
|
|
846
|
+
sortOrder?: number;
|
|
847
|
+
}): Promise<schema.ShippingCarrier>;
|
|
848
|
+
/**
|
|
849
|
+
* Update a shipping carrier
|
|
850
|
+
*/
|
|
851
|
+
export declare function updateShippingCarrier(id: string, data: Partial<{
|
|
852
|
+
name: string;
|
|
853
|
+
code: string;
|
|
854
|
+
description: string | null;
|
|
855
|
+
isActive: boolean;
|
|
856
|
+
sortOrder: number;
|
|
857
|
+
}>): Promise<schema.ShippingCarrier | null>;
|
|
858
|
+
/**
|
|
859
|
+
* Delete a shipping carrier (cascades to zones and rates)
|
|
860
|
+
*/
|
|
861
|
+
export declare function deleteShippingCarrier(id: string): Promise<boolean>;
|
|
862
|
+
/**
|
|
863
|
+
* Find all carriers with their zones and rates (full hierarchy for admin UI)
|
|
864
|
+
*/
|
|
865
|
+
export declare function findCarriersWithZonesAndRates(): Promise<ShippingCarrierWithZones[]>;
|
|
692
866
|
/**
|
|
693
867
|
* Shipping zone with nested rates for API responses
|
|
694
868
|
*/
|
|
695
869
|
export interface ShippingZoneWithRates {
|
|
696
870
|
id: string;
|
|
871
|
+
carrierId: string;
|
|
872
|
+
carrier?: {
|
|
873
|
+
id: string;
|
|
874
|
+
name: string;
|
|
875
|
+
code: string;
|
|
876
|
+
};
|
|
697
877
|
name: string;
|
|
698
878
|
countries: string[];
|
|
699
879
|
isActive: boolean;
|
|
@@ -713,7 +893,7 @@ export interface ShippingZoneWithRates {
|
|
|
713
893
|
}>;
|
|
714
894
|
}
|
|
715
895
|
/**
|
|
716
|
-
* Find all shipping zones with their rates
|
|
896
|
+
* Find all shipping zones with their rates and carrier info
|
|
717
897
|
*/
|
|
718
898
|
export declare function findShippingZones(): Promise<ShippingZoneWithRates[]>;
|
|
719
899
|
/**
|
|
@@ -725,9 +905,10 @@ export declare function findActiveShippingZones(): Promise<ShippingZoneWithRates
|
|
|
725
905
|
*/
|
|
726
906
|
export declare function findShippingZoneById(id: string): Promise<ShippingZoneWithRates | null>;
|
|
727
907
|
/**
|
|
728
|
-
* Create a new shipping zone
|
|
908
|
+
* Create a new shipping zone under a carrier
|
|
729
909
|
*/
|
|
730
910
|
export declare function createShippingZone(data: {
|
|
911
|
+
carrierId: string;
|
|
731
912
|
name: string;
|
|
732
913
|
countries: string[];
|
|
733
914
|
isActive?: boolean;
|
|
@@ -737,6 +918,7 @@ export declare function createShippingZone(data: {
|
|
|
737
918
|
* Update a shipping zone
|
|
738
919
|
*/
|
|
739
920
|
export declare function updateShippingZone(id: string, data: Partial<{
|
|
921
|
+
carrierId: string;
|
|
740
922
|
name: string;
|
|
741
923
|
countries: string[];
|
|
742
924
|
isActive: boolean;
|
|
@@ -783,14 +965,55 @@ export declare function deleteShippingRate(id: string): Promise<boolean>;
|
|
|
783
965
|
*
|
|
784
966
|
* @param country - ISO country code (e.g., 'US', 'CA')
|
|
785
967
|
* @param orderAmount - Order subtotal in dollars
|
|
786
|
-
* @returns Array of applicable shipping rates
|
|
968
|
+
* @returns Array of applicable shipping rates with carrier info
|
|
787
969
|
*/
|
|
788
970
|
export declare function findShippingRatesForCountry(country: string, orderAmount: number): Promise<Array<{
|
|
789
971
|
id: string;
|
|
972
|
+
carrierId: string;
|
|
973
|
+
carrierName: string;
|
|
974
|
+
carrierCode: string;
|
|
790
975
|
zoneName: string;
|
|
791
976
|
name: string;
|
|
792
977
|
description: string | null;
|
|
793
978
|
price: number;
|
|
794
979
|
estimatedDays: string | null;
|
|
795
980
|
}>>;
|
|
981
|
+
/**
|
|
982
|
+
* Shipping option for checkout UI (unified format for both manual and Shippo modes)
|
|
983
|
+
* Compatible with checkout/types.ts ShippingOption
|
|
984
|
+
*/
|
|
985
|
+
export interface ShippingOptionForCheckout {
|
|
986
|
+
id: string;
|
|
987
|
+
carrierId: string;
|
|
988
|
+
carrierName: string;
|
|
989
|
+
carrierCode: string;
|
|
990
|
+
/** Display name (e.g., "Standard Shipping", "Priority Mail") - matches ShippingOption.name */
|
|
991
|
+
name: string;
|
|
992
|
+
/** Description - optional to match ShippingOption */
|
|
993
|
+
description?: string;
|
|
994
|
+
price: number;
|
|
995
|
+
/** Estimated delivery time - optional to match ShippingOption */
|
|
996
|
+
estimatedDays?: string;
|
|
997
|
+
source: 'manual' | 'shippo';
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Shipping options grouped by carrier for checkout UI
|
|
1001
|
+
*/
|
|
1002
|
+
export interface ShippingOptionsGroupedByCarrier {
|
|
1003
|
+
carrier: {
|
|
1004
|
+
id: string;
|
|
1005
|
+
name: string;
|
|
1006
|
+
code: string;
|
|
1007
|
+
};
|
|
1008
|
+
options: ShippingOptionForCheckout[];
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Find shipping options for checkout grouped by carrier.
|
|
1012
|
+
* This is the main function used by the pre-checkout flow.
|
|
1013
|
+
*
|
|
1014
|
+
* @param country - ISO country code (e.g., 'US', 'CA')
|
|
1015
|
+
* @param orderAmount - Order subtotal in dollars
|
|
1016
|
+
* @returns Shipping options grouped by carrier
|
|
1017
|
+
*/
|
|
1018
|
+
export declare function findShippingOptionsForCountry(country: string, orderAmount: number): Promise<ShippingOptionsGroupedByCarrier[]>;
|
|
796
1019
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/core/db/queries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAMlC,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;IACxC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,CAAA;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;;;;;;KAiDnE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;GAUnD;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;GAU/C;AAED;;GAEG;AACH,wBAA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A;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,CAAC,CAAC,CAgDF;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,8FAA8F;IAC9F,IAAI,EAAE,MAAM,CAAA;IACZ,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,OAAO,EAAE,yBAAyB,EAAE,CAAA;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAqC5C"}
|
package/dist/core/db/queries.js
CHANGED
|
@@ -350,6 +350,21 @@ export async function updateOrderStatus(orderId, status) {
|
|
|
350
350
|
.returning();
|
|
351
351
|
return order || null;
|
|
352
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Update order shipping information (for Shippo integration)
|
|
355
|
+
*/
|
|
356
|
+
export async function updateOrderShipping(orderId, shippingData) {
|
|
357
|
+
const db = getDb();
|
|
358
|
+
const [order] = await db
|
|
359
|
+
.update(schema.orders)
|
|
360
|
+
.set({
|
|
361
|
+
...shippingData,
|
|
362
|
+
updatedAt: new Date(),
|
|
363
|
+
})
|
|
364
|
+
.where(eq(schema.orders.id, orderId))
|
|
365
|
+
.returning();
|
|
366
|
+
return order || null;
|
|
367
|
+
}
|
|
353
368
|
/**
|
|
354
369
|
* Find order by Stripe Payment Intent ID
|
|
355
370
|
* Used for idempotency in webhook handling
|
|
@@ -687,6 +702,11 @@ export async function findSettings() {
|
|
|
687
702
|
? Number(settings.freeShippingThreshold)
|
|
688
703
|
: null,
|
|
689
704
|
shippingCountries: settings.shippingCountries,
|
|
705
|
+
// Shippo fields
|
|
706
|
+
shippingMode: settings.shippingMode,
|
|
707
|
+
shippoTestMode: settings.shippoTestMode,
|
|
708
|
+
shippoFromAddress: settings.shippoFromAddress,
|
|
709
|
+
shippoDefaultParcel: settings.shippoDefaultParcel,
|
|
690
710
|
};
|
|
691
711
|
}
|
|
692
712
|
/**
|
|
@@ -714,6 +734,11 @@ export async function upsertSettings(data) {
|
|
|
714
734
|
? String(data.freeShippingThreshold)
|
|
715
735
|
: undefined,
|
|
716
736
|
shippingCountries: data.shippingCountries ?? undefined,
|
|
737
|
+
// Shippo carrier integration
|
|
738
|
+
shippingMode: data.shippingMode ?? undefined,
|
|
739
|
+
shippoTestMode: data.shippoTestMode ?? undefined,
|
|
740
|
+
shippoFromAddress: data.shippoFromAddress ?? undefined,
|
|
741
|
+
shippoDefaultParcel: data.shippoDefaultParcel ?? undefined,
|
|
717
742
|
updatedAt: new Date(),
|
|
718
743
|
};
|
|
719
744
|
let result;
|
|
@@ -744,17 +769,154 @@ export async function upsertSettings(data) {
|
|
|
744
769
|
? Number(result.freeShippingThreshold)
|
|
745
770
|
: null,
|
|
746
771
|
shippingCountries: result.shippingCountries,
|
|
772
|
+
// Shippo fields
|
|
773
|
+
shippingMode: result.shippingMode,
|
|
774
|
+
shippoTestMode: result.shippoTestMode,
|
|
775
|
+
shippoFromAddress: result.shippoFromAddress,
|
|
776
|
+
shippoDefaultParcel: result.shippoDefaultParcel,
|
|
747
777
|
};
|
|
748
778
|
}
|
|
749
779
|
/**
|
|
750
|
-
* Find all shipping
|
|
780
|
+
* Find all shipping carriers
|
|
751
781
|
*/
|
|
752
|
-
export async function
|
|
782
|
+
export async function findShippingCarriers() {
|
|
783
|
+
const db = getDb();
|
|
784
|
+
const carriers = await db
|
|
785
|
+
.select()
|
|
786
|
+
.from(schema.shippingCarriers)
|
|
787
|
+
.orderBy(asc(schema.shippingCarriers.sortOrder), asc(schema.shippingCarriers.name));
|
|
788
|
+
return carriers.map((carrier) => ({
|
|
789
|
+
id: carrier.id,
|
|
790
|
+
name: carrier.name,
|
|
791
|
+
code: carrier.code,
|
|
792
|
+
description: carrier.description,
|
|
793
|
+
isActive: carrier.isActive,
|
|
794
|
+
sortOrder: carrier.sortOrder,
|
|
795
|
+
createdAt: carrier.createdAt,
|
|
796
|
+
updatedAt: carrier.updatedAt,
|
|
797
|
+
}));
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Find active shipping carriers only
|
|
801
|
+
*/
|
|
802
|
+
export async function findActiveShippingCarriers() {
|
|
803
|
+
const db = getDb();
|
|
804
|
+
const carriers = await db
|
|
805
|
+
.select()
|
|
806
|
+
.from(schema.shippingCarriers)
|
|
807
|
+
.where(eq(schema.shippingCarriers.isActive, true))
|
|
808
|
+
.orderBy(asc(schema.shippingCarriers.sortOrder), asc(schema.shippingCarriers.name));
|
|
809
|
+
return carriers.map((carrier) => ({
|
|
810
|
+
id: carrier.id,
|
|
811
|
+
name: carrier.name,
|
|
812
|
+
code: carrier.code,
|
|
813
|
+
description: carrier.description,
|
|
814
|
+
isActive: carrier.isActive,
|
|
815
|
+
sortOrder: carrier.sortOrder,
|
|
816
|
+
createdAt: carrier.createdAt,
|
|
817
|
+
updatedAt: carrier.updatedAt,
|
|
818
|
+
}));
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Find a shipping carrier by ID
|
|
822
|
+
*/
|
|
823
|
+
export async function findShippingCarrierById(id) {
|
|
753
824
|
const db = getDb();
|
|
754
|
-
|
|
755
|
-
const zones = await db
|
|
825
|
+
const [carrier] = await db
|
|
756
826
|
.select()
|
|
827
|
+
.from(schema.shippingCarriers)
|
|
828
|
+
.where(eq(schema.shippingCarriers.id, id))
|
|
829
|
+
.limit(1);
|
|
830
|
+
if (!carrier)
|
|
831
|
+
return null;
|
|
832
|
+
return {
|
|
833
|
+
id: carrier.id,
|
|
834
|
+
name: carrier.name,
|
|
835
|
+
code: carrier.code,
|
|
836
|
+
description: carrier.description,
|
|
837
|
+
isActive: carrier.isActive,
|
|
838
|
+
sortOrder: carrier.sortOrder,
|
|
839
|
+
createdAt: carrier.createdAt,
|
|
840
|
+
updatedAt: carrier.updatedAt,
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Create a new shipping carrier
|
|
845
|
+
*/
|
|
846
|
+
export async function createShippingCarrier(data) {
|
|
847
|
+
const db = getDb();
|
|
848
|
+
const [carrier] = await db
|
|
849
|
+
.insert(schema.shippingCarriers)
|
|
850
|
+
.values({
|
|
851
|
+
name: data.name,
|
|
852
|
+
code: data.code,
|
|
853
|
+
description: data.description || null,
|
|
854
|
+
isActive: data.isActive ?? true,
|
|
855
|
+
sortOrder: data.sortOrder ?? 0,
|
|
856
|
+
})
|
|
857
|
+
.returning();
|
|
858
|
+
return carrier;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Update a shipping carrier
|
|
862
|
+
*/
|
|
863
|
+
export async function updateShippingCarrier(id, data) {
|
|
864
|
+
const db = getDb();
|
|
865
|
+
const [carrier] = await db
|
|
866
|
+
.update(schema.shippingCarriers)
|
|
867
|
+
.set({ ...data, updatedAt: new Date() })
|
|
868
|
+
.where(eq(schema.shippingCarriers.id, id))
|
|
869
|
+
.returning();
|
|
870
|
+
return carrier || null;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Delete a shipping carrier (cascades to zones and rates)
|
|
874
|
+
*/
|
|
875
|
+
export async function deleteShippingCarrier(id) {
|
|
876
|
+
const db = getDb();
|
|
877
|
+
const result = await db
|
|
878
|
+
.delete(schema.shippingCarriers)
|
|
879
|
+
.where(eq(schema.shippingCarriers.id, id))
|
|
880
|
+
.returning({ id: schema.shippingCarriers.id });
|
|
881
|
+
return result.length > 0;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Find all carriers with their zones and rates (full hierarchy for admin UI)
|
|
885
|
+
*/
|
|
886
|
+
export async function findCarriersWithZonesAndRates() {
|
|
887
|
+
const carriers = await findShippingCarriers();
|
|
888
|
+
const zones = await findShippingZones();
|
|
889
|
+
// Group zones by carrier
|
|
890
|
+
const zonesByCarrier = new Map();
|
|
891
|
+
for (const zone of zones) {
|
|
892
|
+
if (!zone.carrierId)
|
|
893
|
+
continue;
|
|
894
|
+
const existing = zonesByCarrier.get(zone.carrierId) || [];
|
|
895
|
+
existing.push(zone);
|
|
896
|
+
zonesByCarrier.set(zone.carrierId, existing);
|
|
897
|
+
}
|
|
898
|
+
return carriers.map((carrier) => ({
|
|
899
|
+
...carrier,
|
|
900
|
+
zones: zonesByCarrier.get(carrier.id) || [],
|
|
901
|
+
}));
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Find all shipping zones with their rates and carrier info
|
|
905
|
+
*/
|
|
906
|
+
export async function findShippingZones() {
|
|
907
|
+
const db = getDb();
|
|
908
|
+
// Get all zones with carrier info via join
|
|
909
|
+
const zonesWithCarriers = await db
|
|
910
|
+
.select({
|
|
911
|
+
zone: schema.shippingZones,
|
|
912
|
+
carrier: {
|
|
913
|
+
id: schema.shippingCarriers.id,
|
|
914
|
+
name: schema.shippingCarriers.name,
|
|
915
|
+
code: schema.shippingCarriers.code,
|
|
916
|
+
},
|
|
917
|
+
})
|
|
757
918
|
.from(schema.shippingZones)
|
|
919
|
+
.leftJoin(schema.shippingCarriers, eq(schema.shippingZones.carrierId, schema.shippingCarriers.id))
|
|
758
920
|
.orderBy(asc(schema.shippingZones.sortOrder), asc(schema.shippingZones.name));
|
|
759
921
|
// Get all rates
|
|
760
922
|
const rates = await db
|
|
@@ -768,9 +930,15 @@ export async function findShippingZones() {
|
|
|
768
930
|
existing.push(rate);
|
|
769
931
|
ratesByZone.set(rate.zoneId, existing);
|
|
770
932
|
}
|
|
771
|
-
// Combine zones with their rates
|
|
772
|
-
return
|
|
933
|
+
// Combine zones with their rates and carrier info
|
|
934
|
+
return zonesWithCarriers.map(({ zone, carrier }) => ({
|
|
773
935
|
id: zone.id,
|
|
936
|
+
carrierId: zone.carrierId,
|
|
937
|
+
carrier: carrier ? {
|
|
938
|
+
id: carrier.id,
|
|
939
|
+
name: carrier.name,
|
|
940
|
+
code: carrier.code,
|
|
941
|
+
} : undefined,
|
|
774
942
|
name: zone.name,
|
|
775
943
|
countries: zone.countries || [],
|
|
776
944
|
isActive: zone.isActive,
|
|
@@ -805,13 +973,14 @@ export async function findShippingZoneById(id) {
|
|
|
805
973
|
return zones.find((z) => z.id === id) || null;
|
|
806
974
|
}
|
|
807
975
|
/**
|
|
808
|
-
* Create a new shipping zone
|
|
976
|
+
* Create a new shipping zone under a carrier
|
|
809
977
|
*/
|
|
810
978
|
export async function createShippingZone(data) {
|
|
811
979
|
const db = getDb();
|
|
812
980
|
const [zone] = await db
|
|
813
981
|
.insert(schema.shippingZones)
|
|
814
982
|
.values({
|
|
983
|
+
carrierId: data.carrierId,
|
|
815
984
|
name: data.name,
|
|
816
985
|
countries: data.countries,
|
|
817
986
|
isActive: data.isActive ?? true,
|
|
@@ -910,12 +1079,15 @@ export async function deleteShippingRate(id) {
|
|
|
910
1079
|
*
|
|
911
1080
|
* @param country - ISO country code (e.g., 'US', 'CA')
|
|
912
1081
|
* @param orderAmount - Order subtotal in dollars
|
|
913
|
-
* @returns Array of applicable shipping rates
|
|
1082
|
+
* @returns Array of applicable shipping rates with carrier info
|
|
914
1083
|
*/
|
|
915
1084
|
export async function findShippingRatesForCountry(country, orderAmount) {
|
|
916
1085
|
const zones = await findActiveShippingZones();
|
|
917
1086
|
const applicableRates = [];
|
|
918
1087
|
for (const zone of zones) {
|
|
1088
|
+
// Skip zones without a carrier (shouldn't happen, but defensive)
|
|
1089
|
+
if (!zone.carrier)
|
|
1090
|
+
continue;
|
|
919
1091
|
// Check if zone covers this country
|
|
920
1092
|
// '*' means all countries (international catch-all)
|
|
921
1093
|
const coversCountry = zone.countries.includes('*') || zone.countries.includes(country.toUpperCase());
|
|
@@ -932,6 +1104,9 @@ export async function findShippingRatesForCountry(country, orderAmount) {
|
|
|
932
1104
|
continue;
|
|
933
1105
|
applicableRates.push({
|
|
934
1106
|
id: rate.id,
|
|
1107
|
+
carrierId: zone.carrierId,
|
|
1108
|
+
carrierName: zone.carrier.name,
|
|
1109
|
+
carrierCode: zone.carrier.code,
|
|
935
1110
|
zoneName: zone.name,
|
|
936
1111
|
name: rate.name,
|
|
937
1112
|
description: rate.description,
|
|
@@ -942,4 +1117,44 @@ export async function findShippingRatesForCountry(country, orderAmount) {
|
|
|
942
1117
|
}
|
|
943
1118
|
return applicableRates;
|
|
944
1119
|
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Find shipping options for checkout grouped by carrier.
|
|
1122
|
+
* This is the main function used by the pre-checkout flow.
|
|
1123
|
+
*
|
|
1124
|
+
* @param country - ISO country code (e.g., 'US', 'CA')
|
|
1125
|
+
* @param orderAmount - Order subtotal in dollars
|
|
1126
|
+
* @returns Shipping options grouped by carrier
|
|
1127
|
+
*/
|
|
1128
|
+
export async function findShippingOptionsForCountry(country, orderAmount) {
|
|
1129
|
+
const rates = await findShippingRatesForCountry(country, orderAmount);
|
|
1130
|
+
// Group by carrier
|
|
1131
|
+
const carrierMap = new Map();
|
|
1132
|
+
for (const rate of rates) {
|
|
1133
|
+
let group = carrierMap.get(rate.carrierId);
|
|
1134
|
+
if (!group) {
|
|
1135
|
+
group = {
|
|
1136
|
+
carrier: {
|
|
1137
|
+
id: rate.carrierId,
|
|
1138
|
+
name: rate.carrierName,
|
|
1139
|
+
code: rate.carrierCode,
|
|
1140
|
+
},
|
|
1141
|
+
options: [],
|
|
1142
|
+
};
|
|
1143
|
+
carrierMap.set(rate.carrierId, group);
|
|
1144
|
+
}
|
|
1145
|
+
group.options.push({
|
|
1146
|
+
id: rate.id,
|
|
1147
|
+
carrierId: rate.carrierId,
|
|
1148
|
+
carrierName: rate.carrierName,
|
|
1149
|
+
carrierCode: rate.carrierCode,
|
|
1150
|
+
name: rate.name,
|
|
1151
|
+
description: rate.description ?? undefined,
|
|
1152
|
+
price: rate.price,
|
|
1153
|
+
estimatedDays: rate.estimatedDays ?? undefined,
|
|
1154
|
+
source: 'manual',
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
// Convert to array and sort by carrier name
|
|
1158
|
+
return Array.from(carrierMap.values()).sort((a, b) => a.carrier.name.localeCompare(b.carrier.name));
|
|
1159
|
+
}
|
|
945
1160
|
//# sourceMappingURL=queries.js.map
|