firebase-functions 3.15.5 → 3.17.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 (51) hide show
  1. package/lib/bin/firebase-functions.d.ts +2 -0
  2. package/lib/bin/firebase-functions.js +48 -0
  3. package/lib/cloud-functions.d.ts +14 -8
  4. package/lib/cloud-functions.js +61 -1
  5. package/lib/common/debug.d.ts +1 -0
  6. package/lib/common/debug.js +54 -0
  7. package/lib/common/encoding.js +6 -0
  8. package/lib/common/manifest.d.ts +1 -0
  9. package/lib/common/manifest.js +2 -0
  10. package/lib/common/providers/https.d.ts +92 -47
  11. package/lib/common/providers/https.js +171 -51
  12. package/lib/common/providers/identity.d.ts +29 -0
  13. package/lib/common/providers/identity.js +96 -0
  14. package/lib/function-builder.d.ts +7 -1
  15. package/lib/function-builder.js +8 -0
  16. package/lib/function-configuration.d.ts +1 -0
  17. package/lib/handler-builder.d.ts +19 -15
  18. package/lib/handler-builder.js +32 -15
  19. package/lib/providers/auth.d.ts +2 -21
  20. package/lib/providers/auth.js +5 -66
  21. package/lib/providers/database.js +2 -1
  22. package/lib/providers/https.d.ts +44 -2
  23. package/lib/providers/https.js +65 -2
  24. package/lib/runtime/loader.d.ts +1 -0
  25. package/lib/runtime/loader.js +101 -0
  26. package/lib/runtime/manifest.d.ts +1 -0
  27. package/lib/runtime/manifest.js +2 -0
  28. package/lib/v2/core.d.ts +10 -3
  29. package/lib/v2/index.d.ts +3 -1
  30. package/lib/v2/index.js +5 -1
  31. package/lib/v2/options.d.ts +1 -1
  32. package/lib/v2/options.js +47 -9
  33. package/lib/v2/params/types.d.ts +2 -1
  34. package/lib/v2/params/types.js +2 -0
  35. package/lib/v2/providers/alerts/alerts.d.ts +36 -0
  36. package/lib/v2/providers/alerts/alerts.js +72 -0
  37. package/lib/v2/providers/alerts/appDistribution.d.ts +35 -0
  38. package/lib/v2/providers/alerts/appDistribution.js +39 -0
  39. package/lib/v2/providers/alerts/billing.d.ts +38 -0
  40. package/lib/v2/providers/alerts/billing.js +30 -0
  41. package/lib/v2/providers/alerts/crashlytics.d.ts +123 -0
  42. package/lib/v2/providers/alerts/crashlytics.js +74 -0
  43. package/lib/v2/providers/alerts/index.d.ts +5 -0
  44. package/lib/v2/providers/alerts/index.js +20 -0
  45. package/lib/v2/providers/https.d.ts +24 -4
  46. package/lib/v2/providers/https.js +72 -3
  47. package/lib/v2/providers/pubsub.d.ts +1 -1
  48. package/lib/v2/providers/pubsub.js +19 -4
  49. package/lib/v2/providers/storage.d.ts +170 -0
  50. package/lib/v2/providers/storage.js +137 -0
  51. package/package.json +34 -7
package/lib/v2/options.js CHANGED
@@ -21,15 +21,19 @@
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.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions = exports.SUPPORTED_INGRESS_SETTINGS = exports.SUPPORTED_VPC_EGRESS_SETTINGS = exports.SUPPORTED_MEMORY_OPTIONS = exports.MAX_CONCURRENCY = exports.MAX_HTTPS_TIMEOUT_SECONDS = exports.MAX_EVENT_TIMEOUT_SECONDS = exports.MIN_TIMEOUT_SECONDS = exports.SUPPORTED_REGIONS = void 0;
24
+ exports.__getSpec = exports.optionsToEndpoint = exports.optionsToTriggerAnnotations = exports.getGlobalOptions = exports.setGlobalOptions = exports.SUPPORTED_INGRESS_SETTINGS = exports.SUPPORTED_VPC_EGRESS_SETTINGS = exports.SUPPORTED_MEMORY_OPTIONS = exports.MAX_CONCURRENCY = exports.MAX_HTTPS_TIMEOUT_SECONDS = exports.MAX_EVENT_TIMEOUT_SECONDS = exports.MIN_TIMEOUT_SECONDS = exports.SUPPORTED_REGIONS = void 0;
25
25
  const encoding_1 = require("../common/encoding");
