@capacitor-firebase/functions 6.0.0-dev.b96fa6c.1718781196 → 6.2.0
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 +1 -1
- package/README.md +103 -22
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctions.java +17 -6
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctionsPlugin.java +22 -2
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByNameOptions.java +11 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByUrlOptions.java +6 -4
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/results/CallResult.java +43 -1
- package/dist/docs.json +172 -29
- package/dist/esm/definitions.d.ts +105 -10
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -3
- package/dist/esm/web.js +7 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +6 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +6 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Classes/Options/CallByNameOptions.swift +7 -1
- package/ios/Plugin/Classes/Results/CallResult.swift +11 -1
- package/ios/Plugin/FirebaseFunctions.swift +11 -1
- package/ios/Plugin/FirebaseFunctionsPlugin.m +1 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.swift +14 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'FirebaseFunctions', '~>
|
|
16
|
+
s.dependency 'FirebaseFunctions', '~> 11.0'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
s.static_framework = true
|
|
19
19
|
end
|
package/README.md
CHANGED
|
@@ -32,7 +32,43 @@ A working example can be found here: [robingenz/capacitor-firebase-plugin-demo](
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { FirebaseFunctions } from '@capacitor-firebase/functions';
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const callByName = async () => {
|
|
36
|
+
const { data } = await FirebaseFunctions.callByName({
|
|
37
|
+
name: 'helloWorld',
|
|
38
|
+
data: {
|
|
39
|
+
string: 'Hello World!',
|
|
40
|
+
number: 123,
|
|
41
|
+
boolean: true,
|
|
42
|
+
array: [1, 2, 3],
|
|
43
|
+
object: {
|
|
44
|
+
key: 'value'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const callByUrl = async () => {
|
|
52
|
+
const { data } = await FirebaseFunctions.callByUrl({
|
|
53
|
+
url: 'https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/helloWorld',
|
|
54
|
+
data: {
|
|
55
|
+
string: 'Hello World!',
|
|
56
|
+
number: 123,
|
|
57
|
+
boolean: true,
|
|
58
|
+
array: [1, 2, 3],
|
|
59
|
+
object: {
|
|
60
|
+
key: 'value'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return data;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const useEmulator = async () => {
|
|
68
|
+
await FirebaseFunctions.useEmulator({
|
|
69
|
+
host: '10.0.2.2',
|
|
70
|
+
port: 9001,
|
|
71
|
+
});
|
|
36
72
|
};
|
|
37
73
|
```
|
|
38
74
|
|
|
@@ -42,6 +78,7 @@ const echo = async () => {
|
|
|
42
78
|
|
|
43
79
|
* [`callByName(...)`](#callbyname)
|
|
44
80
|
* [`callByUrl(...)`](#callbyurl)
|
|
81
|
+
* [`useEmulator(...)`](#useemulator)
|
|
45
82
|
* [Interfaces](#interfaces)
|
|
46
83
|
* [Type Aliases](#type-aliases)
|
|
47
84
|
|
|
@@ -53,14 +90,18 @@ const echo = async () => {
|
|
|
53
90
|
### callByName(...)
|
|
54
91
|
|
|
55
92
|
```typescript
|
|
56
|
-
callByName(options: CallByNameOptions) => Promise<CallByNameResult
|
|
93
|
+
callByName<RequestData = unknown, ResponseData = unknown>(options: CallByNameOptions<RequestData>) => Promise<CallByNameResult<ResponseData>>
|
|
57
94
|
```
|
|
58
95
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
|
96
|
+
Call a callable function by name.
|
|
97
|
+
|
|
98
|
+
| Param | Type |
|
|
99
|
+
| ------------- | ---------------------------------------------------------------------------------- |
|
|
100
|
+
| **`options`** | <code><a href="#callbynameoptions">CallByNameOptions</a><RequestData></code> |
|
|
101
|
+
|
|
102
|
+
**Returns:** <code>Promise<<a href="#callbynameresult">CallByNameResult</a><ResponseData>></code>
|
|
62
103
|
|
|
63
|
-
**
|
|
104
|
+
**Since:** 6.1.0
|
|
64
105
|
|
|
65
106
|
--------------------
|
|
66
107
|
|
|
@@ -68,14 +109,45 @@ callByName(options: CallByNameOptions) => Promise<CallByNameResult>
|
|
|
68
109
|
### callByUrl(...)
|
|
69
110
|
|
|
70
111
|
```typescript
|
|
71
|
-
callByUrl(options: CallByUrlOptions) => Promise<CallByUrlResult
|
|
112
|
+
callByUrl<RequestData = unknown, ResponseData = unknown>(options: CallByUrlOptions<RequestData>) => Promise<CallByUrlResult<ResponseData>>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Call a callable function by URL.
|
|
116
|
+
|
|
117
|
+
| Param | Type |
|
|
118
|
+
| ------------- | -------------------------------------------------------------------------------- |
|
|
119
|
+
| **`options`** | <code><a href="#callbyurloptions">CallByUrlOptions</a><RequestData></code> |
|
|
120
|
+
|
|
121
|
+
**Returns:** <code>Promise<<a href="#callbyurlresult">CallByUrlResult</a><ResponseData>></code>
|
|
122
|
+
|
|
123
|
+
**Since:** 6.1.0
|
|
124
|
+
|
|
125
|
+
--------------------
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### useEmulator(...)
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
useEmulator(options: UseEmulatorOptions) => Promise<void>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Instrument your app to talk to the Cloud Functions emulator.
|
|
135
|
+
|
|
136
|
+
On Android, the cleartext traffic must be allowed. On the Capacitor configuration:
|
|
137
|
+
```
|
|
138
|
+
{
|
|
139
|
+
server: {
|
|
140
|
+
cleartext: true
|
|
141
|
+
}
|
|
142
|
+
}
|
|
72
143
|
```
|
|
144
|
+
**The cleartext traffic is not intended for use in production.**
|
|
73
145
|
|
|
74
|
-
| Param | Type
|
|
75
|
-
| ------------- |
|
|
76
|
-
| **`options`** | <code><a href="#
|
|
146
|
+
| Param | Type |
|
|
147
|
+
| ------------- | ----------------------------------------------------------------- |
|
|
148
|
+
| **`options`** | <code><a href="#useemulatoroptions">UseEmulatorOptions</a></code> |
|
|
77
149
|
|
|
78
|
-
**
|
|
150
|
+
**Since:** 6.1.0
|
|
79
151
|
|
|
80
152
|
--------------------
|
|
81
153
|
|
|
@@ -85,23 +157,32 @@ callByUrl(options: CallByUrlOptions) => Promise<CallByUrlResult>
|
|
|
85
157
|
|
|
86
158
|
#### CallResult
|
|
87
159
|
|
|
88
|
-
| Prop | Type
|
|
89
|
-
| ---------- |
|
|
90
|
-
| **`data`** | <code>
|
|
160
|
+
| Prop | Type | Description | Since |
|
|
161
|
+
| ---------- | ------------------------- | ------------------------------------ | ----- |
|
|
162
|
+
| **`data`** | <code>ResponseData</code> | The result of the callable function. | 6.1.0 |
|
|
91
163
|
|
|
92
164
|
|
|
93
165
|
#### CallByNameOptions
|
|
94
166
|
|
|
95
|
-
| Prop
|
|
96
|
-
|
|
|
97
|
-
| **`name`**
|
|
167
|
+
| Prop | Type | Description | Since |
|
|
168
|
+
| ------------ | ------------------- | ------------------------------------ | ----- |
|
|
169
|
+
| **`name`** | <code>string</code> | The name of the callable function. | 6.1.0 |
|
|
170
|
+
| **`region`** | <code>string</code> | The region of the callable function. | 6.1.0 |
|
|
98
171
|
|
|
99
172
|
|
|
100
173
|
#### CallByUrlOptions
|
|
101
174
|
|
|
102
|
-
| Prop | Type |
|
|
103
|
-
| --------- | ------------------- |
|
|
104
|
-
| **`url`** | <code>string</code> |
|
|
175
|
+
| Prop | Type | Description | Since |
|
|
176
|
+
| --------- | ------------------- | --------------------------------- | ----- |
|
|
177
|
+
| **`url`** | <code>string</code> | The URL of the callable function. | 6.1.0 |
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
#### UseEmulatorOptions
|
|
181
|
+
|
|
182
|
+
| Prop | Type | Description | Default | Since |
|
|
183
|
+
| ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- |
|
|
184
|
+
| **`host`** | <code>string</code> | The emulator host without any port or scheme. Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer. | | 6.1.0 |
|
|
185
|
+
| **`port`** | <code>number</code> | The emulator port. | <code>5001</code> | 6.1.0 |
|
|
105
186
|
|
|
106
187
|
|
|
107
188
|
### Type Aliases
|
|
@@ -109,12 +190,12 @@ callByUrl(options: CallByUrlOptions) => Promise<CallByUrlResult>
|
|
|
109
190
|
|
|
110
191
|
#### CallByNameResult
|
|
111
192
|
|
|
112
|
-
<code><a href="#callresult">CallResult</a
|
|
193
|
+
<code><a href="#callresult">CallResult</a><ResponseData></code>
|
|
113
194
|
|
|
114
195
|
|
|
115
196
|
#### CallByUrlResult
|
|
116
197
|
|
|
117
|
-
<code><a href="#callresult">CallResult</a
|
|
198
|
+
<code><a href="#callresult">CallResult</a><ResponseData></code>
|
|
118
199
|
|
|
119
200
|
</docgen-api>
|
|
120
201
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.firebase.functions;
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
4
5
|
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByNameOptions;
|
|
5
6
|
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByUrlOptions;
|
|
6
7
|
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.results.CallResult;
|
|
7
8
|
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.NonEmptyResultCallback;
|
|
9
|
+
import java.net.URL;
|
|
8
10
|
|
|
9
11
|
public class FirebaseFunctions {
|
|
10
12
|
|
|
@@ -16,9 +18,10 @@ public class FirebaseFunctions {
|
|
|
16
18
|
|
|
17
19
|
public void callByName(@NonNull CallByNameOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
18
20
|
String name = options.getName();
|
|
21
|
+
String region = options.getRegion();
|
|
19
22
|
Object data = options.getData();
|
|
20
23
|
|
|
21
|
-
getFirebaseFunctionsInstance()
|
|
24
|
+
getFirebaseFunctionsInstance(region)
|
|
22
25
|
.getHttpsCallable(name)
|
|
23
26
|
.call(data)
|
|
24
27
|
.addOnSuccessListener(
|
|
@@ -35,11 +38,11 @@ public class FirebaseFunctions {
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
public void callByUrl(@NonNull CallByUrlOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
38
|
-
|
|
41
|
+
URL url = options.getUrl();
|
|
39
42
|
Object data = options.getData();
|
|
40
43
|
|
|
41
|
-
getFirebaseFunctionsInstance()
|
|
42
|
-
.
|
|
44
|
+
getFirebaseFunctionsInstance(null)
|
|
45
|
+
.getHttpsCallableFromUrl(url)
|
|
43
46
|
.call(data)
|
|
44
47
|
.addOnSuccessListener(
|
|
45
48
|
task -> {
|
|
@@ -54,7 +57,15 @@ public class FirebaseFunctions {
|
|
|
54
57
|
);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
public void useEmulator(@NonNull String host, int port) {
|
|
61
|
+
getFirebaseFunctionsInstance(null).useEmulator(host, port);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private com.google.firebase.functions.FirebaseFunctions getFirebaseFunctionsInstance(@Nullable String regionOrCustomDomain) {
|
|
65
|
+
if (regionOrCustomDomain == null) {
|
|
66
|
+
return com.google.firebase.functions.FirebaseFunctions.getInstance();
|
|
67
|
+
} else {
|
|
68
|
+
return com.google.firebase.functions.FirebaseFunctions.getInstance(regionOrCustomDomain);
|
|
69
|
+
}
|
|
59
70
|
}
|
|
60
71
|
}
|
|
@@ -17,6 +17,7 @@ public class FirebaseFunctionsPlugin extends Plugin {
|
|
|
17
17
|
public static final String TAG = "FirebaseFunctions";
|
|
18
18
|
public static final String ERROR_NAME_MISSING = "name must be provided.";
|
|
19
19
|
public static final String ERROR_URL_MISSING = "url must be provided.";
|
|
20
|
+
public static final String ERROR_HOST_MISSING = "host must be provided.";
|
|
20
21
|
|
|
21
22
|
private FirebaseFunctions implementation;
|
|
22
23
|
|
|
@@ -28,14 +29,15 @@ public class FirebaseFunctionsPlugin extends Plugin {
|
|
|
28
29
|
public void callByName(PluginCall call) {
|
|
29
30
|
try {
|
|
30
31
|
JSObject json = call.getData();
|
|
31
|
-
String name = json.getString("name");
|
|
32
|
+
String name = json.getString("name", null);
|
|
32
33
|
if (name == null) {
|
|
33
34
|
call.reject(ERROR_NAME_MISSING);
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
37
|
+
String region = json.getString("region", null);
|
|
36
38
|
Object data = json.opt("data");
|
|
37
39
|
|
|
38
|
-
CallByNameOptions options = new CallByNameOptions(name, data);
|
|
40
|
+
CallByNameOptions options = new CallByNameOptions(name, region, data);
|
|
39
41
|
NonEmptyResultCallback callback = new NonEmptyResultCallback() {
|
|
40
42
|
@Override
|
|
41
43
|
public void success(Result result) {
|
|
@@ -87,4 +89,22 @@ public class FirebaseFunctionsPlugin extends Plugin {
|
|
|
87
89
|
call.reject(exception.getMessage());
|
|
88
90
|
}
|
|
89
91
|
}
|
|
92
|
+
|
|
93
|
+
@PluginMethod
|
|
94
|
+
public void useEmulator(PluginCall call) {
|
|
95
|
+
try {
|
|
96
|
+
String host = call.getString("host");
|
|
97
|
+
if (host == null) {
|
|
98
|
+
call.reject(ERROR_HOST_MISSING);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
int port = call.getInt("port", 5001);
|
|
102
|
+
|
|
103
|
+
implementation.useEmulator(host, port);
|
|
104
|
+
call.resolve();
|
|
105
|
+
} catch (Exception exception) {
|
|
106
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
107
|
+
call.reject(exception.getMessage());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
90
110
|
}
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
4
5
|
|
|
5
6
|
public class CallByNameOptions extends CallOptions {
|
|
6
7
|
|
|
7
8
|
@NonNull
|
|
8
9
|
private String name;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
@Nullable
|
|
12
|
+
private String region;
|
|
13
|
+
|
|
14
|
+
public CallByNameOptions(@NonNull String name, @Nullable String region, Object data) {
|
|
11
15
|
super(data);
|
|
12
16
|
this.name = name;
|
|
17
|
+
this.region = region;
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
@NonNull
|
|
16
21
|
public String getName() {
|
|
17
22
|
return name;
|
|
18
23
|
}
|
|
24
|
+
|
|
25
|
+
@Nullable
|
|
26
|
+
public String getRegion() {
|
|
27
|
+
return region;
|
|
28
|
+
}
|
|
19
29
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
|
+
import java.net.MalformedURLException;
|
|
5
|
+
import java.net.URL;
|
|
4
6
|
|
|
5
7
|
public class CallByUrlOptions extends CallOptions {
|
|
6
8
|
|
|
7
9
|
@NonNull
|
|
8
|
-
private
|
|
10
|
+
private URL url;
|
|
9
11
|
|
|
10
|
-
public CallByUrlOptions(@NonNull String url, Object data) {
|
|
12
|
+
public CallByUrlOptions(@NonNull String url, Object data) throws MalformedURLException {
|
|
11
13
|
super(data);
|
|
12
|
-
this.url = url;
|
|
14
|
+
this.url = new URL(url);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
@NonNull
|
|
16
|
-
public
|
|
18
|
+
public URL getUrl() {
|
|
17
19
|
return url;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -2,8 +2,11 @@ package io.capawesome.capacitorjs.plugins.firebase.functions.classes.results;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSArray;
|
|
5
6
|
import com.getcapacitor.JSObject;
|
|
6
7
|
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.Result;
|
|
8
|
+
import java.util.ArrayList;
|
|
9
|
+
import java.util.Map;
|
|
7
10
|
|
|
8
11
|
public class CallResult implements Result {
|
|
9
12
|
|
|
@@ -16,10 +19,49 @@ public class CallResult implements Result {
|
|
|
16
19
|
|
|
17
20
|
@NonNull
|
|
18
21
|
public JSObject toJSObject() {
|
|
19
|
-
Object dataResult =
|
|
22
|
+
Object dataResult = CallResult.createJSValue(data);
|
|
20
23
|
|
|
21
24
|
JSObject result = new JSObject();
|
|
22
25
|
result.put("data", dataResult);
|
|
23
26
|
return result;
|
|
24
27
|
}
|
|
28
|
+
|
|
29
|
+
@Nullable
|
|
30
|
+
private static Object createJSValue(@Nullable Object object) {
|
|
31
|
+
if (object instanceof Map) {
|
|
32
|
+
return createJSObjectFromMap((Map<String, Object>) object);
|
|
33
|
+
} else if (object instanceof ArrayList) {
|
|
34
|
+
return createJSArrayFromArrayList((ArrayList) object);
|
|
35
|
+
}
|
|
36
|
+
return object;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Nullable
|
|
40
|
+
private static JSObject createJSObjectFromMap(@Nullable Map<String, Object> map) {
|
|
41
|
+
if (map == null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
JSObject object = new JSObject();
|
|
45
|
+
for (String key : map.keySet()) {
|
|
46
|
+
Object value = map.get(key);
|
|
47
|
+
if (value instanceof ArrayList) {
|
|
48
|
+
value = createJSArrayFromArrayList((ArrayList) value);
|
|
49
|
+
} else if (value instanceof Map) {
|
|
50
|
+
value = createJSObjectFromMap((Map<String, Object>) value);
|
|
51
|
+
}
|
|
52
|
+
object.put(key, value);
|
|
53
|
+
}
|
|
54
|
+
return object;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static JSArray createJSArrayFromArrayList(ArrayList arrayList) {
|
|
58
|
+
JSArray array = new JSArray();
|
|
59
|
+
for (Object value : arrayList) {
|
|
60
|
+
if (value instanceof Map) {
|
|
61
|
+
value = createJSObjectFromMap((Map<String, Object>) value);
|
|
62
|
+
}
|
|
63
|
+
array.put(value);
|
|
64
|
+
}
|
|
65
|
+
return array;
|
|
66
|
+
}
|
|
25
67
|
}
|
package/dist/docs.json
CHANGED
|
@@ -7,43 +7,78 @@
|
|
|
7
7
|
"methods": [
|
|
8
8
|
{
|
|
9
9
|
"name": "callByName",
|
|
10
|
-
"signature": "(options: CallByNameOptions) => Promise<CallByNameResult
|
|
10
|
+
"signature": "<RequestData = unknown, ResponseData = unknown>(options: CallByNameOptions<RequestData>) => Promise<CallByNameResult<ResponseData>>",
|
|
11
11
|
"parameters": [
|
|
12
12
|
{
|
|
13
13
|
"name": "options",
|
|
14
14
|
"docs": "",
|
|
15
|
-
"type": "CallByNameOptions"
|
|
15
|
+
"type": "CallByNameOptions<RequestData>"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
|
-
"returns": "Promise<
|
|
19
|
-
"tags": [
|
|
20
|
-
|
|
18
|
+
"returns": "Promise<CallByNameResult<ResponseData>>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "since",
|
|
22
|
+
"text": "6.1.0"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"docs": "Call a callable function by name.",
|
|
21
26
|
"complexTypes": [
|
|
22
|
-
"
|
|
27
|
+
"CallByNameResult",
|
|
28
|
+
"ResponseData",
|
|
23
29
|
"CallByNameOptions",
|
|
24
|
-
"
|
|
30
|
+
"RequestData"
|
|
25
31
|
],
|
|
26
32
|
"slug": "callbyname"
|
|
27
33
|
},
|
|
28
34
|
{
|
|
29
35
|
"name": "callByUrl",
|
|
30
|
-
"signature": "(options: CallByUrlOptions) => Promise<CallByUrlResult
|
|
36
|
+
"signature": "<RequestData = unknown, ResponseData = unknown>(options: CallByUrlOptions<RequestData>) => Promise<CallByUrlResult<ResponseData>>",
|
|
31
37
|
"parameters": [
|
|
32
38
|
{
|
|
33
39
|
"name": "options",
|
|
34
40
|
"docs": "",
|
|
35
|
-
"type": "CallByUrlOptions"
|
|
41
|
+
"type": "CallByUrlOptions<RequestData>"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"returns": "Promise<CallByUrlResult<ResponseData>>",
|
|
45
|
+
"tags": [
|
|
46
|
+
{
|
|
47
|
+
"name": "since",
|
|
48
|
+
"text": "6.1.0"
|
|
36
49
|
}
|
|
37
50
|
],
|
|
38
|
-
"
|
|
39
|
-
"tags": [],
|
|
40
|
-
"docs": "",
|
|
51
|
+
"docs": "Call a callable function by URL.",
|
|
41
52
|
"complexTypes": [
|
|
42
|
-
"
|
|
53
|
+
"CallByUrlResult",
|
|
54
|
+
"ResponseData",
|
|
43
55
|
"CallByUrlOptions",
|
|
44
|
-
"
|
|
56
|
+
"RequestData"
|
|
45
57
|
],
|
|
46
58
|
"slug": "callbyurl"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "useEmulator",
|
|
62
|
+
"signature": "(options: UseEmulatorOptions) => Promise<void>",
|
|
63
|
+
"parameters": [
|
|
64
|
+
{
|
|
65
|
+
"name": "options",
|
|
66
|
+
"docs": "",
|
|
67
|
+
"type": "UseEmulatorOptions"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"returns": "Promise<void>",
|
|
71
|
+
"tags": [
|
|
72
|
+
{
|
|
73
|
+
"name": "since",
|
|
74
|
+
"text": "6.1.0"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"docs": "Instrument your app to talk to the Cloud Functions emulator.\n\nOn Android, the cleartext traffic must be allowed. On the Capacitor configuration:\n```\n{\n server: {\n cleartext: true\n }\n}\n```\n**The cleartext traffic is not intended for use in production.**",
|
|
78
|
+
"complexTypes": [
|
|
79
|
+
"UseEmulatorOptions"
|
|
80
|
+
],
|
|
81
|
+
"slug": "useemulator"
|
|
47
82
|
}
|
|
48
83
|
],
|
|
49
84
|
"properties": []
|
|
@@ -53,15 +88,27 @@
|
|
|
53
88
|
"name": "CallResult",
|
|
54
89
|
"slug": "callresult",
|
|
55
90
|
"docs": "",
|
|
56
|
-
"tags": [
|
|
91
|
+
"tags": [
|
|
92
|
+
{
|
|
93
|
+
"text": "6.1.0",
|
|
94
|
+
"name": "since"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
57
97
|
"methods": [],
|
|
58
98
|
"properties": [
|
|
59
99
|
{
|
|
60
100
|
"name": "data",
|
|
61
|
-
"tags": [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
101
|
+
"tags": [
|
|
102
|
+
{
|
|
103
|
+
"text": "6.1.0",
|
|
104
|
+
"name": "since"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"docs": "The result of the callable function.",
|
|
108
|
+
"complexTypes": [
|
|
109
|
+
"ResponseData"
|
|
110
|
+
],
|
|
111
|
+
"type": "ResponseData"
|
|
65
112
|
}
|
|
66
113
|
]
|
|
67
114
|
},
|
|
@@ -69,15 +116,45 @@
|
|
|
69
116
|
"name": "CallByNameOptions",
|
|
70
117
|
"slug": "callbynameoptions",
|
|
71
118
|
"docs": "",
|
|
72
|
-
"tags": [
|
|
119
|
+
"tags": [
|
|
120
|
+
{
|
|
121
|
+
"text": "6.1.0",
|
|
122
|
+
"name": "since"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
73
125
|
"methods": [],
|
|
74
126
|
"properties": [
|
|
75
127
|
{
|
|
76
128
|
"name": "name",
|
|
77
|
-
"tags": [
|
|
78
|
-
|
|
129
|
+
"tags": [
|
|
130
|
+
{
|
|
131
|
+
"text": "'myFunction'",
|
|
132
|
+
"name": "example"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"text": "6.1.0",
|
|
136
|
+
"name": "since"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"docs": "The name of the callable function.",
|
|
79
140
|
"complexTypes": [],
|
|
80
141
|
"type": "string"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "region",
|
|
145
|
+
"tags": [
|
|
146
|
+
{
|
|
147
|
+
"text": "'us-central1'",
|
|
148
|
+
"name": "example"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"text": "6.1.0",
|
|
152
|
+
"name": "since"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"docs": "The region of the callable function.",
|
|
156
|
+
"complexTypes": [],
|
|
157
|
+
"type": "string | undefined"
|
|
81
158
|
}
|
|
82
159
|
]
|
|
83
160
|
},
|
|
@@ -85,17 +162,81 @@
|
|
|
85
162
|
"name": "CallByUrlOptions",
|
|
86
163
|
"slug": "callbyurloptions",
|
|
87
164
|
"docs": "",
|
|
88
|
-
"tags": [
|
|
165
|
+
"tags": [
|
|
166
|
+
{
|
|
167
|
+
"text": "6.1.0",
|
|
168
|
+
"name": "since"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
89
171
|
"methods": [],
|
|
90
172
|
"properties": [
|
|
91
173
|
{
|
|
92
174
|
"name": "url",
|
|
93
|
-
"tags": [
|
|
94
|
-
|
|
175
|
+
"tags": [
|
|
176
|
+
{
|
|
177
|
+
"text": "'https://us-central1-my-project.cloudfunctions.net/myFunction'",
|
|
178
|
+
"name": "example"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"text": "6.1.0",
|
|
182
|
+
"name": "since"
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
"docs": "The URL of the callable function.",
|
|
95
186
|
"complexTypes": [],
|
|
96
187
|
"type": "string"
|
|
97
188
|
}
|
|
98
189
|
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "UseEmulatorOptions",
|
|
193
|
+
"slug": "useemulatoroptions",
|
|
194
|
+
"docs": "",
|
|
195
|
+
"tags": [
|
|
196
|
+
{
|
|
197
|
+
"text": "6.1.0",
|
|
198
|
+
"name": "since"
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"methods": [],
|
|
202
|
+
"properties": [
|
|
203
|
+
{
|
|
204
|
+
"name": "host",
|
|
205
|
+
"tags": [
|
|
206
|
+
{
|
|
207
|
+
"text": "6.1.0",
|
|
208
|
+
"name": "since"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"text": "\"127.0.0.1\"",
|
|
212
|
+
"name": "example"
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"docs": "The emulator host without any port or scheme.\n\nNote when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer.",
|
|
216
|
+
"complexTypes": [],
|
|
217
|
+
"type": "string"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"name": "port",
|
|
221
|
+
"tags": [
|
|
222
|
+
{
|
|
223
|
+
"text": "6.1.0",
|
|
224
|
+
"name": "since"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"text": "5001",
|
|
228
|
+
"name": "default"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"text": "5001",
|
|
232
|
+
"name": "example"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"docs": "The emulator port.",
|
|
236
|
+
"complexTypes": [],
|
|
237
|
+
"type": "number | undefined"
|
|
238
|
+
}
|
|
239
|
+
]
|
|
99
240
|
}
|
|
100
241
|
],
|
|
101
242
|
"enums": [],
|
|
@@ -106,9 +247,10 @@
|
|
|
106
247
|
"docs": "",
|
|
107
248
|
"types": [
|
|
108
249
|
{
|
|
109
|
-
"text": "CallResult",
|
|
250
|
+
"text": "CallResult<ResponseData>",
|
|
110
251
|
"complexTypes": [
|
|
111
|
-
"CallResult"
|
|
252
|
+
"CallResult",
|
|
253
|
+
"ResponseData"
|
|
112
254
|
]
|
|
113
255
|
}
|
|
114
256
|
]
|
|
@@ -119,9 +261,10 @@
|
|
|
119
261
|
"docs": "",
|
|
120
262
|
"types": [
|
|
121
263
|
{
|
|
122
|
-
"text": "CallResult",
|
|
264
|
+
"text": "CallResult<ResponseData>",
|
|
123
265
|
"complexTypes": [
|
|
124
|
-
"CallResult"
|
|
266
|
+
"CallResult",
|
|
267
|
+
"ResponseData"
|
|
125
268
|
]
|
|
126
269
|
}
|
|
127
270
|
]
|
|
@@ -1,18 +1,113 @@
|
|
|
1
1
|
export interface FirebaseFunctionsPlugin {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Call a callable function by name.
|
|
4
|
+
*
|
|
5
|
+
* @since 6.1.0
|
|
6
|
+
*/
|
|
7
|
+
callByName<RequestData = unknown, ResponseData = unknown>(options: CallByNameOptions<RequestData>): Promise<CallByNameResult<ResponseData>>;
|
|
8
|
+
/**
|
|
9
|
+
* Call a callable function by URL.
|
|
10
|
+
*
|
|
11
|
+
* @since 6.1.0
|
|
12
|
+
*/
|
|
13
|
+
callByUrl<RequestData = unknown, ResponseData = unknown>(options: CallByUrlOptions<RequestData>): Promise<CallByUrlResult<ResponseData>>;
|
|
14
|
+
/**
|
|
15
|
+
* Instrument your app to talk to the Cloud Functions emulator.
|
|
16
|
+
*
|
|
17
|
+
* On Android, the cleartext traffic must be allowed. On the Capacitor configuration:
|
|
18
|
+
* ```
|
|
19
|
+
* {
|
|
20
|
+
* server: {
|
|
21
|
+
* cleartext: true
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
* **The cleartext traffic is not intended for use in production.**
|
|
26
|
+
*
|
|
27
|
+
* @since 6.1.0
|
|
28
|
+
*/
|
|
29
|
+
useEmulator(options: UseEmulatorOptions): Promise<void>;
|
|
4
30
|
}
|
|
5
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @since 6.1.0
|
|
33
|
+
*/
|
|
34
|
+
export interface CallByNameOptions<RequestData = unknown> extends CallOptions<RequestData> {
|
|
35
|
+
/**
|
|
36
|
+
* The name of the callable function.
|
|
37
|
+
*
|
|
38
|
+
* @example 'myFunction'
|
|
39
|
+
* @since 6.1.0
|
|
40
|
+
*/
|
|
6
41
|
name: string;
|
|
42
|
+
/**
|
|
43
|
+
* The region of the callable function.
|
|
44
|
+
*
|
|
45
|
+
* @example 'us-central1'
|
|
46
|
+
* @since 6.1.0
|
|
47
|
+
*/
|
|
48
|
+
region?: string;
|
|
7
49
|
}
|
|
8
|
-
|
|
9
|
-
|
|
50
|
+
/**
|
|
51
|
+
* @since 6.1.0
|
|
52
|
+
*/
|
|
53
|
+
export declare type CallByNameResult<ResponseData = unknown> = CallResult<ResponseData>;
|
|
54
|
+
/**
|
|
55
|
+
* @since 6.1.0
|
|
56
|
+
*/
|
|
57
|
+
export interface CallByUrlOptions<RequestData = unknown> extends CallOptions<RequestData> {
|
|
58
|
+
/**
|
|
59
|
+
* The URL of the callable function.
|
|
60
|
+
*
|
|
61
|
+
* @example 'https://us-central1-my-project.cloudfunctions.net/myFunction'
|
|
62
|
+
* @since 6.1.0
|
|
63
|
+
*/
|
|
10
64
|
url: string;
|
|
11
65
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @since 6.1.0
|
|
68
|
+
*/
|
|
69
|
+
export declare type CallByUrlResult<ResponseData = unknown> = CallResult<ResponseData>;
|
|
70
|
+
/**
|
|
71
|
+
* @since 6.1.0
|
|
72
|
+
*/
|
|
73
|
+
export interface CallOptions<RequestData = unknown> {
|
|
74
|
+
/**
|
|
75
|
+
* The data to pass to the callable function.
|
|
76
|
+
*
|
|
77
|
+
* @since 6.1.0
|
|
78
|
+
*/
|
|
79
|
+
data?: RequestData | null;
|
|
15
80
|
}
|
|
16
|
-
|
|
17
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @since 6.1.0
|
|
83
|
+
*/
|
|
84
|
+
export interface CallResult<ResponseData = unknown> {
|
|
85
|
+
/**
|
|
86
|
+
* The result of the callable function.
|
|
87
|
+
*
|
|
88
|
+
* @since 6.1.0
|
|
89
|
+
*/
|
|
90
|
+
data: ResponseData;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @since 6.1.0
|
|
94
|
+
*/
|
|
95
|
+
export interface UseEmulatorOptions {
|
|
96
|
+
/**
|
|
97
|
+
* The emulator host without any port or scheme.
|
|
98
|
+
*
|
|
99
|
+
* Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer.
|
|
100
|
+
*
|
|
101
|
+
* @since 6.1.0
|
|
102
|
+
* @example "127.0.0.1"
|
|
103
|
+
*/
|
|
104
|
+
host: string;
|
|
105
|
+
/**
|
|
106
|
+
* The emulator port.
|
|
107
|
+
*
|
|
108
|
+
* @since 6.1.0
|
|
109
|
+
* @default 5001
|
|
110
|
+
* @example 5001
|
|
111
|
+
*/
|
|
112
|
+
port?: number;
|
|
18
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface FirebaseFunctionsPlugin {\n callByName(options: CallByNameOptions): Promise<CallByNameResult
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface FirebaseFunctionsPlugin {\n /**\n * Call a callable function by name.\n *\n * @since 6.1.0\n */\n callByName<RequestData = unknown, ResponseData = unknown>(\n options: CallByNameOptions<RequestData>,\n ): Promise<CallByNameResult<ResponseData>>;\n /**\n * Call a callable function by URL.\n *\n * @since 6.1.0\n */\n callByUrl<RequestData = unknown, ResponseData = unknown>(\n options: CallByUrlOptions<RequestData>,\n ): Promise<CallByUrlResult<ResponseData>>;\n /**\n * Instrument your app to talk to the Cloud Functions emulator.\n *\n * On Android, the cleartext traffic must be allowed. On the Capacitor configuration:\n * ```\n * {\n * server: {\n * cleartext: true\n * }\n * }\n * ```\n * **The cleartext traffic is not intended for use in production.**\n *\n * @since 6.1.0\n */\n useEmulator(options: UseEmulatorOptions): Promise<void>;\n}\n\n/**\n * @since 6.1.0\n */\nexport interface CallByNameOptions<RequestData = unknown>\n extends CallOptions<RequestData> {\n /**\n * The name of the callable function.\n *\n * @example 'myFunction'\n * @since 6.1.0\n */\n name: string;\n /**\n * The region of the callable function.\n *\n * @example 'us-central1'\n * @since 6.1.0\n */\n region?: string;\n}\n\n/**\n * @since 6.1.0\n */\nexport type CallByNameResult<ResponseData = unknown> = CallResult<ResponseData>;\n\n/**\n * @since 6.1.0\n */\nexport interface CallByUrlOptions<RequestData = unknown>\n extends CallOptions<RequestData> {\n /**\n * The URL of the callable function.\n *\n * @example 'https://us-central1-my-project.cloudfunctions.net/myFunction'\n * @since 6.1.0\n */\n url: string;\n}\n\n/**\n * @since 6.1.0\n */\nexport type CallByUrlResult<ResponseData = unknown> = CallResult<ResponseData>;\n\n/**\n * @since 6.1.0\n */\nexport interface CallOptions<RequestData = unknown> {\n /**\n * The data to pass to the callable function.\n *\n * @since 6.1.0\n */\n data?: RequestData | null;\n}\n\n/**\n * @since 6.1.0\n */\nexport interface CallResult<ResponseData = unknown> {\n /**\n * The result of the callable function.\n *\n * @since 6.1.0\n */\n data: ResponseData;\n}\n\n/**\n * @since 6.1.0\n */\nexport interface UseEmulatorOptions {\n /**\n * The emulator host without any port or scheme.\n *\n * Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer.\n *\n * @since 6.1.0\n * @example \"127.0.0.1\"\n */\n host: string;\n /**\n * The emulator port.\n *\n * @since 6.1.0\n * @default 5001\n * @example 5001\n */\n port?: number;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { CallByNameOptions, CallByNameResult, CallByUrlOptions, CallResult, FirebaseFunctionsPlugin } from './definitions';
|
|
2
|
+
import type { CallByNameOptions, CallByNameResult, CallByUrlOptions, CallResult, FirebaseFunctionsPlugin, UseEmulatorOptions } from './definitions';
|
|
3
3
|
export declare class FirebaseFunctionsWeb extends WebPlugin implements FirebaseFunctionsPlugin {
|
|
4
|
-
callByName(options: CallByNameOptions): Promise<CallByNameResult
|
|
5
|
-
callByUrl(options: CallByUrlOptions): Promise<CallResult
|
|
4
|
+
callByName<RequestData = unknown, ResponseData = unknown>(options: CallByNameOptions<RequestData>): Promise<CallByNameResult<ResponseData>>;
|
|
5
|
+
callByUrl<RequestData = unknown, ResponseData = unknown>(options: CallByUrlOptions<RequestData>): Promise<CallResult<ResponseData>>;
|
|
6
|
+
useEmulator(options: UseEmulatorOptions): Promise<void>;
|
|
6
7
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';
|
|
2
|
+
import { connectFunctionsEmulator, getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';
|
|
3
3
|
export class FirebaseFunctionsWeb extends WebPlugin {
|
|
4
4
|
async callByName(options) {
|
|
5
|
-
const functions = getFunctions();
|
|
5
|
+
const functions = getFunctions(undefined, options.region);
|
|
6
6
|
const callable = httpsCallable(functions, options.name);
|
|
7
7
|
const result = await callable(options.data);
|
|
8
8
|
return {
|
|
@@ -17,5 +17,10 @@ export class FirebaseFunctionsWeb extends WebPlugin {
|
|
|
17
17
|
data: result.data,
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
async useEmulator(options) {
|
|
21
|
+
const functions = getFunctions();
|
|
22
|
+
const port = options.port || 5001;
|
|
23
|
+
connectFunctionsEmulator(functions, options.host, port);
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAW5B,MAAM,OAAO,oBACX,SAAQ,SAAS;IAGV,KAAK,CAAC,UAAU,CACrB,OAAuC;QAEvC,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,aAAa,CAC5B,SAAS,EACT,OAAO,CAAC,IAAI,CACb,CAAC;QACF,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,CACpB,OAAsC;QAEtC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,oBAAoB,CACnC,SAAS,EACT,OAAO,CAAC,GAAG,CACZ,CAAC;QACF,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,WAAW,CAAC,OAA2B;QAClD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;QAClC,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport {\n connectFunctionsEmulator,\n getFunctions,\n httpsCallable,\n httpsCallableFromURL,\n} from 'firebase/functions';\n\nimport type {\n CallByNameOptions,\n CallByNameResult,\n CallByUrlOptions,\n CallResult,\n FirebaseFunctionsPlugin,\n UseEmulatorOptions,\n} from './definitions';\n\nexport class FirebaseFunctionsWeb\n extends WebPlugin\n implements FirebaseFunctionsPlugin\n{\n public async callByName<RequestData = unknown, ResponseData = unknown>(\n options: CallByNameOptions<RequestData>,\n ): Promise<CallByNameResult<ResponseData>> {\n const functions = getFunctions(undefined, options.region);\n const callable = httpsCallable<RequestData, ResponseData>(\n functions,\n options.name,\n );\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n\n public async callByUrl<RequestData = unknown, ResponseData = unknown>(\n options: CallByUrlOptions<RequestData>,\n ): Promise<CallResult<ResponseData>> {\n const functions = getFunctions();\n const callable = httpsCallableFromURL<RequestData, ResponseData>(\n functions,\n options.url,\n );\n const result = await callable(options.data);\n return {\n data: result.data,\n };\n }\n\n public async useEmulator(options: UseEmulatorOptions): Promise<void> {\n const functions = getFunctions();\n const port = options.port || 5001;\n connectFunctionsEmulator(functions, options.host, port);\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ const FirebaseFunctions = core.registerPlugin('FirebaseFunctions', {
|
|
|
11
11
|
|
|
12
12
|
class FirebaseFunctionsWeb extends core.WebPlugin {
|
|
13
13
|
async callByName(options) {
|
|
14
|
-
const functions$1 = functions.getFunctions();
|
|
14
|
+
const functions$1 = functions.getFunctions(undefined, options.region);
|
|
15
15
|
const callable = functions.httpsCallable(functions$1, options.name);
|
|
16
16
|
const result = await callable(options.data);
|
|
17
17
|
return {
|
|
@@ -26,6 +26,11 @@ class FirebaseFunctionsWeb extends core.WebPlugin {
|
|
|
26
26
|
data: result.data,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
async useEmulator(options) {
|
|
30
|
+
const functions$1 = functions.getFunctions();
|
|
31
|
+
const port = options.port || 5001;
|
|
32
|
+
functions.connectFunctionsEmulator(functions$1, options.host, port);
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +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;
|
|
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 { connectFunctionsEmulator, getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';\nexport class FirebaseFunctionsWeb extends WebPlugin {\n async callByName(options) {\n const functions = getFunctions(undefined, options.region);\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 async useEmulator(options) {\n const functions = getFunctions();\n const port = options.port || 5001;\n connectFunctionsEmulator(functions, options.host, port);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","functions","getFunctions","httpsCallable","httpsCallableFromURL","connectFunctionsEmulator"],"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,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AAClE,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,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,MAAMA,WAAS,GAAGC,sBAAY,EAAE,CAAC;AACzC,QAAQ,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;AAC1C,QAAQG,kCAAwB,CAACJ,WAAS,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAChE,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -7,7 +7,7 @@ var capacitorFirebaseFunctions = (function (exports, core, functions) {
|
|
|
7
7
|
|
|
8
8
|
class FirebaseFunctionsWeb extends core.WebPlugin {
|
|
9
9
|
async callByName(options) {
|
|
10
|
-
const functions$1 = functions.getFunctions();
|
|
10
|
+
const functions$1 = functions.getFunctions(undefined, options.region);
|
|
11
11
|
const callable = functions.httpsCallable(functions$1, options.name);
|
|
12
12
|
const result = await callable(options.data);
|
|
13
13
|
return {
|
|
@@ -22,6 +22,11 @@ var capacitorFirebaseFunctions = (function (exports, core, functions) {
|
|
|
22
22
|
data: result.data,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
async useEmulator(options) {
|
|
26
|
+
const functions$1 = functions.getFunctions();
|
|
27
|
+
const port = options.port || 5001;
|
|
28
|
+
functions.connectFunctionsEmulator(functions$1, options.host, port);
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +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;
|
|
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 { connectFunctionsEmulator, getFunctions, httpsCallable, httpsCallableFromURL, } from 'firebase/functions';\nexport class FirebaseFunctionsWeb extends WebPlugin {\n async callByName(options) {\n const functions = getFunctions(undefined, options.region);\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 async useEmulator(options) {\n const functions = getFunctions();\n const port = options.port || 5001;\n connectFunctionsEmulator(functions, options.host, port);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","functions","getFunctions","httpsCallable","httpsCallableFromURL","connectFunctionsEmulator"],"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,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAClE,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,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,MAAMA,WAAS,GAAGC,sBAAY,EAAE,CAAC;IACzC,QAAQ,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;IAC1C,QAAQG,kCAAwB,CAACJ,WAAS,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChE,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,13 +2,19 @@ import Foundation
|
|
|
2
2
|
|
|
3
3
|
@objc public class CallByNameOptions: CallOptions {
|
|
4
4
|
private var name: String
|
|
5
|
+
private var region: String?
|
|
5
6
|
|
|
6
|
-
init(name: String, data: Any?) {
|
|
7
|
+
init(name: String, region: String?, data: Any?) {
|
|
7
8
|
self.name = name
|
|
9
|
+
self.region = region
|
|
8
10
|
super.init(data: data)
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
func getName() -> String {
|
|
12
14
|
return name
|
|
13
15
|
}
|
|
16
|
+
|
|
17
|
+
func getRegion() -> String? {
|
|
18
|
+
return region
|
|
19
|
+
}
|
|
14
20
|
}
|
|
@@ -10,7 +10,17 @@ import Capacitor
|
|
|
10
10
|
|
|
11
11
|
public func toJSObject() -> AnyObject {
|
|
12
12
|
var result = JSObject()
|
|
13
|
-
result["data"] = data
|
|
13
|
+
result["data"] = CallResult.createJSValue(value: data)
|
|
14
14
|
return result as AnyObject
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
private static func createJSValue(value: Any?) -> JSValue? {
|
|
18
|
+
guard let value = value else {
|
|
19
|
+
return nil
|
|
20
|
+
}
|
|
21
|
+
guard let value = JSTypes.coerceDictionaryToJSObject(["key": value]) as JSObject? else {
|
|
22
|
+
return nil
|
|
23
|
+
}
|
|
24
|
+
return value["key"]
|
|
25
|
+
}
|
|
16
26
|
}
|
|
@@ -15,9 +15,15 @@ import FirebaseFunctions
|
|
|
15
15
|
|
|
16
16
|
@objc public func callByName(_ options: CallByNameOptions, completion: @escaping (Result?, Error?) -> Void) {
|
|
17
17
|
let name = options.getName()
|
|
18
|
+
let region = options.getRegion()
|
|
18
19
|
let data = options.getData()
|
|
19
20
|
|
|
20
|
-
let functions
|
|
21
|
+
let functions: Functions
|
|
22
|
+
if let region = region {
|
|
23
|
+
functions = Functions.functions(region: region)
|
|
24
|
+
} else {
|
|
25
|
+
functions = Functions.functions()
|
|
26
|
+
}
|
|
21
27
|
let callable = functions.httpsCallable(name)
|
|
22
28
|
callable.call(data) { (result, error) in
|
|
23
29
|
if let error = error {
|
|
@@ -44,4 +50,8 @@ import FirebaseFunctions
|
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
}
|
|
53
|
+
|
|
54
|
+
@objc func useEmulator(_ host: String, _ port: Int) {
|
|
55
|
+
Functions.functions().useEmulator(withHost: host, port: port)
|
|
56
|
+
}
|
|
47
57
|
}
|
|
@@ -9,6 +9,7 @@ import Capacitor
|
|
|
9
9
|
public class FirebaseFunctionsPlugin: CAPPlugin {
|
|
10
10
|
public let tag = "FirebaseFunctions"
|
|
11
11
|
public let errorNameMissing = "name must be provided."
|
|
12
|
+
public let errorHostMissing = "host must be provided."
|
|
12
13
|
private var implementation: FirebaseFunctions?
|
|
13
14
|
|
|
14
15
|
override public func load() {
|
|
@@ -20,9 +21,10 @@ public class FirebaseFunctionsPlugin: CAPPlugin {
|
|
|
20
21
|
call.reject(errorNameMissing)
|
|
21
22
|
return
|
|
22
23
|
}
|
|
24
|
+
let region = call.getString("region")
|
|
23
25
|
let data = call.getValue("data")
|
|
24
26
|
|
|
25
|
-
let options = CallByNameOptions(name: name, data: data)
|
|
27
|
+
let options = CallByNameOptions(name: name, region: region, data: data)
|
|
26
28
|
|
|
27
29
|
implementation?.callByName(options, completion: { result, error in
|
|
28
30
|
if let error = error {
|
|
@@ -56,4 +58,15 @@ public class FirebaseFunctionsPlugin: CAPPlugin {
|
|
|
56
58
|
}
|
|
57
59
|
})
|
|
58
60
|
}
|
|
61
|
+
|
|
62
|
+
@objc func useEmulator(_ call: CAPPluginCall) {
|
|
63
|
+
guard let host = call.getString("host") else {
|
|
64
|
+
call.reject(errorHostMissing)
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
let port = call.getInt("port") ?? 5001
|
|
68
|
+
|
|
69
|
+
implementation?.useEmulator(host, port)
|
|
70
|
+
call.resolve()
|
|
71
|
+
}
|
|
59
72
|
}
|
package/package.json
CHANGED