Data Connect 構成ファイル リファレンス

Firebase CLI を使用すると、Firebase プロジェクトをローカルの バージョン管理可能なプロジェクト ディレクトリで管理できます。これには、プロジェクト内の Data Connect サービス、それらのサービスのコネクタ、 スキーマ、クエリ、ミューテーション ソースなどのリソースが含まれます。また、CLI を使用して インストールして操作することもできます。Firebase Data ConnectCLI は、 コンソールで作業する効率的な代替手段です。Firebase

Private Preview プログラム用の Firebase CLI の試験運用版のインストール手順と、Data Connect-関連の CLI コマンドについては、CLI リファレンスをご覧ください。

このリファレンス ガイドでは、以下について説明します。

  • Data Connect プロジェクト 構成ファイルの firebase.json 固有のエントリ。
  • Data Connect 構成を dataconnect.yamlconnector.yaml に。

Firebase プロジェクト構成ファイル

firebase.json 構成リファレンス

dataconnect キーを使用して、プロジェクトで 1 つ以上の Data Connect サービスを構成します。

dataconnect: {
   source: string // Path to the directory containing the dataconnect.yaml service file.
}

dataconnect.yaml 構成リファレンス

dataconnect.yaml ファイルには、アプリケーション スキーマ ソース、コネクタ ソースの場所、データソース接続情報に関する構成情報が保存されます。このファイルは、 Firebase CLI のプロジェクト ディレクトリ指定子としても機能します。

schemaValidation キーは、デプロイ中にスキーマが移行されるときに実行されるスキーマ検証のレベルを制御します。値が設定されていない場合、dataconect:sql:migrate コマンドは互換性のある変更を適用し、厳密な変更を実行する前に確認を求めます。設定されている場合の動作は次のとおりです。

  • STRICT モード。アプリケーション スキーマをデプロイするには、データベース スキーマがアプリケーション スキーマと完全に一致している必要があります。Data Connect スキーマで使用されていないテーブルまたは列は、データベースから削除されます。Data Connect
  • COMPATIBLE モード。アプリケーション スキーマをデプロイするには、データベース スキーマがアプリケーション スキーマと互換性がある必要があります。追加の変更は省略可能です。互換性とは、スキーマの移行が記述したアプリケーション スキーマに基づいていることを意味します。アプリケーション スキーマで使用されていないデータベース内の要素は変更されません。 そのため、デプロイ後、バックエンドに未使用のスキーマ、テーブル、列が含まれる可能性があります。

このファイルの他のキーの値については、以下のコメントで説明します。

# 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]

YAML ファイルは、デフォルト(構成可能)のディレクトリ構造を想定しています。

./(project root)
   /dataconnect
      dataconnect.yaml
      /schema
        *.gql
      /example
        connector.yaml
        *.gql

connector.yaml 構成リファレンス

connector.yaml を使用して、デフォルトの認証モードと 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 TypeScript SDK.
        # Required.
        outputDir: string
        # Name of the Javascript package to be created.
        # Required. Example: @dataconnect/generated
        package: 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
        # Enable React framework bindings.
        # Optional. Default to false.
        react: Boolean
        # Enable Angular framework bindings.
        # Optional. Default to false.
        angular: Boolean
    # Optional.
    dartSdk:
        # Path to the directory that will be updated with the latest generated
        # Flutter Dart SDK.
        # Required.
        outputDir: string
        # Name of the Dart package to be created.
        # Required. Example: "dataconnect_generated"
        package: 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.
        # Required. Example: com.google.firebase.dataconnect.generated
        package: string
    # Optional.
    adminNodeSdk:
        # Path to the directory that will be updated with the latest generated
        # Node Admin 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 (for example: @dataconnect/admin-generated).
        # Required.
        package: string
    # Optional.
    swiftSdk:
        # Path to the directory that will be updated with the latest generated
        # iOS Swift SDK.
        # Required.
        outputDir: string
        # Name of the Swift package to be created.
        # Required. Example: "FirebaseDataConnectGenerated"
        package: string