UNPKG

1.4 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4/**
5 * Helper utility functions for QueryBuilder.
6 */
7var QueryBuilderUtils = /** @class */ (function () {
8 function QueryBuilderUtils() {
9 }
10 /**
11 * Checks if given value is a string representation of alias property,
12 * e.g. "post.category" or "post.id".
13 */
14 QueryBuilderUtils.isAliasProperty = function (str) {
15 // alias property must be a string and must have a dot separator
16 if (typeof str !== "string" || str.indexOf(".") === -1)
17 return false;
18 // extra alias and its property relation
19 var _a = tslib_1.__read(str.split("."), 2), aliasName = _a[0], propertyName = _a[1]; // todo: what about relations in embedded?
20 if (!aliasName || !propertyName)
21 return false;
22 // alias and property must be represented in a special format
23 // const aliasNameRegexp = /^[a-zA-Z0-9_-]+$/;
24 // if (!aliasNameRegexp.test(aliasName) || !aliasNameRegexp.test(propertyName))
25 // return false;
26 // make sure string is not a subquery
27 if (str.indexOf("(") !== -1 || str.indexOf(")") !== -1)
28 return false;
29 return true;
30 };
31 return QueryBuilderUtils;
32}());
33exports.QueryBuilderUtils = QueryBuilderUtils;
34
35//# sourceMappingURL=QueryBuilderUtils.js.map