firebase-functions 3.19.0 → 3.21.0

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.
Files changed (46) hide show
  1. package/lib/cloud-functions.d.ts +8 -0
  2. package/lib/cloud-functions.js +4 -7
  3. package/lib/common/providers/https.d.ts +20 -49
  4. package/lib/common/providers/https.js +7 -45
  5. package/lib/common/providers/identity.d.ts +193 -4
  6. package/lib/common/providers/identity.js +402 -28
  7. package/lib/common/providers/tasks.d.ts +58 -0
  8. package/lib/common/providers/tasks.js +77 -0
  9. package/lib/function-builder.d.ts +5 -2
  10. package/lib/function-builder.js +7 -2
  11. package/lib/handler-builder.d.ts +13 -2
  12. package/lib/handler-builder.js +17 -4
  13. package/lib/index.d.ts +2 -1
  14. package/lib/index.js +3 -1
  15. package/lib/providers/auth.d.ts +19 -6
  16. package/lib/providers/auth.js +60 -8
  17. package/lib/providers/https.d.ts +2 -44
  18. package/lib/providers/https.js +1 -49
  19. package/lib/providers/tasks.d.ts +46 -0
  20. package/lib/providers/tasks.js +75 -0
  21. package/lib/runtime/loader.js +9 -7
  22. package/lib/runtime/manifest.d.ts +8 -10
  23. package/lib/runtime/manifest.js +21 -0
  24. package/lib/v2/core.d.ts +3 -21
  25. package/lib/v2/index.d.ts +4 -1
  26. package/lib/v2/index.js +7 -1
  27. package/lib/v2/options.d.ts +13 -2
  28. package/lib/v2/options.js +22 -30
  29. package/lib/v2/providers/alerts/alerts.d.ts +15 -7
  30. package/lib/v2/providers/alerts/alerts.js +4 -10
  31. package/lib/v2/providers/alerts/appDistribution.d.ts +11 -11
  32. package/lib/v2/providers/alerts/billing.d.ts +17 -11
  33. package/lib/v2/providers/alerts/crashlytics.d.ts +62 -29
  34. package/lib/v2/providers/eventarc.d.ts +32 -0
  35. package/lib/v2/providers/eventarc.js +65 -0
  36. package/lib/v2/providers/https.d.ts +8 -23
  37. package/lib/v2/providers/https.js +3 -48
  38. package/lib/v2/providers/identity.d.ts +22 -0
  39. package/lib/v2/providers/identity.js +73 -0
  40. package/lib/v2/providers/pubsub.d.ts +3 -3
  41. package/lib/v2/providers/pubsub.js +2 -5
  42. package/lib/v2/providers/storage.d.ts +17 -13
  43. package/lib/v2/providers/storage.js +5 -4
  44. package/lib/v2/providers/tasks.d.ts +22 -0
  45. package/lib/v2/providers/tasks.js +88 -0
  46. package/package.json +42 -15
package/lib/v2/index.js CHANGED
@@ -21,18 +21,24 @@
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.alerts = exports.params = exports.logger = exports.storage = exports.pubsub = exports.https = void 0;
24
+ exports.setGlobalOptions = exports.eventarc = exports.tasks = exports.params = exports.logger = exports.storage = exports.pubsub = exports.identity = exports.https = exports.alerts = void 0;
25
25
  const logger = require("../logger");
26
26
  exports.logger = logger;
27
27
  const params = require("./params");
28
28
  exports.params = params;
29
29
  const alerts = require("./providers/alerts");
30
30
  exports.alerts = alerts;
31
+ const eventarc = require("./providers/eventarc");
32
+ exports.eventarc = eventarc;
31
33
  const https = require("./providers/https");
32
34
  exports.https = https;
35
+ const identity = require("./providers/identity");
36
+ exports.identity = identity;
33
37
  const pubsub = require("./providers/pubsub");
34
38
  exports.pubsub = pubsub;
35
39
  const storage = require("./providers/storage");
36
40
  exports.storage = storage;
41
+ const tasks = require("./providers/tasks");
42
+ exports.tasks = tasks;
37
43
  var options_1 = require("./options");
38
44
  Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } });
@@ -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 ["128MB", "256MB", "512MB", "1GB", "2GB", "4GB", "8GB", "16GB", "32GB"];
29
+ export declare const SUPPORTED_MEMORY_OPTIONS: readonly ["128MiB", "256MiB", "512MiB", "1GiB", "2GiB", "4GiB", "8GiB", "16GiB", "32GiB"];
30
30
  /**
31
31
  * A supported memory option.
32
32
  */
