-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
14 lines (12 loc) · 1.23 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import * as functions from 'firebase-functions';
import * as firestore from '@google-cloud/firestore';
import { TypedDocumentSnapshot, TypedQueryDocumentSnapshot } from 'typesafe-node-firestore';
interface TypedEventContext<T extends { [option: string]: any }> extends functions.EventContext {
readonly params: T;
};
export interface TypedDocumentBuilder<T extends firestore.DocumentData, U extends { [option: string]: any } = {}> extends functions.firestore.DocumentBuilder {
onWrite(handler: (change: functions.Change<TypedDocumentSnapshot<T>>, context: TypedEventContext<U>) => PromiseLike<any> | any): functions.CloudFunction<functions.Change<firestore.DocumentSnapshot>>;
onUpdate(handler: (change: functions.Change<TypedQueryDocumentSnapshot<T>>, context: TypedEventContext<U>) => PromiseLike<any> | any): functions.CloudFunction<functions.Change<firestore.QueryDocumentSnapshot>>;
onCreate(handler: (snapshot: TypedQueryDocumentSnapshot<T>, context: TypedEventContext<U>) => PromiseLike<any> | any): functions.CloudFunction<firestore.QueryDocumentSnapshot>;
onDelete(handler: (snapshot: TypedQueryDocumentSnapshot<T>, context: TypedEventContext<U>) => PromiseLike<any> | any): functions.CloudFunction<firestore.QueryDocumentSnapshot>;
};