Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,17 +3,17 @@
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 = () =>

Check warning on line 9 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
new Client({
urlPrefix: dataconnectOrigin(),
apiVersion: DATACONNECT_API_VERSION,
auth: true,
});

export async function listLocations(projectId: string): Promise<string[]> {

Check warning on line 16 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const res = await dataconnectClient().get<{
locations: {
name: string;
Expand All @@ -30,14 +30,14 @@
return res.body;
}

export async function listAllServices(projectId: string): Promise<types.Service[]> {

Check warning on line 33 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const res = await dataconnectClient().get<{ services: types.Service[] }>(
`/projects/${projectId}/locations/-/services`,
);
return res.body.services ?? [];
}

export async function createService(

Check warning on line 40 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
projectId: string,
locationId: string,
serviceId: string,
Expand Down Expand Up @@ -72,13 +72,13 @@
return pollRes;
}

export async function deleteServiceAndChildResources(serviceName: string): Promise<void> {

Check warning on line 75 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const connectors = await listConnectors(serviceName);
await Promise.all(connectors.map(async (c) => deleteConnector(c.name)));
try {
await deleteSchema(serviceName);
} catch (err: any) {

Check warning on line 80 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err.status !== 404) {

Check warning on line 81 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw err;
}
}
Expand All @@ -87,14 +87,14 @@

/** Schema methods */

export async function getSchema(serviceName: string): Promise<types.Schema | undefined> {

Check warning on line 90 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
try {
const res = await dataconnectClient().get<types.Schema>(
`${serviceName}/schemas/${types.SCHEMA_ID}`,
);
return res.body;
} catch (err: any) {

Check warning on line 96 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err.status !== 404) {

Check warning on line 97 in src/dataconnect/client.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
throw err;
}
return undefined;
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
Loading