Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 12 additions & 4 deletions firebase-vscode/src/data-connect/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isPathInside } from "./file-utils";
import { DeepReadOnly } from "../metaprogramming";
import { ConnectorYaml, DataConnectYaml, mainSchemaYaml } from "../../../src/dataconnect/types";
import { ConnectorYaml, DataConnectYaml, mainSchemaYaml, secondarySchemaYamls } from "../../../src/dataconnect/types";
import { Result, ResultValue } from "../result";
import { computed, effect, signal } from "@preact/signals-core";
import {
Expand Down Expand Up @@ -264,19 +264,27 @@ export class ResolvedDataConnectConfig {
return this.value.connectorDirs;
}

get schemaDir(): string {
get mainSchemaDir(): string {
return mainSchemaYaml(this.value).source;
}

get secondarySchemaDirs(): string[] {
return secondarySchemaYamls(this.value).map((s) => s.source);
}

get relativePath(): string {
if (!getConfigPath()) {
return this.path.split("/").pop()!;
}
return path.relative(getConfigPath()!, this.path);
}

get relativeSchemaPath(): string {
return this.schemaDir.replace(".", this.relativePath);
get relativeSchemaPaths(): string[] {
const paths = [this.mainSchemaDir.replace(".", this.relativePath)];
for (const secondarySchemaDir of this.secondarySchemaDirs) {
paths.push(secondarySchemaDir.replace(".", this.relativePath));
}
return paths;
}

get relativeConnectorPaths(): string[] {
Expand Down
9 changes: 4 additions & 5 deletions firebase-vscode/src/data-connect/language-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ export function setupLanguageClient(
// TODO: Expand to multiple services
const config = configs.values[0];
const generatedPath = ".dataconnect";
path.join(config.relativeSchemaPath, "**", "*.gql");
let schemaPaths = [
path.join(config.relativeSchemaPath, "**", "*.gql"),
path.join(config.relativePath, generatedPath, "**", "*.gql"),
];
let schemaPaths = [path.join(config.relativePath, generatedPath, "**", "*.gql")];
for (const relativeSchemaPath of config.relativeSchemaPaths) {
schemaPaths.push(path.join(relativeSchemaPath, "**", "*.gql"));
}
let documentPaths = config.relativeConnectorPaths.map((connectorPath) =>
path.join(connectorPath, "**", "*.gql"),
);
Expand Down
8 changes: 8 additions & 0 deletions src/dataconnect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
file?: string;
warningLevel?: WarningLevel;
workarounds?: Workaround[];
[key: string]: any;

Check warning on line 102 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
};
}
export interface BuildResult {
Expand All @@ -115,7 +115,7 @@
};
}

export function requiresVector(dm?: DeploymentMetadata): boolean {

Check warning on line 118 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
return dm?.primaryDataSource?.postgres?.requiredExtensions?.includes("vector") ?? false;
}

Expand Down Expand Up @@ -209,7 +209,7 @@
connectorYaml: ConnectorYaml;
}

export function toDatasource(

Check warning on line 212 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
projectId: string,
locationId: string,
ds: DatasourceYaml,
Expand Down Expand Up @@ -248,6 +248,14 @@
return mainSch;
}

/** Returns the secondary schema YAMLs for a Data Connect YAML */
export function secondarySchemaYamls(dataconnectYaml: DataConnectYaml): SchemaYaml[] {
if (dataconnectYaml.schema) {
return [];
}
return (dataconnectYaml.schemas || []).filter((s) => s.id && s.id !== MAIN_SCHEMA_ID);
}

/** Returns the main schema from a list of schemas */
export function mainSchema(schemas: Schema[]): Schema {
const mainSch = schemas.find((s) => isMainSchema(s));
Expand All @@ -271,8 +279,8 @@
}

export interface GraphqlResponse {
data: Record<string, any>;

Check warning on line 282 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
errors: any[];

Check warning on line 283 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}

export interface ExecuteOperationRequest {
Expand All @@ -281,11 +289,11 @@
}

export interface GraphqlResponseError {
error: { code: number; message: string; status: string; details: any[] };

Check warning on line 292 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}

export const isGraphQLResponse = (g: any): g is GraphqlResponse => !!g.data || !!g.errors;

Check warning on line 295 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .errors on an `any` value

Check warning on line 295 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .data on an `any` value

Check warning on line 295 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
export const isGraphQLResponseError = (g: any): g is GraphqlResponseError => !!g.error;

Check warning on line 296 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

interface ImpersonationAuthenticated {
authClaims: any;
Expand Down
Loading