Firebase CLI מאפשר לכם לנהל את פרויקטי Firebase בספריית פרויקטים מקומית שאפשר לשלוט בגרסאות שלה. זה כולל שירותים בפרויקטים, מחברים לשירותים האלה ומשאבים כמו סכימה, שאילתות ומקורות מוטציות לכל מחבר.Data Connect בנוסף, ה-CLI מאפשר להתקין ולהפעיל את האמולטור Firebase Data Connect. ה-CLI הוא חלופה יעילה לעבודה במסוף Firebase.
הוראות להתקנת ניסוי ה-CLI של Firebase לתוכנית Private Preview ופקודות CLI שקשורות ל-Data Connect זמינות במאמר העזרה בנושא CLI.
במדריך הזה מוסבר על:
- רשומות ספציפיות ל-Data Connect בקובץ התצורה של פרויקט
firebase.json. - הגדרות Data Connect ב-
dataconnect.yamlוב-connector.yaml.
קבצי הגדרות אישיות של פרויקט Firebase
חומר עזר בנושא התצורה של 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 יימחקו מהמסד.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. 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