@firebase/data-connect 0.0.2-dataconnect-preview.388b61c7e → 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 (34) hide show
  1. package/dist/index.cjs.js +146 -27
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm2017.js +145 -28
  4. package/dist/index.esm2017.js.map +1 -1
  5. package/dist/index.esm5.js +146 -23
  6. package/dist/index.esm5.js.map +1 -1
  7. package/dist/index.node.cjs.js +147 -22
  8. package/dist/index.node.cjs.js.map +1 -1
  9. package/dist/internal.d.ts +32 -5
  10. package/dist/node-esm/index.node.esm.js +145 -28
  11. package/dist/node-esm/index.node.esm.js.map +1 -1
  12. package/dist/node-esm/src/api/DataConnect.d.ts +9 -0
  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/FirebaseAuthProvider.d.ts +1 -1
  16. package/dist/node-esm/src/core/QueryManager.d.ts +1 -1
  17. package/dist/node-esm/src/core/error.d.ts +2 -1
  18. package/dist/node-esm/src/network/fetch.d.ts +1 -1
  19. package/dist/node-esm/src/network/transport/index.d.ts +1 -1
  20. package/dist/node-esm/src/network/transport/rest.d.ts +20 -9
  21. package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
  22. package/dist/private.d.ts +16 -5
  23. package/dist/public.d.ts +5 -3
  24. package/dist/src/api/DataConnect.d.ts +9 -0
  25. package/dist/src/api/index.d.ts +1 -0
  26. package/dist/src/api/query.d.ts +1 -1
  27. package/dist/src/core/FirebaseAuthProvider.d.ts +1 -1
  28. package/dist/src/core/QueryManager.d.ts +1 -1
  29. package/dist/src/core/error.d.ts +2 -1
  30. package/dist/src/network/fetch.d.ts +1 -1
  31. package/dist/src/network/transport/index.d.ts +1 -1
  32. package/dist/src/network/transport/rest.d.ts +20 -9
  33. package/dist/src/util/validateArgs.d.ts +33 -0
  34. package/package.json +10 -6
package/dist/private.d.ts CHANGED
@@ -8,7 +8,7 @@ import { FirebaseApp } from '@firebase/app';
8
8
  import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
9
9
  import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
10
10
  import { FirebaseError } from '@firebase/util';
11
- import { FirebaseOptions } from '@firebase/app';
11
+ import { FirebaseOptions } from '@firebase/app-types';
12
12
  import { LogLevelString } from '@firebase/logger';
13
13
  import { Provider } from '@firebase/component';
14
14
 
@@ -58,7 +58,9 @@ export declare class DataConnect {
58
58
  private _transportClass;
59
59
  private _transportOptions?;
60
60
  private _authTokenProvider?;
61
+ _isUsingGeneratedSdk: boolean;
61
62
  constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
63
+ _useGeneratedSdk(): void;
62
64
  _delete(): Promise<void>;
63
65
  getSettings(): ConnectorConfig;
64
66
  setInitialized(): void;
@@ -89,7 +91,7 @@ declare class DataConnectError extends FirebaseError {
89
91
  message: string);
90
92
  }
91
93
 
92
- declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
94
+ declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
93
95
 
94
96
  /**
95
97
  * DataConnectOptions including project id
@@ -233,6 +235,11 @@ export declare interface OpResult<Data> {
233
235
  fetchTime: string;
234
236
  }
235
237
 
238
+ declare interface ParsedArgs<Variables> {
239
+ dc: DataConnect;
240
+ vars: Variables;
241
+ }
242
+
236
243
  /* Excluded from this release type: parseOptions */
237
244
 
238
245
  export declare const QUERY_STR = "query";
