2020// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121// SOFTWARE.
2222
23- import * as _ from 'lodash' ;
2423import * as express from 'express' ;
24+ import * as _ from 'lodash' ;
2525
26+ import { CloudFunction , EventContext } from './cloud-functions' ;
27+ import {
28+ DeploymentOptions ,
29+ MAX_TIMEOUT_SECONDS ,
30+ RuntimeOptions ,
31+ SUPPORTED_REGIONS ,
32+ VALID_MEMORY_OPTIONS ,
33+ } from './function-configuration' ;
2634import * as analytics from './providers/analytics' ;
2735import * as auth from './providers/auth' ;
2836import * as crashlytics from './providers/crashlytics' ;
@@ -32,35 +40,6 @@ import * as https from './providers/https';
3240import * as pubsub from './providers/pubsub' ;
3341import * as remoteConfig from './providers/remoteConfig' ;
3442import * as storage from './providers/storage' ;
35- import { CloudFunction , EventContext , Schedule } from './cloud-functions' ;
36-
37- /**
38- * List of all regions supported by Cloud Functions.
39- */
40- const SUPPORTED_REGIONS = [
41- 'us-central1' ,
42- 'us-east1' ,
43- 'us-east4' ,
44- 'europe-west1' ,
45- 'europe-west2' ,
46- 'asia-east2' ,
47- 'asia-northeast1' ,
48- ] ;
49-
50- /**
51- * List of available memory options supported by Cloud Functions.
52- */
53- const VALID_MEMORY_OPTS = [ '128MB' , '256MB' , '512MB' , '1GB' , '2GB' ] ;
54-
55- // Adding this memory type here to error on compile for TS users.
56- // Unfortunately I have not found a way to merge this with VALID_MEMORY_OPS
57- // without it being super ugly. But here they are right next to each other at least.
58- type Memory = '128MB' | '256MB' | '512MB' | '1GB' | '2GB' ;
59-
60- /**
61- * Cloud Functions max timeout value.
62- */
63- const MAX_TIMEOUT_SECONDS = 540 ;
6443
6544/**
6645 * Assert that the runtime options passed in are valid.
@@ -70,10 +49,10 @@ const MAX_TIMEOUT_SECONDS = 540;
7049function assertRuntimeOptionsValid ( runtimeOptions : RuntimeOptions ) : boolean {
7150 if (
7251 runtimeOptions . memory &&
73- ! _ . includes ( VALID_MEMORY_OPTS , runtimeOptions . memory )
52+ ! _ . includes ( VALID_MEMORY_OPTIONS , runtimeOptions . memory )
7453 ) {
7554 throw new Error (
76- `The only valid memory allocation values are: ${ VALID_MEMORY_OPTS . join (
55+ `The only valid memory allocation values are: ${ VALID_MEMORY_OPTIONS . join (
7756 ', '
7857 ) } `
7958 ) ;
@@ -130,18 +109,6 @@ export function runWith(runtimeOptions: RuntimeOptions): FunctionBuilder {
130109 }
131110}
132111
133- export interface RuntimeOptions {
134- timeoutSeconds ?: number ;
135- memory ?: Memory ;
136- }
137-
138- export interface DeploymentOptions {
139- regions ?: string [ ] ;
140- timeoutSeconds ?: number ;
141- memory ?: Memory ;
142- schedule ?: Schedule ;
143- }
144-
145112export class FunctionBuilder {
146113 constructor ( private options : DeploymentOptions ) { }
147114
0 commit comments