Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
91fd4ea
fix Credential.getAccessToken (returns a promise)
alextekartik Nov 21, 2020
739f29d
pre nnbd
alextekartik Apr 15, 2021
1177474
basic nnbd migration
alextekartik Apr 15, 2021
d6f018b
fix: dart 2.14 lints
alextekartik Sep 20, 2021
8f11090
fix: dart 2.14 lints
alextekartik Sep 20, 2021
f3738e1
Merge pull request #1 from tekartikdev/null_safety
alextekartik Sep 20, 2021
3931410
fix: test
alextekartik Sep 20, 2021
d639a7e
fix: 2.15 lints
alextekartik Sep 26, 2021
68a2015
Merge pull request #2 from tekartikdev/null_safety
alextekartik Sep 26, 2021
952fabf
dart2_3
alextekartik Nov 2, 2021
571ed19
dart2_3
alextekartik Nov 2, 2021
5c00858
ci
alextekartik Nov 28, 2021
044017b
Merge pull request #3 from tekartikdev/dart2_3
alextekartik Nov 28, 2021
89064dd
[firestore_node] feat: add support for whereIn
alextekartik Jun 20, 2022
b2bf5cc
Merge pull request #4 from tekartikdev/dart2_3
alextekartik Jun 20, 2022
1fc8b17
fix: dart 2.18 lints
alextekartik Jun 26, 2022
35f877e
Merge pull request #5
alextekartik Jun 26, 2022
8bf8157
fix: dart 2.18 lints
alextekartik Jan 17, 2023
c838c10
fix: dart 3.0 compiler error
alextekartik Mar 11, 2023
47cabb0
fix: dart 3.0 compiler error
alextekartik Mar 11, 2023
19ed356
Merge pull request #6 from tekartikdev/dart2_3
alextekartik Mar 12, 2023
e67ef02
fix: dart 3.0 compiler error
alextekartik Mar 20, 2023
d10410f
feat: add orderByKey
alextekartik May 15, 2023
88606eb
Merge pull request #7
alextekartik May 16, 2023
103930e
fix dart 3.1 lints
alextekartik Jul 2, 2023
d37e6c5
Merge pull request #8
alextekartik Jul 2, 2023
5965b93
dart3a branch
alextekartik Jul 10, 2023
e04d126
Merge pull request #9 from tekartikdev/dart3a
alextekartik Oct 9, 2023
5c473bf
ci
alextekartik Oct 22, 2023
b462445
Merging from main
alextekartik Oct 22, 2023
70589d2
fix lints
alextekartik Oct 29, 2023
cc15829
[firestore] supports aggregate queries
alextekartik Jan 31, 2024
5628fb8
fix: lints
alextekartik Jun 8, 2024
2d83948
fix: test when setup is not correct
alextekartik Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Dependabot configuration file.
# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
version: 2

enable-beta-ecosystems: true
updates:
- package-ecosystem: "pub"
directory: "."
schedule:
interval: "monthly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
36 changes: 36 additions & 0 deletions .github/workflows/run_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run CI
on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # every sunday at midnight

