Initial Commit

This commit is contained in:
2026-03-06 04:54:20 -04:00
commit 63677bfcf5
9332 changed files with 1507319 additions and 0 deletions

5
node_modules/@firebase/data-connect/README.md generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# Firebase Data Connect
## Local Development
Check `test/dataconnect.yaml` to ensure that the correct values are filled in.

2069
node_modules/@firebase/data-connect/dist/index.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2039
node_modules/@firebase/data-connect/dist/index.esm.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

748
node_modules/@firebase/data-connect/dist/internal.d.ts generated vendored Normal file
View File

@@ -0,0 +1,748 @@
/**
* Firebase Data Connect
*
* @packageDocumentation
*/
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { FirebaseApp } from '@firebase/app';
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { FirebaseError } from '@firebase/util';
import { LogLevelString } from '@firebase/logger';
import { Provider } from '@firebase/component';
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
declare class AppCheckTokenProvider {
private appCheckProvider?;
private appCheck?;
private serverAppAppCheckToken?;
constructor(app: FirebaseApp, appCheckProvider?: Provider<AppCheckInternalComponentName> | undefined);
getToken(): Promise<AppCheckTokenResult | null>;
addTokenChangeListener(listener: AppCheckTokenListener): void;
}
/**
* @internal
* @param transportOptions1
* @param transportOptions2
* @returns
*/
export declare function areTransportOptionsEqual(transportOptions1: TransportOptions, transportOptions2: TransportOptions): boolean;
declare type AuthTokenListener = (token: string | null) => void;
declare interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
getAuth(): FirebaseAuthInternal;
}
export declare interface CacheProvider<T extends StorageType> {
type: T;
/**
* @internal
*/
initialize(cacheId: string): InternalCacheProvider;
}
export declare interface CacheSettings {
cacheProvider: CacheProvider<StorageType>;
maxAgeSeconds?: number;
}
/**
* enum representing different flavors of the SDK used by developers
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
*/
export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
export declare const CallerSdkTypeEnum: {
readonly Base: "Base";
readonly Generated: "Generated";
readonly TanstackReactCore: "TanstackReactCore";
readonly GeneratedReact: "GeneratedReact";
readonly TanstackAngularCore: "TanstackAngularCore";
readonly GeneratedAngular: "GeneratedAngular";
};
export declare type Code = DataConnectErrorCode;
export declare const Code: {
OTHER: DataConnectErrorCode;
ALREADY_INITIALIZED: DataConnectErrorCode;
NOT_INITIALIZED: DataConnectErrorCode;
NOT_SUPPORTED: DataConnectErrorCode;
INVALID_ARGUMENT: DataConnectErrorCode;
PARTIAL_ERROR: DataConnectErrorCode;
UNAUTHORIZED: DataConnectErrorCode;
};
/**
* Connect to the DataConnect Emulator
* @param dc Data Connect instance
* @param host host of emulator server
* @param port port of emulator server
* @param sslEnabled use https
*/
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
/**
* Connector Config for calling Data Connect backend.
*/
export declare interface ConnectorConfig {
location: string;
connector: string;
service: string;
}
/**
* Class representing Firebase Data Connect
*/
export declare class DataConnect {
readonly app: FirebaseApp;
private readonly dataConnectOptions;
private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
_initialized: boolean;
private _transport;
private _transportClass;
private _transportOptions?;
private _authTokenProvider?;
_isUsingGeneratedSdk: boolean;
_callerSdkType: CallerSdkType;
private _appCheckTokenProvider?;
private _cacheSettings?;
/**
* @internal
*/
private cache?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
/**
* @internal
*/
getCache(): DataConnectCache | undefined;
_useGeneratedSdk(): void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
_delete(): Promise<void>;
getSettings(): ConnectorConfig;
/**
* @internal
*/
setCacheSettings(cacheSettings: CacheSettings): void;
setInitialized(): void;
enableEmulator(transportOptions: TransportOptions): void;
}
declare class DataConnectCache {
private authProvider;
private projectId;
private connectorConfig;
private host;
cacheSettings: CacheSettings;
private cacheProvider;
private uid;
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
initialize(): Promise<void>;
getIdentifier(uid: string | null): Promise<string>;
initializeNewProviders(identifier: string): InternalCacheProvider;
containsResultTree(queryId: string): Promise<boolean>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
}
export declare interface DataConnectEntityArray {
entityIds: string[];
}
/** An error returned by a DataConnect operation. */
export declare class DataConnectError extends FirebaseError {
/** @internal */
readonly name: string;
constructor(code: Code, message: string);
/** @internal */
toString(): string;
}
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
export declare type DataConnectExtension = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity);
/** @internal */
declare type DataConnectExtensionWithMaxAge = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity | DataConnectMaxAge);
/** @internal */
declare interface DataConnectMaxAge {
maxAge: string;
}
/** An error returned by a DataConnect operation. */
export declare class DataConnectOperationError extends DataConnectError {
/** @internal */
readonly name: string;
/** The response received from the backend. */
readonly response: DataConnectOperationFailureResponse;
/** @hideconstructor */
constructor(message: string, response: DataConnectOperationFailureResponse);
}
export declare interface DataConnectOperationFailureResponse {
readonly data?: Record<string, unknown> | null;
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
}
export declare interface DataConnectOperationFailureResponseErrorInfo {
readonly message: string;
readonly path: Array<string | number>;
}
/**
* DataConnectOptions including project id
*/
export declare interface DataConnectOptions extends ConnectorConfig {
projectId: string;
}
declare interface DataConnectResponse<T> {
data: T;
errors: Error[];
extensions: Extensions;
}
/** @internal */
declare interface DataConnectResponseWithMaxAge<T> {
data: T;
errors: Error[];
extensions: ExtensionsWithMaxAge;
}
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
ref: OperationRef<Data, Variables>;
}
export declare interface DataConnectSettings {
cacheSettings?: CacheSettings;
}
export declare interface DataConnectSingleEntity {
entityId: string;
}
/**
* Representation of user provided subscription options.
*/
export declare interface DataConnectSubscription<Data, Variables> {
userCallback: OnResultSubscription<Data, Variables>;
errCallback?: (e?: DataConnectError) => void;
unsubscribe: () => void;
}
/**
* @internal
*/
export declare interface DataConnectTransport {
invokeQuery<T, U>(queryName: string, body?: U): Promise<DataConnectResponseWithMaxAge<T>>;
invokeMutation<T, U>(queryName: string, body?: U): Promise<DataConnectResponse<T>>;
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
onTokenChanged: (token: string | null) => void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
}
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
declare interface DehydratedResultTreeJson {
rootStub: DehydratedStubDataObject;
maxAge: number;
cachedAt: Date;
lastAccessed: Date;
}
declare interface DehydratedStubDataObject {
backingData?: EntityDataObjectJson;
globalID?: string;
scalars: {
[key: string]: FDCScalarValue;
};
references: {
[key: string]: DehydratedStubDataObject;
};
objectLists: {
[key: string]: DehydratedStubDataObject[];
};
}
declare enum EncodingMode {
hydrated = 0,
dehydrated = 1
}
declare class EntityDataObject {
readonly globalID: string;
getServerValue(key: string): unknown;
private serverValues;
private referencedFrom;
constructor(globalID: string);
getServerValues(): {
[key: string]: FDCScalarValue;
};
toJSON(): EntityDataObjectJson;
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
}
declare interface EntityDataObjectJson {
map: {
[key: string]: FDCScalarValue;
};
referencedFrom: string[];
globalID: string;
}
declare class EntityNode {
entityData?: EntityDataObject;
scalars: Record<string, FDCScalarValue>;
references: {
[key: string]: EntityNode;
};
objectLists: {
[key: string]: EntityNode[];
};
globalId?: string;
entityDataKeys: Set<string>;
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
toJSON(mode: EncodingMode): Record<string, unknown>;
static fromJson(obj: DehydratedStubDataObject): EntityNode;
}
/**
* Execute Mutation
* @param mutationRef mutation to execute
* @returns `MutationRef`
*/
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
/**
* Execute Query
* @param queryRef query to execute.
* @returns `QueryPromise`
*/
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
export declare interface ExecuteQueryOptions {
fetchPolicy: QueryFetchPolicy;
}
export declare interface Extensions {
dataConnect?: DataConnectExtension[];
}
/** @internal */
declare interface ExtensionsWithMaxAge {
dataConnect?: DataConnectExtensionWithMaxAge[];
}
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
/**
* Initialize DataConnect instance
* @param options ConnectorConfig
*/
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare class ImpactedQueryRefsAccumulator {
private queryId;
impacted: Set<string>;
constructor(queryId: string);
add(impacted: string[]): void;
consumeEvents(): string[];
}
declare interface InternalCacheProvider {
getEntityData(globalId: string): Promise<EntityDataObject>;
updateEntityData(entityData: EntityDataObject): Promise<void>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
close(): void;
}
/** @internal */
export declare type InternalQueryResult<Data, Variables> = QueryResult<Data, Variables> & Omit<DataConnectResult<Data, Variables>, 'extensions'> & {
extensions?: {
dataConnect?: DataConnectExtensionWithMaxAge[];
};
};
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
export declare const MUTATION_STR = "mutation";
/**
* @internal
*/
export declare class MutationManager {
private _transport;
private _inflight;
constructor(_transport: DataConnectTransport);
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
}
/**
* Mutation return value from `executeMutation`
*/
export declare interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
}
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof MUTATION_STR;
}
/**
* Creates a `MutationRef`
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
*/
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
/**
*
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
* @param variables variables to send with mutation
*/
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
/**
* Mutation Result from `executeMutation`
*/
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: MutationRef<Data, Variables>;
}
/**
* `OnCompleteSubscription`
*/
export declare type OnCompleteSubscription = () => void;
/**
* Signature for `OnErrorSubscription` for `subscribe`
*/
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
/**
* Signature for `OnResultSubscription` for `subscribe`
*/
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
export declare interface OperationRef<_Data, Variables> {
name: string;
variables: Variables;
refType: ReferenceType;
dataConnect: DataConnect;
}
export declare interface OpResult<Data> {
data: Data;
source: DataSource;
fetchTime: string;
extensions?: Extensions;
}
declare interface ParsedArgs<Variables> {
dc: DataConnect;
vars: Variables;
}
/**
*
* @param fullHost
* @returns TransportOptions
* @internal
*/
export declare function parseOptions(fullHost: string): TransportOptions;
export declare const QUERY_STR = "query";
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const QueryFetchPolicy: {
readonly PREFER_CACHE: "PREFER_CACHE";
readonly CACHE_ONLY: "CACHE_ONLY";
readonly SERVER_ONLY: "SERVER_ONLY";
};
export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
declare class QueryManager {
private transport;
private dc;
private cache?;
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
private callbacks;
private subscriptionCache;
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
private queue;
waitForQueuedWrites(): Promise<void>;
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
publishErrorToSubscribers(key: string, err: unknown): void;
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
enableEmulator(host: string, port: number): void;
}
/**
* Promise returned from `executeQuery`
*/
export declare interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
}
/**
* QueryRef object
*/
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof QUERY_STR;
}
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @returns `QueryRef`
*/
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @param variables Variables to execute with
* @returns `QueryRef`
*/
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
/**
* Result of `executeQuery`
*/
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: QueryRef<Data, Variables>;
toJSON: () => SerializedRef<Data, Variables>;
}
/**
* Signature for unsubscribe from `subscribe`
*/
export declare type QueryUnsubscribe = () => void;
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
/**
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
*/
export declare interface RefInfo<Variables> {
name: string;
variables: Variables;
connectorConfig: DataConnectOptions;
}
declare class ResultTree {
private rootStub;
private maxAge;
readonly cachedAt: Date;
private _lastAccessed;
/**
* Create a {@link ResultTree} from a dehydrated JSON object.
* @param value The dehydrated JSON object.
* @returns The {@link ResultTree}.
*/
static fromJson(value: DehydratedResultTreeJson): ResultTree;
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
isStale(): boolean;
updateMaxAge(maxAgeInSeconds: number): void;
updateAccessed(): void;
get lastAccessed(): Date;
getRootStub(): EntityNode;
}
/**
* Serialized Ref as a result of `QueryResult.toJSON()`
*/
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
refInfo: RefInfo<Variables>;
}
/**
* ServerValues
*/
declare interface ServerValues extends Record<string, unknown> {
maxAge?: number;
}
export declare function setLogLevel(logLevel: LogLevelString): void;
export declare const SOURCE_CACHE = "CACHE";
export declare const SOURCE_SERVER = "SERVER";
export declare const StorageType: {
readonly MEMORY: "MEMORY";
};
export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param observer observer object to use for subscribing.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param onNext Callback to call when result comes back.
* @param onError Callback to call when error gets thrown.
* @param onComplete Called when subscription completes.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
/**
* Representation of full observer options in `subscribe`
*/
export declare interface SubscriptionOptions<Data, Variables> {
onNext?: OnResultSubscription<Data, Variables>;
onErr?: OnErrorSubscription;
onComplete?: OnCompleteSubscription;
}
/**
* Delete DataConnect instance
* @param dataConnect DataConnect instance
* @returns
*/
export declare function terminate(dataConnect: DataConnect): Promise<void>;
/**
* Converts serialized ref to query ref
* @param serializedRef ref to convert to `QueryRef`
* @returns `QueryRef`
*/
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
/**
* @internal
*/
export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType) => DataConnectTransport;
/**
* Options to connect to emulator
*/
export declare interface TransportOptions {
host: string;
sslEnabled?: boolean;
port?: number;
}
/**
* The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
* and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
* @param connectorConfig
* @param dcOrVars
* @param vars
* @param validateVars
* @returns {DataConnect} and {Variables} instance
* @internal
*/
export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
/**
*
* @param dcOptions
* @returns {void}
* @internal
*/
export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
export { }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './core/query/subscribe';
export { makeMemoryCacheProvider, CacheProvider } from './api/DataConnect';

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './core/query/subscribe';
export { makeMemoryCacheProvider, CacheProvider } from './api/DataConnect';

