opennms
Version:
Client API for the OpenNMS network monitoring platform
1 lines • 17 kB
JSON
{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/ts-loader/index.js!/data/src/dao/V1FilterProcessor.ts","dependencies":[{"path":"/data/src/dao/V1FilterProcessor.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/OnmsEnum.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/Operator.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsError.ts","mtime":1553611371624},{"path":"/data/src/api/Restriction.ts","mtime":1553611371624},{"path":"/data/src/api/NestedRestriction.ts","mtime":1553611371624},{"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 OnmsEnum_1 = require(\"../internal/OnmsEnum\");\nvar Util_1 = require(\"../internal/Util\");\nvar Comparator_1 = require(\"../api/Comparator\");\nvar Operator_1 = require(\"../api/Operator\");\nvar OnmsError_1 = require(\"../api/OnmsError\");\nvar NestedRestriction_1 = require(\"../api/NestedRestriction\");\n/** @hidden */\nvar nonExclusiveComparators = [Comparator_1.Comparators.NULL, Comparator_1.Comparators.NOTNULL];\n/** @hidden */\nvar isExclusive = function isExclusive(comparator) {\n return nonExclusiveComparators.indexOf(comparator) < 0;\n};\n/**\n * Converts a [[Filter]] into ReSTv1 parameters.\n * @module V1FilterProcessor\n */\n\nvar V1FilterProcessor = function () {\n function V1FilterProcessor() {\n _classCallCheck(this, V1FilterProcessor);\n }\n\n _createClass(V1FilterProcessor, [{\n key: \"getParameters\",\n\n /** Given a filter, return a hash of URL parameters. */\n value: function getParameters(filter) {\n var ret = {};\n if (filter.limit !== undefined) {\n ret.limit = '' + filter.limit;\n }\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = filter.clauses[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var clause = _step.value;\n\n if (clause.operator !== Operator_1.Operators.OR) {\n throw new OnmsError_1.OnmsError('V1 only supports OR operators!');\n }\n if (clause.restriction instanceof NestedRestriction_1.NestedRestriction) {\n throw new OnmsError_1.OnmsError('V1 does not support nested restrictions!');\n }\n var restriction = clause.restriction;\n switch (restriction.comparator) {\n case Comparator_1.Comparators.NULL:\n {\n ret[restriction.attribute] = 'null';\n break;\n }\n case Comparator_1.Comparators.NOTNULL:\n {\n ret[restriction.attribute] = 'notnull';\n break;\n }\n default:\n {\n var comp = restriction.comparator.label.toLowerCase();\n if (ret.comparator && ret.comparator !== comp) {\n throw new OnmsError_1.OnmsError('V1 only supports one restriction comparator type!');\n }\n ret.comparator = comp;\n if (restriction.value instanceof OnmsEnum_1.OnmsEnum) {\n ret[restriction.attribute] = restriction.value.label;\n } else if (Util_1.Util.isDateObject(restriction.value)) {\n ret[restriction.attribute] = Util_1.Util.toDateString(restriction.value);\n } else {\n ret[restriction.attribute] = '' + restriction.value;\n }\n }\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 ret;\n }\n }]);\n\n return V1FilterProcessor;\n}();\n\nexports.V1FilterProcessor = V1FilterProcessor;",{"version":3,"file":"/data/src/dao/V1FilterProcessor.ts","sourceRoot":"","sources":["/data/src/dao/V1FilterProcessor.ts"],"names":[],"mappings":";;;;;;;AACA,yBAA8C;AAC9C,qBAAsC;AAKtC,2BAA8C;AAC9C,yBAA0C;AAC1C,0BAA2C;AAE3C,kCAA2D;AAE3D,AAAc;AACd,IAAM,AAAuB,0BAAG,CAC9B,aAAW,YAAC,AAAI,MAChB,aAAW,YAAC,AAAO,AACpB,AAAC;AAEF,AAAc;AACd,IAAM,AAAW,cAAG,qBAAC,AAAU,AAAE,AAAE;AACjC,AAAM,WAAC,AAAuB,wBAAC,AAAO,QAAC,AAAU,AAAC,cAAG,AAAC,AAAC,AACzD;AAAC,AAAC;AAEF,AAGG,AACH;;;;;;;;;;;;;AACE,AAAuD,AAChD,AAAa;sCAAC,AAAc;AACjC,gBAAM,AAAG,MAAG,AAAmB,AAAC;AAEhC,AAAE,AAAC,gBAAC,AAAM,OAAC,AAAK,UAAK,AAAS,AAAC,WAAC,AAAC;AAC/B,AAAG,oBAAC,AAAK,QAAG,AAAE,KAAG,AAAM,OAAC,AAAK,AAAC,AAChC;AAAC;;;;;;AAED,AAAG,AAAC,AAAC,qCAAgB,AAAM,OAAC,AAAO,AAAC;AAAC,AAAC,wBAA3B,AAAM;;AACf,AAAE,AAAC,wBAAC,AAAM,OAAC,AAAQ,aAAK,WAAS,UAAC,AAAE,AAAC,IAAC,AAAC;AACrC,8BAAM,IAAI,YAAS,UAAC,AAAgC,AAAC,AAAC,AACxD;AAAC;AAED,AAAE,AAAC,wBAAC,AAAM,OAAC,AAAW,uBAAY,oBAAiB,AAAC,mBAAC,AAAC;AACpD,8BAAM,IAAI,YAAS,UAAC,AAA0C,AA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AAAC,AACH;;AAAC;;;;;;;;;;;;;;;;AAED,AAAM,mBAAC,AAAG,AAAC,AACb;AAAC,AACF;;;;;;AA/CD,4BA+CC","sourcesContent":["import {IHash} from '../internal/IHash';\nimport {OnmsEnum} from '../internal/OnmsEnum';\nimport {Util} from '../internal/Util';\n\nimport {IFilterProcessor} from '../api/IFilterProcessor';\n\nimport {Filter} from '../api/Filter';\nimport {Comparators} from '../api/Comparator';\nimport {Operators} from '../api/Operator';\nimport {OnmsError} from '../api/OnmsError';\nimport {Restriction} from '../api/Restriction';\nimport {NestedRestriction} from '../api/NestedRestriction';\n\n/** @hidden */\nconst nonExclusiveComparators = [\n Comparators.NULL,\n Comparators.NOTNULL,\n];\n\n/** @hidden */\nconst isExclusive = (comparator) => {\n return nonExclusiveComparators.indexOf(comparator) < 0;\n};\n\n/**\n * Converts a [[Filter]] into ReSTv1 parameters.\n * @module V1FilterProcessor\n */\nexport class V1FilterProcessor implements IFilterProcessor {\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 for (const clause of filter.clauses) {\n if (clause.operator !== Operators.OR) {\n throw new OnmsError('V1 only supports OR operators!');\n }\n\n if (clause.restriction instanceof NestedRestriction) {\n throw new OnmsError('V1 does not support nested restrictions!');\n }\n\n const restriction = clause.restriction as Restriction;\n switch (restriction.comparator) {\n case Comparators.NULL: {\n ret[restriction.attribute] = 'null';\n break;\n }\n case Comparators.NOTNULL: {\n ret[restriction.attribute] = 'notnull';\n break;\n }\n default: {\n const comp = restriction.comparator.label.toLowerCase();\n if (ret.comparator && ret.comparator !== comp) {\n throw new OnmsError('V1 only supports one restriction comparator type!');\n }\n ret.comparator = comp;\n if (restriction.value instanceof OnmsEnum) {\n ret[restriction.attribute] = (restriction.value as OnmsEnum<any>).label;\n } else if (Util.isDateObject(restriction.value)) {\n ret[restriction.attribute] = Util.toDateString(restriction.value);\n } else {\n ret[restriction.attribute] = '' + restriction.value;\n }\n }\n }\n }\n\n return ret;\n }\n}\n"]}]}