Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ed9856a
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
37deaf7
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
eddcf38
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
a3fed48
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
66307b8
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
4be8d89
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
0f2fc61
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
3a516c1
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
00b81f6
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
eec5092
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
a14708c
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
2ad6d5f
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
cb331d4
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
031d4ad
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
99cb9e5
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
a08a50e
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
3c01002
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
f4d066a
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
085e882
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
6ed3437
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
d823fc7
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
bff9cef
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
3357080
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
3b70edf
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
214ffe6
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
bba3f9a
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
68484ca
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
d28cd2c
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
4fb2211
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
c7a9cf8
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
0f1811c
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
ccee7fe
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
797d7a2
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
77888be
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
779b6d7
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
c2f07de
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
3b0b073
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
5eccc6d
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
6563594
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
9d963b9
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
ad74ed8
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
399ef8b
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
2685ae9
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
dd0ed43
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
8375cf0
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
3119d40
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
28b67ed
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
bc2610a
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
79e5a20
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
71b62e0
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
6dd5b62
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
2d2a508
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
91c1d50
chore: retrigger flaky CodeQL on TSM-08
Justintime50 Aug 11, 2026
e32f599
TSM-10: convert Group E services to TypeScript
Justintime50 Aug 7, 2026
6aa90f7
TSM-10: add permissive create parameter types for Group E services
Justintime50 Aug 11, 2026
1bea24c
TSM-10: convert Group E tests and beta referral service to TypeScript
Justintime50 Aug 11, 2026
9935d40
TSM-10: convert remaining service test harness files to TypeScript
Justintime50 Aug 11, 2026
6e40e66
TSM-10: add source-derived fixture type assertions in tests
Justintime50 Aug 11, 2026
6cc671f
TSM-10: simplify ESM module default typing in compat test
Justintime50 Aug 11, 2026
d4521d6
Type service returns for group E services
Justintime50 Aug 12, 2026
552d812
Format remaining TS service tests
Justintime50 Aug 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ import util from 'util';

import Constants from '../constants';
import FilteringError from '../errors/general/filtering_error';
import ApiKey from '../models/api_key';
import baseService from './base_service';

type ApiKeyUser = Record<string, unknown> & {
id?: string;
keys?: ApiKey[];
children?: Array<Record<string, unknown> & { id?: string; keys?: ApiKey[] }>;
};
type ApiKeyAllResponse = Record<string, unknown>;

