Firebase CLI מאפשר לכם לנהל את פרויקטי Firebase בספריית פרויקטים מקומית שאפשר לשלוט בגרסאות שלה. זה כולל שירותי Data Connectבפרויקטים, מחברים לשירותים האלה ומשאבים כמו סכימה, שאילתות ומקורות מוטציה לכל מחבר. בנוסף, אפשר להשתמש ב-CLI כדי להתקין ולהפעיל את האמולטור Firebase Data Connect. ה-CLI הוא חלופה יעילה לעבודה במסוף Firebase.
הוראות להתקנת ניסוי ה-CLI של Firebase לתוכנית תצוגה מקדימה פרטית, ופקודות CLI שקשורות ל-Data Connect, זמינות במאמר בנושא CLI.
במדריך הזה מוסבר על:
- רשומות ספציפיות ל-Data Connect בקובץ התצורה של פרויקט
firebase.json. - הגדרות Data Connect ב-
dataconnect.yamlוב-connector.yaml. - תפקידי IAM שצריך להגדיר בפרויקטים שמשתמשים ב-Data Connect.
קבצי הגדרות אישיות של פרויקט 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
/connector
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 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/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 package to be created.
# Required.
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
הגדרת IAM בפרויקטים של Data Connect
תפקידי IAM עם הרשאות גרנולריות ל-Data Connect
תפקידים בסיסיים ותפקידים מוגדרים מראש ב-Firebase ממופים לתפקידים ברמה נמוכה יותר ב-Data Connect. טבלת המיפוי מופיעה בהמשך.
כדי לנהל הקצאות של תפקידים ב-IAM עבור Data Connect ברמה מפורטת יותר, משתמשים במסוף Google Cloud.
| תפקיד IAM | הרשאות |
|---|---|
firebasedataconnect.googleapis.com/adminאדמין של Firebase Data Connect API התפקיד הזה כולל את התפקיד 'צפייה ב-Firebase Data Connect API'. היא שוות ערך ל- firebasedataconnect.*.ההרשאה הזו ניתנת לתפקידים Cloud Owner, Cloud Editor, Firebase Admin ו-Firebase Develop Admin. |
גישה מלאה למשאבי Firebase Data Connect API, כולל נתונים.firebasedataconnect.googleapis.com/operations.deletefirebasedataconnect.googleapis.com/operations.cancelfirebasedataconnect.googleapis.com/services.createfirebasedataconnect.googleapis.com/services.updatefirebasedataconnect.googleapis.com/services.deletefirebasedataconnect.googleapis.com/services.executeGraphqlfirebasedataconnect.googleapis.com/services.executeGraphqlReadfirebasedataconnect.googleapis.com/schemas.createfirebasedataconnect.googleapis.com/schemas.updatefirebasedataconnect.googleapis.com/schemas.deletefirebasedataconnect.googleapis.com/schemaRevisions.createfirebasedataconnect.googleapis.com/schemaRevisions.deletefirebasedataconnect.googleapis.com/connectors.createfirebasedataconnect.googleapis.com/connectors.updatefirebasedataconnect.googleapis.com/connectors.deletefirebasedataconnect.googleapis.com/connectorRevisions.createfirebasedataconnect.googleapis.com/connectorRevisions.delete
|
firebasedataconnect.googleapis.com/viewerFirebase Data Connect API Viewer ההרשאה הזו ניתנת על ידי התפקידים Cloud Owner, Cloud Editor, Cloud Viewer, Firebase Admin, Firebase Viewer, Firebase Develop Admin ו-Firebase Develop Viewer. |
גישה לקריאה בלבד למשאבים של Firebase Data Connect API. התפקיד לא מעניק גישה לנתונים.cloudresourcemanager.googleapis.com/projects.listcloudresourcemanager.googleapis.com/projects.getfirebasedataconnect.googleapis.com/operations.listfirebasedataconnect.googleapis.com/operations.getfirebasedataconnect.googleapis.com/locations.listfirebasedataconnect.googleapis.com/locations.getfirebasedataconnect.googleapis.com/services.listfirebasedataconnect.googleapis.com/services.getfirebasedataconnect.googleapis.com/schemas.listfirebasedataconnect.googleapis.com/schemas.getfirebasedataconnect.googleapis.com/schemaRevisions.listfirebasedataconnect.googleapis.com/schemaRevisions.getfirebasedataconnect.googleapis.com/connectors.listfirebasedataconnect.googleapis.com/connectors.getfirebasedataconnect.googleapis.com/connectorRevisions.listfirebasedataconnect.googleapis.com/connectorRevisions.get
|
firebasedataconnect.googleapis.com/dataAdminFirebase Data Connect API Data Admin firebasedataconnect.googleapis.com/dataAdmin
ההרשאה הזו ניתנת על ידי התפקידים Cloud Owner, Cloud Editor, firebasedataconnect.googleapis.com/dataAdmin
Firebase Admin ו-Firebase Develop Admin. |
גישת קריאה וכתיבה מלאה למקורות נתונים.firebasedataconnect.googleapis.com/services.executeGraphqlfirebasedataconnect.googleapis.com/services.executeGraphqlRead
|
firebasedataconnect.googleapis.com/dataViewerכלי להצגת נתונים של Firebase Data Connect API הגישה לכלי הזה ניתנת למשתמשים עם התפקידים הבאים: בעלים ב-Cloud, עורך ב-Cloud, מנהל מערכת ב-Firebase ומנהל פיתוח ב-Firebase. |
הרשאת קריאה בלבד למקורות נתונים.firebasedataconnect.googleapis.com/services.executeGraphqlRead
|