mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-13 22:56:18 +00:00
108 lines
4.2 KiB
TypeScript
108 lines
4.2 KiB
TypeScript
/// <reference types="express" />
|
|
import { Request, Response } from 'express';
|
|
import { DeploymentOptions } from './function-builder';
|
|
export { Request, Response };
|
|
/** The context in which an event occurred.
|
|
* An EventContext describes:
|
|
* - The time an event occurred.
|
|
* - A unique identifier of the event.
|
|
* - The resource on which the event occurred, if applicable.
|
|
* - Authorization of the request that triggered the event, if applicable and available.
|
|
*/
|
|
export interface EventContext {
|
|
/** ID of the event */
|
|
eventId: string;
|
|
/** Timestamp for when the event occured (ISO string) */
|
|
timestamp: string;
|
|
/** Type of event */
|
|
eventType: string;
|
|
/** Resource that triggered the event */
|
|
resource: Resource;
|
|
/** Key-value pairs that represent the values of wildcards in a database reference */
|
|
params: {
|
|
[option: string]: any;
|
|
};
|
|
/** Type of authentication for the triggering action, valid value are: 'ADMIN', 'USER',
|
|
* 'UNAUTHENTICATED'. Only available for database functions.
|
|
*/
|
|
authType?: 'ADMIN' | 'USER' | 'UNAUTHENTICATED';
|
|
/** Firebase auth variable for the user whose action triggered the function. Field will be
|
|
* null for unauthenticated users, and will not exist for admin users. Only available
|
|
* for database functions.
|
|
*/
|
|
auth?: {
|
|
uid: string;
|
|
token: object;
|
|
};
|
|
}
|
|
/** Change describes a change of state - "before" represents the state prior
|
|
* to the event, "after" represents the state after the event.
|
|
*/
|
|
export declare class Change<T> {
|
|
before: T;
|
|
after: T;
|
|
constructor(before?: T, after?: T);
|
|
}
|
|
/** ChangeJson is the JSON format used to construct a Change object. */
|
|
export interface ChangeJson {
|
|
/** Key-value pairs representing state of data before the change.
|
|
* If `fieldMask` is set, then only fields that changed are present in `before`.
|
|
*/
|
|
before?: any;
|
|
/** Key-value pairs representing state of data after the change. */
|
|
after?: any;
|
|
/** Comma-separated string that represents names of field that changed. */
|
|
fieldMask?: string;
|
|
}
|
|
export declare namespace Change {
|
|
/** Factory method for creating a Change from a `before` object and an `after` object. */
|
|
function fromObjects<T>(before: T, after: T): Change<T>;
|
|
/** Factory method for creating a Change from a JSON and an optional customizer function to be
|
|
* applied to both the `before` and the `after` fields.
|
|
*/
|
|
function fromJSON<T>(json: ChangeJson, customizer?: (x: any) => T): Change<T>;
|
|
}
|
|
/** Resource is a standard format for defining a resource (google.rpc.context.AttributeContext.Resource).
|
|
* In Cloud Functions, it is the resource that triggered the function - such as a storage bucket.
|
|
*/
|
|
export interface Resource {
|
|
service: string;
|
|
name: string;
|
|
type?: string;
|
|
labels?: {
|
|
[tag: string]: string;
|
|
};
|
|
}
|
|
/** TriggerAnnotated is used internally by the firebase CLI to understand what type of Cloud Function to deploy. */
|
|
export interface TriggerAnnotated {
|
|
__trigger: {
|
|
httpsTrigger?: {};
|
|
eventTrigger?: {
|
|
eventType: string;
|
|
resource: string;
|
|
service: string;
|
|
};
|
|
labels?: {
|
|
[key: string]: string;
|
|
};
|
|
regions?: string[];
|
|
timeout?: string;
|
|
availableMemoryMb?: number;
|
|
};
|
|
}
|
|
/** A Runnable has a `run` method which directly invokes the user-defined function - useful for unit testing. */
|
|
export interface Runnable<T> {
|
|
run: (data: T, context: any) => PromiseLike<any> | any;
|
|
}
|
|
/**
|
|
* An HttpsFunction is both an object that exports its trigger definitions at __trigger and
|
|
* can be called as a function that takes an express.js Request and Response object.
|
|
*/
|
|
export declare type HttpsFunction = TriggerAnnotated & ((req: Request, resp: Response) => void);
|
|
/**
|
|
* A CloudFunction is both an object that exports its trigger definitions at __trigger and
|
|
* can be called as a function using the raw JS API for Google Cloud Functions.
|
|
*/
|
|
export declare type CloudFunction<T> = Runnable<T> & TriggerAnnotated & ((input: any, context?: any) => PromiseLike<any> | any);
|
|
export declare function optsToTrigger(opts: DeploymentOptions): any;
|