firebase-functions 3.20.1 → 3.21.2
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/lib/apps.js +1 -1
- package/lib/bin/firebase-functions.js +22 -1
- package/lib/cloud-functions.d.ts +56 -35
- package/lib/cloud-functions.js +12 -12
- package/lib/common/encoding.js +21 -1
- package/lib/common/providers/https.d.ts +37 -17
- package/lib/common/providers/https.js +11 -6
- package/lib/common/providers/identity.d.ts +11 -1
- package/lib/common/providers/identity.js +59 -207
- package/lib/common/providers/tasks.d.ts +9 -0
- package/lib/function-builder.d.ts +2 -2
- package/lib/function-builder.js +1 -1
- package/lib/handler-builder.js +3 -3
- package/lib/index.js +6 -2
- package/lib/logger/common.js +21 -0
- package/lib/logger/compat.js +22 -1
- package/lib/logger/index.d.ts +14 -6
- package/lib/logger/index.js +33 -6
- package/lib/providers/analytics.js +1 -1
- package/lib/providers/auth.d.ts +44 -10
- package/lib/providers/auth.js +80 -14
- package/lib/providers/database.js +11 -11
- package/lib/providers/firestore.js +7 -7
- package/lib/providers/https.js +7 -7
- package/lib/providers/pubsub.d.ts +6 -6
- package/lib/providers/pubsub.js +8 -8
- package/lib/providers/remoteConfig.js +1 -1
- package/lib/providers/storage.js +2 -2
- package/lib/providers/tasks.d.ts +30 -15
- package/lib/providers/tasks.js +19 -12
- package/lib/providers/testLab.js +1 -1
- package/lib/runtime/loader.js +9 -7
- package/lib/runtime/manifest.d.ts +5 -0
- package/lib/setup.js +3 -3
- package/lib/v2/core.d.ts +24 -20
- package/lib/v2/index.d.ts +11 -4
- package/lib/v2/index.js +12 -5
- package/lib/v2/options.d.ts +25 -35
- package/lib/v2/options.js +28 -88
- package/lib/v2/params/index.d.ts +4 -1
- package/lib/v2/params/index.js +25 -1
- package/lib/v2/params/types.js +21 -0
- package/lib/v2/providers/alerts/alerts.d.ts +107 -8
- package/lib/v2/providers/alerts/alerts.js +23 -7
- package/lib/v2/providers/alerts/appDistribution.d.ts +112 -12
- package/lib/v2/providers/alerts/appDistribution.js +29 -2
- package/lib/v2/providers/alerts/billing.d.ts +39 -12
- package/lib/v2/providers/alerts/billing.js +38 -1
- package/lib/v2/providers/alerts/crashlytics.d.ts +255 -47
- package/lib/v2/providers/alerts/crashlytics.js +63 -2
- package/lib/v2/providers/alerts/index.d.ts +6 -0
- package/lib/v2/providers/alerts/index.js +32 -1
- package/lib/v2/providers/eventarc.d.ts +90 -6
- package/lib/v2/providers/eventarc.js +7 -3
- package/lib/v2/providers/https.d.ts +128 -4
- package/lib/v2/providers/https.js +18 -14
- package/lib/v2/providers/identity.d.ts +126 -0
- package/lib/v2/providers/identity.js +104 -0
- package/lib/v2/providers/pubsub.d.ts +125 -8
- package/lib/v2/providers/pubsub.js +60 -7
- package/lib/v2/providers/storage.d.ts +209 -17
- package/lib/v2/providers/storage.js +57 -13
- package/lib/v2/providers/tasks.d.ts +107 -7
- package/lib/v2/providers/tasks.js +11 -8
- package/package.json +18 -3
package/lib/providers/testLab.js
CHANGED
|
@@ -57,7 +57,7 @@ class TestMatrixBuilder {
|
|
|
57
57
|
const dataConstructor = (raw) => {
|
|
58
58
|
return new TestMatrix(raw.data);
|
|
59
59
|
};
|
|
60
|
-
return cloud_functions_1.makeCloudFunction({
|
|
60
|
+
return (0, cloud_functions_1.makeCloudFunction)({
|
|
61
61
|
provider: exports.PROVIDER,
|
|
62
62
|
eventType: exports.TEST_MATRIX_COMPLETE_EVENT_TYPE,
|
|
63
63
|
triggerResource: this.triggerResource,
|
package/lib/runtime/loader.js
CHANGED
|
@@ -22,8 +22,8 @@ exports.loadStack = exports.mergeRequiredAPIs = exports.extractStack = void 0;
|
|
|
22
22
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
23
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
24
|
// SOFTWARE.
|
|
25
|
-
const url = require("url");
|
|
26
25
|
const path = require("path");
|
|
26
|
+
const url = require("url");
|
|
27
27
|
/**
|
|
28
28
|
* Dynamically load import function to prevent TypeScript from
|
|
29
29
|
* transpiling into a require.
|
|
@@ -51,17 +51,19 @@ async function loadModule(functionsDir) {
|
|
|
51
51
|
}
|
|
52
52
|
/* @internal */
|
|
53
53
|
function extractStack(module, endpoints, requiredAPIs, prefix = '') {
|
|
54
|
-
for (const [name,
|
|
54
|
+
for (const [name, valAsUnknown] of Object.entries(module)) {
|
|
55
|
+
// We're introspecting untrusted code here. Any is appropraite
|
|
56
|
+
const val = valAsUnknown;
|
|
55
57
|
if (typeof val === 'function' &&
|
|
56
|
-
val
|
|
57
|
-
typeof val
|
|
58
|
+
val.__endpoint &&
|
|
59
|
+
typeof val.__endpoint === 'object') {
|
|
58
60
|
const funcName = prefix + name;
|
|
59
61
|
endpoints[funcName] = {
|
|
60
|
-
...val
|
|
62
|
+
...val.__endpoint,
|
|
61
63
|
entryPoint: funcName.replace(/-/g, '.'),
|
|
62
64
|
};
|
|
63
|
-
if (val
|
|
64
|
-
requiredAPIs.push(...val
|
|
65
|
+
if (val.__requiredAPIs && Array.isArray(val.__requiredAPIs)) {
|
|
66
|
+
requiredAPIs.push(...val.__requiredAPIs);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
else if (typeof val === 'object' && val !== null) {
|
|
@@ -11,6 +11,7 @@ export interface ManifestEndpoint {
|
|
|
11
11
|
concurrency?: number;
|
|
12
12
|
serviceAccountEmail?: string;
|
|
13
13
|
timeoutSeconds?: number;
|
|
14
|
+
cpu?: number | 'gcf_gen1';
|
|
14
15
|
vpc?: {
|
|
15
16
|
connector: string;
|
|
16
17
|
egressSettings?: string;
|
|
@@ -46,6 +47,10 @@ export interface ManifestEndpoint {
|
|
|
46
47
|
maxDoublings?: number;
|
|
47
48
|
};
|
|
48
49
|
};
|
|
50
|
+
blockingTrigger?: {
|
|
51
|
+
eventType: string;
|
|
52
|
+
options?: Record<string, unknown>;
|
|
53
|
+
};
|
|
49
54
|
}
|
|
50
55
|
export interface ManifestRequiredAPI {
|
|
51
56
|
api: string;
|
package/lib/setup.js
CHANGED
|
@@ -31,7 +31,7 @@ function setup() {
|
|
|
31
31
|
// Until the Cloud Functions builder can publish FIREBASE_CONFIG, automatically provide it on import based on what
|
|
32
32
|
// we can deduce.
|
|
33
33
|
if (!process.env.FIREBASE_CONFIG) {
|
|
34
|
-
const cfg = config_1.firebaseConfig();
|
|
34
|
+
const cfg = (0, config_1.firebaseConfig)();
|
|
35
35
|
if (cfg) {
|
|
36
36
|
process.env.FIREBASE_CONFIG = JSON.stringify(cfg);
|
|
37
37
|
}
|
|
@@ -43,7 +43,7 @@ function setup() {
|
|
|
43
43
|
// If FIREBASE_CONFIG is still not found, try using GCLOUD_PROJECT to estimate
|
|
44
44
|
if (!process.env.FIREBASE_CONFIG) {
|
|
45
45
|
if (process.env.GCLOUD_PROJECT) {
|
|
46
|
-
logger_1.warn('Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail');
|
|
46
|
+
(0, logger_1.warn)('Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail');
|
|
47
47
|
process.env.FIREBASE_CONFIG = JSON.stringify({
|
|
48
48
|
databaseURL: process.env.DATABASE_URL ||
|
|
49
49
|
`https://${process.env.GCLOUD_PROJECT}.firebaseio.com`,
|
|
@@ -53,7 +53,7 @@ function setup() {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
logger_1.warn('Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail');
|
|
56
|
+
(0, logger_1.warn)('Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail');
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
package/lib/v2/core.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core functionality of the Firebase Functions v2 SDK.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { ManifestEndpoint } from '../runtime/manifest';
|
|
2
6
|
/**
|
|
3
7
|
* A CloudEventBase is the base of a cross-platform format for encoding a serverless event.
|
|
4
8
|
* More information can be found in https://github.com/cloudevents/spec
|
|
9
|
+
* @typeParam T - The type of the event data.
|
|
10
|
+
* @beta
|
|
5
11
|
*/
|
|
6
|
-
interface
|
|
12
|
+
export interface CloudEvent<T> {
|
|
7
13
|
/** Version of the CloudEvents spec for this event. */
|
|
8
14
|
readonly specversion: '1.0';
|
|
9
15
|
/** A globally unique ID for this event. */
|
|
@@ -18,29 +24,27 @@ interface CloudEventBase<T> {
|
|
|
18
24
|
time: string;
|
|
19
25
|
/** Information about this specific event. */
|
|
20
26
|
data: T;
|
|
21
|
-
/**
|
|
22
|
-
* A map of template parameter name to value for subject strings.
|
|
23
|
-
*
|
|
24
|
-
* This map is only available on some event types that allow templates
|
|
25
|
-
* in the subject string, such as Firestore. When listening to a document
|
|
26
|
-
* template "/users/{uid}", an event with subject "/documents/users/1234"
|
|
27
|
-
* would have a params of {"uid": "1234"}.
|
|
28
|
-
*
|
|
29
|
-
* Params are generated inside the firebase-functions SDK and are not
|
|
30
|
-
* part of the CloudEvents spec nor the payload that a Cloud Function
|
|
31
|
-
* actually receives.
|
|
32
|
-
*/
|
|
33
|
-
params?: Record<string, string>;
|
|
34
27
|
}
|
|
35
28
|
/**
|
|
36
|
-
* A
|
|
29
|
+
* A handler for CloudEvents.
|
|
30
|
+
* @typeParam EventType - The kind of event this function handles.
|
|
31
|
+
* Always a subclass of CloudEvent<>
|
|
32
|
+
* @beta
|
|
37
33
|
*/
|
|
38
|
-
export
|
|
39
|
-
/** A handler for CloudEvents. */
|
|
40
|
-
export interface CloudFunction<T> {
|
|
34
|
+
export interface CloudFunction<EventType extends CloudEvent<unknown>> {
|
|
41
35
|
(raw: CloudEvent<unknown>): any | Promise<any>;
|
|
36
|
+
/** @alpha */
|
|
42
37
|
__trigger?: unknown;
|
|
38
|
+
/** @alpha */
|
|
43
39
|
__endpoint: ManifestEndpoint;
|
|
44
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The callback passed to the CloudFunction constructor.
|
|
42
|
+
* Use run to test a CloudFunction
|
|
43
|
+
* @param event - The parsed event to handle.
|
|
44
|
+
* @returns Any return value. Google Cloud Functions awaits any promise
|
|
45
|
+
* before shutting down your function. Resolved return values
|
|
46
|
+
* are only used for unit testing purposes.
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
run(event: EventType): any | Promise<any>;
|
|
45
50
|
}
|
|
46
|
-
export {};
|
package/lib/v2/index.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The V2 API for Cloud Functions for Firebase.
|
|
3
|
+
* This SDK also supports deep imports. For example, the namespace
|
|
4
|
+
* 'pubsub' is available at 'firebase-functions/v2' or is directly importable
|
|
5
|
+
* from 'firebase-functions/v2/pubsub'.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
1
8
|
import * as logger from '../logger';
|
|
2
|
-
import * as params from './params';
|
|
3
9
|
import * as alerts from './providers/alerts';
|
|
10
|
+
import * as eventarc from './providers/eventarc';
|
|
4
11
|
import * as https from './providers/https';
|
|
12
|
+
import * as identity from './providers/identity';
|
|
5
13
|
import * as pubsub from './providers/pubsub';
|
|
6
14
|
import * as storage from './providers/storage';
|
|
7
15
|
import * as tasks from './providers/tasks';
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
export { setGlobalOptions, GlobalOptions } from './options';
|
|
16
|
+
export { alerts, storage, https, identity, pubsub, logger, tasks, eventarc };
|
|
17
|
+
export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from './options';
|
|
11
18
|
export { CloudFunction, CloudEvent } from './core';
|
package/lib/v2/index.js
CHANGED
|
@@ -21,22 +21,29 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.
|
|
24
|
+
exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.alerts = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* The V2 API for Cloud Functions for Firebase.
|
|
27
|
+
* This SDK also supports deep imports. For example, the namespace
|
|
28
|
+
* 'pubsub' is available at 'firebase-functions/v2' or is directly importable
|
|
29
|
+
* from 'firebase-functions/v2/pubsub'.
|
|
30
|
+
* @packageDocumentation
|
|
31
|
+
*/
|
|
25
32
|
const logger = require("../logger");
|
|
26
33
|
exports.logger = logger;
|
|
27
|
-
const params = require("./params");
|
|
28
|
-
exports.params = params;
|
|
29
34
|
const alerts = require("./providers/alerts");
|
|
30
35
|
exports.alerts = alerts;
|
|
36
|
+
const eventarc = require("./providers/eventarc");
|
|
37
|
+
exports.eventarc = eventarc;
|
|
31
38
|
const https = require("./providers/https");
|
|
32
39
|
exports.https = https;
|
|
40
|
+
const identity = require("./providers/identity");
|
|
41
|
+
exports.identity = identity;
|
|
33
42
|
const pubsub = require("./providers/pubsub");
|
|
34
43
|
exports.pubsub = pubsub;
|
|
35
44
|
const storage = require("./providers/storage");
|
|
36
45
|
exports.storage = storage;
|
|
37
46
|
const tasks = require("./providers/tasks");
|
|
38
47
|
exports.tasks = tasks;
|
|
39
|
-
const eventarc = require("./providers/eventarc");
|
|
40
|
-
exports.eventarc = eventarc;
|
|
41
48
|
var options_1 = require("./options");
|
|
42
49
|
Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } });
|
package/lib/v2/options.d.ts
CHANGED
|
@@ -2,48 +2,19 @@ import { ParamSpec } from './params/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* List of all regions supported by Cloud Functions v2
|
|
4
4
|
*/
|
|
5
|
-
export declare
|
|
6
|
-
/**
|
|
7
|
-
* A region known to be supported by CloudFunctions v2
|
|
8
|
-
*/
|
|
9
|
-
export declare type SupportedRegion = typeof SUPPORTED_REGIONS[number];
|
|
10
|
-
/**
|
|
11
|
-
* Cloud Functions v2 min timeout value.
|
|
12
|
-
*/
|
|
13
|
-
export declare const MIN_TIMEOUT_SECONDS = 1;
|
|
14
|
-
/**
|
|
15
|
-
* Cloud Functions v2 max timeout value for event handlers.
|
|
16
|
-
*/
|
|
17
|
-
export declare const MAX_EVENT_TIMEOUT_SECONDS = 540;
|
|
18
|
-
/**
|
|
19
|
-
* Cloud Functions v2 max timeout for HTTPS functions.
|
|
20
|
-
*/
|
|
21
|
-
export declare const MAX_HTTPS_TIMEOUT_SECONDS = 36000;
|
|
22
|
-
/**
|
|
23
|
-
* Maximum number of requests to serve on a single instance.
|
|
24
|
-
*/
|
|
25
|
-
export declare const MAX_CONCURRENCY = 1000;
|
|
5
|
+
export declare type SupportedRegion = 'asia-northeast1' | 'europe-north1' | 'europe-west1' | 'europe-west4' | 'us-central1' | 'us-east1' | 'us-west1';
|
|
26
6
|
/**
|
|
27
7
|
* List of available memory options supported by Cloud Functions.
|
|
28
8
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
/**
|
|
31
|
-
* A supported memory option.
|
|
32
|
-
*/
|
|
33
|
-
export declare type MemoryOption = typeof SUPPORTED_MEMORY_OPTIONS[number];
|
|
9
|
+
export declare type MemoryOption = '128MiB' | '256MiB' | '512MiB' | '1GiB' | '2GiB' | '4GiB' | '8GiB' | '16GiB' | '32GiB';
|
|
34
10
|
/**
|
|
35
11
|
* List of available options for VpcConnectorEgressSettings.
|
|
36
12
|
*/
|
|
37
|
-
export declare
|
|
38
|
-
/**
|
|
39
|
-
* A valid VPC Egress setting.
|
|
40
|
-
*/
|
|
41
|
-
export declare type VpcEgressSetting = typeof SUPPORTED_VPC_EGRESS_SETTINGS[number];
|
|
13
|
+
export declare type VpcEgressSetting = 'PRIVATE_RANGES_ONLY' | 'ALL_TRAFFIC';
|
|
42
14
|
/**
|
|
43
15
|
* List of available options for IngressSettings.
|
|
44
16
|
*/
|
|
45
|
-
export declare
|
|
46
|
-
export declare type IngressSetting = typeof SUPPORTED_INGRESS_SETTINGS[number];
|
|
17
|
+
export declare type IngressSetting = 'ALLOW_ALL' | 'ALLOW_INTERNAL_ONLY' | 'ALLOW_INTERNAL_AND_GCLB';
|
|
47
18
|
/**
|
|
48
19
|
* GlobalOptions are options that can be set across an entire project.
|
|
49
20
|
* These options are common to HTTPS and Event handling functions.
|
|
@@ -63,6 +34,11 @@ export interface GlobalOptions {
|
|
|
63
34
|
* Timeout for the function in sections, possible values are 0 to 540.
|
|
64
35
|
* HTTPS functions can specify a higher timeout.
|
|
65
36
|
* A value of null restores the default of 60s
|
|
37
|
+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
|
38
|
+
* function depends on the type of function: Event handling functions have a
|
|
39
|
+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
|
40
|
+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
|
41
|
+
* timeout of 1,800s (30 minutes)
|
|
66
42
|
*/
|
|
67
43
|
timeoutSeconds?: number | null;
|
|
68
44
|
/**
|
|
@@ -80,9 +56,20 @@ export interface GlobalOptions {
|
|
|
80
56
|
/**
|
|
81
57
|
* Number of requests a function can serve at once.
|
|
82
58
|
* Can only be applied to functions running on Cloud Functions v2.
|
|
83
|
-
* A value of null restores the default concurrency.
|
|
59
|
+
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
|
60
|
+
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
|
61
|
+
* The maximum value for concurrency is 1,000.
|
|
84
62
|
*/
|
|
85
63
|
concurrency?: number | null;
|
|
64
|
+
/**
|
|
65
|
+
* Fractional number of CPUs to allocate to a function.
|
|
66
|
+
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
|
67
|
+
* This is different from the defaults when using the gcloud utility and is different from
|
|
68
|
+
* the fixed amount assigned in Google Cloud Functions generation 1.
|
|
69
|
+
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
|
70
|
+
* to the value "gcf_gen1"
|
|
71
|
+
*/
|
|
72
|
+
cpu?: number | 'gcf_gen1';
|
|
86
73
|
/**
|
|
87
74
|
* Connect cloud function to specified VPC connector.
|
|
88
75
|
* A value of null removes the VPC connector
|
|
@@ -111,6 +98,7 @@ export interface GlobalOptions {
|
|
|
111
98
|
* Invoker to set access control on https functions.
|
|
112
99
|
*/
|
|
113
100
|
invoker?: 'public' | 'private' | string | string[];
|
|
101
|
+
secrets?: string[];
|
|
114
102
|
}
|
|
115
103
|
/**
|
|
116
104
|
* Sets default options for all functions written using the v2 SDK.
|
|
@@ -118,13 +106,15 @@ export interface GlobalOptions {
|
|
|
118
106
|
*/
|
|
119
107
|
export declare function setGlobalOptions(options: GlobalOptions): void;
|
|
120
108
|
/**
|
|
121
|
-
*
|
|
109
|
+
* Additional fields that can be set on any event-handling Cloud Function.
|
|
122
110
|
*/
|
|
123
111
|
export interface EventHandlerOptions extends GlobalOptions {
|
|
112
|
+
/** Whether failed executions should be delivered again. */
|
|
124
113
|
retry?: boolean;
|
|
125
114
|
}
|
|
126
115
|
/**
|
|
127
116
|
* @hidden
|
|
117
|
+
* @alpha
|
|
128
118
|
*/
|
|
129
119
|
export declare function __getSpec(): {
|
|
130
120
|
globalOptions: GlobalOptions;
|
package/lib/v2/options.js
CHANGED
|
@@ -21,78 +21,25 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.__getSpec = exports.optionsToEndpoint = exports.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions =
|
|
24
|
+
exports.__getSpec = exports.optionsToEndpoint = exports.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Options to configure cloud functions.
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
*/
|
|
25
29
|
const encoding_1 = require("../common/encoding");
|
|
26
30
|
const logger = require("../logger");
|
|
27
31
|
const params_1 = require("./params");
|
|
28
|
-
/**
|
|
29
|
-
* List of all regions supported by Cloud Functions v2
|
|
30
|
-
*/
|
|
31
|
-
exports.SUPPORTED_REGIONS = [
|
|
32
|
-
'asia-northeast1',
|
|
33
|
-
'europe-north1',
|
|
34
|
-
'europe-west1',
|
|
35
|
-
'europe-west4',
|
|
36
|
-
'us-central1',
|
|
37
|
-
'us-east1',
|
|
38
|
-
'us-west1',
|
|
39
|
-
];
|
|
40
|
-
/**
|
|
41
|
-
* Cloud Functions v2 min timeout value.
|
|
42
|
-
*/
|
|
43
|
-
exports.MIN_TIMEOUT_SECONDS = 1;
|
|
44
|
-
/**
|
|
45
|
-
* Cloud Functions v2 max timeout value for event handlers.
|
|
46
|
-
*/
|
|
47
|
-
exports.MAX_EVENT_TIMEOUT_SECONDS = 540;
|
|
48
|
-
/**
|
|
49
|
-
* Cloud Functions v2 max timeout for HTTPS functions.
|
|
50
|
-
*/
|
|
51
|
-
exports.MAX_HTTPS_TIMEOUT_SECONDS = 36000;
|
|
52
|
-
/**
|
|
53
|
-
* Maximum number of requests to serve on a single instance.
|
|
54
|
-
*/
|
|
55
|
-
exports.MAX_CONCURRENCY = 1000;
|
|
56
|
-
/**
|
|
57
|
-
* List of available memory options supported by Cloud Functions.
|
|
58
|
-
*/
|
|
59
|
-
exports.SUPPORTED_MEMORY_OPTIONS = [
|
|
60
|
-
'128MB',
|
|
61
|
-
'256MB',
|
|
62
|
-
'512MB',
|
|
63
|
-
'1GB',
|
|
64
|
-
'2GB',
|
|
65
|
-
'4GB',
|
|
66
|
-
'8GB',
|
|
67
|
-
'16GB',
|
|
68
|
-
'32GB',
|
|
69
|
-
];
|
|
70
32
|
const MemoryOptionToMB = {
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
33
|
+
'128MiB': 128,
|
|
34
|
+
'256MiB': 256,
|
|
35
|
+
'512MiB': 512,
|
|
36
|
+
'1GiB': 1024,
|
|
37
|
+
'2GiB': 2048,
|
|
38
|
+
'4GiB': 4096,
|
|
39
|
+
'8GiB': 8192,
|
|
40
|
+
'16GiB': 16384,
|
|
41
|
+
'32GiB': 32768,
|
|
80
42
|
};
|
|
81
|
-
/**
|
|
82
|
-
* List of available options for VpcConnectorEgressSettings.
|
|
83
|
-
*/
|
|
84
|
-
exports.SUPPORTED_VPC_EGRESS_SETTINGS = [
|
|
85
|
-
'PRIVATE_RANGES_ONLY',
|
|
86
|
-
'ALL_TRAFFIC',
|
|
87
|
-
];
|
|
88
|
-
/**
|
|
89
|
-
* List of available options for IngressSettings.
|
|
90
|
-
*/
|
|
91
|
-
exports.SUPPORTED_INGRESS_SETTINGS = [
|
|
92
|
-
'ALLOW_ALL',
|
|
93
|
-
'ALLOW_INTERNAL_ONLY',
|
|
94
|
-
'ALLOW_INTERNAL_AND_GCLB',
|
|
95
|
-
];
|
|
96
43
|
let globalOptions;
|
|
97
44
|
/**
|
|
98
45
|
* Sets default options for all functions written using the v2 SDK.
|
|
@@ -120,19 +67,19 @@ exports.getGlobalOptions = getGlobalOptions;
|
|
|
120
67
|
*/
|
|
121
68
|
function optionsToTriggerAnnotations(opts) {
|
|
122
69
|
const annotation = {};
|
|
123
|
-
encoding_1.copyIfPresent(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
|
|
124
|
-
encoding_1.convertIfPresent(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
70
|
+
(0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings', 'secrets');
|
|
71
|
+
(0, encoding_1.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
125
72
|
return MemoryOptionToMB[mem];
|
|
126
73
|
});
|
|
127
|
-
encoding_1.convertIfPresent(annotation, opts, 'regions', 'region', (region) => {
|
|
74
|
+
(0, encoding_1.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
|
|
128
75
|
if (typeof region === 'string') {
|
|
129
76
|
return [region];
|
|
130
77
|
}
|
|
131
78
|
return region;
|
|
132
79
|
});
|
|
133
|
-
encoding_1.convertIfPresent(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
|
|
134
|
-
encoding_1.convertIfPresent(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
|
|
135
|
-
encoding_1.convertIfPresent(annotation, opts, 'failurePolicy', 'retry', (retry) => {
|
|
80
|
+
(0, encoding_1.convertIfPresent)(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
|
|
81
|
+
(0, encoding_1.convertIfPresent)(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
|
|
82
|
+
(0, encoding_1.convertIfPresent)(annotation, opts, 'failurePolicy', 'retry', (retry) => {
|
|
136
83
|
return retry ? { retry: true } : null;
|
|
137
84
|
});
|
|
138
85
|
return annotation;
|
|
@@ -144,36 +91,29 @@ exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
|
|
|
144
91
|
*/
|
|
145
92
|
function optionsToEndpoint(opts) {
|
|
146
93
|
const endpoint = {};
|
|
147
|
-
encoding_1.copyIfPresent(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds');
|
|
148
|
-
encoding_1.convertIfPresent(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
|
|
94
|
+
(0, encoding_1.copyIfPresent)(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds', 'cpu');
|
|
95
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
|
|
149
96
|
if (opts.vpcConnector) {
|
|
150
97
|
const vpc = { connector: opts.vpcConnector };
|
|
151
|
-
encoding_1.convertIfPresent(vpc, opts, 'egressSettings', 'vpcConnectorEgressSettings');
|
|
98
|
+
(0, encoding_1.convertIfPresent)(vpc, opts, 'egressSettings', 'vpcConnectorEgressSettings');
|
|
152
99
|
endpoint.vpc = vpc;
|
|
153
100
|
}
|
|
154
|
-
encoding_1.convertIfPresent(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
155
|
-
|
|
156
|
-
'128MB': 128,
|
|
157
|
-
'256MB': 256,
|
|
158
|
-
'512MB': 512,
|
|
159
|
-
'1GB': 1024,
|
|
160
|
-
'2GB': 2048,
|
|
161
|
-
'4GB': 4096,
|
|
162
|
-
'8GB': 8192,
|
|
163
|
-
};
|
|
164
|
-
return memoryLookup[mem];
|
|
101
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
102
|
+
return MemoryOptionToMB[mem];
|
|
165
103
|
});
|
|
166
|
-
encoding_1.convertIfPresent(endpoint, opts, 'region', 'region', (region) => {
|
|
104
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, 'region', 'region', (region) => {
|
|
167
105
|
if (typeof region === 'string') {
|
|
168
106
|
return [region];
|
|
169
107
|
}
|
|
170
108
|
return region;
|
|
171
109
|
});
|
|
110
|
+
(0, encoding_1.convertIfPresent)(endpoint, opts, 'secretEnvironmentVariables', 'secrets', (secrets) => secrets.map((secret) => ({ key: secret })));
|
|
172
111
|
return endpoint;
|
|
173
112
|
}
|
|
174
113
|
exports.optionsToEndpoint = optionsToEndpoint;
|
|
175
114
|
/**
|
|
176
115
|
* @hidden
|
|
116
|
+
* @alpha
|
|
177
117
|
*/
|
|
178
118
|
function __getSpec() {
|
|
179
119
|
return {
|
package/lib/v2/params/index.d.ts
CHANGED
package/lib/v2/params/index.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2021 Firebase
|
|
5
|
+
//
|
|
6
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
// in the Software without restriction, including without limitation the rights
|
|
9
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
// furnished to do so, subject to the following conditions:
|
|
12
|
+
//
|
|
13
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
// copies or substantial portions of the Software.
|
|
15
|
+
//
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
// SOFTWARE.
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
24
|
exports.defineJSON = exports.defineList = exports.defineFloat = exports.defineInt = exports.defineBoolean = exports.defineString = exports.declaredParams = void 0;
|
|
4
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
* @alpha
|
|
28
|
+
*/
|
|
5
29
|
const types_1 = require("./types");
|
|
6
30
|
exports.declaredParams = [];
|
|
7
31
|
/**
|
package/lib/v2/params/types.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2021 Firebase
|
|
5
|
+
//
|
|
6
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
// in the Software without restriction, including without limitation the rights
|
|
9
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
// furnished to do so, subject to the following conditions:
|
|
12
|
+
//
|
|
13
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
// copies or substantial portions of the Software.
|
|
15
|
+
//
|
|
16
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
// SOFTWARE.
|
|
2
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
24
|
exports.JSONParam = exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.StringParam = exports.Param = void 0;
|
|
4
25
|
class Param {
|