Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(indexedChildren: SortedMap, indexName: string) => {
const index = safeGet(this.indexSet_, indexName);
assert(index, 'Missing index implementation for ' + indexName);
if (indexedChildren === fallbackObject) {
// Check to see if we need to index everything
if (index.isDefinedOn(namedNode.node)) {
// We need to build this index
const childList = [];
const iter = existingChildren.getIterator(NamedNode.Wrap);
let next = iter.getNext();
while (next) {
if (next.name !== namedNode.name) {
childList.push(next);
}
next = iter.getNext();
}
childList.push(namedNode);
return buildChildSet(childList, index.getCompare());
if (!objectContainsKey) {
if (optional) {
return;
} else {
throw new Error(
errorPrefixFxn(fnName, argumentNumber, optional) +
'must contain the key "' +
key +
'"'
);
}
}
if (optType) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const val = safeGet(obj as any, key);
if (
(optType === 'number' && !(typeof val === 'number')) ||
(optType === 'string' && !(typeof val === 'string')) ||
(optType === 'boolean' && !(typeof val === 'boolean')) ||
(optType === 'function' && !(typeof val === 'function')) ||
(optType === 'object' && !(typeof val === 'object') && val)
) {
if (optional) {
throw new Error(
errorPrefixFxn(fnName, argumentNumber, optional) +
'contains invalid value for key "' +
key +
'" (must be of type "' +
optType +
'")'
);
const nodeQueue = queueNode.getValue() || [];
nodeQueue.push(transaction);
queueNode.setValue(nodeQueue);
// Update visibleData and raise events
// Note: We intentionally raise events after updating all of our transaction state, since the user could
// start new transactions from the event callbacks.
let priorityForNode;
if (
typeof newVal === 'object' &&
newVal !== null &&
contains(newVal, '.priority')
) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
priorityForNode = safeGet(newVal as any, '.priority');
assert(
isValidPriority(priorityForNode),
'Invalid priority returned by transaction. ' +
'Priority must be a valid string, finite number, server value, or null.'
);
} else {
const currentNode =
this.serverSyncTree_.calcCompleteEventCache(path) ||
ChildrenNode.EMPTY_NODE;
priorityForNode = currentNode.getPriority().val();
}
priorityForNode /** @type {null|number|string} */ = priorityForNode;
const serverValues = this.generateServerValues();
const newNodeUnresolved = nodeFromJSON(newVal, priorityForNode);
const newNode = resolveDeferredValueSnapshot(
deleteRepo(repo: Repo) {
const appRepos = safeGet(this.repos_, repo.app.name);
// This should never happen...
if (!appRepos || safeGet(appRepos, repo.repoInfo_.toURLString()) !== repo) {
fatal(
`Database ${repo.app.name}(${repo.repoInfo_}) has already been deleted.`
);
}
repo.interrupt();
delete appRepos[repo.repoInfo_.toURLString()];
}
RepoManager.prototype.deleteRepo = function (repo) {
var appRepos = safeGet(this.repos_, repo.app.name);
// This should never happen...
if (!appRepos || safeGet(appRepos, repo.repoInfo_.toURLString()) !== repo) {
fatal("Database " + repo.app.name + "(" + repo.repoInfo_ + ") has already been deleted.");
}
repo.interrupt();
delete appRepos[repo.repoInfo_.toURLString()];
};
/**
subTree(pathObj: string | Path): Tree {
// TODO: Require pathObj to be Path?
let path = pathObj instanceof Path ? pathObj : new Path(pathObj);
let child = this as Tree,
next = path.getFront();
while (next !== null) {
const childNode = safeGet(child.node_.children, next) || new TreeNode();
child = new Tree(next, child, childNode);
path = path.popFront();
next = path.getFront();
}
return child;
}
RepoManager.prototype.createRepo = function (repoInfo, app) {
var appRepos = util_1.safeGet(this.repos_, app.name);
if (!appRepos) {
appRepos = {};
this.repos_[app.name] = appRepos;
}
var repo = util_1.safeGet(appRepos, repoInfo.toURLString());
if (repo) {
util_2.fatal('Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.');
}
repo = new Repo_1.Repo(repoInfo, this.useRestClient_, app);
appRepos[repoInfo.toURLString()] = repo;
return repo;
};
/**
private static warnOnListenWarnings_(payload: any, query: Query) {
if (payload && typeof payload === 'object' && contains(payload, 'w')) {
const warnings = safeGet(payload, 'w');
if (Array.isArray(warnings) && ~warnings.indexOf('no_index')) {
const indexSpec =
'".indexOn": "' +
query
.getQueryParams()
.getIndex()
.toString() +
'"';
const indexPath = query.path.toString();
warn(
`Using an unspecified index. Your data will be downloaded and ` +
`filtered on the client. Consider adding ${indexSpec} at ` +
`${indexPath} to your security rules for better performance.`
);
}
}
createRepo(
repoInfo: RepoInfo,
app: FirebaseApp,
authProvider: Provider
): Repo {
let appRepos = safeGet(this.repos_, app.name);
if (!appRepos) {
appRepos = {};
this.repos_[app.name] = appRepos;
}
let repo = safeGet(appRepos, repoInfo.toURLString());
if (repo) {
fatal(
'Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.'
);
}
repo = new Repo(repoInfo, this.useRestClient_, app, authProvider);
appRepos[repoInfo.toURLString()] = repo;
return repo;
}
RepoManager.prototype.createRepo = function (repoInfo, app) {
var appRepos = safeGet(this.repos_, app.name);
if (!appRepos) {
appRepos = {};
this.repos_[app.name] = appRepos;
}
var repo = safeGet(appRepos, repoInfo.toURLString());
if (repo) {
fatal('Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.');
}
repo = new Repo(repoInfo, this.useRestClient_, app);
appRepos[repoInfo.toURLString()] = repo;
return repo;
};
/**