@firebase/data-connect 0.0.1-dataconnect-preview.f2ddc3d7b
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 +965 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm2017.js +942 -0
- package/dist/index.esm2017.js.map +1 -0
- package/dist/index.esm5.js +966 -0
- package/dist/index.esm5.js.map +1 -0
- package/dist/index.node.cjs.js +984 -0
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/internal.d.ts +297 -0
- package/dist/node-esm/index.node.esm.js +937 -0
- package/dist/node-esm/index.node.esm.js.map +1 -0
- package/dist/node-esm/package.json +1 -0
- package/dist/node-esm/src/api/DataConnect.d.ts +70 -0
- package/dist/node-esm/src/api/Mutation.d.ts +36 -0
- package/dist/node-esm/src/api/Reference.d.ts +45 -0
- package/dist/node-esm/src/api/index.d.ts +22 -0
- package/dist/node-esm/src/api/query.d.ts +46 -0
- package/dist/node-esm/src/api.browser.d.ts +29 -0
- package/dist/node-esm/src/api.node.d.ts +17 -0
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +44 -0
- package/dist/node-esm/src/core/QueryManager.d.ts +36 -0
- package/dist/node-esm/src/core/error.d.ts +50 -0
- package/dist/node-esm/src/core/version.d.ts +23 -0
- package/dist/node-esm/src/index.d.ts +29 -0
- package/dist/node-esm/src/index.node.d.ts +18 -0
- package/dist/node-esm/src/logger.d.ts +20 -0
- package/dist/node-esm/src/network/fetch.d.ts +21 -0
- package/dist/node-esm/src/network/index.d.ts +17 -0
- package/dist/node-esm/src/network/transport/index.d.ts +45 -0
- package/dist/node-esm/src/network/transport/rest.d.ts +56 -0
- package/dist/node-esm/src/register.d.ts +1 -0
- package/dist/node-esm/src/util/encoder.d.ts +19 -0
- package/dist/node-esm/src/util/map.d.ts +17 -0
- package/dist/node-esm/src/util/url.d.ts +19 -0
- package/dist/node-esm/test/emulatorSeeder.d.ts +22 -0
- package/dist/node-esm/test/queries.test.d.ts +17 -0
- package/dist/node-esm/test/util.d.ts +26 -0
- package/dist/private.d.ts +291 -0
- package/dist/public.d.ts +187 -0
- package/dist/src/api/DataConnect.d.ts +70 -0
- package/dist/src/api/Mutation.d.ts +36 -0
- package/dist/src/api/Reference.d.ts +45 -0
- package/dist/src/api/index.d.ts +22 -0
- package/dist/src/api/query.d.ts +46 -0
- package/dist/src/api.browser.d.ts +29 -0
- package/dist/src/api.node.d.ts +17 -0
- package/dist/src/core/FirebaseAuthProvider.d.ts +44 -0
- package/dist/src/core/QueryManager.d.ts +36 -0
- package/dist/src/core/error.d.ts +50 -0
- package/dist/src/core/version.d.ts +23 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.node.d.ts +18 -0
- package/dist/src/logger.d.ts +20 -0
- package/dist/src/network/fetch.d.ts +21 -0
- package/dist/src/network/index.d.ts +17 -0
- package/dist/src/network/transport/index.d.ts +45 -0
- package/dist/src/network/transport/rest.d.ts +56 -0
- package/dist/src/register.d.ts +1 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/util/encoder.d.ts +19 -0
- package/dist/src/util/map.d.ts +17 -0
- package/dist/src/util/url.d.ts +19 -0
- package/dist/test/emulatorSeeder.d.ts +22 -0
- package/dist/test/queries.test.d.ts +17 -0
- package/dist/test/util.d.ts +26 -0
- package/package.json +76 -0
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Data Connect
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { FirebaseApp } from '@firebase/app';
|
|
7
|
+
import { FirebaseOptions } from '@firebase/app';
|
|
8
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
9
|
+
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
10
|
+
import { Provider } from '@firebase/component';
|
|
11
|
+
import { LogLevelString } from '@firebase/logger';
|
|
12
|
+
import { FirebaseError } from '@firebase/util';
|
|
13
|
+
|
|
14
|
+
export declare type AuthTokenListener = (token: string | null) => void;
|
|
15
|
+
export declare interface AuthTokenProvider {
|
|
16
|
+
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
17
|
+
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
18
|
+
}
|
|
19
|
+
export declare interface CancellableOperation<T> extends PromiseLike<{
|
|
20
|
+
data: T;
|
|
21
|
+
}> {
|
|
22
|
+
cancel: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
25
|
+
export declare interface ConnectorConfig {
|
|
26
|
+
location: string;
|
|
27
|
+
connector: string;
|
|
28
|
+
service: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class DataConnect {
|
|
31
|
+
readonly app: FirebaseApp;
|
|
32
|
+
private readonly dataConnectOptions;
|
|
33
|
+
private readonly authProvider;
|
|
34
|
+
isEmulator: boolean;
|
|
35
|
+
initialized: boolean;
|
|
36
|
+
private transportClass;
|
|
37
|
+
private transportOptions?;
|
|
38
|
+
private authTokenProvider?;
|
|
39
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, authProvider: Provider<FirebaseAuthInternalName>);
|
|
40
|
+
getSettings(): ConnectorConfig;
|
|
41
|
+
setInitialized(): void;
|
|
42
|
+
enableEmulator(transportOptions: TransportOptions): void;
|
|
43
|
+
}
|
|
44
|
+
export declare interface DataConnectOptions extends ConnectorConfig {
|
|
45
|
+
projectId: string;
|
|
46
|
+
}
|
|
47
|
+
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
48
|
+
ref: OperationRef<Data, Variables>;
|
|
49
|
+
}
|
|
50
|
+
export declare interface DataConnectSubscription<Data, Variables> {
|
|
51
|
+
userCallback: OnResultSubscription<Data, Variables>;
|
|
52
|
+
errCallback?: (e?: FirebaseError) => void;
|
|
53
|
+
unsubscribe: () => void;
|
|
54
|
+
}
|
|
55
|
+
export declare interface DataConnectTransport {
|
|
56
|
+
invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
|
|
57
|
+
data: T;
|
|
58
|
+
errors: Error[];
|
|
59
|
+
}>;
|
|
60
|
+
invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
|
|
61
|
+
data: T;
|
|
62
|
+
errors: Error[];
|
|
63
|
+
}>;
|
|
64
|
+
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
|
|
65
|
+
onTokenChanged: (token: string | null) => void;
|
|
66
|
+
}
|
|
67
|
+
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
68
|
+
export declare class EmulatorTokenProvider implements AuthTokenProvider {
|
|
69
|
+
private accessToken;
|
|
70
|
+
/** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */
|
|
71
|
+
static OWNER: string;
|
|
72
|
+
constructor(accessToken: string);
|
|
73
|
+
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
|
|
74
|
+
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
75
|
+
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
76
|
+
notifyForInvalidToken(): void;
|
|
77
|
+
}
|
|
78
|
+
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
79
|
+
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
80
|
+
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
81
|
+
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
82
|
+
private appName;
|
|
83
|
+
private options;
|
|
84
|
+
private authProvider_;
|
|
85
|
+
private auth_;
|
|
86
|
+
constructor(appName: string, options: FirebaseOptions, authProvider_: Provider<FirebaseAuthInternalName>);
|
|
87
|
+
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
88
|
+
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
89
|
+
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
90
|
+
}
|
|
91
|
+
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
92
|
+
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
93
|
+
export declare class MutationManager {
|
|
94
|
+
private transport;
|
|
95
|
+
constructor(transport: DataConnectTransport);
|
|
96
|
+
executeMutation<Response, Variables>(mutationRef: MutationRef<Response, Variables>): MutationPromise<Response, Variables>;
|
|
97
|
+
}
|
|
98
|
+
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
99
|
+
}
|
|
100
|
+
export declare interface MutationRef<Response, Variables> extends OperationRef<Response, Variables> {
|
|
101
|
+
refType: typeof MutationStr;
|
|
102
|
+
}
|
|
103
|
+
export declare function mutationRef<Response>(dcInstance: DataConnect, queryName: string): MutationRef<Response, undefined>;
|
|
104
|
+
export declare function mutationRef<Response, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): MutationRef<Response, Variables>;
|
|
105
|
+
export declare interface MutationResponse<T> extends CancellableOperation<T> {
|
|
106
|
+
}
|
|
107
|
+
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
108
|
+
ref: MutationRef<Data, Variables>;
|
|
109
|
+
}
|
|
110
|
+
export declare const MutationStr = "mutation";
|
|
111
|
+
export declare type OnCompleteSubscription = () => void;
|
|
112
|
+
export declare type OnErrorSubscription = (err?: FirebaseError) => void;
|
|
113
|
+
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
114
|
+
export declare interface OperationRef<_Data, Variables> {
|
|
115
|
+
name: string;
|
|
116
|
+
variables: Variables;
|
|
117
|
+
refType: ReferenceType;
|
|
118
|
+
dataConnect: DataConnect;
|
|
119
|
+
}
|
|
120
|
+
export declare interface OpResult<Data> {
|
|
121
|
+
data: Data;
|
|
122
|
+
source: DataSource;
|
|
123
|
+
fetchTime: string;
|
|
124
|
+
}
|
|
125
|
+
/* Excluded from this release type: parseOptions */
|
|
126
|
+
export declare interface ProjectOptions {
|
|
127
|
+
location: string;
|
|
128
|
+
connector: string;
|
|
129
|
+
service: string;
|
|
130
|
+
projectId: string;
|
|
131
|
+
}
|
|
132
|
+
export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
133
|
+
}
|
|
134
|
+
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
135
|
+
refType: typeof QueryStr;
|
|
136
|
+
}
|
|
137
|
+
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
138
|
+
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
139
|
+
export declare interface QueryResponse<T> extends CancellableOperation<T> {
|
|
140
|
+
}
|
|
141
|
+
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
142
|
+
ref: QueryRef<Data, Variables>;
|
|
143
|
+
toJSON: () => SerializedRef<Data, Variables>;
|
|
144
|
+
}
|
|
145
|
+
export declare const QueryStr = "query";
|
|
146
|
+
export declare type QueryUnsubscribe = () => void;
|
|
147
|
+
export declare type ReferenceType = typeof QueryStr | typeof MutationStr;
|
|
148
|
+
export declare interface RefInfo<Variables> {
|
|
149
|
+
name: string;
|
|
150
|
+
variables: Variables;
|
|
151
|
+
connectorConfig: DataConnectOptions;
|
|
152
|
+
}
|
|
153
|
+
export declare interface Sender<T> {
|
|
154
|
+
abort: () => void;
|
|
155
|
+
send: () => Promise<T>;
|
|
156
|
+
}
|
|
157
|
+
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
158
|
+
refInfo: RefInfo<Variables>;
|
|
159
|
+
}
|
|
160
|
+
export declare function setLogLevel(logLevel: LogLevelString): void;
|
|
161
|
+
export declare const SOURCE_CACHE = "CACHE";
|
|
162
|
+
export declare const SOURCE_SERVER = "SERVER";
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
* @param queryRef
|
|
167
|
+
* @param onResult
|
|
168
|
+
* @param onErr
|
|
169
|
+
* @param initialCache
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
173
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
174
|
+
export declare interface SubscriptionOptions<Data, Variables> {
|
|
175
|
+
onNext?: OnResultSubscription<Data, Variables>;
|
|
176
|
+
onErr?: OnErrorSubscription;
|
|
177
|
+
onComplete?: OnCompleteSubscription;
|
|
178
|
+
}
|
|
179
|
+
export declare function terminate(dataConnect: DataConnect): void;
|
|
180
|
+
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
181
|
+
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
|
|
182
|
+
export declare interface TransportOptions {
|
|
183
|
+
host: string;
|
|
184
|
+
sslEnabled?: boolean;
|
|
185
|
+
port?: number;
|
|
186
|
+
}
|
|
187
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
19
|
+
import { Provider } from '@firebase/component';
|
|
20
|
+
import { QueryManager } from '../core/QueryManager';
|
|
21
|
+
import { MutationManager } from './Mutation';
|
|
22
|
+
export interface ProjectOptions {
|
|
23
|
+
location: string;
|
|
24
|
+
connector: string;
|
|
25
|
+
service: string;
|
|
26
|
+
projectId: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ConnectorConfig {
|
|
29
|
+
location: string;
|
|
30
|
+
connector: string;
|
|
31
|
+
service: string;
|
|
32
|
+
}
|
|
33
|
+
export interface TransportOptions {
|
|
34
|
+
host: string;
|
|
35
|
+
sslEnabled?: boolean;
|
|
36
|
+
port?: number;
|
|
37
|
+
}
|
|
38
|
+
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param fullHost
|
|
42
|
+
* @returns TransportOptions
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseOptions(fullHost: string): TransportOptions;
|
|
46
|
+
export interface DataConnectOptions extends ConnectorConfig {
|
|
47
|
+
projectId: string;
|
|
48
|
+
}
|
|
49
|
+
export declare class DataConnect {
|
|
50
|
+
readonly app: FirebaseApp;
|
|
51
|
+
private readonly dataConnectOptions;
|
|
52
|
+
private readonly authProvider;
|
|
53
|
+
_queryManager: QueryManager;
|
|
54
|
+
_mutationManager: MutationManager;
|
|
55
|
+
isEmulator: boolean;
|
|
56
|
+
initialized: boolean;
|
|
57
|
+
private _transport;
|
|
58
|
+
private transportClass;
|
|
59
|
+
private transportOptions?;
|
|
60
|
+
private authTokenProvider?;
|
|
61
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, authProvider: Provider<FirebaseAuthInternalName>);
|
|
62
|
+
_delete(): Promise<void>;
|
|
63
|
+
getSettings(): ConnectorConfig;
|
|
64
|
+
setInitialized(): void;
|
|
65
|
+
enableEmulator(transportOptions: TransportOptions): void;
|
|
66
|
+
}
|
|
67
|
+
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
68
|
+
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
69
|
+
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
70
|
+
export declare function terminate(dataConnect: DataConnect): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { DataConnectTransport } from '../network/transport';
|
|
18
|
+
import { DataConnect } from './DataConnect';
|
|
19
|
+
import { DataConnectResult, MutationStr, OperationRef } from './Reference';
|
|
20
|
+
export interface MutationRef<Response, Variables> extends OperationRef<Response, Variables> {
|
|
21
|
+
refType: typeof MutationStr;
|
|
22
|
+
}
|
|
23
|
+
export declare function mutationRef<Response>(dcInstance: DataConnect, queryName: string): MutationRef<Response, undefined>;
|
|
24
|
+
export declare function mutationRef<Response, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): MutationRef<Response, Variables>;
|
|
25
|
+
export declare class MutationManager {
|
|
26
|
+
private transport;
|
|
27
|
+
private _inflight;
|
|
28
|
+
constructor(transport: DataConnectTransport);
|
|
29
|
+
executeMutation<Response, Variables>(mutationRef: MutationRef<Response, Variables>): MutationPromise<Response, Variables>;
|
|
30
|
+
}
|
|
31
|
+
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
32
|
+
ref: MutationRef<Data, Variables>;
|
|
33
|
+
}
|
|
34
|
+
export interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
35
|
+
}
|
|
36
|
+
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { DataConnect, DataConnectOptions } from './DataConnect';
|
|
18
|
+
export declare const QueryStr = "query";
|
|
19
|
+
export declare const MutationStr = "mutation";
|
|
20
|
+
export declare type ReferenceType = typeof QueryStr | typeof MutationStr;
|
|
21
|
+
export declare const SOURCE_SERVER = "SERVER";
|
|
22
|
+
export declare const SOURCE_CACHE = "CACHE";
|
|
23
|
+
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
24
|
+
export interface OpResult<Data> {
|
|
25
|
+
data: Data;
|
|
26
|
+
source: DataSource;
|
|
27
|
+
fetchTime: string;
|
|
28
|
+
}
|
|
29
|
+
export interface OperationRef<_Data, Variables> {
|
|
30
|
+
name: string;
|
|
31
|
+
variables: Variables;
|
|
32
|
+
refType: ReferenceType;
|
|
33
|
+
dataConnect: DataConnect;
|
|
34
|
+
}
|
|
35
|
+
export interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
36
|
+
ref: OperationRef<Data, Variables>;
|
|
37
|
+
}
|
|
38
|
+
export interface RefInfo<Variables> {
|
|
39
|
+
name: string;
|
|
40
|
+
variables: Variables;
|
|
41
|
+
connectorConfig: DataConnectOptions;
|
|
42
|
+
}
|
|
43
|
+
export interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
44
|
+
refInfo: RefInfo<Variables>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
export * from '../network';
|
|
18
|
+
export * from './DataConnect';
|
|
19
|
+
export * from './Reference';
|
|
20
|
+
export * from './Mutation';
|
|
21
|
+
export * from './query';
|
|
22
|
+
export { setLogLevel } from '../logger';
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { DataConnectError } from '../core/error';
|
|
18
|
+
import { DataConnect } from './DataConnect';
|
|
19
|
+
import { OperationRef, QueryStr, DataConnectResult, SerializedRef } from './Reference';
|
|
20
|
+
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
21
|
+
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
22
|
+
export declare type QueryUnsubscribe = () => void;
|
|
23
|
+
export interface DataConnectSubscription<Data, Variables> {
|
|
24
|
+
userCallback: OnResultSubscription<Data, Variables>;
|
|
25
|
+
errCallback?: (e?: DataConnectError) => void;
|
|
26
|
+
unsubscribe: () => void;
|
|
27
|
+
}
|
|
28
|
+
export interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
29
|
+
refType: typeof QueryStr;
|
|
30
|
+
}
|
|
31
|
+
export interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
32
|
+
ref: QueryRef<Data, Variables>;
|
|
33
|
+
toJSON: () => SerializedRef<Data, Variables>;
|
|
34
|
+
}
|
|
35
|
+
export interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
36
|
+
}
|
|
37
|
+
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
38
|
+
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
39
|
+
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
40
|
+
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
41
|
+
export declare type OnCompleteSubscription = () => void;
|
|
42
|
+
export interface SubscriptionOptions<Data, Variables> {
|
|
43
|
+
onNext?: OnResultSubscription<Data, Variables>;
|
|
44
|
+
onErr?: OnErrorSubscription;
|
|
45
|
+
onComplete?: OnCompleteSubscription;
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { OnCompleteSubscription, OnErrorSubscription, OnResultSubscription, QueryRef, QueryUnsubscribe, SubscriptionOptions } from './api/query';
|
|
18
|
+
import { SerializedRef } from './api/Reference';
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
* @param queryRef
|
|
23
|
+
* @param onResult
|
|
24
|
+
* @param onErr
|
|
25
|
+
* @param initialCache
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
29
|
+
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,17 @@
|
|
|
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
|
+
export { subscribe } from './api.browser';
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { FirebaseOptions } from '@firebase/app';
|
|
18
|
+
import { FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
19
|
+
import { Provider } from '@firebase/component';
|
|
20
|
+
export interface AuthTokenProvider {
|
|
21
|
+
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
22
|
+
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
23
|
+
}
|
|
24
|
+
export declare type AuthTokenListener = (token: string | null) => void;
|
|
25
|
+
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
26
|
+
private appName;
|
|
27
|
+
private options;
|
|
28
|
+
private authProvider_;
|
|
29
|
+
private auth_;
|
|
30
|
+
constructor(appName: string, options: FirebaseOptions, authProvider_: Provider<FirebaseAuthInternalName>);
|
|
31
|
+
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
32
|
+
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
33
|
+
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
34
|
+
}
|
|
35
|
+
export declare class EmulatorTokenProvider implements AuthTokenProvider {
|
|
36
|
+
private accessToken;
|
|
37
|
+
/** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */
|
|
38
|
+
static OWNER: string;
|
|
39
|
+
constructor(accessToken: string);
|
|
40
|
+
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
|
|
41
|
+
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
42
|
+
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
43
|
+
notifyForInvalidToken(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { DataConnectSubscription, OnErrorSubscription, OnResultSubscription, QueryPromise, QueryRef } from '../api/query';
|
|
18
|
+
import { OperationRef, OpResult } from '../api/Reference';
|
|
19
|
+
import { DataConnectTransport } from '../network';
|
|
20
|
+
import { DataConnectError } from './error';
|
|
21
|
+
interface TrackedQuery<Response, Variables> {
|
|
22
|
+
ref: Omit<OperationRef<Response, Variables>, 'dataConnect'>;
|
|
23
|
+
subscriptions: Array<DataConnectSubscription<Response, Variables>>;
|
|
24
|
+
currentCache: OpResult<Response> | null;
|
|
25
|
+
lastError: DataConnectError | null;
|
|
26
|
+
}
|
|
27
|
+
export declare class QueryManager {
|
|
28
|
+
private transport;
|
|
29
|
+
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
30
|
+
constructor(transport: DataConnectTransport);
|
|
31
|
+
track<Response, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Response>): TrackedQuery<unknown, unknown> | undefined;
|
|
32
|
+
addSubscription<Response, Variables>(queryRef: OperationRef<Response, Variables>, onResultCallback: OnResultSubscription<Response, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Response>): () => void;
|
|
33
|
+
executeQuery<Response, Variables>(queryRef: QueryRef<Response, Variables>): QueryPromise<Response, Variables>;
|
|
34
|
+
enableEmulator(host: string, port: number): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { FirebaseError } from '@firebase/util';
|
|
18
|
+
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
|
|
19
|
+
export declare type Code = DataConnectErrorCode;
|
|
20
|
+
export declare const Code: {
|
|
21
|
+
OTHER: DataConnectErrorCode;
|
|
22
|
+
ALREADY_INITIALIZED: DataConnectErrorCode;
|
|
23
|
+
NOT_INITIALIZED: DataConnectErrorCode;
|
|
24
|
+
NOT_SUPPORTED: DataConnectErrorCode;
|
|
25
|
+
INVALID_ARGUMENT: DataConnectErrorCode;
|
|
26
|
+
PARTIAL_ERROR: DataConnectErrorCode;
|
|
27
|
+
};
|
|
28
|
+
/** An error returned by a DataConnect operation. */
|
|
29
|
+
export declare class DataConnectError extends FirebaseError {
|
|
30
|
+
/**
|
|
31
|
+
* The backend error code associated with this error.
|
|
32
|
+
*/
|
|
33
|
+
readonly code: DataConnectErrorCode;
|
|
34
|
+
/**
|
|
35
|
+
* A custom error description.
|
|
36
|
+
*/
|
|
37
|
+
readonly message: string;
|
|
38
|
+
/** The stack of the error. */
|
|
39
|
+
readonly stack?: string;
|
|
40
|
+
/** @hideconstructor */
|
|
41
|
+
constructor(
|
|
42
|
+
/**
|
|
43
|
+
* The backend error code associated with this error.
|
|
44
|
+
*/
|
|
45
|
+
code: DataConnectErrorCode,
|
|
46
|
+
/**
|
|
47
|
+
* A custom error description.
|
|
48
|
+
*/
|
|
49
|
+
message: string);
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
/** The semver (www.semver.org) version of the SDK. */
|
|
18
|
+
export declare let SDK_VERSION: string;
|
|
19
|
+
/**
|
|
20
|
+
* SDK_VERSION should be set before any database instance is created
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function setSDKVersion(version: string): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Data Connect
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @license
|
|
8
|
+
* Copyright 2024 Google LLC
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
import { DataConnect } from './api/DataConnect';
|
|
23
|
+
export * from './api';
|
|
24
|
+
export * from './api.browser';
|
|
25
|
+
declare module '@firebase/component' {
|
|
26
|
+
interface NameServiceMapping {
|
|
27
|
+
'data-connect': DataConnect;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export * from './api';
|
|
18
|
+
export * from './api.node';
|