Skip to content

Commit

Permalink
update data connect client, dataplaneclient, and emulator client to v… (
Browse files Browse the repository at this point in the history
#7589)

* update data connect client, dataplaneclient, and emulator client to v1beta

* update tests
  • Loading branch information
hlshen committed Sep 18, 2024
1 parent 8b6f994 commit c222f52
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 37 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- Added support for non-default Firestore databases in `firebase init`. (#7655)
- Update supported range for Angular framework. (#7418)
- Fix (Angular 17+) temporary change the PORT in Angular server.ts. (#6651)
- Updated supported range for Angular framework. (#7418)
- Fixed (Angular 17+) temporary change the PORT in Angular server.ts (#6651)
- Switched Data Connect API from `v1alpha` to `v1beta`. (#7589)
- Improved handling of Spark projects in `firebase init dataconnect`. (#7666)
6 changes: 2 additions & 4 deletions firebase-vscode/src/data-connect/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import {
IntrospectionQuery,
getIntrospectionQuery,
} from "graphql";
import { computed } from "@preact/signals-core";
import { assertExecutionResult } from "../../common/graphql";
import { DataConnectError } from "../../common/error";
import { AuthService } from "../auth/service";
import { UserMockKind } from "../../common/messaging/protocol";
import { firstWhereDefined } from "../utils/signal";
import { EmulatorsController } from "../core/emulators";
import { Emulators } from "../cli";
import { dataConnectConfigs } from "../data-connect/config";

import { firebaseRC } from "../core/config";
Expand Down Expand Up @@ -200,7 +198,7 @@ export class DataConnectService {
});
const resp = await fetch(
(await firstWhereDefined(this.emulatorsController.getLocalEndpoint())) +
`/v1alpha/projects/p/locations/l/services/${serviceId}:executeGraphqlRead`,
`/v1beta/projects/p/locations/l/services/${serviceId}:executeGraphqlRead`,
{
method: "POST",
headers: {
Expand Down Expand Up @@ -251,7 +249,7 @@ export class DataConnectService {
} else {
const resp = await fetch(
(await firstWhereDefined(this.emulatorsController.getLocalEndpoint())) +
`/v1alpha/${servicePath}:executeGraphql`,
`/v1beta/${servicePath}:executeGraphql`,
{
method: "POST",
headers: {
Expand Down
2 changes: 1 addition & 1 deletion scripts/dataconnect-test/templates/dataconnect.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
specVersion: "v1alpha"
specVersion: "v1beta"
serviceId: "__serviceId__"
location: "us-central1"
schema:
Expand Down
61 changes: 34 additions & 27 deletions src/dataconnect/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as nock from "nock";
import * as client from "./client";
import { dataconnectOrigin } from "../api";

const API_VERSION = "v1beta";
describe("DataConnect control plane client", () => {
afterEach(() => {
nock.cleanAll();
Expand All @@ -12,28 +13,30 @@ describe("DataConnect control plane client", () => {
it("Should delete all child resources", async () => {
const testService = "projects/test/locations/us-central1/services/test-service";
const fake = nock(dataconnectOrigin());
fake.get(`/v1alpha/${testService}/connectors?pageSize=100&pageToken=&fields=`).reply(200, {
connectors: [
{ name: `${testService}/connectors/c1` },
{ name: `${testService}/connectors/c2` },
],
});
fake
.delete(`/v1alpha/${testService}/connectors/c1`)
.get(`/${API_VERSION}/${testService}/connectors?pageSize=100&pageToken=&fields=`)
.reply(200, {
connectors: [
{ name: `${testService}/connectors/c1` },
{ name: `${testService}/connectors/c2` },
],
});
fake
.delete(`/${API_VERSION}/${testService}/connectors/c1`)
.reply(200, { name: "projects/test/operations/abc123" });
fake
.delete(`/v1alpha/${testService}/connectors/c2`)
.delete(`/${API_VERSION}/${testService}/connectors/c2`)
.reply(200, { name: "projects/test/operations/def456" });
fake
.delete(`/v1alpha/${testService}/schemas/main`)
.delete(`/${API_VERSION}/${testService}/schemas/main`)
.reply(200, { name: "projects/test/operations/ghi123" });
fake
.delete(`/v1alpha/${testService}`)
.delete(`/${API_VERSION}/${testService}`)
.reply(200, { name: "projects/test/operations/jkl456" });
fake.get("/v1alpha/projects/test/operations/abc123").reply(200, { done: true });
fake.get("/v1alpha/projects/test/operations/def456").reply(200, { done: true });
fake.get("/v1alpha/projects/test/operations/ghi123").reply(200, { done: true });
fake.get("/v1alpha/projects/test/operations/jkl456").reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/abc123`).reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/def456`).reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/ghi123`).reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/jkl456`).reply(200, { done: true });

await client.deleteServiceAndChildResources(testService);

Expand All @@ -43,17 +46,19 @@ describe("DataConnect control plane client", () => {
it("Succeed when there are no connectors", async () => {
const testService = "projects/test/locations/us-central1/services/test-service";
const fake = nock(dataconnectOrigin());
fake.get(`/v1alpha/${testService}/connectors?pageSize=100&pageToken=&fields=`).reply(200, {
connectors: [],
});
fake
.delete(`/v1alpha/${testService}/schemas/main`)
.get(`/${API_VERSION}/${testService}/connectors?pageSize=100&pageToken=&fields=`)
.reply(200, {
connectors: [],
});
fake
.delete(`/${API_VERSION}/${testService}/schemas/main`)
.reply(200, { name: "projects/test/operations/ghi123" });
fake
.delete(`/v1alpha/${testService}`)
.delete(`/${API_VERSION}/${testService}`)
.reply(200, { name: "projects/test/operations/jkl456" });
fake.get("/v1alpha/projects/test/operations/ghi123").reply(200, { done: true });
fake.get("/v1alpha/projects/test/operations/jkl456").reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/ghi123`).reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/jkl456`).reply(200, { done: true });

await client.deleteServiceAndChildResources(testService);

Expand All @@ -63,14 +68,16 @@ describe("DataConnect control plane client", () => {
it("Succeed when there is no schema", async () => {
const testService = "projects/test/locations/us-central1/services/test-service";
const fake = nock(dataconnectOrigin());
fake.get(`/v1alpha/${testService}/connectors?pageSize=100&pageToken=&fields=`).reply(200, {
connectors: [],
});
fake.delete(`/v1alpha/${testService}/schemas/main`).reply(404, {});
fake
.delete(`/v1alpha/${testService}`)
.get(`/${API_VERSION}/${testService}/connectors?pageSize=100&pageToken=&fields=`)
.reply(200, {
connectors: [],
});
fake.delete(`/${API_VERSION}/${testService}/schemas/main`).reply(404, {});
fake
.delete(`/${API_VERSION}/${testService}`)
.reply(200, { name: "projects/test/operations/jkl456" });
fake.get("/v1alpha/projects/test/operations/jkl456").reply(200, { done: true });
fake.get(`/${API_VERSION}/projects/test/operations/jkl456`).reply(200, { done: true });

await client.deleteServiceAndChildResources(testService);

Expand Down
2 changes: 1 addition & 1 deletion src/dataconnect/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Client } from "../apiv2";
import * as operationPoller from "../operation-poller";
import * as types from "./types";

const DATACONNECT_API_VERSION = "v1alpha";
const DATACONNECT_API_VERSION = "v1beta";
const PAGE_SIZE_MAX = 100;

const dataconnectClient = () =>
Expand Down
2 changes: 1 addition & 1 deletion src/dataconnect/dataplaneClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { dataconnectOrigin } from "../api";
import { Client } from "../apiv2";
import * as types from "./types";

const DATACONNECT_API_VERSION = "v1alpha";
const DATACONNECT_API_VERSION = "v1beta";

const dataconnectDataplaneClient = () =>
new Client({
Expand Down
2 changes: 1 addition & 1 deletion templates/init/dataconnect/dataconnect.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
specVersion: "v1alpha"
specVersion: "v1beta"
serviceId: __serviceId__
location: __location__
schema:
Expand Down

0 comments on commit c222f52

Please sign in to comment.