Skip to content

Commit fa7e2e4

Browse files
Justintime50claude
andcommitted
fix: Comprehensive TypeScript definitions audit and fixes
This commit addresses multiple issues with TypeScript definitions: ## Critical Fixes - Fix #515: Export ReferralCustomer property correctly - Add missing api_keys field to Referral interface - Consolidate duplicate Rate definitions (removed types/Shipment/Rate.d.ts) - Add missing exports: Claim, CustomerPortal, Embeddable, Luma, Referral, SmartRate - Add missing services to EasyPost client: Claim, CustomerPortal, Embeddable, Luma, SmartRate ## New Type Definitions - Create Luma type definitions (types/Luma/) - Create SmartRate index file - Create TaxIdentifier type definition for Shipment ## Type Corrections - Fix Pickup.instructions: now optional nullable - Fix Order properties: return_address, buyer_address, is_return now optional nullable - Add missing User.reference field - Fix typo: pickup_man_datetime → pickup_max_datetime - Standardize ScanForm.getNextPage() return type to use scan_forms - Standardize Referral.getNextPage() return type to use referral_customers ## Files Modified (12) - types/EasyPost.d.ts - types/Order/Order.d.ts - types/Pickup/Pickup.d.ts - types/Referral/Referral.d.ts - types/ScanForm/ScanForm.d.ts - types/Shipment/Options/Options.d.ts - types/Shipment/Shipment.d.ts - types/Shipment/ShipmentCreateParameters.d.ts - types/Shipment/index.d.ts - types/User/User.d.ts - types/index.d.ts ## Files Created (5) - types/Luma/Luma.d.ts - types/Luma/index.d.ts - types/SmartRate/index.d.ts - types/Shipment/TaxIdentifier.d.ts ## Files Deleted (1) - types/Shipment/Rate.d.ts (duplicate) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 65921d3 commit fa7e2e4

16 files changed

Lines changed: 117 additions & 88 deletions

File tree

