firebase-functions 3.22.0 → 3.24.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 (39) hide show
  1. package/lib/bin/firebase-functions.js +2 -1
  2. package/lib/common/providers/identity.js +0 -3
  3. package/lib/common/providers/tasks.d.ts +8 -7
  4. package/lib/common/timezone.d.ts +2 -0
  5. package/lib/common/timezone.js +543 -0
  6. package/lib/function-configuration.d.ts +6 -5
  7. package/lib/runtime/loader.js +6 -1
  8. package/lib/runtime/manifest.d.ts +19 -16
  9. package/lib/runtime/manifest.js +24 -0
  10. package/lib/v2/index.d.ts +2 -1
  11. package/lib/v2/index.js +3 -1
  12. package/lib/v2/options.d.ts +16 -6
  13. package/lib/v2/options.js +2 -2
  14. package/lib/v2/params/index.d.ts +14 -12
  15. package/lib/v2/params/index.js +25 -15
  16. package/lib/v2/params/types.d.ts +95 -22
  17. package/lib/v2/params/types.js +127 -67
  18. package/lib/v2/providers/alerts/alerts.d.ts +7 -6
  19. package/lib/v2/providers/alerts/alerts.js +17 -2
  20. package/lib/v2/providers/alerts/appDistribution.d.ts +50 -5
  21. package/lib/v2/providers/alerts/appDistribution.js +24 -2
  22. package/lib/v2/providers/alerts/billing.d.ts +1 -1
  23. package/lib/v2/providers/alerts/billing.js +3 -7
  24. package/lib/v2/providers/alerts/crashlytics.d.ts +7 -6
  25. package/lib/v2/providers/alerts/crashlytics.js +3 -7
  26. package/lib/v2/providers/alerts/index.d.ts +2 -1
  27. package/lib/v2/providers/alerts/index.js +3 -1
  28. package/lib/v2/providers/alerts/performance.d.ts +60 -0
  29. package/lib/v2/providers/alerts/performance.js +81 -0
  30. package/lib/v2/providers/database.d.ts +7 -6
  31. package/lib/v2/providers/eventarc.d.ts +6 -5
  32. package/lib/v2/providers/https.d.ts +6 -5
  33. package/lib/v2/providers/identity.d.ts +8 -7
  34. package/lib/v2/providers/pubsub.d.ts +6 -5
  35. package/lib/v2/providers/scheduler.d.ts +63 -0
  36. package/lib/v2/providers/scheduler.js +98 -0
  37. package/lib/v2/providers/storage.d.ts +6 -5
  38. package/lib/v2/providers/tasks.d.ts +7 -6
  39. package/package.json +17 -7
