@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.
Files changed (40) hide show
  1. package/dist/index.cjs.js +204 -29
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm2017.js +203 -30
  4. package/dist/index.esm2017.js.map +1 -1
  5. package/dist/index.esm5.js +204 -25
  6. package/dist/index.esm5.js.map +1 -1
  7. package/dist/index.node.cjs.js +205 -24
  8. package/dist/index.node.cjs.js.map +1 -1
  9. package/dist/internal.d.ts +159 -13
  10. package/dist/node-esm/index.node.esm.js +203 -30
  11. package/dist/node-esm/index.node.esm.js.map +1 -1
  12. package/dist/node-esm/src/api/DataConnect.d.ts +42 -0
  13. package/dist/node-esm/src/api/Mutation.d.ts +26 -1
  14. package/dist/node-esm/src/api/Reference.d.ts +6 -0
  15. package/dist/node-esm/src/api/index.d.ts +1 -0
  16. package/dist/node-esm/src/api/query.d.ts +51 -1
  17. package/dist/node-esm/src/api.browser.d.ts +12 -7
  18. package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +1 -1
  19. package/dist/node-esm/src/core/QueryManager.d.ts +1 -1
  20. package/dist/node-esm/src/core/error.d.ts +2 -1
  21. package/dist/node-esm/src/network/fetch.d.ts +1 -1
  22. package/dist/node-esm/src/network/transport/index.d.ts +1 -1
  23. package/dist/node-esm/src/network/transport/rest.d.ts +20 -9
  24. package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
  25. package/dist/private.d.ts +141 -19
  26. package/dist/public.d.ts +130 -15
  27. package/dist/src/api/DataConnect.d.ts +42 -0
  28. package/dist/src/api/Mutation.d.ts +26 -1
  29. package/dist/src/api/Reference.d.ts +6 -0
  30. package/dist/src/api/index.d.ts +1 -0
  31. package/dist/src/api/query.d.ts +51 -1
  32. package/dist/src/api.browser.d.ts +12 -7
  33. package/dist/src/core/FirebaseAuthProvider.d.ts +1 -1
  34. package/dist/src/core/QueryManager.d.ts +1 -1
  35. package/dist/src/core/error.d.ts +2 -1
  36. package/dist/src/network/fetch.d.ts +1 -1
  37. package/dist/src/network/transport/index.d.ts +1 -1
  38. package/dist/src/network/transport/rest.d.ts +20 -9
  39. package/dist/src/util/validateArgs.d.ts +33 -0
  40. package/package.json +10 -6
package/dist/public.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
  import { FirebaseApp } from '@firebase/app';
7
- import { FirebaseOptions } from '@firebase/app';
7
+ import { FirebaseOptions } from '@firebase/app-types';
8
8
  import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
9
9
  import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
10
10
  import { Provider } from '@firebase/component';
@@ -21,12 +21,25 @@ 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;
@@ -37,12 +50,18 @@ export declare class DataConnect {
37
50
  setInitialized(): void;
38
51
  enableEmulator(transportOptions: TransportOptions): void;
39
52
  }
53
+ /**
54
+ * DataConnectOptions including project id
55
+ */
40
56
  export declare interface DataConnectOptions extends ConnectorConfig {
41
57
  projectId: string;
42
58
  }
43
59
  export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
44
60
  ref: OperationRef<Data, Variables>;
45
61
  }
62
+ /**
63
+ * Representation of user provided subscription options.
64
+ */
46
65
  export declare interface DataConnectSubscription<Data, Variables> {
47
66
  userCallback: OnResultSubscription<Data, Variables>;
48
67
  errCallback?: (e?: FirebaseError) => void;
@@ -61,7 +80,17 @@ export declare interface DataConnectTransport {
61
80
  onTokenChanged: (token: string | null) => void;
62
81
  }
63
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
+ */
64
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
+ */
65
94
  export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
66
95
  export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
67
96
  export declare class FirebaseAuthProvider implements AuthTokenProvider {
@@ -70,27 +99,59 @@ export declare class FirebaseAuthProvider implements AuthTokenProvider {
70
99
  addTokenChangeListener(listener: AuthTokenListener): void;
71
100
  removeTokenChangeListener(listener: (token: string | null) => void): void;
72
101
  }
102
+ /**
103
+ * Initialize DataConnect instance
104
+ * @param options ConnectorConfig
105
+ */
73
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
+ */
74
112
  export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
75
113
  export declare const MUTATION_STR = "mutation";
76
- export declare class MutationManager {
77
- constructor(_transport: DataConnectTransport);
78
- executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
79
- }
114
+ /* Excluded from this release type: MutationManager */
115
+ /**
116
+ * Mutation return value from `executeMutation`
117
+ */
80
118
  export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
81
119
  }
82
120
  export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
83
121
  refType: typeof MUTATION_STR;
84
122
  }
