Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
64 changes: 32 additions & 32 deletions src/composables/node/useNodePricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,20 +966,20 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
displayPrice: pixversePricingCalculator
},
RecraftCreativeUpscaleNode: {
displayPrice: '$0.25/Run'
displayPrice: '$0.36/Run'
},
RecraftCrispUpscaleNode: {
displayPrice: '$0.004/Run'
displayPrice: '$0.006/Run'
},
RecraftGenerateColorFromImageNode: {
displayPrice: (node: LGraphNode): string => {
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -988,10 +988,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1000,10 +1000,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.08 x n/Run'
if (!nWidget) return '$0.11 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.08 * n).toFixed(2)
const cost = (0.11 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1012,10 +1012,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1024,28 +1024,28 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
RecraftRemoveBackgroundNode: {
displayPrice: '$0.01/Run'
displayPrice: '$0.014/Run'
},
RecraftReplaceBackgroundNode: {
displayPrice: '$0.04/Run'
displayPrice: '$0.057/Run'
},
RecraftTextToImageNode: {
displayPrice: (node: LGraphNode): string => {
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1054,10 +1054,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.08 x n/Run'
if (!nWidget) return '$0.11 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.08 * n).toFixed(2)
const cost = (0.11 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1066,10 +1066,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.01 x n/Run'
if (!nWidget) return '$0.014 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.01 * n).toFixed(2)
const cost = (0.014 * n).toFixed(3)
return `$${cost}/Run`
}
},
Expand Down Expand Up @@ -1209,16 +1209,16 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
) as IComboWidget

// If no length widget exists, default to 5s pricing
if (!lengthWidget) return '$1.50/Run'
if (!lengthWidget) return '$2.15/Run'

const length = String(lengthWidget.value)
if (length === '5s') {
return '$1.50/Run'
return '$2.15/Run'
} else if (length === '10s') {
return '$3.00/Run'
return '$4.29/Run'
}

return '$1.50/Run'
return '$2.15/Run'
}
},
MoonvalleyImg2VideoNode: {
Expand All @@ -1228,16 +1228,16 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
) as IComboWidget

// If no length widget exists, default to 5s pricing
if (!lengthWidget) return '$1.50/Run'
if (!lengthWidget) return '$2.15/Run'

const length = String(lengthWidget.value)
if (length === '5s') {
return '$1.50/Run'
return '$2.15/Run'
} else if (length === '10s') {
return '$3.00/Run'
return '$4.29/Run'
}

return '$1.50/Run'
return '$2.15/Run'
}
},
MoonvalleyVideo2VideoNode: {
Expand All @@ -1247,16 +1247,16 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
) as IComboWidget

// If no length widget exists, default to 5s pricing
if (!lengthWidget) return '$2.25/Run'
if (!lengthWidget) return '$3.22/Run'

const length = String(lengthWidget.value)
if (length === '5s') {
return '$2.25/Run'
return '$3.22/Run'
} else if (length === '10s') {
return '$4.00/Run'
return '$5.72/Run'
}

return '$2.25/Run'
return '$3.22/Run'
}
},
// Runway nodes - using actual node names from ComfyUI
Expand Down
14 changes: 7 additions & 7 deletions tests-ui/tests/composables/node/useNodePricing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.12/Run') // 0.04 * 3
expect(price).toBe('$0.17/Run') // 0.057 * 3
})

it('should calculate dynamic pricing for RecraftTextToVectorNode based on n value', () => {
Expand All @@ -1214,15 +1214,15 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.16/Run') // 0.08 * 2
expect(price).toBe('$0.22/Run') // 0.11 * 2
})

it('should fall back to static display when n widget is missing', () => {
const { getNodeDisplayPrice } = useNodePricing()
const node = createMockNode('RecraftTextToImageNode', [])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.04 x n/Run')
expect(price).toBe('$0.057 x n/Run')
})

it('should handle edge case when n value is 1', () => {
Expand All @@ -1232,7 +1232,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.04/Run') // 0.04 * 1
expect(price).toBe('$0.06/Run') // 0.057 * 1
})
})
})
Expand Down Expand Up @@ -1312,7 +1312,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.12/Run') // 0.04 * 3
expect(price).toBe('$0.17/Run') // 0.057 * 3
})

it('should calculate dynamic pricing for RecraftVectorizeImageNode', () => {
Expand All @@ -1322,7 +1322,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.05/Run') // 0.01 * 5
expect(price).toBe('$0.070/Run') // 0.014 * 5
})

it('should calculate dynamic pricing for RecraftGenerateVectorImageNode', () => {
Expand All @@ -1332,7 +1332,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.16/Run') // 0.08 * 2
expect(price).toBe('$0.22/Run') // 0.11 * 2
})
})

Expand Down