@flexops/sdk 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,27 +52,20 @@ await client.auth.login({
52
52
  ### Rate Shopping
53
53
 
54
54
  ```typescript
55
+ const rateRequest = {
56
+ origin: { addressLine1: '123 Main St', city: 'New York', stateProvince: 'NY', postalCode: '10001' },
57
+ destination: { addressLine1: '456 Oak Ave', city: 'Los Angeles', stateProvince: 'CA', postalCode: '90210' },
58
+ package: { weight: 16, weightUnit: 'oz' },
59
+ };
60
+
55
61
  // Get all available rates
56
- const rates = await client.shipping.getRates({
57
- fromZip: '10001',
58
- toZip: '90210',
59
- weight: 16,
60
- weightUnit: 'oz',
61
- });
62
+ const rates = await client.shipping.getRates(rateRequest);
62
63
 
63
64
  // Get the single cheapest rate
64
- const cheapest = await client.shipping.getCheapestRate({
65
- fromZip: '10001',
66
- toZip: '90210',
67
- weight: 16,
68
- });
65
+ const cheapest = await client.shipping.getCheapestRate(rateRequest);
69
66
 
70
67
  // Get the single fastest rate
71
- const fastest = await client.shipping.getFastestRate({
72
- fromZip: '10001',
73
- toZip: '90210',
74
- weight: 16,
75
- });
68
+ const fastest = await client.shipping.getFastestRate(rateRequest);
76
69
  ```
77
70
 
78
71
  ### Create a Shipping Label
@@ -261,13 +254,13 @@ Every SDK method is a thin wrapper around the FlexOps REST API. If you want to v
261
254
 
262
255
  ```bash
263
256
  # Shop rates across all connected carriers
264
- curl -X POST https://gateway.flexops.io/api/workspaces/ws_abc123/shipping/rates \
257
+ curl -X POST https://gateway.flexops.io/api/shipping/rates \
265
258
  -H "X-API-Key: fxk_live_..." \
266
259
  -H "Content-Type: application/json" \
267
260
  -d '{
268
- "fromAddress": {"street1": "123 Main St", "city": "New York", "state": "NY", "zip": "10001", "country": "US"},
269
- "toAddress": {"street1": "456 Oak Ave", "city": "Los Angeles", "state": "CA", "zip": "90210", "country": "US"},
270
- "parcel": {"weight": 16, "weightUnit": "oz"}
261
+ "origin": {"addressLine1": "123 Main St", "city": "New York", "stateProvince": "NY", "postalCode": "10001", "countryCode": "US"},
262
+ "destination": {"addressLine1": "456 Oak Ave", "city": "Los Angeles", "stateProvince": "CA", "postalCode": "90210", "countryCode": "US"},
263
+ "package": {"weight": 16, "weightUnit": "oz"}
271
264
  }'
272
265
 
273
266
  # Create a label
package/dist/index.d.mts CHANGED
@@ -76,7 +76,20 @@ interface WorkspaceMember {
76
76
  role: 'Owner' | 'Admin' | 'Member' | 'Guest';
77
77
  joinedAt: string;
78
78
  }
79
- interface RateRequest {
79
+ type RateRequest = CanonicalRateRequest | LegacyRateRequest;
80
+ interface CanonicalRateRequest {
81
+ origin: ShippingAddress;
82
+ destination: ShippingAddress;
83
+ package: ShippingPackage;
84
+ carriers?: string[];
85
+ serviceLevels?: string[];
86
+ shipDate?: string;
87
+ includeInsurance?: boolean;
88
+ declaredValue?: number;
89
+ currency?: string;
90
+ }
91
+ /** @deprecated Use CanonicalRateRequest. The legacy shape is retained for source compatibility. */
92
+ interface LegacyRateRequest {
80
93
  fromZip: string;
81
94
  toZip: string;
82
95
  weight: number;
@@ -88,13 +101,43 @@ interface RateRequest {
88
101
  packageType?: string;
89
102
  carriers?: string[];
90
103
  }
104
+ interface ShippingAddress {
105
+ name?: string;
106
+ company?: string;
107
+ addressLine1: string;
108
+ addressLine2?: string;
109
+ city: string;
110
+ stateProvince: string;
111
+ postalCode: string;
112
+ countryCode?: string;
113
+ phone?: string;
114
+ email?: string;
115
+ isResidential?: boolean;
116
+ }
117
+ interface ShippingPackage {
118
+ weight: number;
119
+ weightUnit?: 'oz' | 'lb' | 'g' | 'kg';
120
+ length?: number;
121
+ width?: number;
122
+ height?: number;
123
+ dimensionUnit?: 'in' | 'cm';
124
+ predefinedPackage?: string;
125
+ }
91
126
  interface ShippingRate {
92
- carrier: string;
93
- service: string;
127
+ carrierCode: string;
128
+ carrierName: string;
129
+ serviceCode: string;
130
+ serviceName: string;
94
131
  rate: number;
95
132
  currency: string;
96
- estimatedDays: number;
97
- deliveryDate?: string;
133
+ estimatedDays?: number;
134
+ estimatedDeliveryDate?: string;
135
+ trackingIncluded?: boolean;
136
+ }
137
+ /** Response from a rate-shopping request (raw Gateway `RateShoppingResponse`). */
138
+ interface RateShoppingResponse {
139
+ rates: ShippingRate[];
140
+ currency: string;
98
141
  }
99
142
  interface CreateLabelRequest {
100
143
  carrier: string;
@@ -108,12 +151,15 @@ interface CreateLabelRequest {
108
151
  }
109
152
  interface Label {
110
153
  labelId: string;
154
+ carrierCode: string;
111
155
  trackingNumber: string;
112
- carrier: string;
113
- service: string;
114
156
  labelData: string;
115
157
  labelFormat: string;
116
158
  rate: number;
159
+ currency: string;
160
+ returnLabelData?: string;
161
+ orderId?: number;
162
+ isSandbox: boolean;
117
163
  createdAt: string;
118
164
  }
119
165
  interface Address {
@@ -574,19 +620,23 @@ declare class ShippingResource {
574
620
  constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
575
621
  private wsPath;
576
622
  /** Get shipping rates from all configured carriers. */
577
- getRates(request: RateRequest): Promise<ApiResponse<ShippingRate[]>>;
623
+ getRates(request: RateRequest): Promise<RateShoppingResponse>;
578
624
  /** Get the single cheapest rate across all carriers. */
579
- getCheapestRate(request: RateRequest): Promise<ApiResponse<ShippingRate>>;
625
+ getCheapestRate(request: RateRequest): Promise<ShippingRate>;
580
626
  /** Get the single fastest rate across all carriers. */
581
- getFastestRate(request: RateRequest): Promise<ApiResponse<ShippingRate>>;
582
- /** Create a shipping label. */
583
- createLabel(request: CreateLabelRequest): Promise<ApiResponse<Label>>;
584
- /** Cancel (void) a shipping label. */
585
- cancelLabel(labelId: string): Promise<ApiResponse<unknown>>;
627
+ getFastestRate(request: RateRequest): Promise<ShippingRate>;
628
+ /**
629
+ * Create a shipping label. Supply a `CreateLabelRequest` with `orderId` set to buy against an
630
+ * existing order — the order's ownership, status, ship-method and addresses are validated
631
+ * server-side and postage is settled atomically. Returns the raw label (HTTP 201).
632
+ */
633
+ createLabel(request: CreateLabelRequest): Promise<Label>;
634
+ /** Cancel (void) a shipping label. `carrierCode` is required. */
635
+ cancelLabel(labelId: string, carrierCode: string): Promise<unknown>;
586
636
  /** Track a shipment by tracking number. */
587
- track(trackingNumber: string): Promise<ApiResponse<TrackingInfo>>;
637
+ track(trackingNumber: string): Promise<TrackingInfo>;
588
638
  /** Validate and correct a shipping address. */
589
- validateAddress(address: Address): Promise<ApiResponse<AddressValidationResult>>;
639
+ validateAddress(address: Address): Promise<AddressValidationResult>;
590
640
  /** Create labels in batch. */
591
641
  createBatch(request: BatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
592
642
  /** Preview a batch without purchasing (dry-run). */
@@ -596,13 +646,13 @@ declare class ShippingResource {
596
646
  /** Download a label from a batch job. */
597
647
  downloadBatchLabel(jobId: string, itemId: string): Promise<Response>;
598
648
  /** List available carriers and their services. */
599
- getCarriers(): Promise<ApiResponse<unknown>>;
649
+ getCarriers(): Promise<unknown>;
600
650
  /** Get AI-ranked carrier recommendations for a lane, scored by cost, speed, and reliability. */
601
- getRecommendations(request: CarrierRecommendationRequest): Promise<ApiResponse<CarrierRecommendationResponse>>;
651
+ getRecommendations(request: CarrierRecommendationRequest): Promise<CarrierRecommendationResponse>;
602
652
  /** Predict delivery dates (P25/P50/P75/P95) for a carrier/service/lane combination. */
603
- predictDelivery(request: DeliveryPredictionRequest): Promise<ApiResponse<DeliveryPredictionResponse>>;
653
+ predictDelivery(request: DeliveryPredictionRequest): Promise<DeliveryPredictionResponse>;
604
654
  /** Get cost-saving opportunities: lanes where switching carriers saves money without sacrificing reliability. */
605
- getSavings(): Promise<ApiResponse<CostSavingsSummary>>;
655
+ getSavings(): Promise<CostSavingsSummary>;
606
656
  }
607
657
 
608
658
  /**
@@ -635,7 +685,7 @@ declare class CarriersResource {
635
685
  /** Search international prices. */
636
686
  getInternationalPrices: (body: unknown) => Promise<unknown>;
637
687
  /** Generate a domestic shipping label. */
638
- createDomesticLabel: (body: unknown) => Promise<unknown>;
688
+ createDomesticLabel: (body: unknown) => Promise<Label>;
639
689
  /** Generate a domestic return label. */
640
690
  createReturnLabel: (body: unknown) => Promise<unknown>;
641
691
  /** Generate an international shipping label. */
@@ -1145,10 +1195,9 @@ declare class ReportsResource {
1145
1195
  *
1146
1196
  * // Get shipping rates
1147
1197
  * const rates = await client.shipping.getRates({
1148
- * fromZip: '10001',
1149
- * toZip: '90210',
1150
- * weight: 16,
1151
- * weightUnit: 'oz',
1198
+ * origin: { addressLine1: '123 Main St', city: 'New York', stateProvince: 'NY', postalCode: '10001' },
1199
+ * destination: { addressLine1: '456 Oak Ave', city: 'Los Angeles', stateProvince: 'CA', postalCode: '90210' },
1200
+ * package: { weight: 16, weightUnit: 'oz' },
1152
1201
  * });
1153
1202
  *
1154
1203
  * // Create a label with the cheapest rate
@@ -1217,4 +1266,4 @@ declare class FlexOps {
1217
1266
  setApiKey(key: string): void;
1218
1267
  }
1219
1268
 
1220
- export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
1269
+ export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingAddress, type ShippingPackage, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
package/dist/index.d.ts CHANGED
@@ -76,7 +76,20 @@ interface WorkspaceMember {
76
76
  role: 'Owner' | 'Admin' | 'Member' | 'Guest';
77
77
  joinedAt: string;
78
78
  }
79
- interface RateRequest {
79
+ type RateRequest = CanonicalRateRequest | LegacyRateRequest;
80
+ interface CanonicalRateRequest {
81
+ origin: ShippingAddress;
82
+ destination: ShippingAddress;
83
+ package: ShippingPackage;
84
+ carriers?: string[];
85
+ serviceLevels?: string[];
86
+ shipDate?: string;
87
+ includeInsurance?: boolean;
88
+ declaredValue?: number;
89
+ currency?: string;
90
+ }
91
+ /** @deprecated Use CanonicalRateRequest. The legacy shape is retained for source compatibility. */
92
+ interface LegacyRateRequest {
80
93
  fromZip: string;
81
94
  toZip: string;
82
95
  weight: number;
@@ -88,13 +101,43 @@ interface RateRequest {
88
101
  packageType?: string;
89
102
  carriers?: string[];
90
103
  }
104
+ interface ShippingAddress {
105
+ name?: string;
106
+ company?: string;
107
+ addressLine1: string;
108
+ addressLine2?: string;
109
+ city: string;
110
+ stateProvince: string;
111
+ postalCode: string;
112
+ countryCode?: string;
113
+ phone?: string;
114
+ email?: string;
115
+ isResidential?: boolean;
116
+ }
117
+ interface ShippingPackage {
118
+ weight: number;
119
+ weightUnit?: 'oz' | 'lb' | 'g' | 'kg';
120
+ length?: number;
121
+ width?: number;
122
+ height?: number;
123
+ dimensionUnit?: 'in' | 'cm';
124
+ predefinedPackage?: string;
125
+ }
91
126
  interface ShippingRate {
92
- carrier: string;
93
- service: string;
127
+ carrierCode: string;
128
+ carrierName: string;
129
+ serviceCode: string;
130
+ serviceName: string;
94
131
  rate: number;
95
132
  currency: string;
96
- estimatedDays: number;
97
- deliveryDate?: string;
133
+ estimatedDays?: number;
134
+ estimatedDeliveryDate?: string;
135
+ trackingIncluded?: boolean;
136
+ }
137
+ /** Response from a rate-shopping request (raw Gateway `RateShoppingResponse`). */
138
+ interface RateShoppingResponse {
139
+ rates: ShippingRate[];
140
+ currency: string;
98
141
  }
99
142
  interface CreateLabelRequest {
100
143
  carrier: string;
@@ -108,12 +151,15 @@ interface CreateLabelRequest {
108
151
  }
109
152
  interface Label {
110
153
  labelId: string;
154
+ carrierCode: string;
111
155
  trackingNumber: string;
112
- carrier: string;
113
- service: string;
114
156
  labelData: string;
115
157
  labelFormat: string;
116
158
  rate: number;
159
+ currency: string;
160
+ returnLabelData?: string;
161
+ orderId?: number;
162
+ isSandbox: boolean;
117
163
  createdAt: string;
118
164
  }
119
165
  interface Address {
@@ -574,19 +620,23 @@ declare class ShippingResource {
574
620
  constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
575
621
  private wsPath;
576
622
  /** Get shipping rates from all configured carriers. */
577
- getRates(request: RateRequest): Promise<ApiResponse<ShippingRate[]>>;
623
+ getRates(request: RateRequest): Promise<RateShoppingResponse>;
578
624
  /** Get the single cheapest rate across all carriers. */
579
- getCheapestRate(request: RateRequest): Promise<ApiResponse<ShippingRate>>;
625
+ getCheapestRate(request: RateRequest): Promise<ShippingRate>;
580
626
  /** Get the single fastest rate across all carriers. */
581
- getFastestRate(request: RateRequest): Promise<ApiResponse<ShippingRate>>;
582
- /** Create a shipping label. */
583
- createLabel(request: CreateLabelRequest): Promise<ApiResponse<Label>>;
584
- /** Cancel (void) a shipping label. */
585
- cancelLabel(labelId: string): Promise<ApiResponse<unknown>>;
627
+ getFastestRate(request: RateRequest): Promise<ShippingRate>;
628
+ /**
629
+ * Create a shipping label. Supply a `CreateLabelRequest` with `orderId` set to buy against an
630
+ * existing order — the order's ownership, status, ship-method and addresses are validated
631
+ * server-side and postage is settled atomically. Returns the raw label (HTTP 201).
632
+ */
633
+ createLabel(request: CreateLabelRequest): Promise<Label>;
634
+ /** Cancel (void) a shipping label. `carrierCode` is required. */
635
+ cancelLabel(labelId: string, carrierCode: string): Promise<unknown>;
586
636
  /** Track a shipment by tracking number. */
587
- track(trackingNumber: string): Promise<ApiResponse<TrackingInfo>>;
637
+ track(trackingNumber: string): Promise<TrackingInfo>;
588
638
  /** Validate and correct a shipping address. */
589
- validateAddress(address: Address): Promise<ApiResponse<AddressValidationResult>>;
639
+ validateAddress(address: Address): Promise<AddressValidationResult>;
590
640
  /** Create labels in batch. */
591
641
  createBatch(request: BatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
592
642
  /** Preview a batch without purchasing (dry-run). */
@@ -596,13 +646,13 @@ declare class ShippingResource {
596
646
  /** Download a label from a batch job. */
597
647
  downloadBatchLabel(jobId: string, itemId: string): Promise<Response>;
598
648
  /** List available carriers and their services. */
599
- getCarriers(): Promise<ApiResponse<unknown>>;
649
+ getCarriers(): Promise<unknown>;
600
650
  /** Get AI-ranked carrier recommendations for a lane, scored by cost, speed, and reliability. */
601
- getRecommendations(request: CarrierRecommendationRequest): Promise<ApiResponse<CarrierRecommendationResponse>>;
651
+ getRecommendations(request: CarrierRecommendationRequest): Promise<CarrierRecommendationResponse>;
602
652
  /** Predict delivery dates (P25/P50/P75/P95) for a carrier/service/lane combination. */
603
- predictDelivery(request: DeliveryPredictionRequest): Promise<ApiResponse<DeliveryPredictionResponse>>;
653
+ predictDelivery(request: DeliveryPredictionRequest): Promise<DeliveryPredictionResponse>;
604
654
  /** Get cost-saving opportunities: lanes where switching carriers saves money without sacrificing reliability. */
605
- getSavings(): Promise<ApiResponse<CostSavingsSummary>>;
655
+ getSavings(): Promise<CostSavingsSummary>;
606
656
  }
607
657
 
608
658
  /**
@@ -635,7 +685,7 @@ declare class CarriersResource {
635
685
  /** Search international prices. */
636
686
  getInternationalPrices: (body: unknown) => Promise<unknown>;
637
687
  /** Generate a domestic shipping label. */
638
- createDomesticLabel: (body: unknown) => Promise<unknown>;
688
+ createDomesticLabel: (body: unknown) => Promise<Label>;
639
689
  /** Generate a domestic return label. */
640
690
  createReturnLabel: (body: unknown) => Promise<unknown>;
641
691
  /** Generate an international shipping label. */
@@ -1145,10 +1195,9 @@ declare class ReportsResource {
1145
1195
  *
1146
1196
  * // Get shipping rates
1147
1197
  * const rates = await client.shipping.getRates({
1148
- * fromZip: '10001',
1149
- * toZip: '90210',
1150
- * weight: 16,
1151
- * weightUnit: 'oz',
1198
+ * origin: { addressLine1: '123 Main St', city: 'New York', stateProvince: 'NY', postalCode: '10001' },
1199
+ * destination: { addressLine1: '456 Oak Ave', city: 'Los Angeles', stateProvince: 'CA', postalCode: '90210' },
1200
+ * package: { weight: 16, weightUnit: 'oz' },
1152
1201
  * });
1153
1202
  *
1154
1203
  * // Create a label with the cheapest rate
@@ -1217,4 +1266,4 @@ declare class FlexOps {
1217
1266
  setApiKey(key: string): void;
1218
1267
  }
1219
1268
 
1220
- export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
1269
+ export { type Address, type AddressValidationResult, AnalyticsResource, type ApiKeyInfo, ApiKeysResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateEmailTemplateRequest, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CreateWorkspaceRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, EmailTemplatesResource, type EmissionsEstimate, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, type HsCodeResult, HsCodesResource, type InsurancePolicy, type InsuranceQuote, InsuranceResource, InventoryResource, type Label, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LoginRequest, type LoginResponse, OffsetResource, type OffsetResult, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PickupConfirmation, type PickupRequest, PickupsResource, type RateRequest, type RecurringShipment, RecurringShipmentsResource, type RegisterRequest, type ReportSchedule, ReportsResource, type RetryConfig, type ReturnAuthorization, type ReturnItem, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingAddress, type ShippingPackage, type ShippingRate, ShippingResource, type ShippingRule, type TrackingEvent, type TrackingInfo, type UpdateEmailTemplateRequest, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type WalletBalance, WalletResource, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceMember, WorkspacesResource };
package/dist/index.js CHANGED
@@ -353,40 +353,46 @@ var ShippingResource = class {
353
353
  // -----------------------------------------------------------------------
354
354
  /** Get shipping rates from all configured carriers. */
355
355
  async getRates(request) {
356
- return this.http.post(this.wsPath("shipping/rates"), request);
356
+ return this.http.post("/api/shipping/rates", request);
357
357
  }
358
358
  /** Get the single cheapest rate across all carriers. */
359
359
  async getCheapestRate(request) {
360
- return this.http.post(this.wsPath("shipping/rates/cheapest"), request);
360
+ return this.http.post("/api/shipping/rates/cheapest", request);
361
361
  }
362
362
  /** Get the single fastest rate across all carriers. */
363
363
  async getFastestRate(request) {
364
- return this.http.post(this.wsPath("shipping/rates/fastest"), request);
364
+ return this.http.post("/api/shipping/rates/fastest", request);
365
365
  }
366
366
  // -----------------------------------------------------------------------
367
367
  // Labels
368
368
  // -----------------------------------------------------------------------
369
- /** Create a shipping label. */
369
+ /**
370
+ * Create a shipping label. Supply a `CreateLabelRequest` with `orderId` set to buy against an
371
+ * existing order — the order's ownership, status, ship-method and addresses are validated
372
+ * server-side and postage is settled atomically. Returns the raw label (HTTP 201).
373
+ */
370
374
  async createLabel(request) {
371
- return this.http.post(this.wsPath("shipping/labels"), request, void 0);
375
+ return this.http.post("/api/shipping/labels", request, void 0);
372
376
  }
373
- /** Cancel (void) a shipping label. */
374
- async cancelLabel(labelId) {
375
- return this.http.delete(this.wsPath(`shipping/labels/${labelId}`));
377
+ /** Cancel (void) a shipping label. `carrierCode` is required. */
378
+ async cancelLabel(labelId, carrierCode) {
379
+ return this.http.delete(
380
+ `/api/shipping/labels/${labelId}?carrierCode=${encodeURIComponent(carrierCode)}`
381
+ );
376
382
  }
377
383
  // -----------------------------------------------------------------------
378
384
  // Tracking
379
385
  // -----------------------------------------------------------------------
380
386
  /** Track a shipment by tracking number. */
381
387
  async track(trackingNumber) {
382
- return this.http.get(this.wsPath(`shipping/track/${trackingNumber}`));
388
+ return this.http.get(`/api/shipping/track/${encodeURIComponent(trackingNumber)}`);
383
389
  }
384
390
  // -----------------------------------------------------------------------
385
391
  // Address Validation
386
392
  // -----------------------------------------------------------------------
387
393
  /** Validate and correct a shipping address. */
388
394
  async validateAddress(address) {
389
- return this.http.post(this.wsPath("shipping/addresses/validate"), address);
395
+ return this.http.post("/api/shipping/addresses/validate", address);
390
396
  }
391
397
  // -----------------------------------------------------------------------
392
398
  // Batch Labels
@@ -412,22 +418,22 @@ var ShippingResource = class {
412
418
  // -----------------------------------------------------------------------
413
419
  /** List available carriers and their services. */
414
420
  async getCarriers() {
415
- return this.http.get(this.wsPath("shipping/carriers"));
421
+ return this.http.get("/api/shipping/carriers");
416
422
  }
417
423
  // -----------------------------------------------------------------------
418
424
  // AI Shipping — requires Professional plan or higher
419
425
  // -----------------------------------------------------------------------
420
426
  /** Get AI-ranked carrier recommendations for a lane, scored by cost, speed, and reliability. */
421
427
  async getRecommendations(request) {
422
- return this.http.post(this.wsPath("shipping/recommendations"), request);
428
+ return this.http.post("/api/shipping/recommendations", request);
423
429
  }
424
430
  /** Predict delivery dates (P25/P50/P75/P95) for a carrier/service/lane combination. */
425
431
  async predictDelivery(request) {
426
- return this.http.post(this.wsPath("shipping/predictions/delivery"), request);
432
+ return this.http.post("/api/shipping/predictions/delivery", request);
427
433
  }
428
434
  /** Get cost-saving opportunities: lanes where switching carriers saves money without sacrificing reliability. */
429
435
  async getSavings() {
430
- return this.http.get(this.wsPath("shipping/savings"));
436
+ return this.http.get("/api/shipping/savings");
431
437
  }
432
438
  };
433
439
 
@@ -460,7 +466,10 @@ var CarriersResource = class {
460
466
  /** Search international prices. */
461
467
  getInternationalPrices: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleInternationalPrices"), body),
462
468
  /** Generate a domestic shipping label. */
463
- createDomesticLabel: (body) => this.http.post(this.proxy("api/v3/Shipping/postUspsGenerateDomesticShippingLabel"), body),
469
+ // Domestic USPS labels go through the reliable order-based Gateway path
470
+ // (POST /api/shipping/labels): pass a LabelRequest body with carrierCode:'USPS'
471
+ // and orderId set — server-side order validation + atomic postage settlement.
472
+ createDomesticLabel: (body) => this.http.post("/api/shipping/labels", body),
464
473
  /** Generate a domestic return label. */
465
474
  createReturnLabel: (body) => this.http.post(this.proxy("api/v3/Shipping/postUspsGenerateDomesticReturnsShippingLabel"), body),
466
475
  /** Generate an international shipping label. */
package/dist/index.mjs CHANGED
@@ -311,40 +311,46 @@ var ShippingResource = class {
311
311
  // -----------------------------------------------------------------------
312
312
  /** Get shipping rates from all configured carriers. */
313
313
  async getRates(request) {
314
- return this.http.post(this.wsPath("shipping/rates"), request);
314
+ return this.http.post("/api/shipping/rates", request);
315
315
  }
316
316
  /** Get the single cheapest rate across all carriers. */
317
317
  async getCheapestRate(request) {
318
- return this.http.post(this.wsPath("shipping/rates/cheapest"), request);
318
+ return this.http.post("/api/shipping/rates/cheapest", request);
319
319
  }
320
320
  /** Get the single fastest rate across all carriers. */
321
321
  async getFastestRate(request) {
322
- return this.http.post(this.wsPath("shipping/rates/fastest"), request);
322
+ return this.http.post("/api/shipping/rates/fastest", request);
323
323
  }
324
324
  // -----------------------------------------------------------------------
325
325
  // Labels
326
326
  // -----------------------------------------------------------------------
327
- /** Create a shipping label. */
327
+ /**
328
+ * Create a shipping label. Supply a `CreateLabelRequest` with `orderId` set to buy against an
329
+ * existing order — the order's ownership, status, ship-method and addresses are validated
330
+ * server-side and postage is settled atomically. Returns the raw label (HTTP 201).
331
+ */
328
332
  async createLabel(request) {
329
- return this.http.post(this.wsPath("shipping/labels"), request, void 0);
333
+ return this.http.post("/api/shipping/labels", request, void 0);
330
334
  }
331
- /** Cancel (void) a shipping label. */
332
- async cancelLabel(labelId) {
333
- return this.http.delete(this.wsPath(`shipping/labels/${labelId}`));
335
+ /** Cancel (void) a shipping label. `carrierCode` is required. */
336
+ async cancelLabel(labelId, carrierCode) {
337
+ return this.http.delete(
338
+ `/api/shipping/labels/${labelId}?carrierCode=${encodeURIComponent(carrierCode)}`
339
+ );
334
340
  }
335
341
  // -----------------------------------------------------------------------
336
342
  // Tracking
337
343
  // -----------------------------------------------------------------------
338
344
  /** Track a shipment by tracking number. */
339
345
  async track(trackingNumber) {
340
- return this.http.get(this.wsPath(`shipping/track/${trackingNumber}`));
346
+ return this.http.get(`/api/shipping/track/${encodeURIComponent(trackingNumber)}`);
341
347
  }
342
348
  // -----------------------------------------------------------------------
343
349
  // Address Validation
344
350
  // -----------------------------------------------------------------------
345
351
  /** Validate and correct a shipping address. */
346
352
  async validateAddress(address) {
347
- return this.http.post(this.wsPath("shipping/addresses/validate"), address);
353
+ return this.http.post("/api/shipping/addresses/validate", address);
348
354
  }
349
355
  // -----------------------------------------------------------------------
350
356
  // Batch Labels
@@ -370,22 +376,22 @@ var ShippingResource = class {
370
376
  // -----------------------------------------------------------------------
371
377
  /** List available carriers and their services. */
372
378
  async getCarriers() {
373
- return this.http.get(this.wsPath("shipping/carriers"));
379
+ return this.http.get("/api/shipping/carriers");
374
380
  }
375
381
  // -----------------------------------------------------------------------
376
382
  // AI Shipping — requires Professional plan or higher
377
383
  // -----------------------------------------------------------------------
378
384
  /** Get AI-ranked carrier recommendations for a lane, scored by cost, speed, and reliability. */
379
385
  async getRecommendations(request) {
380
- return this.http.post(this.wsPath("shipping/recommendations"), request);
386
+ return this.http.post("/api/shipping/recommendations", request);
381
387
  }
382
388
  /** Predict delivery dates (P25/P50/P75/P95) for a carrier/service/lane combination. */
383
389
  async predictDelivery(request) {
384
- return this.http.post(this.wsPath("shipping/predictions/delivery"), request);
390
+ return this.http.post("/api/shipping/predictions/delivery", request);
385
391
  }
386
392
  /** Get cost-saving opportunities: lanes where switching carriers saves money without sacrificing reliability. */
387
393
  async getSavings() {
388
- return this.http.get(this.wsPath("shipping/savings"));
394
+ return this.http.get("/api/shipping/savings");
389
395
  }
390
396
  };
391
397
 
@@ -418,7 +424,10 @@ var CarriersResource = class {
418
424
  /** Search international prices. */
419
425
  getInternationalPrices: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleInternationalPrices"), body),
420
426
  /** Generate a domestic shipping label. */
421
- createDomesticLabel: (body) => this.http.post(this.proxy("api/v3/Shipping/postUspsGenerateDomesticShippingLabel"), body),
427
+ // Domestic USPS labels go through the reliable order-based Gateway path
428
+ // (POST /api/shipping/labels): pass a LabelRequest body with carrierCode:'USPS'
429
+ // and orderId set — server-side order validation + atomic postage settlement.
430
+ createDomesticLabel: (body) => this.http.post("/api/shipping/labels", body),
422
431
  /** Generate a domestic return label. */
423
432
  createReturnLabel: (body) => this.http.post(this.proxy("api/v3/Shipping/postUspsGenerateDomesticReturnsShippingLabel"), body),
424
433
  /** Generate an international shipping label. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexops/sdk",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "Official FlexOps Platform Node.js/TypeScript SDK — multi-carrier shipping, order management, and logistics API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
24
24
  "test": "vitest run",
25
25
  "test:watch": "vitest",
26
- "lint": "eslint src/ --ext .ts",
26
+ "lint": "eslint src/",
27
27
  "typecheck": "tsc --noEmit",
28
28
  "prepublishOnly": "npm run build"
29
29
  },
@@ -53,11 +53,13 @@
53
53
  "node": ">=18.0.0"
54
54
  },
55
55
  "devDependencies": {
56
+ "@eslint/js": "^10.0.1",
56
57
  "@openapitools/openapi-generator-cli": "^2.16.3",
57
- "@types/node": "^22.0.0",
58
- "eslint": "^9.0.0",
58
+ "@types/node": "^26.1.2",
59
+ "eslint": "^10.8.0",
59
60
  "tsup": "^8.4.0",
60
61
  "typescript": "^5.8.0",
61
- "vitest": "^3.1.0"
62
+ "typescript-eslint": "^8.65.0",
63
+ "vitest": "^4.1.10"
62
64
  }
63
65
  }