Skip to content

Commit

Permalink
feat(functions): add initial cloud functions (#1)
Browse files Browse the repository at this point in the history
This is currently WIP, opening this to collect initial feedback.

Signed-off-by: Daeyeon Jeong <[email protected]>

---------

Signed-off-by: Daeyeon Jeong <[email protected]>
  • Loading branch information
daeyeon authored Aug 1, 2023
1 parent cd242ee commit 73b551d
Show file tree
Hide file tree
Showing 39 changed files with 2,304 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ plugins:
firebase_core: ["tv-7.0"]
firebase_database: []
firebase_storage: []
cloud_functions: []
cloud_functions: ["tv-7.0"]
3 changes: 3 additions & 0 deletions packages/cloud_functions/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
BasedOnStyle: Google
---
28 changes: 28 additions & 0 deletions packages/cloud_functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# VS Code related
.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
3 changes: 3 additions & 0 deletions packages/cloud_functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1.0

* Initial release.
63 changes: 63 additions & 0 deletions packages/cloud_functions/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
```
Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

```
Copyright (c) 2013 The Flutter Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the names of the copyright holders nor the names of the
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

The externally maintained libraries used by this pluggin is:

- Firebase C++ Open Source SDK is licensed as follows:

```
Copyright 2016 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
31 changes: 31 additions & 0 deletions packages/cloud_functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# cloud_functions_tizen

The [Firebase Cloud Functions for Flutter](https://pub.dev/packages/cloud_functions) implementation for Tizen.

It offers experimental features for using Firebase on Flutter for Tizen. It works by wrapping cross-compiled libraries that are based on the [Firebase C++ SDK](https://github.com/firebase/firebase-cpp-sdk) for Linux.

# Usage

To use this package, you need to include `cloud_functions_tizen` as a dependency alongside `cloud_functions` and `cloud_functions_platform_interface` in your `pubspec.yaml`. Please note that `cloud_functions_tizen` implementation is not officially endorsed for `cloud_functions`.

```yaml
dependencies:
cloud_functions: 4.0.7
cloud_functions_tizen: ^0.1.0
```
Then you can import `cloud_functions` in your Dart code:

```dart
import 'package:cloud_functions/cloud_functions.dart';
```

# Limitations

The following features are currently unavailable as they're not supported by the version of Firebase C++ SDK for Linux that this plugin is currently based on.

- Using `HttpsCallableOptions#timeout` for an HttpsCallable instance's options.

# Known bugs

- The code and details of `FirebaseFunctionsException` aren't properly provided.
11 changes: 11 additions & 0 deletions packages/cloud_functions/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# in the LICENSE file.

include: ../../analysis_options.yaml

linter:
rules:
public_member_api_docs: false
depend_on_referenced_packages: false
library_private_types_in_public_api: false
37 changes: 37 additions & 0 deletions packages/cloud_functions/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# VS Code related
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json
75 changes: 75 additions & 0 deletions packages/cloud_functions/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Example

A test app for cloud function plugin (e2e).

## Prerequisites

1. Configure [the Firebase Options](https://pub.dev/documentation/firebase_core_platform_interface/latest/firebase_core_platform_interface/FirebaseOptions-class.html) below.

```dart
// {plugin_example_path}/lib/firebase_options.dart
static const FirebaseOptions tizen = FirebaseOptions(
apiKey: 'PLACEHOLDER',
appId: 'PLACEHOLDER',
messagingSenderId: 'PLACEHOLDER',
projectId: 'PLACEHOLDER',
databaseURL: 'PLACEHOLDER',
storageBucket: 'PLACEHOLDER',
);
```

2. Configure the Firebase emulator.

To test Cloud Functions, use the emulator. Run the command below to go to the path where you can run a test app on the emulator.

```shell
$ cd tools/emulator/functions
```

Configure your connection address and projectId.

```dart
// example/lib/firebase_options.dart
static String get emulatorHost {
return 'XX.XXX.XXX.XXX';
}
```

```json
// tools/emulator/firebase.json
{
"emulators": {
"functions": {
"port": 5001,
"host": "XX.XXX.XXX.XXX"
}
...
}
}
```

```json
// tools/emulator/.firebaserc
{
"projects": {
"default": "PLACEHOLDER"
}
}
```

3. Run the Firebase emulator for cloud functions.

```shell
$ cd tools/emulator/functions

# `npm install` is required at the first time.

$ npm run serve

┌───────────┬─────────────────────┬──────────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├───────────┼─────────────────────┼──────────────────────────────────────┤
│ Functions │ XX.XXX.XXX.XXX:5001 │ http://XX.XXX.XXX.XXX:4000/functions │
└───────────┴─────────────────────┴──────────────────────────────────────┘
```
1 change: 1 addition & 0 deletions packages/cloud_functions/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: ../analysis_options.yaml
Loading

0 comments on commit 73b551d

Please sign in to comment.