@capacitor-firebase/functions 6.0.0-dev.b96fa6c.1718781196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorFirebaseFunctions.podspec +19 -0
- package/README.md +129 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctions.java +60 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctionsPlugin.java +90 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByNameOptions.java +19 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByUrlOptions.java +19 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallOptions.java +18 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/results/CallResult.java +25 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/EmptyResultCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/Result.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/ResultCallback.java +5 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +131 -0
- package/dist/esm/definitions.d.ts +18 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +21 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +37 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +39 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/CallByNameOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/CallByUrlOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/CallOptions.swift +13 -0
- package/ios/Plugin/Classes/Results/CallResult.swift +16 -0
- package/ios/Plugin/FirebaseFunctions.swift +47 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.h +10 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.m +9 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.swift +59 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/package.json +99 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorFirebaseFunctions'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.dependency 'FirebaseFunctions', '~> 10.25'
|
|
17
|
+
s.swift_version = '5.1'
|
|
18
|
+
s.static_framework = true
|
|
19
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# @capacitor-firebase/functions
|
|
2
|
+
|
|
3
|
+
Unofficial Capacitor plugin for [Firebase Cloud Functions](https://firebase.google.com/docs/functions/).[^1]
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @capacitor-firebase/functions
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Add Firebase to your project if you haven't already ([Android](https://firebase.google.com/docs/android/setup) / [iOS](https://firebase.google.com/docs/ios/setup)).
|
|
13
|
+
|
|
14
|
+
### Android
|
|
15
|
+
|
|
16
|
+
#### Variables
|
|
17
|
+
|
|
18
|
+
This plugin will use the following project variables (defined in your app’s `variables.gradle` file):
|
|
19
|
+
|
|
20
|
+
- `$firebaseFunctionsVersion` version of `com.google.firebase:firebase-functions` (default: `20.4.0`)
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
No configuration required for this plugin.
|
|
25
|
+
|
|
26
|
+
## Demo
|
|
27
|
+
|
|
28
|
+
A working example can be found here: [robingenz/capacitor-firebase-plugin-demo](https://github.com/robingenz/capacitor-firebase-plugin-demo)
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { FirebaseFunctions } from '@capacitor-firebase/functions';
|
|
34
|
+
|
|
35
|
+
const echo = async () => {
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
<docgen-index>
|
|
42
|
+
|
|
43
|
+
* [`callByName(...)`](#callbyname)
|
|
44
|
+
* [`callByUrl(...)`](#callbyurl)
|
|
45
|
+
* [Interfaces](#interfaces)
|
|
46
|
+
* [Type Aliases](#type-aliases)
|
|
47
|
+
|
|
48
|
+
</docgen-index>
|
|
49
|
+
|
|
50
|
+
<docgen-api>
|
|
51
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
52
|
+
|
|
53
|
+
### callByName(...)
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
callByName(options: CallByNameOptions) => Promise<CallByNameResult>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Param | Type |
|
|
60
|
+
| ------------- | --------------------------------------------------------------- |
|
|
61
|
+
| **`options`** | <code><a href="#callbynameoptions">CallByNameOptions</a></code> |
|
|
62
|
+
|
|
63
|
+
**Returns:** <code>Promise<<a href="#callresult">CallResult</a>></code>
|
|
64
|
+
|
|
65
|
+
--------------------
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### callByUrl(...)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
callByUrl(options: CallByUrlOptions) => Promise<CallByUrlResult>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| Param | Type |
|
|
75
|
+
| ------------- | ------------------------------------------------------------- |
|
|
76
|
+
| **`options`** | <code><a href="#callbyurloptions">CallByUrlOptions</a></code> |
|
|
77
|
+
|
|
78
|
+
**Returns:** <code>Promise<<a href="#callresult">CallResult</a>></code>
|
|
79
|
+
|
|
80
|
+
--------------------
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Interfaces
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
#### CallResult
|
|
87
|
+
|
|
88
|
+
| Prop | Type |
|
|
89
|
+
| ---------- | ---------------- |
|
|
90
|
+
| **`data`** | <code>any</code> |
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
#### CallByNameOptions
|
|
94
|
+
|
|
95
|
+
| Prop | Type |
|
|
96
|
+
| ---------- | ------------------- |
|
|
97
|
+
| **`name`** | <code>string</code> |
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
#### CallByUrlOptions
|
|
101
|
+
|
|
102
|
+
| Prop | Type |
|
|
103
|
+
| --------- | ------------------- |
|
|
104
|
+
| **`url`** | <code>string</code> |
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Type Aliases
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
#### CallByNameResult
|
|
111
|
+
|
|
112
|
+
<code><a href="#callresult">CallResult</a></code>
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
#### CallByUrlResult
|
|
116
|
+
|
|
117
|
+
<code><a href="#callresult">CallResult</a></code>
|
|
118
|
+
|
|
119
|
+
</docgen-api>
|
|
120
|
+
|
|
121
|
+
## Changelog
|
|
122
|
+
|
|
123
|
+
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/functions/CHANGELOG.md).
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
See [LICENSE](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/functions/LICENSE).
|
|
128
|
+
|
|
129
|
+
[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
firebaseFunctionsVersion = project.hasProperty('firebaseFunctionsVersion') ? rootProject.ext.firebaseFunctionsVersion : '20.4.0'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
buildscript {
|
|
10
|
+
repositories {
|
|
11
|
+
google()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
}
|
|
14
|
+
dependencies {
|
|
15
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
apply plugin: 'com.android.library'
|
|
20
|
+
|
|
21
|
+
android {
|
|
22
|
+
namespace "io.capawesome.capacitorjs.plugins.firebase.functions"
|
|
23
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
24
|
+
defaultConfig {
|
|
25
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
26
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
27
|
+
versionCode 1
|
|
28
|
+
versionName "1.0"
|
|
29
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
30
|
+
}
|
|
31
|
+
buildTypes {
|
|
32
|
+
release {
|
|
33
|
+
minifyEnabled false
|
|
34
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
lintOptions {
|
|
38
|
+
abortOnError false
|
|
39
|
+
}
|
|
40
|
+
compileOptions {
|
|
41
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
42
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
repositories {
|
|
47
|
+
google()
|
|
48
|
+
mavenCentral()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
dependencies {
|
|
53
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
54
|
+
implementation project(':capacitor-android')
|
|
55
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
|
+
implementation "com.google.firebase:firebase-functions:$firebaseFunctionsVersion"
|
|
57
|
+
testImplementation "junit:junit:$junitVersion"
|
|
58
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
59
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
60
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByNameOptions;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByUrlOptions;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.results.CallResult;
|
|
7
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.NonEmptyResultCallback;
|
|
8
|
+
|
|
9
|
+
public class FirebaseFunctions {
|
|
10
|
+
|
|
11
|
+
private FirebaseFunctionsPlugin plugin;
|
|
12
|
+
|
|
13
|
+
public FirebaseFunctions(FirebaseFunctionsPlugin plugin) {
|
|
14
|
+
this.plugin = plugin;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public void callByName(@NonNull CallByNameOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
18
|
+
String name = options.getName();
|
|
19
|
+
Object data = options.getData();
|
|
20
|
+
|
|
21
|
+
getFirebaseFunctionsInstance()
|
|
22
|
+
.getHttpsCallable(name)
|
|
23
|
+
.call(data)
|
|
24
|
+
.addOnSuccessListener(
|
|
25
|
+
task -> {
|
|
26
|
+
CallResult result = new CallResult(task.getData());
|
|
27
|
+
callback.success(result);
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
.addOnFailureListener(
|
|
31
|
+
exception -> {
|
|
32
|
+
callback.error(exception);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public void callByUrl(@NonNull CallByUrlOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
38
|
+
String url = options.getUrl();
|
|
39
|
+
Object data = options.getData();
|
|
40
|
+
|
|
41
|
+
getFirebaseFunctionsInstance()
|
|
42
|
+
.getHttpsCallable(url)
|
|
43
|
+
.call(data)
|
|
44
|
+
.addOnSuccessListener(
|
|
45
|
+
task -> {
|
|
46
|
+
CallResult result = new CallResult(task.getData());
|
|
47
|
+
callback.success(result);
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
.addOnFailureListener(
|
|
51
|
+
exception -> {
|
|
52
|
+
callback.error(exception);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private com.google.firebase.functions.FirebaseFunctions getFirebaseFunctionsInstance() {
|
|
58
|
+
return com.google.firebase.functions.FirebaseFunctions.getInstance();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Logger;
|
|
5
|
+
import com.getcapacitor.Plugin;
|
|
6
|
+
import com.getcapacitor.PluginCall;
|
|
7
|
+
import com.getcapacitor.PluginMethod;
|
|
8
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByNameOptions;
|
|
10
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByUrlOptions;
|
|
11
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.NonEmptyResultCallback;
|
|
12
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.Result;
|
|
13
|
+
|
|
14
|
+
@CapacitorPlugin(name = "FirebaseFunctions")
|
|
15
|
+
public class FirebaseFunctionsPlugin extends Plugin {
|
|
16
|
+
|
|
17
|
+
public static final String TAG = "FirebaseFunctions";
|
|
18
|
+
public static final String ERROR_NAME_MISSING = "name must be provided.";
|
|
19
|
+
public static final String ERROR_URL_MISSING = "url must be provided.";
|
|
20
|
+
|
|
21
|
+
private FirebaseFunctions implementation;
|
|
22
|
+
|
|
23
|
+
public void load() {
|
|
24
|
+
implementation = new FirebaseFunctions(this);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@PluginMethod
|
|
28
|
+
public void callByName(PluginCall call) {
|
|
29
|
+
try {
|
|
30
|
+
JSObject json = call.getData();
|
|
31
|
+
String name = json.getString("name");
|
|
32
|
+
if (name == null) {
|
|
33
|
+
call.reject(ERROR_NAME_MISSING);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
Object data = json.opt("data");
|
|
37
|
+
|
|
38
|
+
CallByNameOptions options = new CallByNameOptions(name, data);
|
|
39
|
+
NonEmptyResultCallback callback = new NonEmptyResultCallback() {
|
|
40
|
+
@Override
|
|
41
|
+
public void success(Result result) {
|
|
42
|
+
call.resolve(result.toJSObject());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
public void error(Exception exception) {
|
|
47
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
48
|
+
call.reject(exception.getMessage());
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
implementation.callByName(options, callback);
|
|
53
|
+
} catch (Exception exception) {
|
|
54
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
55
|
+
call.reject(exception.getMessage());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@PluginMethod
|
|
60
|
+
public void callByUrl(PluginCall call) {
|
|
61
|
+
try {
|
|
62
|
+
JSObject json = call.getData();
|
|
63
|
+
String url = json.getString("url");
|
|
64
|
+
if (url == null) {
|
|
65
|
+
call.reject(ERROR_URL_MISSING);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
Object data = json.opt("data");
|
|
69
|
+
|
|
70
|
+
CallByUrlOptions options = new CallByUrlOptions(url, data);
|
|
71
|
+
NonEmptyResultCallback callback = new NonEmptyResultCallback() {
|
|
72
|
+
@Override
|
|
73
|
+
public void success(Result result) {
|
|
74
|
+
call.resolve(result.toJSObject());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Override
|
|
78
|
+
public void error(Exception exception) {
|
|
79
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
80
|
+
call.reject(exception.getMessage());
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
implementation.callByUrl(options, callback);
|
|
85
|
+
} catch (Exception exception) {
|
|
86
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
87
|
+
call.reject(exception.getMessage());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
public class CallByNameOptions extends CallOptions {
|
|
6
|
+
|
|
7
|
+
@NonNull
|
|
8
|
+
private String name;
|
|
9
|
+
|
|
10
|
+
public CallByNameOptions(@NonNull String name, Object data) {
|
|
11
|
+
super(data);
|
|
12
|
+
this.name = name;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@NonNull
|
|
16
|
+
public String getName() {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
public class CallByUrlOptions extends CallOptions {
|
|
6
|
+
|
|
7
|
+
@NonNull
|
|
8
|
+
private String url;
|
|
9
|
+
|
|
10
|
+
public CallByUrlOptions(@NonNull String url, Object data) {
|
|
11
|
+
super(data);
|
|
12
|
+
this.url = url;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@NonNull
|
|
16
|
+
public String getUrl() {
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
|
|
5
|
+
public class CallOptions {
|
|
6
|
+
|
|
7
|
+
@Nullable
|
|
8
|
+
private Object data;
|
|
9
|
+
|
|
10
|
+
public CallOptions(@Nullable Object data) {
|
|
11
|
+
this.data = data;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Nullable
|
|
15
|
+
public Object getData() {
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.Result;
|
|
7
|
+
|
|
8
|
+
public class CallResult implements Result {
|
|
9
|
+
|
|
10
|
+
@Nullable
|
|
11
|
+
private Object data;
|
|
12
|
+
|
|
13
|
+
public CallResult(@Nullable Object data) {
|
|
14
|
+
this.data = data;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@NonNull
|
|
18
|
+
public JSObject toJSObject() {
|
|
19
|
+
Object dataResult = this.data;
|
|
20
|
+
|
|
21
|
+
JSObject result = new JSObject();
|
|
22
|
+
result.put("data", dataResult);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "FirebaseFunctionsPlugin",
|
|
4
|
+
"slug": "firebasefunctionsplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "callByName",
|
|
10
|
+
"signature": "(options: CallByNameOptions) => Promise<CallByNameResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "CallByNameOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<CallResult>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"CallResult",
|
|
23
|
+
"CallByNameOptions",
|
|
24
|
+
"CallByNameResult"
|
|
25
|
+
],
|
|
26
|
+
"slug": "callbyname"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "callByUrl",
|
|
30
|
+
"signature": "(options: CallByUrlOptions) => Promise<CallByUrlResult>",
|
|
31
|
+
"parameters": [
|
|
32
|
+
{
|
|
33
|
+
"name": "options",
|
|
34
|
+
"docs": "",
|
|
35
|
+
"type": "CallByUrlOptions"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"returns": "Promise<CallResult>",
|
|
39
|
+
"tags": [],
|
|
40
|
+
"docs": "",
|
|
41
|
+
"complexTypes": [
|
|
42
|
+
"CallResult",
|
|
43
|
+
"CallByUrlOptions",
|
|
44
|
+
"CallByUrlResult"
|
|
45
|
+
],
|
|
46
|
+
"slug": "callbyurl"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"properties": []
|
|
50
|
+
},
|
|
51
|
+
"interfaces": [
|
|
52
|
+
{
|
|
53
|
+
"name": "CallResult",
|
|
54
|
+
"slug": "callresult",
|
|
55
|
+
"docs": "",
|
|
56
|
+
"tags": [],
|
|
57
|
+
"methods": [],
|
|
58
|
+
"properties": [
|
|
59
|
+
{
|
|
60
|
+
"name": "data",
|
|
61
|
+
"tags": [],
|
|
62
|
+
"docs": "",
|
|
63
|
+
"complexTypes": [],
|
|
64
|
+
"type": "any"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "CallByNameOptions",
|
|
70
|
+
"slug": "callbynameoptions",
|
|
71
|
+
"docs": "",
|
|
72
|
+
"tags": [],
|
|
73
|
+
"methods": [],
|
|
74
|
+
"properties": [
|
|
75
|
+
{
|
|
76
|
+
"name": "name",
|
|
77
|
+
"tags": [],
|
|
78
|
+
"docs": "",
|
|
79
|
+
"complexTypes": [],
|
|
80
|
+
"type": "string"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "CallByUrlOptions",
|
|
86
|
+
"slug": "callbyurloptions",
|
|
87
|
+
"docs": "",
|
|
88
|
+
"tags": [],
|
|
89
|
+
"methods": [],
|
|
90
|
+
"properties": [
|
|
91
|
+
{
|
|
92
|
+
"name": "url",
|
|
93
|
+
"tags": [],
|
|
94
|
+
"docs": "",
|
|
95
|
+
"complexTypes": [],
|
|
96
|
+
"type": "string"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"enums": [],
|
|
102
|
+
"typeAliases": [
|
|
103
|
+
{
|
|
104
|
+
"name": "CallByNameResult",
|
|
105
|
+
"slug": "callbynameresult",
|
|
106
|
+
"docs": "",
|
|
107
|
+
"types": [
|
|
108
|
+
{
|
|
109
|
+
"text": "CallResult",
|
|
110
|
+
"complexTypes": [
|
|
111
|
+
"CallResult"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "CallByUrlResult",
|
|
118
|
+
"slug": "callbyurlresult",
|
|
119
|
+
"docs": "",
|
|
120
|
+
"types": [
|
|
121
|
+
{
|
|
122
|
+
"text": "CallResult",
|
|
123
|
+
"complexTypes": [
|
|
124
|
+
"CallResult"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"pluginConfigs": []
|
|
131
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface FirebaseFunctionsPlugin {
|
|
2
|
+
callByName(options: CallByNameOptions): Promise<CallByNameResult>;
|
|
3
|
+
callByUrl(options: CallByUrlOptions): Promise<CallByUrlResult>;
|
|
4
|
+
}
|
|
5
|
+
export interface CallByNameOptions extends CallOptions {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export declare type CallByNameResult = CallResult;
|
|
9
|
+
export interface CallByUrlOptions extends CallOptions {
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
12
|
+
export declare type CallByUrlResult = CallResult;
|
|
13
|
+
export interface CallOptions {
|
|
14
|
+
data?: any;
|
|
15
|
+
}
|
|
16
|
+
export interface CallResult {
|
|
17
|
+
data?: any;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface FirebaseFunctionsPlugin {\n callByName(options: CallByNameOptions): Promise<CallByNameResult>;\n callByUrl(options: CallByUrlOptions): Promise<CallByUrlResult>;\n}\n\nexport interface CallByNameOptions extends CallOptions {\n name: string;\n}\n\nexport type CallByNameResult = CallResult;\n\nexport interface CallByUrlOptions extends CallOptions {\n url: string;\n}\n\nexport type CallByUrlResult = CallResult;\n\nexport interface CallOptions {\n data?: any;\n}\n\nexport interface CallResult {\n data?: any;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const FirebaseFunctions = registerPlugin('FirebaseFunctions', {
|
|
3
|
+
web: () => import('./web').then(m => new m.FirebaseFunctionsWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { FirebaseFunctions };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,iBAAiB,GAAG,cAAc,CACtC,mBAAmB,EACnB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;CACnE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { FirebaseFunctionsPlugin } from './definitions';\n\nconst FirebaseFunctions = registerPlugin<FirebaseFunctionsPlugin>(\n 'FirebaseFunctions',\n {\n web: () => import('./web').then(m => new m.FirebaseFunctionsWeb()),\n },\n);\n\nexport * from './definitions';\nexport { FirebaseFunctions };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { CallByNameOptions, CallByNameResult, CallByUrlOptions, CallResult, FirebaseFunctionsPlugin } from './definitions';
|
|
3
|
+
export declare class FirebaseFunctionsWeb extends WebPlugin implements FirebaseFunctionsPlugin {
|
|
4
|
+
callByName(options: CallByNameOptions): Promise<CallByNameResult>;
|
|
5
|
+
callByUrl(options: CallByUrlOptions): Promise<CallResult>;
|
|
6
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import { getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';
|
|
3
|
+
export class FirebaseFunctionsWeb extends WebPlugin {
|
|
4
|
+
async callByName(options) {
|
|
5
|
+
const functions = getFunctions();
|
|
6
|
+
const callable = httpsCallable(functions, options.name);
|
|
7
|
+
const result = await callable(options.data);
|
|
8
|
+
return {
|
|
9
|
+
data: result.data,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
async callByUrl(options) {
|
|
13
|
+
const functions = getFunctions();
|
|
14
|
+
const callable = httpsCallableFromURL(functions, options.url);
|
|
15
|
+
const result = await callable(options.data);
|
|
16
|
+
return {
|
|
17
|
+
data: result.data,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAU5B,MAAM,OAAO,oBACX,SAAQ,SAAS;IAGV,KAAK,CAAC,UAAU,CACrB,OAA0B;QAE1B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,OAAyB;QAC9C,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,oBAAoB,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport {\n getFunctions,\n httpsCallable,\n httpsCallableFromURL,\n} from 'firebase/functions';\n\nimport type {\n CallByNameOptions,\n CallByNameResult,\n CallByUrlOptions,\n CallResult,\n FirebaseFunctionsPlugin,\n} from './definitions';\n\nexport class FirebaseFunctionsWeb\n extends WebPlugin\n implements FirebaseFunctionsPlugin\n{\n public async callByName(\n options: CallByNameOptions,\n ): Promise<CallByNameResult> {\n const functions = getFunctions();\n const callable = httpsCallable(functions, options.name);\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n\n public async callByUrl(options: CallByUrlOptions): Promise<CallResult> {\n const functions = getFunctions();\n const callable = httpsCallableFromURL(functions, options.url);\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
var functions = require('firebase/functions');
|
|
7
|
+
|
|
8
|
+
const FirebaseFunctions = core.registerPlugin('FirebaseFunctions', {
|
|
9
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FirebaseFunctionsWeb()),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
class FirebaseFunctionsWeb extends core.WebPlugin {
|
|
13
|
+
async callByName(options) {
|
|
14
|
+
const functions$1 = functions.getFunctions();
|
|
15
|
+
const callable = functions.httpsCallable(functions$1, options.name);
|
|
16
|
+
const result = await callable(options.data);
|
|
17
|
+
return {
|
|
18
|
+
data: result.data,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async callByUrl(options) {
|
|
22
|
+
const functions$1 = functions.getFunctions();
|
|
23
|
+
const callable = functions.httpsCallableFromURL(functions$1, options.url);
|
|
24
|
+
const result = await callable(options.data);
|
|
25
|
+
return {
|
|
26
|
+
data: result.data,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
32
|
+
__proto__: null,
|
|
33
|
+
FirebaseFunctionsWeb: FirebaseFunctionsWeb
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.FirebaseFunctions = FirebaseFunctions;
|
|
37
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst FirebaseFunctions = registerPlugin('FirebaseFunctions', {\n web: () => import('./web').then(m => new m.FirebaseFunctionsWeb()),\n});\nexport * from './definitions';\nexport { FirebaseFunctions };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';\nexport class FirebaseFunctionsWeb extends WebPlugin {\n async callByName(options) {\n const functions = getFunctions();\n const callable = httpsCallable(functions, options.name);\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n async callByUrl(options) {\n const functions = getFunctions();\n const callable = httpsCallableFromURL(functions, options.url);\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","functions","getFunctions","httpsCallable","httpsCallableFromURL"],"mappings":";;;;;;;AACK,MAAC,iBAAiB,GAAGA,mBAAc,CAAC,mBAAmB,EAAE;AAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;AACtE,CAAC;;ACDM,MAAM,oBAAoB,SAASC,cAAS,CAAC;AACpD,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B,QAAQ,MAAMC,WAAS,GAAGC,sBAAY,EAAE,CAAC;AACzC,QAAQ,MAAM,QAAQ,GAAGC,uBAAa,CAACF,WAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAChE,QAAQ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACpD,QAAQ,OAAO;AACf,YAAY,IAAI,EAAE,MAAM,CAAC,IAAI;AAC7B,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,MAAMA,WAAS,GAAGC,sBAAY,EAAE,CAAC;AACzC,QAAQ,MAAM,QAAQ,GAAGE,8BAAoB,CAACH,WAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AACtE,QAAQ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACpD,QAAQ,OAAO;AACf,YAAY,IAAI,EAAE,MAAM,CAAC,IAAI;AAC7B,SAAS,CAAC;AACV,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var capacitorFirebaseFunctions = (function (exports, core, functions) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const FirebaseFunctions = core.registerPlugin('FirebaseFunctions', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.FirebaseFunctionsWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class FirebaseFunctionsWeb extends core.WebPlugin {
|
|
9
|
+
async callByName(options) {
|
|
10
|
+
const functions$1 = functions.getFunctions();
|
|
11
|
+
const callable = functions.httpsCallable(functions$1, options.name);
|
|
12
|
+
const result = await callable(options.data);
|
|
13
|
+
return {
|
|
14
|
+
data: result.data,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async callByUrl(options) {
|
|
18
|
+
const functions$1 = functions.getFunctions();
|
|
19
|
+
const callable = functions.httpsCallableFromURL(functions$1, options.url);
|
|
20
|
+
const result = await callable(options.data);
|
|
21
|
+
return {
|
|
22
|
+
data: result.data,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
28
|
+
__proto__: null,
|
|
29
|
+
FirebaseFunctionsWeb: FirebaseFunctionsWeb
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
exports.FirebaseFunctions = FirebaseFunctions;
|
|
33
|
+
|
|
34
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
35
|
+
|
|
36
|
+
return exports;
|
|
37
|
+
|
|
38
|
+
})({}, capacitorExports, functions);
|
|
39
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst FirebaseFunctions = registerPlugin('FirebaseFunctions', {\n web: () => import('./web').then(m => new m.FirebaseFunctionsWeb()),\n});\nexport * from './definitions';\nexport { FirebaseFunctions };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';\nexport class FirebaseFunctionsWeb extends WebPlugin {\n async callByName(options) {\n const functions = getFunctions();\n const callable = httpsCallable(functions, options.name);\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n async callByUrl(options) {\n const functions = getFunctions();\n const callable = httpsCallableFromURL(functions, options.url);\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","functions","getFunctions","httpsCallable","httpsCallableFromURL"],"mappings":";;;AACK,UAAC,iBAAiB,GAAGA,mBAAc,CAAC,mBAAmB,EAAE;IAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACtE,CAAC;;ICDM,MAAM,oBAAoB,SAASC,cAAS,CAAC;IACpD,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B,QAAQ,MAAMC,WAAS,GAAGC,sBAAY,EAAE,CAAC;IACzC,QAAQ,MAAM,QAAQ,GAAGC,uBAAa,CAACF,WAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,QAAQ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,QAAQ,OAAO;IACf,YAAY,IAAI,EAAE,MAAM,CAAC,IAAI;IAC7B,SAAS,CAAC;IACV,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;IAC7B,QAAQ,MAAMA,WAAS,GAAGC,sBAAY,EAAE,CAAC;IACzC,QAAQ,MAAM,QAAQ,GAAGE,8BAAoB,CAACH,WAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE,QAAQ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,QAAQ,OAAO;IACf,YAAY,IAAI,EAAE,MAAM,CAAC,IAAI;IAC7B,SAAS,CAAC;IACV,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class CallResult: NSObject, Result {
|
|
5
|
+
private var data: Any?
|
|
6
|
+
|
|
7
|
+
init(data: Any?) {
|
|
8
|
+
self.data = data
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["data"] = data as! any JSValue
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import FirebaseCore
|
|
3
|
+
import FirebaseFunctions
|
|
4
|
+
|
|
5
|
+
@objc public class FirebaseFunctions: NSObject {
|
|
6
|
+
private let plugin: FirebaseFunctionsPlugin
|
|
7
|
+
|
|
8
|
+
init(plugin: FirebaseFunctionsPlugin) {
|
|
9
|
+
self.plugin = plugin
|
|
10
|
+
super.init()
|
|
11
|
+
if FirebaseApp.app() == nil {
|
|
12
|
+
FirebaseApp.configure()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@objc public func callByName(_ options: CallByNameOptions, completion: @escaping (Result?, Error?) -> Void) {
|
|
17
|
+
let name = options.getName()
|
|
18
|
+
let data = options.getData()
|
|
19
|
+
|
|
20
|
+
let functions = Functions.functions()
|
|
21
|
+
let callable = functions.httpsCallable(name)
|
|
22
|
+
callable.call(data) { (result, error) in
|
|
23
|
+
if let error = error {
|
|
24
|
+
completion(nil, error)
|
|
25
|
+
} else {
|
|
26
|
+
let result = CallResult(data: result?.data)
|
|
27
|
+
completion(result, nil)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc public func callByUrl(_ options: CallByUrlOptions, completion: @escaping (Result?, Error?) -> Void) {
|
|
33
|
+
let url = options.getUrl()
|
|
34
|
+
let data = options.getData()
|
|
35
|
+
|
|
36
|
+
let functions = Functions.functions()
|
|
37
|
+
let callable = functions.httpsCallable(url)
|
|
38
|
+
callable.call(data) { (result, error) in
|
|
39
|
+
if let error = error {
|
|
40
|
+
completion(nil, error)
|
|
41
|
+
} else {
|
|
42
|
+
let result = CallResult(data: result?.data)
|
|
43
|
+
completion(result, nil)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(FirebaseFunctionsPlugin, "FirebaseFunctions",
|
|
7
|
+
CAP_PLUGIN_METHOD(callByName, CAPPluginReturnPromise);
|
|
8
|
+
CAP_PLUGIN_METHOD(callByUrl, CAPPluginReturnPromise);
|
|
9
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(FirebaseFunctionsPlugin)
|
|
9
|
+
public class FirebaseFunctionsPlugin: CAPPlugin {
|
|
10
|
+
public let tag = "FirebaseFunctions"
|
|
11
|
+
public let errorNameMissing = "name must be provided."
|
|
12
|
+
private var implementation: FirebaseFunctions?
|
|
13
|
+
|
|
14
|
+
override public func load() {
|
|
15
|
+
self.implementation = FirebaseFunctions(plugin: self)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@objc func callByName(_ call: CAPPluginCall) {
|
|
19
|
+
guard let name = call.getString("name") else {
|
|
20
|
+
call.reject(errorNameMissing)
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
let data = call.getValue("data")
|
|
24
|
+
|
|
25
|
+
let options = CallByNameOptions(name: name, data: data)
|
|
26
|
+
|
|
27
|
+
implementation?.callByName(options, completion: { result, error in
|
|
28
|
+
if let error = error {
|
|
29
|
+
CAPLog.print("[", self.tag, "] ", error)
|
|
30
|
+
call.reject(error.localizedDescription)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
34
|
+
call.resolve(result)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@objc func callByUrl(_ call: CAPPluginCall) {
|
|
40
|
+
guard let url = call.getString("url") else {
|
|
41
|
+
call.reject("url must be provided.")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
let data = call.getValue("data")
|
|
45
|
+
|
|
46
|
+
let options = CallByUrlOptions(url: url, data: data)
|
|
47
|
+
|
|
48
|
+
implementation?.callByUrl(options, completion: { result, error in
|
|
49
|
+
if let error = error {
|
|
50
|
+
CAPLog.print("[", self.tag, "] ", error)
|
|
51
|
+
call.reject(error.localizedDescription)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
55
|
+
call.resolve(result)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capacitor-firebase/functions",
|
|
3
|
+
"version": "6.0.0-dev.b96fa6c.1718781196",
|
|
4
|
+
"description": "Capacitor plugin for Firebase Cloud Functions.",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"CapacitorFirebaseFunctions.podspec"
|
|
15
|
+
],
|
|
16
|
+
"author": "Robin Genz <mail@robingenz.dev>",
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"homepage": "https://capawesome.io/",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/capawesome-team/capacitor-firebase.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/capawesome-team/capacitor-firebase/issues"
|
|
25
|
+
},
|
|
26
|
+
"funding": [
|
|
27
|
+
{
|
|
28
|
+
"type": "github",
|
|
29
|
+
"url": "https://github.com/sponsors/capawesome-team/"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "opencollective",
|
|
33
|
+
"url": "https://opencollective.com/capawesome"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"keywords": [
|
|
37
|
+
"capacitor",
|
|
38
|
+
"plugin",
|
|
39
|
+
"native"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
43
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
44
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
45
|
+
"verify:web": "npm run build",
|
|
46
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
47
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
48
|
+
"eslint": "eslint . --ext ts",
|
|
49
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
50
|
+
"swiftlint": "node-swiftlint",
|
|
51
|
+
"docgen": "docgen --api FirebaseFunctionsPlugin --output-readme README.md --output-json dist/docs.json",
|
|
52
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
53
|
+
"clean": "rimraf ./dist",
|
|
54
|
+
"watch": "tsc --watch",
|
|
55
|
+
"ios:pod:install": "cd ios && pod install --repo-update && cd ..",
|
|
56
|
+
"prepublishOnly": "npm run build"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@capacitor/android": "6.0.0",
|
|
60
|
+
"@capacitor/cli": "6.0.0",
|
|
61
|
+
"@capacitor/core": "6.0.0",
|
|
62
|
+
"@capacitor/docgen": "0.2.1",
|
|
63
|
+
"@capacitor/ios": "6.0.0",
|
|
64
|
+
"@ionic/eslint-config": "0.3.0",
|
|
65
|
+
"@ionic/swiftlint-config": "1.1.2",
|
|
66
|
+
"eslint": "7.32.0",
|
|
67
|
+
"firebase": "10.9.0",
|
|
68
|
+
"prettier": "2.3.2",
|
|
69
|
+
"prettier-plugin-java": "1.0.2",
|
|
70
|
+
"rimraf": "3.0.2",
|
|
71
|
+
"rollup": "2.77.2",
|
|
72
|
+
"swiftlint": "1.0.1",
|
|
73
|
+
"typescript": "4.1.5"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@capacitor/core": "^6.0.0",
|
|
77
|
+
"firebase": "^10.9.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"firebase": {
|
|
81
|
+
"optional": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
85
|
+
"eslintConfig": {
|
|
86
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
87
|
+
},
|
|
88
|
+
"capacitor": {
|
|
89
|
+
"ios": {
|
|
90
|
+
"src": "ios"
|
|
91
|
+
},
|
|
92
|
+
"android": {
|
|
93
|
+
"src": "android"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public"
|
|
98
|
+
}
|
|
99
|
+
}
|