Socket
Socket
Sign inDemoInstall

odata-query

Package Overview
Dependencies
1
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0 to 7.0.1

239

dist/browser/index.js
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
(function (global){(function (){
/******************************************************************************
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -31,2 +31,3 @@ /* global global, define, System, Reflect, Promise */

var __spreadArrays;
var __spreadArray;
var __await;

@@ -39,2 +40,6 @@ var __asyncGenerator;

var __importDefault;
var __classPrivateFieldGet;
var __classPrivateFieldSet;
var __classPrivateFieldIn;
var __createBinding;
(function (factory) {

@@ -66,5 +71,7 @@ var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
__extends = function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -111,6 +118,7 @@ function __() { this.constructor = d; }

__awaiter = function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -148,10 +156,22 @@ });

__exportStar = function (m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
__exportStar = function(m, o) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
};
__createBinding = Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
__values = function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
return {
if (o && typeof o.length === "number") return {
next: function () {

@@ -162,2 +182,3 @@ if (o && i >= o.length) o = void 0;

};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};

@@ -182,2 +203,3 @@

/** @deprecated */
__spread = function () {

@@ -189,2 +211,3 @@ for (var ar = [], i = 0; i < arguments.length; i++)

/** @deprecated */
__spreadArrays = function () {

@@ -198,2 +221,12 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;

__spreadArray = function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
__await = function (v) {

@@ -234,7 +267,13 @@ return this instanceof __await ? (this.v = v, this) : new __await(v);

var __setModuleDefault = Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
};
__importStar = function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;

@@ -247,2 +286,20 @@ };

__classPrivateFieldGet = function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
__classPrivateFieldSet = function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
__classPrivateFieldIn = function (state, receiver) {
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
};
exporter("__extends", __extends);

@@ -257,2 +314,3 @@ exporter("__assign", __assign);

exporter("__exportStar", __exportStar);
exporter("__createBinding", __createBinding);
exporter("__values", __values);

@@ -262,2 +320,3 @@ exporter("__read", __read);

exporter("__spreadArrays", __spreadArrays);
exporter("__spreadArray", __spreadArray);
exporter("__await", __await);

@@ -270,5 +329,8 @@ exporter("__asyncGenerator", __asyncGenerator);

exporter("__importDefault", __importDefault);
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
exporter("__classPrivateFieldIn", __classPrivateFieldIn);
});
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],2:[function(require,module,exports){

@@ -284,2 +346,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ITEM_ROOT = exports.decimal = exports.alias = exports.json = exports.binary = exports.duration = exports.guid = exports.raw = exports.StandardAggregateMethods = void 0;
var tslib_1 = require("tslib");

@@ -309,9 +372,16 @@ var COMPARISON_OPERATORS = ['eq', 'ne', 'gt', 'ge', 'lt', 'le'];

})(StandardAggregateMethods = exports.StandardAggregateMethods || (exports.StandardAggregateMethods = {}));
exports.raw = function (value) { return ({ type: 'raw', value: value }); };
exports.guid = function (value) { return ({ type: 'guid', value: value }); };
exports.duration = function (value) { return ({ type: 'duration', value: value }); };
exports.binary = function (value) { return ({ type: 'binary', value: value }); };
exports.json = function (value) { return ({ type: 'json', value: value }); };
exports.alias = function (name, value) { return ({ type: 'alias', name: name, value: value }); };
exports.decimal = function (value) { return ({ type: 'decimal', value: value }); };
var raw = function (value) { return ({ type: 'raw', value: value }); };
exports.raw = raw;
var guid = function (value) { return ({ type: 'guid', value: value }); };
exports.guid = guid;
var duration = function (value) { return ({ type: 'duration', value: value }); };
exports.duration = duration;
var binary = function (value) { return ({ type: 'binary', value: value }); };
exports.binary = binary;
var json = function (value) { return ({ type: 'json', value: value }); };
exports.json = json;
var alias = function (name, value) { return ({ type: 'alias', name: name, value: value }); };
exports.alias = alias;
var decimal = function (value) { return ({ type: 'decimal', value: value }); };
exports.decimal = decimal;
exports.ITEM_ROOT = "";

@@ -325,3 +395,3 @@ function default_1(_a) {

if (key != undefined) {
path += "(" + handleValue(key, aliases) + ")";
path += "(".concat(handleValue(key, aliases), ")");
}

@@ -351,7 +421,7 @@ if (filter || typeof count === 'object')

if (action) {
path += "/" + action;
path += "/".concat(action);
}
if (func) {
if (typeof func === 'string') {
path += "/" + func;
path += "/".concat(func);
}

@@ -361,5 +431,5 @@ else if (typeof func === 'object') {

var funcArgs = handleValue(func[funcName], aliases);
path += "/" + funcName;
path += "/".concat(funcName);
if (funcArgs !== "") {
path += "(" + funcArgs + ")";
path += "(".concat(funcArgs, ")");
}

@@ -371,3 +441,3 @@ }

var _a;
return Object.assign(acc, (_a = {}, _a["@" + alias.name] = handleValue(alias.value), _a));
return Object.assign(acc, (_a = {}, _a["@".concat(alias.name)] = handleValue(alias.value), _a));
}, {}));

@@ -380,3 +450,3 @@ }

if (aliases === void 0) { aliases = []; }
return key + " eq " + handleValue(val, aliases);
return "".concat(key, " eq ").concat(handleValue(val, aliases));
}

