firebase-functions
Advanced tools
Comparing version 4.7.0 to 4.8.0
@@ -11,3 +11,3 @@ /** | ||
/** | ||
* A builtin param that resolves to the default RTDB database URL associated | ||
* A built-in parameter that resolves to the default RTDB database URL associated | ||
* with the project, without prompting the deployer. Empty string if none exists. | ||
@@ -17,3 +17,3 @@ */ | ||
/** | ||
* A builtin param that resolves to the Cloud project ID associated with | ||
* A built-in parameter that resolves to the Cloud project ID associated with | ||
* the project, without prompting the deployer. | ||
@@ -23,3 +23,3 @@ */ | ||
/** | ||
* A builtin param that resolves to the Cloud project ID, without prompting | ||
* A built-in parameter that resolves to the Cloud project ID, without prompting | ||
* the deployer. | ||
@@ -29,3 +29,3 @@ */ | ||
/** | ||
* A builtin param that resolves to the Cloud storage bucket associated | ||
* A builtin parameter that resolves to the Cloud storage bucket associated | ||
* with the function, without prompting the deployer. Empty string if not | ||
@@ -37,41 +37,41 @@ * defined. | ||
* Declares a secret param, that will persist values only in Cloud Secret Manager. | ||
* Secrets are stored interally as bytestrings. Use ParamOptions.`as` to provide type | ||
* Secrets are stored interally as bytestrings. Use `ParamOptions.as` to provide type | ||
* hinting during parameter resolution. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `string` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `string` return type for `.value`. | ||
*/ | ||
export declare function defineSecret(name: string): SecretParam; | ||
/** | ||
* Declare a string param. | ||
* Declare a string parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `string` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `string` return type for `.value`. | ||
*/ | ||
export declare function defineString(name: string, options?: ParamOptions<string>): StringParam; | ||
/** | ||
* Declare a boolean param. | ||
* Declare a boolean parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `boolean` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `boolean` return type for `.value`. | ||
*/ | ||
export declare function defineBoolean(name: string, options?: ParamOptions<boolean>): BooleanParam; | ||
/** | ||
* Declare an integer param. | ||
* Declare an integer parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `number` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `number` return type for `.value`. | ||
*/ | ||
export declare function defineInt(name: string, options?: ParamOptions<number>): IntParam; | ||
/** | ||
* Declare a list param. | ||
* Declare a list parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `string[]` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `string[]` return type for `.value`. | ||
*/ | ||
export declare function defineList(name: string, options?: ParamOptions<string[]>): ListParam; |
@@ -37,3 +37,3 @@ "use strict"; | ||
/** | ||
* Use a helper to manage the list such that params are uniquely | ||
* Use a helper to manage the list such that parameters are uniquely | ||
* registered once only but order is preserved. | ||
@@ -59,3 +59,3 @@ * @internal | ||
/** | ||
* A builtin param that resolves to the default RTDB database URL associated | ||
* A built-in parameter that resolves to the default RTDB database URL associated | ||
* with the project, without prompting the deployer. Empty string if none exists. | ||
@@ -65,3 +65,3 @@ */ | ||
/** | ||
* A builtin param that resolves to the Cloud project ID associated with | ||
* A built-in parameter that resolves to the Cloud project ID associated with | ||
* the project, without prompting the deployer. | ||
@@ -71,3 +71,3 @@ */ | ||
/** | ||
* A builtin param that resolves to the Cloud project ID, without prompting | ||
* A built-in parameter that resolves to the Cloud project ID, without prompting | ||
* the deployer. | ||
@@ -77,3 +77,3 @@ */ | ||
/** | ||
* A builtin param that resolves to the Cloud storage bucket associated | ||
* A builtin parameter that resolves to the Cloud storage bucket associated | ||
* with the function, without prompting the deployer. Empty string if not | ||
@@ -85,8 +85,8 @@ * defined. | ||
* Declares a secret param, that will persist values only in Cloud Secret Manager. | ||
* Secrets are stored interally as bytestrings. Use ParamOptions.`as` to provide type | ||
* Secrets are stored interally as bytestrings. Use `ParamOptions.as` to provide type | ||
* hinting during parameter resolution. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `string` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `string` return type for `.value`. | ||
*/ | ||
@@ -100,7 +100,7 @@ function defineSecret(name) { | ||
/** | ||
* Declare a string param. | ||
* Declare a string parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `string` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `string` return type for `.value`. | ||
*/ | ||
@@ -114,7 +114,7 @@ function defineString(name, options = {}) { | ||
/** | ||
* Declare a boolean param. | ||
* Declare a boolean parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `boolean` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `boolean` return type for `.value`. | ||
*/ | ||
@@ -128,7 +128,7 @@ function defineBoolean(name, options = {}) { | ||
/** | ||
* Declare an integer param. | ||
* Declare an integer parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `number` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `number` return type for `.value`. | ||
*/ | ||
@@ -142,7 +142,7 @@ function defineInt(name, options = {}) { | ||
/** | ||
* Declare a float param. | ||
* Declare a float parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `number` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `number` return type for `.value`. | ||
* | ||
@@ -158,7 +158,7 @@ * @internal | ||
/** | ||
* Declare a list param. | ||
* Declare a list parameter. | ||
* | ||
* @param name The name of the environment variable to use to load the param. | ||
* @param options Configuration options for the param. | ||
* @returns A Param with a `string[]` return type for `.value`. | ||
* @param name The name of the environment variable to use to load the parameter. | ||
* @param options Configuration options for the parameter. | ||
* @returns A parameter with a `string[]` return type for `.value`. | ||
*/ | ||
@@ -165,0 +165,0 @@ function defineList(name, options = {}) { |
export declare abstract class Expression<T extends string | number | boolean | string[]> { | ||
/** Returns the Expression's runtime value, based on the CLI's resolution of params. */ | ||
/** Returns the expression's runtime value, based on the CLI's resolution of parameters. */ | ||
value(): T; | ||
/** Returns the Expression's representation as a braced CEL expression. */ | ||
/** Returns the expression's representation as a braced CEL expression. */ | ||
toCEL(): string; | ||
/** Returns the expression's representation as JSON. */ | ||
toJSON(): string; | ||
@@ -28,3 +29,3 @@ } | ||
toString(): string; | ||
/** Returns a TernaryExpression which can resolve to one of two values, based on the resolution of this comparison. */ | ||
/** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */ | ||
thenElse<retT extends string | number | boolean | string[]>(ifTrue: retT | Expression<retT>, ifFalse: retT | Expression<retT>): TernaryExpression<retT>; | ||
@@ -44,4 +45,4 @@ } | ||
/** | ||
* Specifies that a Param's value should be determined by prompting the user | ||
* to type it in interactively at deploy-time. Input that does not match the | ||
* Specifies that a parameter's value should be determined by prompting the user | ||
* to type it in interactively at deploy time. Input that does not match the | ||
* provided validationRegex, if present, will be retried. | ||
@@ -66,3 +67,3 @@ */ | ||
/** | ||
* Specifies that a Param's value should be determined by having the user | ||
* Specifies that a parameter's value should be determined by having the user | ||
* select from a list containing all the project's resources of a certain | ||
@@ -76,6 +77,9 @@ * type. Currently, only type:"storage.googleapis.com/Bucket" is supported. | ||
} | ||
/** | ||
* Autogenerate a list of buckets in a project that a user can select from. | ||
*/ | ||
export declare const BUCKET_PICKER: ResourceInput; | ||
/** | ||
* Specifies that a Param's value should be determined by having the user select | ||
* from a list of pre-canned options interactively at deploy-time. | ||
* Specifies that a parameter's value should be determined by having the user select | ||
* from a list of pre-canned options interactively at deploy time. | ||
*/ | ||
@@ -88,5 +92,5 @@ export interface SelectInput<T = unknown> { | ||
/** | ||
* Specifies that a Param's value should be determined by having the user select | ||
* a subset from a list of pre-canned options interactively at deploy-time. | ||
* Will result in errors if used on Params of type other than string[]. | ||
* Specifies that a parameter's value should be determined by having the user select | ||
* a subset from a list of pre-canned options interactively at deploy time. | ||
* Will result in errors if used on parameters of type other than `string[]`. | ||
*/ | ||
@@ -99,3 +103,3 @@ export interface MultiSelectInput { | ||
/** | ||
* One of the options provided to a SelectInput, containing a value and | ||
* One of the options provided to a `SelectInput`, containing a value and | ||
* optionally a human-readable label to display in the selection interface. | ||
@@ -107,3 +111,3 @@ */ | ||
} | ||
/** The wire representation of a Param when it's sent to the CLI. A superset of ParamOptions. */ | ||
/** The wire representation of a parameter when it's sent to the CLI. A superset of `ParamOptions`. */ | ||
export type ParamSpec<T extends string | number | boolean | string[]> = { | ||
@@ -114,7 +118,7 @@ /** The name of the parameter which will be stored in .env files. Use UPPERCASE. */ | ||
default?: T | Expression<T>; | ||
/** An optional human-readable string to be used as a replacement for the Param's name when prompting. */ | ||
/** An optional human-readable string to be used as a replacement for the parameter's name when prompting. */ | ||
label?: string; | ||
/** An optional long-form description of the Param to be displayed while prompting. */ | ||
/** An optional long-form description of the parameter to be displayed while prompting. */ | ||
description?: string; | ||
/** The way in which the Firebase CLI will prompt for the value of this Param. Defaults to a TextInput. */ | ||
/** The way in which the Firebase CLI will prompt for the value of this parameter. Defaults to a TextInput. */ | ||
input?: ParamInput<T>; | ||
@@ -138,3 +142,3 @@ }; | ||
}; | ||
/** Configuration options which can be used to customize the prompting behavior of a Param. */ | ||
/** Configuration options which can be used to customize the prompting behavior of a parameter. */ | ||
export type ParamOptions<T extends string | number | boolean | string[]> = Omit<ParamSpec<T>, "name" | "type">; | ||
@@ -151,18 +155,18 @@ /** | ||
constructor(name: string, options?: ParamOptions<T>); | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
cmp(cmp: "==" | "!=" | ">" | ">=" | "<" | "<=", rhs: T | Expression<T>): CompareExpression<T>; | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
equals(rhs: T | Expression<T>): CompareExpression<T>; | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
notEquals(rhs: T | Expression<T>): CompareExpression<T>; | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
greaterThan(rhs: T | Expression<T>): CompareExpression<T>; | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
greaterThanOrEqualTo(rhs: T | Expression<T>): CompareExpression<T>; | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
lessThan(rhs: T | Expression<T>): CompareExpression<T>; | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
lessThanOrEqualTo(rhs: T | Expression<T>): CompareExpression<T>; | ||
/** | ||
* Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. | ||
* Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. | ||
* @deprecated A typo. Use lessThanOrEqualTo instead. | ||
@@ -169,0 +173,0 @@ */ |
@@ -32,3 +32,3 @@ "use strict"; | ||
class Expression { | ||
/** Returns the Expression's runtime value, based on the CLI's resolution of params. */ | ||
/** Returns the expression's runtime value, based on the CLI's resolution of parameters. */ | ||
value() { | ||
@@ -46,6 +46,7 @@ if (process.env.FUNCTIONS_CONTROL_API === "true") { | ||
} | ||
/** Returns the Expression's representation as a braced CEL expression. */ | ||
/** Returns the expression's representation as a braced CEL expression. */ | ||
toCEL() { | ||
return `{{ ${this.toString()} }}`; | ||
} | ||
/** Returns the expression's representation as JSON. */ | ||
toJSON() { | ||
@@ -60,4 +61,4 @@ return this.toString(); | ||
/** | ||
* Returns how an entity (either an Expression or a literal value) should be represented in CEL. | ||
* - Expressions delegate to the .toString() method, which is used by the WireManifest | ||
* Returns how an entity (either an `Expression` or a literal value) should be represented in CEL. | ||
* - Expressions delegate to the `.toString()` method, which is used by the WireManifest | ||
* - Strings have to be quoted explicitly | ||
@@ -142,3 +143,3 @@ * - Arrays are represented as []-delimited, parsable JSON | ||
} | ||
/** Returns a TernaryExpression which can resolve to one of two values, based on the resolution of this comparison. */ | ||
/** Returns a `TernaryExpression` which can resolve to one of two values, based on the resolution of this comparison. */ | ||
thenElse(ifTrue, ifFalse) { | ||
@@ -181,2 +182,5 @@ return new TernaryExpression(this, ifTrue, ifFalse); | ||
exports.multiSelect = multiSelect; | ||
/** | ||
* Autogenerate a list of buckets in a project that a user can select from. | ||
*/ | ||
exports.BUCKET_PICKER = { | ||
@@ -202,27 +206,27 @@ resource: { | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
cmp(cmp, rhs) { | ||
return new CompareExpression(cmp, this, rhs); | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
equals(rhs) { | ||
return this.cmp("==", rhs); | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
notEquals(rhs) { | ||
return this.cmp("!=", rhs); | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
greaterThan(rhs) { | ||
return this.cmp(">", rhs); | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
greaterThanOrEqualTo(rhs) { | ||
return this.cmp(">=", rhs); | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
lessThan(rhs) { | ||
return this.cmp("<", rhs); | ||
} | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. */ | ||
/** Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. */ | ||
lessThanOrEqualTo(rhs) { | ||
@@ -232,3 +236,3 @@ return this.cmp("<=", rhs); | ||
/** | ||
* Returns a parametrized expression of Boolean type, based on comparing the value of this param to a literal or a different expression. | ||
* Returns a parametrized expression of Boolean type, based on comparing the value of this parameter to a literal or a different expression. | ||
* @deprecated A typo. Use lessThanOrEqualTo instead. | ||
@@ -313,3 +317,3 @@ */ | ||
* cannot be instantiated by developers, but we provide several canned instances | ||
* of it to make available params that will never have to be defined at | ||
* of it to make available parameters that will never have to be defined at | ||
* deployment time, and can always be read from process.env. | ||
@@ -316,0 +320,0 @@ * @internal |
@@ -31,2 +31,3 @@ "use strict"; | ||
const types_1 = require("../params/types"); | ||
const onInit_1 = require("../common/onInit"); | ||
var change_1 = require("../common/change"); | ||
@@ -73,2 +74,3 @@ Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } }); | ||
} | ||
handler = (0, onInit_1.withInit)(handler); | ||
let promise; | ||
@@ -75,0 +77,0 @@ if (labels && labels["deployment-scheduled"]) { |
@@ -23,1 +23,2 @@ import * as logger from "../logger"; | ||
export { params }; | ||
export { onInit } from "../common/onInit"; |
@@ -38,3 +38,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.params = exports.app = exports.logger = exports.testLab = exports.tasks = exports.storage = exports.remoteConfig = exports.pubsub = exports.https = exports.firestore = exports.database = exports.auth = exports.analytics = void 0; | ||
exports.onInit = exports.params = exports.app = exports.logger = exports.testLab = exports.tasks = exports.storage = exports.remoteConfig = exports.pubsub = exports.https = exports.firestore = exports.database = exports.auth = exports.analytics = void 0; | ||
// Providers: | ||
@@ -73,1 +73,3 @@ const logger = require("../logger"); | ||
exports.params = params; | ||
var onInit_1 = require("../common/onInit"); | ||
Object.defineProperty(exports, "onInit", { enumerable: true, get: function () { return onInit_1.onInit; } }); |
@@ -30,2 +30,4 @@ "use strict"; | ||
const manifest_1 = require("../../runtime/manifest"); | ||
const onInit_1 = require("../../common/onInit"); | ||
const trace_1 = require("../../v2/trace"); | ||
/** | ||
@@ -52,3 +54,3 @@ * Handle HTTP requests. | ||
const cloudFunction = (req, res) => { | ||
return handler(req, res); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(req, res); | ||
}; | ||
@@ -76,8 +78,10 @@ cloudFunction.__trigger = { | ||
// in another handler to avoid accidentally triggering the v2 API | ||
const fixedLen = (data, context) => handler(data, context); | ||
const func = (0, https_1.onCallHandler)({ | ||
const fixedLen = (data, context) => { | ||
return (0, onInit_1.withInit)(handler)(data, context); | ||
}; | ||
const func = (0, trace_1.wrapTraceContext)((0, https_1.onCallHandler)({ | ||
enforceAppCheck: options.enforceAppCheck, | ||
consumeAppCheckToken: options.consumeAppCheckToken, | ||
cors: { origin: true, methods: "POST" }, | ||
}, fixedLen); | ||
}, fixedLen)); | ||
func.__trigger = { | ||
@@ -96,5 +100,5 @@ labels: {}, | ||
}; | ||
func.run = handler; | ||
func.run = fixedLen; | ||
return func; | ||
} | ||
exports._onCallWithOptions = _onCallWithOptions; |
@@ -9,2 +9,3 @@ /** | ||
export { ParamsOf } from "../common/params"; | ||
export { onInit } from "../common/onInit"; | ||
/** | ||
@@ -11,0 +12,0 @@ * A `CloudEventBase` is the base of a cross-platform format for encoding a serverless event. |
@@ -24,3 +24,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Change = void 0; | ||
exports.onInit = exports.Change = void 0; | ||
/** | ||
@@ -32,1 +32,3 @@ * Core functionality of the Cloud Functions for Firebase 2nd gen SDK. | ||
Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } }); | ||
var onInit_1 = require("../common/onInit"); | ||
Object.defineProperty(exports, "onInit", { enumerable: true, get: function () { return onInit_1.onInit; } }); |
@@ -23,5 +23,5 @@ /** | ||
export { setGlobalOptions, GlobalOptions, SupportedRegion, MemoryOption, VpcEgressSetting, IngressSetting, EventHandlerOptions, } from "./options"; | ||
export { CloudFunction, CloudEvent, ParamsOf } from "./core"; | ||
export { CloudFunction, CloudEvent, ParamsOf, onInit } from "./core"; | ||
export { Change } from "../common/change"; | ||
import * as params from "../params"; | ||
export { params }; |
@@ -24,3 +24,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.params = exports.Change = exports.setGlobalOptions = exports.firestore = exports.testLab = exports.remoteConfig = exports.scheduler = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = exports.alerts = void 0; | ||
exports.params = exports.Change = exports.onInit = exports.setGlobalOptions = exports.firestore = exports.testLab = exports.remoteConfig = exports.scheduler = exports.eventarc = exports.tasks = exports.logger = exports.pubsub = exports.identity = exports.https = exports.storage = exports.database = exports.alerts = void 0; | ||
/** | ||
@@ -61,2 +61,4 @@ * The 2nd gen API for Cloud Functions for Firebase. | ||
Object.defineProperty(exports, "setGlobalOptions", { enumerable: true, get: function () { return options_1.setGlobalOptions; } }); | ||
var core_1 = require("./core"); | ||
Object.defineProperty(exports, "onInit", { enumerable: true, get: function () { return core_1.onInit; } }); | ||
var change_1 = require("../common/change"); | ||
@@ -63,0 +65,0 @@ Object.defineProperty(exports, "Change", { enumerable: true, get: function () { return change_1.Change; } }); |
@@ -28,2 +28,3 @@ "use strict"; | ||
const options = require("../../options"); | ||
const onInit_1 = require("../../../common/onInit"); | ||
/** @internal */ | ||
@@ -34,3 +35,3 @@ exports.eventType = "google.firebase.firebasealerts.alerts.v1.published"; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)(convertAlertAndApp(raw)); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(convertAlertAndApp(raw)); | ||
}; | ||
@@ -37,0 +38,0 @@ func.run = handler; |
@@ -27,2 +27,3 @@ "use strict"; | ||
const alerts_1 = require("./alerts"); | ||
const onInit_1 = require("../../../common/onInit"); | ||
/** @internal */ | ||
@@ -45,3 +46,3 @@ exports.newTesterIosDeviceAlert = "appDistribution.newTesterIosDevice"; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)((0, alerts_1.convertAlertAndApp)(raw)); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw)); | ||
}; | ||
@@ -66,3 +67,3 @@ func.run = handler; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)((0, alerts_1.convertAlertAndApp)(raw)); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw)); | ||
}; | ||
@@ -69,0 +70,0 @@ func.run = handler; |
@@ -27,2 +27,3 @@ "use strict"; | ||
const alerts_1 = require("./alerts"); | ||
const onInit_1 = require("../../../common/onInit"); | ||
/** @internal */ | ||
@@ -59,3 +60,3 @@ exports.planUpdateAlert = "billing.planUpdate"; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)((0, alerts_1.convertAlertAndApp)(raw)); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw)); | ||
}; | ||
@@ -62,0 +63,0 @@ func.run = handler; |
@@ -27,2 +27,3 @@ "use strict"; | ||
const alerts_1 = require("./alerts"); | ||
const onInit_1 = require("../../../common/onInit"); | ||
/** @internal */ | ||
@@ -108,3 +109,3 @@ exports.newFatalIssueAlert = "crashlytics.newFatalIssue"; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler((0, alerts_1.convertAlertAndApp)(raw))); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))((0, alerts_1.convertAlertAndApp)(raw)); | ||
}; | ||
@@ -111,0 +112,0 @@ func.run = handler; |
@@ -1,5 +0,1 @@ | ||
/** | ||
* Cloud functions to handle Firebase Performance Monitoring events from Firebase Alerts. | ||
* @packageDocumentation | ||
*/ | ||
import { CloudEvent, CloudFunction } from "../../core"; | ||
@@ -6,0 +2,0 @@ import { EventHandlerOptions } from "../../options"; |
@@ -25,2 +25,8 @@ "use strict"; | ||
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"); | ||
@@ -45,3 +51,3 @@ /** @internal */ | ||
event.data.payload = convertedPayload; | ||
return handler(event); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler(event))); | ||
}; | ||
@@ -48,0 +54,0 @@ func.run = handler; |
@@ -34,2 +34,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
/** @internal */ | ||
@@ -185,3 +186,5 @@ exports.writtenEventType = "google.firebase.database.ref.v1.written"; | ||
const databaseEvent = makeChangedDatabaseEvent(event, instanceUrl, params); | ||
return (0, trace_1.wrapTraceContext)(handler)(databaseEvent); | ||
// 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); | ||
}; | ||
@@ -205,3 +208,3 @@ func.run = handler; | ||
const databaseEvent = makeDatabaseEvent(event, data, instanceUrl, params); | ||
return handler(databaseEvent); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(databaseEvent); | ||
}; | ||
@@ -208,0 +211,0 @@ func.run = handler; |
@@ -33,2 +33,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
function onCustomEventPublished(eventTypeOrOpts, handler) { | ||
@@ -46,3 +47,3 @@ var _a; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)(raw); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw); | ||
}; | ||
@@ -49,0 +50,0 @@ func.run = handler; |
@@ -34,2 +34,3 @@ "use strict"; | ||
const trace_1 = require("../trace"); | ||
const onInit_1 = require("../../common/onInit"); | ||
/** @internal */ | ||
@@ -224,3 +225,3 @@ exports.writtenEventType = "google.cloud.firestore.document.v1.written"; | ||
const firestoreEvent = makeFirestoreEvent(eventType, event, params); | ||
return (0, trace_1.wrapTraceContext)(handler)(firestoreEvent); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(firestoreEvent); | ||
}; | ||
@@ -241,3 +242,3 @@ func.run = handler; | ||
const firestoreEvent = makeChangedFirestoreEvent(event, params); | ||
return handler(firestoreEvent); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(firestoreEvent); | ||
}; | ||
@@ -244,0 +245,0 @@ func.run = handler; |
@@ -178,3 +178,3 @@ import * as express from "express"; | ||
*/ | ||
export declare function onCall<T = any, Return = any | Promise<any>>(opts: CallableOptions, handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return>; | ||
export declare function onCall<T = any, Return = any | Promise<any>>(opts: CallableOptions, handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return extends Promise<unknown> ? Return : Promise<Return>>; | ||
/** | ||
@@ -185,2 +185,2 @@ * Declares a callable method for clients to call using a Firebase SDK. | ||
*/ | ||
export declare function onCall<T = any, Return = any | Promise<any>>(handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return>; | ||
export declare function onCall<T = any, Return = any | Promise<any>>(handler: (request: CallableRequest<T>) => Return): CallableFunction<T, Return extends Promise<unknown> ? Return : Promise<Return>>; |
@@ -37,2 +37,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
function onRequest(optsOrHandler, handler) { | ||
@@ -63,3 +64,3 @@ let opts; | ||
} | ||
handler = (0, trace_1.wrapTraceContext)(handler); | ||
handler = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler)); | ||
Object.defineProperty(handler, "__trigger", { | ||
@@ -123,3 +124,3 @@ get: () => { | ||
// fix the length to prevent api versions from being mismatched. | ||
const fixedLen = (req) => handler(req); | ||
const fixedLen = (req) => (0, onInit_1.withInit)(handler)(req); | ||
let func = (0, https_1.onCallHandler)({ | ||
@@ -167,5 +168,5 @@ cors: { origin, methods: "POST" }, | ||
}; | ||
func.run = handler; | ||
func.run = (0, onInit_1.withInit)(handler); | ||
return func; | ||
} | ||
exports.onCall = onCall; |
@@ -30,2 +30,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
/** | ||
@@ -59,3 +60,3 @@ * Handles an event that is triggered before a user is created | ||
const wrappedHandler = (event) => handler(event); | ||
const func = (0, trace_1.wrapTraceContext)((0, identity_1.wrapHandler)(eventType, wrappedHandler)); | ||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)((0, identity_1.wrapHandler)(eventType, wrappedHandler))); | ||
const legacyEventType = `providers/cloud.auth/eventTypes/user.${eventType}`; | ||
@@ -62,0 +63,0 @@ /** Endpoint */ |
@@ -33,2 +33,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
/** | ||
@@ -129,3 +130,3 @@ * Google Cloud Pub/Sub is a globally distributed message bus that automatically scales as you need it. | ||
messagePublishedData.message = new Message(messagePublishedData.message); | ||
return (0, trace_1.wrapTraceContext)(handler)(raw); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw); | ||
}; | ||
@@ -132,0 +133,0 @@ func.run = handler; |
@@ -25,4 +25,6 @@ "use strict"; | ||
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 */ | ||
@@ -44,5 +46,5 @@ exports.eventType = "google.firebase.remoteconfig.remoteConfig.v1.updated"; | ||
const specificOpts = (0, options_1.optionsToEndpoint)(optsOrHandler); | ||
const func = (raw) => { | ||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)((raw) => { | ||
return handler(raw); | ||
}; | ||
})); | ||
func.run = handler; | ||
@@ -49,0 +51,0 @@ const ep = { |
@@ -30,2 +30,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
/** @internal */ | ||
@@ -76,3 +77,3 @@ function getOpts(args) { | ||
}; | ||
const func = (0, trace_1.wrapTraceContext)(httpFunc); | ||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(httpFunc)); | ||
func.run = handler; | ||
@@ -79,0 +80,0 @@ const globalOpts = options.getGlobalOptions(); |
@@ -34,2 +34,3 @@ "use strict"; | ||
const options = require("../options"); | ||
const onInit_1 = require("../../common/onInit"); | ||
/** @internal */ | ||
@@ -106,3 +107,3 @@ exports.archivedEvent = "google.cloud.storage.object.v1.archived"; | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)(raw); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw); | ||
}; | ||
@@ -109,0 +110,0 @@ func.run = handler; |
@@ -34,2 +34,3 @@ "use strict"; | ||
const manifest_1 = require("../../runtime/manifest"); | ||
const onInit_1 = require("../../common/onInit"); | ||
function onTaskDispatched(optsOrHandler, handler) { | ||
@@ -47,3 +48,3 @@ let opts; | ||
const fixedLen = (req) => handler(req); | ||
const func = (0, trace_1.wrapTraceContext)((0, tasks_1.onDispatchHandler)(fixedLen)); | ||
const func = (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)((0, tasks_1.onDispatchHandler)(fixedLen))); | ||
Object.defineProperty(func, "__trigger", { | ||
@@ -50,0 +51,0 @@ get: () => { |
@@ -25,2 +25,3 @@ "use strict"; | ||
exports.onTestMatrixCompleted = exports.eventType = void 0; | ||
const onInit_1 = require("../../common/onInit"); | ||
const manifest_1 = require("../../runtime/manifest"); | ||
@@ -47,3 +48,3 @@ const options_1 = require("../options"); | ||
const func = (raw) => { | ||
return (0, trace_1.wrapTraceContext)(handler)(raw); | ||
return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw); | ||
}; | ||
@@ -50,0 +51,0 @@ func.run = handler; |
{ | ||
"name": "firebase-functions", | ||
"version": "4.7.0", | ||
"version": "4.8.0", | ||
"description": "Firebase SDK for Cloud Functions", | ||
@@ -113,2 +113,5 @@ "keywords": [ | ||
], | ||
"v2/core": [ | ||
"lib/v2/core" | ||
], | ||
"v2/alerts": [ | ||
@@ -115,0 +118,0 @@ "lib/v2/providers/alerts" |
867579
133
18949