@firebase/data-connect 0.0.3-dataconnect-preview.d986d4bf2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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-types';
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,16 +54,18 @@ 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
66
  _isUsingGeneratedSdk: boolean;
62
- constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
67
+ private _appCheckTokenProvider?;
68
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
63
69
  _useGeneratedSdk(): void;
64
70
  _delete(): Promise<void>;
65
71
  getSettings(): ConnectorConfig;
@@ -113,18 +119,7 @@ export declare interface DataConnectSubscription<Data, Variables> {
113
119
  unsubscribe: () => void;
114
120
  }
115
121
 
116
- export declare interface DataConnectTransport {
117
- invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
118
- data: T;
119
- errors: Error[];
120
- }>;
121
- invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
122
- data: T;
123
- errors: Error[];
124
- }>;
125
- useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
126
- onTokenChanged: (token: string | null) => void;
127
- }
122
+ /* Excluded from this release type: DataConnectTransport */
128
123
 
129
124
  export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
130
125
 
@@ -142,19 +137,6 @@ export declare function executeMutation<Data, Variables>(mutationRef: MutationRe
142
137
  */
143
138
  export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
144
139
 
145
- export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
146
-
147
- export declare class FirebaseAuthProvider implements AuthTokenProvider {
148
- private _appName;
149
- private _options;
150
- private _authProvider;
151
- private _auth;
152
- constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
153
- getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
154
- addTokenChangeListener(listener: AuthTokenListener): void;
155
- removeTokenChangeListener(listener: (token: string | null) => void): void;
156
- }
157
-
158
140
  /**
159
141
  * Initialize DataConnect instance
160
142
  * @param options ConnectorConfig
@@ -197,9 +179,6 @@ export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName:
197
179
  */
198
180
  export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
199
181
 
200
- export declare interface MutationResponse<T> extends CancellableOperation<T> {
201
- }
202
-
203
182
  /**
204
183
  * Mutation Result from `executeMutation`
205
184
  */
@@ -284,9 +263,6 @@ export declare function queryRef<Data>(dcInstance: DataConnect, queryName: strin
284
263
  */
285
264
  export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
286
265
 
287
- export declare interface QueryResponse<T> extends CancellableOperation<T> {
288
- }
289
-
290
266
  /**
291
267
  * Result of `executeQuery`
292
268
  */
@@ -311,11 +287,6 @@ export declare interface RefInfo<Variables> {
311
287
  connectorConfig: DataConnectOptions;
312
288
  }
313
289
 
314
- export declare interface Sender<T> {
315
- abort: () => void;
316
- send: () => Promise<T>;
317
- }
318
-
319
290
  /**
320
291
  * Serialized Ref as a result of `QueryResult.toJSON()`
321
292
  */
@@ -377,7 +348,7 @@ declare interface TrackedQuery<Data, Variables> {
377
348
  lastError: DataConnectError | null;
378
349
  }
379
350
 
380
- export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
351
+ /* Excluded from this release type: TransportClass */
381
352
 
382
353
  /**
383
354
  * Options to connect to emulator
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-types';
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
  */
@@ -263,7 +231,7 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
263
231
  * @returns `QueryRef`
264
232
  */
265
233
  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;
234
+ /* Excluded from this release type: TransportClass */
267
235
  /**
268
236
  * Options to connect to emulator
269
237
  */
@@ -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,16 +56,18 @@ 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
68
  _isUsingGeneratedSdk: boolean;
68
- constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
69
+ private _appCheckTokenProvider?;
70
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
69
71
  _useGeneratedSdk(): void;
70
72
  _delete(): Promise<void>;
71
73
  getSettings(): ConnectorConfig;
@@ -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
+ }
@@ -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, _isUsingGen: boolean): 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, _isUsingGen?: boolean) => 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,14 @@
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?;
23
26
  private _isUsingGen;
24
27
  private _host;
25
28
  private _port;
@@ -29,9 +32,9 @@ export declare class RESTTransport implements DataConnectTransport {
29
32
  private _project;
30
33
  private _serviceName;
31
34
  private _accessToken;
32
- private _authInitialized;
35
+ private _appCheckToken;
33
36
  private _lastToken;
34
- constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
37
+ constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean);
35
38
  get endpointUrl(): string;
36
39
  useEmulator(host: string, port?: number, isSecure?: boolean): void;
37
40
  onTokenChanged(newToken: string | null): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/data-connect",
3
- "version": "0.0.3-dataconnect-preview.d986d4bf2",
3
+ "version": "0.1.0",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.node.cjs.js",
@@ -35,7 +35,7 @@
35
35
  "dev": "rollup -c -w",
36
36
  "test": "run-p --npm-path npm test:emulator",
37
37
  "test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
38
- "test:all": "npm run test:node",
38
+ "test:all": "run-p --npm-path npm lint test:unit",
39
39
  "test:browser": "karma start --single-run",
40
40
  "test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
41
41
  "test:unit": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/unit/**/*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
@@ -47,17 +47,17 @@
47
47
  },
48
48
  "license": "Apache-2.0",
49
49
  "peerDependencies": {
50
- "@firebase/app": "0.10.7-dataconnect-preview.d986d4bf2"
50
+ "@firebase/app": "0.x"
51
51
  },
52
52
  "dependencies": {
53
- "@firebase/auth-interop-types": "0.2.3-dataconnect-preview.d986d4bf2",
54
- "@firebase/component": "0.6.8-dataconnect-preview.d986d4bf2",
55
- "@firebase/logger": "0.4.2-dataconnect-preview.d986d4bf2",
56
- "@firebase/util": "1.9.7-dataconnect-preview.d986d4bf2",
53
+ "@firebase/auth-interop-types": "0.2.3",
54
+ "@firebase/component": "0.6.9",
55
+ "@firebase/logger": "0.4.2",
56
+ "@firebase/util": "1.10.0",
57
57
  "tslib": "^2.1.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@firebase/app": "0.10.7-dataconnect-preview.d986d4bf2",
60
+ "@firebase/app": "0.10.12",
61
61
  "rollup": "2.79.1",
62
62
  "rollup-plugin-typescript2": "0.31.2",
63
63
  "typescript": "4.7.4"