@firebase/data-connect 0.0.2-dataconnect-preview.877f8b7d0 → 0.0.3-dataconnect-preview.d986d4bf2
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 +204 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +203 -30
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +204 -25
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +205 -24
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +159 -13
- package/dist/node-esm/index.node.esm.js +203 -30
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +42 -0
- 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/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 +1 -1
- package/dist/node-esm/src/network/transport/rest.d.ts +20 -9
- package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
- package/dist/private.d.ts +141 -19
- package/dist/public.d.ts +130 -15
- package/dist/src/api/DataConnect.d.ts +42 -0
- 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/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 +1 -1
- package/dist/src/network/transport/rest.d.ts +20 -9
- package/dist/src/util/validateArgs.d.ts +33 -0
- package/package.json +10 -6
package/dist/internal.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { FirebaseApp } from '@firebase/app';
|
|
|
8
8
|
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
9
9
|
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
10
10
|
import { FirebaseError } from '@firebase/util';
|
|
11
|
-
import { FirebaseOptions } from '@firebase/app';
|
|
11
|
+
import { FirebaseOptions } from '@firebase/app-types';
|
|
12
12
|
import { LogLevelString } from '@firebase/logger';
|
|
13
13
|
import { Provider } from '@firebase/component';
|
|
14
14
|
|
|
@@ -25,14 +25,27 @@ export declare interface CancellableOperation<T> extends PromiseLike<{
|
|
|
25
25
|
cancel: () => void;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Connect to the DataConnect Emulator
|
|
30
|
+
* @param dc Data Connect instance
|
|
31
|
+
* @param host host of emulator server
|
|
32
|
+
* @param port port of emulator server
|
|
33
|
+
* @param sslEnabled use https
|
|
34
|
+
*/
|
|
28
35
|
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
29
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Connector Config for calling Data Connect backend.
|
|
39
|
+
*/
|
|
30
40
|
export declare interface ConnectorConfig {
|
|
31
41
|
location: string;
|
|
32
42
|
connector: string;
|
|
33
43
|
service: string;
|
|
34
44
|
}
|
|
35
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Class representing Firebase Data Connect
|
|
48
|
+
*/
|
|
36
49
|
export declare class DataConnect {
|
|
37
50
|
readonly app: FirebaseApp;
|
|
38
51
|
private readonly dataConnectOptions;
|
|
@@ -45,7 +58,9 @@ export declare class DataConnect {
|
|
|
45
58
|
private _transportClass;
|
|
46
59
|
private _transportOptions?;
|
|
47
60
|
private _authTokenProvider?;
|
|
61
|
+
_isUsingGeneratedSdk: boolean;
|
|
48
62
|
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
63
|
+
_useGeneratedSdk(): void;
|
|
49
64
|
_delete(): Promise<void>;
|
|
50
65
|
getSettings(): ConnectorConfig;
|
|
51
66
|
setInitialized(): void;
|
|
@@ -76,8 +91,11 @@ declare class DataConnectError extends FirebaseError {
|
|
|
76
91
|
message: string);
|
|
77
92
|
}
|
|
78
93
|
|
|
79
|
-
declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
|
|
94
|
+
declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
80
95
|
|
|
96
|
+
/**
|
|
97
|
+
* DataConnectOptions including project id
|
|
98
|
+
*/
|
|
81
99
|
export declare interface DataConnectOptions extends ConnectorConfig {
|
|
82
100
|
projectId: string;
|
|
83
101
|
}
|
|
@@ -86,6 +104,9 @@ export declare interface DataConnectResult<Data, Variables> extends OpResult<Dat
|
|
|
86
104
|
ref: OperationRef<Data, Variables>;
|
|
87
105
|
}
|
|
88
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Representation of user provided subscription options.
|
|
109
|
+
*/
|
|
89
110
|
export declare interface DataConnectSubscription<Data, Variables> {
|
|
90
111
|
userCallback: OnResultSubscription<Data, Variables>;
|
|
91
112
|
errCallback?: (e?: DataConnectError) => void;
|
|
@@ -107,8 +128,18 @@ export declare interface DataConnectTransport {
|
|
|
107
128
|
|
|
108
129
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
109
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Execute Mutation
|
|
133
|
+
* @param mutationRef mutation to execute
|
|
134
|
+
* @returns `MutationRef`
|
|
135
|
+
*/
|
|
110
136
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
111
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Execute Query
|
|
140
|
+
* @param queryRef query to execute.
|
|
141
|
+
* @returns `QueryPromise`
|
|
142
|
+
*/
|
|
112
143
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
113
144
|
|
|
114
145
|
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
@@ -124,12 +155,24 @@ export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
|
124
155
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
125
156
|
}
|
|
126
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Initialize DataConnect instance
|
|
160
|
+
* @param options ConnectorConfig
|
|
161
|
+
*/
|
|
127
162
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
128
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Initialize DataConnect instance
|
|
166
|
+
* @param app FirebaseApp to initialize to.
|
|
167
|
+
* @param options ConnectorConfig
|
|
168
|
+
*/
|
|
129
169
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
130
170
|
|
|
131
171
|
export declare const MUTATION_STR = "mutation";
|
|
132
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
133
176
|
export declare class MutationManager {
|
|
134
177
|
private _transport;
|
|
135
178
|
private _inflight;
|
|
@@ -137,6 +180,9 @@ export declare class MutationManager {
|
|
|
137
180
|
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
138
181
|
}
|
|
139
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Mutation return value from `executeMutation`
|
|
185
|
+
*/
|
|
140
186
|
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
141
187
|
}
|
|
142
188
|
|
|
@@ -144,21 +190,44 @@ export declare interface MutationRef<Data, Variables> extends OperationRef<Data,
|
|
|
144
190
|
refType: typeof MUTATION_STR;
|
|
145
191
|
}
|
|
146
192
|
|
|
147
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Creates a `MutationRef`
|
|
195
|
+
* @param dcInstance Data Connect instance
|
|
196
|
+
* @param mutationName name of mutation
|
|
197
|
+
*/
|
|
198
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
148
199
|
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
* @param dcInstance Data Connect instance
|
|
203
|
+
* @param mutationName name of mutation
|
|
204
|
+
* @param variables variables to send with mutation
|
|
205
|
+
*/
|
|
149
206
|
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
150
207
|
|
|
151
208
|
export declare interface MutationResponse<T> extends CancellableOperation<T> {
|
|
152
209
|
}
|
|
153
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Mutation Result from `executeMutation`
|
|
213
|
+
*/
|
|
154
214
|
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
155
215
|
ref: MutationRef<Data, Variables>;
|
|
156
216
|
}
|
|
157
217
|
|
|
218
|
+
/**
|
|
219
|
+
* `OnCompleteSubscription`
|
|
220
|
+
*/
|
|
158
221
|
export declare type OnCompleteSubscription = () => void;
|
|
159
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Signature for `OnErrorSubscription` for `subscribe`
|
|
225
|
+
*/
|
|
160
226
|
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
161
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Signature for `OnResultSubscription` for `subscribe`
|
|
230
|
+
*/
|
|
162
231
|
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
163
232
|
|
|
164
233
|
export declare interface OperationRef<_Data, Variables> {
|
|
@@ -174,6 +243,11 @@ export declare interface OpResult<Data> {
|
|
|
174
243
|
fetchTime: string;
|
|
175
244
|
}
|
|
176
245
|
|
|
246
|
+
declare interface ParsedArgs<Variables> {
|
|
247
|
+
dc: DataConnect;
|
|
248
|
+
vars: Variables;
|
|
249
|
+
}
|
|
250
|
+
|
|
177
251
|
/**
|
|
178
252
|
*
|
|
179
253
|
* @param fullHost
|
|
@@ -188,35 +262,63 @@ declare class QueryManager {
|
|
|
188
262
|
private transport;
|
|
189
263
|
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
190
264
|
constructor(transport: DataConnectTransport);
|
|
191
|
-
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<
|
|
265
|
+
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<Data, Variables>;
|
|
192
266
|
addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
|
|
193
267
|
executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
194
268
|
enableEmulator(host: string, port: number): void;
|
|
195
269
|
}
|
|
196
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Promise returned from `executeQuery`
|
|
273
|
+
*/
|
|
197
274
|
export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
198
275
|
}
|
|
199
276
|
|
|
277
|
+
/**
|
|
278
|
+
* QueryRef object
|
|
279
|
+
*/
|
|
200
280
|
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
201
281
|
refType: typeof QUERY_STR;
|
|
202
282
|
}
|
|
203
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Execute Query
|
|
286
|
+
* @param dcInstance Data Connect instance to use.
|
|
287
|
+
* @param queryName Query to execute
|
|
288
|
+
* @returns `QueryRef`
|
|
289
|
+
*/
|
|
204
290
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
205
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Execute Query
|
|
294
|
+
* @param dcInstance Data Connect instance to use.
|
|
295
|
+
* @param queryName Query to execute
|
|
296
|
+
* @param variables Variables to execute with
|
|
297
|
+
* @returns `QueryRef`
|
|
298
|
+
*/
|
|
206
299
|
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
207
300
|
|
|
208
301
|
export declare interface QueryResponse<T> extends CancellableOperation<T> {
|
|
209
302
|
}
|
|
210
303
|
|
|
304
|
+
/**
|
|
305
|
+
* Result of `executeQuery`
|
|
306
|
+
*/
|
|
211
307
|
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
212
308
|
ref: QueryRef<Data, Variables>;
|
|
213
309
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
214
310
|
}
|
|
215
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Signature for unsubscribe from `subscribe`
|
|
314
|
+
*/
|
|
216
315
|
export declare type QueryUnsubscribe = () => void;
|
|
217
316
|
|
|
218
317
|
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
219
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
|
|
321
|
+
*/
|
|
220
322
|
export declare interface RefInfo<Variables> {
|
|
221
323
|
name: string;
|
|
222
324
|
variables: Variables;
|
|
@@ -228,6 +330,9 @@ export declare interface Sender<T> {
|
|
|
228
330
|
send: () => Promise<T>;
|
|
229
331
|
}
|
|
230
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
335
|
+
*/
|
|
231
336
|
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
232
337
|
refInfo: RefInfo<Variables>;
|
|
233
338
|
}
|
|
@@ -239,27 +344,45 @@ export declare const SOURCE_CACHE = "CACHE";
|
|
|
239
344
|
export declare const SOURCE_SERVER = "SERVER";
|
|
240
345
|
|
|
241
346
|
/**
|
|
242
|
-
*
|
|
243
|
-
* @
|
|
244
|
-
* @param
|
|
245
|
-
* @
|
|
246
|
-
* @param onErr
|
|
247
|
-
* @param initialCache
|
|
248
|
-
* @returns
|
|
347
|
+
* Subscribe to a `QueryRef`
|
|
348
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
349
|
+
* @param observer observer object to use for subscribing.
|
|
350
|
+
* @returns `SubscriptionOptions`
|
|
249
351
|
*/
|
|
250
352
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
251
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Subscribe to a `QueryRef`
|
|
356
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
357
|
+
* @param onNext Callback to call when result comes back.
|
|
358
|
+
* @param onError Callback to call when error gets thrown.
|
|
359
|
+
* @param onComplete Called when subscription completes.
|
|
360
|
+
* @returns `SubscriptionOptions`
|
|
361
|
+
*/
|
|
252
362
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
253
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Representation of full observer options in `subscribe`
|
|
366
|
+
*/
|
|
254
367
|
export declare interface SubscriptionOptions<Data, Variables> {
|
|
255
368
|
onNext?: OnResultSubscription<Data, Variables>;
|
|
256
369
|
onErr?: OnErrorSubscription;
|
|
257
370
|
onComplete?: OnCompleteSubscription;
|
|
258
371
|
}
|
|
259
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Delete DataConnect instance
|
|
375
|
+
* @param dataConnect DataConnect instance
|
|
376
|
+
* @returns
|
|
377
|
+
*/
|
|
260
378
|
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
261
379
|
|
|
262
|
-
|
|
380
|
+
/**
|
|
381
|
+
* Converts serialized ref to query ref
|
|
382
|
+
* @param serializedRef ref to convert to `QueryRef`
|
|
383
|
+
* @returns `QueryRef`
|
|
384
|
+
*/
|
|
385
|
+
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
|
|
263
386
|
|
|
264
387
|
declare interface TrackedQuery<Data, Variables> {
|
|
265
388
|
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
@@ -268,12 +391,35 @@ declare interface TrackedQuery<Data, Variables> {
|
|
|
268
391
|
lastError: DataConnectError | null;
|
|
269
392
|
}
|
|
270
393
|
|
|
271
|
-
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
|
|
394
|
+
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
|
|
272
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Options to connect to emulator
|
|
398
|
+
*/
|
|
273
399
|
export declare interface TransportOptions {
|
|
274
400
|
host: string;
|
|
275
401
|
sslEnabled?: boolean;
|
|
276
402
|
port?: number;
|
|
277
403
|
}
|
|
278
404
|
|
|
405
|
+
/**
|
|
406
|
+
* The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
|
|
407
|
+
* and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
|
|
408
|
+
* @param connectorConfig
|
|
409
|
+
* @param dcOrVars
|
|
410
|
+
* @param vars
|
|
411
|
+
* @param validateVars
|
|
412
|
+
* @returns {DataConnect} and {Variables} instance
|
|
413
|
+
* @internal
|
|
414
|
+
*/
|
|
415
|
+
export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
*
|
|
419
|
+
* @param dcOptions
|
|
420
|
+
* @returns {void}
|
|
421
|
+
* @internal
|
|
422
|
+
*/
|
|
423
|
+
export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
|
|
424
|
+
|
|
279
425
|
export { }
|