@@ -409,2 +479,5 @@ function buildFilter(filters, aliases, propPrefix) {

var value = filter[filterKey];
if (value === undefined) {
return result;
}
var propName = '';

@@ -416,9 +489,9 @@ if (propPrefix) {

else if (INDEXOF_REGEX.test(filterKey)) {
propName = filterKey.replace(INDEXOF_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(" + propPrefix + ")" : "(" + propPrefix + "/" + $1.trim() + ")"; });
propName = filterKey.replace(INDEXOF_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(".concat(propPrefix, ")") : "(".concat(propPrefix, "/").concat($1.trim(), ")"); });
}
else if (FUNCTION_REGEX.test(filterKey)) {
propName = filterKey.replace(FUNCTION_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(" + propPrefix + ")" : "(" + propPrefix + "/" + $1.trim() + ")"; });
propName = filterKey.replace(FUNCTION_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(".concat(propPrefix, ")") : "(".concat(propPrefix, "/").concat($1.trim(), ")"); });
}
else {
propName = propPrefix + "/" + filterKey;
propName = "".concat(propPrefix, "/").concat(filterKey);
}

@@ -443,3 +516,3 @@ }

.filter(function (f) { return f; })
.map(function (f) { return (LOGICAL_OPERATORS.indexOf(op_1) !== -1 ? "(" + f + ")" : f); });
.map(function (f) { return (LOGICAL_OPERATORS.indexOf(op_1) !== -1 ? "(".concat(f, ")") : f); });
if (builtFilters.length) {

@@ -452,3 +525,3 @@ if (LOGICAL_OPERATORS.indexOf(op_1) !== -1) {

else {
result.push("(" + builtFilters.join(" " + op_1 + " ") + ")");
result.push("(".concat(builtFilters.join(" ".concat(op_1, " ")), ")"));
}

@@ -458,3 +531,3 @@ }

else {
result.push(builtFilters.join(" " + op_1 + " "));
result.push(builtFilters.join(" ".concat(op_1, " ")));
}

@@ -474,3 +547,3 @@ }

else {
result.push("" + builtFilters.join(" " + op + " "));
result.push("(".concat(builtFilters.join(" ".concat(op, " ")), ")"));
}

@@ -486,4 +559,7 @@ }

operators.forEach(function (op) {
if (value[op] === undefined) {
return;
}
if (COMPARISON_OPERATORS.indexOf(op) !== -1) {
result.push(propName + " " + op + " " + handleValue(value[op], aliases));
result.push("".concat(propName, " ").concat(op, " ").concat(handleValue(value[op], aliases)));
}

@@ -494,3 +570,3 @@ else if (LOGICAL_OPERATORS.indexOf(op) !== -1) {

.map(function (v) { return '(' + buildFilterCore(v, aliases, propName) + ')'; })
.join(" " + op + " "));
.join(" ".concat(op, " ")));
}

@@ -508,3 +584,3 @@ else {

else if (op === 'has') {
result.push(propName + " " + op + " " + handleValue(value[op], aliases));
result.push("".concat(propName, " ").concat(op, " ").concat(handleValue(value[op], aliases)));
}

@@ -522,3 +598,3 @@ else if (op === 'in') {

// Simple boolean functions (startswith, endswith, contains)
result.push(op + "(" + propName + "," + handleValue(value[op], aliases) + ")");
result.push("".concat(op, "(").concat(propName, ",").concat(handleValue(value[op], aliases), ")"));
}

@@ -535,7 +611,4 @@ else {

}
else if (value === undefined) {
// Ignore/omit filter if value is `undefined`
}
else {
throw new Error("Unexpected value type: " + value);
throw new Error("Unexpected value type: ".concat(value));
}

@@ -567,6 +640,6 @@ return result;

}
return tslib_1.__assign({}, acc, item);
return tslib_1.__assign(tslib_1.__assign({}, acc), item);
}, {}) : value;
var filter = buildFilterCore(filterValue, aliases, lambdaParameter);
clause = propName + "/" + op + "(" + (filter ? lambdaParameter + ":" + filter : '') + ")";
clause = "".concat(propName, "/").concat(op, "(").concat(filter ? "".concat(lambdaParameter, ":").concat(filter) : '', ")");
}

@@ -579,3 +652,3 @@ return clause;

var conditionOperator = collectionOperator == 'all' ? 'ne' : 'eq';
clause = propName + "/" + collectionOperator + "(" + lambdaParameter + ": " + lambdaParameter + " " + conditionOperator + " '" + value + "')";
clause = "".concat(propName, "/").concat(collectionOperator, "(").concat(lambdaParameter, ": ").concat(lambdaParameter, " ").concat(conditionOperator, " '").concat(value, "')");
return clause;

@@ -595,3 +668,3 @@ }

if (typeof value === 'string') {
return "'" + escapeIllegalChars(value) + "'";
return "'".concat(escapeIllegalChars(value), "'");
}

