@@ -25,25 +25,35 @@ import {
25
25
HttpsFunction ,
26
26
Runnable ,
27
27
} from 'firebase-functions/v1' ;
28
-
29
28
import {
30
29
CloudFunction as CloudFunctionV2 ,
31
30
CloudEvent ,
32
31
} from 'firebase-functions/v2' ;
33
-
34
32
import {
35
33
CallableFunction ,
36
34
HttpsFunction as HttpsFunctionV2 ,
37
35
} from 'firebase-functions/v2/https' ;
38
36
39
- import { wrapV1 , WrappedFunction , WrappedScheduledFunction } from './v1' ;
40
-
41
- import { wrapV2 , WrappedV2Function , WrappedV2CallableFunction } from './v2' ;
37
+ import { wrapV1 } from './v1' ;
38
+ import { wrapV2 } from './v2' ;
39
+ import { WrappedFunction , WrappedScheduledFunction } from './types/v1Types' ;
40
+ import { WrappedV2Function , WrappedV2CallableFunction } from './types/v2Types' ;
41
+ import { HttpsFunctionOrCloudFunctionV1 } from './types/v1Types' ;
42
42
43
- type HttpsFunctionOrCloudFunctionV1 < T , U > = U extends HttpsFunction &
44
- Runnable < T >
45
- ? HttpsFunction & Runnable < T >
46
- : CloudFunctionV1 < T > ;
43
+ /**
44
+ * The key differences between V1 and V2 CloudFunctions are:
45
+ * <ul>
46
+ * <li> V1 CloudFunction is sometimes a binary function
47
+ * <li> V2 CloudFunction is always a unary function
48
+ * <li> V1 CloudFunction.run is always a binary function
49
+ * <li> V2 CloudFunction.run is always a unary function
50
+ * @return True iff the CloudFunction is a V2 function.
51
+ */
52
+ function isV2CloudFunction < T extends CloudEvent < unknown > > (
53
+ cloudFunction : any
54
+ ) : cloudFunction is CloudFunctionV2 < T > {
55
+ return cloudFunction . length === 1 && cloudFunction ?. run ?. length === 1 ;
56
+ }
47
57
48
58
// Re-exporting V1 (to reduce breakage)
49
59
export {
@@ -52,13 +62,13 @@ export {
52
62
WrappedFunction ,
53
63
WrappedScheduledFunction ,
54
64
CallableContextOptions ,
65
+ } from './types/v1Types' ;
66
+ export {
55
67
makeChange ,
56
- mockConfig ,
57
- } from './v1' ;
58
-
68
+ mockConfig
69
+ } from './v1'
59
70
// V2 Exports
60
- export { WrappedV2Function } from './v2' ;
61
-
71
+ export { WrappedV2Function } from './types/v2Types' ;
62
72
export function wrap < T > (
63
73
cloudFunction : HttpsFunction & Runnable < T >
64
74
) : WrappedFunction < T , HttpsFunction & Runnable < T > > ;
@@ -84,19 +94,4 @@ export function wrap<T, V extends CloudEvent<unknown>>(
84
94
return wrapV1 < T > (
85
95
cloudFunction as HttpsFunctionOrCloudFunctionV1 < T , typeof cloudFunction >
86
96
) ;
87
- }
88
-
89
- /**
90
- * The key differences between V1 and V2 CloudFunctions are:
91
- * <ul>
92
- * <li> V1 CloudFunction is sometimes a binary function
93
- * <li> V2 CloudFunction is always a unary function
94
- * <li> V1 CloudFunction.run is always a binary function
95
- * <li> V2 CloudFunction.run is always a unary function
96
- * @return True iff the CloudFunction is a V2 function.
97
- */
98
- function isV2CloudFunction < T extends CloudEvent < unknown > > (
99
- cloudFunction : any
100
- ) : cloudFunction is CloudFunctionV2 < T > {
101
- return cloudFunction . length === 1 && cloudFunction ?. run ?. length === 1 ;
102
- }
97
+ }
0 commit comments