link
This commit is contained in:
142
node_modules/firebase-functions/lib/v2/providers/alerts/alerts.d.ts
generated
vendored
Normal file
142
node_modules/firebase-functions/lib/v2/providers/alerts/alerts.d.ts
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
import { ResetValue } from "../../../common/options";
|
||||
import { CloudEvent, CloudFunction } from "../../core";
|
||||
import { Expression } from "../../../params";
|
||||
import * as options from "../../options";
|
||||
import { SecretParam } from "../../../params/types";
|
||||
/**
|
||||
* The CloudEvent data emitted by Firebase Alerts.
|
||||
* @typeParam T - the payload type that is expected for this alert.
|
||||
*/
|
||||
export interface FirebaseAlertData<T = any> {
|
||||
/** Time that the event has created. */
|
||||
createTime: string;
|
||||
/** Time that the event has ended. Optional, only present for ongoing alerts. */
|
||||
endTime: string;
|
||||
/** Payload of the event, which includes the details of the specific alert. */
|
||||
payload: T;
|
||||
}
|
||||
/**
|
||||
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
|
||||
* @typeParam T - the data type for this alert that is wrapped in a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface AlertEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
||||
/** The type of the alerts that got triggered. */
|
||||
alertType: string;
|
||||
/**
|
||||
* The Firebase App ID that’s associated with the alert. This is optional,
|
||||
* and only present when the alert is targeting at a specific Firebase App.
|
||||
*/
|
||||
appId?: string;
|
||||
/** Data for an `AlertEvent` is a `FirebaseAlertData` object with a given payload. */
|
||||
data: FirebaseAlertData<T>;
|
||||
}
|
||||
/** The underlying alert type of the Firebase Alerts provider. */
|
||||
export type AlertType = "crashlytics.newFatalIssue" | "crashlytics.newNonfatalIssue" | "crashlytics.regression" | "crashlytics.stabilityDigest" | "crashlytics.velocity" | "crashlytics.newAnrIssue" | "billing.planUpdate" | "billing.planAutomatedUpdate" | "appDistribution.newTesterIosDevice" | "appDistribution.inAppFeedback" | "performance.threshold" | string;
|
||||
/**
|
||||
* Configuration for Firebase Alert functions.
|
||||
*/
|
||||
export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
||||
/** Scope the handler to trigger on an alert type. */
|
||||
alertType: AlertType;
|
||||
/** Scope the function to trigger on a specific application. */
|
||||
appId?: string;
|
||||
/**
|
||||
* If true, do not deploy or emulate this function.
|
||||
*/
|
||||
omit?: boolean | Expression<boolean>;
|
||||
/**
|
||||
* Region where functions should be deployed.
|
||||
*/
|
||||
region?: options.SupportedRegion | string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Amount of memory to allocate to a function.
|
||||
* A value of null restores the defaults of 256MB.
|
||||
*/
|
||||
memory?: options.MemoryOption | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Timeout for the function in seconds, possible values are 0 to 540.
|
||||
* HTTPS functions can specify a higher timeout.
|
||||
* A value of null restores the default of 60s
|
||||
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
||||
* function depends on the type of function: Event handling functions have a
|
||||
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
||||
* maximum timeout of 3,600s (1 hour). Task queue functions have a maximum
|
||||
* timeout of 1,800s (30 minutes)
|
||||
*/
|
||||
timeoutSeconds?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Min number of actual instances to be running at a given time.
|
||||
* Instances will be billed for memory allocation and 10% of CPU allocation
|
||||
* while idle.
|
||||
* A value of null restores the default min instances.
|
||||
*/
|
||||
minInstances?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Max number of instances to be running in parallel.
|
||||
* A value of null restores the default max instances.
|
||||
*/
|
||||
maxInstances?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Number of requests a function can serve at once.
|
||||
* Can only be applied to functions running on Cloud Functions v2.
|
||||
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
||||
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
||||
* The maximum value for concurrency is 1,000.
|
||||
*/
|
||||
concurrency?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Fractional number of CPUs to allocate to a function.
|
||||
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
||||
* This is different from the defaults when using the gcloud utility and is different from
|
||||
* the fixed amount assigned in Google Cloud Functions generation 1.
|
||||
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
||||
* to the value "gcf_gen1"
|
||||
*/
|
||||
cpu?: number | "gcf_gen1";
|
||||
/**
|
||||
* Connect cloud function to specified VPC connector.
|
||||
* A value of null removes the VPC connector
|
||||
*/
|
||||
vpcConnector?: string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Egress settings for VPC connector.
|
||||
* A value of null turns off VPC connector egress settings
|
||||
*/
|
||||
vpcConnectorEgressSettings?: options.VpcEgressSetting | ResetValue;
|
||||
/**
|
||||
* Specific service account for the function to run as.
|
||||
* A value of null restores the default service account.
|
||||
*/
|
||||
serviceAccount?: string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Ingress settings which control where this function can be called from.
|
||||
* A value of null turns off ingress settings.
|
||||
*/
|
||||
ingressSettings?: options.IngressSetting | ResetValue;
|
||||
/**
|
||||
* User labels to set on the function.
|
||||
*/
|
||||
labels?: Record<string, string>;
|
||||
secrets?: (string | SecretParam)[];
|
||||
/** Whether failed executions should be delivered again. */
|
||||
retry?: boolean | Expression<boolean> | ResetValue;
|
||||
}
|
||||
/**
|
||||
* Declares a function that can handle Firebase Alerts from CloudEvents.
|
||||
* @typeParam T - the type of event.data.payload.
|
||||
* @param alertType - the alert type or Firebase Alert function configuration.
|
||||
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onAlertPublished<T extends {
|
||||
["@type"]: string;
|
||||
} = any>(alertType: AlertType, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
|
||||
/**
|
||||
* Declares a function that can handle Firebase Alerts from CloudEvents.
|
||||
* @typeParam T - the type of event.data.payload.
|
||||
* @param options - the alert type and other options for this cloud function.
|
||||
* @param handler a function that can handle the Firebase Alert inside a CloudEvent.
|
||||
*/
|
||||
export declare function onAlertPublished<T extends {
|
||||
["@type"]: string;
|
||||
} = any>(options: FirebaseAlertOptions, handler: (event: AlertEvent<T>) => any | Promise<any>): CloudFunction<AlertEvent<T>>;
|
||||
108
node_modules/firebase-functions/lib/v2/providers/alerts/alerts.js
generated
vendored
Normal file
108
node_modules/firebase-functions/lib/v2/providers/alerts/alerts.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.convertAlertAndApp = exports.getOptsAndAlertTypeAndApp = exports.getEndpointAnnotation = exports.onAlertPublished = exports.eventType = void 0;
|
||||
const manifest_1 = require("../../../runtime/manifest");
|
||||
const trace_1 = require("../../trace");
|
||||
const options = require("../../options");
|
||||
const onInit_1 = require("../../../common/onInit");
|
||||
/** @internal */
|
||||
exports.eventType = "google.firebase.firebasealerts.alerts.v1.published";
|
||||
function onAlertPublished(alertTypeOrOpts, handler) {
|
||||
const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(convertAlertAndApp(raw));
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
|
||||
return func;
|
||||
}
|
||||
exports.onAlertPublished = onAlertPublished;
|
||||
/**
|
||||
* Helper function for getting the endpoint annotation used in alert handling functions.
|
||||
* @internal
|
||||
*/
|
||||
function getEndpointAnnotation(opts, alertType, appId) {
|
||||
var _a;
|
||||
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
||||
const specificOpts = options.optionsToEndpoint(opts);
|
||||
const endpoint = {
|
||||
...(0, manifest_1.initV2Endpoint)(options.getGlobalOptions(), opts),
|
||||
platform: "gcfv2",
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
},
|
||||
eventTrigger: {
|
||||
eventType: exports.eventType,
|
||||
eventFilters: {
|
||||
alerttype: alertType,
|
||||
},
|
||||
retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
if (appId) {
|
||||
endpoint.eventTrigger.eventFilters.appid = appId;
|
||||
}
|
||||
return endpoint;
|
||||
}
|
||||
exports.getEndpointAnnotation = getEndpointAnnotation;
|
||||
/**
|
||||
* Helper function to parse the function opts, alert type, and appId.
|
||||
* @internal
|
||||
*/
|
||||
function getOptsAndAlertTypeAndApp(alertTypeOrOpts) {
|
||||
let opts;
|
||||
let alertType;
|
||||
let appId;
|
||||
if (typeof alertTypeOrOpts === "string") {
|
||||
alertType = alertTypeOrOpts;
|
||||
opts = {};
|
||||
}
|
||||
else {
|
||||
alertType = alertTypeOrOpts.alertType;
|
||||
appId = alertTypeOrOpts.appId;
|
||||
opts = { ...alertTypeOrOpts };
|
||||
delete opts.alertType;
|
||||
delete opts.appId;
|
||||
}
|
||||
return [opts, alertType, appId];
|
||||
}
|
||||
exports.getOptsAndAlertTypeAndApp = getOptsAndAlertTypeAndApp;
|
||||
/**
|
||||
* Helper function to covert alert type & app id in the CloudEvent to camel case.
|
||||
* @internal
|
||||
*/
|
||||
function convertAlertAndApp(raw) {
|
||||
const event = { ...raw };
|
||||
if ("alerttype" in event) {
|
||||
event.alertType = event.alerttype;
|
||||
}
|
||||
if ("appid" in event) {
|
||||
event.appId = event.appid;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
exports.convertAlertAndApp = convertAlertAndApp;
|
||||
186
node_modules/firebase-functions/lib/v2/providers/alerts/appDistribution.d.ts
generated
vendored
Normal file
186
node_modules/firebase-functions/lib/v2/providers/alerts/appDistribution.d.ts
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* Cloud functions to handle Firebase App Distribution events from Firebase Alerts.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import { ResetValue } from "../../../common/options";
|
||||
import { Expression } from "../../../params";
|
||||
import { CloudEvent, CloudFunction } from "../../core";
|
||||
import { FirebaseAlertData } from "./alerts";
|
||||
import * as options from "../../options";
|
||||
import { SecretParam } from "../../../params/types";
|
||||
/**
|
||||
* The internal payload object for adding a new tester device to app distribution.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface NewTesterDevicePayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroNewTesterIosDevicePayload";
|
||||
/** Name of the tester */
|
||||
testerName: string;
|
||||
/** Email of the tester */
|
||||
testerEmail: string;
|
||||
/** The device model name */
|
||||
testerDeviceModelName: string;
|
||||
/** The device ID */
|
||||
testerDeviceIdentifier: string;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for receiving in-app feedback from a tester.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface InAppFeedbackPayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.AppDistroInAppFeedbackPayload";
|
||||
/** Resource name. Format: `projects/{project_number}/apps/{app_id}/releases/{release_id}/feedbackReports/{feedback_id}` */
|
||||
feedbackReport: string;
|
||||
/** Deep link back to the Firebase console. */
|
||||
feedbackConsoleUri: string;
|
||||
/** Name of the tester */
|
||||
testerName?: string;
|
||||
/** Email of the tester */
|
||||
testerEmail: string;
|
||||
/**
|
||||
* Version consisting of `versionName` and `versionCode` for Android and
|
||||
* `CFBundleShortVersionString` and `CFBundleVersion` for iOS.
|
||||
*/
|
||||
appVersion: string;
|
||||
/** Text entered by the tester */
|
||||
text: string;
|
||||
/** URI to download screenshot. This URI is fast expiring. */
|
||||
screenshotUri?: string;
|
||||
}
|
||||
/**
|
||||
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
|
||||
* @typeParam T - the data type for app distribution alerts that is wrapped in a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface AppDistributionEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
||||
/** The type of the alerts that got triggered. */
|
||||
alertType: string;
|
||||
/** The Firebase App ID that’s associated with the alert. */
|
||||
appId: string;
|
||||
}
|
||||
/**
|
||||
* Configuration for app distribution functions.
|
||||
*/
|
||||
export interface AppDistributionOptions extends options.EventHandlerOptions {
|
||||
/** Scope the function to trigger on a specific application. */
|
||||
appId?: string;
|
||||
/**
|
||||
* If true, do not deploy or emulate this function.
|
||||
*/
|
||||
omit?: boolean | Expression<boolean>;
|
||||
/**
|
||||
* Region where functions should be deployed.
|
||||
*/
|
||||
region?: options.SupportedRegion | string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Amount of memory to allocate to a function.
|
||||
*/
|
||||
memory?: options.MemoryOption | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Timeout for the function in seconds, possible values are 0 to 540.
|
||||
* HTTPS functions can specify a higher timeout.
|
||||
*
|
||||
* @remarks
|
||||
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
||||
* function depends on the type of function: Event handling functions have a
|
||||
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
||||
* maximum timeout of 3,600s (1 hour). Task queue functions have a maximum
|
||||
* timeout of 1,800s (30 minutes)
|
||||
*/
|
||||
timeoutSeconds?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Min number of actual instances to be running at a given time.
|
||||
*
|
||||
* @remarks
|
||||
* Instances will be billed for memory allocation and 10% of CPU allocation
|
||||
* while idle.
|
||||
*/
|
||||
minInstances?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Max number of instances to be running in parallel.
|
||||
*/
|
||||
maxInstances?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Number of requests a function can serve at once.
|
||||
*
|
||||
* @remarks
|
||||
* Can only be applied to functions running on Cloud Functions v2.
|
||||
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
||||
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
||||
* The maximum value for concurrency is 1,000.
|
||||
*/
|
||||
concurrency?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Fractional number of CPUs to allocate to a function.
|
||||
*
|
||||
* @remarks
|
||||
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
||||
* This is different from the defaults when using the gcloud utility and is different from
|
||||
* the fixed amount assigned in Google Cloud Functions generation 1.
|
||||
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
||||
* to the value "gcf_gen1"
|
||||
*/
|
||||
cpu?: number | "gcf_gen1";
|
||||
/**
|
||||
* Connect cloud function to specified VPC connector.
|
||||
*/
|
||||
vpcConnector?: string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Egress settings for VPC connector.
|
||||
*/
|
||||
vpcConnectorEgressSettings?: options.VpcEgressSetting | ResetValue;
|
||||
/**
|
||||
* Specific service account for the function to run as.
|
||||
*/
|
||||
serviceAccount?: string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Ingress settings which control where this function can be called from.
|
||||
*/
|
||||
ingressSettings?: options.IngressSetting | ResetValue;
|
||||
/**
|
||||
* User labels to set on the function.
|
||||
*/
|
||||
labels?: Record<string, string>;
|
||||
secrets?: (string | SecretParam)[];
|
||||
/** Whether failed executions should be delivered again. */
|
||||
retry?: boolean | Expression<boolean> | ResetValue;
|
||||
}
|
||||
/**
|
||||
* Declares a function that can handle adding a new tester iOS device.
|
||||
* @param handler - Event handler which is run every time a new tester iOS device is added.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewTesterIosDevicePublished(handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle adding a new tester iOS device.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler which is run every time a new tester iOS device is added.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewTesterIosDevicePublished(appId: string, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle adding a new tester iOS device.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler which is run every time a new tester iOS device is added.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewTesterIosDevicePublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<NewTesterDevicePayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<NewTesterDevicePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle receiving new in-app feedback from a tester.
|
||||
* @param handler - Event handler which is run every time new feedback is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onInAppFeedbackPublished(handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle receiving new in-app feedback from a tester.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler which is run every time new feedback is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onInAppFeedbackPublished(appId: string, handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle receiving new in-app feedback from a tester.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler which is run every time new feedback is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onInAppFeedbackPublished(opts: AppDistributionOptions, handler: (event: AppDistributionEvent<InAppFeedbackPayload>) => any | Promise<any>): CloudFunction<AppDistributionEvent<InAppFeedbackPayload>>;
|
||||
90
node_modules/firebase-functions/lib/v2/providers/alerts/appDistribution.js
generated
vendored
Normal file
90
node_modules/firebase-functions/lib/v2/providers/alerts/appDistribution.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getOptsAndApp = exports.onInAppFeedbackPublished = exports.onNewTesterIosDevicePublished = exports.inAppFeedbackAlert = exports.newTesterIosDeviceAlert = void 0;
|
||||
const trace_1 = require("../../trace");
|
||||
const alerts_1 = require("./alerts");
|
||||
const onInit_1 = require("../../../common/onInit");
|
||||
/** @internal */
|
||||
exports.newTesterIosDeviceAlert = "appDistribution.newTesterIosDevice";
|
||||
/** @internal */
|
||||
exports.inAppFeedbackAlert = "appDistribution.inAppFeedback";
|
||||
/**
|
||||
* Declares a function that can handle adding a new tester iOS device.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler which is run every time a new tester iOS device is added.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
|
||||
if (typeof appIdOrOptsOrHandler === "function") {
|
||||
handler = appIdOrOptsOrHandler;
|
||||
appIdOrOptsOrHandler = {};
|
||||
}
|
||||
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw));
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.newTesterIosDeviceAlert, appId);
|
||||
return func;
|
||||
}
|
||||
exports.onNewTesterIosDevicePublished = onNewTesterIosDevicePublished;
|
||||
/**
|
||||
* Declares a function that can handle receiving new in-app feedback from a tester.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler which is run every time new feedback is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onInAppFeedbackPublished(appIdOrOptsOrHandler, handler) {
|
||||
if (typeof appIdOrOptsOrHandler === "function") {
|
||||
handler = appIdOrOptsOrHandler;
|
||||
appIdOrOptsOrHandler = {};
|
||||
}
|
||||
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw));
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.inAppFeedbackAlert, appId);
|
||||
return func;
|
||||
}
|
||||
exports.onInAppFeedbackPublished = onInAppFeedbackPublished;
|
||||
/**
|
||||
* Helper function to parse the function opts and appId.
|
||||
* @internal
|
||||
*/
|
||||
function getOptsAndApp(appIdOrOpts) {
|
||||
let opts;
|
||||
let appId;
|
||||
if (typeof appIdOrOpts === "string") {
|
||||
opts = {};
|
||||
appId = appIdOrOpts;
|
||||
}
|
||||
else {
|
||||
appId = appIdOrOpts.appId;
|
||||
opts = { ...appIdOrOpts };
|
||||
delete opts.appId;
|
||||
}
|
||||
return [opts, appId];
|
||||
}
|
||||
exports.getOptsAndApp = getOptsAndApp;
|
||||
65
node_modules/firebase-functions/lib/v2/providers/alerts/billing.d.ts
generated
vendored
Normal file
65
node_modules/firebase-functions/lib/v2/providers/alerts/billing.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Cloud functions to handle billing events from Firebase Alerts.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import { CloudEvent, CloudFunction } from "../../core";
|
||||
import { FirebaseAlertData } from "./alerts";
|
||||
import * as options from "../../options";
|
||||
/**
|
||||
* The internal payload object for billing plan updates.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface PlanUpdatePayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanUpdatePayload";
|
||||
/** A Firebase billing plan. */
|
||||
billingPlan: string;
|
||||
/** The email address of the person that triggered billing plan change */
|
||||
principalEmail: string;
|
||||
/** The type of the notification, e.g. upgrade, downgrade */
|
||||
notificationType: string;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for billing plan automated updates.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface PlanAutomatedUpdatePayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanAutomatedUpdatePayload";
|
||||
/** A Firebase billing plan. */
|
||||
billingPlan: string;
|
||||
/** The type of the notification, e.g. upgrade, downgrade */
|
||||
notificationType: string;
|
||||
}
|
||||
/**
|
||||
* A custom CloudEvent for billing Firebase Alerts (with custom extension attributes).
|
||||
* @typeParam T - the data type for billing alerts that is wrapped in a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface BillingEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
||||
/** The type of the alerts that got triggered. */
|
||||
alertType: string;
|
||||
}
|
||||
/**
|
||||
* Declares a function that can handle a billing plan update event.
|
||||
* @param handler - Event handler which is run every time a billing plan is updated.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onPlanUpdatePublished(handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanUpdatePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a billing plan update event.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler which is run every time a billing plan is updated.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onPlanUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanUpdatePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle an automated billing plan update event.
|
||||
* @param handler - Event handler which is run every time an automated billing plan update occurs.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onPlanAutomatedUpdatePublished(handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle an automated billing plan update event.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler which is run every time an automated billing plan update occurs.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onPlanAutomatedUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
|
||||
65
node_modules/firebase-functions/lib/v2/providers/alerts/billing.js
generated
vendored
Normal file
65
node_modules/firebase-functions/lib/v2/providers/alerts/billing.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.onOperation = exports.onPlanAutomatedUpdatePublished = exports.onPlanUpdatePublished = exports.planAutomatedUpdateAlert = exports.planUpdateAlert = void 0;
|
||||
const trace_1 = require("../../trace");
|
||||
const alerts_1 = require("./alerts");
|
||||
const onInit_1 = require("../../../common/onInit");
|
||||
/** @internal */
|
||||
exports.planUpdateAlert = "billing.planUpdate";
|
||||
/** @internal */
|
||||
exports.planAutomatedUpdateAlert = "billing.planAutomatedUpdate";
|
||||
/**
|
||||
* Declares a function that can handle a billing plan update event.
|
||||
* @param optsOrHandler - Options or an event-handling function.
|
||||
* @param handler - Event handler which is run every time a billing plan is updated.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onPlanUpdatePublished(optsOrHandler, handler) {
|
||||
return onOperation(exports.planUpdateAlert, optsOrHandler, handler);
|
||||
}
|
||||
exports.onPlanUpdatePublished = onPlanUpdatePublished;
|
||||
/**
|
||||
* Declares a function that can handle an automated billing plan update event.
|
||||
* @param optsOrHandler - Options or an event-handling function.
|
||||
* @param handler - Event handler which is run every time an automated billing plan update occurs.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onPlanAutomatedUpdatePublished(optsOrHandler, handler) {
|
||||
return onOperation(exports.planAutomatedUpdateAlert, optsOrHandler, handler);
|
||||
}
|
||||
exports.onPlanAutomatedUpdatePublished = onPlanAutomatedUpdatePublished;
|
||||
/** @internal */
|
||||
function onOperation(alertType, optsOrHandler, handler) {
|
||||
if (typeof optsOrHandler === "function") {
|
||||
handler = optsOrHandler;
|
||||
optsOrHandler = {};
|
||||
}
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw));
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = (0, alerts_1.getEndpointAnnotation)(optsOrHandler, alertType);
|
||||
return func;
|
||||
}
|
||||
exports.onOperation = onOperation;
|
||||
338
node_modules/firebase-functions/lib/v2/providers/alerts/crashlytics.d.ts
generated
vendored
Normal file
338
node_modules/firebase-functions/lib/v2/providers/alerts/crashlytics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
/**
|
||||
* Cloud functions to handle Crashlytics events from Firebase Alerts.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import { ResetValue } from "../../../common/options";
|
||||
import { Expression } from "../../../params";
|
||||
import { CloudEvent, CloudFunction } from "../../core";
|
||||
import { FirebaseAlertData } from "./alerts";
|
||||
import * as options from "../../options";
|
||||
import { SecretParam } from "../../../params/types";
|
||||
/** Generic Crashlytics issue interface */
|
||||
export interface Issue {
|
||||
/** The ID of the Crashlytics issue */
|
||||
id: string;
|
||||
/** The title of the Crashlytics issue */
|
||||
title: string;
|
||||
/** The subtitle of the Crashlytics issue */
|
||||
subtitle: string;
|
||||
/** The application version of the Crashlytics issue */
|
||||
appVersion: string;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for a new fatal issue.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface NewFatalIssuePayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewFatalIssuePayload";
|
||||
/** Basic information of the Crashlytics issue */
|
||||
issue: Issue;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for a new non-fatal issue.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface NewNonfatalIssuePayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewNonfatalIssuePayload";
|
||||
/** Basic information of the Crashlytics issue */
|
||||
issue: Issue;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for a regression alert.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface RegressionAlertPayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsRegressionAlertPayload";
|
||||
/** The type of the Crashlytics issue, e.g. new fatal, new nonfatal, ANR */
|
||||
type: string;
|
||||
/** Basic information of the Crashlytics issue */
|
||||
issue: Issue;
|
||||
/**
|
||||
* The time that the Crashlytics issues was most recently resolved before it
|
||||
* began to reoccur.
|
||||
*/
|
||||
resolveTime: string;
|
||||
}
|
||||
/** Generic Crashlytics trending issue interface */
|
||||
export interface TrendingIssueDetails {
|
||||
/** The type of the Crashlytics issue, e.g. new fatal, new nonfatal, ANR */
|
||||
type: string;
|
||||
/** Basic information of the Crashlytics issue */
|
||||
issue: Issue;
|
||||
/** The number of crashes that occurred with the issue */
|
||||
eventCount: number;
|
||||
/** The number of distinct users that were affected by the issue */
|
||||
userCount: number;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for a stability digest.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface StabilityDigestPayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsStabilityDigestPayload";
|
||||
/**
|
||||
* The date that the digest gets created. Issues in the digest should have the
|
||||
* same date as the digest date
|
||||
*/
|
||||
digestDate: string;
|
||||
/** A stability digest containing several trending Crashlytics issues */
|
||||
trendingIssues: TrendingIssueDetails[];
|
||||
}
|
||||
/**
|
||||
* The internal payload object for a velocity alert.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface VelocityAlertPayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsVelocityAlertPayload";
|
||||
/** Basic information of the Crashlytics issue */
|
||||
issue: Issue;
|
||||
/** The time that the Crashlytics issue gets created */
|
||||
createTime: string;
|
||||
/**
|
||||
* The number of user sessions for the given app version that had this
|
||||
* specific crash issue in the time period used to trigger the velocity alert.
|
||||
*/
|
||||
crashCount: number;
|
||||
/**
|
||||
* The percentage of user sessions for the given app version that had this
|
||||
* specific crash issue in the time period used to trigger the velocity alert.
|
||||
*/
|
||||
crashPercentage: number;
|
||||
/**
|
||||
* The first app version where this issue was seen, and not necessarily the
|
||||
* version that has triggered the alert.
|
||||
*/
|
||||
firstVersion: string;
|
||||
}
|
||||
/**
|
||||
* The internal payload object for a new Application Not Responding issue.
|
||||
* Payload is wrapped inside a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface NewAnrIssuePayload {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.CrashlyticsNewAnrIssuePayload";
|
||||
/** Basic information of the Crashlytics issue */
|
||||
issue: Issue;
|
||||
}
|
||||
/**
|
||||
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
|
||||
* @typeParam T - the data type for Crashlytics alerts that is wrapped in a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface CrashlyticsEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
||||
/** The type of the alerts that got triggered. */
|
||||
alertType: string;
|
||||
/** The Firebase App ID that’s associated with the alert. */
|
||||
appId: string;
|
||||
}
|
||||
/**
|
||||
* Configuration for Crashlytics functions.
|
||||
*/
|
||||
export interface CrashlyticsOptions extends options.EventHandlerOptions {
|
||||
/** Scope the function to trigger on a specific application. */
|
||||
appId?: string;
|
||||
/**
|
||||
* If true, do not deploy or emulate this function.
|
||||
*/
|
||||
omit?: boolean | Expression<boolean>;
|
||||
/**
|
||||
* Region where functions should be deployed.
|
||||
*/
|
||||
region?: options.SupportedRegion | string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Amount of memory to allocate to a function.
|
||||
*/
|
||||
memory?: options.MemoryOption | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Timeout for the function in seconds, possible values are 0 to 540.
|
||||
* HTTPS functions can specify a higher timeout.
|
||||
*
|
||||
* @remarks
|
||||
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
||||
* function depends on the type of function: Event handling functions have a
|
||||
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
||||
* maximum timeout of 3,600s (1 hour). Task queue functions have a maximum
|
||||
* timeout of 1,800s (30 minutes)
|
||||
*/
|
||||
timeoutSeconds?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Min number of actual instances to be running at a given time.
|
||||
*
|
||||
* @remarks
|
||||
* Instances will be billed for memory allocation and 10% of CPU allocation
|
||||
* while idle.
|
||||
*/
|
||||
minInstances?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Max number of instances to be running in parallel.
|
||||
*/
|
||||
maxInstances?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Number of requests a function can serve at once.
|
||||
*
|
||||
* @remarks
|
||||
* Can only be applied to functions running on Cloud Functions v2.
|
||||
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
||||
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
||||
* The maximum value for concurrency is 1,000.
|
||||
*/
|
||||
concurrency?: number | Expression<number> | ResetValue;
|
||||
/**
|
||||
* Fractional number of CPUs to allocate to a function.
|
||||
*
|
||||
* @remarks
|
||||
* Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
||||
* This is different from the defaults when using the gcloud utility and is different from
|
||||
* the fixed amount assigned in Google Cloud Functions generation 1.
|
||||
* To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
||||
* to the value "gcf_gen1"
|
||||
*/
|
||||
cpu?: number | "gcf_gen1";
|
||||
/**
|
||||
* Connect cloud function to specified VPC connector.
|
||||
*/
|
||||
vpcConnector?: string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Egress settings for VPC connector.
|
||||
*/
|
||||
vpcConnectorEgressSettings?: options.VpcEgressSetting | ResetValue;
|
||||
/**
|
||||
* Specific service account for the function to run as.
|
||||
*/
|
||||
serviceAccount?: string | Expression<string> | ResetValue;
|
||||
/**
|
||||
* Ingress settings which control where this function can be called from.
|
||||
*/
|
||||
ingressSettings?: options.IngressSetting | ResetValue;
|
||||
/**
|
||||
* User labels to set on the function.
|
||||
*/
|
||||
labels?: Record<string, string>;
|
||||
secrets?: (string | SecretParam)[];
|
||||
/** Whether failed executions should be delivered again. */
|
||||
retry?: boolean | Expression<boolean> | ResetValue;
|
||||
}
|
||||
/**
|
||||
* Declares a function that can handle a new fatal issue published to Crashlytics.
|
||||
* @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewFatalIssuePublished(handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new fatal issue published to Crashlytics.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewFatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new fatal issue published to Crashlytics.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewFatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewFatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewFatalIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new non-fatal issue published to Crashlytics.
|
||||
* @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewNonfatalIssuePublished(handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new non-fatal issue published to Crashlytics.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewNonfatalIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new non-fatal issue published to Crashlytics.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewNonfatalIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewNonfatalIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewNonfatalIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a regression alert published to Crashlytics.
|
||||
* @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onRegressionAlertPublished(handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a regression alert published to Crashlytics.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
|
||||
*/
|
||||
export declare function onRegressionAlertPublished(appId: string, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a regression alert published to Crashlytics.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
|
||||
*/
|
||||
export declare function onRegressionAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<RegressionAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<RegressionAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a stability digest published to Crashlytics.
|
||||
* @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onStabilityDigestPublished(handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a stability digest published to Crashlytics.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
|
||||
*/
|
||||
export declare function onStabilityDigestPublished(appId: string, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a stability digest published to Crashlytics.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
|
||||
*/
|
||||
export declare function onStabilityDigestPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<StabilityDigestPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<StabilityDigestPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a velocity alert published to Crashlytics.
|
||||
* @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onVelocityAlertPublished(handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a velocity alert published to Crashlytics.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onVelocityAlertPublished(appId: string, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a velocity alert published to Crashlytics.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onVelocityAlertPublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<VelocityAlertPayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<VelocityAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
|
||||
* @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onNewAnrIssuePublished(handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
|
||||
*/
|
||||
export declare function onNewAnrIssuePublished(appId: string, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
|
||||
/**
|
||||
* Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
|
||||
*/
|
||||
export declare function onNewAnrIssuePublished(opts: CrashlyticsOptions, handler: (event: CrashlyticsEvent<NewAnrIssuePayload>) => any | Promise<any>): CloudFunction<CrashlyticsEvent<NewAnrIssuePayload>>;
|
||||
133
node_modules/firebase-functions/lib/v2/providers/alerts/crashlytics.js
generated
vendored
Normal file
133
node_modules/firebase-functions/lib/v2/providers/alerts/crashlytics.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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;
|
||||
const trace_1 = require("../../trace");
|
||||
const alerts_1 = require("./alerts");
|
||||
const onInit_1 = require("../../../common/onInit");
|
||||
/** @internal */
|
||||
exports.newFatalIssueAlert = "crashlytics.newFatalIssue";
|
||||
/** @internal */
|
||||
exports.newNonfatalIssueAlert = "crashlytics.newNonfatalIssue";
|
||||
/** @internal */
|
||||
exports.regressionAlert = "crashlytics.regression";
|
||||
/** @internal */
|
||||
exports.stabilityDigestAlert = "crashlytics.stabilityDigest";
|
||||
/** @internal */
|
||||
exports.velocityAlert = "crashlytics.velocity";
|
||||
/** @internal */
|
||||
exports.newAnrIssueAlert = "crashlytics.newAnrIssue";
|
||||
/**
|
||||
* Declares a function that can handle a new fatal issue published to Crashlytics.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onNewFatalIssuePublished(appIdOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.newFatalIssueAlert, appIdOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onNewFatalIssuePublished = onNewFatalIssuePublished;
|
||||
/**
|
||||
* Declares a function that can handle a new non-fatal issue published to Crashlytics.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onNewNonfatalIssuePublished(appIdOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.newNonfatalIssueAlert, appIdOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onNewNonfatalIssuePublished = onNewNonfatalIssuePublished;
|
||||
/**
|
||||
* Declares a function that can handle a regression alert published to Crashlytics.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onRegressionAlertPublished(appIdOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.regressionAlert, appIdOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onRegressionAlertPublished = onRegressionAlertPublished;
|
||||
/**
|
||||
* Declares a function that can handle a stability digest published to Crashlytics.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onStabilityDigestPublished(appIdOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.stabilityDigestAlert, appIdOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onStabilityDigestPublished = onStabilityDigestPublished;
|
||||
/**
|
||||
* Declares a function that can handle a velocity alert published to Crashlytics.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onVelocityAlertPublished(appIdOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.velocityAlert, appIdOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onVelocityAlertPublished = onVelocityAlertPublished;
|
||||
/**
|
||||
* Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onNewAnrIssuePublished(appIdOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.newAnrIssueAlert, appIdOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onNewAnrIssuePublished = onNewAnrIssuePublished;
|
||||
/** @internal */
|
||||
function onOperation(alertType, appIdOrOptsOrHandler, handler) {
|
||||
if (typeof appIdOrOptsOrHandler === "function") {
|
||||
handler = appIdOrOptsOrHandler;
|
||||
appIdOrOptsOrHandler = {};
|
||||
}
|
||||
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw));
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, alertType, appId);
|
||||
return func;
|
||||
}
|
||||
exports.onOperation = onOperation;
|
||||
/**
|
||||
* Helper function to parse the function opts and appId.
|
||||
* @internal
|
||||
*/
|
||||
function getOptsAndApp(appIdOrOpts) {
|
||||
let opts;
|
||||
let appId;
|
||||
if (typeof appIdOrOpts === "string") {
|
||||
opts = {};
|
||||
appId = appIdOrOpts;
|
||||
}
|
||||
else {
|
||||
appId = appIdOrOpts.appId;
|
||||
opts = { ...appIdOrOpts };
|
||||
delete opts.appId;
|
||||
}
|
||||
return [opts, appId];
|
||||
}
|
||||
exports.getOptsAndApp = getOptsAndApp;
|
||||
12
node_modules/firebase-functions/lib/v2/providers/alerts/index.d.ts
generated
vendored
Normal file
12
node_modules/firebase-functions/lib/v2/providers/alerts/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Cloud functions to handle events from Firebase Alerts.
|
||||
* Subpackages give stronger typing to specific services which
|
||||
* notify users via Firebase Alerts.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import * as appDistribution from "./appDistribution";
|
||||
import * as billing from "./billing";
|
||||
import * as crashlytics from "./crashlytics";
|
||||
import * as performance from "./performance";
|
||||
export { appDistribution, billing, crashlytics, performance };
|
||||
export * from "./alerts";
|
||||
53
node_modules/firebase-functions/lib/v2/providers/alerts/index.js
generated
vendored
Normal file
53
node_modules/firebase-functions/lib/v2/providers/alerts/index.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.performance = exports.crashlytics = exports.billing = exports.appDistribution = void 0;
|
||||
/**
|
||||
* Cloud functions to handle events from Firebase Alerts.
|
||||
* Subpackages give stronger typing to specific services which
|
||||
* notify users via Firebase Alerts.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const appDistribution = require("./appDistribution");
|
||||
exports.appDistribution = appDistribution;
|
||||
const billing = require("./billing");
|
||||
exports.billing = billing;
|
||||
const crashlytics = require("./crashlytics");
|
||||
exports.crashlytics = crashlytics;
|
||||
const performance = require("./performance");
|
||||
exports.performance = performance;
|
||||
__exportStar(require("./alerts"), exports);
|
||||
68
node_modules/firebase-functions/lib/v2/providers/alerts/performance.d.ts
generated
vendored
Normal file
68
node_modules/firebase-functions/lib/v2/providers/alerts/performance.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { CloudEvent, CloudFunction } from "../../core";
|
||||
import { EventHandlerOptions } from "../../options";
|
||||
import { FirebaseAlertData } from "./alerts";
|
||||
/**
|
||||
* The internal payload object for a performance threshold alert.
|
||||
* Payload is wrapped inside a {@link FirebaseAlertData} object.
|
||||
*/
|
||||
export interface ThresholdAlertPayload {
|
||||
/** Name of the trace or network request this alert is for (e.g. my_custom_trace, firebase.com/api/123) */
|
||||
eventName: string;
|
||||
/** The resource type this alert is for (i.e. trace, network request, screen rendering, etc.) */
|
||||
eventType: string;
|
||||
/** The metric type this alert is for (i.e. success rate, response time, duration, etc.) */
|
||||
metricType: string;
|
||||
/** The number of events checked for this alert condition */
|
||||
numSamples: number;
|
||||
/** The threshold value of the alert condition without units (e.g. "75", "2.1") */
|
||||
thresholdValue: number;
|
||||
/** The unit for the alert threshold (e.g. "percent", "seconds") */
|
||||
thresholdUnit: string;
|
||||
/** The percentile of the alert condition, can be 0 if percentile is not applicable to the alert condition and omitted; range: [1, 100] */
|
||||
conditionPercentile?: number;
|
||||
/** The app version this alert was triggered for, can be omitted if the alert is for a network request (because the alert was checked against data from all versions of app) or a web app (where the app is versionless) */
|
||||
appVersion?: string;
|
||||
/** The value that violated the alert condition (e.g. "76.5", "3") */
|
||||
violationValue: number;
|
||||
/** The unit for the violation value (e.g. "percent", "seconds") */
|
||||
violationUnit: string;
|
||||
/** The link to Fireconsole to investigate more into this alert */
|
||||
investigateUri: string;
|
||||
}
|
||||
/**
|
||||
* A custom CloudEvent for Firebase Alerts (with custom extension attributes).
|
||||
* @typeParam T - the data type for performance alerts that is wrapped in a `FirebaseAlertData` object.
|
||||
*/
|
||||
export interface PerformanceEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
|
||||
/** The type of the alerts that got triggered. */
|
||||
alertType: string;
|
||||
/** The Firebase App ID that’s associated with the alert. */
|
||||
appId: string;
|
||||
}
|
||||
/**
|
||||
* Configuration for app distribution functions.
|
||||
*/
|
||||
export interface PerformanceOptions extends EventHandlerOptions {
|
||||
/** Scope the function to trigger on a specific application. */
|
||||
appId?: string;
|
||||
}
|
||||
/**
|
||||
* Declares a function that can handle receiving performance threshold alerts.
|
||||
* @param handler - Event handler which is run every time a threshold alert is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onThresholdAlertPublished(handler: (event: PerformanceEvent<ThresholdAlertPayload>) => any | Promise<any>): CloudFunction<PerformanceEvent<ThresholdAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle receiving performance threshold alerts.
|
||||
* @param appId - A specific application the handler will trigger on.
|
||||
* @param handler - Event handler which is run every time a threshold alert is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onThresholdAlertPublished(appId: string, handler: (event: PerformanceEvent<ThresholdAlertPayload>) => any | Promise<any>): CloudFunction<PerformanceEvent<ThresholdAlertPayload>>;
|
||||
/**
|
||||
* Declares a function that can handle receiving performance threshold alerts.
|
||||
* @param opts - Options that can be set on the function.
|
||||
* @param handler - Event handler which is run every time a threshold alert is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onThresholdAlertPublished(opts: PerformanceOptions, handler: (event: PerformanceEvent<ThresholdAlertPayload>) => any | Promise<any>): CloudFunction<PerformanceEvent<ThresholdAlertPayload>>;
|
||||
85
node_modules/firebase-functions/lib/v2/providers/alerts/performance.js
generated
vendored
Normal file
85
node_modules/firebase-functions/lib/v2/providers/alerts/performance.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Firebase
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.convertPayload = exports.getOptsAndApp = exports.onThresholdAlertPublished = exports.thresholdAlert = void 0;
|
||||
/**
|
||||
* Cloud functions to handle Firebase Performance Monitoring events from Firebase Alerts.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const onInit_1 = require("../../../common/onInit");
|
||||
const trace_1 = require("../../trace");
|
||||
const alerts_1 = require("./alerts");
|
||||
/** @internal */
|
||||
exports.thresholdAlert = "performance.threshold";
|
||||
/**
|
||||
* Declares a function that can handle receiving performance threshold alerts.
|
||||
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
||||
* @param handler - Event handler which is run every time a threshold alert is received.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onThresholdAlertPublished(appIdOrOptsOrHandler, handler) {
|
||||
if (typeof appIdOrOptsOrHandler === "function") {
|
||||
handler = appIdOrOptsOrHandler;
|
||||
appIdOrOptsOrHandler = {};
|
||||
}
|
||||
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
||||
const func = (raw) => {
|
||||
const event = (0, alerts_1.convertAlertAndApp)(raw);
|
||||
const convertedPayload = convertPayload(event.data.payload);
|
||||
event.data.payload = convertedPayload;
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler(event)));
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = (0, alerts_1.getEndpointAnnotation)(opts, exports.thresholdAlert, appId);
|
||||
return func;
|
||||
}
|
||||
exports.onThresholdAlertPublished = onThresholdAlertPublished;
|
||||
/**
|
||||
* Helper function to parse the function opts and appId.
|
||||
* @internal
|
||||
*/
|
||||
function getOptsAndApp(appIdOrOpts) {
|
||||
if (typeof appIdOrOpts === "string") {
|
||||
return [{}, appIdOrOpts];
|
||||
}
|
||||
const opts = { ...appIdOrOpts };
|
||||
const appId = appIdOrOpts.appId;
|
||||
delete opts.appId;
|
||||
return [opts, appId];
|
||||
}
|
||||
exports.getOptsAndApp = getOptsAndApp;
|
||||
/**
|
||||
* Helper function to convert the raw payload of a {@link PerformanceEvent} to a {@link ThresholdAlertPayload}
|
||||
* @internal
|
||||
*/
|
||||
function convertPayload(raw) {
|
||||
const payload = { ...raw };
|
||||
if (typeof payload.conditionPercentile !== "undefined" && payload.conditionPercentile === 0) {
|
||||
delete payload.conditionPercentile;
|
||||
}
|
||||
if (typeof payload.appVersion !== "undefined" && payload.appVersion.length === 0) {
|
||||
delete payload.appVersion;
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
exports.convertPayload = convertPayload;
|
||||
Reference in New Issue
Block a user