@@ -605,3 +678,3 @@ else if (value instanceof Date) {

else if (Array.isArray(value)) {
return "[" + value.map(function (d) { return handleValue(d); }).join(',') + "]";
return "[".concat(value.map(function (d) { return handleValue(d); }).join(','), "]");
}

@@ -617,5 +690,5 @@ else if (value === null) {

case 'duration':
return "duration'" + value.value + "'";
return "duration'".concat(value.value, "'");
case 'binary':
return "binary'" + value.value + "'";
return "binary'".concat(value.value, "'");
case 'alias':

@@ -625,7 +698,7 @@ // Store

aliases.push(value);
return "@" + value.name;
return "@".concat(value.name);
case 'json':
return escape(JSON.stringify(value.value));
case 'decimal':
return value.value + "M";
return "".concat(value.value, "M");
default:

@@ -639,3 +712,3 @@ return Object.entries(value)

var k = _a[0], v = _a[1];
return k + "=" + handleValue(v, aliases);
return "".concat(k, "=").concat(handleValue(v, aliases));
}).join(',');

@@ -661,11 +734,11 @@ }

// Inner-most item
return "$expand=" + item;
return "$expand=".concat(item);
}
else if (index === arr.length - 1) {
// Outer-most item, don't add `$expand=` prefix (added above)
return item + "(" + results + ")";
return "".concat(item, "(").concat(results, ")");
}
else {
// Other items
return "$expand=" + item + "(" + results + ")";
return "$expand=".concat(item, "(").concat(results, ")");
}

@@ -675,3 +748,3 @@ }, '');

else if (Array.isArray(expands)) {
return "" + expands.map(function (e) { return buildExpand(e); }).join(',');
return "".concat(expands.map(function (e) { return buildExpand(e); }).join(','));
}

@@ -694,3 +767,3 @@ else if (typeof expands === 'object') {

case 'top':
value = "" + expands[key];
value = "".concat(expands[key]);
break;

@@ -700,3 +773,3 @@ default:

}
return "$" + key.toLowerCase() + "=" + value;
return "$".concat(key.toLowerCase(), "=").concat(value);
})

@@ -709,3 +782,3 @@ .join(';');

var builtExpand = buildExpand(expands[key]);
return builtExpand ? key + "(" + builtExpand + ")" : key;
return builtExpand ? "".concat(key, "(").concat(builtExpand, ")") : key;
})

@@ -728,6 +801,6 @@ .join(',');

if (unsupportedKeys.length) {
throw new Error("Unsupported transform(s): " + unsupportedKeys);
throw new Error("Unsupported transform(s): ".concat(unsupportedKeys));
}
if (aggregate) {
result.push("aggregate(" + buildAggregate(aggregate) + ")");
result.push("aggregate(".concat(buildAggregate(aggregate), ")"));
}

@@ -737,7 +810,7 @@ if (filter) {

if (builtFilter) {
result.push("filter(" + buildFilter(builtFilter) + ")");
result.push("filter(".concat(buildFilter(builtFilter), ")"));
}
}
if (groupBy) {
result.push("groupby(" + buildGroupBy(groupBy) + ")");
result.push("groupby(".concat(buildGroupBy(groupBy), ")"));
}

@@ -759,8 +832,8 @@ return result;

if (!aggregateValue.with) {
throw new Error("'with' property required for '" + aggregateKey + "'");
throw new Error("'with' property required for '".concat(aggregateKey, "'"));
}
if (!aggregateValue.as) {
throw new Error("'as' property required for '" + aggregateKey + "'");
throw new Error("'as' property required for '".concat(aggregateKey, "'"));
}
return aggregateKey + " with " + aggregateValue.with + " as " + aggregateValue.as;
return "".concat(aggregateKey, " with ").concat(aggregateValue.with, " as ").concat(aggregateValue.as);
});

@@ -774,5 +847,5 @@ })

}
var result = "(" + groupBy.properties.join(',') + ")";
var result = "(".concat(groupBy.properties.join(','), ")");
if (groupBy.transform) {
result += "," + buildTransforms(groupBy.transform);
result += ",".concat(buildTransforms(groupBy.transform));
}

@@ -788,3 +861,3 @@ return result;

})
.map(function (v) { return "" + prefix + v; }).join(',');
.map(function (v) { return "".concat(prefix).concat(String(v)); }).join(',');
}

@@ -795,7 +868,7 @@ else if (typeof orderBy === 'object') {

var k = _a[0], v = _a[1];
return buildOrderBy(v, k + "/");
return buildOrderBy(v, "".concat(k, "/"));
})
.map(function (v) { return "" + prefix + v; }).join(',');
.map(function (v) { return "".concat(prefix).concat(v); }).join(',');
}
return "" + prefix + orderBy;
return "".concat(prefix).concat(String(orderBy));
}

@@ -806,9 +879,9 @@ function buildUrl(path, params) {

.filter(function (key) { return params[key] !== undefined && params[key] !== ''; })
.map(function (key) { return key + "=" + params[key]; });
return queries.length ? path + "?" + queries.join('&') : path;
.map(function (key) { return "".concat(key, "=").concat(params[key]); });
return queries.length ? "".concat(path, "?").concat(queries.join('&')) : path;
}
function parseNot(builtFilters) {
return "not(" + builtFilters.join(' and ') + ")";
return "not(".concat(builtFilters.join(' and '), ")");
}
},{"tslib":1}]},{},[2]);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ITEM_ROOT = exports.decimal = exports.alias = exports.json = exports.binary = exports.duration = exports.guid = exports.raw = exports.StandardAggregateMethods = void 0;
var tslib_1 = require("tslib");

