@firebase/data-connect 0.3.12 → 0.4.0-canary.22476e1bc
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/index.cjs.js +1012 -210
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1011 -212
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +960 -158
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +311 -25
- package/dist/node-esm/index.node.esm.js +959 -160
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +44 -3
- package/dist/node-esm/src/api/Reference.d.ts +2 -0
- package/dist/node-esm/src/api/index.d.ts +2 -1
- package/dist/node-esm/src/api/query.d.ts +9 -26
- package/dist/node-esm/src/api.browser.d.ts +2 -18
- package/dist/node-esm/src/api.node.d.ts +2 -1
- 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/FirebaseAuthProvider.d.ts +3 -1
- 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/network/fetch.d.ts +2 -5
- package/dist/node-esm/src/network/index.d.ts +1 -1
- package/dist/node-esm/src/network/transport/index.d.ts +37 -8
- package/dist/node-esm/src/network/transport/rest.d.ts +5 -17
- package/dist/node-esm/src/util/encoder.d.ts +4 -1
- package/dist/node-esm/src/util/url.d.ts +1 -0
- package/dist/private.d.ts +278 -17
- package/dist/public.d.ts +77 -3
- package/dist/src/api/DataConnect.d.ts +44 -3
- package/dist/src/api/Reference.d.ts +2 -0
- package/dist/src/api/index.d.ts +2 -1
- package/dist/src/api/query.d.ts +9 -26
- package/dist/src/api.browser.d.ts +2 -18
- package/dist/src/api.node.d.ts +2 -1
- 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/FirebaseAuthProvider.d.ts +3 -1
- 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/network/fetch.d.ts +2 -5
- package/dist/src/network/index.d.ts +1 -1
- package/dist/src/network/transport/index.d.ts +37 -8
- package/dist/src/network/transport/rest.d.ts +5 -17
- package/dist/src/util/encoder.d.ts +4 -1
- package/dist/src/util/url.d.ts +1 -0
- package/package.json +7 -7
- package/dist/node-esm/src/core/QueryManager.d.ts +0 -45
- package/dist/src/core/QueryManager.d.ts +0 -45
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 { QueryRef, QueryResult } from '../../api/query';
|
|
18
|
+
import { SerializedRef } from '../../api/Reference';
|
|
19
|
+
import { DataConnectError } from '../error';
|
|
20
|
+
/**
|
|
21
|
+
* `OnCompleteSubscription`
|
|
22
|
+
*/
|
|
23
|
+
export type OnCompleteSubscription = () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Representation of full observer options in `subscribe`
|
|
26
|
+
*/
|
|
27
|
+
export interface SubscriptionOptions<Data, Variables> {
|
|
28
|
+
onNext?: OnResultSubscription<Data, Variables>;
|
|
29
|
+
onErr?: OnErrorSubscription;
|
|
30
|
+
onComplete?: OnCompleteSubscription;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Signature for `OnResultSubscription` for `subscribe`
|
|
34
|
+
*/
|
|
35
|
+
export type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Signature for `OnErrorSubscription` for `subscribe`
|
|
38
|
+
*/
|
|
39
|
+
export type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Signature for unsubscribe from `subscribe`
|
|
42
|
+
*/
|
|
43
|
+
export type QueryUnsubscribe = () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Representation of user provided subscription options.
|
|
46
|
+
*/
|
|
47
|
+
export interface DataConnectSubscription<Data, Variables> {
|
|
48
|
+
userCallback: OnResultSubscription<Data, Variables>;
|
|
49
|
+
errCallback?: (e?: DataConnectError) => void;
|
|
50
|
+
unsubscribe: () => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Subscribe to a `QueryRef`
|
|
54
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
55
|
+
* @param observer observer object to use for subscribing.
|
|
56
|
+
* @returns `SubscriptionOptions`
|
|
57
|
+
*/
|
|
58
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
59
|
+
/**
|
|
60
|
+
* Subscribe to a `QueryRef`
|
|
61
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
62
|
+
* @param onNext Callback to call when result comes back.
|
|
63
|
+
* @param onError Callback to call when error gets thrown.
|
|
64
|
+
* @param onComplete Called when subscription completes.
|
|
65
|
+
* @returns `SubscriptionOptions`
|
|
66
|
+
*/
|
|
67
|
+
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
@@ -14,14 +14,11 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { CallerSdkType } from './transport';
|
|
17
|
+
import { CallerSdkType, DataConnectResponse } from './transport';
|
|
18
18
|
export declare function initializeFetch(fetchImpl: typeof fetch): void;
|
|
19
19
|
export interface DataConnectFetchBody<T> {
|
|
20
20
|
name: string;
|
|
21
21
|
operationName: string;
|
|
22
22
|
variables: T;
|
|
23
23
|
}
|
|
24
|
-
export declare function dcFetch<T, U>(url: string, body: DataConnectFetchBody<U>, { signal }: AbortController, appId: string | null | undefined, accessToken: string | null, appCheckToken: string | null | undefined, _isUsingGen: boolean, _callerSdkType: CallerSdkType, _isUsingEmulator: boolean): Promise<
|
|
25
|
-
data: T;
|
|
26
|
-
errors: Error[];
|
|
27
|
-
}>;
|
|
24
|
+
export declare function dcFetch<T, U>(url: string, body: DataConnectFetchBody<U>, { signal }: AbortController, appId: string | null | undefined, accessToken: string | null, appCheckToken: string | null | undefined, _isUsingGen: boolean, _callerSdkType: CallerSdkType, _isUsingEmulator: boolean): Promise<DataConnectResponse<T>>;
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export { CallerSdkType, CallerSdkTypeEnum, DataConnectTransport, DataConnectEntityArray, DataConnectSingleEntity, DataConnectExtension, Extensions, TransportClass } from './transport';
|
|
@@ -30,18 +30,47 @@ export declare const CallerSdkTypeEnum: {
|
|
|
30
30
|
readonly TanstackAngularCore: "TanstackAngularCore";
|
|
31
31
|
readonly GeneratedAngular: "GeneratedAngular";
|
|
32
32
|
};
|
|
33
|
+
export interface DataConnectEntityArray {
|
|
34
|
+
entityIds: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface DataConnectSingleEntity {
|
|
37
|
+
entityId: string;
|
|
38
|
+
}
|
|
39
|
+
export type DataConnectExtension = {
|
|
40
|
+
path: Array<string | number>;
|
|
41
|
+
} & (DataConnectEntityArray | DataConnectSingleEntity);
|
|
42
|
+
/** @internal */
|
|
43
|
+
export interface DataConnectMaxAge {
|
|
44
|
+
maxAge: string;
|
|
45
|
+
}
|
|
46
|
+
/** @internal */
|
|
47
|
+
export type DataConnectExtensionWithMaxAge = {
|
|
48
|
+
path: Array<string | number>;
|
|
49
|
+
} & (DataConnectEntityArray | DataConnectSingleEntity | DataConnectMaxAge);
|
|
50
|
+
export interface Extensions {
|
|
51
|
+
dataConnect?: DataConnectExtension[];
|
|
52
|
+
}
|
|
53
|
+
/** @internal */
|
|
54
|
+
export interface ExtensionsWithMaxAge {
|
|
55
|
+
dataConnect?: DataConnectExtensionWithMaxAge[];
|
|
56
|
+
}
|
|
57
|
+
export interface DataConnectResponse<T> {
|
|
58
|
+
data: T;
|
|
59
|
+
errors: Error[];
|
|
60
|
+
extensions: Extensions;
|
|
61
|
+
}
|
|
62
|
+
/** @internal */
|
|
63
|
+
export interface DataConnectResponseWithMaxAge<T> {
|
|
64
|
+
data: T;
|
|
65
|
+
errors: Error[];
|
|
66
|
+
extensions: ExtensionsWithMaxAge;
|
|
67
|
+
}
|
|
33
68
|
/**
|
|
34
69
|
* @internal
|
|
35
70
|
*/
|
|
36
71
|
export interface DataConnectTransport {
|
|
37
|
-
invokeQuery<T, U>(queryName: string, body?: U): Promise<
|
|
38
|
-
|
|
39
|
-
errors: Error[];
|
|
40
|
-
}>;
|
|
41
|
-
invokeMutation<T, U>(queryName: string, body?: U): Promise<{
|
|
42
|
-
data: T;
|
|
43
|
-
errors: Error[];
|
|
44
|
-
}>;
|
|
72
|
+
invokeQuery<T, U>(queryName: string, body?: U): Promise<DataConnectResponseWithMaxAge<T>>;
|
|
73
|
+
invokeMutation<T, U>(queryName: string, body?: U): Promise<DataConnectResponse<T>>;
|
|
45
74
|
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
|
|
46
75
|
onTokenChanged: (token: string | null) => void;
|
|
47
76
|
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
|
|
18
18
|
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
|
|
19
19
|
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
|
|
20
|
-
import { CallerSdkType, DataConnectTransport } from '.';
|
|
20
|
+
import { CallerSdkType, DataConnectResponse, DataConnectTransport } from '.';
|
|
21
21
|
export declare class RESTTransport implements DataConnectTransport {
|
|
22
22
|
private apiKey?;
|
|
23
23
|
private appId?;
|
|
@@ -36,26 +36,14 @@ export declare class RESTTransport implements DataConnectTransport {
|
|
|
36
36
|
private _appCheckToken;
|
|
37
37
|
private _lastToken;
|
|
38
38
|
private _isUsingEmulator;
|
|
39
|
-
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: string | undefined, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType);
|
|
39
|
+
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: (string | null) | undefined, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType);
|
|
40
40
|
get endpointUrl(): string;
|
|
41
41
|
useEmulator(host: string, port?: number, isSecure?: boolean): void;
|
|
42
42
|
onTokenChanged(newToken: string | null): void;
|
|
43
43
|
getWithAuth(forceToken?: boolean): Promise<string | null>;
|
|
44
44
|
_setLastToken(lastToken: string | null): void;
|
|
45
|
-
withRetry<T>(promiseFactory: () => Promise<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}>, retry?: boolean): Promise<{
|
|
49
|
-
data: T;
|
|
50
|
-
errors: Error[];
|
|
51
|
-
}>;
|
|
52
|
-
invokeQuery: <T, U>(queryName: string, body?: U) => Promise<{
|
|
53
|
-
data: T;
|
|
54
|
-
errors: Error[];
|
|
55
|
-
}>;
|
|
56
|
-
invokeMutation: <T, U>(queryName: string, body?: U) => Promise<{
|
|
57
|
-
data: T;
|
|
58
|
-
errors: Error[];
|
|
59
|
-
}>;
|
|
45
|
+
withRetry<T>(promiseFactory: () => Promise<DataConnectResponse<T>>, retry?: boolean): Promise<DataConnectResponse<T>>;
|
|
46
|
+
invokeQuery: <T, U>(queryName: string, body?: U) => Promise<DataConnectResponse<T>>;
|
|
47
|
+
invokeMutation: <T, U>(queryName: string, body?: U) => Promise<DataConnectResponse<T>>;
|
|
60
48
|
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
61
49
|
}
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
export type HmacImpl = (obj: unknown) => string;
|
|
17
|
+
export type HmacImpl = (obj: Record<string, unknown>) => string;
|
|
18
18
|
export declare let encoderImpl: HmacImpl;
|
|
19
|
+
export type DecodeHmacImpl = (s: string) => Record<string, unknown>;
|
|
20
|
+
export declare let decoderImpl: DecodeHmacImpl;
|
|
19
21
|
export declare function setEncoder(encoder: HmacImpl): void;
|
|
22
|
+
export declare function setDecoder(decoder: DecodeHmacImpl): void;
|
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { DataConnectOptions, TransportOptions } from '../api/DataConnect';
|
|
18
|
+
export declare const PROD_HOST = "firebasedataconnect.googleapis.com";
|
|
18
19
|
export declare function urlBuilder(projectConfig: DataConnectOptions, transportOptions: TransportOptions): string;
|
|
19
20
|
export declare function addToken(url: string, apiKey?: string): string;
|
package/dist/private.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types
|
|
|
8
8
|
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
|
|
9
9
|
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
|
|
10
10
|
import { FirebaseApp } from '@firebase/app';
|
|
11
|
+
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
|
|
11
12
|
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
12
13
|
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
13
14
|
import { FirebaseError } from '@firebase/util';
|
|
@@ -23,6 +24,17 @@ declare type AuthTokenListener = (token: string | null) => void;
|
|
|
23
24
|
declare interface AuthTokenProvider {
|
|
24
25
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
25
26
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
27
|
+
getAuth(): FirebaseAuthInternal;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare interface CacheProvider<T extends StorageType> {
|
|
31
|
+
type: T;
|
|
32
|
+
/* Excluded from this release type: initialize */
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare interface CacheSettings {
|
|
36
|
+
cacheProvider: CacheProvider<StorageType>;
|
|
37
|
+
maxAgeSeconds?: number;
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
/**
|
|
@@ -89,15 +101,41 @@ export declare class DataConnect {
|
|
|
89
101
|
_isUsingGeneratedSdk: boolean;
|
|
90
102
|
_callerSdkType: CallerSdkType;
|
|
91
103
|
private _appCheckTokenProvider?;
|
|
104
|
+
private _cacheSettings?;
|
|
105
|
+
/* Excluded from this release type: cache */
|
|
92
106
|
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
107
|
+
/* Excluded from this release type: getCache */
|
|
93
108
|
_useGeneratedSdk(): void;
|
|
94
109
|
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
95
110
|
_delete(): Promise<void>;
|
|
96
111
|
getSettings(): ConnectorConfig;
|
|
112
|
+
/* Excluded from this release type: setCacheSettings */
|
|
97
113
|
setInitialized(): void;
|
|
98
114
|
enableEmulator(transportOptions: TransportOptions): void;
|
|
99
115
|
}
|
|
100
116
|
|
|
117
|
+
declare class DataConnectCache {
|
|
118
|
+
private authProvider;
|
|
119
|
+
private projectId;
|
|
120
|
+
private connectorConfig;
|
|
121
|
+
private host;
|
|
122
|
+
cacheSettings: CacheSettings;
|
|
123
|
+
private cacheProvider;
|
|
124
|
+
private uid;
|
|
125
|
+
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
|
|
126
|
+
initialize(): Promise<void>;
|
|
127
|
+
getIdentifier(uid: string | null): Promise<string>;
|
|
128
|
+
initializeNewProviders(identifier: string): InternalCacheProvider;
|
|
129
|
+
containsResultTree(queryId: string): Promise<boolean>;
|
|
130
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
131
|
+
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
|
|
132
|
+
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export declare interface DataConnectEntityArray {
|
|
136
|
+
entityIds: string[];
|
|
137
|
+
}
|
|
138
|
+
|
|
101
139
|
/** An error returned by a DataConnect operation. */
|
|
102
140
|
export declare class DataConnectError extends FirebaseError {
|
|
103
141
|
/* Excluded from this release type: name */
|
|
@@ -107,6 +145,14 @@ export declare class DataConnectError extends FirebaseError {
|
|
|
107
145
|
|
|
108
146
|
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
109
147
|
|
|
148
|
+
export declare type DataConnectExtension = {
|
|
149
|
+
path: Array<string | number>;
|
|
150
|
+
} & (DataConnectEntityArray | DataConnectSingleEntity);
|
|
151
|
+
|
|
152
|
+
/* Excluded from this release type: DataConnectExtensionWithMaxAge */
|
|
153
|
+
|
|
154
|
+
/* Excluded from this release type: DataConnectMaxAge */
|
|
155
|
+
|
|
110
156
|
/** An error returned by a DataConnect operation. */
|
|
111
157
|
export declare class DataConnectOperationError extends DataConnectError {
|
|
112
158
|
/* Excluded from this release type: name */
|
|
@@ -133,17 +179,32 @@ export declare interface DataConnectOptions extends ConnectorConfig {
|
|
|
133
179
|
projectId: string;
|
|
134
180
|
}
|
|
135
181
|
|
|
182
|
+
declare interface DataConnectResponse<T> {
|
|
183
|
+
data: T;
|
|
184
|
+
errors: Error[];
|
|
185
|
+
extensions: Extensions;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* Excluded from this release type: DataConnectResponseWithMaxAge */
|
|
189
|
+
|
|
136
190
|
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
137
191
|
ref: OperationRef<Data, Variables>;
|
|
138
192
|
}
|
|
139
193
|
|
|
194
|
+
export declare interface DataConnectSettings {
|
|
195
|
+
cacheSettings?: CacheSettings;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export declare interface DataConnectSingleEntity {
|
|
199
|
+
entityId: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
140
202
|
/**
|
|
141
203
|
* Representation of user provided subscription options.
|
|
142
204
|
*/
|
|
143
|
-
declare interface DataConnectSubscription<Data, Variables> {
|
|
205
|
+
export declare interface DataConnectSubscription<Data, Variables> {
|
|
144
206
|
userCallback: OnResultSubscription<Data, Variables>;
|
|
145
207
|
errCallback?: (e?: DataConnectError) => void;
|
|
146
|
-
onCompleteCallback?: () => void;
|
|
147
208
|
unsubscribe: () => void;
|
|
148
209
|
}
|
|
149
210
|
|
|
@@ -151,6 +212,70 @@ declare interface DataConnectSubscription<Data, Variables> {
|
|
|
151
212
|
|
|
152
213
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
153
214
|
|
|
215
|
+
declare interface DehydratedResultTreeJson {
|
|
216
|
+
rootStub: DehydratedStubDataObject;
|
|
217
|
+
maxAge: number;
|
|
218
|
+
cachedAt: Date;
|
|
219
|
+
lastAccessed: Date;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare interface DehydratedStubDataObject {
|
|
223
|
+
backingData?: EntityDataObjectJson;
|
|
224
|
+
globalID?: string;
|
|
225
|
+
scalars: {
|
|
226
|
+
[key: string]: FDCScalarValue;
|
|
227
|
+
};
|
|
228
|
+
references: {
|
|
229
|
+
[key: string]: DehydratedStubDataObject;
|
|
230
|
+
};
|
|
231
|
+
objectLists: {
|
|
232
|
+
[key: string]: DehydratedStubDataObject[];
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare enum EncodingMode {
|
|
237
|
+
hydrated = 0,
|
|
238
|
+
dehydrated = 1
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
declare class EntityDataObject {
|
|
242
|
+
readonly globalID: string;
|
|
243
|
+
getServerValue(key: string): unknown;
|
|
244
|
+
private serverValues;
|
|
245
|
+
private referencedFrom;
|
|
246
|
+
constructor(globalID: string);
|
|
247
|
+
getServerValues(): {
|
|
248
|
+
[key: string]: FDCScalarValue;
|
|
249
|
+
};
|
|
250
|
+
toJSON(): EntityDataObjectJson;
|
|
251
|
+
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
|
|
252
|
+
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare interface EntityDataObjectJson {
|
|
256
|
+
map: {
|
|
257
|
+
[key: string]: FDCScalarValue;
|
|
258
|
+
};
|
|
259
|
+
referencedFrom: string[];
|
|
260
|
+
globalID: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare class EntityNode {
|
|
264
|
+
entityData?: EntityDataObject;
|
|
265
|
+
scalars: Record<string, FDCScalarValue>;
|
|
266
|
+
references: {
|
|
267
|
+
[key: string]: EntityNode;
|
|
268
|
+
};
|
|
269
|
+
objectLists: {
|
|
270
|
+
[key: string]: EntityNode[];
|
|
271
|
+
};
|
|
272
|
+
globalId?: string;
|
|
273
|
+
entityDataKeys: Set<string>;
|
|
274
|
+
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
|
|
275
|
+
toJSON(mode: EncodingMode): Record<string, unknown>;
|
|
276
|
+
static fromJson(obj: DehydratedStubDataObject): EntityNode;
|
|
277
|
+
}
|
|
278
|
+
|
|
154
279
|
/**
|
|
155
280
|
* Execute Mutation
|
|
156
281
|
* @param mutationRef mutation to execute
|
|
@@ -163,20 +288,93 @@ export declare function executeMutation<Data, Variables>(mutationRef: MutationRe
|
|
|
163
288
|
* @param queryRef query to execute.
|
|
164
289
|
* @returns `QueryPromise`
|
|
165
290
|
*/
|
|
166
|
-
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables
|
|
291
|
+
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
|
|
292
|
+
|
|
293
|
+
export declare interface ExecuteQueryOptions {
|
|
294
|
+
fetchPolicy: QueryFetchPolicy;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export declare interface Extensions {
|
|
298
|
+
dataConnect?: DataConnectExtension[];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* Excluded from this release type: ExtensionsWithMaxAge */
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @license
|
|
305
|
+
* Copyright 2025 Google LLC
|
|
306
|
+
*
|
|
307
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
308
|
+
* you may not use this file except in compliance with the License.
|
|
309
|
+
* You may obtain a copy of the License at
|
|
310
|
+
*
|
|
311
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
312
|
+
*
|
|
313
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
314
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
315
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
316
|
+
* See the License for the specific language governing permissions and
|
|
317
|
+
* limitations under the License.
|
|
318
|
+
*/
|
|
319
|
+
declare type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
|
|
167
320
|
|
|
168
321
|
/**
|
|
169
322
|
* Initialize DataConnect instance
|
|
170
323
|
* @param options ConnectorConfig
|
|
171
324
|
*/
|
|
325
|
+
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
|
|
326
|
+
|
|
172
327
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
173
328
|
|
|
174
329
|
/**
|
|
175
330
|
* Initialize DataConnect instance
|
|
176
331
|
* @param app FirebaseApp to initialize to.
|
|
177
|
-
* @param
|
|
332
|
+
* @param connectorConfig ConnectorConfig
|
|
333
|
+
*/
|
|
334
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Initialize DataConnect instance
|
|
338
|
+
* @param app FirebaseApp to initialize to.
|
|
339
|
+
* @param connectorConfig ConnectorConfig
|
|
178
340
|
*/
|
|
179
|
-
export declare function getDataConnect(app: FirebaseApp,
|
|
341
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @license
|
|
345
|
+
* Copyright 2025 Google LLC
|
|
346
|
+
*
|
|
347
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
348
|
+
* you may not use this file except in compliance with the License.
|
|
349
|
+
* You may obtain a copy of the License at
|
|
350
|
+
*
|
|
351
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
352
|
+
*
|
|
353
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
354
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
355
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
356
|
+
* See the License for the specific language governing permissions and
|
|
357
|
+
* limitations under the License.
|
|
358
|
+
*/
|
|
359
|
+
declare class ImpactedQueryRefsAccumulator {
|
|
360
|
+
private queryId;
|
|
361
|
+
impacted: Set<string>;
|
|
362
|
+
constructor(queryId: string);
|
|
363
|
+
add(impacted: string[]): void;
|
|
364
|
+
consumeEvents(): string[];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
declare interface InternalCacheProvider {
|
|
368
|
+
getEntityData(globalId: string): Promise<EntityDataObject>;
|
|
369
|
+
updateEntityData(entityData: EntityDataObject): Promise<void>;
|
|
370
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
371
|
+
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
|
|
372
|
+
close(): void;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/* Excluded from this release type: InternalQueryResult */
|
|
376
|
+
|
|
377
|
+
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
|
|
180
378
|
|
|
181
379
|
export declare const MUTATION_STR = "mutation";
|
|
182
380
|
|
|
@@ -240,6 +438,7 @@ export declare interface OpResult<Data> {
|
|
|
240
438
|
data: Data;
|
|
241
439
|
source: DataSource;
|
|
242
440
|
fetchTime: string;
|
|
441
|
+
extensions?: Extensions;
|
|
243
442
|
}
|
|
244
443
|
|
|
245
444
|
declare interface ParsedArgs<Variables> {
|
|
@@ -251,13 +450,50 @@ declare interface ParsedArgs<Variables> {
|
|
|
251
450
|
|
|
252
451
|
export declare const QUERY_STR = "query";
|
|
253
452
|
|
|
453
|
+
/**
|
|
454
|
+
* @license
|
|
455
|
+
* Copyright 2025 Google LLC
|
|
456
|
+
*
|
|
457
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
458
|
+
* you may not use this file except in compliance with the License.
|
|
459
|
+
* You may obtain a copy of the License at
|
|
460
|
+
*
|
|
461
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
462
|
+
*
|
|
463
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
464
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
465
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
466
|
+
* See the License for the specific language governing permissions and
|
|
467
|
+
* limitations under the License.
|
|
468
|
+
*/
|
|
469
|
+
export declare const QueryFetchPolicy: {
|
|
470
|
+
readonly PREFER_CACHE: "PREFER_CACHE";
|
|
471
|
+
readonly CACHE_ONLY: "CACHE_ONLY";
|
|
472
|
+
readonly SERVER_ONLY: "SERVER_ONLY";
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
|
|
476
|
+
|
|
254
477
|
declare class QueryManager {
|
|
255
478
|
private transport;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
479
|
+
private dc;
|
|
480
|
+
private cache?;
|
|
481
|
+
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
|
|
482
|
+
private callbacks;
|
|
483
|
+
private subscriptionCache;
|
|
484
|
+
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
|
|
485
|
+
private queue;
|
|
486
|
+
waitForQueuedWrites(): Promise<void>;
|
|
487
|
+
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
|
|
488
|
+
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
|
|
489
|
+
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
|
|
490
|
+
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
|
|
491
|
+
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
|
|
492
|
+
publishErrorToSubscribers(key: string, err: unknown): void;
|
|
493
|
+
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
|
|
494
|
+
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
|
|
495
|
+
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
|
|
496
|
+
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
|
|
261
497
|
enableEmulator(host: string, port: number): void;
|
|
262
498
|
}
|
|
263
499
|
|
|
@@ -315,6 +551,25 @@ export declare interface RefInfo<Variables> {
|
|
|
315
551
|
connectorConfig: DataConnectOptions;
|
|
316
552
|
}
|
|
317
553
|
|
|
554
|
+
declare class ResultTree {
|
|
555
|
+
private rootStub;
|
|
556
|
+
private maxAge;
|
|
557
|
+
readonly cachedAt: Date;
|
|
558
|
+
private _lastAccessed;
|
|
559
|
+
/**
|
|
560
|
+
* Create a {@link ResultTree} from a dehydrated JSON object.
|
|
561
|
+
* @param value The dehydrated JSON object.
|
|
562
|
+
* @returns The {@link ResultTree}.
|
|
563
|
+
*/
|
|
564
|
+
static fromJson(value: DehydratedResultTreeJson): ResultTree;
|
|
565
|
+
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
|
|
566
|
+
isStale(): boolean;
|
|
567
|
+
updateMaxAge(maxAgeInSeconds: number): void;
|
|
568
|
+
updateAccessed(): void;
|
|
569
|
+
get lastAccessed(): Date;
|
|
570
|
+
getRootStub(): EntityNode;
|
|
571
|
+
}
|
|
572
|
+
|
|
318
573
|
/**
|
|
319
574
|
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
320
575
|
*/
|
|
@@ -322,12 +577,25 @@ export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
|
322
577
|
refInfo: RefInfo<Variables>;
|
|
323
578
|
}
|
|
324
579
|
|
|
580
|
+
/**
|
|
581
|
+
* ServerValues
|
|
582
|
+
*/
|
|
583
|
+
declare interface ServerValues extends Record<string, unknown> {
|
|
584
|
+
maxAge?: number;
|
|
585
|
+
}
|
|
586
|
+
|
|
325
587
|
export declare function setLogLevel(logLevel: LogLevelString): void;
|
|
326
588
|
|
|
327
589
|
export declare const SOURCE_CACHE = "CACHE";
|
|
328
590
|
|
|
329
591
|
export declare const SOURCE_SERVER = "SERVER";
|
|
330
592
|
|
|
593
|
+
export declare const StorageType: {
|
|
594
|
+
readonly MEMORY: "MEMORY";
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
|
|
598
|
+
|
|
331
599
|
/**
|
|
332
600
|
* Subscribe to a `QueryRef`
|
|
333
601
|
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
@@ -369,13 +637,6 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
|
369
637
|
*/
|
|
370
638
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
|
|
371
639
|
|
|
372
|
-
declare interface TrackedQuery<Data, Variables> {
|
|
373
|
-
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
374
|
-
subscriptions: Array<DataConnectSubscription<Data, Variables>>;
|
|
375
|
-
currentCache: OpResult<Data> | null;
|
|
376
|
-
lastError: DataConnectError | null;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
640
|
/* Excluded from this release type: TransportClass */
|
|
380
641
|
|
|
381
642
|
/**
|