Data Connect कॉन्फ़िगरेशन फ़ाइल का रेफ़रंस

Firebase CLI की मदद से, अपने Firebase प्रोजेक्ट को लोकल तौर पर मैनेज किया जा सकता है. साथ ही, वर्शन कंट्रोल की सुविधा वाली प्रोजेक्ट डायरेक्ट्री में भी मैनेज किया जा सकता है. इसमें आपके प्रोजेक्ट में मौजूद सेवाएं, उन सेवाओं के लिए कनेक्टर, और संसाधन शामिल हैं. जैसे, हर कनेक्टर के लिए स्कीमा, क्वेरी, और म्यूटेशन सोर्स.Data Connect सीएलआई की मदद से, Firebase Data Connect एम्युलेटर को इंस्टॉल और ऑपरेट भी किया जा सकता है. सीएलआई, Firebase कंसोल में काम करने का एक बेहतर विकल्प है.

Firebase CLI experiment for Private Preview program इंस्टॉल करने और Data Connect से जुड़ी सीएलआई कमांड के बारे में जानने के लिए, सीएलआई रेफ़रंस देखें.

इस रेफ़रंस गाइड में इनके बारे में बताया गया है:

  • Data Connect प्रोजेक्ट की कॉन्फ़िगरेशन फ़ाइल में Data Connect से जुड़ी खास एंट्री.firebase.json
  • dataconnect.yaml और connector.yaml में Data Connect कॉन्फ़िगरेशन.

Firebase प्रोजेक्ट कॉन्फ़िगरेशन फ़ाइलें

firebase.json कॉन्फ़िगरेशन का रेफ़रंस

अपने प्रोजेक्ट में एक या उससे ज़्यादा Data Connect सेवाओं को कॉन्फ़िगर करने के लिए, dataconnect कुंजियों का इस्तेमाल करें.

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

dataconnect.yaml कॉन्फ़िगरेशन का रेफ़रंस

dataconnect.yaml फ़ाइल में, ऐप्लिकेशन स्कीमा सोर्स, कनेक्टर सोर्स, और डेटा सोर्स कनेक्शन की जानकारी की जगहों के बारे में कॉन्फ़िगरेशन की जानकारी सेव होती है. यह फ़ाइल, Firebase सीएलआई के लिए प्रोजेक्ट डायरेक्ट्री के तौर पर भी काम करती है.

schemaValidation कुंजी, स्कीमा के माइग्रेशन के दौरान किए गए स्कीमा की पुष्टि के लेवल को कंट्रोल करती है. कोई वैल्यू सेट न होने पर, dataconect:sql:migrate कमांड का काम, काम करने वाले बदलावों को लागू करना होता है. साथ ही, सख्त बदलावों को लागू करने से पहले आपको सूचना देना होता है. इस विकल्प को सेट करने पर, यह इस तरह काम करता है:

  • STRICT मोड पर टैप करें. ऐप्लिकेशन स्कीमा को डिप्लॉय करने से पहले, डेटाबेस स्कीमा को ऐप्लिकेशन स्कीमा से पूरी तरह मेल खाना चाहिए. डेटाबेस से उन सभी टेबल या कॉलम को मिटा दिया जाएगा जिनका इस्तेमाल आपके 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 का इस्तेमाल करें.

# 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. Recommend @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. Recommend 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.
        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: @firebasegen-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 dart package to be created.
        # Required. Recommend dataconnect_generated
      - package: string