26
- const encoding_2 = require("../common/encoding");
27
26
  const logger = require("../logger");
28
27
  const params_1 = require("./params");
29
28
  /**
30
29
  * List of all regions supported by Cloud Functions v2
31
30
  */
32
- exports.SUPPORTED_REGIONS = ['us-west1'];
31
+ exports.SUPPORTED_REGIONS = [
32
+ 'us-west1',
33
+ 'us-central1',
34
+ 'europe-west4',
35
+ 'asia-northeast1',
36
+ ];
33
37
  /**
34
38
  * Cloud Functions v2 min timeout value.
35
39
  */
@@ -107,24 +111,58 @@ exports.getGlobalOptions = getGlobalOptions;
107
111
  */
108
112
  function optionsToTriggerAnnotations(opts) {
109
113
  const annotation = {};
110
- (0, encoding_2.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
111
- (0, encoding_2.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
114
+ (0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
115
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
112
116
  return MemoryOptionToMB[mem];
113
117
  });
114
- (0, encoding_2.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
118
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
115
119
  if (typeof region === 'string') {
116
120
  return [region];
117
121
  }
118
122
  return region;
119
123
  });
120
- (0, encoding_2.convertIfPresent)(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
121
- (0, encoding_2.convertIfPresent)(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
122
- (0, encoding_2.convertIfPresent)(annotation, opts, 'failurePolicy', 'retry', (retry) => {
124
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
125
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
126
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'failurePolicy', 'retry', (retry) => {
123
127
  return retry ? { retry: true } : null;
124
128
  });
125
129
  return annotation;
126
130
  }
127
131
  exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
132
+ /**
133
+ * Apply GlobalOptions to endpoint manifest.
134
+ * @internal
135
+ */
136
+ function optionsToEndpoint(opts) {
137
+ const endpoint = {};
138
+ (0, encoding_1.copyIfPresent)(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds');
139
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
140
+ if (opts.vpcConnector) {
141
+ const vpc = { connector: opts.vpcConnector };
142
+ (0, encoding_1.convertIfPresent)(vpc, opts, 'egressSettings', 'vpcConnectorEgressSettings');
143
+ endpoint.vpc = vpc;
144
+ }
145
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
146
+ const memoryLookup = {
147
+ '128MB': 128,
148
+ '256MB': 256,
149
+ '512MB': 512,
150
+ '1GB': 1024,
151
+ '2GB': 2048,
152
+ '4GB': 4096,
153
+ '8GB': 8192,
154
+ };
155
+ return memoryLookup[mem];
156
+ });
157
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'region', 'region', (region) => {
158
+ if (typeof region === 'string') {
159
+ return [region];
160
+ }
161
+ return region;
162
+ });
163
+ return endpoint;
164
+ }
165
+ exports.optionsToEndpoint = optionsToEndpoint;
128
166
  /**
129
167
  * @hidden
130
168
  */
@@ -1,12 +1,13 @@
1
1
  /** @hidden */
2
2
  declare type ParamValueType = 'string' | 'list' | 'boolean' | 'int' | 'float' | 'json';
3
3
  export interface ParamSpec<T = unknown> {
4
+ name: string;
4
5
  default?: T;
5
6
  label?: string;
6
7
  description?: string;
7
8
  valueType?: ParamValueType;
8
9
  }
9
- export declare type ParamOptions<T = unknown> = Omit<ParamSpec<T>, 'valueType'>;
10
+ export declare type ParamOptions<T = unknown> = Omit<ParamSpec<T>, 'name' | 'valueType'>;
10
11
  export declare class Param<T = unknown> {
11
12
  readonly name: string;
12
13
  readonly options: ParamOptions<T>;
@@ -21,6 +21,7 @@ class Param {
21
21
  toSpec() {
22
22
  var _a, _b;
23
23
  const out = {
24
+ name: this.name,
24
25
  ...this.options,
25
26
  valueType: this.constructor.valueType,
26
27
  };
@@ -81,6 +82,7 @@ class ListParam extends Param {
81
82
  }
82
83
  toSpec() {
83
84
  const out = {
85
+ name: this.name,
84
86
  valueType: 'list',
85
87
  ...this.options,
86
88
  };
@@ -0,0 +1,36 @@
1
+ import { CloudEvent, CloudFunction } from '../../core';
2
+ import * as options from '../../options';
3
+ /**
4
+ * The CloudEvent data emitted by Firebase Alerts.
5
+ */
6
+ export interface FirebaseAlertData<T = any> {
7
+ createTime: string;
8
+ endTime: string;
9
+ payload: T;
10
+ }
11
+ interface WithAlertTypeAndApp {
12
+ alertType: string;
13
+ appId?: string;
14
+ }
15
+ /**
16
+ * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
17
+ */
18
+ export declare type AlertEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertTypeAndApp>;
19
+ /** The underlying alert type of the Firebase Alerts provider. */
20
+ export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNonfatalIssue' | 'crashlytics.regression' | 'crashlytics.stabilityDigest' | 'crashlytics.velocity' | 'crashlytics.newAnrIssue' | 'billing.planUpdate' | 'billing.automatedPlanUpdate' | 'appDistribution.newTesterIosDevice' | string;
21
+ /**
22
+ * Configuration for Firebase Alert functions.
23
+ */
24
+ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
25
+ alertType: AlertType;
26
+ appId?: string;
27
+ }
28
+ /**
29
+ * Declares a function that can handle Firebase Alerts from CloudEvents.
30
+ * @param alertTypeOrOpts the alert type or Firebase Alert function configuration.
31
+ * @param handler a function that can handle the Firebase Alert inside a CloudEvent.
32
+ */
33
+ export declare function onAlertPublished<T extends {
34
+ ['@type']: string;
35
+ } = any>(alertTypeOrOpts: AlertType | FirebaseAlertOptions, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<FirebaseAlertData<T>>;
36
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOptsAndAlertTypeAndApp = exports.getEndpointAnnotation = exports.onAlertPublished = exports.eventType = void 0;
4
+ const options = require("../../options");
5
+ /** @internal */
6
+ exports.eventType = 'google.firebase.firebasealerts.alerts.v1.published';
7
+ /**
8
+ * Declares a function that can handle Firebase Alerts from CloudEvents.
9
+ * @param alertTypeOrOpts the alert type or Firebase Alert function configuration.
10
+ * @param handler a function that can handle the Firebase Alert inside a CloudEvent.
11
+ */
12
+ function onAlertPublished(alertTypeOrOpts, handler) {
13
+ const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
14
+ const func = (raw) => {
15
+ return handler(raw);
16
+ };
17
+ func.run = handler;
18
+ func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
19
+ return func;
20
+ }
21
+ exports.onAlertPublished = onAlertPublished;
22
+ /**
23
+ * @internal
24
+ * Helper function for getting the endpoint annotation used in alert handling functions.
25
+ */
26
+ function getEndpointAnnotation(opts, alertType, appId) {
27
+ const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
28
+ const specificOpts = options.optionsToEndpoint(opts);
29
+ const endpoint = {
30
+ platform: 'gcfv2',
31
+ ...baseOpts,
32
+ ...specificOpts,
33
+ labels: {
34
+ ...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
35
+ ...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
36
+ },
37
+ eventTrigger: {
38
+ eventType: exports.eventType,
39
+ eventFilters: {
40
+ alertType,
41
+ },
42
+ retry: !!opts.retry,
43
+ },
44
+ };
45
+ if (appId) {
46
+ endpoint.eventTrigger.eventFilters.appId = appId;
47
+ }
48
+ return endpoint;
49
+ }
50
+ exports.getEndpointAnnotation = getEndpointAnnotation;
51
+ /**
52
+ * @internal
53
+ * Helper function to parse the function opts, alert type, and appId.
54
+ */
55
+ function getOptsAndAlertTypeAndApp(alertTypeOrOpts) {
56
+ let opts;
57
+ let alertType;
58
+ let appId;
59
+ if (typeof alertTypeOrOpts === 'string') {
60
+ alertType = alertTypeOrOpts;
61
+ opts = {};
62
+ }
63
+ else {
64
+ alertType = alertTypeOrOpts.alertType;
65
+ appId = alertTypeOrOpts.appId;
66
+ opts = { ...alertTypeOrOpts };
67
+ delete opts.alertType;
68
+ delete opts.appId;
69
+ }
70
+ return [opts, alertType, appId];
71
+ }
72
+ exports.getOptsAndAlertTypeAndApp = getOptsAndAlertTypeAndApp;
@@ -0,0 +1,35 @@
1
+ import { FirebaseAlertData } from './alerts';
2
+ import { CloudEvent, CloudFunction } from '../../core';
3
+ import * as options from '../../options';
4
+ /**
5
+ * The internal payload object for adding a new tester device to app distribution.
6
+ * Payload is wrapped inside a FirebaseAlertData object.
7
+ */
8
+ export interface NewTesterDevicePayload {
9
+ ['@type']: 'com.google.firebase.firebasealerts.NewTesterDevicePayload';
10
+ testerName: string;
11
+ testerEmail: string;
12
+ testerDeviceModelName: string;
13
+ testerDeviceIdentifier: string;
14
+ }
15
+ interface WithAlertTypeAndApp {
16
+ alertType: string;
17
+ appId: string;
18
+ }
19
+ /**
20
+ * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
21
+ */
22
+ export declare type AppDistributionEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertTypeAndApp>;
23
+ /**
24
+ * Configuration for app distribution functions.
25
+ */
26
+ export interface AppDistributionOptions extends options.EventHandlerOptions {
27
+ appId?: string;
28
+ }
29
+ /**
30
+ * Declares a function that can handle adding a new tester iOS device.
31
+ */
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 {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOptsAndApp = exports.onNewTesterIosDevicePublished = exports.newTesterIosDeviceAlert = void 0;
4
+ const alerts_1 = require("./alerts");
5
+ /** @internal */
6
+ exports.newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice';
7
+ function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
8
+ if (typeof appIdOrOptsOrHandler === 'function') {
9
+ handler = appIdOrOptsOrHandler;
10
+ appIdOrOptsOrHandler = {};
11
+ }
12
+ const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
13
+ const func = (raw) => {
14
+ return handler(raw);
15
+ };
16
+ func.run = handler;
17
+ func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.newTesterIosDeviceAlert, appId);
18
+ return func;
19
+ }
20
+ exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
21
+ /**
22
+ * @internal
23
+ * Helper function to parse the function opts and appId.
24
+ */
25
+ function getOptsAndApp(appIdOrOpts) {
26
+ let opts;
27
+ let appId;
28
+ if (typeof appIdOrOpts === 'string') {
29
+ opts = {};
30
+ appId = appIdOrOpts;
31
+ }
32
+ else {
33
+ appId = appIdOrOpts.appId;
34
+ opts = { ...appIdOrOpts };
35
+ delete opts.appId;
36
+ }
37
+ return [opts, appId];
38
+ }
39
+ exports.getOptsAndApp = getOptsAndApp;
@@ -0,0 +1,38 @@
1
+ import { FirebaseAlertData } from '.';
2
+ import { CloudEvent, CloudFunction } from '../../core';
3
+ import * as options from '../../options';
4
+ /**
5
+ * The internal payload object for billing plan updates.
6
+ * Payload is wrapped inside a FirebaseAlertData object.
7
+ */
8
+ export interface PlanUpdatePayload {
9
+ ['@type']: 'com.google.firebase.firebasealerts.PlanUpdatePayload';
10
+ billingPlan: string;
11
+ principalEmail: string;
12
+ }
13
+ /**
14
+ * The internal payload object for billing plan automated updates.
15
+ * Payload is wrapped inside a FirebaseAlertData object.
16
+ */
17
+ export interface PlanAutomatedUpdatePayload {
18
+ ['@type']: 'com.google.firebase.firebasealerts.PlanAutomatedUpdatePayload';
19
+ billingPlan: string;
20
+ }
21
+ interface WithAlertType {
22
+ alertType: string;
23
+ }
24
+ /**
25
+ * A custom CloudEvent for billing Firebase Alerts (with custom extension attributes).
26
+ */
27
+ export declare type BillingEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertType>;
28
+ /**
29
+ * Declares a function that can handle a billing plan update event.
30
+ */
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>>;
33
+ /**
34
+ * Declares a function that can handle an automated billing plan update event.
35
+ */
36
+ export declare function onAutomatedPlanUpdatePublished(handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<PlanAutomatedUpdatePayload>>;
37
+ export declare function onAutomatedPlanUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<FirebaseAlertData<PlanAutomatedUpdatePayload>>;
38
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onOperation = exports.onAutomatedPlanUpdatePublished = exports.onPlanUpdatePublished = exports.automatedPlanUpdateAlert = exports.planUpdateAlert = void 0;
4
+ const _1 = require(".");
5
+ /** @internal */
6
+ exports.planUpdateAlert = 'billing.planUpdate';
7
+ /** @internal */
8
+ exports.automatedPlanUpdateAlert = 'billing.automatedPlanUpdate';
9
+ function onPlanUpdatePublished(optsOrHandler, handler) {
10
+ return onOperation(exports.planUpdateAlert, optsOrHandler, handler);
11
+ }
12
+ exports.onPlanUpdatePublished = onPlanUpdatePublished;
13
+ function onAutomatedPlanUpdatePublished(optsOrHandler, handler) {
14
+ return onOperation(exports.automatedPlanUpdateAlert, optsOrHandler, handler);
15
+ }
16
+ exports.onAutomatedPlanUpdatePublished = onAutomatedPlanUpdatePublished;
17
+ /** @internal */
18
+ function onOperation(alertType, optsOrHandler, handler) {
19
+ if (typeof optsOrHandler === 'function') {
20
+ handler = optsOrHandler;
21
+ optsOrHandler = {};
22
+ }
23
+ const func = (raw) => {
24
+ return handler(raw);
25
+ };
26
+ func.run = handler;
27
+ func.__endpoint = (0, _1.getEndpointAnnotation)(optsOrHandler, alertType);
28
+ return func;
29
+ }
30
+ exports.onOperation = onOperation;
@@ -0,0 +1,123 @@
1
+ import { FirebaseAlertData } from '.';
2
+ import { CloudEvent, CloudFunction } from '../../core';
3
+ import * as options from '../../options';
4
+ /** Generic crashlytics issue interface */
5
+ interface Issue {
6
+ id: string;
7
+ title: string;
8
+ subtitle: string;
9
+ appVersion: string;
10
+ }
11
+ /**
12
+ * The internal payload object for a new fatal issue.
13
+ * Payload is wrapped inside a FirebaseAlertData object.
14
+ */
15
+ export interface NewFatalIssuePayload {
16
+ ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsNewFatalIssuePayload';
17
+ issue: Issue;
18
+ }
19
+ /**
20
+ * The internal payload object for a new non-fatal issue.
21
+ * Payload is wrapped inside a FirebaseAlertData object.
22
+ */
23
+ export interface NewNonfatalIssuePayload {
24
+ ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsNewNonfatalIssuePayload';
25
+ issue: Issue;
26
+ }
27
+ /**
28
+ * The internal payload object for a regression alert.
29
+ * Payload is wrapped inside a FirebaseAlertData object.
30
+ */
31
+ export interface RegressionAlertPayload {
32
+ ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsRegressionAlertPayload';
33
+ type: string;
34
+ issue: Issue;
35
+ resolveTime: string;
36
+ }
37
+ /** Generic crashlytics trending issue interface */
38
+ interface TrendingIssueDetails {
39
+ type: string;
40
+ issue: Issue;
41
+ eventCount: number;
42
+ userCount: number;
43
+ }
44
+ /**
45
+ * The internal payload object for a stability digest.
46
+ * Payload is wrapped inside a FirebaseAlertData object.
47
+ */
48
+ export interface StabilityDigestPayload {
49
+ ['@type']: 'com.google.firebase.firebasealerts.CrashlyticsStabilityDigestPayload';
50
+ digestDate: string;
51
+ trendingIssues: TrendingIssueDetails[];
52
+ }
53
+ /**
54
+ * The internal payload object for a velocity alert.
55
+ * Payload is wrapped inside a FirebaseAlertData object.
56
+ */
57
+ export interface VelocityAlertPayload {
58
+ ['@type']: 'com.google.firebase.firebasealerts.VelocityAlertPayload';
59
+ issue: Issue;
60
+ createTime: string;
61
+ crashCount: number;
62
+ crashPercentage: number;
63
+ firstVersion: string;
64
+ }
65
+ /**
66
+ * The internal payload object for a new Application Not Responding issue.
67
+ * Payload is wrapped inside a FirebaseAlertData object.
68
+ */
69
+ export interface NewAnrIssuePayload {
70
+ ['@type']: 'com.google.firebase.firebasealerts.NewAnrIssuePayload';
71
+ issue: Issue;
72
+ }
73
+ interface WithAlertTypeAndApp {
74
+ alertType: string;
75
+ appId: string;
76
+ }
77
+ /**
78
+ * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
79
+ */
80
+ export declare type CrashlyticsEvent<T> = CloudEvent<FirebaseAlertData<T>, WithAlertTypeAndApp>;
81
+ /**
82
+ * Configuration for crashlytics functions.
83
+ */
84
+ export interface CrashlyticsOptions extends options.EventHandlerOptions {
85
+ appId?: string;
86
+ }
87
+ /**
88
+ * Declares a function that can handle a new fatal issue published to crashlytics.
89
+ */
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>>;
93
+ /**
94
+ * Declares a function that can handle aa new non-fatal issue published to crashlytics.
95
+ */
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>>;
99
+ /**
100
+ * Declares a function that can handle a regression alert published to crashlytics.
101
+ */
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>>;
105
+ /**
106
+ * Declares a function that can handle a stability digest published to crashlytics.
107
+ */
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>>;
111
+ /**
112
+ * Declares a function that can handle a velocity alert published to crashlytics.
113
+ */
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>>;
117
+ /**
118
+ * Declares a function that can handle a new Application Not Responding issue published to crashlytics.
119
+ */
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>>;
123
+ export {};
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOptsAndApp = exports.onOperation = exports.onNewAnrIssuePublished = exports.onVelocityAlertPublished = exports.onStabilityDigestPublished = exports.onRegressionAlertPublished = exports.onNewNonfatalIssuePublished = exports.onNewFatalIssuePublished = exports.newAnrIssueAlert = exports.velocityAlert = exports.stabilityDigestAlert = exports.regressionAlert = exports.newNonfatalIssueAlert = exports.newFatalIssueAlert = void 0;
4
+ const _1 = require(".");
5
+ /** @internal */
6
+ exports.newFatalIssueAlert = 'crashlytics.newFatalIssue';
7
+ /** @internal */
8
+ exports.newNonfatalIssueAlert = 'crashlytics.newNonfatalIssue';
9
+ /** @internal */
10
+ exports.regressionAlert = 'crashlytics.regression';
11
+ /** @internal */
12
+ exports.stabilityDigestAlert = 'crashlytics.stabilityDigest';
13
+ /** @internal */
14
+ exports.velocityAlert = 'crashlytics.velocity';
15
+ /** @internal */
16
+ exports.newAnrIssueAlert = 'crashlytics.newAnrIssue';
17
+ function onNewFatalIssuePublished(appIdOrOptsOrHandler, handler) {
18
+ return onOperation(exports.newFatalIssueAlert, appIdOrOptsOrHandler, handler);
19
+ }
20
+ exports.onNewFatalIssuePublished = onNewFatalIssuePublished;
21
+ function onNewNonfatalIssuePublished(appIdOrOptsOrHandler, handler) {
22
+ return onOperation(exports.newNonfatalIssueAlert, appIdOrOptsOrHandler, handler);
23
+ }
24
+ exports.onNewNonfatalIssuePublished = onNewNonfatalIssuePublished;
25
+ function onRegressionAlertPublished(appIdOrOptsOrHandler, handler) {
26
+ return onOperation(exports.regressionAlert, appIdOrOptsOrHandler, handler);
27
+ }
28
+ exports.onRegressionAlertPublished = onRegressionAlertPublished;
29
+ function onStabilityDigestPublished(appIdOrOptsOrHandler, handler) {
30
+ return onOperation(exports.stabilityDigestAlert, appIdOrOptsOrHandler, handler);
31
+ }
32
+ exports.onStabilityDigestPublished = onStabilityDigestPublished;
33
+ function onVelocityAlertPublished(appIdOrOptsOrHandler, handler) {
34
+ return onOperation(exports.velocityAlert, appIdOrOptsOrHandler, handler);
35
+ }
36
+ exports.onVelocityAlertPublished = onVelocityAlertPublished;
37
+ function onNewAnrIssuePublished(appIdOrOptsOrHandler, handler) {
38
+ return onOperation(exports.newAnrIssueAlert, appIdOrOptsOrHandler, handler);
39
+ }
40
+ exports.onNewAnrIssuePublished = onNewAnrIssuePublished;
41
+ /** @internal */
42
+ function onOperation(alertType, appIdOrOptsOrHandler, handler) {
43
+ if (typeof appIdOrOptsOrHandler === 'function') {
44
+ handler = appIdOrOptsOrHandler;
45
+ appIdOrOptsOrHandler = {};
46
+ }
47
+ const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
48
+ const func = (raw) => {
49
+ return handler(raw);
50
+ };
51
+ func.run = handler;
52
+ func.__endpoint = (0, _1.getEndpointAnnotation)(opts, alertType, appId);
53
+ return func;
54
+ }
55
+ exports.onOperation = onOperation;
56
+ /**
57
+ * @internal
58
+ * Helper function to parse the function opts and appId.
59
+ */
60
+ function getOptsAndApp(appIdOrOpts) {
61
+ let opts;
62
+ let appId;
63
+ if (typeof appIdOrOpts === 'string') {
64
+ opts = {};
65
+ appId = appIdOrOpts;
66
+ }
67
+ else {
68
+ appId = appIdOrOpts.appId;
69
+ opts = { ...appIdOrOpts };
70
+ delete opts.appId;
71
+ }
72
+ return [opts, appId];
73
+ }
74
+ exports.getOptsAndApp = getOptsAndApp;
@@ -0,0 +1,5 @@
1
+ import * as appDistribution from './appDistribution';
2
+ import * as billing from './billing';
3
+ import * as crashlytics from './crashlytics';
4
+ export { appDistribution, billing, crashlytics };
5
+ export * from './alerts';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.crashlytics = exports.billing = exports.appDistribution = void 0;
14
+ const appDistribution = require("./appDistribution");
15
+ exports.appDistribution = appDistribution;
16
+ const billing = require("./billing");
17
+ exports.billing = billing;
18
+ const crashlytics = require("./crashlytics");
19
+ exports.crashlytics = crashlytics;
20
+ __exportStar(require("./alerts"), exports);
@@ -1,18 +1,38 @@
1
1
  import * as express from 'express';
2
- import { CallableRequest, FunctionsErrorCode, HttpsError, Request } from '../../common/providers/https';
3
2
  import * as options from '../options';
4
- export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
3
+ import { CallableRequest, FunctionsErrorCode, HttpsError, Request, TaskRateLimits, TaskRequest, TaskRetryConfig } from '../../common/providers/https';
4
+ import { ManifestEndpoint } from '../../runtime/manifest';
5
+ export { Request, CallableRequest, FunctionsErrorCode, HttpsError, TaskRateLimits, TaskRequest, TaskRetryConfig as TaskRetryPolicy, };
5
6
  export interface HttpsOptions extends Omit<options.GlobalOptions, 'region'> {
6
7
  region?: options.SupportedRegion | string | Array<options.SupportedRegion | string>;
7
- cors?: string | boolean;
8
+ cors?: string | boolean | RegExp | Array<string | RegExp>;
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[];
8
20
  }
9
21
  export declare type HttpsFunction = ((req: Request, res: express.Response) => void | Promise<void>) & {
10
- __trigger: unknown;
22
+ __trigger?: unknown;
23
+ __endpoint: ManifestEndpoint;
11
24
  };
12
25
  export interface CallableFunction<T, Return> extends HttpsFunction {
13
26
  run(data: CallableRequest<T>): Return;
14
27
  }
28
+ export interface TaskQueueFunction<T = any> extends HttpsFunction {
29
+ run(data: TaskRequest<T>): void | Promise<void>;
30
+ }
15
31
  export declare function onRequest(opts: HttpsOptions, handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
16
32
  export declare function onRequest(handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
17
33
  export declare function onCall<T = any, Return = any | Promise<any>>(opts: HttpsOptions, handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return>;
18
34
  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>;