firebase-functions 3.21.0 → 3.22.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 (66) hide show
  1. package/lib/bin/firebase-functions.js +21 -0
  2. package/lib/cloud-functions.d.ts +54 -88
  3. package/lib/cloud-functions.js +2 -59
  4. package/lib/common/change.d.ts +46 -0
  5. package/lib/common/change.js +82 -0
  6. package/lib/common/encoding.js +21 -1
  7. package/lib/common/providers/database.d.ts +145 -0
  8. package/lib/common/providers/database.js +271 -0
  9. package/lib/common/providers/https.d.ts +37 -17
  10. package/lib/common/providers/https.js +3 -0
  11. package/lib/common/providers/identity.d.ts +5 -1
  12. package/lib/common/providers/identity.js +12 -4
  13. package/lib/common/providers/tasks.d.ts +9 -0
  14. package/lib/common/providers/tasks.js +13 -12
  15. package/lib/function-builder.d.ts +3 -3
  16. package/lib/function-builder.js +2 -2
  17. package/lib/logger/common.js +21 -0
  18. package/lib/logger/compat.js +21 -0
  19. package/lib/logger/index.d.ts +14 -6
  20. package/lib/logger/index.js +33 -6
  21. package/lib/providers/auth.d.ts +26 -5
  22. package/lib/providers/auth.js +18 -4
  23. package/lib/providers/database.d.ts +4 -146
  24. package/lib/providers/database.js +7 -251
  25. package/lib/providers/firestore.d.ts +2 -1
  26. package/lib/providers/firestore.js +2 -1
  27. package/lib/providers/pubsub.d.ts +6 -6
  28. package/lib/providers/pubsub.js +6 -6
  29. package/lib/providers/tasks.d.ts +29 -14
  30. package/lib/providers/tasks.js +10 -3
  31. package/lib/utilities/path-pattern.d.ts +1 -0
  32. package/lib/utilities/path-pattern.js +142 -0
  33. package/lib/v2/core.d.ts +25 -1
  34. package/lib/v2/core.js +7 -0
  35. package/lib/v2/index.d.ts +11 -3
  36. package/lib/v2/index.js +12 -3
  37. package/lib/v2/options.d.ts +13 -34
  38. package/lib/v2/options.js +6 -58
  39. package/lib/v2/params/index.d.ts +4 -1
  40. package/lib/v2/params/index.js +25 -1
  41. package/lib/v2/params/types.js +21 -0
  42. package/lib/v2/providers/alerts/alerts.d.ts +94 -3
  43. package/lib/v2/providers/alerts/alerts.js +23 -7
  44. package/lib/v2/providers/alerts/appDistribution.d.ts +101 -1
  45. package/lib/v2/providers/alerts/appDistribution.js +28 -1
  46. package/lib/v2/providers/alerts/billing.d.ts +23 -2
  47. package/lib/v2/providers/alerts/billing.js +37 -0
  48. package/lib/v2/providers/alerts/crashlytics.d.ts +193 -18
  49. package/lib/v2/providers/alerts/crashlytics.js +62 -1
  50. package/lib/v2/providers/alerts/index.d.ts +6 -0
  51. package/lib/v2/providers/alerts/index.js +27 -0
  52. package/lib/v2/providers/database.d.ts +182 -0
  53. package/lib/v2/providers/database.js +204 -0
  54. package/lib/v2/providers/eventarc.d.ts +89 -5
  55. package/lib/v2/providers/eventarc.js +4 -0
  56. package/lib/v2/providers/https.d.ts +123 -2
  57. package/lib/v2/providers/https.js +13 -3
  58. package/lib/v2/providers/identity.d.ts +108 -4
  59. package/lib/v2/providers/identity.js +33 -2
  60. package/lib/v2/providers/pubsub.d.ts +122 -5
  61. package/lib/v2/providers/pubsub.js +58 -2
  62. package/lib/v2/providers/storage.d.ts +192 -4
  63. package/lib/v2/providers/storage.js +52 -9
  64. package/lib/v2/providers/tasks.d.ts +106 -6
  65. package/lib/v2/providers/tasks.js +4 -0
  66. package/package.json +12 -6
