firebase-functions package

Firebase Cloud Functions 的第二代 API。该SDK支持深度导入。例如,命名空间pubsubfirebase-functions/v2中可用,或者可以直接从firebase-functions/v2/pubsub导入

功能

功能描述
设置全局选项(选项)为使用第二代 SDK 编写的所有函数设置默认选项。

课程

班级描述
改变用于更改状态的事件的 Cloud Functions 接口,例如实时数据库或 Cloud Firestore onWriteonUpdate事件。有关用于构造Change对象的格式的更多信息,请参见下文。

接口

界面描述
云事件(测试版) CloudEventBase是用于编码无服务器事件的跨平台格式的基础。有关更多信息,请参阅 https://github.com/cloudevents/spec。
云函数(测试版) CloudEvents 的处理程序。
事件处理选项可以在任何事件处理函数上设置的附加字段。
全局选项GlobalOptions是可以在整个项目中设置的选项。这些选项对于 HTTPS 和事件处理函数是通用的。

命名空间

命名空间描述
警报
数据库
事件弧
火库
https
身份
记录器
参数
发布订阅
远程配置
调度程序
贮存
任务
测试实验室

类型别名

类型别名描述
入口设置IngressSettings的可用选项列表。
内存选项Cloud Functions 支持的可用内存选项列表。
参数将所有参数捕获组映射到记录的键的类型。例如,ParamsOf < “用户/ { uid } > 是 { uid: string } ParamsOf < “用户/ { uid } /日志/ {日志} > 是 { uid: 字符串;日志:字符串 } ParamsOf < “一些/静态/数据” > 是 { }出于灵活性原因,ParamsOf是记录<字符串,字符串>
支持地区Cloud Functions(第二代)支持的所有区域的列表。
Vpc出口设置VpcConnectorEgressSettings的可用选项列表。

设置全局选项()

为使用第二代 SDK 编写的所有函数设置默认选项。

签名:

export declare function setGlobalOptions(options: GlobalOptions): void;

参数

范围类型描述
选项全局选项设置为默认值的选项

返回:

空白

入口设置

IngressSettings的可用选项列表

签名:

export type IngressSetting = "ALLOW_ALL" | "ALLOW_INTERNAL_ONLY" | "ALLOW_INTERNAL_AND_GCLB";

内存选项

Cloud Functions 支持的可用内存选项列表。

签名:

export type MemoryOption = "128MiB" | "256MiB" | "512MiB" | "1GiB" | "2GiB" | "4GiB" | "8GiB" | "16GiB" | "32GiB";

参数

将所有参数捕获组映射到记录的键的类型。例如,ParamsOf < “用户/ { uid } > 是 { uid: string } ParamsOf < “用户/ { uid } /日志/ {日志} > 是 { uid: 字符串;日志:字符串 } ParamsOf < “一些/静态/数据” > 是 { }

出于灵活性原因,ParamsOf是记录<字符串,字符串>

签名:

export type ParamsOf<PathPattern extends string> = string extends PathPattern ? Record<string, string> : {
    [Key in Extract<Split<NullSafe<PathPattern>, "/">[number]>]: string;
};

支持地区

Cloud Functions(第二代)支持的所有区域的列表。

签名:

export type SupportedRegion = "asia-east1" | "asia-northeast1" | "asia-northeast2" | "europe-north1" | "europe-west1" | "europe-west4" | "us-central1" | "us-east1" | "us-east4" | "us-west1" | "asia-east2" | "asia-northeast3" | "asia-southeast1" | "asia-southeast2" | "asia-south1" | "australia-southeast1" | "europe-central2" | "europe-west2" | "europe-west3" | "europe-west6" | "northamerica-northeast1" | "southamerica-east1" | "us-west2" | "us-west3" | "us-west4";

Vpc出口设置

VpcConnectorEgressSettings的可用选项列表

签名:

export type VpcEgressSetting = "PRIVATE_RANGES_ONLY" | "ALL_TRAFFIC";