Skip to content

Commit d69dbfb

Browse files
committed
reverse refactor of connector id generation
1 parent c76eb46 commit d69dbfb

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/data-connect/data-connect-api-client-internal.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
import { PrefixedFirebaseError } from '../utils/error';
2424
import * as utils from '../utils/index';
2525
import * as validator from '../utils/validator';
26-
import { DataConnectService } from './data-connect';
2726
import { ConnectorConfig, ExecuteGraphqlResponse, GraphqlOptions } from './data-connect-api';
2827

2928
const API_VERSION = 'v1alpha';
@@ -201,7 +200,7 @@ export class DataConnectApiClient {
201200
operationName: options.operationName,
202201
extensions: { impersonate: options.impersonate },
203202
};
204-
const connectorId = DataConnectService.getId(this.connectorConfig);
203+
const connectorId = `${this.connectorConfig.location}-${this.connectorConfig.serviceId}`;
205204
const url = await this.getUrl(
206205
API_VERSION,
207206
this.connectorConfig.location,

src/data-connect/data-connect.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ export class DataConnectService {
3333
this.appInternal = app;
3434
}
3535

36-
static getId(connectorConfig: ConnectorConfig): string {
37-
return `${connectorConfig.location}-${connectorConfig.serviceId}`;
38-
}
39-
4036
getDataConnect(connectorConfig: ConnectorConfig): DataConnect {
41-
const id = DataConnectService.getId(connectorConfig);
37+
const id = `${connectorConfig.location}-${connectorConfig.serviceId}`;
4238
const dc = this.dataConnectInstances.get(id);
4339
if (typeof dc !== 'undefined') {
4440
return dc;

test/unit/data-connect/data-connect-api-client-internal.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { DATA_CONNECT_ERROR_CODE_MAPPING, DataConnectApiClient, FirebaseDataConn
2929
import { FirebaseApp } from '../../../src/app/firebase-app';
3030
import { ConnectorConfig, GraphqlOptions } from '../../../src/data-connect';
3131
import { getMetricsHeader, getSdkVersion } from '../../../src/utils';
32-
import { DataConnectService } from '../../../src/data-connect/data-connect';
3332

3433
describe('DataConnectApiClient', () => {
3534

@@ -311,7 +310,7 @@ describe('DataConnectApiClient', () => {
311310
expect(resp.data.users).to.deep.equal(TEST_RESPONSE.data.users);
312311
expect(stub).to.have.been.calledOnce.and.calledWith({
313312
method: 'POST',
314-
url: `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${DataConnectService.getId(connectorConfig)}:impersonateQuery`,
313+
url: `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${connectorConfig.location}-${connectorConfig.serviceId}:impersonateQuery`,
315314
headers: EXPECTED_HEADERS,
316315
data: {
317316
operationName: unauthenticatedOptions.operationName,
@@ -330,7 +329,7 @@ describe('DataConnectApiClient', () => {
330329
.then(() => {
331330
expect(stub).to.have.been.calledOnce.and.calledWith({
332331
method: 'POST',
333-
url: `http://localhost:9399/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${DataConnectService.getId(connectorConfig)}:impersonateQuery`,
332+
url: `http://localhost:9399/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${connectorConfig.location}-${connectorConfig.serviceId}:impersonateQuery`,
334333
headers: EMULATOR_EXPECTED_HEADERS,
335334
data: {
336335
operationName: unauthenticatedOptions.operationName,
@@ -420,7 +419,7 @@ describe('DataConnectApiClient', () => {
420419
expect(resp.data.users).to.deep.equal(TEST_RESPONSE.data.users);
421420
expect(stub).to.have.been.calledOnce.and.calledWith({
422421
method: 'POST',
423-
url: `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${DataConnectService.getId(connectorConfig)}:impersonateMutation`,
422+
url: `https://firebasedataconnect.googleapis.com/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${connectorConfig.location}-${connectorConfig.serviceId}:impersonateMutation`,
424423
headers: EXPECTED_HEADERS,
425424
data: {
426425
operationName: unauthenticatedOptions.operationName,
@@ -439,7 +438,7 @@ describe('DataConnectApiClient', () => {
439438
.then(() => {
440439
expect(stub).to.have.been.calledOnce.and.calledWith({
441440
method: 'POST',
442-
url: `http://localhost:9399/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${DataConnectService.getId(connectorConfig)}:impersonateMutation`,
441+
url: `http://localhost:9399/v1alpha/projects/test-project/locations/${connectorConfig.location}/services/${connectorConfig.serviceId}/connectors/${connectorConfig.location}-${connectorConfig.serviceId}:impersonateMutation`,
443442
headers: EMULATOR_EXPECTED_HEADERS,
444443
data: {
445444
operationName: unauthenticatedOptions.operationName,

0 commit comments

Comments
 (0)