jobs:
test:
name: Test on ${{ matrix.os }} / ${{ matrix.dart }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: .
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
dart: stable
- os: ubuntu-latest
dart: beta
- os: ubuntu-latest
dart: dev
- os: windows-latest
dart: stable
- os: macos-latest
dart: stable
steps:
- uses: actions/checkout@v4
- uses: dart-lang/[email protected]
with:
sdk: ${{ matrix.dart }}
- run: dart --version
- run: dart pub get
- run: dart run tool/run_ci.dart
29 changes: 29 additions & 0 deletions .github/workflows/run_ci_downgrade_analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run CI Downgrade analyze
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # every sunday at midnight

jobs:
test:
name: Test on ${{ matrix.os }} / ${{ matrix.dart }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: .
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
dart: stable
steps:
- uses: actions/checkout@v4
- uses: dart-lang/[email protected]
with:
sdk: ${{ matrix.dart }}
- run: dart --version
- run: dart pub global activate dev_test
- run: dart pub global run dev_test:run_ci --pub-downgrade --analyze --no-override --recursive
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.packages
.pub/
.dart_tool/
.dart/
build/
# Remove the following pattern if you wish to check in your lock file
pubspec.lock
Expand All @@ -16,5 +17,10 @@ tool/build_example.sh
*.json
!package.json

# Intellij/WebStorm
# Intellij/WebStorm/VSCode
.idea/
*.iml
.vscode/

# Local
/.local/
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ as soon as possible. Read "Firestore Timestamps migration" in README.md for more

## 0.1.0-beta.3

- Updated JS bindings with type arguments for Promises.
- Updated JS bindings with type arguments for node.Promises.

## 0.1.0-beta.2

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ dependencies:
firebase_admin_interop: [latest_version]
```

Git:
```yaml
firebase_admin_interop:
git:
url: https://github.com/tekartikdev/firebase-admin-interop
ref: dart3a
```
Run `pub get`.

2. Create `package.json` file to install Node.js modules used by this library:
Expand Down
8 changes: 5 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# tekartik recommended lints (extension over google lints and pedantic)
include: package:tekartik_lints/strict.yaml

analyzer:
exclude:
- example/**
Expand All @@ -11,10 +14,9 @@ linter:
- close_sinks
- directives_ordering
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- collection_methods_unrelated_type
- prefer_final_fields
- prefer_is_not_empty
- test_types_in_equals
- unrelated_type_equality_checks
- valid_regexps
- valid_regexps
2 changes: 1 addition & 1 deletion example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ main() async {
final serviceAccountKeyFilename = '/absolute/path/to/service-account.json';
final admin = FirebaseAdmin.instance;
final cert = admin.certFromPath(serviceAccountKeyFilename);
final app = admin.initializeApp(new AppOptions(
final app = admin.initializeApp(AppOptions(
credential: cert,
databaseURL: "YOUR_DB_URL",
));
Expand Down
2 changes: 1 addition & 1 deletion lib/firebase_admin_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ export 'src/app.dart';
export 'src/auth.dart';
export 'src/bindings.dart' show AppOptions, SetOptions, FirestoreSettings;
export 'src/database.dart';
export 'src/firestore.dart';
export 'src/firestore.dart' hide AggregateFieldWithAlias;
export 'src/messaging.dart';
26 changes: 12 additions & 14 deletions lib/src/admin.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) 2017, Anatoly Pulyaevskiy. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:meta/meta.dart';

import 'app.dart';
import 'bindings.dart' as js;

Expand All @@ -11,11 +9,11 @@ import 'bindings.dart' as js;
/// To start using Firebase services initialize a Firebase application
/// with [initializeApp] method.
class FirebaseAdmin {
final js.FirebaseAdmin _admin;
final Map<String, App> _apps = new Map();
final js.FirebaseAdmin? _admin;
final Map<String, App> _apps = {};

static FirebaseAdmin get instance => _instance ??= new FirebaseAdmin._();
static FirebaseAdmin _instance;
static FirebaseAdmin get instance => _instance ??= FirebaseAdmin._();
static FirebaseAdmin? _instance;

FirebaseAdmin._() : _admin = js.admin;

Expand Down Expand Up @@ -47,30 +45,30 @@ class FirebaseAdmin {
/// * [App]
/// * [cert]
/// * [certFromPath]
App initializeApp([js.AppOptions options, String name]) {
App? initializeApp([js.AppOptions? options, String? name]) {
if (options == null && name == null) {
// Special case for default app with Application Default Credentials.
name = js.defaultAppName;
if (!_apps.containsKey(name)) {
_apps[name] = new App(_admin.initializeApp());
_apps[name] = App(_admin!.initializeApp());
}
return _apps[name];
}

name ??= js.defaultAppName;
if (!_apps.containsKey(name)) {
_apps[name] = new App(_admin.initializeApp(options, name));
_apps[name] = App(_admin!.initializeApp(options, name));
}
return _apps[name];
}

/// Creates [App] certificate.
js.Credential cert({
@required String projectId,
@required String clientEmail,
@required String privateKey,
required String? projectId,
required String? clientEmail,
required String? privateKey,
}) {
return _admin.credential.cert(new js.ServiceAccountConfig(
return _admin!.credential.cert(js.ServiceAccountConfig(
project_id: projectId,
client_email: clientEmail,
private_key: privateKey,
Expand All @@ -79,6 +77,6 @@ class FirebaseAdmin {

/// Creates app certificate from service account file at specified [path].
js.Credential certFromPath(String path) {
return _admin.credential.cert(path);
return _admin!.credential.cert(path);
}
}
22 changes: 10 additions & 12 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import 'dart:async';

import 'package:meta/meta.dart';
import 'package:node_interop/util.dart';
import 'package:node_interop/util.dart' as node;

import 'admin.dart';
import 'auth.dart';
Expand All @@ -29,25 +29,23 @@ class App {
js.AppOptions get options => nativeInstance.options;

/// Gets the [Auth] service for this application.
Auth auth() => _auth ??= new Auth(nativeInstance.auth());
Auth _auth;
Auth auth() => _auth ??= Auth(nativeInstance.auth());
Auth? _auth;

/// Gets Realtime [Database] client for this application.
Database database() =>
_database ??= new Database(this.nativeInstance.database(), this);
Database _database;
_database ??= Database(nativeInstance.database(), this);
Database? _database;

/// Gets [Firestore] client for this application.
Firestore firestore() =>
_firestore ??= new Firestore(nativeInstance.firestore());
Firestore _firestore;
Firestore firestore() => _firestore ??= Firestore(nativeInstance.firestore());
Firestore? _firestore;

/// Gets [Messaging] client for this application.
Messaging messaging() =>
_messaging ??= new Messaging(nativeInstance.messaging());
Messaging _messaging;
Messaging messaging() => _messaging ??= Messaging(nativeInstance.messaging());
Messaging? _messaging;

/// Renders this app unusable and frees the resources of all associated
/// services.
Future<void> delete() => promiseToFuture<void>(nativeInstance.delete());
Future<void> delete() => node.promiseToFuture<void>(nativeInstance.delete());
}
43 changes: 22 additions & 21 deletions lib/src/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import 'dart:async';

import 'package:meta/meta.dart';
import 'package:node_interop/util.dart';
import 'package:node_interop/util.dart' as node;

import 'bindings.dart' as js show Auth;
import 'bindings.dart'
Expand Down Expand Up @@ -39,41 +39,42 @@ class Auth {
/// Returns a [Future] containing a custom token string for the provided [uid]
/// and payload.
Future<String> createCustomToken(String uid,
[Map<String, String> developerClaims]) =>
promiseToFuture(
nativeInstance.createCustomToken(uid, jsify(developerClaims)));
[Map<String, String>? developerClaims]) =>
node.promiseToFuture(nativeInstance.createCustomToken(
uid, node.jsify(developerClaims ?? <String, String>{})));

/// Creates a new user.
Future<UserRecord> createUser(CreateUserRequest properties) =>
promiseToFuture(nativeInstance.createUser(properties));
node.promiseToFuture(nativeInstance.createUser(properties));

/// Deletes an existing user.
Future<void> deleteUser(String uid) =>
promiseToFuture(nativeInstance.deleteUser(uid));
node.promiseToFuture(nativeInstance.deleteUser(uid));

/// Gets the user data for the user corresponding to a given [uid].
Future<UserRecord> getUser(String uid) =>
promiseToFuture(nativeInstance.getUser(uid));
node.promiseToFuture(nativeInstance.getUser(uid));

/// Gets the user data for the user corresponding to a given [email].
Future<UserRecord> getUserByEmail(String email) =>
promiseToFuture(nativeInstance.getUserByEmail(email));
node.promiseToFuture(nativeInstance.getUserByEmail(email));

/// Gets the user data for the user corresponding to a given [phoneNumber].
Future<UserRecord> getUserByPhoneNumber(String phoneNumber) =>
promiseToFuture(nativeInstance.getUserByPhoneNumber(phoneNumber));
node.promiseToFuture(nativeInstance.getUserByPhoneNumber(phoneNumber));

/// Retrieves a list of users (single batch only) with a size of [maxResults]
/// and starting from the offset as specified by [pageToken].
///
/// This is used to retrieve all the users of a specified project in batches.
Future<ListUsersResult> listUsers([num maxResults, String pageToken]) {
Future<ListUsersResult> listUsers([num? maxResults, String? pageToken]) {
if (pageToken != null && maxResults != null) {
return promiseToFuture(nativeInstance.listUsers(maxResults, pageToken));
return node
.promiseToFuture(nativeInstance.listUsers(maxResults, pageToken));
} else if (maxResults != null) {
return promiseToFuture(nativeInstance.listUsers(maxResults));
return node.promiseToFuture(nativeInstance.listUsers(maxResults));
} else {
return promiseToFuture(nativeInstance.listUsers());
return node.promiseToFuture(nativeInstance.listUsers());
}
}

Expand All @@ -89,7 +90,7 @@ class Auth {
/// ID tokens are revoked, use [Auth.verifyIdToken] where `checkRevoked` is set to
/// `true`.
Future<void> revokeRefreshTokens(String uid) =>
promiseToFuture(nativeInstance.revokeRefreshTokens(uid));
node.promiseToFuture(nativeInstance.revokeRefreshTokens(uid));

/// Sets additional developer claims on an existing user identified by the
/// provided [uid], typically used to define user roles and levels of access.
Expand All @@ -107,25 +108,25 @@ class Auth {
/// related user attributes, use database or other separate storage systems.
Future<void> setCustomUserClaims(
String uid, Map<String, dynamic> customUserClaims) =>
promiseToFuture(
nativeInstance.setCustomUserClaims(uid, jsify(customUserClaims)));
node.promiseToFuture(nativeInstance.setCustomUserClaims(
uid, node.jsify(customUserClaims)));

/// Updates an existing user.
Future<UserRecord> updateUser(String uid, UpdateUserRequest properties) =>
promiseToFuture(nativeInstance.updateUser(uid, properties));
node.promiseToFuture(nativeInstance.updateUser(uid, properties));

/// Verifies a Firebase ID token (JWT).
///
/// If the token is valid, the returned [Future] is completed with an instance
/// of [DecodedIdToken]; otherwise, the future is completed with an error.
/// An optional flag can be passed to additionally check whether the ID token
/// was revoked.
Future<DecodedIdToken> verifyIdToken(String idToken, [bool checkRevoked]) {
Future<DecodedIdToken> verifyIdToken(String idToken, [bool? checkRevoked]) {
if (checkRevoked != null) {
return promiseToFuture(
nativeInstance.verifyIdToken(idToken, checkRevoked));
return node
.promiseToFuture(nativeInstance.verifyIdToken(idToken, checkRevoked));
} else {
return promiseToFuture(nativeInstance.verifyIdToken(idToken));
return node.promiseToFuture(nativeInstance.verifyIdToken(idToken));
}
}
}
Loading