@@ -241,7 +248,7 @@ declare class QueryManager {
241
248
  private transport;
242
249
  _queries: Map<string, TrackedQuery<unknown, unknown>>;
243
250
  constructor(transport: DataConnectTransport);
244
- track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<unknown, unknown>;
251
+ track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<Data, Variables>;
245
252
  addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
246
253
  executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
247
254
  enableEmulator(host: string, port: number): void;
@@ -361,7 +368,7 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
361
368
  * @param serializedRef ref to convert to `QueryRef`
362
369
  * @returns `QueryRef`
363
370
  */
364
- export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
371
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
365
372
 
366
373
  declare interface TrackedQuery<Data, Variables> {
367
374
  ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
@@ -370,7 +377,7 @@ declare interface TrackedQuery<Data, Variables> {
370
377
  lastError: DataConnectError | null;
371
378
  }
372
379
 
373
- export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
380
+ export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean) => DataConnectTransport;
374
381
 
375
382
  /**
376
383
  * Options to connect to emulator
@@ -381,4 +388,8 @@ export declare interface TransportOptions {
381
388
  port?: number;
382
389
  }
383
390
 
391
+ /* Excluded from this release type: validateArgs */
392
+
393
+ /* Excluded from this release type: validateDCOptions */
394
+
384
395
  export { }
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';
@@ -262,8 +262,8 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
262
262
  * @param serializedRef ref to convert to `QueryRef`
263
263
  * @returns `QueryRef`
264
264
  */
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;
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
267
  /**
268
268
  * Options to connect to emulator
269
269
  */
@@ -272,4 +272,6 @@ export declare interface TransportOptions {
272
272
  sslEnabled?: boolean;
273
273
  port?: number;
274
274
  }
275
+ /* Excluded from this release type: validateArgs */
276
+ /* Excluded from this release type: validateDCOptions */
275
277
  export {};
@@ -64,7 +64,9 @@ export declare class DataConnect {
64
64
  private _transportClass;
65
65
  private _transportOptions?;
66
66
  private _authTokenProvider?;
67
+ _isUsingGeneratedSdk: boolean;
67
68
  constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
69
+ _useGeneratedSdk(): void;
68
70
  _delete(): Promise<void>;
69
71
  getSettings(): ConnectorConfig;
70
72
  setInitialized(): void;
@@ -89,6 +91,13 @@ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
89
91
  * @param options ConnectorConfig
90
92
  */
91
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;
92
101
  /**
93
102
  * Delete DataConnect instance
94
103
  * @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
  */
@@ -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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/data-connect",
3
- "version": "0.0.2-dataconnect-preview.388b61c7e",
3
+ "version": "0.0.3-dataconnect-preview.d986d4bf2",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.node.cjs.js",
@@ -38,6 +38,7 @@
38
38
  "test:all": "npm run test:node",
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
+ "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",
41
42
  "test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/dataconnect-test-runner.ts",
42
43
  "api-report": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package data-connect --packageRoot . --typescriptDts ./dist/src/index.d.ts --rollupDts ./dist/private.d.ts --untrimmedRollupDts ./dist/internal.d.ts --publicDts ./dist/public.d.ts && yarn api-report:api-json",
43
44
  "api-report:api-json": "rm -rf temp && api-extractor run --local --verbose",
@@ -45,15 +46,18 @@
45
46
  "typings:public": "node ../../scripts/build/use_typings.js ./dist/public.d.ts"
46
47
  },
47
48
  "license": "Apache-2.0",
49
+ "peerDependencies": {
50
+ "@firebase/app": "0.10.7-dataconnect-preview.d986d4bf2"
51
+ },
48
52
  "dependencies": {
49
- "@firebase/auth-interop-types": "0.2.3-dataconnect-preview.388b61c7e",
50
- "@firebase/component": "0.6.7-dataconnect-preview.388b61c7e",
51
- "@firebase/logger": "0.4.2-dataconnect-preview.388b61c7e",
52
- "@firebase/util": "1.9.6-dataconnect-preview.388b61c7e",
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
57
  "tslib": "^2.1.0"
54
58
  },
55
59
  "devDependencies": {
56
- "@firebase/app": "0.10.3-dataconnect-preview.388b61c7e",
60
+ "@firebase/app": "0.10.7-dataconnect-preview.d986d4bf2",
57
61
  "rollup": "2.79.1",
58
62
  "rollup-plugin-typescript2": "0.31.2",
59
63
  "typescript": "4.7.4"