UNPKG

3.63 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { FirebaseApp, _FirebaseService } from '@firebase/app';
18import { HttpsCallable, HttpsCallableOptions } from './public-types';
19import { ContextProvider } from './context';
20import { Provider } from '@firebase/component';
21import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
22import { MessagingInternalComponentName } from '@firebase/messaging-interop-types';
23import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
24export declare const DEFAULT_REGION = "us-central1";
25/**
26 * Describes the shape of the HttpResponse body.
27 * It makes functions that would otherwise take {} able to access the
28 * possible elements in the body more easily
29 */
30export interface HttpResponseBody {
31 data?: unknown;
32 result?: unknown;
33 error?: {
34 message?: unknown;
35 status?: unknown;
36 details?: unknown;
37 };
38}
39/**
40 * The main class for the Firebase Functions SDK.
41 * @internal
42 */
43export declare class FunctionsService implements _FirebaseService {
44 readonly app: FirebaseApp;
45 readonly fetchImpl: typeof fetch;
46 readonly contextProvider: ContextProvider;
47 emulatorOrigin: string | null;
48 cancelAllRequests: Promise<void>;
49 deleteService: () => Promise<void>;
50 region: string;
51 customDomain: string | null;
52 /**
53 * Creates a new Functions service for the given app.
54 * @param app - The FirebaseApp to use.
55 */
56 constructor(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, messagingProvider: Provider<MessagingInternalComponentName>, appCheckProvider: Provider<AppCheckInternalComponentName>, regionOrCustomDomain: string | undefined, fetchImpl: typeof fetch);
57 _delete(): Promise<void>;
58 /**
59 * Returns the URL for a callable with the given name.
60 * @param name - The name of the callable.
61 * @internal
62 */
63 _url(name: string): string;
64}
65/**
66 * Modify this instance to communicate with the Cloud Functions emulator.
67 *
68 * Note: this must be called before this instance has been used to do any operations.
69 *
70 * @param host The emulator host (ex: localhost)
71 * @param port The emulator port (ex: 5001)
72 * @public
73 */
74export declare function connectFunctionsEmulator(functionsInstance: FunctionsService, host: string, port: number): void;
75/**
76 * Returns a reference to the callable https trigger with the given name.
77 * @param name - The name of the trigger.
78 * @public
79 */
80export declare function httpsCallable<RequestData, ResponseData>(functionsInstance: FunctionsService, name: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData>;
81/**
82 * Returns a reference to the callable https trigger with the given url.
83 * @param url - The url of the trigger.
84 * @public
85 */
86export declare function httpsCallableFromURL<RequestData, ResponseData>(functionsInstance: FunctionsService, url: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData>;