firebase-functions 3.20.1 → 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 (53) hide show
  1. package/lib/apps.js +1 -1
  2. package/lib/bin/firebase-functions.js +1 -1
  3. package/lib/cloud-functions.d.ts +8 -0
  4. package/lib/cloud-functions.js +12 -12
  5. package/lib/common/providers/https.js +8 -6
  6. package/lib/common/providers/identity.d.ts +7 -1
  7. package/lib/common/providers/identity.js +55 -207
  8. package/lib/function-builder.d.ts +1 -1
  9. package/lib/function-builder.js +1 -1
  10. package/lib/handler-builder.js +3 -3
  11. package/lib/index.js +6 -2
  12. package/lib/logger/compat.js +1 -1
  13. package/lib/providers/analytics.js +1 -1
  14. package/lib/providers/auth.d.ts +19 -6
  15. package/lib/providers/auth.js +62 -10
  16. package/lib/providers/database.js +11 -11
  17. package/lib/providers/firestore.js +7 -7
  18. package/lib/providers/https.js +7 -7
  19. package/lib/providers/pubsub.js +2 -2
  20. package/lib/providers/remoteConfig.js +1 -1
  21. package/lib/providers/storage.js +2 -2
  22. package/lib/providers/tasks.d.ts +1 -1
  23. package/lib/providers/tasks.js +9 -9
  24. package/lib/providers/testLab.js +1 -1
  25. package/lib/runtime/loader.js +9 -7
  26. package/lib/runtime/manifest.d.ts +5 -0
  27. package/lib/setup.js +3 -3
  28. package/lib/v2/core.d.ts +3 -21
  29. package/lib/v2/index.d.ts +3 -2
  30. package/lib/v2/index.js +5 -3
  31. package/lib/v2/options.d.ts +13 -2
  32. package/lib/v2/options.js +31 -39
  33. package/lib/v2/providers/alerts/alerts.d.ts +15 -7
  34. package/lib/v2/providers/alerts/appDistribution.d.ts +11 -11
  35. package/lib/v2/providers/alerts/appDistribution.js +1 -1
  36. package/lib/v2/providers/alerts/billing.d.ts +17 -11
  37. package/lib/v2/providers/alerts/billing.js +1 -1
  38. package/lib/v2/providers/alerts/crashlytics.d.ts +62 -29
  39. package/lib/v2/providers/alerts/crashlytics.js +1 -1
  40. package/lib/v2/providers/alerts/index.js +5 -1
  41. package/lib/v2/providers/eventarc.d.ts +1 -1
  42. package/lib/v2/providers/eventarc.js +3 -3
  43. package/lib/v2/providers/https.d.ts +6 -3
  44. package/lib/v2/providers/https.js +5 -11
  45. package/lib/v2/providers/identity.d.ts +22 -0
  46. package/lib/v2/providers/identity.js +73 -0
  47. package/lib/v2/providers/pubsub.d.ts +3 -3
  48. package/lib/v2/providers/pubsub.js +2 -5
  49. package/lib/v2/providers/storage.d.ts +17 -13
  50. package/lib/v2/providers/storage.js +5 -4
  51. package/lib/v2/providers/tasks.d.ts +1 -1
  52. package/lib/v2/providers/tasks.js +7 -8
  53. package/package.json +16 -3
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,19 +120,19 @@ exports.getGlobalOptions = getGlobalOptions;
120
120
  */
121
121
  function optionsToTriggerAnnotations(opts) {
122
122
  const annotation = {};
123
- encoding_1.copyIfPresent(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings');
124
- encoding_1.convertIfPresent(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
123
+ (0, encoding_1.copyIfPresent)(annotation, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'vpcConnector', 'vpcConnectorEgressSettings', 'secrets');
124
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'availableMemoryMb', 'memory', (mem) => {
125
125
  return MemoryOptionToMB[mem];
126
126
  });
127
- encoding_1.convertIfPresent(annotation, opts, 'regions', 'region', (region) => {
127
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'regions', 'region', (region) => {
128
128
  if (typeof region === 'string') {
129
129
  return [region];
130
130
  }
131
131
  return region;
132
132
  });
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) => {
133
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'serviceAccountEmail', 'serviceAccount', encoding_1.serviceAccountFromShorthand);
134
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'timeout', 'timeoutSeconds', encoding_1.durationFromSeconds);
135
+ (0, encoding_1.convertIfPresent)(annotation, opts, 'failurePolicy', 'retry', (retry) => {
136
136
  return retry ? { retry: true } : null;
137
137
  });
138
138
  return annotation;
@@ -144,31 +144,23 @@ exports.optionsToTriggerAnnotations = optionsToTriggerAnnotations;
144
144
  */
145
145
  function optionsToEndpoint(opts) {
146
146
  const endpoint = {};
147
- encoding_1.copyIfPresent(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds');
148
- encoding_1.convertIfPresent(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
147
+ (0, encoding_1.copyIfPresent)(endpoint, opts, 'concurrency', 'minInstances', 'maxInstances', 'ingressSettings', 'labels', 'timeoutSeconds', 'cpu');
148
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'serviceAccountEmail', 'serviceAccount');
149
149
  if (opts.vpcConnector) {
150
150
  const vpc = { connector: opts.vpcConnector };
151
- encoding_1.convertIfPresent(vpc, opts, 'egressSettings', 'vpcConnectorEgressSettings');
151
+ (0, encoding_1.convertIfPresent)(vpc, opts, 'egressSettings', 'vpcConnectorEgressSettings');
152
152
  endpoint.vpc = vpc;
153
153
  }
154
- 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];
154
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
155
+ return MemoryOptionToMB[mem];
165
156
  });