@@ -27,9 +28,16 @@ var COMPARISON_OPERATORS = ['eq', 'ne', 'gt', 'ge', 'lt', 'le'];

})(StandardAggregateMethods = exports.StandardAggregateMethods || (exports.StandardAggregateMethods = {}));
exports.raw = function (value) { return ({ type: 'raw', value: value }); };
exports.guid = function (value) { return ({ type: 'guid', value: value }); };
exports.duration = function (value) { return ({ type: 'duration', value: value }); };
exports.binary = function (value) { return ({ type: 'binary', value: value }); };
exports.json = function (value) { return ({ type: 'json', value: value }); };
exports.alias = function (name, value) { return ({ type: 'alias', name: name, value: value }); };
exports.decimal = function (value) { return ({ type: 'decimal', value: value }); };
var raw = function (value) { return ({ type: 'raw', value: value }); };
exports.raw = raw;
var guid = function (value) { return ({ type: 'guid', value: value }); };
exports.guid = guid;
var duration = function (value) { return ({ type: 'duration', value: value }); };
exports.duration = duration;
var binary = function (value) { return ({ type: 'binary', value: value }); };
exports.binary = binary;
var json = function (value) { return ({ type: 'json', value: value }); };
exports.json = json;
var alias = function (name, value) { return ({ type: 'alias', name: name, value: value }); };
exports.alias = alias;
var decimal = function (value) { return ({ type: 'decimal', value: value }); };
exports.decimal = decimal;
exports.ITEM_ROOT = "";

@@ -43,3 +51,3 @@ function default_1(_a) {

if (key != undefined) {
path += "(" + handleValue(key, aliases) + ")";
path += "(".concat(handleValue(key, aliases), ")");
}

@@ -69,7 +77,7 @@ if (filter || typeof count === 'object')

if (action) {
path += "/" + action;
path += "/".concat(action);
}
if (func) {
if (typeof func === 'string') {
path += "/" + func;
path += "/".concat(func);
}

@@ -79,5 +87,5 @@ else if (typeof func === 'object') {

var funcArgs = handleValue(func[funcName], aliases);
path += "/" + funcName;
path += "/".concat(funcName);
if (funcArgs !== "") {
path += "(" + funcArgs + ")";
path += "(".concat(funcArgs, ")");
}

@@ -89,3 +97,3 @@ }

var _a;
return Object.assign(acc, (_a = {}, _a["@" + alias.name] = handleValue(alias.value), _a));
return Object.assign(acc, (_a = {}, _a["@".concat(alias.name)] = handleValue(alias.value), _a));
}, {}));

@@ -98,3 +106,3 @@ }

if (aliases === void 0) { aliases = []; }
return key + " eq " + handleValue(val, aliases);
return "".concat(key, " eq ").concat(handleValue(val, aliases));
}

@@ -127,2 +135,5 @@ function buildFilter(filters, aliases, propPrefix) {

var value = filter[filterKey];
if (value === undefined) {
return result;
}
var propName = '';

@@ -134,9 +145,9 @@ if (propPrefix) {

else if (INDEXOF_REGEX.test(filterKey)) {
propName = filterKey.replace(INDEXOF_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(" + propPrefix + ")" : "(" + propPrefix + "/" + $1.trim() + ")"; });
propName = filterKey.replace(INDEXOF_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(".concat(propPrefix, ")") : "(".concat(propPrefix, "/").concat($1.trim(), ")"); });
}
else if (FUNCTION_REGEX.test(filterKey)) {
propName = filterKey.replace(FUNCTION_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(" + propPrefix + ")" : "(" + propPrefix + "/" + $1.trim() + ")"; });
propName = filterKey.replace(FUNCTION_REGEX, function (_, $1) { return $1.trim() === exports.ITEM_ROOT ? "(".concat(propPrefix, ")") : "(".concat(propPrefix, "/").concat($1.trim(), ")"); });
}
else {
propName = propPrefix + "/" + filterKey;
propName = "".concat(propPrefix, "/").concat(filterKey);
}

@@ -161,3 +172,3 @@ }

.filter(function (f) { return f; })
.map(function (f) { return (LOGICAL_OPERATORS.indexOf(op_1) !== -1 ? "(" + f + ")" : f); });
.map(function (f) { return (LOGICAL_OPERATORS.indexOf(op_1) !== -1 ? "(".concat(f, ")") : f); });
if (builtFilters.length) {

@@ -170,3 +181,3 @@ if (LOGICAL_OPERATORS.indexOf(op_1) !== -1) {

else {
result.push("(" + builtFilters.join(" " + op_1 + " ") + ")");
result.push("(".concat(builtFilters.join(" ".concat(op_1, " ")), ")"));
}

@@ -176,3 +187,3 @@ }

else {
result.push(builtFilters.join(" " + op_1 + " "));
result.push(builtFilters.join(" ".concat(op_1, " ")));
}

@@ -192,3 +203,3 @@ }

else {
result.push("" + builtFilters.join(" " + op + " "));
result.push("(".concat(builtFilters.join(" ".concat(op, " ")), ")"));
}

@@ -204,4 +215,7 @@ }

operators.forEach(function (op) {
if (value[op] === undefined) {
return;
}
if (COMPARISON_OPERATORS.indexOf(op) !== -1) {
result.push(propName + " " + op + " " + handleValue(value[op], aliases));
result.push("".concat(propName, " ").concat(op, " ").concat(handleValue(value[op], aliases)));
}

@@ -212,3 +226,3 @@ else if (LOGICAL_OPERATORS.indexOf(op) !== -1) {

.map(function (v) { return '(' + buildFilterCore(v, aliases, propName) + ')'; })
.join(" " + op + " "));
.join(" ".concat(op, " ")));
}

@@ -226,3 +240,3 @@ else {

else if (op === 'has') {
result.push(propName + " " + op + " " + handleValue(value[op], aliases));
result.push("".concat(propName, " ").concat(op, " ").concat(handleValue(value[op], aliases)));
}

@@ -240,3 +254,3 @@ else if (op === 'in') {

// Simple boolean functions (startswith, endswith, contains)
result.push(op + "(" + propName + "," + handleValue(value[op], aliases) + ")");
result.push("".concat(op, "(").concat(propName, ",").concat(handleValue(value[op], aliases), ")"));
}

@@ -253,7 +267,4 @@ else {

}
else if (value === undefined) {
// Ignore/omit filter if value is `undefined`
}
else {
throw new Error("Unexpected value type: " + value);
throw new Error("Unexpected value type: ".concat(value));
}

@@ -285,6 +296,6 @@ return result;

}
return tslib_1.__assign({}, acc, item);
return tslib_1.__assign(tslib_1.__assign({}, acc), item);
}, {}) : value;
var filter = buildFilterCore(filterValue, aliases, lambdaParameter);
clause = propName + "/" + op + "(" + (filter ? lambdaParameter + ":" + filter : '') + ")";
clause = "".concat(propName, "/").concat(op, "(").concat(filter ? "".concat(lambdaParameter, ":").concat(filter) : '', ")");
}