85
- export declare function mutationRef<Data>(dcInstance: DataConnect, queryName: string): MutationRef<Data, undefined>;
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
+ */
86
135
  export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
87
136
  export declare interface MutationResponse<T> extends CancellableOperation<T> {
88
137
  }
138
+ /**
139
+ * Mutation Result from `executeMutation`
140
+ */
89
141
  export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
90
142
  ref: MutationRef<Data, Variables>;
91
143
  }
144
+ /**
145
+ * `OnCompleteSubscription`
146
+ */
92
147
  export declare type OnCompleteSubscription = () => void;
148
+ /**
149
+ * Signature for `OnErrorSubscription` for `subscribe`
150
+ */
93
151
  export declare type OnErrorSubscription = (err?: FirebaseError) => void;
152
+ /**
153
+ * Signature for `OnResultSubscription` for `subscribe`
154
+ */
94
155
  export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
95
156
  export declare interface OperationRef<_Data, Variables> {
96
157
  name: string;
@@ -105,21 +166,49 @@ export declare interface OpResult<Data> {
105
166
  }
106
167
  /* Excluded from this release type: parseOptions */
107
168
  export declare const QUERY_STR = "query";
169
+ /**
170
+ * Promise returned from `executeQuery`
171
+ */
108
172
  export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
109
173
  }
174
+ /**
175
+ * QueryRef object
176
+ */
110
177
  export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
111
178
  refType: typeof QUERY_STR;
112
179
  }
180
+ /**
181
+ * Execute Query
182
+ * @param dcInstance Data Connect instance to use.
183
+ * @param queryName Query to execute
184
+ * @returns `QueryRef`
185
+ */
113
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
+ */
114
194
  export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
115
195
  export declare interface QueryResponse<T> extends CancellableOperation<T> {
116
196
  }
197
+ /**
198
+ * Result of `executeQuery`
199
+ */
117
200
  export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
118
201
  ref: QueryRef<Data, Variables>;
119
202
  toJSON: () => SerializedRef<Data, Variables>;
120
203
  }
204
+ /**
205
+ * Signature for unsubscribe from `subscribe`
206
+ */
121
207
  export declare type QueryUnsubscribe = () => void;
122
208
  export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
209
+ /**
210
+ * Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
211
+ */
123
212
  export declare interface RefInfo<Variables> {
124
213
  name: string;
125
214
  variables: Variables;
@@ -129,6 +218,9 @@ export declare interface Sender<T> {
129
218
  abort: () => void;
130
219
  send: () => Promise<T>;
131
220
  }
221
+ /**
222
+ * Serialized Ref as a result of `QueryResult.toJSON()`
223
+ */
132
224
  export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
133
225
  refInfo: RefInfo<Variables>;
134
226
  }
@@ -136,27 +228,50 @@ export declare function setLogLevel(logLevel: LogLevelString): void;
136
228
  export declare const SOURCE_CACHE = "CACHE";
137
229
  export declare const SOURCE_SERVER = "SERVER";
138
230
  /**
139
- *
140
- * @public
141
- * @param queryRef
142
- * @param onResult
143
- * @param onErr
144
- * @param initialCache
145
- * @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`
146
235
  */
147
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
+ */
148
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
+ */
149
249
  export declare interface SubscriptionOptions<Data, Variables> {
150
250
  onNext?: OnResultSubscription<Data, Variables>;
151
251
  onErr?: OnErrorSubscription;
152
252
  onComplete?: OnCompleteSubscription;
153
253
  }
254
+ /**
255
+ * Delete DataConnect instance
256
+ * @param dataConnect DataConnect instance
257
+ * @returns
258
+ */
154
259
  export declare function terminate(dataConnect: DataConnect): Promise<void>;