View File

@@ -0,0 +1,159 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
import { Provider } from '@firebase/component';
import { DataConnectCache } from '../cache/Cache';
import { InternalCacheProvider } from '../cache/CacheProvider';
import { QueryManager } from '../core/query/QueryManager';
import { CallerSdkType } from '../network';
import { MutationManager } from './Mutation';
/**
* Connector Config for calling Data Connect backend.
*/
export interface ConnectorConfig {
location: string;
connector: string;
service: string;
}
/**
* Options to connect to emulator
*/
export interface TransportOptions {
host: string;
sslEnabled?: boolean;
port?: number;
}
/**
*
* @param fullHost
* @returns TransportOptions
* @internal
*/
export declare function parseOptions(fullHost: string): TransportOptions;
/**
* DataConnectOptions including project id
*/
export interface DataConnectOptions extends ConnectorConfig {
projectId: string;
}
/**
* Class representing Firebase Data Connect
*/
export declare class DataConnect {
readonly app: FirebaseApp;
private readonly dataConnectOptions;
private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
_initialized: boolean;
private _transport;
private _transportClass;
private _transportOptions?;
private _authTokenProvider?;
_isUsingGeneratedSdk: boolean;
_callerSdkType: CallerSdkType;
private _appCheckTokenProvider?;
private _cacheSettings?;
/**
* @internal
*/
private cache?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
/**
* @internal
*/
getCache(): DataConnectCache | undefined;
_useGeneratedSdk(): void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
_delete(): Promise<void>;
getSettings(): ConnectorConfig;
/**
* @internal
*/
setCacheSettings(cacheSettings: CacheSettings): void;
setInitialized(): void;
enableEmulator(transportOptions: TransportOptions): void;
}
/**
* @internal
* @param transportOptions1
* @param transportOptions2
* @returns
*/
export declare function areTransportOptionsEqual(transportOptions1: TransportOptions, transportOptions2: TransportOptions): boolean;
/**
* Connect to the DataConnect Emulator
* @param dc Data Connect instance
* @param host host of emulator server
* @param port port of emulator server
* @param sslEnabled use https
*/
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
export interface DataConnectSettings {
cacheSettings?: CacheSettings;
}
/**
* Initialize DataConnect instance
* @param options ConnectorConfig
*/
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
/**
*
* @param dcOptions
* @returns {void}
* @internal
*/
export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
/**
* Delete DataConnect instance
* @param dataConnect DataConnect instance
* @returns
*/
export declare function terminate(dataConnect: DataConnect): Promise<void>;
export declare const StorageType: {
readonly MEMORY: "MEMORY";
};
export type StorageType = (typeof StorageType)[keyof typeof StorageType];
export interface CacheSettings {
cacheProvider: CacheProvider<StorageType>;
maxAgeSeconds?: number;
}
export interface CacheProvider<T extends StorageType> {
type: T;
/**
* @internal
*/
initialize(cacheId: string): InternalCacheProvider;
}
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;

View File

@@ -0,0 +1,61 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectTransport } from '../network/transport';
import { DataConnect } from './DataConnect';
import { DataConnectResult, MUTATION_STR, OperationRef } from './Reference';
export interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof MUTATION_STR;
}
/**
* Creates a `MutationRef`
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
*/
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
/**
*
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
* @param variables variables to send with mutation
*/
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
/**
* @internal
*/
export declare class MutationManager {
private _transport;
private _inflight;
constructor(_transport: DataConnectTransport);
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
}
/**
* Mutation Result from `executeMutation`
*/
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: MutationRef<Data, Variables>;
}
/**
* Mutation return value from `executeMutation`
*/
export interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
}
/**
* Execute Mutation
* @param mutationRef mutation to execute
* @returns `MutationRef`
*/
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;

View File

@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Extensions } from '../network';
import { DataConnect, DataConnectOptions } from './DataConnect';
export declare const QUERY_STR = "query";
export declare const MUTATION_STR = "mutation";
export type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
export declare const SOURCE_SERVER = "SERVER";
export declare const SOURCE_CACHE = "CACHE";
export type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
export interface OpResult<Data> {
data: Data;
source: DataSource;
fetchTime: string;
extensions?: Extensions;
}
export interface OperationRef<_Data, Variables> {
name: string;
variables: Variables;
refType: ReferenceType;
dataConnect: DataConnect;
}
export interface DataConnectResult<Data, Variables> extends OpResult<Data> {
ref: OperationRef<Data, Variables>;
}
/**
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
*/
export interface RefInfo<Variables> {
name: string;
variables: Variables;
connectorConfig: DataConnectOptions;
}
/**
* Serialized Ref as a result of `QueryResult.toJSON()`
*/
export interface SerializedRef<Data, Variables> extends OpResult<Data> {
refInfo: RefInfo<Variables>;
}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from '../network';
export { ExecuteQueryOptions, QueryFetchPolicy } from '../core/query/queryOptions';
export { CacheSettings, validateDCOptions, ConnectorConfig, DataConnect, DataConnectOptions, DataConnectSettings, StorageType, TransportOptions, areTransportOptionsEqual, connectDataConnectEmulator, getDataConnect, parseOptions, terminate } from './DataConnect';
export * from './Reference';
export * from './Mutation';
export * from './query';
export { setLogLevel } from '../logger';
export { validateArgs } from '../util/validateArgs';
export { DataConnectErrorCode, Code, DataConnectError, DataConnectOperationError, DataConnectOperationFailureResponse, DataConnectOperationFailureResponseErrorInfo } from '../core/error';

View File

@@ -0,0 +1,71 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ExecuteQueryOptions } from '../core/query/queryOptions';
import { DataConnectExtensionWithMaxAge } from '../network/transport';
import { DataConnect } from './DataConnect';
import { OperationRef, QUERY_STR, DataConnectResult, SerializedRef } from './Reference';
/**
* QueryRef object
*/
export interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof QUERY_STR;
}
/** @internal */
export type InternalQueryResult<Data, Variables> = QueryResult<Data, Variables> & Omit<DataConnectResult<Data, Variables>, 'extensions'> & {
extensions?: {
dataConnect?: DataConnectExtensionWithMaxAge[];
};
};
/**
* Result of `executeQuery`
*/
export interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: QueryRef<Data, Variables>;
toJSON: () => SerializedRef<Data, Variables>;
}
/**
* Promise returned from `executeQuery`
*/
export interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
}
/**
* Execute Query
* @param queryRef query to execute.
* @returns `QueryPromise`
*/
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @returns `QueryRef`
*/
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @param variables Variables to execute with
* @returns `QueryRef`
*/
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
/**
* Converts serialized ref to query ref
* @param serializedRef ref to convert to `QueryRef`
* @returns `QueryRef`
*/
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;

View File

