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;
|
||||
190
node_modules/firebase-functions/lib/v2/providers/database.d.ts
generated
vendored
Normal file
190
node_modules/firebase-functions/lib/v2/providers/database.d.ts
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
import { Change } from "../../common/change";
|
||||
import { ParamsOf } from "../../common/params";
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { DataSnapshot } from "../../common/providers/database";
|
||||
import { CloudEvent, CloudFunction } from "../core";
|
||||
import { Expression } from "../../params";
|
||||
import * as options from "../options";
|
||||
import { SecretParam } from "../../params/types";
|
||||
export { DataSnapshot };
|
||||
/** @hidden */
|
||||
export interface RawRTDBCloudEventData {
|
||||
["@type"]: "type.googleapis.com/google.events.firebase.database.v1.ReferenceEventData";
|
||||
data: any;
|
||||
delta: any;
|
||||
}
|
||||
/** @hidden */
|
||||
export interface RawRTDBCloudEvent extends CloudEvent<RawRTDBCloudEventData> {
|
||||
firebasedatabasehost: string;
|
||||
instance: string;
|
||||
ref: string;
|
||||
location: string;
|
||||
}
|
||||
/** A CloudEvent that contains a DataSnapshot or a Change<DataSnapshot> */
|
||||
export interface DatabaseEvent<T, Params = Record<string, string>> extends CloudEvent<T> {
|
||||
/** The domain of the database instance */
|
||||
firebaseDatabaseHost: string;
|
||||
/** The instance ID portion of the fully qualified resource name */
|
||||
instance: string;
|
||||
/** The database reference path */
|
||||
ref: string;
|
||||
/** The location of the database */
|
||||
location: string;
|
||||
/**
|
||||
* An object containing the values of the path patterns.
|
||||
* Only named capture groups will be populated - {key}, {key=*}, {key=**}
|
||||
*/
|
||||
params: Params;
|
||||
}
|
||||
/** ReferenceOptions extend EventHandlerOptions with provided ref and optional instance */
|
||||
export interface ReferenceOptions<Ref extends string = string> extends options.EventHandlerOptions {
|
||||
/**
|
||||
* Specify the handler to trigger on a database reference(s).
|
||||
* This value can either be a single reference or a pattern.
|
||||
* Examples: '/foo/bar', '/foo/{bar}'
|
||||
*/
|
||||
ref: Ref;
|
||||
/**
|
||||
* Specify the handler to trigger on a database instance(s).
|
||||
* If present, this value can either be a single instance or a pattern.
|
||||
* Examples: 'my-instance-1', 'my-instance-*'
|
||||
* Note: The capture syntax cannot be used for 'instance'.
|
||||
*/
|
||||
instance?: 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;
|
||||
}
|
||||
/**
|
||||
* Event handler which triggers when data is created, updated, or deleted in Realtime Database.
|
||||
*
|
||||
* @param reference - The database reference path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
|
||||
*/
|
||||
export declare function onValueWritten<Ref extends string>(ref: Ref, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is created, updated, or deleted in Realtime Database.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
|
||||
*/
|
||||
export declare function onValueWritten<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is created in Realtime Database.
|
||||
*
|
||||
* @param reference - The database reference path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Realtime Database create occurs.
|
||||
*/
|
||||
export declare function onValueCreated<Ref extends string>(ref: Ref, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is created in Realtime Database.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Realtime Database create occurs.
|
||||
*/
|
||||
export declare function onValueCreated<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is updated in Realtime Database.
|
||||
*
|
||||
* @param reference - The database reference path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Realtime Database update occurs.
|
||||
*/
|
||||
export declare function onValueUpdated<Ref extends string>(ref: Ref, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is updated in Realtime Database.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Realtime Database update occurs.
|
||||
*/
|
||||
export declare function onValueUpdated<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<Change<DataSnapshot>, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is deleted in Realtime Database.
|
||||
*
|
||||
* @param reference - The database reference path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Realtime Database deletion occurs.
|
||||
*/
|
||||
export declare function onValueDeleted<Ref extends string>(ref: Ref, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;
|
||||
/**
|
||||
* Event handler which triggers when data is deleted in Realtime Database.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Realtime Database deletion occurs.
|
||||
*/
|
||||
export declare function onValueDeleted<Ref extends string>(opts: ReferenceOptions<Ref>, handler: (event: DatabaseEvent<DataSnapshot, ParamsOf<Ref>>) => any | Promise<any>): CloudFunction<DatabaseEvent<DataSnapshot, ParamsOf<Ref>>>;
|
||||
219
node_modules/firebase-functions/lib/v2/providers/database.js
generated
vendored
Normal file
219
node_modules/firebase-functions/lib/v2/providers/database.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
"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.onChangedOperation = exports.makeEndpoint = exports.makeParams = exports.getOpts = exports.onValueDeleted = exports.onValueUpdated = exports.onValueCreated = exports.onValueWritten = exports.deletedEventType = exports.updatedEventType = exports.createdEventType = exports.writtenEventType = exports.DataSnapshot = void 0;
|
||||
const app_1 = require("../../common/app");
|
||||
const database_1 = require("../../common/providers/database");
|
||||
Object.defineProperty(exports, "DataSnapshot", { enumerable: true, get: function () { return database_1.DataSnapshot; } });
|
||||
const path_1 = require("../../common/utilities/path");
|
||||
const path_pattern_1 = require("../../common/utilities/path-pattern");
|
||||
const utils_1 = require("../../common/utilities/utils");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const trace_1 = require("../trace");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
/** @internal */
|
||||
exports.writtenEventType = "google.firebase.database.ref.v1.written";
|
||||
/** @internal */
|
||||
exports.createdEventType = "google.firebase.database.ref.v1.created";
|
||||
/** @internal */
|
||||
exports.updatedEventType = "google.firebase.database.ref.v1.updated";
|
||||
/** @internal */
|
||||
exports.deletedEventType = "google.firebase.database.ref.v1.deleted";
|
||||
/**
|
||||
* Event handler which triggers when data is created, updated, or deleted in Realtime Database.
|
||||
*
|
||||
* @param referenceOrOpts - Options or a string reference.
|
||||
* @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
|
||||
*/
|
||||
function onValueWritten(referenceOrOpts, handler) {
|
||||
return onChangedOperation(exports.writtenEventType, referenceOrOpts, handler);
|
||||
}
|
||||
exports.onValueWritten = onValueWritten;
|
||||
/**
|
||||
* Event handler which triggers when data is created in Realtime Database.
|
||||
*
|
||||
* @param referenceOrOpts - Options or a string reference.
|
||||
* @param handler - Event handler which is run every time a Realtime Database create occurs.
|
||||
*/
|
||||
function onValueCreated(referenceOrOpts, handler) {
|
||||
return onOperation(exports.createdEventType, referenceOrOpts, handler);
|
||||
}
|
||||
exports.onValueCreated = onValueCreated;
|
||||
/**
|
||||
* Event handler which triggers when data is updated in Realtime Database.
|
||||
*
|
||||
* @param referenceOrOpts - Options or a string reference.
|
||||
* @param handler - Event handler which is run every time a Realtime Database update occurs.
|
||||
*/
|
||||
function onValueUpdated(referenceOrOpts, handler) {
|
||||
return onChangedOperation(exports.updatedEventType, referenceOrOpts, handler);
|
||||
}
|
||||
exports.onValueUpdated = onValueUpdated;
|
||||
/**
|
||||
* Event handler which triggers when data is deleted in Realtime Database.
|
||||
*
|
||||
* @param referenceOrOpts - Options or a string reference.
|
||||
* @param handler - Event handler which is run every time a Realtime Database deletion occurs.
|
||||
*/
|
||||
function onValueDeleted(referenceOrOpts, handler) {
|
||||
// TODO - need to use event.data.delta
|
||||
return onOperation(exports.deletedEventType, referenceOrOpts, handler);
|
||||
}
|
||||
exports.onValueDeleted = onValueDeleted;
|
||||
/** @internal */
|
||||
function getOpts(referenceOrOpts) {
|
||||
let path;
|
||||
let instance;
|
||||
let opts;
|
||||
if (typeof referenceOrOpts === "string") {
|
||||
path = (0, path_1.normalizePath)(referenceOrOpts);
|
||||
instance = "*";
|
||||
opts = {};
|
||||
}
|
||||
else {
|
||||
path = (0, path_1.normalizePath)(referenceOrOpts.ref);
|
||||
instance = referenceOrOpts.instance || "*";
|
||||
opts = { ...referenceOrOpts };
|
||||
delete opts.ref;
|
||||
delete opts.instance;
|
||||
}
|
||||
return {
|
||||
path,
|
||||
instance,
|
||||
opts,
|
||||
};
|
||||
}
|
||||
exports.getOpts = getOpts;
|
||||
/** @internal */
|
||||
function makeParams(event, path, instance) {
|
||||
return {
|
||||
...path.extractMatches(event.ref),
|
||||
...instance.extractMatches(event.instance),
|
||||
};
|
||||
}
|
||||
exports.makeParams = makeParams;
|
||||
/** @hidden */
|
||||
function makeDatabaseEvent(event, data, instance, params) {
|
||||
const snapshot = new database_1.DataSnapshot(data, event.ref, (0, app_1.getApp)(), instance);
|
||||
const databaseEvent = {
|
||||
...event,
|
||||
firebaseDatabaseHost: event.firebasedatabasehost,
|
||||
data: snapshot,
|
||||
params,
|
||||
};
|
||||
delete databaseEvent.firebasedatabasehost;
|
||||
return databaseEvent;
|
||||
}
|
||||
/** @hidden */
|
||||
function makeChangedDatabaseEvent(event, instance, params) {
|
||||
const before = new database_1.DataSnapshot(event.data.data, event.ref, (0, app_1.getApp)(), instance);
|
||||
const after = new database_1.DataSnapshot((0, utils_1.applyChange)(event.data.data, event.data.delta), event.ref, (0, app_1.getApp)(), instance);
|
||||
const databaseEvent = {
|
||||
...event,
|
||||
firebaseDatabaseHost: event.firebasedatabasehost,
|
||||
data: {
|
||||
before,
|
||||
after,
|
||||
},
|
||||
params,
|
||||
};
|
||||
delete databaseEvent.firebasedatabasehost;
|
||||
return databaseEvent;
|
||||
}
|
||||
/** @internal */
|
||||
function makeEndpoint(eventType, opts, path, instance) {
|
||||
var _a;
|
||||
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
||||
const specificOpts = options.optionsToEndpoint(opts);
|
||||
const eventFilters = {};
|
||||
const eventFilterPathPatterns = {
|
||||
// Note: Eventarc always treats ref as a path pattern
|
||||
ref: path.getValue(),
|
||||
};
|
||||
instance.hasWildcards()
|
||||
? (eventFilterPathPatterns.instance = instance.getValue())
|
||||
: (eventFilters.instance = instance.getValue());
|
||||
return {
|
||||
...(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,
|
||||
eventFilters,
|
||||
eventFilterPathPatterns,
|
||||
retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.makeEndpoint = makeEndpoint;
|
||||
/** @internal */
|
||||
function onChangedOperation(eventType, referenceOrOpts, handler) {
|
||||
const { path, instance, opts } = getOpts(referenceOrOpts);
|
||||
const pathPattern = new path_pattern_1.PathPattern(path);
|
||||
const instancePattern = new path_pattern_1.PathPattern(instance);
|
||||
// wrap the handler
|
||||
const func = (raw) => {
|
||||
const event = raw;
|
||||
const instanceUrl = getInstance(event);
|
||||
const params = makeParams(event, pathPattern, instancePattern);
|
||||
const databaseEvent = makeChangedDatabaseEvent(event, instanceUrl, params);
|
||||
// Intentionally put init in the context of traces in case there is something
|
||||
// expensive to observe.
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(databaseEvent);
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = makeEndpoint(eventType, opts, pathPattern, instancePattern);
|
||||
return func;
|
||||
}
|
||||
exports.onChangedOperation = onChangedOperation;
|
||||
/** @internal */
|
||||
function onOperation(eventType, referenceOrOpts, handler) {
|
||||
const { path, instance, opts } = getOpts(referenceOrOpts);
|
||||
const pathPattern = new path_pattern_1.PathPattern(path);
|
||||
const instancePattern = new path_pattern_1.PathPattern(instance);
|
||||
// wrap the handler
|
||||
const func = (raw) => {
|
||||
const event = raw;
|
||||
const instanceUrl = getInstance(event);
|
||||
const params = makeParams(event, pathPattern, instancePattern);
|
||||
const data = eventType === exports.deletedEventType ? event.data.data : event.data.delta;
|
||||
const databaseEvent = makeDatabaseEvent(event, data, instanceUrl, params);
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(databaseEvent);
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = makeEndpoint(eventType, opts, pathPattern, instancePattern);
|
||||
return func;
|
||||
}
|
||||
exports.onOperation = onOperation;
|
||||
function getInstance(event) {
|
||||
const emuHost = process.env.FIREBASE_DATABASE_EMULATOR_HOST;
|
||||
return emuHost
|
||||
? `http://${emuHost}/?ns=${event.instance}`
|
||||
: `https://${event.instance}.${event.firebasedatabasehost}`;
|
||||
}
|
||||
123
node_modules/firebase-functions/lib/v2/providers/eventarc.d.ts
generated
vendored
Normal file
123
node_modules/firebase-functions/lib/v2/providers/eventarc.d.ts
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { CloudEvent, CloudFunction } from "../core";
|
||||
import { Expression } from "../../params";
|
||||
import * as options from "../options";
|
||||
import { SecretParam } from "../../params/types";
|
||||
/** Options that can be set on an Eventarc trigger. */
|
||||
export interface EventarcTriggerOptions extends options.EventHandlerOptions {
|
||||
/**
|
||||
* Type of the event to trigger on.
|
||||
*/
|
||||
eventType: string;
|
||||
/**
|
||||
* ID of the channel. Can be either:
|
||||
* * fully qualified channel resource name:
|
||||
* `projects/{project}/locations/{location}/channels/{channel-id}`
|
||||
* * partial resource name with location and channel ID, in which case
|
||||
* the runtime project ID of the function will be used:
|
||||
* `locations/{location}/channels/{channel-id}`
|
||||
* * partial channel ID, in which case the runtime project ID of the
|
||||
* function and `us-central1` as location will be used:
|
||||
* `{channel-id}`
|
||||
*
|
||||
* If not specified, the default Firebase channel will be used:
|
||||
* `projects/{project}/locations/us-central1/channels/firebase`
|
||||
*/
|
||||
channel?: string;
|
||||
/**
|
||||
* Eventarc event exact match filter.
|
||||
*/
|
||||
filters?: Record<string, 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;
|
||||
}
|
||||
/** Handles an Eventarc event published on the default channel.
|
||||
* @param eventType - Type of the event to trigger on.
|
||||
* @param handler - A function to execute when triggered.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onCustomEventPublished<T = any>(eventType: string, handler: (event: CloudEvent<T>) => any | Promise<any>): CloudFunction<CloudEvent<T>>;
|
||||
/** Handles an Eventarc event.
|
||||
* @param opts - Options to set on this function
|
||||
* @param handler - A function to execute when triggered.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onCustomEventPublished<T = any>(opts: EventarcTriggerOptions, handler: (event: CloudEvent<T>) => any | Promise<any>): CloudFunction<CloudEvent<T>>;
|
||||
79
node_modules/firebase-functions/lib/v2/providers/eventarc.js
generated
vendored
Normal file
79
node_modules/firebase-functions/lib/v2/providers/eventarc.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"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.onCustomEventPublished = void 0;
|
||||
/**
|
||||
* Cloud functions to integrate directly with Eventarc.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const encoding_1 = require("../../common/encoding");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const trace_1 = require("../trace");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
function onCustomEventPublished(eventTypeOrOpts, handler) {
|
||||
var _a, _b;
|
||||
let opts;
|
||||
if (typeof eventTypeOrOpts === "string") {
|
||||
opts = {
|
||||
eventType: eventTypeOrOpts,
|
||||
};
|
||||
}
|
||||
else if (typeof eventTypeOrOpts === "object") {
|
||||
opts = eventTypeOrOpts;
|
||||
}
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw);
|
||||
};
|
||||
func.run = handler;
|
||||
const channel = (_a = opts.channel) !== null && _a !== void 0 ? _a : "locations/us-central1/channels/firebase";
|
||||
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: opts.eventType,
|
||||
eventFilters: {},
|
||||
retry: (_b = opts.retry) !== null && _b !== void 0 ? _b : false,
|
||||
channel,
|
||||
},
|
||||
};
|
||||
(0, encoding_1.convertIfPresent)(endpoint.eventTrigger, opts, "eventFilters", "filters");
|
||||
(0, encoding_1.copyIfPresent)(endpoint.eventTrigger, opts, "retry");
|
||||
func.__endpoint = endpoint;
|
||||
func.__requiredAPIs = [
|
||||
{
|
||||
api: "eventarcpublishing.googleapis.com",
|
||||
reason: "Needed for custom event functions",
|
||||
},
|
||||
];
|
||||
return func;
|
||||
}
|
||||
exports.onCustomEventPublished = onCustomEventPublished;
|
||||
172
node_modules/firebase-functions/lib/v2/providers/firestore.d.ts
generated
vendored
Normal file
172
node_modules/firebase-functions/lib/v2/providers/firestore.d.ts
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
import * as firestore from "firebase-admin/firestore";
|
||||
import { ParamsOf } from "../../common/params";
|
||||
import { Change, CloudEvent, CloudFunction } from "../core";
|
||||
import { EventHandlerOptions } from "../options";
|
||||
import { Expression } from "../../params";
|
||||
export { Change };
|
||||
/** A Firestore DocumentSnapshot */
|
||||
export type DocumentSnapshot = firestore.DocumentSnapshot;
|
||||
/** A Firestore QueryDocumentSnapshot */
|
||||
export type QueryDocumentSnapshot = firestore.QueryDocumentSnapshot;
|
||||
/**
|
||||
* AuthType defines the possible values for the authType field in a Firestore event with auth context.
|
||||
* - service_account: a non-user principal used to identify a workload or machine user.
|
||||
* - api_key: a non-user client API key.
|
||||
* - system: an obscured identity used when Cloud Platform or another system triggered the event. Examples include a database record which was deleted based on a TTL.
|
||||
* - unauthenticated: an unauthenticated action.
|
||||
* - unknown: a general type to capture all other principals not captured in the other auth types.
|
||||
*/
|
||||
export type AuthType = "service_account" | "api_key" | "system" | "unauthenticated" | "unknown";
|
||||
/** A CloudEvent that contains a DocumentSnapshot or a Change<DocumentSnapshot> */
|
||||
export interface FirestoreEvent<T, Params = Record<string, string>> extends CloudEvent<T> {
|
||||
/** The location of the Firestore instance */
|
||||
location: string;
|
||||
/** The project identifier */
|
||||
project: string;
|
||||
/** The Firestore database */
|
||||
database: string;
|
||||
/** The Firestore namespace */
|
||||
namespace: string;
|
||||
/** The document path */
|
||||
document: string;
|
||||
/**
|
||||
* An object containing the values of the path patterns.
|
||||
* Only named capture groups will be populated - {key}, {key=*}, {key=**}
|
||||
*/
|
||||
params: Params;
|
||||
}
|
||||
export interface FirestoreAuthEvent<T, Params = Record<string, string>> extends FirestoreEvent<T, Params> {
|
||||
/** The type of principal that triggered the event */
|
||||
authType: AuthType;
|
||||
/** The unique identifier for the principal */
|
||||
authId?: string;
|
||||
}
|
||||
/** DocumentOptions extend EventHandlerOptions with provided document and optional database and namespace. */
|
||||
export interface DocumentOptions<Document extends string = string> extends EventHandlerOptions {
|
||||
/** The document path */
|
||||
document: Document | Expression<string>;
|
||||
/** The Firestore database */
|
||||
database?: string | Expression<string>;
|
||||
/** The Firestore namespace */
|
||||
namespace?: string | Expression<string>;
|
||||
}
|
||||
/**
|
||||
* Event handler that triggers when a document is created, updated, or deleted in Firestore.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore create, update, or delete occurs.
|
||||
*/
|
||||
export declare function onDocumentWritten<Document extends string>(document: Document, handler: (event: FirestoreEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created, updated, or deleted in Firestore.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore create, update, or delete occurs.
|
||||
*/
|
||||
export declare function onDocumentWritten<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created, updated, or deleted in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore create, update, or delete occurs.
|
||||
*/
|
||||
export declare function onDocumentWrittenWithAuthContext<Document extends string>(document: Document, handler: (event: FirestoreAuthEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created, updated, or deleted in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore create, update, or delete occurs.
|
||||
*/
|
||||
export declare function onDocumentWrittenWithAuthContext<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreAuthEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<Change<DocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created in Firestore.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore create occurs.
|
||||
*/
|
||||
export declare function onDocumentCreated<Document extends string>(document: Document, handler: (event: FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created in Firestore.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore create occurs.
|
||||
*/
|
||||
export declare function onDocumentCreated<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore create occurs.
|
||||
*/
|
||||
export declare function onDocumentCreatedWithAuthContext<Document extends string>(document: Document, handler: (event: FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is created in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore create occurs.
|
||||
*/
|
||||
export declare function onDocumentCreatedWithAuthContext<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is updated in Firestore.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore update occurs.
|
||||
*/
|
||||
export declare function onDocumentUpdated<Document extends string>(document: Document, handler: (event: FirestoreEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is updated in Firestore.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore update occurs.
|
||||
*/
|
||||
export declare function onDocumentUpdated<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is updated in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore update occurs.
|
||||
*/
|
||||
export declare function onDocumentUpdatedWithAuthContext<Document extends string>(document: Document, handler: (event: FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is updated in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore update occurs.
|
||||
*/
|
||||
export declare function onDocumentUpdatedWithAuthContext<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<Change<QueryDocumentSnapshot> | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is deleted in Firestore.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore delete occurs.
|
||||
*/
|
||||
export declare function onDocumentDeleted<Document extends string>(document: Document, handler: (event: FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is deleted in Firestore.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore delete occurs.
|
||||
*/
|
||||
export declare function onDocumentDeleted<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is deleted in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param document - The Firestore document path to trigger on.
|
||||
* @param handler - Event handler which is run every time a Firestore delete occurs.
|
||||
*/
|
||||
export declare function onDocumentDeletedWithAuthContext<Document extends string>(document: Document, handler: (event: FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
/**
|
||||
* Event handler that triggers when a document is deleted in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firestore delete occurs.
|
||||
*/
|
||||
export declare function onDocumentDeletedWithAuthContext<Document extends string>(opts: DocumentOptions<Document>, handler: (event: FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>) => any | Promise<any>): CloudFunction<FirestoreAuthEvent<QueryDocumentSnapshot | undefined, ParamsOf<Document>>>;
|
||||
323
node_modules/firebase-functions/lib/v2/providers/firestore.js
generated
vendored
Normal file
323
node_modules/firebase-functions/lib/v2/providers/firestore.js
generated
vendored
Normal file
@@ -0,0 +1,323 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2023 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.onChangedOperation = exports.onOperation = exports.makeEndpoint = exports.makeChangedFirestoreEvent = exports.makeFirestoreEvent = exports.makeParams = exports.createBeforeSnapshot = exports.createSnapshot = exports.getOpts = exports.onDocumentDeletedWithAuthContext = exports.onDocumentDeleted = exports.onDocumentUpdatedWithAuthContext = exports.onDocumentUpdated = exports.onDocumentCreatedWithAuthContext = exports.onDocumentCreated = exports.onDocumentWrittenWithAuthContext = exports.onDocumentWritten = exports.deletedEventWithAuthContextType = exports.updatedEventWithAuthContextType = exports.createdEventWithAuthContextType = exports.writtenEventWithAuthContextType = exports.deletedEventType = exports.updatedEventType = exports.createdEventType = exports.writtenEventType = exports.Change = void 0;
|
||||
const logger = require("../../logger");
|
||||
const path_1 = require("../../common/utilities/path");
|
||||
const path_pattern_1 = require("../../common/utilities/path-pattern");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const core_1 = require("../core");
|
||||
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return core_1.Change; } });
|
||||
const options_1 = require("../options");
|
||||
const firestore_1 = require("../../common/providers/firestore");
|
||||
const trace_1 = require("../trace");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
/** @internal */
|
||||
exports.writtenEventType = "google.cloud.firestore.document.v1.written";
|
||||
/** @internal */
|
||||
exports.createdEventType = "google.cloud.firestore.document.v1.created";
|
||||
/** @internal */
|
||||
exports.updatedEventType = "google.cloud.firestore.document.v1.updated";
|
||||
/** @internal */
|
||||
exports.deletedEventType = "google.cloud.firestore.document.v1.deleted";
|
||||
/** @internal */
|
||||
exports.writtenEventWithAuthContextType = "google.cloud.firestore.document.v1.written.withAuthContext";
|
||||
/** @internal */
|
||||
exports.createdEventWithAuthContextType = "google.cloud.firestore.document.v1.created.withAuthContext";
|
||||
/** @internal */
|
||||
exports.updatedEventWithAuthContextType = "google.cloud.firestore.document.v1.updated.withAuthContext";
|
||||
/** @internal */
|
||||
exports.deletedEventWithAuthContextType = "google.cloud.firestore.document.v1.deleted.withAuthContext";
|
||||
/**
|
||||
* Event handler that triggers when a document is created, updated, or deleted in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore create, update, or delete occurs.
|
||||
*/
|
||||
function onDocumentWritten(documentOrOpts, handler) {
|
||||
return onChangedOperation(exports.writtenEventType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentWritten = onDocumentWritten;
|
||||
/**
|
||||
* Event handler that triggers when a document is created, updated, or deleted in Firestore.
|
||||
* This trigger also provides the authentication context of the principal who triggered the event.
|
||||
*
|
||||
* @param opts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore create, update, or delete occurs.
|
||||
*/
|
||||
function onDocumentWrittenWithAuthContext(documentOrOpts, handler) {
|
||||
return onChangedOperation(exports.writtenEventWithAuthContextType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentWrittenWithAuthContext = onDocumentWrittenWithAuthContext;
|
||||
/**
|
||||
* Event handler that triggers when a document is created in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore create occurs.
|
||||
*/
|
||||
function onDocumentCreated(documentOrOpts, handler) {
|
||||
return onOperation(exports.createdEventType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentCreated = onDocumentCreated;
|
||||
/**
|
||||
* Event handler that triggers when a document is created in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore create occurs.
|
||||
*/
|
||||
function onDocumentCreatedWithAuthContext(documentOrOpts, handler) {
|
||||
return onOperation(exports.createdEventWithAuthContextType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentCreatedWithAuthContext = onDocumentCreatedWithAuthContext;
|
||||
/**
|
||||
* Event handler that triggers when a document is updated in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore update occurs.
|
||||
*/
|
||||
function onDocumentUpdated(documentOrOpts, handler) {
|
||||
return onChangedOperation(exports.updatedEventType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentUpdated = onDocumentUpdated;
|
||||
/**
|
||||
* Event handler that triggers when a document is updated in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore update occurs.
|
||||
*/
|
||||
function onDocumentUpdatedWithAuthContext(documentOrOpts, handler) {
|
||||
return onChangedOperation(exports.updatedEventWithAuthContextType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentUpdatedWithAuthContext = onDocumentUpdatedWithAuthContext;
|
||||
/**
|
||||
* Event handler that triggers when a document is deleted in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore delete occurs.
|
||||
*/
|
||||
function onDocumentDeleted(documentOrOpts, handler) {
|
||||
return onOperation(exports.deletedEventType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentDeleted = onDocumentDeleted;
|
||||
/**
|
||||
* Event handler that triggers when a document is deleted in Firestore.
|
||||
*
|
||||
* @param documentOrOpts - Options or a string document path.
|
||||
* @param handler - Event handler which is run every time a Firestore delete occurs.
|
||||
*/
|
||||
function onDocumentDeletedWithAuthContext(documentOrOpts, handler) {
|
||||
return onOperation(exports.deletedEventWithAuthContextType, documentOrOpts, handler);
|
||||
}
|
||||
exports.onDocumentDeletedWithAuthContext = onDocumentDeletedWithAuthContext;
|
||||
/** @internal */
|
||||
function getOpts(documentOrOpts) {
|
||||
let document;
|
||||
let database;
|
||||
let namespace;
|
||||
let opts;
|
||||
if (typeof documentOrOpts === "string") {
|
||||
document = (0, path_1.normalizePath)(documentOrOpts);
|
||||
database = "(default)";
|
||||
namespace = "(default)";
|
||||
opts = {};
|
||||
}
|
||||
else {
|
||||
document =
|
||||
typeof documentOrOpts.document === "string"
|
||||
? (0, path_1.normalizePath)(documentOrOpts.document)
|
||||
: documentOrOpts.document;
|
||||
database = documentOrOpts.database || "(default)";
|
||||
namespace = documentOrOpts.namespace || "(default)";
|
||||
opts = { ...documentOrOpts };
|
||||
delete opts.document;
|
||||
delete opts.database;
|
||||
delete opts.namespace;
|
||||
}
|
||||
return {
|
||||
document,
|
||||
database,
|
||||
namespace,
|
||||
opts,
|
||||
};
|
||||
}
|
||||
exports.getOpts = getOpts;
|
||||
/** @hidden */
|
||||
function getPath(event) {
|
||||
return `projects/${event.project}/databases/${event.database}/documents/${event.document}`;
|
||||
}
|
||||
/** @internal */
|
||||
function createSnapshot(event) {
|
||||
var _a, _b, _c, _d;
|
||||
if (((_a = event.datacontenttype) === null || _a === void 0 ? void 0 : _a.includes("application/protobuf")) || Buffer.isBuffer(event.data)) {
|
||||
return (0, firestore_1.createSnapshotFromProtobuf)(event.data, getPath(event), event.database);
|
||||
}
|
||||
else if ((_b = event.datacontenttype) === null || _b === void 0 ? void 0 : _b.includes("application/json")) {
|
||||
return (0, firestore_1.createSnapshotFromJson)(event.data, event.source, (_c = event.data.value) === null || _c === void 0 ? void 0 : _c.createTime, (_d = event.data.value) === null || _d === void 0 ? void 0 : _d.updateTime, event.database);
|
||||
}
|
||||
else {
|
||||
logger.error(`Cannot determine payload type, datacontenttype is ${event.datacontenttype}, failing out.`);
|
||||
throw Error("Error: Cannot parse event payload.");
|
||||
}
|
||||
}
|
||||
exports.createSnapshot = createSnapshot;
|
||||
/** @internal */
|
||||
function createBeforeSnapshot(event) {
|
||||
var _a, _b, _c, _d;
|
||||
if (((_a = event.datacontenttype) === null || _a === void 0 ? void 0 : _a.includes("application/protobuf")) || Buffer.isBuffer(event.data)) {
|
||||
return (0, firestore_1.createBeforeSnapshotFromProtobuf)(event.data, getPath(event), event.database);
|
||||
}
|
||||
else if ((_b = event.datacontenttype) === null || _b === void 0 ? void 0 : _b.includes("application/json")) {
|
||||
return (0, firestore_1.createBeforeSnapshotFromJson)(event.data, event.source, (_c = event.data.oldValue) === null || _c === void 0 ? void 0 : _c.createTime, (_d = event.data.oldValue) === null || _d === void 0 ? void 0 : _d.updateTime, event.database);
|
||||
}
|
||||
else {
|
||||
logger.error(`Cannot determine payload type, datacontenttype is ${event.datacontenttype}, failing out.`);
|
||||
throw Error("Error: Cannot parse event payload.");
|
||||
}
|
||||
}
|
||||
exports.createBeforeSnapshot = createBeforeSnapshot;
|
||||
/** @internal */
|
||||
function makeParams(document, documentPattern) {
|
||||
return {
|
||||
...documentPattern.extractMatches(document),
|
||||
};
|
||||
}
|
||||
exports.makeParams = makeParams;
|
||||
/** @internal */
|
||||
function makeFirestoreEvent(eventType, event, params) {
|
||||
const data = event.data
|
||||
? eventType === exports.createdEventType || eventType === exports.createdEventWithAuthContextType
|
||||
? createSnapshot(event)
|
||||
: createBeforeSnapshot(event)
|
||||
: undefined;
|
||||
const firestoreEvent = {
|
||||
...event,
|
||||
params,
|
||||
data,
|
||||
};
|
||||
delete firestoreEvent.datacontenttype;
|
||||
delete firestoreEvent.dataschema;
|
||||
if ("authtype" in event) {
|
||||
const eventWithAuth = {
|
||||
...firestoreEvent,
|
||||
authType: event.authtype,
|
||||
authId: event.authid,
|
||||
};
|
||||
delete eventWithAuth.authtype;
|
||||
delete eventWithAuth.authid;
|
||||
return eventWithAuth;
|
||||
}
|
||||
return firestoreEvent;
|
||||
}
|
||||
exports.makeFirestoreEvent = makeFirestoreEvent;
|
||||
/** @internal */
|
||||
function makeChangedFirestoreEvent(event, params) {
|
||||
const data = event.data
|
||||
? core_1.Change.fromObjects(createBeforeSnapshot(event), createSnapshot(event))
|
||||
: undefined;
|
||||
const firestoreEvent = {
|
||||
...event,
|
||||
params,
|
||||
data,
|
||||
};
|
||||
delete firestoreEvent.datacontenttype;
|
||||
delete firestoreEvent.dataschema;
|
||||
if ("authtype" in event) {
|
||||
const eventWithAuth = {
|
||||
...firestoreEvent,
|
||||
authType: event.authtype,
|
||||
authId: event.authid,
|
||||
};
|
||||
delete eventWithAuth.authtype;
|
||||
delete eventWithAuth.authid;
|
||||
return eventWithAuth;
|
||||
}
|
||||
return firestoreEvent;
|
||||
}
|
||||
exports.makeChangedFirestoreEvent = makeChangedFirestoreEvent;
|
||||
/** @internal */
|
||||
function makeEndpoint(eventType, opts, document, database, namespace) {
|
||||
var _a;
|
||||
const baseOpts = (0, options_1.optionsToEndpoint)((0, options_1.getGlobalOptions)());
|
||||
const specificOpts = (0, options_1.optionsToEndpoint)(opts);
|
||||
const eventFilters = {
|
||||
database,
|
||||
namespace,
|
||||
};
|
||||
const eventFilterPathPatterns = {};
|
||||
const maybePattern = typeof document === "string" ? new path_pattern_1.PathPattern(document).hasWildcards() : true;
|
||||
if (maybePattern) {
|
||||
eventFilterPathPatterns.document = document;
|
||||
}
|
||||
else {
|
||||
eventFilters.document = document;
|
||||
}
|
||||
return {
|
||||
...(0, manifest_1.initV2Endpoint)((0, options_1.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,
|
||||
eventFilters,
|
||||
eventFilterPathPatterns,
|
||||
retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.makeEndpoint = makeEndpoint;
|
||||
/** @internal */
|
||||
function onOperation(eventType, documentOrOpts, handler) {
|
||||
const { document, database, namespace, opts } = getOpts(documentOrOpts);
|
||||
// wrap the handler
|
||||
const func = (raw) => {
|
||||
const event = raw;
|
||||
const documentPattern = new path_pattern_1.PathPattern(typeof document === "string" ? document : document.value());
|
||||
const params = makeParams(event.document, documentPattern);
|
||||
const firestoreEvent = makeFirestoreEvent(eventType, event, params);
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(firestoreEvent);
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = makeEndpoint(eventType, opts, document, database, namespace);
|
||||
return func;
|
||||
}
|
||||
exports.onOperation = onOperation;
|
||||
/** @internal */
|
||||
function onChangedOperation(eventType, documentOrOpts, handler) {
|
||||
const { document, database, namespace, opts } = getOpts(documentOrOpts);
|
||||
// wrap the handler
|
||||
const func = (raw) => {
|
||||
const event = raw;
|
||||
const documentPattern = new path_pattern_1.PathPattern(typeof document === "string" ? document : document.value());
|
||||
const params = makeParams(event.document, documentPattern);
|
||||
const firestoreEvent = makeChangedFirestoreEvent(event, params);
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(firestoreEvent);
|
||||
};
|
||||
func.run = handler;
|
||||
func.__endpoint = makeEndpoint(eventType, opts, document, database, namespace);
|
||||
return func;
|
||||
}
|
||||
exports.onChangedOperation = onChangedOperation;
|
||||
239
node_modules/firebase-functions/lib/v2/providers/https.d.ts
generated
vendored
Normal file
239
node_modules/firebase-functions/lib/v2/providers/https.d.ts
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
import * as express from "express";
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { CallableRequest, CallableResponse, FunctionsErrorCode, HttpsError, Request, AuthData } from "../../common/providers/https";
|
||||
import { ManifestEndpoint } from "../../runtime/manifest";
|
||||
import { GlobalOptions, SupportedRegion } from "../options";
|
||||
import { Expression } from "../../params";
|
||||
import { SecretParam } from "../../params/types";
|
||||
import * as options from "../options";
|
||||
export { Request, CallableRequest, CallableResponse, FunctionsErrorCode, HttpsError };
|
||||
/**
|
||||
* Options that can be set on an onRequest HTTPS function.
|
||||
*/
|
||||
export interface HttpsOptions extends Omit<GlobalOptions, "region" | "enforceAppCheck"> {
|
||||
/**
|
||||
* If true, do not deploy or emulate this function.
|
||||
*/
|
||||
omit?: boolean | Expression<boolean>;
|
||||
/** HTTP functions can override global options and can specify multiple regions to deploy to. */
|
||||
region?: SupportedRegion | string | Array<SupportedRegion | string> | Expression<string> | ResetValue;
|
||||
/** If true, allows CORS on requests to this function.
|
||||
* If this is a `string` or `RegExp`, allows requests from domains that match the provided value.
|
||||
* If this is an `Array`, allows requests from domains matching at least one entry of the array.
|
||||
* Defaults to true for {@link https.CallableFunction} and false otherwise.
|
||||
*/
|
||||
cors?: string | boolean | RegExp | Array<string | RegExp>;
|
||||
/**
|
||||
* 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)[];
|
||||
/**
|
||||
* Invoker to set access control on https functions.
|
||||
*/
|
||||
invoker?: "public" | "private" | string | string[];
|
||||
}
|
||||
/**
|
||||
* Options that can be set on a callable HTTPS function.
|
||||
*/
|
||||
export interface CallableOptions<T = any> extends HttpsOptions {
|
||||
/**
|
||||
* Determines whether Firebase AppCheck is enforced.
|
||||
* When true, requests with invalid tokens autorespond with a 401
|
||||
* (Unauthorized) error.
|
||||
* When false, requests with invalid tokens set event.app to undefiend.
|
||||
*/
|
||||
enforceAppCheck?: boolean;
|
||||
/**
|
||||
* Determines whether Firebase App Check token is consumed on request. Defaults to false.
|
||||
*
|
||||
* @remarks
|
||||
* Set this to true to enable the App Check replay protection feature by consuming the App Check token on callable
|
||||
* request. Tokens that are found to be already consumed will have request.app.alreadyConsumed property set true.
|
||||
*
|
||||
*
|
||||
* Tokens are only considered to be consumed if it is sent to the App Check service by setting this option to true.
|
||||
* Other uses of the token do not consume it.
|
||||
*
|
||||
* This replay protection feature requires an additional network call to the App Check backend and forces the clients
|
||||
* to obtain a fresh attestation from the chosen attestation providers. This can therefore negatively impact
|
||||
* performance and can potentially deplete your attestation providers' quotas faster. Use this feature only for
|
||||
* protecting low volume, security critical, or expensive operations.
|
||||
*
|
||||
* This option does not affect the enforceAppCheck option. Setting the latter to true will cause the callable function
|
||||
* to automatically respond with a 401 Unauthorized status code when request includes an invalid App Check token.
|
||||
* When request includes valid but consumed App Check tokens, requests will not be automatically rejected. Instead,
|
||||
* the request.app.alreadyConsumed property will be set to true and pass the execution to the handler code for making
|
||||
* further decisions, such as requiring additional security checks or rejecting the request.
|
||||
*/
|
||||
consumeAppCheckToken?: boolean;
|
||||
/**
|
||||
* Time in seconds between sending heartbeat messages to keep the connection
|
||||
* alive. Set to `null` to disable heartbeats.
|
||||
*
|
||||
* Defaults to 30 seconds.
|
||||
*/
|
||||
heartbeatSeconds?: number | null;
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* Callback for whether a request is authorized.
|
||||
*
|
||||
* Designed to allow reusable auth policies to be passed as an options object. Two built-in reusable policies exist:
|
||||
* isSignedIn and hasClaim.
|
||||
*/
|
||||
authPolicy?: (auth: AuthData | null, data: T) => boolean | Promise<boolean>;
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* An auth policy that requires a user to be signed in.
|
||||
*/
|
||||
export declare const isSignedIn: () => (auth: AuthData | null) => boolean;
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* An auth policy that requires a user to be both signed in and have a specific claim (optionally with a specific value)
|
||||
*/
|
||||
export declare const hasClaim: (claim: string, value?: string) => (auth: AuthData | null) => boolean;
|
||||
/**
|
||||
* Handles HTTPS requests.
|
||||
*/
|
||||
export type HttpsFunction = ((
|
||||
/** An Express request object representing the HTTPS call to the function. */
|
||||
req: Request,
|
||||
/** An Express response object, for this function to respond to callers. */
|
||||
res: express.Response) => void | Promise<void>) & {
|
||||
/** @alpha */
|
||||
__trigger?: unknown;
|
||||
/** @alpha */
|
||||
__endpoint: ManifestEndpoint;
|
||||
};
|
||||
/**
|
||||
* Creates a callable method for clients to call using a Firebase SDK.
|
||||
*/
|
||||
export interface CallableFunction<T, Return, Stream = unknown> extends HttpsFunction {
|
||||
/** Executes the handler function with the provided data as input. Used for unit testing.
|
||||
* @param data - An input for the handler function.
|
||||
* @returns The output of the handler function.
|
||||
*/
|
||||
run(request: CallableRequest<T>): Return;
|
||||
stream(request: CallableRequest<T>, response: CallableResponse<Stream>): {
|
||||
stream: AsyncIterable<Stream>;
|
||||
output: Return;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Handles HTTPS requests.
|
||||
* @param opts - Options to set on this function
|
||||
* @param handler - A function that takes a {@link https.Request} and response object, same signature as an Express app.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onRequest(opts: HttpsOptions, handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
|
||||
/**
|
||||
* Handles HTTPS requests.
|
||||
* @param handler - A function that takes a {@link https.Request} and response object, same signature as an Express app.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onRequest(handler: (request: Request, response: express.Response) => void | Promise<void>): HttpsFunction;
|
||||
/**
|
||||
* Declares a callable method for clients to call using a Firebase SDK.
|
||||
* @param opts - Options to set on this function.
|
||||
* @param handler - A function that takes a {@link https.CallableRequest}.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onCall<T = any, Return = any | Promise<any>, Stream = unknown>(opts: CallableOptions<T>, handler: (request: CallableRequest<T>, response?: CallableResponse<Stream>) => Return): CallableFunction<T, Return extends Promise<unknown> ? Return : Promise<Return>, Stream>;
|
||||
/**
|
||||
* Declares a callable method for clients to call using a Firebase SDK.
|
||||
* @param handler - A function that takes a {@link https.CallableRequest}.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onCall<T = any, Return = any | Promise<any>, Stream = unknown>(handler: (request: CallableRequest<T>, response?: CallableResponse<Stream>) => Return): CallableFunction<T, Return extends Promise<unknown> ? Return : Promise<Return>>;
|
||||
interface ZodType<T = any> {
|
||||
__output: T;
|
||||
}
|
||||
interface GenkitRunOptions {
|
||||
context?: any;
|
||||
}
|
||||
type GenkitAction<I extends ZodType = ZodType<any>, O extends ZodType = ZodType<any>, S extends ZodType = ZodType<any>> = {
|
||||
run(input: I["__output"], options: GenkitRunOptions): Promise<{
|
||||
result: O["__output"];
|
||||
}>;
|
||||
stream(input: I["__output"], options: GenkitRunOptions): {
|
||||
stream: AsyncIterable<S["__output"]>;
|
||||
output: Promise<O["__output"]>;
|
||||
};
|
||||
__action: {
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
type ActionInput<F extends GenkitAction> = F extends GenkitAction<infer I extends ZodType, any, any> ? I["__output"] : never;
|
||||
type ActionOutput<F extends GenkitAction> = F extends GenkitAction<any, infer O extends ZodType, any> ? O["__output"] : never;
|
||||
type ActionStream<F extends GenkitAction> = F extends GenkitAction<any, any, infer S extends ZodType> ? S["__output"] : never;
|
||||
export declare function onCallGenkit<A extends GenkitAction>(action: A): CallableFunction<ActionInput<A>, Promise<ActionOutput<A>>, ActionStream<A>>;
|
||||
export declare function onCallGenkit<A extends GenkitAction>(opts: CallableOptions<ActionInput<A>>, flow: A): CallableFunction<ActionInput<A>, Promise<ActionOutput<A>>, ActionStream<A>>;
|
||||
246
node_modules/firebase-functions/lib/v2/providers/https.js
generated
vendored
Normal file
246
node_modules/firebase-functions/lib/v2/providers/https.js
generated
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
"use strict";
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2021 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.onCallGenkit = exports.onCall = exports.onRequest = exports.hasClaim = exports.isSignedIn = exports.HttpsError = void 0;
|
||||
/**
|
||||
* Cloud functions to handle HTTPS request or callable RPCs.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const cors = require("cors");
|
||||
const encoding_1 = require("../../common/encoding");
|
||||
const trace_1 = require("../trace");
|
||||
const debug_1 = require("../../common/debug");
|
||||
const https_1 = require("../../common/providers/https");
|
||||
Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return https_1.HttpsError; } });
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
const logger = require("../../logger");
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* An auth policy that requires a user to be signed in.
|
||||
*/
|
||||
const isSignedIn = () => (auth) => !!auth;
|
||||
exports.isSignedIn = isSignedIn;
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* An auth policy that requires a user to be both signed in and have a specific claim (optionally with a specific value)
|
||||
*/
|
||||
const hasClaim = (claim, value) => (auth) => {
|
||||
if (!auth) {
|
||||
return false;
|
||||
}
|
||||
if (!(claim in auth.token)) {
|
||||
return false;
|
||||
}
|
||||
return !value || auth.token[claim] === value;
|
||||
};
|
||||
exports.hasClaim = hasClaim;
|
||||
function onRequest(optsOrHandler, handler) {
|
||||
let opts;
|
||||
if (arguments.length === 1) {
|
||||
opts = {};
|
||||
handler = optsOrHandler;
|
||||
}
|
||||
else {
|
||||
opts = optsOrHandler;
|
||||
}
|
||||
if ((0, debug_1.isDebugFeatureEnabled)("enableCors") || "cors" in opts) {
|
||||
let origin = opts.cors;
|
||||
if ((0, debug_1.isDebugFeatureEnabled)("enableCors")) {
|
||||
// Respect `cors: false` to turn off cors even if debug feature is enabled.
|
||||
origin = opts.cors === false ? false : true;
|
||||
}
|
||||
// Arrays cause the access-control-allow-origin header to be dynamic based
|
||||
// on the origin header of the request. If there is only one element in the
|
||||
// array, this is unnecessary.
|
||||
if (Array.isArray(origin) && origin.length === 1) {
|
||||
origin = origin[0];
|
||||
}
|
||||
const middleware = cors({ origin });
|
||||
const userProvidedHandler = handler;
|
||||
handler = (req, res) => {
|
||||
return new Promise((resolve) => {
|
||||
res.on("finish", resolve);
|
||||
middleware(req, res, () => {
|
||||
resolve(userProvidedHandler(req, res));
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
handler = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler));
|
||||
Object.defineProperty(handler, "__trigger", {
|
||||
get: () => {
|
||||
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
||||
// global options calls region a scalar and https allows it to be an array,
|
||||
// but optionsToTriggerAnnotations handles both cases.
|
||||
const specificOpts = options.optionsToTriggerAnnotations(opts);
|
||||
const trigger = {
|
||||
platform: "gcfv2",
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
},
|
||||
httpsTrigger: {
|
||||
allowInsecure: false,
|
||||
},
|
||||
};
|
||||
(0, encoding_1.convertIfPresent)(trigger.httpsTrigger, options.getGlobalOptions(), "invoker", "invoker", encoding_1.convertInvoker);
|
||||
(0, encoding_1.convertIfPresent)(trigger.httpsTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
|
||||
return trigger;
|
||||
},
|
||||
});
|
||||
const globalOpts = options.getGlobalOptions();
|
||||
const baseOpts = options.optionsToEndpoint(globalOpts);
|
||||
// global options calls region a scalar and https allows it to be an array,
|
||||
// but optionsToTriggerAnnotations handles both cases.
|
||||
const specificOpts = options.optionsToEndpoint(opts);
|
||||
const endpoint = {
|
||||
...(0, manifest_1.initV2Endpoint)(globalOpts, opts),
|
||||
platform: "gcfv2",
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
},
|
||||
httpsTrigger: {},
|
||||
};
|
||||
(0, encoding_1.convertIfPresent)(endpoint.httpsTrigger, globalOpts, "invoker", "invoker", encoding_1.convertInvoker);
|
||||
(0, encoding_1.convertIfPresent)(endpoint.httpsTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
|
||||
handler.__endpoint = endpoint;
|
||||
return handler;
|
||||
}
|
||||
exports.onRequest = onRequest;
|
||||
function onCall(optsOrHandler, handler) {
|
||||
var _a;
|
||||
let opts;
|
||||
if (arguments.length === 1) {
|
||||
opts = {};
|
||||
handler = optsOrHandler;
|
||||
}
|
||||
else {
|
||||
opts = optsOrHandler;
|
||||
}
|
||||
let origin = (0, debug_1.isDebugFeatureEnabled)("enableCors") ? true : "cors" in opts ? opts.cors : true;
|
||||
// Arrays cause the access-control-allow-origin header to be dynamic based
|
||||
// on the origin header of the request. If there is only one element in the
|
||||
// array, this is unnecessary.
|
||||
if (Array.isArray(origin) && origin.length === 1) {
|
||||
origin = origin[0];
|
||||
}
|
||||
// fix the length of handler to make the call to handler consistent
|
||||
const fixedLen = (req, resp) => handler(req, resp);
|
||||
let func = (0, https_1.onCallHandler)({
|
||||
cors: { origin, methods: "POST" },
|
||||
enforceAppCheck: (_a = opts.enforceAppCheck) !== null && _a !== void 0 ? _a : options.getGlobalOptions().enforceAppCheck,
|
||||
consumeAppCheckToken: opts.consumeAppCheckToken,
|
||||
heartbeatSeconds: opts.heartbeatSeconds,
|
||||
authPolicy: opts.authPolicy,
|
||||
}, fixedLen, "gcfv2");
|
||||
func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(func));
|
||||
Object.defineProperty(func, "__trigger", {
|
||||
get: () => {
|
||||
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
||||
// global options calls region a scalar and https allows it to be an array,
|
||||
// but optionsToTriggerAnnotations handles both cases.
|
||||
const specificOpts = options.optionsToTriggerAnnotations(opts);
|
||||
return {
|
||||
platform: "gcfv2",
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
"deployment-callable": "true",
|
||||
},
|
||||
httpsTrigger: {
|
||||
allowInsecure: false,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
||||
// global options calls region a scalar and https allows it to be an array,
|
||||
// but optionsToEndpoint handles both cases.
|
||||
const specificOpts = options.optionsToEndpoint(opts);
|
||||
func.__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,
|
||||
},
|
||||
callableTrigger: {},
|
||||
};
|
||||
// TODO: in the next major version, do auth/appcheck in these helper methods too.
|
||||
func.run = (0, onInit_1.withInit)(handler);
|
||||
func.stream = () => {
|
||||
return {
|
||||
stream: {
|
||||
next() {
|
||||
return Promise.reject("Coming soon");
|
||||
},
|
||||
},
|
||||
output: Promise.reject("Coming soon"),
|
||||
};
|
||||
};
|
||||
return func;
|
||||
}
|
||||
exports.onCall = onCall;
|
||||
function onCallGenkit(optsOrAction, action) {
|
||||
var _a;
|
||||
let opts;
|
||||
if (arguments.length === 2) {
|
||||
opts = optsOrAction;
|
||||
}
|
||||
else {
|
||||
opts = {};
|
||||
action = optsOrAction;
|
||||
}
|
||||
if (!((_a = opts.secrets) === null || _a === void 0 ? void 0 : _a.length)) {
|
||||
logger.debug(`Genkit function for ${action.__action.name} is not bound to any secret. This may mean that you are not storing API keys as a secret or that you are not binding your secret to this function. See https://firebase.google.com/docs/functions/config-env?gen=2nd#secret_parameters for more information.`);
|
||||
}
|
||||
const cloudFunction = onCall(opts, async (req, res) => {
|
||||
const context = {};
|
||||
(0, encoding_1.copyIfPresent)(context, req, "auth", "app", "instanceIdToken");
|
||||
if (!req.acceptsStreaming) {
|
||||
const { result } = await action.run(req.data, { context });
|
||||
return result;
|
||||
}
|
||||
const { stream, output } = action.stream(req.data, { context });
|
||||
for await (const chunk of stream) {
|
||||
await res.sendChunk(chunk);
|
||||
}
|
||||
return output;
|
||||
});
|
||||
cloudFunction.__endpoint.callableTrigger.genkitAction = action.__action.name;
|
||||
return cloudFunction;
|
||||
}
|
||||
exports.onCallGenkit = onCallGenkit;
|
||||
155
node_modules/firebase-functions/lib/v2/providers/identity.d.ts
generated
vendored
Normal file
155
node_modules/firebase-functions/lib/v2/providers/identity.d.ts
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Cloud functions to handle events from Google Cloud Identity Platform.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { AuthBlockingEvent, AuthBlockingEventType, AuthUserRecord, BeforeCreateResponse, BeforeSignInResponse, BeforeEmailResponse, BeforeSmsResponse, HandlerV2, HttpsError, MaybeAsync } from "../../common/providers/identity";
|
||||
import { BlockingFunction } from "../../v1/cloud-functions";
|
||||
import { Expression } from "../../params";
|
||||
import * as options from "../options";
|
||||
import { SecretParam } from "../../params/types";
|
||||
export { AuthUserRecord, AuthBlockingEvent, HttpsError };
|
||||
/** @hidden Internally used when parsing the options. */
|
||||
interface InternalOptions {
|
||||
opts: options.GlobalOptions;
|
||||
idToken: boolean;
|
||||
accessToken: boolean;
|
||||
refreshToken: boolean;
|
||||
}
|
||||
/**
|
||||
* All function options plus idToken, accessToken, and refreshToken.
|
||||
*/
|
||||
export interface BlockingOptions {
|
||||
/** Pass the ID Token credential to the function. */
|
||||
idToken?: boolean;
|
||||
/** Pass the Access Token credential to the function. */
|
||||
accessToken?: boolean;
|
||||
/** Pass the Refresh Token credential to the function. */
|
||||
refreshToken?: boolean;
|
||||
/**
|
||||
* 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)[];
|
||||
}
|
||||
/**
|
||||
* Handles an event that is triggered before a user is created.
|
||||
* @param handler - Event handler which is run every time before a user is created.
|
||||
*/
|
||||
export declare function beforeUserCreated(handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeCreateResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before a user is created.
|
||||
* @param opts - Object containing function options.
|
||||
* @param handler - Event handler which is run every time before a user is created.
|
||||
*/
|
||||
export declare function beforeUserCreated(opts: BlockingOptions, handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeCreateResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before a user is signed in.
|
||||
* @param handler - Event handler which is run every time before a user is signed in.
|
||||
*/
|
||||
export declare function beforeUserSignedIn(handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeSignInResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before a user is signed in.
|
||||
* @param opts - Object containing function options.
|
||||
* @param handler - Event handler which is run every time before a user is signed in.
|
||||
*/
|
||||
export declare function beforeUserSignedIn(opts: BlockingOptions, handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeSignInResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before an email is sent to a user.
|
||||
* @param handler - Event handler that is run before an email is sent to a user.
|
||||
*/
|
||||
export declare function beforeEmailSent(handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeEmailResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before an email is sent to a user.
|
||||
* @param opts - Object containing function options.
|
||||
* @param handler - Event handler that is run before an email is sent to a user.
|
||||
*/
|
||||
export declare function beforeEmailSent(opts: Omit<BlockingOptions, "idToken" | "accessToken" | "refreshToken">, handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeEmailResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before an SMS is sent to a user.
|
||||
* @param handler - Event handler that is run before an SMS is sent to a user.
|
||||
*/
|
||||
export declare function beforeSmsSent(handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeSmsResponse | void>): BlockingFunction;
|
||||
/**
|
||||
* Handles an event that is triggered before an SMS is sent to a user.
|
||||
* @param opts - Object containing function options.
|
||||
* @param handler - Event handler that is run before an SMS is sent to a user.
|
||||
*/
|
||||
export declare function beforeSmsSent(opts: Omit<BlockingOptions, "idToken" | "accessToken" | "refreshToken">, handler: (event: AuthBlockingEvent) => MaybeAsync<BeforeSmsResponse | void>): BlockingFunction;
|
||||
/** @hidden */
|
||||
export declare function beforeOperation(eventType: AuthBlockingEventType, optsOrHandler: BlockingOptions | ((event: AuthBlockingEvent) => MaybeAsync<BeforeCreateResponse | BeforeSignInResponse | BeforeEmailResponse | BeforeSmsResponse | void>), handler: HandlerV2): BlockingFunction;
|
||||
/** @hidden */
|
||||
export declare function getOpts(blockingOptions: BlockingOptions): InternalOptions;
|
||||
124
node_modules/firebase-functions/lib/v2/providers/identity.js
generated
vendored
Normal file
124
node_modules/firebase-functions/lib/v2/providers/identity.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
"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.getOpts = exports.beforeOperation = exports.beforeSmsSent = exports.beforeEmailSent = exports.beforeUserSignedIn = exports.beforeUserCreated = exports.HttpsError = void 0;
|
||||
const identity_1 = require("../../common/providers/identity");
|
||||
Object.defineProperty(exports, "HttpsError", { enumerable: true, get: function () { return identity_1.HttpsError; } });
|
||||
const trace_1 = require("../trace");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
/**
|
||||
* Handles an event that is triggered before a user is created.
|
||||
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user creation).
|
||||
* @param handler? - If defined, an event handler which is run every time before a user is created.
|
||||
*/
|
||||
function beforeUserCreated(optsOrHandler, handler) {
|
||||
return beforeOperation("beforeCreate", optsOrHandler, handler);
|
||||
}
|
||||
exports.beforeUserCreated = beforeUserCreated;
|
||||
/**
|
||||
* Handles an event that is triggered before a user is signed in.
|
||||
* @param optsOrHandler - Either an object containing function options, or an event handler (run before user signin).
|
||||
* @param handler - Event handler which is run every time before a user is signed in.
|
||||
*/
|
||||
function beforeUserSignedIn(optsOrHandler, handler) {
|
||||
return beforeOperation("beforeSignIn", optsOrHandler, handler);
|
||||
}
|
||||
exports.beforeUserSignedIn = beforeUserSignedIn;
|
||||
/**
|
||||
* Handles an event that is triggered before an email is sent to a user.
|
||||
* @param optsOrHandler- Either an object containing function options, or an event handler that is run before an email is sent to a user.
|
||||
* @param handler - Event handler that is run before an email is sent to a user.
|
||||
*/
|
||||
function beforeEmailSent(optsOrHandler, handler) {
|
||||
return beforeOperation("beforeSendEmail", optsOrHandler, handler);
|
||||
}
|
||||
exports.beforeEmailSent = beforeEmailSent;
|
||||
/**
|
||||
* Handles an event that is triggered before an SMS is sent to a user.
|
||||
* @param optsOrHandler - Either an object containing function options, or an event handler that is run before an SMS is sent to a user.
|
||||
* @param handler - Event handler that is run before an SMS is sent to a user.
|
||||
*/
|
||||
function beforeSmsSent(optsOrHandler, handler) {
|
||||
return beforeOperation("beforeSendSms", optsOrHandler, handler);
|
||||
}
|
||||
exports.beforeSmsSent = beforeSmsSent;
|
||||
/** @hidden */
|
||||
function beforeOperation(eventType, optsOrHandler, handler) {
|
||||
if (!handler || typeof optsOrHandler === "function") {
|
||||
handler = optsOrHandler;
|
||||
optsOrHandler = {};
|
||||
}
|
||||
const { opts, ...blockingOptions } = getOpts(optsOrHandler);
|
||||
// Create our own function that just calls the provided function so we know for sure that
|
||||
// handler takes one argument. This is something common/providers/identity depends on.
|
||||
const annotatedHandler = Object.assign(handler, { platform: "gcfv2" });
|
||||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)((0, identity_1.wrapHandler)(eventType, annotatedHandler)));
|
||||
const legacyEventType = `providers/cloud.auth/eventTypes/user.${eventType}`;
|
||||
/** Endpoint */
|
||||
const baseOptsEndpoint = options.optionsToEndpoint(options.getGlobalOptions());
|
||||
const specificOptsEndpoint = options.optionsToEndpoint(opts);
|
||||
func.__endpoint = {
|
||||
...(0, manifest_1.initV2Endpoint)(options.getGlobalOptions(), opts),
|
||||
platform: "gcfv2",
|
||||
...baseOptsEndpoint,
|
||||
...specificOptsEndpoint,
|
||||
labels: {
|
||||
...baseOptsEndpoint === null || baseOptsEndpoint === void 0 ? void 0 : baseOptsEndpoint.labels,
|
||||
...specificOptsEndpoint === null || specificOptsEndpoint === void 0 ? void 0 : specificOptsEndpoint.labels,
|
||||
},
|
||||
blockingTrigger: {
|
||||
eventType: legacyEventType,
|
||||
options: {
|
||||
...((eventType === "beforeCreate" || eventType === "beforeSignIn") && blockingOptions),
|
||||
},
|
||||
},
|
||||
};
|
||||
func.__requiredAPIs = [
|
||||
{
|
||||
api: "identitytoolkit.googleapis.com",
|
||||
reason: "Needed for auth blocking functions",
|
||||
},
|
||||
];
|
||||
func.run = handler;
|
||||
return func;
|
||||
}
|
||||
exports.beforeOperation = beforeOperation;
|
||||
/** @hidden */
|
||||
function getOpts(blockingOptions) {
|
||||
const accessToken = blockingOptions.accessToken || false;
|
||||
const idToken = blockingOptions.idToken || false;
|
||||
const refreshToken = blockingOptions.refreshToken || false;
|
||||
const opts = { ...blockingOptions };
|
||||
delete opts.accessToken;
|
||||
delete opts.idToken;
|
||||
delete opts.refreshToken;
|
||||
return {
|
||||
opts,
|
||||
accessToken,
|
||||
idToken,
|
||||
refreshToken,
|
||||
};
|
||||
}
|
||||
exports.getOpts = getOpts;
|
||||
181
node_modules/firebase-functions/lib/v2/providers/pubsub.d.ts
generated
vendored
Normal file
181
node_modules/firebase-functions/lib/v2/providers/pubsub.d.ts
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { CloudEvent, CloudFunction } from "../core";
|
||||
import { Expression } from "../../params";
|
||||
import * as options from "../options";
|
||||
import { SecretParam } from "../../params/types";
|
||||
/**
|
||||
* Google Cloud Pub/Sub is a globally distributed message bus that automatically scales as you need it.
|
||||
* You can create a function ({@link onMessagePublished}) that handles pub/sub events by using functions.pubsub.
|
||||
*
|
||||
* This function triggers whenever a new pub/sub message is sent to a specific topic.
|
||||
* You must specify the Pub/Sub topic name that you want to trigger your function, and set the event within the
|
||||
* onPublish() event handler.
|
||||
*
|
||||
* PubSub Topic:
|
||||
* <ul>
|
||||
* <li>A resource that you can publish messages to and then consume those messages via subscriptions.
|
||||
* <li>An isolated data stream for pub/sub messages.
|
||||
* <li>Messages are published to a topic.
|
||||
* <li>Messages are listened to via a subscription.
|
||||
* <li>Each subscription listens to the messages published to exactly one topic.
|
||||
*
|
||||
* Subscriptions - Resource that listens to the messages published by exactly one topic.
|
||||
*
|
||||
* [More info here](https://firebase.google.com/docs/functions/pubsub-events)
|
||||
*/
|
||||
/**
|
||||
* Interface representing a Google Cloud Pub/Sub message.
|
||||
*
|
||||
* @param data - Payload of a Pub/Sub message.
|
||||
* @typeParam T - Type representing `Message.data`'s JSON format
|
||||
*/
|
||||
export declare class Message<T> {
|
||||
/**
|
||||
* Autogenerated ID that uniquely identifies this message.
|
||||
*/
|
||||
readonly messageId: string;
|
||||
/**
|
||||
* Time the message was published
|
||||
*/
|
||||
readonly publishTime: string;
|
||||
/**
|
||||
* The data payload of this message object as a base64-encoded string.
|
||||
*/
|
||||
readonly data: string;
|
||||
/**
|
||||
* User-defined attributes published with the message, if any.
|
||||
*/
|
||||
readonly attributes: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* User-defined key used to ensure ordering amongst messages with the same key.
|
||||
*/
|
||||
readonly orderingKey: string;
|
||||
/** @hidden */
|
||||
private _json;
|
||||
/**
|
||||
* @hidden
|
||||
* @alpha
|
||||
*/
|
||||
constructor(data: any);
|
||||
/**
|
||||
* The JSON data payload of this message object, if any.
|
||||
*/
|
||||
get json(): T;
|
||||
/**
|
||||
* Returns a JSON-serializable representation of this object.
|
||||
*
|
||||
* @returns A JSON-serializable representation of this object.
|
||||
*/
|
||||
toJSON(): any;
|
||||
}
|
||||
/**
|
||||
* The interface published in a Pub/Sub publish subscription.
|
||||
* @typeParam T - Type representing `Message.data`'s JSON format
|
||||
*/
|
||||
export interface MessagePublishedData<T = any> {
|
||||
/** Google Cloud Pub/Sub message. */
|
||||
readonly message: Message<T>;
|
||||
/** A subscription resource. */
|
||||
readonly subscription: string;
|
||||
}
|
||||
/** PubSubOptions extend EventHandlerOptions but must include a topic. */
|
||||
export interface PubSubOptions extends options.EventHandlerOptions {
|
||||
/** The Pub/Sub topic to watch for message events */
|
||||
topic: 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;
|
||||
}
|
||||
/**
|
||||
* Handle a message being published to a Pub/Sub topic.
|
||||
* @param topic - The Pub/Sub topic to watch for message events.
|
||||
* @param handler - runs every time a Cloud Pub/Sub message is published
|
||||
* @typeParam T - Type representing `Message.data`'s JSON format
|
||||
*/
|
||||
export declare function onMessagePublished<T = any>(topic: string, handler: (event: CloudEvent<MessagePublishedData<T>>) => any | Promise<any>): CloudFunction<CloudEvent<MessagePublishedData<T>>>;
|
||||
/**
|
||||
* Handle a message being published to a Pub/Sub topic.
|
||||
* @param options - Option containing information (topic) for event
|
||||
* @param handler - runs every time a Cloud Pub/Sub message is published
|
||||
* @typeParam T - Type representing `Message.data`'s JSON format
|
||||
*/
|
||||
export declare function onMessagePublished<T = any>(options: PubSubOptions, handler: (event: CloudEvent<MessagePublishedData<T>>) => any | Promise<any>): CloudFunction<CloudEvent<MessagePublishedData<T>>>;
|
||||
173
node_modules/firebase-functions/lib/v2/providers/pubsub.js
generated
vendored
Normal file
173
node_modules/firebase-functions/lib/v2/providers/pubsub.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
"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.onMessagePublished = exports.Message = void 0;
|
||||
/**
|
||||
* Cloud functions to handle events from Google Cloud Pub/Sub.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const encoding_1 = require("../../common/encoding");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const trace_1 = require("../trace");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
/**
|
||||
* Google Cloud Pub/Sub is a globally distributed message bus that automatically scales as you need it.
|
||||
* You can create a function ({@link onMessagePublished}) that handles pub/sub events by using functions.pubsub.
|
||||
*
|
||||
* This function triggers whenever a new pub/sub message is sent to a specific topic.
|
||||
* You must specify the Pub/Sub topic name that you want to trigger your function, and set the event within the
|
||||
* onPublish() event handler.
|
||||
*
|
||||
* PubSub Topic:
|
||||
* <ul>
|
||||
* <li>A resource that you can publish messages to and then consume those messages via subscriptions.
|
||||
* <li>An isolated data stream for pub/sub messages.
|
||||
* <li>Messages are published to a topic.
|
||||
* <li>Messages are listened to via a subscription.
|
||||
* <li>Each subscription listens to the messages published to exactly one topic.
|
||||
*
|
||||
* Subscriptions - Resource that listens to the messages published by exactly one topic.
|
||||
*
|
||||
* [More info here](https://firebase.google.com/docs/functions/pubsub-events)
|
||||
*/
|
||||
/**
|
||||
* Interface representing a Google Cloud Pub/Sub message.
|
||||
*
|
||||
* @param data - Payload of a Pub/Sub message.
|
||||
* @typeParam T - Type representing `Message.data`'s JSON format
|
||||
*/
|
||||
class Message {
|
||||
/**
|
||||
* @hidden
|
||||
* @alpha
|
||||
*/
|
||||
constructor(data) {
|
||||
this.messageId = data.messageId;
|
||||
this.data = data.data;
|
||||
this.attributes = data.attributes || {};
|
||||
this.orderingKey = data.orderingKey || "";
|
||||
this.publishTime = data.publishTime || new Date().toISOString();
|
||||
this._json = data.json;
|
||||
}
|
||||
/**
|
||||
* The JSON data payload of this message object, if any.
|
||||
*/
|
||||
get json() {
|
||||
if (typeof this._json === "undefined") {
|
||||
try {
|
||||
this._json = JSON.parse(Buffer.from(this.data, "base64").toString("utf8"));
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`Unable to parse Pub/Sub message data as JSON: ${err.message}`);
|
||||
}
|
||||
}
|
||||
return this._json;
|
||||
}
|
||||
/**
|
||||
* Returns a JSON-serializable representation of this object.
|
||||
*
|
||||
* @returns A JSON-serializable representation of this object.
|
||||
*/
|
||||
toJSON() {
|
||||
const json = {
|
||||
messageId: this.messageId,
|
||||
data: this.data,
|
||||
publishTime: this.publishTime,
|
||||
};
|
||||
if (Object.keys(this.attributes).length) {
|
||||
json.attributes = this.attributes;
|
||||
}
|
||||
if (this.orderingKey) {
|
||||
json.orderingKey = this.orderingKey;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
exports.Message = Message;
|
||||
/**
|
||||
* Handle a message being published to a Pub/Sub topic.
|
||||
* @param topicOrOptions - A string representing the PubSub topic or an option (which contains the topic)
|
||||
* @param handler - runs every time a Cloud Pub/Sub message is published
|
||||
* @typeParam T - Type representing `Message.data`'s JSON format
|
||||
*/
|
||||
function onMessagePublished(topicOrOptions, handler) {
|
||||
var _a;
|
||||
let topic;
|
||||
let opts;
|
||||
if (typeof topicOrOptions === "string") {
|
||||
topic = topicOrOptions;
|
||||
opts = {};
|
||||
}
|
||||
else {
|
||||
topic = topicOrOptions.topic;
|
||||
opts = { ...topicOrOptions };
|
||||
delete opts.topic;
|
||||
}
|
||||
const func = (raw) => {
|
||||
const messagePublishedData = raw.data;
|
||||
messagePublishedData.message = new Message(messagePublishedData.message);
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw);
|
||||
};
|
||||
func.run = handler;
|
||||
Object.defineProperty(func, "__trigger", {
|
||||
get: () => {
|
||||
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
||||
const specificOpts = options.optionsToTriggerAnnotations(opts);
|
||||
return {
|
||||
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: "google.cloud.pubsub.topic.v1.messagePublished",
|
||||
resource: `projects/${process.env.GCLOUD_PROJECT}/topics/${topic}`,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
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: "google.cloud.pubsub.topic.v1.messagePublished",
|
||||
eventFilters: { topic },
|
||||
retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
(0, encoding_1.copyIfPresent)(endpoint.eventTrigger, opts, "retry", "retry");
|
||||
func.__endpoint = endpoint;
|
||||
return func;
|
||||
}
|
||||
exports.onMessagePublished = onMessagePublished;
|
||||
63
node_modules/firebase-functions/lib/v2/providers/remoteConfig.d.ts
generated
vendored
Normal file
63
node_modules/firebase-functions/lib/v2/providers/remoteConfig.d.ts
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import { CloudEvent, CloudFunction } from "../core";
|
||||
import { EventHandlerOptions } from "../options";
|
||||
/** All the fields associated with the person/service account that wrote a Remote Config template. */
|
||||
export interface ConfigUser {
|
||||
/** Display name. */
|
||||
name: string;
|
||||
/** Email address. */
|
||||
email: string;
|
||||
/** Image URL. */
|
||||
imageUrl: string;
|
||||
}
|
||||
/** What type of update was associated with the Remote Config template version. */
|
||||
export type ConfigUpdateOrigin =
|
||||
/** Catch-all for unrecognized values. */
|
||||
"REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED"
|
||||
/** The update came from the Firebase UI. */
|
||||
| "CONSOLE"
|
||||
/** The update came from the Remote Config REST API. */
|
||||
| "REST_API"
|
||||
/** The update came from the Firebase Admin Node SDK. */
|
||||
| "ADMIN_SDK_NODE";
|
||||
/** Where the Remote Config update action originated. */
|
||||
export type ConfigUpdateType =
|
||||
/** Catch-all for unrecognized enum values */
|
||||
"REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED"
|
||||
/** A regular incremental update */
|
||||
| "INCREMENTAL_UPDATE"
|
||||
/** A forced update. The ETag was specified as "*" in an UpdateRemoteConfigRequest request or the "Force Update" button was pressed on the console */
|
||||
| "FORCED_UPDATE"
|
||||
/** A rollback to a previous Remote Config template */
|
||||
| "ROLLBACK";
|
||||
/** The data within Firebase Remote Config update events. */
|
||||
export interface ConfigUpdateData {
|
||||
/** The version number of the version's corresponding Remote Config template. */
|
||||
versionNumber: number;
|
||||
/** When the Remote Config template was written to the Remote Config server. */
|
||||
updateTime: string;
|
||||
/** Aggregation of all metadata fields about the account that performed the update. */
|
||||
updateUser: ConfigUser;
|
||||
/** The user-provided description of the corresponding Remote Config template. */
|
||||
description: string;
|
||||
/** Where the update action originated. */
|
||||
updateOrigin: ConfigUpdateOrigin;
|
||||
/** What type of update was made. */
|
||||
updateType: ConfigUpdateType;
|
||||
/** Only present if this version is the result of a rollback, and will be the version number of the Remote Config template that was rolled-back to. */
|
||||
rollbackSource: number;
|
||||
}
|
||||
/**
|
||||
* Event handler which triggers when data is updated in a Remote Config.
|
||||
*
|
||||
* @param handler - Event handler which is run every time a Remote Config update occurs.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onConfigUpdated(handler: (event: CloudEvent<ConfigUpdateData>) => any | Promise<any>): CloudFunction<CloudEvent<ConfigUpdateData>>;
|
||||
/**
|
||||
* Event handler which triggers when data is updated in a Remote Config.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Remote Config update occurs.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onConfigUpdated(opts: EventHandlerOptions, handler: (event: CloudEvent<ConfigUpdateData>) => any | Promise<any>): CloudFunction<CloudEvent<ConfigUpdateData>>;
|
||||
68
node_modules/firebase-functions/lib/v2/providers/remoteConfig.js
generated
vendored
Normal file
68
node_modules/firebase-functions/lib/v2/providers/remoteConfig.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"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.onConfigUpdated = exports.eventType = void 0;
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const options_1 = require("../options");
|
||||
const trace_1 = require("../trace");
|
||||
/** @internal */
|
||||
exports.eventType = "google.firebase.remoteconfig.remoteConfig.v1.updated";
|
||||
/**
|
||||
* Event handler which triggers when data is updated in a Remote Config.
|
||||
*
|
||||
* @param optsOrHandler - Options or an event handler.
|
||||
* @param handler - Event handler which is run every time a Remote Config update occurs.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onConfigUpdated(optsOrHandler, handler) {
|
||||
var _a;
|
||||
if (typeof optsOrHandler === "function") {
|
||||
handler = optsOrHandler;
|
||||
optsOrHandler = {};
|
||||
}
|
||||
const baseOpts = (0, options_1.optionsToEndpoint)((0, options_1.getGlobalOptions)());
|
||||
const specificOpts = (0, options_1.optionsToEndpoint)(optsOrHandler);
|
||||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)((raw) => {
|
||||
return handler(raw);
|
||||
}));
|
||||
func.run = handler;
|
||||
const ep = {
|
||||
...(0, manifest_1.initV2Endpoint)((0, options_1.getGlobalOptions)(), optsOrHandler),
|
||||
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: {},
|
||||
retry: (_a = optsOrHandler.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
func.__endpoint = ep;
|
||||
return func;
|
||||
}
|
||||
exports.onConfigUpdated = onConfigUpdated;
|
||||
65
node_modules/firebase-functions/lib/v2/providers/scheduler.d.ts
generated
vendored
Normal file
65
node_modules/firebase-functions/lib/v2/providers/scheduler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { timezone } from "../../common/timezone";
|
||||
import { ManifestRequiredAPI } from "../../runtime/manifest";
|
||||
import { HttpsFunction } from "./https";
|
||||
import { Expression } from "../../params";
|
||||
import * as options from "../options";
|
||||
/**
|
||||
* Interface representing a ScheduleEvent that is passed to the function handler.
|
||||
*/
|
||||
export interface ScheduledEvent {
|
||||
/**
|
||||
* The Cloud Scheduler job name.
|
||||
* Populated via the X-CloudScheduler-JobName header.
|
||||
*
|
||||
* If invoked manually, this field is undefined.
|
||||
*/
|
||||
jobName?: string;
|
||||
/**
|
||||
* For Cloud Scheduler jobs specified in the unix-cron format,
|
||||
* this is the job schedule time in RFC3339 UTC "Zulu" format.
|
||||
* Populated via the X-CloudScheduler-ScheduleTime header.
|
||||
*
|
||||
* If the schedule is manually triggered, this field will be
|
||||
* the function execution time.
|
||||
*/
|
||||
scheduleTime: string;
|
||||
}
|
||||
/** The Cloud Function type for Schedule triggers. */
|
||||
export interface ScheduleFunction extends HttpsFunction {
|
||||
__requiredAPIs?: ManifestRequiredAPI[];
|
||||
run(data: ScheduledEvent): void | Promise<void>;
|
||||
}
|
||||
/** Options that can be set on a Schedule trigger. */
|
||||
export interface ScheduleOptions extends options.GlobalOptions {
|
||||
/** The schedule, in Unix Crontab or AppEngine syntax. */
|
||||
schedule: string;
|
||||
/** The timezone that the schedule executes in. */
|
||||
timeZone?: timezone | Expression<string> | ResetValue;
|
||||
/** The number of retry attempts for a failed run. */
|
||||
retryCount?: number | Expression<number> | ResetValue;
|
||||
/** The time limit for retrying. */
|
||||
maxRetrySeconds?: number | Expression<number> | ResetValue;
|
||||
/** The minimum time to wait before retying. */
|
||||
minBackoffSeconds?: number | Expression<number> | ResetValue;
|
||||
/** The maximum time to wait before retrying. */
|
||||
maxBackoffSeconds?: number | Expression<number> | ResetValue;
|
||||
/** The time between will double max doublings times. */
|
||||
maxDoublings?: number | Expression<number> | ResetValue;
|
||||
}
|
||||
/**
|
||||
* Handler for scheduled functions. Triggered whenever the associated
|
||||
* scheduler job sends a http request.
|
||||
* @param schedule - The schedule, in Unix Crontab or AppEngine syntax.
|
||||
* @param handler - A function to execute when triggered.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onSchedule(schedule: string, handler: (event: ScheduledEvent) => void | Promise<void>): ScheduleFunction;
|
||||
/**
|
||||
* Handler for scheduled functions. Triggered whenever the associated
|
||||
* scheduler job sends a http request.
|
||||
* @param options - Options to set on scheduled functions.
|
||||
* @param handler - A function to execute when triggered.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
export declare function onSchedule(options: ScheduleOptions, handler: (event: ScheduledEvent) => void | Promise<void>): ScheduleFunction;
|
||||
103
node_modules/firebase-functions/lib/v2/providers/scheduler.js
generated
vendored
Normal file
103
node_modules/firebase-functions/lib/v2/providers/scheduler.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"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.onSchedule = exports.getOpts = void 0;
|
||||
const encoding_1 = require("../../common/encoding");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const trace_1 = require("../trace");
|
||||
const logger = require("../../logger");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
/** @internal */
|
||||
function getOpts(args) {
|
||||
if (typeof args === "string") {
|
||||
return {
|
||||
schedule: args,
|
||||
opts: {},
|
||||
};
|
||||
}
|
||||
return {
|
||||
schedule: args.schedule,
|
||||
timeZone: args.timeZone,
|
||||
retryConfig: {
|
||||
retryCount: args.retryCount,
|
||||
maxRetrySeconds: args.maxRetrySeconds,
|
||||
minBackoffSeconds: args.minBackoffSeconds,
|
||||
maxBackoffSeconds: args.maxBackoffSeconds,
|
||||
maxDoublings: args.maxDoublings,
|
||||
},
|
||||
opts: args,
|
||||
};
|
||||
}
|
||||
exports.getOpts = getOpts;
|
||||
/**
|
||||
* Handler for scheduled functions. Triggered whenever the associated
|
||||
* scheduler job sends a http request.
|
||||
* @param args - Either a schedule or an object containing function options.
|
||||
* @param handler - A function to execute when triggered.
|
||||
* @returns A function that you can export and deploy.
|
||||
*/
|
||||
function onSchedule(args, handler) {
|
||||
const separatedOpts = getOpts(args);
|
||||
const httpFunc = async (req, res) => {
|
||||
const event = {
|
||||
jobName: req.header("X-CloudScheduler-JobName") || undefined,
|
||||
scheduleTime: req.header("X-CloudScheduler-ScheduleTime") || new Date().toISOString(),
|
||||
};
|
||||
try {
|
||||
await handler(event);
|
||||
res.status(200).send();
|
||||
}
|
||||
catch (err) {
|
||||
logger.error(err.message);
|
||||
res.status(500).send();
|
||||
}
|
||||
};
|
||||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(httpFunc));
|
||||
func.run = handler;
|
||||
const globalOpts = options.getGlobalOptions();
|
||||
const baseOptsEndpoint = options.optionsToEndpoint(globalOpts);
|
||||
const specificOptsEndpoint = options.optionsToEndpoint(separatedOpts.opts);
|
||||
const ep = {
|
||||
...(0, manifest_1.initV2Endpoint)(globalOpts, separatedOpts.opts),
|
||||
platform: "gcfv2",
|
||||
...baseOptsEndpoint,
|
||||
...specificOptsEndpoint,
|
||||
labels: {
|
||||
...baseOptsEndpoint === null || baseOptsEndpoint === void 0 ? void 0 : baseOptsEndpoint.labels,
|
||||
...specificOptsEndpoint === null || specificOptsEndpoint === void 0 ? void 0 : specificOptsEndpoint.labels,
|
||||
},
|
||||
scheduleTrigger: (0, manifest_1.initV2ScheduleTrigger)(separatedOpts.schedule, globalOpts, separatedOpts.opts),
|
||||
};
|
||||
(0, encoding_1.copyIfPresent)(ep.scheduleTrigger, separatedOpts, "timeZone");
|
||||
(0, encoding_1.copyIfPresent)(ep.scheduleTrigger.retryConfig, separatedOpts.retryConfig, "retryCount", "maxRetrySeconds", "minBackoffSeconds", "maxBackoffSeconds", "maxDoublings");
|
||||
func.__endpoint = ep;
|
||||
func.__requiredAPIs = [
|
||||
{
|
||||
api: "cloudscheduler.googleapis.com",
|
||||
reason: "Needed for scheduled functions.",
|
||||
},
|
||||
];
|
||||
return func;
|
||||
}
|
||||
exports.onSchedule = onSchedule;
|
||||
369
node_modules/firebase-functions/lib/v2/providers/storage.d.ts
generated
vendored
Normal file
369
node_modules/firebase-functions/lib/v2/providers/storage.d.ts
generated
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { CloudEvent, CloudFunction } from "../core";
|
||||
import { Expression } from "../../params";
|
||||
import * as options from "../options";
|
||||
import { SecretParam } from "../../params/types";
|
||||
/**
|
||||
* An object within Google Cloud Storage.
|
||||
* Ref: https://github.com/googleapis/google-cloudevents-nodejs/blob/main/cloud/storage/v1/StorageObjectData.ts
|
||||
*/
|
||||
export interface StorageObjectData {
|
||||
/**
|
||||
* The name of the bucket containing this object.
|
||||
*/
|
||||
bucket: string;
|
||||
/**
|
||||
* Cache-Control directive for the object data, matching
|
||||
* [https://tools.ietf.org/html/rfc7234#section-5.2"][RFC 7234 §5.2].
|
||||
*/
|
||||
cacheControl?: string;
|
||||
/**
|
||||
* Number of underlying components that make up this object. Components are
|
||||
* accumulated by compose operations.
|
||||
* Attempting to set this field will result in an error.
|
||||
*/
|
||||
componentCount?: number;
|
||||
/**
|
||||
* Content-Disposition of the object data, matching
|
||||
* [https://tools.ietf.org/html/rfc6266][RFC 6266].
|
||||
*/
|
||||
contentDisposition?: string;
|
||||
/**
|
||||
* Content-Encoding of the object data, matching
|
||||
* [https://tools.ietf.org/html/rfc7231#section-3.1.2.2][RFC 7231 §3.1.2.2]
|
||||
*/
|
||||
contentEncoding?: string;
|
||||
/**
|
||||
* Content-Language of the object data, matching
|
||||
* [https://tools.ietf.org/html/rfc7231#section-3.1.3.2][RFC 7231 §3.1.3.2].
|
||||
*/
|
||||
contentLanguage?: string;
|
||||
/**
|
||||
* Content-Type of the object data, matching
|
||||
* [https://tools.ietf.org/html/rfc7231#section-3.1.1.5][RFC 7231 §3.1.1.5].
|
||||
* If an object is stored without a Content-Type, it is served as
|
||||
* `application/octet-stream`.
|
||||
*/
|
||||
contentType?: string;
|
||||
/**
|
||||
* CRC32c checksum. For more information about using the CRC32c
|
||||
* checksum, see
|
||||
* [https://cloud.google.com/storage/docs/hashes-etags#_JSONAPI][Hashes and
|
||||
* ETags: Best Practices].
|
||||
*/
|
||||
crc32c?: string;
|
||||
/**
|
||||
* Metadata of customer-supplied encryption key, if the object is encrypted by
|
||||
* such a key.
|
||||
*/
|
||||
customerEncryption?: CustomerEncryption;
|
||||
/**
|
||||
* HTTP 1.1 Entity tag for the object. See
|
||||
* [https://tools.ietf.org/html/rfc7232#section-2.3][RFC 7232 §2.3].
|
||||
*/
|
||||
etag?: string;
|
||||
/**
|
||||
* The content generation of this object. Used for object versioning.
|
||||
* Attempting to set this field will result in an error.
|
||||
*/
|
||||
generation: number;
|
||||
/**
|
||||
* The ID of the object, including the bucket name, object name, and
|
||||
* generation number.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The kind of item this is. For objects, this is always "storage#object".
|
||||
*/
|
||||
kind?: string;
|
||||
/**
|
||||
* MD5 hash of the data; encoded using base64 as per
|
||||
* [https://tools.ietf.org/html/rfc4648#section-4][RFC 4648 §4]. For more
|
||||
* information about using the MD5 hash, see
|
||||
* [https://cloud.google.com/storage/docs/hashes-etags#_JSONAPI][Hashes and
|
||||
* ETags: Best Practices].
|
||||
*/
|
||||
md5Hash?: string;
|
||||
/**
|
||||
* Media download link.
|
||||
*/
|
||||
mediaLink?: string;
|
||||
/**
|
||||
* User-provided metadata, in key/value pairs.
|
||||
*/
|
||||
metadata?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* The version of the metadata for this object at this generation. Used for
|
||||
* preconditions and for detecting changes in metadata. A metageneration
|
||||
* number is only meaningful in the context of a particular generation of a
|
||||
* particular object.
|
||||
*/
|
||||
metageneration: number;
|
||||
/**
|
||||
* The name of the object.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The link to this object.
|
||||
*/
|
||||
selfLink?: string;
|
||||
/**
|
||||
* Content-Length of the object data in bytes, matching
|
||||
* [https://tools.ietf.org/html/rfc7230#section-3.3.2][RFC 7230 §3.3.2].
|
||||
*/
|
||||
size: number;
|
||||
/**
|
||||
* Storage class of the object.
|
||||
*/
|
||||
storageClass: string;
|
||||
/**
|
||||
* The creation time of the object.
|
||||
* Attempting to set this field will result in an error.
|
||||
*/
|
||||
timeCreated?: Date | string;
|
||||
/**
|
||||
* The deletion time of the object. Will be returned if and only if this
|
||||
* version of the object has been deleted.
|
||||
*/
|
||||
timeDeleted?: Date | string;
|
||||
/**
|
||||
* The time at which the object's storage class was last changed.
|
||||
*/
|
||||
timeStorageClassUpdated?: Date | string;
|
||||
/**
|
||||
* The modification time of the object metadata.
|
||||
*/
|
||||
updated?: Date | string;
|
||||
}
|
||||
/**
|
||||
* Metadata of customer-supplied encryption key, if the object is encrypted by
|
||||
* such a key.
|
||||
*/
|
||||
export interface CustomerEncryption {
|
||||
/**
|
||||
* The encryption algorithm.
|
||||
*/
|
||||
encryptionAlgorithm?: string;
|
||||
/**
|
||||
* SHA256 hash value of the encryption key.
|
||||
*/
|
||||
keySha256?: string;
|
||||
}
|
||||
/** A CloudEvent that contains StorageObjectData */
|
||||
export interface StorageEvent extends CloudEvent<StorageObjectData> {
|
||||
/** The name of the bucket containing this object. */
|
||||
bucket: string;
|
||||
}
|
||||
/** StorageOptions extend EventHandlerOptions with a bucket name */
|
||||
export interface StorageOptions extends options.EventHandlerOptions {
|
||||
/** The name of the bucket containing this object. */
|
||||
bucket?: string | Expression<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;
|
||||
}
|
||||
/**
|
||||
* Event handler sent only when a bucket has enabled object versioning.
|
||||
* This event indicates that the live version of an object has become an
|
||||
* archived version, either because it was archived or because it was
|
||||
* overwritten by the upload of an object of the same name.
|
||||
*
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
||||
*/
|
||||
export declare function onObjectArchived(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler sent only when a bucket has enabled object versioning.
|
||||
* This event indicates that the live version of an object has become an
|
||||
* archived version, either because it was archived or because it was
|
||||
* overwritten by the upload of an object of the same name.
|
||||
*
|
||||
* @param bucket - The name of the bucket containing this object.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
||||
*/
|
||||
export declare function onObjectArchived(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler sent only when a bucket has enabled object versioning.
|
||||
* This event indicates that the live version of an object has become an
|
||||
* archived version, either because it was archived or because it was
|
||||
* overwritten by the upload of an object of the same name.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
||||
*/
|
||||
export declare function onObjectArchived(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage object
|
||||
* creation occurs.
|
||||
*
|
||||
* Sent when a new object (or a new generation of an existing object)
|
||||
* is successfully created in the bucket. This includes copying or rewriting
|
||||
* an existing object. A failed upload does not trigger this event.
|
||||
*
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
||||
*/
|
||||
export declare function onObjectFinalized(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage object
|
||||
* creation occurs.
|
||||
*
|
||||
* Sent when a new object (or a new generation of an existing object)
|
||||
* is successfully created in the bucket. This includes copying or rewriting
|
||||
* an existing object. A failed upload does not trigger this event.
|
||||
*
|
||||
* @param bucket - The name of the bucket containing this object.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
||||
*/
|
||||
export declare function onObjectFinalized(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage object
|
||||
* creation occurs.
|
||||
*
|
||||
* Sent when a new object (or a new generation of an existing object)
|
||||
* is successfully created in the bucket. This includes copying or rewriting
|
||||
* an existing object. A failed upload does not trigger this event.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
||||
*/
|
||||
export declare function onObjectFinalized(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
||||
*
|
||||
* Sent when an object has been permanently deleted. This includes objects
|
||||
* that are overwritten or are deleted as part of the bucket's lifecycle
|
||||
* configuration. For buckets with object versioning enabled, this is not
|
||||
* sent when an object is archived, even if archival occurs
|
||||
* via the `storage.objects.delete` method.
|
||||
*
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
||||
*/
|
||||
export declare function onObjectDeleted(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
||||
*
|
||||
* Sent when an object has been permanently deleted. This includes objects
|
||||
* that are overwritten or are deleted as part of the bucket's lifecycle
|
||||
* configuration. For buckets with object versioning enabled, this is not
|
||||
* sent when an object is archived, even if archival occurs
|
||||
* via the `storage.objects.delete` method.
|
||||
*
|
||||
* @param bucket - The name of the bucket containing this object.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
||||
*/
|
||||
export declare function onObjectDeleted(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
||||
*
|
||||
* Sent when an object has been permanently deleted. This includes objects
|
||||
* that are overwritten or are deleted as part of the bucket's lifecycle
|
||||
* configuration. For buckets with object versioning enabled, this is not
|
||||
* sent when an object is archived, even if archival occurs
|
||||
* via the `storage.objects.delete` method.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
||||
*/
|
||||
export declare function onObjectDeleted(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time the metadata of an existing object
|
||||
* changes.
|
||||
*
|
||||
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
||||
*/
|
||||
export declare function onObjectMetadataUpdated(handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time the metadata of an existing object
|
||||
* changes.
|
||||
*
|
||||
* @param bucket - The name of the bucket containing this object.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
||||
*/
|
||||
export declare function onObjectMetadataUpdated(bucket: string | Expression<string>, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
/**
|
||||
* Event handler which fires every time the metadata of an existing object
|
||||
* changes.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
||||
*/
|
||||
export declare function onObjectMetadataUpdated(opts: StorageOptions, handler: (event: StorageEvent) => any | Promise<any>): CloudFunction<StorageEvent>;
|
||||
185
node_modules/firebase-functions/lib/v2/providers/storage.js
generated
vendored
Normal file
185
node_modules/firebase-functions/lib/v2/providers/storage.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
"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.getOptsAndBucket = exports.onOperation = exports.onObjectMetadataUpdated = exports.onObjectDeleted = exports.onObjectFinalized = exports.onObjectArchived = exports.metadataUpdatedEvent = exports.deletedEvent = exports.finalizedEvent = exports.archivedEvent = void 0;
|
||||
/**
|
||||
* Cloud functions to handle events from Google Cloud Storage.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const config_1 = require("../../common/config");
|
||||
const encoding_1 = require("../../common/encoding");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const trace_1 = require("../trace");
|
||||
const options = require("../options");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
/** @internal */
|
||||
exports.archivedEvent = "google.cloud.storage.object.v1.archived";
|
||||
/** @internal */
|
||||
exports.finalizedEvent = "google.cloud.storage.object.v1.finalized";
|
||||
/** @internal */
|
||||
exports.deletedEvent = "google.cloud.storage.object.v1.deleted";
|
||||
/** @internal */
|
||||
exports.metadataUpdatedEvent = "google.cloud.storage.object.v1.metadataUpdated";
|
||||
/**
|
||||
* Event handler sent only when a bucket has enabled object versioning.
|
||||
* This event indicates that the live version of an object has become an
|
||||
* archived version, either because it was archived or because it was
|
||||
* overwritten by the upload of an object of the same name.
|
||||
*
|
||||
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage archival occurs.
|
||||
*/
|
||||
function onObjectArchived(bucketOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.archivedEvent, bucketOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onObjectArchived = onObjectArchived;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage object
|
||||
* creation occurs.
|
||||
*
|
||||
* Sent when a new object (or a new generation of an existing object)
|
||||
* is successfully created in the bucket. This includes copying or rewriting
|
||||
* an existing object. A failed upload does not trigger this event.
|
||||
*
|
||||
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object creation occurs.
|
||||
*/
|
||||
function onObjectFinalized(bucketOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.finalizedEvent, bucketOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onObjectFinalized = onObjectFinalized;
|
||||
/**
|
||||
* Event handler which fires every time a Google Cloud Storage deletion occurs.
|
||||
*
|
||||
* Sent when an object has been permanently deleted. This includes objects
|
||||
* that are overwritten or are deleted as part of the bucket's lifecycle
|
||||
* configuration. For buckets with object versioning enabled, this is not
|
||||
* sent when an object is archived, even if archival occurs
|
||||
* via the `storage.objects.delete` method.
|
||||
*
|
||||
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object deletion occurs.
|
||||
*/
|
||||
function onObjectDeleted(bucketOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.deletedEvent, bucketOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onObjectDeleted = onObjectDeleted;
|
||||
/**
|
||||
* Event handler which fires every time the metadata of an existing object
|
||||
* changes.
|
||||
*
|
||||
* @param bucketOrOptsOrHandler - Options or string that may (or may not) define the bucket to be used.
|
||||
* @param handler - Event handler which is run every time a Google Cloud Storage object metadata update occurs.
|
||||
*/
|
||||
function onObjectMetadataUpdated(bucketOrOptsOrHandler, handler) {
|
||||
return onOperation(exports.metadataUpdatedEvent, bucketOrOptsOrHandler, handler);
|
||||
}
|
||||
exports.onObjectMetadataUpdated = onObjectMetadataUpdated;
|
||||
/** @internal */
|
||||
function onOperation(eventType, bucketOrOptsOrHandler, handler) {
|
||||
if (typeof bucketOrOptsOrHandler === "function") {
|
||||
handler = bucketOrOptsOrHandler;
|
||||
bucketOrOptsOrHandler = {};
|
||||
}
|
||||
const [opts, bucket] = getOptsAndBucket(bucketOrOptsOrHandler);
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw);
|
||||
};
|
||||
func.run = handler;
|
||||
Object.defineProperty(func, "__trigger", {
|
||||
get: () => {
|
||||
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
||||
const specificOpts = options.optionsToTriggerAnnotations(opts);
|
||||
return {
|
||||
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,
|
||||
resource: bucket, // TODO(colerogers): replace with 'bucket,' eventually
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
// TypeScript doesn't recognize defineProperty as adding a property and complains
|
||||
// that __endpoint doesn't exist. We can either cast to any and lose all type safety
|
||||
// or we can just assign a meaningless value before calling defineProperty.
|
||||
func.__endpoint = {};
|
||||
// SDK may attempt to read FIREBASE_CONFIG env var to fetch the default bucket name.
|
||||
// To prevent runtime errors when FIREBASE_CONFIG env var is missing, we use getters.
|
||||
Object.defineProperty(func, "__endpoint", {
|
||||
get: () => {
|
||||
var _a;
|
||||
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
||||
const specificOpts = options.optionsToEndpoint(opts);
|
||||
const endpoint = {
|
||||
platform: "gcfv2",
|
||||
...(0, manifest_1.initV2Endpoint)(options.getGlobalOptions(), opts),
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
},
|
||||
eventTrigger: {
|
||||
eventType,
|
||||
eventFilters: { bucket },
|
||||
retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
(0, encoding_1.copyIfPresent)(endpoint.eventTrigger, opts, "retry", "retry");
|
||||
return endpoint;
|
||||
},
|
||||
});
|
||||
return func;
|
||||
}
|
||||
exports.onOperation = onOperation;
|
||||
/** @internal */
|
||||
function getOptsAndBucket(bucketOrOpts) {
|
||||
var _a;
|
||||
let bucket;
|
||||
let opts;
|
||||
// If bucket is a string or Expression<string>
|
||||
if (typeof bucketOrOpts === "string" || "value" in bucketOrOpts) {
|
||||
bucket = bucketOrOpts;
|
||||
opts = {};
|
||||
}
|
||||
else {
|
||||
bucket = bucketOrOpts.bucket || ((_a = (0, config_1.firebaseConfig)()) === null || _a === void 0 ? void 0 : _a.storageBucket);
|
||||
opts = { ...bucketOrOpts };
|
||||
delete opts.bucket;
|
||||
}
|
||||
if (!bucket) {
|
||||
throw new Error("Missing bucket name. If you are unit testing, please provide a bucket name" +
|
||||
" by providing bucket name directly in the event handler or by setting process.env.FIREBASE_CONFIG.");
|
||||
}
|
||||
if (typeof bucket === "string" && !/^[a-z\d][a-z\d\\._-]{1,230}[a-z\d]$/.test(bucket)) {
|
||||
throw new Error(`Invalid bucket name ${bucket}`);
|
||||
}
|
||||
return [opts, bucket];
|
||||
}
|
||||
exports.getOptsAndBucket = getOptsAndBucket;
|
||||
131
node_modules/firebase-functions/lib/v2/providers/tasks.d.ts
generated
vendored
Normal file
131
node_modules/firebase-functions/lib/v2/providers/tasks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
import { ResetValue } from "../../common/options";
|
||||
import { AuthData, RateLimits, Request, RetryConfig } from "../../common/providers/tasks";
|
||||
import * as options from "../options";
|
||||
import { HttpsFunction } from "./https";
|
||||
import { Expression } from "../../params";
|
||||
import { SecretParam } from "../../params/types";
|
||||
export { AuthData, Request, RateLimits, RetryConfig };
|
||||
export interface TaskQueueOptions extends options.EventHandlerOptions {
|
||||
/** How a task should be retried in the event of a non-2xx return. */
|
||||
retryConfig?: RetryConfig;
|
||||
/** How congestion control should be applied to the function. */
|
||||
rateLimits?: RateLimits;
|
||||
/**
|
||||
* Who can enqueue tasks for this function.
|
||||
*
|
||||
* @remakrs
|
||||
* If left unspecified, only service accounts which have
|
||||
* `roles/cloudtasks.enqueuer` and `roles/cloudfunctions.invoker`
|
||||
* will have permissions.
|
||||
*/
|
||||
invoker?: "private" | string | 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;
|
||||
}
|
||||
/**
|
||||
* A handler for tasks.
|
||||
* @typeParam T - The task data interface. Task data is unmarshaled from JSON.
|
||||
*/
|
||||
export interface TaskQueueFunction<T = any> extends HttpsFunction {
|
||||
/**
|
||||
* The callback passed to the `TaskQueueFunction` constructor.
|
||||
* @param request - A TaskRequest containing data and auth information.
|
||||
* @returns Any return value. Google Cloud Functions will await any promise
|
||||
* before shutting down your function. Resolved return values
|
||||
* are only used for unit testing purposes.
|
||||
*/
|
||||
run(request: Request<T>): void | Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
||||
* @param handler - A callback to handle task requests.
|
||||
* @typeParam Args - The interface for the request's `data` field.
|
||||
* @returns A function you can export and deploy.
|
||||
*/
|
||||
export declare function onTaskDispatched<Args = any>(handler: (request: Request<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
|
||||
/**
|
||||
* Creates a handler for tasks sent to a Google Cloud Tasks queue.
|
||||
* @param options - Configuration for the task queue or Cloud Function.
|
||||
* @param handler - A callback to handle task requests.
|
||||
* @typeParam Args - The interface for the request's `data` field.
|
||||
* @returns A function you can export and deploy.
|
||||
*/
|
||||
export declare function onTaskDispatched<Args = any>(options: TaskQueueOptions, handler: (request: Request<Args>) => void | Promise<void>): TaskQueueFunction<Args>;
|
||||
99
node_modules/firebase-functions/lib/v2/providers/tasks.js
generated
vendored
Normal file
99
node_modules/firebase-functions/lib/v2/providers/tasks.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"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.onTaskDispatched = void 0;
|
||||
/**
|
||||
* Cloud functions to handle Tasks enqueued with Google Cloud Tasks.
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const encoding_1 = require("../../common/encoding");
|
||||
const tasks_1 = require("../../common/providers/tasks");
|
||||
const options = require("../options");
|
||||
const trace_1 = require("../trace");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
function onTaskDispatched(optsOrHandler, handler) {
|
||||
let opts;
|
||||
if (arguments.length === 1) {
|
||||
opts = {};
|
||||
handler = optsOrHandler;
|
||||
}
|
||||
else {
|
||||
opts = optsOrHandler;
|
||||
}
|
||||
// onDispatchHandler sniffs the function length to determine which API to present.
|
||||
// fix the length to prevent api versions from being mismatched.
|
||||
const fixedLen = (req) => handler(req);
|
||||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)((0, tasks_1.onDispatchHandler)(fixedLen)));
|
||||
Object.defineProperty(func, "__trigger", {
|
||||
get: () => {
|
||||
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
||||
// global options calls region a scalar and https allows it to be an array,
|
||||
// but optionsToTriggerAnnotations handles both cases.
|
||||
const specificOpts = options.optionsToTriggerAnnotations(opts);
|
||||
const taskQueueTrigger = {};
|
||||
(0, encoding_1.copyIfPresent)(taskQueueTrigger, opts, "retryConfig", "rateLimits");
|
||||
(0, encoding_1.convertIfPresent)(taskQueueTrigger, options.getGlobalOptions(), "invoker", "invoker", encoding_1.convertInvoker);
|
||||
(0, encoding_1.convertIfPresent)(taskQueueTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
|
||||
return {
|
||||
platform: "gcfv2",
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
},
|
||||
taskQueueTrigger,
|
||||
};
|
||||
},
|
||||
});
|
||||
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
|
||||
// global options calls region a scalar and https allows it to be an array,
|
||||
// but optionsToManifestEndpoint handles both cases.
|
||||
const specificOpts = options.optionsToEndpoint(opts);
|
||||
func.__endpoint = {
|
||||
platform: "gcfv2",
|
||||
...(0, manifest_1.initV2Endpoint)(options.getGlobalOptions(), opts),
|
||||
...baseOpts,
|
||||
...specificOpts,
|
||||
labels: {
|
||||
...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
|
||||
...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
|
||||
},
|
||||
taskQueueTrigger: (0, manifest_1.initTaskQueueTrigger)(options.getGlobalOptions(), opts),
|
||||
};
|
||||
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.retryConfig, opts.retryConfig, "maxAttempts", "maxBackoffSeconds", "maxDoublings", "maxRetrySeconds", "minBackoffSeconds");
|
||||
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger.rateLimits, opts.rateLimits, "maxConcurrentDispatches", "maxDispatchesPerSecond");
|
||||
(0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, options.getGlobalOptions(), "invoker", "invoker", encoding_1.convertInvoker);
|
||||
(0, encoding_1.convertIfPresent)(func.__endpoint.taskQueueTrigger, opts, "invoker", "invoker", encoding_1.convertInvoker);
|
||||
(0, encoding_1.copyIfPresent)(func.__endpoint.taskQueueTrigger, opts, "retry", "retry");
|
||||
func.__requiredAPIs = [
|
||||
{
|
||||
api: "cloudtasks.googleapis.com",
|
||||
reason: "Needed for task queue functions",
|
||||
},
|
||||
];
|
||||
func.run = handler;
|
||||
return func;
|
||||
}
|
||||
exports.onTaskDispatched = onTaskDispatched;
|
||||
110
node_modules/firebase-functions/lib/v2/providers/testLab.d.ts
generated
vendored
Normal file
110
node_modules/firebase-functions/lib/v2/providers/testLab.d.ts
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
import { CloudEvent, CloudFunction } from "../core";
|
||||
import { EventHandlerOptions } from "../options";
|
||||
/** Possible test states for a test matrix. */
|
||||
export type TestState =
|
||||
/** The default value. This value is used if the state is omitted. */
|
||||
"TEST_STATE_UNSPECIFIED"
|
||||
/** The test matrix is being validated. */
|
||||
| "VALIDATING"
|
||||
/** The test matrix is waiting for resources to become available. */
|
||||
| "PENDING"
|
||||
/** The test matrix has completed normally. */
|
||||
| "FINISHED"
|
||||
/** The test matrix has completed because of an infrastructure failure. */
|
||||
| "ERROR"
|
||||
/** The test matrix was not run because the provided inputs are not valid. */
|
||||
| "INVALID";
|
||||
/** Outcome summary for a finished test matrix. */
|
||||
export type OutcomeSummary =
|
||||
/** The default value. This value is used if the state is omitted. */
|
||||
"OUTCOME_SUMMARY_UNSPECIFIED"
|
||||
/**
|
||||
* The test matrix run was successful, for instance:
|
||||
* - All test cases passed.
|
||||
* - No crash of the application under test was detected.
|
||||
*/
|
||||
| "SUCCESS"
|
||||
/**
|
||||
* A run failed, for instance:
|
||||
* - One or more test case failed.
|
||||
* - A test timed out.
|
||||
* - The application under test crashed.
|
||||
*/
|
||||
| "FAILURE"
|
||||
/**
|
||||
* Something unexpected happened. The test run should still be considered
|
||||
* unsuccessful but this is likely a transient problem and re-running the
|
||||
* test might be successful.
|
||||
*/
|
||||
| "INCONCLUSIVE"
|
||||
/** All tests were skipped. */
|
||||
| "SKIPPED";
|
||||
/** Locations where test results are stored. */
|
||||
export interface ResultStorage {
|
||||
/**
|
||||
* Tool Results history resource containing test results. Format is
|
||||
* `projects/{project_id}/histories/{history_id}`.
|
||||
* See https://firebase.google.com/docs/test-lab/reference/toolresults/rest
|
||||
* for more information.
|
||||
*/
|
||||
toolResultsHistory: string;
|
||||
/**
|
||||
* Tool Results execution resource containing test results. Format is
|
||||
* `projects/{project_id}/histories/{history_id}/executions/{execution_id}`.
|
||||
* Optional, can be omitted in erroneous test states.
|
||||
* See https://firebase.google.com/docs/test-lab/reference/toolresults/rest
|
||||
* for more information.
|
||||
*/
|
||||
toolResultsExecution: string;
|
||||
/** URI to the test results in the Firebase Web Console. */
|
||||
resultsUri: string;
|
||||
/**
|
||||
* Location in Google Cloud Storage where test results are written to.
|
||||
* In the form "gs://bucket/path/to/somewhere".
|
||||
*/
|
||||
gcsPath: string;
|
||||
}
|
||||
/** Information about the client which invoked the test. */
|
||||
export interface ClientInfo {
|
||||
/** Client name, such as "gcloud". */
|
||||
client: string;
|
||||
/** Map of detailed information about the client. */
|
||||
details: Record<string, string>;
|
||||
}
|
||||
/** The data within all Firebase test matrix completed events. */
|
||||
export interface TestMatrixCompletedData {
|
||||
/** Time the test matrix was created. */
|
||||
createTime: string;
|
||||
/** State of the test matrix. */
|
||||
state: TestState;
|
||||
/**
|
||||
* Code that describes why the test matrix is considered invalid. Only set for
|
||||
* matrices in the INVALID state.
|
||||
*/
|
||||
invalidMatrixDetails: string;
|
||||
/** Outcome summary of the test matrix. */
|
||||
outcomeSummary: OutcomeSummary;
|
||||
/** Locations where test results are stored. */
|
||||
resultStorage: ResultStorage;
|
||||
/** Information provided by the client that created the test matrix. */
|
||||
clientInfo: ClientInfo;
|
||||
/** ID of the test matrix this event belongs to. */
|
||||
testMatrixId: string;
|
||||
}
|
||||
/**
|
||||
* Event handler which triggers when a Firebase test matrix completes.
|
||||
*
|
||||
* @param handler - Event handler which is run every time a Firebase test matrix completes.
|
||||
* @returns A Cloud Function that you can export and deploy.
|
||||
* @alpha
|
||||
*/
|
||||
export declare function onTestMatrixCompleted(handler: (event: CloudEvent<TestMatrixCompletedData>) => any | Promise<any>): CloudFunction<CloudEvent<TestMatrixCompletedData>>;
|
||||
/**
|
||||
* Event handler which triggers when a Firebase test matrix completes.
|
||||
*
|
||||
* @param opts - Options that can be set on an individual event-handling function.
|
||||
* @param handler - Event handler which is run every time a Firebase test matrix completes.
|
||||
* @returns A Cloud Function that you can export and deploy.
|
||||
* @alpha
|
||||
*/
|
||||
export declare function onTestMatrixCompleted(opts: EventHandlerOptions, handler: (event: CloudEvent<TestMatrixCompletedData>) => any | Promise<any>): CloudFunction<CloudEvent<TestMatrixCompletedData>>;
|
||||
69
node_modules/firebase-functions/lib/v2/providers/testLab.js
generated
vendored
Normal file
69
node_modules/firebase-functions/lib/v2/providers/testLab.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"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.onTestMatrixCompleted = exports.eventType = void 0;
|
||||
const onInit_1 = require("../../common/onInit");
|
||||
const manifest_1 = require("../../runtime/manifest");
|
||||
const options_1 = require("../options");
|
||||
const trace_1 = require("../trace");
|
||||
/** @internal */
|
||||
exports.eventType = "google.firebase.testlab.testMatrix.v1.completed";
|
||||
/**
|
||||
* Event handler which triggers when a Firebase test matrix completes.
|
||||
*
|
||||
* @param optsOrHandler - Options or an event handler.
|
||||
* @param handler - Event handler which is run every time a Firebase test matrix completes.
|
||||
* @returns A Cloud Function that you can export and deploy.
|
||||
* @alpha
|
||||
*/
|
||||
function onTestMatrixCompleted(optsOrHandler, handler) {
|
||||
var _a;
|
||||
if (typeof optsOrHandler === "function") {
|
||||
handler = optsOrHandler;
|
||||
optsOrHandler = {};
|
||||
}
|
||||
const baseOpts = (0, options_1.optionsToEndpoint)((0, options_1.getGlobalOptions)());
|
||||
const specificOpts = (0, options_1.optionsToEndpoint)(optsOrHandler);
|
||||
const func = (raw) => {
|
||||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw);
|
||||
};
|
||||
func.run = handler;
|
||||
const ep = {
|
||||
...(0, manifest_1.initV2Endpoint)((0, options_1.getGlobalOptions)(), optsOrHandler),
|
||||
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: {},
|
||||
retry: (_a = optsOrHandler.retry) !== null && _a !== void 0 ? _a : false,
|
||||
},
|
||||
};
|
||||
func.__endpoint = ep;
|
||||
return func;
|
||||
}
|
||||
exports.onTestMatrixCompleted = onTestMatrixCompleted;
|
||||
Reference in New Issue
Block a user