@depup/firebase__data-connect 0.4.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/index.cjs.js +2069 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +2039 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.node.cjs.js +2084 -0
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/internal.d.ts +748 -0
- package/dist/node-esm/index.node.esm.js +2054 -0
- package/dist/node-esm/index.node.esm.js.map +1 -0
- package/dist/node-esm/package.json +1 -0
- package/dist/node-esm/src/api/DataConnect.d.ts +159 -0
- package/dist/node-esm/src/api/Mutation.d.ts +61 -0
- package/dist/node-esm/src/api/Reference.d.ts +53 -0
- package/dist/node-esm/src/api/index.d.ts +25 -0
- package/dist/node-esm/src/api/query.d.ts +71 -0
- package/dist/node-esm/src/api.browser.d.ts +18 -0
- package/dist/node-esm/src/api.node.d.ts +18 -0
- package/dist/node-esm/src/cache/Cache.d.ts +53 -0
- package/dist/node-esm/src/cache/CacheProvider.d.ts +25 -0
- package/dist/node-esm/src/cache/EntityDataObject.d.ts +37 -0
- package/dist/node-esm/src/cache/EntityNode.d.ts +56 -0
- package/dist/node-esm/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
- package/dist/node-esm/src/cache/InMemoryCacheProvider.d.ts +30 -0
- package/dist/node-esm/src/cache/ResultTree.d.ts +42 -0
- package/dist/node-esm/src/cache/ResultTreeProcessor.d.ts +40 -0
- package/dist/node-esm/src/cache/cacheUtils.d.ts +20 -0
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +31 -0
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +36 -0
- package/dist/node-esm/src/core/error.d.ts +53 -0
- package/dist/node-esm/src/core/query/QueryManager.d.ts +47 -0
- package/dist/node-esm/src/core/query/queryOptions.d.ts +25 -0
- package/dist/node-esm/src/core/query/subscribe.d.ts +67 -0
- package/dist/node-esm/src/core/version.d.ts +23 -0
- package/dist/node-esm/src/index.d.ts +29 -0
- package/dist/node-esm/src/index.node.d.ts +18 -0
- package/dist/node-esm/src/logger.d.ts +20 -0
- package/dist/node-esm/src/network/fetch.d.ts +24 -0
- package/dist/node-esm/src/network/index.d.ts +17 -0
- package/dist/node-esm/src/network/transport/index.d.ts +81 -0
- package/dist/node-esm/src/network/transport/rest.d.ts +49 -0
- package/dist/node-esm/src/register.d.ts +1 -0
- package/dist/node-esm/src/util/encoder.d.ts +22 -0
- package/dist/node-esm/src/util/map.d.ts +17 -0
- package/dist/node-esm/src/util/url.d.ts +20 -0
- package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
- package/dist/private.d.ts +655 -0
- package/dist/public.d.ts +350 -0
- package/dist/src/api/DataConnect.d.ts +159 -0
- package/dist/src/api/Mutation.d.ts +61 -0
- package/dist/src/api/Reference.d.ts +53 -0
- package/dist/src/api/index.d.ts +25 -0
- package/dist/src/api/query.d.ts +71 -0
- package/dist/src/api.browser.d.ts +18 -0
- package/dist/src/api.node.d.ts +18 -0
- package/dist/src/cache/Cache.d.ts +53 -0
- package/dist/src/cache/CacheProvider.d.ts +25 -0
- package/dist/src/cache/EntityDataObject.d.ts +37 -0
- package/dist/src/cache/EntityNode.d.ts +56 -0
- package/dist/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
- package/dist/src/cache/InMemoryCacheProvider.d.ts +30 -0
- package/dist/src/cache/ResultTree.d.ts +42 -0
- package/dist/src/cache/ResultTreeProcessor.d.ts +40 -0
- package/dist/src/cache/cacheUtils.d.ts +20 -0
- package/dist/src/core/AppCheckTokenProvider.d.ts +31 -0
- package/dist/src/core/FirebaseAuthProvider.d.ts +36 -0
- package/dist/src/core/error.d.ts +53 -0
- package/dist/src/core/query/QueryManager.d.ts +47 -0
- package/dist/src/core/query/queryOptions.d.ts +25 -0
- package/dist/src/core/query/subscribe.d.ts +67 -0
- package/dist/src/core/version.d.ts +23 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.node.d.ts +18 -0
- package/dist/src/logger.d.ts +20 -0
- package/dist/src/network/fetch.d.ts +24 -0
- package/dist/src/network/index.d.ts +17 -0
- package/dist/src/network/transport/index.d.ts +81 -0
- package/dist/src/network/transport/rest.d.ts +49 -0
- package/dist/src/register.d.ts +1 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/util/encoder.d.ts +22 -0
- package/dist/src/util/map.d.ts +17 -0
- package/dist/src/util/url.d.ts +20 -0
- package/dist/src/util/validateArgs.d.ts +33 -0
- package/package.json +99 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.esm.js","sources":["../../src/core/error.ts","../../src/core/version.ts","../../src/logger.ts","../../src/network/transport/index.ts","../../src/network/fetch.ts","../../src/cache/EntityDataObject.ts","../../src/cache/InMemoryCacheProvider.ts","../../src/cache/EntityNode.ts","../../src/cache/ResultTree.ts","../../src/cache/ImpactedQueryRefsAccumulator.ts","../../src/cache/ResultTreeProcessor.ts","../../src/cache/Cache.ts","../../src/core/AppCheckTokenProvider.ts","../../src/core/FirebaseAuthProvider.ts","../../src/api/Reference.ts","../../src/cache/cacheUtils.ts","../../src/util/encoder.ts","../../src/core/query/QueryManager.ts","../../src/util/url.ts","../../src/network/transport/rest.ts","../../src/api/Mutation.ts","../../src/api/DataConnect.ts","../../src/register.ts","../../src/core/query/queryOptions.ts","../../src/api/query.ts","../../src/util/validateArgs.ts","../../src/core/query/subscribe.ts","../../src/index.node.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseError } from '@firebase/util';\n\nexport type DataConnectErrorCode =\n | 'other'\n | 'already-initialized'\n | 'not-initialized'\n | 'not-supported'\n | 'invalid-argument'\n | 'partial-error'\n | 'unauthorized';\n\nexport type Code = DataConnectErrorCode;\n\nexport const Code = {\n OTHER: 'other' as DataConnectErrorCode,\n ALREADY_INITIALIZED: 'already-initialized' as DataConnectErrorCode,\n NOT_INITIALIZED: 'not-initialized' as DataConnectErrorCode,\n NOT_SUPPORTED: 'not-supported' as DataConnectErrorCode,\n INVALID_ARGUMENT: 'invalid-argument' as DataConnectErrorCode,\n PARTIAL_ERROR: 'partial-error' as DataConnectErrorCode,\n UNAUTHORIZED: 'unauthorized' as DataConnectErrorCode\n};\n\n/** An error returned by a DataConnect operation. */\nexport class DataConnectError extends FirebaseError {\n /** @internal */\n readonly name: string = 'DataConnectError';\n\n constructor(code: Code, message: string) {\n super(code, message);\n\n // Ensure the instanceof operator works as expected on subclasses of Error.\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#custom_error_types\n // and https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget\n Object.setPrototypeOf(this, DataConnectError.prototype);\n }\n\n /** @internal */\n toString(): string {\n return `${this.name}[code=${this.code}]: ${this.message}`;\n }\n}\n\n/** An error returned by a DataConnect operation. */\nexport class DataConnectOperationError extends DataConnectError {\n /** @internal */\n readonly name: string = 'DataConnectOperationError';\n\n /** The response received from the backend. */\n readonly response: DataConnectOperationFailureResponse;\n\n /** @hideconstructor */\n constructor(message: string, response: DataConnectOperationFailureResponse) {\n super(Code.PARTIAL_ERROR, message);\n this.response = response;\n }\n}\n\nexport interface DataConnectOperationFailureResponse {\n // The \"data\" provided by the backend in the response message.\n //\n // Will be `undefined` if no \"data\" was provided in the response message.\n // Otherwise, will be `null` if `null` was explicitly specified as the \"data\"\n // in the response message. Otherwise, will be the value of the \"data\"\n // specified as the \"data\" in the response message\n readonly data?: Record<string, unknown> | null;\n\n // The list of errors provided by the backend in the response message.\n readonly errors: DataConnectOperationFailureResponseErrorInfo[];\n}\n\n// Information about the error, as provided in the response from the backend.\n// See https://spec.graphql.org/draft/#sec-Errors\nexport interface DataConnectOperationFailureResponseErrorInfo {\n // The error message.\n readonly message: string;\n\n // The path of the field in the response data to which this error relates.\n // String values in this array refer to field names. Numeric values in this\n // array always satisfy `Number.isInteger()` and refer to the index in an\n // array.\n readonly path: Array<string | number>;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** The semver (www.semver.org) version of the SDK. */\nexport let SDK_VERSION = '';\n\n/**\n * SDK_VERSION should be set before any database instance is created\n * @internal\n */\nexport function setSDKVersion(version: string): void {\n SDK_VERSION = version;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Logger, LogLevelString } from '@firebase/logger';\n\nimport { SDK_VERSION } from './core/version';\n\nconst logger = new Logger('@firebase/data-connect');\nexport function setLogLevel(logLevel: LogLevelString): void {\n logger.setLogLevel(logLevel);\n}\nexport function logDebug(msg: string): void {\n logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`);\n}\n\nexport function logError(msg: string): void {\n logger.error(`DataConnect (${SDK_VERSION}): ${msg}`);\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DataConnectOptions, TransportOptions } from '../../api/DataConnect';\nimport { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';\nimport { AuthTokenProvider } from '../../core/FirebaseAuthProvider';\n\n/**\n * enum representing different flavors of the SDK used by developers\n * use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning\n */\nexport type CallerSdkType =\n | 'Base' // Core JS SDK\n | 'Generated' // Generated JS SDK\n | 'TanstackReactCore' // Tanstack non-generated React SDK\n | 'GeneratedReact' // Generated React SDK\n | 'TanstackAngularCore' // Tanstack non-generated Angular SDK\n | 'GeneratedAngular'; // Generated Angular SDK\nexport const CallerSdkTypeEnum = {\n Base: 'Base', // Core JS SDK\n Generated: 'Generated', // Generated JS SDK\n TanstackReactCore: 'TanstackReactCore', // Tanstack non-generated React SDK\n GeneratedReact: 'GeneratedReact', // Tanstack non-generated Angular SDK\n TanstackAngularCore: 'TanstackAngularCore', // Tanstack non-generated Angular SDK\n GeneratedAngular: 'GeneratedAngular' // Generated Angular SDK\n} as const;\n\nexport interface DataConnectEntityArray {\n entityIds: string[];\n}\n\nexport interface DataConnectSingleEntity {\n entityId: string;\n}\n\nexport type DataConnectExtension = {\n path: Array<string | number>;\n} & (DataConnectEntityArray | DataConnectSingleEntity);\n\n/** @internal */\nexport interface DataConnectMaxAge {\n maxAge: string;\n}\n\n/** @internal */\nexport type DataConnectExtensionWithMaxAge = {\n path: Array<string | number>;\n} & (DataConnectEntityArray | DataConnectSingleEntity | DataConnectMaxAge);\n\nexport interface Extensions {\n dataConnect?: DataConnectExtension[];\n}\n\n/** @internal */\nexport interface ExtensionsWithMaxAge {\n dataConnect?: DataConnectExtensionWithMaxAge[];\n}\n\nexport interface DataConnectResponse<T> {\n data: T;\n errors: Error[];\n extensions: Extensions;\n}\n\n/** @internal */\nexport interface DataConnectResponseWithMaxAge<T> {\n data: T;\n errors: Error[];\n extensions: ExtensionsWithMaxAge;\n}\n\n/**\n * @internal\n */\nexport interface DataConnectTransport {\n invokeQuery<T, U>(\n queryName: string,\n body?: U\n ): Promise<DataConnectResponseWithMaxAge<T>>;\n invokeMutation<T, U>(\n queryName: string,\n body?: U\n ): Promise<DataConnectResponse<T>>;\n useEmulator(host: string, port?: number, sslEnabled?: boolean): void;\n onTokenChanged: (token: string | null) => void;\n _setCallerSdkType(callerSdkType: CallerSdkType): void;\n}\n\n/**\n * @internal\n */\nexport type TransportClass = new (\n options: DataConnectOptions,\n apiKey?: string,\n appId?: string,\n authProvider?: AuthTokenProvider,\n appCheckProvider?: AppCheckTokenProvider,\n transportOptions?: TransportOptions,\n _isUsingGen?: boolean,\n _callerSdkType?: CallerSdkType\n) => DataConnectTransport;\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isCloudWorkstation } from '@firebase/util';\n\nimport {\n Code,\n DataConnectError,\n DataConnectOperationError,\n DataConnectOperationFailureResponse\n} from '../core/error';\nimport { SDK_VERSION } from '../core/version';\nimport { logError } from '../logger';\n\nimport {\n CallerSdkType,\n CallerSdkTypeEnum,\n Extensions,\n DataConnectResponse\n} from './transport';\n\nlet connectFetch: typeof fetch | null = globalThis.fetch;\nexport function initializeFetch(fetchImpl: typeof fetch): void {\n connectFetch = fetchImpl;\n}\nfunction getGoogApiClientValue(\n _isUsingGen: boolean,\n _callerSdkType: CallerSdkType\n): string {\n let str = 'gl-js/ fire/' + SDK_VERSION;\n if (\n _callerSdkType !== CallerSdkTypeEnum.Base &&\n _callerSdkType !== CallerSdkTypeEnum.Generated\n ) {\n str += ' js/' + _callerSdkType.toLowerCase();\n } else if (_isUsingGen || _callerSdkType === CallerSdkTypeEnum.Generated) {\n str += ' js/gen';\n }\n return str;\n}\nexport interface DataConnectFetchBody<T> {\n name: string;\n operationName: string;\n variables: T;\n}\nexport async function dcFetch<T, U>(\n url: string,\n body: DataConnectFetchBody<U>,\n { signal }: AbortController,\n appId: string | null | undefined,\n accessToken: string | null,\n appCheckToken: string | null | undefined,\n _isUsingGen: boolean,\n _callerSdkType: CallerSdkType,\n _isUsingEmulator: boolean\n): Promise<DataConnectResponse<T>> {\n if (!connectFetch) {\n throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');\n }\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType)\n };\n if (accessToken) {\n headers['X-Firebase-Auth-Token'] = accessToken;\n }\n if (appId) {\n headers['x-firebase-gmpid'] = appId;\n }\n if (appCheckToken) {\n headers['X-Firebase-AppCheck'] = appCheckToken;\n }\n const bodyStr = JSON.stringify(body);\n const fetchOptions: RequestInit = {\n body: bodyStr,\n method: 'POST',\n headers,\n signal\n };\n if (isCloudWorkstation(url) && _isUsingEmulator) {\n fetchOptions.credentials = 'include';\n }\n\n let response: Response;\n try {\n response = await connectFetch(url, fetchOptions);\n } catch (err) {\n throw new DataConnectError(\n Code.OTHER,\n 'Failed to fetch: ' + JSON.stringify(err)\n );\n }\n let jsonResponse: JsonResponse<T>;\n try {\n jsonResponse = await response.json();\n } catch (e) {\n throw new DataConnectError(Code.OTHER, JSON.stringify(e));\n }\n const message = getErrorMessage(jsonResponse);\n if (response.status >= 400) {\n logError('Error while performing request: ' + JSON.stringify(jsonResponse));\n if (response.status === 401) {\n throw new DataConnectError(Code.UNAUTHORIZED, message);\n }\n throw new DataConnectError(Code.OTHER, message);\n }\n if (jsonResponse.errors && jsonResponse.errors.length) {\n const stringified = JSON.stringify(jsonResponse.errors);\n const failureResponse: DataConnectOperationFailureResponse = {\n errors: jsonResponse.errors,\n data: jsonResponse.data as Record<string, unknown>\n };\n throw new DataConnectOperationError(\n 'DataConnect error while performing request: ' + stringified,\n failureResponse\n );\n }\n if (!jsonResponse.extensions) {\n jsonResponse.extensions = {\n dataConnect: []\n };\n }\n return jsonResponse as DataConnectResponse<T>;\n}\ninterface JsonResponse<T> {\n message?: string;\n errors: [];\n data: Record<string, unknown> | T | null;\n extensions?: Extensions;\n}\nfunction getErrorMessage(obj: JsonResponse<unknown>): string {\n if ('message' in obj && obj.message) {\n return obj.message;\n }\n return JSON.stringify(obj);\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type FDCScalarValue =\n | string\n | number\n | boolean\n | undefined\n | null\n | Record<string, unknown>\n | FDCScalarValue[];\n\nexport interface EntityDataObjectJson {\n map: {\n [key: string]: FDCScalarValue;\n };\n referencedFrom: string[];\n globalID: string;\n}\n\nexport class EntityDataObject {\n getServerValue(key: string): unknown {\n return this.serverValues[key];\n }\n private serverValues: { [key: string]: FDCScalarValue } = {};\n private referencedFrom = new Set<string>();\n constructor(public readonly globalID: string) {}\n getServerValues(): { [key: string]: FDCScalarValue } {\n return this.serverValues;\n }\n toJSON(): EntityDataObjectJson {\n return {\n globalID: this.globalID,\n map: this.serverValues,\n referencedFrom: Array.from(this.referencedFrom)\n };\n }\n static fromJSON(json: EntityDataObjectJson): EntityDataObject {\n const edo = new EntityDataObject(json.globalID);\n edo.serverValues = json.map;\n edo.referencedFrom = new Set(json.referencedFrom);\n return edo;\n }\n\n updateServerValue(\n key: string,\n value: FDCScalarValue,\n requestedFrom: string\n ): string[] {\n this.serverValues[key] = value;\n this.referencedFrom.add(requestedFrom);\n return Array.from(this.referencedFrom);\n }\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InternalCacheProvider } from './CacheProvider';\nimport { EntityDataObject } from './EntityDataObject';\nimport { ResultTree } from './ResultTree';\n\nexport class InMemoryCacheProvider implements InternalCacheProvider {\n private edos = new Map<string, EntityDataObject>();\n private resultTrees = new Map<string, ResultTree>();\n constructor(private _keyId: string) {}\n\n async setResultTree(queryId: string, rt: ResultTree): Promise<void> {\n this.resultTrees.set(queryId, rt);\n }\n async getResultTree(queryId: string): Promise<ResultTree | undefined> {\n return this.resultTrees.get(queryId);\n }\n async updateEntityData(entityData: EntityDataObject): Promise<void> {\n this.edos.set(entityData.globalID, entityData);\n }\n async getEntityData(globalId: string): Promise<EntityDataObject> {\n if (!this.edos.has(globalId)) {\n this.edos.set(globalId, new EntityDataObject(globalId));\n }\n // Because of the above, we can guarantee that there will be an EDO at the globalId.\n return this.edos.get(globalId)!;\n }\n close(): Promise<void> {\n // No-op\n return Promise.resolve();\n }\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Code, DataConnectError } from '../core/error';\n\nimport { InternalCacheProvider } from './CacheProvider';\nimport {\n EntityDataObject,\n EntityDataObjectJson,\n FDCScalarValue\n} from './EntityDataObject';\nimport { ImpactedQueryRefsAccumulator } from './ImpactedQueryRefsAccumulator';\n\nexport const GLOBAL_ID_KEY = '_id';\nexport const OBJECT_LISTS_KEY = '_objectLists';\nexport const REFERENCES_KEY = '_references';\nexport const SCALARS_KEY = '_scalars';\nexport const ENTITY_DATA_KEYS_KEY = '_entity_data_keys';\nexport class EntityNode {\n entityData?: EntityDataObject;\n scalars: Record<string, FDCScalarValue> = {};\n references: { [key: string]: EntityNode } = {};\n objectLists: {\n [key: string]: EntityNode[];\n } = {};\n globalId?: string;\n entityDataKeys: Set<string> = new Set();\n\n async loadData(\n queryId: string,\n values: FDCScalarValue,\n entityIds: Record<string, unknown> | undefined,\n acc: ImpactedQueryRefsAccumulator,\n cacheProvider: InternalCacheProvider\n ): Promise<void> {\n if (values === undefined) {\n return;\n }\n if (typeof values !== 'object' || Array.isArray(values)) {\n throw new DataConnectError(\n Code.INVALID_ARGUMENT,\n 'EntityNode initialized with non-object value'\n );\n }\n if (values === null) {\n return;\n }\n\n if (\n typeof values === 'object' &&\n entityIds &&\n entityIds[GLOBAL_ID_KEY] &&\n typeof entityIds[GLOBAL_ID_KEY] === 'string'\n ) {\n this.globalId = entityIds[GLOBAL_ID_KEY];\n this.entityData = await cacheProvider.getEntityData(this.globalId);\n }\n for (const key in values) {\n if (values.hasOwnProperty(key)) {\n if (typeof values[key] === 'object') {\n if (Array.isArray(values[key])) {\n const ids: Record<string, unknown> | undefined =\n entityIds && (entityIds[key] as Record<string, unknown>);\n const objArray: EntityNode[] = [];\n const scalarArray: Array<NonNullable<FDCScalarValue>> = [];\n for (const [index, value] of values[key].entries()) {\n if (typeof value === 'object') {\n if (Array.isArray(value)) {\n // Note: we don't support sparse arrays.\n } else {\n const entityNode = new EntityNode();\n await entityNode.loadData(\n queryId,\n value,\n ids && (ids[index] as Record<string, unknown>),\n acc,\n cacheProvider\n );\n objArray.push(entityNode);\n }\n } else {\n scalarArray.push(value);\n }\n }\n if (scalarArray.length > 0 && objArray.length > 0) {\n this.scalars[key] = values[key];\n } else if (scalarArray.length > 0) {\n if (this.entityData) {\n const impactedRefs = this.entityData.updateServerValue(\n key,\n scalarArray,\n queryId\n );\n this.entityDataKeys.add(key);\n acc.add(impactedRefs);\n } else {\n this.scalars[key] = scalarArray;\n }\n } else if (objArray.length > 0) {\n this.objectLists[key] = objArray;\n } else {\n this.scalars[key] = [];\n }\n } else {\n if (values[key] === null) {\n this.scalars[key] = null;\n continue;\n }\n const entityNode = new EntityNode();\n // TODO: Load Data might need to be pushed into ResultTreeProcessor instead.\n await entityNode.loadData(\n queryId,\n (values as Record<string, FDCScalarValue>)[key],\n entityIds && (entityIds[key] as Record<string, unknown>),\n acc,\n cacheProvider\n );\n this.references[key] = entityNode;\n }\n } else {\n if (this.entityData) {\n const impactedRefs = this.entityData.updateServerValue(\n key,\n values[key] as FDCScalarValue,\n queryId\n );\n this.entityDataKeys.add(key);\n acc.add(impactedRefs);\n } else {\n this.scalars[key] = values[key] as FDCScalarValue;\n }\n }\n }\n }\n if (this.entityData) {\n await cacheProvider.updateEntityData(this.entityData);\n }\n }\n\n toJSON(mode: EncodingMode): Record<string, unknown> {\n const resultObject: Record<string, unknown> = {};\n if (mode === EncodingMode.hydrated) {\n if (this.entityData) {\n for (const key of this.entityDataKeys) {\n resultObject[key] = this.entityData.getServerValue(key);\n }\n }\n\n if (this.scalars) {\n Object.assign(resultObject, this.scalars);\n }\n if (this.references) {\n for (const key in this.references) {\n if (this.references.hasOwnProperty(key)) {\n resultObject[key] = this.references[key].toJSON(mode);\n }\n }\n }\n if (this.objectLists) {\n for (const key in this.objectLists) {\n if (this.objectLists.hasOwnProperty(key)) {\n resultObject[key] = this.objectLists[key].map(obj =>\n obj.toJSON(mode)\n );\n }\n }\n }\n return resultObject;\n } else {\n // Get JSON representation of dehydrated list\n if (this.entityData) {\n resultObject[GLOBAL_ID_KEY] = this.entityData.globalID;\n }\n\n resultObject[ENTITY_DATA_KEYS_KEY] = Array.from(this.entityDataKeys);\n\n if (this.scalars) {\n resultObject[SCALARS_KEY] = this.scalars;\n }\n\n if (this.references) {\n const references = {} as Record<string, unknown>;\n for (const key in this.references) {\n if (this.references.hasOwnProperty(key)) {\n references[key] = this.references[key].toJSON(mode);\n }\n }\n resultObject[REFERENCES_KEY] = references;\n }\n if (this.objectLists) {\n const objectLists = {} as Record<string, unknown>;\n for (const key in this.objectLists) {\n if (this.objectLists.hasOwnProperty(key)) {\n objectLists[key] = this.objectLists[key].map(obj =>\n obj.toJSON(mode)\n );\n }\n }\n resultObject[OBJECT_LISTS_KEY] = objectLists;\n }\n }\n\n return resultObject;\n }\n\n static fromJson(obj: DehydratedStubDataObject): EntityNode {\n const sdo = new EntityNode();\n if (obj.backingData) {\n sdo.entityData = EntityDataObject.fromJSON(obj.backingData);\n }\n sdo.globalId = obj.globalID;\n sdo.scalars = obj.scalars;\n if (obj.references) {\n const references: Record<string, unknown> = {};\n for (const key in obj.references) {\n if (obj.references.hasOwnProperty(key)) {\n references[key] = EntityNode.fromJson(obj.references[key]);\n }\n }\n sdo.references = references as typeof sdo.references;\n }\n if (obj.objectLists) {\n const objectLists: Record<string, unknown> = {};\n for (const key in obj.objectLists) {\n if (obj.objectLists.hasOwnProperty(key)) {\n objectLists[key] = obj.objectLists[key].map(obj =>\n EntityNode.fromJson(obj)\n );\n }\n }\n sdo.objectLists = objectLists as typeof sdo.objectLists;\n }\n return sdo;\n }\n}\n\nexport interface DehydratedStubDataObject {\n backingData?: EntityDataObjectJson;\n globalID?: string;\n scalars: { [key: string]: FDCScalarValue };\n references: { [key: string]: DehydratedStubDataObject };\n objectLists: {\n [key: string]: DehydratedStubDataObject[];\n };\n}\n\n// Helpful for storing in persistent cache, which is not available yet.\nexport enum EncodingMode {\n hydrated,\n dehydrated\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EntityNode, DehydratedStubDataObject } from './EntityNode';\n\nexport class ResultTree {\n /**\n * Create a {@link ResultTree} from a dehydrated JSON object.\n * @param value The dehydrated JSON object.\n * @returns The {@link ResultTree}.\n */\n static fromJson(value: DehydratedResultTreeJson): ResultTree {\n return new ResultTree(\n EntityNode.fromJson(value.rootStub),\n value.maxAge,\n value.cachedAt,\n value.lastAccessed\n );\n }\n constructor(\n private rootStub: EntityNode,\n private maxAge: number = 0,\n public readonly cachedAt: Date,\n private _lastAccessed: Date\n ) {}\n isStale(): boolean {\n return (\n Date.now() - new Date(this.cachedAt.getTime()).getTime() >\n this.maxAge * 1000\n );\n }\n updateMaxAge(maxAgeInSeconds: number): void {\n this.maxAge = maxAgeInSeconds;\n }\n updateAccessed(): void {\n this._lastAccessed = new Date();\n }\n get lastAccessed(): Date {\n return this._lastAccessed;\n }\n getRootStub(): EntityNode {\n return this.rootStub;\n }\n}\n\ninterface DehydratedResultTreeJson {\n rootStub: DehydratedStubDataObject;\n maxAge: number;\n cachedAt: Date;\n lastAccessed: Date;\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class ImpactedQueryRefsAccumulator {\n impacted = new Set<string>();\n constructor(private queryId: string) {}\n add(impacted: string[]): void {\n impacted\n .filter(ref => ref !== this.queryId)\n .forEach(ref => this.impacted.add(ref));\n }\n consumeEvents(): string[] {\n const events = Array.from(this.impacted);\n this.impacted.clear();\n return events;\n }\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InternalCacheProvider } from './CacheProvider';\nimport { EncodingMode, EntityNode } from './EntityNode';\nimport { ImpactedQueryRefsAccumulator } from './ImpactedQueryRefsAccumulator';\n\ninterface DehydratedResults {\n entityNode: EntityNode;\n impacted: string[];\n}\n\nexport class ResultTreeProcessor {\n /**\n * Hydrate the EntityNode into a JSON object so that it can be returned to the user.\n * @param rootStubObject\n * @returns {string}\n */\n hydrateResults(rootStubObject: EntityNode): Record<string, unknown> {\n return rootStubObject.toJSON(EncodingMode.hydrated);\n }\n /**\n * Dehydrate results so that they can be stored in the cache.\n * @param json\n * @param entityIds\n * @param cacheProvider\n * @param queryId\n * @returns {Promise<DehydratedResults>}\n */\n async dehydrateResults(\n json: Record<string, unknown>,\n entityIds: Record<string, unknown>,\n cacheProvider: InternalCacheProvider,\n queryId: string\n ): Promise<DehydratedResults> {\n const acc = new ImpactedQueryRefsAccumulator(queryId);\n const entityNode = new EntityNode();\n await entityNode.loadData(queryId, json, entityIds, acc, cacheProvider);\n return {\n entityNode,\n impacted: acc.consumeEvents()\n };\n }\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { generateSHA256Hash } from '@firebase/util';\n\nimport {\n CacheProvider,\n CacheSettings,\n type ConnectorConfig\n} from '../api/DataConnect';\nimport { Code, DataConnectError } from '../core/error';\nimport { type AuthTokenProvider } from '../core/FirebaseAuthProvider';\n\nimport { InternalCacheProvider } from './CacheProvider';\nimport { InMemoryCacheProvider } from './InMemoryCacheProvider';\nimport { ResultTree } from './ResultTree';\nimport { ResultTreeProcessor } from './ResultTreeProcessor';\n\nexport const Memory = 'memory';\n\nexport type DataConnectStorage = typeof Memory;\n\n/**\n * ServerValues\n */\nexport interface ServerValues extends Record<string, unknown> {\n maxAge?: number;\n}\n\nexport class DataConnectCache {\n private cacheProvider: InternalCacheProvider | null = null;\n private uid: string | null = null;\n constructor(\n private authProvider: AuthTokenProvider,\n private projectId: string,\n private connectorConfig: ConnectorConfig,\n private host: string,\n public cacheSettings: CacheSettings\n ) {\n this.authProvider.addTokenChangeListener(async _ => {\n const newUid = this.authProvider.getAuth().getUid();\n // We should only close if the token changes and so does the new UID\n if (this.uid !== newUid) {\n this.cacheProvider?.close();\n this.uid = newUid;\n const identifier = await this.getIdentifier(this.uid);\n this.cacheProvider = this.initializeNewProviders(identifier);\n }\n });\n }\n\n async initialize(): Promise<void> {\n if (!this.cacheProvider) {\n const identifier = await this.getIdentifier(this.uid);\n this.cacheProvider = this.initializeNewProviders(identifier);\n }\n }\n\n async getIdentifier(uid: string | null): Promise<string> {\n const identifier = `${\n 'memory' // TODO: replace this with indexeddb when persistence is available.\n }-${this.projectId}-${this.connectorConfig.service}-${\n this.connectorConfig.connector\n }-${this.connectorConfig.location}-${uid}-${this.host}`;\n const sha256 = await generateSHA256Hash(identifier);\n return sha256;\n }\n\n initializeNewProviders(identifier: string): InternalCacheProvider {\n return this.cacheSettings.cacheProvider.initialize(identifier);\n }\n\n async containsResultTree(queryId: string): Promise<boolean> {\n await this.initialize();\n const resultTree = await this.cacheProvider!.getResultTree(queryId);\n return resultTree !== undefined;\n }\n async getResultTree(queryId: string): Promise<ResultTree | undefined> {\n await this.initialize();\n return this.cacheProvider!.getResultTree(queryId);\n }\n async getResultJSON(queryId: string): Promise<Record<string, unknown>> {\n await this.initialize();\n const processor = new ResultTreeProcessor();\n const cacheProvider = this.cacheProvider;\n const resultTree = await cacheProvider!.getResultTree(queryId);\n if (!resultTree) {\n throw new DataConnectError(\n Code.INVALID_ARGUMENT,\n `${queryId} not found in cache. Call \"update()\" first.`\n );\n }\n return processor.hydrateResults(resultTree.getRootStub());\n }\n async update(\n queryId: string,\n serverValues: ServerValues,\n entityIds: Record<string, unknown>\n ): Promise<string[]> {\n await this.initialize();\n const processor = new ResultTreeProcessor();\n const cacheProvider = this.cacheProvider;\n const { entityNode: stubDataObject, impacted } =\n await processor.dehydrateResults(\n serverValues,\n entityIds,\n cacheProvider!,\n queryId\n );\n const now = new Date();\n await cacheProvider!.setResultTree(\n queryId,\n new ResultTree(\n stubDataObject,\n serverValues.maxAge || this.cacheSettings.maxAgeSeconds,\n now,\n now\n )\n );\n return impacted;\n }\n}\n\nexport class MemoryStub implements CacheProvider<'MEMORY'> {\n type: 'MEMORY' = 'MEMORY';\n /**\n * @internal\n */\n initialize(cacheId: string): InMemoryCacheProvider {\n return new InMemoryCacheProvider(cacheId);\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseApp, _isFirebaseServerApp } from '@firebase/app';\nimport {\n AppCheckInternalComponentName,\n AppCheckTokenListener,\n AppCheckTokenResult,\n FirebaseAppCheckInternal\n} from '@firebase/app-check-interop-types';\nimport { Provider } from '@firebase/component';\n\n/**\n * @internal\n * Abstraction around AppCheck's token fetching capabilities.\n */\nexport class AppCheckTokenProvider {\n private appCheck?: FirebaseAppCheckInternal | null;\n private serverAppAppCheckToken?: string;\n constructor(\n app: FirebaseApp,\n private appCheckProvider?: Provider<AppCheckInternalComponentName>\n ) {\n if (_isFirebaseServerApp(app) && app.settings.appCheckToken) {\n this.serverAppAppCheckToken = app.settings.appCheckToken;\n }\n this.appCheck = appCheckProvider?.getImmediate({ optional: true });\n if (!this.appCheck) {\n void appCheckProvider\n ?.get()\n .then(appCheck => (this.appCheck = appCheck))\n .catch();\n }\n }\n\n getToken(): Promise<AppCheckTokenResult | null> {\n if (this.serverAppAppCheckToken) {\n return Promise.resolve({ token: this.serverAppAppCheckToken });\n }\n\n if (!this.appCheck) {\n return new Promise<AppCheckTokenResult | null>((resolve, reject) => {\n // Support delayed initialization of FirebaseAppCheck. This allows our\n // customers to initialize the RTDB SDK before initializing Firebase\n // AppCheck and ensures that all requests are authenticated if a token\n // becomes available before the timoeout below expires.\n setTimeout(() => {\n if (this.appCheck) {\n this.getToken().then(resolve, reject);\n } else {\n resolve(null);\n }\n }, 0);\n });\n }\n return this.appCheck.getToken();\n }\n\n addTokenChangeListener(listener: AppCheckTokenListener): void {\n void this.appCheckProvider\n ?.get()\n .then(appCheck => appCheck.addTokenListener(listener));\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseOptions } from '@firebase/app-types';\nimport {\n FirebaseAuthInternal,\n FirebaseAuthInternalName,\n FirebaseAuthTokenData\n} from '@firebase/auth-interop-types';\nimport { Provider } from '@firebase/component';\n\nimport { logDebug, logError } from '../logger';\n\n// @internal\nexport interface AuthTokenProvider {\n getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;\n addTokenChangeListener(listener: AuthTokenListener): void;\n getAuth(): FirebaseAuthInternal;\n}\nexport type AuthTokenListener = (token: string | null) => void;\n\n// @internal\nexport class FirebaseAuthProvider implements AuthTokenProvider {\n private _auth: FirebaseAuthInternal;\n constructor(\n private _appName: string,\n private _options: FirebaseOptions,\n private _authProvider: Provider<FirebaseAuthInternalName>\n ) {\n this._auth = _authProvider.getImmediate({ optional: true })!;\n if (!this._auth) {\n _authProvider.onInit(auth => (this._auth = auth));\n }\n }\n getAuth(): FirebaseAuthInternal {\n return this._auth;\n }\n getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null> {\n if (!this._auth) {\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n if (this._auth) {\n this.getToken(forceRefresh).then(resolve, reject);\n } else {\n resolve(null);\n }\n }, 0);\n });\n }\n return this._auth.getToken(forceRefresh).catch(error => {\n if (error && error.code === 'auth/token-not-initialized') {\n logDebug(\n 'Got auth/token-not-initialized error. Treating as null token.'\n );\n return null;\n } else {\n logError(\n 'Error received when attempting to retrieve token: ' +\n JSON.stringify(error)\n );\n return Promise.reject(error);\n }\n });\n }\n addTokenChangeListener(listener: AuthTokenListener): void {\n this._auth?.addAuthTokenListener(listener);\n }\n removeTokenChangeListener(listener: (token: string | null) => void): void {\n this._authProvider\n .get()\n .then(auth => auth.removeAuthTokenListener(listener))\n .catch(err => logError(err));\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Extensions } from '../network';\n\nimport { DataConnect, DataConnectOptions } from './DataConnect';\nexport const QUERY_STR = 'query';\nexport const MUTATION_STR = 'mutation';\nexport type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;\n\nexport const SOURCE_SERVER = 'SERVER';\nexport const SOURCE_CACHE = 'CACHE';\nexport type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;\n\nexport interface OpResult<Data> {\n data: Data;\n source: DataSource;\n fetchTime: string;\n extensions?: Extensions;\n}\n\nexport interface OperationRef<_Data, Variables> {\n name: string;\n variables: Variables;\n refType: ReferenceType;\n dataConnect: DataConnect;\n}\n\nexport interface DataConnectResult<Data, Variables> extends OpResult<Data> {\n ref: OperationRef<Data, Variables>;\n // future metadata\n}\n\n/**\n * Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`\n */\nexport interface RefInfo<Variables> {\n name: string;\n variables: Variables;\n connectorConfig: DataConnectOptions;\n}\n/**\n * Serialized Ref as a result of `QueryResult.toJSON()`\n */\nexport interface SerializedRef<Data, Variables> extends OpResult<Data> {\n refInfo: RefInfo<Variables>;\n}\n","/**\n * @license\n * Copyright 2026 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OpResult } from '../api/Reference';\nimport { DataConnectExtension } from '../network';\nexport function parseEntityIds<T>(\n result: OpResult<T>\n): Record<string, unknown> {\n // Iterate through extensions.dataConnect\n const dataConnectExtensions = result.extensions?.dataConnect;\n const dataCopy = Object.assign(result);\n if (!dataConnectExtensions) {\n return dataCopy;\n }\n const ret: Record<string, unknown> = {};\n for (const extension of dataConnectExtensions) {\n const { path } = extension;\n populatePath(path, ret, extension);\n }\n return ret;\n}\n\n// mutates the object to update the path\nexport function populatePath(\n path: Array<string | number>,\n toUpdate: Record<string | number, unknown>,\n extension: DataConnectExtension\n): void {\n let curObj: Record<string | number, unknown> = toUpdate;\n for (const slice of path) {\n if (typeof curObj[slice] !== 'object') {\n curObj[slice] = {};\n }\n curObj = curObj[slice] as Record<string, unknown>;\n }\n\n if ('entityId' in extension && extension.entityId) {\n curObj['_id'] = extension.entityId;\n } else if ('entityIds' in extension) {\n const entityArr = extension.entityIds;\n for (let i = 0; i < entityArr.length; i++) {\n const entityId = entityArr[i];\n if (typeof curObj[i] === 'undefined') {\n curObj[i] = {};\n }\n (curObj[i] as Record<string, unknown>)._id = entityId;\n }\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type HmacImpl = (obj: Record<string, unknown>) => string;\nexport let encoderImpl: HmacImpl;\nexport type DecodeHmacImpl = (s: string) => Record<string, unknown>;\nexport let decoderImpl: DecodeHmacImpl;\nexport function setEncoder(encoder: HmacImpl): void {\n encoderImpl = encoder;\n}\nexport function setDecoder(decoder: DecodeHmacImpl): void {\n decoderImpl = decoder;\n}\nfunction sortKeysForObj(o: Record<string, unknown>): Record<string, unknown> {\n return Object.keys(o)\n .sort()\n .reduce((accumulator, currentKey) => {\n accumulator[currentKey] = o[currentKey];\n return accumulator;\n }, {} as Record<string, unknown>);\n}\nsetEncoder((o: Record<string, unknown>) => JSON.stringify(sortKeysForObj(o)));\nsetDecoder(s => sortKeysForObj(JSON.parse(s)));\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type DataConnect } from '../../api/DataConnect';\nimport { QueryRef, QueryResult } from '../../api/query';\nimport {\n QUERY_STR,\n SerializedRef,\n SOURCE_SERVER,\n DataSource,\n SOURCE_CACHE\n} from '../../api/Reference';\nimport { DataConnectSubscription } from '../../api.browser';\nimport { DataConnectCache, ServerValues } from '../../cache/Cache';\nimport { parseEntityIds } from '../../cache/cacheUtils';\nimport { EncodingMode } from '../../cache/EntityNode';\nimport { DataConnectTransport, Extensions } from '../../network';\nimport {\n DataConnectExtensionWithMaxAge,\n ExtensionsWithMaxAge\n} from '../../network/transport';\nimport { decoderImpl, encoderImpl } from '../../util/encoder';\nimport { Code, DataConnectError } from '../error';\n\nimport {\n OnCompleteSubscription,\n OnErrorSubscription,\n OnResultSubscription\n} from './subscribe';\n\nexport function getRefSerializer<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n data: Data,\n source: DataSource,\n fetchTime: string\n) {\n return function toJSON(): SerializedRef<Data, Variables> {\n return {\n data,\n refInfo: {\n name: queryRef.name,\n variables: queryRef.variables,\n connectorConfig: {\n projectId: queryRef.dataConnect.app.options.projectId!,\n ...queryRef.dataConnect.getSettings()\n }\n },\n fetchTime,\n source\n };\n };\n}\n\nexport class QueryManager {\n async preferCacheResults<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n allowStale = false\n ): Promise<QueryResult<Data, Variables>> {\n let cacheResult: QueryResult<Data, Variables> | undefined;\n try {\n cacheResult = await this.fetchCacheResults(queryRef, allowStale);\n } catch (e) {\n // Ignore the error and try to fetch from the server.\n }\n if (cacheResult) {\n return cacheResult;\n }\n return this.fetchServerResults(queryRef);\n }\n private callbacks = new Map<\n string,\n Array<DataConnectSubscription<unknown, unknown>>\n >();\n private subscriptionCache = new Map<string, QueryResult<unknown, unknown>>();\n constructor(\n private transport: DataConnectTransport,\n private dc: DataConnect,\n private cache?: DataConnectCache\n ) {}\n private queue: Array<Promise<unknown>> = [];\n async waitForQueuedWrites(): Promise<void> {\n for (const promise of this.queue) {\n await promise;\n }\n this.queue = [];\n }\n\n updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void {\n this.queue.push(\n this.updateCache(updatedData).then(async result =>\n this.publishCacheResultsToSubscribers(result, updatedData.fetchTime)\n )\n );\n }\n\n async updateCache<Data, Variables>(\n result: QueryResult<Data, Variables>,\n extensions?: DataConnectExtensionWithMaxAge[]\n ): Promise<string[]> {\n await this.waitForQueuedWrites();\n if (this.cache) {\n const entityIds = parseEntityIds(result);\n const updatedMaxAge = getMaxAgeFromExtensions(extensions);\n if (updatedMaxAge !== undefined) {\n this.cache.cacheSettings.maxAgeSeconds = updatedMaxAge;\n }\n return this.cache.update(\n encoderImpl({\n name: result.ref.name,\n variables: result.ref.variables,\n refType: QUERY_STR\n }),\n result.data as ServerValues,\n entityIds\n );\n } else {\n const key = encoderImpl({\n name: result.ref.name,\n variables: result.ref.variables,\n refType: QUERY_STR\n });\n this.subscriptionCache.set(key, result);\n return [key];\n }\n }\n\n addSubscription<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n onResultCallback: OnResultSubscription<Data, Variables>,\n onCompleteCallback?: OnCompleteSubscription,\n onErrorCallback?: OnErrorSubscription,\n initialCache?: QueryResult<Data, Variables>\n ): () => void {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n\n const unsubscribe = (): void => {\n if (this.callbacks.has(key)) {\n const callbackList = this.callbacks.get(key)!;\n this.callbacks.set(\n key,\n callbackList.filter(callback => callback !== subscription)\n );\n onCompleteCallback?.();\n }\n };\n const subscription: DataConnectSubscription<Data, Variables> = {\n userCallback: onResultCallback,\n errCallback: onErrorCallback,\n unsubscribe\n };\n\n if (initialCache) {\n this.updateSSR(initialCache);\n }\n\n const promise = this.preferCacheResults(queryRef, /*allowStale=*/ true);\n // We want to ignore the error and let subscriptions handle it\n promise.then(undefined, err => {});\n\n if (!this.callbacks.has(key)) {\n this.callbacks.set(key, []);\n }\n this.callbacks\n .get(key)!\n .push(subscription as DataConnectSubscription<unknown, unknown>);\n\n return unsubscribe;\n }\n\n async fetchServerResults<Data, Variables>(\n queryRef: QueryRef<Data, Variables>\n ): Promise<QueryResult<Data, Variables>> {\n await this.waitForQueuedWrites();\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n try {\n const result = await this.transport.invokeQuery<Data, Variables>(\n queryRef.name,\n queryRef.variables\n );\n const fetchTime = Date.now().toString();\n const originalExtensions = result.extensions;\n const queryResult: QueryResult<Data, Variables> = {\n ...result,\n ref: queryRef,\n source: SOURCE_SERVER,\n fetchTime,\n data: result.data,\n extensions: getDataConnectExtensionsWithoutMaxAge(originalExtensions),\n toJSON: getRefSerializer(\n queryRef,\n result.data,\n SOURCE_SERVER,\n fetchTime\n )\n };\n let updatedKeys: string[] = [];\n updatedKeys = await this.updateCache(\n queryResult,\n originalExtensions?.dataConnect\n );\n this.publishDataToSubscribers(key, queryResult);\n if (this.cache) {\n await this.publishCacheResultsToSubscribers(updatedKeys, fetchTime);\n } else {\n this.subscriptionCache.set(key, queryResult);\n }\n return queryResult;\n } catch (e) {\n this.publishErrorToSubscribers(key, e);\n throw e;\n }\n }\n\n async fetchCacheResults<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n allowStale = false\n ): Promise<QueryResult<Data, Variables>> {\n await this.waitForQueuedWrites();\n let result: QueryResult<Data, Variables> | undefined | null;\n if (!this.cache) {\n result = await this.getFromSubscriberCache(queryRef);\n } else {\n result = await this.getFromResultTreeCache(queryRef, allowStale);\n }\n if (!result) {\n throw new DataConnectError(\n Code.OTHER,\n 'No cache entry found for query: ' + queryRef.name\n );\n }\n const fetchTime = Date.now().toString();\n const queryResult: QueryResult<Data, Variables> = {\n ...result,\n ref: queryRef,\n source: SOURCE_CACHE,\n fetchTime,\n data: result.data,\n extensions: result.extensions,\n toJSON: getRefSerializer(queryRef, result.data, SOURCE_CACHE, fetchTime)\n };\n if (this.cache) {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n await this.publishCacheResultsToSubscribers([key], fetchTime);\n } else {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n this.subscriptionCache.set(key, queryResult);\n this.publishDataToSubscribers(key, queryResult);\n }\n\n return queryResult;\n }\n\n publishErrorToSubscribers(key: string, err: unknown): void {\n this.callbacks.get(key)?.forEach(subscription => {\n if (subscription.errCallback) {\n subscription.errCallback(err as DataConnectError);\n }\n });\n }\n\n async getFromResultTreeCache<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n allowStale = false\n ): Promise<QueryResult<Data, Variables> | null> {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n if (!this.cache || !(await this.cache.containsResultTree(key))) {\n return null;\n }\n const cacheResult: Data = (await this.cache!.getResultJSON(key)) as Data;\n const resultTree = await this.cache!.getResultTree(key);\n if (!allowStale && resultTree!.isStale()) {\n return null;\n }\n const result: QueryResult<Data, Variables> = {\n source: SOURCE_CACHE,\n ref: queryRef,\n data: cacheResult,\n toJSON: getRefSerializer(\n queryRef,\n cacheResult,\n SOURCE_CACHE,\n resultTree!.cachedAt.toString()\n ),\n fetchTime: resultTree!.cachedAt.toString()\n };\n (await this.cache!.getResultTree(key))!.updateAccessed();\n return result;\n }\n async getFromSubscriberCache<Data, Variables>(\n queryRef: QueryRef<Data, Variables>\n ): Promise<QueryResult<Data, Variables> | undefined> {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n if (!this.subscriptionCache.has(key)) {\n return;\n }\n const result = this.subscriptionCache.get(key);\n result!.source = SOURCE_CACHE;\n result!.toJSON = getRefSerializer(\n result!.ref,\n result!.data,\n SOURCE_CACHE,\n result!.fetchTime\n );\n return result as QueryResult<Data, Variables>;\n }\n\n publishDataToSubscribers(\n key: string,\n queryResult: QueryResult<unknown, unknown>\n ): void {\n if (!this.callbacks.has(key)) {\n return;\n }\n const subscribers = this.callbacks.get(key);\n subscribers!.forEach(callback => {\n callback.userCallback(queryResult);\n });\n }\n async publishCacheResultsToSubscribers(\n impactedQueries: string[],\n fetchTime: string\n ): Promise<void> {\n if (!this.cache) {\n return;\n }\n for (const query of impactedQueries) {\n const callbacks = this.callbacks.get(query);\n if (!callbacks) {\n continue;\n }\n const newJson = (await this.cache.getResultTree(query))!\n .getRootStub()\n .toJSON(EncodingMode.hydrated);\n const { name, variables } = decoderImpl(query) as unknown as QueryRef<\n unknown,\n unknown\n >;\n const queryRef: QueryRef<unknown, unknown> = {\n dataConnect: this.dc,\n refType: QUERY_STR,\n name,\n variables\n };\n this.publishDataToSubscribers(query, {\n data: newJson,\n fetchTime,\n ref: queryRef,\n source: SOURCE_CACHE,\n toJSON: getRefSerializer(queryRef, newJson, SOURCE_CACHE, fetchTime)\n });\n }\n }\n enableEmulator(host: string, port: number): void {\n this.transport.useEmulator(host, port);\n }\n}\n\nexport function getMaxAgeFromExtensions(\n extensions: DataConnectExtensionWithMaxAge[] | undefined\n): number | undefined {\n if (!extensions) {\n return;\n }\n for (const extension of extensions) {\n if (\n 'maxAge' in extension &&\n extension.maxAge !== undefined &&\n extension.maxAge !== null\n ) {\n if (extension.maxAge.endsWith('s')) {\n return Number(\n extension.maxAge.substring(0, extension.maxAge.length - 1)\n );\n }\n }\n }\n}\nfunction getDataConnectExtensionsWithoutMaxAge(\n extensions: ExtensionsWithMaxAge\n): Extensions | undefined {\n return {\n dataConnect: extensions.dataConnect?.filter(\n extension => 'entityId' in extension || 'entityIds' in extension\n )\n };\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DataConnectOptions, TransportOptions } from '../api/DataConnect';\nimport { Code, DataConnectError } from '../core/error';\nimport { logError } from '../logger';\n\nexport const PROD_HOST = 'firebasedataconnect.googleapis.com';\n\nexport function urlBuilder(\n projectConfig: DataConnectOptions,\n transportOptions: TransportOptions\n): string {\n const { connector, location, projectId: project, service } = projectConfig;\n const { host, sslEnabled, port } = transportOptions;\n const protocol = sslEnabled ? 'https' : 'http';\n const realHost = host || PROD_HOST;\n let baseUrl = `${protocol}://${realHost}`;\n if (typeof port === 'number') {\n baseUrl += `:${port}`;\n } else if (typeof port !== 'undefined') {\n logError('Port type is of an invalid type');\n throw new DataConnectError(\n Code.INVALID_ARGUMENT,\n 'Incorrect type for port passed in!'\n );\n }\n return `${baseUrl}/v1/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;\n}\nexport function addToken(url: string, apiKey?: string): string {\n if (!apiKey) {\n return url;\n }\n const newUrl = new URL(url);\n newUrl.searchParams.append('key', apiKey);\n return newUrl.toString();\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DataConnectOptions, TransportOptions } from '../../api/DataConnect';\nimport { AppCheckTokenProvider } from '../../core/AppCheckTokenProvider';\nimport { DataConnectError, Code } from '../../core/error';\nimport { AuthTokenProvider } from '../../core/FirebaseAuthProvider';\nimport { logDebug } from '../../logger';\nimport { addToken, urlBuilder } from '../../util/url';\nimport { dcFetch } from '../fetch';\n\nimport {\n CallerSdkType,\n CallerSdkTypeEnum,\n DataConnectResponse,\n DataConnectTransport\n} from '.';\n\nexport class RESTTransport implements DataConnectTransport {\n private _host = '';\n private _port: number | undefined;\n private _location = 'l';\n private _connectorName = '';\n private _secure = true;\n private _project = 'p';\n private _serviceName: string;\n private _accessToken: string | null = null;\n private _appCheckToken: string | null | undefined = null;\n private _lastToken: string | null = null;\n private _isUsingEmulator = false;\n constructor(\n options: DataConnectOptions,\n private apiKey?: string | undefined,\n private appId?: string | null,\n private authProvider?: AuthTokenProvider | undefined,\n private appCheckProvider?: AppCheckTokenProvider | undefined,\n transportOptions?: TransportOptions | undefined,\n private _isUsingGen = false,\n private _callerSdkType: CallerSdkType = CallerSdkTypeEnum.Base\n ) {\n if (transportOptions) {\n if (typeof transportOptions.port === 'number') {\n this._port = transportOptions.port;\n }\n if (typeof transportOptions.sslEnabled !== 'undefined') {\n this._secure = transportOptions.sslEnabled;\n }\n this._host = transportOptions.host;\n }\n const { location, projectId: project, connector, service } = options;\n if (location) {\n this._location = location;\n }\n if (project) {\n this._project = project;\n }\n this._serviceName = service;\n if (!connector) {\n throw new DataConnectError(\n Code.INVALID_ARGUMENT,\n 'Connector Name required!'\n );\n }\n this._connectorName = connector;\n this.authProvider?.addTokenChangeListener(token => {\n logDebug(`New Token Available: ${token}`);\n this._accessToken = token;\n });\n this.appCheckProvider?.addTokenChangeListener(result => {\n const { token } = result;\n logDebug(`New App Check Token Available: ${token}`);\n this._appCheckToken = token;\n });\n }\n get endpointUrl(): string {\n return urlBuilder(\n {\n connector: this._connectorName,\n location: this._location,\n projectId: this._project,\n service: this._serviceName\n },\n { host: this._host, sslEnabled: this._secure, port: this._port }\n );\n }\n useEmulator(host: string, port?: number, isSecure?: boolean): void {\n this._host = host;\n this._isUsingEmulator = true;\n if (typeof port === 'number') {\n this._port = port;\n }\n if (typeof isSecure !== 'undefined') {\n this._secure = isSecure;\n }\n }\n onTokenChanged(newToken: string | null): void {\n this._accessToken = newToken;\n }\n\n async getWithAuth(forceToken = false): Promise<string | null> {\n let starterPromise: Promise<string | null> = new Promise(resolve =>\n resolve(this._accessToken)\n );\n if (this.appCheckProvider) {\n const appCheckToken = await this.appCheckProvider.getToken();\n if (appCheckToken) {\n this._appCheckToken = appCheckToken.token;\n }\n }\n if (this.authProvider) {\n starterPromise = this.authProvider\n .getToken(/*forceToken=*/ forceToken)\n .then(data => {\n if (!data) {\n return null;\n }\n this._accessToken = data.accessToken;\n return this._accessToken;\n });\n } else {\n starterPromise = new Promise(resolve => resolve(''));\n }\n return starterPromise;\n }\n\n _setLastToken(lastToken: string | null): void {\n this._lastToken = lastToken;\n }\n\n withRetry<T>(\n promiseFactory: () => Promise<DataConnectResponse<T>>,\n retry = false\n ): Promise<DataConnectResponse<T>> {\n let isNewToken = false;\n return this.getWithAuth(retry)\n .then(res => {\n isNewToken = this._lastToken !== res;\n this._lastToken = res;\n return res;\n })\n .then(promiseFactory)\n .catch(err => {\n // Only retry if the result is unauthorized and the last token isn't the same as the new one.\n if (\n 'code' in err &&\n err.code === Code.UNAUTHORIZED &&\n !retry &&\n isNewToken\n ) {\n logDebug('Retrying due to unauthorized');\n return this.withRetry(promiseFactory, true);\n }\n throw err;\n });\n }\n\n // TODO(mtewani): Update U to include shape of body defined in line 13.\n invokeQuery: <T, U>(\n queryName: string,\n body?: U\n ) => Promise<DataConnectResponse<T>> = <T, U = unknown>(\n queryName: string,\n body: U\n ) => {\n const abortController = new AbortController();\n\n // TODO(mtewani): Update to proper value\n const withAuth = this.withRetry(() =>\n dcFetch<T, U>(\n addToken(`${this.endpointUrl}:executeQuery`, this.apiKey),\n {\n name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,\n operationName: queryName,\n variables: body\n },\n abortController,\n this.appId,\n this._accessToken,\n this._appCheckToken,\n this._isUsingGen,\n this._callerSdkType,\n this._isUsingEmulator\n )\n );\n return withAuth;\n };\n invokeMutation: <T, U>(\n queryName: string,\n body?: U\n ) => Promise<DataConnectResponse<T>> = <T, U = unknown>(\n mutationName: string,\n body: U\n ) => {\n const abortController = new AbortController();\n const taskResult = this.withRetry(() => {\n return dcFetch<T, U>(\n addToken(`${this.endpointUrl}:executeMutation`, this.apiKey),\n {\n name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,\n operationName: mutationName,\n variables: body\n },\n abortController,\n this.appId,\n this._accessToken,\n this._appCheckToken,\n this._isUsingGen,\n this._callerSdkType,\n this._isUsingEmulator\n );\n });\n return taskResult;\n };\n\n _setCallerSdkType(callerSdkType: CallerSdkType): void {\n this._callerSdkType = callerSdkType;\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DataConnectTransport } from '../network/transport';\n\nimport { DataConnect } from './DataConnect';\nimport {\n DataConnectResult,\n MUTATION_STR,\n OperationRef,\n SOURCE_SERVER\n} from './Reference';\n\nexport interface MutationRef<Data, Variables>\n extends OperationRef<Data, Variables> {\n refType: typeof MUTATION_STR;\n}\n\n/**\n * Creates a `MutationRef`\n * @param dcInstance Data Connect instance\n * @param mutationName name of mutation\n */\nexport function mutationRef<Data>(\n dcInstance: DataConnect,\n mutationName: string\n): MutationRef<Data, undefined>;\n/**\n *\n * @param dcInstance Data Connect instance\n * @param mutationName name of mutation\n * @param variables variables to send with mutation\n */\nexport function mutationRef<Data, Variables>(\n dcInstance: DataConnect,\n mutationName: string,\n variables: Variables\n): MutationRef<Data, Variables>;\n/**\n *\n * @param dcInstance Data Connect instance\n * @param mutationName name of mutation\n * @param variables variables to send with mutation\n * @returns `MutationRef`\n */\nexport function mutationRef<Data, Variables>(\n dcInstance: DataConnect,\n mutationName: string,\n variables?: Variables\n): MutationRef<Data, Variables> {\n dcInstance.setInitialized();\n const ref: MutationRef<Data, Variables> = {\n dataConnect: dcInstance,\n name: mutationName,\n refType: MUTATION_STR,\n variables: variables as Variables\n };\n return ref;\n}\n\n/**\n * @internal\n */\nexport class MutationManager {\n private _inflight: Array<Promise<unknown>> = [];\n constructor(private _transport: DataConnectTransport) {}\n executeMutation<Data, Variables>(\n mutationRef: MutationRef<Data, Variables>\n ): MutationPromise<Data, Variables> {\n const result = this._transport.invokeMutation<Data, Variables>(\n mutationRef.name,\n mutationRef.variables\n );\n const withRefPromise = result.then(res => {\n const obj: MutationResult<Data, Variables> = {\n ...res, // Double check that the result is result.data, not just result\n source: SOURCE_SERVER,\n ref: mutationRef,\n fetchTime: Date.now().toLocaleString()\n };\n return obj;\n });\n this._inflight.push(result);\n const removePromise = (): Array<Promise<unknown>> =>\n (this._inflight = this._inflight.filter(promise => promise !== result));\n result.then(removePromise, removePromise);\n return withRefPromise;\n }\n}\n\n/**\n * Mutation Result from `executeMutation`\n */\nexport interface MutationResult<Data, Variables>\n extends DataConnectResult<Data, Variables> {\n ref: MutationRef<Data, Variables>;\n}\n/**\n * Mutation return value from `executeMutation`\n */\nexport interface MutationPromise<Data, Variables>\n extends Promise<MutationResult<Data, Variables>> {\n // reserved for special actions like cancellation\n}\n\n/**\n * Execute Mutation\n * @param mutationRef mutation to execute\n * @returns `MutationRef`\n */\nexport function executeMutation<Data, Variables>(\n mutationRef: MutationRef<Data, Variables>\n): MutationPromise<Data, Variables> {\n return mutationRef.dataConnect._mutationManager.executeMutation(mutationRef);\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n FirebaseApp,\n _getProvider,\n _removeServiceInstance,\n getApp\n} from '@firebase/app';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { Provider } from '@firebase/component';\nimport {\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\n\nimport { DataConnectCache, MemoryStub } from '../cache/Cache';\nimport { InternalCacheProvider } from '../cache/CacheProvider';\nimport { AppCheckTokenProvider } from '../core/AppCheckTokenProvider';\nimport { Code, DataConnectError } from '../core/error';\nimport {\n AuthTokenProvider,\n FirebaseAuthProvider\n} from '../core/FirebaseAuthProvider';\nimport { QueryManager } from '../core/query/QueryManager';\nimport { logDebug, logError } from '../logger';\nimport {\n CallerSdkType,\n CallerSdkTypeEnum,\n DataConnectTransport,\n TransportClass\n} from '../network';\nimport { RESTTransport } from '../network/transport/rest';\nimport { PROD_HOST } from '../util/url';\n\nimport { MutationManager } from './Mutation';\n\n/**\n * Connector Config for calling Data Connect backend.\n */\nexport interface ConnectorConfig {\n location: string;\n connector: string;\n service: string;\n}\n\n/**\n * Options to connect to emulator\n */\nexport interface TransportOptions {\n host: string;\n sslEnabled?: boolean;\n port?: number;\n}\n\nconst FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR =\n 'FIREBASE_DATA_CONNECT_EMULATOR_HOST';\n\n/**\n *\n * @param fullHost\n * @returns TransportOptions\n * @internal\n */\nexport function parseOptions(fullHost: string): TransportOptions {\n const [protocol, hostName] = fullHost.split('://');\n const isSecure = protocol === 'https';\n const [host, portAsString] = hostName.split(':');\n const port = Number(portAsString);\n return { host, port, sslEnabled: isSecure };\n}\n/**\n * DataConnectOptions including project id\n */\nexport interface DataConnectOptions extends ConnectorConfig {\n projectId: string;\n}\n\n/**\n * Class representing Firebase Data Connect\n */\nexport class DataConnect {\n _queryManager!: QueryManager;\n _mutationManager!: MutationManager;\n isEmulator = false;\n _initialized = false;\n private _transport!: DataConnectTransport;\n private _transportClass: TransportClass | undefined;\n private _transportOptions?: TransportOptions;\n private _authTokenProvider?: AuthTokenProvider;\n _isUsingGeneratedSdk: boolean = false;\n _callerSdkType: CallerSdkType = CallerSdkTypeEnum.Base;\n private _appCheckTokenProvider?: AppCheckTokenProvider;\n private _cacheSettings?: CacheSettings;\n /**\n * @internal\n */\n private cache?: DataConnectCache;\n // @internal\n constructor(\n public readonly app: FirebaseApp,\n // TODO(mtewani): Replace with _dataConnectOptions in the future\n private readonly dataConnectOptions: DataConnectOptions,\n private readonly _authProvider: Provider<FirebaseAuthInternalName>,\n private readonly _appCheckProvider: Provider<AppCheckInternalComponentName>\n ) {\n if (typeof process !== 'undefined' && process.env) {\n const host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR];\n if (host) {\n logDebug('Found custom host. Using emulator');\n this.isEmulator = true;\n this._transportOptions = parseOptions(host);\n }\n }\n }\n /**\n * @internal\n */\n getCache(): DataConnectCache | undefined {\n return this.cache;\n }\n // @internal\n _useGeneratedSdk(): void {\n if (!this._isUsingGeneratedSdk) {\n this._isUsingGeneratedSdk = true;\n }\n }\n _setCallerSdkType(callerSdkType: CallerSdkType): void {\n this._callerSdkType = callerSdkType;\n if (this._initialized) {\n this._transport._setCallerSdkType(callerSdkType);\n }\n }\n _delete(): Promise<void> {\n _removeServiceInstance(\n this.app,\n 'data-connect',\n JSON.stringify(this.getSettings())\n );\n return Promise.resolve();\n }\n\n // @internal\n getSettings(): ConnectorConfig {\n const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));\n delete copy.projectId;\n return copy;\n }\n\n /**\n * @internal\n */\n setCacheSettings(cacheSettings: CacheSettings): void {\n this._cacheSettings = cacheSettings;\n }\n\n // @internal\n setInitialized(): void {\n if (this._initialized) {\n return;\n }\n if (this._transportClass === undefined) {\n logDebug('transportClass not provided. Defaulting to RESTTransport.');\n this._transportClass = RESTTransport;\n }\n\n this._authTokenProvider = new FirebaseAuthProvider(\n this.app.name,\n this.app.options,\n this._authProvider\n );\n const connectorConfig: ConnectorConfig = {\n connector: this.dataConnectOptions.connector,\n service: this.dataConnectOptions.service,\n location: this.dataConnectOptions.location\n };\n if (this._cacheSettings) {\n this.cache = new DataConnectCache(\n this._authTokenProvider,\n this.app.options.projectId!,\n connectorConfig,\n this._transportOptions?.host || PROD_HOST,\n this._cacheSettings\n );\n }\n\n if (this._appCheckProvider) {\n this._appCheckTokenProvider = new AppCheckTokenProvider(\n this.app,\n this._appCheckProvider\n );\n }\n\n this._transport = new this._transportClass(\n this.dataConnectOptions,\n this.app.options.apiKey,\n this.app.options.appId,\n this._authTokenProvider,\n this._appCheckTokenProvider,\n undefined,\n this._isUsingGeneratedSdk,\n this._callerSdkType\n );\n if (this._transportOptions) {\n this._transport.useEmulator(\n this._transportOptions.host,\n this._transportOptions.port,\n this._transportOptions.sslEnabled\n );\n }\n\n this._queryManager = new QueryManager(this._transport, this, this.cache);\n this._mutationManager = new MutationManager(this._transport);\n this._initialized = true;\n }\n\n // @internal\n enableEmulator(transportOptions: TransportOptions): void {\n if (\n this._transportOptions &&\n this._initialized &&\n !areTransportOptionsEqual(this._transportOptions, transportOptions)\n ) {\n logError('enableEmulator called after initialization');\n throw new DataConnectError(\n Code.ALREADY_INITIALIZED,\n 'DataConnect instance already initialized!'\n );\n }\n this._transportOptions = transportOptions;\n this.isEmulator = true;\n }\n}\n\n/**\n * @internal\n * @param transportOptions1\n * @param transportOptions2\n * @returns\n */\nexport function areTransportOptionsEqual(\n transportOptions1: TransportOptions,\n transportOptions2: TransportOptions\n): boolean {\n return (\n transportOptions1.host === transportOptions2.host &&\n transportOptions1.port === transportOptions2.port &&\n transportOptions1.sslEnabled === transportOptions2.sslEnabled\n );\n}\n\n/**\n * Connect to the DataConnect Emulator\n * @param dc Data Connect instance\n * @param host host of emulator server\n * @param port port of emulator server\n * @param sslEnabled use https\n */\nexport function connectDataConnectEmulator(\n dc: DataConnect,\n host: string,\n port?: number,\n sslEnabled = false\n): void {\n // Workaround to get cookies in Firebase Studio\n if (isCloudWorkstation(host)) {\n void pingServer(`https://${host}${port ? `:${port}` : ''}`);\n updateEmulatorBanner('Data Connect', true);\n }\n dc.enableEmulator({ host, port, sslEnabled });\n}\n\nexport interface DataConnectSettings {\n cacheSettings?: CacheSettings;\n}\n\n/**\n * Initialize DataConnect instance\n * @param options ConnectorConfig\n */\nexport function getDataConnect(\n options: ConnectorConfig,\n settings?: DataConnectSettings\n): DataConnect;\nexport function getDataConnect(options: ConnectorConfig): DataConnect;\n/**\n * Initialize DataConnect instance\n * @param app FirebaseApp to initialize to.\n * @param connectorConfig ConnectorConfig\n */\nexport function getDataConnect(\n app: FirebaseApp,\n connectorConfig: ConnectorConfig\n): DataConnect;\n\n/**\n * Initialize DataConnect instance\n * @param app FirebaseApp to initialize to.\n * @param connectorConfig ConnectorConfig\n */\nexport function getDataConnect(\n app: FirebaseApp,\n connectorConfig: ConnectorConfig,\n settings: DataConnectSettings\n): DataConnect;\n\nexport function getDataConnect(\n appOrConnectorConfig: FirebaseApp | ConnectorConfig,\n settingsOrConnectorConfig?: ConnectorConfig | DataConnectSettings,\n settings?: DataConnectSettings\n): DataConnect {\n let app: FirebaseApp;\n let connectorConfig: ConnectorConfig;\n let realSettings: DataConnectSettings;\n if ('location' in appOrConnectorConfig) {\n connectorConfig = appOrConnectorConfig;\n app = getApp();\n realSettings = settingsOrConnectorConfig as DataConnectSettings;\n } else {\n app = appOrConnectorConfig;\n connectorConfig = settingsOrConnectorConfig as ConnectorConfig;\n realSettings = settings as DataConnectSettings;\n }\n\n if (!app || Object.keys(app).length === 0) {\n app = getApp();\n }\n\n // Options to store in Firebase Component Provider.\n const serializedOptions = {\n ...connectorConfig,\n projectId: app.options.projectId\n };\n\n // We should sort the keys before initialization.\n const sortedSerialized = Object.fromEntries(\n Object.entries(serializedOptions).sort()\n );\n\n const provider = _getProvider(app, 'data-connect');\n const identifier = JSON.stringify(sortedSerialized);\n if (provider.isInitialized(identifier)) {\n const dcInstance = provider.getImmediate({ identifier });\n const options = provider.getOptions(identifier);\n const optionsValid = Object.keys(options).length > 0;\n if (optionsValid) {\n logDebug('Re-using cached instance');\n return dcInstance;\n }\n }\n validateDCOptions(connectorConfig);\n\n logDebug('Creating new DataConnect instance');\n // Initialize with options.\n const dataConnect = provider.initialize({\n instanceIdentifier: identifier,\n options: Object.fromEntries(\n Object.entries({\n ...sortedSerialized\n }).sort()\n )\n });\n if (realSettings?.cacheSettings) {\n dataConnect.setCacheSettings(realSettings.cacheSettings);\n }\n return dataConnect;\n}\n\n/**\n *\n * @param dcOptions\n * @returns {void}\n * @internal\n */\nexport function validateDCOptions(dcOptions: ConnectorConfig): boolean {\n const fields = ['connector', 'location', 'service'];\n if (!dcOptions) {\n throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required');\n }\n fields.forEach(field => {\n if (\n dcOptions[field as keyof ConnectorConfig] === null ||\n dcOptions[field as keyof ConnectorConfig] === undefined\n ) {\n throw new DataConnectError(Code.INVALID_ARGUMENT, `${field} Required`);\n }\n });\n return true;\n}\n\n/**\n * Delete DataConnect instance\n * @param dataConnect DataConnect instance\n * @returns\n */\nexport function terminate(dataConnect: DataConnect): Promise<void> {\n return dataConnect._delete();\n // TODO(mtewani): Stop pending tasks\n}\nexport const StorageType = {\n MEMORY: 'MEMORY'\n} as const;\n\nexport type StorageType = (typeof StorageType)[keyof typeof StorageType];\n\nexport interface CacheSettings {\n cacheProvider: CacheProvider<StorageType>;\n maxAgeSeconds?: number;\n}\nexport interface CacheProvider<T extends StorageType> {\n type: T;\n /**\n * @internal\n */\n initialize(cacheId: string): InternalCacheProvider;\n}\n\nexport function makeMemoryCacheProvider(): CacheProvider<'MEMORY'> {\n return new MemoryStub();\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n _registerComponent,\n registerVersion,\n SDK_VERSION\n} from '@firebase/app';\nimport { Component, ComponentType } from '@firebase/component';\n\nimport { name, version } from '../package.json';\nimport { setSDKVersion } from '../src/core/version';\n\nimport { DataConnect, ConnectorConfig } from './api/DataConnect';\nimport { Code, DataConnectError } from './core/error';\n\nexport function registerDataConnect(variant?: string): void {\n setSDKVersion(SDK_VERSION);\n _registerComponent(\n new Component(\n 'data-connect',\n (container, { instanceIdentifier: connectorConfigStr, options }) => {\n const app = container.getProvider('app').getImmediate()!;\n const authProvider = container.getProvider('auth-internal');\n const appCheckProvider = container.getProvider('app-check-internal');\n let newOpts = options as ConnectorConfig;\n if (connectorConfigStr) {\n newOpts = {\n ...JSON.parse(connectorConfigStr),\n ...newOpts\n };\n }\n if (!app.options.projectId) {\n throw new DataConnectError(\n Code.INVALID_ARGUMENT,\n 'Project ID must be provided. Did you pass in a proper projectId to initializeApp?'\n );\n }\n return new DataConnect(\n app,\n { ...newOpts, projectId: app.options.projectId! },\n authProvider,\n appCheckProvider\n );\n },\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n registerVersion(name, version, variant);\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const QueryFetchPolicy = {\n PREFER_CACHE: 'PREFER_CACHE',\n CACHE_ONLY: 'CACHE_ONLY',\n SERVER_ONLY: 'SERVER_ONLY'\n} as const;\n\n/*\n * Represents policy for how executeQuery fetches data\n *\n */\nexport type QueryFetchPolicy =\n (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];\n\nexport interface ExecuteQueryOptions {\n fetchPolicy: QueryFetchPolicy;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Code, DataConnectError } from '../core/error';\nimport {\n ExecuteQueryOptions,\n QueryFetchPolicy\n} from '../core/query/queryOptions';\nimport { DataConnectExtensionWithMaxAge } from '../network/transport';\n\nimport { DataConnect, getDataConnect } from './DataConnect';\nimport {\n OperationRef,\n QUERY_STR,\n DataConnectResult,\n SerializedRef\n} from './Reference';\n\n/**\n * QueryRef object\n */\nexport interface QueryRef<Data, Variables>\n extends OperationRef<Data, Variables> {\n refType: typeof QUERY_STR;\n}\n\n/** @internal */\nexport type InternalQueryResult<Data, Variables> = QueryResult<\n Data,\n Variables\n> &\n Omit<DataConnectResult<Data, Variables>, 'extensions'> & {\n extensions?: {\n dataConnect?: DataConnectExtensionWithMaxAge[];\n };\n };\n\n/**\n * Result of `executeQuery`\n */\nexport interface QueryResult<Data, Variables>\n extends DataConnectResult<Data, Variables> {\n ref: QueryRef<Data, Variables>;\n toJSON: () => SerializedRef<Data, Variables>;\n}\n/**\n * Promise returned from `executeQuery`\n */\nexport interface QueryPromise<Data, Variables>\n extends Promise<QueryResult<Data, Variables>> {\n // reserved for special actions like cancellation\n}\n\n/**\n * Execute Query\n * @param queryRef query to execute.\n * @returns `QueryPromise`\n */\nexport function executeQuery<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n options?: ExecuteQueryOptions\n): QueryPromise<Data, Variables> {\n if (queryRef.refType !== QUERY_STR) {\n return Promise.reject(\n new DataConnectError(\n Code.INVALID_ARGUMENT,\n `ExecuteQuery can only execute query operations`\n )\n );\n }\n const queryManager = queryRef.dataConnect._queryManager;\n const fetchPolicy = options?.fetchPolicy ?? QueryFetchPolicy.PREFER_CACHE;\n switch (fetchPolicy) {\n case QueryFetchPolicy.SERVER_ONLY:\n return queryManager.fetchServerResults(queryRef);\n case QueryFetchPolicy.CACHE_ONLY:\n return queryManager.fetchCacheResults(queryRef, true);\n case QueryFetchPolicy.PREFER_CACHE:\n return queryManager.preferCacheResults(queryRef, false);\n default:\n throw new DataConnectError(\n Code.INVALID_ARGUMENT,\n `Invalid fetch policy: ${fetchPolicy}`\n );\n }\n}\n\n/**\n * Execute Query\n * @param dcInstance Data Connect instance to use.\n * @param queryName Query to execute\n * @returns `QueryRef`\n */\nexport function queryRef<Data>(\n dcInstance: DataConnect,\n queryName: string\n): QueryRef<Data, undefined>;\n/**\n * Execute Query\n * @param dcInstance Data Connect instance to use.\n * @param queryName Query to execute\n * @param variables Variables to execute with\n * @returns `QueryRef`\n */\nexport function queryRef<Data, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables: Variables\n): QueryRef<Data, Variables>;\n/**\n * Execute Query\n * @param dcInstance Data Connect instance to use.\n * @param queryName Query to execute\n * @param variables Variables to execute with\n * @param initialCache initial cache to use for client hydration\n * @returns `QueryRef`\n */\nexport function queryRef<Data, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables?: Variables,\n initialCache?: QueryResult<Data, Variables>\n): QueryRef<Data, Variables> {\n dcInstance.setInitialized();\n if (initialCache !== undefined) {\n dcInstance._queryManager.updateSSR(initialCache);\n }\n return {\n dataConnect: dcInstance,\n refType: QUERY_STR,\n name: queryName,\n variables: variables as Variables\n };\n}\n/**\n * Converts serialized ref to query ref\n * @param serializedRef ref to convert to `QueryRef`\n * @returns `QueryRef`\n */\nexport function toQueryRef<Data, Variables>(\n serializedRef: SerializedRef<Data, Variables>\n): QueryRef<Data, Variables> {\n const {\n refInfo: { name, variables, connectorConfig }\n } = serializedRef;\n return queryRef(getDataConnect(connectorConfig), name, variables);\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ConnectorConfig,\n DataConnect,\n getDataConnect\n} from '../api/DataConnect';\nimport { Code, DataConnectError } from '../core/error';\ninterface ParsedArgs<Variables> {\n dc: DataConnect;\n vars: Variables;\n}\n\n/**\n * The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,\n * and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.\n * @param connectorConfig\n * @param dcOrVars\n * @param vars\n * @param validateVars\n * @returns {DataConnect} and {Variables} instance\n * @internal\n */\nexport function validateArgs<Variables extends object>(\n connectorConfig: ConnectorConfig,\n dcOrVars?: DataConnect | Variables,\n vars?: Variables,\n validateVars?: boolean\n): ParsedArgs<Variables> {\n let dcInstance: DataConnect;\n let realVars: Variables;\n if (dcOrVars && 'enableEmulator' in dcOrVars) {\n dcInstance = dcOrVars as DataConnect;\n realVars = vars as Variables;\n } else {\n dcInstance = getDataConnect(connectorConfig);\n realVars = dcOrVars as Variables;\n }\n if (!dcInstance || (!realVars && validateVars)) {\n throw new DataConnectError(Code.INVALID_ARGUMENT, 'Variables required.');\n }\n return { dc: dcInstance, vars: realVars };\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { QueryRef, QueryResult, toQueryRef } from '../../api/query';\nimport { SerializedRef } from '../../api/Reference';\nimport { DataConnectError, Code } from '../error';\n\nimport { getRefSerializer } from './QueryManager';\n\n/**\n * `OnCompleteSubscription`\n */\nexport type OnCompleteSubscription = () => void;\n/**\n * Representation of full observer options in `subscribe`\n */\nexport interface SubscriptionOptions<Data, Variables> {\n onNext?: OnResultSubscription<Data, Variables>;\n onErr?: OnErrorSubscription;\n onComplete?: OnCompleteSubscription;\n}\n\n/**\n * Signature for `OnResultSubscription` for `subscribe`\n */\nexport type OnResultSubscription<Data, Variables> = (\n res: QueryResult<Data, Variables>\n) => void;\n/**\n * Signature for `OnErrorSubscription` for `subscribe`\n */\nexport type OnErrorSubscription = (err?: DataConnectError) => void;\n/**\n * Signature for unsubscribe from `subscribe`\n */\nexport type QueryUnsubscribe = () => void;\n/**\n * Representation of user provided subscription options.\n */\nexport interface DataConnectSubscription<Data, Variables> {\n userCallback: OnResultSubscription<Data, Variables>;\n errCallback?: (e?: DataConnectError) => void;\n unsubscribe: () => void;\n}\n\n/**\n * Subscribe to a `QueryRef`\n * @param queryRefOrSerializedResult query ref or serialized result.\n * @param observer observer object to use for subscribing.\n * @returns `SubscriptionOptions`\n */\nexport function subscribe<Data, Variables>(\n queryRefOrSerializedResult:\n | QueryRef<Data, Variables>\n | SerializedRef<Data, Variables>,\n observer: SubscriptionOptions<Data, Variables>\n): QueryUnsubscribe;\n/**\n * Subscribe to a `QueryRef`\n * @param queryRefOrSerializedResult query ref or serialized result.\n * @param onNext Callback to call when result comes back.\n * @param onError Callback to call when error gets thrown.\n * @param onComplete Called when subscription completes.\n * @returns `SubscriptionOptions`\n */\nexport function subscribe<Data, Variables>(\n queryRefOrSerializedResult:\n | QueryRef<Data, Variables>\n | SerializedRef<Data, Variables>,\n onNext: OnResultSubscription<Data, Variables>,\n onError?: OnErrorSubscription,\n onComplete?: OnCompleteSubscription\n): QueryUnsubscribe;\n/**\n * Subscribe to a `QueryRef`\n * @param queryRefOrSerializedResult query ref or serialized result.\n * @param observerOrOnNext observer object or next function.\n * @param onError Callback to call when error gets thrown.\n * @param onComplete Called when subscription completes.\n * @returns `SubscriptionOptions`\n */\nexport function subscribe<Data, Variables>(\n queryRefOrSerializedResult:\n | QueryRef<Data, Variables>\n | SerializedRef<Data, Variables>,\n observerOrOnNext:\n | SubscriptionOptions<Data, Variables>\n | OnResultSubscription<Data, Variables>,\n onError?: OnErrorSubscription,\n onComplete?: OnCompleteSubscription\n): QueryUnsubscribe {\n let ref: QueryRef<Data, Variables>;\n let initialCache: QueryResult<Data, Variables> | undefined;\n if ('refInfo' in queryRefOrSerializedResult) {\n const serializedRef: SerializedRef<Data, Variables> =\n queryRefOrSerializedResult;\n const { data, source, fetchTime } = serializedRef;\n\n ref = toQueryRef(serializedRef);\n initialCache = {\n data,\n source,\n fetchTime,\n ref,\n toJSON: getRefSerializer(ref, data, source, fetchTime)\n };\n } else {\n ref = queryRefOrSerializedResult;\n }\n let onResult: OnResultSubscription<Data, Variables> | undefined = undefined;\n if (typeof observerOrOnNext === 'function') {\n onResult = observerOrOnNext;\n } else {\n onResult = observerOrOnNext.onNext;\n onError = observerOrOnNext.onErr;\n onComplete = observerOrOnNext.onComplete;\n }\n if (!onResult) {\n throw new DataConnectError(Code.INVALID_ARGUMENT, 'Must provide onNext');\n }\n return ref.dataConnect._queryManager.addSubscription(\n ref,\n onResult,\n onComplete,\n onError,\n initialCache\n );\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { initializeFetch } from './network/fetch';\nimport { registerDataConnect } from './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,CAAC,MAAM,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
19
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
20
|
+
import { Provider } from '@firebase/component';
|
|
21
|
+
import { DataConnectCache } from '../cache/Cache';
|
|
22
|
+
import { InternalCacheProvider } from '../cache/CacheProvider';
|
|
23
|
+
import { QueryManager } from '../core/query/QueryManager';
|
|
24
|
+
import { CallerSdkType } from '../network';
|
|
25
|
+
import { MutationManager } from './Mutation';
|
|
26
|
+
/**
|
|
27
|
+
* Connector Config for calling Data Connect backend.
|
|
28
|
+
*/
|
|
29
|
+
export interface ConnectorConfig {
|
|
30
|
+
location: string;
|
|
31
|
+
connector: string;
|
|
32
|
+
service: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options to connect to emulator
|
|
36
|
+
*/
|
|
37
|
+
export interface TransportOptions {
|
|
38
|
+
host: string;
|
|
39
|
+
sslEnabled?: boolean;
|
|
40
|
+
port?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param fullHost
|
|
45
|
+
* @returns TransportOptions
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseOptions(fullHost: string): TransportOptions;
|
|
49
|
+
/**
|
|
50
|
+
* DataConnectOptions including project id
|
|
51
|
+
*/
|
|
52
|
+
export interface DataConnectOptions extends ConnectorConfig {
|
|
53
|
+
projectId: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Class representing Firebase Data Connect
|
|
57
|
+
*/
|
|
58
|
+
export declare class DataConnect {
|
|
59
|
+
readonly app: FirebaseApp;
|
|
60
|
+
private readonly dataConnectOptions;
|
|
61
|
+
private readonly _authProvider;
|
|
62
|
+
private readonly _appCheckProvider;
|
|
63
|
+
_queryManager: QueryManager;
|
|
64
|
+
_mutationManager: MutationManager;
|
|
65
|
+
isEmulator: boolean;
|
|
66
|
+
_initialized: boolean;
|
|
67
|
+
private _transport;
|
|
68
|
+
private _transportClass;
|
|
69
|
+
private _transportOptions?;
|
|
70
|
+
private _authTokenProvider?;
|
|
71
|
+
_isUsingGeneratedSdk: boolean;
|
|
72
|
+
_callerSdkType: CallerSdkType;
|
|
73
|
+
private _appCheckTokenProvider?;
|
|
74
|
+
private _cacheSettings?;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
private cache?;
|
|
79
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
getCache(): DataConnectCache | undefined;
|
|
84
|
+
_useGeneratedSdk(): void;
|
|
85
|
+
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
86
|
+
_delete(): Promise<void>;
|
|
87
|
+
getSettings(): ConnectorConfig;
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
setCacheSettings(cacheSettings: CacheSettings): void;
|
|
92
|
+
setInitialized(): void;
|
|
93
|
+
enableEmulator(transportOptions: TransportOptions): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
* @param transportOptions1
|
|
98
|
+
* @param transportOptions2
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
export declare function areTransportOptionsEqual(transportOptions1: TransportOptions, transportOptions2: TransportOptions): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Connect to the DataConnect Emulator
|
|
104
|
+
* @param dc Data Connect instance
|
|
105
|
+
* @param host host of emulator server
|
|
106
|
+
* @param port port of emulator server
|
|
107
|
+
* @param sslEnabled use https
|
|
108
|
+
*/
|
|
109
|
+
export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
|
|
110
|
+
export interface DataConnectSettings {
|
|
111
|
+
cacheSettings?: CacheSettings;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Initialize DataConnect instance
|
|
115
|
+
* @param options ConnectorConfig
|
|
116
|
+
*/
|
|
117
|
+
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
|
|
118
|
+
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
119
|
+
/**
|
|
120
|
+
* Initialize DataConnect instance
|
|
121
|
+
* @param app FirebaseApp to initialize to.
|
|
122
|
+
* @param connectorConfig ConnectorConfig
|
|
123
|
+
*/
|
|
124
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
|
|
125
|
+
/**
|
|
126
|
+
* Initialize DataConnect instance
|
|
127
|
+
* @param app FirebaseApp to initialize to.
|
|
128
|
+
* @param connectorConfig ConnectorConfig
|
|
129
|
+
*/
|
|
130
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* @param dcOptions
|
|
134
|
+
* @returns {void}
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Delete DataConnect instance
|
|
140
|
+
* @param dataConnect DataConnect instance
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
144
|
+
export declare const StorageType: {
|
|
145
|
+
readonly MEMORY: "MEMORY";
|
|
146
|
+
};
|
|
147
|
+
export type StorageType = (typeof StorageType)[keyof typeof StorageType];
|
|
148
|
+
export interface CacheSettings {
|
|
149
|
+
cacheProvider: CacheProvider<StorageType>;
|
|
150
|
+
maxAgeSeconds?: number;
|
|
151
|
+
}
|
|
152
|
+
export interface CacheProvider<T extends StorageType> {
|
|
153
|
+
type: T;
|
|
154
|
+
/**
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
initialize(cacheId: string): InternalCacheProvider;
|
|
158
|
+
}
|
|
159
|
+
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { DataConnectTransport } from '../network/transport';
|
|
18
|
+
import { DataConnect } from './DataConnect';
|
|
19
|
+
import { DataConnectResult, MUTATION_STR, OperationRef } from './Reference';
|
|
20
|
+
export interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
21
|
+
refType: typeof MUTATION_STR;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a `MutationRef`
|
|
25
|
+
* @param dcInstance Data Connect instance
|
|
26
|
+
* @param mutationName name of mutation
|
|
27
|
+
*/
|
|
28
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param dcInstance Data Connect instance
|
|
32
|
+
* @param mutationName name of mutation
|
|
33
|
+
* @param variables variables to send with mutation
|
|
34
|
+
*/
|
|
35
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare class MutationManager {
|
|
40
|
+
private _transport;
|
|
41
|
+
private _inflight;
|
|
42
|
+
constructor(_transport: DataConnectTransport);
|
|
43
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mutation Result from `executeMutation`
|
|
47
|
+
*/
|
|
48
|
+
export interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
|
|
49
|
+
ref: MutationRef<Data, Variables>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mutation return value from `executeMutation`
|
|
53
|
+
*/
|
|
54
|
+
export interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Execute Mutation
|
|
58
|
+
* @param mutationRef mutation to execute
|
|
59
|
+
* @returns `MutationRef`
|
|
60
|
+
*/
|
|
61
|
+
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|