166
- encoding_1.convertIfPresent(endpoint, opts, 'region', 'region', (region) => {
157
+ (0, encoding_1.convertIfPresent)(endpoint, opts, 'region', 'region', (region) => {
167
158
  if (typeof region === 'string') {
168
159
  return [region];
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>>;
@@ -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>>;
@@ -14,7 +14,7 @@ function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
14
14
  return handler(raw);
15
15
  };
16
16
  func.run = handler;
17
- func.__endpoint = alerts_1.getEndpointAnnotation(opts, exports.newTesterIosDeviceAlert, appId);
17
+ func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.newTesterIosDeviceAlert, appId);
18
18
  return func;
19
19
  }
20
20
  exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
@@ -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>>;
@@ -24,7 +24,7 @@ function onOperation(alertType, optsOrHandler, handler) {
24
24
  return handler(raw);
25
25
  };
26
26
  func.run = handler;
27
- func.__endpoint = _1.getEndpointAnnotation(optsOrHandler, alertType);
27
+ func.__endpoint = (0, _1.getEndpointAnnotation)(optsOrHandler, alertType);
28
28
  return func;
29
29
  }
30
30
  exports.onOperation = onOperation;
@@ -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 {};
@@ -49,7 +49,7 @@ function onOperation(alertType, appIdOrOptsOrHandler, handler) {
49
49
  return handler(raw);
50
50
  };
51
51
  func.run = handler;
52
- func.__endpoint = _1.getEndpointAnnotation(opts, alertType, appId);
52
+ func.__endpoint = (0, _1.getEndpointAnnotation)(opts, alertType, appId);
53
53
  return func;
54
54
  }
55
55
  exports.onOperation = onOperation;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,5 +1,5 @@
1
- import * as options from '../options';
2
1
  import { CloudEvent, CloudFunction } from '../core';
2
+ import * as options from '../options';
3
3
  /** Options that can be set on an Eventarc trigger. */
