@firebase/data-connect 0.0.2-dataconnect-preview.388b61c7e → 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 (36) hide show
  1. package/dist/index.cjs.js +246 -52
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm2017.js +245 -51
  4. package/dist/index.esm2017.js.map +1 -1
  5. package/dist/index.esm5.js +265 -50
  6. package/dist/index.esm5.js.map +1 -1
  7. package/dist/index.node.cjs.js +266 -51
  8. package/dist/index.node.cjs.js.map +1 -1
  9. package/dist/internal.d.ts +59 -33
  10. package/dist/node-esm/index.node.esm.js +245 -51
  11. package/dist/node-esm/index.node.esm.js.map +1 -1
  12. package/dist/node-esm/src/api/DataConnect.d.ts +14 -3
  13. package/dist/node-esm/src/api/index.d.ts +1 -0
  14. package/dist/node-esm/src/api/query.d.ts +1 -1
  15. package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +30 -0
  16. package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +1 -1
  17. package/dist/node-esm/src/core/QueryManager.d.ts +1 -1
  18. package/dist/node-esm/src/core/error.d.ts +2 -1
  19. package/dist/node-esm/src/network/fetch.d.ts +1 -1
  20. package/dist/node-esm/src/network/transport/index.d.ts +8 -10
  21. package/dist/node-esm/src/network/transport/rest.d.ts +24 -10
  22. package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
  23. package/dist/private.d.ts +27 -45
  24. package/dist/public.d.ts +8 -38
  25. package/dist/src/api/DataConnect.d.ts +14 -3
  26. package/dist/src/api/index.d.ts +1 -0
  27. package/dist/src/api/query.d.ts +1 -1
  28. package/dist/src/core/AppCheckTokenProvider.d.ts +30 -0
  29. package/dist/src/core/FirebaseAuthProvider.d.ts +1 -1
  30. package/dist/src/core/QueryManager.d.ts +1 -1
  31. package/dist/src/core/error.d.ts +2 -1
  32. package/dist/src/network/fetch.d.ts +1 -1
  33. package/dist/src/network/transport/index.d.ts +8 -10
  34. package/dist/src/network/transport/rest.d.ts +24 -10
  35. package/dist/src/util/validateArgs.d.ts +33 -0
  36. package/package.json +11 -7
@@ -15,11 +15,15 @@
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';
19
20
  import { DataConnectTransport } from '.';
20
21
  export declare class RESTTransport implements DataConnectTransport {
21
22
  private apiKey?;
23
+ private appId?;
22
24
  private authProvider?;
25
+ private appCheckProvider?;
26
+ private _isUsingGen;
23
27
  private _host;
24
28
  private _port;
25
29
  private _location;
@@ -28,17 +32,27 @@ export declare class RESTTransport implements DataConnectTransport {
28
32
  private _project;
29
33
  private _serviceName;
30
34
  private _accessToken;
31
- private _authInitialized;
32
- constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined);
35
+ private _appCheckToken;
36
+ private _lastToken;
37
+ constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
33
38
  get endpointUrl(): string;
34
39
  useEmulator(host: string, port?: number, isSecure?: boolean): void;
35
40
  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
- };
41
+ getWithAuth(forceToken?: boolean): Promise<string>;
42
+ _setLastToken(lastToken: string | null): void;
43
+ withRetry<T>(promiseFactory: () => Promise<{
44
+ data: T;
45
+ errors: Error[];
46
+ }>, retry?: boolean): Promise<{
47
+ data: T;
48
+ errors: Error[];
49
+ }>;
50
+ invokeQuery: <T, U>(queryName: string, body?: U) => PromiseLike<{
51
+ data: T;
52
+ errors: Error[];
53
+ }>;
54
+ invokeMutation: <T, U>(queryName: string, body?: U) => PromiseLike<{
55
+ data: T;
56
+ errors: Error[];
57
+ }>;
44
58
  }
@@ -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 {};
package/dist/private.d.ts CHANGED
@@ -4,17 +4,21 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
 
7
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
8
+ import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
9
+ import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
7
10
  import { FirebaseApp } from '@firebase/app';
8
11
  import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
9
12
  import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
10
13
  import { FirebaseError } from '@firebase/util';
