@firebase/data-connect 0.3.12 → 0.4.0-canary.78384d32c
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
|
@@ -18,7 +18,9 @@ import { FirebaseApp } from '@firebase/app';
|
|
|
18
18
|
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
19
19
|
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
20
20
|
import { Provider } from '@firebase/component';
|
|
21
|
-
import {
|
|
21
|
+
import { DataConnectCache } from '../cache/Cache';
|
|
22
|
+
import { InternalCacheProvider } from '../cache/CacheProvider';
|
|
23
|
+
import { QueryManager } from '../core/query/QueryManager';
|
|
22
24
|
import { CallerSdkType } from '../network';
|
|
23
25
|
import { MutationManager } from './Mutation';
|
|
24
26
|
/**
|
|
@@ -69,11 +71,24 @@ export declare class DataConnect {
|
|
|
69
71
|
_isUsingGeneratedSdk: boolean;
|
|
70
72
|
_callerSdkType: CallerSdkType;
|
|
71
73
|
private _appCheckTokenProvider?;
|
|
74
|
+
private _cacheSettings?;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
private cache?;
|
|
72
79
|
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
getCache(): DataConnectCache | undefined;
|
|
73
84
|
_useGeneratedSdk(): void;
|
|
74
85
|
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
75
86
|
_delete(): Promise<void>;
|
|
76
87
|
getSettings(): ConnectorConfig;
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
setCacheSettings(cacheSettings: CacheSettings): void;
|
|
77
92
|
setInitialized(): void;
|
|
78
93
|
enableEmulator(transportOptions: TransportOptions): void;
|
|
79
94
|
}
|
|
@@ -92,17 +107,27 @@ export declare function areTransportOptionsEqual(transportOptions1: TransportOpt
|
|
|
92
107
|
* @param sslEnabled use https
|
|
93
108
|
*/
|
|
94
109
|
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
110
|
+
export interface DataConnectSettings {
|
|
111
|
+
cacheSettings?: CacheSettings;
|
|
112
|
+
}
|
|
95
113
|
/**
|
|
96
114
|
* Initialize DataConnect instance
|
|
97
115
|
* @param options ConnectorConfig
|
|
98
116
|
*/
|
|
117
|
+
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
|
|
99
118
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
100
119
|
/**
|
|
101
120
|
* Initialize DataConnect instance
|
|
102
121
|
* @param app FirebaseApp to initialize to.
|
|
103
|
-
* @param
|
|
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
|
|
104
129
|
*/
|
|
105
|
-
export declare function getDataConnect(app: FirebaseApp,
|
|
130
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
|
|
106
131
|
/**
|
|
107
132
|
*
|
|
108
133
|
* @param dcOptions
|
|
@@ -116,3 +141,19 @@ export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
|
|
|
116
141
|
* @returns
|
|
117
142
|
*/
|
|
118
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'>;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { Extensions } from '../network';
|
|
17
18
|
import { DataConnect, DataConnectOptions } from './DataConnect';
|
|
18
19
|
export declare const QUERY_STR = "query";
|
|
19
20
|
export declare const MUTATION_STR = "mutation";
|
|
@@ -25,6 +26,7 @@ export interface OpResult<Data> {
|
|
|
25
26
|
data: Data;
|
|
26
27
|
source: DataSource;
|
|
27
28
|
fetchTime: string;
|
|
29
|
+
extensions?: Extensions;
|
|
28
30
|
}
|
|
29
31
|
export interface OperationRef<_Data, Variables> {
|
|
30
32
|
name: string;
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
export * from '../network';
|
|
18
|
-
export
|
|
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';
|
|
19
20
|
export * from './Reference';
|
|
20
21
|
export * from './Mutation';
|
|
21
22
|
export * from './query';
|
|
@@ -14,27 +14,22 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { ExecuteQueryOptions } from '../core/query/queryOptions';
|
|
18
|
+
import { DataConnectExtensionWithMaxAge } from '../network/transport';
|
|
18
19
|
import { DataConnect } from './DataConnect';
|
|
19
20
|
import { OperationRef, QUERY_STR, DataConnectResult, SerializedRef } from './Reference';
|
|
20
|
-
/**
|
|
21
|
-
* Signature for `OnResultSubscription` for `subscribe`
|
|
22
|
-
*/
|
|
23
|
-
export type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Signature for `OnErrorSubscription` for `subscribe`
|
|
26
|
-
*/
|
|
27
|
-
export type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Signature for unsubscribe from `subscribe`
|
|
30
|
-
*/
|
|
31
|
-
export type QueryUnsubscribe = () => void;
|
|
32
21
|
/**
|
|
33
22
|
* QueryRef object
|
|
34
23
|
*/
|
|
35
24
|
export interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
36
25
|
refType: typeof QUERY_STR;
|
|
37
26
|
}
|
|
27
|
+
/** @internal */
|
|
28
|
+
export type InternalQueryResult<Data, Variables> = QueryResult<Data, Variables> & Omit<DataConnectResult<Data, Variables>, 'extensions'> & {
|
|
29
|
+
extensions?: {
|
|
30
|
+
dataConnect?: DataConnectExtensionWithMaxAge[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
38
33
|
/**
|
|
39
34
|
* Result of `executeQuery`
|
|
40
35
|
*/
|
|
@@ -52,7 +47,7 @@ export interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data,
|
|
|
52
47
|
* @param queryRef query to execute.
|
|
53
48
|
* @returns `QueryPromise`
|
|
54
49
|
*/
|
|
55
|
-
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables
|
|
50
|
+
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
|
|
56
51
|
/**
|
|
57
52
|
* Execute Query
|
|
58
53
|
* @param dcInstance Data Connect instance to use.
|
|
@@ -74,15 +69,3 @@ export declare function queryRef<Data, Variables>(dcInstance: DataConnect, query
|
|
|
74
69
|
* @returns `QueryRef`
|
|
75
70
|
*/
|
|
76
71
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
|
|
77
|
-
/**
|
|
78
|
-
* `OnCompleteSubscription`
|
|
79
|
-
*/
|
|
80
|
-
export type OnCompleteSubscription = () => void;
|
|
81
|
-
/**
|
|
82
|
-
* Representation of full observer options in `subscribe`
|
|
83
|
-
*/
|
|
84
|
-
export interface SubscriptionOptions<Data, Variables> {
|
|
85
|
-
onNext?: OnResultSubscription<Data, Variables>;
|
|
86
|
-
onErr?: OnErrorSubscription;
|
|
87
|
-
onComplete?: OnCompleteSubscription;
|
|
88
|
-
}
|
|
@@ -14,21 +14,5 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Subscribe to a `QueryRef`
|
|
21
|
-
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
22
|
-
* @param observer observer object to use for subscribing.
|
|
23
|
-
* @returns `SubscriptionOptions`
|
|
24
|
-
*/
|
|
25
|
-
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
|
|
26
|
-
/**
|
|
27
|
-
* Subscribe to a `QueryRef`
|
|
28
|
-
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
29
|
-
* @param onNext Callback to call when result comes back.
|
|
30
|
-
* @param onError Callback to call when error gets thrown.
|
|
31
|
-
* @param onComplete Called when subscription completes.
|
|
32
|
-
* @returns `SubscriptionOptions`
|
|
33
|
-
*/
|
|
34
|
-
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
|
|
17
|
+
export * from './core/query/subscribe';
|
|
18
|
+
export { makeMemoryCacheProvider, CacheProvider } from './api/DataConnect';
|
|
@@ -14,4 +14,5 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export * from './core/query/subscribe';
|
|
18
|
+
export { makeMemoryCacheProvider, CacheProvider } from './api/DataConnect';
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { CacheProvider, CacheSettings, type ConnectorConfig } from '../api/DataConnect';
|
|
18
|
+
import { type AuthTokenProvider } from '../core/FirebaseAuthProvider';
|
|
19
|
+
import { InternalCacheProvider } from './CacheProvider';
|
|
20
|
+
import { InMemoryCacheProvider } from './InMemoryCacheProvider';
|
|
21
|
+
import { ResultTree } from './ResultTree';
|
|
22
|
+
export declare const Memory = "memory";
|
|
23
|
+
export type DataConnectStorage = typeof Memory;
|
|
24
|
+
/**
|
|
25
|
+
* ServerValues
|
|
26
|
+
*/
|
|
27
|
+
export interface ServerValues extends Record<string, unknown> {
|
|
28
|
+
maxAge?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class DataConnectCache {
|
|
31
|
+
private authProvider;
|
|
32
|
+
private projectId;
|
|
33
|
+
private connectorConfig;
|
|
34
|
+
private host;
|
|
35
|
+
cacheSettings: CacheSettings;
|
|
36
|
+
private cacheProvider;
|
|
37
|
+
private uid;
|
|
38
|
+
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
|
|
39
|
+
initialize(): Promise<void>;
|
|
40
|
+
getIdentifier(uid: string | null): Promise<string>;
|
|
41
|
+
initializeNewProviders(identifier: string): InternalCacheProvider;
|
|
42
|
+
containsResultTree(queryId: string): Promise<boolean>;
|
|
43
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
44
|
+
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
|
|
45
|
+
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
|
|
46
|
+
}
|
|
47
|
+
export declare class MemoryStub implements CacheProvider<'MEMORY'> {
|
|
48
|
+
type: 'MEMORY';
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
initialize(cacheId: string): InMemoryCacheProvider;
|
|
53
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { EntityDataObject } from './EntityDataObject';
|
|
18
|
+
import { ResultTree } from './ResultTree';
|
|
19
|
+
export interface InternalCacheProvider {
|
|
20
|
+
getEntityData(globalId: string): Promise<EntityDataObject>;
|
|
21
|
+
updateEntityData(entityData: EntityDataObject): Promise<void>;
|
|
22
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
23
|
+
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
|
|
24
|
+
close(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
export type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
|
|
18
|
+
export interface EntityDataObjectJson {
|
|
19
|
+
map: {
|
|
20
|
+
[key: string]: FDCScalarValue;
|
|
21
|
+
};
|
|
22
|
+
referencedFrom: string[];
|
|
23
|
+
globalID: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class EntityDataObject {
|
|
26
|
+
readonly globalID: string;
|
|
27
|
+
getServerValue(key: string): unknown;
|
|
28
|
+
private serverValues;
|
|
29
|
+
private referencedFrom;
|
|
30
|
+
constructor(globalID: string);
|
|
31
|
+
getServerValues(): {
|
|
32
|
+
[key: string]: FDCScalarValue;
|
|
33
|
+
};
|
|
34
|
+
toJSON(): EntityDataObjectJson;
|
|
35
|
+
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
|
|
36
|
+
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { InternalCacheProvider } from './CacheProvider';
|
|
18
|
+
import { EntityDataObject, EntityDataObjectJson, FDCScalarValue } from './EntityDataObject';
|
|
19
|
+
import { ImpactedQueryRefsAccumulator } from './ImpactedQueryRefsAccumulator';
|
|
20
|
+
export declare const GLOBAL_ID_KEY = "_id";
|
|
21
|
+
export declare const OBJECT_LISTS_KEY = "_objectLists";
|
|
22
|
+
export declare const REFERENCES_KEY = "_references";
|
|
23
|
+
export declare const SCALARS_KEY = "_scalars";
|
|
24
|
+
export declare const ENTITY_DATA_KEYS_KEY = "_entity_data_keys";
|
|
25
|
+
export declare class EntityNode {
|
|
26
|
+
entityData?: EntityDataObject;
|
|
27
|
+
scalars: Record<string, FDCScalarValue>;
|
|
28
|
+
references: {
|
|
29
|
+
[key: string]: EntityNode;
|
|
30
|
+
};
|
|
31
|
+
objectLists: {
|
|
32
|
+
[key: string]: EntityNode[];
|
|
33
|
+
};
|
|
34
|
+
globalId?: string;
|
|
35
|
+
entityDataKeys: Set<string>;
|
|
36
|
+
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
|
|
37
|
+
toJSON(mode: EncodingMode): Record<string, unknown>;
|
|
38
|
+
static fromJson(obj: DehydratedStubDataObject): EntityNode;
|
|
39
|
+
}
|
|
40
|
+
export interface DehydratedStubDataObject {
|
|
41
|
+
backingData?: EntityDataObjectJson;
|
|
42
|
+
globalID?: string;
|
|
43
|
+
scalars: {
|
|
44
|
+
[key: string]: FDCScalarValue;
|
|
45
|
+
};
|
|
46
|
+
references: {
|
|
47
|
+
[key: string]: DehydratedStubDataObject;
|
|
48
|
+
};
|
|
49
|
+
objectLists: {
|
|
50
|
+
[key: string]: DehydratedStubDataObject[];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare enum EncodingMode {
|
|
54
|
+
hydrated = 0,
|
|
55
|
+
dehydrated = 1
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export declare class ImpactedQueryRefsAccumulator {
|
|
18
|
+
private queryId;
|
|
19
|
+
impacted: Set<string>;
|
|
20
|
+
constructor(queryId: string);
|
|
21
|
+
add(impacted: string[]): void;
|
|
22
|
+
consumeEvents(): string[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { InternalCacheProvider } from './CacheProvider';
|
|
18
|
+
import { EntityDataObject } from './EntityDataObject';
|
|
19
|
+
import { ResultTree } from './ResultTree';
|
|
20
|
+
export declare class InMemoryCacheProvider implements InternalCacheProvider {
|
|
21
|
+
private _keyId;
|
|
22
|
+
private edos;
|
|
23
|
+
private resultTrees;
|
|
24
|
+
constructor(_keyId: string);
|
|
25
|
+
setResultTree(queryId: string, rt: ResultTree): Promise<void>;
|
|
26
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
27
|
+
updateEntityData(entityData: EntityDataObject): Promise<void>;
|
|
28
|
+
getEntityData(globalId: string): Promise<EntityDataObject>;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { EntityNode, DehydratedStubDataObject } from './EntityNode';
|
|
18
|
+
export declare class ResultTree {
|
|
19
|
+
private rootStub;
|
|
20
|
+
private maxAge;
|
|
21
|
+
readonly cachedAt: Date;
|
|
22
|
+
private _lastAccessed;
|
|
23
|
+
/**
|
|
24
|
+
* Create a {@link ResultTree} from a dehydrated JSON object.
|
|
25
|
+
* @param value The dehydrated JSON object.
|
|
26
|
+
* @returns The {@link ResultTree}.
|
|
27
|
+
*/
|
|
28
|
+
static fromJson(value: DehydratedResultTreeJson): ResultTree;
|
|
29
|
+
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
|
|
30
|
+
isStale(): boolean;
|
|
31
|
+
updateMaxAge(maxAgeInSeconds: number): void;
|
|
32
|
+
updateAccessed(): void;
|
|
33
|
+
get lastAccessed(): Date;
|
|
34
|
+
getRootStub(): EntityNode;
|
|
35
|
+
}
|
|
36
|
+
interface DehydratedResultTreeJson {
|
|
37
|
+
rootStub: DehydratedStubDataObject;
|
|
38
|
+
maxAge: number;
|
|
39
|
+
cachedAt: Date;
|
|
40
|
+
lastAccessed: Date;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { InternalCacheProvider } from './CacheProvider';
|
|
18
|
+
import { EntityNode } from './EntityNode';
|
|
19
|
+
interface DehydratedResults {
|
|
20
|
+
entityNode: EntityNode;
|
|
21
|
+
impacted: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare class ResultTreeProcessor {
|
|
24
|
+
/**
|
|
25
|
+
* Hydrate the EntityNode into a JSON object so that it can be returned to the user.
|
|
26
|
+
* @param rootStubObject
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
hydrateResults(rootStubObject: EntityNode): Record<string, unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* Dehydrate results so that they can be stored in the cache.
|
|
32
|
+
* @param json
|
|
33
|
+
* @param entityIds
|
|
34
|
+
* @param cacheProvider
|
|
35
|
+
* @param queryId
|
|
36
|
+
* @returns {Promise<DehydratedResults>}
|
|
37
|
+
*/
|
|
38
|
+
dehydrateResults(json: Record<string, unknown>, entityIds: Record<string, unknown>, cacheProvider: InternalCacheProvider, queryId: string): Promise<DehydratedResults>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 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 { OpResult } from '../api/Reference';
|
|
18
|
+
import { DataConnectExtension } from '../network';
|
|
19
|
+
export declare function parseEntityIds<T>(result: OpResult<T>): Record<string, unknown>;
|
|
20
|
+
export declare function populatePath(path: Array<string | number>, toUpdate: Record<string | number, unknown>, extension: DataConnectExtension): void;
|
|
@@ -15,11 +15,12 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { FirebaseOptions } from '@firebase/app-types';
|
|
18
|
-
import { FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
18
|
+
import { FirebaseAuthInternal, FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
19
19
|
import { Provider } from '@firebase/component';
|
|
20
20
|
export interface AuthTokenProvider {
|
|
21
21
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
22
22
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
23
|
+
getAuth(): FirebaseAuthInternal;
|
|
23
24
|
}
|
|
24
25
|
export type AuthTokenListener = (token: string | null) => void;
|
|
25
26
|
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
@@ -28,6 +29,7 @@ export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
|
28
29
|
private _authProvider;
|
|
29
30
|
private _auth;
|
|
30
31
|
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
32
|
+
getAuth(): FirebaseAuthInternal;
|
|
31
33
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
32
34
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
33
35
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { type DataConnect } from '../../api/DataConnect';
|
|
18
|
+
import { QueryRef, QueryResult } from '../../api/query';
|
|
19
|
+
import { SerializedRef, DataSource } from '../../api/Reference';
|
|
20
|
+
import { DataConnectCache } from '../../cache/Cache';
|
|
21
|
+
import { DataConnectTransport } from '../../network';
|
|
22
|
+
import { DataConnectExtensionWithMaxAge } from '../../network/transport';
|
|
23
|
+
import { OnCompleteSubscription, OnErrorSubscription, OnResultSubscription } from './subscribe';
|
|
24
|
+
export declare function getRefSerializer<Data, Variables>(queryRef: QueryRef<Data, Variables>, data: Data, source: DataSource, fetchTime: string): () => SerializedRef<Data, Variables>;
|
|
25
|
+
export declare class QueryManager {
|
|
26
|
+
private transport;
|
|
27
|
+
private dc;
|
|
28
|
+
private cache?;
|
|
29
|
+
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
|
|
30
|
+
private callbacks;
|
|
31
|
+
private subscriptionCache;
|
|
32
|
+
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
|
|
33
|
+
private queue;
|
|
34
|
+
waitForQueuedWrites(): Promise<void>;
|
|
35
|
+
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
|
|
36
|
+
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
|
|
37
|
+
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
|
|
38
|
+
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
|
|
39
|
+
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
|
|
40
|
+
publishErrorToSubscribers(key: string, err: unknown): void;
|
|
41
|
+
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
|
|
42
|
+
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
|
|
43
|
+
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
|
|
44
|
+
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
|
|
45
|
+
enableEmulator(host: string, port: number): void;
|
|
46
|
+
}
|
|
47
|
+
export declare function getMaxAgeFromExtensions(extensions: DataConnectExtensionWithMaxAge[] | undefined): number | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
export declare const QueryFetchPolicy: {
|
|
18
|
+
readonly PREFER_CACHE: "PREFER_CACHE";
|
|
19
|
+
readonly CACHE_ONLY: "CACHE_ONLY";
|
|
20
|
+
readonly SERVER_ONLY: "SERVER_ONLY";
|
|
21
|
+
};
|
|
22
|
+
export type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
|
|
23
|
+
export interface ExecuteQueryOptions {
|
|
24
|
+
fetchPolicy: QueryFetchPolicy;
|
|
25
|
+
}
|