@capacitor-firebase/functions 6.0.0-dev.59ed099.1719590033 → 6.1.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/README.md +58 -15
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctions.java +7 -3
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctionsPlugin.java +19 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByNameOptions.java +1 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByUrlOptions.java +6 -4
- package/dist/docs.json +95 -16
- package/dist/esm/definitions.d.ts +48 -10
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -3
- package/dist/esm/web.js +6 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +5 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +5 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Classes/Options/CallByNameOptions.swift +1 -1
- package/ios/Plugin/FirebaseFunctions.swift +5 -1
- package/ios/Plugin/FirebaseFunctionsPlugin.m +1 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.swift +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,13 @@ const callByUrl = async () => {
|
|
|
63
63
|
});
|
|
64
64
|
return data;
|
|
65
65
|
};
|
|
66
|
+
|
|
67
|
+
const useEmulator = async () => {
|
|
68
|
+
await FirebaseFunctions.useEmulator({
|
|
69
|
+
host: '10.0.2.2',
|
|
70
|
+
port: 9001,
|
|
71
|
+
});
|
|
72
|
+
};
|
|
66
73
|
```
|
|
67
74
|
|
|
68
75
|
## API
|
|
@@ -71,6 +78,7 @@ const callByUrl = async () => {
|
|
|
71
78
|
|
|
72
79
|
* [`callByName(...)`](#callbyname)
|
|
73
80
|
* [`callByUrl(...)`](#callbyurl)
|
|
81
|
+
* [`useEmulator(...)`](#useemulator)
|
|
74
82
|
* [Interfaces](#interfaces)
|
|
75
83
|
* [Type Aliases](#type-aliases)
|
|
76
84
|
|
|
@@ -82,16 +90,16 @@ const callByUrl = async () => {
|
|
|
82
90
|
### callByName(...)
|
|
83
91
|
|
|
84
92
|
```typescript
|
|
85
|
-
callByName(options: CallByNameOptions) => Promise<CallByNameResult
|
|
93
|
+
callByName<RequestData = unknown, ResponseData = unknown>(options: CallByNameOptions<RequestData>) => Promise<CallByNameResult<ResponseData>>
|
|
86
94
|
```
|
|
87
95
|
|
|
88
96
|
Call a callable function by name.
|
|
89
97
|
|
|
90
|
-
| Param | Type
|
|
91
|
-
| ------------- |
|
|
92
|
-
| **`options`** | <code><a href="#callbynameoptions">CallByNameOptions</a
|
|
98
|
+
| Param | Type |
|
|
99
|
+
| ------------- | ---------------------------------------------------------------------------------- |
|
|
100
|
+
| **`options`** | <code><a href="#callbynameoptions">CallByNameOptions</a><RequestData></code> |
|
|
93
101
|
|
|
94
|
-
**Returns:** <code>Promise<<a href="#
|
|
102
|
+
**Returns:** <code>Promise<<a href="#callbynameresult">CallByNameResult</a><ResponseData>></code>
|
|
95
103
|
|
|
96
104
|
**Since:** 6.1.0
|
|
97
105
|
|
|
@@ -101,16 +109,43 @@ Call a callable function by name.
|
|
|
101
109
|
### callByUrl(...)
|
|
102
110
|
|
|
103
111
|
```typescript
|
|
104
|
-
callByUrl(options: CallByUrlOptions) => Promise<CallByUrlResult
|
|
112
|
+
callByUrl<RequestData = unknown, ResponseData = unknown>(options: CallByUrlOptions<RequestData>) => Promise<CallByUrlResult<ResponseData>>
|
|
105
113
|
```
|
|
106
114
|
|
|
107
115
|
Call a callable function by URL.
|
|
108
116
|
|
|
109
|
-
| Param | Type
|
|
110
|
-
| ------------- |
|
|
111
|
-
| **`options`** | <code><a href="#callbyurloptions">CallByUrlOptions</a
|
|
117
|
+
| Param | Type |
|
|
118
|
+
| ------------- | -------------------------------------------------------------------------------- |
|
|
119
|
+
| **`options`** | <code><a href="#callbyurloptions">CallByUrlOptions</a><RequestData></code> |
|
|
112
120
|
|
|
113
|
-
**Returns:** <code>Promise<<a href="#
|
|
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
|
+
}
|
|
143
|
+
```
|
|
144
|
+
**The cleartext traffic is not intended for use in production.**
|
|
145
|
+
|
|
146
|
+
| Param | Type |
|
|
147
|
+
| ------------- | ----------------------------------------------------------------- |
|
|
148
|
+
| **`options`** | <code><a href="#useemulatoroptions">UseEmulatorOptions</a></code> |
|
|
114
149
|
|
|
115
150
|
**Since:** 6.1.0
|
|
116
151
|
|
|
@@ -122,9 +157,9 @@ Call a callable function by URL.
|
|
|
122
157
|
|
|
123
158
|
#### CallResult
|
|
124
159
|
|
|
125
|
-
| Prop | Type
|
|
126
|
-
| ---------- |
|
|
127
|
-
| **`data`** | <code>
|
|
160
|
+
| Prop | Type | Description | Since |
|
|
161
|
+
| ---------- | ------------------------- | ------------------------------------ | ----- |
|
|
162
|
+
| **`data`** | <code>ResponseData</code> | The result of the callable function. | 6.1.0 |
|
|
128
163
|
|
|
129
164
|
|
|
130
165
|
#### CallByNameOptions
|
|
@@ -142,17 +177,25 @@ Call a callable function by URL.
|
|
|
142
177
|
| **`url`** | <code>string</code> | The URL of the callable function. | 6.1.0 |
|
|
143
178
|
|
|
144
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 |
|
|
186
|
+
|
|
187
|
+
|
|
145
188
|
### Type Aliases
|
|
146
189
|
|
|
147
190
|
|
|
148
191
|
#### CallByNameResult
|
|
149
192
|
|
|
150
|
-
<code><a href="#callresult">CallResult</a
|
|
193
|
+
<code><a href="#callresult">CallResult</a><ResponseData></code>
|
|
151
194
|
|
|
152
195
|
|
|
153
196
|
#### CallByUrlResult
|
|
154
197
|
|
|
155
|
-
<code><a href="#callresult">CallResult</a
|
|
198
|
+
<code><a href="#callresult">CallResult</a><ResponseData></code>
|
|
156
199
|
|
|
157
200
|
</docgen-api>
|
|
158
201
|
|
|
@@ -2,11 +2,11 @@ package io.capawesome.capacitorjs.plugins.firebase.functions;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
|
-
|
|
6
5
|
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByNameOptions;
|
|
7
6
|
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByUrlOptions;
|
|
8
7
|
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.results.CallResult;
|
|
9
8
|
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.NonEmptyResultCallback;
|
|
9
|
+
import java.net.URL;
|
|
10
10
|
|
|
11
11
|
public class FirebaseFunctions {
|
|
12
12
|
|
|
@@ -38,11 +38,11 @@ public class FirebaseFunctions {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
public void callByUrl(@NonNull CallByUrlOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
41
|
-
|
|
41
|
+
URL url = options.getUrl();
|
|
42
42
|
Object data = options.getData();
|
|
43
43
|
|
|
44
44
|
getFirebaseFunctionsInstance(null)
|
|
45
|
-
.
|
|
45
|
+
.getHttpsCallableFromUrl(url)
|
|
46
46
|
.call(data)
|
|
47
47
|
.addOnSuccessListener(
|
|
48
48
|
task -> {
|
|
@@ -57,6 +57,10 @@ public class FirebaseFunctions {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
public void useEmulator(@NonNull String host, int port) {
|
|
61
|
+
getFirebaseFunctionsInstance(null).useEmulator(host, port);
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
private com.google.firebase.functions.FirebaseFunctions getFirebaseFunctionsInstance(@Nullable String regionOrCustomDomain) {
|
|
61
65
|
if (regionOrCustomDomain == null) {
|
|
62
66
|
return com.google.firebase.functions.FirebaseFunctions.getInstance();
|
|
@@ -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
|
|
|
@@ -88,4 +89,22 @@ public class FirebaseFunctionsPlugin extends Plugin {
|
|
|
88
89
|
call.reject(exception.getMessage());
|
|
89
90
|
}
|
|
90
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
|
+
}
|
|
91
110
|
}
|
|
@@ -11,7 +11,7 @@ public class CallByNameOptions extends CallOptions {
|
|
|
11
11
|
@Nullable
|
|
12
12
|
private String region;
|
|
13
13
|
|
|
14
|
-
public CallByNameOptions(@NonNull String name, @Nullable String region,
|
|
14
|
+
public CallByNameOptions(@NonNull String name, @Nullable String region, Object data) {
|
|
15
15
|
super(data);
|
|
16
16
|
this.name = name;
|
|
17
17
|
this.region = region;
|
|
@@ -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
|
}
|
package/dist/docs.json
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
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<
|
|
18
|
+
"returns": "Promise<CallByNameResult<ResponseData>>",
|
|
19
19
|
"tags": [
|
|
20
20
|
{
|
|
21
21
|
"name": "since",
|
|
@@ -24,23 +24,24 @@
|
|
|
24
24
|
],
|
|
25
25
|
"docs": "Call a callable function by name.",
|
|
26
26
|
"complexTypes": [
|
|
27
|
-
"
|
|
27
|
+
"CallByNameResult",
|
|
28
|
+
"ResponseData",
|
|
28
29
|
"CallByNameOptions",
|
|
29
|
-
"
|
|
30
|
+
"RequestData"
|
|
30
31
|
],
|
|
31
32
|
"slug": "callbyname"
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
"name": "callByUrl",
|
|
35
|
-
"signature": "(options: CallByUrlOptions) => Promise<CallByUrlResult
|
|
36
|
+
"signature": "<RequestData = unknown, ResponseData = unknown>(options: CallByUrlOptions<RequestData>) => Promise<CallByUrlResult<ResponseData>>",
|
|
36
37
|
"parameters": [
|
|
37
38
|
{
|
|
38
39
|
"name": "options",
|
|
39
40
|
"docs": "",
|
|
40
|
-
"type": "CallByUrlOptions"
|
|
41
|
+
"type": "CallByUrlOptions<RequestData>"
|
|
41
42
|
}
|
|
42
43
|
],
|
|
43
|
-
"returns": "Promise<
|
|
44
|
+
"returns": "Promise<CallByUrlResult<ResponseData>>",
|
|
44
45
|
"tags": [
|
|
45
46
|
{
|
|
46
47
|
"name": "since",
|
|
@@ -49,11 +50,35 @@
|
|
|
49
50
|
],
|
|
50
51
|
"docs": "Call a callable function by URL.",
|
|
51
52
|
"complexTypes": [
|
|
52
|
-
"
|
|
53
|
+
"CallByUrlResult",
|
|
54
|
+
"ResponseData",
|
|
53
55
|
"CallByUrlOptions",
|
|
54
|
-
"
|
|
56
|
+
"RequestData"
|
|
55
57
|
],
|
|
56
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"
|
|
57
82
|
}
|
|
58
83
|
],
|
|
59
84
|
"properties": []
|
|
@@ -80,8 +105,10 @@
|
|
|
80
105
|
}
|
|
81
106
|
],
|
|
82
107
|
"docs": "The result of the callable function.",
|
|
83
|
-
"complexTypes": [
|
|
84
|
-
|
|
108
|
+
"complexTypes": [
|
|
109
|
+
"ResponseData"
|
|
110
|
+
],
|
|
111
|
+
"type": "ResponseData"
|
|
85
112
|
}
|
|
86
113
|
]
|
|
87
114
|
},
|
|
@@ -160,6 +187,56 @@
|
|
|
160
187
|
"type": "string"
|
|
161
188
|
}
|
|
162
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
|
+
]
|
|
163
240
|
}
|
|
164
241
|
],
|
|
165
242
|
"enums": [],
|
|
@@ -170,9 +247,10 @@
|
|
|
170
247
|
"docs": "",
|
|
171
248
|
"types": [
|
|
172
249
|
{
|
|
173
|
-
"text": "CallResult",
|
|
250
|
+
"text": "CallResult<ResponseData>",
|
|
174
251
|
"complexTypes": [
|
|
175
|
-
"CallResult"
|
|
252
|
+
"CallResult",
|
|
253
|
+
"ResponseData"
|
|
176
254
|
]
|
|
177
255
|
}
|
|
178
256
|
]
|
|
@@ -183,9 +261,10 @@
|
|
|
183
261
|
"docs": "",
|
|
184
262
|
"types": [
|
|
185
263
|
{
|
|
186
|
-
"text": "CallResult",
|
|
264
|
+
"text": "CallResult<ResponseData>",
|
|
187
265
|
"complexTypes": [
|
|
188
|
-
"CallResult"
|
|
266
|
+
"CallResult",
|
|
267
|
+
"ResponseData"
|
|
189
268
|
]
|
|
190
269
|
}
|
|
191
270
|
]
|
|
@@ -4,18 +4,34 @@ export interface FirebaseFunctionsPlugin {
|
|
|
4
4
|
*
|
|
5
5
|
* @since 6.1.0
|
|
6
6
|
*/
|
|
7
|
-
callByName(options: CallByNameOptions): Promise<CallByNameResult
|
|
7
|
+
callByName<RequestData = unknown, ResponseData = unknown>(options: CallByNameOptions<RequestData>): Promise<CallByNameResult<ResponseData>>;
|
|
8
8
|
/**
|
|
9
9
|
* Call a callable function by URL.
|
|
10
10
|
*
|
|
11
11
|
* @since 6.1.0
|
|
12
12
|
*/
|
|
13
|
-
callByUrl(options: CallByUrlOptions): Promise<CallByUrlResult
|
|
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>;
|
|
14
30
|
}
|
|
15
31
|
/**
|
|
16
32
|
* @since 6.1.0
|
|
17
33
|
*/
|
|
18
|
-
export interface CallByNameOptions extends CallOptions {
|
|
34
|
+
export interface CallByNameOptions<RequestData = unknown> extends CallOptions<RequestData> {
|
|
19
35
|
/**
|
|
20
36
|
* The name of the callable function.
|
|
21
37
|
*
|
|
@@ -34,11 +50,11 @@ export interface CallByNameOptions extends CallOptions {
|
|
|
34
50
|
/**
|
|
35
51
|
* @since 6.1.0
|
|
36
52
|
*/
|
|
37
|
-
export declare type CallByNameResult = CallResult
|
|
53
|
+
export declare type CallByNameResult<ResponseData = unknown> = CallResult<ResponseData>;
|
|
38
54
|
/**
|
|
39
55
|
* @since 6.1.0
|
|
40
56
|
*/
|
|
41
|
-
export interface CallByUrlOptions extends CallOptions {
|
|
57
|
+
export interface CallByUrlOptions<RequestData = unknown> extends CallOptions<RequestData> {
|
|
42
58
|
/**
|
|
43
59
|
* The URL of the callable function.
|
|
44
60
|
*
|
|
@@ -50,26 +66,48 @@ export interface CallByUrlOptions extends CallOptions {
|
|
|
50
66
|
/**
|
|
51
67
|
* @since 6.1.0
|
|
52
68
|
*/
|
|
53
|
-
export declare type CallByUrlResult = CallResult
|
|
69
|
+
export declare type CallByUrlResult<ResponseData = unknown> = CallResult<ResponseData>;
|
|
54
70
|
/**
|
|
55
71
|
* @since 6.1.0
|
|
56
72
|
*/
|
|
57
|
-
export interface CallOptions {
|
|
73
|
+
export interface CallOptions<RequestData = unknown> {
|
|
58
74
|
/**
|
|
59
75
|
* The data to pass to the callable function.
|
|
60
76
|
*
|
|
61
77
|
* @since 6.1.0
|
|
62
78
|
*/
|
|
63
|
-
data?:
|
|
79
|
+
data?: RequestData | null;
|
|
64
80
|
}
|
|
65
81
|
/**
|
|
66
82
|
* @since 6.1.0
|
|
67
83
|
*/
|
|
68
|
-
export interface CallResult {
|
|
84
|
+
export interface CallResult<ResponseData = unknown> {
|
|
69
85
|
/**
|
|
70
86
|
* The result of the callable function.
|
|
71
87
|
*
|
|
72
88
|
* @since 6.1.0
|
|
73
89
|
*/
|
|
74
|
-
data
|
|
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;
|
|
75
113
|
}
|
|
@@ -1 +1 @@
|
|
|
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(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,5 +1,5 @@
|
|
|
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
5
|
const functions = getFunctions(undefined, options.region);
|
|
@@ -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
|
@@ -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(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}\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,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;;;;;;;;;"}
|
|
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
|
@@ -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(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}\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,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;;;;;;;;;;;;;;;;;"}
|
|
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;;;;;;;;;;;;;;;;;"}
|
|
@@ -18,7 +18,7 @@ import FirebaseFunctions
|
|
|
18
18
|
let region = options.getRegion()
|
|
19
19
|
let data = options.getData()
|
|
20
20
|
|
|
21
|
-
let functions: Functions
|
|
21
|
+
let functions: Functions
|
|
22
22
|
if let region = region {
|
|
23
23
|
functions = Functions.functions(region: region)
|
|
24
24
|
} else {
|
|
@@ -50,4 +50,8 @@ import FirebaseFunctions
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
@objc func useEmulator(_ host: String, _ port: Int) {
|
|
55
|
+
Functions.functions().useEmulator(withHost: host, port: port)
|
|
56
|
+
}
|
|
53
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() {
|
|
@@ -57,4 +58,15 @@ public class FirebaseFunctionsPlugin: CAPPlugin {
|
|
|
57
58
|
}
|
|
58
59
|
})
|
|
59
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
|
+
}
|
|
60
72
|
}
|
package/package.json
CHANGED