@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CacheProvider, CacheSettings, type ConnectorConfig } from '../api/DataConnect';
import { type AuthTokenProvider } from '../core/FirebaseAuthProvider';
import { InternalCacheProvider } from './CacheProvider';
import { InMemoryCacheProvider } from './InMemoryCacheProvider';
import { ResultTree } from './ResultTree';
export declare const Memory = "memory";
export type DataConnectStorage = typeof Memory;
/**
* ServerValues
*/
export interface ServerValues extends Record<string, unknown> {
maxAge?: number;
}
export declare class DataConnectCache {
private authProvider;
private projectId;
private connectorConfig;
private host;
cacheSettings: CacheSettings;
private cacheProvider;
private uid;
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
initialize(): Promise<void>;
getIdentifier(uid: string | null): Promise<string>;
initializeNewProviders(identifier: string): InternalCacheProvider;
containsResultTree(queryId: string): Promise<boolean>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
}
export declare class MemoryStub implements CacheProvider<'MEMORY'> {
type: 'MEMORY';
/**
* @internal
*/
initialize(cacheId: string): InMemoryCacheProvider;
}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityDataObject } from './EntityDataObject';
import { ResultTree } from './ResultTree';
export interface InternalCacheProvider {
getEntityData(globalId: string): Promise<EntityDataObject>;
updateEntityData(entityData: EntityDataObject): Promise<void>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
close(): void;
}

View File

@@ -0,0 +1,37 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
export interface EntityDataObjectJson {
map: {
[key: string]: FDCScalarValue;
};
referencedFrom: string[];
globalID: string;
}
export declare class EntityDataObject {
readonly globalID: string;
getServerValue(key: string): unknown;
private serverValues;
private referencedFrom;
constructor(globalID: string);
getServerValues(): {
[key: string]: FDCScalarValue;
};
toJSON(): EntityDataObjectJson;
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
}

View File

@@ -0,0 +1,56 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InternalCacheProvider } from './CacheProvider';
import { EntityDataObject, EntityDataObjectJson, FDCScalarValue } from './EntityDataObject';
import { ImpactedQueryRefsAccumulator } from './ImpactedQueryRefsAccumulator';
export declare const GLOBAL_ID_KEY = "_id";
export declare const OBJECT_LISTS_KEY = "_objectLists";
export declare const REFERENCES_KEY = "_references";
export declare const SCALARS_KEY = "_scalars";
export declare const ENTITY_DATA_KEYS_KEY = "_entity_data_keys";
export declare class EntityNode {
entityData?: EntityDataObject;
scalars: Record<string, FDCScalarValue>;
references: {
[key: string]: EntityNode;
};
objectLists: {
[key: string]: EntityNode[];
};
globalId?: string;
entityDataKeys: Set<string>;
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
toJSON(mode: EncodingMode): Record<string, unknown>;
static fromJson(obj: DehydratedStubDataObject): EntityNode;
}
export interface DehydratedStubDataObject {
backingData?: EntityDataObjectJson;
globalID?: string;
scalars: {
[key: string]: FDCScalarValue;
};
references: {
[key: string]: DehydratedStubDataObject;
};
objectLists: {
[key: string]: DehydratedStubDataObject[];
};
}
export declare enum EncodingMode {
hydrated = 0,
dehydrated = 1
}

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare class ImpactedQueryRefsAccumulator {
private queryId;
impacted: Set<string>;
constructor(queryId: string);
add(impacted: string[]): void;
consumeEvents(): string[];
}

View File

@@ -0,0 +1,30 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InternalCacheProvider } from './CacheProvider';
import { EntityDataObject } from './EntityDataObject';
import { ResultTree } from './ResultTree';
export declare class InMemoryCacheProvider implements InternalCacheProvider {
private _keyId;
private edos;
private resultTrees;
constructor(_keyId: string);
setResultTree(queryId: string, rt: ResultTree): Promise<void>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
updateEntityData(entityData: EntityDataObject): Promise<void>;
getEntityData(globalId: string): Promise<EntityDataObject>;
close(): Promise<void>;
}

View File

@@ -0,0 +1,42 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityNode, DehydratedStubDataObject } from './EntityNode';
export declare class ResultTree {
private rootStub;
private maxAge;
readonly cachedAt: Date;
private _lastAccessed;
/**
* Create a {@link ResultTree} from a dehydrated JSON object.
* @param value The dehydrated JSON object.
* @returns The {@link ResultTree}.
*/
static fromJson(value: DehydratedResultTreeJson): ResultTree;
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
isStale(): boolean;
updateMaxAge(maxAgeInSeconds: number): void;
updateAccessed(): void;
get lastAccessed(): Date;
getRootStub(): EntityNode;
}
interface DehydratedResultTreeJson {
rootStub: DehydratedStubDataObject;
maxAge: number;
cachedAt: Date;
lastAccessed: Date;
}
export {};

View File

@@ -0,0 +1,40 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InternalCacheProvider } from './CacheProvider';
import { EntityNode } from './EntityNode';
interface DehydratedResults {
entityNode: EntityNode;
impacted: string[];
}
export declare class ResultTreeProcessor {
/**
* Hydrate the EntityNode into a JSON object so that it can be returned to the user.
* @param rootStubObject
* @returns {string}
*/
hydrateResults(rootStubObject: EntityNode): Record<string, unknown>;
/**
* Dehydrate results so that they can be stored in the cache.
* @param json
* @param entityIds
* @param cacheProvider
* @param queryId
* @returns {Promise<DehydratedResults>}
*/
dehydrateResults(json: Record<string, unknown>, entityIds: Record<string, unknown>, cacheProvider: InternalCacheProvider, queryId: string): Promise<DehydratedResults>;
}
export {};

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { OpResult } from '../api/Reference';
import { DataConnectExtension } from '../network';
export declare function parseEntityIds<T>(result: OpResult<T>): Record<string, unknown>;
export declare function populatePath(path: Array<string | number>, toUpdate: Record<string | number, unknown>, extension: DataConnectExtension): void;

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName, AppCheckTokenListener, AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { Provider } from '@firebase/component';
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
export declare class AppCheckTokenProvider {
private appCheckProvider?;
private appCheck?;
private serverAppAppCheckToken?;
constructor(app: FirebaseApp, appCheckProvider?: Provider<AppCheckInternalComponentName> | undefined);
getToken(): Promise<AppCheckTokenResult | null>;
addTokenChangeListener(listener: AppCheckTokenListener): void;
}

View File

@@ -0,0 +1,36 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseOptions } from '@firebase/app-types';
import { FirebaseAuthInternal, FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { Provider } from '@firebase/component';
export interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
getAuth(): FirebaseAuthInternal;
}
export type AuthTokenListener = (token: string | null) => void;
export declare class FirebaseAuthProvider implements AuthTokenProvider {
private _appName;
private _options;
private _authProvider;
private _auth;
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
getAuth(): FirebaseAuthInternal;
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
removeTokenChangeListener(listener: (token: string | null) => void): void;
}

View File

@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseError } from '@firebase/util';
export type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
export type Code = DataConnectErrorCode;
export declare const Code: {
OTHER: DataConnectErrorCode;
ALREADY_INITIALIZED: DataConnectErrorCode;
NOT_INITIALIZED: DataConnectErrorCode;
NOT_SUPPORTED: DataConnectErrorCode;
INVALID_ARGUMENT: DataConnectErrorCode;
PARTIAL_ERROR: DataConnectErrorCode;
UNAUTHORIZED: DataConnectErrorCode;
};
/** An error returned by a DataConnect operation. */
export declare class DataConnectError extends FirebaseError {
/** @internal */
readonly name: string;
constructor(code: Code, message: string);
/** @internal */
toString(): string;
}
/** An error returned by a DataConnect operation. */
export declare class DataConnectOperationError extends DataConnectError {
/** @internal */
readonly name: string;
/** The response received from the backend. */
readonly response: DataConnectOperationFailureResponse;
/** @hideconstructor */
constructor(message: string, response: DataConnectOperationFailureResponse);
}
export interface DataConnectOperationFailureResponse {
readonly data?: Record<string, unknown> | null;
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
}
export interface DataConnectOperationFailureResponseErrorInfo {
readonly message: string;
readonly path: Array<string | number>;
}

View File

@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type DataConnect } from '../../api/DataConnect';
import { QueryRef, QueryResult } from '../../api/query';
import { SerializedRef, DataSource } from '../../api/Reference';
import { DataConnectCache } from '../../cache/Cache';
import { DataConnectTransport } from '../../network';
import { DataConnectExtensionWithMaxAge } from '../../network/transport';
import { OnCompleteSubscription, OnErrorSubscription, OnResultSubscription } from './subscribe';
export declare function getRefSerializer<Data, Variables>(queryRef: QueryRef<Data, Variables>, data: Data, source: DataSource, fetchTime: string): () => SerializedRef<Data, Variables>;
export declare class QueryManager {
private transport;
private dc;
private cache?;
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
private callbacks;
private subscriptionCache;
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
private queue;
waitForQueuedWrites(): Promise<void>;
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
publishErrorToSubscribers(key: string, err: unknown): void;
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
enableEmulator(host: string, port: number): void;
}
export declare function getMaxAgeFromExtensions(extensions: DataConnectExtensionWithMaxAge[] | undefined): number | undefined;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const QueryFetchPolicy: {
readonly PREFER_CACHE: "PREFER_CACHE";
readonly CACHE_ONLY: "CACHE_ONLY";
readonly SERVER_ONLY: "SERVER_ONLY";
};
export type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
export interface ExecuteQueryOptions {
fetchPolicy: QueryFetchPolicy;
}

View File

@@ -0,0 +1,67 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { QueryRef, QueryResult } from '../../api/query';
import { SerializedRef } from '../../api/Reference';
import { DataConnectError } from '../error';
/**
* `OnCompleteSubscription`
*/
export type OnCompleteSubscription = () => void;
/**
* Representation of full observer options in `subscribe`
*/
export interface SubscriptionOptions<Data, Variables> {
onNext?: OnResultSubscription<Data, Variables>;
onErr?: OnErrorSubscription;
onComplete?: OnCompleteSubscription;
}
/**
* Signature for `OnResultSubscription` for `subscribe`
*/
export type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
/**
* Signature for `OnErrorSubscription` for `subscribe`
*/
export type OnErrorSubscription = (err?: DataConnectError) => void;
/**
* Signature for unsubscribe from `subscribe`
*/
export type QueryUnsubscribe = () => void;
/**
* Representation of user provided subscription options.
*/
export interface DataConnectSubscription<Data, Variables> {
userCallback: OnResultSubscription<Data, Variables>;
errCallback?: (e?: DataConnectError) => void;
unsubscribe: () => void;
}
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param observer observer object to use for subscribing.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param onNext Callback to call when result comes back.
* @param onError Callback to call when error gets thrown.
* @param onComplete Called when subscription completes.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** The semver (www.semver.org) version of the SDK. */
export declare let SDK_VERSION: string;
/**
* SDK_VERSION should be set before any database instance is created
* @internal
*/
export declare function setSDKVersion(version: string): void;

