رابط خط فرمان Firebase CLI) به شما امکان میدهد پروژههای فایربیس خود را در یک دایرکتوری پروژه محلی و قابل کنترل با نسخه مدیریت کنید. این شامل سرویسهای Data Connect در پروژههای شما، کانکتورهای مربوط به آن سرویسها و منابعی مانند منابع طرحواره، پرسوجو و جهش برای هر کانکتور میشود. رابط خط فرمان همچنین به شما امکان میدهد شبیهساز Firebase Data Connect را نصب و راهاندازی کنید. رابط خط فرمان جایگزین کارآمدی برای کار در کنسول Firebase است.
برای دستورالعملهای نصب آزمایش Firebase CLI برای برنامه Private Preview و دستورات CLI مربوط به Data Connect ، به مرجع CLI مراجعه کنید.
این راهنمای مرجع موارد زیر را مستند میکند:
- ورودیهای خاص Data Connect در فایل پیکربندی پروژه
firebase.jsonشما. - پیکربندیهای Data Connect در
dataconnect.yamlوconnector.yaml.
فایلهای پیکربندی پروژه فایربیس
مرجع پیکربندی firebase.json
از کلیدهای dataconnect برای پیکربندی یک یا چند سرویس 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 شما استفاده نشود، از پایگاه داده حذف خواهد شد. -
COMPATIBLEmode. The database schema must be compatible with the application schema before the application schema can be deployed; any additional changes are considered optional. Compatible means that schema migrations are based on the application schema you write. Elements in your database that are not used by your application schema are left unmodified. Therefore, after deployment, your backend may contain unused schemas, tables, and columns.
مقادیر سایر کلیدهای این فایل در توضیحات زیر توضیح داده شده است.
# 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
برای پیکربندی حالت احراز هویت پیشفرض و گزینههای تولید SDK 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. 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
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to executeQuery() and as the
# initial result returned from subscribe().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures how results are to be cached.
# Optional. Only "memory" is allowed for JavaScript SDKs.
storage: string
# 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
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute() and as the
# initial result returned from subscribe().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional.
# Default: "persistent" for Android and iOS targets, "memory" for web.
storage: 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
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional. Default: persistent
storage: 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
# Enable and configure client-side caching for the generated SDK.
# Optional. If the `clientCache` key is not present, caching is disabled.
clientCache:
# The maximum age allowed for cached results before fetching fresh
# values. A value of "0" means that responses are cached, but the
# client SDK will always fetch fresh values; the cached values are
# only used when CACHE_ONLY is specified to execute().
# Examples: "0", "30s", "1h30m"
# Optional. Default: "0"
maxAge: string
# Configures whether results are to be cached in persistent storage
# or in memory ("persistent" or "memory").
# Optional. Default: persistent
storage: string