@@ -297,3 +308,3 @@ return clause;

var conditionOperator = collectionOperator == 'all' ? 'ne' : 'eq';
clause = propName + "/" + collectionOperator + "(" + lambdaParameter + ": " + lambdaParameter + " " + conditionOperator + " '" + value + "')";
clause = "".concat(propName, "/").concat(collectionOperator, "(").concat(lambdaParameter, ": ").concat(lambdaParameter, " ").concat(conditionOperator, " '").concat(value, "')");
return clause;

@@ -313,3 +324,3 @@ }

if (typeof value === 'string') {
return "'" + escapeIllegalChars(value) + "'";
return "'".concat(escapeIllegalChars(value), "'");
}

@@ -323,3 +334,3 @@ else if (value instanceof Date) {

else if (Array.isArray(value)) {
return "[" + value.map(function (d) { return handleValue(d); }).join(',') + "]";
return "[".concat(value.map(function (d) { return handleValue(d); }).join(','), "]");
}

@@ -335,5 +346,5 @@ else if (value === null) {

case 'duration':
return "duration'" + value.value + "'";
return "duration'".concat(value.value, "'");
case 'binary':
return "binary'" + value.value + "'";
return "binary'".concat(value.value, "'");
case 'alias':

@@ -343,7 +354,7 @@ // Store

aliases.push(value);
return "@" + value.name;
return "@".concat(value.name);
case 'json':
return escape(JSON.stringify(value.value));
case 'decimal':
return value.value + "M";
return "".concat(value.value, "M");
default:

@@ -357,3 +368,3 @@ return Object.entries(value)

var k = _a[0], v = _a[1];
return k + "=" + handleValue(v, aliases);
return "".concat(k, "=").concat(handleValue(v, aliases));
}).join(',');

@@ -379,11 +390,11 @@ }

// Inner-most item
return "$expand=" + item;
return "$expand=".concat(item);
}
else if (index === arr.length - 1) {
// Outer-most item, don't add `$expand=` prefix (added above)
return item + "(" + results + ")";
return "".concat(item, "(").concat(results, ")");
}
else {
// Other items
return "$expand=" + item + "(" + results + ")";
return "$expand=".concat(item, "(").concat(results, ")");
}

@@ -393,3 +404,3 @@ }, '');

else if (Array.isArray(expands)) {
return "" + expands.map(function (e) { return buildExpand(e); }).join(',');
return "".concat(expands.map(function (e) { return buildExpand(e); }).join(','));
}

@@ -412,3 +423,3 @@ else if (typeof expands === 'object') {

case 'top':
value = "" + expands[key];
value = "".concat(expands[key]);
break;

@@ -418,3 +429,3 @@ default:

}
return "$" + key.toLowerCase() + "=" + value;
return "$".concat(key.toLowerCase(), "=").concat(value);
})

@@ -427,3 +438,3 @@ .join(';');

var builtExpand = buildExpand(expands[key]);
return builtExpand ? key + "(" + builtExpand + ")" : key;
return builtExpand ? "".concat(key, "(").concat(builtExpand, ")") : key;
})

@@ -446,6 +457,6 @@ .join(',');

if (unsupportedKeys.length) {
throw new Error("Unsupported transform(s): " + unsupportedKeys);
throw new Error("Unsupported transform(s): ".concat(unsupportedKeys));
}
if (aggregate) {
result.push("aggregate(" + buildAggregate(aggregate) + ")");
result.push("aggregate(".concat(buildAggregate(aggregate), ")"));
}