View File

@@ -0,0 +1,29 @@
/**
* Firebase Data Connect
*
* @packageDocumentation
*/
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnect } from './api/DataConnect';
export * from './api';
export * from './api.browser';
declare module '@firebase/component' {
interface NameServiceMapping {
'data-connect': DataConnect;
}
}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './api';
export * from './api.node';

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LogLevelString } from '@firebase/logger';
export declare function setLogLevel(logLevel: LogLevelString): void;
export declare function logDebug(msg: string): void;
export declare function logError(msg: string): void;

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CallerSdkType, DataConnectResponse } from './transport';
export declare function initializeFetch(fetchImpl: typeof fetch): void;
export interface DataConnectFetchBody<T> {
name: string;
operationName: string;
variables: T;
}
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>>;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { CallerSdkType, CallerSdkTypeEnum, DataConnectTransport, DataConnectEntityArray, DataConnectSingleEntity, DataConnectExtension, Extensions, TransportClass } from './transport';

View File

@@ -0,0 +1,81 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
/**
* enum representing different flavors of the SDK used by developers
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
*/
export type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
export declare const CallerSdkTypeEnum: {
readonly Base: "Base";
readonly Generated: "Generated";
readonly TanstackReactCore: "TanstackReactCore";
readonly GeneratedReact: "GeneratedReact";
readonly TanstackAngularCore: "TanstackAngularCore";
readonly GeneratedAngular: "GeneratedAngular";
};
export interface DataConnectEntityArray {
entityIds: string[];
}
export interface DataConnectSingleEntity {
entityId: string;
}
export type DataConnectExtension = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity);
/** @internal */
export interface DataConnectMaxAge {
maxAge: string;
}
/** @internal */
export type DataConnectExtensionWithMaxAge = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity | DataConnectMaxAge);
export interface Extensions {
dataConnect?: DataConnectExtension[];
}
/** @internal */
export interface ExtensionsWithMaxAge {
dataConnect?: DataConnectExtensionWithMaxAge[];
}
export interface DataConnectResponse<T> {
data: T;
errors: Error[];
extensions: Extensions;
}
/** @internal */
export interface DataConnectResponseWithMaxAge<T> {
data: T;
errors: Error[];
extensions: ExtensionsWithMaxAge;
}
/**
* @internal
*/
export interface DataConnectTransport {
invokeQuery<T, U>(queryName: string, body?: U): Promise<DataConnectResponseWithMaxAge<T>>;
invokeMutation<T, U>(queryName: string, body?: U): Promise<DataConnectResponse<T>>;
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
onTokenChanged: (token: string | null) => void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
}
/**
* @internal
*/
export type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType) => DataConnectTransport;

View File

@@ -0,0 +1,49 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
import { CallerSdkType, DataConnectResponse, DataConnectTransport } from '.';
export declare class RESTTransport implements DataConnectTransport {
private apiKey?;
private appId?;
private authProvider?;
private appCheckProvider?;
private _isUsingGen;
private _callerSdkType;
private _host;
private _port;
private _location;
private _connectorName;
private _secure;
private _project;
private _serviceName;
private _accessToken;
private _appCheckToken;
private _lastToken;
private _isUsingEmulator;
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: (string | null) | undefined, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType);
get endpointUrl(): string;
useEmulator(host: string, port?: number, isSecure?: boolean): void;
onTokenChanged(newToken: string | null): void;
getWithAuth(forceToken?: boolean): Promise<string | null>;
_setLastToken(lastToken: string | null): void;
withRetry<T>(promiseFactory: () => Promise<DataConnectResponse<T>>, retry?: boolean): Promise<DataConnectResponse<T>>;
invokeQuery: <T, U>(queryName: string, body?: U) => Promise<DataConnectResponse<T>>;
invokeMutation: <T, U>(queryName: string, body?: U) => Promise<DataConnectResponse<T>>;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
}

View File

@@ -0,0 +1 @@
export declare function registerDataConnect(variant?: string): void;

View File

@@ -0,0 +1,22 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type HmacImpl = (obj: Record<string, unknown>) => string;
export declare let encoderImpl: HmacImpl;
export type DecodeHmacImpl = (s: string) => Record<string, unknown>;
export declare let decoderImpl: DecodeHmacImpl;
export declare function setEncoder(encoder: HmacImpl): void;
export declare function setDecoder(decoder: DecodeHmacImpl): void;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function setIfNotExists<T>(map: Map<string, T>, key: string, val: T): void;

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectOptions, TransportOptions } from '../api/DataConnect';
export declare const PROD_HOST = "firebasedataconnect.googleapis.com";
export declare function urlBuilder(projectConfig: DataConnectOptions, transportOptions: TransportOptions): string;
export declare function addToken(url: string, apiKey?: string): string;

View File

@@ -0,0 +1,33 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ConnectorConfig, DataConnect } from '../api/DataConnect';
interface ParsedArgs<Variables> {
dc: DataConnect;
vars: Variables;
}
/**
* The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
* and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
* @param connectorConfig
* @param dcOrVars
* @param vars
* @param validateVars
* @returns {DataConnect} and {Variables} instance
* @internal
*/
export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
export {};

655
node_modules/@firebase/data-connect/dist/private.d.ts generated vendored Normal file
View File

