@firebase/data-connect 0.0.1-dataconnect-preview.323fdc1b8 → 0.0.2-dataconnect-preview.877f8b7d0
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 +124 -162
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +123 -160
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +125 -163
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +74 -93
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +30 -48
- package/dist/node-esm/index.node.esm.js +75 -92
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +6 -12
- package/dist/node-esm/src/api/Mutation.d.ts +8 -8
- package/dist/node-esm/src/api/Reference.d.ts +3 -3
- package/dist/node-esm/src/api/query.d.ts +2 -2
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +5 -15
- package/dist/node-esm/src/core/QueryManager.d.ts +7 -7
- package/dist/node-esm/src/network/transport/rest.d.ts +13 -25
- package/dist/node-esm/src/util/url.d.ts +2 -2
- package/dist/private.d.ts +30 -48
- package/dist/public.d.ts +13 -38
- package/dist/src/api/DataConnect.d.ts +6 -12
- package/dist/src/api/Mutation.d.ts +8 -8
- package/dist/src/api/Reference.d.ts +3 -3
- package/dist/src/api/query.d.ts +2 -2
- package/dist/src/core/FirebaseAuthProvider.d.ts +5 -15
- package/dist/src/core/QueryManager.d.ts +7 -7
- package/dist/src/network/transport/rest.d.ts +13 -25
- package/dist/src/util/url.d.ts +2 -2
- package/package.json +7 -7
- package/dist/node-esm/test/emulatorSeeder.d.ts +0 -22
- package/dist/node-esm/test/queries.test.d.ts +0 -17
- package/dist/node-esm/test/util.d.ts +0 -26
- package/dist/test/emulatorSeeder.d.ts +0 -22
- package/dist/test/queries.test.d.ts +0 -17
- package/dist/test/util.d.ts +0 -26
package/dist/private.d.ts
CHANGED
|
@@ -36,16 +36,16 @@ export declare interface ConnectorConfig {
|
|
|
36
36
|
export declare class DataConnect {
|
|
37
37
|
readonly app: FirebaseApp;
|
|
38
38
|
private readonly dataConnectOptions;
|
|
39
|
-
private readonly
|
|
39
|
+
private readonly _authProvider;
|
|
40
40
|
_queryManager: QueryManager;
|
|
41
41
|
_mutationManager: MutationManager;
|
|
42
42
|
isEmulator: boolean;
|
|
43
43
|
initialized: boolean;
|
|
44
44
|
private _transport;
|
|
45
|
-
private
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions,
|
|
45
|
+
private _transportClass;
|
|
46
|
+
private _transportOptions?;
|
|
47
|
+
private _authTokenProvider?;
|
|
48
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
49
49
|
_delete(): Promise<void>;
|
|
50
50
|
getSettings(): ConnectorConfig;
|
|
51
51
|
setInitialized(): void;
|
|
@@ -107,17 +107,6 @@ export declare interface DataConnectTransport {
|
|
|
107
107
|
|
|
108
108
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
109
109
|
|
|
110
|
-
export declare class EmulatorTokenProvider implements AuthTokenProvider {
|
|
111
|
-
private accessToken;
|
|
112
|
-
/** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */
|
|
113
|
-
static OWNER: string;
|
|
114
|
-
constructor(accessToken: string);
|
|
115
|
-
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
|
|
116
|
-
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
117
|
-
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
118
|
-
notifyForInvalidToken(): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
110
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
122
111
|
|
|
123
112
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
@@ -125,11 +114,11 @@ export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, V
|
|
|
125
114
|
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
126
115
|
|
|
127
116
|
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
128
|
-
private
|
|
129
|
-
private
|
|
130
|
-
private
|
|
131
|
-
private
|
|
132
|
-
constructor(
|
|
117
|
+
private _appName;
|
|
118
|
+
private _options;
|
|
119
|
+
private _authProvider;
|
|
120
|
+
private _auth;
|
|
121
|
+
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
133
122
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
134
123
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
135
124
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
@@ -139,23 +128,25 @@ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
|
139
128
|
|
|
140
129
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
141
130
|
|
|
131
|
+
export declare const MUTATION_STR = "mutation";
|
|
132
|
+
|
|
142
133
|
export declare class MutationManager {
|
|
143
|
-
private
|
|
134
|
+
private _transport;
|
|
144
135
|
private _inflight;
|
|
145
|
-
constructor(
|
|
146
|
-
executeMutation<
|
|
136
|
+
constructor(_transport: DataConnectTransport);
|
|
137
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
147
138
|
}
|
|
148
139
|
|
|
149
140
|
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
150
141
|
}
|
|
151
142
|
|
|
152
|
-
export declare interface MutationRef<
|
|
153
|
-
refType: typeof
|
|
143
|
+
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
144
|
+
refType: typeof MUTATION_STR;
|
|
154
145
|
}
|
|
155
146
|
|
|
156
|
-
export declare function mutationRef<
|
|
147
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, queryName: string): MutationRef<Data, undefined>;
|
|
157
148
|
|
|
158
|
-
export declare function mutationRef<
|
|
149
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
159
150
|
|
|
160
151
|
export declare interface MutationResponse<T> extends CancellableOperation<T> {
|
|
161
152
|
}
|
|
@@ -164,8 +155,6 @@ export declare interface MutationResult<Data, Variables> extends DataConnectResu
|
|
|
164
155
|
ref: MutationRef<Data, Variables>;
|
|
165
156
|
}
|
|
166
157
|
|
|
167
|
-
export declare const MutationStr = "mutation";
|
|
168
|
-
|
|
169
158
|
export declare type OnCompleteSubscription = () => void;
|
|
170
159
|
|
|
171
160
|
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
@@ -187,20 +176,15 @@ export declare interface OpResult<Data> {
|
|
|
187
176
|
|
|
188
177
|
/* Excluded from this release type: parseOptions */
|
|
189
178
|
|
|
190
|
-
export declare
|
|
191
|
-
location: string;
|
|
192
|
-
connector: string;
|
|
193
|
-
service: string;
|
|
194
|
-
projectId: string;
|
|
195
|
-
}
|
|
179
|
+
export declare const QUERY_STR = "query";
|
|
196
180
|
|
|
197
181
|
declare class QueryManager {
|
|
198
182
|
private transport;
|
|
199
183
|
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
200
184
|
constructor(transport: DataConnectTransport);
|
|
201
|
-
track<
|
|
202
|
-
addSubscription<
|
|
203
|
-
executeQuery<
|
|
185
|
+
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<unknown, unknown>;
|
|
186
|
+
addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
|
|
187
|
+
executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
204
188
|
enableEmulator(host: string, port: number): void;
|
|
205
189
|
}
|
|
206
190
|
|
|
@@ -208,7 +192,7 @@ export declare interface QueryPromise<Data, Variables> extends PromiseLike<Query
|
|
|
208
192
|
}
|
|
209
193
|
|
|
210
194
|
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
211
|
-
refType: typeof
|
|
195
|
+
refType: typeof QUERY_STR;
|
|
212
196
|
}
|
|
213
197
|
|
|
214
198
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
@@ -223,11 +207,9 @@ export declare interface QueryResult<Data, Variables> extends DataConnectResult<
|
|
|
223
207
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
224
208
|
}
|
|
225
209
|
|
|
226
|
-
export declare const QueryStr = "query";
|
|
227
|
-
|
|
228
210
|
export declare type QueryUnsubscribe = () => void;
|
|
229
211
|
|
|
230
|
-
export declare type ReferenceType = typeof
|
|
212
|
+
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
231
213
|
|
|
232
214
|
export declare interface RefInfo<Variables> {
|
|
233
215
|
name: string;
|
|
@@ -269,14 +251,14 @@ export declare interface SubscriptionOptions<Data, Variables> {
|
|
|
269
251
|
onComplete?: OnCompleteSubscription;
|
|
270
252
|
}
|
|
271
253
|
|
|
272
|
-
export declare function terminate(dataConnect: DataConnect): void
|
|
254
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
273
255
|
|
|
274
256
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
275
257
|
|
|
276
|
-
declare interface TrackedQuery<
|
|
277
|
-
ref: Omit<OperationRef<
|
|
278
|
-
subscriptions: Array<DataConnectSubscription<
|
|
279
|
-
currentCache: OpResult<
|
|
258
|
+
declare interface TrackedQuery<Data, Variables> {
|
|
259
|
+
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
260
|
+
subscriptions: Array<DataConnectSubscription<Data, Variables>>;
|
|
261
|
+
currentCache: OpResult<Data> | null;
|
|
280
262
|
lastError: DataConnectError | null;
|
|
281
263
|
}
|
|
282
264
|
|
package/dist/public.d.ts
CHANGED
|
@@ -30,13 +30,9 @@ export declare interface ConnectorConfig {
|
|
|
30
30
|
export declare class DataConnect {
|
|
31
31
|
readonly app: FirebaseApp;
|
|
32
32
|
private readonly dataConnectOptions;
|
|
33
|
-
private readonly authProvider;
|
|
34
33
|
isEmulator: boolean;
|
|
35
34
|
initialized: boolean;
|
|
36
|
-
|
|
37
|
-
private transportOptions?;
|
|
38
|
-
private authTokenProvider?;
|
|
39
|
-
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, authProvider: Provider<FirebaseAuthInternalName>);
|
|
35
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
40
36
|
getSettings(): ConnectorConfig;
|
|
41
37
|
setInitialized(): void;
|
|
42
38
|
enableEmulator(transportOptions: TransportOptions): void;
|
|
@@ -65,49 +61,34 @@ export declare interface DataConnectTransport {
|
|
|
65
61
|
onTokenChanged: (token: string | null) => void;
|
|
66
62
|
}
|
|
67
63
|
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
64
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
79
65
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
80
66
|
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
81
67
|
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
82
|
-
|
|
83
|
-
private options;
|
|
84
|
-
private authProvider_;
|
|
85
|
-
private auth_;
|
|
86
|
-
constructor(appName: string, options: FirebaseOptions, authProvider_: Provider<FirebaseAuthInternalName>);
|
|
68
|
+
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
87
69
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
88
70
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
89
71
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
90
72
|
}
|
|
91
73
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
92
74
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
75
|
+
export declare const MUTATION_STR = "mutation";
|
|
93
76
|
export declare class MutationManager {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
executeMutation<Response, Variables>(mutationRef: MutationRef<Response, Variables>): MutationPromise<Response, Variables>;
|
|
77
|
+
constructor(_transport: DataConnectTransport);
|
|
78
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
97
79
|
}
|
|
98
80
|
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
99
81
|
}
|
|
100
|
-
export declare interface MutationRef<
|
|
101
|
-
refType: typeof
|
|
82
|
+
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
83
|
+
refType: typeof MUTATION_STR;
|
|
102
84
|
}
|
|
103
|
-
export declare function mutationRef<
|
|
104
|
-
export declare function mutationRef<
|
|
85
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, queryName: string): MutationRef<Data, undefined>;
|
|
86
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
105
87
|
export declare interface MutationResponse<T> extends CancellableOperation<T> {
|
|
106
88
|
}
|
|
107
89
|
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
108
90
|
ref: MutationRef<Data, Variables>;
|
|
109
91
|
}
|
|
110
|
-
export declare const MutationStr = "mutation";
|
|
111
92
|
export declare type OnCompleteSubscription = () => void;
|
|
112
93
|
export declare type OnErrorSubscription = (err?: FirebaseError) => void;
|
|
113
94
|
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
@@ -123,16 +104,11 @@ export declare interface OpResult<Data> {
|
|
|
123
104
|
fetchTime: string;
|
|
124
105
|
}
|
|
125
106
|
/* Excluded from this release type: parseOptions */
|
|
126
|
-
export declare
|
|
127
|
-
location: string;
|
|
128
|
-
connector: string;
|
|
129
|
-
service: string;
|
|
130
|
-
projectId: string;
|
|
131
|
-
}
|
|
107
|
+
export declare const QUERY_STR = "query";
|
|
132
108
|
export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
133
109
|
}
|
|
134
110
|
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
135
|
-
refType: typeof
|
|
111
|
+
refType: typeof QUERY_STR;
|
|
136
112
|
}
|
|
137
113
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
138
114
|
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
@@ -142,9 +118,8 @@ export declare interface QueryResult<Data, Variables> extends DataConnectResult<
|
|
|
142
118
|
ref: QueryRef<Data, Variables>;
|
|
143
119
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
144
120
|
}
|
|
145
|
-
export declare const QueryStr = "query";
|
|
146
121
|
export declare type QueryUnsubscribe = () => void;
|
|
147
|
-
export declare type ReferenceType = typeof
|
|
122
|
+
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
148
123
|
export declare interface RefInfo<Variables> {
|
|
149
124
|
name: string;
|
|
150
125
|
variables: Variables;
|
|
@@ -176,7 +151,7 @@ export declare interface SubscriptionOptions<Data, Variables> {
|
|
|
176
151
|
onErr?: OnErrorSubscription;
|
|
177
152
|
onComplete?: OnCompleteSubscription;
|
|
178
153
|
}
|
|
179
|
-
export declare function terminate(dataConnect: DataConnect): void
|
|
154
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
180
155
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
181
156
|
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
|
|
182
157
|
export declare interface TransportOptions {
|
|
@@ -19,12 +19,6 @@ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
|
19
19
|
import { Provider } from '@firebase/component';
|
|
20
20
|
import { QueryManager } from '../core/QueryManager';
|
|
21
21
|
import { MutationManager } from './Mutation';
|
|
22
|
-
export interface ProjectOptions {
|
|
23
|
-
location: string;
|
|
24
|
-
connector: string;
|
|
25
|
-
service: string;
|
|
26
|
-
projectId: string;
|
|
27
|
-
}
|
|
28
22
|
export interface ConnectorConfig {
|
|
29
23
|
location: string;
|
|
30
24
|
connector: string;
|
|
@@ -49,16 +43,16 @@ export interface DataConnectOptions extends ConnectorConfig {
|
|
|
49
43
|
export declare class DataConnect {
|
|
50
44
|
readonly app: FirebaseApp;
|
|
51
45
|
private readonly dataConnectOptions;
|
|
52
|
-
private readonly
|
|
46
|
+
private readonly _authProvider;
|
|
53
47
|
_queryManager: QueryManager;
|
|
54
48
|
_mutationManager: MutationManager;
|
|
55
49
|
isEmulator: boolean;
|
|
56
50
|
initialized: boolean;
|
|
57
51
|
private _transport;
|
|
58
|
-
private
|
|
59
|
-
private
|
|
60
|
-
private
|
|
61
|
-
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions,
|
|
52
|
+
private _transportClass;
|
|
53
|
+
private _transportOptions?;
|
|
54
|
+
private _authTokenProvider?;
|
|
55
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
62
56
|
_delete(): Promise<void>;
|
|
63
57
|
getSettings(): ConnectorConfig;
|
|
64
58
|
setInitialized(): void;
|
|
@@ -67,4 +61,4 @@ export declare class DataConnect {
|
|
|
67
61
|
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
68
62
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
69
63
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
70
|
-
export declare function terminate(dataConnect: DataConnect): void
|
|
64
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { DataConnectTransport } from '../network/transport';
|
|
18
18
|
import { DataConnect } from './DataConnect';
|
|
19
|
-
import { DataConnectResult,
|
|
20
|
-
export interface MutationRef<
|
|
21
|
-
refType: typeof
|
|
19
|
+
import { DataConnectResult, MUTATION_STR, OperationRef } from './Reference';
|
|
20
|
+
export interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
21
|
+
refType: typeof MUTATION_STR;
|
|
22
22
|
}
|
|
23
|
-
export declare function mutationRef<
|
|
24
|
-
export declare function mutationRef<
|
|
23
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, queryName: string): MutationRef<Data, undefined>;
|
|
24
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
25
25
|
export declare class MutationManager {
|
|
26
|
-
private
|
|
26
|
+
private _transport;
|
|
27
27
|
private _inflight;
|
|
28
|
-
constructor(
|
|
29
|
-
executeMutation<
|
|
28
|
+
constructor(_transport: DataConnectTransport);
|
|
29
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
30
30
|
}
|
|
31
31
|
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
32
32
|
ref: MutationRef<Data, Variables>;
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { DataConnect, DataConnectOptions } from './DataConnect';
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare type ReferenceType = typeof
|
|
18
|
+
export declare const QUERY_STR = "query";
|
|
19
|
+
export declare const MUTATION_STR = "mutation";
|
|
20
|
+
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
21
21
|
export declare const SOURCE_SERVER = "SERVER";
|
|
22
22
|
export declare const SOURCE_CACHE = "CACHE";
|
|
23
23
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
package/dist/src/api/query.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { DataConnectError } from '../core/error';
|
|
18
18
|
import { DataConnect } from './DataConnect';
|
|
19
|
-
import { OperationRef,
|
|
19
|
+
import { OperationRef, QUERY_STR, DataConnectResult, SerializedRef } from './Reference';
|
|
20
20
|
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
21
21
|
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
22
22
|
export declare type QueryUnsubscribe = () => void;
|
|
@@ -26,7 +26,7 @@ export interface DataConnectSubscription<Data, Variables> {
|
|
|
26
26
|
unsubscribe: () => void;
|
|
27
27
|
}
|
|
28
28
|
export interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
29
|
-
refType: typeof
|
|
29
|
+
refType: typeof QUERY_STR;
|
|
30
30
|
}
|
|
31
31
|
export interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
32
32
|
ref: QueryRef<Data, Variables>;
|
|
@@ -23,22 +23,12 @@ export interface AuthTokenProvider {
|
|
|
23
23
|
}
|
|
24
24
|
export declare type AuthTokenListener = (token: string | null) => void;
|
|
25
25
|
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
constructor(
|
|
26
|
+
private _appName;
|
|
27
|
+
private _options;
|
|
28
|
+
private _authProvider;
|
|
29
|
+
private _auth;
|
|
30
|
+
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
31
31
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
32
32
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
33
33
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
34
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
|
-
}
|
|
@@ -18,19 +18,19 @@ import { DataConnectSubscription, OnErrorSubscription, OnResultSubscription, Que
|
|
|
18
18
|
import { OperationRef, OpResult } from '../api/Reference';
|
|
19
19
|
import { DataConnectTransport } from '../network';
|
|
20
20
|
import { DataConnectError } from './error';
|
|
21
|
-
interface TrackedQuery<
|
|
22
|
-
ref: Omit<OperationRef<
|
|
23
|
-
subscriptions: Array<DataConnectSubscription<
|
|
24
|
-
currentCache: OpResult<
|
|
21
|
+
interface TrackedQuery<Data, Variables> {
|
|
22
|
+
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
23
|
+
subscriptions: Array<DataConnectSubscription<Data, Variables>>;
|
|
24
|
+
currentCache: OpResult<Data> | null;
|
|
25
25
|
lastError: DataConnectError | null;
|
|
26
26
|
}
|
|
27
27
|
export declare class QueryManager {
|
|
28
28
|
private transport;
|
|
29
29
|
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
30
30
|
constructor(transport: DataConnectTransport);
|
|
31
|
-
track<
|
|
32
|
-
addSubscription<
|
|
33
|
-
executeQuery<
|
|
31
|
+
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<unknown, unknown>;
|
|
32
|
+
addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
|
|
33
|
+
executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
34
34
|
enableEmulator(host: string, port: number): void;
|
|
35
35
|
}
|
|
36
36
|
export {};
|
|
@@ -14,43 +14,31 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { DataConnectTransport } from '.';
|
|
18
17
|
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
|
|
19
18
|
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
|
|
19
|
+
import { DataConnectTransport } from '.';
|
|
20
20
|
export declare class RESTTransport implements DataConnectTransport {
|
|
21
21
|
private apiKey?;
|
|
22
22
|
private authProvider?;
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
23
|
+
private _host;
|
|
24
|
+
private _port;
|
|
25
|
+
private _location;
|
|
26
|
+
private _connectorName;
|
|
27
|
+
private _secure;
|
|
28
|
+
private _project;
|
|
29
|
+
private _serviceName;
|
|
30
|
+
private _accessToken;
|
|
31
|
+
private _authInitialized;
|
|
32
32
|
constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined);
|
|
33
33
|
get endpointUrl(): string;
|
|
34
34
|
useEmulator(host: string, port?: number, isSecure?: boolean): void;
|
|
35
35
|
onTokenChanged(newToken: string | null): void;
|
|
36
|
-
getWithAuth(): Promise<string
|
|
36
|
+
getWithAuth(): Promise<string>;
|
|
37
37
|
invokeQuery: <T, U = unknown>(queryName: string, body: U) => {
|
|
38
|
-
then:
|
|
39
|
-
data: T;
|
|
40
|
-
errors: Error[];
|
|
41
|
-
}, TResult2 = never>(onfulfilled?: ((value: {
|
|
42
|
-
data: T;
|
|
43
|
-
errors: Error[];
|
|
44
|
-
}) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
|
|
38
|
+
then: any;
|
|
45
39
|
};
|
|
46
40
|
invokeMutation: <T, U = unknown>(mutationName: string, body: U) => {
|
|
47
|
-
then:
|
|
48
|
-
data: T;
|
|
49
|
-
errors: Error[];
|
|
50
|
-
}, TResult2 = never>(onfulfilled?: ((value: {
|
|
51
|
-
data: T;
|
|
52
|
-
errors: Error[];
|
|
53
|
-
}) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
|
|
41
|
+
then: any;
|
|
54
42
|
cancel: () => void;
|
|
55
43
|
};
|
|
56
44
|
}
|
package/dist/src/util/url.d.ts
CHANGED
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
18
|
-
export declare function urlBuilder(projectConfig:
|
|
17
|
+
import { DataConnectOptions, TransportOptions } from '../api/DataConnect';
|
|
18
|
+
export declare function urlBuilder(projectConfig: DataConnectOptions, transportOptions: TransportOptions): string;
|
|
19
19
|
export declare function addToken(url: string, apiKey?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/data-connect",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-dataconnect-preview.877f8b7d0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"main": "dist/index.node.cjs.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"prettier": "prettier --write '*.js' '*.ts' '@(src|test)/**/*.ts'",
|
|
34
34
|
"build:deps": "lerna run --scope @firebase/'{app,data-connect}' --include-dependencies build",
|
|
35
35
|
"dev": "rollup -c -w",
|
|
36
|
-
"test": "run-p --npm-path npm
|
|
36
|
+
"test": "run-p --npm-path npm test:emulator",
|
|
37
37
|
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
|
|
38
38
|
"test:all": "npm run test:node",
|
|
39
39
|
"test:browser": "karma start --single-run",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"license": "Apache-2.0",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firebase/auth-interop-types": "0.2.
|
|
50
|
-
"@firebase/component": "0.6.
|
|
51
|
-
"@firebase/logger": "0.4.
|
|
52
|
-
"@firebase/util": "1.9.
|
|
49
|
+
"@firebase/auth-interop-types": "0.2.3-dataconnect-preview.877f8b7d0",
|
|
50
|
+
"@firebase/component": "0.6.7-dataconnect-preview.877f8b7d0",
|
|
51
|
+
"@firebase/logger": "0.4.2-dataconnect-preview.877f8b7d0",
|
|
52
|
+
"@firebase/util": "1.9.6-dataconnect-preview.877f8b7d0",
|
|
53
53
|
"tslib": "^2.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@firebase/app": "0.10.
|
|
56
|
+
"@firebase/app": "0.10.3-dataconnect-preview.877f8b7d0",
|
|
57
57
|
"rollup": "2.79.1",
|
|
58
58
|
"rollup-plugin-typescript2": "0.31.2",
|
|
59
59
|
"typescript": "4.7.4"
|
|
@@ -1,22 +0,0 @@
|
|
|
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 { ReferenceType } from '../src';
|
|
18
|
-
export interface SeedInfo {
|
|
19
|
-
type: ReferenceType;
|
|
20
|
-
name: string;
|
|
21
|
-
}
|
|
22
|
-
export declare function setupQueries(schema: string, seedInfoArray: SeedInfo[], skipSchema?: boolean): Promise<import("node-fetch").Response>;
|
|
@@ -1,17 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,26 +0,0 @@
|
|
|
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 } from '../src';
|
|
18
|
-
export declare const USE_EMULATOR = true;
|
|
19
|
-
export declare const EMULATOR_PORT: string | undefined;
|
|
20
|
-
export declare const CONNECTOR_NAME = "c";
|
|
21
|
-
export declare const LOCATION_NAME = "l";
|
|
22
|
-
export declare const SERVICE_NAME = "l";
|
|
23
|
-
export declare const PROJECT_ID = "p";
|
|
24
|
-
export declare function getConnectionConfig(): ConnectorConfig;
|
|
25
|
-
export declare const app: import("@firebase/app").FirebaseApp;
|
|
26
|
-
export declare function initDatabase(): import("../src").DataConnect;
|
|
@@ -1,22 +0,0 @@
|
|
|
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 { ReferenceType } from '../src';
|
|
18
|
-
export interface SeedInfo {
|
|
19
|
-
type: ReferenceType;
|
|
20
|
-
name: string;
|
|
21
|
-
}
|
|
22
|
-
export declare function setupQueries(schema: string, seedInfoArray: SeedInfo[], skipSchema?: boolean): Promise<import("node-fetch").Response>;
|