Skip to content

Commit 2e80935

Browse files
authored
Merge branch 'master' into jh-idx-hax
2 parents 8e1378c + 4712d8f commit 2e80935

File tree

10 files changed

+226
-91
lines changed

10 files changed

+226
-91
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- Fixed version for init genkit. Previously it was looking for the version of the old package 'genkit' instead of th new 'genkit-cli'.
2+
- Updated the Firebase Data Connect local toolkit to v2.3.1, which contains the following changes: (#8455)
3+
- Added support for `inc` and `dec` update transforms for `Date` and `Timestamp` scalars.
4+
- Fixed a bug where `OR` and `AND` clauses may be evaluated in the incorrect order.
5+
- Fixed an issue where `{includes: $var}` or `{includesAll: [$var]}` clauses should be dropped if `$var` is missing.

firebase-vscode/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## Next
1+
## NEXT
2+
3+
## 1.3.0
4+
5+
- [Fixed] Fixed an issue where adhoc operations would fail to execute
26

37
## 1.2.0
48

firebase-vscode/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firebase-vscode/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"publisher": "GoogleCloudTools",
55
"icon": "./resources/firebase_dataconnect_logo.png",
66
"description": "Firebase Data Connect for VSCode",
7-
"version": "1.2.0",
7+
"version": "1.3.0",
88
"engines": {
99
"vscode": "^1.69.0"
1010
},

firebase-vscode/src/data-connect/execution/execution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export function registerExecution(
276276
operationName: ast.name?.value,
277277
// We send the compiled GQL from the whole connector to support fragments
278278
// In the case of adhoc operation, just send the sole document
279-
query: gqlText ?? document,
279+
query: gqlText || document,
280280
variables: executionArgsJSON.value,
281281
path: documentPath,
282282
instance,

firebase-vscode/src/data-connect/service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class DataConnectService {
3737
private authService: AuthService,
3838
private dataConnectToolkit: DataConnectToolkit,
3939
private emulatorsController: EmulatorsController,
40-
) {}
40+
) { }
4141

4242
async servicePath(
4343
path: string
@@ -90,7 +90,7 @@ export class DataConnectService {
9090
const errorResponse =
9191
response as ClientResponse<ExecuteGraphqlResponseError>;
9292
throw new DataConnectError(
93-
`Prod Request failed with status ${response.status}\nMessage ${errorResponse?.body?.error?.message}`,
93+
`Prod Request failed with status ${response.status}\nError Response: ${JSON.stringify(errorResponse?.body)}`,
9494
);
9595
}
9696
const successResponse = response as ClientResponse<ExecuteGraphqlResponse>;
@@ -106,7 +106,7 @@ export class DataConnectService {
106106
const errorResponse =
107107
response as ClientResponse<ExecuteGraphqlResponseError>;
108108
throw new DataConnectError(
109-
`Emulator Request failed with status ${response.status}\nMessage ${errorResponse?.body?.error?.message}`,
109+
`Emulator Request failed with status ${response.status}\nError Response: ${JSON.stringify(errorResponse?.body)}`,
110110
);
111111
}
112112
const successResponse = response as ClientResponse<ExecuteGraphqlResponse>;
@@ -117,7 +117,7 @@ export class DataConnectService {
117117
*
118118
* If the JSON is invalid, will throw.
119119
*/
120-
private _serializeBody(body: { variables?: string; [key: string]: unknown }) {
120+
private _serializeBody(body: { variables?: string;[key: string]: unknown }) {
121121
if (!body.variables || body.variables.trim().length === 0) {
122122
body.variables = undefined;
123123
return JSON.stringify(body);
@@ -190,7 +190,7 @@ export class DataConnectService {
190190
});
191191
const resp = await fetch(
192192
(await this.dataConnectToolkit.getFDCToolkitURL()) +
193-
`/v1/projects/p/locations/l/services/${serviceId}:executeGraphqlRead`,
193+
`/v1/projects/p/locations/l/services/${serviceId}:executeGraphqlRead`,
194194
{
195195
method: "POST",
196196
headers: {
@@ -266,7 +266,7 @@ function parseVariableString(variables: string): Record<string, any> {
266266
}
267267
try {
268268
return JSON.parse(variables);
269-
} catch(e: any) {
269+
} catch (e: any) {
270270
throw new Error(
271271
"Unable to parse variables as JSON. Double check that that there are no unmatched braces or quotes, or unqouted keys in the variables pane."
272272
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { browser, expect } from "@wdio/globals";
2+
import {
3+
ExecutionPanel,
4+
HistoryItem,
5+
} from "../../utils/page_objects/execution";
6+
import { firebaseSuite, firebaseTest } from "../../utils/test_hooks";
7+
import { EditorView } from "../../utils/page_objects/editor";
8+
import {
9+
mockProject,
10+
mutationsPath,
11+
queriesPath,
12+
queryWithFragmentPath,
13+
} from "../../utils/projects";
14+
import { FirebaseCommands } from "../../utils/page_objects/commands";
15+
import { FirebaseSidebar } from "../../utils/page_objects/sidebar";
16+
import { mockUser } from "../../utils/user";
17+
import { Workbench, Notification } from "wdio-vscode-service";
18+
import { Notifications } from "../../utils/page_objects/notifications";
19+
import path from "path";
20+
21+
firebaseSuite("Execution", async function () {
22+
firebaseTest(
23+
"should be able to start emulator and execute operation",
24+
async function () {
25+
const workbench = await browser.getWorkbench();
26+
27+
const sidebar = new FirebaseSidebar(workbench);
28+
await sidebar.openExtensionSidebar();
29+
30+
const commands = new FirebaseCommands();
31+
await commands.waitForUser();
32+
33+
await mockUser({ email: "[email protected]" });
34+
await mockProject("test-project");
35+
36+
const execution = new ExecutionPanel(workbench);
37+
const editor = new EditorView(workbench);
38+
39+
// Click run local while emulator is not started
40+
await editor.openFile(mutationsPath);
41+
await editor.runLocalButton.waitForDisplayed();
42+
await editor.runLocalButton.click();
43+
44+
// get start emulator notification
45+
const notificationUtil = new Notifications(workbench);
46+
const startEmulatorsNotif =
47+
await notificationUtil.getStartEmulatorNotification();
48+
expect(startEmulatorsNotif).toExist();
49+
50+
console.log(
51+
"Starting emulators from local execution. Waiting for emulators to start...",
52+
);
53+
54+
await commands.waitForEmulators();
55+
56+
const current = await sidebar.currentEmulators();
57+
expect(current).toContain("dataconnect :9399");
58+
await browser.pause(4000); // strange case where emulators are showing before actually callable
59+
60+
// Test 1 - Execute adhoc read data
61+
62+
// Open the schema file
63+
const schemaFilePath = path.join(
64+
__dirname,
65+
"..",
66+
"..",
67+
"test_projects",
68+
"fishfood",
69+
"dataconnect",
70+
"schema",
71+
"schema.gql",
72+
);
73+
await editor.openFile(schemaFilePath);
74+
75+
// Verify that inline Read Data button is displayed
76+
const readDataButton = await editor.readDataButton;
77+
await readDataButton.waitForDisplayed();
78+
79+
// Click the Read Data button
80+
await readDataButton.click();
81+
82+
// Wait a bit for the query to be generated
83+
await browser.pause(5000);
84+
85+
// Verify the generated query
86+
const activeEditor = await editor.getActiveEditor();
87+
const editorTitle = activeEditor?.document.fileName.split("/").pop();
88+
const editorContent = await editor.activeEditorContent();
89+
90+
expect(editorContent).toHaveText(`query {
91+
posts{
92+
id
93+
content
94+
}
95+
}`);
96+
// file should be created, saved, then opened
97+
expect(activeEditor?.document.isDirty).toBe(false);
98+
99+
await editor.runLocalButton.waitForDisplayed();
100+
await editor.runLocalButton.click();
101+
102+
async function getExecutionStatus(name: string) {
103+
await browser.pause(1000);
104+
let item = await execution.history.getSelectedItem();
105+
let status = await item.getStatus();
106+
let label = await item.getLabel();
107+
while (status === "pending" && label !== name) {
108+
await browser.pause(1000);
109+
item = await execution.history.getSelectedItem();
110+
status = await item.getStatus();
111+
}
112+
return item;
113+
}
114+
115+
// Check the history entry
116+
const item3 = await getExecutionStatus("anonymous");
117+
expect(await item3.getLabel()).toBe("anonymous");
118+
expect(await item3.getStatus()).toBe("success");
119+
await editor.closeAllEditors();
120+
},
121+
);
122+
});

scripts/publish/firebase-docker-image/cloudbuild.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ steps:
1313
entrypoint: "sh"
1414
args:
1515
- "-c"
16-
- "docker build -t us-central1-docker.pkg.dev/$PROJECT_ID/us/firebase:$(cat /workspace/version_number.txt) -t us-central1-docker.pkg.dev/$PROJECT_ID/us/firebase:latest -f ./Dockerfile ."
16+
- "docker build -t us-docker.pkg.dev/$PROJECT_ID/us/firebase:$(cat /workspace/version_number.txt) -t us-docker.pkg.dev/$PROJECT_ID/us/firebase:latest -f ./Dockerfile ."
1717

1818
images:
19-
- "us-central1-docker.pkg.dev/$PROJECT_ID/us/firebase"
19+
- "us-docker.pkg.dev/$PROJECT_ID/us/firebase"

src/emulator/downloadableEmulators.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ const EMULATOR_UPDATE_DETAILS: { [s in DownloadableEmulators]: EmulatorUpdateDet
5959
dataconnect:
6060
process.platform === "darwin" // macos
6161
? {
62-
version: "2.2.0",
63-
expectedSize: 26538752,
64-
expectedChecksum: "15304de22f04e51db155b1c76229e3f3",
62+
version: "2.3.1",
63+
expectedSize: 27271936,
64+
expectedChecksum: "5ffcfe584c5af818477a00eb6450dd66",
6565
}
6666
: process.platform === "win32" // windows
6767
? {
68-
version: "2.2.0",
69-
expectedSize: 26982912,
70-
expectedChecksum: "a7677c4dfe78275eab7320b1ff777e9e",
68+
version: "2.3.1",
69+
expectedSize: 27729408,
70+
expectedChecksum: "b71f1686724e8e051810b3a2e14c6d08",
7171
}
7272
: {
73-
version: "2.2.0", // linux
74-
expectedSize: 26452120,
75-
expectedChecksum: "ef332cc135bc05e43121020e5c1fef09",
73+
version: "2.3.1", // linux
74+
expectedSize: 27185304,
75+
expectedChecksum: "54c40731f4563073404591ef1ffcdc20",
7676
},
7777
};
7878

0 commit comments

Comments
 (0)