{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/ts-loader/index.js!/data/src/dao/V2FilterProcessor.ts","dependencies":[{"path":"/data/src/dao/V2FilterProcessor.ts","mtime":1553611371628},{"path":"/data/node_modules/typescript-logging/dist/commonjs/typescript-logging.d.ts","mtime":1553611387808},{"path":"/data/node_modules/typescript-logging/dist/commonjs/control/LogGroupControl.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/control/CategoryServiceControl.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/MessagesToExtensionJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/MessagesFromExtensionJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/ExtensionMessageJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/AbstractCategoryLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/LoggerOptions.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryService.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryConsoleLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryDelegateLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryMessageBufferImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/Logger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactory.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactoryService.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactoryRuntimeSettings.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/AbstractLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/ConsoleLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/MessageBufferLoggerImpl.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/DataStructures.d.ts","mtime":1553611387936},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/JSONHelper.d.ts","mtime":1553611387936},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/MessageUtils.d.ts","mtime":1553611387936},{"path":"/data/node_modules/moment/moment.d.ts","mtime":1553611386704},{"path":"/data/node_modules/axios/index.d.ts","mtime":1553611386356},{"path":"/data/typings/index.d.ts","mtime":1553611371628},{"path":"/data/node_modules/@types/fs-extra/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/node/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/node/inspector.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/glob/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/minimatch/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/glob/node_modules/@types/minimatch/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/handlebars/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/highlight.js/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/jest/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/jquery/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/lodash/index.d.ts","mtime":1553611386320},{"path":"/data/node_modules/@types/lodash/common/common.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/array.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/collection.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/date.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/function.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/lang.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/math.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/number.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/object.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/seq.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/string.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/util.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/marked/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/shelljs/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/urijs/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/typescript/lib/lib.es2015.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.core.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.collection.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.generator.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.promise.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.iterable.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.symbol.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.proxy.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.reflect.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es5.d.ts","mtime":1553611387388},{"path":"/data/node_modules/typescript/lib/lib.dom.d.ts","mtime":1553611387384},{"path":"/data/src/internal/IHash.ts","mtime":1553611371628},{"path":"/data/src/internal/Util.ts","mtime":1553611371628},{"path":"/data/src/api/IFilterProcessor.ts","mtime":1553611371624},{"path":"/data/src/api/Filter.ts","mtime":1553611371624},{"path":"/data/src/api/Comparator.ts","mtime":1553611371624},{"path":"/data/src/api/Restriction.ts","mtime":1553611371624},{"path":"/data/src/api/NestedRestriction.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsError.ts","mtime":1553611371624},{"path":"/data/src/api/Operator.ts","mtime":1553611371624},{"path":"/data/src/api/Clause.ts","mtime":1553611371624},{"path":"/data/src/api/SearchPropertyType.ts","mtime":1553611371628},{"path":"/data/src/dao/ISearchPropertyAccessor.ts","mtime":1553611371628},{"path":"/data/.babelrc","mtime":1553611371556},{"path":"/data/node_modules/cache-loader/dist/cjs.js","mtime":1553611387012},{"path":"/data/node_modules/babel-loader/lib/index.js","mtime":1553611386992},{"path":"/data/node_modules/ts-loader/index.js","mtime":1553611386824}],"contextDependencies":[],"result":["\"use strict\";\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Util_1 = require(\"../internal/Util\");\nvar Comparator_1 = require(\"../api/Comparator\");\nvar NestedRestriction_1 = require(\"../api/NestedRestriction\");\nvar OnmsError_1 = require(\"../api/OnmsError\");\nvar Operator_1 = require(\"../api/Operator\");\nvar SearchPropertyType_1 = require(\"../api/SearchPropertyType\");\n/**\n * Converts a [[Filter]] into ReSTv2 FIQL parameters.\n * @module V2FilterProcessor\n */\n\nvar V2FilterProcessor = function () {\n    function V2FilterProcessor(searchPropertyAccessor) {\n        _classCallCheck(this, V2FilterProcessor);\n\n        this.searchPropertyAccessor = searchPropertyAccessor;\n    }\n    /** Given a filter, return a hash of URL parameters. */\n\n\n    _createClass(V2FilterProcessor, [{\n        key: \"getParameters\",\n        value: function getParameters(filter) {\n            var ret = {};\n            if (filter.limit !== undefined) {\n                ret.limit = '' + filter.limit;\n            }\n            var search = this.toFIQL(filter.clauses);\n            if (search.length > 0) {\n                ret._s = search;\n            }\n            return ret;\n        }\n        /**\n         * Given a comparator, convert it to a correspond comparator\n         * that can be used in the FIQL expression.\n         */\n\n    }, {\n        key: \"toFIQLComparator\",\n        value: function toFIQLComparator(comparator) {\n            switch (comparator) {\n                case Comparator_1.Comparators.EQ:\n                case Comparator_1.Comparators.NULL:\n                    return '==';\n                case Comparator_1.Comparators.NE:\n                case Comparator_1.Comparators.NOTNULL:\n                    return '!=';\n                case Comparator_1.Comparators.GT:\n                    return '=gt=';\n                case Comparator_1.Comparators.LT:\n                    return '=lt=';\n                case Comparator_1.Comparators.GE:\n                    return '=ge=';\n                case Comparator_1.Comparators.LE:\n                    return '=le=';\n                case Comparator_1.Comparators.LIKE:\n                    return '==';\n                case Comparator_1.Comparators.ILIKE:\n                default:\n                    throw new OnmsError_1.OnmsError('Unsupported comparator type: ' + comparator);\n            }\n        }\n        /** Given a restriction, compute the value to use in the FIQL expression. */\n\n    }, {\n        key: \"toFIQLValue\",\n        value: function toFIQLValue(restriction) {\n            switch (restriction.comparator) {\n                case Comparator_1.Comparators.NULL:\n                case Comparator_1.Comparators.NOTNULL:\n                    return restriction.value === undefined ? V2FilterProcessor.NULL_VALUE : encodeURIComponent(restriction.value);\n                default:\n                    if (restriction.value === 'null' || restriction.value === void 0) {\n                        var property = this.searchPropertyAccessor.getProperty(restriction.attribute);\n                        if (property && property.type === SearchPropertyType_1.SearchPropertyTypes.TIMESTAMP) {\n                            return V2FilterProcessor.NULL_DATE_ENCODED;\n                        }\n                        return V2FilterProcessor.NULL_VALUE;\n                    }\n                    return encodeURIComponent(this.applyDateConversion(restriction.value));\n            }\n        }\n        /** Given an operator, convert it to the corresponding FIQL operator. */\n\n    }, {\n        key: \"toFIQLOperator\",\n        value: function toFIQLOperator(operator) {\n            switch (operator) {\n                case Operator_1.Operators.AND:\n                    return ';';\n                case Operator_1.Operators.OR:\n                    return ',';\n                default:\n                    throw new OnmsError_1.OnmsError('Unsupported operator type: ' + operator);\n            }\n        }\n        /** Given a list of clauses, recursively generate the FIQL query string. */\n\n    }, {\n        key: \"toFIQL\",\n        value: function toFIQL(clauses) {\n            var search = '';\n            var _iteratorNormalCompletion = true;\n            var _didIteratorError = false;\n            var _iteratorError = undefined;\n\n            try {\n                for (var _iterator = clauses[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n                    var clause = _step.value;\n\n                    if (search.length > 0) {\n                        search += this.toFIQLOperator(clause.operator);\n                    }\n                    if (clause.restriction instanceof NestedRestriction_1.NestedRestriction) {\n                        search += '(' + this.toFIQL(clause.restriction.clauses) + ')';\n                    } else {\n                        var restriction = clause.restriction;\n                        var comp = this.toFIQLComparator(restriction.comparator);\n                        var value = this.toFIQLValue(restriction);\n                        search += [restriction.attribute, comp, value].join('');\n                    }\n                }\n            } catch (err) {\n                _didIteratorError = true;\n                _iteratorError = err;\n            } finally {\n                try {\n                    if (!_iteratorNormalCompletion && _iterator.return) {\n                        _iterator.return();\n                    }\n                } finally {\n                    if (_didIteratorError) {\n                        throw _iteratorError;\n                    }\n                }\n            }\n\n            return search;\n        }\n        /**\n         * If the given value is a date value, it is converted to be properly parsed by the OpenNMS ReST API,\n         * otherwise it is not modified.\n         *\n         * @param value Any value which may need conversion.\n         */\n\n    }, {\n        key: \"applyDateConversion\",\n        value: function applyDateConversion(value) {\n            if (Util_1.Util.isDateObject(value)) {\n                return Util_1.Util.toDateString(value);\n            }\n            return value;\n        }\n    }]);\n\n    return V2FilterProcessor;\n}();\n/** Constant used to represent null values in the V2 API. */\n\n\nV2FilterProcessor.NULL_VALUE = \"\\0\";\n/** Constant used to represent null dates in the V2 API.\n *  This must be explicitly set as the restriction value when using\n *  either the NULL or NOTNULL comparators on date fields.\n */\nV2FilterProcessor.NULL_DATE = '1970-01-01T00:00:00.000+0000';\n/**\n * pre-encoded to avoid running `encodeURIComponent` every time we deal with a null date\n * @hidden\n */\nV2FilterProcessor.NULL_DATE_ENCODED = encodeURIComponent(V2FilterProcessor.NULL_DATE);\nexports.V2FilterProcessor = V2FilterProcessor;",{"version":3,"file":"/data/src/dao/V2FilterProcessor.ts","sourceRoot":"","sources":["/data/src/dao/V2FilterProcessor.ts"],"names":[],"mappings":";;;;;;;AACA,qBAAsC;AAKtC,2BAA0D;AAE1D,kCAA2D;AAC3D,0BAA2C;AAC3C,yBAAoD;AAEpD,mCAA8D;AAG9D,AAGG,AACH;;;;;;AAoBE,+BAAY,AAAgD;;;AACxD,AAAI,aAAC,AAAsB,yBAAG,AAAsB,AAAC,AACzD;AAAC;AAED,AAAuD,AAChD,AAAa;;;;;sCAAC,AAAc;AAC/B,gBAAM,AAAG,MAAG,AAAmB,AAAC;AAEhC,AAAE,AAAC,gBAAC,AAAM,OAAC,AAAK,UAAK,AAAS,AAAC,WAAC,AAAC;AAC7B,AAAG,oBAAC,AAAK,QAAG,AAAE,KAAG,AAAM,OAAC,AAAK,AAAC,AAClC;AAAC;AAED,gBAAM,AAAM,SAAG,AAAI,KAAC,AAAM,OAAC,AAAM,OAAC,AAAO,AAAC,AAAC;AAC3C,AAAE,AAAC,gBAAC,AAAM,OAAC,AAAM,SAAG,AAAC,AAAC,GAAC,AAAC;AACpB,AAAG,oBAAC,AAAE,KAAG,AAAM,AAAC,AACpB;AAAC;AAED,AAAM,mBAAC,AAAG,AAAC,AACf;AAAC;AA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ACN,4BAAM,AAAW,cAAG,AAAM,OAAC,AAA0B,AAAC;AACtD,4BAAM,AAAI,OAAG,AAAI,KAAC,AAAgB,iBAAC,AAAW,YAAC,AAAU,AAAC,AAAC;AAC3D,4BAAM,AAAK,QAAG,AAAI,KAAC,AAAW,YAAC,AAAW,AAAC,AAAC;AAC5C,AAAM,kCAAI,CAAC,AAAW,YAAC,AAAS,WAAE,AAAI,MAAE,AAAK,AAAC,OAAC,AAAI,KAAC,AAAE,AAAC,AAAC,AAC1D;AAAC,AACH;AAAC;;;;;;;;;;;;;;;;AACD,AAAM,mBAAC,AAAM,AAAC,AAChB;AAAC;AAEF,AAKG,AACM,AAAmB;;;;;;;;;4CAAC,AAAU;AAClC,AAAE,AAAC,gBAAC,OAAI,KAAC,AAAY,aAAC,AAAK,AAAC,AAAC,QAAC,AAAC;AAC3B,AAAM,uBAAC,OAAI,KAAC,AAAY,aAAC,AAAK,AAAC,AAAC,AACpC;AAAC;AACD,AAAM,mBAAC,AAAK,AAAC,AACjB;AAAC;;;;;AA/HD,AAA4D;;;AAC9C,kBAAU,aAAG,AAAQ,AAAC;AAEpC,AAGG;;;;AACW,kBAAS,YAAG,AAA8B,AAAC;AAEzD,AAGG;;;;AACY,kBAAiB,oBAAG,AAAkB,mBAAC,AAAiB,kBAAC,AAAS,AAAC,AAAC;AAfrF,4BAkIC","sourcesContent":["import {IHash} from '../internal/IHash';\nimport {Util} from '../internal/Util';\n\nimport {IFilterProcessor} from '../api/IFilterProcessor';\n\nimport {Filter} from '../api/Filter';\nimport {Comparator, Comparators} from '../api/Comparator';\nimport {Restriction} from '../api/Restriction';\nimport {NestedRestriction} from '../api/NestedRestriction';\nimport {OnmsError} from '../api/OnmsError';\nimport {Operator, Operators} from '../api/Operator';\nimport {Clause} from '../api/Clause';\nimport {SearchPropertyTypes} from '../api/SearchPropertyType';\nimport {ISearchPropertyAccessor} from './ISearchPropertyAccessor';\n\n/**\n * Converts a [[Filter]] into ReSTv2 FIQL parameters.\n * @module V2FilterProcessor\n */\nexport class V2FilterProcessor implements IFilterProcessor {\n\n  /** Constant used to represent null values in the V2 API. */\n  public static NULL_VALUE = '\\u0000';\n\n  /** Constant used to represent null dates in the V2 API.\n   *  This must be explicitly set as the restriction value when using\n   *  either the NULL or NOTNULL comparators on date fields.\n   */\n  public static NULL_DATE = '1970-01-01T00:00:00.000+0000';\n\n  /**\n   * pre-encoded to avoid running `encodeURIComponent` every time we deal with a null date\n   * @hidden\n   */\n  private static NULL_DATE_ENCODED = encodeURIComponent(V2FilterProcessor.NULL_DATE);\n\n  /** The accessor for Properties */\n  private searchPropertyAccessor: ISearchPropertyAccessor;\n\n  constructor(searchPropertyAccessor?: ISearchPropertyAccessor) {\n      this.searchPropertyAccessor = searchPropertyAccessor;\n  }\n\n  /** Given a filter, return a hash of URL parameters. */\n  public getParameters(filter: Filter) {\n      const ret = {} as IHash<string>;\n\n      if (filter.limit !== undefined) {\n          ret.limit = '' + filter.limit;\n      }\n\n      const search = this.toFIQL(filter.clauses);\n      if (search.length > 0) {\n          ret._s = search;\n      }\n\n      return ret;\n  }\n\n  /**\n   * Given a comparator, convert it to a correspond comparator\n   * that can be used in the FIQL expression.\n   */\n  private toFIQLComparator(comparator: Comparator) {\n    switch (comparator) {\n      case Comparators.EQ:\n      case Comparators.NULL:\n        return '==';\n      case Comparators.NE:\n      case Comparators.NOTNULL:\n        return '!=';\n      case Comparators.GT:\n        return '=gt=';\n      case Comparators.LT:\n        return '=lt=';\n      case Comparators.GE:\n        return '=ge=';\n      case Comparators.LE:\n        return '=le=';\n      case Comparators.LIKE:\n        return '==';\n      case Comparators.ILIKE:\n      default:\n        throw new OnmsError('Unsupported comparator type: ' + comparator);\n    }\n  }\n\n  /** Given a restriction, compute the value to use in the FIQL expression. */\n  private toFIQLValue(restriction: Restriction) {\n    switch (restriction.comparator) {\n      case Comparators.NULL:\n      case Comparators.NOTNULL:\n          return restriction.value === undefined ? V2FilterProcessor.NULL_VALUE : encodeURIComponent(restriction.value);\n      default:\n          if (restriction.value === 'null' || restriction.value === void 0) {\n              const property = this.searchPropertyAccessor.getProperty(restriction.attribute);\n              if (property && property.type === SearchPropertyTypes.TIMESTAMP) {\n                  return V2FilterProcessor.NULL_DATE_ENCODED;\n              }\n              return V2FilterProcessor.NULL_VALUE;\n          }\n          return encodeURIComponent(this.applyDateConversion(restriction.value));\n    }\n  }\n\n  /** Given an operator, convert it to the corresponding FIQL operator. */\n  private toFIQLOperator(operator: Operator) {\n    switch (operator) {\n      case Operators.AND:\n        return ';';\n      case Operators.OR:\n        return ',';\n      default:\n        throw new OnmsError('Unsupported operator type: ' + operator);\n    }\n  }\n\n  /** Given a list of clauses, recursively generate the FIQL query string. */\n  private toFIQL(clauses: Clause[]) {\n    let search = '';\n    for (const clause of clauses) {\n      if (search.length > 0) {\n        search += this.toFIQLOperator(clause.operator);\n      }\n\n      if (clause.restriction instanceof NestedRestriction) {\n        search += '(' + this.toFIQL(clause.restriction.clauses) + ')';\n      } else {\n        const restriction = clause.restriction as Restriction;\n        const comp = this.toFIQLComparator(restriction.comparator);\n        const value = this.toFIQLValue(restriction);\n        search += [restriction.attribute, comp, value].join('');\n      }\n    }\n    return search;\n  }\n\n /**\n  * If the given value is a date value, it is converted to be properly parsed by the OpenNMS ReST API,\n  * otherwise it is not modified.\n  *\n  * @param value Any value which may need conversion.\n  */\n  private applyDateConversion(value: any): any {\n      if (Util.isDateObject(value)) {\n          return Util.toDateString(value);\n      }\n      return value;\n  }\n}\n"]}]}