firebase-functions 3.18.1 → 3.20.1
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 +1 -1
- package/lib/cloud-functions.js +12 -12
- package/lib/common/providers/https.d.ts +20 -49
- package/lib/common/providers/https.js +10 -50
- package/lib/common/providers/identity.d.ts +187 -4
- package/lib/common/providers/identity.js +553 -27
- package/lib/common/providers/tasks.d.ts +58 -0
- package/lib/common/providers/tasks.js +77 -0
- package/lib/function-builder.d.ts +4 -1
- package/lib/function-builder.js +6 -1
- package/lib/handler-builder.d.ts +13 -2
- package/lib/handler-builder.js +18 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -2
- package/lib/logger/compat.js +1 -1
- package/lib/providers/analytics.js +1 -1
- package/lib/providers/auth.js +2 -2
- package/lib/providers/database.js +12 -12
- package/lib/providers/firestore.js +7 -7
- package/lib/providers/https.d.ts +2 -44
- package/lib/providers/https.js +8 -56
- package/lib/providers/pubsub.js +2 -2
- package/lib/providers/remoteConfig.js +1 -1
- package/lib/providers/storage.js +2 -2
- package/lib/providers/tasks.d.ts +46 -0
- package/lib/providers/tasks.js +75 -0
- package/lib/providers/testLab.js +1 -1
- package/lib/runtime/manifest.d.ts +5 -3
- package/lib/runtime/manifest.js +21 -0
- package/lib/setup.js +3 -3
- package/lib/v2/index.d.ts +3 -1
- package/lib/v2/index.js +5 -1
- package/lib/v2/options.d.ts +2 -2
- package/lib/v2/options.js +23 -14
- package/lib/v2/providers/alerts/alerts.js +2 -2
- package/lib/v2/providers/alerts/appDistribution.js +1 -1
- package/lib/v2/providers/alerts/billing.d.ts +2 -2
- package/lib/v2/providers/alerts/billing.js +6 -6
- package/lib/v2/providers/alerts/crashlytics.js +1 -1
- package/lib/v2/providers/eventarc.d.ts +32 -0
- package/lib/v2/providers/eventarc.js +65 -0
- package/lib/v2/providers/https.d.ts +2 -20
- package/lib/v2/providers/https.js +4 -43
- package/lib/v2/providers/pubsub.js +1 -1
- package/lib/v2/providers/storage.js +3 -5
- package/lib/v2/providers/tasks.d.ts +22 -0
- package/lib/v2/providers/tasks.js +89 -0
- package/package.json +29 -15
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as express from 'express';
|
|
2
|
+
import { Request } from '../common/providers/https';
|
|
3
|
+
import { ManifestEndpoint, ManifestRequiredAPI } from '../runtime/manifest';
|
|
4
|
+
import { TaskContext, RateLimits, RetryConfig } from '../common/providers/tasks';
|
|
5
|
+
export {
|
|
6
|
+
/** @hidden */
|
|
7
|
+
RetryConfig as RetryPolicy,
|
|
8
|
+
/** @hidden */
|
|
9
|
+
RateLimits,
|
|
10
|
+
/** @hidden */
|
|
11
|
+
TaskContext, };
|
|
12
|
+
/**
|
|
13
|
+
* Configurations for Task Queue Functions.
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
export interface TaskQueueOptions {
|
|
17
|
+
retryConfig?: RetryConfig;
|
|
18
|
+
rateLimits?: RateLimits;
|
|
19
|
+
/**
|
|
20
|
+
* Who can enqueue tasks for this function.
|
|
21
|
+
* If left unspecified, only service accounts which have
|
|
22
|
+
* roles/cloudtasks.enqueuer and roles/cloudfunctions.invoker
|
|
23
|
+
* will have permissions.
|
|
24
|
+
*/
|
|
25
|
+
invoker?: 'private' | string | string[];
|
|
26
|
+
}
|
|
27
|
+
/** @hidden */
|
|
28
|
+
export interface TaskQueueFunction {
|
|
29
|
+
(req: Request, res: express.Response): Promise<void>;
|
|
30
|
+
__trigger: unknown;
|
|
31
|
+
__endpoint: ManifestEndpoint;
|
|
32
|
+
__requiredAPIs?: ManifestRequiredAPI[];
|
|
33
|
+
run(data: any, context: TaskContext): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** @hidden */
|
|
36
|
+
export declare class TaskQueueBuilder {
|
|
37
|
+
private readonly tqOpts?;
|
|
38
|
+
private readonly depOpts?;
|
|
39
|
+
onDispatch(handler: (data: any, context: TaskContext) => void | Promise<void>): TaskQueueFunction;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
|
|
43
|
+
* @param options Configuration for the Task Queue that feeds into this function.
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
export declare function taskQueue(options?: TaskQueueOptions): TaskQueueBuilder;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2022 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.
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.taskQueue = exports.TaskQueueBuilder = void 0;
|
|
25
|
+
const cloud_functions_1 = require("../cloud-functions");
|
|
26
|
+
const encoding_1 = require("../common/encoding");
|
|
27
|
+
const tasks_1 = require("../common/providers/tasks");
|
|
28
|
+
/** @hidden */
|
|
29
|
+
class TaskQueueBuilder {
|
|
30
|
+
/** @internal */
|
|
31
|
+
constructor(tqOpts, depOpts) {
|
|
32
|
+
this.tqOpts = tqOpts;
|
|
33
|
+
this.depOpts = depOpts;
|
|
34
|
+
}
|
|
35
|
+
onDispatch(handler) {
|
|
36
|
+
// onEnqueueHandler sniffs the function length of the passed-in callback
|
|
37
|
+
// and the user could have only tried to listen to data. Wrap their handler
|
|
38
|
+
// in another handler to avoid accidentally triggering the v2 API
|
|
39
|
+
const fixedLen = (data, context) => handler(data, context);
|
|
40
|
+
const func = tasks_1.onDispatchHandler(fixedLen);
|
|
41
|
+
func.__trigger = {
|
|
42
|
+
...cloud_functions_1.optionsToTrigger(this.depOpts || {}),
|
|
43
|
+
taskQueueTrigger: {},
|
|
44
|
+
};
|
|
45
|
+
encoding_1.copyIfPresent(func.__trigger.taskQueueTrigger, this.tqOpts, 'retryConfig');
|
|
46
|
+
encoding_1.copyIfPresent(func.__trigger.taskQueueTrigger, this.tqOpts, 'rateLimits');
|
|
47
|
+
encoding_1.convertIfPresent(func.__trigger.taskQueueTrigger, this.tqOpts, 'invoker', 'invoker', encoding_1.convertInvoker);
|
|
48
|
+
func.__endpoint = {
|
|
49
|
+
platform: 'gcfv1',
|
|
50
|
+
...cloud_functions_1.optionsToEndpoint(this.depOpts),
|
|
51
|
+
taskQueueTrigger: {},
|
|
52
|
+
};
|
|
53
|
+
encoding_1.copyIfPresent(func.__endpoint.taskQueueTrigger, this.tqOpts, 'retryConfig');
|
|
54
|
+
encoding_1.copyIfPresent(func.__endpoint.taskQueueTrigger, this.tqOpts, 'rateLimits');
|
|
55
|
+
encoding_1.convertIfPresent(func.__endpoint.taskQueueTrigger, this.tqOpts, 'invoker', 'invoker', encoding_1.convertInvoker);
|
|
56
|
+
func.__requiredAPIs = [
|
|
57
|
+
{
|
|
58
|
+
api: 'cloudtasks.googleapis.com',
|
|
59
|
+
reason: 'Needed for task queue functions',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
func.run = handler;
|
|
63
|
+
return func;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.TaskQueueBuilder = TaskQueueBuilder;
|
|
67
|
+
/**
|
|
68
|
+
* Declares a function that can handle tasks enqueued using the Firebase Admin SDK.
|
|
69
|
+
* @param options Configuration for the Task Queue that feeds into this function.
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
function taskQueue(options) {
|
|
73
|
+
return new TaskQueueBuilder(options);
|
|
74
|
+
}
|
|
75
|
+
exports.taskQueue = taskQueue;
|
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
|
|
60
|
+
return cloud_functions_1.makeCloudFunction({
|
|
61
61
|
provider: exports.PROVIDER,
|
|
62
62
|
eventType: exports.TEST_MATRIX_COMPLETE_EVENT_TYPE,
|
|
63
63
|
triggerResource: this.triggerResource,
|
|
@@ -18,16 +18,18 @@ export interface ManifestEndpoint {
|
|
|
18
18
|
labels?: Record<string, string>;
|
|
19
19
|
ingressSettings?: string;
|
|
20
20
|
environmentVariables?: Record<string, string>;
|
|
21
|
-
secretEnvironmentVariables?: {
|
|
21
|
+
secretEnvironmentVariables?: Array<{
|
|
22
22
|
key: string;
|
|
23
23
|
secret?: string;
|
|
24
|
-
}
|
|
24
|
+
}>;
|
|
25
25
|
httpsTrigger?: {
|
|
26
26
|
invoker?: string[];
|
|
27
27
|
};
|
|
28
28
|
callableTrigger?: {};
|
|
29
29
|
eventTrigger?: {
|
|
30
30
|
eventFilters: Record<string, string>;
|
|
31
|
+
eventFilterPathPatterns?: Record<string, string>;
|
|
32
|
+
channel?: string;
|
|
31
33
|
eventType: string;
|
|
32
34
|
retry: boolean;
|
|
33
35
|
region?: string;
|
|
@@ -51,7 +53,7 @@ export interface ManifestRequiredAPI {
|
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* An definition of a function deployment as appears in the Manifest.
|
|
54
|
-
|
|
56
|
+
*/
|
|
55
57
|
export interface ManifestStack {
|
|
56
58
|
specVersion: 'v1alpha1';
|
|
57
59
|
requiredAPIs: ManifestRequiredAPI[];
|
package/lib/runtime/manifest.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
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
|
|
14
|
+
// all 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 });
|
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 =
|
|
34
|
+
const cfg = 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
|
-
|
|
46
|
+
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
|
-
|
|
56
|
+
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/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import * as alerts from './providers/alerts';
|
|
|
4
4
|
import * as https from './providers/https';
|
|
5
5
|
import * as pubsub from './providers/pubsub';
|
|
6
6
|
import * as storage from './providers/storage';
|
|
7
|
-
|
|
7
|
+
import * as tasks from './providers/tasks';
|
|
8
|
+
import * as eventarc from './providers/eventarc';
|
|
9
|
+
export { alerts, https, pubsub, storage, logger, params, tasks, eventarc };
|
|
8
10
|
export { setGlobalOptions, GlobalOptions } from './options';
|
|
9
11
|
export { CloudFunction, CloudEvent } from './core';
|
package/lib/v2/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
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.
|
|
24
|
+
exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.params = exports.logger = exports.storage = exports.pubsub = exports.https = exports.alerts = void 0;
|
|
25
25
|
const logger = require("../logger");
|
|
26
26
|
exports.logger = logger;
|
|
27
27
|
const params = require("./params");
|
|
@@ -34,5 +34,9 @@ const pubsub = require("./providers/pubsub");
|
|
|
34
34
|
exports.pubsub = pubsub;
|
|
35
35
|
const storage = require("./providers/storage");
|
|
36
36
|
exports.storage = storage;
|
|
37
|
+
const tasks = require("./providers/tasks");
|
|
38
|
+
exports.tasks = tasks;
|
|
39
|
+
const eventarc = require("./providers/eventarc");
|
|
40
|
+
exports.eventarc = eventarc;
|
|
37
41
|
var options_1 = require("./options");
|
|
38
42
|
Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } });
|
package/lib/v2/options.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ParamSpec } from './params/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* List of all regions supported by Cloud Functions v2
|
|
4
4
|
*/
|
|
5
|
-
export declare const SUPPORTED_REGIONS: readonly ["
|
|
5
|
+
export declare const SUPPORTED_REGIONS: readonly ["asia-northeast1", "europe-north1", "europe-west1", "europe-west4", "us-central1", "us-east1", "us-west1"];
|
|
6
6
|
/**
|
|
7
7
|
* A region known to be supported by CloudFunctions v2
|
|
8
8
|
*/
|
|
@@ -26,7 +26,7 @@ export declare const MAX_CONCURRENCY = 1000;
|
|
|
26
26
|
/**
|
|
27
27
|
* List of available memory options supported by Cloud Functions.
|
|
28
28
|
*/
|
|
29
|
-
export declare const SUPPORTED_MEMORY_OPTIONS: readonly ["256MB", "512MB", "1GB", "2GB", "4GB", "8GB"];
|
|
29
|
+
export declare const SUPPORTED_MEMORY_OPTIONS: readonly ["128MB", "256MB", "512MB", "1GB", "2GB", "4GB", "8GB", "16GB", "32GB"];
|
|
30
30
|
/**
|
|
31
31
|
* A supported memory option.
|
|
32
32
|
*/
|
package/lib/v2/options.js
CHANGED
|
@@ -29,10 +29,13 @@ const params_1 = require("./params");
|
|
|
29
29
|
* List of all regions supported by Cloud Functions v2
|
|
30
30
|
*/
|
|
31
31
|
exports.SUPPORTED_REGIONS = [
|
|
32
|
-
'us-west1',
|
|
33
|
-
'us-central1',
|
|
34
|
-
'europe-west4',
|
|
35
32
|
'asia-northeast1',
|
|
33
|
+
'europe-north1',
|
|
34
|
+
'europe-west1',
|
|
35
|
+
'europe-west4',
|
|
36
|
+
'us-central1',
|
|
37
|
+
'us-east1',
|
|
38
|
+
'us-west1',
|
|
36
39
|
];
|
|
37
40
|
/**
|
|
38
41
|
* Cloud Functions v2 min timeout value.
|
|
@@ -54,20 +57,26 @@ exports.MAX_CONCURRENCY = 1000;
|
|
|
54
57
|
* List of available memory options supported by Cloud Functions.
|
|
55
58
|
*/
|
|
56
59
|
exports.SUPPORTED_MEMORY_OPTIONS = [
|
|
60
|
+
'128MB',
|
|
57
61
|
'256MB',
|
|
58
62
|
'512MB',
|
|
59
63
|
'1GB',
|
|
60
64
|
'2GB',
|
|
61
65
|
'4GB',
|
|
62
66
|
'8GB',
|
|
67
|
+
'16GB',
|
|
68
|
+
'32GB',
|
|
63
69
|
];
|
|
64
70
|
const MemoryOptionToMB = {
|
|
71
|
+
'128MB': 128,
|
|
65
72
|
'256MB': 256,
|
|
66
73
|
'512MB': 512,
|
|
67
74
|
'1GB': 1024,
|
|
68
75
|
'2GB': 2048,
|
|
69
76
|
'4GB': 4096,
|
|
70
77
|
'8GB': 8192,
|
|
78
|
+
'16GB': 16384,
|
|
79
|
+
'32GB': 32768,
|
|
71
80
|
};
|
|
72
81
|
/**
|
|
73
82
|
* List of available options for VpcConnectorEgressSettings.
|
|
@@ -111,19 +120,19 @@ exports.getGlobalOptions = getGlobalOptions;
|
|
|
111
120
|
*/
|
|
112
121
|
function optionsToTriggerAnnotations(opts) {
|
|
113
122
|
const annotation = {};
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
encoding_1.copyIfPresent(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
|
|
124
|
+
encoding_1.convertIfPresent(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
116
125
|
return MemoryOptionToMB[mem];
|
|
117
126
|
});
|
|
118
|
-
|
|
127
|
+
encoding_1.convertIfPresent(annotation, opts, 'regions', 'region', (region) => {
|
|
119
128
|
if (typeof region === 'string') {
|
|
120
129
|
return [region];
|
|
121
130
|
}
|
|
122
131
|
return region;
|
|
123
132
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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) => {
|
|
127
136
|
return retry ? { retry: true } : null;
|
|
128
137
|
});
|
|
129
138
|
return annotation;
|
|
@@ -135,14 +144,14 @@ exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
|
|
|
135
144
|
*/
|
|
136
145
|
function optionsToEndpoint(opts) {
|
|
137
146
|
const endpoint = {};
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
encoding_1.copyIfPresent(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds');
|
|
148
|
+
encoding_1.convertIfPresent(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
|
|
140
149
|
if (opts.vpcConnector) {
|
|
141
150
|
const vpc = { connector: opts.vpcConnector };
|
|
142
|
-
|
|
151
|
+
encoding_1.convertIfPresent(vpc, opts, 'egressSettings', 'vpcConnectorEgressSettings');
|
|
143
152
|
endpoint.vpc = vpc;
|
|
144
153
|
}
|
|
145
|
-
|
|
154
|
+
encoding_1.convertIfPresent(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
|
|
146
155
|
const memoryLookup = {
|
|
147
156
|
'128MB': 128,
|
|
148
157
|
'256MB': 256,
|
|
@@ -154,7 +163,7 @@ function optionsToEndpoint(opts) {
|
|
|
154
163
|
};
|
|
155
164
|
return memoryLookup[mem];
|
|
156
165
|
});
|
|
157
|
-
|
|
166
|
+
encoding_1.convertIfPresent(endpoint, opts, 'region', 'region', (region) => {
|
|
158
167
|
if (typeof region === 'string') {
|
|
159
168
|
return [region];
|
|
160
169
|
}
|
|
@@ -37,13 +37,13 @@ function getEndpointAnnotation(opts, alertType, appId) {
|
|
|
37
37
|
eventTrigger: {
|
|
38
38
|
eventType: exports.eventType,
|
|
39
39
|
eventFilters: {
|
|
40
|
-
alertType,
|
|
40
|
+
alerttype: alertType,
|
|
41
41
|
},
|
|
42
42
|
retry: !!opts.retry,
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
if (appId) {
|
|
46
|
-
endpoint.eventTrigger.eventFilters.
|
|
46
|
+
endpoint.eventTrigger.eventFilters.appid = appId;
|
|
47
47
|
}
|
|
48
48
|
return endpoint;
|
|
49
49
|
}
|
|
@@ -14,7 +14,7 @@ function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
|
|
|
14
14
|
return handler(raw);
|
|
15
15
|
};
|
|
16
16
|
func.run = handler;
|
|
17
|
-
func.__endpoint =
|
|
17
|
+
func.__endpoint = alerts_1.getEndpointAnnotation(opts, exports.newTesterIosDeviceAlert, appId);
|
|
18
18
|
return func;
|
|
19
19
|
}
|
|
20
20
|
exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
|
|
@@ -33,6 +33,6 @@ export declare function onPlanUpdatePublished(opts: options.EventHandlerOptions,
|
|
|
33
33
|
/**
|
|
34
34
|
* Declares a function that can handle an automated billing plan update event.
|
|
35
35
|
*/
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
36
|
+
export declare function onPlanAutomatedUpdatePublished(handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<PlanAutomatedUpdatePayload>>;
|
|
37
|
+
export declare function onPlanAutomatedUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<PlanAutomatedUpdatePayload>>;
|
|
38
38
|
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onOperation = exports.
|
|
3
|
+
exports.onOperation = exports.onPlanAutomatedUpdatePublished = exports.onPlanUpdatePublished = exports.planAutomatedUpdateAlert = exports.planUpdateAlert = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
/** @internal */
|
|
6
6
|
exports.planUpdateAlert = 'billing.planUpdate';
|
|
7
7
|
/** @internal */
|
|
8
|
-
exports.
|
|
8
|
+
exports.planAutomatedUpdateAlert = 'billing.planAutomatedUpdate';
|
|
9
9
|
function onPlanUpdatePublished(optsOrHandler, handler) {
|
|
10
10
|
return onOperation(exports.planUpdateAlert, optsOrHandler, handler);
|
|
11
11
|
}
|
|
12
12
|
exports.onPlanUpdatePublished = onPlanUpdatePublished;
|
|
13
|
-
function
|
|
14
|
-
return onOperation(exports.
|
|
13
|
+
function onPlanAutomatedUpdatePublished(optsOrHandler, handler) {
|
|
14
|
+
return onOperation(exports.planAutomatedUpdateAlert, optsOrHandler, handler);
|
|
15
15
|
}
|
|
16
|
-
exports.
|
|
16
|
+
exports.onPlanAutomatedUpdatePublished = onPlanAutomatedUpdatePublished;
|
|
17
17
|
/** @internal */
|
|
18
18
|
function onOperation(alertType, optsOrHandler, handler) {
|
|
19
19
|
if (typeof optsOrHandler === 'function') {
|
|
@@ -24,7 +24,7 @@ function onOperation(alertType, optsOrHandler, handler) {
|
|
|
24
24
|
return handler(raw);
|
|
25
25
|
};
|
|
26
26
|
func.run = handler;
|
|
27
|
-
func.__endpoint =
|
|
27
|
+
func.__endpoint = _1.getEndpointAnnotation(optsOrHandler, alertType);
|
|
28
28
|
return func;
|
|
29
29
|
}
|
|
30
30
|
exports.onOperation = onOperation;
|
|
@@ -49,7 +49,7 @@ function onOperation(alertType, appIdOrOptsOrHandler, handler) {
|
|
|
49
49
|
return handler(raw);
|
|
50
50
|
};
|
|
51
51
|
func.run = handler;
|
|
52
|
-
func.__endpoint =
|
|
52
|
+
func.__endpoint = _1.getEndpointAnnotation(opts, alertType, appId);
|
|
53
53
|
return func;
|
|
54
54
|
}
|
|
55
55
|
exports.onOperation = onOperation;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as options from '../options';
|
|
2
|
+
import { CloudEvent, CloudFunction } from '../core';
|
|
3
|
+
/** Options that can be set on an Eventarc trigger. */
|
|
4
|
+
export interface EventarcTriggerOptions extends options.EventHandlerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Type of the event.
|
|
7
|
+
*/
|
|
8
|
+
eventType: string;
|
|
9
|
+
/**
|
|
10
|
+
* ID of the channel. Can be either:
|
|
11
|
+
* * fully qualified channel resource name:
|
|
12
|
+
* `projects/{project}/locations/{location}/channels/{channel-id}`
|
|
13
|
+
* * partial resource name with location and channel ID, in which case
|
|
14
|
+
* the runtime project ID of the function will be used:
|
|
15
|
+
* `locations/{location}/channels/{channel-id}`
|
|
16
|
+
* * partial channel ID, in which case the runtime project ID of the
|
|
17
|
+
* function and `us-central1` as location will be used:
|
|
18
|
+
* `{channel-id}`
|
|
19
|
+
*
|
|
20
|
+
* If not specified, the default Firebase channel will be used:
|
|
21
|
+
* `projects/{project}/locations/us-central1/channels/firebase`
|
|
22
|
+
*/
|
|
23
|
+
channel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Eventarc event exact match filter.
|
|
26
|
+
*/
|
|
27
|
+
filters?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
export declare type CloudEventHandler = (event: CloudEvent<any>) => any | Promise<any>;
|
|
30
|
+
/** Handle an Eventarc event published on the default channel. */
|
|
31
|
+
export declare function onCustomEventPublished<T = any>(eventType: string, handler: CloudEventHandler): CloudFunction<CloudEvent<T>>;
|
|
32
|
+
export declare function onCustomEventPublished<T = any>(opts: EventarcTriggerOptions, handler: CloudEventHandler): CloudFunction<CloudEvent<T>>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2022 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.
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.onCustomEventPublished = void 0;
|
|
25
|
+
const options = require("../options");
|
|
26
|
+
const encoding_1 = require("../../common/encoding");
|
|
27
|
+
function onCustomEventPublished(eventTypeOrOpts, handler) {
|
|
28
|
+
var _a;
|
|
29
|
+
let opts;
|
|
30
|
+
if (typeof eventTypeOrOpts === 'string') {
|
|
31
|
+
opts = {
|
|
32
|
+
eventType: eventTypeOrOpts,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (typeof eventTypeOrOpts === 'object') {
|
|
36
|
+
opts = eventTypeOrOpts;
|
|
37
|
+
}
|
|
38
|
+
const func = (raw) => {
|
|
39
|
+
return handler(raw);
|
|
40
|
+
};
|
|
41
|
+
func.run = handler;
|
|
42
|
+
const channel = (_a = opts.channel) !== null && _a !== void 0 ? _a : 'locations/us-central1/channels/firebase';
|
|
43
|
+
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
|
44
|
+
const specificOpts = options.optionsToEndpoint(opts);
|
|
45
|
+
const endpoint = {
|
|
46
|
+
platform: 'gcfv2',
|
|
47
|
+
...baseOpts,
|
|
48
|
+
...specificOpts,
|
|
49
|
+
labels: {
|
|
50
|
+
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
|
51
|
+
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
|
52
|
+
},
|
|
53
|
+
eventTrigger: {
|
|
54
|
+
eventType: opts.eventType,
|
|
55
|
+
eventFilters: {},
|
|
56
|
+
retry: false,
|
|
57
|
+
channel,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
encoding_1.convertIfPresent(endpoint.eventTrigger, opts, 'eventFilters', 'filters');
|
|
61
|
+
encoding_1.copyIfPresent(endpoint.eventTrigger, opts, 'retry');
|
|
62
|
+
func.__endpoint = endpoint;
|
|
63
|
+
return func;
|
|
64
|
+
}
|
|
65
|
+
exports.onCustomEventPublished = onCustomEventPublished;
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import * as options from '../options';
|
|
3
|
-
import { CallableRequest, FunctionsErrorCode, HttpsError, Request
|
|
3
|
+
import { CallableRequest, FunctionsErrorCode, HttpsError, Request } from '../../common/providers/https';
|
|
4
4
|
import { ManifestEndpoint } from '../../runtime/manifest';
|
|
5
|
-
export { Request, CallableRequest, FunctionsErrorCode, HttpsError
|
|
5
|
+
export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
|
|
6
6
|
export interface HttpsOptions extends Omit<options.GlobalOptions, 'region'> {
|
|
7
7
|
region?: options.SupportedRegion | string | Array<options.SupportedRegion | string>;
|
|
8
8
|
cors?: string | boolean | RegExp | Array<string | RegExp>;
|
|
9
9
|
}
|
|
10
|
-
export interface TaskQueueOptions extends options.GlobalOptions {
|
|
11
|
-
retryConfig?: TaskRetryConfig;
|
|
12
|
-
rateLimits?: TaskRateLimits;
|
|
13
|
-
/**
|
|
14
|
-
* Who can enqueue tasks for this function.
|
|
15
|
-
* If left unspecified, only service accounts which have
|
|
16
|
-
* roles/cloudtasks.enqueuer and roles/cloudfunctions.invoker
|
|
17
|
-
* will have permissions.
|
|
18
|
-
*/
|
|
19
|
-
invoker?: 'private' | string | string[];
|
|
20
|
-
}
|
|
21
10
|
export declare type HttpsFunction = ((req: Request, res: express.Response) => void | Promise<void>) & {
|
|
22
11
|
__trigger?: unknown;
|
|
23
12
|
__endpoint: ManifestEndpoint;
|
|
@@ -25,14 +14,7 @@ export declare type HttpsFunction = ((req: Request, res: express.Response) => vo
|
|
|
25
14
|
export interface CallableFunction<T, Return> extends HttpsFunction {
|
|
26
15
|
run(data: CallableRequest<T>): Return;
|
|
27
16
|
}
|
|
28
|
-
export interface TaskQueueFunction<T = any> extends HttpsFunction {
|
|
29
|
-
run(data: TaskRequest<T>): void | Promise<void>;
|
|
30
|
-
}
|
|
31
17
|
export declare function onRequest(opts: HttpsOptions, handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
|
|
32
18
|
export declare function onRequest(handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
|
|
33
19
|
export declare function onCall<T = any, Return = any | Promise<any>>(opts: HttpsOptions, handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return>;
|
|
34
20
|
export declare function onCall<T = any, Return = any | Promise<any>>(handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return>;
|
|
35
|
-
/** Handle a request sent to a Cloud Tasks queue. */
|
|
36
|
-
export declare function onTaskDispatched<Args = any>(handler: (request: TaskRequest<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
|
|
37
|
-
/** Handle a request sent to a Cloud Tasks queue. */
|
|
38
|
-
export declare function onTaskDispatched<Args = any>(options: TaskQueueOptions, handler: (request: TaskRequest<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
|