types/EasyPost.d.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ import { Batch } from './Batch';
44
import { Billing } from './Billing';
55
import { Brand } from './Brand';
66
import { CarrierAccount, CarrierMetadata, CarrierType } from './Carrier';
7+
import { Claim } from './Claim';
8+
import { CustomerPortalAccountLink } from './CustomerPortal';
79
import { CustomsInfo, CustomsItem } from './Customs';
10+
import { EmbeddablesSession } from './Embeddable';
811
import { EndShipper } from './EndShipper';
912
import { Event } from './Event';
1013
import { Fee } from './Fee';
1114
import { Insurance } from './Insurance';
15+
import { Luma } from './Luma';
1216
import { Order } from './Order';
1317
import { Parcel } from './Parcel';
1418
import { PaymentMethod } from './PaymentMethod';
@@ -19,6 +23,7 @@ import { Refund } from './Refund';
1923
import { Report } from './Report';
2024
import { ScanForm } from './ScanForm';
2125
import { Shipment } from './Shipment';
26+
import { SmartRate } from './SmartRate';
2227
import { Tracker } from './Tracker';
2328
import { User } from './User';
2429
import { Utils } from './Utility';
@@ -77,22 +82,27 @@ export default class EasyPost {
7782
public CarrierAccount: typeof CarrierAccount;
7883
public CarrierMetadata: typeof CarrierMetadata;
7984
public CarrierType: typeof CarrierType;
85+
public Claim: typeof Claim;
86+
public CustomerPortal: typeof CustomerPortalAccountLink;
8087
public CustomsInfo: typeof CustomsInfo;
8188
public CustomsItem: typeof CustomsItem;
89+
public Embeddable: typeof EmbeddablesSession;
8290
public EndShipper: typeof EndShipper;
8391
public Event: typeof Event;
8492
public Fee: typeof Fee; // TODO: Fix IFee
8593
public Insurance: typeof Insurance;
94+
public Luma: typeof Luma;
8695
public Order: typeof Order;
8796
public Parcel: typeof Parcel;
8897
public PaymentMethod: typeof PaymentMethod;
8998
public Pickup: typeof Pickup;
9099
public Rate: typeof Rate;
91-
public Referral: typeof Referral;
100+
public ReferralCustomer: typeof Referral;
92101
public Refund: typeof Refund;
93102
public Report: typeof Report;
94103
public ScanForm: typeof ScanForm;
95104
public Shipment: typeof Shipment;
105+
public SmartRate: typeof SmartRate;
96106
public Tracker: typeof Tracker;
97107
public User: typeof User;
98108
public Utils: typeof Utils;

types/Luma/Luma.d.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Interface representing an EasyPost Luma promise object.
3+
*
4+
* @see https://docs.easypost.com/docs/luma
5+
*/
6+
export declare interface ILumaPromise {
7+
/** Always returns "LumaInfo". */
8+
object: string;
9+
10+
/** The delivery date and time commitment. */
11+
delivery_datetime: string | null;
12+
13+
/** The delivery date commitment. */
14+
delivery_date: string | null;
15+
16+
/** The pickup date and time commitment. */
17+
pickup_datetime: string | null;
18+
19+
/** The pickup date commitment. */
20+
pickup_date: string | null;
21+
22+
/** The carrier account used for the promise. */
23+
carrier_account_id: string | null;
24+
25+
/** The service level used for the promise. */
26+
service: string | null;
27+
28+
/** The carrier used for the promise. */
29+
carrier: string | null;
30+
}
31+
32+
/**
33+
* The Luma class interacts with the Luma API to provide service recommendations.
34+
*
35+
* @see https://docs.easypost.com/docs/luma
36+
*/
37+
export declare class Luma {
38+
/**
39+
* Get service recommendations from Luma that meet the criteria of your ruleset.
40+
*
41+
* @see https://docs.easypost.com/docs/luma
42+
*
43+
* @param params - The parameters to get a Luma promise with (shipment parameters).
44+
* @returns {Promise<ILumaPromise>} - An object containing the Luma promise.
45+
*/
46+
static getPromise(params: object): Promise<ILumaPromise>;
47+
}

types/Luma/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Luma';

types/Order/Order.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ export declare class Order implements IOrder {
6767
id: string;
6868
mode: 'test' | 'production';
6969
object: 'Order';
70-
reference?: string;
70+
reference?: string | null;
7171
to_address: IAddress;
7272
from_address: IAddress;
73-
return_address: IAddress;
74-
buyer_address: IAddress;
73+
return_address?: IAddress | null;
74+
buyer_address?: IAddress | null;
7575
shipments: IShipment[];
7676
rates: IRate[];
7777
messages: IMessage[];
78-
is_return: boolean;
78+
is_return?: boolean | null;
7979
created_at: string;
8080
updated_at: string;
8181

types/Pickup/Pickup.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export declare class Pickup implements IPickup {
101101
min_datetime: string;
102102
max_datetime: string;
103103
is_account_address?: boolean | null;
104-
instructions: string;
104+
instructions?: string | null;
105105
messages: IMessage[];
106106
confirmation: string;
107107
shipment: IShipment;

types/Referral/Referral.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { IApiKey } from '../ApiKey';
12
import { IUser } from '../User';
23
import { IReferralCreateParameters } from './ReferralCreateParameters';
34
import { IReferralListParameters } from './ReferralListParameters';
@@ -7,7 +8,14 @@ import { IReferralListParameters } from './ReferralListParameters';
78
*
89
* @see https://docs.easypost.com/docs/users/referral-customers
910
*/
10-
export declare interface IReferral extends IUser {}
11+
export declare interface IReferral extends IUser {
12+
/**
13+
* API keys for the referral customer (only returned on creation).
14+
* Contains both test and production API keys.
15+
* These keys should be saved securely as they cannot be retrieved again later.
16+
*/
17+
api_keys?: IApiKey[];
18+
}
1119

1220
export declare class Referral implements IReferral {
1321
public constructor(input: IReferralCreateParameters);
@@ -26,6 +34,7 @@ export declare class Referral implements IReferral {
2634
secondary_recharge_amount: string;
2735
recharge_threshold: string;
2836
children: IUser[];
37+
api_keys?: IApiKey[];
2938

3039
/**
3140
* Creates a referral customer.
@@ -111,5 +120,5 @@ export declare class Referral implements IReferral {
111120
static getNextPage(
112121
referralCustomers: Object,
113122
pageSize?: number,
114-
): Promise<{ referrals: Referral[]; has_more: boolean }>;
123+
): Promise<{ referral_customers: Referral[]; has_more: boolean }>;
115124
}

types/ScanForm/ScanForm.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ export declare class ScanForm implements IScanForm {
122122
static getNextPage(
123123
scanforms: Object,
124124
pageSize?: number,
125-
): Promise<{ scanforms: ScanForm[]; has_more: boolean }>;
125+
): Promise<{ scan_forms: ScanForm[]; has_more: boolean }>;
126126
}

types/Shipment/Options/Options.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export declare interface IOptions {
275275
/**
276276
* The latest a package should be picked up. Supported carriers vary.
277277
*/
278-
pickup_man_datetime: string | null;
278+
pickup_max_datetime: string | null;
279279

280280
/**
281281
* You can optionally print custom messages on labels.

types/Shipment/Rate.d.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

types/Shipment/Shipment.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IPostageLabel } from './PostageLabel';
1414
import { IRate } from './Rate';
1515
import { IShipmentCreateParameters } from './ShipmentCreateParameters';
1616
import { IShipmentListParameters } from './ShipmentListParameters';
17+
import { ITaxIdentifier } from './TaxIdentifier';
1718

1819
/**
1920
* The workhorse of the EasyPost API, a Shipment is made up of a "to" and "from" Address, the Parcel being shipped, and any customs forms required for international deliveries.
@@ -59,6 +60,11 @@ export declare interface IShipment extends IObjectWithId<'Shipment'>, IDatedObje
5960
*/
6061
customs_info?: ICustomsInfo | null;
6162

63+
/**
64+
* Tax identifiers for the shipment
65+
*/
66+
tax_identifiers?: ITaxIdentifier[];
67+
6268
/**
6369
* Document created to manifest and scan multiple shipments
6470
*/

0 commit comments

Comments
 (0)