Skip to content

Commit 27d574e

Browse files
SalakarEhesphelenafordkirstywilliamsgreghesp
authored
feat(firebase_firestore): v1 rework (#2913)
Co-authored-by: ehesp <[email protected]> Co-authored-by: Helena Ford <[email protected]> Co-authored-by: Kirsty Williams <[email protected]> Co-authored-by: Greg Hesp <[email protected]>
1 parent 426620d commit 27d574e

File tree

182 files changed

+13234
-7690
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+13234
-7690
lines changed

.github/workflows/firebase_firestore.yaml

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,67 @@ jobs:
3636
run: |
3737
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
3838
flutter build apk
39+
- name: Download Emulator Image
40+
run: |
41+
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-28;google_apis;x86_64"
42+
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name TestingAVD --device "Nexus 5X" -k 'system-images;android-28;google_apis;x86_64' -g google_apis
43+
$ANDROID_HOME/emulator/emulator -list-avds
44+
- name: Start Android Emulator
45+
timeout-minutes: 15
46+
continue-on-error: true
47+
run: |
48+
echo "Starting emulator"
49+
nohup $ANDROID_HOME/emulator/emulator -avd TestingAVD -no-audio -no-snapshot -no-window -no-boot-anim &
50+
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
51+
$ANDROID_HOME/platform-tools/adb devices
52+
$ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0.0
53+
$ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0.0
54+
$ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0.0
55+
echo "Emulator started"
56+
flutter emulators
57+
- name: "Drive Example"
58+
run: |
59+
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
60+
flutter drive --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart
3961
40-
ios:
62+
apple:
4163
runs-on: macos-latest
42-
timeout-minutes: 30
64+
timeout-minutes: 40
4365
steps:
4466
- uses: actions/checkout@v1
4567
with:
4668
fetch-depth: 0
4769
- uses: subosito/flutter-action@v1
4870
with:
49-
channel: "stable"
71+
channel: "dev"
5072
- name: "Install Tools"
5173
run: |
5274
pub global activate melos
5375
echo "::add-path::$HOME/.pub-cache/bin"
76+
flutter config --enable-macos-desktop
77+
flutter devices
5478
- name: "Bootstrap Workspace"
5579
run: melos bootstrap
56-
- name: "Build Example"
80+
- name: "Build iOS Example"
5781
run: |
5882
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
5983
flutter build ios --no-codesign
84+
- name: "Boot Simulator"
85+
run: xcrun simctl boot "iPhone 11"
86+
- name: "Drive iOS Example"
87+
run: |
88+
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
89+
flutter drive -d \"iPhone 11\" --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart
90+
- name: "Shutdown Simulator"
91+
run: xcrun simctl shutdown "iPhone 11"
92+
- name: "Build MacOS Example"
93+
run: |
94+
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" -- \
95+
flutter build macos
96+
- name: "Drive MacOS Example"
97+
run: |
98+
melos exec -c 1 --fail-fast --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=test_driver -- \
99+
flutter drive -d macos --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart
60100
61101
web:
62102
runs-on: ubuntu-latest
@@ -79,4 +119,10 @@ jobs:
79119
- name: "Build Example"
80120
run: |
81121
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=web -- \
82-
flutter build web
122+
flutter build web
123+
- name: "Drive Example"
124+
run: |
125+
melos clean && melos bootstrap
126+
chromedriver --port=4444 &
127+
melos exec -c 1 --scope="$FLUTTERFIRE_PLUGIN_SCOPE_EXAMPLE" --dir-exists=web -- \
128+
flutter drive --release --no-pub --verbose-system-logs --browser-name=chrome --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.DS_Store
22
.atom/
33
.idea/
4-
.vscode/
4+
.vscode/*
5+
!.vscode/tasks.json
6+
!.vscode/settings.json
57

68
.packages
79
.pub/
@@ -11,7 +13,6 @@ flutter_export_environment.sh
1113

1214
examples/all_plugins/pubspec.yaml
1315

14-
Podfile
1516
Podfile.lock
1617
Pods/
1718
.symlinks/
@@ -43,4 +44,5 @@ build/
4344
.project
4445
.classpath
4546
.settings
46-
pubspec.yaml
47+
/pubspec.yaml
48+
.last_build_id

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dart.runPubGetOnPubspecChanges": false
3+
}

.vscode/tasks.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "melos:bootstrap",
6+
"type": "shell",
7+
"command": "melos bootstrap",
8+
"detail": "Bootstrap this current workspace and link all packages together",
9+
"problemMatcher": []
10+
},
11+
{
12+
"label": "melos:clean",
13+
"type": "shell",
14+
"command": "melos clean",
15+
"detail": "Clean the current workspace and all build & temporary pub files",
16+
"problemMatcher": []
17+
},
18+
{
19+
"label": "melos:run",
20+
"type": "shell",
21+
"command": "melos run",
22+
"presentation": {
23+
"echo": true,
24+
"reveal": "always",
25+
"focus": true,
26+
"panel": "shared",
27+
"showReuseMessage": false,
28+
"clear": true
29+
},
30+
"detail": "Select a script defined in melos.yaml to run",
31+
"problemMatcher": []
32+
},
33+
{
34+
"label": "format",
35+
"type": "shell",
36+
"command": "melos run format",
37+
"detail": "Format all .dart, .h, .m & .java files in the project",
38+
"problemMatcher": []
39+
},
40+
{
41+
"label": "chromedriver",
42+
"isBackground": true,
43+
"type": "shell",
44+
"command": "chromedriver --port=4444",
45+
"detail": "Start a background chromedriver instance port on 4444",
46+
"problemMatcher": []
47+
},
48+
{
49+
"label": "firestore -> analyze",
50+
"type": "shell",
51+
"command": "melos exec -c 1 --scope=\"*firestore*\" --fail-fast -- pub global run tuneup check",
52+
"detail": "Run Dart Analyzer on all Firestore packages",
53+
"problemMatcher": []
54+
},
55+
{
56+
"label": "firestore -> test",
57+
"type": "shell",
58+
"command": "melos exec -c 1 --scope=\"*firestore*\" --fail-fast --ignore=\"*web*\" --ignore=\"*example*\" -- flutter test",
59+
"detail": "Run `flutter test` on all Firestore packages (excluding web & example)",
60+
"problemMatcher": []
61+
},
62+
{
63+
"label": "firestore -> test:e2e",
64+
"type": "shell",
65+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_example*\" --fail-fast --dir-exists=test_driver -- flutter drive --no-pub --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart",
66+
"detail": "Run end-to-end testing for Android & iOS via `flutter drive` on the Firestore example application",
67+
"problemMatcher": []
68+
},
69+
{
70+
"label": "firestore -> test:e2e:web",
71+
"type": "shell",
72+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_example*\" --dir-exists=web --fail-fast --dir-exists=test_driver -- flutter drive --release -d chrome --no-pub --verbose-system-logs --browser-name=chrome --target=./test_driver/MELOS_PARENT_PACKAGE_NAME_e2e.dart",
73+
"detail": "Run end-to-end testing for Web via `flutter drive` on the Firestore example application",
74+
"problemMatcher": []
75+
},
76+
{
77+
"label": "firestore -> test:web",
78+
"type": "shell",
79+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_web*\" --fail-fast -- flutter test --platform=chrome",
80+
"detail": "Run `flutter test` on the Firestore web package (with '--platform=chrome')",
81+
"problemMatcher": []
82+
},
83+
{
84+
"label": "firestore -> build:example:ios",
85+
"type": "shell",
86+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_example*\" --fail-fast -- flutter build ios --no-codesign",
87+
"detail": "Build the Firestore iOS example application",
88+
"problemMatcher": []
89+
},
90+
{
91+
"label": "firestore -> build:example:android",
92+
"type": "shell",
93+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_example*\" --fail-fast -- flutter build apk",
94+
"detail": "Build the Firestore Android example application",
95+
"problemMatcher": []
96+
},
97+
{
98+
"label": "firestore -> build:example:macos",
99+
"type": "shell",
100+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_example*\" --fail-fast -- flutter build macos",
101+
"detail": "Build the Firestore MacOS example application",
102+
"problemMatcher": []
103+
},
104+
{
105+
"label": "firestore -> build:example:web",
106+
"type": "shell",
107+
"command": "melos exec -c 1 --scope=\"*cloud_firestore_example*\" --fail-fast -- flutter build web",
108+
"detail": "Build the Firestore Web example application",
109+
"problemMatcher": []
110+
}
111+
]
112+
}

packages/cloud_firestore/cloud_firestore/CHANGELOG.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,83 @@
1+
## [UNPUBLISHED]
2+
3+
Along with the below changes, the plugin has undergone a quality of life update to better support exceptions thrown. Any Firestore specific errors now return a `FirebaseException`, allowing you to directly access the code (e.g. `permission-denied`) and message.
4+
5+
**`Firestore`**:
6+
- **BREAKING**: `settings()` is now a synchronous setter that accepts a `Settings` instance.
7+
- **NEW**: This change allows us to support changing Firestore settings (such as using the Firestore emulator) without having to quit the application, e.g. Hot Restarts.
8+
- **BREAKING**: `enablePersistence()` is now a Web only method, use `[Settings.persistenceEnabled]` instead for other platforms.
9+
- **DEPRECATED**: Calling `document()` is deprecated in favor of `doc()`.
10+
- **DEPRECATED**: Class `Firestore` is now deprecated. Use `FirebaseFirestore` instead.
11+
- **DEPRECATED**: Calling `Firestore(app: app)` is now deprecated. Use `FirebaseFirestore.instance` or `FirebaseFirestore.instanceFor(app: app)` instead.
12+
- **NEW**: Added `clearPersistence()` support.
13+
- **NEW**: Added `disableNetwork()` support.
14+
- **NEW**: Added `enableNetwork()` support.
15+
- **NEW**: Added `snapshotInSync()` listener support.
16+
- **NEW**: Added `terminate()` support.
17+
- **NEW**: Added `waitForPendingWrites()` support.
18+
- **FIX**: All document/query listeners & currently in progress transactions are now correctly torn down between Hot Restarts.
19+
20+
**`CollectionReference`**:
21+
- **BREAKING**: Getting a collection parent document via `parent()` has been changed to a getter `parent`.
22+
- **DEPRECATED**: Calling `document()` is deprecated in favor of `doc()`.
23+
24+
**`Query`**:
25+
- **BREAKING**: The internal query logic has been overhauled to better assert invalid queries locally.
26+
- **DEPRECATED**: Calling `getDocuments()` is deprecated in favor of `get()`.
27+
- **BREAKING**: `getDocuments`/`get` has been updated to accept an instance of `GetOptions` (see below).
28+
- **NEW**: Query methods can now be chained.
29+
- **NEW**: It is now possible to call same-point cursor based queries without throwing (e.g. calling `endAt()` and then `endBefore()` will replace the "end" cursor query with the `endBefore`).
30+
- **NEW**: Added support for the `limitToLast` query modifier.
31+
32+
**`QuerySnapshot`**:
33+
- **DEPRECATED**: `documents` has been deprecated in favor of `docs`.
34+
- **DEPRECATED**: `documentChanges` has been deprecated in favor of `docChanges`.
35+
- **NEW**: `docs` now returns a `List<QueryDocumentSnapshot>` vs `List<DocumentSnapshot>`. This doesn't break existing functionality.
36+
37+
**`DocumentReference`**:
38+
- **BREAKING**: `setData`/`set` has been updated to accept an instance of `SetOptions` (see below, supports `mergeFields`).
39+
- **BREAKING**: `get()` has been updated to accept an instance of `GetOptions` (see below).
40+
- **BREAKING**: Getting a document parent collection via `parent()` has been changed to a getter `parent`.
41+
- **DEPRECATED**: `documentID` has been deprecated in favor of `id`.
42+
- **DEPRECATED**: `setData()` has been deprecated in favor of `set()`.
43+
- **DEPRECATED**: `updateData()` has been deprecated in favor of `update()`.
44+
45+
**`DocumentChange`**:
46+
- **DEPRECATED**: Calling `document()` is deprecated in favor of `doc()`.
47+
48+
**`DocumentSnapshot`**:
49+
- **BREAKING**: The `get data` getter is now a `data()` method instead.
50+
- **DEPRECATED**: `documentID` has been deprecated in favor of `id`.
51+
- **NEW**: Added support for fetching nested snapshot data via the `get()` method. If no data exists at the given path, a `StateError` will be thrown.
52+
- **FIX**: `NaN` values stored in your Firestore instance are now correctly parsed when reading & writing data.
53+
- **FIX**: `INFINITY` values stored in your Firestore instance are now correctly parsed when reading & writing data.
54+
- **FIX**: `-INFINITY` values stored in your Firestore instance are now correctly parsed when reading & writing data.
55+
56+
**`WriteBatch`**:
57+
- **DEPRECATED**: `setData()` has been deprecated in favor of `set()`.
58+
- **DEPRECATED**: `updateData()` has been deprecated in favor of `update()`.
59+
- **BREAKING**: `setData`/`set` now supports `SetOptions` to merge data/fields (previously this accepted a `Map`).
60+
61+
**`Transaction`**:
62+
- **BREAKING**: Transactions have been overhauled to address a number of critical issues:
63+
- Values returned from the transaction will now be returned from the Future. Previously, only JSON serializable values were supported. It is now possible to return any value from your transaction handler, e.g. a `DocumentSnapshot`.
64+
- When manually throwing an exception, the context was lost and a generic `PlatformException` was thrown. You can now throw & catch on any exceptions.
65+
- The modify methods on a transaction (`set`, `delete`, `update`) were previously Futures. These have been updated to better reflect how transactions should behave - they are now synchronous and are executed atomically once the transaction handler block has finished executing.
66+
- **FIX**: Timeouts will now function correctly.
67+
- **FIX**: iOS: transaction completion block incorrectly resolving a `FlutterResult` multiple times.
68+
69+
See the new [transactions documentation](https://firebase.flutter.dev/docs/firestore/usage#transactions) to learn more.
70+
71+
**`FieldPath`**:
72+
- **NEW**: The constructor has now been made public to accept a `List` of `String` values. Previously field paths were accessible only via a dot-notated string path. This meant attempting to access a field in a document with a `.` in the name (e.g. `[email protected]`) was impossible.
73+
74+
**`GetOptions`**: New class created to support how data is fetched from Firestore (`server`, `cache`, `serverAndCache`).
75+
76+
**`SetOptions`**: New class created to both `merge` and `mergeFields` when setting data on documents.
77+
78+
**`GeoPoint`**:
79+
- **BREAKING**: Add latitude and longitude validation when constructing a new `GeoPoint` instance.
80+
181
## 0.13.7+1
282

383
* Fix crash where listeners are not removed when app quits.

0 commit comments

Comments
 (0)