@@ -0,0 +1,655 @@
/**
* Firebase Data Connect
*
* @packageDocumentation
*/
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { FirebaseApp } from '@firebase/app';
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { FirebaseError } from '@firebase/util';
import { LogLevelString } from '@firebase/logger';
import { Provider } from '@firebase/component';
/* Excluded from this release type: AppCheckTokenProvider */
/* Excluded from this release type: areTransportOptionsEqual */
declare type AuthTokenListener = (token: string | null) => void;
declare interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
getAuth(): FirebaseAuthInternal;
}
export declare interface CacheProvider<T extends StorageType> {
type: T;
/* Excluded from this release type: initialize */
}
export declare interface CacheSettings {
cacheProvider: CacheProvider<StorageType>;
maxAgeSeconds?: number;
}
/**
* enum representing different flavors of the SDK used by developers
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
*/
export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
export declare const CallerSdkTypeEnum: {
readonly Base: "Base";
readonly Generated: "Generated";
readonly TanstackReactCore: "TanstackReactCore";
readonly GeneratedReact: "GeneratedReact";
readonly TanstackAngularCore: "TanstackAngularCore";
readonly GeneratedAngular: "GeneratedAngular";
};
export declare type Code = DataConnectErrorCode;
export declare const Code: {
OTHER: DataConnectErrorCode;
ALREADY_INITIALIZED: DataConnectErrorCode;
NOT_INITIALIZED: DataConnectErrorCode;
NOT_SUPPORTED: DataConnectErrorCode;
INVALID_ARGUMENT: DataConnectErrorCode;
PARTIAL_ERROR: DataConnectErrorCode;
UNAUTHORIZED: DataConnectErrorCode;
};
/**
* Connect to the DataConnect Emulator
* @param dc Data Connect instance
* @param host host of emulator server
* @param port port of emulator server
* @param sslEnabled use https
*/
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
/**
* Connector Config for calling Data Connect backend.
*/
export declare interface ConnectorConfig {
location: string;
connector: string;
service: string;
}
/**
* Class representing Firebase Data Connect
*/
export declare class DataConnect {
readonly app: FirebaseApp;
private readonly dataConnectOptions;
private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
_initialized: boolean;
private _transport;
private _transportClass;
private _transportOptions?;
private _authTokenProvider?;
_isUsingGeneratedSdk: boolean;
_callerSdkType: CallerSdkType;
private _appCheckTokenProvider?;
private _cacheSettings?;
/* Excluded from this release type: cache */
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
/* Excluded from this release type: getCache */
_useGeneratedSdk(): void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
_delete(): Promise<void>;
getSettings(): ConnectorConfig;
/* Excluded from this release type: setCacheSettings */
setInitialized(): void;
enableEmulator(transportOptions: TransportOptions): void;
}
declare class DataConnectCache {
private authProvider;
private projectId;
private connectorConfig;
private host;
cacheSettings: CacheSettings;
private cacheProvider;
private uid;
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
initialize(): Promise<void>;
getIdentifier(uid: string | null): Promise<string>;
initializeNewProviders(identifier: string): InternalCacheProvider;
containsResultTree(queryId: string): Promise<boolean>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
}
export declare interface DataConnectEntityArray {
entityIds: string[];
}
/** An error returned by a DataConnect operation. */
export declare class DataConnectError extends FirebaseError {
/* Excluded from this release type: name */
constructor(code: Code, message: string);
/* Excluded from this release type: toString */
}
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
export declare type DataConnectExtension = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity);
/* Excluded from this release type: DataConnectExtensionWithMaxAge */
/* Excluded from this release type: DataConnectMaxAge */
/** An error returned by a DataConnect operation. */
export declare class DataConnectOperationError extends DataConnectError {
/* Excluded from this release type: name */
/** The response received from the backend. */
readonly response: DataConnectOperationFailureResponse;
/** @hideconstructor */
constructor(message: string, response: DataConnectOperationFailureResponse);
}
export declare interface DataConnectOperationFailureResponse {
readonly data?: Record<string, unknown> | null;
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
}
export declare interface DataConnectOperationFailureResponseErrorInfo {
readonly message: string;
readonly path: Array<string | number>;
}
/**
* DataConnectOptions including project id
*/
export declare interface DataConnectOptions extends ConnectorConfig {
projectId: string;
}
declare interface DataConnectResponse<T> {
data: T;
errors: Error[];
extensions: Extensions;
}
/* Excluded from this release type: DataConnectResponseWithMaxAge */
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
ref: OperationRef<Data, Variables>;
}
export declare interface DataConnectSettings {
cacheSettings?: CacheSettings;
}
export declare interface DataConnectSingleEntity {
entityId: string;
}
/**
* Representation of user provided subscription options.
*/
export declare interface DataConnectSubscription<Data, Variables> {
userCallback: OnResultSubscription<Data, Variables>;
errCallback?: (e?: DataConnectError) => void;
unsubscribe: () => void;
}
/* Excluded from this release type: DataConnectTransport */
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
declare interface DehydratedResultTreeJson {
rootStub: DehydratedStubDataObject;
maxAge: number;
cachedAt: Date;
lastAccessed: Date;
}
declare interface DehydratedStubDataObject {
backingData?: EntityDataObjectJson;
globalID?: string;
scalars: {
[key: string]: FDCScalarValue;
};
references: {
[key: string]: DehydratedStubDataObject;
};
objectLists: {
[key: string]: DehydratedStubDataObject[];
};
}
declare enum EncodingMode {
hydrated = 0,
dehydrated = 1
}
declare class EntityDataObject {
readonly globalID: string;
getServerValue(key: string): unknown;
private serverValues;
private referencedFrom;
constructor(globalID: string);
getServerValues(): {
[key: string]: FDCScalarValue;
};
toJSON(): EntityDataObjectJson;
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
}
declare interface EntityDataObjectJson {
map: {
[key: string]: FDCScalarValue;
};
referencedFrom: string[];
globalID: string;
}
declare class EntityNode {
entityData?: EntityDataObject;
scalars: Record<string, FDCScalarValue>;
references: {
[key: string]: EntityNode;
};
objectLists: {
[key: string]: EntityNode[];
};
globalId?: string;
entityDataKeys: Set<string>;
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
toJSON(mode: EncodingMode): Record<string, unknown>;
static fromJson(obj: DehydratedStubDataObject): EntityNode;
}
/**
* Execute Mutation
* @param mutationRef mutation to execute
* @returns `MutationRef`
*/
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
/**
* Execute Query
* @param queryRef query to execute.
* @returns `QueryPromise`
*/
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
export declare interface ExecuteQueryOptions {
fetchPolicy: QueryFetchPolicy;
}
export declare interface Extensions {
dataConnect?: DataConnectExtension[];
}
/* Excluded from this release type: ExtensionsWithMaxAge */
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
/**
* Initialize DataConnect instance
* @param options ConnectorConfig
*/
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare class ImpactedQueryRefsAccumulator {
private queryId;
impacted: Set<string>;
constructor(queryId: string);
add(impacted: string[]): void;
consumeEvents(): string[];
}
declare interface InternalCacheProvider {
getEntityData(globalId: string): Promise<EntityDataObject>;
updateEntityData(entityData: EntityDataObject): Promise<void>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
close(): void;
}
/* Excluded from this release type: InternalQueryResult */
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
export declare const MUTATION_STR = "mutation";
/* Excluded from this release type: MutationManager */
/**
* Mutation return value from `executeMutation`
*/
export declare interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
}
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof MUTATION_STR;
}
/**
* Creates a `MutationRef`
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
*/
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
/**
*
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
* @param variables variables to send with mutation
*/
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
/**
* Mutation Result from `executeMutation`
*/
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: MutationRef<Data, Variables>;
}
/**
* `OnCompleteSubscription`
*/
export declare type OnCompleteSubscription = () => void;
/**
* Signature for `OnErrorSubscription` for `subscribe`
*/
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
/**
* Signature for `OnResultSubscription` for `subscribe`
*/
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
export declare interface OperationRef<_Data, Variables> {
name: string;
variables: Variables;
refType: ReferenceType;
dataConnect: DataConnect;
}
export declare interface OpResult<Data> {
data: Data;
source: DataSource;
fetchTime: string;
extensions?: Extensions;
}
declare interface ParsedArgs<Variables> {
dc: DataConnect;
vars: Variables;
}
/* Excluded from this release type: parseOptions */
export declare const QUERY_STR = "query";
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const QueryFetchPolicy: {
readonly PREFER_CACHE: "PREFER_CACHE";
readonly CACHE_ONLY: "CACHE_ONLY";
readonly SERVER_ONLY: "SERVER_ONLY";
};
export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
declare class QueryManager {
private transport;
private dc;
private cache?;
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
private callbacks;
private subscriptionCache;
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
private queue;
waitForQueuedWrites(): Promise<void>;
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
publishErrorToSubscribers(key: string, err: unknown): void;
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
enableEmulator(host: string, port: number): void;
}
/**
* Promise returned from `executeQuery`
*/
export declare interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
}
/**
* QueryRef object
*/
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof QUERY_STR;
}
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @returns `QueryRef`
*/
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @param variables Variables to execute with
* @returns `QueryRef`
*/
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
/**
* Result of `executeQuery`
*/
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: QueryRef<Data, Variables>;
toJSON: () => SerializedRef<Data, Variables>;
}
/**
* Signature for unsubscribe from `subscribe`
*/
export declare type QueryUnsubscribe = () => void;
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
/**
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
*/
export declare interface RefInfo<Variables> {
name: string;
variables: Variables;
connectorConfig: DataConnectOptions;
}
declare class ResultTree {
private rootStub;
private maxAge;
readonly cachedAt: Date;
private _lastAccessed;
/**
* Create a {@link ResultTree} from a dehydrated JSON object.
* @param value The dehydrated JSON object.
* @returns The {@link ResultTree}.
*/
static fromJson(value: DehydratedResultTreeJson): ResultTree;
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
isStale(): boolean;
updateMaxAge(maxAgeInSeconds: number): void;
updateAccessed(): void;
get lastAccessed(): Date;
getRootStub(): EntityNode;
}
/**
* Serialized Ref as a result of `QueryResult.toJSON()`
*/
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
refInfo: RefInfo<Variables>;
}
/**
* ServerValues
*/
declare interface ServerValues extends Record<string, unknown> {
maxAge?: number;
}
export declare function setLogLevel(logLevel: LogLevelString): void;
export declare const SOURCE_CACHE = "CACHE";
export declare const SOURCE_SERVER = "SERVER";
export declare const StorageType: {
readonly MEMORY: "MEMORY";
};
export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param observer observer object to use for subscribing.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param onNext Callback to call when result comes back.
* @param onError Callback to call when error gets thrown.
* @param onComplete Called when subscription completes.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
/**
* Representation of full observer options in `subscribe`
*/
export declare interface SubscriptionOptions<Data, Variables> {
onNext?: OnResultSubscription<Data, Variables>;
onErr?: OnErrorSubscription;
onComplete?: OnCompleteSubscription;
}
/**
* Delete DataConnect instance
* @param dataConnect DataConnect instance
* @returns
*/
export declare function terminate(dataConnect: DataConnect): Promise<void>;
/**
* Converts serialized ref to query ref
* @param serializedRef ref to convert to `QueryRef`
* @returns `QueryRef`
*/
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
/* Excluded from this release type: TransportClass */
/**
* Options to connect to emulator
*/
export declare interface TransportOptions {
host: string;
sslEnabled?: boolean;
port?: number;
}
/* Excluded from this release type: validateArgs */
/* Excluded from this release type: validateDCOptions */
export { }

350
node_modules/@firebase/data-connect/dist/public.d.ts generated vendored Normal file
View File

