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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
- Add a confirmation in `firebase init dataconnect` before asking for app idea description. (#9282)
- [BREAKING] Removed deprecated `firebase --open-sesame` and `firebase --close-sesame` commands. Use `firebase experiments:enable` and `firebase experiments:disable` instead.
- [BREAKING] Enforce strict timeout validation for functions. (#9540)
- [BREAKING] Update `dataconnect:\*` commands to use flags instead of positional arguments for `--service` & `--location`. Changed output type of `dataconnect:sql:migrate --json` (#9312)
143 changes: 0 additions & 143 deletions firebase-vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/commands/dataconnect-execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as clc from "colorette";
import { Command } from "../command";
import { Options } from "../options";
import { getProjectId, needProjectId } from "../projectUtils";
import { pickService, readGQLFiles, squashGraphQL } from "../dataconnect/load";
import { pickOneService, readGQLFiles, squashGraphQL } from "../dataconnect/load";
import { requireAuth } from "../requireAuth";
import { Constants } from "../emulator/constants";
import { Client } from "../apiv2";
Expand Down Expand Up @@ -207,7 +207,12 @@ export const command = new Command("dataconnect:execute [file] [operationName]")
}

async function getServiceInfo(): Promise<ServiceInfo> {
return pickService(projectId, options.config, serviceId || undefined).catch((e) => {
return pickOneService(
projectId,
options.config,
serviceId || undefined,
locationId || undefined,
).catch((e: unknown) => {
if (!(e instanceof FirebaseError)) {
return Promise.reject(e);
}
Expand Down
26 changes: 20 additions & 6 deletions src/commands/dataconnect-sdk-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Command } from "../command";
import { Options } from "../options";
import { DataConnectEmulator } from "../emulator/dataconnectEmulator";
import { getProjectId } from "../projectUtils";
import { loadAll } from "../dataconnect/load";
import { pickServices } from "../dataconnect/load";
import { getProjectDefaultAccount } from "../auth";
import { logBullet, logLabeledSuccess, logWarning } from "../utils";
import { ServiceInfo } from "../dataconnect/types";
Expand All @@ -16,10 +16,18 @@ import { FirebaseError } from "../error";
import { postInitSaves } from "./init";
import { EmulatorHub } from "../emulator/hub";

type GenerateOptions = Options & { watch?: boolean };
type GenerateOptions = Options & { watch?: boolean; service?: string; location?: string };

export const command = new Command("dataconnect:sdk:generate")
.description("generate typed SDKs for your Data Connect connectors")
.description("generate typed SDKs to use Data Connect in your apps")
.option(
"--service <serviceId>",
"the serviceId of the Data Connect service. If not provided, generates SDKs for all services.",
)
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
)
.option(
"--watch",
"watch for changes to your connector GQL files and regenerate your SDKs when updates occur",
Expand Down Expand Up @@ -59,7 +67,7 @@ export const command = new Command("dataconnect:sdk:generate")
options.config = config;
}

let serviceInfosWithSDKs = await loadAllWithSDKs(projectId, config);
let serviceInfosWithSDKs = await loadAllWithSDKs(projectId, config, options);
if (!serviceInfosWithSDKs.length) {
if (justRanInit || options.nonInteractive) {
throw new FirebaseError(
Expand All @@ -82,7 +90,7 @@ export const command = new Command("dataconnect:sdk:generate")
await dataconnectSdkInit.askQuestions(setup);
await dataconnectSdkInit.actuate(setup, config);
justRanInit = true;
serviceInfosWithSDKs = await loadAllWithSDKs(projectId, config);
serviceInfosWithSDKs = await loadAllWithSDKs(projectId, config, options);
}

await generateSDKsInAll(options, serviceInfosWithSDKs, justRanInit);
Expand All @@ -91,8 +99,14 @@ export const command = new Command("dataconnect:sdk:generate")
async function loadAllWithSDKs(
projectId: string | undefined,
config: Config,
options: GenerateOptions,
): Promise<ServiceInfo[]> {
const serviceInfos = await loadAll(projectId || EmulatorHub.MISSING_PROJECT_PLACEHOLDER, config);
const serviceInfos = await pickServices(
projectId || EmulatorHub.MISSING_PROJECT_PLACEHOLDER,
config,
options.service,
options.location,
);
return serviceInfos.filter((serviceInfo) =>
serviceInfo.connectorInfo.some((c) => {
return (
Expand Down
24 changes: 18 additions & 6 deletions src/commands/dataconnect-sql-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,42 @@ import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { ensureApis } from "../dataconnect/ensureApis";
import { requirePermissions } from "../requirePermissions";
import { pickService } from "../dataconnect/load";
import { pickOneService } from "../dataconnect/load";
import { diffSchema } from "../dataconnect/schemaMigration";
import { requireAuth } from "../requireAuth";
import { mainSchema, mainSchemaYaml } from "../dataconnect/types";

export const command = new Command("dataconnect:sql:diff [serviceId]")
type DiffOptions = Options & { service?: string; location?: string };

export const command = new Command("dataconnect:sql:diff")
.description(
"display the differences between a local Data Connect schema and your CloudSQL database's current schema",
"display the differences between the local Data Connect schema and your CloudSQL database's schema",
)
.option("--service <serviceId>", "the serviceId of the Data Connect service")
.option(
"--location <location>",
"the location of the Data Connect service. Only needed if service ID is used in multiple locations.",
)
.before(requirePermissions, [
"firebasedataconnect.services.list",
"firebasedataconnect.schemas.list",
"firebasedataconnect.schemas.update",
])
.before(requireAuth)
.action(async (serviceId: string, options: Options) => {
.action(async (options: DiffOptions) => {
const projectId = needProjectId(options);
await ensureApis(projectId);
const serviceInfo = await pickService(projectId, options.config, serviceId);
const serviceInfo = await pickOneService(
projectId,
options.config,
options.service,
options.location,
);

const diffs = await diffSchema(
options,
mainSchema(serviceInfo.schemas),
mainSchemaYaml(serviceInfo.dataConnectYaml).datasource.postgresql?.schemaValidation,
);
return { projectId, serviceId, diffs };
return { projectId, diffs };
});
Loading
Loading