@firebase/data-connect 0.0.1-dataconnect-preview.f2ddc3d7b

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 (66) hide show
  1. package/dist/index.cjs.js +965 -0
  2. package/dist/index.cjs.js.map +1 -0
  3. package/dist/index.esm2017.js +942 -0
  4. package/dist/index.esm2017.js.map +1 -0
  5. package/dist/index.esm5.js +966 -0
  6. package/dist/index.esm5.js.map +1 -0
  7. package/dist/index.node.cjs.js +984 -0
  8. package/dist/index.node.cjs.js.map +1 -0
  9. package/dist/internal.d.ts +297 -0
  10. package/dist/node-esm/index.node.esm.js +937 -0
  11. package/dist/node-esm/index.node.esm.js.map +1 -0
  12. package/dist/node-esm/package.json +1 -0
  13. package/dist/node-esm/src/api/DataConnect.d.ts +70 -0
  14. package/dist/node-esm/src/api/Mutation.d.ts +36 -0
  15. package/dist/node-esm/src/api/Reference.d.ts +45 -0
  16. package/dist/node-esm/src/api/index.d.ts +22 -0
  17. package/dist/node-esm/src/api/query.d.ts +46 -0
  18. package/dist/node-esm/src/api.browser.d.ts +29 -0
  19. package/dist/node-esm/src/api.node.d.ts +17 -0
  20. package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +44 -0
  21. package/dist/node-esm/src/core/QueryManager.d.ts +36 -0
  22. package/dist/node-esm/src/core/error.d.ts +50 -0
  23. package/dist/node-esm/src/core/version.d.ts +23 -0
  24. package/dist/node-esm/src/index.d.ts +29 -0
  25. package/dist/node-esm/src/index.node.d.ts +18 -0
  26. package/dist/node-esm/src/logger.d.ts +20 -0
  27. package/dist/node-esm/src/network/fetch.d.ts +21 -0
  28. package/dist/node-esm/src/network/index.d.ts +17 -0
  29. package/dist/node-esm/src/network/transport/index.d.ts +45 -0
  30. package/dist/node-esm/src/network/transport/rest.d.ts +56 -0
  31. package/dist/node-esm/src/register.d.ts +1 -0
  32. package/dist/node-esm/src/util/encoder.d.ts +19 -0
  33. package/dist/node-esm/src/util/map.d.ts +17 -0
  34. package/dist/node-esm/src/util/url.d.ts +19 -0
  35. package/dist/node-esm/test/emulatorSeeder.d.ts +22 -0
  36. package/dist/node-esm/test/queries.test.d.ts +17 -0
  37. package/dist/node-esm/test/util.d.ts +26 -0
  38. package/dist/private.d.ts +291 -0
  39. package/dist/public.d.ts +187 -0
  40. package/dist/src/api/DataConnect.d.ts +70 -0
  41. package/dist/src/api/Mutation.d.ts +36 -0
  42. package/dist/src/api/Reference.d.ts +45 -0
  43. package/dist/src/api/index.d.ts +22 -0
  44. package/dist/src/api/query.d.ts +46 -0
  45. package/dist/src/api.browser.d.ts +29 -0
  46. package/dist/src/api.node.d.ts +17 -0
  47. package/dist/src/core/FirebaseAuthProvider.d.ts +44 -0
  48. package/dist/src/core/QueryManager.d.ts +36 -0
  49. package/dist/src/core/error.d.ts +50 -0
  50. package/dist/src/core/version.d.ts +23 -0
  51. package/dist/src/index.d.ts +29 -0
  52. package/dist/src/index.node.d.ts +18 -0
  53. package/dist/src/logger.d.ts +20 -0
  54. package/dist/src/network/fetch.d.ts +21 -0
  55. package/dist/src/network/index.d.ts +17 -0
  56. package/dist/src/network/transport/index.d.ts +45 -0
  57. package/dist/src/network/transport/rest.d.ts +56 -0
  58. package/dist/src/register.d.ts +1 -0
  59. package/dist/src/tsdoc-metadata.json +11 -0
  60. package/dist/src/util/encoder.d.ts +19 -0
  61. package/dist/src/util/map.d.ts +17 -0
  62. package/dist/src/util/url.d.ts +19 -0
  63. package/dist/test/emulatorSeeder.d.ts +22 -0
  64. package/dist/test/queries.test.d.ts +17 -0
  65. package/dist/test/util.d.ts +26 -0
  66. package/package.json +76 -0
