@firebase/data-connect
Advanced tools
Comparing version 0.1.0-canary.aa6db78eb to 0.1.0-canary.b942e9e6e
@@ -5,2 +5,3 @@ 'use strict'; | ||
var tslib = require('tslib'); | ||
var app = require('@firebase/app'); | ||
@@ -12,3 +13,3 @@ var component = require('@firebase/component'); | ||
const name = "@firebase/data-connect"; | ||
const version = "0.1.0-canary.aa6db78eb"; | ||
const version = "0.1.0-canary.b942e9e6e"; | ||
@@ -32,3 +33,3 @@ /** | ||
/** The semver (www.semver.org) version of the SDK. */ | ||
let SDK_VERSION = ''; | ||
var SDK_VERSION = ''; | ||
/** | ||
@@ -62,4 +63,5 @@ * SDK_VERSION should be set before any database instance is created | ||
*/ | ||
class AppCheckTokenProvider { | ||
constructor(appName_, appCheckProvider) { | ||
var AppCheckTokenProvider = /** @class */ (function () { | ||
function AppCheckTokenProvider(appName_, appCheckProvider) { | ||
var _this = this; | ||
this.appName_ = appName_; | ||
@@ -69,8 +71,9 @@ this.appCheckProvider = appCheckProvider; | ||
if (!this.appCheck) { | ||
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch()); | ||
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(function (appCheck) { return (_this.appCheck = appCheck); }).catch()); | ||
} | ||
} | ||
getToken(forceRefresh) { | ||
AppCheckTokenProvider.prototype.getToken = function (forceRefresh) { | ||
var _this = this; | ||
if (!this.appCheck) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function (resolve, reject) { | ||
// Support delayed initialization of FirebaseAppCheck. This allows our | ||
@@ -80,5 +83,5 @@ // customers to initialize the RTDB SDK before initializing Firebase | ||
// becomes available before the timoeout below expires. | ||
setTimeout(() => { | ||
if (this.appCheck) { | ||
this.getToken(forceRefresh).then(resolve, reject); | ||
setTimeout(function () { | ||
if (_this.appCheck) { | ||
_this.getToken(forceRefresh).then(resolve, reject); | ||
} | ||
@@ -92,8 +95,9 @@ else { | ||
return this.appCheck.getToken(forceRefresh); | ||
} | ||
addTokenChangeListener(listener) { | ||
}; | ||
AppCheckTokenProvider.prototype.addTokenChangeListener = function (listener) { | ||
var _a; | ||
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener))); | ||
} | ||
} | ||
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(function (appCheck) { return appCheck.addTokenListener(listener); })); | ||
}; | ||
return AppCheckTokenProvider; | ||
}()); | ||
@@ -116,3 +120,3 @@ /** | ||
*/ | ||
const Code = { | ||
var Code = { | ||
OTHER: 'other', | ||
@@ -127,5 +131,6 @@ ALREADY_INITIALIZED: 'already-initialized', | ||
/** An error returned by a DataConnect operation. */ | ||
class DataConnectError extends util.FirebaseError { | ||
var DataConnectError = /** @class */ (function (_super) { | ||
tslib.__extends(DataConnectError, _super); | ||
/** @hideconstructor */ | ||
constructor( | ||
function DataConnectError( | ||
/** | ||
@@ -139,11 +144,13 @@ * The backend error code associated with this error. | ||
message) { | ||
super(code, message); | ||
this.code = code; | ||
this.message = message; | ||
var _this = _super.call(this, code, message) || this; | ||
_this.code = code; | ||
_this.message = message; | ||
// HACK: We write a toString property directly because Error is not a real | ||
// class and so inheritance does not work correctly. We could alternatively | ||
// do the same "back-door inheritance" trick that FirebaseError does. | ||
this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`; | ||
_this.toString = function () { return "".concat(_this.name, ": [code=").concat(_this.code, "]: ").concat(_this.message); }; | ||
return _this; | ||
} | ||
} | ||
return DataConnectError; | ||
}(util.FirebaseError)); | ||
@@ -166,3 +173,3 @@ /** | ||
*/ | ||
const logger = new logger$1.Logger('@firebase/data-connect'); | ||
var logger = new logger$1.Logger('@firebase/data-connect'); | ||
function setLogLevel(logLevel) { | ||
@@ -172,6 +179,6 @@ logger.setLogLevel(logLevel); | ||
function logDebug(msg) { | ||
logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`); | ||
logger.debug("DataConnect (".concat(SDK_VERSION, "): ").concat(msg)); | ||
} | ||
function logError(msg) { | ||
logger.error(`DataConnect (${SDK_VERSION}): ${msg}`); | ||
logger.error("DataConnect (".concat(SDK_VERSION, "): ").concat(msg)); | ||
} | ||
@@ -196,4 +203,5 @@ | ||
// @internal | ||
class FirebaseAuthProvider { | ||
constructor(_appName, _options, _authProvider) { | ||
var FirebaseAuthProvider = /** @class */ (function () { | ||
function FirebaseAuthProvider(_appName, _options, _authProvider) { | ||
var _this = this; | ||
this._appName = _appName; | ||
@@ -204,11 +212,12 @@ this._options = _options; | ||
if (!this._auth) { | ||
_authProvider.onInit(auth => (this._auth = auth)); | ||
_authProvider.onInit(function (auth) { return (_this._auth = auth); }); | ||
} | ||
} | ||
getToken(forceRefresh) { | ||
FirebaseAuthProvider.prototype.getToken = function (forceRefresh) { | ||
var _this = this; | ||
if (!this._auth) { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (this._auth) { | ||
this.getToken(forceRefresh).then(resolve, reject); | ||
return new Promise(function (resolve, reject) { | ||
setTimeout(function () { | ||
if (_this._auth) { | ||
_this.getToken(forceRefresh).then(resolve, reject); | ||
} | ||
@@ -221,3 +230,3 @@ else { | ||
} | ||
return this._auth.getToken(forceRefresh).catch(error => { | ||
return this._auth.getToken(forceRefresh).catch(function (error) { | ||
if (error && error.code === 'auth/token-not-initialized') { | ||
@@ -233,14 +242,15 @@ logDebug('Got auth/token-not-initialized error. Treating as null token.'); | ||
}); | ||
} | ||
addTokenChangeListener(listener) { | ||
}; | ||
FirebaseAuthProvider.prototype.addTokenChangeListener = function (listener) { | ||
var _a; | ||
(_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener); | ||
} | ||
removeTokenChangeListener(listener) { | ||
}; | ||
FirebaseAuthProvider.prototype.removeTokenChangeListener = function (listener) { | ||
this._authProvider | ||
.get() | ||
.then(auth => auth.removeAuthTokenListener(listener)) | ||
.catch(err => logError(err)); | ||
} | ||
} | ||
.then(function (auth) { return auth.removeAuthTokenListener(listener); }) | ||
.catch(function (err) { return logError(err); }); | ||
}; | ||
return FirebaseAuthProvider; | ||
}()); | ||
@@ -263,6 +273,6 @@ /** | ||
*/ | ||
const QUERY_STR = 'query'; | ||
const MUTATION_STR = 'mutation'; | ||
const SOURCE_SERVER = 'SERVER'; | ||
const SOURCE_CACHE = 'CACHE'; | ||
var QUERY_STR = 'query'; | ||
var MUTATION_STR = 'mutation'; | ||
var SOURCE_SERVER = 'SERVER'; | ||
var SOURCE_CACHE = 'CACHE'; | ||
@@ -285,7 +295,7 @@ /** | ||
*/ | ||
let encoderImpl; | ||
var encoderImpl; | ||
function setEncoder(encoder) { | ||
encoderImpl = encoder; | ||
} | ||
setEncoder(o => JSON.stringify(o)); | ||
setEncoder(function (o) { return JSON.stringify(o); }); | ||
@@ -333,27 +343,27 @@ /** | ||
return { | ||
data, | ||
data: data, | ||
refInfo: { | ||
name: queryRef.name, | ||
variables: queryRef.variables, | ||
connectorConfig: Object.assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings()) | ||
connectorConfig: tslib.__assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings()) | ||
}, | ||
fetchTime: Date.now().toLocaleString(), | ||
source | ||
source: source | ||
}; | ||
}; | ||
} | ||
class QueryManager { | ||
constructor(transport) { | ||
var QueryManager = /** @class */ (function () { | ||
function QueryManager(transport) { | ||
this.transport = transport; | ||
this._queries = new Map(); | ||
} | ||
track(queryName, variables, initialCache) { | ||
const ref = { | ||
QueryManager.prototype.track = function (queryName, variables, initialCache) { | ||
var ref = { | ||
name: queryName, | ||
variables, | ||
variables: variables, | ||
refType: QUERY_STR | ||
}; | ||
const key = encoderImpl(ref); | ||
const newTrackedQuery = { | ||
ref, | ||
var key = encoderImpl(ref); | ||
var newTrackedQuery = { | ||
ref: ref, | ||
subscriptions: [], | ||
@@ -366,5 +376,6 @@ currentCache: initialCache || null, | ||
return this._queries.get(key); | ||
} | ||
addSubscription(queryRef, onResultCallback, onErrorCallback, initialCache) { | ||
const key = encoderImpl({ | ||
}; | ||
QueryManager.prototype.addSubscription = function (queryRef, onResultCallback, onErrorCallback, initialCache) { | ||
var _this = this; | ||
var key = encoderImpl({ | ||
name: queryRef.name, | ||
@@ -374,10 +385,10 @@ variables: queryRef.variables, | ||
}); | ||
const trackedQuery = this._queries.get(key); | ||
const subscription = { | ||
var trackedQuery = this._queries.get(key); | ||
var subscription = { | ||
userCallback: onResultCallback, | ||
errCallback: onErrorCallback | ||
}; | ||
const unsubscribe = () => { | ||
const trackedQuery = this._queries.get(key); | ||
trackedQuery.subscriptions = trackedQuery.subscriptions.filter(sub => sub !== subscription); | ||
var unsubscribe = function () { | ||
var trackedQuery = _this._queries.get(key); | ||
trackedQuery.subscriptions = trackedQuery.subscriptions.filter(function (sub) { return sub !== subscription; }); | ||
}; | ||
@@ -393,3 +404,3 @@ if (initialCache && trackedQuery.currentCache !== initialCache) { | ||
if (trackedQuery.currentCache !== null) { | ||
const cachedData = trackedQuery.currentCache.data; | ||
var cachedData = trackedQuery.currentCache.data; | ||
onResultCallback({ | ||
@@ -409,14 +420,17 @@ data: cachedData, | ||
errCallback: onErrorCallback, | ||
unsubscribe | ||
unsubscribe: unsubscribe | ||
}); | ||
if (!trackedQuery.currentCache) { | ||
logDebug(`No cache available for query ${queryRef.name} with variables ${JSON.stringify(queryRef.variables)}. Calling executeQuery.`); | ||
const promise = this.executeQuery(queryRef); | ||
logDebug("No cache available for query ".concat(queryRef.name, " with variables ").concat(JSON.stringify(queryRef.variables), ". Calling executeQuery.")); | ||
var promise = this.executeQuery(queryRef); | ||
// We want to ignore the error and let subscriptions handle it | ||
promise.then(undefined, err => { }); | ||
promise.then(undefined, function (err) { }); | ||
} | ||
return unsubscribe; | ||
} | ||
executeQuery(queryRef) { | ||
const key = encoderImpl({ | ||
}; | ||
QueryManager.prototype.executeQuery = function (queryRef) { | ||
if (queryRef.refType !== QUERY_STR) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "ExecuteQuery can only execute query operation"); | ||
} | ||
var key = encoderImpl({ | ||
name: queryRef.name, | ||
@@ -426,8 +440,8 @@ variables: queryRef.variables, | ||
}); | ||
const trackedQuery = this._queries.get(key); | ||
const result = this.transport.invokeQuery(queryRef.name, queryRef.variables); | ||
const newR = result.then(res => { | ||
const fetchTime = new Date().toString(); | ||
const result = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime }); | ||
trackedQuery.subscriptions.forEach(subscription => { | ||
var trackedQuery = this._queries.get(key); | ||
var result = this.transport.invokeQuery(queryRef.name, queryRef.variables); | ||
var newR = result.then(function (res) { | ||
var fetchTime = new Date().toString(); | ||
var result = tslib.__assign(tslib.__assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime: fetchTime }); | ||
trackedQuery.subscriptions.forEach(function (subscription) { | ||
subscription.userCallback(result); | ||
@@ -438,8 +452,8 @@ }); | ||
source: SOURCE_CACHE, | ||
fetchTime | ||
fetchTime: fetchTime | ||
}; | ||
return result; | ||
}, err => { | ||
}, function (err) { | ||
trackedQuery.lastError = err; | ||
trackedQuery.subscriptions.forEach(subscription => { | ||
trackedQuery.subscriptions.forEach(function (subscription) { | ||
if (subscription.errCallback) { | ||
@@ -452,10 +466,11 @@ subscription.errCallback(err); | ||
return newR; | ||
} | ||
enableEmulator(host, port) { | ||
}; | ||
QueryManager.prototype.enableEmulator = function (host, port) { | ||
this.transport.useEmulator(host, port); | ||
} | ||
} | ||
}; | ||
return QueryManager; | ||
}()); | ||
function compareDates(str1, str2) { | ||
const date1 = new Date(str1); | ||
const date2 = new Date(str2); | ||
var date1 = new Date(str1); | ||
var date2 = new Date(str2); | ||
return date1.getTime() < date2.getTime(); | ||
@@ -481,9 +496,9 @@ } | ||
function urlBuilder(projectConfig, transportOptions) { | ||
const { connector, location, projectId: project, service } = projectConfig; | ||
const { host, sslEnabled, port } = transportOptions; | ||
const protocol = sslEnabled ? 'https' : 'http'; | ||
const realHost = host || `firebasedataconnect.googleapis.com`; | ||
let baseUrl = `${protocol}://${realHost}`; | ||
var connector = projectConfig.connector, location = projectConfig.location, project = projectConfig.projectId, service = projectConfig.service; | ||
var host = transportOptions.host, sslEnabled = transportOptions.sslEnabled, port = transportOptions.port; | ||
var protocol = sslEnabled ? 'https' : 'http'; | ||
var realHost = host || "firebasedataconnect.googleapis.com"; | ||
var baseUrl = "".concat(protocol, "://").concat(realHost); | ||
if (typeof port === 'number') { | ||
baseUrl += `:${port}`; | ||
baseUrl += ":".concat(port); | ||
} | ||
@@ -494,3 +509,3 @@ else if (typeof port !== 'undefined') { | ||
} | ||
return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`; | ||
return "".concat(baseUrl, "/v1beta/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector); | ||
} | ||
@@ -501,3 +516,3 @@ function addToken(url, apiKey) { | ||
} | ||
const newUrl = new URL(url); | ||
var newUrl = new URL(url); | ||
newUrl.searchParams.append('key', apiKey); | ||
@@ -523,15 +538,17 @@ return newUrl.toString(); | ||
*/ | ||
let connectFetch = globalThis.fetch; | ||
var connectFetch = globalThis.fetch; | ||
function getGoogApiClientValue(_isUsingGen) { | ||
let str = 'gl-js/ fire/' + SDK_VERSION; | ||
var str = 'gl-js/ fire/' + SDK_VERSION; | ||
if (_isUsingGen) { | ||
str += ' web/gen'; | ||
str += ' js/gen'; | ||
} | ||
return str; | ||
} | ||
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) { | ||
function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen) { | ||
var _this = this; | ||
var signal = _a.signal; | ||
if (!connectFetch) { | ||
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!'); | ||
} | ||
const headers = { | ||
var headers = { | ||
'Content-Type': 'application/json', | ||
@@ -549,34 +566,45 @@ 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen) | ||
} | ||
const bodyStr = JSON.stringify(body); | ||
logDebug(`Making request out to ${url} with body: ${bodyStr}`); | ||
var bodyStr = JSON.stringify(body); | ||
logDebug("Making request out to ".concat(url, " with body: ").concat(bodyStr)); | ||
return connectFetch(url, { | ||
body: bodyStr, | ||
method: 'POST', | ||
headers, | ||
signal | ||
headers: headers, | ||
signal: signal | ||
}) | ||
.catch(err => { | ||
.catch(function (err) { | ||
throw new DataConnectError(Code.OTHER, 'Failed to fetch: ' + JSON.stringify(err)); | ||
}) | ||
.then(async (response) => { | ||
let jsonResponse = null; | ||
try { | ||
jsonResponse = await response.json(); | ||
} | ||
catch (e) { | ||
throw new DataConnectError(Code.OTHER, JSON.stringify(e)); | ||
} | ||
const message = getMessage(jsonResponse); | ||
if (response.status >= 400) { | ||
logError('Error while performing request: ' + JSON.stringify(jsonResponse)); | ||
if (response.status === 401) { | ||
throw new DataConnectError(Code.UNAUTHORIZED, message); | ||
.then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () { | ||
var jsonResponse, e_1, message; | ||
return tslib.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
jsonResponse = null; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
jsonResponse = _a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
throw new DataConnectError(Code.OTHER, JSON.stringify(e_1)); | ||
case 4: | ||
message = getMessage(jsonResponse); | ||
if (response.status >= 400) { | ||
logError('Error while performing request: ' + JSON.stringify(jsonResponse)); | ||
if (response.status === 401) { | ||
throw new DataConnectError(Code.UNAUTHORIZED, message); | ||
} | ||
throw new DataConnectError(Code.OTHER, message); | ||
} | ||
return [2 /*return*/, jsonResponse]; | ||
} | ||
throw new DataConnectError(Code.OTHER, message); | ||
} | ||
return jsonResponse; | ||
}) | ||
.then(res => { | ||
}); | ||
}); }) | ||
.then(function (res) { | ||
if (res.errors && res.errors.length) { | ||
const stringified = JSON.stringify(res.errors); | ||
var stringified = JSON.stringify(res.errors); | ||
logError('DataConnect error while performing request: ' + stringified); | ||
@@ -611,4 +639,6 @@ throw new DataConnectError(Code.OTHER, stringified); | ||
*/ | ||
class RESTTransport { | ||
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) { | ||
var RESTTransport = /** @class */ (function () { | ||
function RESTTransport(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen) { | ||
if (_isUsingGen === void 0) { _isUsingGen = false; } | ||
var _this = this; | ||
var _a, _b; | ||
@@ -629,11 +659,13 @@ this.apiKey = apiKey; | ||
// TODO(mtewani): Update U to include shape of body defined in line 13. | ||
this.invokeQuery = (queryName, body) => { | ||
const abortController = new AbortController(); | ||
this.invokeQuery = function (queryName, body) { | ||
var abortController = new AbortController(); | ||
// TODO(mtewani): Update to proper value | ||
const withAuth = this.withRetry(() => dcFetch(addToken(`${this.endpointUrl}:executeQuery`, this.apiKey), { | ||
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`, | ||
operationName: queryName, | ||
variables: body | ||
}, // TODO(mtewani): This is a patch, fix this. | ||
abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen)); | ||
var withAuth = _this.withRetry(function () { | ||
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeQuery"), _this.apiKey), { | ||
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName), | ||
operationName: queryName, | ||
variables: body | ||
}, // TODO(mtewani): This is a patch, fix this. | ||
abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen); | ||
}); | ||
return { | ||
@@ -644,10 +676,10 @@ then: withAuth.then.bind(withAuth), | ||
}; | ||
this.invokeMutation = (mutationName, body) => { | ||
const abortController = new AbortController(); | ||
const taskResult = this.withRetry(() => { | ||
return dcFetch(addToken(`${this.endpointUrl}:executeMutation`, this.apiKey), { | ||
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`, | ||
this.invokeMutation = function (mutationName, body) { | ||
var abortController = new AbortController(); | ||
var taskResult = _this.withRetry(function () { | ||
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeMutation"), _this.apiKey), { | ||
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName), | ||
operationName: mutationName, | ||
variables: body | ||
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen); | ||
}, abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen); | ||
}); | ||
@@ -658,3 +690,3 @@ return { | ||
// finally: taskResult.finally.bind(taskResult), | ||
cancel: () => abortController.abort() | ||
cancel: function () { return abortController.abort(); } | ||
}; | ||
@@ -671,3 +703,3 @@ }; | ||
} | ||
const { location, projectId: project, connector, service } = options; | ||
var location = options.location, project = options.projectId, connector = options.connector, service = options.service; | ||
if (location) { | ||
@@ -684,21 +716,25 @@ this._location = location; | ||
this._connectorName = connector; | ||
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(token => { | ||
logDebug(`New Token Available: ${token}`); | ||
this._accessToken = token; | ||
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(function (token) { | ||
logDebug("New Token Available: ".concat(token)); | ||
_this._accessToken = token; | ||
}); | ||
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => { | ||
const { token } = result; | ||
logDebug(`New App Check Token Available: ${token}`); | ||
this._appCheckToken = token; | ||
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(function (result) { | ||
var token = result.token; | ||
logDebug("New App Check Token Available: ".concat(token)); | ||
_this._appCheckToken = token; | ||
}); | ||
} | ||
get endpointUrl() { | ||
return urlBuilder({ | ||
connector: this._connectorName, | ||
location: this._location, | ||
projectId: this._project, | ||
service: this._serviceName | ||
}, { host: this._host, sslEnabled: this._secure, port: this._port }); | ||
} | ||
useEmulator(host, port, isSecure) { | ||
Object.defineProperty(RESTTransport.prototype, "endpointUrl", { | ||
get: function () { | ||
return urlBuilder({ | ||
connector: this._connectorName, | ||
location: this._location, | ||
projectId: this._project, | ||
service: this._serviceName | ||
}, { host: this._host, sslEnabled: this._secure, port: this._port }); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
RESTTransport.prototype.useEmulator = function (host, port, isSecure) { | ||
this._host = host; | ||
@@ -711,41 +747,59 @@ if (typeof port === 'number') { | ||
} | ||
} | ||
onTokenChanged(newToken) { | ||
}; | ||
RESTTransport.prototype.onTokenChanged = function (newToken) { | ||
this._accessToken = newToken; | ||
} | ||
async getWithAuth(forceToken = false) { | ||
}; | ||
RESTTransport.prototype.getWithAuth = function (forceToken) { | ||
var _a; | ||
let starterPromise = new Promise(resolve => resolve(this._accessToken)); | ||
if (this.appCheckProvider) { | ||
this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token; | ||
} | ||
if (this.authProvider) { | ||
starterPromise = this.authProvider | ||
.getToken(/*forceToken=*/ forceToken) | ||
.then(data => { | ||
if (!data) { | ||
return null; | ||
if (forceToken === void 0) { forceToken = false; } | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
var starterPromise, _b; | ||
var _this = this; | ||
return tslib.__generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
starterPromise = new Promise(function (resolve) { | ||
return resolve(_this._accessToken); | ||
}); | ||
if (!this.appCheckProvider) return [3 /*break*/, 2]; | ||
_b = this; | ||
return [4 /*yield*/, this.appCheckProvider.getToken()]; | ||
case 1: | ||
_b._appCheckToken = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.token; | ||
_c.label = 2; | ||
case 2: | ||
if (this.authProvider) { | ||
starterPromise = this.authProvider | ||
.getToken(/*forceToken=*/ forceToken) | ||
.then(function (data) { | ||
if (!data) { | ||
return null; | ||
} | ||
_this._accessToken = data.accessToken; | ||
return _this._accessToken; | ||
}); | ||
} | ||
else { | ||
starterPromise = new Promise(function (resolve) { return resolve(''); }); | ||
} | ||
return [2 /*return*/, starterPromise]; | ||
} | ||
this._accessToken = data.accessToken; | ||
return this._accessToken; | ||
}); | ||
} | ||
else { | ||
starterPromise = new Promise(resolve => resolve('')); | ||
} | ||
return starterPromise; | ||
} | ||
_setLastToken(lastToken) { | ||
}); | ||
}; | ||
RESTTransport.prototype._setLastToken = function (lastToken) { | ||
this._lastToken = lastToken; | ||
} | ||
withRetry(promiseFactory, retry = false) { | ||
let isNewToken = false; | ||
}; | ||
RESTTransport.prototype.withRetry = function (promiseFactory, retry) { | ||
var _this = this; | ||
if (retry === void 0) { retry = false; } | ||
var isNewToken = false; | ||
return this.getWithAuth(retry) | ||
.then(res => { | ||
isNewToken = this._lastToken !== res; | ||
this._lastToken = res; | ||
.then(function (res) { | ||
isNewToken = _this._lastToken !== res; | ||
_this._lastToken = res; | ||
return res; | ||
}) | ||
.then(promiseFactory) | ||
.catch(err => { | ||
.catch(function (err) { | ||
// Only retry if the result is unauthorized and the last token isn't the same as the new one. | ||
@@ -757,8 +811,9 @@ if ('code' in err && | ||
logDebug('Retrying due to unauthorized'); | ||
return this.withRetry(promiseFactory, true); | ||
return _this.withRetry(promiseFactory, true); | ||
} | ||
throw err; | ||
}); | ||
} | ||
} | ||
}; | ||
return RESTTransport; | ||
}()); | ||
@@ -790,3 +845,3 @@ /** | ||
dcInstance.setInitialized(); | ||
const ref = { | ||
var ref = { | ||
dataConnect: dcInstance, | ||
@@ -802,19 +857,23 @@ name: mutationName, | ||
*/ | ||
class MutationManager { | ||
constructor(_transport) { | ||
var MutationManager = /** @class */ (function () { | ||
function MutationManager(_transport) { | ||
this._transport = _transport; | ||
this._inflight = []; | ||
} | ||
executeMutation(mutationRef) { | ||
const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables); | ||
const withRefPromise = result.then(res => { | ||
const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() }); | ||
MutationManager.prototype.executeMutation = function (mutationRef) { | ||
var _this = this; | ||
var result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables); | ||
var withRefPromise = result.then(function (res) { | ||
var obj = tslib.__assign(tslib.__assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() }); | ||
return obj; | ||
}); | ||
this._inflight.push(result); | ||
const removePromise = () => (this._inflight = this._inflight.filter(promise => promise !== result)); | ||
var removePromise = function () { | ||
return (_this._inflight = _this._inflight.filter(function (promise) { return promise !== result; })); | ||
}; | ||
result.then(removePromise, removePromise); | ||
return withRefPromise; | ||
} | ||
} | ||
}; | ||
return MutationManager; | ||
}()); | ||
/** | ||
@@ -845,3 +904,3 @@ * Execute Mutation | ||
*/ | ||
const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST'; | ||
var FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST'; | ||
/** | ||
@@ -854,7 +913,7 @@ * | ||
function parseOptions(fullHost) { | ||
const [protocol, hostName] = fullHost.split('://'); | ||
const isSecure = protocol === 'https'; | ||
const [host, portAsString] = hostName.split(':'); | ||
const port = Number(portAsString); | ||
return { host, port, sslEnabled: isSecure }; | ||
var _a = fullHost.split('://'), protocol = _a[0], hostName = _a[1]; | ||
var isSecure = protocol === 'https'; | ||
var _b = hostName.split(':'), host = _b[0], portAsString = _b[1]; | ||
var port = Number(portAsString); | ||
return { host: host, port: port, sslEnabled: isSecure }; | ||
} | ||
@@ -864,5 +923,5 @@ /** | ||
*/ | ||
class DataConnect { | ||
var DataConnect = /** @class */ (function () { | ||
// @internal | ||
constructor(app, | ||
function DataConnect(app, | ||
// TODO(mtewani): Replace with _dataConnectOptions in the future | ||
@@ -878,3 +937,3 @@ dataConnectOptions, _authProvider, _appCheckProvider) { | ||
if (typeof process !== 'undefined' && process.env) { | ||
const host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR]; | ||
var host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR]; | ||
if (host) { | ||
@@ -888,19 +947,19 @@ logDebug('Found custom host. Using emulator'); | ||
// @internal | ||
_useGeneratedSdk() { | ||
DataConnect.prototype._useGeneratedSdk = function () { | ||
if (!this._isUsingGeneratedSdk) { | ||
this._isUsingGeneratedSdk = true; | ||
} | ||
} | ||
_delete() { | ||
}; | ||
DataConnect.prototype._delete = function () { | ||
app._removeServiceInstance(this.app, 'data-connect', JSON.stringify(this.getSettings())); | ||
return Promise.resolve(); | ||
} | ||
}; | ||
// @internal | ||
getSettings() { | ||
const copy = JSON.parse(JSON.stringify(this.dataConnectOptions)); | ||
DataConnect.prototype.getSettings = function () { | ||
var copy = JSON.parse(JSON.stringify(this.dataConnectOptions)); | ||
delete copy.projectId; | ||
return copy; | ||
} | ||
}; | ||
// @internal | ||
setInitialized() { | ||
DataConnect.prototype.setInitialized = function () { | ||
if (this._initialized) { | ||
@@ -926,5 +985,5 @@ return; | ||
this._mutationManager = new MutationManager(this._transport); | ||
} | ||
}; | ||
// @internal | ||
enableEmulator(transportOptions) { | ||
DataConnect.prototype.enableEmulator = function (transportOptions) { | ||
if (this._initialized) { | ||
@@ -936,4 +995,5 @@ logError('enableEmulator called after initialization'); | ||
this.isEmulator = true; | ||
} | ||
} | ||
}; | ||
return DataConnect; | ||
}()); | ||
/** | ||
@@ -946,8 +1006,9 @@ * Connect to the DataConnect Emulator | ||
*/ | ||
function connectDataConnectEmulator(dc, host, port, sslEnabled = false) { | ||
dc.enableEmulator({ host, port, sslEnabled }); | ||
function connectDataConnectEmulator(dc, host, port, sslEnabled) { | ||
if (sslEnabled === void 0) { sslEnabled = false; } | ||
dc.enableEmulator({ host: host, port: port, sslEnabled: sslEnabled }); | ||
} | ||
function getDataConnect(appOrOptions, optionalOptions) { | ||
let app$1; | ||
let dcOptions; | ||
var app$1; | ||
var dcOptions; | ||
if ('location' in appOrOptions) { | ||
@@ -964,8 +1025,8 @@ dcOptions = appOrOptions; | ||
} | ||
const provider = app._getProvider(app$1, 'data-connect'); | ||
const identifier = JSON.stringify(dcOptions); | ||
var provider = app._getProvider(app$1, 'data-connect'); | ||
var identifier = JSON.stringify(dcOptions); | ||
if (provider.isInitialized(identifier)) { | ||
const dcInstance = provider.getImmediate({ identifier }); | ||
const options = provider.getOptions(identifier); | ||
const optionsValid = Object.keys(options).length > 0; | ||
var dcInstance = provider.getImmediate({ identifier: identifier }); | ||
var options = provider.getOptions(identifier); | ||
var optionsValid = Object.keys(options).length > 0; | ||
if (optionsValid) { | ||
@@ -991,9 +1052,9 @@ logDebug('Re-using cached instance'); | ||
function validateDCOptions(dcOptions) { | ||
const fields = ['connector', 'location', 'service']; | ||
var fields = ['connector', 'location', 'service']; | ||
if (!dcOptions) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required'); | ||
} | ||
fields.forEach(field => { | ||
fields.forEach(function (field) { | ||
if (dcOptions[field] === null || dcOptions[field] === undefined) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, `${field} Required`); | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "".concat(field, " Required")); | ||
} | ||
@@ -1013,25 +1074,10 @@ }); | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
function registerDataConnect(variant) { | ||
setSDKVersion(app.SDK_VERSION); | ||
app._registerComponent(new component.Component('data-connect', (container, { instanceIdentifier: settings, options }) => { | ||
const app = container.getProvider('app').getImmediate(); | ||
const authProvider = container.getProvider('auth-internal'); | ||
const appCheckProvider = container.getProvider('app-check-internal'); | ||
let newOpts = options; | ||
app._registerComponent(new component.Component('data-connect', function (container, _a) { | ||
var settings = _a.instanceIdentifier, options = _a.options; | ||
var app = container.getProvider('app').getImmediate(); | ||
var authProvider = container.getProvider('auth-internal'); | ||
var appCheckProvider = container.getProvider('app-check-internal'); | ||
var newOpts = options; | ||
if (settings) { | ||
@@ -1043,3 +1089,3 @@ newOpts = JSON.parse(settings); | ||
} | ||
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider); | ||
return new DataConnect(app, tslib.__assign(tslib.__assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider); | ||
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); | ||
@@ -1099,3 +1145,3 @@ app.registerVersion(name, version, variant); | ||
function toQueryRef(serializedRef) { | ||
const { refInfo: { name, variables, connectorConfig } } = serializedRef; | ||
var _a = serializedRef.refInfo, name = _a.name, variables = _a.variables, connectorConfig = _a.connectorConfig; | ||
return queryRef(getDataConnect(connectorConfig), name, variables); | ||
@@ -1131,4 +1177,4 @@ } | ||
function validateArgs(connectorConfig, dcOrVars, vars, validateVars) { | ||
let dcInstance; | ||
let realVars; | ||
var dcInstance; | ||
var realVars; | ||
if (dcOrVars && 'enableEmulator' in dcOrVars) { | ||
@@ -1173,11 +1219,11 @@ dcInstance = dcOrVars; | ||
function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComplete) { | ||
let ref; | ||
let initialCache; | ||
var ref; | ||
var initialCache; | ||
if ('refInfo' in queryRefOrSerializedResult) { | ||
const serializedRef = queryRefOrSerializedResult; | ||
const { data, source, fetchTime } = serializedRef; | ||
var serializedRef = queryRefOrSerializedResult; | ||
var data = serializedRef.data, source = serializedRef.source, fetchTime = serializedRef.fetchTime; | ||
initialCache = { | ||
data, | ||
source, | ||
fetchTime | ||
data: data, | ||
source: source, | ||
fetchTime: fetchTime | ||
}; | ||
@@ -1189,3 +1235,3 @@ ref = toQueryRef(serializedRef); | ||
} | ||
let onResult = undefined; | ||
var onResult = undefined; | ||
if (typeof observerOrOnNext === 'function') { | ||
@@ -1192,0 +1238,0 @@ onResult = observerOrOnNext; |
@@ -0,1 +1,2 @@ | ||
import { __extends, __assign, __awaiter, __generator } from 'tslib'; | ||
import { _removeServiceInstance, getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app'; | ||
@@ -7,3 +8,3 @@ import { Component } from '@firebase/component'; | ||
const name = "@firebase/data-connect"; | ||
const version = "0.1.0-canary.aa6db78eb"; | ||
const version = "0.1.0-canary.b942e9e6e"; | ||
@@ -27,3 +28,3 @@ /** | ||
/** The semver (www.semver.org) version of the SDK. */ | ||
let SDK_VERSION = ''; | ||
var SDK_VERSION = ''; | ||
/** | ||
@@ -57,4 +58,5 @@ * SDK_VERSION should be set before any database instance is created | ||
*/ | ||
class AppCheckTokenProvider { | ||
constructor(appName_, appCheckProvider) { | ||
var AppCheckTokenProvider = /** @class */ (function () { | ||
function AppCheckTokenProvider(appName_, appCheckProvider) { | ||
var _this = this; | ||
this.appName_ = appName_; | ||
@@ -64,8 +66,9 @@ this.appCheckProvider = appCheckProvider; | ||
if (!this.appCheck) { | ||
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch()); | ||
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(function (appCheck) { return (_this.appCheck = appCheck); }).catch()); | ||
} | ||
} | ||
getToken(forceRefresh) { | ||
AppCheckTokenProvider.prototype.getToken = function (forceRefresh) { | ||
var _this = this; | ||
if (!this.appCheck) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function (resolve, reject) { | ||
// Support delayed initialization of FirebaseAppCheck. This allows our | ||
@@ -75,5 +78,5 @@ // customers to initialize the RTDB SDK before initializing Firebase | ||
// becomes available before the timoeout below expires. | ||
setTimeout(() => { | ||
if (this.appCheck) { | ||
this.getToken(forceRefresh).then(resolve, reject); | ||
setTimeout(function () { | ||
if (_this.appCheck) { | ||
_this.getToken(forceRefresh).then(resolve, reject); | ||
} | ||
@@ -87,8 +90,9 @@ else { | ||
return this.appCheck.getToken(forceRefresh); | ||
} | ||
addTokenChangeListener(listener) { | ||
}; | ||
AppCheckTokenProvider.prototype.addTokenChangeListener = function (listener) { | ||
var _a; | ||
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener))); | ||
} | ||
} | ||
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(function (appCheck) { return appCheck.addTokenListener(listener); })); | ||
}; | ||
return AppCheckTokenProvider; | ||
}()); | ||
@@ -111,3 +115,3 @@ /** | ||
*/ | ||
const Code = { | ||
var Code = { | ||
OTHER: 'other', | ||
@@ -122,5 +126,6 @@ ALREADY_INITIALIZED: 'already-initialized', | ||
/** An error returned by a DataConnect operation. */ | ||
class DataConnectError extends FirebaseError { | ||
var DataConnectError = /** @class */ (function (_super) { | ||
__extends(DataConnectError, _super); | ||
/** @hideconstructor */ | ||
constructor( | ||
function DataConnectError( | ||
/** | ||
@@ -134,11 +139,13 @@ * The backend error code associated with this error. | ||
message) { | ||
super(code, message); | ||
this.code = code; | ||
this.message = message; | ||
var _this = _super.call(this, code, message) || this; | ||
_this.code = code; | ||
_this.message = message; | ||
// HACK: We write a toString property directly because Error is not a real | ||
// class and so inheritance does not work correctly. We could alternatively | ||
// do the same "back-door inheritance" trick that FirebaseError does. | ||
this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`; | ||
_this.toString = function () { return "".concat(_this.name, ": [code=").concat(_this.code, "]: ").concat(_this.message); }; | ||
return _this; | ||
} | ||
} | ||
return DataConnectError; | ||
}(FirebaseError)); | ||
@@ -161,3 +168,3 @@ /** | ||
*/ | ||
const logger = new Logger('@firebase/data-connect'); | ||
var logger = new Logger('@firebase/data-connect'); | ||
function setLogLevel(logLevel) { | ||
@@ -167,6 +174,6 @@ logger.setLogLevel(logLevel); | ||
function logDebug(msg) { | ||
logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`); | ||
logger.debug("DataConnect (".concat(SDK_VERSION, "): ").concat(msg)); | ||
} | ||
function logError(msg) { | ||
logger.error(`DataConnect (${SDK_VERSION}): ${msg}`); | ||
logger.error("DataConnect (".concat(SDK_VERSION, "): ").concat(msg)); | ||
} | ||
@@ -191,4 +198,5 @@ | ||
// @internal | ||
class FirebaseAuthProvider { | ||
constructor(_appName, _options, _authProvider) { | ||
var FirebaseAuthProvider = /** @class */ (function () { | ||
function FirebaseAuthProvider(_appName, _options, _authProvider) { | ||
var _this = this; | ||
this._appName = _appName; | ||
@@ -199,11 +207,12 @@ this._options = _options; | ||
if (!this._auth) { | ||
_authProvider.onInit(auth => (this._auth = auth)); | ||
_authProvider.onInit(function (auth) { return (_this._auth = auth); }); | ||
} | ||
} | ||
getToken(forceRefresh) { | ||
FirebaseAuthProvider.prototype.getToken = function (forceRefresh) { | ||
var _this = this; | ||
if (!this._auth) { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (this._auth) { | ||
this.getToken(forceRefresh).then(resolve, reject); | ||
return new Promise(function (resolve, reject) { | ||
setTimeout(function () { | ||
if (_this._auth) { | ||
_this.getToken(forceRefresh).then(resolve, reject); | ||
} | ||
@@ -216,3 +225,3 @@ else { | ||
} | ||
return this._auth.getToken(forceRefresh).catch(error => { | ||
return this._auth.getToken(forceRefresh).catch(function (error) { | ||
if (error && error.code === 'auth/token-not-initialized') { | ||
@@ -228,14 +237,15 @@ logDebug('Got auth/token-not-initialized error. Treating as null token.'); | ||
}); | ||
} | ||
addTokenChangeListener(listener) { | ||
}; | ||
FirebaseAuthProvider.prototype.addTokenChangeListener = function (listener) { | ||
var _a; | ||
(_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener); | ||
} | ||
removeTokenChangeListener(listener) { | ||
}; | ||
FirebaseAuthProvider.prototype.removeTokenChangeListener = function (listener) { | ||
this._authProvider | ||
.get() | ||
.then(auth => auth.removeAuthTokenListener(listener)) | ||
.catch(err => logError(err)); | ||
} | ||
} | ||
.then(function (auth) { return auth.removeAuthTokenListener(listener); }) | ||
.catch(function (err) { return logError(err); }); | ||
}; | ||
return FirebaseAuthProvider; | ||
}()); | ||
@@ -258,6 +268,6 @@ /** | ||
*/ | ||
const QUERY_STR = 'query'; | ||
const MUTATION_STR = 'mutation'; | ||
const SOURCE_SERVER = 'SERVER'; | ||
const SOURCE_CACHE = 'CACHE'; | ||
var QUERY_STR = 'query'; | ||
var MUTATION_STR = 'mutation'; | ||
var SOURCE_SERVER = 'SERVER'; | ||
var SOURCE_CACHE = 'CACHE'; | ||
@@ -280,7 +290,7 @@ /** | ||
*/ | ||
let encoderImpl; | ||
var encoderImpl; | ||
function setEncoder(encoder) { | ||
encoderImpl = encoder; | ||
} | ||
setEncoder(o => JSON.stringify(o)); | ||
setEncoder(function (o) { return JSON.stringify(o); }); | ||
@@ -328,27 +338,27 @@ /** | ||
return { | ||
data, | ||
data: data, | ||
refInfo: { | ||
name: queryRef.name, | ||
variables: queryRef.variables, | ||
connectorConfig: Object.assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings()) | ||
connectorConfig: __assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings()) | ||
}, | ||
fetchTime: Date.now().toLocaleString(), | ||
source | ||
source: source | ||
}; | ||
}; | ||
} | ||
class QueryManager { | ||
constructor(transport) { | ||
var QueryManager = /** @class */ (function () { | ||
function QueryManager(transport) { | ||
this.transport = transport; | ||
this._queries = new Map(); | ||
} | ||
track(queryName, variables, initialCache) { | ||
const ref = { | ||
QueryManager.prototype.track = function (queryName, variables, initialCache) { | ||
var ref = { | ||
name: queryName, | ||
variables, | ||
variables: variables, | ||
refType: QUERY_STR | ||
}; | ||
const key = encoderImpl(ref); | ||
const newTrackedQuery = { | ||
ref, | ||
var key = encoderImpl(ref); | ||
var newTrackedQuery = { | ||
ref: ref, | ||
subscriptions: [], | ||
@@ -361,5 +371,6 @@ currentCache: initialCache || null, | ||
return this._queries.get(key); | ||
} | ||
addSubscription(queryRef, onResultCallback, onErrorCallback, initialCache) { | ||
const key = encoderImpl({ | ||
}; | ||
QueryManager.prototype.addSubscription = function (queryRef, onResultCallback, onErrorCallback, initialCache) { | ||
var _this = this; | ||
var key = encoderImpl({ | ||
name: queryRef.name, | ||
@@ -369,10 +380,10 @@ variables: queryRef.variables, | ||
}); | ||
const trackedQuery = this._queries.get(key); | ||
const subscription = { | ||
var trackedQuery = this._queries.get(key); | ||
var subscription = { | ||
userCallback: onResultCallback, | ||
errCallback: onErrorCallback | ||
}; | ||
const unsubscribe = () => { | ||
const trackedQuery = this._queries.get(key); | ||
trackedQuery.subscriptions = trackedQuery.subscriptions.filter(sub => sub !== subscription); | ||
var unsubscribe = function () { | ||
var trackedQuery = _this._queries.get(key); | ||
trackedQuery.subscriptions = trackedQuery.subscriptions.filter(function (sub) { return sub !== subscription; }); | ||
}; | ||
@@ -388,3 +399,3 @@ if (initialCache && trackedQuery.currentCache !== initialCache) { | ||
if (trackedQuery.currentCache !== null) { | ||
const cachedData = trackedQuery.currentCache.data; | ||
var cachedData = trackedQuery.currentCache.data; | ||
onResultCallback({ | ||
@@ -404,14 +415,17 @@ data: cachedData, | ||
errCallback: onErrorCallback, | ||
unsubscribe | ||
unsubscribe: unsubscribe | ||
}); | ||
if (!trackedQuery.currentCache) { | ||
logDebug(`No cache available for query ${queryRef.name} with variables ${JSON.stringify(queryRef.variables)}. Calling executeQuery.`); | ||
const promise = this.executeQuery(queryRef); | ||
logDebug("No cache available for query ".concat(queryRef.name, " with variables ").concat(JSON.stringify(queryRef.variables), ". Calling executeQuery.")); | ||
var promise = this.executeQuery(queryRef); | ||
// We want to ignore the error and let subscriptions handle it | ||
promise.then(undefined, err => { }); | ||
promise.then(undefined, function (err) { }); | ||
} | ||
return unsubscribe; | ||
} | ||
executeQuery(queryRef) { | ||
const key = encoderImpl({ | ||
}; | ||
QueryManager.prototype.executeQuery = function (queryRef) { | ||
if (queryRef.refType !== QUERY_STR) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "ExecuteQuery can only execute query operation"); | ||
} | ||
var key = encoderImpl({ | ||
name: queryRef.name, | ||
@@ -421,8 +435,8 @@ variables: queryRef.variables, | ||
}); | ||
const trackedQuery = this._queries.get(key); | ||
const result = this.transport.invokeQuery(queryRef.name, queryRef.variables); | ||
const newR = result.then(res => { | ||
const fetchTime = new Date().toString(); | ||
const result = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime }); | ||
trackedQuery.subscriptions.forEach(subscription => { | ||
var trackedQuery = this._queries.get(key); | ||
var result = this.transport.invokeQuery(queryRef.name, queryRef.variables); | ||
var newR = result.then(function (res) { | ||
var fetchTime = new Date().toString(); | ||
var result = __assign(__assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime: fetchTime }); | ||
trackedQuery.subscriptions.forEach(function (subscription) { | ||
subscription.userCallback(result); | ||
@@ -433,8 +447,8 @@ }); | ||
source: SOURCE_CACHE, | ||
fetchTime | ||
fetchTime: fetchTime | ||
}; | ||
return result; | ||
}, err => { | ||
}, function (err) { | ||
trackedQuery.lastError = err; | ||
trackedQuery.subscriptions.forEach(subscription => { | ||
trackedQuery.subscriptions.forEach(function (subscription) { | ||
if (subscription.errCallback) { | ||
@@ -447,10 +461,11 @@ subscription.errCallback(err); | ||
return newR; | ||
} | ||
enableEmulator(host, port) { | ||
}; | ||
QueryManager.prototype.enableEmulator = function (host, port) { | ||
this.transport.useEmulator(host, port); | ||
} | ||
} | ||
}; | ||
return QueryManager; | ||
}()); | ||
function compareDates(str1, str2) { | ||
const date1 = new Date(str1); | ||
const date2 = new Date(str2); | ||
var date1 = new Date(str1); | ||
var date2 = new Date(str2); | ||
return date1.getTime() < date2.getTime(); | ||
@@ -476,9 +491,9 @@ } | ||
function urlBuilder(projectConfig, transportOptions) { | ||
const { connector, location, projectId: project, service } = projectConfig; | ||
const { host, sslEnabled, port } = transportOptions; | ||
const protocol = sslEnabled ? 'https' : 'http'; | ||
const realHost = host || `firebasedataconnect.googleapis.com`; | ||
let baseUrl = `${protocol}://${realHost}`; | ||
var connector = projectConfig.connector, location = projectConfig.location, project = projectConfig.projectId, service = projectConfig.service; | ||
var host = transportOptions.host, sslEnabled = transportOptions.sslEnabled, port = transportOptions.port; | ||
var protocol = sslEnabled ? 'https' : 'http'; | ||
var realHost = host || "firebasedataconnect.googleapis.com"; | ||
var baseUrl = "".concat(protocol, "://").concat(realHost); | ||
if (typeof port === 'number') { | ||
baseUrl += `:${port}`; | ||
baseUrl += ":".concat(port); | ||
} | ||
@@ -489,3 +504,3 @@ else if (typeof port !== 'undefined') { | ||
} | ||
return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`; | ||
return "".concat(baseUrl, "/v1beta/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector); | ||
} | ||
@@ -496,3 +511,3 @@ function addToken(url, apiKey) { | ||
} | ||
const newUrl = new URL(url); | ||
var newUrl = new URL(url); | ||
newUrl.searchParams.append('key', apiKey); | ||
@@ -518,15 +533,17 @@ return newUrl.toString(); | ||
*/ | ||
let connectFetch = globalThis.fetch; | ||
var connectFetch = globalThis.fetch; | ||
function getGoogApiClientValue(_isUsingGen) { | ||
let str = 'gl-js/ fire/' + SDK_VERSION; | ||
var str = 'gl-js/ fire/' + SDK_VERSION; | ||
if (_isUsingGen) { | ||
str += ' web/gen'; | ||
str += ' js/gen'; | ||
} | ||
return str; | ||
} | ||
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) { | ||
function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen) { | ||
var _this = this; | ||
var signal = _a.signal; | ||
if (!connectFetch) { | ||
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!'); | ||
} | ||
const headers = { | ||
var headers = { | ||
'Content-Type': 'application/json', | ||
@@ -544,34 +561,45 @@ 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen) | ||
} | ||
const bodyStr = JSON.stringify(body); | ||
logDebug(`Making request out to ${url} with body: ${bodyStr}`); | ||
var bodyStr = JSON.stringify(body); | ||
logDebug("Making request out to ".concat(url, " with body: ").concat(bodyStr)); | ||
return connectFetch(url, { | ||
body: bodyStr, | ||
method: 'POST', | ||
headers, | ||
signal | ||
headers: headers, | ||
signal: signal | ||
}) | ||
.catch(err => { | ||
.catch(function (err) { | ||
throw new DataConnectError(Code.OTHER, 'Failed to fetch: ' + JSON.stringify(err)); | ||
}) | ||
.then(async (response) => { | ||
let jsonResponse = null; | ||
try { | ||
jsonResponse = await response.json(); | ||
} | ||
catch (e) { | ||
throw new DataConnectError(Code.OTHER, JSON.stringify(e)); | ||
} | ||
const message = getMessage(jsonResponse); | ||
if (response.status >= 400) { | ||
logError('Error while performing request: ' + JSON.stringify(jsonResponse)); | ||
if (response.status === 401) { | ||
throw new DataConnectError(Code.UNAUTHORIZED, message); | ||
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { | ||
var jsonResponse, e_1, message; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
jsonResponse = null; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
jsonResponse = _a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
throw new DataConnectError(Code.OTHER, JSON.stringify(e_1)); | ||
case 4: | ||
message = getMessage(jsonResponse); | ||
if (response.status >= 400) { | ||
logError('Error while performing request: ' + JSON.stringify(jsonResponse)); | ||
if (response.status === 401) { | ||
throw new DataConnectError(Code.UNAUTHORIZED, message); | ||
} | ||
throw new DataConnectError(Code.OTHER, message); | ||
} | ||
return [2 /*return*/, jsonResponse]; | ||
} | ||
throw new DataConnectError(Code.OTHER, message); | ||
} | ||
return jsonResponse; | ||
}) | ||
.then(res => { | ||
}); | ||
}); }) | ||
.then(function (res) { | ||
if (res.errors && res.errors.length) { | ||
const stringified = JSON.stringify(res.errors); | ||
var stringified = JSON.stringify(res.errors); | ||
logError('DataConnect error while performing request: ' + stringified); | ||
@@ -606,4 +634,6 @@ throw new DataConnectError(Code.OTHER, stringified); | ||
*/ | ||
class RESTTransport { | ||
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) { | ||
var RESTTransport = /** @class */ (function () { | ||
function RESTTransport(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen) { | ||
if (_isUsingGen === void 0) { _isUsingGen = false; } | ||
var _this = this; | ||
var _a, _b; | ||
@@ -624,11 +654,13 @@ this.apiKey = apiKey; | ||
// TODO(mtewani): Update U to include shape of body defined in line 13. | ||
this.invokeQuery = (queryName, body) => { | ||
const abortController = new AbortController(); | ||
this.invokeQuery = function (queryName, body) { | ||
var abortController = new AbortController(); | ||
// TODO(mtewani): Update to proper value | ||
const withAuth = this.withRetry(() => dcFetch(addToken(`${this.endpointUrl}:executeQuery`, this.apiKey), { | ||
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`, | ||
operationName: queryName, | ||
variables: body | ||
}, // TODO(mtewani): This is a patch, fix this. | ||
abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen)); | ||
var withAuth = _this.withRetry(function () { | ||
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeQuery"), _this.apiKey), { | ||
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName), | ||
operationName: queryName, | ||
variables: body | ||
}, // TODO(mtewani): This is a patch, fix this. | ||
abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen); | ||
}); | ||
return { | ||
@@ -639,10 +671,10 @@ then: withAuth.then.bind(withAuth), | ||
}; | ||
this.invokeMutation = (mutationName, body) => { | ||
const abortController = new AbortController(); | ||
const taskResult = this.withRetry(() => { | ||
return dcFetch(addToken(`${this.endpointUrl}:executeMutation`, this.apiKey), { | ||
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`, | ||
this.invokeMutation = function (mutationName, body) { | ||
var abortController = new AbortController(); | ||
var taskResult = _this.withRetry(function () { | ||
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeMutation"), _this.apiKey), { | ||
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName), | ||
operationName: mutationName, | ||
variables: body | ||
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen); | ||
}, abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen); | ||
}); | ||
@@ -653,3 +685,3 @@ return { | ||
// finally: taskResult.finally.bind(taskResult), | ||
cancel: () => abortController.abort() | ||
cancel: function () { return abortController.abort(); } | ||
}; | ||
@@ -666,3 +698,3 @@ }; | ||
} | ||
const { location, projectId: project, connector, service } = options; | ||
var location = options.location, project = options.projectId, connector = options.connector, service = options.service; | ||
if (location) { | ||
@@ -679,21 +711,25 @@ this._location = location; | ||
this._connectorName = connector; | ||
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(token => { | ||
logDebug(`New Token Available: ${token}`); | ||
this._accessToken = token; | ||
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(function (token) { | ||
logDebug("New Token Available: ".concat(token)); | ||
_this._accessToken = token; | ||
}); | ||
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => { | ||
const { token } = result; | ||
logDebug(`New App Check Token Available: ${token}`); | ||
this._appCheckToken = token; | ||
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(function (result) { | ||
var token = result.token; | ||
logDebug("New App Check Token Available: ".concat(token)); | ||
_this._appCheckToken = token; | ||
}); | ||
} | ||
get endpointUrl() { | ||
return urlBuilder({ | ||
connector: this._connectorName, | ||
location: this._location, | ||
projectId: this._project, | ||
service: this._serviceName | ||
}, { host: this._host, sslEnabled: this._secure, port: this._port }); | ||
} | ||
useEmulator(host, port, isSecure) { | ||
Object.defineProperty(RESTTransport.prototype, "endpointUrl", { | ||
get: function () { | ||
return urlBuilder({ | ||
connector: this._connectorName, | ||
location: this._location, | ||
projectId: this._project, | ||
service: this._serviceName | ||
}, { host: this._host, sslEnabled: this._secure, port: this._port }); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
RESTTransport.prototype.useEmulator = function (host, port, isSecure) { | ||
this._host = host; | ||
@@ -706,41 +742,59 @@ if (typeof port === 'number') { | ||
} | ||
} | ||
onTokenChanged(newToken) { | ||
}; | ||
RESTTransport.prototype.onTokenChanged = function (newToken) { | ||
this._accessToken = newToken; | ||
} | ||
async getWithAuth(forceToken = false) { | ||
}; | ||
RESTTransport.prototype.getWithAuth = function (forceToken) { | ||
var _a; | ||
let starterPromise = new Promise(resolve => resolve(this._accessToken)); | ||
if (this.appCheckProvider) { | ||
this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token; | ||
} | ||
if (this.authProvider) { | ||
starterPromise = this.authProvider | ||
.getToken(/*forceToken=*/ forceToken) | ||
.then(data => { | ||
if (!data) { | ||
return null; | ||
if (forceToken === void 0) { forceToken = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var starterPromise, _b; | ||
var _this = this; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
starterPromise = new Promise(function (resolve) { | ||
return resolve(_this._accessToken); | ||
}); | ||
if (!this.appCheckProvider) return [3 /*break*/, 2]; | ||
_b = this; | ||
return [4 /*yield*/, this.appCheckProvider.getToken()]; | ||
case 1: | ||
_b._appCheckToken = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.token; | ||
_c.label = 2; | ||
case 2: | ||
if (this.authProvider) { | ||
starterPromise = this.authProvider | ||
.getToken(/*forceToken=*/ forceToken) | ||
.then(function (data) { | ||
if (!data) { | ||
return null; | ||
} | ||
_this._accessToken = data.accessToken; | ||
return _this._accessToken; | ||
}); | ||
} | ||
else { | ||
starterPromise = new Promise(function (resolve) { return resolve(''); }); | ||
} | ||
return [2 /*return*/, starterPromise]; | ||
} | ||
this._accessToken = data.accessToken; | ||
return this._accessToken; | ||
}); | ||
} | ||
else { | ||
starterPromise = new Promise(resolve => resolve('')); | ||
} | ||
return starterPromise; | ||
} | ||
_setLastToken(lastToken) { | ||
}); | ||
}; | ||
RESTTransport.prototype._setLastToken = function (lastToken) { | ||
this._lastToken = lastToken; | ||
} | ||
withRetry(promiseFactory, retry = false) { | ||
let isNewToken = false; | ||
}; | ||
RESTTransport.prototype.withRetry = function (promiseFactory, retry) { | ||
var _this = this; | ||
if (retry === void 0) { retry = false; } | ||
var isNewToken = false; | ||
return this.getWithAuth(retry) | ||
.then(res => { | ||
isNewToken = this._lastToken !== res; | ||
this._lastToken = res; | ||
.then(function (res) { | ||
isNewToken = _this._lastToken !== res; | ||
_this._lastToken = res; | ||
return res; | ||
}) | ||
.then(promiseFactory) | ||
.catch(err => { | ||
.catch(function (err) { | ||
// Only retry if the result is unauthorized and the last token isn't the same as the new one. | ||
@@ -752,8 +806,9 @@ if ('code' in err && | ||
logDebug('Retrying due to unauthorized'); | ||
return this.withRetry(promiseFactory, true); | ||
return _this.withRetry(promiseFactory, true); | ||
} | ||
throw err; | ||
}); | ||
} | ||
} | ||
}; | ||
return RESTTransport; | ||
}()); | ||
@@ -785,3 +840,3 @@ /** | ||
dcInstance.setInitialized(); | ||
const ref = { | ||
var ref = { | ||
dataConnect: dcInstance, | ||
@@ -797,19 +852,23 @@ name: mutationName, | ||
*/ | ||
class MutationManager { | ||
constructor(_transport) { | ||
var MutationManager = /** @class */ (function () { | ||
function MutationManager(_transport) { | ||
this._transport = _transport; | ||
this._inflight = []; | ||
} | ||
executeMutation(mutationRef) { | ||
const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables); | ||
const withRefPromise = result.then(res => { | ||
const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() }); | ||
MutationManager.prototype.executeMutation = function (mutationRef) { | ||
var _this = this; | ||
var result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables); | ||
var withRefPromise = result.then(function (res) { | ||
var obj = __assign(__assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() }); | ||
return obj; | ||
}); | ||
this._inflight.push(result); | ||
const removePromise = () => (this._inflight = this._inflight.filter(promise => promise !== result)); | ||
var removePromise = function () { | ||
return (_this._inflight = _this._inflight.filter(function (promise) { return promise !== result; })); | ||
}; | ||
result.then(removePromise, removePromise); | ||
return withRefPromise; | ||
} | ||
} | ||
}; | ||
return MutationManager; | ||
}()); | ||
/** | ||
@@ -840,3 +899,3 @@ * Execute Mutation | ||
*/ | ||
const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST'; | ||
var FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST'; | ||
/** | ||
@@ -849,7 +908,7 @@ * | ||
function parseOptions(fullHost) { | ||
const [protocol, hostName] = fullHost.split('://'); | ||
const isSecure = protocol === 'https'; | ||
const [host, portAsString] = hostName.split(':'); | ||
const port = Number(portAsString); | ||
return { host, port, sslEnabled: isSecure }; | ||
var _a = fullHost.split('://'), protocol = _a[0], hostName = _a[1]; | ||
var isSecure = protocol === 'https'; | ||
var _b = hostName.split(':'), host = _b[0], portAsString = _b[1]; | ||
var port = Number(portAsString); | ||
return { host: host, port: port, sslEnabled: isSecure }; | ||
} | ||
@@ -859,5 +918,5 @@ /** | ||
*/ | ||
class DataConnect { | ||
var DataConnect = /** @class */ (function () { | ||
// @internal | ||
constructor(app, | ||
function DataConnect(app, | ||
// TODO(mtewani): Replace with _dataConnectOptions in the future | ||
@@ -873,3 +932,3 @@ dataConnectOptions, _authProvider, _appCheckProvider) { | ||
if (typeof process !== 'undefined' && process.env) { | ||
const host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR]; | ||
var host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR]; | ||
if (host) { | ||
@@ -883,19 +942,19 @@ logDebug('Found custom host. Using emulator'); | ||
// @internal | ||
_useGeneratedSdk() { | ||
DataConnect.prototype._useGeneratedSdk = function () { | ||
if (!this._isUsingGeneratedSdk) { | ||
this._isUsingGeneratedSdk = true; | ||
} | ||
} | ||
_delete() { | ||
}; | ||
DataConnect.prototype._delete = function () { | ||
_removeServiceInstance(this.app, 'data-connect', JSON.stringify(this.getSettings())); | ||
return Promise.resolve(); | ||
} | ||
}; | ||
// @internal | ||
getSettings() { | ||
const copy = JSON.parse(JSON.stringify(this.dataConnectOptions)); | ||
DataConnect.prototype.getSettings = function () { | ||
var copy = JSON.parse(JSON.stringify(this.dataConnectOptions)); | ||
delete copy.projectId; | ||
return copy; | ||
} | ||
}; | ||
// @internal | ||
setInitialized() { | ||
DataConnect.prototype.setInitialized = function () { | ||
if (this._initialized) { | ||
@@ -921,5 +980,5 @@ return; | ||
this._mutationManager = new MutationManager(this._transport); | ||
} | ||
}; | ||
// @internal | ||
enableEmulator(transportOptions) { | ||
DataConnect.prototype.enableEmulator = function (transportOptions) { | ||
if (this._initialized) { | ||
@@ -931,4 +990,5 @@ logError('enableEmulator called after initialization'); | ||
this.isEmulator = true; | ||
} | ||
} | ||
}; | ||
return DataConnect; | ||
}()); | ||
/** | ||
@@ -941,8 +1001,9 @@ * Connect to the DataConnect Emulator | ||
*/ | ||
function connectDataConnectEmulator(dc, host, port, sslEnabled = false) { | ||
dc.enableEmulator({ host, port, sslEnabled }); | ||
function connectDataConnectEmulator(dc, host, port, sslEnabled) { | ||
if (sslEnabled === void 0) { sslEnabled = false; } | ||
dc.enableEmulator({ host: host, port: port, sslEnabled: sslEnabled }); | ||
} | ||
function getDataConnect(appOrOptions, optionalOptions) { | ||
let app; | ||
let dcOptions; | ||
var app; | ||
var dcOptions; | ||
if ('location' in appOrOptions) { | ||
@@ -959,8 +1020,8 @@ dcOptions = appOrOptions; | ||
} | ||
const provider = _getProvider(app, 'data-connect'); | ||
const identifier = JSON.stringify(dcOptions); | ||
var provider = _getProvider(app, 'data-connect'); | ||
var identifier = JSON.stringify(dcOptions); | ||
if (provider.isInitialized(identifier)) { | ||
const dcInstance = provider.getImmediate({ identifier }); | ||
const options = provider.getOptions(identifier); | ||
const optionsValid = Object.keys(options).length > 0; | ||
var dcInstance = provider.getImmediate({ identifier: identifier }); | ||
var options = provider.getOptions(identifier); | ||
var optionsValid = Object.keys(options).length > 0; | ||
if (optionsValid) { | ||
@@ -986,9 +1047,9 @@ logDebug('Re-using cached instance'); | ||
function validateDCOptions(dcOptions) { | ||
const fields = ['connector', 'location', 'service']; | ||
var fields = ['connector', 'location', 'service']; | ||
if (!dcOptions) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required'); | ||
} | ||
fields.forEach(field => { | ||
fields.forEach(function (field) { | ||
if (dcOptions[field] === null || dcOptions[field] === undefined) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, `${field} Required`); | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "".concat(field, " Required")); | ||
} | ||
@@ -1008,25 +1069,10 @@ }); | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
function registerDataConnect(variant) { | ||
setSDKVersion(SDK_VERSION$1); | ||
_registerComponent(new Component('data-connect', (container, { instanceIdentifier: settings, options }) => { | ||
const app = container.getProvider('app').getImmediate(); | ||
const authProvider = container.getProvider('auth-internal'); | ||
const appCheckProvider = container.getProvider('app-check-internal'); | ||
let newOpts = options; | ||
_registerComponent(new Component('data-connect', function (container, _a) { | ||
var settings = _a.instanceIdentifier, options = _a.options; | ||
var app = container.getProvider('app').getImmediate(); | ||
var authProvider = container.getProvider('auth-internal'); | ||
var appCheckProvider = container.getProvider('app-check-internal'); | ||
var newOpts = options; | ||
if (settings) { | ||
@@ -1038,3 +1084,3 @@ newOpts = JSON.parse(settings); | ||
} | ||
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider); | ||
return new DataConnect(app, __assign(__assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider); | ||
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); | ||
@@ -1094,3 +1140,3 @@ registerVersion(name, version, variant); | ||
function toQueryRef(serializedRef) { | ||
const { refInfo: { name, variables, connectorConfig } } = serializedRef; | ||
var _a = serializedRef.refInfo, name = _a.name, variables = _a.variables, connectorConfig = _a.connectorConfig; | ||
return queryRef(getDataConnect(connectorConfig), name, variables); | ||
@@ -1126,4 +1172,4 @@ } | ||
function validateArgs(connectorConfig, dcOrVars, vars, validateVars) { | ||
let dcInstance; | ||
let realVars; | ||
var dcInstance; | ||
var realVars; | ||
if (dcOrVars && 'enableEmulator' in dcOrVars) { | ||
@@ -1168,11 +1214,11 @@ dcInstance = dcOrVars; | ||
function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComplete) { | ||
let ref; | ||
let initialCache; | ||
var ref; | ||
var initialCache; | ||
if ('refInfo' in queryRefOrSerializedResult) { | ||
const serializedRef = queryRefOrSerializedResult; | ||
const { data, source, fetchTime } = serializedRef; | ||
var serializedRef = queryRefOrSerializedResult; | ||
var data = serializedRef.data, source = serializedRef.source, fetchTime = serializedRef.fetchTime; | ||
initialCache = { | ||
data, | ||
source, | ||
fetchTime | ||
data: data, | ||
source: source, | ||
fetchTime: fetchTime | ||
}; | ||
@@ -1184,3 +1230,3 @@ ref = toQueryRef(serializedRef); | ||
} | ||
let onResult = undefined; | ||
var onResult = undefined; | ||
if (typeof observerOrOnNext === 'function') { | ||
@@ -1187,0 +1233,0 @@ onResult = observerOrOnNext; |
@@ -137,3 +137,3 @@ 'use strict'; | ||
if (_isUsingGen) { | ||
str += ' web/gen'; | ||
str += ' js/gen'; | ||
} | ||
@@ -217,4 +217,4 @@ return str; | ||
var name = "@firebase/data-connect"; | ||
var version = "0.1.0-canary.aa6db78eb"; | ||
const name = "@firebase/data-connect"; | ||
const version = "0.1.0-canary.b942e9e6e"; | ||
@@ -513,2 +513,5 @@ /** | ||
QueryManager.prototype.executeQuery = function (queryRef) { | ||
if (queryRef.refType !== QUERY_STR) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "ExecuteQuery can only execute query operation"); | ||
} | ||
var key = encoderImpl({ | ||
@@ -1044,3 +1047,3 @@ name: queryRef.name, | ||
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation | ||
app.registerVersion(name, version, 'cjs5'); | ||
app.registerVersion(name, version, 'cjs2017'); | ||
} | ||
@@ -1047,0 +1050,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { __extends, __awaiter, __generator, __assign } from 'tslib'; | ||
import { FirebaseError } from '@firebase/util'; | ||
@@ -22,3 +23,3 @@ import { Logger } from '@firebase/logger'; | ||
*/ | ||
const Code = { | ||
var Code = { | ||
OTHER: 'other', | ||
@@ -33,5 +34,6 @@ ALREADY_INITIALIZED: 'already-initialized', | ||
/** An error returned by a DataConnect operation. */ | ||
class DataConnectError extends FirebaseError { | ||
var DataConnectError = /** @class */ (function (_super) { | ||
__extends(DataConnectError, _super); | ||
/** @hideconstructor */ | ||
constructor( | ||
function DataConnectError( | ||
/** | ||
@@ -45,11 +47,13 @@ * The backend error code associated with this error. | ||
message) { | ||
super(code, message); | ||
this.code = code; | ||
this.message = message; | ||
var _this = _super.call(this, code, message) || this; | ||
_this.code = code; | ||
_this.message = message; | ||
// HACK: We write a toString property directly because Error is not a real | ||
// class and so inheritance does not work correctly. We could alternatively | ||
// do the same "back-door inheritance" trick that FirebaseError does. | ||
this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`; | ||
_this.toString = function () { return "".concat(_this.name, ": [code=").concat(_this.code, "]: ").concat(_this.message); }; | ||
return _this; | ||
} | ||
} | ||
return DataConnectError; | ||
}(FirebaseError)); | ||
@@ -73,3 +77,3 @@ /** | ||
/** The semver (www.semver.org) version of the SDK. */ | ||
let SDK_VERSION = ''; | ||
var SDK_VERSION = ''; | ||
/** | ||
@@ -99,3 +103,3 @@ * SDK_VERSION should be set before any database instance is created | ||
*/ | ||
const logger = new Logger('@firebase/data-connect'); | ||
var logger = new Logger('@firebase/data-connect'); | ||
function setLogLevel(logLevel) { | ||
@@ -105,6 +109,6 @@ logger.setLogLevel(logLevel); | ||
function logDebug(msg) { | ||
logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`); | ||
logger.debug("DataConnect (".concat(SDK_VERSION, "): ").concat(msg)); | ||
} | ||
function logError(msg) { | ||
logger.error(`DataConnect (${SDK_VERSION}): ${msg}`); | ||
logger.error("DataConnect (".concat(SDK_VERSION, "): ").concat(msg)); | ||
} | ||
@@ -128,3 +132,3 @@ | ||
*/ | ||
let connectFetch = globalThis.fetch; | ||
var connectFetch = globalThis.fetch; | ||
function initializeFetch(fetchImpl) { | ||
@@ -134,13 +138,15 @@ connectFetch = fetchImpl; | ||
function getGoogApiClientValue(_isUsingGen) { | ||
let str = 'gl-js/ fire/' + SDK_VERSION; | ||
var str = 'gl-js/ fire/' + SDK_VERSION; | ||
if (_isUsingGen) { | ||
str += ' web/gen'; | ||
str += ' js/gen'; | ||
} | ||
return str; | ||
} | ||
function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) { | ||
function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen) { | ||
var _this = this; | ||
var signal = _a.signal; | ||
if (!connectFetch) { | ||
throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!'); | ||
} | ||
const headers = { | ||
var headers = { | ||
'Content-Type': 'application/json', | ||
@@ -158,34 +164,45 @@ 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen) | ||
} | ||
const bodyStr = JSON.stringify(body); | ||
logDebug(`Making request out to ${url} with body: ${bodyStr}`); | ||
var bodyStr = JSON.stringify(body); | ||
logDebug("Making request out to ".concat(url, " with body: ").concat(bodyStr)); | ||
return connectFetch(url, { | ||
body: bodyStr, | ||
method: 'POST', | ||
headers, | ||
signal | ||
headers: headers, | ||
signal: signal | ||
}) | ||
.catch(err => { | ||
.catch(function (err) { | ||
throw new DataConnectError(Code.OTHER, 'Failed to fetch: ' + JSON.stringify(err)); | ||
}) | ||
.then(async (response) => { | ||
let jsonResponse = null; | ||
try { | ||
jsonResponse = await response.json(); | ||
} | ||
catch (e) { | ||
throw new DataConnectError(Code.OTHER, JSON.stringify(e)); | ||
} | ||
const message = getMessage(jsonResponse); | ||
if (response.status >= 400) { | ||
logError('Error while performing request: ' + JSON.stringify(jsonResponse)); | ||
if (response.status === 401) { | ||
throw new DataConnectError(Code.UNAUTHORIZED, message); | ||
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { | ||
var jsonResponse, e_1, message; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
jsonResponse = null; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
jsonResponse = _a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
throw new DataConnectError(Code.OTHER, JSON.stringify(e_1)); | ||
case 4: | ||
message = getMessage(jsonResponse); | ||
if (response.status >= 400) { | ||
logError('Error while performing request: ' + JSON.stringify(jsonResponse)); | ||
if (response.status === 401) { | ||
throw new DataConnectError(Code.UNAUTHORIZED, message); | ||
} | ||
throw new DataConnectError(Code.OTHER, message); | ||
} | ||
return [2 /*return*/, jsonResponse]; | ||
} | ||
throw new DataConnectError(Code.OTHER, message); | ||
} | ||
return jsonResponse; | ||
}) | ||
.then(res => { | ||
}); | ||
}); }) | ||
.then(function (res) { | ||
if (res.errors && res.errors.length) { | ||
const stringified = JSON.stringify(res.errors); | ||
var stringified = JSON.stringify(res.errors); | ||
logError('DataConnect error while performing request: ' + stringified); | ||
@@ -205,3 +222,3 @@ throw new DataConnectError(Code.OTHER, stringified); | ||
const name = "@firebase/data-connect"; | ||
const version = "0.1.0-canary.aa6db78eb"; | ||
const version = "0.1.0-canary.b942e9e6e"; | ||
@@ -228,4 +245,5 @@ /** | ||
*/ | ||
class AppCheckTokenProvider { | ||
constructor(appName_, appCheckProvider) { | ||
var AppCheckTokenProvider = /** @class */ (function () { | ||
function AppCheckTokenProvider(appName_, appCheckProvider) { | ||
var _this = this; | ||
this.appName_ = appName_; | ||
@@ -235,8 +253,9 @@ this.appCheckProvider = appCheckProvider; | ||
if (!this.appCheck) { | ||
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch()); | ||
void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(function (appCheck) { return (_this.appCheck = appCheck); }).catch()); | ||
} | ||
} | ||
getToken(forceRefresh) { | ||
AppCheckTokenProvider.prototype.getToken = function (forceRefresh) { | ||
var _this = this; | ||
if (!this.appCheck) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function (resolve, reject) { | ||
// Support delayed initialization of FirebaseAppCheck. This allows our | ||
@@ -246,5 +265,5 @@ // customers to initialize the RTDB SDK before initializing Firebase | ||
// becomes available before the timoeout below expires. | ||
setTimeout(() => { | ||
if (this.appCheck) { | ||
this.getToken(forceRefresh).then(resolve, reject); | ||
setTimeout(function () { | ||
if (_this.appCheck) { | ||
_this.getToken(forceRefresh).then(resolve, reject); | ||
} | ||
@@ -258,8 +277,9 @@ else { | ||
return this.appCheck.getToken(forceRefresh); | ||
} | ||
addTokenChangeListener(listener) { | ||
}; | ||
AppCheckTokenProvider.prototype.addTokenChangeListener = function (listener) { | ||
var _a; | ||
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener))); | ||
} | ||
} | ||
void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(function (appCheck) { return appCheck.addTokenListener(listener); })); | ||
}; | ||
return AppCheckTokenProvider; | ||
}()); | ||
@@ -283,4 +303,5 @@ /** | ||
// @internal | ||
class FirebaseAuthProvider { | ||
constructor(_appName, _options, _authProvider) { | ||
var FirebaseAuthProvider = /** @class */ (function () { | ||
function FirebaseAuthProvider(_appName, _options, _authProvider) { | ||
var _this = this; | ||
this._appName = _appName; | ||
@@ -291,11 +312,12 @@ this._options = _options; | ||
if (!this._auth) { | ||
_authProvider.onInit(auth => (this._auth = auth)); | ||
_authProvider.onInit(function (auth) { return (_this._auth = auth); }); | ||
} | ||
} | ||
getToken(forceRefresh) { | ||
FirebaseAuthProvider.prototype.getToken = function (forceRefresh) { | ||
var _this = this; | ||
if (!this._auth) { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (this._auth) { | ||
this.getToken(forceRefresh).then(resolve, reject); | ||
return new Promise(function (resolve, reject) { | ||
setTimeout(function () { | ||
if (_this._auth) { | ||
_this.getToken(forceRefresh).then(resolve, reject); | ||
} | ||
@@ -308,3 +330,3 @@ else { | ||
} | ||
return this._auth.getToken(forceRefresh).catch(error => { | ||
return this._auth.getToken(forceRefresh).catch(function (error) { | ||
if (error && error.code === 'auth/token-not-initialized') { | ||
@@ -320,14 +342,15 @@ logDebug('Got auth/token-not-initialized error. Treating as null token.'); | ||
}); | ||
} | ||
addTokenChangeListener(listener) { | ||
}; | ||
FirebaseAuthProvider.prototype.addTokenChangeListener = function (listener) { | ||
var _a; | ||
(_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener); | ||
} | ||
removeTokenChangeListener(listener) { | ||
}; | ||
FirebaseAuthProvider.prototype.removeTokenChangeListener = function (listener) { | ||
this._authProvider | ||
.get() | ||
.then(auth => auth.removeAuthTokenListener(listener)) | ||
.catch(err => logError(err)); | ||
} | ||
} | ||
.then(function (auth) { return auth.removeAuthTokenListener(listener); }) | ||
.catch(function (err) { return logError(err); }); | ||
}; | ||
return FirebaseAuthProvider; | ||
}()); | ||
@@ -350,6 +373,6 @@ /** | ||
*/ | ||
const QUERY_STR = 'query'; | ||
const MUTATION_STR = 'mutation'; | ||
const SOURCE_SERVER = 'SERVER'; | ||
const SOURCE_CACHE = 'CACHE'; | ||
var QUERY_STR = 'query'; | ||
var MUTATION_STR = 'mutation'; | ||
var SOURCE_SERVER = 'SERVER'; | ||
var SOURCE_CACHE = 'CACHE'; | ||
@@ -372,7 +395,7 @@ /** | ||
*/ | ||
let encoderImpl; | ||
var encoderImpl; | ||
function setEncoder(encoder) { | ||
encoderImpl = encoder; | ||
} | ||
setEncoder(o => JSON.stringify(o)); | ||
setEncoder(function (o) { return JSON.stringify(o); }); | ||
@@ -420,27 +443,27 @@ /** | ||
return { | ||
data, | ||
data: data, | ||
refInfo: { | ||
name: queryRef.name, | ||
variables: queryRef.variables, | ||
connectorConfig: Object.assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings()) | ||
connectorConfig: __assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings()) | ||
}, | ||
fetchTime: Date.now().toLocaleString(), | ||
source | ||
source: source | ||
}; | ||
}; | ||
} | ||
class QueryManager { | ||
constructor(transport) { | ||
var QueryManager = /** @class */ (function () { | ||
function QueryManager(transport) { | ||
this.transport = transport; | ||
this._queries = new Map(); | ||
} | ||
track(queryName, variables, initialCache) { | ||
const ref = { | ||
QueryManager.prototype.track = function (queryName, variables, initialCache) { | ||
var ref = { | ||
name: queryName, | ||
variables, | ||
variables: variables, | ||
refType: QUERY_STR | ||
}; | ||
const key = encoderImpl(ref); | ||
const newTrackedQuery = { | ||
ref, | ||
var key = encoderImpl(ref); | ||
var newTrackedQuery = { | ||
ref: ref, | ||
subscriptions: [], | ||
@@ -453,5 +476,6 @@ currentCache: initialCache || null, | ||
return this._queries.get(key); | ||
} | ||
addSubscription(queryRef, onResultCallback, onErrorCallback, initialCache) { | ||
const key = encoderImpl({ | ||
}; | ||
QueryManager.prototype.addSubscription = function (queryRef, onResultCallback, onErrorCallback, initialCache) { | ||
var _this = this; | ||
var key = encoderImpl({ | ||
name: queryRef.name, | ||
@@ -461,10 +485,10 @@ variables: queryRef.variables, | ||
}); | ||
const trackedQuery = this._queries.get(key); | ||
const subscription = { | ||
var trackedQuery = this._queries.get(key); | ||
var subscription = { | ||
userCallback: onResultCallback, | ||
errCallback: onErrorCallback | ||
}; | ||
const unsubscribe = () => { | ||
const trackedQuery = this._queries.get(key); | ||
trackedQuery.subscriptions = trackedQuery.subscriptions.filter(sub => sub !== subscription); | ||
var unsubscribe = function () { | ||
var trackedQuery = _this._queries.get(key); | ||
trackedQuery.subscriptions = trackedQuery.subscriptions.filter(function (sub) { return sub !== subscription; }); | ||
}; | ||
@@ -480,3 +504,3 @@ if (initialCache && trackedQuery.currentCache !== initialCache) { | ||
if (trackedQuery.currentCache !== null) { | ||
const cachedData = trackedQuery.currentCache.data; | ||
var cachedData = trackedQuery.currentCache.data; | ||
onResultCallback({ | ||
@@ -496,14 +520,17 @@ data: cachedData, | ||
errCallback: onErrorCallback, | ||
unsubscribe | ||
unsubscribe: unsubscribe | ||
}); | ||
if (!trackedQuery.currentCache) { | ||
logDebug(`No cache available for query ${queryRef.name} with variables ${JSON.stringify(queryRef.variables)}. Calling executeQuery.`); | ||
const promise = this.executeQuery(queryRef); | ||
logDebug("No cache available for query ".concat(queryRef.name, " with variables ").concat(JSON.stringify(queryRef.variables), ". Calling executeQuery.")); | ||
var promise = this.executeQuery(queryRef); | ||
// We want to ignore the error and let subscriptions handle it | ||
promise.then(undefined, err => { }); | ||
promise.then(undefined, function (err) { }); | ||
} | ||
return unsubscribe; | ||
} | ||
executeQuery(queryRef) { | ||
const key = encoderImpl({ | ||
}; | ||
QueryManager.prototype.executeQuery = function (queryRef) { | ||
if (queryRef.refType !== QUERY_STR) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "ExecuteQuery can only execute query operation"); | ||
} | ||
var key = encoderImpl({ | ||
name: queryRef.name, | ||
@@ -513,8 +540,8 @@ variables: queryRef.variables, | ||
}); | ||
const trackedQuery = this._queries.get(key); | ||
const result = this.transport.invokeQuery(queryRef.name, queryRef.variables); | ||
const newR = result.then(res => { | ||
const fetchTime = new Date().toString(); | ||
const result = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime }); | ||
trackedQuery.subscriptions.forEach(subscription => { | ||
var trackedQuery = this._queries.get(key); | ||
var result = this.transport.invokeQuery(queryRef.name, queryRef.variables); | ||
var newR = result.then(function (res) { | ||
var fetchTime = new Date().toString(); | ||
var result = __assign(__assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime: fetchTime }); | ||
trackedQuery.subscriptions.forEach(function (subscription) { | ||
subscription.userCallback(result); | ||
@@ -525,8 +552,8 @@ }); | ||
source: SOURCE_CACHE, | ||
fetchTime | ||
fetchTime: fetchTime | ||
}; | ||
return result; | ||
}, err => { | ||
}, function (err) { | ||
trackedQuery.lastError = err; | ||
trackedQuery.subscriptions.forEach(subscription => { | ||
trackedQuery.subscriptions.forEach(function (subscription) { | ||
if (subscription.errCallback) { | ||
@@ -539,10 +566,11 @@ subscription.errCallback(err); | ||
return newR; | ||
} | ||
enableEmulator(host, port) { | ||
}; | ||
QueryManager.prototype.enableEmulator = function (host, port) { | ||
this.transport.useEmulator(host, port); | ||
} | ||
} | ||
}; | ||
return QueryManager; | ||
}()); | ||
function compareDates(str1, str2) { | ||
const date1 = new Date(str1); | ||
const date2 = new Date(str2); | ||
var date1 = new Date(str1); | ||
var date2 = new Date(str2); | ||
return date1.getTime() < date2.getTime(); | ||
@@ -568,9 +596,9 @@ } | ||
function urlBuilder(projectConfig, transportOptions) { | ||
const { connector, location, projectId: project, service } = projectConfig; | ||
const { host, sslEnabled, port } = transportOptions; | ||
const protocol = sslEnabled ? 'https' : 'http'; | ||
const realHost = host || `firebasedataconnect.googleapis.com`; | ||
let baseUrl = `${protocol}://${realHost}`; | ||
var connector = projectConfig.connector, location = projectConfig.location, project = projectConfig.projectId, service = projectConfig.service; | ||
var host = transportOptions.host, sslEnabled = transportOptions.sslEnabled, port = transportOptions.port; | ||
var protocol = sslEnabled ? 'https' : 'http'; | ||
var realHost = host || "firebasedataconnect.googleapis.com"; | ||
var baseUrl = "".concat(protocol, "://").concat(realHost); | ||
if (typeof port === 'number') { | ||
baseUrl += `:${port}`; | ||
baseUrl += ":".concat(port); | ||
} | ||
@@ -581,3 +609,3 @@ else if (typeof port !== 'undefined') { | ||
} | ||
return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`; | ||
return "".concat(baseUrl, "/v1beta/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector); | ||
} | ||
@@ -588,3 +616,3 @@ function addToken(url, apiKey) { | ||
} | ||
const newUrl = new URL(url); | ||
var newUrl = new URL(url); | ||
newUrl.searchParams.append('key', apiKey); | ||
@@ -610,4 +638,6 @@ return newUrl.toString(); | ||
*/ | ||
class RESTTransport { | ||
constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) { | ||
var RESTTransport = /** @class */ (function () { | ||
function RESTTransport(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen) { | ||
if (_isUsingGen === void 0) { _isUsingGen = false; } | ||
var _this = this; | ||
var _a, _b; | ||
@@ -628,11 +658,13 @@ this.apiKey = apiKey; | ||
// TODO(mtewani): Update U to include shape of body defined in line 13. | ||
this.invokeQuery = (queryName, body) => { | ||
const abortController = new AbortController(); | ||
this.invokeQuery = function (queryName, body) { | ||
var abortController = new AbortController(); | ||
// TODO(mtewani): Update to proper value | ||
const withAuth = this.withRetry(() => dcFetch(addToken(`${this.endpointUrl}:executeQuery`, this.apiKey), { | ||
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`, | ||
operationName: queryName, | ||
variables: body | ||
}, // TODO(mtewani): This is a patch, fix this. | ||
abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen)); | ||
var withAuth = _this.withRetry(function () { | ||
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeQuery"), _this.apiKey), { | ||
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName), | ||
operationName: queryName, | ||
variables: body | ||
}, // TODO(mtewani): This is a patch, fix this. | ||
abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen); | ||
}); | ||
return { | ||
@@ -643,10 +675,10 @@ then: withAuth.then.bind(withAuth), | ||
}; | ||
this.invokeMutation = (mutationName, body) => { | ||
const abortController = new AbortController(); | ||
const taskResult = this.withRetry(() => { | ||
return dcFetch(addToken(`${this.endpointUrl}:executeMutation`, this.apiKey), { | ||
name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`, | ||
this.invokeMutation = function (mutationName, body) { | ||
var abortController = new AbortController(); | ||
var taskResult = _this.withRetry(function () { | ||
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeMutation"), _this.apiKey), { | ||
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName), | ||
operationName: mutationName, | ||
variables: body | ||
}, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen); | ||
}, abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen); | ||
}); | ||
@@ -657,3 +689,3 @@ return { | ||
// finally: taskResult.finally.bind(taskResult), | ||
cancel: () => abortController.abort() | ||
cancel: function () { return abortController.abort(); } | ||
}; | ||
@@ -670,3 +702,3 @@ }; | ||
} | ||
const { location, projectId: project, connector, service } = options; | ||
var location = options.location, project = options.projectId, connector = options.connector, service = options.service; | ||
if (location) { | ||
@@ -683,21 +715,25 @@ this._location = location; | ||
this._connectorName = connector; | ||
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(token => { | ||
logDebug(`New Token Available: ${token}`); | ||
this._accessToken = token; | ||
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(function (token) { | ||
logDebug("New Token Available: ".concat(token)); | ||
_this._accessToken = token; | ||
}); | ||
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => { | ||
const { token } = result; | ||
logDebug(`New App Check Token Available: ${token}`); | ||
this._appCheckToken = token; | ||
(_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(function (result) { | ||
var token = result.token; | ||
logDebug("New App Check Token Available: ".concat(token)); | ||
_this._appCheckToken = token; | ||
}); | ||
} | ||
get endpointUrl() { | ||
return urlBuilder({ | ||
connector: this._connectorName, | ||
location: this._location, | ||
projectId: this._project, | ||
service: this._serviceName | ||
}, { host: this._host, sslEnabled: this._secure, port: this._port }); | ||
} | ||
useEmulator(host, port, isSecure) { | ||
Object.defineProperty(RESTTransport.prototype, "endpointUrl", { | ||
get: function () { | ||
return urlBuilder({ | ||
connector: this._connectorName, | ||
location: this._location, | ||
projectId: this._project, | ||
service: this._serviceName | ||
}, { host: this._host, sslEnabled: this._secure, port: this._port }); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
RESTTransport.prototype.useEmulator = function (host, port, isSecure) { | ||
this._host = host; | ||
@@ -710,41 +746,59 @@ if (typeof port === 'number') { | ||
} | ||
} | ||
onTokenChanged(newToken) { | ||
}; | ||
RESTTransport.prototype.onTokenChanged = function (newToken) { | ||
this._accessToken = newToken; | ||
} | ||
async getWithAuth(forceToken = false) { | ||
}; | ||
RESTTransport.prototype.getWithAuth = function (forceToken) { | ||
var _a; | ||
let starterPromise = new Promise(resolve => resolve(this._accessToken)); | ||
if (this.appCheckProvider) { | ||
this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token; | ||
} | ||
if (this.authProvider) { | ||
starterPromise = this.authProvider | ||
.getToken(/*forceToken=*/ forceToken) | ||
.then(data => { | ||
if (!data) { | ||
return null; | ||
if (forceToken === void 0) { forceToken = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var starterPromise, _b; | ||
var _this = this; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
starterPromise = new Promise(function (resolve) { | ||
return resolve(_this._accessToken); | ||
}); | ||
if (!this.appCheckProvider) return [3 /*break*/, 2]; | ||
_b = this; | ||
return [4 /*yield*/, this.appCheckProvider.getToken()]; | ||
case 1: | ||
_b._appCheckToken = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.token; | ||
_c.label = 2; | ||
case 2: | ||
if (this.authProvider) { | ||
starterPromise = this.authProvider | ||
.getToken(/*forceToken=*/ forceToken) | ||
.then(function (data) { | ||
if (!data) { | ||
return null; | ||
} | ||
_this._accessToken = data.accessToken; | ||
return _this._accessToken; | ||
}); | ||
} | ||
else { | ||
starterPromise = new Promise(function (resolve) { return resolve(''); }); | ||
} | ||
return [2 /*return*/, starterPromise]; | ||
} | ||
this._accessToken = data.accessToken; | ||
return this._accessToken; | ||
}); | ||
} | ||
else { | ||
starterPromise = new Promise(resolve => resolve('')); | ||
} | ||
return starterPromise; | ||
} | ||
_setLastToken(lastToken) { | ||
}); | ||
}; | ||
RESTTransport.prototype._setLastToken = function (lastToken) { | ||
this._lastToken = lastToken; | ||
} | ||
withRetry(promiseFactory, retry = false) { | ||
let isNewToken = false; | ||
}; | ||
RESTTransport.prototype.withRetry = function (promiseFactory, retry) { | ||
var _this = this; | ||
if (retry === void 0) { retry = false; } | ||
var isNewToken = false; | ||
return this.getWithAuth(retry) | ||
.then(res => { | ||
isNewToken = this._lastToken !== res; | ||
this._lastToken = res; | ||
.then(function (res) { | ||
isNewToken = _this._lastToken !== res; | ||
_this._lastToken = res; | ||
return res; | ||
}) | ||
.then(promiseFactory) | ||
.catch(err => { | ||
.catch(function (err) { | ||
// Only retry if the result is unauthorized and the last token isn't the same as the new one. | ||
@@ -756,8 +810,9 @@ if ('code' in err && | ||
logDebug('Retrying due to unauthorized'); | ||
return this.withRetry(promiseFactory, true); | ||
return _this.withRetry(promiseFactory, true); | ||
} | ||
throw err; | ||
}); | ||
} | ||
} | ||
}; | ||
return RESTTransport; | ||
}()); | ||
@@ -789,3 +844,3 @@ /** | ||
dcInstance.setInitialized(); | ||
const ref = { | ||
var ref = { | ||
dataConnect: dcInstance, | ||
@@ -801,19 +856,23 @@ name: mutationName, | ||
*/ | ||
class MutationManager { | ||
constructor(_transport) { | ||
var MutationManager = /** @class */ (function () { | ||
function MutationManager(_transport) { | ||
this._transport = _transport; | ||
this._inflight = []; | ||
} | ||
executeMutation(mutationRef) { | ||
const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables); | ||
const withRefPromise = result.then(res => { | ||
const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() }); | ||
MutationManager.prototype.executeMutation = function (mutationRef) { | ||
var _this = this; | ||
var result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables); | ||
var withRefPromise = result.then(function (res) { | ||
var obj = __assign(__assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() }); | ||
return obj; | ||
}); | ||
this._inflight.push(result); | ||
const removePromise = () => (this._inflight = this._inflight.filter(promise => promise !== result)); | ||
var removePromise = function () { | ||
return (_this._inflight = _this._inflight.filter(function (promise) { return promise !== result; })); | ||
}; | ||
result.then(removePromise, removePromise); | ||
return withRefPromise; | ||
} | ||
} | ||
}; | ||
return MutationManager; | ||
}()); | ||
/** | ||
@@ -844,3 +903,3 @@ * Execute Mutation | ||
*/ | ||
const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST'; | ||
var FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST'; | ||
/** | ||
@@ -853,7 +912,7 @@ * | ||
function parseOptions(fullHost) { | ||
const [protocol, hostName] = fullHost.split('://'); | ||
const isSecure = protocol === 'https'; | ||
const [host, portAsString] = hostName.split(':'); | ||
const port = Number(portAsString); | ||
return { host, port, sslEnabled: isSecure }; | ||
var _a = fullHost.split('://'), protocol = _a[0], hostName = _a[1]; | ||
var isSecure = protocol === 'https'; | ||
var _b = hostName.split(':'), host = _b[0], portAsString = _b[1]; | ||
var port = Number(portAsString); | ||
return { host: host, port: port, sslEnabled: isSecure }; | ||
} | ||
@@ -863,5 +922,5 @@ /** | ||
*/ | ||
class DataConnect { | ||
var DataConnect = /** @class */ (function () { | ||
// @internal | ||
constructor(app, | ||
function DataConnect(app, | ||
// TODO(mtewani): Replace with _dataConnectOptions in the future | ||
@@ -877,3 +936,3 @@ dataConnectOptions, _authProvider, _appCheckProvider) { | ||
if (typeof process !== 'undefined' && process.env) { | ||
const host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR]; | ||
var host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR]; | ||
if (host) { | ||
@@ -887,19 +946,19 @@ logDebug('Found custom host. Using emulator'); | ||
// @internal | ||
_useGeneratedSdk() { | ||
DataConnect.prototype._useGeneratedSdk = function () { | ||
if (!this._isUsingGeneratedSdk) { | ||
this._isUsingGeneratedSdk = true; | ||
} | ||
} | ||
_delete() { | ||
}; | ||
DataConnect.prototype._delete = function () { | ||
_removeServiceInstance(this.app, 'data-connect', JSON.stringify(this.getSettings())); | ||
return Promise.resolve(); | ||
} | ||
}; | ||
// @internal | ||
getSettings() { | ||
const copy = JSON.parse(JSON.stringify(this.dataConnectOptions)); | ||
DataConnect.prototype.getSettings = function () { | ||
var copy = JSON.parse(JSON.stringify(this.dataConnectOptions)); | ||
delete copy.projectId; | ||
return copy; | ||
} | ||
}; | ||
// @internal | ||
setInitialized() { | ||
DataConnect.prototype.setInitialized = function () { | ||
if (this._initialized) { | ||
@@ -925,5 +984,5 @@ return; | ||
this._mutationManager = new MutationManager(this._transport); | ||
} | ||
}; | ||
// @internal | ||
enableEmulator(transportOptions) { | ||
DataConnect.prototype.enableEmulator = function (transportOptions) { | ||
if (this._initialized) { | ||
@@ -935,4 +994,5 @@ logError('enableEmulator called after initialization'); | ||
this.isEmulator = true; | ||
} | ||
} | ||
}; | ||
return DataConnect; | ||
}()); | ||
/** | ||
@@ -945,8 +1005,9 @@ * Connect to the DataConnect Emulator | ||
*/ | ||
function connectDataConnectEmulator(dc, host, port, sslEnabled = false) { | ||
dc.enableEmulator({ host, port, sslEnabled }); | ||
function connectDataConnectEmulator(dc, host, port, sslEnabled) { | ||
if (sslEnabled === void 0) { sslEnabled = false; } | ||
dc.enableEmulator({ host: host, port: port, sslEnabled: sslEnabled }); | ||
} | ||
function getDataConnect(appOrOptions, optionalOptions) { | ||
let app; | ||
let dcOptions; | ||
var app; | ||
var dcOptions; | ||
if ('location' in appOrOptions) { | ||
@@ -963,8 +1024,8 @@ dcOptions = appOrOptions; | ||
} | ||
const provider = _getProvider(app, 'data-connect'); | ||
const identifier = JSON.stringify(dcOptions); | ||
var provider = _getProvider(app, 'data-connect'); | ||
var identifier = JSON.stringify(dcOptions); | ||
if (provider.isInitialized(identifier)) { | ||
const dcInstance = provider.getImmediate({ identifier }); | ||
const options = provider.getOptions(identifier); | ||
const optionsValid = Object.keys(options).length > 0; | ||
var dcInstance = provider.getImmediate({ identifier: identifier }); | ||
var options = provider.getOptions(identifier); | ||
var optionsValid = Object.keys(options).length > 0; | ||
if (optionsValid) { | ||
@@ -990,9 +1051,9 @@ logDebug('Re-using cached instance'); | ||
function validateDCOptions(dcOptions) { | ||
const fields = ['connector', 'location', 'service']; | ||
var fields = ['connector', 'location', 'service']; | ||
if (!dcOptions) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required'); | ||
} | ||
fields.forEach(field => { | ||
fields.forEach(function (field) { | ||
if (dcOptions[field] === null || dcOptions[field] === undefined) { | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, `${field} Required`); | ||
throw new DataConnectError(Code.INVALID_ARGUMENT, "".concat(field, " Required")); | ||
} | ||
@@ -1012,25 +1073,10 @@ }); | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
function registerDataConnect(variant) { | ||
setSDKVersion(SDK_VERSION$1); | ||
_registerComponent(new Component('data-connect', (container, { instanceIdentifier: settings, options }) => { | ||
const app = container.getProvider('app').getImmediate(); | ||
const authProvider = container.getProvider('auth-internal'); | ||
const appCheckProvider = container.getProvider('app-check-internal'); | ||
let newOpts = options; | ||
_registerComponent(new Component('data-connect', function (container, _a) { | ||
var settings = _a.instanceIdentifier, options = _a.options; | ||
var app = container.getProvider('app').getImmediate(); | ||
var authProvider = container.getProvider('auth-internal'); | ||
var appCheckProvider = container.getProvider('app-check-internal'); | ||
var newOpts = options; | ||
if (settings) { | ||
@@ -1042,3 +1088,3 @@ newOpts = JSON.parse(settings); | ||
} | ||
return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider); | ||
return new DataConnect(app, __assign(__assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider); | ||
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true)); | ||
@@ -1098,3 +1144,3 @@ registerVersion(name, version, variant); | ||
function toQueryRef(serializedRef) { | ||
const { refInfo: { name, variables, connectorConfig } } = serializedRef; | ||
var _a = serializedRef.refInfo, name = _a.name, variables = _a.variables, connectorConfig = _a.connectorConfig; | ||
return queryRef(getDataConnect(connectorConfig), name, variables); | ||
@@ -1130,4 +1176,4 @@ } | ||
function validateArgs(connectorConfig, dcOrVars, vars, validateVars) { | ||
let dcInstance; | ||
let realVars; | ||
var dcInstance; | ||
var realVars; | ||
if (dcOrVars && 'enableEmulator' in dcOrVars) { | ||
@@ -1172,11 +1218,11 @@ dcInstance = dcOrVars; | ||
function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComplete) { | ||
let ref; | ||
let initialCache; | ||
var ref; | ||
var initialCache; | ||
if ('refInfo' in queryRefOrSerializedResult) { | ||
const serializedRef = queryRefOrSerializedResult; | ||
const { data, source, fetchTime } = serializedRef; | ||
var serializedRef = queryRefOrSerializedResult; | ||
var data = serializedRef.data, source = serializedRef.source, fetchTime = serializedRef.fetchTime; | ||
initialCache = { | ||
data, | ||
source, | ||
fetchTime | ||
data: data, | ||
source: source, | ||
fetchTime: fetchTime | ||
}; | ||
@@ -1188,3 +1234,3 @@ ref = toQueryRef(serializedRef); | ||
} | ||
let onResult = undefined; | ||
var onResult = undefined; | ||
if (typeof observerOrOnNext === 'function') { | ||
@@ -1191,0 +1237,0 @@ onResult = observerOrOnNext; |
{ | ||
"name": "@firebase/data-connect", | ||
"version": "0.1.0-canary.aa6db78eb", | ||
"version": "0.1.0-canary.b942e9e6e", | ||
"description": "", | ||
@@ -9,3 +9,2 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"module": "dist/index.esm2017.js", | ||
"esm5": "dist/index.esm5.js", | ||
"exports": { | ||
@@ -18,3 +17,2 @@ ".": { | ||
}, | ||
"esm5": "./dist/index.esm5.js", | ||
"browser": { | ||
@@ -52,13 +50,13 @@ "require": "./dist/index.cjs.js", | ||
"peerDependencies": { | ||
"@firebase/app": "0.10.12-canary.aa6db78eb" | ||
"@firebase/app": "0.10.13-canary.b942e9e6e" | ||
}, | ||
"dependencies": { | ||
"@firebase/auth-interop-types": "0.2.3-canary.aa6db78eb", | ||
"@firebase/component": "0.6.9-canary.aa6db78eb", | ||
"@firebase/logger": "0.4.2-canary.aa6db78eb", | ||
"@firebase/util": "1.10.0-canary.aa6db78eb", | ||
"@firebase/auth-interop-types": "0.2.3-canary.b942e9e6e", | ||
"@firebase/component": "0.6.9-canary.b942e9e6e", | ||
"@firebase/logger": "0.4.2-canary.b942e9e6e", | ||
"@firebase/util": "1.10.0-canary.b942e9e6e", | ||
"tslib": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@firebase/app": "0.10.12-canary.aa6db78eb", | ||
"@firebase/app": "0.10.13-canary.b942e9e6e", | ||
"rollup": "2.79.1", | ||
@@ -65,0 +63,0 @@ "rollup-plugin-typescript2": "0.31.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
4
80
8
649737
62
7426
+ Added@firebase/app@0.10.13-canary.b942e9e6e(transitive)
+ Added@firebase/auth-interop-types@0.2.3-canary.b942e9e6e(transitive)
+ Added@firebase/component@0.6.9-canary.b942e9e6e(transitive)
+ Added@firebase/logger@0.4.2-canary.b942e9e6e(transitive)
+ Added@firebase/util@1.10.0-canary.b942e9e6e(transitive)
- Removed@firebase/app@0.10.12-canary.aa6db78eb(transitive)
- Removed@firebase/auth-interop-types@0.2.3-canary.aa6db78eb(transitive)
- Removed@firebase/component@0.6.9-canary.aa6db78eb(transitive)
- Removed@firebase/logger@0.4.2-canary.aa6db78eb(transitive)
- Removed@firebase/util@1.10.0-canary.aa6db78eb(transitive)