@@ -0,0 +1,350 @@
/**
* Firebase Data Connect
*
* @packageDocumentation
*/
import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
import { Provider } from '@firebase/component';
import { LogLevelString } from '@firebase/logger';
import { FirebaseError } from '@firebase/util';
export declare interface CacheProvider<T extends StorageType> {
type: T;
}
export declare interface CacheSettings {
cacheProvider: CacheProvider<StorageType>;
maxAgeSeconds?: number;
}
/**
* enum representing different flavors of the SDK used by developers
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
*/
export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
export declare const CallerSdkTypeEnum: {
readonly Base: "Base";
readonly Generated: "Generated";
readonly TanstackReactCore: "TanstackReactCore";
readonly GeneratedReact: "GeneratedReact";
readonly TanstackAngularCore: "TanstackAngularCore";
readonly GeneratedAngular: "GeneratedAngular";
};
export declare type Code = DataConnectErrorCode;
export declare const Code: {
OTHER: DataConnectErrorCode;
ALREADY_INITIALIZED: DataConnectErrorCode;
NOT_INITIALIZED: DataConnectErrorCode;
NOT_SUPPORTED: DataConnectErrorCode;
INVALID_ARGUMENT: DataConnectErrorCode;
PARTIAL_ERROR: DataConnectErrorCode;
UNAUTHORIZED: DataConnectErrorCode;
};
/**
* Connect to the DataConnect Emulator
* @param dc Data Connect instance
* @param host host of emulator server
* @param port port of emulator server
* @param sslEnabled use https
*/
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
/**
* Connector Config for calling Data Connect backend.
*/
export declare interface ConnectorConfig {
location: string;
connector: string;
service: string;
}
/**
* Class representing Firebase Data Connect
*/
export declare class DataConnect {
readonly app: FirebaseApp;
private readonly dataConnectOptions;
isEmulator: boolean;
/* Excluded from this release type: cache */
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
getSettings(): ConnectorConfig;
/* Excluded from this release type: setCacheSettings */
setInitialized(): void;
enableEmulator(transportOptions: TransportOptions): void;
}
export declare interface DataConnectEntityArray {
entityIds: string[];
}
/** An error returned by a DataConnect operation. */
export declare class DataConnectError extends FirebaseError {
/* Excluded from this release type: name */
constructor(code: Code, message: string);
}
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
export declare type DataConnectExtension = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity);
/* Excluded from this release type: DataConnectExtensionWithMaxAge */
/* Excluded from this release type: DataConnectMaxAge */
/** An error returned by a DataConnect operation. */
export declare class DataConnectOperationError extends DataConnectError {
/* Excluded from this release type: name */
/** The response received from the backend. */
readonly response: DataConnectOperationFailureResponse;
private constructor();
}
export declare interface DataConnectOperationFailureResponse {
readonly data?: Record<string, unknown> | null;
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
}
export declare interface DataConnectOperationFailureResponseErrorInfo {
readonly message: string;
readonly path: Array<string | number>;
}
/**
* DataConnectOptions including project id
*/
export declare interface DataConnectOptions extends ConnectorConfig {
projectId: string;
}
/* Excluded from this release type: DataConnectResponseWithMaxAge */
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
ref: OperationRef<Data, Variables>;
}
export declare interface DataConnectSettings {
cacheSettings?: CacheSettings;
}
export declare interface DataConnectSingleEntity {
entityId: string;
}
/**
* Representation of user provided subscription options.
*/
export declare interface DataConnectSubscription<Data, Variables> {
userCallback: OnResultSubscription<Data, Variables>;
errCallback?: (e?: DataConnectError) => void;
unsubscribe: () => void;
}
/* Excluded from this release type: DataConnectTransport */
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
/**
* Execute Mutation
* @param mutationRef mutation to execute
* @returns `MutationRef`
*/
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
/**
* Execute Query
* @param queryRef query to execute.
* @returns `QueryPromise`
*/
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
export declare interface ExecuteQueryOptions {
fetchPolicy: QueryFetchPolicy;
}
export declare interface Extensions {
dataConnect?: DataConnectExtension[];
}
/**
* Initialize DataConnect instance
* @param options ConnectorConfig
*/
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
/* Excluded from this release type: InternalQueryResult */
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
export declare const MUTATION_STR = "mutation";
/* Excluded from this release type: MutationManager */
/**
* Mutation return value from `executeMutation`
*/
export declare interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
}
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof MUTATION_STR;
}
/**
* Creates a `MutationRef`
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
*/
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
/**
*
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
* @param variables variables to send with mutation
*/
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
/**
* Mutation Result from `executeMutation`
*/
export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: MutationRef<Data, Variables>;
}
/**
* `OnCompleteSubscription`
*/
export declare type OnCompleteSubscription = () => void;
/**
* Signature for `OnErrorSubscription` for `subscribe`
*/
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
/**
* Signature for `OnResultSubscription` for `subscribe`
*/
export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
export declare interface OperationRef<_Data, Variables> {
name: string;
variables: Variables;
refType: ReferenceType;
dataConnect: DataConnect;
}
export declare interface OpResult<Data> {
data: Data;
source: DataSource;
fetchTime: string;
extensions?: Extensions;
}
/* Excluded from this release type: parseOptions */
export declare const QUERY_STR = "query";
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const QueryFetchPolicy: {
readonly PREFER_CACHE: "PREFER_CACHE";
readonly CACHE_ONLY: "CACHE_ONLY";
readonly SERVER_ONLY: "SERVER_ONLY";
};
export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
/**
* Promise returned from `executeQuery`
*/
export declare interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
}
/**
* QueryRef object
*/
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof QUERY_STR;
}
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @returns `QueryRef`
*/
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @param variables Variables to execute with
* @returns `QueryRef`
*/
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
/**
* Result of `executeQuery`
*/
export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: QueryRef<Data, Variables>;
toJSON: () => SerializedRef<Data, Variables>;
}
/**
* Signature for unsubscribe from `subscribe`
*/
export declare type QueryUnsubscribe = () => void;
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
/**
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
*/
export declare interface RefInfo<Variables> {
name: string;
variables: Variables;
connectorConfig: DataConnectOptions;
}
/**
* Serialized Ref as a result of `QueryResult.toJSON()`
*/
export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
refInfo: RefInfo<Variables>;
}
export declare function setLogLevel(logLevel: LogLevelString): void;
export declare const SOURCE_CACHE = "CACHE";
export declare const SOURCE_SERVER = "SERVER";
export declare const StorageType: {
readonly MEMORY: "MEMORY";
};
export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param observer observer object to use for subscribing.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param onNext Callback to call when result comes back.
* @param onError Callback to call when error gets thrown.
* @param onComplete Called when subscription completes.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
/**
* Representation of full observer options in `subscribe`
*/
export declare interface SubscriptionOptions<Data, Variables> {
onNext?: OnResultSubscription<Data, Variables>;
onErr?: OnErrorSubscription;
onComplete?: OnCompleteSubscription;
}
/**
* Delete DataConnect instance
* @param dataConnect DataConnect instance
* @returns
*/
export declare function terminate(dataConnect: DataConnect): Promise<void>;
/**
* Converts serialized ref to query ref
* @param serializedRef ref to convert to `QueryRef`
* @returns `QueryRef`
*/
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
/* Excluded from this release type: TransportClass */
/**
* Options to connect to emulator
*/
export declare interface TransportOptions {
host: string;
sslEnabled?: boolean;
port?: number;
}
/* Excluded from this release type: validateArgs */
/* Excluded from this release type: validateDCOptions */
export {};

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './core/query/subscribe';
export { makeMemoryCacheProvider, CacheProvider } from './api/DataConnect';

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './core/query/subscribe';
export { makeMemoryCacheProvider, CacheProvider } from './api/DataConnect';

View File

@@ -0,0 +1,159 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
import { Provider } from '@firebase/component';
import { DataConnectCache } from '../cache/Cache';
import { InternalCacheProvider } from '../cache/CacheProvider';
import { QueryManager } from '../core/query/QueryManager';
import { CallerSdkType } from '../network';
import { MutationManager } from './Mutation';
/**
* Connector Config for calling Data Connect backend.
*/
export interface ConnectorConfig {
location: string;
connector: string;
service: string;
}
/**
* Options to connect to emulator
*/
export interface TransportOptions {
host: string;
sslEnabled?: boolean;
port?: number;
}
/**
*
* @param fullHost
* @returns TransportOptions
* @internal
*/
export declare function parseOptions(fullHost: string): TransportOptions;
/**
* DataConnectOptions including project id
*/
export interface DataConnectOptions extends ConnectorConfig {
projectId: string;
}
/**
* Class representing Firebase Data Connect
*/
export declare class DataConnect {
readonly app: FirebaseApp;
private readonly dataConnectOptions;
private readonly _authProvider;
private readonly _appCheckProvider;
_queryManager: QueryManager;
_mutationManager: MutationManager;
isEmulator: boolean;
_initialized: boolean;
private _transport;
private _transportClass;
private _transportOptions?;
private _authTokenProvider?;
_isUsingGeneratedSdk: boolean;
_callerSdkType: CallerSdkType;
private _appCheckTokenProvider?;
private _cacheSettings?;
/**
* @internal
*/
private cache?;
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
/**
* @internal
*/
getCache(): DataConnectCache | undefined;
_useGeneratedSdk(): void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
_delete(): Promise<void>;
getSettings(): ConnectorConfig;
/**
* @internal
*/
setCacheSettings(cacheSettings: CacheSettings): void;
setInitialized(): void;
enableEmulator(transportOptions: TransportOptions): void;
}
/**
* @internal
* @param transportOptions1
* @param transportOptions2
* @returns
*/
export declare function areTransportOptionsEqual(transportOptions1: TransportOptions, transportOptions2: TransportOptions): boolean;
/**
* Connect to the DataConnect Emulator
* @param dc Data Connect instance
* @param host host of emulator server
* @param port port of emulator server
* @param sslEnabled use https
*/
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
export interface DataConnectSettings {
cacheSettings?: CacheSettings;
}
/**
* Initialize DataConnect instance
* @param options ConnectorConfig
*/
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
/**
* Initialize DataConnect instance
* @param app FirebaseApp to initialize to.
* @param connectorConfig ConnectorConfig
*/
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
/**
*
* @param dcOptions
* @returns {void}
* @internal
*/
export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
/**
* Delete DataConnect instance
* @param dataConnect DataConnect instance
* @returns
*/
export declare function terminate(dataConnect: DataConnect): Promise<void>;
export declare const StorageType: {
readonly MEMORY: "MEMORY";
};
export type StorageType = (typeof StorageType)[keyof typeof StorageType];
export interface CacheSettings {
cacheProvider: CacheProvider<StorageType>;
maxAgeSeconds?: number;
}
export interface CacheProvider<T extends StorageType> {
type: T;
/**
* @internal
*/
initialize(cacheId: string): InternalCacheProvider;
}
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;

View File

@@ -0,0 +1,61 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectTransport } from '../network/transport';
import { DataConnect } from './DataConnect';
import { DataConnectResult, MUTATION_STR, OperationRef } from './Reference';
export interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof MUTATION_STR;
}
/**
* Creates a `MutationRef`
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
*/
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
/**
*
* @param dcInstance Data Connect instance
* @param mutationName name of mutation
* @param variables variables to send with mutation
*/
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
/**
* @internal
*/
export declare class MutationManager {
private _transport;
private _inflight;
constructor(_transport: DataConnectTransport);
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
}
/**
* Mutation Result from `executeMutation`
*/
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: MutationRef<Data, Variables>;
}
/**
* Mutation return value from `executeMutation`
*/
export interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
}
/**
* Execute Mutation
* @param mutationRef mutation to execute
* @returns `MutationRef`
*/
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;

View File

@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Extensions } from '../network';
import { DataConnect, DataConnectOptions } from './DataConnect';
export declare const QUERY_STR = "query";
export declare const MUTATION_STR = "mutation";
export type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
export declare const SOURCE_SERVER = "SERVER";
export declare const SOURCE_CACHE = "CACHE";
export type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
export interface OpResult<Data> {
data: Data;
source: DataSource;
fetchTime: string;
extensions?: Extensions;
}
export interface OperationRef<_Data, Variables> {
name: string;
variables: Variables;
refType: ReferenceType;
dataConnect: DataConnect;
}
export interface DataConnectResult<Data, Variables> extends OpResult<Data> {
ref: OperationRef<Data, Variables>;
}
/**
* Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
*/
export interface RefInfo<Variables> {
name: string;
variables: Variables;
connectorConfig: DataConnectOptions;
}
/**
* Serialized Ref as a result of `QueryResult.toJSON()`
*/
export interface SerializedRef<Data, Variables> extends OpResult<Data> {
refInfo: RefInfo<Variables>;
}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from '../network';
export { ExecuteQueryOptions, QueryFetchPolicy } from '../core/query/queryOptions';
export { CacheSettings, validateDCOptions, ConnectorConfig, DataConnect, DataConnectOptions, DataConnectSettings, StorageType, TransportOptions, areTransportOptionsEqual, connectDataConnectEmulator, getDataConnect, parseOptions, terminate } from './DataConnect';
export * from './Reference';
export * from './Mutation';
export * from './query';
export { setLogLevel } from '../logger';
export { validateArgs } from '../util/validateArgs';
export { DataConnectErrorCode, Code, DataConnectError, DataConnectOperationError, DataConnectOperationFailureResponse, DataConnectOperationFailureResponseErrorInfo } from '../core/error';

View File

