Firebase CLI umożliwia zarządzanie projektami Firebase w lokalnym katalogu projektu, który można kontrolować za pomocą systemu kontroli wersji. Obejmuje to Data Connectusługi w projektach, łączniki do tych usług i zasoby, takie jak schemat, źródła zapytań i mutacji dla każdego łącznika. Interfejs wiersza poleceń umożliwia też instalowanie i obsługiwanie emulatora Firebase Data Connect. Interfejs CLI to wydajna alternatywa dla pracy w Firebase konsoli.
Instrukcje instalacji eksperymentalnej wersji interfejsu wiersza poleceń Firebase w ramach programu prywatnego podglądu oraz polecenia interfejsu wiersza poleceń związane z Data Connect znajdziesz w dokumentacji interfejsu wiersza poleceń.
Ten przewodnik zawiera dokumentację:
- Data Connect-specific entries in your
firebase.json
project configuration file. - Data Connect konfiguracje w
dataconnect.yaml
iconnector.yaml
. - Role IAM, które musisz skonfigurować w projektach korzystających z Data Connect.
Pliki konfiguracyjne projektu Firebase
Informacje o konfiguracji pliku firebase.json
Za pomocą klawiszy dataconnect
skonfiguruj co najmniej 1 Data Connectusługę w projekcie.
dataconnect: {
source: string // Path to the directory containing the dataconnect.yaml service file.
}
Dokumentacja konfiguracji pliku dataconnect.yaml
Plik dataconnect.yaml
zawiera informacje o konfiguracji lokalizacji źródeł schematu aplikacji, źródeł oprogramowania sprzęgającego i informacji o połączeniu ze źródłem danych. Plik ten służy też jako wskaźnik katalogu projektu dla interfejsu wiersza poleceń Firebase.
Klucz schemaValidation
określa poziom weryfikacji schematu przeprowadzanej podczas migracji schematów w trakcie wdrażania. Jeśli nie ustawisz żadnej wartości, polecenie dataconect:sql:migrate
zastosuje zgodne zmiany i przed wprowadzeniem zmian ścisłych wyświetli prośbę o potwierdzenie. Po ustawieniu tej opcji zachowanie jest następujące:
STRICT
. Przed wdrożeniem schematu aplikacji schemat bazy danych musi dokładnie odpowiadać schematowi aplikacji. Wszystkie tabele i kolumny, które nie są używane w Twoim Data Connectschemacie, zostaną usunięte z bazy danych.COMPATIBLE
. Przed wdrożeniem schematu aplikacji schemat bazy danych musi być z nim zgodny. Wszelkie dodatkowe zmiany są opcjonalne. Oznacza to, że migracje schematu są oparte na schemacie aplikacji, który piszesz. Elementy w bazie danych, które nie są używane przez schemat aplikacji, pozostają niezmienione. Dlatego po wdrożeniu backend może zawierać nieużywane schematy, tabele i kolumny.
Wartości innych kluczy w tym pliku są wyjaśnione w komentarzach poniżej.
# The top-level Firebase Data Connect YAML file.
# The Firebase Data Connect API version to target.
# Optional. Defaults to the latest version.
specVersion: string
# The ID of the Firebase Data Connect service resource.
# Required.
serviceId: string
# The location of the Firebase Data Connect service.
# Required.
location: string
# Required.
schema:
# Relative path to directory for schema definitions.
# Recursively loads all .gql files in this directory.
# Optional. If not present, defaults to ./schema.
source: string
# Datasource connection information.
# Required.
datasource:
# Required.
postgresql:
# The name of the PostgreSQL database.
# Required.
database: string
cloudSql:
# The ID of the CloudSQL instance resource.
# Required.
instanceId: string
# Schema validation mode for schema migrations.
# Defaults to unspecified/commented out, meaning you are prompted to
# review all changes during migration.
# If desired, uncomment and indicate one of "STRICT" or "COMPATIBLE".
schemaValidation: string
# Required.
# Relative paths to directories for connector definitions.
# Recursively loads all .gql files in the listed directories.
# All directories specified MUST contain a connector.yaml file.
connectorDirs: [string]
Plik YAML zakłada domyślną (ale konfigurowalną) strukturę katalogów:
./(project root)
/dataconnect
dataconnect.yaml
/schema
*.gql
/connector
connector.yaml
*.gql
Dokumentacja konfiguracji pliku connector.yaml
Użyj ikony connector.yaml
, aby skonfigurować domyślny tryb uwierzytelniania i opcje generowania pakietu SDK.
# The connector-level YAML file.
# Required. The connector name of the Firebase Data Connect connector resource.
connectorId: string
# Optional. If not specified, no generated libraries (i.e. type-safe SDKs) will be generated.
generate:
# Optional.
javascriptSdk:
# Path to the directory that will be updated with the latest generated
# web SDK.
# Required.
- outputDir: string
# Path to your package.json directory. If specified, the new generated sdk will be installed in this path.
# Optional. If not provided, the package will not be auto-installed for you.
- packageJsonDir: string
# Name of the package to be created.
# Optional. Defaults to @firebasegen/<connectorID>
- package: string
<option>: string
# Optional.
swiftSdk:
# Path to the directory that will be updated with the latest generated
# iOS Swift SDK.
# Required.
- outputDir: string
# Name of the package to be created.
- package: string
<option>: string
# Optional.
kotlinSdk:
# Path to the directory that will be updated with the latest generated
# Android SDK.
# Required.
- outputDir: string
# Name of the package to be created.
- package: string
<option>: string
Konfiguracja uprawnień w projektach Data Connect
Szczegółowe role uprawnień dla Data Connect
Poziomy podstawowe i role wstępnie zdefiniowane w Firebase są mapowane na role niższego poziomuData Connect. Mapowanie znajdziesz w tabeli.
Aby zarządzać poszczególnymi przypisaniami ról uprawnień dla Data Connect na bardziej szczegółowym poziomie, użyj Google Cloud konsoli.
Rola uprawnień | Uprawnienia |
---|---|
firebasedataconnect.googleapis.com/admin Administrator interfejsu Firebase Data Connect API Ta rola obejmuje rolę Wyświetlający interfejs Firebase Data Connect API. Jest to odpowiednik firebasedataconnect.* .Mają je użytkownicy z przypisaną rolą Właściciel Cloud, Edytujący Cloud, Administrator Firebase lub Administrator Firebase Develop. |
Pełny dostęp do zasobów interfejsu Firebase Data Connect API, w tym do danych.firebasedataconnect.googleapis.com/operations.delete firebasedataconnect.googleapis.com/operations.cancel firebasedataconnect.googleapis.com/services.create firebasedataconnect.googleapis.com/services.update firebasedataconnect.googleapis.com/services.delete firebasedataconnect.googleapis.com/services.executeGraphql firebasedataconnect.googleapis.com/services.executeGraphqlRead firebasedataconnect.googleapis.com/schemas.create firebasedataconnect.googleapis.com/schemas.update firebasedataconnect.googleapis.com/schemas.delete firebasedataconnect.googleapis.com/schemaRevisions.create firebasedataconnect.googleapis.com/schemaRevisions.delete firebasedataconnect.googleapis.com/connectors.create firebasedataconnect.googleapis.com/connectors.update firebasedataconnect.googleapis.com/connectors.delete firebasedataconnect.googleapis.com/connectorRevisions.create firebasedataconnect.googleapis.com/connectorRevisions.delete
|
firebasedataconnect.googleapis.com/viewer Wyświetlający interfejs Firebase Data Connect API Jest on przyznawany przez role Właściciel chmury, Edytujący chmurę, Wyświetlający chmurę, Administrator Firebase, Wyświetlający Firebase, Administrator Firebase Develop i Wyświetlający Firebase Develop. |
Dostęp tylko do odczytu do zasobów interfejsu Firebase Data Connect API. Rola nie daje dostępu do danych.cloudresourcemanager.googleapis.com/projects.list cloudresourcemanager.googleapis.com/projects.get firebasedataconnect.googleapis.com/operations.list firebasedataconnect.googleapis.com/operations.get firebasedataconnect.googleapis.com/locations.list firebasedataconnect.googleapis.com/locations.get firebasedataconnect.googleapis.com/services.list firebasedataconnect.googleapis.com/services.get firebasedataconnect.googleapis.com/schemas.list firebasedataconnect.googleapis.com/schemas.get firebasedataconnect.googleapis.com/schemaRevisions.list firebasedataconnect.googleapis.com/schemaRevisions.get firebasedataconnect.googleapis.com/connectors.list firebasedataconnect.googleapis.com/connectors.get firebasedataconnect.googleapis.com/connectorRevisions.list firebasedataconnect.googleapis.com/connectorRevisions.get
|
firebasedataconnect.googleapis.com/dataAdmin Administrator danych interfejsu Firebase Data Connect API Jest on przyznawany przez role Właściciel chmury, Edytujący chmurę, Administrator Firebase i Administrator Firebase Develop. |
Pełne uprawnienia do zapisu i odczytu źródeł danych.firebasedataconnect.googleapis.com/services.executeGraphql firebasedataconnect.googleapis.com/services.executeGraphqlRead
|
firebasedataconnect.googleapis.com/dataViewer Wyświetlający dane interfejsu Firebase Data Connect API Jest on dostępny w przypadku ról Właściciel chmury, Edytujący chmurę, Administrator Firebase i Administrator Firebase Develop. |
Dostęp tylko do odczytu do źródeł danych.firebasedataconnect.googleapis.com/services.executeGraphqlRead
|