MCPcopy Create free account
hub / github.com/firebase/firebase-tools / getIdentifiers

Function getIdentifiers

src/dataconnect/schemaMigration.ts:409–439  ·  view source on GitHub ↗
(schema: Schema)

Source from the content-addressed store, hash-verified

407}
408
409export function getIdentifiers(schema: Schema): {
410 instanceName: string;
411 instanceId: string;
412 databaseId: string;
413 schemaName: string;
414 serviceName: string;
415} {
416 const postgresDatasource = schema.datasources.find((d) => d.postgresql);
417 const databaseId = postgresDatasource?.postgresql?.database;
418 if (!databaseId) {
419 throw new FirebaseError(
420 "SQL Connect schema must have a postgres datasource with a database name.",
421 );
422 }
423 const instanceName = postgresDatasource?.postgresql?.cloudSql?.instance;
424 if (!instanceName) {
425 throw new FirebaseError(
426 "SQL Connect schema must have a postgres datasource with a CloudSQL instance.",
427 );
428 }
429 const instanceId = instanceName.split("/").pop()!;
430 const schemaName = postgresDatasource?.postgresql?.schema || DEFAULT_SCHEMA;
431 const serviceName = serviceNameFromSchema(schema);
432 return {
433 databaseId,
434 instanceId,
435 instanceName,
436 schemaName,
437 serviceName,
438 };
439}
440
441/** Extracts the service name from the schema name. */
442export function serviceNameFromSchema(schema: Schema): string {

Callers 6

diffSchemaFunction · 0.85
migrateSchemaFunction · 0.85
grantRoleToUserInSchemaFunction · 0.85

Calls 1

serviceNameFromSchemaFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…