Skip to content

Commit

Permalink
fix: expose the types for Comparison input with multiple line items
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritesh Hirani committed Jan 12, 2024
1 parent 3495d0d commit 3b313ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/compareWithLabeled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
FieldResult,
LineItem,
LineItemFieldResults,
ComparisonInputWithMultipleValues,
ComparisonInputWithMultiPossibleValues,
} from './types'

type ComparisonResultWithoutAPS = Omit<ComparisonResult, 'APS'>
Expand Down Expand Up @@ -47,7 +47,7 @@ export const createMismatchComment = (
export const evaluateField = (
field: keyof ComparisonInput,
parsed: ComparisonInput,
labeled: ComparisonInputWithMultipleValues,
labeled: ComparisonInputWithMultiPossibleValues,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
comparator: ComparisonFn<any>,
comparatorOptions?: ComparisonOptions
Expand Down Expand Up @@ -122,7 +122,7 @@ export const evaluateArray = <T = unknown>(

export const evaluateCostsAddUp = (
parsed: ComparisonInput,
labeled: ComparisonInputWithMultipleValues
labeled: ComparisonInputWithMultiPossibleValues
): FieldResult => {
const expectedTotal = labeled?.totalAmount
if (!expectedTotal) return { match: null, comments: ['missing labeled total amount'] }
Expand Down Expand Up @@ -164,7 +164,7 @@ export const evaluateCostsAddUp = (

export const evaluateLineItemCount = (
parsed: ComparisonInput['lineItems'],
labeled: ComparisonInputWithMultipleValues['lineItems']
labeled: ComparisonInputWithMultiPossibleValues['lineItems']
): FieldResult => {
if (!parsed && !labeled) {
return {
Expand All @@ -188,7 +188,7 @@ export const evaluateLineItemCount = (

export const evaluateLineItemFields = (
parsed: ComparisonInput['lineItems'],
labeled: ComparisonInputWithMultipleValues['lineItems']
labeled: ComparisonInputWithMultiPossibleValues['lineItems']
): LineItemFieldResults => {
const result: LineItemFieldResults = {
lineItemName: { match: null },
Expand Down Expand Up @@ -320,7 +320,7 @@ export const compareWithLabeled = ({
labeled,
}: {
parsed: ComparisonInput
labeled: ComparisonInputWithMultipleValues
labeled: ComparisonInputWithMultiPossibleValues
}): ComparisonResult => {
const fieldResults: ComparisonResultWithoutAPS = {
status: evaluateField('status', parsed, labeled, compareOrderStatus),
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { compareWithLabeled } from './compareWithLabeled'
export { MatchKey, APS_FIELDS } from './constants'
export type { ComparisonInput, ComparisonResult, LineItemWithMultiPossibleValues } from './types'
export type {
ComparisonInput,
ComparisonInputWithMultiPossibleValues,
ComparisonResult,
LineItemWithMultiPossibleValues,
} from './types'
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type ComparisonInput = {
trackingNumbers: string[] | null
}

export type ComparisonInputWithMultipleValues = Omit<
export type ComparisonInputWithMultiPossibleValues = Omit<
ComparisonInput,
'lineItems' | 'merchantName'
> & {
Expand Down

0 comments on commit 3b313ec

Please sign in to comment.