-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fixed googleapis issue #9445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed googleapis issue #9445
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Fixes MCP server issue where `googleapis` is not available. (#9443) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { Client } from "../apiv2"; | ||
| import { cloudTestingOrigin } from "../api"; | ||
|
|
||
| export const API_VERSION = "v1"; | ||
|
|
||
| export const client = new Client({ | ||
| urlPrefix: cloudTestingOrigin(), | ||
| auth: true, | ||
| apiVersion: API_VERSION, | ||
| }); | ||
|
|
||
| type EnvironmentType = | ||
| | "ENVIRONMENT_TYPE_UNSPECIFIED" | ||
| | "ANDROID" | ||
| | "IOS" | ||
| | "NETWORK_CONFIGURATION" | ||
| | "PROVIDED_SOFTWARE" | ||
| | "DEVICE_IP_BLOCKS"; | ||
|
|
||
| type TestEnvironmentCatalog = unknown; | ||
|
|
||
| /** | ||
| * Gets the catalog of supported test environments. | ||
| */ | ||
| export async function testEnvironmentCatalog( | ||
| projectId: string, | ||
| environmentType: EnvironmentType, | ||
| ): Promise<unknown> { | ||
| const name = `testEnvironmentCatalog/${environmentType}`; | ||
|
|
||
| const queryParams: Record<string, string> = { projectId }; | ||
| const res = await client.get<TestEnvironmentCatalog>(name, { queryParams }); | ||
|
|
||
| return res.body; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,7 @@ import { tool } from "../../tool"; | |
| import { toContent } from "../../util"; | ||
| import { toAppName } from "../../../appdistribution/options-parser-util"; | ||
| import { AppDistributionClient } from "../../../appdistribution/client"; | ||
| import { google } from "googleapis"; | ||
| import { getAccessToken } from "../../../apiv2"; | ||
| import { testEnvironmentCatalog } from "../../../gcp/apptesting"; | ||
|
|
||
| const TestDeviceSchema = z | ||
| .object({ | ||
|
|
@@ -98,20 +97,20 @@ export const check_status = tool( | |
| title: "Check Remote Test", | ||
| readOnlyHint: true, | ||
| }, | ||
| _meta: { | ||
| requiresAuth: true, | ||
| requiresProject: true, | ||
| }, | ||
| }, | ||
| async ({ release_test_name, getAvailableDevices }) => { | ||
| async ({ release_test_name, getAvailableDevices }, { projectId }) => { | ||
| let devices = undefined; | ||
| let releaseTest = undefined; | ||
| if (release_test_name) { | ||
| const client = new AppDistributionClient(); | ||
| releaseTest = await client.getReleaseTest(release_test_name); | ||
| } | ||
| if (getAvailableDevices) { | ||
| const testing = google.testing("v1"); | ||
| devices = await testing.testEnvironmentCatalog.get({ | ||
| oauth_token: await getAccessToken(), | ||
| environmentType: "ANDROID", | ||
| }); | ||
| devices = await testEnvironmentCatalog(projectId || "", "ANDROID"); | ||
| } | ||
|
Comment on lines
112
to
114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing an empty string for if (getAvailableDevices) {
if (!projectId) {
throw new FirebaseError("Project ID is required to get available devices but is missing.");
}
devices = await testEnvironmentCatalog(projectId, "ANDROID");
} |
||
|
|
||
| return toContent({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
unknownforTestEnvironmentCatalogand the function's return type reduces type safety and makes the response harder to work with for consumers of this function. It would be beneficial to define a proper type for theTestEnvironmentCatalogbased on the expected API response structure. Even a partial type definition with aTODOto fill it out later would be an improvement overunknown.