@@ -455,7 +466,7 @@ if (filter) {

if (builtFilter) {
result.push("filter(" + buildFilter(builtFilter) + ")");
result.push("filter(".concat(buildFilter(builtFilter), ")"));
}
}
if (groupBy) {
result.push("groupby(" + buildGroupBy(groupBy) + ")");
result.push("groupby(".concat(buildGroupBy(groupBy), ")"));
}

@@ -477,8 +488,8 @@ return result;

if (!aggregateValue.with) {
throw new Error("'with' property required for '" + aggregateKey + "'");
throw new Error("'with' property required for '".concat(aggregateKey, "'"));
}
if (!aggregateValue.as) {
throw new Error("'as' property required for '" + aggregateKey + "'");
throw new Error("'as' property required for '".concat(aggregateKey, "'"));
}
return aggregateKey + " with " + aggregateValue.with + " as " + aggregateValue.as;
return "".concat(aggregateKey, " with ").concat(aggregateValue.with, " as ").concat(aggregateValue.as);
});

@@ -492,5 +503,5 @@ })

}
var result = "(" + groupBy.properties.join(',') + ")";
var result = "(".concat(groupBy.properties.join(','), ")");
if (groupBy.transform) {
result += "," + buildTransforms(groupBy.transform);
result += ",".concat(buildTransforms(groupBy.transform));
}

@@ -506,3 +517,3 @@ return result;

})
.map(function (v) { return "" + prefix + v; }).join(',');
.map(function (v) { return "".concat(prefix).concat(String(v)); }).join(',');
}

@@ -513,7 +524,7 @@ else if (typeof orderBy === 'object') {

var k = _a[0], v = _a[1];
return buildOrderBy(v, k + "/");
return buildOrderBy(v, "".concat(k, "/"));
})
.map(function (v) { return "" + prefix + v; }).join(',');
.map(function (v) { return "".concat(prefix).concat(v); }).join(',');
}
return "" + prefix + orderBy;
return "".concat(prefix).concat(String(orderBy));
}

@@ -524,7 +535,7 @@ function buildUrl(path, params) {

.filter(function (key) { return params[key] !== undefined && params[key] !== ''; })
.map(function (key) { return key + "=" + params[key]; });
return queries.length ? path + "?" + queries.join('&') : path;
.map(function (key) { return "".concat(key, "=").concat(params[key]); });
return queries.length ? "".concat(path, "?").concat(queries.join('&')) : path;
}
function parseNot(builtFilters) {
return "not(" + builtFilters.join(' and ') + ")";
return "not(".concat(builtFilters.join(' and '), ")");
}

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __assign, __rest } from "tslib";
var COMPARISON_OPERATORS = ['eq', 'ne', 'gt', 'ge', 'lt', 'le'];

@@ -40,3 +40,3 @@ var LOGICAL_OPERATORS = ['and', 'or', 'not'];

if (key != undefined) {
path += "(" + handleValue(key, aliases) + ")";
path += "(".concat(handleValue(key, aliases), ")");
}

@@ -66,7 +66,7 @@ if (filter || typeof count === 'object')

if (action) {
path += "/" + action;
path += "/".concat(action);
}
if (func) {
if (typeof func === 'string') {
path += "/" + func;
path += "/".concat(func);
}

@@ -76,5 +76,5 @@ else if (typeof func === 'object') {

var funcArgs = handleValue(func[funcName], aliases);
path += "/" + funcName;
path += "/".concat(funcName);
if (funcArgs !== "") {
path += "(" + funcArgs + ")";
path += "(".concat(funcArgs, ")");
}

@@ -86,10 +86,10 @@ }

var _a;
return Object.assign(acc, (_a = {}, _a["@" + alias.name] = handleValue(alias.value), _a));
return Object.assign(acc, (_a = {}, _a["@".concat(alias.name)] = handleValue(alias.value), _a));
}, {}));
}
return buildUrl(path, tslib_1.__assign({ $select: $select, $search: $search, $skiptoken: $skiptoken, $format: $format }, params));
return buildUrl(path, __assign({ $select: $select, $search: $search, $skiptoken: $skiptoken, $format: $format }, params));
}
function renderPrimitiveValue(key, val, aliases) {
if (aliases === void 0) { aliases = []; }
return key + " eq " + handleValue(val, aliases);
return "".concat(key, " eq ").concat(handleValue(val, aliases));
}