@@ -80,9 +80,19 @@ export interface GlobalOptions {
80
80
  /**
81
81
  * Number of requests a function can serve at once.
82
82
  * Can only be applied to functions running on Cloud Functions v2.
83
- * A value of null restores the default concurrency.
83
+ * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
84
+ * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
84
85
  */
85
86
  concurrency?: number | null;
87
+ /**
88
+ * Fractional number of CPUs to allocate to a function.
89
+ * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
90
+ * This is different from the defaults when using the gcloud utility and is different from
91
+ * the fixed amount assigned in Google Cloud Functions generation 1.
92
+ * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
93
+ * to the value "gcf_gen1"
94
+ */
95
+ cpu?: number | 'gcf_gen1';
86
96
  /**
87
97
  * Connect cloud function to specified VPC connector.
88
98
  * A value of null removes the VPC connector
@@ -111,6 +121,7 @@ export interface GlobalOptions {
111
121
  * Invoker to set access control on https functions.
112
122
  */
113
123
  invoker?: 'public' | 'private' | string | string[];
124
+ secrets?: string[];
114
125
  }
115
126
  /**
116
127
  * Sets default options for all functions written using the v2 SDK.
package/lib/v2/options.js CHANGED
@@ -57,26 +57,26 @@ exports.MAX_CONCURRENCY = 1000;
57
57
  * List of available memory options supported by Cloud Functions.
58
58
  */
59
59
  exports.SUPPORTED_MEMORY_OPTIONS = [
60
- '128MB',
61
- '256MB',
62
- '512MB',
63
- '1GB',
64
- '2GB',
65
- '4GB',
66
- '8GB',
67
- '16GB',
68
- '32GB',
60
+ '128MiB',
61
+ '256MiB',
62
+ '512MiB',
63
+ '1GiB',
64
+ '2GiB',
65
+ '4GiB',
66
+ '8GiB',
67
+ '16GiB',
68
+ '32GiB',
69
69
  ];
70
70
  const MemoryOptionToMB = {
71
- '128MB': 128,
72
- '256MB': 256,
73
- '512MB': 512,
74
- '1GB': 1024,
75
- '2GB': 2048,
76
- '4GB': 4096,
77
- '8GB': 8192,
78
- '16GB': 16384,
79
- '32GB': 32768,
71
+ '128MiB': 128,
72
+ '256MiB': 256,
73
+ '512MiB': 512,
74
+ '1GiB': 1024,
75
+ '2GiB': 2048,
76
+ '4GiB': 4096,
77
+ '8GiB': 8192,
78
+ '16GiB': 16384,
79
+ '32GiB': 32768,
80
80
  };
81
81
  /**
82
82
  * List of available options for VpcConnectorEgressSettings.
@@ -120,7 +120,7 @@ exports.getGlobalOptions = getGlobalOptions;
120
120
  */