155
- export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
156
- export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
260
+ /**
261
+ * Converts serialized ref to query ref
262
+ * @param serializedRef ref to convert to `QueryRef`
263
+ * @returns `QueryRef`
264
+ */
265
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
266
+ export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
267
+ /**
268
+ * Options to connect to emulator
269
+ */
157
270
  export declare interface TransportOptions {
158
271
  host: string;
159
272
  sslEnabled?: boolean;
160
273
  port?: number;
161
274
  }
275
+ /* Excluded from this release type: validateArgs */
276
+ /* Excluded from this release type: validateDCOptions */
162
277
  export {};
@@ -19,11 +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
+ * Connector Config for calling Data Connect backend.
24
+ */
22
25
  export interface ConnectorConfig {
23
26
  location: string;
24
27
  connector: string;
25
28
  service: string;
26
29
  }
30
+ /**
31
+ * Options to connect to emulator
32
+ */
27
33
  export interface TransportOptions {
28
34
  host: string;
29
35
  sslEnabled?: boolean;
@@ -37,9 +43,15 @@ export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CO
37
43
  * @internal
38
44
  */
39
45
  export declare function parseOptions(fullHost: string): TransportOptions;
46
+ /**
47
+ * DataConnectOptions including project id
48
+ */
40
49
  export interface DataConnectOptions extends ConnectorConfig {
41
50
  projectId: string;
42
51
  }
52
+ /**
53
+ * Class representing Firebase Data Connect
54
+ */
43
55
  export declare class DataConnect {
44
56
  readonly app: FirebaseApp;
45
57
  private readonly dataConnectOptions;
@@ -52,13 +64,43 @@ export declare class DataConnect {
52
64
  private _transportClass;
53
65
  private _transportOptions?;
54
66
  private _authTokenProvider?;
67
+ _isUsingGeneratedSdk: boolean;
55
68
  constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
69
+ _useGeneratedSdk(): void;
56
70
  _delete(): Promise<void>;
57
71
  getSettings(): ConnectorConfig;
58
72
  setInitialized(): void;
59
73
  enableEmulator(transportOptions: TransportOptions): void;
60
74
  }
75
+ /**
76
+ * Connect to the DataConnect Emulator
77
+ * @param dc Data Connect instance
78
+ * @param host host of emulator server
79
+ * @param port port of emulator server
80
+ * @param sslEnabled use https
81
+ */
61
82
  export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
83
+ /**
84
+ * Initialize DataConnect instance
85
+ * @param options ConnectorConfig
86
+ */
62
87
  export declare function getDataConnect(options: ConnectorConfig): DataConnect;
88
+ /**
89
+ * Initialize DataConnect instance
90
+ * @param app FirebaseApp to initialize to.
91
+ * @param options ConnectorConfig
92
+ */
63
93
  export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
94
+ /**
95
+ *
96
+ * @param dcOptions
97
+ * @returns {void}
98
+ * @internal
99
+ */
100
+ export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
101
+ /**
102
+ * Delete DataConnect instance
103
+ * @param dataConnect DataConnect instance
104
+ * @returns
105
+ */
64
106
  export declare function terminate(dataConnect: DataConnect): Promise<void>;
@@ -20,17 +20,42 @@ import { DataConnectResult, MUTATION_STR, OperationRef } from './Reference';
20
20
  export interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
21
21
  refType: typeof MUTATION_STR;
22
22
  }
23
- export declare function mutationRef<Data>(dcInstance: DataConnect, queryName: string): MutationRef<Data, undefined>;
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
+ */
24
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
40
  private _transport;
27
41
  private _inflight;
28
42
  constructor(_transport: DataConnectTransport);
29
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>;
@@ -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
  }
@@ -20,3 +20,4 @@ export * from './Reference';
20
20
  export * from './Mutation';
21
21
  export * from './query';
22
22
  export { setLogLevel } from '../logger';
23
+ export { validateArgs } from '../util/validateArgs';
@@ -17,28 +17,78 @@
17
17
  import { DataConnectError } from '../core/error';
18
18
  import { DataConnect } from './DataConnect';
