EventContext interface

事件发生的上下文。

EventContext 描述: - 事件发生的时间。 - 事件的唯一标识符。 - 发生事件的资源(如果适用)。 - 触发事件的请求的授权(如果适用且可用)。

签名:

export interface EventContext<Params = Record<string, string>> 

特性

财产类型描述
授权{ 令牌:对象; uid:字符串; }触发该功能的用户的身份验证信息。
授权类型“管理员” | “用户” | “未经验证”用户的权限级别。
事件ID细绳事件的唯一标识符。
事件类型细绳事件类型。
参数参数一个对象,其中包含提供给实时数据库触发器方法的path参数中的通配符值。
资源资源发出事件的资源。
时间戳细绳RFC 3339字符串形式的事件时间戳。

事件上下文.auth

触发该功能的用户的身份验证信息。

该对象包含经过身份验证的用户的uidtoken属性。有关包括令牌密钥在内的更多详细信息,请参阅安全规则参考

仅针对实时数据库触发器和可调用函数填充此字段。对于未经身份验证的用户,该字段为空。对于 Firebase 管理员用户和不提供用户信息的事件类型,此字段不存在。

签名:

auth?: {
        token: object;
        uid: string;
    };

EventContext.authType

用户的权限级别。

有效值为:

  • ADMIN :开发者用户或通过服务帐户进行身份验证的用户。

  • USER :已知用户。

  • UNAUTHENTICATED :未经验证的操作

  • null :适用于不提供用户信息的事件类型(实时数据库除外)。

签名:

authType?: "ADMIN" | "USER" | "UNAUTHENTICATED";

事件上下文.eventId

事件的唯一标识符。

签名:

eventId: string;

EventContext.eventType

事件类型。

可能的值为:

  • google.analytics.event.log

  • google.firebase.auth.user.create

  • google.firebase.auth.user.delete

  • google.firebase.database.ref.write

  • google.firebase.database.ref.create

  • google.firebase.database.ref.update

  • google.firebase.database.ref.delete

  • google.firestore.document.write

  • google.firestore.document.create

  • google.firestore.document.update

  • google.firestore.document.delete

  • google.pubsub.topic.publish

  • google.firebase.remoteconfig.update

  • google.storage.object.finalize

  • google.storage.object.archive

  • google.storage.object.delete

  • google.storage.object.metadataUpdate

  • google.testing.testMatrix.complete

签名:

eventType: string;

EventContext.params

一个对象,其中包含提供给实时数据库触发器方法的path参数中的通配符值。

签名:

params: Params;

EventContext.资源

发出事件的资源。

有效值为:

分析: projects/<projectId>/events/<analyticsEventType>

实时数据库: projects/_/instances/<databaseInstance>/refs/<databasePath>

存储: projects/_/buckets/<bucketName>/objects/<fileName>#<generation>

身份验证: projects/<projectId>

发布/订阅: projects/<projectId>/topics/<topicName>

由于实时数据库实例和 Cloud Storage 存储分区是全局唯一的且与项目无关,因此它们的资源以projects/_开头。下划线不是有效的项目名称。

签名:

resource: Resource;

EventContext.timestamp

RFC 3339字符串形式的事件时间戳。

签名:

timestamp: string;