@capacitor-firebase/functions 6.0.0-dev.59ed099.1719590033
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 +167 -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 +67 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctionsPlugin.java +91 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByNameOptions.java +29 -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 +67 -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 +195 -0
- package/dist/esm/definitions.d.ts +75 -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 +20 -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 +26 -0
- package/ios/Plugin/FirebaseFunctions.swift +53 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.h +10 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.m +9 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.swift +60 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/package.json +99 -0
package/dist/docs.json
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
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
|
+
{
|
|
21
|
+
"name": "since",
|
|
22
|
+
"text": "6.1.0"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"docs": "Call a callable function by name.",
|
|
26
|
+
"complexTypes": [
|
|
27
|
+
"CallResult",
|
|
28
|
+
"CallByNameOptions",
|
|
29
|
+
"CallByNameResult"
|
|
30
|
+
],
|
|
31
|
+
"slug": "callbyname"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "callByUrl",
|
|
35
|
+
"signature": "(options: CallByUrlOptions) => Promise<CallByUrlResult>",
|
|
36
|
+
"parameters": [
|
|
37
|
+
{
|
|
38
|
+
"name": "options",
|
|
39
|
+
"docs": "",
|
|
40
|
+
"type": "CallByUrlOptions"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"returns": "Promise<CallResult>",
|
|
44
|
+
"tags": [
|
|
45
|
+
{
|
|
46
|
+
"name": "since",
|
|
47
|
+
"text": "6.1.0"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"docs": "Call a callable function by URL.",
|
|
51
|
+
"complexTypes": [
|
|
52
|
+
"CallResult",
|
|
53
|
+
"CallByUrlOptions",
|
|
54
|
+
"CallByUrlResult"
|
|
55
|
+
],
|
|
56
|
+
"slug": "callbyurl"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"properties": []
|
|
60
|
+
},
|
|
61
|
+
"interfaces": [
|
|
62
|
+
{
|
|
63
|
+
"name": "CallResult",
|
|
64
|
+
"slug": "callresult",
|
|
65
|
+
"docs": "",
|
|
66
|
+
"tags": [
|
|
67
|
+
{
|
|
68
|
+
"text": "6.1.0",
|
|
69
|
+
"name": "since"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"methods": [],
|
|
73
|
+
"properties": [
|
|
74
|
+
{
|
|
75
|
+
"name": "data",
|
|
76
|
+
"tags": [
|
|
77
|
+
{
|
|
78
|
+
"text": "6.1.0",
|
|
79
|
+
"name": "since"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"docs": "The result of the callable function.",
|
|
83
|
+
"complexTypes": [],
|
|
84
|
+
"type": "any"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "CallByNameOptions",
|
|
90
|
+
"slug": "callbynameoptions",
|
|
91
|
+
"docs": "",
|
|
92
|
+
"tags": [
|
|
93
|
+
{
|
|
94
|
+
"text": "6.1.0",
|
|
95
|
+
"name": "since"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"methods": [],
|
|
99
|
+
"properties": [
|
|
100
|
+
{
|
|
101
|
+
"name": "name",
|
|
102
|
+
"tags": [
|
|
103
|
+
{
|
|
104
|
+
"text": "'myFunction'",
|
|
105
|
+
"name": "example"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"text": "6.1.0",
|
|
109
|
+
"name": "since"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"docs": "The name of the callable function.",
|
|
113
|
+
"complexTypes": [],
|
|
114
|
+
"type": "string"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "region",
|
|
118
|
+
"tags": [
|
|
119
|
+
{
|
|
120
|
+
"text": "'us-central1'",
|
|
121
|
+
"name": "example"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"text": "6.1.0",
|
|
125
|
+
"name": "since"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"docs": "The region of the callable function.",
|
|
129
|
+
"complexTypes": [],
|
|
130
|
+
"type": "string | undefined"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "CallByUrlOptions",
|
|
136
|
+
"slug": "callbyurloptions",
|
|
137
|
+
"docs": "",
|
|
138
|
+
"tags": [
|
|
139
|
+
{
|
|
140
|
+
"text": "6.1.0",
|
|
141
|
+
"name": "since"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"methods": [],
|
|
145
|
+
"properties": [
|
|
146
|
+
{
|
|
147
|
+
"name": "url",
|
|
148
|
+
"tags": [
|
|
149
|
+
{
|
|
150
|
+
"text": "'https://us-central1-my-project.cloudfunctions.net/myFunction'",
|
|
151
|
+
"name": "example"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"text": "6.1.0",
|
|
155
|
+
"name": "since"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"docs": "The URL of the callable function.",
|
|
159
|
+
"complexTypes": [],
|
|
160
|
+
"type": "string"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"enums": [],
|
|
166
|
+
"typeAliases": [
|
|
167
|
+
{
|
|
168
|
+
"name": "CallByNameResult",
|
|
169
|
+
"slug": "callbynameresult",
|
|
170
|
+
"docs": "",
|
|
171
|
+
"types": [
|
|
172
|
+
{
|
|
173
|
+
"text": "CallResult",
|
|
174
|
+
"complexTypes": [
|
|
175
|
+
"CallResult"
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "CallByUrlResult",
|
|
182
|
+
"slug": "callbyurlresult",
|
|
183
|
+
"docs": "",
|
|
184
|
+
"types": [
|
|
185
|
+
{
|
|
186
|
+
"text": "CallResult",
|
|
187
|
+
"complexTypes": [
|
|
188
|
+
"CallResult"
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"pluginConfigs": []
|
|
195
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface FirebaseFunctionsPlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Call a callable function by name.
|
|
4
|
+
*
|
|
5
|
+
* @since 6.1.0
|
|
6
|
+
*/
|
|
7
|
+
callByName(options: CallByNameOptions): Promise<CallByNameResult>;
|
|
8
|
+
/**
|
|
9
|
+
* Call a callable function by URL.
|
|
10
|
+
*
|
|
11
|
+
* @since 6.1.0
|
|
12
|
+
*/
|
|
13
|
+
callByUrl(options: CallByUrlOptions): Promise<CallByUrlResult>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @since 6.1.0
|
|
17
|
+
*/
|
|
18
|
+
export interface CallByNameOptions extends CallOptions {
|
|
19
|
+
/**
|
|
20
|
+
* The name of the callable function.
|
|
21
|
+
*
|
|
22
|
+
* @example 'myFunction'
|
|
23
|
+
* @since 6.1.0
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* The region of the callable function.
|
|
28
|
+
*
|
|
29
|
+
* @example 'us-central1'
|
|
30
|
+
* @since 6.1.0
|
|
31
|
+
*/
|
|
32
|
+
region?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @since 6.1.0
|
|
36
|
+
*/
|
|
37
|
+
export declare type CallByNameResult = CallResult;
|
|
38
|
+
/**
|
|
39
|
+
* @since 6.1.0
|
|
40
|
+
*/
|
|
41
|
+
export interface CallByUrlOptions extends CallOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The URL of the callable function.
|
|
44
|
+
*
|
|
45
|
+
* @example 'https://us-central1-my-project.cloudfunctions.net/myFunction'
|
|
46
|
+
* @since 6.1.0
|
|
47
|
+
*/
|
|
48
|
+
url: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @since 6.1.0
|
|
52
|
+
*/
|
|
53
|
+
export declare type CallByUrlResult = CallResult;
|
|
54
|
+
/**
|
|
55
|
+
* @since 6.1.0
|
|
56
|
+
*/
|
|
57
|
+
export interface CallOptions {
|
|
58
|
+
/**
|
|
59
|
+
* The data to pass to the callable function.
|
|
60
|
+
*
|
|
61
|
+
* @since 6.1.0
|
|
62
|
+
*/
|
|
63
|
+
data?: any;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @since 6.1.0
|
|
67
|
+
*/
|
|
68
|
+
export interface CallResult {
|
|
69
|
+
/**
|
|
70
|
+
* The result of the callable function.
|
|
71
|
+
*
|
|
72
|
+
* @since 6.1.0
|
|
73
|
+
*/
|
|
74
|
+
data?: any;
|
|
75
|
+
}
|
|
@@ -0,0 +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>;\n /**\n * Call a callable function by URL.\n *\n * @since 6.1.0\n */\n callByUrl(options: CallByUrlOptions): Promise<CallByUrlResult>;\n}\n\n/**\n * @since 6.1.0\n */\nexport interface CallByNameOptions extends CallOptions {\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 = CallResult;\n\n/**\n * @since 6.1.0\n */\nexport interface CallByUrlOptions extends CallOptions {\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 = CallResult;\n\n/**\n * @since 6.1.0\n */\nexport interface CallOptions {\n /**\n * The data to pass to the callable function.\n *\n * @since 6.1.0\n */\n data?: any;\n}\n\n/**\n * @since 6.1.0\n */\nexport interface CallResult {\n /**\n * The result of the callable function.\n *\n * @since 6.1.0\n */\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(undefined, options.region);
|
|
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,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1D,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(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\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(undefined, options.region);
|
|
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(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;;;;;;;;;"}
|
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(undefined, options.region);
|
|
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(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;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class CallByNameOptions: CallOptions {
|
|
4
|
+
private var name: String
|
|
5
|
+
private var region: String?
|
|
6
|
+
|
|
7
|
+
init(name: String, region: String?, data: Any?) {
|
|
8
|
+
self.name = name
|
|
9
|
+
self.region = region
|
|
10
|
+
super.init(data: data)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func getName() -> String {
|
|
14
|
+
return name
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func getRegion() -> String? {
|
|
18
|
+
return region
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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"] = CallResult.createJSValue(value: data)
|
|
14
|
+
return result as AnyObject
|
|
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
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 region = options.getRegion()
|
|
19
|
+
let data = options.getData()
|
|
20
|
+
|
|
21
|
+
let functions: Functions;
|
|
22
|
+
if let region = region {
|
|
23
|
+
functions = Functions.functions(region: region)
|
|
24
|
+
} else {
|
|
25
|
+
functions = Functions.functions()
|
|
26
|
+
}
|
|
27
|
+
let callable = functions.httpsCallable(name)
|
|
28
|
+
callable.call(data) { (result, error) in
|
|
29
|
+
if let error = error {
|
|
30
|
+
completion(nil, error)
|
|
31
|
+
} else {
|
|
32
|
+
let result = CallResult(data: result?.data)
|
|
33
|
+
completion(result, nil)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@objc public func callByUrl(_ options: CallByUrlOptions, completion: @escaping (Result?, Error?) -> Void) {
|
|
39
|
+
let url = options.getUrl()
|
|
40
|
+
let data = options.getData()
|
|
41
|
+
|
|
42
|
+
let functions = Functions.functions()
|
|
43
|
+
let callable = functions.httpsCallable(url)
|
|
44
|
+
callable.call(data) { (result, error) in
|
|
45
|
+
if let error = error {
|
|
46
|
+
completion(nil, error)
|
|
47
|
+
} else {
|
|
48
|
+
let result = CallResult(data: result?.data)
|
|
49
|
+
completion(result, nil)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -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,60 @@
|
|
|
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 region = call.getString("region")
|
|
24
|
+
let data = call.getValue("data")
|
|
25
|
+
|
|
26
|
+
let options = CallByNameOptions(name: name, region: region, data: data)
|
|
27
|
+
|
|
28
|
+
implementation?.callByName(options, completion: { result, error in
|
|
29
|
+
if let error = error {
|
|
30
|
+
CAPLog.print("[", self.tag, "] ", error)
|
|
31
|
+
call.reject(error.localizedDescription)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
35
|
+
call.resolve(result)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc func callByUrl(_ call: CAPPluginCall) {
|
|
41
|
+
guard let url = call.getString("url") else {
|
|
42
|
+
call.reject("url must be provided.")
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
let data = call.getValue("data")
|
|
46
|
+
|
|
47
|
+
let options = CallByUrlOptions(url: url, data: data)
|
|
48
|
+
|
|
49
|
+
implementation?.callByUrl(options, completion: { result, error in
|
|
50
|
+
if let error = error {
|
|
51
|
+
CAPLog.print("[", self.tag, "] ", error)
|
|
52
|
+
call.reject(error.localizedDescription)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
56
|
+
call.resolve(result)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -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>
|