@@ -21,90 +21,169 @@
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.JSONParam = exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.StringParam = exports.Param = void 0;
25
- class Param {
24
+ exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.StringParam = exports.SecretParam = exports.Param = exports.CompareExpression = exports.TernaryExpression = exports.Expression = void 0;
25
+ /*
26
+ * A CEL expression which can be evaluated during function deployment, and
27
+ * resolved to a value of the generic type parameter: i.e, you can pass
28
+ * an Expression<number> as the value of an option that normally accepts numbers.
29
+ */
30
+ class Expression {
31
+ // Returns the Expression's runtime value, based on the CLI's resolution of params.
32
+ value() {
33
+ throw new Error('Not implemented');
34
+ }
35
+ // Returns the Expression's representation as a braced CEL expression.
36
+ toCEL() {
37
+ return `{{ ${this.toString()} }}`;
38
+ }
39
+ toJSON() {
40
+ return this.toString();
41
+ }
42
+ }
43
+ exports.Expression = Expression;
44
+ function quoteIfString(literal) {
45
+ // TODO(vsfan@): CEL's string escape semantics are slightly different than Javascript's, what do we do here?
46
+ return typeof literal === 'string' ? `"${literal}"` : literal;
47
+ }
48
+ /**
49
+ * A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
50
+ */
51
+ class TernaryExpression extends Expression {
52
+ constructor(test, ifTrue, ifFalse) {
53
+ super();
54
+ this.test = test;
55
+ this.ifTrue = ifTrue;
56
+ this.ifFalse = ifFalse;
57
+ this.ifTrue = ifTrue;
58
+ this.ifFalse = ifFalse;
59
+ }
60
+ value() {
61
+ return !!this.test.value ? this.ifTrue : this.ifFalse;
62
+ }
63
+ toString() {
64
+ return `${this.test} ? ${quoteIfString(this.ifTrue)} : ${quoteIfString(this.ifFalse)}`;
65
+ }
66
+ }
67
+ exports.TernaryExpression = TernaryExpression;
68
+ /**
69
+ * A CEL expression that evaluates to boolean true or false based on a comparison
70
+ * between the value of another expression and a literal of that same type.
71
+ */
72
+ class CompareExpression extends Expression {
73
+ constructor(cmp, lhs, rhs) {
74
+ super();
75
+ this.cmp = cmp;
76
+ this.lhs = lhs;
77
+ this.rhs = rhs;
78
+ }
79
+ value() {
80
+ const left = this.lhs.value();
81
+ switch (this.cmp) {
82
+ case '==':
83
+ return left === this.rhs;
84
+ case '>':
85
+ return left > this.rhs;
86
+ case '>=':
87
+ return left >= this.rhs;
88
+ case '<':
89
+ return left < this.rhs;
90
+ case '<=':
91
+ return left <= this.rhs;
92
+ default:
93
+ throw new Error('Unknown comparator ' + this.cmp);
94
+ }
95
+ }
96
+ toString() {
97
+ return `${this.lhs} ${this.cmp} ${quoteIfString(this.rhs)}`;
98
+ }
99
+ then(ifTrue, ifFalse) {
100
+ return new TernaryExpression(this, ifTrue, ifFalse);
101
+ }
102
+ }
103
+ exports.CompareExpression = CompareExpression;
104
+ class Param extends Expression {
26
105
  constructor(name, options = {}) {
106
+ super();
27
107
  this.name = name;
28
108
  this.options = options;
29
109
  }
30
- get rawValue() {
31
- return process.env[this.name];
110
+ value() {
111
+ throw new Error('Not implemented');
32
112
  }
33
- get value() {
34
- return this.rawValue || this.options.default || '';
113
+ cmp(cmp, rhs) {
114
+ return new CompareExpression(cmp, this, rhs);
35
115
  }
36
- toString() {
37
- return `{{params.${this.name}}}`;
116
+ equals(rhs) {
117
+ return this.cmp('==', rhs);
38
118
  }
39
- toJSON() {
40
- return this.toString();
119
+ toString() {
120
+ return `params.${this.name}`;
41
121
  }
42
122
  toSpec() {
43
- var _a, _b;
44
123
  const out = {
45
124
  name: this.name,
46
125
  ...this.options,
47
- valueType: this.constructor.valueType,
126
+ type: this.constructor.type,
48
127
  };
49
- if (this.options.default && typeof this.options.default !== 'string') {
50
- out.default = (_b = (_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString) === null || _b === void 0 ? void 0 : _b.call(_a);
51
- }
52
128
  return out;
53
129
  }
54
130
  }
55
131
  exports.Param = Param;
56
- Param.valueType = 'string';
132
+ Param.type = 'string';
133
+ class SecretParam {
134
+ constructor(name) {
135
+ this.name = name;
136
+ }
137
+ value() {
138
+ return process.env[this.name] || '';
139
+ }
140
+ toSpec() {
141
+ return {
142
+ type: 'secret',
143
+ name: this.name,
144
+ };
145
+ }
146
+ }
147
+ exports.SecretParam = SecretParam;
148
+ SecretParam.type = 'secret';
57
149
  class StringParam extends Param {
150
+ value() {
151
+ return process.env[this.name] || '';
152
+ }
58
153
  }
59
154
  exports.StringParam = StringParam;
60
155
  class IntParam extends Param {
61
- get value() {
62
- var _a;
63
- const intVal = parseInt(this.rawValue || ((_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString()) || '0', 10);
64
- if (Number.isNaN(intVal)) {
65
- throw new Error(`unable to load param "${this.name}", value ${JSON.stringify(this.rawValue)} could not be parsed as integer`);
66
- }
67
- return intVal;
156
+ value() {
157
+ return parseInt(process.env[this.name] || '0', 10) || 0;
68
158
  }
69
159
  }
70
160
  exports.IntParam = IntParam;
71
- IntParam.valueType = 'int';
161
+ IntParam.type = 'int';
72
162
  class FloatParam extends Param {
73
- get value() {
74
- var _a;
75
- const floatVal = parseFloat(this.rawValue || ((_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString()) || '0');
76
- if (Number.isNaN(floatVal)) {
77
- throw new Error(`unable to load param "${this.name}", value ${JSON.stringify(this.rawValue)} could not be parsed as float`);
78
- }
79
- return floatVal;
163
+ value() {
164
+ return parseFloat(process.env[this.name] || '0') || 0;
80
165
  }
81
166
  }
82
167
  exports.FloatParam = FloatParam;
83
- FloatParam.valueType = 'float';
168
+ FloatParam.type = 'float';
84
169
  class BooleanParam extends Param {
85
- get value() {
86
- var _a;
87
- const lowerVal = (this.rawValue ||
88
- ((_a = this.options.default) === null || _a === void 0 ? void 0 : _a.toString()) ||
89
- 'false').toLowerCase();
90
- if (!['true', 'y', 'yes', '1', 'false', 'n', 'no', '0'].includes(lowerVal)) {
91
- throw new Error(`unable to load param "${this.name}", value ${JSON.stringify(this.rawValue)} could not be parsed as boolean`);
92
- }
93
- return ['true', 'y', 'yes', '1'].includes(lowerVal);
170
+ value() {
171
+ return !!process.env[this.name];
172
+ }
173
+ then(ifTrue, ifFalse) {
174
+ return new TernaryExpression(this, ifTrue, ifFalse);
94
175
  }
95
176
  }
96
177
  exports.BooleanParam = BooleanParam;
97
- BooleanParam.valueType = 'boolean';
178
+ BooleanParam.type = 'boolean';
98
179
  class ListParam extends Param {
99
- get value() {
100
- return typeof this.rawValue === 'string'
101
- ? this.rawValue.split(/, ?/)
102
- : this.options.default || [];
180
+ value() {
181
+ throw new Error('Not implemented');
103
182
  }
104
183
  toSpec() {
105
184
  const out = {
106
185
  name: this.name,
107
- valueType: 'list',
186
+ type: 'list',
108
187
  ...this.options,
109
188
  };
110
189
  if (this.options.default && this.options.default.length > 0) {
@@ -114,23 +193,4 @@ class ListParam extends Param {
114
193
  }
115
194
  }
116
195
  exports.ListParam = ListParam;
117
- ListParam.valueType = 'list';
118
- class JSONParam extends Param {
119
- get value() {
120
- var _a;
121
- if (this.rawValue) {
122
- try {
123
- return JSON.parse(this.rawValue);
124
- }
125
- catch (e) {
126
- throw new Error(`unable to load param "${this.name}", value ${this.rawValue} could not be parsed as JSON: ${e.message}`);
127
- }
128
- }
129
- else if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('default')) {
130
- return this.options.default;
131
- }
132
- return {};
133
- }
134
- }
135
- exports.JSONParam = JSONParam;
136
- JSONParam.valueType = 'json';
196
+ ListParam.type = 'list';
@@ -1,5 +1,6 @@
1
1
  import { CloudEvent, CloudFunction } from '../../core';
2
2
  import * as options from '../../options';
3
+ import { Expression } from '../../params';
3
4
  /**
4
5
  * The CloudEvent data emitted by Firebase Alerts.
5
6
  * @typeParam T - the payload type that is expected for this alert.
@@ -28,7 +29,7 @@ export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
28
29
  data: FirebaseAlertData<T>;
29
30
  }
30
31
  /** The underlying alert type of the Firebase Alerts provider. */
31
- export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNonfatalIssue' | 'crashlytics.regression' | 'crashlytics.stabilityDigest' | 'crashlytics.velocity' | 'crashlytics.newAnrIssue' | 'billing.planUpdate' | 'billing.automatedPlanUpdate' | 'appDistribution.newTesterIosDevice' | string;
32
+ export declare type AlertType = 'crashlytics.newFatalIssue' | 'crashlytics.newNonfatalIssue' | 'crashlytics.regression' | 'crashlytics.stabilityDigest' | 'crashlytics.velocity' | 'crashlytics.newAnrIssue' | 'billing.planUpdate' | 'billing.automatedPlanUpdate' | 'appDistribution.newTesterIosDevice' | 'appDistribution.inAppFeedback' | 'performance.threshold' | string;
32
33
  /**
33
34
  * Configuration for Firebase Alert functions.
34
35
  */
@@ -45,7 +46,7 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
45
46
  * Amount of memory to allocate to a function.
46
47
  * A value of null restores the defaults of 256MB.
47
48
  */
48
- memory?: options.MemoryOption | null;
49
+ memory?: options.MemoryOption | Expression<number> | null;
49
50
  /**
50
51
  * Timeout for the function in sections, possible values are 0 to 540.
51
52
  * HTTPS functions can specify a higher timeout.
@@ -56,19 +57,19 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
56
57
  * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
57
58
  * timeout of 1,800s (30 minutes)
58
59
  */
59
- timeoutSeconds?: number | null;
60
+ timeoutSeconds?: number | Expression<number> | null;
60
61
  /**
61
62
  * Min number of actual instances to be running at a given time.
62
63
  * Instances will be billed for memory allocation and 10% of CPU allocation
63
64
  * while idle.
64
65
  * A value of null restores the default min instances.
65
66
  */
66
- minInstances?: number | null;
67
+ minInstances?: number | Expression<number> | null;
67
68
  /**
68
69
  * Max number of instances to be running in parallel.
69
70
  * A value of null restores the default max instances.
70
71
  */
71
- maxInstances?: number | null;
72
+ maxInstances?: number | Expression<number> | null;
72
73
  /**
73
74
  * Number of requests a function can serve at once.
74
75
  * Can only be applied to functions running on Cloud Functions v2.
@@ -76,7 +77,7 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
76
77
  * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
77
78
  * The maximum value for concurrency is 1,000.
78
79
  */
79
- concurrency?: number | null;
80
+ concurrency?: number | Expression<number> | null;
80
81
  /**
81
82
  * Fractional number of CPUs to allocate to a function.
82
83
  * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
@@ -21,14 +21,14 @@
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.getOptsAndAlertTypeAndApp = exports.getEndpointAnnotation = exports.onAlertPublished = exports.eventType = void 0;
24
+ exports.convertAlertAndApp = exports.getOptsAndAlertTypeAndApp = exports.getEndpointAnnotation = exports.onAlertPublished = exports.eventType = void 0;
25
25
  const options = require("../../options");
26
26
  /** @internal */
27
27
  exports.eventType = 'google.firebase.firebasealerts.alerts.v1.published';
28
28
  function onAlertPublished(alertTypeOrOpts, handler) {
29
29
  const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
30
30
  const func = (raw) => {
31
- return handler(raw);
31
+ return handler(convertAlertAndApp(raw));
32
32
  };
33
33
  func.run = handler;
34
34
  func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
@@ -86,3 +86,18 @@ function getOptsAndAlertTypeAndApp(alertTypeOrOpts) {
86
86
  return [opts, alertType, appId];
87
87
  }
88
88
  exports.getOptsAndAlertTypeAndApp = getOptsAndAlertTypeAndApp;
89
+ /**
90
+ * Helper function to covert alert type & app id in the CloudEvent to camel case.
91
+ * @internal
92
+ */
93
+ function convertAlertAndApp(raw) {
94
+ const event = { ...raw };
95
+ if ('alerttype' in event) {
96
+ event.alertType = event.alerttype;
97
+ }
98
+ if ('appid' in event) {
99
+ event.appId = event.appid;
100
+ }
101
+ return event;
102
+ }
103
+ exports.convertAlertAndApp = convertAlertAndApp;
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { CloudEvent, CloudFunction } from '../../core';
6
6
  import * as options from '../../options';
7
+ import { Expression } from '../../params';
7
8
  import { FirebaseAlertData } from './alerts';
8
9
  /**
9
10
  * The internal payload object for adding a new tester device to app distribution.
@@ -20,6 +21,30 @@ export interface NewTesterDevicePayload {
20
21
  /** The device ID */
21
22
  testerDeviceIdentifier: string;
22
23
  }
24
+ /**
25
+ * The internal payload object for receiving in-app feedback from a tester.
26
+ * Payload is wrapped inside a `FirebaseAlertData` object.
27
+ */
28
+ export interface InAppFeedbackPayload {
29
+ ['@type']: 'type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroInAppFeedbackPayload';
30
+ /** Resource name. Format: `projects/{project_number}/apps/{app_id}/releases/{release_id}/feedbackReports/{feedback_id}` */
31
+ feedbackReport: string;
32
+ /** Deep link back to the Firebase console. */
33
+ feedbackConsoleUri: string;
34
+ /** Name of the tester */
35
+ testerName?: string;
36
+ /** Email of the tester */
37
+ testerEmail: string;
38
+ /**
39
+ * Version consisting of `versionName` and `versionCode` for Android and
40
+ * `CFBundleShortVersionString` and `CFBundleVersion` for iOS.
41
+ */
42
+ appVersion: string;
43
+ /** Text entered by the tester */
44
+ text: string;
45
+ /** URI to download screenshot. This URI is fast expiring. */
46
+ screenshotUri?: string;
47
+ }
23
48
  /**
24
49
  * A custom CloudEvent for Firebase Alerts (with custom extension attributes).
25
50
  * @typeParam T - the data type for app distribution alerts that is wrapped in a `FirebaseAlertData` object.
@@ -44,7 +69,7 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
44
69
  * Amount of memory to allocate to a function.
45
70
  * A value of null restores the defaults of 256MB.
46
71
  */
47
- memory?: options.MemoryOption | null;
72
+ memory?: options.MemoryOption | Expression<number> | null;
48
73
  /**
49
74
  * Timeout for the function in sections, possible values are 0 to 540.
50
75
  * HTTPS functions can specify a higher timeout.
@@ -55,19 +80,19 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
55
80
  * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
56
81
  * timeout of 1,800s (30 minutes)
57
82
  */
58
- timeoutSeconds?: number | null;
83
+ timeoutSeconds?: number | Expression<number> | null;
59
84
  /**
60
85
  * Min number of actual instances to be running at a given time.
61
86
  * Instances will be billed for memory allocation and 10% of CPU allocation
62
87
  * while idle.
63
88
  * A value of null restores the default min instances.
64
89
  */
65
- minInstances?: number | null;
90
+ minInstances?: number | Expression<number> | null;
66
91
  /**
67
92
  * Max number of instances to be running in parallel.
68
93
  * A value of null restores the default max instances.
69
94
  */
70
- maxInstances?: number | null;
95
+ maxInstances?: number | Expression<number> | null;
71
96
  /**
72
97
  * Number of requests a function can serve at once.
73
98
  * Can only be applied to functions running on Cloud Functions v2.
@@ -75,7 +100,7 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
75
100
  * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
76
101
  * The maximum value for concurrency is 1,000.
77
102
  */
78
- concurrency?: number | null;
103
+ concurrency?: number | Expression<number> | null;
79
104
  /**
80
105
  * Fractional number of CPUs to allocate to a function.
81
106
  * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
@@ -133,3 +158,23 @@ export declare function onNewTesterIosDevicePublished(appId: string, handler: (e
133
158
  * @returns A function that you can export and deploy.
134
159
  */
135
160
  export declare function onNewTesterIosDevicePublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
161
+ /**
162
+ * Declares a function that can handle receiving new in-app feedback from a tester.
163
+ * @param handler - Event handler which is run every time new feedback is received.
164
+ * @returns A function that you can export and deploy.
165
+ */
166
+ export declare function onInAppFeedbackPublished(handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
167
+ /**
168
+ * Declares a function that can handle receiving new in-app feedback from a tester.
169
+ * @param appId - A specific application the handler will trigger on.
170
+ * @param handler - Event handler which is run every time new feedback is received.
171
+ * @returns A function that you can export and deploy.
172
+ */
173
+ export declare function onInAppFeedbackPublished(appId: string, handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
174
+ /**
175
+ * Declares a function that can handle receiving new in-app feedback from a tester.
176
+ * @param opts - Options that can be set on the function.
177
+ * @param handler - Event handler which is run every time new feedback is received.
178
+ * @returns A function that you can export and deploy.
179
+ */
180
+ export declare function onInAppFeedbackPublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
@@ -21,10 +21,12 @@
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.getOptsAndApp = exports.onNewTesterIosDevicePublished = exports.newTesterIosDeviceAlert = void 0;
24
+ exports.getOptsAndApp = exports.onInAppFeedbackPublished = exports.onNewTesterIosDevicePublished = exports.inAppFeedbackAlert = exports.newTesterIosDeviceAlert = void 0;
25
25
  const alerts_1 = require("./alerts");
26
26
  /** @internal */
27
27
  exports.newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice';
28
+ /** @internal */
29
+ exports.inAppFeedbackAlert = 'appDistribution.inAppFeedback';
28
30
  /**
29
31
  * Declares a function that can handle adding a new tester iOS device.
30
32
  * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
@@ -38,13 +40,33 @@ function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
38
40
  }
39
41
  const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
40
42
  const func = (raw) => {
41
- return handler(raw);
43
+ return handler((0, alerts_1.convertAlertAndApp)(raw));
42
44
  };
43
45
  func.run = handler;
44
46
  func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.newTesterIosDeviceAlert, appId);
45
47
  return func;
46
48
  }
47
49
  exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
50
+ /**
51
+ * Declares a function that can handle receiving new in-app feedback from a tester.
52
+ * @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
53
+ * @param handler - Event handler which is run every time new feedback is received.
54
+ * @returns A function that you can export and deploy.
55
+ */
56
+ function onInAppFeedbackPublished(appIdOrOptsOrHandler, handler) {
57
+ if (typeof appIdOrOptsOrHandler === 'function') {
58
+ handler = appIdOrOptsOrHandler;
59
+ appIdOrOptsOrHandler = {};
60
+ }
61
+ const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
62
+ const func = (raw) => {
63
+ return handler((0, alerts_1.convertAlertAndApp)(raw));
64
+ };
65
+ func.run = handler;
66
+ func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.inAppFeedbackAlert, appId);
67
+ return func;
68
+ }
69
+ exports.onInAppFeedbackPublished = onInAppFeedbackPublished;
48
70
  /**
49
71
  * Helper function to parse the function opts and appId.
50
72
  * @internal
@@ -2,9 +2,9 @@
2
2
  * Cloud functions to handle billing events from Firebase Alerts.
3
3
  * @packageDocumentation
4
4
  */
5
- import { FirebaseAlertData } from '.';
6
5
  import { CloudEvent, CloudFunction } from '../../core';
7
6
  import * as options from '../../options';
7
+ import { FirebaseAlertData } from './alerts';
8
8
  /**
9
9
  * The internal payload object for billing plan updates.
10
10
  * Payload is wrapped inside a `FirebaseAlertData` object.
@@ -22,11 +22,7 @@
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.onOperation = exports.onPlanAutomatedUpdatePublished = exports.onPlanUpdatePublished = exports.planAutomatedUpdateAlert = exports.planUpdateAlert = void 0;
25
- /**
26
- * Cloud functions to handle billing events from Firebase Alerts.
27
- * @packageDocumentation
28
- */
29
- const _1 = require(".");
25
+ const alerts_1 = require("./alerts");
30
26
  /** @internal */
31
27
  exports.planUpdateAlert = 'billing.planUpdate';
32
28
  /** @internal */
@@ -58,10 +54,10 @@ function onOperation(alertType, optsOrHandler, handler) {
58
54
  optsOrHandler = {};
59
55
  }
60
56
  const func = (raw) => {
61
- return handler(raw);
57
+ return handler((0, alerts_1.convertAlertAndApp)(raw));
62
58
  };
63
59
  func.run = handler;
64
- func.__endpoint = (0, _1.getEndpointAnnotation)(optsOrHandler, alertType);
60
+ func.__endpoint = (0, alerts_1.getEndpointAnnotation)(optsOrHandler, alertType);
65
61
  return func;
66
62
  }
67
63
  exports.onOperation = onOperation;
@@ -2,9 +2,10 @@
2
2
  * Cloud functions to handle Crashlytics events from Firebase Alerts.
3
3
  * @packageDocumentation
4
4
  */
5
- import { FirebaseAlertData } from '.';
6
5
  import { CloudEvent, CloudFunction } from '../../core';
7
6
  import * as options from '../../options';
7
+ import { Expression } from '../../params';
8
+ import { FirebaseAlertData } from './alerts';
8
9
  /** Generic Crashlytics issue interface */
9
10
  export interface Issue {
10
11
  /** The ID of the Crashlytics issue */
@@ -134,7 +135,7 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
134
135
  * Amount of memory to allocate to a function.
135
136
  * A value of null restores the defaults of 256MB.
136
137
  */
137
- memory?: options.MemoryOption | null;
138
+ memory?: options.MemoryOption | Expression<number> | null;
138
139
  /**
139
140
  * Timeout for the function in sections, possible values are 0 to 540.
140
141
  * HTTPS functions can specify a higher timeout.
@@ -145,19 +146,19 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
145
146
  * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
146
147
  * timeout of 1,800s (30 minutes)
147
148
  */
148
- timeoutSeconds?: number | null;
149
+ timeoutSeconds?: number | Expression<number> | null;
149
150
  /**
150
151
  * Min number of actual instances to be running at a given time.
151
152
  * Instances will be billed for memory allocation and 10% of CPU allocation
152
153
  * while idle.
153
154
  * A value of null restores the default min instances.
154
155
  */
155
- minInstances?: number | null;
156
+ minInstances?: number | Expression<number> | null;
156
157
  /**
157
158
  * Max number of instances to be running in parallel.
158
159
  * A value of null restores the default max instances.
159
160
  */
160
- maxInstances?: number | null;
161
+ maxInstances?: number | Expression<number> | null;
161
162
  /**
162
163
  * Number of requests a function can serve at once.
163
164
  * Can only be applied to functions running on Cloud Functions v2.
@@ -165,7 +166,7 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
165
166
  * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
166
167
  * The maximum value for concurrency is 1,000.
167
168
  */
168
- concurrency?: number | null;
169
+ concurrency?: number | Expression<number> | null;
169
170
  /**
170
171
  * Fractional number of CPUs to allocate to a function.
171
172
  * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
@@ -22,11 +22,7 @@
22
22
  // SOFTWARE.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
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
- */
29
- const _1 = require(".");
25
+ const alerts_1 = require("./alerts");
30
26
  /** @internal */
31
27
  exports.newFatalIssueAlert = 'crashlytics.newFatalIssue';
32
28
  /** @internal */
@@ -107,10 +103,10 @@ function onOperation(alertType, appIdOrOptsOrHandler, handler) {
107
103
  }
108
104
  const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
109
105
  const func = (raw) => {
110
- return handler(raw);
106
+ return handler((0, alerts_1.convertAlertAndApp)(raw));
111
107
  };
112
108
  func.run = handler;
113
- func.__endpoint = (0, _1.getEndpointAnnotation)(opts, alertType, appId);
109
+ func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, alertType, appId);
114
110
  return func;
115
111
  }
116
112
  exports.onOperation = onOperation;
@@ -7,5 +7,6 @@
7
7
  import * as appDistribution from './appDistribution';
8
8
  import * as billing from './billing';
9
9
  import * as crashlytics from './crashlytics';
10
- export { appDistribution, billing, crashlytics };
10
+ import * as performance from './performance';
11
+ export { appDistribution, billing, crashlytics, performance };
11
12
  export * from './alerts';
@@ -35,7 +35,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
35
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.crashlytics = exports.billing = exports.appDistribution = void 0;
38
+ exports.performance = exports.crashlytics = exports.billing = exports.appDistribution = void 0;
39
39
  /**
40
40
  * Cloud functions to handle events from Firebase Alerts.
41
41
  * Subpackages give stronger typing to specific services which
@@ -48,4 +48,6 @@ const billing = require("./billing");
48
48
  exports.billing = billing;
49
49
  const crashlytics = require("./crashlytics");
50
50
  exports.crashlytics = crashlytics;
51
+ const performance = require("./performance");
52
+ exports.performance = performance;
51
53
  __exportStar(require("./alerts"), exports);