@trigger.dev/billing
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -1550,2 +1550,8 @@ import { z, ZodType } from 'zod'; | ||
type PlanCostResult = { | ||
runsCost: number; | ||
concurrentRunCost: number; | ||
total: number; | ||
}; | ||
type EstimateResult = { | ||
@@ -1555,3 +1561,3 @@ plan: { | ||
}; | ||
cost: number; | ||
cost: PlanCostResult; | ||
}; | ||
@@ -1558,0 +1564,0 @@ declare function estimate({ usage, plans, }: { |
@@ -179,3 +179,3 @@ // src/schemas/planDefinitions.ts | ||
} | ||
let total = 0; | ||
let concurrentRunCost = 0; | ||
if (plan.concurrentRuns !== void 0) { | ||
@@ -199,4 +199,5 @@ const concurrentUsage = usage["concurrent_runs"] ?? 0; | ||
}); | ||
total += result ?? 0; | ||
concurrentRunCost += result ?? 0; | ||
} | ||
let runsCost = 0; | ||
if (plan.runs !== void 0) { | ||
@@ -220,5 +221,9 @@ const runUsage = usage["runs"] ?? 0; | ||
}); | ||
total += (result == null ? void 0 : result.total) ?? 0; | ||
runsCost += (result == null ? void 0 : result.total) ?? 0; | ||
} | ||
return total; | ||
return { | ||
runsCost, | ||
concurrentRunCost, | ||
total: runsCost + concurrentRunCost | ||
}; | ||
} | ||
@@ -277,3 +282,3 @@ function calculateGraduatedCost({ | ||
const cost = planCost({ usage, plan }); | ||
if (cost !== void 0 && (result === void 0 || cost < result.cost)) { | ||
if (cost !== void 0 && (result === void 0 || cost.total < result.cost.total)) { | ||
result = { plan: { code: plan.code }, cost }; | ||
@@ -280,0 +285,0 @@ } |
{ | ||
"name": "@trigger.dev/billing", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Calculates the billing for a given organization", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162107
2329