forked from dienianindya/gsi_ess_mobile
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
37 lines
1.3 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.booleanXOR = exports.parseFieldName = exports.parseIndexName = void 0;
|
|
const error_1 = require("../error");
|
|
const INDEX_NAME_REGEX = /projects\/([^\/]+?)\/databases\/\(default\)\/collectionGroups\/([^\/]+?)\/indexes\/([^\/]*)/;
|
|
const FIELD_NAME_REGEX = /projects\/([^\/]+?)\/databases\/\(default\)\/collectionGroups\/([^\/]+?)\/fields\/([^\/]*)/;
|
|
function parseIndexName(name) {
|
|
if (!name) {
|
|
throw new error_1.FirebaseError(`Cannot parse undefined index name.`);
|
|
}
|
|
const m = name.match(INDEX_NAME_REGEX);
|
|
if (!m || m.length < 4) {
|
|
throw new error_1.FirebaseError(`Error parsing index name: ${name}`);
|
|
}
|
|
return {
|
|
projectId: m[1],
|
|
collectionGroupId: m[2],
|
|
indexId: m[3],
|
|
};
|
|
}
|
|
exports.parseIndexName = parseIndexName;
|
|
function parseFieldName(name) {
|
|
const m = name.match(FIELD_NAME_REGEX);
|
|
if (!m || m.length < 4) {
|
|
throw new error_1.FirebaseError(`Error parsing field name: ${name}`);
|
|
}
|
|
return {
|
|
projectId: m[1],
|
|
collectionGroupId: m[2],
|
|
fieldPath: m[3],
|
|
};
|
|
}
|
|
exports.parseFieldName = parseFieldName;
|
|
function booleanXOR(a, b) {
|
|
return !!(Number(a) - Number(b));
|
|
}
|
|
exports.booleanXOR = booleanXOR;
|