@firebase/data-connect 0.0.1-dataconnect-preview.323fdc1b8 → 0.0.2-dataconnect-preview.877f8b7d0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +124 -162
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +123 -160
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +125 -163
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +74 -93
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +30 -48
- package/dist/node-esm/index.node.esm.js +75 -92
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +6 -12
- package/dist/node-esm/src/api/Mutation.d.ts +8 -8
- package/dist/node-esm/src/api/Reference.d.ts +3 -3
- package/dist/node-esm/src/api/query.d.ts +2 -2
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +5 -15
- package/dist/node-esm/src/core/QueryManager.d.ts +7 -7
- package/dist/node-esm/src/network/transport/rest.d.ts +13 -25
- package/dist/node-esm/src/util/url.d.ts +2 -2
- package/dist/private.d.ts +30 -48
- package/dist/public.d.ts +13 -38
- package/dist/src/api/DataConnect.d.ts +6 -12
- package/dist/src/api/Mutation.d.ts +8 -8
- package/dist/src/api/Reference.d.ts +3 -3
- package/dist/src/api/query.d.ts +2 -2
- package/dist/src/core/FirebaseAuthProvider.d.ts +5 -15
- package/dist/src/core/QueryManager.d.ts +7 -7
- package/dist/src/network/transport/rest.d.ts +13 -25
- package/dist/src/util/url.d.ts +2 -2
- package/package.json +7 -7
- package/dist/node-esm/test/emulatorSeeder.d.ts +0 -22
- package/dist/node-esm/test/queries.test.d.ts +0 -17
- package/dist/node-esm/test/util.d.ts +0 -26
- package/dist/test/emulatorSeeder.d.ts +0 -22
- package/dist/test/queries.test.d.ts +0 -17
- package/dist/test/util.d.ts +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.cjs.js","sources":["../src/core/error.ts","../src/core/version.ts","../src/logger.ts","../src/network/fetch.ts","../src/core/FirebaseAuthProvider.ts","../src/api/Reference.ts","../src/util/encoder.ts","../src/util/map.ts","../src/core/QueryManager.ts","../src/util/url.ts","../src/network/transport/rest.ts","../src/api/Mutation.ts","../src/api/DataConnect.ts","../src/register.ts","../src/api/query.ts","../src/api.browser.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\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};\n\n/** An error returned by a DataConnect operation. */\nexport class DataConnectError extends FirebaseError {\n /** The stack of the error. */\n readonly stack?: string;\n\n /** @hideconstructor */\n constructor(\n /**\n * The backend error code associated with this error.\n */\n readonly code: DataConnectErrorCode,\n /**\n * A custom error description.\n */\n readonly message: string\n ) {\n super(code, message);\n\n // HACK: We write a toString property directly because Error is not a real\n // class and so inheritance does not work correctly. We could alternatively\n // do the same \"back-door inheritance\" trick that FirebaseError does.\n this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`;\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\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, LogLevel, LogLevelString } from '@firebase/logger';\nimport { SDK_VERSION } from './core/version';\n\nconst logger = new Logger('@firebase/data-connect');\nexport function setLogLevel(logLevel: LogLevelString) {\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 { Code, DataConnectError } from '../core/error';\nimport { logDebug, logError } from '../logger';\n\nlet connectFetch: typeof fetch | null = globalThis.fetch;\nexport function initializeFetch(fetchImpl: typeof fetch) {\n connectFetch = fetchImpl;\n}\nexport function dcFetch<T, U>(\n url: string,\n body: U,\n { signal }: AbortController,\n accessToken: string | null\n) {\n if (!connectFetch) {\n throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');\n }\n const headers: HeadersInit = {\n 'Content-Type': 'application/json'\n };\n if (accessToken) {\n headers['X-Firebase-Auth-Token'] = accessToken;\n }\n const bodyStr = JSON.stringify(body);\n logDebug(`Making request out to ${url} with body: ${bodyStr}`);\n return connectFetch(url, {\n body: bodyStr,\n method: 'POST',\n headers,\n signal\n })\n .then(async response => {\n let jsonResponse = null;\n try {\n jsonResponse = await response.json();\n } catch (e) {\n throw new DataConnectError(Code.OTHER, JSON.stringify(e));\n }\n if (response.status >= 400) {\n logError(\n 'Error while performing request: ' + JSON.stringify(jsonResponse)\n );\n throw new DataConnectError(Code.OTHER, JSON.stringify(jsonResponse));\n }\n return jsonResponse;\n })\n .then(res => {\n if (res.errors && res.errors.length) {\n const stringified = JSON.stringify(res.errors);\n logError('DataConnect error while performing request: ' + stringified);\n throw new DataConnectError(Code.OTHER, stringified);\n }\n return res as { data: T; errors: Error[] };\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';\nimport {\n FirebaseAuthInternal,\n FirebaseAuthInternalName,\n FirebaseAuthTokenData\n} from '@firebase/auth-interop-types';\nimport { Provider } from '@firebase/component';\nimport { logDebug, logError } from '../logger';\n\nexport interface AuthTokenProvider {\n getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;\n addTokenChangeListener(listener: AuthTokenListener): void;\n}\nexport type AuthTokenListener = (token: string | null) => void;\n\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 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) {\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 }\n}\nexport class EmulatorTokenProvider implements AuthTokenProvider {\n /** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */\n static OWNER = 'owner';\n\n constructor(private accessToken: string) {}\n\n getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData> {\n return Promise.resolve({\n accessToken: this.accessToken\n });\n }\n\n addTokenChangeListener(listener: AuthTokenListener): void {\n // Invoke the listener immediately to match the behavior in Firebase Auth\n // (see packages/auth/src/auth.js#L1807)\n listener(this.accessToken);\n }\n\n removeTokenChangeListener(listener: (token: string | null) => void): void {}\n\n notifyForInvalidToken(): void {}\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 { DataConnect, DataConnectOptions } from './DataConnect';\nexport const QueryStr = 'query';\nexport const MutationStr = 'mutation';\nexport type ReferenceType = typeof QueryStr | typeof MutationStr;\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}\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\nexport interface RefInfo<Variables> {\n name: string;\n variables: Variables;\n connectorConfig: DataConnectOptions;\n}\nexport interface SerializedRef<Data, Variables> extends OpResult<Data> {\n refInfo: RefInfo<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\nexport type HmacImpl = (obj: unknown) => string;\nexport let encoderImpl: HmacImpl;\nexport function setEncoder(encoder: HmacImpl) {\n encoderImpl = encoder;\n}\nsetEncoder(o => JSON.stringify(o));\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 function setIfNotExists<T>(map: Map<string, T>, key: string, val: T) {\n if (!map.has(key)) {\n map.set(key, val);\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 {\n DataConnectSubscription,\n OnErrorSubscription,\n OnResultSubscription,\n QueryPromise,\n QueryRef,\n QueryResult\n} from '../api/query';\nimport {\n OperationRef,\n QueryStr,\n OpResult,\n SerializedRef,\n SOURCE_SERVER,\n DataSource,\n SOURCE_CACHE\n} from '../api/Reference';\nimport { logDebug } from '../logger';\nimport { DataConnectTransport } from '../network';\nimport { encoderImpl } from '../util/encoder';\nimport { setIfNotExists } from '../util/map';\nimport { DataConnectError } from './error';\n\ninterface TrackedQuery<Response, Variables> {\n ref: Omit<OperationRef<Response, Variables>, 'dataConnect'>;\n subscriptions: Array<DataConnectSubscription<Response, Variables>>;\n currentCache: OpResult<Response> | null;\n lastError: DataConnectError | null;\n}\n\nfunction getRefSerializer<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n data: Data,\n source: DataSource\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: Date.now().toLocaleString(),\n source\n };\n };\n}\n\nexport class QueryManager {\n _queries: Map<string, TrackedQuery<unknown, unknown>>;\n constructor(private transport: DataConnectTransport) {\n this._queries = new Map();\n }\n track<Response, Variables>(\n queryName: string,\n variables: Variables,\n initialCache?: OpResult<Response>\n ) {\n const ref: TrackedQuery<Response, Variables>['ref'] = {\n name: queryName,\n variables,\n refType: QueryStr\n };\n const key = encoderImpl(ref);\n const newTrackedQuery: TrackedQuery<Response, Variables> = {\n ref,\n subscriptions: [],\n currentCache: initialCache || null,\n lastError: null\n };\n // @ts-ignore\n setIfNotExists(this._queries, key, newTrackedQuery);\n return this._queries.get(key);\n }\n addSubscription<Response, Variables>(\n queryRef: OperationRef<Response, Variables>,\n onResultCallback: OnResultSubscription<Response, Variables>,\n onErrorCallback?: OnErrorSubscription,\n initialCache?: OpResult<Response>\n ) {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QueryStr\n });\n const trackedQuery = this._queries.get(key) as TrackedQuery<\n Response,\n Variables\n >;\n const subscription = {\n userCallback: onResultCallback,\n errCallback: onErrorCallback\n };\n const unsubscribe = () => {\n const trackedQuery = this._queries.get(key)!;\n trackedQuery.subscriptions = trackedQuery.subscriptions.filter(\n sub => sub !== subscription\n );\n };\n if (initialCache && trackedQuery.currentCache !== initialCache) {\n logDebug('Initial cache found. Comparing dates.');\n if (\n !trackedQuery.currentCache ||\n (trackedQuery.currentCache &&\n compareDates(\n trackedQuery.currentCache.fetchTime,\n initialCache.fetchTime\n ))\n ) {\n trackedQuery.currentCache = initialCache;\n }\n }\n if (trackedQuery.currentCache !== null) {\n const cachedData = trackedQuery.currentCache.data;\n onResultCallback({\n data: cachedData,\n source: SOURCE_CACHE,\n ref: queryRef as QueryRef<Response, Variables>,\n toJSON: getRefSerializer(\n queryRef as QueryRef<Response, Variables>,\n trackedQuery.currentCache.data,\n SOURCE_CACHE\n ),\n fetchTime: trackedQuery.currentCache.fetchTime\n });\n if (trackedQuery.lastError !== null && onErrorCallback) {\n onErrorCallback(undefined);\n }\n }\n\n trackedQuery.subscriptions.push({\n userCallback: onResultCallback,\n errCallback: onErrorCallback,\n unsubscribe\n });\n if (!trackedQuery.currentCache) {\n logDebug(\n `No cache available for query ${\n queryRef.name\n } with variables ${JSON.stringify(\n queryRef.variables\n )}. Calling executeQuery.`\n );\n const promise = this.executeQuery(\n queryRef as QueryRef<Response, Variables>\n );\n // We want to ignore the error and let subscriptions handle it\n promise.then(undefined, err => {});\n }\n return unsubscribe;\n }\n executeQuery<Response, Variables>(\n queryRef: QueryRef<Response, Variables>\n ): QueryPromise<Response, Variables> {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QueryStr\n });\n const trackedQuery = this._queries.get(key)!;\n const result = this.transport.invokeQuery<Response, Variables>(\n queryRef.name,\n queryRef.variables\n );\n const newR = result.then(\n res => {\n const fetchTime = new Date().toString();\n const result: QueryResult<Response, Variables> = {\n ...res,\n source: SOURCE_SERVER,\n ref: queryRef,\n toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER),\n fetchTime\n };\n trackedQuery.subscriptions.forEach(subscription => {\n subscription.userCallback(result);\n });\n trackedQuery.currentCache = {\n data: res.data,\n source: SOURCE_CACHE,\n fetchTime\n };\n return result;\n },\n err => {\n trackedQuery.lastError = err;\n trackedQuery.subscriptions.forEach(subscription => {\n if (subscription.errCallback) {\n subscription.errCallback(err);\n }\n });\n throw err;\n }\n );\n\n return newR;\n }\n enableEmulator(host: string, port: number) {\n this.transport.useEmulator(host, port);\n }\n}\nfunction compareDates(str1: string, str2: string) {\n const date1 = new Date(str1);\n const date2 = new Date(str2);\n return date1.getTime() < date2.getTime();\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 { ProjectOptions, TransportOptions } from '../api/DataConnect';\nimport { Code, DataConnectError } from '../core/error';\nimport { logError } from '../logger';\n\nexport function urlBuilder(\n projectConfig: ProjectOptions,\n transportOptions: TransportOptions\n) {\n const { connector, location, projectId: project, service } = projectConfig;\n const { host, sslEnabled, port } = transportOptions;\n const protocol = sslEnabled ? 'https' : 'http';\n const realHost = host || `firebasedataconnect.googleapis.com`;\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}/v1alpha/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 { DataConnectTransport } from '.';\nimport { DataConnectOptions, TransportOptions } from '../../api/DataConnect';\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\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 authInitialized_ = false;\n constructor(\n options: DataConnectOptions,\n private apiKey?: string | undefined,\n private authProvider?: AuthTokenProvider | undefined,\n transportOptions?: TransportOptions | undefined\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 }\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 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) {\n this.accessToken = newToken;\n }\n\n getWithAuth() {\n let starterPromise: Promise<string | null> = new Promise(resolve =>\n resolve(this.accessToken)\n );\n if (!this.authInitialized_) {\n if (this.authProvider) {\n starterPromise = this.authProvider\n .getToken(/*forceToken=*/ false)\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 }\n return starterPromise;\n }\n\n // TODO(mtewani): Update U to include shape of body defined in line 13.\n invokeQuery = <T, U = unknown>(queryName: string, body: U) => {\n const abortController = new AbortController();\n\n // TODO(mtewani): Update to proper value\n const withAuth = this.getWithAuth().then(() => {\n return 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 } as unknown as U, // TODO(mtewani): This is a patch, fix this.\n abortController,\n this.accessToken\n );\n });\n\n return {\n then: withAuth.then.bind(withAuth)\n };\n };\n invokeMutation = <T, U = unknown>(mutationName: string, body: U) => {\n const abortController = new AbortController();\n const taskResult = this.getWithAuth().then(() => {\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 } as unknown as U,\n abortController,\n this.accessToken\n );\n });\n\n return {\n then: taskResult.then.bind(taskResult),\n // catch: taskResult.catch.bind(taskResult),\n // finally: taskResult.finally.bind(taskResult),\n cancel: () => abortController.abort()\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 { DataConnectTransport } from '../network/transport';\n\nimport { DataConnect } from './DataConnect';\nimport {\n DataConnectResult,\n MutationStr,\n OperationRef,\n SOURCE_SERVER\n} from './Reference';\n\nexport interface MutationRef<Response, Variables>\n extends OperationRef<Response, Variables> {\n refType: typeof MutationStr;\n}\n\nexport function mutationRef<Response>(\n dcInstance: DataConnect,\n queryName: string\n): MutationRef<Response, undefined>;\nexport function mutationRef<Response, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables: Variables\n): MutationRef<Response, Variables>;\nexport function mutationRef<Response, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables?: Variables\n): MutationRef<Response, Variables> {\n dcInstance.setInitialized();\n const ref: MutationRef<Response, Variables> = {\n dataConnect: dcInstance,\n name: queryName,\n refType: MutationStr,\n variables: variables as Variables\n };\n return ref;\n}\n\nexport class MutationManager {\n private _inflight: Array<PromiseLike<unknown>> = [];\n constructor(private transport: DataConnectTransport) {}\n executeMutation<Response, Variables>(\n mutationRef: MutationRef<Response, Variables>\n ): MutationPromise<Response, Variables> {\n const result = this.transport.invokeMutation<Response, Variables>(\n mutationRef.name,\n mutationRef.variables\n );\n const withRefPromise = result.then(res => {\n const obj: MutationResult<Response, 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 = () =>\n (this._inflight = this._inflight.filter(promise => promise !== result));\n result.then(removePromise, removePromise);\n return withRefPromise;\n }\n}\n\nexport interface MutationResult<Data, Variables>\n extends DataConnectResult<Data, Variables> {\n ref: MutationRef<Data, Variables>;\n}\nexport interface MutationPromise<Data, Variables>\n extends PromiseLike<MutationResult<Data, Variables>> {\n // reserved for special actions like cancellation\n}\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 { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { Provider } from '@firebase/component';\n\nimport {\n AuthTokenProvider,\n EmulatorTokenProvider,\n FirebaseAuthProvider\n} from '../core/FirebaseAuthProvider';\nimport { QueryManager } from '../core/QueryManager';\nimport { DataConnectTransport, TransportClass } from '../network';\nimport { RESTTransport } from '../network/transport/rest';\n\nimport { MutationManager } from './Mutation';\nimport { Code, DataConnectError } from '../core/error';\nimport { logDebug, logError } from '../logger';\n\nexport interface ProjectOptions {\n location: string;\n connector: string;\n service: string;\n projectId: string;\n}\n\nexport interface ConnectorConfig {\n location: string;\n connector: string;\n service: string;\n}\n\nexport interface TransportOptions {\n host: string;\n sslEnabled?: boolean;\n port?: number;\n}\n\nexport const 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}\nexport interface DataConnectOptions extends ConnectorConfig {\n projectId: string;\n}\n\nexport class DataConnect {\n _queryManager!: QueryManager;\n _mutationManager!: MutationManager;\n public isEmulator = false;\n initialized = false;\n private _transport!: DataConnectTransport;\n private transportClass: TransportClass | undefined;\n private transportOptions?: TransportOptions;\n private authTokenProvider?: AuthTokenProvider;\n constructor(\n public readonly app: FirebaseApp,\n private readonly dataConnectOptions: DataConnectOptions,\n private readonly authProvider: Provider<FirebaseAuthInternalName>\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 _delete() {\n _removeServiceInstance(\n this.app,\n 'data-connect',\n JSON.stringify(this.getSettings())\n );\n return Promise.resolve();\n }\n\n getSettings(): ConnectorConfig {\n const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));\n delete copy.projectId;\n return copy;\n }\n\n setInitialized() {\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 if (this.authProvider) {\n this.authTokenProvider = this.isEmulator\n ? new EmulatorTokenProvider(EmulatorTokenProvider.OWNER)\n : new FirebaseAuthProvider(\n this.app.name,\n this.app.options,\n this.authProvider\n );\n }\n\n this.initialized = true;\n this._transport = new this.transportClass(\n this.dataConnectOptions,\n this.app.options.apiKey,\n this.authTokenProvider\n );\n if (this.transportOptions) {\n this._transport.useEmulator(\n this.transportOptions.host,\n this.transportOptions.port,\n this.transportOptions.sslEnabled\n );\n }\n this._queryManager = new QueryManager(this._transport);\n this._mutationManager = new MutationManager(this._transport);\n }\n\n enableEmulator(transportOptions: TransportOptions) {\n if (this.initialized) {\n logError('enableEmulator called without initializing');\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\nexport function connectDataConnectEmulator(\n dc: DataConnect,\n host: string,\n port?: number,\n sslEnabled = false\n) {\n dc.enableEmulator({ host, port, sslEnabled });\n}\n\nexport function getDataConnect(options: ConnectorConfig): DataConnect;\nexport function getDataConnect(\n app: FirebaseApp,\n options: ConnectorConfig\n): DataConnect;\nexport function getDataConnect(\n appOrOptions: FirebaseApp | ConnectorConfig,\n optionalOptions?: ConnectorConfig\n): DataConnect {\n let app: FirebaseApp;\n let dcOptions: ConnectorConfig;\n if ('location' in appOrOptions) {\n dcOptions = appOrOptions;\n app = getApp();\n } else {\n dcOptions = optionalOptions!;\n app = appOrOptions;\n }\n\n if (!app) {\n app = getApp();\n }\n const provider = _getProvider(app, 'data-connect');\n const identifier = JSON.stringify(dcOptions);\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 if (!dcOptions) {\n throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required');\n }\n logDebug('Creating new DataConnect instance');\n // Initialize with options.\n return provider.initialize({\n instanceIdentifier: identifier,\n options: dcOptions\n });\n}\n\nexport function terminate(dataConnect: DataConnect) {\n dataConnect._delete();\n // TODO(mtewani): Stop pending tasks\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';\n\nexport function registerDataConnect(variant?: string): void {\n setSDKVersion(SDK_VERSION);\n _registerComponent(\n new Component(\n 'data-connect',\n (container, { instanceIdentifier: settings, options }) => {\n const app = container.getProvider('app').getImmediate()!;\n const authProvider = container.getProvider('auth-internal');\n let newOpts = options as ConnectorConfig;\n if (settings) {\n newOpts = JSON.parse(settings);\n }\n return new DataConnect(\n app,\n { ...newOpts, projectId: app.options.projectId! },\n authProvider\n );\n },\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n registerVersion(name, version, variant);\n // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\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 { DataConnectError } from '../core/error';\nimport { DataConnect, getDataConnect } from './DataConnect';\nimport {\n OperationRef,\n QueryStr,\n DataConnectResult,\n SerializedRef\n} from './Reference';\n\nexport type OnResultSubscription<Data, Variables> = (\n res: QueryResult<Data, Variables>\n) => void;\nexport type OnErrorSubscription = (err?: DataConnectError) => void;\nexport type QueryUnsubscribe = () => void;\nexport interface DataConnectSubscription<Data, Variables> {\n userCallback: OnResultSubscription<Data, Variables>;\n errCallback?: (e?: DataConnectError) => void;\n unsubscribe: () => void;\n}\nexport interface QueryRef<Data, Variables>\n extends OperationRef<Data, Variables> {\n refType: typeof QueryStr;\n}\nexport interface QueryResult<Data, Variables>\n extends DataConnectResult<Data, Variables> {\n ref: QueryRef<Data, Variables>;\n toJSON: () => SerializedRef<Data, Variables>;\n}\nexport interface QueryPromise<Data, Variables>\n extends PromiseLike<QueryResult<Data, Variables>> {\n // reserved for special actions like cancellation\n}\n\nexport function executeQuery<Data, Variables>(\n queryRef: QueryRef<Data, Variables>\n): QueryPromise<Data, Variables> {\n return queryRef.dataConnect._queryManager.executeQuery(queryRef);\n}\n\nexport function queryRef<Data>(\n dcInstance: DataConnect,\n queryName: string\n): QueryRef<Data, undefined>;\nexport function queryRef<Data, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables: Variables\n): QueryRef<Data, Variables>;\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 dcInstance._queryManager.track(queryName, variables, initialCache);\n return {\n dataConnect: dcInstance,\n refType: QueryStr,\n name: queryName,\n variables: variables as Variables\n };\n}\nexport function toQueryRef<Data, Variables>(\n serializedRef: SerializedRef<Data, Variables>\n) {\n const {\n refInfo: { name, variables, connectorConfig }\n } = serializedRef;\n return queryRef(getDataConnect(connectorConfig), name, variables);\n}\nexport type OnCompleteSubscription = () => void;\nexport interface SubscriptionOptions<Data, Variables> {\n onNext?: OnResultSubscription<Data, Variables>;\n onErr?: OnErrorSubscription;\n onComplete?: OnCompleteSubscription;\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 OnCompleteSubscription,\n OnErrorSubscription,\n OnResultSubscription,\n QueryRef,\n QueryUnsubscribe,\n SubscriptionOptions,\n toQueryRef\n} from './api/query';\nimport { OpResult, SerializedRef } from './api/Reference';\nimport { DataConnectError, Code } from './core/error';\n\n/**\n *\n * @public\n * @param queryRef\n * @param onResult\n * @param onErr\n * @param initialCache\n * @returns\n */\nexport function subscribe<Data, Variables>(\n queryRefOrSerializedResult:\n | QueryRef<Data, Variables>\n | SerializedRef<Data, Variables>,\n observer: SubscriptionOptions<Data, Variables>\n): QueryUnsubscribe;\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;\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: OpResult<Data> | undefined;\n if ('refInfo' in queryRefOrSerializedResult) {\n let serializedRef: SerializedRef<Data, Variables> =\n queryRefOrSerializedResult;\n const { data, source, fetchTime } = serializedRef;\n initialCache = {\n data,\n source,\n fetchTime\n };\n ref = toQueryRef(serializedRef);\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 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 './register';\n\nexport * from './api';\nexport * from './api.node';\ninitializeFetch(fetch);\n\nregisterDataConnect('node');\n"],"names":["__extends","FirebaseError","Logger","__awaiter","__assign","_removeServiceInstance","app","getApp","_getProvider","SDK_VERSION","_registerComponent","Component","registerVersion"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAcI,IAAM,IAAI,GAAG;AAClB,IAAA,KAAK,EAAE,OAA+B;AACtC,IAAA,mBAAmB,EAAE,qBAA6C;AAClE,IAAA,eAAe,EAAE,iBAAyC;AAC1D,IAAA,aAAa,EAAE,eAAuC;AACtD,IAAA,gBAAgB,EAAE,kBAA0C;AAC5D,IAAA,aAAa,EAAE,eAAuC;CACvD,CAAC;AAEF;AACA,IAAA,gBAAA,kBAAA,UAAA,MAAA,EAAA;IAAsCA,eAAa,CAAA,gBAAA,EAAA,MAAA,CAAA,CAAA;;AAKjD,IAAA,SAAA,gBAAA;AACE;;AAEG;IACM,IAA0B;AACnC;;AAEG;IACM,OAAe,EAAA;AAR1B,QAAA,IAAA,KAAA,GAUE,MAAM,CAAA,IAAA,CAAA,IAAA,EAAA,IAAI,EAAE,OAAO,CAAC,IAMrB,IAAA,CAAA;QAZU,KAAI,CAAA,IAAA,GAAJ,IAAI,CAAsB;QAI1B,KAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;;;;QAOxB,KAAI,CAAC,QAAQ,GAAG,YAAA,EAAM,OAAA,EAAG,CAAA,MAAA,CAAA,KAAI,CAAC,IAAI,EAAA,UAAA,CAAA,CAAA,MAAA,CAAW,KAAI,CAAC,IAAI,gBAAM,KAAI,CAAC,OAAO,CAAE,CAAA,EAAA,CAAC;;KAC5E;IACH,OAAC,gBAAA,CAAA;AAAD,CAtBA,CAAsCC,kBAAa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AAY,GAAG;AACb,YAAA,IAAI,EAAA,IAAA;AACJ,YAAA,MAAM,EAAA,MAAA;AACN,YAAA,SAAS,EAAA,SAAA;SACV,CAAC;AACF,QAAA,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;AACjC,KAAA;AAAM,SAAA;QACL,GAAG,GAAG,0BAA0B,CAAC;AAClC,KAAA;IACD,IAAI,QAAQ,GAAsD,SAAS,CAAC;AAC5E,IAAA,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE;QAC1C,QAAQ,GAAG,gBAAgB,CAAC;AAC7B,KAAA;AAAM,SAAA;AACL,QAAA,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnC,QAAA,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC;AACjC,QAAa,gBAAgB,CAAC,UAAU,CAAC;AAC1C,KAAA;IACD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;AAC1E,KAAA;AACD,IAAA,OAAO,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAClD,GAAG,EACH,QAAQ,EACR,OAAO,EACP,YAAY,CACb,CAAC;AACJ;;AC9FA;;;;;;;;;;;;;;;AAeG;AAOH,eAAe,CAAC,KAAK,CAAC,CAAC;AAEvB,mBAAmB,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.node.cjs.js","sources":["../src/core/error.ts","../src/core/version.ts","../src/logger.ts","../src/network/fetch.ts","../src/core/FirebaseAuthProvider.ts","../src/api/Reference.ts","../src/util/encoder.ts","../src/util/map.ts","../src/core/QueryManager.ts","../src/util/url.ts","../src/network/transport/rest.ts","../src/api/Mutation.ts","../src/api/DataConnect.ts","../src/register.ts","../src/api/query.ts","../src/api.browser.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\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};\n\n/** An error returned by a DataConnect operation. */\nexport class DataConnectError extends FirebaseError {\n /** The stack of the error. */\n readonly stack?: string;\n\n /** @hideconstructor */\n constructor(\n /**\n * The backend error code associated with this error.\n */\n readonly code: DataConnectErrorCode,\n /**\n * A custom error description.\n */\n readonly message: string\n ) {\n super(code, message);\n\n // HACK: We write a toString property directly because Error is not a real\n // class and so inheritance does not work correctly. We could alternatively\n // do the same \"back-door inheritance\" trick that FirebaseError does.\n this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`;\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\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) {\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 { Code, DataConnectError } from '../core/error';\nimport { logDebug, logError } from '../logger';\n\nlet connectFetch: typeof fetch | null = globalThis.fetch;\nexport function initializeFetch(fetchImpl: typeof fetch) {\n connectFetch = fetchImpl;\n}\nexport function dcFetch<T, U>(\n url: string,\n body: U,\n { signal }: AbortController,\n accessToken: string | null\n) {\n if (!connectFetch) {\n throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');\n }\n const headers: HeadersInit = {\n 'Content-Type': 'application/json'\n };\n if (accessToken) {\n headers['X-Firebase-Auth-Token'] = accessToken;\n }\n const bodyStr = JSON.stringify(body);\n logDebug(`Making request out to ${url} with body: ${bodyStr}`);\n return connectFetch(url, {\n body: bodyStr,\n method: 'POST',\n headers,\n signal\n }).catch(err => {\n throw new DataConnectError(Code.OTHER, \"Failed to fetch: \" + JSON.stringify(err));\n })\n .then(async response => {\n let jsonResponse = null;\n try {\n jsonResponse = await response.json();\n } catch (e) {\n throw new DataConnectError(Code.OTHER, JSON.stringify(e));\n }\n if (response.status >= 400) {\n logError(\n 'Error while performing request: ' + JSON.stringify(jsonResponse)\n );\n throw new DataConnectError(Code.OTHER, JSON.stringify(jsonResponse));\n }\n return jsonResponse;\n })\n .then(res => {\n if (res.errors && res.errors.length) {\n const stringified = JSON.stringify(res.errors);\n logError('DataConnect error while performing request: ' + stringified);\n throw new DataConnectError(Code.OTHER, stringified);\n }\n return res as { data: T; errors: Error[] };\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';\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\nexport interface AuthTokenProvider {\n getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;\n addTokenChangeListener(listener: AuthTokenListener): void;\n}\nexport type AuthTokenListener = (token: string | null) => void;\n\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 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 }\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 { 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}\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\nexport interface RefInfo<Variables> {\n name: string;\n variables: Variables;\n connectorConfig: DataConnectOptions;\n}\nexport interface SerializedRef<Data, Variables> extends OpResult<Data> {\n refInfo: RefInfo<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\nexport type HmacImpl = (obj: unknown) => string;\nexport let encoderImpl: HmacImpl;\nexport function setEncoder(encoder: HmacImpl) {\n encoderImpl = encoder;\n}\nsetEncoder(o => JSON.stringify(o));\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 function setIfNotExists<T>(map: Map<string, T>, key: string, val: T): void {\n if (!map.has(key)) {\n map.set(key, val);\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 {\n DataConnectSubscription,\n OnErrorSubscription,\n OnResultSubscription,\n QueryPromise,\n QueryRef,\n QueryResult\n} from '../api/query';\nimport {\n OperationRef,\n QUERY_STR,\n OpResult,\n SerializedRef,\n SOURCE_SERVER,\n DataSource,\n SOURCE_CACHE\n} from '../api/Reference';\nimport { logDebug } from '../logger';\nimport { DataConnectTransport } from '../network';\nimport { encoderImpl } from '../util/encoder';\nimport { setIfNotExists } from '../util/map';\n\nimport { DataConnectError } from './error';\n\ninterface TrackedQuery<Data, Variables> {\n ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;\n subscriptions: Array<DataConnectSubscription<Data, Variables>>;\n currentCache: OpResult<Data> | null;\n lastError: DataConnectError | null;\n}\n\nfunction getRefSerializer<Data, Variables>(\n queryRef: QueryRef<Data, Variables>,\n data: Data,\n source: DataSource\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: Date.now().toLocaleString(),\n source\n };\n };\n}\n\nexport class QueryManager {\n _queries: Map<string, TrackedQuery<unknown, unknown>>;\n constructor(private transport: DataConnectTransport) {\n this._queries = new Map();\n }\n track<Data, Variables>(\n queryName: string,\n variables: Variables,\n initialCache?: OpResult<Data>\n ) {\n const ref: TrackedQuery<Data, Variables>['ref'] = {\n name: queryName,\n variables,\n refType: QUERY_STR\n };\n const key = encoderImpl(ref);\n const newTrackedQuery: TrackedQuery<Data, Variables> = {\n ref,\n subscriptions: [],\n currentCache: initialCache || null,\n lastError: null\n };\n // @ts-ignore\n setIfNotExists(this._queries, key, newTrackedQuery);\n return this._queries.get(key);\n }\n addSubscription<Data, Variables>(\n queryRef: OperationRef<Data, Variables>,\n onResultCallback: OnResultSubscription<Data, Variables>,\n onErrorCallback?: OnErrorSubscription,\n initialCache?: OpResult<Data>\n ): () => void {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n const trackedQuery = this._queries.get(key) as TrackedQuery<\n Data,\n Variables\n >;\n const subscription = {\n userCallback: onResultCallback,\n errCallback: onErrorCallback\n };\n const unsubscribe = () => {\n const trackedQuery = this._queries.get(key)!;\n trackedQuery.subscriptions = trackedQuery.subscriptions.filter(\n sub => sub !== subscription\n );\n };\n if (initialCache && trackedQuery.currentCache !== initialCache) {\n logDebug('Initial cache found. Comparing dates.');\n if (\n !trackedQuery.currentCache ||\n (trackedQuery.currentCache &&\n compareDates(\n trackedQuery.currentCache.fetchTime,\n initialCache.fetchTime\n ))\n ) {\n trackedQuery.currentCache = initialCache;\n }\n }\n if (trackedQuery.currentCache !== null) {\n const cachedData = trackedQuery.currentCache.data;\n onResultCallback({\n data: cachedData,\n source: SOURCE_CACHE,\n ref: queryRef as QueryRef<Data, Variables>,\n toJSON: getRefSerializer(\n queryRef as QueryRef<Data, Variables>,\n trackedQuery.currentCache.data,\n SOURCE_CACHE\n ),\n fetchTime: trackedQuery.currentCache.fetchTime\n });\n if (trackedQuery.lastError !== null && onErrorCallback) {\n onErrorCallback(undefined);\n }\n }\n\n trackedQuery.subscriptions.push({\n userCallback: onResultCallback,\n errCallback: onErrorCallback,\n unsubscribe\n });\n if (!trackedQuery.currentCache) {\n logDebug(\n `No cache available for query ${\n queryRef.name\n } with variables ${JSON.stringify(\n queryRef.variables\n )}. Calling executeQuery.`\n );\n const promise = this.executeQuery(\n queryRef as QueryRef<Data, Variables>\n );\n // We want to ignore the error and let subscriptions handle it\n promise.then(undefined, err => {});\n }\n return unsubscribe;\n }\n executeQuery<Data, Variables>(\n queryRef: QueryRef<Data, Variables>\n ): QueryPromise<Data, Variables> {\n const key = encoderImpl({\n name: queryRef.name,\n variables: queryRef.variables,\n refType: QUERY_STR\n });\n const trackedQuery = this._queries.get(key)!;\n const result = this.transport.invokeQuery<Data, Variables>(\n queryRef.name,\n queryRef.variables\n );\n const newR = result.then(\n res => {\n const fetchTime = new Date().toString();\n const result: QueryResult<Data, Variables> = {\n ...res,\n source: SOURCE_SERVER,\n ref: queryRef,\n toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER),\n fetchTime\n };\n trackedQuery.subscriptions.forEach(subscription => {\n subscription.userCallback(result);\n });\n trackedQuery.currentCache = {\n data: res.data,\n source: SOURCE_CACHE,\n fetchTime\n };\n return result;\n },\n err => {\n trackedQuery.lastError = err;\n trackedQuery.subscriptions.forEach(subscription => {\n if (subscription.errCallback) {\n subscription.errCallback(err);\n }\n });\n throw err;\n }\n );\n\n return newR;\n }\n enableEmulator(host: string, port: number) {\n this.transport.useEmulator(host, port);\n }\n}\nfunction compareDates(str1: string, str2: string) {\n const date1 = new Date(str1);\n const date2 = new Date(str2);\n return date1.getTime() < date2.getTime();\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 function urlBuilder(\n projectConfig: DataConnectOptions,\n transportOptions: TransportOptions\n) {\n const { connector, location, projectId: project, service } = projectConfig;\n const { host, sslEnabled, port } = transportOptions;\n const protocol = sslEnabled ? 'https' : 'http';\n const realHost = host || `firebasedataconnect.googleapis.com`;\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}/v1alpha/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 { 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 { DataConnectTransport } 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 _authInitialized = false;\n constructor(\n options: DataConnectOptions,\n private apiKey?: string | undefined,\n private authProvider?: AuthTokenProvider | undefined,\n transportOptions?: TransportOptions | undefined\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 }\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 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) {\n this._accessToken = newToken;\n }\n\n getWithAuth() {\n let starterPromise: Promise<string | null> = new Promise(resolve =>\n resolve(this._accessToken)\n );\n if (!this._authInitialized) {\n if (this.authProvider) {\n starterPromise = this.authProvider\n .getToken(/*forceToken=*/ false)\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 }\n return starterPromise;\n }\n\n // TODO(mtewani): Update U to include shape of body defined in line 13.\n invokeQuery = <T, U = unknown>(queryName: string, body: U) => {\n const abortController = new AbortController();\n\n // TODO(mtewani): Update to proper value\n const withAuth = this.getWithAuth().then(() => {\n return 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 } as unknown as U, // TODO(mtewani): This is a patch, fix this.\n abortController,\n this._accessToken\n );\n });\n\n return {\n then: withAuth.then.bind(withAuth)\n };\n };\n invokeMutation = <T, U = unknown>(mutationName: string, body: U) => {\n const abortController = new AbortController();\n const taskResult = this.getWithAuth().then(() => {\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 } as unknown as U,\n abortController,\n this._accessToken\n );\n });\n\n return {\n then: taskResult.then.bind(taskResult),\n // catch: taskResult.catch.bind(taskResult),\n // finally: taskResult.finally.bind(taskResult),\n cancel: () => abortController.abort()\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 { 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\nexport function mutationRef<Data>(\n dcInstance: DataConnect,\n queryName: string\n): MutationRef<Data, undefined>;\nexport function mutationRef<Data, Variables>(\n dcInstance: DataConnect,\n mutationName: string,\n variables: Variables\n): MutationRef<Data, Variables>;\nexport function mutationRef<Data, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables?: Variables\n): MutationRef<Data, Variables> {\n dcInstance.setInitialized();\n const ref: MutationRef<Data, Variables> = {\n dataConnect: dcInstance,\n name: queryName,\n refType: MUTATION_STR,\n variables: variables as Variables\n };\n return ref;\n}\n\nexport class MutationManager {\n private _inflight: Array<PromiseLike<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 = () =>\n (this._inflight = this._inflight.filter(promise => promise !== result));\n result.then(removePromise, removePromise);\n return withRefPromise;\n }\n}\n\nexport interface MutationResult<Data, Variables>\n extends DataConnectResult<Data, Variables> {\n ref: MutationRef<Data, Variables>;\n}\nexport interface MutationPromise<Data, Variables>\n extends PromiseLike<MutationResult<Data, Variables>> {\n // reserved for special actions like cancellation\n}\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 { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { Provider } from '@firebase/component';\n\nimport { Code, DataConnectError } from '../core/error';\nimport {\n AuthTokenProvider,\n FirebaseAuthProvider\n} from '../core/FirebaseAuthProvider';\nimport { QueryManager } from '../core/QueryManager';\nimport { logDebug, logError } from '../logger';\nimport { DataConnectTransport, TransportClass } from '../network';\nimport { RESTTransport } from '../network/transport/rest';\n\nimport { MutationManager } from './Mutation';\n\n\nexport interface ConnectorConfig {\n location: string;\n connector: string;\n service: string;\n}\n\nexport interface TransportOptions {\n host: string;\n sslEnabled?: boolean;\n port?: number;\n}\n\nexport const 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}\nexport interface DataConnectOptions extends ConnectorConfig {\n projectId: string;\n}\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 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 ) {\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 _delete(): Promise<void> {\n _removeServiceInstance(\n this.app,\n 'data-connect',\n JSON.stringify(this.getSettings())\n );\n return Promise.resolve();\n }\n\n getSettings(): ConnectorConfig {\n const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));\n delete copy.projectId;\n return copy;\n }\n\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 if (this._authProvider) {\n this._authTokenProvider = new FirebaseAuthProvider(\n this.app.name,\n this.app.options,\n this._authProvider\n );\n }\n\n this.initialized = true;\n this._transport = new this._transportClass(\n this.dataConnectOptions,\n this.app.options.apiKey,\n this._authTokenProvider\n );\n if (this._transportOptions) {\n this._transport.useEmulator(\n this._transportOptions.host,\n this._transportOptions.port,\n this._transportOptions.sslEnabled\n );\n }\n this._queryManager = new QueryManager(this._transport);\n this._mutationManager = new MutationManager(this._transport);\n }\n\n enableEmulator(transportOptions: TransportOptions): void {\n if (this.initialized) {\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\nexport function connectDataConnectEmulator(\n dc: DataConnect,\n host: string,\n port?: number,\n sslEnabled = false\n): void {\n dc.enableEmulator({ host, port, sslEnabled });\n}\n\nexport function getDataConnect(options: ConnectorConfig): DataConnect;\nexport function getDataConnect(\n app: FirebaseApp,\n options: ConnectorConfig\n): DataConnect;\nexport function getDataConnect(\n appOrOptions: FirebaseApp | ConnectorConfig,\n optionalOptions?: ConnectorConfig\n): DataConnect {\n let app: FirebaseApp;\n let dcOptions: ConnectorConfig;\n if ('location' in appOrOptions) {\n dcOptions = appOrOptions;\n app = getApp();\n } else {\n dcOptions = optionalOptions!;\n app = appOrOptions;\n }\n\n if (!app) {\n app = getApp();\n }\n const provider = _getProvider(app, 'data-connect');\n const identifier = JSON.stringify(dcOptions);\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 if (!dcOptions) {\n throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required');\n }\n logDebug('Creating new DataConnect instance');\n // Initialize with options.\n return provider.initialize({\n instanceIdentifier: identifier,\n options: dcOptions\n });\n}\n\nexport function terminate(dataConnect: DataConnect): Promise<void> {\n return dataConnect._delete();\n // TODO(mtewani): Stop pending tasks\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';\n\nexport function registerDataConnect(variant?: string): void {\n setSDKVersion(SDK_VERSION);\n _registerComponent(\n new Component(\n 'data-connect',\n (container, { instanceIdentifier: settings, options }) => {\n const app = container.getProvider('app').getImmediate()!;\n const authProvider = container.getProvider('auth-internal');\n let newOpts = options as ConnectorConfig;\n if (settings) {\n newOpts = JSON.parse(settings);\n }\n return new DataConnect(\n app,\n { ...newOpts, projectId: app.options.projectId! },\n authProvider\n );\n },\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n registerVersion(name, version, variant);\n // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\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 { DataConnectError } from '../core/error';\n\nimport { DataConnect, getDataConnect } from './DataConnect';\nimport {\n OperationRef,\n QUERY_STR,\n DataConnectResult,\n SerializedRef\n} from './Reference';\n\nexport type OnResultSubscription<Data, Variables> = (\n res: QueryResult<Data, Variables>\n) => void;\nexport type OnErrorSubscription = (err?: DataConnectError) => void;\nexport type QueryUnsubscribe = () => void;\nexport interface DataConnectSubscription<Data, Variables> {\n userCallback: OnResultSubscription<Data, Variables>;\n errCallback?: (e?: DataConnectError) => void;\n unsubscribe: () => void;\n}\nexport interface QueryRef<Data, Variables>\n extends OperationRef<Data, Variables> {\n refType: typeof QUERY_STR;\n}\nexport interface QueryResult<Data, Variables>\n extends DataConnectResult<Data, Variables> {\n ref: QueryRef<Data, Variables>;\n toJSON: () => SerializedRef<Data, Variables>;\n}\nexport interface QueryPromise<Data, Variables>\n extends PromiseLike<QueryResult<Data, Variables>> {\n // reserved for special actions like cancellation\n}\n\nexport function executeQuery<Data, Variables>(\n queryRef: QueryRef<Data, Variables>\n): QueryPromise<Data, Variables> {\n return queryRef.dataConnect._queryManager.executeQuery(queryRef);\n}\n\nexport function queryRef<Data>(\n dcInstance: DataConnect,\n queryName: string\n): QueryRef<Data, undefined>;\nexport function queryRef<Data, Variables>(\n dcInstance: DataConnect,\n queryName: string,\n variables: Variables\n): QueryRef<Data, Variables>;\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 dcInstance._queryManager.track(queryName, variables, initialCache);\n return {\n dataConnect: dcInstance,\n refType: QUERY_STR,\n name: queryName,\n variables: variables as Variables\n };\n}\nexport function toQueryRef<Data, Variables>(\n serializedRef: SerializedRef<Data, Variables>\n) {\n const {\n refInfo: { name, variables, connectorConfig }\n } = serializedRef;\n return queryRef(getDataConnect(connectorConfig), name, variables);\n}\nexport type OnCompleteSubscription = () => void;\nexport interface SubscriptionOptions<Data, Variables> {\n onNext?: OnResultSubscription<Data, Variables>;\n onErr?: OnErrorSubscription;\n onComplete?: OnCompleteSubscription;\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 OnCompleteSubscription,\n OnErrorSubscription,\n OnResultSubscription,\n QueryRef,\n QueryUnsubscribe,\n SubscriptionOptions,\n toQueryRef\n} from './api/query';\nimport { OpResult, SerializedRef } from './api/Reference';\nimport { DataConnectError, Code } from './core/error';\n\n/**\n *\n * @public\n * @param queryRef\n * @param onResult\n * @param onErr\n * @param initialCache\n * @returns\n */\nexport function subscribe<Data, Variables>(\n queryRefOrSerializedResult:\n | QueryRef<Data, Variables>\n | SerializedRef<Data, Variables>,\n observer: SubscriptionOptions<Data, Variables>\n): QueryUnsubscribe;\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;\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: OpResult<Data> | undefined;\n if ('refInfo' in queryRefOrSerializedResult) {\n const serializedRef: SerializedRef<Data, Variables> =\n queryRefOrSerializedResult;\n const { data, source, fetchTime } = serializedRef;\n initialCache = {\n data,\n source,\n fetchTime\n };\n ref = toQueryRef(serializedRef);\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 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 './register';\n\nexport * from './api';\nexport * from './api.node';\ninitializeFetch(fetch);\n\nregisterDataConnect('node');\n"],"names":["__extends","FirebaseError","Logger","__awaiter","__assign","_removeServiceInstance","app","getApp","_getProvider","SDK_VERSION","_registerComponent","Component","registerVersion"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAcI,IAAM,IAAI,GAAG;AAClB,IAAA,KAAK,EAAE,OAA+B;AACtC,IAAA,mBAAmB,EAAE,qBAA6C;AAClE,IAAA,eAAe,EAAE,iBAAyC;AAC1D,IAAA,aAAa,EAAE,eAAuC;AACtD,IAAA,gBAAgB,EAAE,kBAA0C;AAC5D,IAAA,aAAa,EAAE,eAAuC;CACvD,CAAC;AAEF;AACA,IAAA,gBAAA,kBAAA,UAAA,MAAA,EAAA;IAAsCA,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AAmB;AAClD,QAAA,YAAY,GAAG;AACb,YAAA,IAAI,EAAA,IAAA;AACJ,YAAA,MAAM,EAAA,MAAA;AACN,YAAA,SAAS,EAAA,SAAA;SACV,CAAC;AACF,QAAA,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;AACjC,KAAA;AAAM,SAAA;QACL,GAAG,GAAG,0BAA0B,CAAC;AAClC,KAAA;IACD,IAAI,QAAQ,GAAsD,SAAS,CAAC;AAC5E,IAAA,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE;QAC1C,QAAQ,GAAG,gBAAgB,CAAC;AAC7B,KAAA;AAAM,SAAA;AACL,QAAA,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnC,QAAA,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC;AACjC,QAAa,gBAAgB,CAAC,UAAU,CAAC;AAC1C,KAAA;IACD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;AAC1E,KAAA;AACD,IAAA,OAAO,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAClD,GAAG,EACH,QAAQ,EACR,OAAO,EACP,YAAY,CACb,CAAC;AACJ;;AC9FA;;;;;;;;;;;;;;;AAeG;AAOH,eAAe,CAAC,KAAK,CAAC,CAAC;AAEvB,mBAAmB,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -36,16 +36,16 @@ export declare interface ConnectorConfig {
|
|
|
36
36
|
export declare class DataConnect {
|
|
37
37
|
readonly app: FirebaseApp;
|
|
38
38
|
private readonly dataConnectOptions;
|
|
39
|
-
private readonly
|
|
39
|
+
private readonly _authProvider;
|
|
40
40
|
_queryManager: QueryManager;
|
|
41
41
|
_mutationManager: MutationManager;
|
|
42
42
|
isEmulator: boolean;
|
|
43
43
|
initialized: boolean;
|
|
44
44
|
private _transport;
|
|
45
|
-
private
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions,
|
|
45
|
+
private _transportClass;
|
|
46
|
+
private _transportOptions?;
|
|
47
|
+
private _authTokenProvider?;
|
|
48
|
+
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
49
49
|
_delete(): Promise<void>;
|
|
50
50
|
getSettings(): ConnectorConfig;
|
|
51
51
|
setInitialized(): void;
|
|
@@ -107,17 +107,6 @@ export declare interface DataConnectTransport {
|
|
|
107
107
|
|
|
108
108
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
109
109
|
|
|
110
|
-
export declare class EmulatorTokenProvider implements AuthTokenProvider {
|
|
111
|
-
private accessToken;
|
|
112
|
-
/** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */
|
|
113
|
-
static OWNER: string;
|
|
114
|
-
constructor(accessToken: string);
|
|
115
|
-
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
|
|
116
|
-
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
117
|
-
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
118
|
-
notifyForInvalidToken(): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
110
|
export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
122
111
|
|
|
123
112
|
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
@@ -125,11 +114,11 @@ export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, V
|
|
|
125
114
|
export declare const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = "FIREBASE_DATA_CONNECT_EMULATOR_HOST";
|
|
126
115
|
|
|
127
116
|
export declare class FirebaseAuthProvider implements AuthTokenProvider {
|
|
128
|
-
private
|
|
129
|
-
private
|
|
130
|
-
private
|
|
131
|
-
private
|
|
132
|
-
constructor(
|
|
117
|
+
private _appName;
|
|
118
|
+
private _options;
|
|
119
|
+
private _authProvider;
|
|
120
|
+
private _auth;
|
|
121
|
+
constructor(_appName: string, _options: FirebaseOptions, _authProvider: Provider<FirebaseAuthInternalName>);
|
|
133
122
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
134
123
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
135
124
|
removeTokenChangeListener(listener: (token: string | null) => void): void;
|
|
@@ -139,23 +128,25 @@ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
|
139
128
|
|
|
140
129
|
export declare function getDataConnect(app: FirebaseApp, options: ConnectorConfig): DataConnect;
|
|
141
130
|
|
|
131
|
+
export declare const MUTATION_STR = "mutation";
|
|
132
|
+
|
|
142
133
|
export declare class MutationManager {
|
|
143
|
-
private
|
|
134
|
+
private _transport;
|
|
144
135
|
private _inflight;
|
|
145
|
-
constructor(
|
|
146
|
-
executeMutation<
|
|
136
|
+
constructor(_transport: DataConnectTransport);
|
|
137
|
+
executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
|
|
147
138
|
}
|
|
148
139
|
|
|
149
140
|
export declare interface MutationPromise<Data, Variables> extends PromiseLike<MutationResult<Data, Variables>> {
|
|
150
141
|
}
|
|
151
142
|
|
|
152
|
-
export declare interface MutationRef<
|
|
153
|
-
refType: typeof
|
|
143
|
+
export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
144
|
+
refType: typeof MUTATION_STR;
|
|
154
145
|
}
|
|
155
146
|
|
|
156
|
-
export declare function mutationRef<
|
|
147
|
+
export declare function mutationRef<Data>(dcInstance: DataConnect, queryName: string): MutationRef<Data, undefined>;
|
|
157
148
|
|
|
158
|
-
export declare function mutationRef<
|
|
149
|
+
export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
|
|
159
150
|
|
|
160
151
|
export declare interface MutationResponse<T> extends CancellableOperation<T> {
|
|
161
152
|
}
|
|
@@ -164,8 +155,6 @@ export declare interface MutationResult<Data, Variables> extends DataConnectResu
|
|
|
164
155
|
ref: MutationRef<Data, Variables>;
|
|
165
156
|
}
|
|
166
157
|
|
|
167
|
-
export declare const MutationStr = "mutation";
|
|
168
|
-
|
|
169
158
|
export declare type OnCompleteSubscription = () => void;
|
|
170
159
|
|
|
171
160
|
export declare type OnErrorSubscription = (err?: DataConnectError) => void;
|
|
@@ -193,20 +182,15 @@ export declare interface OpResult<Data> {
|
|
|
193
182
|
*/
|
|
194
183
|
export declare function parseOptions(fullHost: string): TransportOptions;
|
|
195
184
|
|
|
196
|
-
export declare
|
|
197
|
-
location: string;
|
|
198
|
-
connector: string;
|
|
199
|
-
service: string;
|
|
200
|
-
projectId: string;
|
|
201
|
-
}
|
|
185
|
+
export declare const QUERY_STR = "query";
|
|
202
186
|
|
|
203
187
|
declare class QueryManager {
|
|
204
188
|
private transport;
|
|
205
189
|
_queries: Map<string, TrackedQuery<unknown, unknown>>;
|
|
206
190
|
constructor(transport: DataConnectTransport);
|
|
207
|
-
track<
|
|
208
|
-
addSubscription<
|
|
209
|
-
executeQuery<
|
|
191
|
+
track<Data, Variables>(queryName: string, variables: Variables, initialCache?: OpResult<Data>): TrackedQuery<unknown, unknown>;
|
|
192
|
+
addSubscription<Data, Variables>(queryRef: OperationRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onErrorCallback?: OnErrorSubscription, initialCache?: OpResult<Data>): () => void;
|
|
193
|
+
executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>): QueryPromise<Data, Variables>;
|
|
210
194
|
enableEmulator(host: string, port: number): void;
|
|
211
195
|
}
|
|
212
196
|
|
|
@@ -214,7 +198,7 @@ export declare interface QueryPromise<Data, Variables> extends PromiseLike<Query
|
|
|
214
198
|
}
|
|
215
199
|
|
|
216
200
|
export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
|
|
217
|
-
refType: typeof
|
|
201
|
+
refType: typeof QUERY_STR;
|
|
218
202
|
}
|
|
219
203
|
|
|
220
204
|
export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
|
|
@@ -229,11 +213,9 @@ export declare interface QueryResult<Data, Variables> extends DataConnectResult<
|
|
|
229
213
|
toJSON: () => SerializedRef<Data, Variables>;
|
|
230
214
|
}
|
|
231
215
|
|
|
232
|
-
export declare const QueryStr = "query";
|
|
233
|
-
|
|
234
216
|
export declare type QueryUnsubscribe = () => void;
|
|
235
217
|
|
|
236
|
-
export declare type ReferenceType = typeof
|
|
218
|
+
export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
|
|
237
219
|
|
|
238
220
|
export declare interface RefInfo<Variables> {
|
|
239
221
|
name: string;
|
|
@@ -275,14 +257,14 @@ export declare interface SubscriptionOptions<Data, Variables> {
|
|
|
275
257
|
onComplete?: OnCompleteSubscription;
|
|
276
258
|
}
|
|
277
259
|
|
|
278
|
-
export declare function terminate(dataConnect: DataConnect): void
|
|
260
|
+
export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
279
261
|
|
|
280
262
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<unknown, Variables>;
|
|
281
263
|
|
|
282
|
-
declare interface TrackedQuery<
|
|
283
|
-
ref: Omit<OperationRef<
|
|
284
|
-
subscriptions: Array<DataConnectSubscription<
|
|
285
|
-
currentCache: OpResult<
|
|
264
|
+
declare interface TrackedQuery<Data, Variables> {
|
|
265
|
+
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
266
|
+
subscriptions: Array<DataConnectSubscription<Data, Variables>>;
|
|
267
|
+
currentCache: OpResult<Data> | null;
|
|
286
268
|
lastError: DataConnectError | null;
|
|
287
269
|
}
|
|
288
270
|
|