export default (easypostClient) =>
/**
* The ApiKeyService class provides methods for interacting with EasyPost {@link ApiKey} objects.
Expand All @@ -17,20 +25,20 @@ export default (easypostClient) =>
* @returns {Array} - List of associated API Keys.
* @throws {FilteringError} If user or API Keys are not found.
*/
static async retrieveApiKeysForUser(id) {
static async retrieveApiKeysForUser(id: string): Promise<ApiKey[]> {
const url = `api_keys`;

try {
const response = await easypostClient._get(url);
const user = this._convertToEasyPostObject(response.body);
const user = this._convertToEasyPostObject(response.body) as ApiKeyUser;

if (user.id == id) {
return user.keys;
return user.keys ?? [];
}

user.children.forEach((child) => {
user.children?.forEach((child) => {
if (child.id == id) {
return child.keys;
return child.keys ?? [];
}
});
} catch (e) {
Expand All @@ -45,7 +53,7 @@ export default (easypostClient) =>
* See {@link https://docs.easypost.com/docs/api-keys#retrieve-an-api-key EasyPost API Documentation} for more information.
* @returns {Object} - An object containing the API keys associated with the current authenticated user and its child users.
*/
static async all(params = {}) {
static async all(params: Record<string, unknown> = {}): Promise<ApiKeyAllResponse> {
const url = 'api_keys';

return this._all(url, params);
Expand All @@ -57,7 +65,7 @@ export default (easypostClient) =>
* @param {string} mode - The mode for the API key (either "production" or "test").
* @returns {ApiKey} - The created API key.
*/
static async create(mode) {
static async create(mode: string): Promise<ApiKey> {
const url = 'api_keys';
const params = { mode };

Expand All @@ -70,7 +78,7 @@ export default (easypostClient) =>
* @param {string} id - The ID of the API key to delete.
* @returns {Promise|Promise<never>} - A promise that resolves if the API key was successfully deleted.
*/
static async delete(id) {
static async delete(id: string): Promise<void> {
const url = `api_keys/${id}`;

try {
Expand All @@ -88,7 +96,7 @@ export default (easypostClient) =>
* @param {string} id - The ID of the API key to enable.
* @returns {ApiKey} - The enabled API key.
*/
static async enable(id) {
static async enable(id: string): Promise<ApiKey> {
const url = `api_keys/${id}/enable`;

try {
Expand All @@ -106,7 +114,7 @@ export default (easypostClient) =>
* @param {string} id - The ID of the API key to disable.
* @returns {ApiKey} - The disabled API key.
*/
static async disable(id) {
static async disable(id: string): Promise<ApiKey> {
const url = `api_keys/${id}/disable`;

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import baseService from './base_service';

type BetaPaymentMethodResponse = Record<string, unknown>;
type BetaRefundResponse = Record<string, unknown>;
type BetaClientSecretResponse = Record<string, unknown>;

export default (easypostClient) =>
class BetaReferralCustomerService extends baseService(easypostClient) {
/**
Expand All @@ -9,7 +13,11 @@ export default (easypostClient) =>
* @param {string} [priority] - Which priority to set the payment method to ('primary' or 'secondary').
* @returns {Object} - A JSON object representing the payment method.
*/
static async addPaymentMethod(stripeCustomerId, paymentMethodReference, priority = 'primary') {
static async addPaymentMethod(
stripeCustomerId: string,
paymentMethodReference: string,
priority: string = 'primary',
): Promise<BetaPaymentMethodResponse> {
const params = {
payment_method: {
stripe_customer_id: stripeCustomerId,
Expand All @@ -30,7 +38,7 @@ export default (easypostClient) =>
* @param {number} refundAmount - Amount to be refunded by cents.
* @returns {Object} - A JSON object representing the refund.
*/
static async refundByAmount(refundAmount) {
static async refundByAmount(refundAmount: number): Promise<BetaRefundResponse> {
const params = {
refund_amount: refundAmount,
};
Expand All @@ -47,7 +55,7 @@ export default (easypostClient) =>
* @param {string} paymentLogId - ID of the payment log.
* @returns {object} - Returns BetaPaymentRefund object.
*/
static async refundByPaymentLog(paymentLogId) {
static async refundByPaymentLog(paymentLogId: string): Promise<BetaRefundResponse> {
const params = {
payment_log_id: paymentLogId,
};
Expand All @@ -63,7 +71,7 @@ export default (easypostClient) =>
* Creates a client secret to use with Stripe when adding a credit card.
* @returns {object} - A JSON object representing the client secret.
*/
static async createCreditCardClientSecret() {
static async createCreditCardClientSecret(): Promise<BetaClientSecretResponse> {
const url = 'beta/setup_intents';

const response = await easypostClient._post(url, null);
Expand All @@ -75,7 +83,9 @@ export default (easypostClient) =>
* Creates a client secret to use with Stripe when adding a credit card.
* @returns {object} - A JSON object representing the client secret.
*/
static async createBankAccountClientSecret(returnUrl) {
static async createBankAccountClientSecret(
returnUrl: string | null,
): Promise<BetaClientSecretResponse> {
const params = returnUrl ? { return_url: returnUrl } : null;

const url = 'beta/financial_connections_sessions';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import baseService from './base_service';
import type { ICustomerPortalAccountLink } from '../../types/CustomerPortal/CustomerPortalAccountLink';

type CustomerPortalAccountLinkCreateParameters = Record<string, unknown> & {
session_type?: 'account_onboarding' | 'account_management' | null;
user_id?: string | null;
refresh_url?: string | null;
return_url?: string | null;
metadata?: Record<string, unknown> | null;
};

export default (easypostClient) =>
/**
Expand All @@ -11,7 +20,9 @@ export default (easypostClient) =>
* @param {Object} [params] - The parameters to create a session from.
* @returns {Object} - An object containing the created session.
*/
static async createAccountLink(params = {}) {
static async createAccountLink(
params: CustomerPortalAccountLinkCreateParameters = {},
): Promise<ICustomerPortalAccountLink> {
const url = 'customer_portal/account_link';

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import baseService from './base_service';
import type { IEmbeddablesSession } from '../../types/Embeddable/EmbeddablesSession';

type EmbeddablesSessionCreateParameters = Record<string, unknown> & {
origin_host?: string | null;
user_id?: string | null;
};

export default (easypostClient) =>
/**
Expand All @@ -11,7 +17,9 @@ export default (easypostClient) =>
* @param {Object} [params] - The parameters to create a session from.
* @returns {Object} - An object containing the created session.
*/
static async createSession(params = {}) {
static async createSession(
params: EmbeddablesSessionCreateParameters = {},
): Promise<IEmbeddablesSession> {
const url = 'embeddables/session';

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import baseService from './base_service';
import EndShipper from '../models/end_shipper';

type EndShipperCreateParameters = Record<string, unknown> & {
name?: string | null;
company?: string | null;
street1?: string | null;
street2?: string | null;
city?: string | null;
state?: string | null;
zip?: string | null;
country?: string | null;
phone?: string | null;
email?: string | null;
};
type EndShipperListResponse = { end_shippers: EndShipper[]; has_more: boolean };

export default (easypostClient) =>
/**
Expand All @@ -12,7 +27,7 @@ export default (easypostClient) =>
* @param {Object} params - Parameters for the end shipper to be created.
* @returns {EndShipper} - The created end shipper.
*/
static async create(params) {
static async create(params: EndShipperCreateParameters): Promise<EndShipper> {
const url = 'end_shippers';
const wrappedParams = { address: params };

Expand All @@ -26,7 +41,7 @@ export default (easypostClient) =>
* @param {Object} params - Parameters for the end shipper to be updated.
* @returns {EndShipper} - The updated end shipper.
*/
static async update(id, params) {
static async update(id: string, params: EndShipperCreateParameters): Promise<EndShipper> {
const url = `end_shippers/${id}`;
const wrappedParams = { address: params };

Expand All @@ -45,7 +60,7 @@ export default (easypostClient) =>
* @param {string} id - The ID of the end shipper to retrieve.
* @returns {EndShipper} - The retrieved end shipper.
*/
static async retrieve(id) {
static async retrieve(id: string): Promise<EndShipper> {
const url = `end_shippers/${id}`;

return this._retrieve(url);
Expand All @@ -57,7 +72,7 @@ export default (easypostClient) =>
* @param {Object} [params] - Parameters to filter the list of end shippers.
* @returns {Object} - An object containing a list of {@link EndShipper end shippers} and pagination information.
*/
static async all(params = {}) {
static async all(params: Record<string, unknown> = {}): Promise<EndShipperListResponse> {
const url = 'end_shippers';

return this._all(url, params);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { v4 as uuid } from 'uuid';

import type {
IFedExAccountValidationResponse,
IFedExRequestPinResponse,
} from '../../types/FedExRegistration/FedExRegistration';
import baseService from './base_service';

type FedExValidationMap = Record<string, unknown> & { name?: string | null };
type FedExParams = Record<string, unknown> & {
address_validation?: FedExValidationMap;
pin_validation?: FedExValidationMap;
invoice_validation?: FedExValidationMap;
easypost_details?: Record<string, unknown>;
};

export default (easypostClient) =>
/**
* The FedExRegistrationService class provides methods for registering FedEx carrier accounts with MFA.
Expand All @@ -14,7 +26,10 @@ export default (easypostClient) =>
* @param {Object} params - Map of parameters.
* @returns {Object}
*/
static async registerAddress(fedexAccountNumber, params) {
static async registerAddress(
fedexAccountNumber: string,
params: FedExParams,
): Promise<IFedExAccountValidationResponse> {
const wrappedParams = this._wrapAddressValidation(params);
const endpoint = `fedex_registrations/${fedexAccountNumber}/address`;

Expand All @@ -33,7 +48,11 @@ export default (easypostClient) =>
* @param {Object} params - Map of parameters.
* @returns {Object}
*/
static async requestPin(fedexAccountNumber, pinMethodOption, params) {
static async requestPin(
fedexAccountNumber: string,
pinMethodOption: string,
params: FedExParams,
): Promise<IFedExRequestPinResponse> {
const wrappedParams = this._wrapPinValidation(params);
wrappedParams.pin_method = {
option: pinMethodOption,
Expand All @@ -54,7 +73,10 @@ export default (easypostClient) =>
* @param {Object} params - Map of parameters.
* @returns {Object}
*/
static async validatePin(fedexAccountNumber, params) {
static async validatePin(
fedexAccountNumber: string,
params: FedExParams,
): Promise<IFedExAccountValidationResponse> {
const wrappedParams = this._wrapPinValidation(params);
const endpoint = `fedex_registrations/${fedexAccountNumber}/pin/validate`;

Expand All @@ -72,7 +94,10 @@ export default (easypostClient) =>
* @param {Object} params - Map of parameters.
* @returns {Object}
*/
static async submitInvoice(fedexAccountNumber, params) {
static async submitInvoice(
fedexAccountNumber: string,
params: FedExParams,
): Promise<IFedExAccountValidationResponse> {
const wrappedParams = this._wrapInvoiceValidation(params);
const endpoint = `fedex_registrations/${fedexAccountNumber}/invoice`;

Expand All @@ -91,8 +116,8 @@ export default (easypostClient) =>
* @param {Object} params - The original parameters map.
* @returns {Object} - A new map with properly wrapped address_validation and easypost_details.
*/
static _wrapAddressValidation(params) {
const wrappedParams = {};
static _wrapAddressValidation(params: FedExParams): Record<string, unknown> {
const wrappedParams: Record<string, unknown> = {};

if (params.address_validation) {
const addressValidation = { ...params.address_validation };
Expand All @@ -114,8 +139,8 @@ export default (easypostClient) =>
* @param {Object} params - The original parameters map.
* @returns {Object} - A new map with properly wrapped pin_validation and easypost_details.
*/
static _wrapPinValidation(params) {
const wrappedParams = {};
static _wrapPinValidation(params: FedExParams): Record<string, unknown> {
const wrappedParams: Record<string, unknown> = {};

if (params.pin_validation) {
const pinValidation = { ...params.pin_validation };
Expand All @@ -137,8 +162,8 @@ export default (easypostClient) =>
* @param {Object} params - The original parameters map.
* @returns {Object} - A new map with properly wrapped invoice_validation and easypost_details.
*/
static _wrapInvoiceValidation(params) {
const wrappedParams = {};
static _wrapInvoiceValidation(params: FedExParams): Record<string, unknown> {
const wrappedParams: Record<string, unknown> = {};

if (params.invoice_validation) {
const invoiceValidation = { ...params.invoice_validation };
Expand All @@ -160,7 +185,7 @@ export default (easypostClient) =>
* @private
* @param {Object} map - The map to ensure the "name" field in.
*/
static _ensureNameField(map) {
static _ensureNameField(map: FedExValidationMap): void {
if (!map.name || map.name === null) {
const uuidValue = uuid().replace(/-/g, '');
map.name = uuidValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import baseService from './base_service';
import type { ILumaPromise } from '../../types/Luma/Luma';

type LumaParams = Record<string, unknown>;

export default (easypostClient) =>
/**
Expand All @@ -11,7 +14,7 @@ export default (easypostClient) =>
* @param {Object} params - The parameters to get a Luma promise with.
* @returns {Object} - An object containing the Luma promise.
*/
static async getPromise(params) {
static async getPromise(params: LumaParams): Promise<ILumaPromise> {
const url = `luma/promise`;

const wrappedParams = {
Expand Down
Loading