@depup/firebase__data-connect 0.4.0-depup.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/README.md +31 -0
- package/changes.json +10 -0
- package/dist/index.cjs.js +2069 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +2039 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.node.cjs.js +2084 -0
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/internal.d.ts +748 -0
- package/dist/node-esm/index.node.esm.js +2054 -0
- package/dist/node-esm/index.node.esm.js.map +1 -0
- package/dist/node-esm/package.json +1 -0
- package/dist/node-esm/src/api/DataConnect.d.ts +159 -0
- package/dist/node-esm/src/api/Mutation.d.ts +61 -0
- package/dist/node-esm/src/api/Reference.d.ts +53 -0
- package/dist/node-esm/src/api/index.d.ts +25 -0
- package/dist/node-esm/src/api/query.d.ts +71 -0
- package/dist/node-esm/src/api.browser.d.ts +18 -0
- package/dist/node-esm/src/api.node.d.ts +18 -0
- package/dist/node-esm/src/cache/Cache.d.ts +53 -0
- package/dist/node-esm/src/cache/CacheProvider.d.ts +25 -0
- package/dist/node-esm/src/cache/EntityDataObject.d.ts +37 -0
- package/dist/node-esm/src/cache/EntityNode.d.ts +56 -0
- package/dist/node-esm/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
- package/dist/node-esm/src/cache/InMemoryCacheProvider.d.ts +30 -0
- package/dist/node-esm/src/cache/ResultTree.d.ts +42 -0
- package/dist/node-esm/src/cache/ResultTreeProcessor.d.ts +40 -0
- package/dist/node-esm/src/cache/cacheUtils.d.ts +20 -0
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +31 -0
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +36 -0
- package/dist/node-esm/src/core/error.d.ts +53 -0
- package/dist/node-esm/src/core/query/QueryManager.d.ts +47 -0
- package/dist/node-esm/src/core/query/queryOptions.d.ts +25 -0
- package/dist/node-esm/src/core/query/subscribe.d.ts +67 -0
- package/dist/node-esm/src/core/version.d.ts +23 -0
- package/dist/node-esm/src/index.d.ts +29 -0
- package/dist/node-esm/src/index.node.d.ts +18 -0
- package/dist/node-esm/src/logger.d.ts +20 -0
- package/dist/node-esm/src/network/fetch.d.ts +24 -0
- package/dist/node-esm/src/network/index.d.ts +17 -0
- package/dist/node-esm/src/network/transport/index.d.ts +81 -0
- package/dist/node-esm/src/network/transport/rest.d.ts +49 -0
- package/dist/node-esm/src/register.d.ts +1 -0
- package/dist/node-esm/src/util/encoder.d.ts +22 -0
- package/dist/node-esm/src/util/map.d.ts +17 -0
- package/dist/node-esm/src/util/url.d.ts +20 -0
- package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
- package/dist/private.d.ts +655 -0
- package/dist/public.d.ts +350 -0
- package/dist/src/api/DataConnect.d.ts +159 -0
- package/dist/src/api/Mutation.d.ts +61 -0
- package/dist/src/api/Reference.d.ts +53 -0
- package/dist/src/api/index.d.ts +25 -0
- package/dist/src/api/query.d.ts +71 -0
- package/dist/src/api.browser.d.ts +18 -0
- package/dist/src/api.node.d.ts +18 -0
- package/dist/src/cache/Cache.d.ts +53 -0
- package/dist/src/cache/CacheProvider.d.ts +25 -0
- package/dist/src/cache/EntityDataObject.d.ts +37 -0
- package/dist/src/cache/EntityNode.d.ts +56 -0
- package/dist/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
- package/dist/src/cache/InMemoryCacheProvider.d.ts +30 -0
- package/dist/src/cache/ResultTree.d.ts +42 -0
- package/dist/src/cache/ResultTreeProcessor.d.ts +40 -0
- package/dist/src/cache/cacheUtils.d.ts +20 -0
- package/dist/src/core/AppCheckTokenProvider.d.ts +31 -0
- package/dist/src/core/FirebaseAuthProvider.d.ts +36 -0
- package/dist/src/core/error.d.ts +53 -0
- package/dist/src/core/query/QueryManager.d.ts +47 -0
- package/dist/src/core/query/queryOptions.d.ts +25 -0
- package/dist/src/core/query/subscribe.d.ts +67 -0
- package/dist/src/core/version.d.ts +23 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.node.d.ts +18 -0
- package/dist/src/logger.d.ts +20 -0
- package/dist/src/network/fetch.d.ts +24 -0
- package/dist/src/network/index.d.ts +17 -0
- package/dist/src/network/transport/index.d.ts +81 -0
- package/dist/src/network/transport/rest.d.ts +49 -0
- package/dist/src/register.d.ts +1 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/util/encoder.d.ts +22 -0
- package/dist/src/util/map.d.ts +17 -0
- package/dist/src/util/url.d.ts +20 -0
- package/dist/src/util/validateArgs.d.ts +33 -0
- package/package.json +99 -0
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firebase Data Connect
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { FirebaseApp } from '@firebase/app';
|
|
7
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
8
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
9
|
+
import { Provider } from '@firebase/component';
|
|
10
|
+
import { LogLevelString } from '@firebase/logger';
|
|
11
|
+
import { FirebaseError } from '@firebase/util';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export declare interface CacheProvider<T extends StorageType> {
|
|
15
|
+
type: T;
|
|
16
|
+
}
|
|
17
|
+
export declare interface CacheSettings {
|
|
18
|
+
cacheProvider: CacheProvider<StorageType>;
|
|
19
|
+
maxAgeSeconds?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* enum representing different flavors of the SDK used by developers
|
|
23
|
+
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
|
|
24
|
+
*/
|
|
25
|
+
export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
|
|
26
|
+
export declare const CallerSdkTypeEnum: {
|
|
27
|
+
readonly Base: "Base";
|
|
28
|
+
readonly Generated: "Generated";
|
|
29
|
+
readonly TanstackReactCore: "TanstackReactCore";
|
|
30
|
+
readonly GeneratedReact: "GeneratedReact";
|
|
31
|
+
readonly TanstackAngularCore: "TanstackAngularCore";
|
|
32
|
+
readonly GeneratedAngular: "GeneratedAngular";
|
|
33
|
+
};
|
|
34
|
+
export declare type Code = DataConnectErrorCode;
|
|
35
|
+
export declare const Code: {
|
|
36
|
+
OTHER: DataConnectErrorCode;
|
|
37
|
+
ALREADY_INITIALIZED: DataConnectErrorCode;
|
|
38
|
+
NOT_INITIALIZED: DataConnectErrorCode;
|
|
39
|
+
NOT_SUPPORTED: DataConnectErrorCode;
|
|
40
|
+
INVALID_ARGUMENT: DataConnectErrorCode;
|
|
41
|
+
PARTIAL_ERROR: DataConnectErrorCode;
|
|
42
|
+
UNAUTHORIZED: DataConnectErrorCode;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Connect to the DataConnect Emulator
|
|
46
|
+
* @param dc Data Connect instance
|
|
47
|
+
* @param host host of emulator server
|
|
48
|
+
* @param port port of emulator server
|
|
49
|
+
* @param sslEnabled use https
|
|
50
|
+
*/
|
|
51
|
+
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Connector Config for calling Data Connect backend.
|
|
54
|
+
*/
|
|
55
|
+
export declare interface ConnectorConfig {
|
|
56
|
+
location: string;
|
|
57
|
+
connector: string;
|
|
58
|
+
service: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Class representing Firebase Data Connect
|
|
62
|
+
*/
|
|
63
|
+
export declare class DataConnect {
|
|
64
|
+
readonly app: FirebaseApp;
|
|
65
|
+
private readonly dataConnectOptions;
|
|
66
|
+
isEmulator: boolean;
|
|
67
|
+
/* Excluded from this release type: cache */
|
|
68
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
69
|
+
getSettings(): ConnectorConfig;
|
|
70
|
+
/* Excluded from this release type: setCacheSettings */
|
|
71
|
+
setInitialized(): void;
|
|
72
|
+
enableEmulator(transportOptions: TransportOptions): void;
|
|
73
|
+
}
|
|
74
|
+
export declare interface DataConnectEntityArray {
|
|
75
|
+
entityIds: string[];
|
|
76
|
+
}
|
|
77
|
+
/** An error returned by a DataConnect operation. */
|
|
78
|
+
export declare class DataConnectError extends FirebaseError {
|
|
79
|
+
/* Excluded from this release type: name */
|
|
80
|
+
constructor(code: Code, message: string);
|
|
81
|
+
}
|
|
82
|
+
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
83
|
+
export declare type DataConnectExtension = {
|
|
84
|
+
path: Array<string | number>;
|
|
85
|
+
} & (DataConnectEntityArray | DataConnectSingleEntity);
|
|
86
|
+
/* Excluded from this release type: DataConnectExtensionWithMaxAge */
|
|
87
|
+
/* Excluded from this release type: DataConnectMaxAge */
|
|
88
|
+
/** An error returned by a DataConnect operation. */
|
|
89
|
+
export declare class DataConnectOperationError extends DataConnectError {
|
|
90
|
+
/* Excluded from this release type: name */
|
|
91
|
+
/** The response received from the backend. */
|
|
92
|
+
readonly response: DataConnectOperationFailureResponse;
|
|
93
|
+
private constructor();
|
|
94
|
+
}
|
|
95
|
+
export declare interface DataConnectOperationFailureResponse {
|
|
96
|
+
readonly data?: Record<string, unknown> | null;
|
|
97
|
+
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
|
|
98
|
+
}
|
|
99
|
+
export declare interface DataConnectOperationFailureResponseErrorInfo {
|
|
100
|
+
readonly message: string;
|
|
101
|
+
readonly path: Array<string | number>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* DataConnectOptions including project id
|
|
105
|
+
*/
|
|
106
|
+
export declare interface DataConnectOptions extends ConnectorConfig {
|
|
107
|
+
projectId: string;
|
|
108
|
+
}
|
|
109
|
+
/* Excluded from this release type: DataConnectResponseWithMaxAge */
|
|
110
|
+
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
111
|
+
ref: OperationRef<Data, Variables>;
|
|
112
|
+
}
|
|
113
|
+
export declare interface DataConnectSettings {
|
|
114
|
+
cacheSettings?: CacheSettings;
|
|
115
|
+
}
|
|
116
|
+
export declare interface DataConnectSingleEntity {
|
|
117
|
+
entityId: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Representation of user provided subscription options.
|
|
121
|
+
*/
|
|
122
|
+
export declare interface DataConnectSubscription<Data, Variables> {
|
|
123
|
+
userCallback: OnResultSubscription<Data, Variables>;
|
|
124
|
+
errCallback?: (e?: DataConnectError) => void;
|
|
125
|
+
unsubscribe: () => void;
|
|
126
|
+
}
|
|
127
|
+
/* Excluded from this release type: DataConnectTransport */
|
|
128
|
+
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
129
|
+
/**
|
|
130
|
+
* Execute Mutation
|
|
131
|
+
* @param mutationRef mutation to execute
|
|
132
|
+
* @returns `MutationRef`
|
|
133
|
+
*/
|
|
134
|
+
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
135
|
+
/**
|
|
136
|
+
* Execute Query
|
|
137
|
+
* @param queryRef query to execute.
|
|
138
|
+
* @returns `QueryPromise`
|
|
139
|
+
*/
|
|
140
|
+
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
|
|
141
|
+
export declare interface ExecuteQueryOptions {
|
|
142
|
+
fetchPolicy: QueryFetchPolicy;
|
|
143
|
+
}
|
|
144
|
+
export declare interface Extensions {
|
|
145
|
+
dataConnect?: DataConnectExtension[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Initialize DataConnect instance
|
|
149
|
+
* @param options ConnectorConfig
|
|
150
|
+
*/
|
|
151
|
+
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
|
|
152
|
+
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
153
|
+
/**
|
|
154
|
+
* Initialize DataConnect instance
|
|
155
|
+
* @param app FirebaseApp to initialize to.
|
|
156
|
+
* @param connectorConfig ConnectorConfig
|
|
157
|
+
*/
|
|
158
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
|
|
159
|
+
/**
|
|
160
|
+
* Initialize DataConnect instance
|
|
161
|
+
* @param app FirebaseApp to initialize to.
|
|
162
|
+
* @param connectorConfig ConnectorConfig
|
|
163
|
+
*/
|
|
164
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
|
|
165
|
+
/* Excluded from this release type: InternalQueryResult */
|
|
166
|
+
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
|
|
167
|
+
export declare const MUTATION_STR = "mutation";
|
|
168
|
+
/* Excluded from this release type: MutationManager */
|
|
169
|
+
/**
|
|
170
|
+
* Mutation return value from `executeMutation`
|
|
171
|
+
*/
|
|
172
|
+
export declare interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
|
|
173
|
+
}
|
|
174
|
+
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
175
|
+
refType: typeof MUTATION_STR;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Creates a `MutationRef`
|
|
179
|
+
* @param dcInstance Data Connect instance
|
|
180
|
+
* @param mutationName name of mutation
|
|
181
|
+
*/
|
|
182
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
* @param dcInstance Data Connect instance
|
|
186
|
+
* @param mutationName name of mutation
|
|
187
|
+
* @param variables variables to send with mutation
|
|
188
|
+
*/
|
|
189
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
190
|
+
/**
|
|
191
|
+
* Mutation Result from `executeMutation`
|
|
192
|
+
*/
|
|
193
|
+
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
194
|
+
ref: MutationRef<Data, Variables>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* `OnCompleteSubscription`
|
|
198
|
+
*/
|
|
199
|
+
export declare type OnCompleteSubscription = () => void;
|
|
200
|
+
/**
|
|
201
|
+
* Signature for `OnErrorSubscription` for `subscribe`
|
|
202
|
+
*/
|
|
203
|
+
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
204
|
+
/**
|
|
205
|
+
* Signature for `OnResultSubscription` for `subscribe`
|
|
206
|
+
*/
|
|
207
|
+
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
208
|
+
export declare interface OperationRef<_Data, Variables> {
|
|
209
|
+
name: string;
|
|
210
|
+
variables: Variables;
|
|
211
|
+
refType: ReferenceType;
|
|
212
|
+
dataConnect: DataConnect;
|
|
213
|
+
}
|
|
214
|
+
export declare interface OpResult<Data> {
|
|
215
|
+
data: Data;
|
|
216
|
+
source: DataSource;
|
|
217
|
+
fetchTime: string;
|
|
218
|
+
extensions?: Extensions;
|
|
219
|
+
}
|
|
220
|
+
/* Excluded from this release type: parseOptions */
|
|
221
|
+
export declare const QUERY_STR = "query";
|
|
222
|
+
/**
|
|
223
|
+
* @license
|
|
224
|
+
* Copyright 2025 Google LLC
|
|
225
|
+
*
|
|
226
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
227
|
+
* you may not use this file except in compliance with the License.
|
|
228
|
+
* You may obtain a copy of the License at
|
|
229
|
+
*
|
|
230
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
231
|
+
*
|
|
232
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
233
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
234
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
235
|
+
* See the License for the specific language governing permissions and
|
|
236
|
+
* limitations under the License.
|
|
237
|
+
*/
|
|
238
|
+
export declare const QueryFetchPolicy: {
|
|
239
|
+
readonly PREFER_CACHE: "PREFER_CACHE";
|
|
240
|
+
readonly CACHE_ONLY: "CACHE_ONLY";
|
|
241
|
+
readonly SERVER_ONLY: "SERVER_ONLY";
|
|
242
|
+
};
|
|
243
|
+
export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
|
|
244
|
+
/**
|
|
245
|
+
* Promise returned from `executeQuery`
|
|
246
|
+
*/
|
|
247
|
+
export declare interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* QueryRef object
|
|
251
|
+
*/
|
|
252
|
+
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
253
|
+
refType: typeof QUERY_STR;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Execute Query
|
|
257
|
+
* @param dcInstance Data Connect instance to use.
|
|
258
|
+
* @param queryName Query to execute
|
|
259
|
+
* @returns `QueryRef`
|
|
260
|
+
*/
|
|
261
|
+
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
262
|
+
/**
|
|
263
|
+
* Execute Query
|
|
264
|
+
* @param dcInstance Data Connect instance to use.
|
|
265
|
+
* @param queryName Query to execute
|
|
266
|
+
* @param variables Variables to execute with
|
|
267
|
+
* @returns `QueryRef`
|
|
268
|
+
*/
|
|
269
|
+
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
|
|
270
|
+
/**
|
|
271
|
+
* Result of `executeQuery`
|
|
272
|
+
*/
|
|
273
|
+
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
274
|
+
ref: QueryRef<Data, Variables>;
|
|
275
|
+
toJSON: () => SerializedRef<Data, Variables>;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Signature for unsubscribe from `subscribe`
|
|
279
|
+
*/
|
|
280
|
+
export declare type QueryUnsubscribe = () => void;
|
|
281
|
+
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
282
|
+
/**
|
|
283
|
+
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
|
|
284
|
+
*/
|
|
285
|
+
export declare interface RefInfo<Variables> {
|
|
286
|
+
name: string;
|
|
287
|
+
variables: Variables;
|
|
288
|
+
connectorConfig: DataConnectOptions;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
292
|
+
*/
|
|
293
|
+
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
294
|
+
refInfo: RefInfo<Variables>;
|
|
295
|
+
}
|
|
296
|
+
export declare function setLogLevel(logLevel: LogLevelString): void;
|
|
297
|
+
export declare const SOURCE_CACHE = "CACHE";
|
|
298
|
+
export declare const SOURCE_SERVER = "SERVER";
|
|
299
|
+
export declare const StorageType: {
|
|
300
|
+
readonly MEMORY: "MEMORY";
|
|
301
|
+
};
|
|
302
|
+
export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
|
|
303
|
+
/**
|
|
304
|
+
* Subscribe to a `QueryRef`
|
|
305
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
306
|
+
* @param observer observer object to use for subscribing.
|
|
307
|
+
* @returns `SubscriptionOptions`
|
|
308
|
+
*/
|
|
309
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
310
|
+
/**
|
|
311
|
+
* Subscribe to a `QueryRef`
|
|
312
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
313
|
+
* @param onNext Callback to call when result comes back.
|
|
314
|
+
* @param onError Callback to call when error gets thrown.
|
|
315
|
+
* @param onComplete Called when subscription completes.
|
|
316
|
+
* @returns `SubscriptionOptions`
|
|
317
|
+
*/
|
|
318
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
319
|
+
/**
|
|
320
|
+
* Representation of full observer options in `subscribe`
|
|
321
|
+
*/
|
|
322
|
+
export declare interface SubscriptionOptions<Data, Variables> {
|
|
323
|
+
onNext?: OnResultSubscription<Data, Variables>;
|
|
324
|
+
onErr?: OnErrorSubscription;
|
|
325
|
+
onComplete?: OnCompleteSubscription;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Delete DataConnect instance
|
|
329
|
+
* @param dataConnect DataConnect instance
|
|
330
|
+
* @returns
|
|
331
|
+
*/
|
|
332
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Converts serialized ref to query ref
|
|
335
|
+
* @param serializedRef ref to convert to `QueryRef`
|
|
336
|
+
* @returns `QueryRef`
|
|
337
|
+
*/
|
|
338
|
+
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
|
|
339
|
+
/* Excluded from this release type: TransportClass */
|
|
340
|
+
/**
|
|
341
|
+
* Options to connect to emulator
|
|
342
|
+
*/
|
|
343
|
+
export declare interface TransportOptions {
|
|
344
|
+
host: string;
|
|
345
|
+
sslEnabled?: boolean;
|
|
346
|
+
port?: number;
|
|
347
|
+
}
|
|
348
|
+
/* Excluded from this release type: validateArgs */
|
|
349
|
+
/* Excluded from this release type: validateDCOptions */
|
|
350
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
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 { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
19
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
20
|
+
import { Provider } from '@firebase/component';
|
|
21
|
+
import { DataConnectCache } from '../cache/Cache';
|
|
22
|
+
import { InternalCacheProvider } from '../cache/CacheProvider';
|
|
23
|
+
import { QueryManager } from '../core/query/QueryManager';
|
|
24
|
+
import { CallerSdkType } from '../network';
|
|
25
|
+
import { MutationManager } from './Mutation';
|
|
26
|
+
/**
|
|
27
|
+
* Connector Config for calling Data Connect backend.
|
|
28
|
+
*/
|
|
29
|
+
export interface ConnectorConfig {
|
|
30
|
+
location: string;
|
|
31
|
+
connector: string;
|
|
32
|
+
service: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options to connect to emulator
|
|
36
|
+
*/
|
|
37
|
+
export interface TransportOptions {
|
|
38
|
+
host: string;
|
|
39
|
+
sslEnabled?: boolean;
|
|
40
|
+
port?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param fullHost
|
|
45
|
+
* @returns TransportOptions
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseOptions(fullHost: string): TransportOptions;
|
|
49
|
+
/**
|
|
50
|
+
* DataConnectOptions including project id
|
|
51
|
+
*/
|
|
52
|
+
export interface DataConnectOptions extends ConnectorConfig {
|
|
53
|
+
projectId: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Class representing Firebase Data Connect
|
|
57
|
+
*/
|
|
58
|
+
export declare class DataConnect {
|
|
59
|
+
readonly app: FirebaseApp;
|
|
60
|
+
private readonly dataConnectOptions;
|
|
61
|
+
private readonly _authProvider;
|
|
62
|
+
private readonly _appCheckProvider;
|
|
63
|
+
_queryManager: QueryManager;
|
|
64
|
+
_mutationManager: MutationManager;
|
|
65
|
+
isEmulator: boolean;
|
|
66
|
+
_initialized: boolean;
|
|
67
|
+
private _transport;
|
|
68
|
+
private _transportClass;
|
|
69
|
+
private _transportOptions?;
|
|
70
|
+
private _authTokenProvider?;
|
|
71
|
+
_isUsingGeneratedSdk: boolean;
|
|
72
|
+
_callerSdkType: CallerSdkType;
|
|
73
|
+
private _appCheckTokenProvider?;
|
|
74
|
+
private _cacheSettings?;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
private cache?;
|
|
79
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
getCache(): DataConnectCache | undefined;
|
|
84
|
+
_useGeneratedSdk(): void;
|
|
85
|
+
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
86
|
+
_delete(): Promise<void>;
|
|
87
|
+
getSettings(): ConnectorConfig;
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
setCacheSettings(cacheSettings: CacheSettings): void;
|
|
92
|
+
setInitialized(): void;
|
|
93
|
+
enableEmulator(transportOptions: TransportOptions): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
* @param transportOptions1
|
|
98
|
+
* @param transportOptions2
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
export declare function areTransportOptionsEqual(transportOptions1: TransportOptions, transportOptions2: TransportOptions): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Connect to the DataConnect Emulator
|
|
104
|
+
* @param dc Data Connect instance
|
|
105
|
+
* @param host host of emulator server
|
|
106
|
+
* @param port port of emulator server
|
|
107
|
+
* @param sslEnabled use https
|
|
108
|
+
*/
|
|
109
|
+
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
110
|
+
export interface DataConnectSettings {
|
|
111
|
+
cacheSettings?: CacheSettings;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Initialize DataConnect instance
|
|
115
|
+
* @param options ConnectorConfig
|
|
116
|
+
*/
|
|
117
|
+
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
|
|
118
|
+
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
119
|
+
/**
|
|
120
|
+
* Initialize DataConnect instance
|
|
121
|
+
* @param app FirebaseApp to initialize to.
|
|
122
|
+
* @param connectorConfig ConnectorConfig
|
|
123
|
+
*/
|
|
124
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
|
|
125
|
+
/**
|
|
126
|
+
* Initialize DataConnect instance
|
|
127
|
+
* @param app FirebaseApp to initialize to.
|
|
128
|
+
* @param connectorConfig ConnectorConfig
|
|
129
|
+
*/
|
|
130
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* @param dcOptions
|
|
134
|
+
* @returns {void}
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Delete DataConnect instance
|
|
140
|
+
* @param dataConnect DataConnect instance
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
144
|
+
export declare const StorageType: {
|
|
145
|
+
readonly MEMORY: "MEMORY";
|
|
146
|
+
};
|
|
147
|
+
export type StorageType = (typeof StorageType)[keyof typeof StorageType];
|
|
148
|
+
export interface CacheSettings {
|
|
149
|
+
cacheProvider: CacheProvider<StorageType>;
|
|
150
|
+
maxAgeSeconds?: number;
|
|
151
|
+
}
|
|
152
|
+
export interface CacheProvider<T extends StorageType> {
|
|
153
|
+
type: T;
|
|
154
|
+
/**
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
initialize(cacheId: string): InternalCacheProvider;
|
|
158
|
+
}
|
|
159
|
+
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 '../network/transport';
|
|
18
|
+
import { DataConnect } from './DataConnect';
|
|
19
|
+
import { DataConnectResult, MUTATION_STR, OperationRef } from './Reference';
|
|
20
|
+
export interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
21
|
+
refType: typeof MUTATION_STR;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a `MutationRef`
|
|
25
|
+
* @param dcInstance Data Connect instance
|
|
26
|
+
* @param mutationName name of mutation
|
|
27
|
+
*/
|
|
28
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param dcInstance Data Connect instance
|
|
32
|
+
* @param mutationName name of mutation
|
|
33
|
+
* @param variables variables to send with mutation
|
|
34
|
+
*/
|
|
35
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare class MutationManager {
|
|
40
|
+
private _transport;
|
|
41
|
+
private _inflight;
|
|
42
|
+
constructor(_transport: DataConnectTransport);
|
|
43
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mutation Result from `executeMutation`
|
|
47
|
+
*/
|
|
48
|
+
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
49
|
+
ref: MutationRef<Data, Variables>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mutation return value from `executeMutation`
|
|
53
|
+
*/
|
|
54
|
+
export interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Execute Mutation
|
|
58
|
+
* @param mutationRef mutation to execute
|
|
59
|
+
* @returns `MutationRef`
|
|
60
|
+
*/
|
|
61
|
+
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { Extensions } from '../network';
|
|
18
|
+
import { DataConnect, DataConnectOptions } from './DataConnect';
|
|
19
|
+
export declare const QUERY_STR = "query";
|
|
20
|
+
export declare const MUTATION_STR = "mutation";
|
|
21
|
+
export type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
22
|
+
export declare const SOURCE_SERVER = "SERVER";
|
|
23
|
+
export declare const SOURCE_CACHE = "CACHE";
|
|
24
|
+
export type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
25
|
+
export interface OpResult<Data> {
|
|
26
|
+
data: Data;
|
|
27
|
+
source: DataSource;
|
|
28
|
+
fetchTime: string;
|
|
29
|
+
extensions?: Extensions;
|
|
30
|
+
}
|
|
31
|
+
export interface OperationRef<_Data, Variables> {
|
|
32
|
+
name: string;
|
|
33
|
+
variables: Variables;
|
|
34
|
+
refType: ReferenceType;
|
|
35
|
+
dataConnect: DataConnect;
|
|
36
|
+
}
|
|
37
|
+
export interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
38
|
+
ref: OperationRef<Data, Variables>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
|
|
42
|
+
*/
|
|
43
|
+
export interface RefInfo<Variables> {
|
|
44
|
+
name: string;
|
|
45
|
+
variables: Variables;
|
|
46
|
+
connectorConfig: DataConnectOptions;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
50
|
+
*/
|
|
51
|
+
export interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
52
|
+
refInfo: RefInfo<Variables>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 '../network';
|
|
18
|
+
export { ExecuteQueryOptions, QueryFetchPolicy } from '../core/query/queryOptions';
|
|
19
|
+
export { CacheSettings, validateDCOptions, ConnectorConfig, DataConnect, DataConnectOptions, DataConnectSettings, StorageType, TransportOptions, areTransportOptionsEqual, connectDataConnectEmulator, getDataConnect, parseOptions, terminate } from './DataConnect';
|
|
20
|
+
export * from './Reference';
|
|
21
|
+
export * from './Mutation';
|
|
22
|
+
export * from './query';
|
|
23
|
+
export { setLogLevel } from '../logger';
|
|
24
|
+
export { validateArgs } from '../util/validateArgs';
|
|
25
|
+
export { DataConnectErrorCode, Code, DataConnectError, DataConnectOperationError, DataConnectOperationFailureResponse, DataConnectOperationFailureResponseErrorInfo } from '../core/error';
|