-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathindex.ts
More file actions
87 lines (81 loc) · 2.81 KB
/
index.ts
File metadata and controls
87 lines (81 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*!
* @license
* Copyright 2024 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Firebase Data Connect service.
*
* @packageDocumentation
*/
import { App, getApp } from '../app';
import { FirebaseApp } from '../app/firebase-app';
import { DataConnect, DataConnectService } from './data-connect';
import { ConnectorConfig } from './data-connect-api';
export {
GraphqlOptions,
ExecuteGraphqlResponse,
ConnectorConfig,
ImpersonateAuthenticated,
ImpersonateUnauthenticated,
AuthClaims
} from './data-connect-api'
export {
DataConnect,
} from './data-connect'
/**
* Gets the {@link DataConnect} service with the provided connector configuration
* for the default app or a given app.
*
* `getDataConnect(connectorConfig)` can be called with no app argument to access the default
* app's `DataConnect` service or as `getDataConnect(connectorConfig, app)` to access the
* `DataConnect` service associated with a specific app.
*
* @example
* ```javascript
* const connectorConfig: ConnectorConfig = {
* location: 'us-west2',
* serviceId: 'my-service',
* };
*
* // Get the `DataConnect` service for the default app
* const defaultDataConnect = getDataConnect(connectorConfig);
* ```
*
* @example
* ```javascript
* // Get the `DataConnect` service for a given app
* const otherDataConnect = getDataConnect(connectorConfig, otherApp);
* ```
*
* @param connectorConfig - Connector configuration for the `DataConnect` service.
*
* @param app - Optional app for which to return the `DataConnect` service.
* If not provided, the default `DataConnect` service is returned.
*
* @returns The default `DataConnect` service with the provided connector configuration
* if no app is provided, or the `DataConnect` service associated with the provided app.
*/
// export function getDataConnect(connectorConfig: ConnectorConfig, app?: App): DataConnect {
// if (typeof app === 'undefined') {
// app = getApp();
// }
export function getDataConnect(connectorConfig: ConnectorConfig, app?: App): DataConnect {
if (typeof app === 'undefined') {
app = getApp();
}
const firebaseApp: FirebaseApp = app as FirebaseApp;
const dataConnectService = firebaseApp.getOrInitService('dataConnect', (app) => new DataConnectService(app));
return dataConnectService.getDataConnect(connectorConfig);
}