@@ -1352,23 +1352,33 @@ export class AdminController extends Controller {
13521352 public async updateOrgPricingConfig (
13531353 @Request ( ) request : JawnAuthenticatedRequest ,
13541354 @Path ( ) orgId : string ,
1355- @Body ( ) body : { heliconePricingMultiplier : number }
1355+ @Body ( ) body : { endpointMultipliers : Record < string , number > }
13561356 ) : Promise < Result < null , string > > {
13571357 await authCheckThrow ( request . authParams . userId ) ;
13581358
1359- const { heliconePricingMultiplier } = body ;
1359+ const { endpointMultipliers } = body ;
13601360
1361- if (
1362- heliconePricingMultiplier < 0 ||
1363- heliconePricingMultiplier > 2 ||
1364- isNaN ( heliconePricingMultiplier )
1365- ) {
1366- return err ( "Pricing multiplier must be between 0 and 2" ) ;
1361+ // Validate each multiplier
1362+ for ( const [ endpoint , multiplier ] of Object . entries ( endpointMultipliers ) ) {
1363+ if ( multiplier < 0 || multiplier > 2 || isNaN ( multiplier ) ) {
1364+ return err ( `Invalid multiplier for ${ endpoint } : must be between 0 and 2` ) ;
1365+ }
1366+
1367+ // Validate endpoint key format (should contain colon)
1368+ if ( ! endpoint . includes ( ':' ) ) {
1369+ return err ( `Invalid endpoint key format: ${ endpoint } ` ) ;
1370+ }
13671371 }
13681372
13691373 const { error } = await dbExecute (
1370- `UPDATE organization SET pricing_config = jsonb_set(COALESCE(pricing_config, '{}'), '{heliconePricingMultiplier}', $1::text::jsonb) WHERE id = $2` ,
1371- [ heliconePricingMultiplier . toString ( ) , orgId ]
1374+ `UPDATE organization
1375+ SET pricing_config = jsonb_set(
1376+ COALESCE(pricing_config, '{}'),
1377+ '{endpointMultipliers}',
1378+ $1::jsonb
1379+ )
1380+ WHERE id = $2` ,
1381+ [ JSON . stringify ( endpointMultipliers ) , orgId ]
13721382 ) ;
13731383
13741384 if ( error ) {
0 commit comments