121
121
  function optionsToTriggerAnnotations(opts) {
122
122
  const annotation = {};
123
- (0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
123
+ (0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings', 'secrets');
124
124
  (0, encoding_1.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
125
125
  return MemoryOptionToMB[mem];
126
126
  });
@@ -144,7 +144,7 @@ exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
144
144
  */
145
145
  function optionsToEndpoint(opts) {
146
146
  const endpoint = {};
147
- (0, encoding_1.copyIfPresent)(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds');
147
+ (0, encoding_1.copyIfPresent)(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds', 'cpu');
148
148
  (0, encoding_1.convertIfPresent)(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
149
149
  if (opts.vpcConnector) {
150
150
  const vpc = { connector: opts.vpcConnector };
@@ -152,16 +152,7 @@ function optionsToEndpoint(opts) {
152
152
  endpoint.vpc = vpc;
153
153
  }
154
154
  (0, encoding_1.convertIfPresent)(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
155
- const memoryLookup = {
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];
155
+ return MemoryOptionToMB[mem];
165
156
  });
166
157
  (0, encoding_1.convertIfPresent)(endpoint, opts, 'region', 'region', (region) => {
167
158
  if (typeof region === 'string') {
@@ -169,6 +160,7 @@ function optionsToEndpoint(opts) {
169
160
  }
170
161
  return region;
171
162
  });
163
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'secretEnvironmentVariables', 'secrets', (secrets) => secrets.map((secret) => ({ key: secret })));
172
164
  return endpoint;
173
165
  }
174
166
  exports.optionsToEndpoint = optionsToEndpoint;
@@ -4,18 +4,27 @@ import * as options from '../../options';
4
4
  * The CloudEvent data emitted by Firebase Alerts.
5
5
  */
6
6
  export interface FirebaseAlertData<T = any> {
7
+ /** Time that the event has created. */
7
8
  createTime: string;
9
+ /** Time that the event has ended. Optional, only present for ongoing alerts. */
8
10
  endTime: string;
11
+ /** Payload of the event, which includes the details of the specific alert. */
9
12
  payload: T;
10
13
  }
11
- interface WithAlertTypeAndApp {
12
- alertType: string;
13
- appId?: string;
14
- }
15
14
  /**
16
15
  * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
17
16
  */
18
- export declare type AlertEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertTypeAndApp>;
17
+ export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
18
+ /** The type of the alerts that got triggered. */
19
+ alertType: string;
20
+ /**
21
+ * The Firebase App ID that’s associated with the alert. This is optional,
22
+ * and only present when the alert is targeting at a specific Firebase App.
23
+ */
24
+ appId?: string;
25
+ /** Data for an AlertEvent is a FirebaseAlertData with a given payload. */
26
+ data: FirebaseAlertData<T>;
27
+ }
19
28
  /** The underlying alert type of the Firebase Alerts provider. */
20
29
  export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNonfatalIssue' | 'crashlytics.regression' | 'crashlytics.stabilityDigest' | 'crashlytics.velocity' | 'crashlytics.newAnrIssue' | 'billing.planUpdate' | 'billing.automatedPlanUpdate' | 'appDistribution.newTesterIosDevice' | string;
21
30
  /**
@@ -32,5 +41,4 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
32
41
  */
33
42
  export declare function onAlertPublished<T extends {
34
43
  ['@type']: string;
35
- } = any>(alertTypeOrOpts: AlertType | FirebaseAlertOptions, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<FirebaseAlertData<T>>;
36
- export {};
44
+ } = any>(alertTypeOrOpts: AlertType | FirebaseAlertOptions, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
@@ -36,20 +36,14 @@ function getEndpointAnnotation(opts, alertType, appId) {
36
36
  },
37
37
  eventTrigger: {
38
38
  eventType: exports.eventType,
39
- eventFilters: [
40
- {
41
- attribute: 'alerttype',
42
- value: alertType,
43
- },
44
- ],
39
+ eventFilters: {
40
+ alerttype: alertType,
41
+ },
45
42
  retry: !!opts.retry,
46
43
  },
47
44
  };
48
45
  if (appId) {
49
- endpoint.eventTrigger.eventFilters.push({
50
- attribute: 'appid',
51
- value: appId,
52
- });
46
+ endpoint.eventTrigger.eventFilters.appid = appId;
53
47
  }
54
48
  return endpoint;
55
49
  }
@@ -1,25 +1,26 @@
1
- import { FirebaseAlertData } from './alerts';
2
1
  import { CloudEvent, CloudFunction } from '../../core';
3
2
  import * as options from '../../options';
3
+ import { FirebaseAlertData } from './alerts';
4
4
  /**
5
5
  * The internal payload object for adding a new tester device to app distribution.
6
6
  * Payload is wrapped inside a FirebaseAlertData object.
7
7
  */
8
8
  export interface NewTesterDevicePayload {
9
- ['@type']: 'com.google.firebase.firebasealerts.NewTesterDevicePayload';
9
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroNewTesterIosDevicePayload';
10
10
  testerName: string;
11
11
  testerEmail: string;
12
12
  testerDeviceModelName: string;
13
13
  testerDeviceIdentifier: string;
14
14
  }
15
- interface WithAlertTypeAndApp {
16
- alertType: string;
17
- appId: string;
18
- }
19
15
  /**
20
16
  * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
21
17
  */
22
- export declare type AppDistributionEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertTypeAndApp>;
18
+ export interface AppDistributionEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
19
+ /** The type of the alerts that got triggered. */
20
+ alertType: string;
21
+ /** The Firebase App ID that’s associated with the alert. */
22
+ appId: string;
23
+ }
23
24
  /**
24
25
  * Configuration for app distribution functions.
25
26
  */
@@ -29,7 +30,6 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
29
30
  /**
30
31
  * Declares a function that can handle adding a new tester iOS device.
31
32
  */
32
- export declare function onNewTesterIosDevicePublished(handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewTesterDevicePayload>>;
33
- export declare function onNewTesterIosDevicePublished(appId: string, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewTesterDevicePayload>>;
34
- export declare function onNewTesterIosDevicePublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewTesterDevicePayload>>;
35
- export {};
33
+ export declare function onNewTesterIosDevicePublished(handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
34
+ export declare function onNewTesterIosDevicePublished(appId: string, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
35
+ export declare function onNewTesterIosDevicePublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
@@ -6,33 +6,39 @@ import * as options from '../../options';
6
6
  * Payload is wrapped inside a FirebaseAlertData object.
7
7
  */
8
8
  export interface PlanUpdatePayload {
9
- ['@type']: 'com.google.firebase.firebasealerts.PlanUpdatePayload';
9
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanUpdatePayload';
10
+ /** A Firebase billing plan. */
10
11
  billingPlan: string;
12
+ /** The email address of the person that triggered billing plan change */
11
13
  principalEmail: string;
14
+ /** The type of the notification, e.g. upgrade, downgrade */
15
+ notificationType: string;
12
16
  }
13
17
  /**
14
18
  * The internal payload object for billing plan automated updates.
15
19
  * Payload is wrapped inside a FirebaseAlertData object.
16
20
  */
17
21
  export interface PlanAutomatedUpdatePayload {
18
- ['@type']: 'com.google.firebase.firebasealerts.PlanAutomatedUpdatePayload';
22
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanAutomatedUpdatePayload';
23
+ /** A Firebase billing plan. */
19
24
  billingPlan: string;
20
- }
21
- interface WithAlertType {
22
- alertType: string;
25
+ /** The type of the notification, e.g. upgrade, downgrade */
26
+ notificationType: string;
23
27
  }
24
28
  /**
25
29
  * A custom CloudEvent for billing Firebase Alerts (with custom extension attributes).
26
30
  */
27
- export declare type BillingEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertType>;
31
+ export interface BillingEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
32
+ /** The type of the alerts that got triggered. */
33
+ alertType: string;
34
+ }
28
35
  /**
29
36
  * Declares a function that can handle a billing plan update event.
30
37
  */
31
- export declare function onPlanUpdatePublished(handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<PlanUpdatePayload>>;
32
- export declare function onPlanUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<PlanUpdatePayload>>;
38
+ export declare function onPlanUpdatePublished(handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanUpdatePayload>>;
39
+ export declare function onPlanUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanUpdatePayload>>;
33
40
  /**
34
41
  * Declares a function that can handle an automated billing plan update event.
35
42
  */
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
- export {};
43
+ export declare function onPlanAutomatedUpdatePublished(handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
44
+ export declare function onPlanAutomatedUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
@@ -13,7 +13,8 @@ interface Issue {
13
13
  * Payload is wrapped inside a FirebaseAlertData object.
14
14
  */
15
15
  export interface NewFatalIssuePayload {
16
- ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsNewFatalIssuePayload';
16
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewFatalIssuePayload';
17
+ /** Basic information of the Crashlytics issue */
17
18
  issue: Issue;
18
19
  }
19
20
  /**
@@ -21,7 +22,8 @@ export interface NewFatalIssuePayload {
21
22
  * Payload is wrapped inside a FirebaseAlertData object.
22
23
  */
23
24
  export interface NewNonfatalIssuePayload {
24
- ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsNewNonfatalIssuePayload';
25
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewNonfatalIssuePayload';
26
+ /** Basic information of the Crashlytics issue */
25
27
  issue: Issue;
26
28
  }
27
29
  /**
@@ -29,16 +31,26 @@ export interface NewNonfatalIssuePayload {
29
31
  * Payload is wrapped inside a FirebaseAlertData object.
30
32
  */
31
33
  export interface RegressionAlertPayload {
32
- ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsRegressionAlertPayload';
34
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsRegressionAlertPayload';
35
+ /** The type of the Crashlytics issue, e.g. new fatal, new nonfatal, ANR */
33
36
  type: string;
37
+ /** Basic information of the Crashlytics issue */
34
38
  issue: Issue;
39
+ /**
40
+ * The time that the Crashlytics issues was most recently resolved before it
41
+ * began to reoccur.
42
+ */
35
43
  resolveTime: string;
36
44
  }
37
45
  /** Generic crashlytics trending issue interface */
38
46
  interface TrendingIssueDetails {
47
+ /** The type of the Crashlytics issue, e.g. new fatal, new nonfatal, ANR */
39
48
  type: string;
49
+ /** Basic information of the Crashlytics issue */
40
50
  issue: Issue;
51
+ /** The number of crashes that occurred with the issue */
41
52
  eventCount: number;
53
+ /** The number of distinct users that were affected by the issue */
42
54
  userCount: number;
43
55
  }
44
56
  /**
@@ -46,8 +58,13 @@ interface TrendingIssueDetails {
46
58
  * Payload is wrapped inside a FirebaseAlertData object.
47
59
  */
48
60
  export interface StabilityDigestPayload {
49
- ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsStabilityDigestPayload';
61
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsStabilityDigestPayload';
62
+ /**
63
+ * The date that the digest gets created. Issues in the digest should have the
64
+ * same date as the digest date
65
+ */
50
66
  digestDate: string;
67
+ /** A stability digest containing several trending Crashlytics issues */
51
68
  trendingIssues: TrendingIssueDetails[];
52
69
  }
53
70
  /**
@@ -55,11 +72,25 @@ export interface StabilityDigestPayload {
55
72
  * Payload is wrapped inside a FirebaseAlertData object.
56
73
  */
57
74
  export interface VelocityAlertPayload {
58
- ['@type']: 'com.google.firebase.firebasealerts.VelocityAlertPayload';
75
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsVelocityAlertPayload';
76
+ /** Basic information of the Crashlytics issue */
59
77
  issue: Issue;
78
+ /** The time that the Crashlytics issue gets created */
60
79
  createTime: string;
80
+ /**
81
+ * The number of user sessions for the given app version that had this
82
+ * specific crash issue in the time period used to trigger the velocity alert.
83
+ */
61
84
  crashCount: number;
85
+ /**
86
+ * The percentage of user sessions for the given app version that had this
87
+ * specific crash issue in the time period used to trigger the velocity alert.
88
+ */
62
89
  crashPercentage: number;
90
+ /**
91
+ * The first app version where this issue was seen, and not necessarily the
92
+ * version that has triggered the alert.
93
+ */
63
94
  firstVersion: string;
64
95
  }
65
96
  /**
@@ -67,17 +98,19 @@ export interface VelocityAlertPayload {
67
98
  * Payload is wrapped inside a FirebaseAlertData object.
68
99
  */
69
100
  export interface NewAnrIssuePayload {
70
- ['@type']: 'com.google.firebase.firebasealerts.NewAnrIssuePayload';
101
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewAnrIssuePayload';
102
+ /** Basic information of the Crashlytics issue */
71
103
  issue: Issue;
72
104
  }
73
- interface WithAlertTypeAndApp {
74
- alertType: string;
75
- appId: string;
76
- }
77
105
  /**
78
106
  * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
79
107
  */
80
- export declare type CrashlyticsEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertTypeAndApp>;
108
+ export interface CrashlyticsEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
109
+ /** The type of the alerts that got triggered. */
110
+ alertType: string;
111
+ /** The Firebase App ID that’s associated with the alert. */
112
+ appId: string;
113
+ }
81
114
  /**
82
115
  * Configuration for crashlytics functions.
83
116
  */
@@ -87,37 +120,37 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
87
120
  /**
88
121
  * Declares a function that can handle a new fatal issue published to crashlytics.
89
122
  */
90
- export declare function onNewFatalIssuePublished(handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewFatalIssuePayload>>;
91
- export declare function onNewFatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewFatalIssuePayload>>;
92
- export declare function onNewFatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewFatalIssuePayload>>;
123
+ export declare function onNewFatalIssuePublished(handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
124
+ export declare function onNewFatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
125
+ export declare function onNewFatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
93
126
  /**
94
127
  * Declares a function that can handle aa new non-fatal issue published to crashlytics.
95
128
  */
96
- export declare function onNewNonfatalIssuePublished(handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewNonfatalIssuePayload>>;
97
- export declare function onNewNonfatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewNonfatalIssuePayload>>;
98
- export declare function onNewNonfatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewNonfatalIssuePayload>>;
129
+ export declare function onNewNonfatalIssuePublished(handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
130
+ export declare function onNewNonfatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
131
+ export declare function onNewNonfatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
99
132
  /**
100
133
  * Declares a function that can handle a regression alert published to crashlytics.
101
134
  */
102
- export declare function onRegressionAlertPublished(handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<RegressionAlertPayload>>;
103
- export declare function onRegressionAlertPublished(appId: string, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<RegressionAlertPayload>>;
104
- export declare function onRegressionAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<RegressionAlertPayload>>;
135
+ export declare function onRegressionAlertPublished(handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
136
+ export declare function onRegressionAlertPublished(appId: string, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
137
+ export declare function onRegressionAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
105
138
  /**
106
139
  * Declares a function that can handle a stability digest published to crashlytics.
107
140
  */
108
- export declare function onStabilityDigestPublished(handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<StabilityDigestPayload>>;
109
- export declare function onStabilityDigestPublished(appId: string, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<StabilityDigestPayload>>;
110
- export declare function onStabilityDigestPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<StabilityDigestPayload>>;
141
+ export declare function onStabilityDigestPublished(handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
142
+ export declare function onStabilityDigestPublished(appId: string, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
143
+ export declare function onStabilityDigestPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
111
144
  /**
112
145
  * Declares a function that can handle a velocity alert published to crashlytics.
113
146
  */
114
- export declare function onVelocityAlertPublished(handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<VelocityAlertPayload>>;
115
- export declare function onVelocityAlertPublished(appId: string, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<VelocityAlertPayload>>;
116
- export declare function onVelocityAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<VelocityAlertPayload>>;
147
+ export declare function onVelocityAlertPublished(handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
148
+ export declare function onVelocityAlertPublished(appId: string, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
149
+ export declare function onVelocityAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
117
150
  /**
118
151
  * Declares a function that can handle a new Application Not Responding issue published to crashlytics.
119
152
  */
120
- export declare function onNewAnrIssuePublished(handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewAnrIssuePayload>>;
121
- export declare function onNewAnrIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewAnrIssuePayload>>;
122
- export declare function onNewAnrIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<NewAnrIssuePayload>>;
153
+ export declare function onNewAnrIssuePublished(handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
154
+ export declare function onNewAnrIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
155
+ export declare function onNewAnrIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
123
156
  export {};
@@ -0,0 +1,32 @@
1
+ import { CloudEvent, CloudFunction } from '../core';
2
+ import * as options from '../options';
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 encoding_1 = require("../../common/encoding");
26
+ const options = require("../options");
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
+ (0, encoding_1.convertIfPresent)(endpoint.eventTrigger, opts, 'eventFilters', 'filters');
61
+ (0, encoding_1.copyIfPresent)(endpoint.eventTrigger, opts, 'retry');
62
+ func.__endpoint = endpoint;
63
+ return func;
64
+ }
65
+ exports.onCustomEventPublished = onCustomEventPublished;
@@ -1,23 +1,15 @@
1
1
  import * as express from 'express';
2
- import * as options from '../options';
3
- import { CallableRequest, FunctionsErrorCode, HttpsError, Request, TaskRateLimits, TaskRequest, TaskRetryConfig } from '../../common/providers/https';
2
+ import { CallableRequest, FunctionsErrorCode, HttpsError, Request } from '../../common/providers/https';
4
3
  import { ManifestEndpoint } from '../../runtime/manifest';
5
- export { Request, CallableRequest, FunctionsErrorCode, HttpsError, TaskRateLimits, TaskRequest, TaskRetryConfig as TaskRetryPolicy, };
6
- export interface HttpsOptions extends Omit<options.GlobalOptions, 'region'> {
7
- region?: options.SupportedRegion | string | Array<options.SupportedRegion | string>;
4
+ import { GlobalOptions, SupportedRegion } from '../options';
5
+ export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
6
+ /**
7
+ * Options that can be set on an individual HTTPS Cloud Function.
8
+ */
9
+ export interface HttpsOptions extends Omit<GlobalOptions, 'region'> {
10
+ region?: SupportedRegion | string | Array<SupportedRegion | string>;
8
11
  cors?: string | boolean | RegExp | Array<string | RegExp>;
9
12
  }
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
13
  export declare type HttpsFunction = ((req: Request, res: express.Response) => void | Promise<void>) & {
22
14
  __trigger?: unknown;
23
15
  __endpoint: ManifestEndpoint;
@@ -25,14 +17,7 @@ export declare type HttpsFunction = ((req: Request, res: express.Response) => vo
25
17
  export interface CallableFunction<T, Return> extends HttpsFunction {
26
18
  run(data: CallableRequest<T>): Return;
27
19
  }
28
- export interface TaskQueueFunction<T = any> extends HttpsFunction {
29
- run(data: TaskRequest<T>): void | Promise<void>;
30
- }
31
20
  export declare function onRequest(opts: HttpsOptions, handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
32
21
  export declare function onRequest(handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
33
22
  export declare function onCall<T = any, Return = any | Promise<any>>(opts: HttpsOptions, handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return>;
34
23
  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>;