19
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
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>;
40
- export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
79
+ /**
80
+ * Converts serialized ref to query ref
81
+ * @param serializedRef ref to convert to `QueryRef`
82
+ * @returns `QueryRef`
83
+ */
84
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, 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
- * @public
22
- * @param queryRef
23
- * @param onResult
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;
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { FirebaseOptions } from '@firebase/app';
17
+ import { FirebaseOptions } from '@firebase/app-types';
18
18
  import { FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
19
19
  import { Provider } from '@firebase/component';
20
20
  export interface AuthTokenProvider {
@@ -28,7 +28,7 @@ export declare class QueryManager {
28
28
  private transport;
29
29
  _queries: Map<string, TrackedQuery<unknown, unknown>>;
30
30
  constructor(transport: DataConnectTransport);
31
- track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<unknown, unknown>;
31
+ track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<Data, Variables>;
32
32
  addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
33
33
  executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
34
34
  enableEmulator(host: string, port: number): void;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { FirebaseError } from '@firebase/util';
18
- export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
18
+ export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
19
19
  export declare type Code = DataConnectErrorCode;
20
20
  export declare const Code: {
21
21
  OTHER: DataConnectErrorCode;
@@ -24,6 +24,7 @@ export declare const Code: {
24
24
  NOT_SUPPORTED: DataConnectErrorCode;
25
25
  INVALID_ARGUMENT: DataConnectErrorCode;
26
26
  PARTIAL_ERROR: DataConnectErrorCode;
27
+ UNAUTHORIZED: DataConnectErrorCode;
27
28
  };
28
29
  /** An error returned by a DataConnect operation. */
29
30
  export declare class DataConnectError extends FirebaseError {
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  export declare function initializeFetch(fetchImpl: typeof fetch): void;
18
- export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, accessToken: string | null): Promise<{
18
+ export declare function dcFetch<T, U>(url: string, body: U, { signal }: AbortController, accessToken: string | null, _isUsingGen: boolean): Promise<{
19
19
  data: T;
20
20
  errors: Error[];
21
21
  }>;
@@ -41,5 +41,5 @@ export interface Sender<T> {
41
41
  abort: () => void;
42
42
  send: () => Promise<T>;
43
43
  }
44
- export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
44
+ export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
45
45
  export * from '../../core/FirebaseAuthProvider';
@@ -20,6 +20,7 @@ import { DataConnectTransport } from '.';
20
20
  export declare class RESTTransport implements DataConnectTransport {
21
21
  private apiKey?;
22
22
  private authProvider?;
23
+ private _isUsingGen;
23
24
  private _host;
24
25
  private _port;
25
26
  private _location;
@@ -29,16 +30,26 @@ export declare class RESTTransport implements DataConnectTransport {
29
30
  private _serviceName;
30
31
  private _accessToken;
31
32
  private _authInitialized;
32
- constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined);
33
+ private _lastToken;
34
+ constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
33
35
  get endpointUrl(): string;
34
36
  useEmulator(host: string, port?: number, isSecure?: boolean): void;
35
37
  onTokenChanged(newToken: string | null): void;
36
- getWithAuth(): Promise<string>;
37
- invokeQuery: <T, U = unknown>(queryName: string, body: U) => {
38
- then: any;
39
- };
40
- invokeMutation: <T, U = unknown>(mutationName: string, body: U) => {
41
- then: any;
42
- cancel: () => void;
43
- };
38
+ getWithAuth(forceToken?: boolean): Promise<string>;
39
+ _setLastToken(lastToken: string | null): void;
40
+ withRetry<T>(promiseFactory: () => Promise<{
41
+ data: T;
42
+ errors: Error[];
43
+ }>, retry?: boolean): Promise<{
44
+ data: T;
45
+ errors: Error[];
46
+ }>;
47
+ invokeQuery: <T, U>(queryName: string, body?: U) => PromiseLike<{
48
+ data: T;
49
+ errors: Error[];
50
+ }>;
51
+ invokeMutation: <T, U>(queryName: string, body?: U) => PromiseLike<{
52
+ data: T;
53
+ errors: Error[];
54
+ }>;
44
55
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ConnectorConfig, DataConnect } from '../api/DataConnect';
18
+ interface ParsedArgs<Variables> {
19
+ dc: DataConnect;
20
+ vars: Variables;
21
+ }
22
+ /**
23
+ * The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
24
+ * and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
25
+ * @param connectorConfig
26
+ * @param dcOrVars
27
+ * @param vars
28
+ * @param validateVars
29
+ * @returns {DataConnect} and {Variables} instance
30
+ * @internal
31
+ */
32
+ export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
33
+ export {};