11
- import { FirebaseOptions } from '@firebase/app';
12
14
  import { LogLevelString } from '@firebase/logger';
13
15
  import { Provider } from '@firebase/component';
14
16
 
15
- export declare type AuthTokenListener = (token: string | null) => void;
17
+ /* Excluded from this release type: AppCheckTokenProvider */
16
18
 
17
- export declare interface AuthTokenProvider {
19
+ declare type AuthTokenListener = (token: string | null) => void;
20
+
21
+ declare interface AuthTokenProvider {
18
22
  getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
19
23
  addTokenChangeListener(listener: AuthTokenListener): void;
20
24
  }
@@ -50,15 +54,19 @@ export declare class DataConnect {
50
54
  readonly app: FirebaseApp;
51
55
  private readonly dataConnectOptions;
52
56
  private readonly _authProvider;
57
+ private readonly _appCheckProvider;
53
58
  _queryManager: QueryManager;
54
59
  _mutationManager: MutationManager;
55
60
  isEmulator: boolean;
56
- initialized: boolean;
61
+ _initialized: boolean;
57
62
  private _transport;
58
63
  private _transportClass;
59
64
  private _transportOptions?;
60
65
  private _authTokenProvider?;
61
- constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
66
+ _isUsingGeneratedSdk: boolean;
67
+ private _appCheckTokenProvider?;
68
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
69
+ _useGeneratedSdk(): void;
62
70
  _delete(): Promise<void>;
63
71
  getSettings(): ConnectorConfig;
64
72
  setInitialized(): void;
@@ -89,7 +97,7 @@ declare class DataConnectError extends FirebaseError {
89
97
  message: string);
90
98
  }
91
99
 
92
- declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
100
+ declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
93
101
 
94
102
  /**
95
103
  * DataConnectOptions including project id
@@ -111,18 +119,7 @@ export declare interface DataConnectSubscription<Data, Variables> {
111
119
  unsubscribe: () => void;
112
120
  }
113
121
 
114
- export declare interface DataConnectTransport {
115
- invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
116
- data: T;
117
- errors: Error[];
118
- }>;
119
- invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
120
- data: T;
121
- errors: Error[];
122
- }>;
123
- useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
124
- onTokenChanged: (token: string | null) => void;
125
- }
122
+ /* Excluded from this release type: DataConnectTransport */
126
123
 
127
124
  export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
128
125
 
@@ -140,19 +137,6 @@ export declare function executeMutation<Data, Variables>(mutationRef: MutationRe
140
137
  */
141
138
  export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
142
139
 
143
- export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
144
-
145
- export declare class FirebaseAuthProvider implements AuthTokenProvider {
146
- private _appName;
147
- private _options;
148
- private _authProvider;
149
- private _auth;
150
- constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
151
- getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
152
- addTokenChangeListener(listener: AuthTokenListener): void;
153
- removeTokenChangeListener(listener: (token: string | null) => void): void;
154
- }
155
-
156
140
  /**
157
141
  * Initialize DataConnect instance
158
142
  * @param options ConnectorConfig
@@ -195,9 +179,6 @@ export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName:
195
179
  */
196
180
  export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
197
181
 
198
- export declare interface MutationResponse<T> extends CancellableOperation<T> {
199
- }
200
-
201
182
  /**
202
183
  * Mutation Result from `executeMutation`
203
184
  */
@@ -233,6 +214,11 @@ export declare interface OpResult<Data> {
233
214
  fetchTime: string;
234
215
  }
235
216
 
217
+ declare interface ParsedArgs<Variables> {
218
+ dc: DataConnect;
219
+ vars: Variables;
220
+ }
221
+
236
222
  /* Excluded from this release type: parseOptions */
237
223
 
238
224
  export declare const QUERY_STR = "query";
@@ -241,7 +227,7 @@ declare class QueryManager {
241
227
  private transport;
242
228
  _queries: Map<string, TrackedQuery<unknown, unknown>>;
243
229
  constructor(transport: DataConnectTransport);
244
- track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<unknown, unknown>;
230
+ track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<Data, Variables>;
245
231
  addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
246
232
  executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
247
233
  enableEmulator(host: string, port: number): void;
@@ -277,9 +263,6 @@ export declare function queryRef<Data>(dcInstance: DataConnect, queryName: strin
277
263
  */
278
264
  export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
279
265
 
280
- export declare interface QueryResponse<T> extends CancellableOperation<T> {
281
- }
282
-
283
266
  /**
284
267
  * Result of `executeQuery`
285
268
  */
@@ -304,11 +287,6 @@ export declare interface RefInfo<Variables> {
304
287
  connectorConfig: DataConnectOptions;
305
288
  }
306
289
 
307
- export declare interface Sender<T> {
308
- abort: () => void;
309
- send: () => Promise<T>;
310
- }
311
-
312
290
  /**
313
291
  * Serialized Ref as a result of `QueryResult.toJSON()`
314
292
  */
@@ -361,7 +339,7 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
361
339
  * @param serializedRef ref to convert to `QueryRef`
362
340
  * @returns `QueryRef`
363
341
  */
364
- export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
342
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
365
343
 
366
344
  declare interface TrackedQuery<Data, Variables> {
367
345
  ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
@@ -370,7 +348,7 @@ declare interface TrackedQuery<Data, Variables> {
370
348
  lastError: DataConnectError | null;
371
349
  }
372
350
 
373
- export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
351
+ /* Excluded from this release type: TransportClass */
374
352
 
375
353
  /**
376
354
  * Options to connect to emulator
@@ -381,4 +359,8 @@ export declare interface TransportOptions {
381
359
  port?: number;
382
360
  }
383
361
 
362
+ /* Excluded from this release type: validateArgs */
363
+
364
+ /* Excluded from this release type: validateDCOptions */
365
+
384
366
  export { }
package/dist/public.d.ts CHANGED
@@ -4,18 +4,13 @@
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
  }> {
@@ -44,8 +39,7 @@ export declare class DataConnect {
44
39
  readonly app: FirebaseApp;
45
40
  private readonly dataConnectOptions;
46
41
  isEmulator: boolean;
47
- initialized: boolean;
48
- constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
42
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
49
43
  getSettings(): ConnectorConfig;
50
44
  setInitialized(): void;
51
45
  enableEmulator(transportOptions: TransportOptions): void;
@@ -67,18 +61,7 @@ export declare interface DataConnectSubscription<Data, Variables> {
67
61
  errCallback?: (e?: FirebaseError) => void;
68
62
  unsubscribe: () => void;
69
63
  }
70
- export declare interface DataConnectTransport {
71
- invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
72
- data: T;
73
- errors: Error[];
74
- }>;
75
- invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
76
- data: T;
77
- errors: Error[];
78
- }>;
79
- useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
80
- onTokenChanged: (token: string | null) => void;
81
- }
64
+ /* Excluded from this release type: DataConnectTransport */
82
65
  export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
83
66
  /**
84
67
  * Execute Mutation
@@ -92,13 +75,6 @@ export declare function executeMutation<Data, Variables>(mutationRef: MutationRe
92
75
  * @returns `QueryPromise`
93
76
  */
94
77
  export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
95
- export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
96
- export declare class FirebaseAuthProvider implements AuthTokenProvider {
97
- constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
98
- getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
99
- addTokenChangeListener(listener: AuthTokenListener): void;
100
- removeTokenChangeListener(listener: (token: string | null) => void): void;
101
- }
102
78
  /**
103
79
  * Initialize DataConnect instance
104
80
  * @param options ConnectorConfig
@@ -133,8 +109,6 @@ export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName:
133
109
  * @param variables variables to send with mutation
134
110
  */
135
111
  export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
136
- export declare interface MutationResponse<T> extends CancellableOperation<T> {
137
- }
138
112
  /**
139
113
  * Mutation Result from `executeMutation`
140
114
  */
@@ -192,8 +166,6 @@ export declare function queryRef<Data>(dcInstance: DataConnect, queryName: strin
192
166
  * @returns `QueryRef`
193
167
  */
194
168
  export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
195
- export declare interface QueryResponse<T> extends CancellableOperation<T> {
196
- }
197
169
  /**
198
170
  * Result of `executeQuery`
199
171
  */
@@ -214,10 +186,6 @@ export declare interface RefInfo<Variables> {
214
186
  variables: Variables;
215
187
  connectorConfig: DataConnectOptions;
216
188
  }
217
- export declare interface Sender<T> {
218
- abort: () => void;
219
- send: () => Promise<T>;
220
- }
221
189
  /**
222
190
  * Serialized Ref as a result of `QueryResult.toJSON()`
223
191
  */
@@ -262,8 +230,8 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
262
230
  * @param serializedRef ref to convert to `QueryRef`
263
231
  * @returns `QueryRef`
264
232
  */
265
- export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
266
- export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
233
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
234
+ /* Excluded from this release type: TransportClass */
267
235
  /**
268
236
  * Options to connect to emulator
269
237
  */
@@ -272,4 +240,6 @@ export declare interface TransportOptions {
272
240
  sslEnabled?: boolean;
273
241
  port?: number;
274
242
  }
243
+ /* Excluded from this release type: validateArgs */
244
+ /* Excluded from this release type: validateDCOptions */
275
245
  export {};
@@ -15,6 +15,7 @@
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';
@@ -35,7 +36,6 @@ export interface TransportOptions {
35
36
  sslEnabled?: boolean;
36
37
  port?: number;
37
38
  }
38
- export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
39
39
  /**
40
40
  *
41
41
  * @param fullHost
@@ -56,15 +56,19 @@ export declare class DataConnect {
56
56
  readonly app: FirebaseApp;
57
57
  private readonly dataConnectOptions;
58
58
  private readonly _authProvider;
59
+ private readonly _appCheckProvider;
59
60
  _queryManager: QueryManager;
60
61
  _mutationManager: MutationManager;
61
62
  isEmulator: boolean;
62
- initialized: boolean;
63
+ _initialized: boolean;
63
64
  private _transport;
64
65
  private _transportClass;
65
66
  private _transportOptions?;
66
67
  private _authTokenProvider?;
67
- 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;
68
72
  _delete(): Promise<void>;
69
73
  getSettings(): ConnectorConfig;
70
74
  setInitialized(): void;
@@ -89,6 +93,13 @@ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
89
93
  * @param options ConnectorConfig
90
94
  */
91
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;
92
103
  /**
93
104
  * Delete DataConnect instance
94
105
  * @param dataConnect DataConnect instance
@@ -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';
@@ -81,7 +81,7 @@ export declare function queryRef<Data, Variables>(dcInstance: DataConnect, query
81
81
  * @param serializedRef ref to convert to `QueryRef`
82
82
  * @returns `QueryRef`
83
83
  */
84
- export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
84
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
85
85
  /**
86
86
  * `OnCompleteSubscription`
87
87
  */
@@ -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;
@@ -15,11 +15,15 @@
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';
19
20
  import { DataConnectTransport } from '.';
20
21
  export declare class RESTTransport implements DataConnectTransport {
21
22
  private apiKey?;
23
+ private appId?;
22
24
  private authProvider?;
25
+ private appCheckProvider?;
26
+ private _isUsingGen;
23
27
  private _host;
24
28
  private _port;
25
29
  private _location;
@@ -28,17 +32,27 @@ export declare class RESTTransport implements DataConnectTransport {
28
32
  private _project;
29
33
  private _serviceName;
30
34
  private _accessToken;
31
- private _authInitialized;
32
- constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined);
35
+ private _appCheckToken;
36
+ private _lastToken;
37
+ constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
33
38
  get endpointUrl(): string;
34
39
  useEmulator(host: string, port?: number, isSecure?: boolean): void;
35
40
  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
- };
41
+ getWithAuth(forceToken?: boolean): Promise<string>;
42
+ _setLastToken(lastToken: string | null): void;
43
+ withRetry<T>(promiseFactory: () => Promise<{
44
+ data: T;
45
+ errors: Error[];
46
+ }>, retry?: boolean): Promise<{
47
+ data: T;
48
+ errors: Error[];
49
+ }>;
50
+ invokeQuery: <T, U>(queryName: string, body?: U) => PromiseLike<{
51
+ data: T;
52
+ errors: Error[];
53
+ }>;
54
+ invokeMutation: <T, U>(queryName: string, body?: U) => PromiseLike<{
55
+ data: T;
56
+ errors: Error[];
57
+ }>;
44
58
  }
@@ -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 {};