@@ -122,2 +122,5 @@ function buildFilter(filters, aliases, propPrefix) {

var value = filter[filterKey];
if (value === undefined) {
return result;
}
var propName = '';

@@ -129,9 +132,9 @@ if (propPrefix) {

else if (INDEXOF_REGEX.test(filterKey)) {
propName = filterKey.replace(INDEXOF_REGEX, function (_, $1) { return $1.trim() === ITEM_ROOT ? "(" + propPrefix + ")" : "(" + propPrefix + "/" + $1.trim() + ")"; });
propName = filterKey.replace(INDEXOF_REGEX, function (_, $1) { return $1.trim() === ITEM_ROOT ? "(".concat(propPrefix, ")") : "(".concat(propPrefix, "/").concat($1.trim(), ")"); });
}
else if (FUNCTION_REGEX.test(filterKey)) {
propName = filterKey.replace(FUNCTION_REGEX, function (_, $1) { return $1.trim() === ITEM_ROOT ? "(" + propPrefix + ")" : "(" + propPrefix + "/" + $1.trim() + ")"; });
propName = filterKey.replace(FUNCTION_REGEX, function (_, $1) { return $1.trim() === ITEM_ROOT ? "(".concat(propPrefix, ")") : "(".concat(propPrefix, "/").concat($1.trim(), ")"); });
}
else {
propName = propPrefix + "/" + filterKey;
propName = "".concat(propPrefix, "/").concat(filterKey);
}

@@ -156,3 +159,3 @@ }

.filter(function (f) { return f; })
.map(function (f) { return (LOGICAL_OPERATORS.indexOf(op_1) !== -1 ? "(" + f + ")" : f); });
.map(function (f) { return (LOGICAL_OPERATORS.indexOf(op_1) !== -1 ? "(".concat(f, ")") : f); });
if (builtFilters.length) {

@@ -165,3 +168,3 @@ if (LOGICAL_OPERATORS.indexOf(op_1) !== -1) {

else {
result.push("(" + builtFilters.join(" " + op_1 + " ") + ")");
result.push("(".concat(builtFilters.join(" ".concat(op_1, " ")), ")"));
}

@@ -171,3 +174,3 @@ }

else {
result.push(builtFilters.join(" " + op_1 + " "));
result.push(builtFilters.join(" ".concat(op_1, " ")));
}

@@ -187,3 +190,3 @@ }

else {
result.push("" + builtFilters.join(" " + op + " "));
result.push("(".concat(builtFilters.join(" ".concat(op, " ")), ")"));
}

@@ -199,4 +202,7 @@ }

operators.forEach(function (op) {
if (value[op] === undefined) {
return;
}
if (COMPARISON_OPERATORS.indexOf(op) !== -1) {
result.push(propName + " " + op + " " + handleValue(value[op], aliases));
result.push("".concat(propName, " ").concat(op, " ").concat(handleValue(value[op], aliases)));
}

@@ -207,3 +213,3 @@ else if (LOGICAL_OPERATORS.indexOf(op) !== -1) {

.map(function (v) { return '(' + buildFilterCore(v, aliases, propName) + ')'; })
.join(" " + op + " "));
.join(" ".concat(op, " ")));
}

@@ -221,3 +227,3 @@ else {

else if (op === 'has') {
result.push(propName + " " + op + " " + handleValue(value[op], aliases));
result.push("".concat(propName, " ").concat(op, " ").concat(handleValue(value[op], aliases)));
}

@@ -235,3 +241,3 @@ else if (op === 'in') {

// Simple boolean functions (startswith, endswith, contains)
result.push(op + "(" + propName + "," + handleValue(value[op], aliases) + ")");
result.push("".concat(op, "(").concat(propName, ",").concat(handleValue(value[op], aliases), ")"));
}

@@ -248,7 +254,4 @@ else {

}
else if (value === undefined) {
// Ignore/omit filter if value is `undefined`
}
else {
throw new Error("Unexpected value type: " + value);
throw new Error("Unexpected value type: ".concat(value));
}

@@ -280,6 +283,6 @@ return result;

}
return tslib_1.__assign({}, acc, item);
return __assign(__assign({}, acc), item);
}, {}) : value;
var filter = buildFilterCore(filterValue, aliases, lambdaParameter);
clause = propName + "/" + op + "(" + (filter ? lambdaParameter + ":" + filter : '') + ")";
clause = "".concat(propName, "/").concat(op, "(").concat(filter ? "".concat(lambdaParameter, ":").concat(filter) : '', ")");
}

@@ -292,3 +295,3 @@ return clause;

var conditionOperator = collectionOperator == 'all' ? 'ne' : 'eq';
clause = propName + "/" + collectionOperator + "(" + lambdaParameter + ": " + lambdaParameter + " " + conditionOperator + " '" + value + "')";
clause = "".concat(propName, "/").concat(collectionOperator, "(").concat(lambdaParameter, ": ").concat(lambdaParameter, " ").concat(conditionOperator, " '").concat(value, "')");
return clause;

@@ -308,3 +311,3 @@ }

if (typeof value === 'string') {
return "'" + escapeIllegalChars(value) + "'";
return "'".concat(escapeIllegalChars(value), "'");
}

@@ -318,3 +321,3 @@ else if (value instanceof Date) {

else if (Array.isArray(value)) {
return "[" + value.map(function (d) { return handleValue(d); }).join(',') + "]";
return "[".concat(value.map(function (d) { return handleValue(d); }).join(','), "]");
}

@@ -330,5 +333,5 @@ else if (value === null) {

case 'duration':
return "duration'" + value.value + "'";
return "duration'".concat(value.value, "'");
case 'binary':
return "binary'" + value.value + "'";
return "binary'".concat(value.value, "'");
case 'alias':

@@ -338,7 +341,7 @@ // Store

aliases.push(value);
return "@" + value.name;
return "@".concat(value.name);
case 'json':
return escape(JSON.stringify(value.value));
case 'decimal':
return value.value + "M";
return "".concat(value.value, "M");
default:

@@ -352,3 +355,3 @@ return Object.entries(value)

var k = _a[0], v = _a[1];
return k + "=" + handleValue(v, aliases);
return "".concat(k, "=").concat(handleValue(v, aliases));
}).join(',');