@@ -1,16 +1,24 @@
1
+ /**
2
+ * Cloud functions to handle Crashlytics events from Firebase Alerts.
3
+ * @packageDocumentation
4
+ */
1
5
  import { FirebaseAlertData } from '.';
2
6
  import { CloudEvent, CloudFunction } from '../../core';
3
7
  import * as options from '../../options';
4
- /** Generic crashlytics issue interface */
5
- interface Issue {
8
+ /** Generic Crashlytics issue interface */
9
+ export interface Issue {
10
+ /** The ID of the Crashlytics issue */
6
11
  id: string;
12
+ /** The title of the Crashlytics issue */
7
13
  title: string;
14
+ /** The subtitle of the Crashlytics issue */
8
15
  subtitle: string;
16
+ /** The application version of the Crashlytics issue */
9
17
  appVersion: string;
10
18
  }
11
19
  /**
12
20
  * The internal payload object for a new fatal issue.
13
- * Payload is wrapped inside a FirebaseAlertData object.
21
+ * Payload is wrapped inside a `FirebaseAlertData` object.
14
22
  */
15
23
  export interface NewFatalIssuePayload {
16
24
  ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewFatalIssuePayload';
@@ -19,7 +27,7 @@ export interface NewFatalIssuePayload {
19
27
  }
20
28
  /**
21
29
  * The internal payload object for a new non-fatal issue.
22
- * Payload is wrapped inside a FirebaseAlertData object.
30
+ * Payload is wrapped inside a `FirebaseAlertData` object.
23
31
  */
24
32
  export interface NewNonfatalIssuePayload {
25
33
  ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewNonfatalIssuePayload';
@@ -28,7 +36,7 @@ export interface NewNonfatalIssuePayload {
28
36
  }
29
37
  /**
30
38
  * The internal payload object for a regression alert.
31
- * Payload is wrapped inside a FirebaseAlertData object.
39
+ * Payload is wrapped inside a `FirebaseAlertData` object.
32
40
  */
33
41
  export interface RegressionAlertPayload {
34
42
  ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsRegressionAlertPayload';
@@ -42,8 +50,8 @@ export interface RegressionAlertPayload {
42
50
  */
43
51
  resolveTime: string;
44
52
  }
45
- /** Generic crashlytics trending issue interface */
46
- interface TrendingIssueDetails {
53
+ /** Generic Crashlytics trending issue interface */
54
+ export interface TrendingIssueDetails {
47
55
  /** The type of the Crashlytics issue, e.g. new fatal, new nonfatal, ANR */
48
56
  type: string;
49
57
  /** Basic information of the Crashlytics issue */
@@ -55,7 +63,7 @@ interface TrendingIssueDetails {
55
63
  }
56
64
  /**
57
65
  * The internal payload object for a stability digest.
58
- * Payload is wrapped inside a FirebaseAlertData object.
66
+ * Payload is wrapped inside a `FirebaseAlertData` object.
59
67
  */
60
68
  export interface StabilityDigestPayload {
61
69
  ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsStabilityDigestPayload';
@@ -69,7 +77,7 @@ export interface StabilityDigestPayload {
69
77
  }
70
78
  /**
71
79
  * The internal payload object for a velocity alert.
72
- * Payload is wrapped inside a FirebaseAlertData object.
80
+ * Payload is wrapped inside a `FirebaseAlertData` object.
73
81
  */
74
82
  export interface VelocityAlertPayload {
75
83
  ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsVelocityAlertPayload';
@@ -95,7 +103,7 @@ export interface VelocityAlertPayload {
95
103
  }
96
104
  /**
97
105
  * The internal payload object for a new Application Not Responding issue.
98
- * Payload is wrapped inside a FirebaseAlertData object.
106
+ * Payload is wrapped inside a `FirebaseAlertData` object.
99
107
  */
100
108
  export interface NewAnrIssuePayload {
101
109
  ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewAnrIssuePayload';
@@ -104,6 +112,7 @@ export interface NewAnrIssuePayload {
104
112
  }
105
113
  /**
106
114
  * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
115
+ * @typeParam T - the data type for Crashlytics alerts that is wrapped in a `FirebaseAlertData` object.
107
116
  */
108
117
  export interface CrashlyticsEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
109
118
  /** The type of the alerts that got triggered. */
@@ -112,45 +121,211 @@ export interface CrashlyticsEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
112
121
  appId: string;
113
122
  }
114
123
  /**
115
- * Configuration for crashlytics functions.
124
+ * Configuration for Crashlytics functions.
116
125
  */
117
126
  export interface CrashlyticsOptions extends options.EventHandlerOptions {
127
+ /** Scope the function to trigger on a specific application. */
118
128
  appId?: string;
129
+ /**
130
+ * Region where functions should be deployed.
131
+ */
132
+ region?: options.SupportedRegion | string;
133
+ /**
134
+ * Amount of memory to allocate to a function.
135
+ * A value of null restores the defaults of 256MB.
136
+ */
137
+ memory?: options.MemoryOption | null;
138
+ /**
139
+ * Timeout for the function in sections, possible values are 0 to 540.
140
+ * HTTPS functions can specify a higher timeout.
141
+ * A value of null restores the default of 60s
142
+ * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
143
+ * function depends on the type of function: Event handling functions have a
144
+ * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
145
+ * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
146
+ * timeout of 1,800s (30 minutes)
147
+ */
148
+ timeoutSeconds?: number | null;
149
+ /**
150
+ * Min number of actual instances to be running at a given time.
151
+ * Instances will be billed for memory allocation and 10% of CPU allocation
152
+ * while idle.
153
+ * A value of null restores the default min instances.
154
+ */
155
+ minInstances?: number | null;
156
+ /**
157
+ * Max number of instances to be running in parallel.
158
+ * A value of null restores the default max instances.
159
+ */
160
+ maxInstances?: number | null;
161
+ /**
162
+ * Number of requests a function can serve at once.
163
+ * Can only be applied to functions running on Cloud Functions v2.
164
+ * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
165
+ * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
166
+ * The maximum value for concurrency is 1,000.
167
+ */
168
+ concurrency?: number | null;
169
+ /**
170
+ * Fractional number of CPUs to allocate to a function.
171
+ * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
172
+ * This is different from the defaults when using the gcloud utility and is different from
173
+ * the fixed amount assigned in Google Cloud Functions generation 1.
174
+ * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
175
+ * to the value "gcf_gen1"
176
+ */
177
+ cpu?: number | 'gcf_gen1';
178
+ /**
179
+ * Connect cloud function to specified VPC connector.
180
+ * A value of null removes the VPC connector
181
+ */
182
+ vpcConnector?: string | null;
183
+ /**
184
+ * Egress settings for VPC connector.
185
+ * A value of null turns off VPC connector egress settings
186
+ */
187
+ vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
188
+ /**
189
+ * Specific service account for the function to run as.
190
+ * A value of null restores the default service account.
191
+ */
192
+ serviceAccount?: string | null;
193
+ /**
194
+ * Ingress settings which control where this function can be called from.
195
+ * A value of null turns off ingress settings.
196
+ */
197
+ ingressSettings?: options.IngressSetting | null;
198
+ /**
199
+ * User labels to set on the function.
200
+ */
201
+ labels?: Record<string, string>;
202
+ secrets?: string[];
203
+ /** Whether failed executions should be delivered again. */
204
+ retry?: boolean;
119
205
  }
120
206
  /**
121
- * Declares a function that can handle a new fatal issue published to crashlytics.
207
+ * Declares a function that can handle a new fatal issue published to Crashlytics.
208
+ * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
209
+ * @returns A function that you can export and deploy.
122
210
  */
123
211
  export declare function onNewFatalIssuePublished(handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
212
+ /**
213
+ * Declares a function that can handle a new fatal issue published to Crashlytics.
214
+ * @param appId - A specific application the handler will trigger on.
215
+ * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
216
+ * @returns A function that you can export and deploy.
217
+ */
124
218
  export declare function onNewFatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
219
+ /**
220
+ * Declares a function that can handle a new fatal issue published to Crashlytics.
221
+ * @param opts - Options that can be set on the function.
222
+ * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
223
+ * @returns A function that you can export and deploy.
224
+ */
125
225
  export declare function onNewFatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
126
226
  /**
127
- * Declares a function that can handle aa new non-fatal issue published to crashlytics.
227
+ * Declares a function that can handle a new non-fatal issue published to Crashlytics.
228
+ * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
229
+ * @returns A function that you can export and deploy.
128
230
  */
129
231
  export declare function onNewNonfatalIssuePublished(handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
232
+ /**
233
+ * Declares a function that can handle a new non-fatal issue published to Crashlytics.
234
+ * @param appId - A specific application the handler will trigger on.
235
+ * @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
236
+ * @returns A function that you can export and deploy.
237
+ */
130
238
  export declare function onNewNonfatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
239
+ /**
240
+ * Declares a function that can handle a new non-fatal issue published to Crashlytics.
241
+ * @param opts - Options that can be set on the function.
242
+ * @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
243
+ * @returns A function that you can export and deploy.
244
+ */
131
245
  export declare function onNewNonfatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
132
246
  /**
133
- * Declares a function that can handle a regression alert published to crashlytics.
247
+ * Declares a function that can handle a regression alert published to Crashlytics.
248
+ * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
249
+ * @returns A function that you can export and deploy.
134
250
  */
135
251
  export declare function onRegressionAlertPublished(handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
252
+ /**
253
+ * Declares a function that can handle a regression alert published to Crashlytics.
254
+ * @param appId - A specific application the handler will trigger on.
255
+ * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
256
+ * @returns A function that you can export and deploy.
257
+
258
+ */
136
259
  export declare function onRegressionAlertPublished(appId: string, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
260
+ /**
261
+ * Declares a function that can handle a regression alert published to Crashlytics.
262
+ * @param opts - Options that can be set on the function.
263
+ * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
264
+ * @returns A function that you can export and deploy.
265
+
266
+ */
137
267
  export declare function onRegressionAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
138
268
  /**
139
- * Declares a function that can handle a stability digest published to crashlytics.
269
+ * Declares a function that can handle a stability digest published to Crashlytics.
270
+ * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
271
+ * @returns A function that you can export and deploy.
140
272
  */
141
273
  export declare function onStabilityDigestPublished(handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
274
+ /**
275
+ * Declares a function that can handle a stability digest published to Crashlytics.
276
+ * @param appId - A specific application the handler will trigger on.
277
+ * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
278
+ * @returns A function that you can export and deploy.
279
+
280
+ */
142
281
  export declare function onStabilityDigestPublished(appId: string, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
282
+ /**
283
+ * Declares a function that can handle a stability digest published to Crashlytics.
284
+ * @param opts - Options that can be set on the function.
285
+ * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
286
+ * @returns A function that you can export and deploy.
287
+
288
+ */
143
289
  export declare function onStabilityDigestPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
144
290
  /**
145
- * Declares a function that can handle a velocity alert published to crashlytics.
291
+ * Declares a function that can handle a velocity alert published to Crashlytics.
292
+ * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
293
+ * @returns A function that you can export and deploy.
146
294
  */
147
295
  export declare function onVelocityAlertPublished(handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
296
+ /**
297
+ * Declares a function that can handle a velocity alert published to Crashlytics.
298
+ * @param appId - A specific application the handler will trigger on.
299
+ * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
300
+ * @returns A function that you can export and deploy.
301
+ */
148
302
  export declare function onVelocityAlertPublished(appId: string, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
303
+ /**
304
+ * Declares a function that can handle a velocity alert published to Crashlytics.
305
+ * @param opts - Options that can be set on the function.
306
+ * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
307
+ * @returns A function that you can export and deploy.
308
+ */
149
309
  export declare function onVelocityAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
150
310
  /**
151
- * Declares a function that can handle a new Application Not Responding issue published to crashlytics.
311
+ * Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
312
+ * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
313
+ * @returns A function that you can export and deploy.
152
314
  */
153
315
  export declare function onNewAnrIssuePublished(handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
316
+ /**
317
+ * Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
318
+ * @param appId - A specific application the handler will trigger on.
319
+ * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
320
+ * @returns A function that you can export and deploy.
321
+
322
+ */
154
323
  export declare function onNewAnrIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
324
+ /**
325
+ * Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
326
+ * @param opts - Options that can be set on the function.
327
+ * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
328
+ * @returns A function that you can export and deploy.
329
+
330
+ */
155
331
  export declare function onNewAnrIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
156
- export {};
@@ -1,6 +1,31 @@
1
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.
2
23
  Object.defineProperty(exports, "__esModule", { value: true });
3
24
  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;
25
+ /**
26
+ * Cloud functions to handle Crashlytics events from Firebase Alerts.
27
+ * @packageDocumentation
28
+ */
4
29
  const _1 = require(".");
5
30
  /** @internal */
6
31
  exports.newFatalIssueAlert = 'crashlytics.newFatalIssue';
@@ -14,26 +39,62 @@ exports.stabilityDigestAlert = 'crashlytics.stabilityDigest';
14
39
  exports.velocityAlert = 'crashlytics.velocity';
15
40
  /** @internal */
16
41
  exports.newAnrIssueAlert = 'crashlytics.newAnrIssue';
42
+ /**
43
+ * Declares a function that can handle a new fatal issue published to Crashlytics.
44
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
45
+ * @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
46
+ * @returns A function that you can export and deploy.
47
+ */
17
48
  function onNewFatalIssuePublished(appIdOrOptsOrHandler, handler) {
18
49
  return onOperation(exports.newFatalIssueAlert, appIdOrOptsOrHandler, handler);
19
50
  }
20
51
  exports.onNewFatalIssuePublished = onNewFatalIssuePublished;
52
+ /**
53
+ * Declares a function that can handle a new non-fatal issue published to Crashlytics.
54
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
55
+ * @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
56
+ * @returns A function that you can export and deploy.
57
+ */
21
58
  function onNewNonfatalIssuePublished(appIdOrOptsOrHandler, handler) {
22
59
  return onOperation(exports.newNonfatalIssueAlert, appIdOrOptsOrHandler, handler);
23
60
  }
24
61
  exports.onNewNonfatalIssuePublished = onNewNonfatalIssuePublished;
62
+ /**
63
+ * Declares a function that can handle a regression alert published to Crashlytics.
64
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
65
+ * @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
66
+ * @returns A function that you can export and deploy.
67
+ */
25
68
  function onRegressionAlertPublished(appIdOrOptsOrHandler, handler) {
26
69
  return onOperation(exports.regressionAlert, appIdOrOptsOrHandler, handler);
27
70
  }
28
71
  exports.onRegressionAlertPublished = onRegressionAlertPublished;
72
+ /**
73
+ * Declares a function that can handle a stability digest published to Crashlytics.
74
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
75
+ * @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
76
+ * @returns A function that you can export and deploy.
77
+ */
29
78
  function onStabilityDigestPublished(appIdOrOptsOrHandler, handler) {
30
79
  return onOperation(exports.stabilityDigestAlert, appIdOrOptsOrHandler, handler);
31
80
  }
32
81
  exports.onStabilityDigestPublished = onStabilityDigestPublished;
82
+ /**
83
+ * Declares a function that can handle a velocity alert published to Crashlytics.
84
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
85
+ * @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
86
+ * @returns A function that you can export and deploy.
87
+ */
33
88
  function onVelocityAlertPublished(appIdOrOptsOrHandler, handler) {
34
89
  return onOperation(exports.velocityAlert, appIdOrOptsOrHandler, handler);
35
90
  }
36
91
  exports.onVelocityAlertPublished = onVelocityAlertPublished;
92
+ /**
93
+ * Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
94
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
95
+ * @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
96
+ * @returns A function that you can export and deploy.
97
+ */
37
98
  function onNewAnrIssuePublished(appIdOrOptsOrHandler, handler) {
38
99
  return onOperation(exports.newAnrIssueAlert, appIdOrOptsOrHandler, handler);
39
100
  }
@@ -54,8 +115,8 @@ function onOperation(alertType, appIdOrOptsOrHandler, handler) {
54
115
  }
55
116
  exports.onOperation = onOperation;
56
117
  /**
57
- * @internal
58
118
  * Helper function to parse the function opts and appId.
119
+ * @internal
59
120
  */
60
121
  function getOptsAndApp(appIdOrOpts) {
61
122
  let opts;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Cloud functions to handle events from Firebase Alerts.
3
+ * Subpackages give stronger typing to specific services which
4
+ * notify users via Firebase Alerts.
5
+ * @packageDocumentation
6
+ */
1
7
  import * as appDistribution from './appDistribution';
2
8
  import * as billing from './billing';
3
9
  import * as crashlytics from './crashlytics';
@@ -1,4 +1,25 @@
1
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.
2
23
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
24
  if (k2 === undefined) k2 = k;
4
25
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -15,6 +36,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
36
  };
16
37
  Object.defineProperty(exports, "__esModule", { value: true });
17
38
  exports.crashlytics = exports.billing = exports.appDistribution = void 0;
39
+ /**
40
+ * Cloud functions to handle events from Firebase Alerts.
41
+ * Subpackages give stronger typing to specific services which
42
+ * notify users via Firebase Alerts.
43
+ * @packageDocumentation
44
+ */
18
45
  const appDistribution = require("./appDistribution");
19
46
  exports.appDistribution = appDistribution;
20
47
  const billing = require("./billing");
@@ -0,0 +1,182 @@
1
+ import { Change } from '../../common/change';
2
+ import { DataSnapshot } from '../../common/providers/database';
3
+ import { CloudEvent, CloudFunction } from '../core';
4
+ import * as options from '../options';
5
+ export { DataSnapshot };
6
+ /** @hidden */
7
+ export interface RawRTDBCloudEventData {
8
+ ['@type']: 'type.googleapis.com/google.events.firebase.database.v1.ReferenceEventData';
9
+ data: any;
10
+ delta: any;
11
+ }
12
+ /** @hidden */
13
+ export interface RawRTDBCloudEvent extends CloudEvent<RawRTDBCloudEventData> {
14
+ firebasedatabasehost: string;
15
+ instance: string;
16
+ ref: string;
17
+ location: string;
18
+ }
19
+ /** A CloudEvent that contains a DataSnapshot or a Change<DataSnapshot> */
20
+ export interface DatabaseEvent<T> extends CloudEvent<T> {
21
+ /** The domain of the database instance */
22
+ firebaseDatabaseHost: string;
23
+ /** The instance ID portion of the fully qualified resource name */
24
+ instance: string;
25
+ /** The database reference path */
26
+ ref: string;
27
+ /** The location of the database */
28
+ location: string;
29
+ /**
30
+ * An object containing the values of the path patterns.
31
+ * Only named capture groups will be populated - {key}, {key=*}, {key=**}
32
+ */
33
+ params: Record<string, string>;
34
+ }
35
+ /** ReferenceOptions extend EventHandlerOptions with provided ref and optional instance */
36
+ export interface ReferenceOptions extends options.EventHandlerOptions {
37
+ /**
38
+ * Specify the handler to trigger on a database reference(s).
39
+ * This value can either be a single reference or a pattern.
40
+ * Examples: '/foo/bar', '/foo/{bar}'
41
+ */
42
+ ref: string;
43
+ /**
44
+ * Specify the handler to trigger on a database instance(s).
45
+ * If present, this value can either be a single instance or a pattern.
46
+ * Examples: 'my-instance-1', 'my-instance-*'
47
+ * Note: The capture syntax cannot be used for 'instance'.
48
+ */
49
+ instance?: string;
50
+ /**
51
+ * Region where functions should be deployed.
52
+ */
53
+ region?: options.SupportedRegion | string;
54
+ /**
55
+ * Amount of memory to allocate to a function.
56
+ * A value of null restores the defaults of 256MB.
57
+ */
58
+ memory?: options.MemoryOption | null;
59
+ /**
60
+ * Timeout for the function in sections, possible values are 0 to 540.
61
+ * HTTPS functions can specify a higher timeout.
62
+ * A value of null restores the default of 60s
63
+ * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
64
+ * function depends on the type of function: Event handling functions have a
65
+ * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
66
+ * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
67
+ * timeout of 1,800s (30 minutes)
68
+ */
69
+ timeoutSeconds?: number | null;
70
+ /**
71
+ * Min number of actual instances to be running at a given time.
72
+ * Instances will be billed for memory allocation and 10% of CPU allocation
73
+ * while idle.
74
+ * A value of null restores the default min instances.
75
+ */
76
+ minInstances?: number | null;
77
+ /**
78
+ * Max number of instances to be running in parallel.
79
+ * A value of null restores the default max instances.
80
+ */
81
+ maxInstances?: number | null;
82
+ /**
83
+ * Number of requests a function can serve at once.
84
+ * Can only be applied to functions running on Cloud Functions v2.
85
+ * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
86
+ * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
87
+ * The maximum value for concurrency is 1,000.
88
+ */
89
+ concurrency?: number | null;
90
+ /**
91
+ * Fractional number of CPUs to allocate to a function.
92
+ * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
93
+ * This is different from the defaults when using the gcloud utility and is different from
94
+ * the fixed amount assigned in Google Cloud Functions generation 1.
95
+ * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
96
+ * to the value "gcf_gen1"
97
+ */
98
+ cpu?: number | 'gcf_gen1';
99
+ /**
100
+ * Connect cloud function to specified VPC connector.
101
+ * A value of null removes the VPC connector
102
+ */
103
+ vpcConnector?: string | null;
104
+ /**
105
+ * Egress settings for VPC connector.
106
+ * A value of null turns off VPC connector egress settings
107
+ */
108
+ vpcConnectorEgressSettings?: options.VpcEgressSetting | null;
109
+ /**
110
+ * Specific service account for the function to run as.
111
+ * A value of null restores the default service account.
112
+ */
113
+ serviceAccount?: string | null;
114
+ /**
115
+ * Ingress settings which control where this function can be called from.
116
+ * A value of null turns off ingress settings.
117
+ */
118
+ ingressSettings?: options.IngressSetting | null;
119
+ /**
120
+ * User labels to set on the function.
121
+ */
122
+ labels?: Record<string, string>;
123
+ secrets?: string[];
124
+ /** Whether failed executions should be delivered again. */
125
+ retry?: boolean;
126
+ }
127
+ /**
128
+ * Event handler which triggers when data is created, updated, or deleted in Realtime Database.
129
+ *
130
+ * @param reference - The database reference path to trigger on.
131
+ * @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
132
+ */
133
+ export declare function onValueWritten(reference: string, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
134
+ /**
135
+ * Event handler which triggers when data is created, updated, or deleted in Realtime Database.
136
+ *
137
+ * @param opts - Options that can be set on an individual event-handling function.
138
+ * @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
139
+ */
140
+ export declare function onValueWritten(opts: ReferenceOptions, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
141
+ /**
142
+ * Event handler which triggers when data is created in Realtime Database.
143
+ *
144
+ * @param reference - The database reference path to trigger on.
145
+ * @param handler - Event handler which is run every time a Realtime Database create occurs.
146
+ */
147
+ export declare function onValueCreated(reference: string, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
148
+ /**
149
+ * Event handler which triggers when data is created in Realtime Database.
150
+ *
151
+ * @param opts - Options that can be set on an individual event-handling function.
152
+ * @param handler - Event handler which is run every time a Realtime Database create occurs.
153
+ */
154
+ export declare function onValueCreated(opts: ReferenceOptions, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
155
+ /**
156
+ * Event handler which triggers when data is updated in Realtime Database.
157
+ *
158
+ * @param reference - The database reference path to trigger on.
159
+ * @param handler - Event handler which is run every time a Realtime Database update occurs.
160
+ */
161
+ export declare function onValueUpdated(reference: string, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
162
+ /**
163
+ * Event handler which triggers when data is updated in Realtime Database.
164
+ *
165
+ * @param opts - Options that can be set on an individual event-handling function.
166
+ * @param handler - Event handler which is run every time a Realtime Database update occurs.
167
+ */
168
+ export declare function onValueUpdated(opts: ReferenceOptions, handler: (event: DatabaseEvent<Change<DataSnapshot>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>>>;
169
+ /**
170
+ * Event handler which triggers when data is deleted in Realtime Database.
171
+ *
172
+ * @param reference - The database reference path to trigger on.
173
+ * @param handler - Event handler which is run every time a Realtime Database deletion occurs.
174
+ */
175
+ export declare function onValueDeleted(reference: string, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;
176
+ /**
177
+ * Event handler which triggers when data is deleted in Realtime Database.
178
+ *
179
+ * @param opts - Options that can be set on an individual event-handling function.
180
+ * @param handler - Event handler which is run every time a Realtime Database deletion occurs.
181
+ */
182
+ export declare function onValueDeleted(opts: ReferenceOptions, handler: (event: DatabaseEvent<DataSnapshot>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot>>;