4
4
  export interface EventarcTriggerOptions extends options.EventHandlerOptions {
5
5
  /**
@@ -22,8 +22,8 @@
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.onCustomEventPublished = void 0;
25
- const options = require("../options");
26
25
  const encoding_1 = require("../../common/encoding");
26
+ const options = require("../options");
27
27
  function onCustomEventPublished(eventTypeOrOpts, handler) {
28
28
  var _a;
29
29
  let opts;
@@ -57,8 +57,8 @@ function onCustomEventPublished(eventTypeOrOpts, handler) {
57
57
  channel,
58
58
  },
59
59
  };
60
- encoding_1.convertIfPresent(endpoint.eventTrigger, opts, 'eventFilters', 'filters');
61
- encoding_1.copyIfPresent(endpoint.eventTrigger, opts, 'retry');
60
+ (0, encoding_1.convertIfPresent)(endpoint.eventTrigger, opts, 'eventFilters', 'filters');
61
+ (0, encoding_1.copyIfPresent)(endpoint.eventTrigger, opts, 'retry');
62
62
  func.__endpoint = endpoint;
63
63
  return func;
64
64
  }
@@ -1,10 +1,13 @@
1
1
  import * as express from 'express';
2
- import * as options from '../options';
3
2
  import { CallableRequest, FunctionsErrorCode, HttpsError, Request } from '../../common/providers/https';
4
3
  import { ManifestEndpoint } from '../../runtime/manifest';
4
+ import { GlobalOptions, SupportedRegion } from '../options';
5
5
  export { Request, CallableRequest, FunctionsErrorCode, HttpsError };
6
- export interface HttpsOptions extends Omit<options.GlobalOptions, 'region'> {
7
- region?: options.SupportedRegion | string | Array<options.SupportedRegion | string>;
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
13
  export declare type HttpsFunction = ((req: Request, res: express.Response) => void | Promise<void>) & {
@@ -24,9 +24,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.onCall = exports.onRequest = exports.HttpsError = void 0;
25
25
  const cors = require("cors");
26
26
  const encoding_1 = require("../../common/encoding");
27
- const options = require("../options");
28
27
  const https_1 = require("../../common/providers/https");
29
28
  Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return https_1.HttpsError; } });
29
+ const options = require("../options");
30
30
  function onRequest(optsOrHandler, handler) {
31
31
  let opts;
32
32
  if (arguments.length === 1) {
@@ -54,9 +54,6 @@ function onRequest(optsOrHandler, handler) {
54
54
  // but optionsToTriggerAnnotations handles both cases.
55
55
  const specificOpts = options.optionsToTriggerAnnotations(opts);
56
56
  const trigger = {
57
- // TODO(inlined): Remove "apiVersion" once the latest version of the CLI
58
- // has migrated to "platform".
59
- apiVersion: 2,
60
57
  platform: 'gcfv2',
61
58
  ...baseOpts,
62
59
  ...specificOpts,
@@ -68,7 +65,7 @@ function onRequest(optsOrHandler, handler) {
68
65
  allowInsecure: false,
69
66
  },
70
67
  };
71
- encoding_1.convertIfPresent(trigger.httpsTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
68
+ (0, encoding_1.convertIfPresent)(trigger.httpsTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
72
69
  return trigger;
73
70
  },
74
71
  });
@@ -86,7 +83,7 @@ function onRequest(optsOrHandler, handler) {
86
83
  },
87
84
  httpsTrigger: {},
88
85
  };
89
- encoding_1.convertIfPresent(endpoint.httpsTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
86
+ (0, encoding_1.convertIfPresent)(endpoint.httpsTrigger, opts, 'invoker', 'invoker', encoding_1.convertInvoker);
90
87
  handler.__endpoint = endpoint;
91
88
  return handler;
92
89
  }
@@ -104,7 +101,7 @@ function onCall(optsOrHandler, handler) {
104
101
  // onCallHandler sniffs the function length to determine which API to present.
105
102
  // fix the length to prevent api versions from being mismatched.
106
103
  const fixedLen = (req) => handler(req);
107
- const func = https_1.onCallHandler({ cors: { origin, methods: 'POST' } }, fixedLen);
104
+ const func = (0, https_1.onCallHandler)({ cors: { origin, methods: 'POST' } }, fixedLen);
108
105
  Object.defineProperty(func, '__trigger', {
109
106
  get: () => {
110
107
  const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
@@ -112,9 +109,6 @@ function onCall(optsOrHandler, handler) {
112
109
  // but optionsToTriggerAnnotations handles both cases.
113
110
  const specificOpts = options.optionsToTriggerAnnotations(opts);
114
111
  return {
115
- // TODO(inlined): Remove "apiVersion" once the latest version of the CLI
116
- // has migrated to "platform".
117
- apiVersion: 2,
118
112
  platform: 'gcfv2',
119
113
  ...baseOpts,
120
114
  ...specificOpts,
@@ -131,7 +125,7 @@ function onCall(optsOrHandler, handler) {
131
125
  });
132
126
  const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
133
127
  // global options calls region a scalar and https allows it to be an array,
134
- // but optionsToManifestEndpoint handles both cases.
128
+ // but optionsToEndpoint handles both cases.
135
129
  const specificOpts = options.optionsToEndpoint(opts);
136
130
  func.__endpoint = {
137
131
  platform: 'gcfv2',
@@ -0,0 +1,22 @@
1
+ import { BlockingFunction } from '../../cloud-functions';
2
+ import { AuthBlockingEvent, BeforeCreateResponse, BeforeSignInResponse, HttpsError } from '../../common/providers/identity';
3
+ import * as options from '../options';
4
+ export { HttpsError };
5
+ /**
6
+ * All function options plus idToken, accessToken, and refreshToken.
7
+ */
8
+ export interface BlockingOptions extends options.GlobalOptions {
9
+ idToken?: boolean;
10
+ accessToken?: boolean;
11
+ refreshToken?: boolean;
12
+ }
13
+ /**
14
+ * Handle an event that is triggered before a user is created.
15
+ */
16
+ export declare function beforeUserCreated(handler: (event: AuthBlockingEvent) => BeforeCreateResponse | Promise<BeforeCreateResponse> | void | Promise<void>): BlockingFunction;
17
+ export declare function beforeUserCreated(opts: BlockingOptions, handler: (event: AuthBlockingEvent) => BeforeCreateResponse | Promise<BeforeCreateResponse> | void | Promise<void>): BlockingFunction;
18
+ /**
19
+ * Handle an event that is triggered before a user is signed in.
20
+ */
21
+ export declare function beforeUserSignedIn(handler: (event: AuthBlockingEvent) => BeforeSignInResponse | Promise<BeforeSignInResponse> | void | Promise<void>): BlockingFunction;
22
+ export declare function beforeUserSignedIn(opts: BlockingOptions, handler: (event: AuthBlockingEvent) => BeforeSignInResponse | Promise<BeforeSignInResponse> | void | Promise<void>): BlockingFunction;