@@ -0,0 +1,71 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ExecuteQueryOptions } from '../core/query/queryOptions';
import { DataConnectExtensionWithMaxAge } from '../network/transport';
import { DataConnect } from './DataConnect';
import { OperationRef, QUERY_STR, DataConnectResult, SerializedRef } from './Reference';
/**
* QueryRef object
*/
export interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
refType: typeof QUERY_STR;
}
/** @internal */
export type InternalQueryResult<Data, Variables> = QueryResult<Data, Variables> & Omit<DataConnectResult<Data, Variables>, 'extensions'> & {
extensions?: {
dataConnect?: DataConnectExtensionWithMaxAge[];
};
};
/**
* Result of `executeQuery`
*/
export interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
ref: QueryRef<Data, Variables>;
toJSON: () => SerializedRef<Data, Variables>;
}
/**
* Promise returned from `executeQuery`
*/
export interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
}
/**
* Execute Query
* @param queryRef query to execute.
* @returns `QueryPromise`
*/
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @returns `QueryRef`
*/
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
/**
* Execute Query
* @param dcInstance Data Connect instance to use.
* @param queryName Query to execute
* @param variables Variables to execute with
* @returns `QueryRef`
*/
export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
/**
* Converts serialized ref to query ref
* @param serializedRef ref to convert to `QueryRef`
* @returns `QueryRef`
*/
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;

View File

@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CacheProvider, CacheSettings, type ConnectorConfig } from '../api/DataConnect';
import { type AuthTokenProvider } from '../core/FirebaseAuthProvider';
import { InternalCacheProvider } from './CacheProvider';
import { InMemoryCacheProvider } from './InMemoryCacheProvider';
import { ResultTree } from './ResultTree';
export declare const Memory = "memory";
export type DataConnectStorage = typeof Memory;
/**
* ServerValues
*/
export interface ServerValues extends Record<string, unknown> {
maxAge?: number;
}
export declare class DataConnectCache {
private authProvider;
private projectId;
private connectorConfig;
private host;
cacheSettings: CacheSettings;
private cacheProvider;
private uid;
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
initialize(): Promise<void>;
getIdentifier(uid: string | null): Promise<string>;
initializeNewProviders(identifier: string): InternalCacheProvider;
containsResultTree(queryId: string): Promise<boolean>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
}
export declare class MemoryStub implements CacheProvider<'MEMORY'> {
type: 'MEMORY';
/**
* @internal
*/
initialize(cacheId: string): InMemoryCacheProvider;
}

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityDataObject } from './EntityDataObject';
import { ResultTree } from './ResultTree';
export interface InternalCacheProvider {
getEntityData(globalId: string): Promise<EntityDataObject>;
updateEntityData(entityData: EntityDataObject): Promise<void>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
close(): void;
}

View File

@@ -0,0 +1,37 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
export interface EntityDataObjectJson {
map: {
[key: string]: FDCScalarValue;
};
referencedFrom: string[];
globalID: string;
}
export declare class EntityDataObject {
readonly globalID: string;
getServerValue(key: string): unknown;
private serverValues;
private referencedFrom;
constructor(globalID: string);
getServerValues(): {
[key: string]: FDCScalarValue;
};
toJSON(): EntityDataObjectJson;
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
}

View File

@@ -0,0 +1,56 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InternalCacheProvider } from './CacheProvider';
import { EntityDataObject, EntityDataObjectJson, FDCScalarValue } from './EntityDataObject';
import { ImpactedQueryRefsAccumulator } from './ImpactedQueryRefsAccumulator';
export declare const GLOBAL_ID_KEY = "_id";
export declare const OBJECT_LISTS_KEY = "_objectLists";
export declare const REFERENCES_KEY = "_references";
export declare const SCALARS_KEY = "_scalars";
export declare const ENTITY_DATA_KEYS_KEY = "_entity_data_keys";
export declare class EntityNode {
entityData?: EntityDataObject;
scalars: Record<string, FDCScalarValue>;
references: {
[key: string]: EntityNode;
};
objectLists: {
[key: string]: EntityNode[];
};
globalId?: string;
entityDataKeys: Set<string>;
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
toJSON(mode: EncodingMode): Record<string, unknown>;
static fromJson(obj: DehydratedStubDataObject): EntityNode;
}
export interface DehydratedStubDataObject {
backingData?: EntityDataObjectJson;
globalID?: string;
scalars: {
[key: string]: FDCScalarValue;
};
references: {
[key: string]: DehydratedStubDataObject;
};
objectLists: {
[key: string]: DehydratedStubDataObject[];
};
}
export declare enum EncodingMode {
hydrated = 0,
dehydrated = 1
}

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare class ImpactedQueryRefsAccumulator {
private queryId;
impacted: Set<string>;
constructor(queryId: string);
add(impacted: string[]): void;
consumeEvents(): string[];
}

View File

@@ -0,0 +1,30 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InternalCacheProvider } from './CacheProvider';
import { EntityDataObject } from './EntityDataObject';
import { ResultTree } from './ResultTree';
export declare class InMemoryCacheProvider implements InternalCacheProvider {
private _keyId;
private edos;
private resultTrees;
constructor(_keyId: string);
setResultTree(queryId: string, rt: ResultTree): Promise<void>;
getResultTree(queryId: string): Promise<ResultTree | undefined>;
updateEntityData(entityData: EntityDataObject): Promise<void>;
getEntityData(globalId: string): Promise<EntityDataObject>;
close(): Promise<void>;
}

View File

@@ -0,0 +1,42 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityNode, DehydratedStubDataObject } from './EntityNode';
export declare class ResultTree {
private rootStub;
private maxAge;
readonly cachedAt: Date;
private _lastAccessed;
/**
* Create a {@link ResultTree} from a dehydrated JSON object.
* @param value The dehydrated JSON object.
* @returns The {@link ResultTree}.
*/
static fromJson(value: DehydratedResultTreeJson): ResultTree;
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
isStale(): boolean;
updateMaxAge(maxAgeInSeconds: number): void;
updateAccessed(): void;
get lastAccessed(): Date;
getRootStub(): EntityNode;
}
interface DehydratedResultTreeJson {
rootStub: DehydratedStubDataObject;
maxAge: number;
cachedAt: Date;
lastAccessed: Date;
}
export {};

View File

@@ -0,0 +1,40 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InternalCacheProvider } from './CacheProvider';
import { EntityNode } from './EntityNode';
interface DehydratedResults {
entityNode: EntityNode;
impacted: string[];
}
export declare class ResultTreeProcessor {
/**
* Hydrate the EntityNode into a JSON object so that it can be returned to the user.
* @param rootStubObject
* @returns {string}
*/
hydrateResults(rootStubObject: EntityNode): Record<string, unknown>;
/**
* Dehydrate results so that they can be stored in the cache.
* @param json
* @param entityIds
* @param cacheProvider
* @param queryId
* @returns {Promise<DehydratedResults>}
*/
dehydrateResults(json: Record<string, unknown>, entityIds: Record<string, unknown>, cacheProvider: InternalCacheProvider, queryId: string): Promise<DehydratedResults>;
}
export {};

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { OpResult } from '../api/Reference';
import { DataConnectExtension } from '../network';
export declare function parseEntityIds<T>(result: OpResult<T>): Record<string, unknown>;
export declare function populatePath(path: Array<string | number>, toUpdate: Record<string | number, unknown>, extension: DataConnectExtension): void;

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseApp } from '@firebase/app';
import { AppCheckInternalComponentName, AppCheckTokenListener, AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { Provider } from '@firebase/component';
/**
* @internal
* Abstraction around AppCheck's token fetching capabilities.
*/
export declare class AppCheckTokenProvider {
private appCheckProvider?;
private appCheck?;
private serverAppAppCheckToken?;
constructor(app: FirebaseApp, appCheckProvider?: Provider<AppCheckInternalComponentName> | undefined);
getToken(): Promise<AppCheckTokenResult | null>;
addTokenChangeListener(listener: AppCheckTokenListener): void;
}

View File

@@ -0,0 +1,36 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseOptions } from '@firebase/app-types';
import { FirebaseAuthInternal, FirebaseAuthInternalName, FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { Provider } from '@firebase/component';
export interface AuthTokenProvider {
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
getAuth(): FirebaseAuthInternal;
}
export type AuthTokenListener = (token: string | null) => void;
export declare class FirebaseAuthProvider implements AuthTokenProvider {
private _appName;
private _options;
private _authProvider;
private _auth;
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
getAuth(): FirebaseAuthInternal;
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
addTokenChangeListener(listener: AuthTokenListener): void;
removeTokenChangeListener(listener: (token: string | null) => void): void;
}

View File

@@ -0,0 +1,53 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FirebaseError } from '@firebase/util';
export type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
export type Code = DataConnectErrorCode;
export declare const Code: {
OTHER: DataConnectErrorCode;
ALREADY_INITIALIZED: DataConnectErrorCode;
NOT_INITIALIZED: DataConnectErrorCode;
NOT_SUPPORTED: DataConnectErrorCode;
INVALID_ARGUMENT: DataConnectErrorCode;
PARTIAL_ERROR: DataConnectErrorCode;
UNAUTHORIZED: DataConnectErrorCode;
};
/** An error returned by a DataConnect operation. */
export declare class DataConnectError extends FirebaseError {
/** @internal */
readonly name: string;
constructor(code: Code, message: string);
/** @internal */
toString(): string;
}
/** An error returned by a DataConnect operation. */
export declare class DataConnectOperationError extends DataConnectError {
/** @internal */
readonly name: string;
/** The response received from the backend. */
readonly response: DataConnectOperationFailureResponse;
/** @hideconstructor */
constructor(message: string, response: DataConnectOperationFailureResponse);
}
export interface DataConnectOperationFailureResponse {
readonly data?: Record<string, unknown> | null;
readonly errors: DataConnectOperationFailureResponseErrorInfo[];
}
export interface DataConnectOperationFailureResponseErrorInfo {
readonly message: string;
readonly path: Array<string | number>;
}

View File

