17
17
18
18
import * as validator from '../utils/validator' ;
19
19
import { FirebaseEventarcError , toCloudEventProtoFormat } from './eventarc-utils' ;
20
- import { Eventarc , Channel } from './eventarc' ;
20
+ import { App } from '../app' ;
21
+ import { Channel } from './eventarc' ;
21
22
import {
22
23
HttpRequestConfig , HttpClient , HttpError , AuthorizedHttpClient
23
24
} from '../utils/api-request' ;
@@ -43,21 +44,21 @@ export class EventarcApiClient {
43
44
private projectId ?: string ;
44
45
private readonly resolvedChannelName : Promise < string > ;
45
46
46
- constructor ( private readonly eventarc : Eventarc , private readonly channel : Channel ) {
47
- if ( ! validator . isNonNullObject ( eventarc . app ) || ! ( 'options' in eventarc . app ) ) {
47
+ constructor ( private readonly app : App , private readonly channel : Channel ) {
48
+ if ( ! validator . isNonNullObject ( app ) || ! ( 'options' in app ) ) {
48
49
throw new FirebaseEventarcError (
49
50
'invalid-argument' ,
50
- 'First argument passed to admin.appCheck () must be a valid Firebase app instance.' ) ;
51
+ 'First argument passed to Channel () must be a valid Eventarc service instance.' ) ;
51
52
}
52
- this . httpClient = new AuthorizedHttpClient ( eventarc . app as FirebaseApp ) ;
53
+ this . httpClient = new AuthorizedHttpClient ( app as FirebaseApp ) ;
53
54
this . resolvedChannelName = this . resolveChannelName ( channel . name ) ;
54
55
}
55
56
56
57
private getProjectId ( ) : Promise < string > {
57
58
if ( this . projectId ) {
58
59
return Promise . resolve ( this . projectId ) ;
59
60
}
60
- return utils . findProjectId ( this . eventarc . app )
61
+ return utils . findProjectId ( this . app )
61
62
. then ( ( projectId ) => {
62
63
if ( ! validator . isNonEmptyString ( projectId ) ) {
63
64
throw new FirebaseEventarcError (
@@ -153,4 +154,4 @@ export class EventarcApiClient {
153
154
const projectId = await this . getProjectId ( ) ;
154
155
return `projects/${ projectId } /locations/${ location } /channels/${ channelId } ` ;
155
156
}
156
- }
157
+ }
0 commit comments