@@ -374,11 +377,11 @@ }

// Inner-most item
return "$expand=" + item;
return "$expand=".concat(item);
}
else if (index === arr.length - 1) {
// Outer-most item, don't add `$expand=` prefix (added above)
return item + "(" + results + ")";
return "".concat(item, "(").concat(results, ")");
}
else {
// Other items
return "$expand=" + item + "(" + results + ")";
return "$expand=".concat(item, "(").concat(results, ")");
}

@@ -388,3 +391,3 @@ }, '');

else if (Array.isArray(expands)) {
return "" + expands.map(function (e) { return buildExpand(e); }).join(',');
return "".concat(expands.map(function (e) { return buildExpand(e); }).join(','));
}

@@ -407,3 +410,3 @@ else if (typeof expands === 'object') {

case 'top':
value = "" + expands[key];
value = "".concat(expands[key]);
break;

@@ -413,3 +416,3 @@ default:

}
return "$" + key.toLowerCase() + "=" + value;
return "$".concat(key.toLowerCase(), "=").concat(value);
})

@@ -422,3 +425,3 @@ .join(';');

var builtExpand = buildExpand(expands[key]);
return builtExpand ? key + "(" + builtExpand + ")" : key;
return builtExpand ? "".concat(key, "(").concat(builtExpand, ")") : key;
})

@@ -434,3 +437,3 @@ .join(',');

var transformsResult = transformsArray.reduce(function (result, transform) {
var aggregate = transform.aggregate, filter = transform.filter, groupBy = transform.groupBy, rest = tslib_1.__rest(transform, ["aggregate", "filter", "groupBy"]);
var aggregate = transform.aggregate, filter = transform.filter, groupBy = transform.groupBy, rest = __rest(transform, ["aggregate", "filter", "groupBy"]);
// TODO: support as many of the following:

@@ -442,6 +445,6 @@ // topcount, topsum, toppercent,

if (unsupportedKeys.length) {
throw new Error("Unsupported transform(s): " + unsupportedKeys);
throw new Error("Unsupported transform(s): ".concat(unsupportedKeys));
}
if (aggregate) {
result.push("aggregate(" + buildAggregate(aggregate) + ")");
result.push("aggregate(".concat(buildAggregate(aggregate), ")"));
}

@@ -451,7 +454,7 @@ if (filter) {

if (builtFilter) {
result.push("filter(" + buildFilter(builtFilter) + ")");
result.push("filter(".concat(buildFilter(builtFilter), ")"));
}
}
if (groupBy) {
result.push("groupby(" + buildGroupBy(groupBy) + ")");
result.push("groupby(".concat(buildGroupBy(groupBy), ")"));
}

@@ -473,8 +476,8 @@ return result;

if (!aggregateValue.with) {
throw new Error("'with' property required for '" + aggregateKey + "'");
throw new Error("'with' property required for '".concat(aggregateKey, "'"));
}
if (!aggregateValue.as) {
throw new Error("'as' property required for '" + aggregateKey + "'");
throw new Error("'as' property required for '".concat(aggregateKey, "'"));
}
return aggregateKey + " with " + aggregateValue.with + " as " + aggregateValue.as;
return "".concat(aggregateKey, " with ").concat(aggregateValue.with, " as ").concat(aggregateValue.as);
});

@@ -488,5 +491,5 @@ })

}
var result = "(" + groupBy.properties.join(',') + ")";
var result = "(".concat(groupBy.properties.join(','), ")");
if (groupBy.transform) {
result += "," + buildTransforms(groupBy.transform);
result += ",".concat(buildTransforms(groupBy.transform));
}

@@ -502,3 +505,3 @@ return result;

})
.map(function (v) { return "" + prefix + v; }).join(',');
.map(function (v) { return "".concat(prefix).concat(String(v)); }).join(',');
}

@@ -509,7 +512,7 @@ else if (typeof orderBy === 'object') {

var k = _a[0], v = _a[1];
return buildOrderBy(v, k + "/");
return buildOrderBy(v, "".concat(k, "/"));
})
.map(function (v) { return "" + prefix + v; }).join(',');
.map(function (v) { return "".concat(prefix).concat(v); }).join(',');
}
return "" + prefix + orderBy;
return "".concat(prefix).concat(String(orderBy));
}

@@ -520,7 +523,7 @@ function buildUrl(path, params) {

.filter(function (key) { return params[key] !== undefined && params[key] !== ''; })
.map(function (key) { return key + "=" + params[key]; });
return queries.length ? path + "?" + queries.join('&') : path;
.map(function (key) { return "".concat(key, "=").concat(params[key]); });
return queries.length ? "".concat(path, "?").concat(queries.join('&')) : path;
}
function parseNot(builtFilters) {
return "not(" + builtFilters.join(' and ') + ")";
return "not(".concat(builtFilters.join(' and '), ")");
}
{
"name": "odata-query",
"version": "7.0.0",
"version": "7.0.1",
"author": "Sean Lynch <techniq35@gmail.com>",

@@ -30,4 +30,5 @@ "license": "MIT",

"test-watch": "jest --watchAll",
"preversion": "npm run build"
"preversion": "npm run build",
"prepublish": "npm run build"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc