Skip to content

Commit

Permalink
Refactor/multiple type import fixes (#182)
Browse files Browse the repository at this point in the history
* Improve multiple type import patterns

* Change multiple missing imports

* Add missing import

---------

Co-authored-by: José Carneiro <[email protected]>
  • Loading branch information
josecarneiro and José Carneiro authored Feb 4, 2025
1 parent 503e08c commit 16af76e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/fixtures/coupon.samples.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Coupon } from '@epilot/pricing-client';
import { Coupon } from '../../types';

export const percentageDiscountCoupon: Coupon = {
_id: 'coupon#1',
Expand Down
4 changes: 1 addition & 3 deletions src/pricing.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { PriceItems, PriceItemsDto } from '@epilot/pricing-client';

import * as coupons from './__tests__/fixtures/coupon.samples';
import * as samples from './__tests__/fixtures/price.samples';
import * as results from './__tests__/fixtures/pricing.results';
Expand All @@ -14,7 +12,7 @@ import {
mapToPriceSnapshot,
mapToProductSnapshot,
} from './pricing';
import type { CompositePrice, CompositePriceItemDto, Price, PriceItemDto } from './types';
import type { CompositePrice, CompositePriceItemDto, Price, PriceItemDto, PriceItems, PriceItemsDto } from './types';

describe('computeAggregatedAndPriceTotals', () => {
describe('when is_composite_price = false', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/pricing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { CashbackAmount, PriceItems } from '@epilot/pricing-client';
import type { Currency } from 'dinero.js';

import { DEFAULT_CURRENCY } from './currencies';
Expand All @@ -9,13 +8,15 @@ import {
normalizeValueToFrequencyUnit,
} from './normalizers';
import type {
CashbackAmount,
CompositePriceItem,
CompositePriceItemDto,
ExternalFeeMapping,
Price,
PriceInputMapping,
PriceItem,
PriceItemDto,
PriceItems,
PriceItemsDto,
PricingDetails,
Product,
Expand Down
59 changes: 31 additions & 28 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import type { Components } from '@epilot/pricing-client';
export type {
Price,
PriceItem,
PriceItemDto,
Product,
Coupon,
PricingDetails,
PriceItems,
PriceItemsDto,
Tax,
TaxAmountDto,
TaxAmount,
CompositePrice,
CompositePriceItemDto,
CompositePriceItem,
EntityItem,
TaxAmountBreakdown,
RecurrenceAmount,
RecurrenceAmountWithTax,
BillingPeriod,
PriceInputMappings,
PriceInputMapping,
ExternalFeeMappings,
ExternalFeeMapping,
PriceTier,
PriceTierEnhanced,
PriceTierDisplayMode,
PriceGetAg,
CashbackAmount,
} from '@epilot/pricing-client';
import type { BillingPeriod } from '@epilot/pricing-client';

export type Price = Components.Schemas.Price;
export type PriceItem = Components.Schemas.PriceItem;
export type PriceItemDto = Components.Schemas.PriceItemDto;
export type Product = Components.Schemas.Product;
export type Coupon = Components.Schemas.Coupon;
export type PricingDetails = Components.Schemas.PricingDetails;
export type PriceItems = Components.Schemas.PriceItems;
export type PriceItemsDto = Components.Schemas.PriceItemsDto;
export type Tax = Components.Schemas.Tax;
export type TaxAmountDto = Components.Schemas.TaxAmountDto;
export type TaxAmount = Components.Schemas.TaxAmount;
export type CompositePrice = Components.Schemas.CompositePrice;
export type CompositePriceItemDto = Components.Schemas.CompositePriceItemDto;
export type CompositePriceItem = Components.Schemas.CompositePriceItem;
export type EntityItem = Components.Schemas.EntityItem;
export type TaxAmountBreakdown = Components.Schemas.TaxAmountBreakdown;
export type RecurrenceAmount = Components.Schemas.RecurrenceAmount;
export type RecurrenceAmountWithTax = Components.Schemas.RecurrenceAmountWithTax;
export type BillingPeriod = Components.Schemas.BillingPeriod;
export type PriceInputMappings = Components.Schemas.PriceInputMappings;
export type PriceInputMapping = Components.Schemas.PriceInputMapping;
export type ExternalFeeMappings = Components.Schemas.ExternalFeeMappings;
export type ExternalFeeMapping = Components.Schemas.ExternalFeeMapping;
export type TimeFrequency = Exclude<BillingPeriod, 'one_time'>;
export type PriceTier = Components.Schemas.PriceTier;
export type PriceTierEnhanced = Components.Schemas.PriceTierEnhanced;
export type PriceTierDisplayMode = Components.Schemas.PriceTierDisplayMode;
export type PriceGetAg = Components.Schemas.PriceGetAg;
5 changes: 2 additions & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ export const getTaxValue = (tax?: Tax | Array<Tax>) => {
* @param price the price object
* @returns true if the price is tax inclusive, false otherwise. defaults to true.
*/
export const isTaxInclusivePrice = (price?: Price): boolean => {
return price?.is_tax_inclusive ?? true;
};
export const isTaxInclusivePrice = (price?: Pick<Price, 'is_tax_inclusive'>): boolean =>
price?.is_tax_inclusive ?? true;

/**
* Gets the quantity for a specific tier.
Expand Down

0 comments on commit 16af76e

Please sign in to comment.