@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type DataConnect } from '../../api/DataConnect';
import { QueryRef, QueryResult } from '../../api/query';
import { SerializedRef, DataSource } from '../../api/Reference';
import { DataConnectCache } from '../../cache/Cache';
import { DataConnectTransport } from '../../network';
import { DataConnectExtensionWithMaxAge } from '../../network/transport';
import { OnCompleteSubscription, OnErrorSubscription, OnResultSubscription } from './subscribe';
export declare function getRefSerializer<Data, Variables>(queryRef: QueryRef<Data, Variables>, data: Data, source: DataSource, fetchTime: string): () => SerializedRef<Data, Variables>;
export declare class QueryManager {
private transport;
private dc;
private cache?;
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
private callbacks;
private subscriptionCache;
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
private queue;
waitForQueuedWrites(): Promise<void>;
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
publishErrorToSubscribers(key: string, err: unknown): void;
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
enableEmulator(host: string, port: number): void;
}
export declare function getMaxAgeFromExtensions(extensions: DataConnectExtensionWithMaxAge[] | undefined): number | undefined;

View File

@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare const QueryFetchPolicy: {
readonly PREFER_CACHE: "PREFER_CACHE";
readonly CACHE_ONLY: "CACHE_ONLY";
readonly SERVER_ONLY: "SERVER_ONLY";
};
export type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
export interface ExecuteQueryOptions {
fetchPolicy: QueryFetchPolicy;
}

View File

@@ -0,0 +1,67 @@
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { QueryRef, QueryResult } from '../../api/query';
import { SerializedRef } from '../../api/Reference';
import { DataConnectError } from '../error';
/**
* `OnCompleteSubscription`
*/
export type OnCompleteSubscription = () => void;
/**
* Representation of full observer options in `subscribe`
*/
export interface SubscriptionOptions<Data, Variables> {
onNext?: OnResultSubscription<Data, Variables>;
onErr?: OnErrorSubscription;
onComplete?: OnCompleteSubscription;
}
/**
* Signature for `OnResultSubscription` for `subscribe`
*/
export type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
/**
* Signature for `OnErrorSubscription` for `subscribe`
*/
export type OnErrorSubscription = (err?: DataConnectError) => void;
/**
* Signature for unsubscribe from `subscribe`
*/
export type QueryUnsubscribe = () => void;
/**
* Representation of user provided subscription options.
*/
export interface DataConnectSubscription<Data, Variables> {
userCallback: OnResultSubscription<Data, Variables>;
errCallback?: (e?: DataConnectError) => void;
unsubscribe: () => void;
}
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param observer observer object to use for subscribing.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
/**
* Subscribe to a `QueryRef`
* @param queryRefOrSerializedResult query ref or serialized result.
* @param onNext Callback to call when result comes back.
* @param onError Callback to call when error gets thrown.
* @param onComplete Called when subscription completes.
* @returns `SubscriptionOptions`
*/
export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** The semver (www.semver.org) version of the SDK. */
export declare let SDK_VERSION: string;
/**
* SDK_VERSION should be set before any database instance is created
* @internal
*/
export declare function setSDKVersion(version: string): void;

View File

@@ -0,0 +1,29 @@
/**
* Firebase Data Connect
*
* @packageDocumentation
*/
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnect } from './api/DataConnect';
export * from './api';
export * from './api.browser';
declare module '@firebase/component' {
interface NameServiceMapping {
'data-connect': DataConnect;
}
}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './api';
export * from './api.node';

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LogLevelString } from '@firebase/logger';
export declare function setLogLevel(logLevel: LogLevelString): void;
export declare function logDebug(msg: string): void;
export declare function logError(msg: string): void;

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CallerSdkType, DataConnectResponse } from './transport';
export declare function initializeFetch(fetchImpl: typeof fetch): void;
export interface DataConnectFetchBody<T> {
name: string;
operationName: string;
variables: T;
}
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>>;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { CallerSdkType, CallerSdkTypeEnum, DataConnectTransport, DataConnectEntityArray, DataConnectSingleEntity, DataConnectExtension, Extensions, TransportClass } from './transport';

View File

@@ -0,0 +1,81 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
/**
* enum representing different flavors of the SDK used by developers
* use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
*/
export type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
export declare const CallerSdkTypeEnum: {
readonly Base: "Base";
readonly Generated: "Generated";
readonly TanstackReactCore: "TanstackReactCore";
readonly GeneratedReact: "GeneratedReact";
readonly TanstackAngularCore: "TanstackAngularCore";
readonly GeneratedAngular: "GeneratedAngular";
};
export interface DataConnectEntityArray {
entityIds: string[];
}
export interface DataConnectSingleEntity {
entityId: string;
}
export type DataConnectExtension = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity);
/** @internal */
export interface DataConnectMaxAge {
maxAge: string;
}
/** @internal */
export type DataConnectExtensionWithMaxAge = {
path: Array<string | number>;
} & (DataConnectEntityArray | DataConnectSingleEntity | DataConnectMaxAge);
export interface Extensions {
dataConnect?: DataConnectExtension[];
}
/** @internal */
export interface ExtensionsWithMaxAge {
dataConnect?: DataConnectExtensionWithMaxAge[];
}
export interface DataConnectResponse<T> {
data: T;
errors: Error[];
extensions: Extensions;
}
/** @internal */
export interface DataConnectResponseWithMaxAge<T> {
data: T;
errors: Error[];
extensions: ExtensionsWithMaxAge;
}
/**
* @internal
*/
export interface DataConnectTransport {
invokeQuery<T, U>(queryName: string, body?: U): Promise<DataConnectResponseWithMaxAge<T>>;
invokeMutation<T, U>(queryName: string, body?: U): Promise<DataConnectResponse<T>>;
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
onTokenChanged: (token: string | null) => void;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
}
/**
* @internal
*/
export type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType) => DataConnectTransport;

View File

@@ -0,0 +1,49 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
import { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
import { CallerSdkType, DataConnectResponse, DataConnectTransport } from '.';
export declare class RESTTransport implements DataConnectTransport {
private apiKey?;
private appId?;
private authProvider?;
private appCheckProvider?;
private _isUsingGen;
private _callerSdkType;
private _host;
private _port;
private _location;
private _connectorName;
private _secure;
private _project;
private _serviceName;
private _accessToken;
private _appCheckToken;
private _lastToken;
private _isUsingEmulator;
constructor(options: DataConnectOptions, apiKey?: string | undefined, appId?: (string | null) | undefined, authProvider?: AuthTokenProvider | undefined, appCheckProvider?: AppCheckTokenProvider | undefined, transportOptions?: TransportOptions | undefined, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType);
get endpointUrl(): string;
useEmulator(host: string, port?: number, isSecure?: boolean): void;
onTokenChanged(newToken: string | null): void;
getWithAuth(forceToken?: boolean): Promise<string | null>;
_setLastToken(lastToken: string | null): void;
withRetry<T>(promiseFactory: () => Promise<DataConnectResponse<T>>, retry?: boolean): Promise<DataConnectResponse<T>>;
invokeQuery: <T, U>(queryName: string, body?: U) => Promise<DataConnectResponse<T>>;
invokeMutation: <T, U>(queryName: string, body?: U) => Promise<DataConnectResponse<T>>;
_setCallerSdkType(callerSdkType: CallerSdkType): void;
}

View File

@@ -0,0 +1 @@
export declare function registerDataConnect(variant?: string): void;

View File

@@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "0.1.2"
}
]
}

View File

@@ -0,0 +1,22 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type HmacImpl = (obj: Record<string, unknown>) => string;
export declare let encoderImpl: HmacImpl;
export type DecodeHmacImpl = (s: string) => Record<string, unknown>;
export declare let decoderImpl: DecodeHmacImpl;
export declare function setEncoder(encoder: HmacImpl): void;
export declare function setDecoder(decoder: DecodeHmacImpl): void;

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare function setIfNotExists<T>(map: Map<string, T>, key: string, val: T): void;

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataConnectOptions, TransportOptions } from '../api/DataConnect';
export declare const PROD_HOST = "firebasedataconnect.googleapis.com";
export declare function urlBuilder(projectConfig: DataConnectOptions, transportOptions: TransportOptions): string;
export declare function addToken(url: string, apiKey?: string): string;

View File

@@ -0,0 +1,33 @@
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ConnectorConfig, DataConnect } from '../api/DataConnect';
interface ParsedArgs<Variables> {
dc: DataConnect;
vars: Variables;
}
/**
* The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
* and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
* @param connectorConfig
* @param dcOrVars
* @param vars
* @param validateVars
* @returns {DataConnect} and {Variables} instance
* @internal
*/
export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
export {};

78
node_modules/@firebase/data-connect/package.json generated vendored Normal file
View File

@@ -0,0 +1,78 @@
{
"name": "@firebase/data-connect",
"version": "0.4.0",
"description": "",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "dist/index.node.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"exports": {
".": {
"types": "./dist/public.d.ts",
"node": {
"import": "./dist/node-esm/index.node.esm.js",
"require": "./dist/index.node.cjs.js"
},
"browser": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm.js"
},
"default": "./dist/index.esm.js"
},
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore' --fix",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c rollup.config.js && yarn api-report",
"prettier": "prettier --write '*.js' '*.ts' '@(src|test)/**/*.ts'",
"build:deps": "lerna run --scope @firebase/'{app,data-connect}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p --npm-path npm lint test:emulator",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
"test:all": "run-p --npm-path npm lint test:browser test:node",
"test:browser": "karma start",
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
"test:unit": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/unit/**/*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/dataconnect-test-runner.ts",
"api-report": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ../../repo-scripts/prune-dts/extract-public-api.ts --package data-connect --packageRoot . --typescriptDts ./dist/src/index.d.ts --rollupDts ./dist/private.d.ts --untrimmedRollupDts ./dist/internal.d.ts --publicDts ./dist/public.d.ts && yarn api-report:api-json",
"api-report:api-json": "rm -rf temp && api-extractor run --local --verbose",
"doc": "api-documenter markdown --input temp --output docs",
"typings:public": "node ../../scripts/build/use_typings.js ./dist/public.d.ts"
},
"license": "Apache-2.0",
"peerDependencies": {
"@firebase/app": "0.x"
},
"dependencies": {
"@firebase/auth-interop-types": "0.2.4",
"@firebase/component": "0.7.1",
"@firebase/logger": "0.5.0",
"@firebase/util": "1.14.0",
"tslib": "^2.1.0"
},
"devDependencies": {
"@firebase/app": "0.14.9",
"rollup": "2.79.2",
"rollup-plugin-typescript2": "0.36.0",
"typescript": "5.5.4"
},
"repository": {
"directory": "packages/data-connect",
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"typings": "./dist/public.d.ts",
"nyc": {
"extension": [
".ts"
],
"reportDir": "./coverage/node"
}
}