1- import * as functions from 'firebase-functions' ;
21import { Value } from '@sinclair/typebox/value' ;
32import {
43 CreateMediatorData ,
54 MediatorProfileExtended ,
65 UpdateMediatorStatusData ,
76} from '@deliberation-lab/utils' ;
8- import { onCall } from 'firebase-functions/v2/https' ;
7+ import { onCall , HttpsError } from 'firebase-functions/v2/https' ;
98
109import { app } from './app' ;
1110import { AuthGuard } from './utils/auth-guard' ;
@@ -23,7 +22,7 @@ export const updateMediatorStatus = onCall(async (request) => {
2322 await AuthGuard . isExperimenter ( request ) ;
2423
2524 if ( ! Value . Check ( UpdateMediatorStatusData , data ) ) {
26- throw new functions . https . HttpsError ( 'invalid-argument' , 'Invalid data' ) ;
25+ throw new HttpsError ( 'invalid-argument' , 'Invalid data' ) ;
2726 }
2827
2928 const mediatorDoc = app
@@ -36,7 +35,7 @@ export const updateMediatorStatus = onCall(async (request) => {
3635 await app . firestore ( ) . runTransaction ( async ( transaction ) => {
3736 const snapshot = await mediatorDoc . get ( ) ;
3837 if ( ! snapshot . exists ) {
39- throw new functions . https . HttpsError ( 'not-found' , 'Mediator not found' ) ;
38+ throw new HttpsError ( 'not-found' , 'Mediator not found' ) ;
4039 }
4140
4241 const mediator = snapshot . data ( ) as MediatorProfileExtended ;
@@ -59,7 +58,7 @@ export const createMediator = onCall(async (request) => {
5958 await AuthGuard . isExperimenter ( request ) ;
6059
6160 if ( ! Value . Check ( CreateMediatorData , data ) ) {
62- throw new functions . https . HttpsError ( 'invalid-argument' , 'Invalid data' ) ;
61+ throw new HttpsError ( 'invalid-argument' , 'Invalid data' ) ;
6362 }
6463
6564 const mediatorsInCohort = (
@@ -77,7 +76,7 @@ export const createMediator = onCall(async (request) => {
7776 ) ;
7877
7978 if ( existingMediator ) {
80- throw new functions . https . HttpsError (
79+ throw new HttpsError (
8180 'already-exists' ,
8281 'Mediator already assigned to cohort' ,
8382 ) ;
@@ -90,10 +89,7 @@ export const createMediator = onCall(async (request) => {
9089 ) ;
9190
9291 if ( ! mediator ) {
93- throw new functions . https . HttpsError (
94- 'not-found' ,
95- 'Agent mediator persona not found' ,
96- ) ;
92+ throw new HttpsError ( 'not-found' , 'Agent mediator persona not found' ) ;
9793 }
9894
9995 const mediatorDoc = app
0 commit comments