@firebase/data-connect 0.0.2-dataconnect-preview.877f8b7d0 → 0.0.3-canary.beaa4dffb

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