@firebase/data-connect 0.0.2-dataconnect-preview.877f8b7d0 → 0.0.3-canary.beaa4dffb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +304 -54
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +303 -53
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +323 -52
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +324 -53
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +186 -41
- package/dist/node-esm/index.node.esm.js +303 -53
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +47 -3
- package/dist/node-esm/src/api/Mutation.d.ts +26 -1
- package/dist/node-esm/src/api/Reference.d.ts +6 -0
- package/dist/node-esm/src/api/index.d.ts +1 -0
- package/dist/node-esm/src/api/query.d.ts +51 -1
- package/dist/node-esm/src/api.browser.d.ts +12 -7
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +30 -0
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +1 -1
- package/dist/node-esm/src/core/QueryManager.d.ts +1 -1
- package/dist/node-esm/src/core/error.d.ts +2 -1
- package/dist/node-esm/src/network/fetch.d.ts +1 -1
- package/dist/node-esm/src/network/transport/index.d.ts +8 -10
- package/dist/node-esm/src/network/transport/rest.d.ts +24 -10
- package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
- package/dist/private.d.ts +152 -59
- package/dist/public.d.ts +133 -50
- package/dist/src/api/DataConnect.d.ts +47 -3
- package/dist/src/api/Mutation.d.ts +26 -1
- package/dist/src/api/Reference.d.ts +6 -0
- package/dist/src/api/index.d.ts +1 -0
- package/dist/src/api/query.d.ts +51 -1
- package/dist/src/api.browser.d.ts +12 -7
- package/dist/src/core/AppCheckTokenProvider.d.ts +30 -0
- package/dist/src/core/FirebaseAuthProvider.d.ts +1 -1
- package/dist/src/core/QueryManager.d.ts +1 -1
- package/dist/src/core/error.d.ts +2 -1
- package/dist/src/network/fetch.d.ts +1 -1
- package/dist/src/network/transport/index.d.ts +8 -10
- package/dist/src/network/transport/rest.d.ts +24 -10
- package/dist/src/util/validateArgs.d.ts +33 -0
- package/package.json +11 -7
|
@@ -17,13 +17,18 @@
|
|
|
17
17
|
import { OnCompleteSubscription, OnErrorSubscription, OnResultSubscription, QueryRef, QueryUnsubscribe, SubscriptionOptions } from './api/query';
|
|
18
18
|
import { SerializedRef } from './api/Reference';
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
24
|
-
* @param onErr
|
|
25
|
-
* @param initialCache
|
|
26
|
-
* @returns
|
|
20
|
+
* Subscribe to a `QueryRef`
|
|
21
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
22
|
+
* @param observer observer object to use for subscribing.
|
|
23
|
+
* @returns `SubscriptionOptions`
|
|
27
24
|
*/
|
|
28
25
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
26
|
+
/**
|
|
27
|
+
* Subscribe to a `QueryRef`
|
|
28
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
29
|
+
* @param onNext Callback to call when result comes back.
|
|
30
|
+
* @param onError Callback to call when error gets thrown.
|
|
31
|
+
* @param onComplete Called when subscription completes.
|
|
32
|
+
* @returns `SubscriptionOptions`
|
|
33
|
+
*/
|
|
29
34
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 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
|
+
*/
|
|
17
|
+
import { AppCheckInternalComponentName, AppCheckTokenListener, AppCheckTokenResult } from '@firebase/app-check-interop-types';
|
|
18
|
+
import { Provider } from '@firebase/component';
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
* Abstraction around AppCheck's token fetching capabilities.
|
|
22
|
+
*/
|
|
23
|
+
export declare class AppCheckTokenProvider {
|
|
24
|
+
private appName_;
|
|
25
|
+
private appCheckProvider?;
|
|
26
|
+
private appCheck?;
|
|
27
|
+
constructor(appName_: string, appCheckProvider?: Provider<AppCheckInternalComponentName>);
|
|
28
|
+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
29
|
+
addTokenChangeListener(listener: AppCheckTokenListener): void;
|
|
30
|
+
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { FirebaseOptions } from '@firebase/app';
|
|
17
|
+
import { FirebaseOptions } from '@firebase/app-types';
|
|
18
18
|
import { FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
19
19
|
import { Provider } from '@firebase/component';
|
|
20
20
|
export interface AuthTokenProvider {
|
|
@@ -28,7 +28,7 @@ export declare class QueryManager {
|
|
|
28
28
|
private transport;
|
|
29
29
|
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
30
30
|
constructor(transport: DataConnectTransport);
|
|
31
|
-
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<
|
|
31
|
+
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<Data, Variables>;
|
|
32
32
|
addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
|
|
33
33
|
executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
34
34
|
enableEmulator(host: string, port: number): void;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { FirebaseError } from '@firebase/util';
|
|
18
|
-
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
|
|
18
|
+
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
19
19
|
export declare type Code = DataConnectErrorCode;
|
|
20
20
|
export declare const Code: {
|
|
21
21
|
OTHER: DataConnectErrorCode;
|
|
@@ -24,6 +24,7 @@ export declare const Code: {
|
|
|
24
24
|
NOT_SUPPORTED: DataConnectErrorCode;
|
|
25
25
|
INVALID_ARGUMENT: DataConnectErrorCode;
|
|
26
26
|
PARTIAL_ERROR: DataConnectErrorCode;
|
|
27
|
+
UNAUTHORIZED: DataConnectErrorCode;
|
|
27
28
|
};
|
|
28
29
|
/** An error returned by a DataConnect operation. */
|
|
29
30
|
export declare class DataConnectError extends FirebaseError {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
export declare function initializeFetch(fetchImpl: typeof fetch): void;
|
|
18
|
-
export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, accessToken: string | null): Promise<{
|
|
18
|
+
export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, appId: string | null, accessToken: string | null, appCheckToken: string | null, _isUsingGen: boolean): Promise<{
|
|
19
19
|
data: T;
|
|
20
20
|
errors: Error[];
|
|
21
21
|
}>;
|
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
|
|
18
|
+
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
|
|
18
19
|
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
19
23
|
export interface DataConnectTransport {
|
|
20
24
|
invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
|
|
21
25
|
data: T;
|
|
@@ -33,13 +37,7 @@ export interface CancellableOperation<T> extends PromiseLike<{
|
|
|
33
37
|
}> {
|
|
34
38
|
cancel: () => void;
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export interface Sender<T> {
|
|
41
|
-
abort: () => void;
|
|
42
|
-
send: () => Promise<T>;
|
|
43
|
-
}
|
|
44
|
-
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
|
|
45
|
-
export * from '../../core/FirebaseAuthProvider';
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
|
|
@@ -15,11 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
|
|
18
|
+
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
|
|
18
19
|
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
|
|
19
20
|
import { DataConnectTransport } from '.';
|
|
20
21
|
export declare class RESTTransport implements DataConnectTransport {
|
|
21
22
|
private apiKey?;
|
|
23
|
+
private appId?;
|
|
22
24
|
private authProvider?;
|
|
25
|
+
private appCheckProvider?;
|
|
26
|
+
private _isUsingGen;
|
|
23
27
|
private _host;
|
|
24
28
|
private _port;
|
|
25
29
|
private _location;
|
|
@@ -28,17 +32,27 @@ export declare class RESTTransport implements DataConnectTransport {
|
|
|
28
32
|
private _project;
|
|
29
33
|
private _serviceName;
|
|
30
34
|
private _accessToken;
|
|
31
|
-
private
|
|
32
|
-
|
|
35
|
+
private _appCheckToken;
|
|
36
|
+
private _lastToken;
|
|
37
|
+
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
|
|
33
38
|
get endpointUrl(): string;
|
|
34
39
|
useEmulator(host: string, port?: number, isSecure?: boolean): void;
|
|
35
40
|
onTokenChanged(newToken: string | null): void;
|
|
36
|
-
getWithAuth(): Promise<string>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
getWithAuth(forceToken?: boolean): Promise<string>;
|
|
42
|
+
_setLastToken(lastToken: string | null): void;
|
|
43
|
+
withRetry<T>(promiseFactory: () => Promise<{
|
|
44
|
+
data: T;
|
|
45
|
+
errors: Error[];
|
|
46
|
+
}>, retry?: boolean): Promise<{
|
|
47
|
+
data: T;
|
|
48
|
+
errors: Error[];
|
|
49
|
+
}>;
|
|
50
|
+
invokeQuery: <T, U>(queryName: string, body?: U) => PromiseLike<{
|
|
51
|
+
data: T;
|
|
52
|
+
errors: Error[];
|
|
53
|
+
}>;
|
|
54
|
+
invokeMutation: <T, U>(queryName: string, body?: U) => PromiseLike<{
|
|
55
|
+
data: T;
|
|
56
|
+
errors: Error[];
|
|
57
|
+
}>;
|
|
44
58
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 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
|
+
*/
|
|
17
|
+
import { ConnectorConfig, DataConnect } from '../api/DataConnect';
|
|
18
|
+
interface ParsedArgs<Variables> {
|
|
19
|
+
dc: DataConnect;
|
|
20
|
+
vars: Variables;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
|
|
24
|
+
* and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
|
|
25
|
+
* @param connectorConfig
|
|
26
|
+
* @param dcOrVars
|
|
27
|
+
* @param vars
|
|
28
|
+
* @param validateVars
|
|
29
|
+
* @returns {DataConnect} and {Variables} instance
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
|
|
33
|
+
export {};
|
package/dist/private.d.ts
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
8
|
+
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
|
|
9
|
+
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
|
|
7
10
|
import { FirebaseApp } from '@firebase/app';
|
|
8
11
|
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
9
12
|
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
10
13
|
import { FirebaseError } from '@firebase/util';
|
|
11
|
-
import { FirebaseOptions } from '@firebase/app';
|
|
12
14
|
import { LogLevelString } from '@firebase/logger';
|
|
13
15
|
import { Provider } from '@firebase/component';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
/* Excluded from this release type: AppCheckTokenProvider */
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
declare type AuthTokenListener = (token: string | null) => void;
|
|
20
|
+
|
|
21
|
+
declare interface AuthTokenProvider {
|
|
18
22
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
19
23
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
20
24
|
}
|
|
@@ -25,27 +29,44 @@ export declare interface CancellableOperation<T> extends PromiseLike<{
|
|
|
25
29
|
cancel: () => void;
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Connect to the DataConnect Emulator
|
|
34
|
+
* @param dc Data Connect instance
|
|
35
|
+
* @param host host of emulator server
|
|
36
|
+
* @param port port of emulator server
|
|
37
|
+
* @param sslEnabled use https
|
|
38
|
+
*/
|
|
28
39
|
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
29
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Connector Config for calling Data Connect backend.
|
|
43
|
+
*/
|
|
30
44
|
export declare interface ConnectorConfig {
|
|
31
45
|
location: string;
|
|
32
46
|
connector: string;
|
|
33
47
|
service: string;
|
|
34
48
|
}
|
|
35
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Class representing Firebase Data Connect
|
|
52
|
+
*/
|
|
36
53
|
export declare class DataConnect {
|
|
37
54
|
readonly app: FirebaseApp;
|
|
38
55
|
private readonly dataConnectOptions;
|
|
39
56
|
private readonly _authProvider;
|
|
57
|
+
private readonly _appCheckProvider;
|
|
40
58
|
_queryManager: QueryManager;
|
|
41
59
|
_mutationManager: MutationManager;
|
|
42
60
|
isEmulator: boolean;
|
|
43
|
-
|
|
61
|
+
_initialized: boolean;
|
|
44
62
|
private _transport;
|
|
45
63
|
private _transportClass;
|
|
46
64
|
private _transportOptions?;
|
|
47
65
|
private _authTokenProvider?;
|
|
48
|
-
|
|
66
|
+
_isUsingGeneratedSdk: boolean;
|
|
67
|
+
private _appCheckTokenProvider?;
|
|
68
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
69
|
+
_useGeneratedSdk(): void;
|
|
49
70
|
_delete(): Promise<void>;
|
|
50
71
|
getSettings(): ConnectorConfig;
|
|
51
72
|
setInitialized(): void;
|
|
@@ -76,8 +97,11 @@ declare class DataConnectError extends FirebaseError {
|
|
|
76
97
|
message: string);
|
|
77
98
|
}
|
|
78
99
|
|
|
79
|
-
declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
|
|
100
|
+
declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
80
101
|
|
|
102
|
+
/**
|
|
103
|
+
* DataConnectOptions including project id
|
|
104
|
+
*/
|
|
81
105
|
export declare interface DataConnectOptions extends ConnectorConfig {
|
|
82
106
|
projectId: string;
|
|
83
107
|
}
|
|
@@ -86,57 +110,53 @@ export declare interface DataConnectResult<Data, Variables> extends OpResult<Dat
|
|
|
86
110
|
ref: OperationRef<Data, Variables>;
|
|
87
111
|
}
|
|
88
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Representation of user provided subscription options.
|
|
115
|
+
*/
|
|
89
116
|
export declare interface DataConnectSubscription<Data, Variables> {
|
|
90
117
|
userCallback: OnResultSubscription<Data, Variables>;
|
|
91
118
|
errCallback?: (e?: DataConnectError) => void;
|
|
92
119
|
unsubscribe: () => void;
|
|
93
120
|
}
|
|
94
121
|
|
|
95
|
-
|
|
96
|
-
invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
|
|
97
|
-
data: T;
|
|
98
|
-
errors: Error[];
|
|
99
|
-
}>;
|
|
100
|
-
invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
|
|
101
|
-
data: T;
|
|
102
|
-
errors: Error[];
|
|
103
|
-
}>;
|
|
104
|
-
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
|
|
105
|
-
onTokenChanged: (token: string | null) => void;
|
|
106
|
-
}
|
|
122
|
+
/* Excluded from this release type: DataConnectTransport */
|
|
107
123
|
|
|
108
124
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
109
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Execute Mutation
|
|
128
|
+
* @param mutationRef mutation to execute
|
|
129
|
+
* @returns `MutationRef`
|
|
130
|
+
*/
|
|
110
131
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
111
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Execute Query
|
|
135
|
+
* @param queryRef query to execute.
|
|
136
|
+
* @returns `QueryPromise`
|
|
137
|
+
*/
|
|
112
138
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
113
139
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
private _options;
|
|
119
|
-
private _authProvider;
|
|
120
|
-
private _auth;
|
|
121
|
-
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
122
|
-
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
123
|
-
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
124
|
-
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
125
|
-
}
|
|
126
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Initialize DataConnect instance
|
|
142
|
+
* @param options ConnectorConfig
|
|
143
|
+
*/
|
|
127
144
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
128
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Initialize DataConnect instance
|
|
148
|
+
* @param app FirebaseApp to initialize to.
|
|
149
|
+
* @param options ConnectorConfig
|
|
150
|
+
*/
|
|
129
151
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
130
152
|
|
|
131
153
|
export declare const MUTATION_STR = "mutation";
|
|
132
154
|
|
|
133
|
-
|
|
134
|
-
private _transport;
|
|
135
|
-
private _inflight;
|
|
136
|
-
constructor(_transport: DataConnectTransport);
|
|
137
|
-
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
138
|
-
}
|
|
155
|
+
/* Excluded from this release type: MutationManager */
|
|
139
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Mutation return value from `executeMutation`
|
|
159
|
+
*/
|
|
140
160
|
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
141
161
|
}
|
|
142
162
|
|
|
@@ -144,21 +164,41 @@ export declare interface MutationRef<Data, Variables> extends OperationRef<Data,
|
|
|
144
164
|
refType: typeof MUTATION_STR;
|
|
145
165
|
}
|
|
146
166
|
|
|
147
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Creates a `MutationRef`
|
|
169
|
+
* @param dcInstance Data Connect instance
|
|
170
|
+
* @param mutationName name of mutation
|
|
171
|
+
*/
|
|
172
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
148
173
|
|
|
174
|
+
/**
|
|
175
|
+
*
|
|
176
|
+
* @param dcInstance Data Connect instance
|
|
177
|
+
* @param mutationName name of mutation
|
|
178
|
+
* @param variables variables to send with mutation
|
|
179
|
+
*/
|
|
149
180
|
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
150
181
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Mutation Result from `executeMutation`
|
|
184
|
+
*/
|
|
154
185
|
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
155
186
|
ref: MutationRef<Data, Variables>;
|
|
156
187
|
}
|
|
157
188
|
|
|
189
|
+
/**
|
|
190
|
+
* `OnCompleteSubscription`
|
|
191
|
+
*/
|
|
158
192
|
export declare type OnCompleteSubscription = () => void;
|
|
159
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Signature for `OnErrorSubscription` for `subscribe`
|
|
196
|
+
*/
|
|
160
197
|
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
161
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Signature for `OnResultSubscription` for `subscribe`
|
|
201
|
+
*/
|
|
162
202
|
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
163
203
|
|
|
164
204
|
export declare interface OperationRef<_Data, Variables> {
|
|
@@ -174,6 +214,11 @@ export declare interface OpResult<Data> {
|
|
|
174
214
|
fetchTime: string;
|
|
175
215
|
}
|
|
176
216
|
|
|
217
|
+
declare interface ParsedArgs<Variables> {
|
|
218
|
+
dc: DataConnect;
|
|
219
|
+
vars: Variables;
|
|
220
|
+
}
|
|
221
|
+
|
|
177
222
|
/* Excluded from this release type: parseOptions */
|
|
178
223
|
|
|
179
224
|
export declare const QUERY_STR = "query";
|
|
@@ -182,46 +227,69 @@ declare class QueryManager {
|
|
|
182
227
|
private transport;
|
|
183
228
|
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
184
229
|
constructor(transport: DataConnectTransport);
|
|
185
|
-
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<
|
|
230
|
+
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<Data, Variables>;
|
|
186
231
|
addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
|
|
187
232
|
executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
188
233
|
enableEmulator(host: string, port: number): void;
|
|
189
234
|
}
|
|
190
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Promise returned from `executeQuery`
|
|
238
|
+
*/
|
|
191
239
|
export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
192
240
|
}
|
|
193
241
|
|
|
242
|
+
/**
|
|
243
|
+
* QueryRef object
|
|
244
|
+
*/
|
|
194
245
|
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
195
246
|
refType: typeof QUERY_STR;
|
|
196
247
|
}
|
|
197
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Execute Query
|
|
251
|
+
* @param dcInstance Data Connect instance to use.
|
|
252
|
+
* @param queryName Query to execute
|
|
253
|
+
* @returns `QueryRef`
|
|
254
|
+
*/
|
|
198
255
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
199
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Execute Query
|
|
259
|
+
* @param dcInstance Data Connect instance to use.
|
|
260
|
+
* @param queryName Query to execute
|
|
261
|
+
* @param variables Variables to execute with
|
|
262
|
+
* @returns `QueryRef`
|
|
263
|
+
*/
|
|
200
264
|
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
201
265
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Result of `executeQuery`
|
|
268
|
+
*/
|
|
205
269
|
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
206
270
|
ref: QueryRef<Data, Variables>;
|
|
207
271
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
208
272
|
}
|
|
209
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Signature for unsubscribe from `subscribe`
|
|
276
|
+
*/
|
|
210
277
|
export declare type QueryUnsubscribe = () => void;
|
|
211
278
|
|
|
212
279
|
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
213
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
|
|
283
|
+
*/
|
|
214
284
|
export declare interface RefInfo<Variables> {
|
|
215
285
|
name: string;
|
|
216
286
|
variables: Variables;
|
|
217
287
|
connectorConfig: DataConnectOptions;
|
|
218
288
|
}
|
|
219
289
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
292
|
+
*/
|
|
225
293
|
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
226
294
|
refInfo: RefInfo<Variables>;
|
|
227
295
|
}
|
|
@@ -233,27 +301,45 @@ export declare const SOURCE_CACHE = "CACHE";
|
|
|
233
301
|
export declare const SOURCE_SERVER = "SERVER";
|
|
234
302
|
|
|
235
303
|
/**
|
|
236
|
-
*
|
|
237
|
-
* @
|
|
238
|
-
* @param
|
|
239
|
-
* @
|
|
240
|
-
* @param onErr
|
|
241
|
-
* @param initialCache
|
|
242
|
-
* @returns
|
|
304
|
+
* Subscribe to a `QueryRef`
|
|
305
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
306
|
+
* @param observer observer object to use for subscribing.
|
|
307
|
+
* @returns `SubscriptionOptions`
|
|
243
308
|
*/
|
|
244
309
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
245
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Subscribe to a `QueryRef`
|
|
313
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
314
|
+
* @param onNext Callback to call when result comes back.
|
|
315
|
+
* @param onError Callback to call when error gets thrown.
|
|
316
|
+
* @param onComplete Called when subscription completes.
|
|
317
|
+
* @returns `SubscriptionOptions`
|
|
318
|
+
*/
|
|
246
319
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
247
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Representation of full observer options in `subscribe`
|
|
323
|
+
*/
|
|
248
324
|
export declare interface SubscriptionOptions<Data, Variables> {
|
|
249
325
|
onNext?: OnResultSubscription<Data, Variables>;
|
|
250
326
|
onErr?: OnErrorSubscription;
|
|
251
327
|
onComplete?: OnCompleteSubscription;
|
|
252
328
|
}
|
|
253
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Delete DataConnect instance
|
|
332
|
+
* @param dataConnect DataConnect instance
|
|
333
|
+
* @returns
|
|
334
|
+
*/
|
|
254
335
|
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
255
336
|
|
|
256
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Converts serialized ref to query ref
|
|
339
|
+
* @param serializedRef ref to convert to `QueryRef`
|
|
340
|
+
* @returns `QueryRef`
|
|
341
|
+
*/
|
|
342
|
+
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
|
|
257
343
|
|
|
258
344
|
declare interface TrackedQuery<Data, Variables> {
|
|
259
345
|
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
@@ -262,12 +348,19 @@ declare interface TrackedQuery<Data, Variables> {
|
|
|
262
348
|
lastError: DataConnectError | null;
|
|
263
349
|
}
|
|
264
350
|
|
|
265
|
-
|
|
351
|
+
/* Excluded from this release type: TransportClass */
|
|
266
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Options to connect to emulator
|
|
355
|
+
*/
|
|
267
356
|
export declare interface TransportOptions {
|
|
268
357
|
host: string;
|
|
269
358
|
sslEnabled?: boolean;
|
|
270
359
|
port?: number;
|
|
271
360
|
}
|
|
272
361
|
|
|
362
|
+
/* Excluded from this release type: validateArgs */
|
|
363
|
+
|
|
364
|
+
/* Excluded from this release type: validateDCOptions */
|
|
365
|
+
|
|
273
366
|
export { }
|