@@ -0,0 +1,18 @@
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
+ export * from './api';
18
+ export * from './api.node';
@@ -0,0 +1,20 @@
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 { LogLevelString } from "@firebase/logger";
18
+ export declare function setLogLevel(logLevel: LogLevelString): void;
19
+ export declare function logDebug(msg: string): void;
20
+ export declare function logError(msg: string): void;
@@ -0,0 +1,21 @@
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
+ 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<{
19
+ data: T;
20
+ errors: Error[];
21
+ }>;
@@ -0,0 +1,17 @@
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
+ export * from './transport';
@@ -0,0 +1,45 @@
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 { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
18
+ import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
19
+ export interface DataConnectTransport {
20
+ invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
21
+ data: T;
22
+ errors: Error[];
23
+ }>;
24
+ invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
25
+ data: T;
26
+ errors: Error[];
27
+ }>;
28
+ useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
29
+ onTokenChanged: (token: string | null) => void;
30
+ }
31
+ export interface CancellableOperation<T> extends PromiseLike<{
32
+ data: T;
33
+ }> {
34
+ cancel: () => void;
35
+ }
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';
@@ -0,0 +1,56 @@
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 { DataConnectTransport } from '.';
18
+ import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
19
+ import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
20
+ export declare class RESTTransport implements DataConnectTransport {
21
+ private apiKey?;
22
+ private authProvider?;
23
+ private host;
24
+ private port;
25
+ private location;
26
+ private connectorName;
27
+ private secure;
28
+ private project;
29
+ private serviceName;
30
+ private accessToken;
31
+ private authInitialized_;
32
+ constructor(options: DataConnectOptions, apiKey?: string | undefined, authProvider?: AuthTokenProvider | undefined, transportOptions?: TransportOptions | undefined);
33
+ get endpointUrl(): string;
34
+ useEmulator(host: string, port?: number, isSecure?: boolean): void;
35
+ onTokenChanged(newToken: string | null): void;
36
+ getWithAuth(): Promise<string | null>;
37
+ invokeQuery: <T, U = unknown>(queryName: string, body: U) => {
38
+ then: <TResult1 = {
39
+ data: T;
40
+ errors: Error[];
41
+ }, TResult2 = never>(onfulfilled?: ((value: {
42
+ data: T;
43
+ errors: Error[];
44
+ }) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
45
+ };
46
+ invokeMutation: <T, U = unknown>(mutationName: string, body: U) => {
47
+ then: <TResult1 = {
48
+ data: T;
49
+ errors: Error[];
50
+ }, TResult2 = never>(onfulfilled?: ((value: {
51
+ data: T;
52
+ errors: Error[];
53
+ }) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
54
+ cancel: () => void;
55
+ };
56
+ }
@@ -0,0 +1 @@
1
+ export declare function registerDataConnect(variant?: string): void;
@@ -0,0 +1,19 @@
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
+ export declare type HmacImpl = (obj: unknown) => string;
18
+ export declare let encoderImpl: HmacImpl;
19
+ export declare function setEncoder(encoder: HmacImpl): void;
@@ -0,0 +1,17 @@
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
+ export declare function setIfNotExists<T>(map: Map<string, T>, key: string, val: T): void;
@@ -0,0 +1,19 @@
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 { ProjectOptions, TransportOptions } from '../api/DataConnect';
18
+ export declare function urlBuilder(projectConfig: ProjectOptions, transportOptions: TransportOptions): string;
19
+ export declare function addToken(url: string, apiKey?: string): string;
@@ -0,0 +1,22 @@
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 { ReferenceType } from '../src';
18
+ export interface SeedInfo {
19
+ type: ReferenceType;
20
+ name: string;
21
+ }
22
+ export declare function setupQueries(schema: string, seedInfoArray: SeedInfo[], skipSchema?: boolean): Promise<import("node-fetch").Response>;
@@ -0,0 +1,17 @@
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
+ export {};
@@ -0,0 +1,26 @@
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 } from '../src';
18
+ export declare const USE_EMULATOR = true;
19
+ export declare const EMULATOR_PORT: string | undefined;
20
+ export declare const CONNECTOR_NAME = "c";
21
+ export declare const LOCATION_NAME = "l";
22
+ export declare const SERVICE_NAME = "l";
23
+ export declare const PROJECT_ID = "p";
24
+ export declare function getConnectionConfig(): ConnectorConfig;
25
+ export declare const app: import("@firebase/app").FirebaseApp;
26
+ export declare function initDatabase(): import("../src").DataConnect;
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Firebase Data Connect
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { FirebaseApp } from '@firebase/app';
8
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
9
+ import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
10
+ import { FirebaseError } from '@firebase/util';
11
+ import { FirebaseOptions } from '@firebase/app';
12
+ import { LogLevelString } from '@firebase/logger';
13
+ import { Provider } from '@firebase/component';
14
+
15
+ export declare type AuthTokenListener = (token: string | null) => void;
16
+
17
+ export declare interface AuthTokenProvider {
18
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
19
+ addTokenChangeListener(listener: AuthTokenListener): void;
20
+ }
21
+
22
+ export declare interface CancellableOperation<T> extends PromiseLike<{
23
+ data: T;
24
+ }> {
25
+ cancel: () => void;
26
+ }
27
+
28
+ export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
29
+
30
+ export declare interface ConnectorConfig {
31
+ location: string;
32
+ connector: string;
33
+ service: string;
34
+ }
35
+
36
+ export declare class DataConnect {
37
+ readonly app: FirebaseApp;
38
+ private readonly dataConnectOptions;
39
+ private readonly authProvider;
40
+ _queryManager: QueryManager;
41
+ _mutationManager: MutationManager;
42
+ isEmulator: boolean;
43
+ initialized: boolean;
44
+ private _transport;
45
+ private transportClass;
46
+ private transportOptions?;
47
+ private authTokenProvider?;
48
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, authProvider: Provider<FirebaseAuthInternalName>);
49
+ _delete(): Promise<void>;
50
+ getSettings(): ConnectorConfig;
51
+ setInitialized(): void;
52
+ enableEmulator(transportOptions: TransportOptions): void;
53
+ }
54
+
55
+ /** An error returned by a DataConnect operation. */
56
+ declare class DataConnectError extends FirebaseError {
57
+ /**
58
+ * The backend error code associated with this error.
59
+ */
60
+ readonly code: DataConnectErrorCode;
61
+ /**
62
+ * A custom error description.
63
+ */
64
+ readonly message: string;
65
+ /** The stack of the error. */
66
+ readonly stack?: string;
67
+ /** @hideconstructor */
68
+ constructor(
69
+ /**
70
+ * The backend error code associated with this error.
71
+ */
72
+ code: DataConnectErrorCode,
73
+ /**
74
+ * A custom error description.
75
+ */
76
+ message: string);
77
+ }
78
+
79
+ declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error';
80
+
81
+ export declare interface DataConnectOptions extends ConnectorConfig {
82
+ projectId: string;
83
+ }
84
+
85
+ export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
86
+ ref: OperationRef<Data, Variables>;
87
+ }
88
+
89
+ export declare interface DataConnectSubscription<Data, Variables> {
90
+ userCallback: OnResultSubscription<Data, Variables>;
91
+ errCallback?: (e?: DataConnectError) => void;
92
+ unsubscribe: () => void;
93
+ }
94
+
95
+ export declare interface DataConnectTransport {
96
+ invokeQuery<T, U>(queryName: string, body?: U): PromiseLike<{
97
+ data: T;
98
+ errors: Error[];
99
+ }>;
100
+ invokeMutation<T, U>(queryName: string, body?: U): PromiseLike<{
101
+ data: T;
102
+ errors: Error[];
103
+ }>;
104
+ useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
105
+ onTokenChanged: (token: string | null) => void;
106
+ }
107
+
108
+ export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
109
+
110
+ export declare class EmulatorTokenProvider implements AuthTokenProvider {
111
+ private accessToken;
112
+ /** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */
113
+ static OWNER: string;
114
+ constructor(accessToken: string);
115
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
116
+ addTokenChangeListener(listener: AuthTokenListener): void;
117
+ removeTokenChangeListener(listener: (token: string | null) => void): void;
118
+ notifyForInvalidToken(): void;
119
+ }
120
+
121
+ export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
122
+
123
+ export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
124
+
125
+ export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
126
+
127
+ export declare class FirebaseAuthProvider implements AuthTokenProvider {
128
+ private appName;
129
+ private options;
130
+ private authProvider_;
131
+ private auth_;
132
+ constructor(appName: string, options: FirebaseOptions, authProvider_: Provider<FirebaseAuthInternalName>);
133
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
134
+ addTokenChangeListener(listener: AuthTokenListener): void;
135
+ removeTokenChangeListener(listener: (token: string | null) => void): void;
136
+ }
137
+
138
+ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
139
+
140
+ export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
141
+
142
+ export declare class MutationManager {
143
+ private transport;
144
+ private _inflight;
145
+ constructor(transport: DataConnectTransport);
146
+ executeMutation<Response, Variables>(mutationRef: MutationRef<Response, Variables>): MutationPromise<Response, Variables>;
147
+ }
148
+
149
+ export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
150
+ }
151
+
152
+ export declare interface MutationRef<Response, Variables> extends OperationRef<Response, Variables> {
153
+ refType: typeof MutationStr;
154
+ }
155
+
156
+ export declare function mutationRef<Response>(dcInstance: DataConnect, queryName: string): MutationRef<Response, undefined>;
157
+
158
+ export declare function mutationRef<Response, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): MutationRef<Response, Variables>;
159
+
160
+ export declare interface MutationResponse<T> extends CancellableOperation<T> {
161
+ }
162
+
163
+ export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
164
+ ref: MutationRef<Data, Variables>;
165
+ }
166
+
167
+ export declare const MutationStr = "mutation";
168
+
169
+ export declare type OnCompleteSubscription = () => void;
170
+
171
+ export declare type OnErrorSubscription = (err?: DataConnectError) => void;
172
+
173
+ export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
174
+
175
+ export declare interface OperationRef<_Data, Variables> {
176
+ name: string;
177
+ variables: Variables;
178
+ refType: ReferenceType;
179
+ dataConnect: DataConnect;
180
+ }
181
+
182
+ export declare interface OpResult<Data> {
183
+ data: Data;
184
+ source: DataSource;
185
+ fetchTime: string;
186
+ }
187
+
188
+ /* Excluded from this release type: parseOptions */
189
+
190
+ export declare interface ProjectOptions {
191
+ location: string;
192
+ connector: string;
193
+ service: string;
194
+ projectId: string;
195
+ }
196
+
197
+ declare class QueryManager {
198
+ private transport;
199
+ _queries: Map<string, TrackedQuery<unknown, unknown>>;
200
+ constructor(transport: DataConnectTransport);
201
+ track<Response, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Response>): TrackedQuery<unknown, unknown> | undefined;
202
+ addSubscription<Response, Variables>(queryRef: OperationRef<Response, Variables>, onResultCallback: OnResultSubscription<Response, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Response>): () => void;
203
+ executeQuery<Response, Variables>(queryRef: QueryRef<Response, Variables>): QueryPromise<Response, Variables>;
204
+ enableEmulator(host: string, port: number): void;
205
+ }
206
+
207
+ export declare interface QueryPromise<Data, Variables> extends PromiseLike<QueryResult<Data, Variables>> {
208
+ }
209
+
210
+ export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
211
+ refType: typeof QueryStr;
212
+ }
213
+
214
+ export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
215
+
216
+ export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
217
+
218
+ export declare interface QueryResponse<T> extends CancellableOperation<T> {
219
+ }
220
+
221
+ export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
222
+ ref: QueryRef<Data, Variables>;
223
+ toJSON: () => SerializedRef<Data, Variables>;
224
+ }
225
+
226
+ export declare const QueryStr = "query";
227
+
228
+ export declare type QueryUnsubscribe = () => void;
229
+
230
+ export declare type ReferenceType = typeof QueryStr | typeof MutationStr;
231
+
232
+ export declare interface RefInfo<Variables> {
233
+ name: string;
234
+ variables: Variables;
235
+ connectorConfig: DataConnectOptions;
236
+ }
237
+
238
+ export declare interface Sender<T> {
239
+ abort: () => void;
240
+ send: () => Promise<T>;
241
+ }
242
+
243
+ export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
244
+ refInfo: RefInfo<Variables>;
245
+ }
246
+
247
+ export declare function setLogLevel(logLevel: LogLevelString): void;
248
+
249
+ export declare const SOURCE_CACHE = "CACHE";
250
+
251
+ export declare const SOURCE_SERVER = "SERVER";
252
+
253
+ /**
254
+ *
255
+ * @public
256
+ * @param queryRef
257
+ * @param onResult
258
+ * @param onErr
259
+ * @param initialCache
260
+ * @returns
261
+ */
262
+ export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
263
+
264
+ export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
265
+
266
+ export declare interface SubscriptionOptions<Data, Variables> {
267
+ onNext?: OnResultSubscription<Data, Variables>;
268
+ onErr?: OnErrorSubscription;
269
+ onComplete?: OnCompleteSubscription;
270
+ }
271
+
272
+ export declare function terminate(dataConnect: DataConnect): void;
273
+
274
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
275
+
276
+ declare interface TrackedQuery<Response, Variables> {
277
+ ref: Omit<OperationRef<Response, Variables>, 'dataConnect'>;
278
+ subscriptions: Array<DataConnectSubscription<Response, Variables>>;
279
+ currentCache: OpResult<Response> | null;
280
+ lastError: DataConnectError | null;
281
+ }
282
+
283
+ export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, authProvider?: AuthTokenProvider, transportOptions?: TransportOptions) => DataConnectTransport;
284
+
285
+ export declare interface TransportOptions {
286
+ host: string;
287
+ sslEnabled?: boolean;
288
+ port?: number;
289
+ }
290
+
291
+ export { }