@firebase/data-connect 0.0.1-dataconnect-preview.81ee5169c → 0.0.2-dataconnect-preview.388b61c7e
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 +181 -141
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +180 -140
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +183 -143
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +132 -72
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +156 -44
- package/dist/node-esm/index.node.esm.js +132 -72
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +39 -12
- package/dist/node-esm/src/api/Mutation.d.ts +33 -8
- package/dist/node-esm/src/api/Reference.d.ts +9 -3
- package/dist/node-esm/src/api/query.d.ts +52 -2
- package/dist/node-esm/src/api.browser.d.ts +12 -7
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +5 -5
- 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 +151 -47
- package/dist/public.d.ts +135 -37
- package/dist/src/api/DataConnect.d.ts +39 -12
- package/dist/src/api/Mutation.d.ts +33 -8
- package/dist/src/api/Reference.d.ts +9 -3
- package/dist/src/api/query.d.ts +52 -2
- package/dist/src/api.browser.d.ts +12 -7
- package/dist/src/core/FirebaseAuthProvider.d.ts +5 -5
- 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/public.d.ts
CHANGED
|
@@ -21,32 +21,47 @@ export declare interface CancellableOperation<T> extends PromiseLike<{
|
|
|
21
21
|
}> {
|
|
22
22
|
cancel: () => void;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Connect to the DataConnect Emulator
|
|
26
|
+
* @param dc Data Connect instance
|
|
27
|
+
* @param host host of emulator server
|
|
28
|
+
* @param port port of emulator server
|
|
29
|
+
* @param sslEnabled use https
|
|
30
|
+
*/
|
|
24
31
|
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
32
|
+
/**
|
|
33
|
+
* Connector Config for calling Data Connect backend.
|
|
34
|
+
*/
|
|
25
35
|
export declare interface ConnectorConfig {
|
|
26
36
|
location: string;
|
|
27
37
|
connector: string;
|
|
28
38
|
service: string;
|
|
29
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Class representing Firebase Data Connect
|
|
42
|
+
*/
|
|
30
43
|
export declare class DataConnect {
|
|
31
44
|
readonly app: FirebaseApp;
|
|
32
45
|
private readonly dataConnectOptions;
|
|
33
|
-
private readonly authProvider;
|
|
34
46
|
isEmulator: boolean;
|
|
35
47
|
initialized: boolean;
|
|
36
|
-
|
|
37
|
-
private transportOptions?;
|
|
38
|
-
private authTokenProvider?;
|
|
39
|
-
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, authProvider: Provider<FirebaseAuthInternalName>);
|
|
48
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
40
49
|
getSettings(): ConnectorConfig;
|
|
41
50
|
setInitialized(): void;
|
|
42
51
|
enableEmulator(transportOptions: TransportOptions): void;
|
|
43
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* DataConnectOptions including project id
|
|
55
|
+
*/
|
|
44
56
|
export declare interface DataConnectOptions extends ConnectorConfig {
|
|
45
57
|
projectId: string;
|
|
46
58
|
}
|
|
47
59
|
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
48
60
|
ref: OperationRef<Data, Variables>;
|
|
49
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Representation of user provided subscription options.
|
|
64
|
+
*/
|
|
50
65
|
export declare interface DataConnectSubscription<Data, Variables> {
|
|
51
66
|
userCallback: OnResultSubscription<Data, Variables>;
|
|
52
67
|
errCallback?: (e?: FirebaseError) => void;
|
|
@@ -65,41 +80,78 @@ export declare interface DataConnectTransport {
|
|
|
65
80
|
onTokenChanged: (token: string | null) => void;
|
|
66
81
|
}
|
|
67
82
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
83
|
+
/**
|
|
84
|
+
* Execute Mutation
|
|
85
|
+
* @param mutationRef mutation to execute
|
|
86
|
+
* @returns `MutationRef`
|
|
87
|
+
*/
|
|
68
88
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
89
|
+
/**
|
|
90
|
+
* Execute Query
|
|
91
|
+
* @param queryRef query to execute.
|
|
92
|
+
* @returns `QueryPromise`
|
|
93
|
+
*/
|
|
69
94
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
70
95
|
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
71
96
|
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
72
|
-
|
|
73
|
-
private options;
|
|
74
|
-
private authProvider_;
|
|
75
|
-
private auth_;
|
|
76
|
-
constructor(appName: string, options: FirebaseOptions, authProvider_: Provider<FirebaseAuthInternalName>);
|
|
97
|
+
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
77
98
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
78
99
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
79
100
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
80
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Initialize DataConnect instance
|
|
104
|
+
* @param options ConnectorConfig
|
|
105
|
+
*/
|
|
81
106
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
107
|
+
/**
|
|
108
|
+
* Initialize DataConnect instance
|
|
109
|
+
* @param app FirebaseApp to initialize to.
|
|
110
|
+
* @param options ConnectorConfig
|
|
111
|
+
*/
|
|
82
112
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
83
|
-
export declare
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
113
|
+
export declare const MUTATION_STR = "mutation";
|
|
114
|
+
/* Excluded from this release type: MutationManager */
|
|
115
|
+
/**
|
|
116
|
+
* Mutation return value from `executeMutation`
|
|
117
|
+
*/
|
|
88
118
|
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
89
119
|
}
|
|
90
|
-
export declare interface MutationRef<
|
|
91
|
-
refType: typeof
|
|
120
|
+
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
121
|
+
refType: typeof MUTATION_STR;
|
|
92
122
|
}
|
|
93
|
-
|
|
94
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Creates a `MutationRef`
|
|
125
|
+
* @param dcInstance Data Connect instance
|
|
126
|
+
* @param mutationName name of mutation
|
|
127
|
+
*/
|
|
128
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @param dcInstance Data Connect instance
|
|
132
|
+
* @param mutationName name of mutation
|
|
133
|
+
* @param variables variables to send with mutation
|
|
134
|
+
*/
|
|
135
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
95
136
|
export declare interface MutationResponse<T> extends CancellableOperation<T> {
|
|
96
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Mutation Result from `executeMutation`
|
|
140
|
+
*/
|
|
97
141
|
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
98
142
|
ref: MutationRef<Data, Variables>;
|
|
99
143
|
}
|
|
100
|
-
|
|
144
|
+
/**
|
|
145
|
+
* `OnCompleteSubscription`
|
|
146
|
+
*/
|
|
101
147
|
export declare type OnCompleteSubscription = () => void;
|
|
148
|
+
/**
|
|
149
|
+
* Signature for `OnErrorSubscription` for `subscribe`
|
|
150
|
+
*/
|
|
102
151
|
export declare type OnErrorSubscription = (err?: FirebaseError) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Signature for `OnResultSubscription` for `subscribe`
|
|
154
|
+
*/
|
|
103
155
|
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
104
156
|
export declare interface OperationRef<_Data, Variables> {
|
|
105
157
|
name: string;
|
|
@@ -113,28 +165,50 @@ export declare interface OpResult<Data> {
|
|
|
113
165
|
fetchTime: string;
|
|
114
166
|
}
|
|
115
167
|
/* Excluded from this release type: parseOptions */
|
|
116
|
-
export declare
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
projectId: string;
|
|
121
|
-
}
|
|
168
|
+
export declare const QUERY_STR = "query";
|
|
169
|
+
/**
|
|
170
|
+
* Promise returned from `executeQuery`
|
|
171
|
+
*/
|
|
122
172
|
export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
123
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* QueryRef object
|
|
176
|
+
*/
|
|
124
177
|
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
125
|
-
refType: typeof
|
|
178
|
+
refType: typeof QUERY_STR;
|
|
126
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Execute Query
|
|
182
|
+
* @param dcInstance Data Connect instance to use.
|
|
183
|
+
* @param queryName Query to execute
|
|
184
|
+
* @returns `QueryRef`
|
|
185
|
+
*/
|
|
127
186
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
187
|
+
/**
|
|
188
|
+
* Execute Query
|
|
189
|
+
* @param dcInstance Data Connect instance to use.
|
|
190
|
+
* @param queryName Query to execute
|
|
191
|
+
* @param variables Variables to execute with
|
|
192
|
+
* @returns `QueryRef`
|
|
193
|
+
*/
|
|
128
194
|
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
129
195
|
export declare interface QueryResponse<T> extends CancellableOperation<T> {
|
|
130
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Result of `executeQuery`
|
|
199
|
+
*/
|
|
131
200
|
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
132
201
|
ref: QueryRef<Data, Variables>;
|
|
133
202
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
134
203
|
}
|
|
135
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Signature for unsubscribe from `subscribe`
|
|
206
|
+
*/
|
|
136
207
|
export declare type QueryUnsubscribe = () => void;
|
|
137
|
-
export declare type ReferenceType = typeof
|
|
208
|
+
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
209
|
+
/**
|
|
210
|
+
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
|
|
211
|
+
*/
|
|
138
212
|
export declare interface RefInfo<Variables> {
|
|
139
213
|
name: string;
|
|
140
214
|
variables: Variables;
|
|
@@ -144,6 +218,9 @@ export declare interface Sender<T> {
|
|
|
144
218
|
abort: () => void;
|
|
145
219
|
send: () => Promise<T>;
|
|
146
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
223
|
+
*/
|
|
147
224
|
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
148
225
|
refInfo: RefInfo<Variables>;
|
|
149
226
|
}
|
|
@@ -151,24 +228,45 @@ export declare function setLogLevel(logLevel: LogLevelString): void;
|
|
|
151
228
|
export declare const SOURCE_CACHE = "CACHE";
|
|
152
229
|
export declare const SOURCE_SERVER = "SERVER";
|
|
153
230
|
/**
|
|
154
|
-
*
|
|
155
|
-
* @
|
|
156
|
-
* @param
|
|
157
|
-
* @
|
|
158
|
-
* @param onErr
|
|
159
|
-
* @param initialCache
|
|
160
|
-
* @returns
|
|
231
|
+
* Subscribe to a `QueryRef`
|
|
232
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
233
|
+
* @param observer observer object to use for subscribing.
|
|
234
|
+
* @returns `SubscriptionOptions`
|
|
161
235
|
*/
|
|
162
236
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
237
|
+
/**
|
|
238
|
+
* Subscribe to a `QueryRef`
|
|
239
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
240
|
+
* @param onNext Callback to call when result comes back.
|
|
241
|
+
* @param onError Callback to call when error gets thrown.
|
|
242
|
+
* @param onComplete Called when subscription completes.
|
|
243
|
+
* @returns `SubscriptionOptions`
|
|
244
|
+
*/
|
|
163
245
|
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
246
|
+
/**
|
|
247
|
+
* Representation of full observer options in `subscribe`
|
|
248
|
+
*/
|
|
164
249
|
export declare interface SubscriptionOptions<Data, Variables> {
|
|
165
250
|
onNext?: OnResultSubscription<Data, Variables>;
|
|
166
251
|
onErr?: OnErrorSubscription;
|
|
167
252
|
onComplete?: OnCompleteSubscription;
|
|
168
253
|
}
|
|
169
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Delete DataConnect instance
|
|
256
|
+
* @param dataConnect DataConnect instance
|
|
257
|
+
* @returns
|
|
258
|
+
*/
|
|
259
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Converts serialized ref to query ref
|
|
262
|
+
* @param serializedRef ref to convert to `QueryRef`
|
|
263
|
+
* @returns `QueryRef`
|
|
264
|
+
*/
|
|
170
265
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
171
266
|
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
|
|
267
|
+
/**
|
|
268
|
+
* Options to connect to emulator
|
|
269
|
+
*/
|
|
172
270
|
export declare interface TransportOptions {
|
|
173
271
|
host: string;
|
|
174
272
|
sslEnabled?: boolean;
|
|
@@ -19,17 +19,17 @@ 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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
service: string;
|
|
26
|
-
projectId: string;
|
|
27
|
-
}
|
|
22
|
+
/**
|
|
23
|
+
* Connector Config for calling Data Connect backend.
|
|
24
|
+
*/
|
|
28
25
|
export interface ConnectorConfig {
|
|
29
26
|
location: string;
|
|
30
27
|
connector: string;
|
|
31
28
|
service: string;
|
|
32
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Options to connect to emulator
|
|
32
|
+
*/
|
|
33
33
|
export interface TransportOptions {
|
|
34
34
|
host: string;
|
|
35
35
|
sslEnabled?: boolean;
|
|
@@ -43,28 +43,55 @@ export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CO
|
|
|
43
43
|
* @internal
|
|
44
44
|
*/
|
|
45
45
|
export declare function parseOptions(fullHost: string): TransportOptions;
|
|
46
|
+
/**
|
|
47
|
+
* DataConnectOptions including project id
|
|
48
|
+
*/
|
|
46
49
|
export interface DataConnectOptions extends ConnectorConfig {
|
|
47
50
|
projectId: string;
|
|
48
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Class representing Firebase Data Connect
|
|
54
|
+
*/
|
|
49
55
|
export declare class DataConnect {
|
|
50
56
|
readonly app: FirebaseApp;
|
|
51
57
|
private readonly dataConnectOptions;
|
|
52
|
-
private readonly
|
|
58
|
+
private readonly _authProvider;
|
|
53
59
|
_queryManager: QueryManager;
|
|
54
60
|
_mutationManager: MutationManager;
|
|
55
61
|
isEmulator: boolean;
|
|
56
62
|
initialized: boolean;
|
|
57
63
|
private _transport;
|
|
58
|
-
private
|
|
59
|
-
private
|
|
60
|
-
private
|
|
61
|
-
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions,
|
|
64
|
+
private _transportClass;
|
|
65
|
+
private _transportOptions?;
|
|
66
|
+
private _authTokenProvider?;
|
|
67
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
62
68
|
_delete(): Promise<void>;
|
|
63
69
|
getSettings(): ConnectorConfig;
|
|
64
70
|
setInitialized(): void;
|
|
65
71
|
enableEmulator(transportOptions: TransportOptions): void;
|
|
66
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Connect to the DataConnect Emulator
|
|
75
|
+
* @param dc Data Connect instance
|
|
76
|
+
* @param host host of emulator server
|
|
77
|
+
* @param port port of emulator server
|
|
78
|
+
* @param sslEnabled use https
|
|
79
|
+
*/
|
|
67
80
|
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
81
|
+
/**
|
|
82
|
+
* Initialize DataConnect instance
|
|
83
|
+
* @param options ConnectorConfig
|
|
84
|
+
*/
|
|
68
85
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
86
|
+
/**
|
|
87
|
+
* Initialize DataConnect instance
|
|
88
|
+
* @param app FirebaseApp to initialize to.
|
|
89
|
+
* @param options ConnectorConfig
|
|
90
|
+
*/
|
|
69
91
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
70
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Delete DataConnect instance
|
|
94
|
+
* @param dataConnect DataConnect instance
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
@@ -16,21 +16,46 @@
|
|
|
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
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Creates a `MutationRef`
|
|
25
|
+
* @param dcInstance Data Connect instance
|
|
26
|
+
* @param mutationName name of mutation
|
|
27
|
+
*/
|
|
28
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param dcInstance Data Connect instance
|
|
32
|
+
* @param mutationName name of mutation
|
|
33
|
+
* @param variables variables to send with mutation
|
|
34
|
+
*/
|
|
35
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
25
39
|
export declare class MutationManager {
|
|
26
|
-
private
|
|
40
|
+
private _transport;
|
|
27
41
|
private _inflight;
|
|
28
|
-
constructor(
|
|
29
|
-
executeMutation<
|
|
42
|
+
constructor(_transport: DataConnectTransport);
|
|
43
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
30
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Mutation Result from `executeMutation`
|
|
47
|
+
*/
|
|
31
48
|
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
32
49
|
ref: MutationRef<Data, Variables>;
|
|
33
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Mutation return value from `executeMutation`
|
|
53
|
+
*/
|
|
34
54
|
export interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
35
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Execute Mutation
|
|
58
|
+
* @param mutationRef mutation to execute
|
|
59
|
+
* @returns `MutationRef`
|
|
60
|
+
*/
|
|
36
61
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<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;
|
|
@@ -35,11 +35,17 @@ export interface OperationRef<_Data, Variables> {
|
|
|
35
35
|
export interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
36
36
|
ref: OperationRef<Data, Variables>;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
|
|
40
|
+
*/
|
|
38
41
|
export interface RefInfo<Variables> {
|
|
39
42
|
name: string;
|
|
40
43
|
variables: Variables;
|
|
41
44
|
connectorConfig: DataConnectOptions;
|
|
42
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
48
|
+
*/
|
|
43
49
|
export interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
44
50
|
refInfo: RefInfo<Variables>;
|
|
45
51
|
}
|
package/dist/src/api/query.d.ts
CHANGED
|
@@ -16,29 +16,79 @@
|
|
|
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
|
+
/**
|
|
21
|
+
* Signature for `OnResultSubscription` for `subscribe`
|
|
22
|
+
*/
|
|
20
23
|
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Signature for `OnErrorSubscription` for `subscribe`
|
|
26
|
+
*/
|
|
21
27
|
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Signature for unsubscribe from `subscribe`
|
|
30
|
+
*/
|
|
22
31
|
export declare type QueryUnsubscribe = () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Representation of user provided subscription options.
|
|
34
|
+
*/
|
|
23
35
|
export interface DataConnectSubscription<Data, Variables> {
|
|
24
36
|
userCallback: OnResultSubscription<Data, Variables>;
|
|
25
37
|
errCallback?: (e?: DataConnectError) => void;
|
|
26
38
|
unsubscribe: () => void;
|
|
27
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* QueryRef object
|
|
42
|
+
*/
|
|
28
43
|
export interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
29
|
-
refType: typeof
|
|
44
|
+
refType: typeof QUERY_STR;
|
|
30
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of `executeQuery`
|
|
48
|
+
*/
|
|
31
49
|
export interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
32
50
|
ref: QueryRef<Data, Variables>;
|
|
33
51
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
34
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Promise returned from `executeQuery`
|
|
55
|
+
*/
|
|
35
56
|
export interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
|
|
36
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Execute Query
|
|
60
|
+
* @param queryRef query to execute.
|
|
61
|
+
* @returns `QueryPromise`
|
|
62
|
+
*/
|
|
37
63
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
64
|
+
/**
|
|
65
|
+
* Execute Query
|
|
66
|
+
* @param dcInstance Data Connect instance to use.
|
|
67
|
+
* @param queryName Query to execute
|
|
68
|
+
* @returns `QueryRef`
|
|
69
|
+
*/
|
|
38
70
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Execute Query
|
|
73
|
+
* @param dcInstance Data Connect instance to use.
|
|
74
|
+
* @param queryName Query to execute
|
|
75
|
+
* @param variables Variables to execute with
|
|
76
|
+
* @returns `QueryRef`
|
|
77
|
+
*/
|
|
39
78
|
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
79
|
+
/**
|
|
80
|
+
* Converts serialized ref to query ref
|
|
81
|
+
* @param serializedRef ref to convert to `QueryRef`
|
|
82
|
+
* @returns `QueryRef`
|
|
83
|
+
*/
|
|
40
84
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
85
|
+
/**
|
|
86
|
+
* `OnCompleteSubscription`
|
|
87
|
+
*/
|
|
41
88
|
export declare type OnCompleteSubscription = () => void;
|
|
89
|
+
/**
|
|
90
|
+
* Representation of full observer options in `subscribe`
|
|
91
|
+
*/
|
|
42
92
|
export interface SubscriptionOptions<Data, Variables> {
|
|
43
93
|
onNext?: OnResultSubscription<Data, Variables>;
|
|
44
94
|
onErr?: OnErrorSubscription;
|
|
@@ -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;
|
|
@@ -23,11 +23,11 @@ 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;
|
|
@@ -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;
|