Skip to content

Commit

Permalink
Merge branch 'master' into aalej-func-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan committed Apr 30, 2024
2 parents e7607fe + 3a23591 commit 3b6710e
Show file tree
Hide file tree
Showing 218 changed files with 15,093 additions and 6,615 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@ module.exports = {
"src/emulator/auth/schema.ts",
// TODO(hsubox76): Set up a job to run eslint separately on vscode dir
"firebase-vscode/",
// If this is leftover from "clean-install.sh", don't lint it
"clean/**",
],
};
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
- fix non static check for not-found route in Next.js 14.2 (#7012)
- Adds `*.local` to .gitignore and functions ignore for javascript,typescript, and python templates. (#7018)
- Adds `*.local` to .gitignore and functions ignore for `init functions`. (#7018)
40 changes: 18 additions & 22 deletions firebase-vscode/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
// "react"
],
"rules": {
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
// "react"
],
"rules": {
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
3 changes: 2 additions & 1 deletion firebase-vscode/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist/
resources/dist
.vscode-test
.wdio-vscode-service
logs
logs
!*.tgz
10 changes: 10 additions & 0 deletions firebase-vscode/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## The default
**/.git
**/.svn
**/.hg
**/node_modules

## The good stuff
dist
resources
package-lock.json
4 changes: 1 addition & 3 deletions firebase-vscode/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
"recommendations": ["dbaeumer.vscode-eslint"]
}
12 changes: 3 additions & 9 deletions firebase-vscode/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
Expand All @@ -25,9 +21,7 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/dist/test/**/*.js"
],
"outFiles": ["${workspaceFolder}/dist/test/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
Expand Down
5 changes: 4 additions & 1 deletion firebase-vscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ webpack.*.js
../
*.zip
node_modules/
dist/test/
dist/test/
*.tgz
package-lock.json
.wdio-vscode-service/
28 changes: 28 additions & 0 deletions firebase-vscode/common/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** An error thrown before the GraphQL operation could complete.
*
* This could include HTTP errors or JSON parsing errors.
*/
export class DataConnectError extends Error {
constructor(message: string, cause?: unknown) {
super(message, { cause });
}
}

/** Encode an error into a {@link SerializedError} */
export function toSerializedError(error: Error): SerializedError {
return {
name: error.name,
message: error.message,
stack: error.stack,
cause:
error.cause instanceof Error ? toSerializedError(error.cause) : undefined,
};
}

/** An error object that can be sent across webview boundaries */
export interface SerializedError {
name?: string;
message: string;
stack?: string;
cause?: SerializedError;
}
63 changes: 63 additions & 0 deletions firebase-vscode/common/graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { ExecutionResult, GraphQLError } from "graphql";

/** Asserts that an unknown object is a {@link ExecutionResult} */
export function assertExecutionResult(
response: any
): asserts response is ExecutionResult {
if (!response) {
throw new Error(`Expected ExecutionResult but got ${response}`);
}

const type = typeof response;
if (type !== "object") {
throw new Error(`Expected ExecutionResult but got ${type}`);
}

const { data, errors } = response;
if (!data && !errors) {
throw new Error(
`Expected ExecutionResult to have either "data" or "errors" set but none found`
);
}

if (errors) {
if (!Array.isArray(errors)) {
throw new Error(
`Expected errors to be an array but got ${typeof errors}`
);
}
for (const error of errors) {
assertGraphQLError(error);
}
}
}

export function isExecutionResult(response: any): response is ExecutionResult {
try {
assertExecutionResult(response);
return true;
} catch {
return false;
}
}

/** Asserts that an unknown object is a {@link GraphQLError} */
export function assertGraphQLError(
error: unknown
): asserts error is GraphQLError {
if (!error) {
throw new Error(`Expected GraphQLError but got ${error}`);
}

const type = typeof error;
if (type !== "object") {
throw new Error(`Expected GraphQLError but got ${type}`);
}

const { message } = error as GraphQLError;
if (typeof message !== "string") {
throw new Error(
`Expected GraphQLError to have "message" set but got ${typeof message}`
);
}
}
2 changes: 1 addition & 1 deletion firebase-vscode/common/messaging/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function createBroker<
on<E extends keyof IncomingMessages>(
message: Extract<E, string>,
listener: (params: IncomingMessages[E]) => void
) {
): () => void {
return broker.addListener(message, listener);
},
delete(): void {
Expand Down
73 changes: 61 additions & 12 deletions firebase-vscode/common/messaging/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ import { User } from "../../../src/types/auth";
import { ServiceAccountUser } from "../types";
import { RCData } from "../../../src/rc";
import { EmulatorUiSelections, RunningEmulatorInfo } from "./types";
import { ExecutionResult } from "graphql";
import { SerializedError } from "../error";

export const DEFAULT_EMULATOR_UI_SELECTIONS: EmulatorUiSelections = {
projectId: "demo-something",
importStateFolderPath: "",
exportStateOnExit: false,
mode: "dataconnect",
debugLogging: false,
};

export enum UserMockKind {
ADMIN = "admin",
UNAUTHENTICATED = "unauthenticated",
AUTHENTICATED = "authenticated",
}
export type UserMock =
| { kind: UserMockKind.ADMIN | UserMockKind.UNAUTHENTICATED }
| {
kind: UserMockKind.AUTHENTICATED;
claims: string;
};

export interface WebviewToExtensionParamsMap {
/**
Expand All @@ -17,6 +39,13 @@ export interface WebviewToExtensionParamsMap {
addUser: {};
logout: { email: string };

/* Emulator panel requests */
getEmulatorUiSelections: void;
getEmulatorInfos: void;
updateEmulatorUiSelections: Partial<EmulatorUiSelections>;
/* Equivalent to the `firebase emulators:start` command.*/
launchEmulators: void;

/** Notify extension that current user has been changed in UI. */
requestChangeUser: { user: User | ServiceAccountUser };

Expand Down Expand Up @@ -44,6 +73,9 @@ export interface WebviewToExtensionParamsMap {
*/
promptUserForInput: { title: string; prompt: string };

/** Calls the `firebase init` CLI */
runFirebaseInit: void;

/**
* Show a UI message using the vscode interface
*/
Expand All @@ -61,27 +93,45 @@ export interface WebviewToExtensionParamsMap {
href: string;
};

/**
* Equivalent to the `firebase emulators:start` command.
*/
launchEmulators: {
emulatorUiSelections: EmulatorUiSelections;
};

/** Stops the emulators gracefully allowing for data export if required. */
stopEmulators: {};
stopEmulators: void;

selectEmulatorImportFolder: {};

definedDataConnectArgs: string;

/** Prompts the user to select a directory in which to place the quickstart */
chooseQuickstartDir: {};

notifyAuthUserMockChange: UserMock;

/** Deploy connectors/services to production */
"fdc.deploy": void;

/** Deploy all connectors/services to production */
"fdc.deploy-all": void;
}

export interface DataConnectResults {
query: string;
displayName: string;
results?: ExecutionResult | SerializedError;
args?: string;
}

export type ValueOrError<T> =
| { value: T; error: undefined }
| { error: string; value: undefined };

export interface ExtensionToWebviewParamsMap {
/** Triggered when the emulator UI/state changes */
notifyEmulatorUiSelectionsChanged: EmulatorUiSelections;
notifyEmulatorStateChanged: {
status: "running" | "stopped" | "starting" | "stopping";
infos: RunningEmulatorInfo | undefined;
};
notifyEmulatorImportFolder: { folder: string };

/** Triggered when new environment variables values are found. */
notifyEnv: { env: { isMonospace: boolean } };

Expand Down Expand Up @@ -133,10 +183,9 @@ export interface ExtensionToWebviewParamsMap {
*/
notifyPreviewChannelResponse: { id: string };

notifyEmulatorsStopped: {};
notifyEmulatorStartFailed: {};
notifyRunningEmulatorInfo: RunningEmulatorInfo;
notifyEmulatorImportFolder: { folder: string };
// data connect specific
notifyDataConnectResults: DataConnectResults;
notifyDataConnectRequiredArgs: { args: string[] };
}

export type MessageParamsMap =
Expand Down
2 changes: 1 addition & 1 deletion firebase-vscode/common/messaging/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export interface EmulatorUiSelections {
firebaseJsonPath?: string;
importStateFolderPath?: string;
exportStateOnExit: boolean;
mode: "hosting" | "all";
mode: "hosting" | "all" | "dataconnect";
debugLogging: boolean;
}
4 changes: 2 additions & 2 deletions firebase-vscode/common/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export interface ServiceAccount {
user: ServiceAccountUser
user: ServiceAccountUser;
}

export interface ServiceAccountUser {
email: string;
type: 'service_account'
type: "service_account";
}
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 3b6710e

Please sign in to comment.