diff --git a/.travis.yml b/.travis.yml index 636b8e3ed..e121959d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ before_install: language: node_js node_js: - - "6.0" + - "10.0" - "4.2" - "0.12" - "0.10" diff --git a/client/splunk.js b/client/splunk.js index caa304908..7648b0729 100644 --- a/client/splunk.js +++ b/client/splunk.js @@ -10545,11 +10545,11 @@ exports.XMLParser = XMLParser; }); -require.define("/node_modules/elementtree/node_modules/sax/package.json", function (require, module, exports, __dirname, __filename) { +require.define("/node_modules/sax/package.json", function (require, module, exports, __dirname, __filename) { module.exports = {"main":"lib/sax.js"} }); -require.define("/node_modules/elementtree/node_modules/sax/lib/sax.js", function (require, module, exports, __dirname, __filename) { +require.define("/node_modules/sax/lib/sax.js", function (require, module, exports, __dirname, __filename) { // wrapper for non-node envs ;(function (sax) { diff --git a/client/splunk.min.js b/client/splunk.min.js index 4b69c29a5..b2856de72 100644 --- a/client/splunk.min.js +++ b/client/splunk.min.js @@ -2,6 +2,6 @@ var __exportName = 'splunkjs'; -var require=function(a,b){var c=require.resolve(a,b||"/"),d=require.modules[c];if(!d)throw new Error("Failed to resolve module "+a+", tried "+c);var e=d._cached?d._cached:d();return e};require.paths=[],require.modules={},require.extensions=[".js",".coffee"],require._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},require.resolve=function(){return function(a,b){function g(a){if(require.modules[a])return a;for(var b=0;b=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";d.push(f)}return d}b||(b="/");if(require._core[a])return a;var c=require.modules.path();b=c.resolve("/",b);var d=b||"/";if(a.match(/^(?:\.\.?\/|\/)/)){var e=g(c.resolve(d,a))||h(c.resolve(d,a));if(e)return e}var f=i(a,d);if(f)return f;throw new Error("Cannot find module '"+a+"'")}}(),require.alias=function(a,b){var c=require.modules.path(),d=null;try{d=require.resolve(a+"/package.json","/")}catch(e){d=require.resolve(a,"/")}var f=c.dirname(d),g=(Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b})(require.modules);for(var h=0;h0){var c=a.shift();c()}}},!0),function(c){b?(a.push(c),window.postMessage("browserify-tick","*")):setTimeout(c,0)}}()),process.title||(process.title="browser"),process.binding||(process.binding=function(a){if(a==="evals")return require("vm");throw new Error("No such module")}),process.cwd||(process.cwd=function(){return"."}),require.define("path",function(a,b,c,d,e){function f(a,b){var c=[];for(var d=0;d=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var h=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var a="",b=!1;for(var c=arguments.length;c>=-1&&!b;c--){var d=c>=0?arguments[c]:process.cwd();if(typeof d!="string"||!d)continue;a=d+"/"+a,b=d.charAt(0)==="/"}return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=a.charAt(0)==="/",c=a.slice(-1)==="/";return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),!a&&!b&&(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(f(a,function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var b=h.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=h.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return h.exec(a)[3]||""}}),require.define("/package.json",function(a,b,c,d,e){b.exports={main:"index.js"}}),require.define("/index.js",function(a,b,c,d,e){(function(){var d=c||this;process.env=process.env||{},b.exports=d={Logger:a("./lib/log").Logger,Context:a("./lib/context"),Service:a("./lib/service"),Http:a("./lib/http"),Utils:a("./lib/utils"),Async:a("./lib/async"),Paths:a("./lib/paths").Paths,Class:a("./lib/jquery.class").Class,ModularInputs:a("./lib/modularinputs")},typeof window=="undefined"&&(d.NodeHttp=a("./lib/platform/node/node_http").NodeHttp)})()}),require.define("/lib/log.js",function(a,b,c,d,e){(function(){"use strict";var b=a("./utils"),d=c||this,e={ALL:4,INFO:3,WARN:2,ERROR:1,NONE:0},f=function(a){b.isString(a)&&e.hasOwnProperty(a)?process.env.LOG_LEVEL=e[a]:!isNaN(parseInt(a,10))&&b.keyOf(parseInt(a,10),e)?process.env.LOG_LEVEL=a:process.env.LOG_LEVEL=e.ERROR};process.env.LOG_LEVEL?f(process.env.LOG_LEVEL):process.env.LOG_LEVEL=e.ERROR;var g,h,i,j;g=h=i=j=function(){};if(typeof console!="undefined"){var k=function(a){return function(b){try{console[a].apply(console,arguments)}catch(c){console[a](b)}}};console.log&&(g=k("log")),console.error&&(i=k("error")),console.warn&&(h=k("warn")),console.info&&(j=k("info"))}c.Logger={log:function(){process.env.LOG_LEVEL>=e.ALL&&g.apply(null,arguments)},error:function(){process.env.LOG_LEVEL>=e.ERROR&&i.apply(null,arguments)},warn:function(){process.env.LOG_LEVEL>=e.WARN&&h.apply(null,arguments)},info:function(){process.env.LOG_LEVEL>=e.INFO&&j.apply(null,arguments)},printMessages:function(a){a=a||[];for(var b=0;b=0},e.startsWith=function(a,b){var c=a.match("^"+b);return c&&c.length>0&&c[0]===b},e.endsWith=function(a,b){var c=a.match(b+"$");return c&&c.length>0&&c[0]===b};var f=Object.prototype.toString;e.toArray=function(a){return Array.prototype.slice.call(a)},e.isArray=Array.isArray||function(a){return f.call(a)==="[object Array]"},e.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},e.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)},e.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},e.isObject=function(a){return a===Object(a)},e.isEmpty=function(a){if(e.isArray(a)||e.isString(a))return a.length===0;for(var b in a)if(this.hasOwnProperty.call(a,b))return!1;return!0},e.forEach=function(a,b,c){if(a===null)return;if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;dh)return 1}return 0}}),h.Sharing={USER:"user",APP:"app",GLOBAL:"global",SYSTEM:"system"}})()}),require.define("/lib/paths.js",function(a,b,c,d,e){(function(){"use strict";var a=c||this;a.Paths={apps:"/services/apps/local",capabilities:"authorization/capabilities",configurations:"configs",dataModels:"datamodel/model",deploymentClient:"deployment/client",deploymentServers:"deployment/server",deploymentServerClasses:"deployment/serverclass",deploymentTenants:"deployment/tenants",eventTypes:"saved/eventtypes",firedAlerts:"alerts/fired_alerts",indexes:"data/indexes",info:"/services/server/info",inputs:null,jobs:"search/jobs",licenseGroups:"licenser/groups",licenseMessages:"licenser/messages",licensePools:"licenser/pools",licenseSlaves:"licenser/slaves",licenseStacks:"licenser/stacks",licenses:"licenser/licenses",loggers:"server/logger",login:"/services/auth/login",messages:"messages",passwords:"admin/passwords",parser:"search/parser",pivot:"datamodel/pivot",properties:"properties",roles:"authorization/roles",savedSearches:"saved/searches",settings:"server/settings",storagePasswords:"storage/passwords",users:"/services/authentication/users",typeahead:"search/typeahead",views:"data/ui/views",currentUser:"/services/authentication/current-context",submitEvent:"/services/receivers/simple"}})()}),require.define("/lib/jquery.class.js",function(a,b,c,d,e){(function(){var a=c||this,b=!1,d=/xyz/.test(function(){return xyz})?/\b_super\b/:/.*/;a.Class=function(){},a.Class.extend=function(a){function g(){!b&&this.init&&this.init.apply(this,arguments)}var c=this.prototype;b=!0;var e=new this;b=!1;for(var f in a)e[f]=typeof a[f]=="function"&&typeof c[f]=="function"&&d.test(a[f])?function(a,b){return function(){var d=this._super;this._super=c[a];var e=b.apply(this,arguments);return this._super=d,e}}(f,a[f]):a[f];return g.prototype=e,g.constructor=g,g.extend=arguments.callee,g}})()}),require.define("/lib/http.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./jquery.class").Class,e=a("./log").Logger,f=a("./utils"),g=a("cookie"),h=c||this,i=null,j={5:function(a){var b=a.query||{},c=a.post||{},d=b.output_mode||c.output_mode||"json";return f.startsWith(d,"json")||(d="json"),b.output_mode=d,b},4:function(a){return a.query||{}},"default":function(a){return j[5](a)},none:function(a){return a.query||{}}};b.exports=h=i=d.extend({init:function(){this.get=f.bind(this,this.get),this.del=f.bind(this,this.del),this.post=f.bind(this,this.post),this.request=f.bind(this,this.request),this._buildResponse=f.bind(this,this._buildResponse),this._setSplunkVersion("none"),this._cookieStore={}},_setSplunkVersion:function(a){this.version=a},_getCookieString:function(){var a="";return f.forEach(this._cookieStore,function(b,c){a+=c,a+="=",a+=b,a+="; "}),a},_parseCookieHeader:function(a){var b=g.parse(a),c={};return f.forEach(b,function(a,b){if(c.key)return;c.key=b,c.value=a}),c},get:function(a,b,c,d,e){var f={method:"GET",headers:b,timeout:d,query:c};return this.request(a,f,e)},post:function(a,b,c,d,e){b["Content-Type"]="application/x-www-form-urlencoded";var f={method:"POST",headers:b,timeout:d,post:c};return this.request(a,f,e)},del:function(a,b,c,d,e){var f={method:"DELETE",headers:b,timeout:d,query:c};return this.request(a,f,e)},request:function(a,b,c){var d=this,e=function(a){c=c||function(){};var b=a.response.headers["set-cookie"];b&&f.forEach(b,function(a){var b=d._parseCookieHeader(a);d._cookieStore[b.key]=b.value}),a.status<400&&a.status!=="abort"?c(null,a):c(a)},g=f.getWithVersion(this.version,j)(b),h=b.post||{},k=a+"?"+i.encode(g),l=b.body?b.body:i.encode(h),m=d._getCookieString();m.length!==0&&(b.headers.Cookie=m,delete b.headers.Authorization);var n={method:b.method,headers:b.headers,timeout:b.timeout,body:l};return this.makeRequest(k,n,e)},makeRequest:function(a,b,c){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},parseJson:function(a){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},_buildResponse:function(a,b,c){var d,g={},h=null;b&&b.headers&&(h=f.trim(b.headers["content-type"]||b.headers["Content-Type"]||b.headers["Content-type"]||b.headers.contentType));if(f.startsWith(h,"application/json")&&c)try{g=this.parseJson(c)||{}}catch(i){e.error("Error in parsing JSON:",c,i),g=c}else g=c;return g&&e.printMessages(g.messages),d={response:b,status:b?b.statusCode:0,data:g,error:a},d}}),i.encode=function(a){var b="";for(var c in a)if(a.hasOwnProperty(c)){b&&b[b.length-1]!=="&"&&(b+="&");var d=a[c];if(d instanceof Array)for(var e=0;e1&&!b)throw new Error("Ambiguous match for name '"+a+"'");for(var e=0;e","<=",">=","is","isNull","isNotNull"],ipv4:["is","isNull","isNotNull","contains","doesNotContain","startsWith"]},_binning:["auto","year","month","day","hour","minute","second"],_sortDirection:["ASCENDING","DESCENDING","DEFAULT"],_statsFunctions:["list","values","first","last","count","dc","sum","average","max","min","stdev","duration","earliest","latest"],init:function(a){this.dataModelObject=a,this.columns=[],this.rows=[],this.filters=[],this.cells=[],this.accelerationNamespace=a.dataModel.isAccelerated()?a.dataModel.name:null,this.run=i.bind(this,this.run),this.pivot=i.bind(this,this.pivot)},setAccelerationJob:function(a){a&&a instanceof k.Job&&(a=a.sid);if(!a)throw new Error("Sid to use for acceleration must not be null.");return this.accelerationNamespace="sid="+a,this},addFilter:function(a,b,c,d){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add filter on a nonexistent field.");if(b!==this.dataModelObject.fieldByName(a).type)throw new Error("Cannot add "+b+" filter on "+a+" because it is of type "+this.dataModelObject.fieldByName(a).type);if(!i.contains(this._comparisons[b],c))throw new Error("Cannot add "+b+" filter because "+c+" is not a valid comparison operator");var e={fieldName:a,owner:this.dataModelObject.fieldByName(a).lineage.join("."),type:b};return i.contains(["boolean","string","ipv4","number"],e.type)&&(e.rule={comparator:c,compareTo:d}),this.filters.push(e),this},addLimitFilter:function(a,b,c,d,e){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add limit filter on a nonexistent field.");var f=this.dataModelObject.fieldByName(a);if(!i.contains(["string","number","objectCount"],f.type))throw new Error("Cannot add limit filter on "+a+" because it is of type "+f.type);if("string"===f.type&&!i.contains(["count","dc"],e))throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found "+e);if("number"===f.type&&!i.contains(["count","dc","average","sum"],e))throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found "+e);if("objectCount"===f.type&&!i.contains(["count"],e))throw new Error("Stats function for fields of type object count must be COUNT; found "+e);var g={fieldName:a,owner:f.lineage.join("."),type:f.type,attributeName:b,attributeOwner:this.dataModelObject.fieldByName(b).lineage.join("."),sortDirection:c,limitAmount:d,statsFn:e};return g.limitType="ASCENDING"===c?"lowest":"highest",this.filters.push(g),this},addRowSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],c.type))throw new Error("Field was of type "+c.type+", expected number or string.");var d={fieldName:a,owner:c.owner,type:c.type,label:b};return"number"===c.type&&(d.display="all"),this.rows.push(d),this},addRangeRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("number"!==d.type)throw new Error("Field was of type "+d.type+", expected number.");var e={};return!i.isUndefined(c.start)&&c.start!==null&&(e.start=c.start),!i.isUndefined(c.end)&&c.end!==null&&(e.end=c.end),!i.isUndefined(c.step)&&c.step!==null&&(e.size=c.step),!i.isUndefined(c.limit)&&c.limit!==null&&(e.maxNumberOf=c.limit),this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,display:"ranges",ranges:e}),this},addBooleanRowSplit:function(a,b,c,d){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var e=this.dataModelObject.fieldByName(a);if("boolean"!==e.type)throw new Error("Field was of type "+e.type+", expected boolean.");return this.rows.push({fieldName:a,owner:e.owner,type:e.type,label:b,trueLabel:c,falseLabel:d}),this},addTimestampRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("timestamp"!==d.type)throw new Error("Field was of type "+d.type+", expected timestamp.");if(!i.contains(this._binning,c))throw new Error("Invalid binning "+c+" found. Valid values are: "+this._binning.join(", "));return this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,period:c}),this},addColumnSplit:function(a){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var b=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],b.type))throw new Error("Field was of type "+b.type+", expected number or string.");var c={fieldName:a,owner:b.owner,type:b.type};return"number"===b.type&&(c.display="all"),this.columns.push(c),this},addRangeColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("number"!==c.type)throw new Error("Field was of type "+c.type+", expected number.");var d={};return!i.isUndefined(b.start)&&b.start!==null&&(d.start=b.start),!i.isUndefined(b.end)&&b.end!==null&&(d.end=b.end),!i.isUndefined(b.step)&&b.step!==null&&(d.size=b.step),!i.isUndefined(b.limit)&&b.limit!==null&&(d.maxNumberOf=b.limit),this.columns.push({fieldName:a,owner:c.owner,type:c.type,display:"ranges",ranges:d}),this},addBooleanColumnSplit:function(a,b,c){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("boolean"!==d.type)throw new Error("Field was of type "+d.type+", expected boolean.");return this.columns.push({fieldName:a,owner:d.owner,type:d.type,trueLabel:b,falseLabel:c}),this},addTimestampColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("timestamp"!==c.type)throw new Error("Field was of type "+c.type+", expected timestamp.");if(!i.contains(this._binning,b))throw new Error("Invalid binning "+b+" found. Valid values are: "+this._binning.join(", "));return this.columns.push({fieldName:a,owner:c.owner,type:c.type,period:b}),this},addCellValue:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if(i.contains(["string","ipv4"],d.type)&&!i.contains(["list","values","first","last","count","dc"],c))throw new Error("Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found "+c);if("number"===d.type&&!i.contains(["sum","count","average","min","max","stdev","list","values"],c))throw new Error("Stats function on number field must be must be one of: sum, count, average, max, min, stdev, list, or distinct_values; found "+c);if("timestamp"===d.type&&!i.contains(["duration","earliest","latest","list","values"],c))throw new Error("Stats function on timestamp field must be one of: duration, earliest, latest, list, or distinct values; found "+c);if(i.contains(["objectCount","childCount"],d.type)&&"count"!==c)throw new Error("Stats function on childcount and objectcount fields must be count; found "+c);if("boolean"===d.type)throw new Error("Cannot use boolean valued fields as cell values.");return this.cells.push({fieldName:a,owner:d.lineage.join("."),type:d.type,label:b,sparkline:!1,value:c}),this},toJsonObject:function(){return{dataModel:this.dataModelObject.dataModel.name,baseClass:this.dataModelObject.name,rows:this.rows,columns:this.columns,cells:this.cells,filters:this.filters}},pivot:function(a){var b=this.dataModelObject.dataModel.service,c={pivot_json:JSON.stringify(this.toJsonObject())};return i.isUndefined(this.accelerationNamespace)||(c.namespace=this.accelerationNamespace),b.get(g.pivot+"/"+encodeURIComponent(this.dataModelObject.dataModel.name),c,function(c,d){if(c){a(new Error(c.data.messages[0].text),d);return}d.data.entry&&d.data.entry[0]?a(null,new j.Pivot(b,d.data.entry[0].content)):a(new Error("Didn't get a Pivot report back from Splunk"),d)})},run:function(a,b){b||(b=a,a={}),a=a||{},this.pivot(function(c,d){c?b(c,null,null):d.run(a,f.augment(b,d))})}}),j.DataModelObject=h.extend({init:function(a,b){a=a||{},a.owner=a.owner||"",this.dataModel=b,this.name=a.objectName,this.displayName=a.displayName,this.parentName=a.parentName,this.lineage=a.lineage.split("."),a.hasOwnProperty("groupByFields")&&(this.groupByFields=a.groupByFields),a.hasOwnProperty("objectsToGroup")&&(this.objectsToGroup=a.objectsToGroup),a.hasOwnProperty("transactionMaxTimeSpan")&&(this.maxSpan=a.transactionMaxTimeSpan),a.hasOwnProperty("transactionMaxPause")&&(this.maxPause=a.transactionMaxPause),a.hasOwnProperty("baseSearch")&&(this.baseSearch=a.baseSearch),this.fields={};for(var c=0;c0)}})}})})()}),require.define("/lib/async.js",function(a,b,c,d,e){(function(){"use strict";var b=a("./utils"),d=c||this;d.whilst=function(a,b,c){a=a||function(){return!1},b=b||function(a){a()},c=c||function(){};var e=function(e){e?c(e):d.whilst(a,b,c)};a()?b(e):c(null)},d.parallel=function(a,c){if(arguments.length>1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){},a.length===0&&c();var e=a.length,f=[],g=function(a){return function(d){if(d)c&&c(d),c=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),f[a]=g,--e===0&&(f.unshift(null),c&&c.apply(null,f))}}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};var e=function(a,c,d,f){if(!a){d.unshift(null),f.apply(null,d);return}a(function(a){if(a)f&&f(a),f=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),d.push(g),e(c[0],c.slice(1),d,f)}})};e(a[0],a.slice(1),[],c)},d.parallelMap=function(a,c,e){a=a||[],e=e||function(){};var f=[],g=function(a,b){return function(d){c(a,b,d)}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};if(!a.length)c();else{var e=function(a,d,f){var g=function(a){if(a)c(a),c=function(){};else{var f=b.toArray(arguments);f.shift(),e(d[0],d.slice(1),f)}},h=f;d.length?h.push(g):h.push(c),a.apply(null,h)};e(a[0],a.slice(1),[])}},d.sleep=function(a,b){setTimeout(function(){b()},a)},d.augment=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){var c=Array.prototype.slice.call(arguments);for(var d=0;d tag unexpected.")}},f.parseXMLData=function(a,b){var c={},d=a.getchildren();for(var e=0;e/g,">"),d||(a=a.replace(/\n/g," "),a=a.replace(/\r/g," ")),c&&(a=a.replace(/"/g,"""))),a}function w(a,b){return v(a,b,!0)}function x(a,b){return v(a,b,!1)}function y(a,b){return v(a,b,!1,!0)}function z(a,b,c){function g(a){return a}function h(a){if(a[0]==="{"){var b=a.substring(1).split("}",2),g=b[0],h=b[1],i=e[g];i===undefined&&(i=t[g],i===undefined&&(i="ns"+Object.keys(e).length),i!=="xml"&&(e[g]=i)),i?d[a]=f("%s:%s",i,h):d[a]=h}else{if(c)throw new Error("cannot use non-qualified names with default_namespace option");d[a]=a}}var d={},e={};return c&&(e[c]=""),a.iter(null,function(a){var b,c=a.tag,e=a.text,f=a.items();if(c instanceof r&&d[c.text]===undefined)h(c.text);else if(typeof c=="string")h(c);else if(c!==null&&c!==o&&c!==p&&c!==q)throw new Error("Invalid tag type for serialization: "+c);e instanceof r&&d[e.text]===undefined&&h(e.text),f.forEach(function(a){var b=a[0],c=a[1];b instanceof r&&(b=b.text),d[b]===undefined&&h(b),c instanceof r&&d[c.text]===undefined&&h(c.text)})}),[d,e]}function A(a,b,c,d,e,h,i){var j=b.tag,k=b.text,l,m,n=h||h===0;a(Array(h+1).join(i));if(j===o)a(f("",x(k,c)));else if(j===q)a(f("",x(k,c)));else if(j===p)k=k||"",a(f("",k));else{j=d[j];if(j===undefined)k&&a(y(k,c)),b.iter(function(b){A(a,b,c,d,null,n?h+1:!1,i)});else{a("<"+j),l=b.items();if(l||e)l.sort(),l.forEach(function(b){var e=b[0],g=b[1];e instanceof r&&(e=e.text),g instanceof r?g=d[g.text]:g=w(g,c),a(f(' %s="%s"',d[e],g))}),e&&(l=g.items(e),l.sort(function(a,b){return a[1]"),!k&&n&&a("\n"),k&&a(y(k,c)),b._children.forEach(function(b){A(a,b,c,d,null,n?h+1:!1,i)}),!k&&h&&a(Array(h+1).join(i)),a("")):a(" />")}}n&&a("\n")}function B(a,b){var c=new s;return c.parse(a,b),c}function C(a,b){return(new s(a)).write(b)}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./elementpath"),i=a("./treebuilder").TreeBuilder,j=a("./parser").get_parser,k=a("./constants"),l=0;m.prototype.toString=function(){return f("",this.tag,this._id)},m.prototype.makeelement=function(a,b){return new m(a,b)},m.prototype.len=function(){return this._children.length},m.prototype.getItem=function(a){return this._children[a]},m.prototype.setItem=function(a,b){this._children[a]=b},m.prototype.delItem=function(a){this._children.splice(a,1)},m.prototype.getSlice=function(a,b){return this._children.slice(a,b)},m.prototype.setSlice=function(a,b,c){var d,e=0;for(d=a;d\n");if(a.method==="text")_serialize_text(b,self._root,encoding);else{var c,d,e,f,h=z(this._root,a.encoding,a.default_namespace);c=h[0],d=h[1],a.hasOwnProperty("indent")?(e=0,f=(new Array(a.indent+1)).join(" ")):e=!1;if(a.method==="xml")A(function(a){b.push(a)},this._root,a.encoding,c,d,e,f);else throw new Error("unknown serialization method "+a.method)}return b.join("")};var t={"http://www.w3.org/XML/1998/namespace":"xml","http://www.w3.org/1999/xhtml":"html","http://www.w3.org/1999/02/22-rdf-syntax-ns#":"rdf","http://schemas.xmlsoap.org/wsdl/":"wsdl","http://www.w3.org/2001/XMLSchema":"xs","http://www.w3.org/2001/XMLSchema-instance":"xsi","http://purl.org/dc/elements/1.1/":"dc"};c.PI=q,c.Comment=o,c.CData=p,c.ProcessingInstruction=q,c.SubElement=n,c.QName=r,c.ElementTree=s,c.ElementPath=h,c.Element=function(a,b){return new m(a,b)},c.XML=function(a){var b=new s;return b.parse(a)},c.parse=B,c.register_namespace=u,c.tostring=C}),require.define("/node_modules/elementtree/lib/sprintf.js",function(a,b,c,d,e){function h(a){var b,c,d=a,e=0,h=1,i="return '";for(b=0;b100&&(i={});if(b.charAt(0)==="/")throw new h(null,"Cannot use absolute path on element");d=k(b),c=[];function o(){return d.shift()}j=o();for(;;){var p=j[1]||"";l=r[p](o,j);if(!l)throw new h(null,f("Invalid path: %s",b));c.push(l),j=o();if(!j)break;j[1]==="/"&&(j=o());if(!j)break}i[b]=c}d=[a],n=new s(a);for(e=0,g=c.length;e0?c[0]:null}function v(a,b,c){var d=t(a,b);return d&&d.length>0?d[0].text:c}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./errors").SyntaxError,i={},j=new RegExp("('[^']*'|\"[^\"]*\"|::|//?|\\.\\.|\\(\\)|[/.*:\\[\\]\\(\\)@=])|((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|\\s+","g"),k=g.findall.bind(null,j),r={"":l,"*":m,".":n,"..":p,"//":o,"[":q};c.find=u,c.findall=t,c.findtext=v}),require.define("/node_modules/elementtree/lib/errors.js",function(a,b,c,d,e){function h(a,b){b=b||g("Syntax Error at token %s",a.toString()),this.token=a,this.message=b,Error.call(this,b)}var f=a("util"),g=a("./sprintf").sprintf;f.inherits(h,Error),c.SyntaxError=h}),require.define("util",function(a,b,c,d,e){function g(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&g(a.__proto__)}function h(a){return a instanceof RegExp||typeof a=="object"&&Object.prototype.toString.call(a)==="[object RegExp]"}function i(a){if(a instanceof Date)return!0;if(typeof a!="object")return!1;var b=Date.prototype&&n(Date.prototype),c=a.__proto__&&n(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}function j(a){return a<10?"0"+a.toString(10):a.toString(10)}function l(){var a=new Date,b=[j(a.getHours()),j(a.getMinutes()),j(a.getSeconds())].join(":");return[a.getDate(),k[a.getMonth()],b].join(" ")}var f=a("events");c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,d,e){function k(a,d){if(a&&typeof a.inspect=="function"&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(d);switch(typeof a){case"undefined":return j("undefined","undefined");case"string":var e="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return j(e,"string");case"number":return j(""+a,"number");case"boolean":return j(""+a,"boolean")}if(a===null)return j("null","null");var l=m(a),o=b?n(a):l;if(typeof a=="function"&&o.length===0){if(h(a))return j(""+a,"regexp");var p=a.name?": "+a.name:"";return j("[Function"+p+"]","special")}if(i(a)&&o.length===0)return j(a.toUTCString(),"date");var q,r,s;g(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]);if(typeof a=="function"){var t=a.name?": "+a.name:"";q=h(a)?" "+a:" [Function"+t+"]"}else q="";i(a)&&(q=" "+a.toUTCString());if(o.length===0)return s[0]+q+s[1];if(d<0)return h(a)?j(""+a,"regexp"):j("[Object]","special");f.push(a);var u=o.map(function(b){var c,e;a.__lookupGetter__&&(a.__lookupGetter__(b)?a.__lookupSetter__(b)?e=j("[Getter/Setter]","special"):e=j("[Getter]","special"):a.__lookupSetter__(b)&&(e=j("[Setter]","special"))),l.indexOf(b)<0&&(c="["+b+"]"),e||(f.indexOf(a[b])<0?(d===null?e=k(a[b]):e=k(a[b],d-1),e.indexOf("\n")>-1&&(g(a)?e=e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):e="\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=j("[Circular]","special"));if(typeof c=="undefined"){if(r==="Array"&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=j(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=j(c,"string"))}return c+": "+e});f.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return w>50?u=s[0]+(q===""?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:u=s[0]+q+" "+u.join(", ")+" "+s[1],u}var f=[],j=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return e||(j=function(a,b){return a}),k(a,typeof d=="undefined"?2:d)};var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(a){},c.pump=null;var m=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},n=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},o=Object.create||function(a,b){var c;if(a===null)c={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return typeof b!="undefined"&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=o(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}}),require.define("events",function(a,b,c,d,e){process.EventEmitter||(process.EventEmitter=function(){});var f=c.EventEmitter=process.EventEmitter,g=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.toString.call(a)==="[object Array]"},h=10;f.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},f.prototype.emit=function(a){if(a==="error")if(!this._events||!this._events.error||g(this._events.error)&&!this._events.error.length)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if(typeof b=="function"){switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0}if(g(b)){var c=Array.prototype.slice.call(arguments,1),d=b.slice();for(var e=0,f=d.length;e0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var d=c.indexOf(b);if(d<0)return this;c.splice(d,1),c.length==0&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),require.define("/node_modules/elementtree/lib/treebuilder.js",function(a,b,c,d,e){function f(b){this._data=[],this._elem=[],this._last=null,this._tail=null,b||(b=a("./elementtree").Element),this._factory=b}f.prototype.close=function(){return this._last},f.prototype._flush=function(){if(this._data){if(this._last!==null){var a=this._data.join("");this._tail?this._last.tail=a:this._last.text=a}this._data=[]}},f.prototype.data=function(a){this._data.push(a)},f.prototype.start=function(a,b){this._flush();var c=this._factory(a,b);this._last=c,this._elem.length&&this._elem[this._elem.length-1].append(c),this._elem.push(c),this._tail=null},f.prototype.end=function(a){this._flush(),this._last=this._elem.pop();if(this._last.tag!==a)throw new Error("end tag mismatch");return this._tail=1,this._last},c.TreeBuilder=f}),require.define("/node_modules/elementtree/lib/parser.js",function(a,b,c,d,e){function h(a){if(a==="sax")return g.sax;throw new Error("Invalid parser: "+a)}var f=a("util"),g=a("./parsers/index");c.get_parser=h}),require.define("/node_modules/elementtree/lib/parsers/index.js",function(a,b,c,d,e){c.sax=a("./sax")}),require.define("/node_modules/elementtree/lib/parsers/sax.js",function(a,b,c,d,e){function i(a){this.parser=g.parser(!0),this.target=a?a:new h,this.parser.onopentag=this._handleOpenTag.bind(this),this.parser.ontext=this._handleText.bind(this),this.parser.oncdata=this._handleCdata.bind(this),this.parser.ondoctype=this._handleDoctype.bind(this),this.parser.oncomment=this._handleComment.bind(this),this.parser.onclosetag=this._handleCloseTag.bind(this),this.parser.onerror=this._handleError.bind(this)}var f=a("util"),g=a("sax"),h=a("./../treebuilder").TreeBuilder;i.prototype._handleOpenTag=function(a){this.target.start(a.name,a.attributes)},i.prototype._handleText=function(a){this.target.data(a)},i.prototype._handleCdata=function(a){this.target.data(a)},i.prototype._handleDoctype=function(a){},i.prototype._handleComment=function(a){},i.prototype._handleCloseTag=function(a){this.target.end(a)},i.prototype._handleError=function(a){throw a},i.prototype.feed=function(a){this.parser.write(a)},i.prototype.close=function(){return this.parser.close(),this.target.close()},c.XMLParser=i}),require.define("/node_modules/elementtree/node_modules/sax/package.json",function(a,b,c,d,e){b.exports={main:"lib/sax.js"}}),require.define("/node_modules/elementtree/node_modules/sax/lib/sax.js",function(a,b,c,d,e){(function(b){function d(a,c){if(!(this instanceof d))return new d(a,c);var e=this;f(e),e.q=e.c="",e.bufferCheckPosition=b.MAX_BUFFER_LENGTH,e.opt=c||{},e.tagCase=e.opt.lowercasetags?"toLowerCase":"toUpperCase",e.tags=[],e.closed=e.closedRoot=e.sawRoot=!1,e.tag=e.error=null,e.strict=!!a,e.noscript=!!a||!!e.opt.noscript,e.state=B.BEGIN,e.ENTITIES=Object.create(b.ENTITIES),e.attribList=[],e.opt.xmlns&&(e.ns=Object.create(x)),e.position=e.line=e.column=0,C(e,"onready")}function e(a){var d=Math.max(b.MAX_BUFFER_LENGTH,10),e=0;for(var f=0,g=c.length;fd)switch(c[f]){case"textNode":E(a);break;case"cdata":D(a,"oncdata",a.cdata),a.cdata="";break;case"script":D(a,"onscript",a.script),a.script="";break;default:G(a,"Max buffer length exceeded: "+c[f])}e=Math.max(e,h)}a.bufferCheckPosition=b.MAX_BUFFER_LENGTH-e+a.position}function f(a){for(var b=0,d=c.length;b",a.state=B.TEXT;return}a.tagName=c;var f=a.tags.length;while(f-->b){var g=a.tag=a.tags.pop();a.tagName=a.tag.name,D(a,"onclosetag",a.tagName);var h={};for(var i in g.ns)h[i]=g.ns[i];var j=a.tags[a.tags.length-1]||a;a.opt.xmlns&&g.ns!==j.ns&&Object.keys(g.ns).forEach(function(b){var c=g.ns[b];D(a,"onclosenamespace",{prefix:b,uri:c})})}b===0&&(a.closedRoot=!0),a.tagName=a.attribValue=a.attribName="",a.attribList.length=0,a.state=B.TEXT}function O(a){var b=a.entity.toLowerCase(),c,d="";return a.ENTITIES[b]?a.ENTITIES[b]:(b.charAt(0)==="#"&&(b.charAt(1)==="x"?(b=b.slice(2),c=parseInt(b,16),d=c.toString(16)):(b=b.slice(1),c=parseInt(b,10),d=c.toString(10))),b=b.replace(/^0+/,""),d.toLowerCase()!==b?(I(a,"Invalid character entity"),"&"+a.entity+";"):String.fromCharCode(c))}function P(a){var b=this;if(this.error)throw this.error;if(b.closed)return G(b,"Cannot write after close. Assign an onready handler.");if(a===null)return H(b);var c=0,d="";while(b.c=d=a.charAt(c++)){b.position++,d==="\n"?(b.line++,b.column=0):b.column++;switch(b.state){case B.BEGIN:d==="<"?b.state=B.OPEN_WAKA:A(l,d)&&(I(b,"Non-whitespace before first tag."),b.textNode=d,b.state=B.TEXT);continue;case B.TEXT:if(b.sawRoot&&!b.closedRoot){var f=c-1;while(d&&d!=="<"&&d!=="&")d=a.charAt(c++),d&&(b.position++,d==="\n"?(b.line++,b.column=0):b.column++);b.textNode+=a.substring(f,c-1)}d==="<"?b.state=B.OPEN_WAKA:(A(l,d)&&(!b.sawRoot||b.closedRoot)&&I("Text data outside of root node."),d==="&"?b.state=B.TEXT_ENTITY:b.textNode+=d);continue;case B.SCRIPT:d==="<"?b.state=B.SCRIPT_ENDING:b.script+=d;continue;case B.SCRIPT_ENDING:d==="/"?(D(b,"onscript",b.script),b.state=B.CLOSE_TAG,b.script="",b.tagName=""):(b.script+="<"+d,b.state=B.SCRIPT);continue;case B.OPEN_WAKA:d==="!"?(b.state=B.SGML_DECL,b.sgmlDecl=""):z(l,d)||(z(o,d)?(b.startTagPosition=b.position-1,b.state=B.OPEN_TAG,b.tagName=d):d==="/"?(b.startTagPosition=b.position-1,b.state=B.CLOSE_TAG,b.tagName=""):d==="?"?(b.state=B.PROC_INST,b.procInstName=b.procInstBody=""):(I(b,"Unencoded <"),b.textNode+="<"+d,b.state=B.TEXT));continue;case B.SGML_DECL:(b.sgmlDecl+d).toUpperCase()===t?(D(b,"onopencdata"),b.state=B.CDATA,b.sgmlDecl="",b.cdata=""):b.sgmlDecl+d==="--"?(b.state=B.COMMENT,b.comment="",b.sgmlDecl=""):(b.sgmlDecl+d).toUpperCase()===u?(b.state=B.DOCTYPE,(b.doctype||b.sawRoot)&&I(b,"Inappropriately located doctype declaration"),b.doctype="",b.sgmlDecl=""):d===">"?(D(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=B.TEXT):z(q,d)?(b.state=B.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case B.SGML_DECL_QUOTED:d===b.q&&(b.state=B.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case B.DOCTYPE:d===">"?(b.state=B.TEXT,D(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,d==="["?b.state=B.DOCTYPE_DTD:z(q,d)&&(b.state=B.DOCTYPE_QUOTED,b.q=d));continue;case B.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=B.DOCTYPE);continue;case B.DOCTYPE_DTD:b.doctype+=d,d==="]"?b.state=B.DOCTYPE:z(q,d)&&(b.state=B.DOCTYPE_DTD_QUOTED,b.q=d);continue;case B.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=B.DOCTYPE_DTD,b.q="");continue;case B.COMMENT:d==="-"?b.state=B.COMMENT_ENDING:b.comment+=d;continue;case B.COMMENT_ENDING:d==="-"?(b.state=B.COMMENT_ENDED,b.comment=F(b.opt,b.comment),b.comment&&D(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=B.COMMENT);continue;case B.COMMENT_ENDED:d!==">"?(I(b,"Malformed comment"),b.comment+="--"+d,b.state=B.COMMENT):b.state=B.TEXT;continue;case B.CDATA:d==="]"?b.state=B.CDATA_ENDING:b.cdata+=d;continue;case B.CDATA_ENDING:d==="]"?b.state=B.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=B.CDATA);continue;case B.CDATA_ENDING_2:d===">"?(b.cdata&&D(b,"oncdata",b.cdata),D(b,"onclosecdata"),b.cdata="",b.state=B.TEXT):d==="]"?b.cdata+="]":(b.cdata+="]]"+d,b.state=B.CDATA);continue;case B.PROC_INST:d==="?"?b.state=B.PROC_INST_ENDING:z(l,d)?b.state=B.PROC_INST_BODY:b.procInstName+=d;continue;case B.PROC_INST_BODY:if(!b.procInstBody&&z(l,d))continue;d==="?"?b.state=B.PROC_INST_ENDING:z(q,d)?(b.state=B.PROC_INST_QUOTED,b.q=d,b.procInstBody+=d):b.procInstBody+=d;continue;case B.PROC_INST_ENDING:d===">"?(D(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=B.TEXT):(b.procInstBody+="?"+d,b.state=B.PROC_INST_BODY);continue;case B.PROC_INST_QUOTED:b.procInstBody+=d,d===b.q&&(b.state=B.PROC_INST_BODY,b.q="");continue;case B.OPEN_TAG:z(p,d)?b.tagName+=d:(J(b),d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:(A(l,d)&&I(b,"Invalid character in tag name"),b.state=B.ATTRIB));continue;case B.OPEN_TAG_SLASH:d===">"?(M(b,!0),N(b)):(I(b,"Forward-slash in opening tag not followed by >"),b.state=B.ATTRIB);continue;case B.ATTRIB:if(z(l,d))continue;d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:z(o,d)?(b.attribName=d,b.attribValue="",b.state=B.ATTRIB_NAME):I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME:d==="="?b.state=B.ATTRIB_VALUE:z(l,d)?b.state=B.ATTRIB_NAME_SAW_WHITE:z(p,d)?b.attribName+=d:I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME_SAW_WHITE:if(d==="=")b.state=B.ATTRIB_VALUE;else{if(z(l,d))continue;I(b,"Attribute without value"),b.tag.attributes[b.attribName]="",b.attribValue="",D(b,"onattribute",{name:b.attribName,value:""}),b.attribName="",d===">"?M(b):z(o,d)?(b.attribName=d,b.state=B.ATTRIB_NAME):(I(b,"Invalid attribute name"),b.state=B.ATTRIB)}continue;case B.ATTRIB_VALUE:if(z(l,d))continue;z(q,d)?(b.q=d,b.state=B.ATTRIB_VALUE_QUOTED):(I(b,"Unquoted attribute value"),b.state=B.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case B.ATTRIB_VALUE_QUOTED:if(d!==b.q){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}L(b),b.q="",b.state=B.ATTRIB;continue;case B.ATTRIB_VALUE_UNQUOTED:if(A(s,d)){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}L(b),d===">"?M(b):b.state=B.ATTRIB;continue;case B.CLOSE_TAG:if(!b.tagName){if(z(l,d))continue;A(o,d)?I(b,"Invalid tagname in closing tag."):b.tagName=d}else d===">"?N(b):z(p,d)?b.tagName+=d:(A(l,d)&&I(b,"Invalid tagname in closing tag"),b.state=B.CLOSE_TAG_SAW_WHITE);continue;case B.CLOSE_TAG_SAW_WHITE:if(z(l,d))continue;d===">"?N(b):I("Invalid characters in closing tag");continue;case B.TEXT_ENTITY:case B.ATTRIB_VALUE_ENTITY_Q:case B.ATTRIB_VALUE_ENTITY_U:switch(b.state){case B.TEXT_ENTITY:var g=B.TEXT,h="textNode";break;case B.ATTRIB_VALUE_ENTITY_Q:var g=B.ATTRIB_VALUE_QUOTED,h="attribValue";break;case B.ATTRIB_VALUE_ENTITY_U:var g=B.ATTRIB_VALUE_UNQUOTED,h="attribValue"}d===";"?(b[h]+=O(b),b.entity="",b.state=g):z(r,d)?b.entity+=d:(I("Invalid character entity"),b[h]+="&"+b.entity+d,b.entity="",b.state=g);continue;default:throw new Error(b,"Unknown state: "+b.state)}}return b.position>=b.bufferCheckPosition&&e(b),b}b.parser=function(a,b){return new d(a,b)},b.SAXParser=d,b.SAXStream=k,b.createStream=j,b.MAX_BUFFER_LENGTH=65536;var c=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];b.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(a){function b(){this.__proto__=a}return b.prototype=a,new b}),Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.__proto__}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),d.prototype={end:function(){H(this)},write:P,resume:function(){return this.error=null,this},close:function(){return this.write(null)},end:function(){return this.write(null)}};try{var g=a("stream").Stream}catch(h){var g=function(){}}var i=b.EVENTS.filter(function(a){return a!=="error"&&a!=="end"});k.prototype=Object.create(g.prototype,{constructor:{value:k}}),k.prototype.write=function(a){return this._parser.write(a.toString()),this.emit("data",a),!0},k.prototype.end=function(a){return a&&a.length&&this._parser.write(a.toString()),this._parser.end(),!0},k.prototype.on=function(a,b){var c=this;return!c._parser["on"+a]&&i.indexOf(a)!==-1&&(c._parser["on"+a]=function(){var b=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);b.splice(0,0,a),c.emit.apply(c,b)}),g.prototype.on.call(c,a,b)};var l="\r\n\t ",m="0124356789",n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",o=n+"_:",p=o+m+"-.",q="'\"",r=m+n+"#",s=l+">",t="[CDATA[",u="DOCTYPE",v="http://www.w3.org/XML/1998/namespace",w="http://www.w3.org/2000/xmlns/",x={xml:v,xmlns:w};l=y(l),m=y(m),n=y(n),o=y(o),p=y(p),q=y(q),r=y(r),s=y(s);var B=0;b.STATE={BEGIN:B++,TEXT:B++,TEXT_ENTITY:B++,OPEN_WAKA:B++,SGML_DECL:B++,SGML_DECL_QUOTED:B++,DOCTYPE:B++,DOCTYPE_QUOTED:B++,DOCTYPE_DTD:B++,DOCTYPE_DTD_QUOTED:B++,COMMENT_STARTING:B++,COMMENT:B++,COMMENT_ENDING:B++,COMMENT_ENDED:B++,CDATA:B++,CDATA_ENDING:B++,CDATA_ENDING_2:B++,PROC_INST:B++,PROC_INST_BODY:B++,PROC_INST_QUOTED:B++,PROC_INST_ENDING:B++,OPEN_TAG:B++,OPEN_TAG_SLASH:B++,ATTRIB:B++,ATTRIB_NAME:B++,ATTRIB_NAME_SAW_WHITE:B++,ATTRIB_VALUE:B++,ATTRIB_VALUE_QUOTED:B++,ATTRIB_VALUE_UNQUOTED:B++,ATTRIB_VALUE_ENTITY_Q:B++,ATTRIB_VALUE_ENTITY_U:B++,CLOSE_TAG:B++,CLOSE_TAG_SAW_WHITE:B++,SCRIPT:B++,SCRIPT_ENDING:B++},b.ENTITIES={apos:"'",quot:'"',amp:"&",gt:">",lt:"<"};for(var B in b.STATE)b.STATE[b.STATE[B]]=B;B=b.STATE})(typeof c=="undefined"?sax={}:c)}),require.define("stream",function(a,b,c,d,e){function h(){f.EventEmitter.call(this)}var f=a("events"),g=a("util");g.inherits(h,f.EventEmitter),b.exports=h,h.Stream=h,h.prototype.pipe=function(a,b){function d(b){a.writable&&!1===a.write(b)&&c.pause&&c.pause()}function e(){c.readable&&c.resume&&c.resume()}function g(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.end()}function h(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.destroy()}function i(a){j();if(this.listeners("error").length===0)throw a}function j(){c.removeListener("data",d),a.removeListener("drain",e),c.removeListener("end",g),c.removeListener("close",h),c.removeListener("error",i),a.removeListener("error",i),c.removeListener("end",j),c.removeListener("close",j),a.removeListener("end",j),a.removeListener("close",j)}var c=this;c.on("data",d),a.on("drain",e),!a._isStdio&&(!b||b.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,c.on("end",g),c.on("close",h));var f=!1;return c.on("error",i),a.on("error",i),c.on("end",j),c.on("close",j),a.on("end",j),a.on("close",j),a.emit("pipe",c),a}}),require.define("/node_modules/elementtree/lib/constants.js",function(a,b,c,d,e){var f="sax";c.DEFAULT_PARSER=f}),require.define("/lib/modularinputs/inputdefinition.js",function(a,b,c,d,e){(function(){function e(){this.metadata={},this.inputs={}}var c=a("elementtree"),d=a("./utils");e.parse=function(a){var b=new e,f=c.parse(a).getroot().getchildren();for(var g=0;g=10?b=parseFloat(a.toString().substring(0,14)).toFixed(3):a.toString().length<=13||a.toString().indexOf(".")<10?b=parseFloat(a).toFixed(3):b=(parseFloat(a.toString().substring(0,14))/1e3).toFixed(3)):a.toString().length===13?b=(parseFloat(a)/1e3).toFixed(3):a.toString().length<=12?b=parseFloat(a).toFixed(3):b=parseFloat(a.toString().substring(0,13)/1e3).toFixed(3),b)},e.prototype._writeTo=function(a){if(!this.data)throw new Error("Events must have at least the data field set to be written to XML.");var b=c.Element("event");this.stanza&&b.set("stanza",this.stanza),b.set("unbroken",(+this.unbroken).toString()),!d.isUndefined(this.time)&&this.time!==null&&(c.SubElement(b,"time").text=e.formatTime(this.time).toString()),typeof this.data=="object"&&(this.data=JSON.stringify(this.data));var f=[{tag:"source",text:this.source},{tag:"sourcetype",text:this.sourcetype},{tag:"index",text:this.index},{tag:"host",text:this.host},{tag:"data",text:this.data}];for(var g=0;g"),this._headerWritten=!0);try{a._writeTo(this._out)}catch(b){throw b.message==="Events must have at least the data field set to be written to XML."?(e.warn("",b.message,this._err),b):(e.error("",b.message,this._err),b)}},h.prototype.writeXMLDocument=function(a){var b=c.tostring(a,{xml_declaration:!1});this._out.write(b)},h.prototype.close=function(){this._out.write("")},b.exports=h})()}),require.define("/lib/modularinputs/logger.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./utils"),e=c||this;e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL",e._log=function(a,b,c,d){d=d||process.stderr,b&&b.length>0&&(b+=" ");var e=a+" Modular input "+b+c+"\n";d.write(e)},e.debug=function(a,b,c){try{e._log(e.DEBUG,a,b,c)}catch(d){throw d}},e.info=function(a,b,c){try{e._log(e.INFO,a,b,c)}catch(d){throw d}},e.warn=function(a,b,c){try{e._log(e.WARN,a,b,c)}catch(d){throw d}},e.error=function(a,b,c){try{e._log(e.ERROR,a,b,c)}catch(d){throw d}},e.fatal=function(a,b,c){try{e._log(e.FATAL,a,b,c)}catch(d){throw d}},b.exports=e})()}),require.define("/lib/modularinputs/argument.js",function(a,b,c,d,e){(function(){function e(a){a||(a={}),this.name=d.isUndefined(a.name)?"":a.name,this.description=d.isUndefined(a.description)?null:a.description,this.validation=d.isUndefined(a.validation)?null:a.validation,this.dataType=d.isUndefined(a.dataType)?e.dataTypeString:a.dataType,this.requiredOnEdit=d.isUndefined(a.requiredOnEdit)?!1:a.requiredOnEdit,this.requiredOnCreate=d.isUndefined(a.requiredOnCreate)?!1:a.requiredOnCreate}var c=a("elementtree"),d=a("./utils");e.dataTypeBoolean="BOOLEAN",e.dataTypeNumber="NUMBER",e.dataTypeString="STRING",e.prototype.addToDocument=function(a){var b=c.SubElement(a,"arg");b.set("name",this.name),this.description&&(c.SubElement(b,"description").text=this.description),this.validation&&(c.SubElement(b,"validation").text=this.validation);var d=[{tag:"data_type",value:this.dataType},{tag:"required_on_edit",value:this.requiredOnEdit},{tag:"required_on_create",value:this.requiredOnCreate}];for(var e=0;e")){clearTimeout(o);var g=h.parse(c);a._inputDefinition=g,k._inputDefinition=g,f.chain([function(b){f.parallelEach(Object.keys(a._inputDefinition.inputs),function(b,c,e){var g=a._inputDefinition.inputs[b];f.chain([function(c){a.start(b,g,c)},function(c){a.streamEvents(b,g,d,c)},function(c){a.end(b,g,c)}],function(a){e(a,a?1:0)})},function(a){b(a,a?1:0)})}],function(a){d._headerWritten&&d.close(),j(a,a?1:0)})}})}else if(b.length>=2&&b[1].toString().toLowerCase()==="--scheme"){var p=a.getScheme();if(!p)l.fatal("","script returned a null scheme.",d._err),j(null,1);else try{d.writeXMLDocument(p.toXML()),j(null,0)}catch(q){l.fatal("","script could not return the scheme, error: "+q,d._err),j(q,1)}}else if(b.length>=2&&b[1].toString().toLowerCase()==="--validate-arguments"){var r=setTimeout(function(){j(new Error("Receiving validation definition prior to validating timed out."),1)},30500);i.on("data",function(b){n=Buffer.concat([n,b]);var h=n.toString("utf8",0,n.length).trim();e.endsWith(h,"")&&(clearTimeout(r),f.chain([function(b){try{if(e.isUndefined(a.validateInput))b();else{var c=g.parse(n.toString("utf8",0,n.length));a.validateInput(c,b)}}catch(d){b(d)}}],function(a){if(a){l.error("",a.message),l.error("","Stack trace for a modular input error: "+a.stack);try{var b=c.Element("error");c.SubElement(b,"message").text=a.message,d.writeXMLDocument(b),j(a,1)}catch(e){j(e,1)}}else j(null,0)}))})}else{var s="Invalid arguments to modular input script: "+b.join()+"\n";l.error("",s,d._err),j(s,1)}},m.service=function(){if(this._service)return this._service;if(!this._inputDefinition)return null;var a=this._inputDefinition.metadata.server_uri,b=this._inputDefinition.metadata.session_key,c=d.parse(a),e=c.protocol.replace(":",""),f=c.hostname,g=c.port;return this._service=new k({scheme:e,host:f,port:g,token:b}),this._service},m.prototype.setup=function(a){a()},m.prototype.start=function(a,b,c){c()},m.prototype.end=function(a,b,c){c()},m.prototype.teardown=function(a){a()},b.exports=m})()}),require.define("url",function(a,b,c,d,e){function v(a,b,c){if(a&&typeof a=="object"&&a.href)return a;if(typeof a!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d={},e=a;for(var h=0,j=e.length;hn)d.hostname="";else{var G=d.hostname.split(/\./);for(var h=0,j=G.length;h127?I+="x":I+=H[J];if(!I.match(o)){var L=G.slice(0,h),M=G.slice(h+1),N=H.match(p);N&&(L.push(N[1]),M.unshift(N[2])),M.length&&(e="/"+M.join(".")+e),d.hostname=L.join(".");break}}}}d.hostname=d.hostname.toLowerCase();var O=d.hostname.split("."),P=[];for(var h=0;h0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}a.search=b.search,a.query=b.query;if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.href=w(a),a}if(!h.length)return delete a.pathname,a.search?delete a.path:a.path="/"+a.search,a.href=w(a),a;var k=h.slice(-1)[0],l=(a.host||b.host)&&(k==="."||k==="..")||k==="",m=0;for(var n=h.length;n>=0;n--)k=h[n],k=="."?h.splice(n,1):k===".."?(h.splice(n,1),m++):m&&(h.splice(n,1),m--);if(!f&&!g)for(;m--;m)h.unshift("..");f&&h[0]!==""&&(!h[0]||h[0].charAt(0)!=="/")&&h.unshift(""),l&&h.join("/").substr(-1)!=="/"&&h.push("");var o=h[0]===""||h[0]&&h[0].charAt(0)==="/";if(i){a.hostname=a.host=o?"":h.length?h.shift():"";var j=a.host&&a.host.indexOf("@")>0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}f=f||a.host&&h.length,f&&!o&&h.unshift(""),a.pathname=h.join("/");if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.auth=b.auth||a.auth,a.slashes=a.slashes||b.slashes,a.href=w(a),a}function z(a){var b={},c=h.exec(a);return c&&(c=c[0],b.port=c.substr(1),a=a.substr(0,a.length-c.length)),a&&(b.hostname=a),b}var f={encode:function(a){return a}};c.parse=v,c.resolve=x,c.resolveObject=y,c.format=w;var g=/^([a-z0-9.+-]+:)/i,h=/:[0-9]+$/,i=["<",">",'"',"`"," ","\r","\n","\t"],j=["{","}","|","\\","^","~","[","]","`"].concat(i),k=["'"],l=["%","/","?",";","#"].concat(j).concat(k),m=["/","@","?","#"].concat(i),n=255,o=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,p=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,q={javascript:!0,"javascript:":!0},r={javascript:!0,"javascript:":!0},s={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},t={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},u=a("querystring")}),require.define("querystring",function(a,b,c,d,e){function j(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function k(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";d.push(f)}return d}b||(b="/");if(require._core[a])return a;var c=require.modules.path();b=c.resolve("/",b);var d=b||"/";if(a.match(/^(?:\.\.?\/|\/)/)){var e=g(c.resolve(d,a))||h(c.resolve(d,a));if(e)return e}var f=i(a,d);if(f)return f;throw new Error("Cannot find module '"+a+"'")}}(),require.alias=function(a,b){var c=require.modules.path(),d=null;try{d=require.resolve(a+"/package.json","/")}catch(e){d=require.resolve(a,"/")}var f=c.dirname(d),g=(Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b})(require.modules);for(var h=0;h0){var c=a.shift();c()}}},!0),function(c){b?(a.push(c),window.postMessage("browserify-tick","*")):setTimeout(c,0)}}()),process.title||(process.title="browser"),process.binding||(process.binding=function(a){if(a==="evals")return require("vm");throw new Error("No such module")}),process.cwd||(process.cwd=function(){return"."}),require.define("path",function(a,b,c,d,e){function f(a,b){var c=[];for(var d=0;d=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var h=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var a="",b=!1;for(var c=arguments.length;c>=-1&&!b;c--){var d=c>=0?arguments[c]:process.cwd();if(typeof d!="string"||!d)continue;a=d+"/"+a,b=d.charAt(0)==="/"}return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=a.charAt(0)==="/",c=a.slice(-1)==="/";return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),!a&&!b&&(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(f(a,function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var b=h.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=h.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return h.exec(a)[3]||""}}),require.define("/package.json",function(a,b,c,d,e){b.exports={main:"index.js"}}),require.define("/index.js",function(a,b,c,d,e){(function(){var d=c||this;process.env=process.env||{},b.exports=d={Logger:a("./lib/log").Logger,Context:a("./lib/context"),Service:a("./lib/service"),Http:a("./lib/http"),Utils:a("./lib/utils"),Async:a("./lib/async"),Paths:a("./lib/paths").Paths,Class:a("./lib/jquery.class").Class,ModularInputs:a("./lib/modularinputs")},typeof window=="undefined"&&(d.NodeHttp=a("./lib/platform/node/node_http").NodeHttp)})()}),require.define("/lib/log.js",function(a,b,c,d,e){(function(){"use strict";var b=a("./utils"),d=c||this,e={ALL:4,INFO:3,WARN:2,ERROR:1,NONE:0},f=function(a){b.isString(a)&&e.hasOwnProperty(a)?process.env.LOG_LEVEL=e[a]:!isNaN(parseInt(a,10))&&b.keyOf(parseInt(a,10),e)?process.env.LOG_LEVEL=a:process.env.LOG_LEVEL=e.ERROR};process.env.LOG_LEVEL?f(process.env.LOG_LEVEL):process.env.LOG_LEVEL=e.ERROR;var g,h,i,j;g=h=i=j=function(){};if(typeof console!="undefined"){var k=function(a){return function(b){try{console[a].apply(console,arguments)}catch(c){console[a](b)}}};console.log&&(g=k("log")),console.error&&(i=k("error")),console.warn&&(h=k("warn")),console.info&&(j=k("info"))}c.Logger={log:function(){process.env.LOG_LEVEL>=e.ALL&&g.apply(null,arguments)},error:function(){process.env.LOG_LEVEL>=e.ERROR&&i.apply(null,arguments)},warn:function(){process.env.LOG_LEVEL>=e.WARN&&h.apply(null,arguments)},info:function(){process.env.LOG_LEVEL>=e.INFO&&j.apply(null,arguments)},printMessages:function(a){a=a||[];for(var b=0;b=0},e.startsWith=function(a,b){var c=a.match("^"+b);return c&&c.length>0&&c[0]===b},e.endsWith=function(a,b){var c=a.match(b+"$");return c&&c.length>0&&c[0]===b};var f=Object.prototype.toString;e.toArray=function(a){return Array.prototype.slice.call(a)},e.isArray=Array.isArray||function(a){return f.call(a)==="[object Array]"},e.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},e.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)},e.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},e.isObject=function(a){return a===Object(a)},e.isEmpty=function(a){if(e.isArray(a)||e.isString(a))return a.length===0;for(var b in a)if(this.hasOwnProperty.call(a,b))return!1;return!0},e.forEach=function(a,b,c){if(a===null)return;if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;dh)return 1}return 0}}),h.Sharing={USER:"user",APP:"app",GLOBAL:"global",SYSTEM:"system"}})()}),require.define("/lib/paths.js",function(a,b,c,d,e){(function(){"use strict";var a=c||this;a.Paths={apps:"/services/apps/local",capabilities:"authorization/capabilities",configurations:"configs",dataModels:"datamodel/model",deploymentClient:"deployment/client",deploymentServers:"deployment/server",deploymentServerClasses:"deployment/serverclass",deploymentTenants:"deployment/tenants",eventTypes:"saved/eventtypes",firedAlerts:"alerts/fired_alerts",indexes:"data/indexes",info:"/services/server/info",inputs:null,jobs:"search/jobs",licenseGroups:"licenser/groups",licenseMessages:"licenser/messages",licensePools:"licenser/pools",licenseSlaves:"licenser/slaves",licenseStacks:"licenser/stacks",licenses:"licenser/licenses",loggers:"server/logger",login:"/services/auth/login",messages:"messages",passwords:"admin/passwords",parser:"search/parser",pivot:"datamodel/pivot",properties:"properties",roles:"authorization/roles",savedSearches:"saved/searches",settings:"server/settings",storagePasswords:"storage/passwords",users:"/services/authentication/users",typeahead:"search/typeahead",views:"data/ui/views",currentUser:"/services/authentication/current-context",submitEvent:"/services/receivers/simple"}})()}),require.define("/lib/jquery.class.js",function(a,b,c,d,e){(function(){var a=c||this,b=!1,d=/xyz/.test(function(){return xyz})?/\b_super\b/:/.*/;a.Class=function(){},a.Class.extend=function(a){function g(){!b&&this.init&&this.init.apply(this,arguments)}var c=this.prototype;b=!0;var e=new this;b=!1;for(var f in a)e[f]=typeof a[f]=="function"&&typeof c[f]=="function"&&d.test(a[f])?function(a,b){return function(){var d=this._super;this._super=c[a];var e=b.apply(this,arguments);return this._super=d,e}}(f,a[f]):a[f];return g.prototype=e,g.constructor=g,g.extend=arguments.callee,g}})()}),require.define("/lib/http.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./jquery.class").Class,e=a("./log").Logger,f=a("./utils"),g=a("cookie"),h=c||this,i=null,j={5:function(a){var b=a.query||{},c=a.post||{},d=b.output_mode||c.output_mode||"json";return f.startsWith(d,"json")||(d="json"),b.output_mode=d,b},4:function(a){return a.query||{}},"default":function(a){return j[5](a)},none:function(a){return a.query||{}}};b.exports=h=i=d.extend({init:function(){this.get=f.bind(this,this.get),this.del=f.bind(this,this.del),this.post=f.bind(this,this.post),this.request=f.bind(this,this.request),this._buildResponse=f.bind(this,this._buildResponse),this._setSplunkVersion("none"),this._cookieStore={}},_setSplunkVersion:function(a){this.version=a},_getCookieString:function(){var a="";return f.forEach(this._cookieStore,function(b,c){a+=c,a+="=",a+=b,a+="; "}),a},_parseCookieHeader:function(a){var b=g.parse(a),c={};return f.forEach(b,function(a,b){if(c.key)return;c.key=b,c.value=a}),c},get:function(a,b,c,d,e){var f={method:"GET",headers:b,timeout:d,query:c};return this.request(a,f,e)},post:function(a,b,c,d,e){b["Content-Type"]="application/x-www-form-urlencoded";var f={method:"POST",headers:b,timeout:d,post:c};return this.request(a,f,e)},del:function(a,b,c,d,e){var f={method:"DELETE",headers:b,timeout:d,query:c};return this.request(a,f,e)},request:function(a,b,c){var d=this,e=function(a){c=c||function(){};var b=a.response.headers["set-cookie"];b&&f.forEach(b,function(a){var b=d._parseCookieHeader(a);d._cookieStore[b.key]=b.value}),a.status<400&&a.status!=="abort"?c(null,a):c(a)},g=f.getWithVersion(this.version,j)(b),h=b.post||{},k=a+"?"+i.encode(g),l=b.body?b.body:i.encode(h),m=d._getCookieString();m.length!==0&&(b.headers.Cookie=m,delete b.headers.Authorization);var n={method:b.method,headers:b.headers,timeout:b.timeout,body:l};return this.makeRequest(k,n,e)},makeRequest:function(a,b,c){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},parseJson:function(a){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},_buildResponse:function(a,b,c){var d,g={},h=null;b&&b.headers&&(h=f.trim(b.headers["content-type"]||b.headers["Content-Type"]||b.headers["Content-type"]||b.headers.contentType));if(f.startsWith(h,"application/json")&&c)try{g=this.parseJson(c)||{}}catch(i){e.error("Error in parsing JSON:",c,i),g=c}else g=c;return g&&e.printMessages(g.messages),d={response:b,status:b?b.statusCode:0,data:g,error:a},d}}),i.encode=function(a){var b="";for(var c in a)if(a.hasOwnProperty(c)){b&&b[b.length-1]!=="&"&&(b+="&");var d=a[c];if(d instanceof Array)for(var e=0;e1&&!b)throw new Error("Ambiguous match for name '"+a+"'");for(var e=0;e","<=",">=","is","isNull","isNotNull"],ipv4:["is","isNull","isNotNull","contains","doesNotContain","startsWith"]},_binning:["auto","year","month","day","hour","minute","second"],_sortDirection:["ASCENDING","DESCENDING","DEFAULT"],_statsFunctions:["list","values","first","last","count","dc","sum","average","max","min","stdev","duration","earliest","latest"],init:function(a){this.dataModelObject=a,this.columns=[],this.rows=[],this.filters=[],this.cells=[],this.accelerationNamespace=a.dataModel.isAccelerated()?a.dataModel.name:null,this.run=i.bind(this,this.run),this.pivot=i.bind(this,this.pivot)},setAccelerationJob:function(a){a&&a instanceof k.Job&&(a=a.sid);if(!a)throw new Error("Sid to use for acceleration must not be null.");return this.accelerationNamespace="sid="+a,this},addFilter:function(a,b,c,d){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add filter on a nonexistent field.");if(b!==this.dataModelObject.fieldByName(a).type)throw new Error("Cannot add "+b+" filter on "+a+" because it is of type "+this.dataModelObject.fieldByName(a).type);if(!i.contains(this._comparisons[b],c))throw new Error("Cannot add "+b+" filter because "+c+" is not a valid comparison operator");var e={fieldName:a,owner:this.dataModelObject.fieldByName(a).lineage.join("."),type:b};return i.contains(["boolean","string","ipv4","number"],e.type)&&(e.rule={comparator:c,compareTo:d}),this.filters.push(e),this},addLimitFilter:function(a,b,c,d,e){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add limit filter on a nonexistent field.");var f=this.dataModelObject.fieldByName(a);if(!i.contains(["string","number","objectCount"],f.type))throw new Error("Cannot add limit filter on "+a+" because it is of type "+f.type);if("string"===f.type&&!i.contains(["count","dc"],e))throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found "+e);if("number"===f.type&&!i.contains(["count","dc","average","sum"],e))throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found "+e);if("objectCount"===f.type&&!i.contains(["count"],e))throw new Error("Stats function for fields of type object count must be COUNT; found "+e);var g={fieldName:a,owner:f.lineage.join("."),type:f.type,attributeName:b,attributeOwner:this.dataModelObject.fieldByName(b).lineage.join("."),sortDirection:c,limitAmount:d,statsFn:e};return g.limitType="ASCENDING"===c?"lowest":"highest",this.filters.push(g),this},addRowSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],c.type))throw new Error("Field was of type "+c.type+", expected number or string.");var d={fieldName:a,owner:c.owner,type:c.type,label:b};return"number"===c.type&&(d.display="all"),this.rows.push(d),this},addRangeRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("number"!==d.type)throw new Error("Field was of type "+d.type+", expected number.");var e={};return!i.isUndefined(c.start)&&c.start!==null&&(e.start=c.start),!i.isUndefined(c.end)&&c.end!==null&&(e.end=c.end),!i.isUndefined(c.step)&&c.step!==null&&(e.size=c.step),!i.isUndefined(c.limit)&&c.limit!==null&&(e.maxNumberOf=c.limit),this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,display:"ranges",ranges:e}),this},addBooleanRowSplit:function(a,b,c,d){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var e=this.dataModelObject.fieldByName(a);if("boolean"!==e.type)throw new Error("Field was of type "+e.type+", expected boolean.");return this.rows.push({fieldName:a,owner:e.owner,type:e.type,label:b,trueLabel:c,falseLabel:d}),this},addTimestampRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("timestamp"!==d.type)throw new Error("Field was of type "+d.type+", expected timestamp.");if(!i.contains(this._binning,c))throw new Error("Invalid binning "+c+" found. Valid values are: "+this._binning.join(", "));return this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,period:c}),this},addColumnSplit:function(a){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var b=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],b.type))throw new Error("Field was of type "+b.type+", expected number or string.");var c={fieldName:a,owner:b.owner,type:b.type};return"number"===b.type&&(c.display="all"),this.columns.push(c),this},addRangeColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("number"!==c.type)throw new Error("Field was of type "+c.type+", expected number.");var d={};return!i.isUndefined(b.start)&&b.start!==null&&(d.start=b.start),!i.isUndefined(b.end)&&b.end!==null&&(d.end=b.end),!i.isUndefined(b.step)&&b.step!==null&&(d.size=b.step),!i.isUndefined(b.limit)&&b.limit!==null&&(d.maxNumberOf=b.limit),this.columns.push({fieldName:a,owner:c.owner,type:c.type,display:"ranges",ranges:d}),this},addBooleanColumnSplit:function(a,b,c){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("boolean"!==d.type)throw new Error("Field was of type "+d.type+", expected boolean.");return this.columns.push({fieldName:a,owner:d.owner,type:d.type,trueLabel:b,falseLabel:c}),this},addTimestampColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("timestamp"!==c.type)throw new Error("Field was of type "+c.type+", expected timestamp.");if(!i.contains(this._binning,b))throw new Error("Invalid binning "+b+" found. Valid values are: "+this._binning.join(", "));return this.columns.push({fieldName:a,owner:c.owner,type:c.type,period:b}),this},addCellValue:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if(i.contains(["string","ipv4"],d.type)&&!i.contains(["list","values","first","last","count","dc"],c))throw new Error("Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found "+c);if("number"===d.type&&!i.contains(["sum","count","average","min","max","stdev","list","values"],c))throw new Error("Stats function on number field must be must be one of: sum, count, average, max, min, stdev, list, or distinct_values; found "+c);if("timestamp"===d.type&&!i.contains(["duration","earliest","latest","list","values"],c))throw new Error("Stats function on timestamp field must be one of: duration, earliest, latest, list, or distinct values; found "+c);if(i.contains(["objectCount","childCount"],d.type)&&"count"!==c)throw new Error("Stats function on childcount and objectcount fields must be count; found "+c);if("boolean"===d.type)throw new Error("Cannot use boolean valued fields as cell values.");return this.cells.push({fieldName:a,owner:d.lineage.join("."),type:d.type,label:b,sparkline:!1,value:c}),this},toJsonObject:function(){return{dataModel:this.dataModelObject.dataModel.name,baseClass:this.dataModelObject.name,rows:this.rows,columns:this.columns,cells:this.cells,filters:this.filters}},pivot:function(a){var b=this.dataModelObject.dataModel.service,c={pivot_json:JSON.stringify(this.toJsonObject())};return i.isUndefined(this.accelerationNamespace)||(c.namespace=this.accelerationNamespace),b.get(g.pivot+"/"+encodeURIComponent(this.dataModelObject.dataModel.name),c,function(c,d){if(c){a(new Error(c.data.messages[0].text),d);return}d.data.entry&&d.data.entry[0]?a(null,new j.Pivot(b,d.data.entry[0].content)):a(new Error("Didn't get a Pivot report back from Splunk"),d)})},run:function(a,b){b||(b=a,a={}),a=a||{},this.pivot(function(c,d){c?b(c,null,null):d.run(a,f.augment(b,d))})}}),j.DataModelObject=h.extend({init:function(a,b){a=a||{},a.owner=a.owner||"",this.dataModel=b,this.name=a.objectName,this.displayName=a.displayName,this.parentName=a.parentName,this.lineage=a.lineage.split("."),a.hasOwnProperty("groupByFields")&&(this.groupByFields=a.groupByFields),a.hasOwnProperty("objectsToGroup")&&(this.objectsToGroup=a.objectsToGroup),a.hasOwnProperty("transactionMaxTimeSpan")&&(this.maxSpan=a.transactionMaxTimeSpan),a.hasOwnProperty("transactionMaxPause")&&(this.maxPause=a.transactionMaxPause),a.hasOwnProperty("baseSearch")&&(this.baseSearch=a.baseSearch),this.fields={};for(var c=0;c0)}})}})})()}),require.define("/lib/async.js",function(a,b,c,d,e){(function(){"use strict";var b=a("./utils"),d=c||this;d.whilst=function(a,b,c){a=a||function(){return!1},b=b||function(a){a()},c=c||function(){};var e=function(e){e?c(e):d.whilst(a,b,c)};a()?b(e):c(null)},d.parallel=function(a,c){if(arguments.length>1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){},a.length===0&&c();var e=a.length,f=[],g=function(a){return function(d){if(d)c&&c(d),c=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),f[a]=g,--e===0&&(f.unshift(null),c&&c.apply(null,f))}}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};var e=function(a,c,d,f){if(!a){d.unshift(null),f.apply(null,d);return}a(function(a){if(a)f&&f(a),f=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),d.push(g),e(c[0],c.slice(1),d,f)}})};e(a[0],a.slice(1),[],c)},d.parallelMap=function(a,c,e){a=a||[],e=e||function(){};var f=[],g=function(a,b){return function(d){c(a,b,d)}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};if(!a.length)c();else{var e=function(a,d,f){var g=function(a){if(a)c(a),c=function(){};else{var f=b.toArray(arguments);f.shift(),e(d[0],d.slice(1),f)}},h=f;d.length?h.push(g):h.push(c),a.apply(null,h)};e(a[0],a.slice(1),[])}},d.sleep=function(a,b){setTimeout(function(){b()},a)},d.augment=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){var c=Array.prototype.slice.call(arguments);for(var d=0;d tag unexpected.")}},f.parseXMLData=function(a,b){var c={},d=a.getchildren();for(var e=0;e/g,">"),d||(a=a.replace(/\n/g," "),a=a.replace(/\r/g," ")),c&&(a=a.replace(/"/g,"""))),a}function w(a,b){return v(a,b,!0)}function x(a,b){return v(a,b,!1)}function y(a,b){return v(a,b,!1,!0)}function z(a,b,c){function g(a){return a}function h(a){if(a[0]==="{"){var b=a.substring(1).split("}",2),g=b[0],h=b[1],i=e[g];i===undefined&&(i=t[g],i===undefined&&(i="ns"+Object.keys(e).length),i!=="xml"&&(e[g]=i)),i?d[a]=f("%s:%s",i,h):d[a]=h}else{if(c)throw new Error("cannot use non-qualified names with default_namespace option");d[a]=a}}var d={},e={};return c&&(e[c]=""),a.iter(null,function(a){var b,c=a.tag,e=a.text,f=a.items();if(c instanceof r&&d[c.text]===undefined)h(c.text);else if(typeof c=="string")h(c);else if(c!==null&&c!==o&&c!==p&&c!==q)throw new Error("Invalid tag type for serialization: "+c);e instanceof r&&d[e.text]===undefined&&h(e.text),f.forEach(function(a){var b=a[0],c=a[1];b instanceof r&&(b=b.text),d[b]===undefined&&h(b),c instanceof r&&d[c.text]===undefined&&h(c.text)})}),[d,e]}function A(a,b,c,d,e,h,i){var j=b.tag,k=b.text,l,m,n=h||h===0;a(Array(h+1).join(i));if(j===o)a(f("",x(k,c)));else if(j===q)a(f("",x(k,c)));else if(j===p)k=k||"",a(f("",k));else{j=d[j];if(j===undefined)k&&a(y(k,c)),b.iter(function(b){A(a,b,c,d,null,n?h+1:!1,i)});else{a("<"+j),l=b.items();if(l||e)l.sort(),l.forEach(function(b){var e=b[0],g=b[1];e instanceof r&&(e=e.text),g instanceof r?g=d[g.text]:g=w(g,c),a(f(' %s="%s"',d[e],g))}),e&&(l=g.items(e),l.sort(function(a,b){return a[1]"),!k&&n&&a("\n"),k&&a(y(k,c)),b._children.forEach(function(b){A(a,b,c,d,null,n?h+1:!1,i)}),!k&&h&&a(Array(h+1).join(i)),a("")):a(" />")}}n&&a("\n")}function B(a,b){var c=new s;return c.parse(a,b),c}function C(a,b){return(new s(a)).write(b)}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./elementpath"),i=a("./treebuilder").TreeBuilder,j=a("./parser").get_parser,k=a("./constants"),l=0;m.prototype.toString=function(){return f("",this.tag,this._id)},m.prototype.makeelement=function(a,b){return new m(a,b)},m.prototype.len=function(){return this._children.length},m.prototype.getItem=function(a){return this._children[a]},m.prototype.setItem=function(a,b){this._children[a]=b},m.prototype.delItem=function(a){this._children.splice(a,1)},m.prototype.getSlice=function(a,b){return this._children.slice(a,b)},m.prototype.setSlice=function(a,b,c){var d,e=0;for(d=a;d\n");if(a.method==="text")_serialize_text(b,self._root,encoding);else{var c,d,e,f,h=z(this._root,a.encoding,a.default_namespace);c=h[0],d=h[1],a.hasOwnProperty("indent")?(e=0,f=(new Array(a.indent+1)).join(" ")):e=!1;if(a.method==="xml")A(function(a){b.push(a)},this._root,a.encoding,c,d,e,f);else throw new Error("unknown serialization method "+a.method)}return b.join("")};var t={"http://www.w3.org/XML/1998/namespace":"xml","http://www.w3.org/1999/xhtml":"html","http://www.w3.org/1999/02/22-rdf-syntax-ns#":"rdf","http://schemas.xmlsoap.org/wsdl/":"wsdl","http://www.w3.org/2001/XMLSchema":"xs","http://www.w3.org/2001/XMLSchema-instance":"xsi","http://purl.org/dc/elements/1.1/":"dc"};c.PI=q,c.Comment=o,c.CData=p,c.ProcessingInstruction=q,c.SubElement=n,c.QName=r,c.ElementTree=s,c.ElementPath=h,c.Element=function(a,b){return new m(a,b)},c.XML=function(a){var b=new s;return b.parse(a)},c.parse=B,c.register_namespace=u,c.tostring=C}),require.define("/node_modules/elementtree/lib/sprintf.js",function(a,b,c,d,e){function h(a){var b,c,d=a,e=0,h=1,i="return '";for(b=0;b100&&(i={});if(b.charAt(0)==="/")throw new h(null,"Cannot use absolute path on element");d=k(b),c=[];function o(){return d.shift()}j=o();for(;;){var p=j[1]||"";l=r[p](o,j);if(!l)throw new h(null,f("Invalid path: %s",b));c.push(l),j=o();if(!j)break;j[1]==="/"&&(j=o());if(!j)break}i[b]=c}d=[a],n=new s(a);for(e=0,g=c.length;e0?c[0]:null}function v(a,b,c){var d=t(a,b);return d&&d.length>0?d[0].text:c}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./errors").SyntaxError,i={},j=new RegExp("('[^']*'|\"[^\"]*\"|::|//?|\\.\\.|\\(\\)|[/.*:\\[\\]\\(\\)@=])|((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|\\s+","g"),k=g.findall.bind(null,j),r={"":l,"*":m,".":n,"..":p,"//":o,"[":q};c.find=u,c.findall=t,c.findtext=v}),require.define("/node_modules/elementtree/lib/errors.js",function(a,b,c,d,e){function h(a,b){b=b||g("Syntax Error at token %s",a.toString()),this.token=a,this.message=b,Error.call(this,b)}var f=a("util"),g=a("./sprintf").sprintf;f.inherits(h,Error),c.SyntaxError=h}),require.define("util",function(a,b,c,d,e){function g(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&g(a.__proto__)}function h(a){return a instanceof RegExp||typeof a=="object"&&Object.prototype.toString.call(a)==="[object RegExp]"}function i(a){if(a instanceof Date)return!0;if(typeof a!="object")return!1;var b=Date.prototype&&n(Date.prototype),c=a.__proto__&&n(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}function j(a){return a<10?"0"+a.toString(10):a.toString(10)}function l(){var a=new Date,b=[j(a.getHours()),j(a.getMinutes()),j(a.getSeconds())].join(":");return[a.getDate(),k[a.getMonth()],b].join(" ")}var f=a("events");c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,d,e){function k(a,d){if(a&&typeof a.inspect=="function"&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(d);switch(typeof a){case"undefined":return j("undefined","undefined");case"string":var e="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return j(e,"string");case"number":return j(""+a,"number");case"boolean":return j(""+a,"boolean")}if(a===null)return j("null","null");var l=m(a),o=b?n(a):l;if(typeof a=="function"&&o.length===0){if(h(a))return j(""+a,"regexp");var p=a.name?": "+a.name:"";return j("[Function"+p+"]","special")}if(i(a)&&o.length===0)return j(a.toUTCString(),"date");var q,r,s;g(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]);if(typeof a=="function"){var t=a.name?": "+a.name:"";q=h(a)?" "+a:" [Function"+t+"]"}else q="";i(a)&&(q=" "+a.toUTCString());if(o.length===0)return s[0]+q+s[1];if(d<0)return h(a)?j(""+a,"regexp"):j("[Object]","special");f.push(a);var u=o.map(function(b){var c,e;a.__lookupGetter__&&(a.__lookupGetter__(b)?a.__lookupSetter__(b)?e=j("[Getter/Setter]","special"):e=j("[Getter]","special"):a.__lookupSetter__(b)&&(e=j("[Setter]","special"))),l.indexOf(b)<0&&(c="["+b+"]"),e||(f.indexOf(a[b])<0?(d===null?e=k(a[b]):e=k(a[b],d-1),e.indexOf("\n")>-1&&(g(a)?e=e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):e="\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=j("[Circular]","special"));if(typeof c=="undefined"){if(r==="Array"&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=j(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=j(c,"string"))}return c+": "+e});f.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return w>50?u=s[0]+(q===""?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:u=s[0]+q+" "+u.join(", ")+" "+s[1],u}var f=[],j=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return e||(j=function(a,b){return a}),k(a,typeof d=="undefined"?2:d)};var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(a){},c.pump=null;var m=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},n=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},o=Object.create||function(a,b){var c;if(a===null)c={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return typeof b!="undefined"&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=o(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}}),require.define("events",function(a,b,c,d,e){process.EventEmitter||(process.EventEmitter=function(){});var f=c.EventEmitter=process.EventEmitter,g=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.toString.call(a)==="[object Array]"},h=10;f.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},f.prototype.emit=function(a){if(a==="error")if(!this._events||!this._events.error||g(this._events.error)&&!this._events.error.length)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if(typeof b=="function"){switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0}if(g(b)){var c=Array.prototype.slice.call(arguments,1),d=b.slice();for(var e=0,f=d.length;e0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var d=c.indexOf(b);if(d<0)return this;c.splice(d,1),c.length==0&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),require.define("/node_modules/elementtree/lib/treebuilder.js",function(a,b,c,d,e){function f(b){this._data=[],this._elem=[],this._last=null,this._tail=null,b||(b=a("./elementtree").Element),this._factory=b}f.prototype.close=function(){return this._last},f.prototype._flush=function(){if(this._data){if(this._last!==null){var a=this._data.join("");this._tail?this._last.tail=a:this._last.text=a}this._data=[]}},f.prototype.data=function(a){this._data.push(a)},f.prototype.start=function(a,b){this._flush();var c=this._factory(a,b);this._last=c,this._elem.length&&this._elem[this._elem.length-1].append(c),this._elem.push(c),this._tail=null},f.prototype.end=function(a){this._flush(),this._last=this._elem.pop();if(this._last.tag!==a)throw new Error("end tag mismatch");return this._tail=1,this._last},c.TreeBuilder=f}),require.define("/node_modules/elementtree/lib/parser.js",function(a,b,c,d,e){function h(a){if(a==="sax")return g.sax;throw new Error("Invalid parser: "+a)}var f=a("util"),g=a("./parsers/index");c.get_parser=h}),require.define("/node_modules/elementtree/lib/parsers/index.js",function(a,b,c,d,e){c.sax=a("./sax")}),require.define("/node_modules/elementtree/lib/parsers/sax.js",function(a,b,c,d,e){function i(a){this.parser=g.parser(!0),this.target=a?a:new h,this.parser.onopentag=this._handleOpenTag.bind(this),this.parser.ontext=this._handleText.bind(this),this.parser.oncdata=this._handleCdata.bind(this),this.parser.ondoctype=this._handleDoctype.bind(this),this.parser.oncomment=this._handleComment.bind(this),this.parser.onclosetag=this._handleCloseTag.bind(this),this.parser.onerror=this._handleError.bind(this)}var f=a("util"),g=a("sax"),h=a("./../treebuilder").TreeBuilder;i.prototype._handleOpenTag=function(a){this.target.start(a.name,a.attributes)},i.prototype._handleText=function(a){this.target.data(a)},i.prototype._handleCdata=function(a){this.target.data(a)},i.prototype._handleDoctype=function(a){},i.prototype._handleComment=function(a){},i.prototype._handleCloseTag=function(a){this.target.end(a)},i.prototype._handleError=function(a){throw a},i.prototype.feed=function(a){this.parser.write(a)},i.prototype.close=function(){return this.parser.close(),this.target.close()},c.XMLParser=i}),require.define("/node_modules/sax/package.json",function(a,b,c,d,e){b.exports={main:"lib/sax.js"}}),require.define("/node_modules/sax/lib/sax.js",function(a,b,c,d,e){(function(b){function d(a,c){if(!(this instanceof d))return new d(a,c);var e=this;f(e),e.q=e.c="",e.bufferCheckPosition=b.MAX_BUFFER_LENGTH,e.opt=c||{},e.tagCase=e.opt.lowercasetags?"toLowerCase":"toUpperCase",e.tags=[],e.closed=e.closedRoot=e.sawRoot=!1,e.tag=e.error=null,e.strict=!!a,e.noscript=!!a||!!e.opt.noscript,e.state=B.BEGIN,e.ENTITIES=Object.create(b.ENTITIES),e.attribList=[],e.opt.xmlns&&(e.ns=Object.create(x)),e.position=e.line=e.column=0,C(e,"onready")}function e(a){var d=Math.max(b.MAX_BUFFER_LENGTH,10),e=0;for(var f=0,g=c.length;fd)switch(c[f]){case"textNode":E(a);break;case"cdata":D(a,"oncdata",a.cdata),a.cdata="";break;case"script":D(a,"onscript",a.script),a.script="";break;default:G(a,"Max buffer length exceeded: "+c[f])}e=Math.max(e,h)}a.bufferCheckPosition=b.MAX_BUFFER_LENGTH-e+a.position}function f(a){for(var b=0,d=c.length;b",a.state=B.TEXT;return}a.tagName=c;var f=a.tags.length;while(f-->b){var g=a.tag=a.tags.pop();a.tagName=a.tag.name,D(a,"onclosetag",a.tagName);var h={};for(var i in g.ns)h[i]=g.ns[i];var j=a.tags[a.tags.length-1]||a;a.opt.xmlns&&g.ns!==j.ns&&Object.keys(g.ns).forEach(function(b){var c=g.ns[b];D(a,"onclosenamespace",{prefix:b,uri:c})})}b===0&&(a.closedRoot=!0),a.tagName=a.attribValue=a.attribName="",a.attribList.length=0,a.state=B.TEXT}function O(a){var b=a.entity.toLowerCase(),c,d="";return a.ENTITIES[b]?a.ENTITIES[b]:(b.charAt(0)==="#"&&(b.charAt(1)==="x"?(b=b.slice(2),c=parseInt(b,16),d=c.toString(16)):(b=b.slice(1),c=parseInt(b,10),d=c.toString(10))),b=b.replace(/^0+/,""),d.toLowerCase()!==b?(I(a,"Invalid character entity"),"&"+a.entity+";"):String.fromCharCode(c))}function P(a){var b=this;if(this.error)throw this.error;if(b.closed)return G(b,"Cannot write after close. Assign an onready handler.");if(a===null)return H(b);var c=0,d="";while(b.c=d=a.charAt(c++)){b.position++,d==="\n"?(b.line++,b.column=0):b.column++;switch(b.state){case B.BEGIN:d==="<"?b.state=B.OPEN_WAKA:A(l,d)&&(I(b,"Non-whitespace before first tag."),b.textNode=d,b.state=B.TEXT);continue;case B.TEXT:if(b.sawRoot&&!b.closedRoot){var f=c-1;while(d&&d!=="<"&&d!=="&")d=a.charAt(c++),d&&(b.position++,d==="\n"?(b.line++,b.column=0):b.column++);b.textNode+=a.substring(f,c-1)}d==="<"?b.state=B.OPEN_WAKA:(A(l,d)&&(!b.sawRoot||b.closedRoot)&&I("Text data outside of root node."),d==="&"?b.state=B.TEXT_ENTITY:b.textNode+=d);continue;case B.SCRIPT:d==="<"?b.state=B.SCRIPT_ENDING:b.script+=d;continue;case B.SCRIPT_ENDING:d==="/"?(D(b,"onscript",b.script),b.state=B.CLOSE_TAG,b.script="",b.tagName=""):(b.script+="<"+d,b.state=B.SCRIPT);continue;case B.OPEN_WAKA:d==="!"?(b.state=B.SGML_DECL,b.sgmlDecl=""):z(l,d)||(z(o,d)?(b.startTagPosition=b.position-1,b.state=B.OPEN_TAG,b.tagName=d):d==="/"?(b.startTagPosition=b.position-1,b.state=B.CLOSE_TAG,b.tagName=""):d==="?"?(b.state=B.PROC_INST,b.procInstName=b.procInstBody=""):(I(b,"Unencoded <"),b.textNode+="<"+d,b.state=B.TEXT));continue;case B.SGML_DECL:(b.sgmlDecl+d).toUpperCase()===t?(D(b,"onopencdata"),b.state=B.CDATA,b.sgmlDecl="",b.cdata=""):b.sgmlDecl+d==="--"?(b.state=B.COMMENT,b.comment="",b.sgmlDecl=""):(b.sgmlDecl+d).toUpperCase()===u?(b.state=B.DOCTYPE,(b.doctype||b.sawRoot)&&I(b,"Inappropriately located doctype declaration"),b.doctype="",b.sgmlDecl=""):d===">"?(D(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=B.TEXT):z(q,d)?(b.state=B.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case B.SGML_DECL_QUOTED:d===b.q&&(b.state=B.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case B.DOCTYPE:d===">"?(b.state=B.TEXT,D(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,d==="["?b.state=B.DOCTYPE_DTD:z(q,d)&&(b.state=B.DOCTYPE_QUOTED,b.q=d));continue;case B.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=B.DOCTYPE);continue;case B.DOCTYPE_DTD:b.doctype+=d,d==="]"?b.state=B.DOCTYPE:z(q,d)&&(b.state=B.DOCTYPE_DTD_QUOTED,b.q=d);continue;case B.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=B.DOCTYPE_DTD,b.q="");continue;case B.COMMENT:d==="-"?b.state=B.COMMENT_ENDING:b.comment+=d;continue;case B.COMMENT_ENDING:d==="-"?(b.state=B.COMMENT_ENDED,b.comment=F(b.opt,b.comment),b.comment&&D(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=B.COMMENT);continue;case B.COMMENT_ENDED:d!==">"?(I(b,"Malformed comment"),b.comment+="--"+d,b.state=B.COMMENT):b.state=B.TEXT;continue;case B.CDATA:d==="]"?b.state=B.CDATA_ENDING:b.cdata+=d;continue;case B.CDATA_ENDING:d==="]"?b.state=B.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=B.CDATA);continue;case B.CDATA_ENDING_2:d===">"?(b.cdata&&D(b,"oncdata",b.cdata),D(b,"onclosecdata"),b.cdata="",b.state=B.TEXT):d==="]"?b.cdata+="]":(b.cdata+="]]"+d,b.state=B.CDATA);continue;case B.PROC_INST:d==="?"?b.state=B.PROC_INST_ENDING:z(l,d)?b.state=B.PROC_INST_BODY:b.procInstName+=d;continue;case B.PROC_INST_BODY:if(!b.procInstBody&&z(l,d))continue;d==="?"?b.state=B.PROC_INST_ENDING:z(q,d)?(b.state=B.PROC_INST_QUOTED,b.q=d,b.procInstBody+=d):b.procInstBody+=d;continue;case B.PROC_INST_ENDING:d===">"?(D(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=B.TEXT):(b.procInstBody+="?"+d,b.state=B.PROC_INST_BODY);continue;case B.PROC_INST_QUOTED:b.procInstBody+=d,d===b.q&&(b.state=B.PROC_INST_BODY,b.q="");continue;case B.OPEN_TAG:z(p,d)?b.tagName+=d:(J(b),d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:(A(l,d)&&I(b,"Invalid character in tag name"),b.state=B.ATTRIB));continue;case B.OPEN_TAG_SLASH:d===">"?(M(b,!0),N(b)):(I(b,"Forward-slash in opening tag not followed by >"),b.state=B.ATTRIB);continue;case B.ATTRIB:if(z(l,d))continue;d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:z(o,d)?(b.attribName=d,b.attribValue="",b.state=B.ATTRIB_NAME):I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME:d==="="?b.state=B.ATTRIB_VALUE:z(l,d)?b.state=B.ATTRIB_NAME_SAW_WHITE:z(p,d)?b.attribName+=d:I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME_SAW_WHITE:if(d==="=")b.state=B.ATTRIB_VALUE;else{if(z(l,d))continue;I(b,"Attribute without value"),b.tag.attributes[b.attribName]="",b.attribValue="",D(b,"onattribute",{name:b.attribName,value:""}),b.attribName="",d===">"?M(b):z(o,d)?(b.attribName=d,b.state=B.ATTRIB_NAME):(I(b,"Invalid attribute name"),b.state=B.ATTRIB)}continue;case B.ATTRIB_VALUE:if(z(l,d))continue;z(q,d)?(b.q=d,b.state=B.ATTRIB_VALUE_QUOTED):(I(b,"Unquoted attribute value"),b.state=B.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case B.ATTRIB_VALUE_QUOTED:if(d!==b.q){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}L(b),b.q="",b.state=B.ATTRIB;continue;case B.ATTRIB_VALUE_UNQUOTED:if(A(s,d)){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}L(b),d===">"?M(b):b.state=B.ATTRIB;continue;case B.CLOSE_TAG:if(!b.tagName){if(z(l,d))continue;A(o,d)?I(b,"Invalid tagname in closing tag."):b.tagName=d}else d===">"?N(b):z(p,d)?b.tagName+=d:(A(l,d)&&I(b,"Invalid tagname in closing tag"),b.state=B.CLOSE_TAG_SAW_WHITE);continue;case B.CLOSE_TAG_SAW_WHITE:if(z(l,d))continue;d===">"?N(b):I("Invalid characters in closing tag");continue;case B.TEXT_ENTITY:case B.ATTRIB_VALUE_ENTITY_Q:case B.ATTRIB_VALUE_ENTITY_U:switch(b.state){case B.TEXT_ENTITY:var g=B.TEXT,h="textNode";break;case B.ATTRIB_VALUE_ENTITY_Q:var g=B.ATTRIB_VALUE_QUOTED,h="attribValue";break;case B.ATTRIB_VALUE_ENTITY_U:var g=B.ATTRIB_VALUE_UNQUOTED,h="attribValue"}d===";"?(b[h]+=O(b),b.entity="",b.state=g):z(r,d)?b.entity+=d:(I("Invalid character entity"),b[h]+="&"+b.entity+d,b.entity="",b.state=g);continue;default:throw new Error(b,"Unknown state: "+b.state)}}return b.position>=b.bufferCheckPosition&&e(b),b}b.parser=function(a,b){return new d(a,b)},b.SAXParser=d,b.SAXStream=k,b.createStream=j,b.MAX_BUFFER_LENGTH=65536;var c=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];b.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(a){function b(){this.__proto__=a}return b.prototype=a,new b}),Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.__proto__}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),d.prototype={end:function(){H(this)},write:P,resume:function(){return this.error=null,this},close:function(){return this.write(null)},end:function(){return this.write(null)}};try{var g=a("stream").Stream}catch(h){var g=function(){}}var i=b.EVENTS.filter(function(a){return a!=="error"&&a!=="end"});k.prototype=Object.create(g.prototype,{constructor:{value:k}}),k.prototype.write=function(a){return this._parser.write(a.toString()),this.emit("data",a),!0},k.prototype.end=function(a){return a&&a.length&&this._parser.write(a.toString()),this._parser.end(),!0},k.prototype.on=function(a,b){var c=this;return!c._parser["on"+a]&&i.indexOf(a)!==-1&&(c._parser["on"+a]=function(){var b=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);b.splice(0,0,a),c.emit.apply(c,b)}),g.prototype.on.call(c,a,b)};var l="\r\n\t ",m="0124356789",n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",o=n+"_:",p=o+m+"-.",q="'\"",r=m+n+"#",s=l+">",t="[CDATA[",u="DOCTYPE",v="http://www.w3.org/XML/1998/namespace",w="http://www.w3.org/2000/xmlns/",x={xml:v,xmlns:w};l=y(l),m=y(m),n=y(n),o=y(o),p=y(p),q=y(q),r=y(r),s=y(s);var B=0;b.STATE={BEGIN:B++,TEXT:B++,TEXT_ENTITY:B++,OPEN_WAKA:B++,SGML_DECL:B++,SGML_DECL_QUOTED:B++,DOCTYPE:B++,DOCTYPE_QUOTED:B++,DOCTYPE_DTD:B++,DOCTYPE_DTD_QUOTED:B++,COMMENT_STARTING:B++,COMMENT:B++,COMMENT_ENDING:B++,COMMENT_ENDED:B++,CDATA:B++,CDATA_ENDING:B++,CDATA_ENDING_2:B++,PROC_INST:B++,PROC_INST_BODY:B++,PROC_INST_QUOTED:B++,PROC_INST_ENDING:B++,OPEN_TAG:B++,OPEN_TAG_SLASH:B++,ATTRIB:B++,ATTRIB_NAME:B++,ATTRIB_NAME_SAW_WHITE:B++,ATTRIB_VALUE:B++,ATTRIB_VALUE_QUOTED:B++,ATTRIB_VALUE_UNQUOTED:B++,ATTRIB_VALUE_ENTITY_Q:B++,ATTRIB_VALUE_ENTITY_U:B++,CLOSE_TAG:B++,CLOSE_TAG_SAW_WHITE:B++,SCRIPT:B++,SCRIPT_ENDING:B++},b.ENTITIES={apos:"'",quot:'"',amp:"&",gt:">",lt:"<"};for(var B in b.STATE)b.STATE[b.STATE[B]]=B;B=b.STATE})(typeof c=="undefined"?sax={}:c)}),require.define("stream",function(a,b,c,d,e){function h(){f.EventEmitter.call(this)}var f=a("events"),g=a("util");g.inherits(h,f.EventEmitter),b.exports=h,h.Stream=h,h.prototype.pipe=function(a,b){function d(b){a.writable&&!1===a.write(b)&&c.pause&&c.pause()}function e(){c.readable&&c.resume&&c.resume()}function g(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.end()}function h(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.destroy()}function i(a){j();if(this.listeners("error").length===0)throw a}function j(){c.removeListener("data",d),a.removeListener("drain",e),c.removeListener("end",g),c.removeListener("close",h),c.removeListener("error",i),a.removeListener("error",i),c.removeListener("end",j),c.removeListener("close",j),a.removeListener("end",j),a.removeListener("close",j)}var c=this;c.on("data",d),a.on("drain",e),!a._isStdio&&(!b||b.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,c.on("end",g),c.on("close",h));var f=!1;return c.on("error",i),a.on("error",i),c.on("end",j),c.on("close",j),a.on("end",j),a.on("close",j),a.emit("pipe",c),a}}),require.define("/node_modules/elementtree/lib/constants.js",function(a,b,c,d,e){var f="sax";c.DEFAULT_PARSER=f}),require.define("/lib/modularinputs/inputdefinition.js",function(a,b,c,d,e){(function(){function e(){this.metadata={},this.inputs={}}var c=a("elementtree"),d=a("./utils");e.parse=function(a){var b=new e,f=c.parse(a).getroot().getchildren();for(var g=0;g=10?b=parseFloat(a.toString().substring(0,14)).toFixed(3):a.toString().length<=13||a.toString().indexOf(".")<10?b=parseFloat(a).toFixed(3):b=(parseFloat(a.toString().substring(0,14))/1e3).toFixed(3)):a.toString().length===13?b=(parseFloat(a)/1e3).toFixed(3):a.toString().length<=12?b=parseFloat(a).toFixed(3):b=parseFloat(a.toString().substring(0,13)/1e3).toFixed(3),b)},e.prototype._writeTo=function(a){if(!this.data)throw new Error("Events must have at least the data field set to be written to XML.");var b=c.Element("event");this.stanza&&b.set("stanza",this.stanza),b.set("unbroken",(+this.unbroken).toString()),!d.isUndefined(this.time)&&this.time!==null&&(c.SubElement(b,"time").text=e.formatTime(this.time).toString()),typeof this.data=="object"&&(this.data=JSON.stringify(this.data));var f=[{tag:"source",text:this.source},{tag:"sourcetype",text:this.sourcetype},{tag:"index",text:this.index},{tag:"host",text:this.host},{tag:"data",text:this.data}];for(var g=0;g"),this._headerWritten=!0);try{a._writeTo(this._out)}catch(b){throw b.message==="Events must have at least the data field set to be written to XML."?(e.warn("",b.message,this._err),b):(e.error("",b.message,this._err),b)}},h.prototype.writeXMLDocument=function(a){var b=c.tostring(a,{xml_declaration:!1});this._out.write(b)},h.prototype.close=function(){this._out.write("")},b.exports=h})()}),require.define("/lib/modularinputs/logger.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./utils"),e=c||this;e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL",e._log=function(a,b,c,d){d=d||process.stderr,b&&b.length>0&&(b+=" ");var e=a+" Modular input "+b+c+"\n";d.write(e)},e.debug=function(a,b,c){try{e._log(e.DEBUG,a,b,c)}catch(d){throw d}},e.info=function(a,b,c){try{e._log(e.INFO,a,b,c)}catch(d){throw d}},e.warn=function(a,b,c){try{e._log(e.WARN,a,b,c)}catch(d){throw d}},e.error=function(a,b,c){try{e._log(e.ERROR,a,b,c)}catch(d){throw d}},e.fatal=function(a,b,c){try{e._log(e.FATAL,a,b,c)}catch(d){throw d}},b.exports=e})()}),require.define("/lib/modularinputs/argument.js",function(a,b,c,d,e){(function(){function e(a){a||(a={}),this.name=d.isUndefined(a.name)?"":a.name,this.description=d.isUndefined(a.description)?null:a.description,this.validation=d.isUndefined(a.validation)?null:a.validation,this.dataType=d.isUndefined(a.dataType)?e.dataTypeString:a.dataType,this.requiredOnEdit=d.isUndefined(a.requiredOnEdit)?!1:a.requiredOnEdit,this.requiredOnCreate=d.isUndefined(a.requiredOnCreate)?!1:a.requiredOnCreate}var c=a("elementtree"),d=a("./utils");e.dataTypeBoolean="BOOLEAN",e.dataTypeNumber="NUMBER",e.dataTypeString="STRING",e.prototype.addToDocument=function(a){var b=c.SubElement(a,"arg");b.set("name",this.name),this.description&&(c.SubElement(b,"description").text=this.description),this.validation&&(c.SubElement(b,"validation").text=this.validation);var d=[{tag:"data_type",value:this.dataType},{tag:"required_on_edit",value:this.requiredOnEdit},{tag:"required_on_create",value:this.requiredOnCreate}];for(var e=0;e")){clearTimeout(o);var g=h.parse(c);a._inputDefinition=g,k._inputDefinition=g,f.chain([function(b){f.parallelEach(Object.keys(a._inputDefinition.inputs),function(b,c,e){var g=a._inputDefinition.inputs[b];f.chain([function(c){a.start(b,g,c)},function(c){a.streamEvents(b,g,d,c)},function(c){a.end(b,g,c)}],function(a){e(a,a?1:0)})},function(a){b(a,a?1:0)})}],function(a){d._headerWritten&&d.close(),j(a,a?1:0)})}})}else if(b.length>=2&&b[1].toString().toLowerCase()==="--scheme"){var p=a.getScheme();if(!p)l.fatal("","script returned a null scheme.",d._err),j(null,1);else try{d.writeXMLDocument(p.toXML()),j(null,0)}catch(q){l.fatal("","script could not return the scheme, error: "+q,d._err),j(q,1)}}else if(b.length>=2&&b[1].toString().toLowerCase()==="--validate-arguments"){var r=setTimeout(function(){j(new Error("Receiving validation definition prior to validating timed out."),1)},30500);i.on("data",function(b){n=Buffer.concat([n,b]);var h=n.toString("utf8",0,n.length).trim();e.endsWith(h,"")&&(clearTimeout(r),f.chain([function(b){try{if(e.isUndefined(a.validateInput))b();else{var c=g.parse(n.toString("utf8",0,n.length));a.validateInput(c,b)}}catch(d){b(d)}}],function(a){if(a){l.error("",a.message),l.error("","Stack trace for a modular input error: "+a.stack);try{var b=c.Element("error");c.SubElement(b,"message").text=a.message,d.writeXMLDocument(b),j(a,1)}catch(e){j(e,1)}}else j(null,0)}))})}else{var s="Invalid arguments to modular input script: "+b.join()+"\n";l.error("",s,d._err),j(s,1)}},m.service=function(){if(this._service)return this._service;if(!this._inputDefinition)return null;var a=this._inputDefinition.metadata.server_uri,b=this._inputDefinition.metadata.session_key,c=d.parse(a),e=c.protocol.replace(":",""),f=c.hostname,g=c.port;return this._service=new k({scheme:e,host:f,port:g,token:b}),this._service},m.prototype.setup=function(a){a()},m.prototype.start=function(a,b,c){c()},m.prototype.end=function(a,b,c){c()},m.prototype.teardown=function(a){a()},b.exports=m})()}),require.define("url",function(a,b,c,d,e){function v(a,b,c){if(a&&typeof a=="object"&&a.href)return a;if(typeof a!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d={},e=a;for(var h=0,j=e.length;hn)d.hostname="";else{var G=d.hostname.split(/\./);for(var h=0,j=G.length;h127?I+="x":I+=H[J];if(!I.match(o)){var L=G.slice(0,h),M=G.slice(h+1),N=H.match(p);N&&(L.push(N[1]),M.unshift(N[2])),M.length&&(e="/"+M.join(".")+e),d.hostname=L.join(".");break}}}}d.hostname=d.hostname.toLowerCase();var O=d.hostname.split("."),P=[];for(var h=0;h0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}a.search=b.search,a.query=b.query;if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.href=w(a),a}if(!h.length)return delete a.pathname,a.search?delete a.path:a.path="/"+a.search,a.href=w(a),a;var k=h.slice(-1)[0],l=(a.host||b.host)&&(k==="."||k==="..")||k==="",m=0;for(var n=h.length;n>=0;n--)k=h[n],k=="."?h.splice(n,1):k===".."?(h.splice(n,1),m++):m&&(h.splice(n,1),m--);if(!f&&!g)for(;m--;m)h.unshift("..");f&&h[0]!==""&&(!h[0]||h[0].charAt(0)!=="/")&&h.unshift(""),l&&h.join("/").substr(-1)!=="/"&&h.push("");var o=h[0]===""||h[0]&&h[0].charAt(0)==="/";if(i){a.hostname=a.host=o?"":h.length?h.shift():"";var j=a.host&&a.host.indexOf("@")>0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}f=f||a.host&&h.length,f&&!o&&h.unshift(""),a.pathname=h.join("/");if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.auth=b.auth||a.auth,a.slashes=a.slashes||b.slashes,a.href=w(a),a}function z(a){var b={},c=h.exec(a);return c&&(c=c[0],b.port=c.substr(1),a=a.substr(0,a.length-c.length)),a&&(b.hostname=a),b}var f={encode:function(a){return a}};c.parse=v,c.resolve=x,c.resolveObject=y,c.format=w;var g=/^([a-z0-9.+-]+:)/i,h=/:[0-9]+$/,i=["<",">",'"',"`"," ","\r","\n","\t"],j=["{","}","|","\\","^","~","[","]","`"].concat(i),k=["'"],l=["%","/","?",";","#"].concat(j).concat(k),m=["/","@","?","#"].concat(i),n=255,o=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,p=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,q={javascript:!0,"javascript:":!0},r={javascript:!0,"javascript:":!0},s={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},t={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},u=a("querystring")}),require.define("querystring",function(a,b,c,d,e){function j(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function k(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";d.push(f)}return d}b||(b="/");if(require._core[a])return a;var c=require.modules.path();b=c.resolve("/",b);var d=b||"/";if(a.match(/^(?:\.\.?\/|\/)/)){var e=g(c.resolve(d,a))||h(c.resolve(d,a));if(e)return e}var f=i(a,d);if(f)return f;throw new Error("Cannot find module '"+a+"'")}}(),require.alias=function(a,b){var c=require.modules.path(),d=null;try{d=require.resolve(a+"/package.json","/")}catch(e){d=require.resolve(a,"/")}var f=c.dirname(d),g=(Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b})(require.modules);for(var h=0;h0){var c=a.shift();c()}}},!0),function(c){b?(a.push(c),window.postMessage("browserify-tick","*")):setTimeout(c,0)}}()),process.title||(process.title="browser"),process.binding||(process.binding=function(a){if(a==="evals")return require("vm");throw new Error("No such module")}),process.cwd||(process.cwd=function(){return"."}),require.define("path",function(a,b,c,d,e){function f(a,b){var c=[];for(var d=0;d=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var h=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var a="",b=!1;for(var c=arguments.length;c>=-1&&!b;c--){var d=c>=0?arguments[c]:process.cwd();if(typeof d!="string"||!d)continue;a=d+"/"+a,b=d.charAt(0)==="/"}return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=a.charAt(0)==="/",c=a.slice(-1)==="/";return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),!a&&!b&&(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(f(a,function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var b=h.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=h.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return h.exec(a)[3]||""}}),require.define("/tests/test_utils.js",function(a,b,c,d,e){c.setup=function(){var b=a("../index");return b.Logger.setLevel("ALL"),{"Callback#callback to object success":function(a){var b=function(a){a(null,"one","two")};b(function(b,c,d){a.strictEqual(c,"one"),a.strictEqual(d,"two"),a.done()})},"Callback#callback to object error - single argument":function(a){var b=function(a){a("one")};b(function(b,c,d){a.strictEqual(b,"one"),a.ok(!c),a.ok(!d),a.done()})},"Callback#callback to object error - multi argument":function(a){var b=function(a){a(["one","two"])};b(function(b,c,d){a.strictEqual(b[0],"one"),a.strictEqual(b[1],"two"),a.ok(!c),a.ok(!d),a.done()})},"keyOf works":function(a){a.ok(b.Utils.keyOf(3,{a:3,b:5})),a.ok(!b.Utils.keyOf(3,{a:12,b:6})),a.done()},bind:function(a){var c;(function(){c=function(a){this.a=a}})();var d={},e=b.Utils.bind(d,c);e(12),a.strictEqual(d.a,12),a.done()},trim:function(a){a.strictEqual(b.Utils.trim(" test of something \n\r \t"),"test of something");var c=String.prototype.trim;String.prototype.trim=null,a.strictEqual(b.Utils.trim(" test of something \n\r \t"),"test of something"),String.prototype.trim=c,a.done()},indexOf:function(a){a.strictEqual(b.Utils.indexOf([1,2,3,4,5],3),2),a.strictEqual(b.Utils.indexOf([1,2,3,4,3],3),2),a.strictEqual(b.Utils.indexOf([1,2,3,4,5],12),-1),a.done()},contains:function(a){a.ok(b.Utils.contains([1,2,3,4,5],3)),a.ok(b.Utils.contains([1,2,3,4,3],3)),a.ok(!b.Utils.contains([1,2,3,4,5],12)),a.done()},startsWith:function(a){a.ok(b.Utils.startsWith("abcdefg","abc")),a.ok(!b.Utils.startsWith("bcdefg","abc")),a.done()},endsWith:function(a){a.ok(b.Utils.endsWith("abcdef","def")),a.ok(!b.Utils.endsWith("abcdef","bcd")),a.done()},toArray:function(a){(function(){var c=b.Utils.toArray(arguments),d=[1,2,3,4,5];for(var e=0;e=e.ALL&&g.apply(null,arguments)},error:function(){process.env.LOG_LEVEL>=e.ERROR&&i.apply(null,arguments)},warn:function(){process.env.LOG_LEVEL>=e.WARN&&h.apply(null,arguments)},info:function(){process.env.LOG_LEVEL>=e.INFO&&j.apply(null,arguments)},printMessages:function(a){a=a||[];for(var b=0;b=0},e.startsWith=function(a,b){var c=a.match("^"+b);return c&&c.length>0&&c[0]===b},e.endsWith=function(a,b){var c=a.match(b+"$");return c&&c.length>0&&c[0]===b};var f=Object.prototype.toString;e.toArray=function(a){return Array.prototype.slice.call(a)},e.isArray=Array.isArray||function(a){return f.call(a)==="[object Array]"},e.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},e.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)},e.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},e.isObject=function(a){return a===Object(a)},e.isEmpty=function(a){if(e.isArray(a)||e.isString(a))return a.length===0;for(var b in a)if(this.hasOwnProperty.call(a,b))return!1;return!0},e.forEach=function(a,b,c){if(a===null)return;if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;dh)return 1}return 0}}),h.Sharing={USER:"user",APP:"app",GLOBAL:"global",SYSTEM:"system"}})()}),require.define("/lib/paths.js",function(a,b,c,d,e){(function(){"use strict";var a=c||this;a.Paths={apps:"/services/apps/local",capabilities:"authorization/capabilities",configurations:"configs",dataModels:"datamodel/model",deploymentClient:"deployment/client",deploymentServers:"deployment/server",deploymentServerClasses:"deployment/serverclass",deploymentTenants:"deployment/tenants",eventTypes:"saved/eventtypes",firedAlerts:"alerts/fired_alerts",indexes:"data/indexes",info:"/services/server/info",inputs:null,jobs:"search/jobs",licenseGroups:"licenser/groups",licenseMessages:"licenser/messages",licensePools:"licenser/pools",licenseSlaves:"licenser/slaves",licenseStacks:"licenser/stacks",licenses:"licenser/licenses",loggers:"server/logger",login:"/services/auth/login",messages:"messages",passwords:"admin/passwords",parser:"search/parser",pivot:"datamodel/pivot",properties:"properties",roles:"authorization/roles",savedSearches:"saved/searches",settings:"server/settings",storagePasswords:"storage/passwords",users:"/services/authentication/users",typeahead:"search/typeahead",views:"data/ui/views",currentUser:"/services/authentication/current-context",submitEvent:"/services/receivers/simple"}})()}),require.define("/lib/jquery.class.js",function(a,b,c,d,e){(function(){var a=c||this,b=!1,d=/xyz/.test(function(){return xyz})?/\b_super\b/:/.*/;a.Class=function(){},a.Class.extend=function(a){function g(){!b&&this.init&&this.init.apply(this,arguments)}var c=this.prototype;b=!0;var e=new this;b=!1;for(var f in a)e[f]=typeof a[f]=="function"&&typeof c[f]=="function"&&d.test(a[f])?function(a,b){return function(){var d=this._super;this._super=c[a];var e=b.apply(this,arguments);return this._super=d,e}}(f,a[f]):a[f];return g.prototype=e,g.constructor=g,g.extend=arguments.callee,g}})()}),require.define("/lib/http.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./jquery.class").Class,e=a("./log").Logger,f=a("./utils"),g=a("cookie"),h=c||this,i=null,j={5:function(a){var b=a.query||{},c=a.post||{},d=b.output_mode||c.output_mode||"json";return f.startsWith(d,"json")||(d="json"),b.output_mode=d,b},4:function(a){return a.query||{}},"default":function(a){return j[5](a)},none:function(a){return a.query||{}}};b.exports=h=i=d.extend({init:function(){this.get=f.bind(this,this.get),this.del=f.bind(this,this.del),this.post=f.bind(this,this.post),this.request=f.bind(this,this.request),this._buildResponse=f.bind(this,this._buildResponse),this._setSplunkVersion("none"),this._cookieStore={}},_setSplunkVersion:function(a){this.version=a},_getCookieString:function(){var a="";return f.forEach(this._cookieStore,function(b,c){a+=c,a+="=",a+=b,a+="; "}),a},_parseCookieHeader:function(a){var b=g.parse(a),c={};return f.forEach(b,function(a,b){if(c.key)return;c.key=b,c.value=a}),c},get:function(a,b,c,d,e){var f={method:"GET",headers:b,timeout:d,query:c};return this.request(a,f,e)},post:function(a,b,c,d,e){b["Content-Type"]="application/x-www-form-urlencoded";var f={method:"POST",headers:b,timeout:d,post:c};return this.request(a,f,e)},del:function(a,b,c,d,e){var f={method:"DELETE",headers:b,timeout:d,query:c};return this.request(a,f,e)},request:function(a,b,c){var d=this,e=function(a){c=c||function(){};var b=a.response.headers["set-cookie"];b&&f.forEach(b,function(a){var b=d._parseCookieHeader(a);d._cookieStore[b.key]=b.value}),a.status<400&&a.status!=="abort"?c(null,a):c(a)},g=f.getWithVersion(this.version,j)(b),h=b.post||{},k=a+"?"+i.encode(g),l=b.body?b.body:i.encode(h),m=d._getCookieString();m.length!==0&&(b.headers.Cookie=m,delete b.headers.Authorization);var n={method:b.method,headers:b.headers,timeout:b.timeout,body:l};return this.makeRequest(k,n,e)},makeRequest:function(a,b,c){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},parseJson:function(a){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},_buildResponse:function(a,b,c){var d,g={},h=null;b&&b.headers&&(h=f.trim(b.headers["content-type"]||b.headers["Content-Type"]||b.headers["Content-type"]||b.headers.contentType));if(f.startsWith(h,"application/json")&&c)try{g=this.parseJson(c)||{}}catch(i){e.error("Error in parsing JSON:",c,i),g=c}else g=c;return g&&e.printMessages(g.messages),d={response:b,status:b?b.statusCode:0,data:g,error:a},d}}),i.encode=function(a){var b="";for(var c in a)if(a.hasOwnProperty(c)){b&&b[b.length-1]!=="&"&&(b+="&");var d=a[c];if(d instanceof Array)for(var e=0;e1&&!b)throw new Error("Ambiguous match for name '"+a+"'");for(var e=0;e","<=",">=","is","isNull","isNotNull"],ipv4:["is","isNull","isNotNull","contains","doesNotContain","startsWith"]},_binning:["auto","year","month","day","hour","minute","second"],_sortDirection:["ASCENDING","DESCENDING","DEFAULT"],_statsFunctions:["list","values","first","last","count","dc","sum","average","max","min","stdev","duration","earliest","latest"],init:function(a){this.dataModelObject=a,this.columns=[],this.rows=[],this.filters=[],this.cells=[],this.accelerationNamespace=a.dataModel.isAccelerated()?a.dataModel.name:null,this.run=i.bind(this,this.run),this.pivot=i.bind(this,this.pivot)},setAccelerationJob:function(a){a&&a instanceof k.Job&&(a=a.sid);if(!a)throw new Error("Sid to use for acceleration must not be null.");return this.accelerationNamespace="sid="+a,this},addFilter:function(a,b,c,d){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add filter on a nonexistent field.");if(b!==this.dataModelObject.fieldByName(a).type)throw new Error("Cannot add "+b+" filter on "+a+" because it is of type "+this.dataModelObject.fieldByName(a).type);if(!i.contains(this._comparisons[b],c))throw new Error("Cannot add "+b+" filter because "+c+" is not a valid comparison operator");var e={fieldName:a,owner:this.dataModelObject.fieldByName(a).lineage.join("."),type:b};return i.contains(["boolean","string","ipv4","number"],e.type)&&(e.rule={comparator:c,compareTo:d}),this.filters.push(e),this},addLimitFilter:function(a,b,c,d,e){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add limit filter on a nonexistent field.");var f=this.dataModelObject.fieldByName(a);if(!i.contains(["string","number","objectCount"],f.type))throw new Error("Cannot add limit filter on "+a+" because it is of type "+f.type);if("string"===f.type&&!i.contains(["count","dc"],e))throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found "+e);if("number"===f.type&&!i.contains(["count","dc","average","sum"],e))throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found "+e);if("objectCount"===f.type&&!i.contains(["count"],e))throw new Error("Stats function for fields of type object count must be COUNT; found "+e);var g={fieldName:a,owner:f.lineage.join("."),type:f.type,attributeName:b,attributeOwner:this.dataModelObject.fieldByName(b).lineage.join("."),sortDirection:c,limitAmount:d,statsFn:e};return g.limitType="ASCENDING"===c?"lowest":"highest",this.filters.push(g),this},addRowSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],c.type))throw new Error("Field was of type "+c.type+", expected number or string.");var d={fieldName:a,owner:c.owner,type:c.type,label:b};return"number"===c.type&&(d.display="all"),this.rows.push(d),this},addRangeRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("number"!==d.type)throw new Error("Field was of type "+d.type+", expected number.");var e={};return!i.isUndefined(c.start)&&c.start!==null&&(e.start=c.start),!i.isUndefined(c.end)&&c.end!==null&&(e.end=c.end),!i.isUndefined(c.step)&&c.step!==null&&(e.size=c.step),!i.isUndefined(c.limit)&&c.limit!==null&&(e.maxNumberOf=c.limit),this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,display:"ranges",ranges:e}),this},addBooleanRowSplit:function(a,b,c,d){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var e=this.dataModelObject.fieldByName(a);if("boolean"!==e.type)throw new Error("Field was of type "+e.type+", expected boolean.");return this.rows.push({fieldName:a,owner:e.owner,type:e.type,label:b,trueLabel:c,falseLabel:d}),this},addTimestampRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("timestamp"!==d.type)throw new Error("Field was of type "+d.type+", expected timestamp.");if(!i.contains(this._binning,c))throw new Error("Invalid binning "+c+" found. Valid values are: "+this._binning.join(", "));return this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,period:c}),this},addColumnSplit:function(a){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var b=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],b.type))throw new Error("Field was of type "+b.type+", expected number or string.");var c={fieldName:a,owner:b.owner,type:b.type};return"number"===b.type&&(c.display="all"),this.columns.push(c),this},addRangeColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("number"!==c.type)throw new Error("Field was of type "+c.type+", expected number.");var d={};return!i.isUndefined(b.start)&&b.start!==null&&(d.start=b.start),!i.isUndefined(b.end)&&b.end!==null&&(d.end=b.end),!i.isUndefined(b.step)&&b.step!==null&&(d.size=b.step),!i.isUndefined(b.limit)&&b.limit!==null&&(d.maxNumberOf=b.limit),this.columns.push({fieldName:a,owner:c.owner,type:c.type,display:"ranges",ranges:d}),this},addBooleanColumnSplit:function(a,b,c){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("boolean"!==d.type)throw new Error("Field was of type "+d.type+", expected boolean.");return this.columns.push({fieldName:a,owner:d.owner,type:d.type,trueLabel:b,falseLabel:c}),this},addTimestampColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("timestamp"!==c.type)throw new Error("Field was of type "+c.type+", expected timestamp.");if(!i.contains(this._binning,b))throw new Error("Invalid binning "+b+" found. Valid values are: "+this._binning.join(", "));return this.columns.push({fieldName:a,owner:c.owner,type:c.type,period:b}),this},addCellValue:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if(i.contains(["string","ipv4"],d.type)&&!i.contains(["list","values","first","last","count","dc"],c))throw new Error("Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found "+c);if("number"===d.type&&!i.contains(["sum","count","average","min","max","stdev","list","values"],c))throw new Error("Stats function on number field must be must be one of: sum, count, average, max, min, stdev, list, or distinct_values; found "+c);if("timestamp"===d.type&&!i.contains(["duration","earliest","latest","list","values"],c))throw new Error("Stats function on timestamp field must be one of: duration, earliest, latest, list, or distinct values; found "+c);if(i.contains(["objectCount","childCount"],d.type)&&"count"!==c)throw new Error("Stats function on childcount and objectcount fields must be count; found "+c);if("boolean"===d.type)throw new Error("Cannot use boolean valued fields as cell values.");return this.cells.push({fieldName:a,owner:d.lineage.join("."),type:d.type,label:b,sparkline:!1,value:c}),this},toJsonObject:function(){return{dataModel:this.dataModelObject.dataModel.name,baseClass:this.dataModelObject.name,rows:this.rows,columns:this.columns,cells:this.cells,filters:this.filters}},pivot:function(a){var b=this.dataModelObject.dataModel.service,c={pivot_json:JSON.stringify(this.toJsonObject())};return i.isUndefined(this.accelerationNamespace)||(c.namespace=this.accelerationNamespace),b.get(g.pivot+"/"+encodeURIComponent(this.dataModelObject.dataModel.name),c,function(c,d){if(c){a(new Error(c.data.messages[0].text),d);return}d.data.entry&&d.data.entry[0]?a(null,new j.Pivot(b,d.data.entry[0].content)):a(new Error("Didn't get a Pivot report back from Splunk"),d)})},run:function(a,b){b||(b=a,a={}),a=a||{},this.pivot(function(c,d){c?b(c,null,null):d.run(a,f.augment(b,d))})}}),j.DataModelObject=h.extend({init:function(a,b){a=a||{},a.owner=a.owner||"",this.dataModel=b,this.name=a.objectName,this.displayName=a.displayName,this.parentName=a.parentName,this.lineage=a.lineage.split("."),a.hasOwnProperty("groupByFields")&&(this.groupByFields=a.groupByFields),a.hasOwnProperty("objectsToGroup")&&(this.objectsToGroup=a.objectsToGroup),a.hasOwnProperty("transactionMaxTimeSpan")&&(this.maxSpan=a.transactionMaxTimeSpan),a.hasOwnProperty("transactionMaxPause")&&(this.maxPause=a.transactionMaxPause),a.hasOwnProperty("baseSearch")&&(this.baseSearch=a.baseSearch),this.fields={};for(var c=0;c0)}})}})})()}),require.define("/lib/async.js",function(a,b,c,d,e){(function(){"use strict";var b=a("./utils"),d=c||this;d.whilst=function(a,b,c){a=a||function(){return!1},b=b||function(a){a()},c=c||function(){};var e=function(e){e?c(e):d.whilst(a,b,c)};a()?b(e):c(null)},d.parallel=function(a,c){if(arguments.length>1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){},a.length===0&&c();var e=a.length,f=[],g=function(a){return function(d){if(d)c&&c(d),c=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),f[a]=g,--e===0&&(f.unshift(null),c&&c.apply(null,f))}}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};var e=function(a,c,d,f){if(!a){d.unshift(null),f.apply(null,d);return}a(function(a){if(a)f&&f(a),f=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),d.push(g),e(c[0],c.slice(1),d,f)}})};e(a[0],a.slice(1),[],c)},d.parallelMap=function(a,c,e){a=a||[],e=e||function(){};var f=[],g=function(a,b){return function(d){c(a,b,d)}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};if(!a.length)c();else{var e=function(a,d,f){var g=function(a){if(a)c(a),c=function(){};else{var f=b.toArray(arguments);f.shift(),e(d[0],d.slice(1),f)}},h=f;d.length?h.push(g):h.push(c),a.apply(null,h)};e(a[0],a.slice(1),[])}},d.sleep=function(a,b){setTimeout(function(){b()},a)},d.augment=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){var c=Array.prototype.slice.call(arguments);for(var d=0;d tag unexpected.")}},f.parseXMLData=function(a,b){var c={},d=a.getchildren();for(var e=0;e/g,">"),d||(a=a.replace(/\n/g," "),a=a.replace(/\r/g," ")),c&&(a=a.replace(/"/g,"""))),a}function w(a,b){return v(a,b,!0)}function x(a,b){return v(a,b,!1)}function y(a,b){return v(a,b,!1,!0)}function z(a,b,c){function g(a){return a}function h(a){if(a[0]==="{"){var b=a.substring(1).split("}",2),g=b[0],h=b[1],i=e[g];i===undefined&&(i=t[g],i===undefined&&(i="ns"+Object.keys(e).length),i!=="xml"&&(e[g]=i)),i?d[a]=f("%s:%s",i,h):d[a]=h}else{if(c)throw new Error("cannot use non-qualified names with default_namespace option");d[a]=a}}var d={},e={};return c&&(e[c]=""),a.iter(null,function(a){var b,c=a.tag,e=a.text,f=a.items();if(c instanceof r&&d[c.text]===undefined)h(c.text);else if(typeof c=="string")h(c);else if(c!==null&&c!==o&&c!==p&&c!==q)throw new Error("Invalid tag type for serialization: "+c);e instanceof r&&d[e.text]===undefined&&h(e.text),f.forEach(function(a){var b=a[0],c=a[1];b instanceof r&&(b=b.text),d[b]===undefined&&h(b),c instanceof r&&d[c.text]===undefined&&h(c.text)})}),[d,e]}function A(a,b,c,d,e,h,i){var j=b.tag,k=b.text,l,m,n=h||h===0;a(Array(h+1).join(i));if(j===o)a(f("",x(k,c)));else if(j===q)a(f("",x(k,c)));else if(j===p)k=k||"",a(f("",k));else{j=d[j];if(j===undefined)k&&a(y(k,c)),b.iter(function(b){A(a,b,c,d,null,n?h+1:!1,i)});else{a("<"+j),l=b.items();if(l||e)l.sort(),l.forEach(function(b){var e=b[0],g=b[1];e instanceof r&&(e=e.text),g instanceof r?g=d[g.text]:g=w(g,c),a(f(' %s="%s"',d[e],g))}),e&&(l=g.items(e),l.sort(function(a,b){return a[1]"),!k&&n&&a("\n"),k&&a(y(k,c)),b._children.forEach(function(b){A(a,b,c,d,null,n?h+1:!1,i)}),!k&&h&&a(Array(h+1).join(i)),a("")):a(" />")}}n&&a("\n")}function B(a,b){var c=new s;return c.parse(a,b),c}function C(a,b){return(new s(a)).write(b)}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./elementpath"),i=a("./treebuilder").TreeBuilder,j=a("./parser").get_parser,k=a("./constants"),l=0;m.prototype.toString=function(){return f("",this.tag,this._id)},m.prototype.makeelement=function(a,b){return new m(a,b)},m.prototype.len=function(){return this._children.length},m.prototype.getItem=function(a){return this._children[a]},m.prototype.setItem=function(a,b){this._children[a]=b},m.prototype.delItem=function(a){this._children.splice(a,1)},m.prototype.getSlice=function(a,b){return this._children.slice(a,b)},m.prototype.setSlice=function(a,b,c){var d,e=0;for(d=a;d\n");if(a.method==="text")_serialize_text(b,self._root,encoding);else{var c,d,e,f,h=z(this._root,a.encoding,a.default_namespace);c=h[0],d=h[1],a.hasOwnProperty("indent")?(e=0,f=(new Array(a.indent+1)).join(" ")):e=!1;if(a.method==="xml")A(function(a){b.push(a)},this._root,a.encoding,c,d,e,f);else throw new Error("unknown serialization method "+a.method)}return b.join("")};var t={"http://www.w3.org/XML/1998/namespace":"xml","http://www.w3.org/1999/xhtml":"html","http://www.w3.org/1999/02/22-rdf-syntax-ns#":"rdf","http://schemas.xmlsoap.org/wsdl/":"wsdl","http://www.w3.org/2001/XMLSchema":"xs","http://www.w3.org/2001/XMLSchema-instance":"xsi","http://purl.org/dc/elements/1.1/":"dc"};c.PI=q,c.Comment=o,c.CData=p,c.ProcessingInstruction=q,c.SubElement=n,c.QName=r,c.ElementTree=s,c.ElementPath=h,c.Element=function(a,b){return new m(a,b)},c.XML=function(a){var b=new s;return b.parse(a)},c.parse=B,c.register_namespace=u,c.tostring=C}),require.define("/node_modules/elementtree/lib/sprintf.js",function(a,b,c,d,e){function h(a){var b,c,d=a,e=0,h=1,i="return '";for(b=0;b100&&(i={});if(b.charAt(0)==="/")throw new h(null,"Cannot use absolute path on element");d=k(b),c=[];function o(){return d.shift()}j=o();for(;;){var p=j[1]||"";l=r[p](o,j);if(!l)throw new h(null,f("Invalid path: %s",b));c.push(l),j=o();if(!j)break;j[1]==="/"&&(j=o());if(!j)break}i[b]=c}d=[a],n=new s(a);for(e=0,g=c.length;e0?c[0]:null}function v(a,b,c){var d=t(a,b);return d&&d.length>0?d[0].text:c}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./errors").SyntaxError,i={},j=new RegExp("('[^']*'|\"[^\"]*\"|::|//?|\\.\\.|\\(\\)|[/.*:\\[\\]\\(\\)@=])|((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|\\s+","g"),k=g.findall.bind(null,j),r={"":l,"*":m,".":n,"..":p,"//":o,"[":q};c.find=u,c.findall=t,c.findtext=v}),require.define("/node_modules/elementtree/lib/errors.js",function(a,b,c,d,e){function h(a,b){b=b||g("Syntax Error at token %s",a.toString()),this.token=a,this.message=b,Error.call(this,b)}var f=a("util"),g=a("./sprintf").sprintf;f.inherits(h,Error),c.SyntaxError=h}),require.define("util",function(a,b,c,d,e){function g(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&g(a.__proto__)}function h(a){return a instanceof RegExp||typeof a=="object"&&Object.prototype.toString.call(a)==="[object RegExp]"}function i(a){if(a instanceof Date)return!0;if(typeof a!="object")return!1;var b=Date.prototype&&n(Date.prototype),c=a.__proto__&&n(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}function j(a){return a<10?"0"+a.toString(10):a.toString(10)}function l(){var a=new Date,b=[j(a.getHours()),j(a.getMinutes()),j(a.getSeconds())].join(":");return[a.getDate(),k[a.getMonth()],b].join(" ")}var f=a("events");c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,d,e){function k(a,d){if(a&&typeof a.inspect=="function"&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(d);switch(typeof a){case"undefined":return j("undefined","undefined");case"string":var e="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return j(e,"string");case"number":return j(""+a,"number");case"boolean":return j(""+a,"boolean")}if(a===null)return j("null","null");var l=m(a),o=b?n(a):l;if(typeof a=="function"&&o.length===0){if(h(a))return j(""+a,"regexp");var p=a.name?": "+a.name:"";return j("[Function"+p+"]","special")}if(i(a)&&o.length===0)return j(a.toUTCString(),"date");var q,r,s;g(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]);if(typeof a=="function"){var t=a.name?": "+a.name:"";q=h(a)?" "+a:" [Function"+t+"]"}else q="";i(a)&&(q=" "+a.toUTCString());if(o.length===0)return s[0]+q+s[1];if(d<0)return h(a)?j(""+a,"regexp"):j("[Object]","special");f.push(a);var u=o.map(function(b){var c,e;a.__lookupGetter__&&(a.__lookupGetter__(b)?a.__lookupSetter__(b)?e=j("[Getter/Setter]","special"):e=j("[Getter]","special"):a.__lookupSetter__(b)&&(e=j("[Setter]","special"))),l.indexOf(b)<0&&(c="["+b+"]"),e||(f.indexOf(a[b])<0?(d===null?e=k(a[b]):e=k(a[b],d-1),e.indexOf("\n")>-1&&(g(a)?e=e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):e="\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=j("[Circular]","special"));if(typeof c=="undefined"){if(r==="Array"&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=j(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=j(c,"string"))}return c+": "+e});f.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return w>50?u=s[0]+(q===""?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:u=s[0]+q+" "+u.join(", ")+" "+s[1],u}var f=[],j=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return e||(j=function(a,b){return a}),k(a,typeof d=="undefined"?2:d)};var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(a){},c.pump=null;var m=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},n=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},o=Object.create||function(a,b){var c;if(a===null)c={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return typeof b!="undefined"&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=o(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}}),require.define("events",function(a,b,c,d,e){process.EventEmitter||(process.EventEmitter=function(){});var f=c.EventEmitter=process.EventEmitter,g=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.toString.call(a)==="[object Array]"},h=10;f.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},f.prototype.emit=function(a){if(a==="error")if(!this._events||!this._events.error||g(this._events.error)&&!this._events.error.length)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if(typeof b=="function"){switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0}if(g(b)){var c=Array.prototype.slice.call(arguments,1),d=b.slice();for(var e=0,f=d.length;e0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var d=c.indexOf(b);if(d<0)return this;c.splice(d,1),c.length==0&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),require.define("/node_modules/elementtree/lib/treebuilder.js",function(a,b,c,d,e){function f(b){this._data=[],this._elem=[],this._last=null,this._tail=null,b||(b=a("./elementtree").Element),this._factory=b}f.prototype.close=function(){return this._last},f.prototype._flush=function(){if(this._data){if(this._last!==null){var a=this._data.join("");this._tail?this._last.tail=a:this._last.text=a}this._data=[]}},f.prototype.data=function(a){this._data.push(a)},f.prototype.start=function(a,b){this._flush();var c=this._factory(a,b);this._last=c,this._elem.length&&this._elem[this._elem.length-1].append(c),this._elem.push(c),this._tail=null},f.prototype.end=function(a){this._flush(),this._last=this._elem.pop();if(this._last.tag!==a)throw new Error("end tag mismatch");return this._tail=1,this._last},c.TreeBuilder=f}),require.define("/node_modules/elementtree/lib/parser.js",function(a,b,c,d,e){function h(a){if(a==="sax")return g.sax;throw new Error("Invalid parser: "+a)}var f=a("util"),g=a("./parsers/index");c.get_parser=h}),require.define("/node_modules/elementtree/lib/parsers/index.js",function(a,b,c,d,e){c.sax=a("./sax")}),require.define("/node_modules/elementtree/lib/parsers/sax.js",function(a,b,c,d,e){function i(a){this.parser=g.parser(!0),this.target=a?a:new h,this.parser.onopentag=this._handleOpenTag.bind(this),this.parser.ontext=this._handleText.bind(this),this.parser.oncdata=this._handleCdata.bind(this),this.parser.ondoctype=this._handleDoctype.bind(this),this.parser.oncomment=this._handleComment.bind(this),this.parser.onclosetag=this._handleCloseTag.bind(this),this.parser.onerror=this._handleError.bind(this)}var f=a("util"),g=a("sax"),h=a("./../treebuilder").TreeBuilder;i.prototype._handleOpenTag=function(a){this.target.start(a.name,a.attributes)},i.prototype._handleText=function(a){this.target.data(a)},i.prototype._handleCdata=function(a){this.target.data(a)},i.prototype._handleDoctype=function(a){},i.prototype._handleComment=function(a){},i.prototype._handleCloseTag=function(a){this.target.end(a)},i.prototype._handleError=function(a){throw a},i.prototype.feed=function(a){this.parser.write(a)},i.prototype.close=function(){return this.parser.close(),this.target.close()},c.XMLParser=i}),require.define("/node_modules/elementtree/node_modules/sax/package.json",function(a,b,c,d,e){b.exports={main:"lib/sax.js"}}),require.define("/node_modules/elementtree/node_modules/sax/lib/sax.js",function(a,b,c,d,e){(function(b){function d(a,c){if(!(this instanceof d))return new d(a,c);var e=this;f(e),e.q=e.c="",e.bufferCheckPosition=b.MAX_BUFFER_LENGTH,e.opt=c||{},e.tagCase=e.opt.lowercasetags?"toLowerCase":"toUpperCase",e.tags=[],e.closed=e.closedRoot=e.sawRoot=!1,e.tag=e.error=null,e.strict=!!a,e.noscript=!!a||!!e.opt.noscript,e.state=B.BEGIN,e.ENTITIES=Object.create(b.ENTITIES),e.attribList=[],e.opt.xmlns&&(e.ns=Object.create(x)),e.position=e.line=e.column=0,C(e,"onready")}function e(a){var d=Math.max(b.MAX_BUFFER_LENGTH,10),e=0;for(var f=0,g=c.length;fd)switch(c[f]){case"textNode":E(a);break;case"cdata":D(a,"oncdata",a.cdata),a.cdata="";break;case"script":D(a,"onscript",a.script),a.script="";break;default:G(a,"Max buffer length exceeded: "+c[f])}e=Math.max(e,h)}a.bufferCheckPosition=b.MAX_BUFFER_LENGTH-e+a.position}function f(a){for(var b=0,d=c.length;b",a.state=B.TEXT;return}a.tagName=c;var f=a.tags.length;while(f-->b){var g=a.tag=a.tags.pop();a.tagName=a.tag.name,D(a,"onclosetag",a.tagName);var h={};for(var i in g.ns)h[i]=g.ns[i];var j=a.tags[a.tags.length-1]||a;a.opt.xmlns&&g.ns!==j.ns&&Object.keys(g.ns).forEach(function(b){var c=g.ns[b];D(a,"onclosenamespace",{prefix:b,uri:c})})}b===0&&(a.closedRoot=!0),a.tagName=a.attribValue=a.attribName="",a.attribList.length=0,a.state=B.TEXT}function O(a){var b=a.entity.toLowerCase(),c,d="";return a.ENTITIES[b]?a.ENTITIES[b]:(b.charAt(0)==="#"&&(b.charAt(1)==="x"?(b=b.slice(2),c=parseInt(b,16),d=c.toString(16)):(b=b.slice(1),c=parseInt(b,10),d=c.toString(10))),b=b.replace(/^0+/,""),d.toLowerCase()!==b?(I(a,"Invalid character entity"),"&"+a.entity+";"):String.fromCharCode(c))}function P(a){var b=this;if(this.error)throw this.error;if(b.closed)return G(b,"Cannot write after close. Assign an onready handler.");if(a===null)return H(b);var c=0,d="";while(b.c=d=a.charAt(c++)){b.position++,d==="\n"?(b.line++,b.column=0):b.column++;switch(b.state){case B.BEGIN:d==="<"?b.state=B.OPEN_WAKA:A(l,d)&&(I(b,"Non-whitespace before first tag."),b.textNode=d,b.state=B.TEXT);continue;case B.TEXT:if(b.sawRoot&&!b.closedRoot){var f=c-1;while(d&&d!=="<"&&d!=="&")d=a.charAt(c++),d&&(b.position++,d==="\n"?(b.line++,b.column=0):b.column++);b.textNode+=a.substring(f,c-1)}d==="<"?b.state=B.OPEN_WAKA:(A(l,d)&&(!b.sawRoot||b.closedRoot)&&I("Text data outside of root node."),d==="&"?b.state=B.TEXT_ENTITY:b.textNode+=d);continue;case B.SCRIPT:d==="<"?b.state=B.SCRIPT_ENDING:b.script+=d;continue;case B.SCRIPT_ENDING:d==="/"?(D(b,"onscript",b.script),b.state=B.CLOSE_TAG,b.script="",b.tagName=""):(b.script+="<"+d,b.state=B.SCRIPT);continue;case B.OPEN_WAKA:d==="!"?(b.state=B.SGML_DECL,b.sgmlDecl=""):z(l,d)||(z(o,d)?(b.startTagPosition=b.position-1,b.state=B.OPEN_TAG,b.tagName=d):d==="/"?(b.startTagPosition=b.position-1,b.state=B.CLOSE_TAG,b.tagName=""):d==="?"?(b.state=B.PROC_INST,b.procInstName=b.procInstBody=""):(I(b,"Unencoded <"),b.textNode+="<"+d,b.state=B.TEXT));continue;case B.SGML_DECL:(b.sgmlDecl+d).toUpperCase()===t?(D(b,"onopencdata"),b.state=B.CDATA,b.sgmlDecl="",b.cdata=""):b.sgmlDecl+d==="--"?(b.state=B.COMMENT,b.comment="",b.sgmlDecl=""):(b.sgmlDecl+d).toUpperCase()===u?(b.state=B.DOCTYPE,(b.doctype||b.sawRoot)&&I(b,"Inappropriately located doctype declaration"),b.doctype="",b.sgmlDecl=""):d===">"?(D(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=B.TEXT):z(q,d)?(b.state=B.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case B.SGML_DECL_QUOTED:d===b.q&&(b.state=B.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case B.DOCTYPE:d===">"?(b.state=B.TEXT,D(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,d==="["?b.state=B.DOCTYPE_DTD:z(q,d)&&(b.state=B.DOCTYPE_QUOTED,b.q=d));continue;case B.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=B.DOCTYPE);continue;case B.DOCTYPE_DTD:b.doctype+=d,d==="]"?b.state=B.DOCTYPE:z(q,d)&&(b.state=B.DOCTYPE_DTD_QUOTED,b.q=d);continue;case B.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=B.DOCTYPE_DTD,b.q="");continue;case B.COMMENT:d==="-"?b.state=B.COMMENT_ENDING:b.comment+=d;continue;case B.COMMENT_ENDING:d==="-"?(b.state=B.COMMENT_ENDED,b.comment=F(b.opt,b.comment),b.comment&&D(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=B.COMMENT);continue;case B.COMMENT_ENDED:d!==">"?(I(b,"Malformed comment"),b.comment+="--"+d,b.state=B.COMMENT):b.state=B.TEXT;continue;case B.CDATA:d==="]"?b.state=B.CDATA_ENDING:b.cdata+=d;continue;case B.CDATA_ENDING:d==="]"?b.state=B.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=B.CDATA);continue;case B.CDATA_ENDING_2:d===">"?(b.cdata&&D(b,"oncdata",b.cdata),D(b,"onclosecdata"),b.cdata="",b.state=B.TEXT):d==="]"?b.cdata+="]":(b.cdata+="]]"+d,b.state=B.CDATA);continue;case B.PROC_INST:d==="?"?b.state=B.PROC_INST_ENDING:z(l,d)?b.state=B.PROC_INST_BODY:b.procInstName+=d;continue;case B.PROC_INST_BODY:if(!b.procInstBody&&z(l,d))continue;d==="?"?b.state=B.PROC_INST_ENDING:z(q,d)?(b.state=B.PROC_INST_QUOTED,b.q=d,b.procInstBody+=d):b.procInstBody+=d;continue;case B.PROC_INST_ENDING:d===">"?(D(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=B.TEXT):(b.procInstBody+="?"+d,b.state=B.PROC_INST_BODY);continue;case B.PROC_INST_QUOTED:b.procInstBody+=d,d===b.q&&(b.state=B.PROC_INST_BODY,b.q="");continue;case B.OPEN_TAG:z(p,d)?b.tagName+=d:(J(b),d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:(A(l,d)&&I(b,"Invalid character in tag name"),b.state=B.ATTRIB));continue;case B.OPEN_TAG_SLASH:d===">"?(M(b,!0),N(b)):(I(b,"Forward-slash in opening tag not followed by >"),b.state=B.ATTRIB);continue;case B.ATTRIB:if(z(l,d))continue;d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:z(o,d)?(b.attribName=d,b.attribValue="",b.state=B.ATTRIB_NAME):I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME:d==="="?b.state=B.ATTRIB_VALUE:z(l,d)?b.state=B.ATTRIB_NAME_SAW_WHITE:z(p,d)?b.attribName+=d:I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME_SAW_WHITE:if(d==="=")b.state=B.ATTRIB_VALUE;else{if(z(l,d))continue;I(b,"Attribute without value"),b.tag.attributes[b.attribName]="",b.attribValue="",D(b,"onattribute",{name:b.attribName,value:""}),b.attribName="",d===">"?M(b):z(o,d)?(b.attribName=d,b.state=B.ATTRIB_NAME):(I(b,"Invalid attribute name"),b.state=B.ATTRIB)}continue;case B.ATTRIB_VALUE:if(z(l,d))continue;z(q,d)?(b.q=d,b.state=B.ATTRIB_VALUE_QUOTED):(I(b,"Unquoted attribute value"),b.state=B.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case B.ATTRIB_VALUE_QUOTED:if(d!==b.q){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}L(b),b.q="",b.state=B.ATTRIB;continue;case B.ATTRIB_VALUE_UNQUOTED:if(A(s,d)){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}L(b),d===">"?M(b):b.state=B.ATTRIB;continue;case B.CLOSE_TAG:if(!b.tagName){if(z(l,d))continue;A(o,d)?I(b,"Invalid tagname in closing tag."):b.tagName=d}else d===">"?N(b):z(p,d)?b.tagName+=d:(A(l,d)&&I(b,"Invalid tagname in closing tag"),b.state=B.CLOSE_TAG_SAW_WHITE);continue;case B.CLOSE_TAG_SAW_WHITE:if(z(l,d))continue;d===">"?N(b):I("Invalid characters in closing tag");continue;case B.TEXT_ENTITY:case B.ATTRIB_VALUE_ENTITY_Q:case B.ATTRIB_VALUE_ENTITY_U:switch(b.state){case B.TEXT_ENTITY:var g=B.TEXT,h="textNode";break;case B.ATTRIB_VALUE_ENTITY_Q:var g=B.ATTRIB_VALUE_QUOTED,h="attribValue";break;case B.ATTRIB_VALUE_ENTITY_U:var g=B.ATTRIB_VALUE_UNQUOTED,h="attribValue"}d===";"?(b[h]+=O(b),b.entity="",b.state=g):z(r,d)?b.entity+=d:(I("Invalid character entity"),b[h]+="&"+b.entity+d,b.entity="",b.state=g);continue;default:throw new Error(b,"Unknown state: "+b.state)}}return b.position>=b.bufferCheckPosition&&e(b),b}b.parser=function(a,b){return new d(a,b)},b.SAXParser=d,b.SAXStream=k,b.createStream=j,b.MAX_BUFFER_LENGTH=65536;var c=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];b.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(a){function b(){this.__proto__=a}return b.prototype=a,new b}),Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.__proto__}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),d.prototype={end:function(){H(this)},write:P,resume:function(){return this.error=null,this},close:function(){return this.write(null)},end:function(){return this.write(null)}};try{var g=a("stream").Stream}catch(h){var g=function(){}}var i=b.EVENTS.filter(function(a){return a!=="error"&&a!=="end"});k.prototype=Object.create(g.prototype,{constructor:{value:k}}),k.prototype.write=function(a){return this._parser.write(a.toString()),this.emit("data",a),!0},k.prototype.end=function(a){return a&&a.length&&this._parser.write(a.toString()),this._parser.end(),!0},k.prototype.on=function(a,b){var c=this;return!c._parser["on"+a]&&i.indexOf(a)!==-1&&(c._parser["on"+a]=function(){var b=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);b.splice(0,0,a),c.emit.apply(c,b)}),g.prototype.on.call(c,a,b)};var l="\r\n\t ",m="0124356789",n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",o=n+"_:",p=o+m+"-.",q="'\"",r=m+n+"#",s=l+">",t="[CDATA[",u="DOCTYPE",v="http://www.w3.org/XML/1998/namespace",w="http://www.w3.org/2000/xmlns/",x={xml:v,xmlns:w};l=y(l),m=y(m),n=y(n),o=y(o),p=y(p),q=y(q),r=y(r),s=y(s);var B=0;b.STATE={BEGIN:B++,TEXT:B++,TEXT_ENTITY:B++,OPEN_WAKA:B++,SGML_DECL:B++,SGML_DECL_QUOTED:B++,DOCTYPE:B++,DOCTYPE_QUOTED:B++,DOCTYPE_DTD:B++,DOCTYPE_DTD_QUOTED:B++,COMMENT_STARTING:B++,COMMENT:B++,COMMENT_ENDING:B++,COMMENT_ENDED:B++,CDATA:B++,CDATA_ENDING:B++,CDATA_ENDING_2:B++,PROC_INST:B++,PROC_INST_BODY:B++,PROC_INST_QUOTED:B++,PROC_INST_ENDING:B++,OPEN_TAG:B++,OPEN_TAG_SLASH:B++,ATTRIB:B++,ATTRIB_NAME:B++,ATTRIB_NAME_SAW_WHITE:B++,ATTRIB_VALUE:B++,ATTRIB_VALUE_QUOTED:B++,ATTRIB_VALUE_UNQUOTED:B++,ATTRIB_VALUE_ENTITY_Q:B++,ATTRIB_VALUE_ENTITY_U:B++,CLOSE_TAG:B++,CLOSE_TAG_SAW_WHITE:B++,SCRIPT:B++,SCRIPT_ENDING:B++},b.ENTITIES={apos:"'",quot:'"',amp:"&",gt:">",lt:"<"};for(var B in b.STATE)b.STATE[b.STATE[B]]=B;B=b.STATE})(typeof c=="undefined"?sax={}:c)}),require.define("stream",function(a,b,c,d,e){function h(){f.EventEmitter.call(this)}var f=a("events"),g=a("util");g.inherits(h,f.EventEmitter),b.exports=h,h.Stream=h,h.prototype.pipe=function(a,b){function d(b){a.writable&&!1===a.write(b)&&c.pause&&c.pause()}function e(){c.readable&&c.resume&&c.resume()}function g(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.end()}function h(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.destroy()}function i(a){j();if(this.listeners("error").length===0)throw a}function j(){c.removeListener("data",d),a.removeListener("drain",e),c.removeListener("end",g),c.removeListener("close",h),c.removeListener("error",i),a.removeListener("error",i),c.removeListener("end",j),c.removeListener("close",j),a.removeListener("end",j),a.removeListener("close",j)}var c=this;c.on("data",d),a.on("drain",e),!a._isStdio&&(!b||b.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,c.on("end",g),c.on("close",h));var f=!1;return c.on("error",i),a.on("error",i),c.on("end",j),c.on("close",j),a.on("end",j),a.on("close",j),a.emit("pipe",c),a}}),require.define("/node_modules/elementtree/lib/constants.js",function(a,b,c,d,e){var f="sax";c.DEFAULT_PARSER=f}),require.define("/lib/modularinputs/inputdefinition.js",function(a,b,c,d,e){(function(){function e(){this.metadata={},this.inputs={}}var c=a("elementtree"),d=a("./utils");e.parse=function(a){var b=new e,f=c.parse(a).getroot().getchildren();for(var g=0;g=10?b=parseFloat(a.toString().substring(0,14)).toFixed(3):a.toString().length<=13||a.toString().indexOf(".")<10?b=parseFloat(a).toFixed(3):b=(parseFloat(a.toString().substring(0,14))/1e3).toFixed(3)):a.toString().length===13?b=(parseFloat(a)/1e3).toFixed(3):a.toString().length<=12?b=parseFloat(a).toFixed(3):b=parseFloat(a.toString().substring(0,13)/1e3).toFixed(3),b)},e.prototype._writeTo=function(a){if(!this.data)throw new Error("Events must have at least the data field set to be written to XML.");var b=c.Element("event");this.stanza&&b.set("stanza",this.stanza),b.set("unbroken",(+this.unbroken).toString()),!d.isUndefined(this.time)&&this.time!==null&&(c.SubElement(b,"time").text=e.formatTime(this.time).toString()),typeof this.data=="object"&&(this.data=JSON.stringify(this.data));var f=[{tag:"source",text:this.source},{tag:"sourcetype",text:this.sourcetype},{tag:"index",text:this.index},{tag:"host",text:this.host},{tag:"data",text:this.data}];for(var g=0;g"),this._headerWritten=!0);try{a._writeTo(this._out)}catch(b){throw b.message==="Events must have at least the data field set to be written to XML."?(e.warn("",b.message,this._err),b):(e.error("",b.message,this._err),b)}},h.prototype.writeXMLDocument=function(a){var b=c.tostring(a,{xml_declaration:!1});this._out.write(b)},h.prototype.close=function(){this._out.write("")},b.exports=h})()}),require.define("/lib/modularinputs/logger.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./utils"),e=c||this;e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL",e._log=function(a,b,c,d){d=d||process.stderr,b&&b.length>0&&(b+=" ");var e=a+" Modular input "+b+c+"\n";d.write(e)},e.debug=function(a,b,c){try{e._log(e.DEBUG,a,b,c)}catch(d){throw d}},e.info=function(a,b,c){try{e._log(e.INFO,a,b,c)}catch(d){throw d}},e.warn=function(a,b,c){try{e._log(e.WARN,a,b,c)}catch(d){throw d}},e.error=function(a,b,c){try{e._log(e.ERROR,a,b,c)}catch(d){throw d}},e.fatal=function(a,b,c){try{e._log(e.FATAL,a,b,c)}catch(d){throw d}},b.exports=e})()}),require.define("/lib/modularinputs/argument.js",function(a,b,c,d,e){(function(){function e(a){a||(a={}),this.name=d.isUndefined(a.name)?"":a.name,this.description=d.isUndefined(a.description)?null:a.description,this.validation=d.isUndefined(a.validation)?null:a.validation,this.dataType=d.isUndefined(a.dataType)?e.dataTypeString:a.dataType,this.requiredOnEdit=d.isUndefined(a.requiredOnEdit)?!1:a.requiredOnEdit,this.requiredOnCreate=d.isUndefined(a.requiredOnCreate)?!1:a.requiredOnCreate}var c=a("elementtree"),d=a("./utils");e.dataTypeBoolean="BOOLEAN",e.dataTypeNumber="NUMBER",e.dataTypeString="STRING",e.prototype.addToDocument=function(a){var b=c.SubElement(a,"arg");b.set("name",this.name),this.description&&(c.SubElement(b,"description").text=this.description),this.validation&&(c.SubElement(b,"validation").text=this.validation);var d=[{tag:"data_type",value:this.dataType},{tag:"required_on_edit",value:this.requiredOnEdit},{tag:"required_on_create",value:this.requiredOnCreate}];for(var e=0;e")){clearTimeout(o);var g=h.parse(c);a._inputDefinition=g,k._inputDefinition=g,f.chain([function(b){f.parallelEach(Object.keys(a._inputDefinition.inputs),function(b,c,e){var g=a._inputDefinition.inputs[b];f.chain([function(c){a.start(b,g,c)},function(c){a.streamEvents(b,g,d,c)},function(c){a.end(b,g,c)}],function(a){e(a,a?1:0)})},function(a){b(a,a?1:0)})}],function(a){d._headerWritten&&d.close(),j(a,a?1:0)})}})}else if(b.length>=2&&b[1].toString().toLowerCase()==="--scheme"){var p=a.getScheme();if(!p)l.fatal("","script returned a null scheme.",d._err),j(null,1);else try{d.writeXMLDocument(p.toXML()),j(null,0)}catch(q){l.fatal("","script could not return the scheme, error: "+q,d._err),j(q,1)}}else if(b.length>=2&&b[1].toString().toLowerCase()==="--validate-arguments"){var r=setTimeout(function(){j(new Error("Receiving validation definition prior to validating timed out."),1)},30500);i.on("data",function(b){n=Buffer.concat([n,b]);var h=n.toString("utf8",0,n.length).trim();e.endsWith(h,"")&&(clearTimeout(r),f.chain([function(b){try{if(e.isUndefined(a.validateInput))b();else{var c=g.parse(n.toString("utf8",0,n.length));a.validateInput(c,b)}}catch(d){b(d)}}],function(a){if(a){l.error("",a.message),l.error("","Stack trace for a modular input error: "+a.stack);try{var b=c.Element("error");c.SubElement(b,"message").text=a.message,d.writeXMLDocument(b),j(a,1)}catch(e){j(e,1)}}else j(null,0)}))})}else{var s="Invalid arguments to modular input script: "+b.join()+"\n";l.error("",s,d._err),j(s,1)}},m.service=function(){if(this._service)return this._service;if(!this._inputDefinition)return null;var a=this._inputDefinition.metadata.server_uri,b=this._inputDefinition.metadata.session_key,c=d.parse(a),e=c.protocol.replace(":",""),f=c.hostname,g=c.port;return this._service=new k({scheme:e,host:f,port:g,token:b}),this._service},m.prototype.setup=function(a){a()},m.prototype.start=function(a,b,c){c()},m.prototype.end=function(a,b,c){c()},m.prototype.teardown=function(a){a()},b.exports=m})()}),require.define("url",function(a,b,c,d,e){function v(a,b,c){if(a&&typeof a=="object"&&a.href)return a;if(typeof a!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d={},e=a;for(var h=0,j=e.length;hn)d.hostname="";else{var G=d.hostname.split(/\./);for(var h=0,j=G.length;h127?I+="x":I+=H[J];if(!I.match(o)){var L=G.slice(0,h),M=G.slice(h+1),N=H.match(p);N&&(L.push(N[1]),M.unshift(N[2])),M.length&&(e="/"+M.join(".")+e),d.hostname=L.join(".");break}}}}d.hostname=d.hostname.toLowerCase();var O=d.hostname.split("."),P=[];for(var h=0;h0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}a.search=b.search,a.query=b.query;if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.href=w(a),a}if(!h.length)return delete a.pathname,a.search?delete a.path:a.path="/"+a.search,a.href=w(a),a;var k=h.slice(-1)[0],l=(a.host||b.host)&&(k==="."||k==="..")||k==="",m=0;for(var n=h.length;n>=0;n--)k=h[n],k=="."?h.splice(n,1):k===".."?(h.splice(n,1),m++):m&&(h.splice(n,1),m--);if(!f&&!g)for(;m--;m)h.unshift("..");f&&h[0]!==""&&(!h[0]||h[0].charAt(0)!=="/")&&h.unshift(""),l&&h.join("/").substr(-1)!=="/"&&h.push("");var o=h[0]===""||h[0]&&h[0].charAt(0)==="/";if(i){a.hostname=a.host=o?"":h.length?h.shift():"";var j=a.host&&a.host.indexOf("@")>0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}f=f||a.host&&h.length,f&&!o&&h.unshift(""),a.pathname=h.join("/");if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.auth=b.auth||a.auth,a.slashes=a.slashes||b.slashes,a.href=w(a),a}function z(a){var b={},c=h.exec(a);return c&&(c=c[0],b.port=c.substr(1),a=a.substr(0,a.length-c.length)),a&&(b.hostname=a),b}var f={encode:function(a){return a}};c.parse=v,c.resolve=x,c.resolveObject=y,c.format=w;var g=/^([a-z0-9.+-]+:)/i,h=/:[0-9]+$/,i=["<",">",'"',"`"," ","\r","\n","\t"],j=["{","}","|","\\","^","~","[","]","`"].concat(i),k=["'"],l=["%","/","?",";","#"].concat(j).concat(k),m=["/","@","?","#"].concat(i),n=255,o=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,p=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,q={javascript:!0,"javascript:":!0},r={javascript:!0,"javascript:":!0},s={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},t={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},u=a("querystring")}),require.define("querystring",function(a,b,c,d,e){function j(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function k(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d","Username to login with",undefined,!0).option("--password ","Username to login with",undefined,!1).option("--scheme ","Scheme to use","https",!1).option("--host ","Hostname to use","localhost",!1).option("--port ","Port to use",8089,!1).option("--version ","Which version to use","4",!1),a.parse=function(c){c=(c||[]).slice(2);var d=j();for(var e in d)if(d.hasOwnProperty(e)&&c.indexOf("--"+e)<0){var f=d[e];c.unshift(f),c.unshift("--"+e.trim())}c.unshift(""),c.unshift("");var g=b.call(a,c);return g},a.add=function(b,c,d,e,f,h){var i={};e=e||[];var j=a.command(b+(d?" "+d:"")).description(c||"");for(var k=0;k=0,m="<"+e[k]+">";j.option("--"+e[k]+" "+m,"",undefined,l)}j.action(function(){var a=g.toArray(arguments);a.unshift(b),h.apply(null,a)})},a}})()}),require.define("/tests/test_service.js",function(a,b,c,d,e){c.setup=function(b,c){var d=a("../index"),f=d.Utils,g=d.Async,h=a("./utils"),i=a("path");d.Logger.setLevel("ALL");var j=0,k=function(){return"id"+j++ +"_"+(new Date).valueOf()},l={"Namespace Tests":{setUp:function(a){this.service=b;var c=this,d="jssdk_testapp_"+k(),e="jssdk_testapp_"+k(),f="jssdk_testuser_"+k(),h="jssdk_testuser_"+k(),i=this.service.apps(),j=this.service.users();this.namespace11={owner:f,app:d},this.namespace12={owner:f,app:e},this.namespace21={owner:h,app:d},this.namespace22={owner:h,app:e},g.chain([function(a){i.create({name:d},a)},function(a,b){c.app1=a,c.appName1=d,i.create({name:e},b)},function(a,b){c.app2=a,c.appName2=e,j.create({name:f,password:"abc",roles:["user"]},b)},function(a,b){c.user1=a,c.userName1=f,j.create({name:h,password:"abc",roles:["user"]},b)},function(a,b){c.user2=a,c.userName2=h,b()}],function(b){a()})},"Callback#Namespace protection":function(a){var b="jssdk_search_"+k(),c="search *",d=this.service,e=d.savedSearches(this.namespace11),f=d.savedSearches(this.namespace21),h=this;g.chain([function(a){e.create({name:b,search:c},a)},function(a,b){e.fetch(b)},function(a,b){f.fetch(b)},function(d,g){var h=e.item(b),i=f.item(b);a.ok(h),a.strictEqual(h.name,b),a.strictEqual(h.properties().search,c),a.ok(!i),g()}],function(b){a.ok(!b),a.done()})},"Callback#Namespace item":function(a){var b="jssdk_search_"+k(),c="search *",d=this.service,e={owner:"-",app:this.appName1},f={owner:"nobody",app:this.appName1},h=d.savedSearches(this.namespace11),i=d.savedSearches(this.namespace21),j=d.savedSearches(e),l=d.savedSearches(f),m=this;g.chain([function(a){h.create({name:b,search:c},a)},function(a,d){i.create({name:b,search:c},d)},function(a,b){j.fetch(b)},function(a,b){h.fetch(b)},function(a,b){i.fetch(b)},function(d,e){var f=h.item(b,m.namespace11),g=i.item(b,m.namespace21);a.ok(f),a.strictEqual(f.name,b),a.strictEqual(f.properties().search,c),a.strictEqual(f.namespace.owner,m.namespace11.owner),a.strictEqual(f.namespace.app,m.namespace11.app),a.ok(g),a.strictEqual(g.name,b),a.strictEqual(g.properties().search,c),a.strictEqual(g.namespace.owner,m.namespace21.owner),a.strictEqual(g.namespace.app,m.namespace21.app),e()},function(a){l.create({name:b,search:c},a)},function(a,b){h.fetch(b)},function(a,b){i.fetch(b)},function(d,e){try{j.item(b),a.ok(!1)}catch(f){a.ok(f)}try{j.item(b,{owner:"-"}),a.ok(!1)}catch(f){a.ok(f)}try{j.item(b,{app:"-"}),a.ok(!1)}catch(f){a.ok(f)}try{j.item(b,{app:"-",owner:"-"}),a.ok(!1)}catch(f){a.ok(f)}var g=j.item(b,m.namespace11),h=j.item(b,m.namespace21);a.ok(g),a.strictEqual(g.name,b),a.strictEqual(g.properties().search,c),a.strictEqual(g.namespace.owner,m.namespace11.owner),a.strictEqual(g.namespace.app,m.namespace11.app),a.ok(h),a.strictEqual(h.name,b),a.strictEqual(h.properties().search,c),a.strictEqual(h.namespace.owner,m.namespace21.owner),a.strictEqual(h.namespace.app,m.namespace21.app),e()}],function(b){a.ok(!b),a.done()})},"Callback#delete test applications":function(a){var b=this.service.apps();b.fetch(function(b,c){a.ok(!b),a.ok(c);var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})},"Callback#delete test users":function(a){var b=this.service.users();b.fetch(function(b,c){var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})}},"Job Tests":{setUp:function(a){this.service=b,a()},"Callback#Create+abort job":function(a){var b=this.service;g.chain([function(a){var c=i.join(process.env.SPLUNK_HOME,"/etc/apps/sdk-app-collection/build/sleep_command.tar");c=c.replace("%20"," "),b.post("apps/appinstall",{update:1,name:c},a)},function(c){var d=k(),e={id:d},f=b.jobs({app:"sdk-app-collection"}),h=f.oneshotSearch("search index=_internal | head 1 | sleep 10",e,function(b,c){a.ok(b),a.ok(!c),a.strictEqual(b.error,"abort"),a.done()});g.sleep(1e3,function(){h.abort()})}],function(b){a.ok(!b),a.done()})},"Callback#Create+cancel job":function(a){var b=k();this.service.jobs().search("search index=_internal | head 1",{id:b},function(c,d){a.ok(d),a.strictEqual(d.sid,b),d.cancel(function(){a.done()})})},"Callback#Create job error":function(a){var b=k();this.service.jobs().search({search:"index=_internal | head 1",id:b},function(b){a.ok(!!b),a.done()})},"Callback#List jobs":function(a){this.service.jobs().fetch(function(b,c){a.ok(!b),a.ok(c);var d=c.list();a.ok(d.length>0);for(var e=0;ec),a.ok(e<=c*2),b.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Set priority":function(a){var b=k(),c=0,d=this,e=this.service.specialize("nobody","sdk-app-collection");g.chain([function(a){e.jobs().search("search index=_internal | head 1 | sleep 5",{id:b},a)},function(a,b){a.track({},{ready:function(a){b(null,a)}})},function(b,c){var d=b.properties().priority;a.ok(d,5),b.setPriority(d+1,c)},function(a,b){a.fetch(b)},function(a,b){a.cancel(b)}],function(b){a.ok(!b),a.done()})},"Callback#Search log":function(a){var b=k(),c=this;g.chain([function(a){c.service.jobs().search("search index=_internal | head 1",{id:b,exec_mode:"blocking"},a)},function(a,b){a.searchlog(b)},function(b,c,d){a.ok(c),a.ok(b),a.ok(b.length>0),a.ok(b.split("\r\n").length>0),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Search summary":function(a){var b=k(),c=this;g.chain([function(a){c.service.jobs().search('search index=_internal | head 1 | eval foo="bar" | fields foo',{id:b,status_buckets:300,rf:["foo"]},a)},function(a,b){g.sleep(2e3,function(){a.summary({},b)})},function(b,c,d){a.ok(c),a.ok(b),a.strictEqual(b.event_count,1),a.strictEqual(b.fields.foo.count,1),a.strictEqual(b.fields.foo.distinct_count,1),a.ok(b.fields.foo.is_exact,1),a.strictEqual(b.fields.foo.modes.length,1),a.strictEqual(b.fields.foo.modes[0].count,1),a.strictEqual(b.fields.foo.modes[0].value,"bar"),a.ok(b.fields.foo.modes[0].is_exact),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Search timeline":function(a){var b=k(),c=this;g.chain([function(a){c.service.jobs().search('search index=_internal | head 1 | eval foo="bar" | fields foo',{id:b,status_buckets:300,rf:["foo"],exec_mode:"blocking"},a)},function(a,b){a.timeline({},b)},function(b,c,d){a.ok(c),a.ok(b),a.strictEqual(b.buckets.length,1),a.strictEqual(b.event_count,1),a.strictEqual(b.buckets[0].available_count,1),a.strictEqual(b.buckets[0].duration,.001),a.strictEqual(b.buckets[0].earliest_time_offset,b.buckets[0].latest_time_offset),a.strictEqual(b.buckets[0].total_count,1),a.ok(b.buckets[0].is_finalized),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Touch":function(a){var b=k(),c=this,d="";g.chain([function(a){c.service.jobs().search("search index=_internal | head 1",{id:b},a)},function(a,b){a.fetch(b)},function(b,c){a.ok(b),d=b.properties().updated,g.sleep(1200,function(){b.touch(c)})},function(a,b){a.fetch(b)},function(b,c){a.ok(d!==b.updated()),b.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#Create failure":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",d=this.service.jobs();a.throws(function(){d.create({search:c,name:b,exec_mode:"oneshot"},function(){})}),a.done()},"Callback#Create fails with no search string":function(a){var b=this.service.jobs();b.create("",{},function(b){a.ok(b),a.done()})},"Callback#Oneshot search":function(a){var b=k(),c=this,d="";g.chain([function(a){c.service.jobs().oneshotSearch("search index=_internal | head 1 | stats count",{id:b},a)},function(b,c){a.ok(b),a.ok(b.fields),a.strictEqual(b.fields.length,1),a.strictEqual(b.fields[0],"count"),a.ok(b.rows),a.strictEqual(b.rows.length,1),a.strictEqual(b.rows[0].length,1),a.strictEqual(b.rows[0][0],"1"),c()}],function(b){a.ok(!b),a.done()})},"Callback#Oneshot search with no results":function(a){var b=k(),c=this,d="";g.chain([function(a){var d="search index=history MUST_NOT_EXISTABCDEF";c.service.jobs().oneshotSearch(d,{id:b},a)},function(b,c){a.ok(b),a.strictEqual(b.fields.length,0),a.strictEqual(b.rows.length,0),a.ok(!b.preview),c()}],function(b){a.ok(!b),a.done()})},"Callback#Service oneshot search":function(a){var b=k(),c=this,d={owner:"admin",app:"search"},e=6.1,f="DEBUG";g.chain([function(b){g.chain([function(a){c.service.serverInfo(a)},function(a,c){e=parseFloat(a.properties().version),e<6.2?b():c()},function(a){c.service.configurations({owner:"admin",app:"search"}).fetch(a)},function(a,b){try{a.item("limits").fetch(b)}catch(c){b(c)}},function(a,b){var c=a.item("search_info");f=c.properties().infocsv_log_level,c.update({infocsv_log_level:"DEBUG"},b)},function(b,c){a.strictEqual("DEBUG",b.properties().infocsv_log_level),c()}],function(c){a.ok(!c),b()})},function(a){c.service.oneshotSearch("search index=_internal | head 1 | stats count",{id:b},d,a)},function(b,c){a.ok(b),a.ok(b.fields),a.strictEqual(b.fields.length,1),a.strictEqual(b.fields[0],"count"),a.ok(b.rows),a.strictEqual(b.rows.length,1),a.strictEqual(b.rows[0].length,1),a.strictEqual(b.rows[0][0],"1"),a.ok(b.messages[1].text.indexOf('owner="admin"')),a.ok(b.messages[1].text.indexOf('app="search"')),c()},function(b){g.chain([function(a){e<6.2?b():a()},function(a){c.service.configurations({owner:"admin",app:"search"}).fetch(a)},function(a,b){try{a.item("limits").fetch(b)}catch(c){b(c)}},function(a,b){var c=a.item("search_info");c.update({infocsv_log_level:f},b)},function(b,c){a.strictEqual(f,b.properties().infocsv_log_level),c()}],function(c){a.ok(!c),b()})}],function(b){a.ok(!b),a.done()})},"Callback#Service search":function(a){var b=k(),c=this.service,d=this,e={owner:"admin",app:"search"};g.chain([function(a){d.service.search("search index=_internal | head 1 | stats count",{id:b},e,a)},function(c,d){a.strictEqual(c.sid,b),a.strictEqual(c.namespace,e),h.pollUntil(c,function(a){return c.properties().isDone},10,d)},function(a,b){a.results({},b)},function(b,c,d){a.strictEqual(b.rows.length,1),a.strictEqual(b.fields.length,1),a.strictEqual(b.fields[0],"count"),a.strictEqual(b.rows[0][0],"1"),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Wait until job done":function(a){this.service.search("search index=_internal | head 1000",{},function(b,c){a.ok(!b);var d=0,e=0;c.track({period:200},{ready:function(b){a.ok(b),d++},progress:function(b){a.ok(b),e++},done:function(b){a.ok(b),a.ok(d===1),a.ok(e>=1),a.done()},failed:function(b){a.ok(b),a.ok(!1,"Job failed unexpectedly."),a.done()},error:function(b){a.ok(b),a.ok(!1,"Error while tracking job."),a.done()}})})},"Callback#Wait until job failed":function(a){this.service.search("search index=_internal | head bogusarg",{},function(b,c){if(b){a.ok(!b),a.done();return}var d=0,e=0;c.track({period:200},{ready:function(b){a.ok(b),d++},progress:function(b){a.ok(b),e++},done:function(b){a.ok(b),a.ok(!1,"Job became done unexpectedly."),a.done()},failed:function(b){a.ok(b),a.ok(d===1),a.ok(e>=1),a.done()},error:function(b){a.ok(b),a.ok(!1,"Error while tracking job."),a.done()}})})},"Callback#track() with default params and one function":function(a){this.service.search("search index=_internal | head 1",{},function(b,c){if(b){a.ok(!b),a.done();return}c.track({},function(b){a.ok(b),a.done()})})},"Callback#track() should stop polling if only the ready callback is specified":function(a){this.service.search("search index=_internal | head 1",{},function(b,c){if(b){a.ok(!b),a.done();return}c.track({},{ready:function(b){a.ok(b)},_stoppedAfterReady:function(b){a.done()}})})},"Callback#track() a job that is not immediately ready":function(a){var b=20,c=b,e=!1;for(var f=0;f.*) To: (?.*) ",i.expression);var j=d.pbe9bd0rp4;a.ok(j),a.strictEqual("event1",j.owner),a.same(["event1"],j.lineage),a.strictEqual("GeoIP",j.type),a.ok(j.isGeoIP()),a.ok(!j.isLookup()),a.ok(!j.isEval()),a.ok(!j.isRex()),a.strictEqual("·Ä©·öô‡Øµ comment of pbe9bd0rp4",j.comment),a.strictEqual(5,j.outputFieldNames().length),a.strictEqual("output_from_reverse_hostname",j.inputField),c()}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - run queries":function(a){if(this.skip){a.done();return}var b,c=this;g.chain([function(a){c.dataModels.fetch(a)},function(a,c){var d=a.item("internal_audit_logs");b=d.objectByName("searches"),b.startSearch({},"",c)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,c){a.strictEqual("| datamodel internal_audit_logs searches search",b.properties().request.search),b.cancel(c)},function(a,c){b.startSearch({status_buckets:5,enable_lookups:!1},"| head 3",c)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,c){a.strictEqual("| datamodel internal_audit_logs searches search | head 3",b.properties().request.search),b.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - baseSearch is parsed correctly":function(a){if(this.skip){a.done();return}var b;try{b=JSON.parse(f.readFile(e,"../data/model_with_multiple_types.json"))}catch(c){a.ok(!c),a.done()}var h="delete-me-"+k(),i,j=this;g.chain([function(a){j.dataModels.create(h,b,a)},function(b,c){i=b.objectByName("search1"),a.ok(i),a.ok(i instanceof d.Service.DataModelObject),a.strictEqual("BaseSearch",i.parentName),a.ok(i.isBaseSearch()),a.ok(!i.isBaseTransaction()),a.strictEqual("search index=_internal | head 10",i.baseSearch),c()}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - baseTransaction is parsed correctly":function(a){if(this.skip){a.done();return}var b;try{b=JSON.parse(f.readFile(e,"../data/model_with_multiple_types.json"))}catch(c){a.ok(!c),a.done()}var h="delete-me-"+k(),i,j=this;g.chain([function(a){j.dataModels.create(h,b,a)},function(b,c){i=b.objectByName("transaction1"),a.ok(i),a.ok(i instanceof d.Service.DataModelObject),a.strictEqual("BaseTransaction",i.parentName),a.ok(i.isBaseTransaction()),a.ok(!i.isBaseSearch()),a.same(["event1"],i.objectsToGroup),a.same(["host","from"],i.groupByFields),a.strictEqual("25s",i.maxPause),a.strictEqual("100m",i.maxSpan),c()}],function(b){a.ok(!b),a.done()})}},"Pivot tests":{setUp:function(a){this.service=b,this.dataModels=b.dataModels({owner:"nobody",app:"search"}),this.skip=!1;var c=this;this.service.serverInfo(function(b,e){parseInt(e.properties().version.split(".")[0],10)<6&&(c.skip=!0,d.Logger.log("Skipping pivot tests...")),a(b)})},"Callback#Pivot - test constructor args":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){a.ok(b.objectByName("test_data")),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test acceleration, then pivot":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){b.objectByName("test_data"),a.ok(b),b.acceleration.enabled=!0,b.acceleration.earliestTime="-2mon",b.acceleration.cronSchedule="0 */12 * * *",b.update(c)},function(b,c){var d=b.properties();a.strictEqual(!0,b.isAccelerated()),a.strictEqual(!0,!!b.acceleration.enabled),a.strictEqual("-2mon",b.acceleration.earliest_time),a.strictEqual("0 */12 * * *",b.acceleration.cron_schedule);var e=b.objectByName("test_data"),f=e.createPivotSpecification();a.strictEqual(e.dataModel.name,f.accelerationNamespace);var g="delete-me-"+k();f.setAccelerationJob(g),a.strictEqual("sid="+g,f.accelerationNamespace);var h="delete-me-"+k();f.accelerationNamespace=h,a.strictEqual(h,f.accelerationNamespace),f.addCellValue("test_data","Source Value","count").run(c)},function(b,c,d){a.ok(b),a.ok(c),a.notStrictEqual("FAILED",b.properties().dispatchState),b.track({},function(b){a.ok(c.tstatsSearch),a.strictEqual(0,b.properties().request.search.indexOf("| tstats")),a.strictEqual("| tstats",b.properties().request.search.match("^\\| tstats")[0]),a.strictEqual(1,b.properties().request.search.match("^\\| tstats").length),a.strictEqual(c.tstatsSearch,b.properties().request.search),d(null,b)})},function(b,c){a.ok(b),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test illegal filtering (all types)":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter(k(),"boolean","=",!0),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addFilter("_time","boolean","=",!0),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add boolean filter on _time because it is of type timestamp")}try{e.addFilter("has_boris","string","contains","abc"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add string filter on has_boris because it is of type boolean")}try{e.addFilter(k(),"string","contains","abc"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addFilter("has_boris","ipv4","startsWith","192.168"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add ipv4 filter on has_boris because it is of type boolean")}try{e.addFilter(k(),"ipv4","startsWith","192.168"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addFilter("has_boris","number","atLeast",2.3),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add number filter on has_boris because it is of type boolean")}try{e.addFilter(k(),"number","atLeast",2.3),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addLimitFilter("has_boris","host","DEFAULT",50,"count"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add limit filter on has_boris because it is of type boolean")}try{e.addLimitFilter(k(),"host","DEFAULT",50,"count"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add limit filter on a nonexistent field.")}try{e.addLimitFilter("source","host","DEFAULT",50,"sum"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found sum")}try{e.addLimitFilter("epsilon","host","DEFAULT",50,"duration"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found duration")}try{e.addLimitFilter("test_data","host","DEFAULT",50,"list"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function for fields of type object count must be COUNT; found list")}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test boolean filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("has_boris","boolean","=",!0),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("has_boris",f.fieldName),a.strictEqual("boolean",f.type),a.strictEqual("=",f.rule.comparator),a.strictEqual(!0,f.rule.compareTo),a.strictEqual("test_data",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test string filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("host","string","contains","abc"),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("host",f.fieldName),a.strictEqual("string",f.type),a.strictEqual("contains",f.rule.comparator),a.strictEqual("abc",f.rule.compareTo),a.strictEqual("BaseEvent",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test IPv4 filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("hostip","ipv4","startsWith","192.168"),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("hostip",f.fieldName),a.strictEqual("ipv4",f.type),a.strictEqual("startsWith",f.rule.comparator),a.strictEqual("192.168",f.rule.compareTo),a.strictEqual("test_data",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test number filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("epsilon","number",">=",2.3),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("epsilon",f.fieldName),a.strictEqual("number",f.type),a.strictEqual(">=",f.rule.comparator),a.strictEqual(2.3,f.rule.compareTo),a.strictEqual("test_data",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test limit filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addLimitFilter("epsilon","host","ASCENDING",500,"average"),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("owner")),a.ok(f.hasOwnProperty("attributeName")),a.ok(f.hasOwnProperty("attributeOwner")),a.ok(f.hasOwnProperty("limitType")),a.ok(f.hasOwnProperty("limitAmount")),a.ok(f.hasOwnProperty("statsFn")),a.strictEqual("epsilon",f.fieldName),a.strictEqual("number",f.type),a.strictEqual("test_data",f.owner),a.strictEqual("host",f.attributeName),a.strictEqual("BaseEvent",f.attributeOwner),a.strictEqual("lowest",f.limitType),a.strictEqual(500,f.limitAmount),a.strictEqual("average",f.statsFn)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test row split":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addRowSplit("has_boris","Wrong type here"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number or string.")}var g=k();try{e.addRowSplit(g,"Break Me!"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addRowSplit("epsilon","My Label"),a.strictEqual(1,e.rows.length);var h=e.rows[0];a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("display")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("My Label",h.label),a.strictEqual("all",h.display),a.same({fieldName:"epsilon",owner:"test_data",type:"number",label:"My Label",display:"all"},h),e.addRowSplit("host","My Label"),a.strictEqual(2,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(!h.hasOwnProperty("display")),a.strictEqual("host",h.fieldName),a.strictEqual("BaseEvent",h.owner),a.strictEqual("string",h.type),a.strictEqual("My Label",h.label),a.same({fieldName:"host",owner:"BaseEvent",type:"string",label:"My Label"},h);try{e.addRangeRowSplit("has_boris","Wrong type here",{start:0,end:100,step:20,limit:5})}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number.")}try{e.addRangeRowSplit(g,"Break Me!",{start:0,end:100,step:20,limit:5}),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addRangeRowSplit("epsilon","My Label",{start:0,end:100,step:20,limit:5}),a.strictEqual(3,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("display")),a.ok(h.hasOwnProperty("ranges")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("My Label",h.label),a.strictEqual("ranges",h.display);var i={start:0,end:100,size:20,maxNumberOf:5};a.same(i,h.ranges),a.same({fieldName:"epsilon",owner:"test_data",type:"number",label:"My Label",display:"ranges",ranges:i},h);try{e.addBooleanRowSplit("epsilon","Wrong type here","t","f")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected boolean.")}try{e.addBooleanRowSplit(g,"Break Me!","t","f"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addBooleanRowSplit("has_boris","My Label","is_true","is_false"),a.strictEqual(4,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("trueLabel")),a.ok(h.hasOwnProperty("falseLabel")),a.strictEqual("has_boris",h.fieldName),a.strictEqual("My Label",h.label),a.strictEqual("test_data",h.owner),a.strictEqual("boolean",h.type),a.strictEqual("is_true",h.trueLabel),a.strictEqual("is_false",h.falseLabel),a.same({fieldName:"has_boris",label:"My Label",owner:"test_data",type:"boolean",trueLabel:"is_true",falseLabel:"is_false"},h);try{e.addTimestampRowSplit("epsilon","Wrong type here","some binning")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected timestamp.")}try{e.addTimestampRowSplit(g,"Break Me!","some binning"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}try{e.addTimestampRowSplit("_time","some label","Bogus binning value"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Invalid binning Bogus binning value found. Valid values are: "+e._binning.join(", "))}e.addTimestampRowSplit("_time","My Label","day"),a.strictEqual(5,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("period")),a.strictEqual("_time",h.fieldName),a.strictEqual("My Label",h.label),a.strictEqual("BaseEvent",h.owner),a.strictEqual("timestamp",h.type),a.strictEqual("day",h.period),a.same({fieldName:"_time",label:"My Label",owner:"BaseEvent",type:"timestamp",period:"day"},h),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test column split":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addColumnSplit("has_boris","Wrong type here"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number or string.")}var g=k();try{e.addColumnSplit(g,"Break Me!"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addColumnSplit("epsilon"),a.strictEqual(1,e.columns.length);var h=e.columns[e.columns.length-1];a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("display")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("all",h.display),a.same({fieldName:"epsilon",owner:"test_data",type:"number",display:"all"},h),e.addColumnSplit("host"),a.strictEqual(2,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(!h.hasOwnProperty("display")),a.strictEqual("host",h.fieldName),a.strictEqual("BaseEvent",h.owner),a.strictEqual("string",h.type),a.same({fieldName:"host",owner:"BaseEvent",type:"string"},h),c();try{e.addRangeColumnSplit("has_boris","Wrong type here",{start:0,end:100,step:20,limit:5})}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number.")}try{e.addRangeColumnSplit(g,{start:0,end:100,step:20,limit:5}),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addRangeColumnSplit("epsilon",{start:0,end:100,step:20,limit:5}),a.strictEqual(3,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("display")),a.ok(h.hasOwnProperty("ranges")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("ranges",h.display);var i={start:"0",end:"100",size:"20",maxNumberOf:"5"};a.same(i,h.ranges),a.same({fieldName:"epsilon",owner:"test_data",type:"number",display:"ranges",ranges:i},h);try{e.addBooleanColumnSplit("epsilon","t","f")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected boolean.")}try{e.addBooleanColumnSplit(g,"t","f"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addBooleanColumnSplit("has_boris","is_true","is_false"),a.strictEqual(4,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(!h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("trueLabel")),a.ok(h.hasOwnProperty("falseLabel")),a.strictEqual("has_boris",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("boolean",h.type),a.strictEqual("is_true",h.trueLabel),a.strictEqual("is_false",h.falseLabel),a.same({fieldName:"has_boris",owner:"test_data",type:"boolean",trueLabel:"is_true",falseLabel:"is_false"},h);try{e.addTimestampColumnSplit("epsilon","Wrong type here")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected timestamp.")}try{e.addTimestampColumnSplit(g,"Break Me!"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}try{e.addTimestampColumnSplit("_time","Bogus binning value"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Invalid binning Bogus binning value found. Valid values are: "+e._binning.join(", "))}e.addTimestampColumnSplit("_time","day"),a.strictEqual(5,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(!h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("period")),a.strictEqual("_time",h.fieldName),a.strictEqual("BaseEvent",h.owner),a.strictEqual("timestamp",h.type),a.strictEqual("day",h.period),a.same({fieldName:"_time",owner:"BaseEvent",type:"timestamp",period:"day"},h)}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test cell value":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addCellValue("iDontExist","Break Me!","explosion"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field iDontExist")}try{e.addCellValue("source","Wrong Stats Function","stdev"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found stdev")}e.addCellValue("source","Source Value","dc"),a.strictEqual(1,e.cells.length);var g=e.cells[e.cells.length-1];a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("source",g.fieldName),a.strictEqual("BaseEvent",g.owner),a.strictEqual("string",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("dc",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"source",owner:"BaseEvent",type:"string",label:"Source Value",value:"dc",sparkline:!1},g);try{e.addCellValue("hostip","Wrong Stats Function","stdev"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found stdev")}e.addCellValue("hostip","Source Value","dc"),a.strictEqual(2,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("hostip",g.fieldName),a.strictEqual("test_data",g.owner),a.strictEqual("ipv4",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("dc",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"hostip",owner:"test_data",type:"ipv4",label:"Source Value",value:"dc",sparkline:!1},g);try{e.addCellValue("has_boris","Booleans not allowed","sum"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot use boolean valued fields as cell values.")}try{e.addCellValue("epsilon","Wrong Stats Function","latest"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on number field must be must be one of: sum, count, average, max, min, stdev, list, or distinct_values; found latest")}e.addCellValue("epsilon","Source Value","average"),a.strictEqual(3,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("epsilon",g.fieldName),a.strictEqual("test_data",g.owner),a.strictEqual("number",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("average",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"epsilon",owner:"test_data",type:"number",label:"Source Value",value:"average",sparkline:!1},g);try{e.addCellValue("_time","Wrong Stats Function","max"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on timestamp field must be one of: duration, earliest, latest, list, or distinct values; found max")}e.addCellValue("_time","Source Value","earliest"),a.strictEqual(4,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("_time",g.fieldName),a.strictEqual("BaseEvent",g.owner),a.strictEqual("timestamp",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("earliest",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"_time",owner:"BaseEvent",type:"timestamp",label:"Source Value",value:"earliest",sparkline:!1},g);try{e.addCellValue("test_data","Wrong Stats Function","min"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on childcount and objectcount fields must be count; found min")}e.addCellValue("test_data","Source Value","count"),a.strictEqual(5,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("test_data",g.fieldName),a.strictEqual("test_data",g.owner),a.strictEqual("objectCount",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("count",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"test_data",owner:"test_data",type:"objectCount",label:"Source Value",value:"count",sparkline:!1},g),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test pivot throws HTTP exception":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d),d.createPivotSpecification().pivot(c)},function(b,c){a.ok(!1)}],function(b){a.ok(b);var c="In handler 'datamodelpivot': Error in 'PivotReport': Must have non-empty cells or non-empty rows.";a.ok(f.endsWith(b.message,c)),a.done()})},"Callback#Pivot - test pivot with simple namespace":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var i=this,j,l,m;g.chain([function(a){i.dataModels.create(b,c,a)},function(b,c){j=b.objectByName("test_data"),a.ok(j),j.createLocalAccelerationJob(null,c)},function(b,c){m=b,a.ok(b),l=j.createPivotSpecification(),l.addBooleanRowSplit("has_boris","Has Boris","meep","hilda"),l.addCellValue("hostip","Distinct IPs","count"),l.setAccelerationJob(b),a.strictEqual("string",typeof l.accelerationNamespace),a.strictEqual("sid="+b.sid,l.accelerationNamespace),l.setAccelerationJob(b.sid),a.strictEqual("string",typeof l.accelerationNamespace),a.strictEqual("sid="+b.sid,l.accelerationNamespace),l.pivot(c)},function(b,c){a.ok(b.tstatsSearch),a.ok(b.tstatsSearch.length>0),a.strictEqual(0,b.tstatsSearch.indexOf("| tstats")),a.strictEqual("| tstats",b.tstatsSearch.match("^\\| tstats")[0]),a.strictEqual(1,b.tstatsSearch.match("^\\| tstats").length),b.run(c)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,c){a.ok("FAILED"!==b.properties().dispatchState),a.strictEqual(0,b.properties().request.search.indexOf("| tstats")),a.strictEqual("| tstats",b.properties().request.search.match("^\\| tstats")[0]),a.strictEqual(1,b.properties().request.search.match("^\\| tstats").length),m.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test pivot column range split":function(a){if(this.skip){a.done();return}var b=this,c;g.chain([function(a){b.dataModels.fetch(a)},function(a,b){var c=a.item("internal_audit_logs"),d=c.objectByName("searches"),e=d.createPivotSpecification();e.addRowSplit("user","Executing user"),e.addRangeColumnSplit("exec_time",{start:0,end:12,step:5,limit:4}),e.addCellValue("search","Search Query","values"),e.pivot(b)},function(a,b){c=a.tstatsSearch||a.pivotSearch,a.run(b)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,d){a.notStrictEqual("FAILED",b.properties().dispatchState),a.strictEqual(c,b.properties().request.search),b.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test pivot with PivotSpecification.run and Job.track":function(a){if(this.skip){a.done();return}var b=this;g.chain([function(a){b.dataModels.fetch(a)},function(a,b){var c=a.item("internal_audit_logs"),d=c.objectByName("searches"),e=d.createPivotSpecification();e.addRowSplit("user","Executing user"),e.addRangeColumnSplit("exec_time",{start:0,end:12,step:5,limit:4}),e.addCellValue("search","Search Query","values"),e.run({},b)},function(b,c,d){b.track({},function(b){a.strictEqual(c.tstatsSearch||c.pivotSearch,b.properties().request.search),d(null,b)})},function(b,c){a.notStrictEqual("FAILED",b.properties().dispatchState),b.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - delete any remaining data models created by the SDK tests":function(a){if(this.skip){a.done();return}b.dataModels().fetch(function(b,c){b&&a.ok(!b);var d=c.list();g.seriesEach(d,function(a,b,c){f.startsWith(a.name,"delete-me")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})}},"App Tests":{setUp:function(a){this.service=b,a()},"Callback#list applications":function(a){var b=this.service.apps();b.fetch(function(b,c){var d=c.list();a.ok(d.length>0),a.done()})},"Callback#contains applications":function(a){var b=this.service.apps();b.fetch(function(b,c){var d=c.item("search");a.ok(d),a.done()})},"Callback#create + contains app":function(a){var b="jssdk_testapp_"+k(),c=this.service.apps();c.create({name:b},function(b,d){var e=d.name;c.fetch(function(b,c){var f=c.item(e);a.ok(f),d.remove(function(){a.done()})})})},"Callback#create + modify app":function(a){var b="TEST DESCRIPTION",c="1.1",d="jssdk_testapp_"+k(),e=this.service.apps();g.chain([function(a){e.create({name:d},a)},function(e,f){a.ok(e),a.strictEqual(e.name,d),a.strictEqual(e.properties().version,"1.0"),e.update({description:b,version:c},f)},function(d,e){a.ok(d);var f=d.properties();a.strictEqual(f.description,b),a.strictEqual(f.version,c),d.remove(e)}],function(b){a.ok(!b),a.done()})},"Callback#delete test applications":function(a){var b=this.service.apps();b.fetch(function(b,c){var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})},"list applications with cookies as authentication":function(a){this.service.serverInfo(function(c,e){var h=parseInt(e.properties().version.split(".")[0],10),i=parseInt(e.properties().version.split(".")[1],10);if(h<6||h===6&&i<2){d.Logger.log("Skipping cookie test..."),a.done();return}var j=new d.Service({scheme:b.scheme,host:b.host,port:b.port,username:b.username,password:b.password,version:b.version}),k=new d.Service({scheme:b.scheme,host:b.host,port:b.port,version:b.version});g.chain([function(a){j.login(a)},function(b,c){var d=j.http._cookieStore;a.ok(!f.isEmpty(d)),k.http._cookieStore=d;var e=k.apps();e.fetch(c)},function(b,c){var d=b.list();a.ok(d.length>0),a.ok(!f.isEmpty(k.http._cookieStore)),c()}],function(b){a.ok(!b),a.done()})})}},"Saved Search Tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Callback#list":function(a){var b=this.service.savedSearches();b.fetch(function(b,c){var d=c.list();a.ok(d.length>0);for(var e=0;e0);for(var e=0;e1),a.ok(f.indexOf(b.fields().optional,"disabled")>-1),b.remove(c)}],function(b){a.ok(!b),a.done()})},"Callback#dispatch error":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",e=new d.Service.SavedSearch(this.loggedOutService,b,{owner:"nobody",app:"search"});e.dispatch(function(b){a.ok(b),a.done()})},"Callback#dispatch omitting optional arguments":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",d=this.service.savedSearches({owner:this.service.username,app:"sdk-app-collection"});g.chain([function(a){d.create({search:c,name:b},a)},function(d,e){a.ok(d),a.strictEqual(d.name,b),a.strictEqual(d.properties().search,c),a.ok(!d.properties().description),d.dispatch(e)},function(b,c,d){a.ok(b),a.ok(c),a.done()}])},"Callback#history error":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",e=new d.Service.SavedSearch(this.loggedOutService,b,{owner:"nobody",app:"search",sharing:"system"});e.history(function(b){a.ok(b),a.done()})},"Callback#Update error":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",e=new d.Service.SavedSearch(this.loggedOutService,b,{owner:"nobody",app:"search",sharing:"system"});e.update({},function(b){a.ok(b),a.done()})},"Callback#oneshot requires search string":function(a){a.throws(function(){this.service.oneshotSearch({name:"jssdk_oneshot_"+k()},function(a){})}),a.done()},"Callback#Create + dispatch + history":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",d=this.service.savedSearches({owner:this.service.username,app:"sdk-app-collection"});g.chain(function(a){d.create({search:c,name:b},a)},function(d,e){a.ok(d),a.strictEqual(d.name,b),a.strictEqual(d.properties().search,c),a.ok(!d.properties().description),d.dispatch({force_dispatch:!1,"dispatch.buckets":295},e)},function(b,c,d){a.ok(b),a.ok(c),h.pollUntil(b,function(a){return b.properties().isDone},10,g.augment(d,c))},function(b,c,d){a.strictEqual(b.properties().statusBuckets,295),c.history(g.augment(d,b))},function(b,c,d,e){a.ok(b),a.ok(b.length>0),a.ok(c),a.ok(d);var f=function(a){return function(b){a.cancel(b)}},h=!1,i=[];for(var j=0;j0),c()}],function(b){a.ok(!b),a.done()})},"Callback#item":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web"),c()}],function(b){a.ok(!b),a.done()})},"Callback#contains stanza":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web");var d=b.item("settings");a.ok(d),d.fetch(c)},function(b,c){a.ok(b.properties().hasOwnProperty("httpport")),c()}],function(b){a.ok(!b),a.done()})},"Callback#create file + create stanza + update stanza":function(a){var c=this,e="jssdk_file_"+k(),f="barfoo_"+k(),h={owner:"admin",app:"search"};g.chain([function(a){var b=c.service.configurations(h);b.fetch(a)},function(a,b){a.create(e,b)},function(a,b){a.create("stanza",b)},function(a,b){a.update({jssdk_foobar:f},b)},function(b,c){a.strictEqual(b.properties().jssdk_foobar,f),c()},function(a){var c=new d.Service.ConfigurationFile(b,e);c.fetch(a)},function(b,c){var d=b.item("stanza");a.ok(d),d.remove(c)}],function(b){a.ok(!b),a.done()})}},"Configuration Tests":{setUp:function(a){this.service=b,a()},"Callback#list":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.list();a.ok(d.length>0),c()}],function(b){a.ok(!b),a.done()})},"Callback#contains":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web"),c()}],function(b){a.ok(!b),a.done()})},"Callback#contains stanza":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web");var d=b.item("settings");a.ok(d),d.fetch(c)},function(b,c){a.ok(b.properties().hasOwnProperty("httpport")),c()}],function(b){a.ok(!b),a.done()})},"Callback#configurations init":function(a){a.throws(function(){var a=new d.Service.Configurations(this.service,{owner:"-",app:"-",sharing:"system"})}),a.done()},"Callback#create file + create stanza + update stanza":function(a){var c=this,e={owner:"nobody",app:"system"},f="jssdk_file_"+k(),h="barfoo_"+k();g.chain([function(a){var c=b.configurations(e);c.fetch(a)},function(a,b){a.create({__conf:f},b)},function(a,b){a.item("stanza")&&a.item("stanza").remove(),a.create("stanza",b)},function(a,b){a.update({jssdk_foobar:h},b)},function(b,c){a.strictEqual(b.properties().jssdk_foobar,h),c()},function(a){var c=new d.Service.ConfigurationFile(b,f);c.fetch(a)},function(b,c){var d=b.item("stanza");a.ok(d),d.remove(c)}],function(b){a.ok(!b),a.done()})},"Callback#can get default stanza":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,d){var e=b.item("savedsearches");a.strictEqual(c,e.namespace),a.ok(e),e.fetch(d)},function(b,d){a.strictEqual(c,b.namespace),b.getDefaultStanza().fetch(d)},function(b,d){a.strictEqual(b.name,"default"),a.strictEqual(c,b.namespace),d()}],function(b){a.ok(!b),a.done()})},"Callback#updating default stanza is noop":function(a){var b=this,c={owner:"admin",app:"search"},d=null,e="this won't work";g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,d){var e=b.item("savedsearches");a.strictEqual(c,e.namespace),a.ok(e),e.fetch(d)},function(b,d){a.strictEqual(c,b.namespace),b.getDefaultStanza().fetch(d)},function(b,f){a.ok(b._properties.hasOwnProperty("max_concurrent")),a.strictEqual(c,b.namespace),d=b._properties.max_concurrent,b.update({max_concurrent:e},f)},function(b,c){a.ok(b.properties().hasOwnProperty("max_concurrent")),a.strictEqual(b.properties().max_concurrent,d),a.notStrictEqual(b.properties().max_concurrent,e),b.fetch(c)},function(b,c){a.ok(b.properties().hasOwnProperty("max_concurrent")),a.strictEqual(b.properties().max_concurrent,d),a.notStrictEqual(b.properties().max_concurrent,e),c()}],function(b){a.ok(!b),a.done()})}},"Storage Passwords Tests":{setUp:function(a){this.service=b,a()},"Callback#Create":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual(d+":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create with backslashes":function(a){var b=-1,c="\\delete-me-"+k(),d="\\delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual("\\"+d+":\\"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create with slashes":function(a){var b=-1,c="/delete-me-"+k(),d="/delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual(d+":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create without realm":function(a){var b=-1,c="delete-me-"+k(),d=this;g.chain([function(a){d.service.storagePasswords().fetch(a)},function(a,d){b=a.list().length,a.create({name:c,password:"changeme"},d)},function(b,e){a.strictEqual(c,b.properties().username),a.strictEqual(":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual("",b.properties().realm),d.service.storagePasswords().fetch(g.augment(e,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){d.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create should fail without user, or realm":function(a){var b=this;g.chain([function(a){b.service.storagePasswords().fetch(a)},function(a,b){a.create({name:null,password:"changeme"},b)}],function(b){a.ok(b),a.done()})},"Callback#Create should fail without password":function(a){var b=this;g.chain([function(a){b.service.storagePasswords().fetch(a)},function(a,b){a.create({name:"something",password:null},b)}],function(b){a.ok(b),a.done()})},"Callback#Create should fail without user, realm, or password":function(a){var b=this;g.chain([function(a){b.service.storagePasswords().fetch(a)},function(a,b){a.create({name:null,password:null},b)}],function(b){a.ok(b),a.done()})},"Callback#Create with colons":function(a){var b=-1,c=":delete-me-"+k(),d=":delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual("\\"+d+":\\"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create crazy":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c+":end!@#$%^&*()_+{}:|<>?",realm:":start::!@#$%^&*()_+{}:|<>?"+d,password:"changeme"},e)},function(b,f){a.strictEqual(c+":end!@#$%^&*()_+{}:|<>?",b.properties().username),a.strictEqual("\\:start\\:\\:!@#$%^&*()_+{}\\:|<>?"+d+":"+c+"\\:end!@#$%^&*()_+{}\\:|<>?:",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(":start::!@#$%^&*()_+{}:|<>?"+d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create with unicode chars":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c+":end!@#$%^&*()_+{}:|<>?쎼 and 쎶 and <&> für",realm:":start::!@#$%^&*()_+{}:|<>?"+encodeURIComponent("쎼 and 쎶 and <&> für")+d,password:decodeURIComponent(encodeURIComponent("쎼 and 쎶 and <&> für"))},e)},function(b,f){a.strictEqual(c+":end!@#$%^&*()_+{}:|<>?쎼 and 쎶 and <&> für",b.properties().username),a.strictEqual("\\:start\\:\\:!@#$%^&*()_+{}\\:|<>?"+encodeURIComponent("쎼 and 쎶 and <&> für")+d+":"+c+"\\:end!@#$%^&*()_+{}\\:|<>?쎼 and 쎶 and <&> für:",b.name),a.strictEqual(decodeURIComponent(encodeURIComponent("쎼 and 쎶 and <&> für")),b.properties().clear_password),a.strictEqual(":start::!@#$%^&*()_+{}:|<>?"+encodeURIComponent("쎼 and 쎶 and <&> für")+d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Read":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual(d+":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(e,f,g){try{a.ok(!!e.item(d+":"+c+":"))}catch(h){a.ok(!1)}var i=e.list(),j=!1;a.strictEqual(b+1,i.length);for(var k=0;k0},function(a){g.sleep(d,function(){b.fetch(a)})},function(b){b?a(b):a(c<=0?"Timed out":null)})}],function(b){a.ok(!b),a.done()})},"Callback#list indexes":function(a){var b=this.service.indexes();b.fetch(function(b,c){var d=c.list();a.ok(d.length>0),a.done()})},"Callback#contains index":function(a){var b=this.service.indexes(),c=this.indexName;b.fetch(function(b,d){var e=d.item(c);a.ok(e),a.done()})},"Callback#modify index":function(a){var b=this.indexName,c=this.service.indexes(),d=!1;g.chain([function(a){c.fetch(a)},function(c,e){var f=c.item(b);a.ok(f),d=f.properties().syncMeta,f.update({syncMeta:!d},e)},function(b,c){a.ok(b);var e=b.properties();a.strictEqual(!d,e.syncMeta),b.update({syncMeta:!e.syncMeta},c)},function(b,c){a.ok(b);var e=b.properties();a.strictEqual(d,e.syncMeta),c()}],function(b){a.ok(!b),a.done()})},"Callback#Enable+disable index":function(a){var b=this.indexName,c=this.service.indexes();g.chain([function(a){c.fetch(a)},function(c,d){var e=c.item(b);a.ok(e),e.disable(d)},function(b,c){a.ok(b),b.fetch(c)},function(b,c){a.ok(b),a.ok(b.properties().disabled),b.enable(c)},function(b,c){a.ok(b),b.fetch(c)},function(b,c){a.ok(b),a.ok(!b.properties().disabled),c()}],function(b){a.ok(!b),a.done()})},"Callback#Service submit event":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.service,e=this.indexName;g.chain(function(a){d.log(b,{sourcetype:c,index:e},a)},function(d,f){a.ok(d),a.strictEqual(d.sourcetype,c),a.strictEqual(d.bytes,b.length),a.strictEqual(d.index,e),f()},function(b){a.ok(!b),a.done()})},"Callback#Service submit event, omitting optional arguments":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.service,e=this.indexName;g.chain(function(a){d.log(b,a)},function(c,d){a.ok(c),a.strictEqual(c.bytes,b.length),d()},function(b){a.ok(!b),a.done()})},"Callback#Service submit events with multi-byte chars":function(a){var b=this.service,c=["Ummelner Straße 6","Ümmelner Straße 6","Iԉtérԉátíòлåɭìƶåtiòл","Intérnâtì߀лàɭíƶɑtïòл","ãϻét dòner turƙëy ѵ߀lù","ptãte ìԉ rëρrèhënԁérit ","ϻ߀lɭit fìɭèt ϻìǥnoԉ ɭäb߀ríѕ"," êӽ cɦùck cüpïᏧåtåt Ꮷèѕëruлt. ","D߀ɭor ѵélít ìrurè, sèᏧ ѕhòr","t riƅѕ c߀ɰ ɭãnԁյàéɢêr drúmst","ícƙ. Minïm ƃàɭl tip ѕհòrt rìƃѕ,"," ïԁ aɭïqúìρ ѕɦànƙ ρ߀rcɦéttɑ. Pìǥ"," hãm ɦòck ìлcídíԁùԉt séԁ cüpïϻ ","ƙèviл láborê. Et taiɭ ѕtriρ"," steák út üllãϻc߀ rump d߀ɭore.","٩(͡๏̯͡๏)۶ ٩(-̮̮̃•̃).","Lɑƅòré ƃrësãòlá d߀лèr ѕâlámí ","cíllûm ìn ѕɯìлe ϻêàtɭ߀àf dûìs ","ρãncettä ƅrìsƙét ԁèsêrûлt áútè"," յòɰɭ. Lɑbòrìѕ ƙìêɭ","básá ԁòlòré fatƃɑck ƅêéf. Pɑѕtr","ämì piɢ ѕհàлƙ ùɭɭamcò ѕaû","ѕäǥë sɦànƙlë."," Cúpím ɭäƃorum drumstïcƙ jerkϒ veli"," pïcåԉɦɑ ƙíéɭƅãsa. Alïqû","iρ írürë cûpíϻ, äɭìɋuâ ǥròûлd ","roúлᏧ toԉgüè ρàrìãtùr ","briѕkèt ԉostruᏧ cûɭpɑ"," ìd còлѕèqûât làƅ߀rìs."],d=0;g.seriesMap(c,function(a,c,e){d++,b.log(a,e)},function(b,e){a.ok(!b),a.strictEqual(d,c.length);for(var f in c){a.notStrictEqual(c[f].length,e[f].bytes);try{a.strictEqual(Buffer.byteLength(c[f]),e[f].bytes)}catch(b){a.strictEqual(decodeURI(encodeURIComponent(c[f])).length,e[f].bytes)}}a.done()})},"Callback#Service submit event, failure":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.loggedOutService,e=this.indexName;g.chain(function(c){a.ok(d),d.log(b,c)},function(b){a.ok(b),a.done()})},"Callback#remove throws an error":function(a){var b=this.service.indexes().item("_internal");a.throws(function(){b.remove()}),a.done()},"Callback#create an index with alternate argument format":function(a){var b=this.service.indexes();b.create({name:"_internal"},function(b,c){a.ok(b.data.messages[0].text.match("name=_internal already exists")),a.done()})},"Callback#Index submit event with omitted optional arguments":function(a){var b="Hello world -- "+k(),c=this.indexName,d=this.service.indexes();g.chain([function(a){d.fetch(a)},function(d,e){var f=d.item(c);a.ok(f),a.strictEqual(f.name,c),f.submitEvent(b,e)},function(d,e,f){a.ok(d),a.strictEqual(d.bytes,b.length),a.strictEqual(d.index,c),f()}],function(b){a.ok(!b),a.done()})},"Callback#Index submit event":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.indexName,e=this.service.indexes();g.chain([function(a){e.fetch(a)},function(e,f){var g=e.item(d);a.ok(g),a.strictEqual(g.name,d),g.submitEvent(b,{sourcetype:c},f)},function(e,f,g){a.ok(e),a.strictEqual(e.sourcetype,c),a.strictEqual(e.bytes,b.length),a.strictEqual(e.index,d),g()}],function(b){a.ok(!b),a.done()})}},"User Tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},tearDown:function(a){this.service.logout(a)},"Callback#Current user":function(a){var b=this.service;b.currentUser(function(c,d){a.ok(!c),a.ok(d),a.strictEqual(d.name,b.username),a.done()})},"Callback#Current user fails":function(a){var b=this.loggedOutService;b.currentUser(function(b,c){a.ok(b),a.done()})},"Callback#List users":function(a){var b=this.service;b.users().fetch(function(b,c){var d=c.list();a.ok(!b),a.ok(c),a.ok(d),a.ok(d.length>0),a.done()})},"Callback#create user failure":function(a){this.loggedOutService.users().create({name:"jssdk_testuser",password:"abc",roles:"user"},function(b,c){a.ok(b),a.done()})},"Callback#Create + update + delete user":function(a){var b=this.service,c="jssdk_testuser";g.chain([function(a){b.users().create({name:"jssdk_testuser",password:"abc",roles:"user"},a)},function(b,d){a.ok(b),a.strictEqual(b.name,c),a.strictEqual(b.properties().roles.length,1),a.strictEqual(b.properties().roles[0],"user"),b.update({realname:"JS SDK",roles:["admin","user"]},d)},function(b,c){a.ok(b),a.strictEqual(b.properties().realname,"JS SDK"),a.strictEqual(b.properties().roles.length,2),a.strictEqual(b.properties().roles[0],"admin"),a.strictEqual(b.properties().roles[1],"user"),b.remove(c)}],function(b){a.ok(!b),a.done()})},"Callback#Roles":function(a){var b=this.service,c="jssdk_testuser_"+k();g.chain([function(a){b.users().create({name:c,password:"abc",roles:"user"},a)},function(b,d){a.ok(b),a.strictEqual(b.name,c),a.strictEqual(b.properties().roles.length,1),a.strictEqual(b.properties().roles[0],"user"),b.update({roles:["admin","user"]},d)},function(b,c){a.ok(b),a.strictEqual(b.properties().roles.length,2),a.strictEqual(b.properties().roles[0],"admin"),a.strictEqual(b.properties().roles[1],"user"),b.update({roles:"user"},c)},function(b,c){a.ok(b),a.strictEqual(b.properties().roles.length,1),a.strictEqual(b.properties().roles[0],"user"),b.update({roles:"__unknown__"},c)}],function(b){a.ok(b),a.strictEqual(b.status,400),a.done()})},"Callback#Passwords":function(a){var b=this.service,c=null,e="jssdk_testuser_"+k();g.chain([function(a){b.users().create({name:e,password:"abc",roles:"user"},a)},function(f,h){a.ok(f),a.strictEqual(f.name,e),a.strictEqual(f.properties().roles.length,1),a.strictEqual(f.properties().roles[0],"user"),c=new d.Service(b.http,{username:e,password:"abc",host:b.host,port:b.port,scheme:b.scheme,version:b.version}),c.login(g.augment(h,f))},function(b,c,d){a.ok(b),a.ok(c),c.update({password:"abc2"},d)},function(b,d){c.login(function(c,e){a.ok(c),a.ok(!e),b.update({password:"abc"},d)})},function(b,d){a.ok(b),c.login(d)}],function(b){a.ok(!b),a.done()})},"Callback#delete test users":function(a){var b=this.service.users();b.fetch(function(b,c){var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})}},"Server Info Tests":{setUp:function(a){this.service=b,a()},"Callback#Basic":function(a){var b=this.service;b.serverInfo(function(b,c){a.ok(!b),a.ok(c),a.strictEqual(c.name,"server-info"),a.ok(c.properties().hasOwnProperty("version")),a.ok(c.properties().hasOwnProperty("serverName")),a.ok(c.properties().hasOwnProperty("os_version")),a.done()})}},"View Tests":{setUp:function(a){this.service=b,a()},"Callback#List views":function(a){var b=this.service;b.views({owner:"admin",app:"search"}).fetch(function(b,c){a.ok(!b),a.ok(c);var d=c.list();a.ok(d),a.ok(d.length>0);for(var e=0;e",e="";g.chain([function(a){b.views({owner:"admin",app:"sdk-app-collection"}).create({name:c,"eai:data":d},a)},function(b,f){a.ok(b),a.strictEqual(b.name,c),a.strictEqual(b.properties()["eai:data"],d),b.update({"eai:data":e},f)},function(b,c){a.ok(b),a.strictEqual(b.properties()["eai:data"],e),b.remove(c)}],function(b){a.ok(!b),a.done()})}},"Parser Tests":{setUp:function(a){this.service=b,a()},"Callback#Basic parse":function(a){var b=this.service;b.parse("search index=_internal | head 1",function(b,c){a.ok(!b),a.ok(c),a.ok(c.commands.length>0),a.done()})},"Callback#Parse error":function(a){var b=this.service;b.parse("ABCXYZ",function(b,c){a.ok(b),a.strictEqual(b.status,400),a.done()})}},"Typeahead Tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Callback#Typeahead failure":function(a){var b=this.loggedOutService;b.typeahead("index=",1,function(b,c){a.ok(b),a.done()})},"Callback#Basic typeahead":function(a){var b=this.service;b.typeahead("index=",1,function(b,c){a.ok(!b),a.ok(c),a.strictEqual(c.length,1),a.ok(c[0]),a.done()})},"Typeahead with omitted optional arguments":function(a){var b=this.service;b.typeahead("index=",function(b,c){a.ok(!b),a.ok(c),a.done()})}},"Endpoint Tests":{setUp:function(a){this.service=b,a()},"Throws on null arguments to init":function(a){var b=this.service;a.throws(function(){var a=new d.Service.Endpoint(null,"a/b")}),a.throws(function(){var a=new d.Service.Endpoint(b,null)}),a.done()},"Endpoint delete on a relative path":function(a){var b=this.service,c=new d.Service.Endpoint(b,"/search/jobs/12345");c.del("search/jobs/12345",{},function(){a.done()})},"Methods of Resource to be overridden":function(a){var b=this.service,c=new d.Service.Resource(b,"/search/jobs/12345");a.throws(function(){c.path()}),a.throws(function(){c.fetch()}),a.ok(d.Utils.isEmpty(c.state())),a.done()}},"Entity tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Accessors function properly":function(a){var b=new d.Service.Entity(this.service,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b._load({acl:{owner:"boris",app:"factory",sharing:"app"},links:{link1:35},published:"meep",author:"Hilda"}),a.ok(b.acl().owner==="boris"),a.ok(b.acl().app==="factory"),a.ok(b.acl().sharing==="app"),a.ok(b.links().link1===35),a.strictEqual(b.author(),"Hilda"),a.strictEqual(b.published(),"meep"),a.done()},"Refresh throws error correctly":function(a){var b=new d.Service.Entity(this.loggedOutService,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b.fetch({},function(b){a.ok(b),a.done()})},"Cannot update name of entity":function(a){var b=new d.Service.Entity(this.service,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});a.throws(function(){b.update({name:"asdf"})}),a.done()},"Disable throws error correctly":function(a){var b=new d.Service.Entity(this.loggedOutService,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b.disable(function(b){a.ok(b),a.done()})},"Enable throws error correctly":function(a){var b=new d.Service.Entity(this.loggedOutService,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b.enable(function(b){a.ok(b),a.done()})},"Does reload work?":function(a){var b=new d.Service.Index(this.service,"data/indexes/sdk-test",{owner:"admin",app:"search",sharing:"app"}),c="jssdk_testapp_"+k(),e=this.service.apps(),f=this;g.chain(function(a){e.create({name:c},a)},function(b,c){b.reload(function(d){a.ok(!d),c(null,b)})},function(b,c){var e=new d.Service.Application(f.loggedOutService,b.name);e.reload(function(d){a.ok(d),c(null,b)})},function(a,b){a.remove(b)},function(b){a.ok(!b),a.done()})}},"Collection tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Methods to be overridden throw":function(a){var b=new d.Service.Collection(this.service,"/data/indexes",{owner:"admin",app:"search",sharing:"app"});a.throws(function(){b.instantiateEntity({})}),a.done()},"Accessors work":function(a){var b=new d.Service.Collection(this.service,"/data/indexes",{owner:"admin",app:"search",sharing:"app"});b._load({links:"Hilda",updated:!0}),a.strictEqual(b.links(),"Hilda"),a.ok(b.updated()),a.done()},"Contains throws without a good id":function(a){var b=new d.Service.Collection(this.service,"/data/indexes",{owner:"admin",app:"search",sharing:"app"});a.throws(function(){b.item(null)}),a.done()}}};return l};if(b===a.main){var f=a("../index"),g=a("../examples/node/cmdline"),h=a("../contrib/nodeunit/test_reporter"),i=g.create(),j=i.parse(process.argv);if(!j)throw new Error("Error in parsing command line parameters");if(!process.env.SPLUNK_HOME)throw new Error("$PATH variable SPLUNK_HOME is not set. Please export SPLUNK_HOME to the splunk instance.");var k=new f.Service({scheme:j.opts.scheme,host:j.opts.host,port:j.opts.port,username:j.opts.username,password:j.opts.password,version:j.opts.version}),l=new f.Service({scheme:j.opts.scheme,host:j.opts.host,port:j.opts.port,username:j.opts.username,password:j.opts.password+"wrong",version:j.opts.version}),m=c.setup(k,l);k.login(function(a,b){if(a||!b)throw new Error("Login failed - not running tests",a||"");h.run([{Tests:m}])})}}),require.define("/tests/test_examples.js",function(a,b,c,d,e){c.setup=function(b,c){var d=a("../index"),e=d.Async;d.Logger.setLevel("ALL");var f=0,g=function(){return"id"+f++ +"_"+(new Date).valueOf()},h=["program","script"];return{"Hello World Tests":{Apps:function(b){var d=a("../examples/node/helloworld/apps").main;d(c,b.done)},"Apps#Async":function(b){var d=a("../examples/node/helloworld/apps_async").main;d(c,b.done)},"Pivot#Async":function(b){var d=a("../examples/node/helloworld/pivot_async").main;d(c,b.done)},"Fired Alerts":function(b){var d=a("../examples/node/helloworld/firedalerts").main;d(c,b.done)},"Fired Alerts#Async":function(b){var d=a("../examples/node/helloworld/firedalerts_async").main;d(c,b.done)},"Fired Alerts#Create":function(b){var d=a("../examples/node/helloworld/firedalerts_create").main;d(c,b.done)},"Fired Alerts#Delete":function(b){var d=a("../examples/node/helloworld/firedalerts_delete").main;d(c,b.done)},"Get Job by sid":function(b){var d=a("../examples/node/helloworld/get_job").main;d(c,b.done)},"Endpoint Instantiation":function(b){var d=a("../examples/node/helloworld/endpoint_instantiation").main;d(c,b.done)},"Saved Searches":function(b){var d=a("../examples/node/helloworld/savedsearches").main;d(c,b.done)},"Saved Searches#Async":function(b){var d=a("../examples/node/helloworld/savedsearches_async").main;d(c,b.done)},"Saved Searches#Delete":function(b){var d=a("../examples/node/helloworld/savedsearches_delete").main;d(c,b.done)},"Saved Searches#Create":function(b){var d=a("../examples/node/helloworld/savedsearches_create").main;d(c,b.done)},"Saved Searches#Delete Again":function(b){var d=a("../examples/node/helloworld/savedsearches_delete").main;d(c,b.done)},"Search#normal":function(b){var d=a("../examples/node/helloworld/search_normal").main;d(c,b.done)},"Search#blocking":function(b){var d=a("../examples/node/helloworld/search_blocking").main;d(c,b.done)},"Search#oneshot":function(b){var d=a("../examples/node/helloworld/search_oneshot").main;d(c,b.done)},"Search#realtime":function(b){var d=a("../examples/node/helloworld/search_realtime").main;d(c,b.done)},Logging:function(b){var d=a("../examples/node/helloworld/log").main;d(c,b.done)}},"Jobs Example Tests":{setUp:function(b){var c=this;this.main=a("../examples/node/jobs").main,this.run=function(a,b,d,e){var f=h.slice();a&&f.push(a);if(b)for(var g=0;g ")),console.log("\t Internal name: "+l.name),l.startSearch({},"| head 5",b)},function(a,b){a.track({},function(a){a.results({},b)})},function(a,b,c){console.log("Results:");for(var d=0;dd},function(b){g.sleep(1e3,function(){a.preview({},function(a,c){if(a){b(a);return}if(c&&c.rows){d++,console.log("========== Iteration "+d+" ==========");var e=c.fields.indexOf("sourcetype"),f=c.fields.indexOf("count");for(var g=0;g",k,[],e),c.add("preview","Fetch preview results for the specified search jobs","",k,[],e),c.add("events","Fetch events for the specified search jobs","",j,[],e),c.add("cancel","Cancel the specify search jobs","",[],[],e),c.add("list","List all search jobs or properties for those specified","[sids...]",[],[],e),c.parse(a);if(!c.executedCommand){console.log(c.helpInformation()),b("You must specify a command to run.");return}},b===a.main&&c.main(process.argv)})()}),require.define("/examples/node/search.js",function(a,b,c,d,e){(function(){var d=a("../../index"),e=d.Class,f=d.Utils,g=d.Async,h=a("./cmdline"),i=a("util").print,j=["search","earliest_time","latest_time","now","time_format","exec_mode","search_mode","rt_blocking","rt_queue_size","rt_maxblocksecs","rt_indexfilter","id","status_buckets","max_count","max_time","timeout","auto_finalize_ec","enable_lookups","reload_macros","reduce_freq","spawn_process","required_field_list","rf","auto_cancel","auto_pause"],k=function(a){return new d.Service({scheme:a.scheme,host:a.host,port:a.port,username:a.username,password:a.password,version:a.version})},l=function(a,b,c){var d=b.search,e=b.verbose,f=b.count||0,h=b.mode||"row";delete b.search,delete b.verbose,delete b.count,delete b.mode,g.chain([function(c){a.search(d,b,c)},function(a,b){g.whilst(function(){return!a.properties().isDone},function(b){a.fetch(function(a,d){if(a)c(a);else{var f=d.properties();if(e){var h=f.doneProgress*100+"%",j=f.scanCount,k=f.eventCount,l=f.resultCount,m="-- "+h+" done | "+j+" scanned | "+k+" matched | "+l+" results";i("\r"+m+" ")}g.sleep(1e3,b)}})},function(c){e&&i("\r"),b(c,a)})},function(a,b){a.results({count:f,json_mode:h},b)},function(a,b,c){process.stdout.write(JSON.stringify(a)),b.cancel(c)}],function(a){c(a)})},m=function(a,b,c){var d=b.search;delete b.search,a.oneshotSearch(d,b,function(a,b){a?c(a):(console.log(JSON.stringify(b)),c())})};c.main=function(a,b){d.Logger.setLevel("NONE"),b=b||function(a){a&&console.log(a)};var c=h.create();c.name="search",c.description("Create a search and print the results to stdout"),c.option("--verbose","Output job progress as we wait for completion"),c.option("--count ","How many results to fetch"),c.option("--mode ","Row or column mode [row|column]");var e=j,f=["search"];for(var g=0;g=0,n="<"+e[g]+">";c.option("--"+e[g]+" "+n,"",undefined,i)}c.on("--help",function(){console.log(" Examples:"),console.log(" "),console.log(" Create a regular search:"),console.log(" > node search.js --search 'search index=_internal | head 10'"),console.log(" "),console.log(" Create a oneshot search:"),console.log(" > node search.js --search 'search index=_internal | head 10' --exec_mode oneshot"),console.log(" "),console.log(" Create a regular search and only return 10 results:"),console.log(" > node search.js --search 'search index=_internal | head 20' --count 10"),console.log(" "),console.log(" Create a regular search and output the progress while the search is running"),console.log(" > node search.js --search 'search index=_internal | head 20' --verbose"),console.log(" ")}),c.parse(a);var o=k(c.opts);o.login(function(a,d){if(a||!d){b("Error logging in");return}delete c.username,delete c.password,delete c.scheme,delete c.host,delete c.port,delete c.namespace,delete c.version,c.opts.exec_mode==="oneshot"?m(o,c.opts,b):l(o,c.opts,b)})},b===a.main&&c.main(process.argv)})()}),require.define("/browser.test.entry.js",function(a,b,c,d,e){window.SplunkTest={Utils:a("../../tests/test_utils"),Async:a("../../tests/test_async"),Http:a("../../tests/test_http"),Context:a("../../tests/test_context"),Service:a("../../tests/test_service"),Examples:a("../../tests/test_examples")}}),require("/browser.test.entry.js") +var require=function(a,b){var c=require.resolve(a,b||"/"),d=require.modules[c];if(!d)throw new Error("Failed to resolve module "+a+", tried "+c);var e=d._cached?d._cached:d();return e};require.paths=[],require.modules={},require.extensions=[".js",".coffee"],require._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},require.resolve=function(){return function(a,b){function g(a){if(require.modules[a])return a;for(var b=0;b=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";d.push(f)}return d}b||(b="/");if(require._core[a])return a;var c=require.modules.path();b=c.resolve("/",b);var d=b||"/";if(a.match(/^(?:\.\.?\/|\/)/)){var e=g(c.resolve(d,a))||h(c.resolve(d,a));if(e)return e}var f=i(a,d);if(f)return f;throw new Error("Cannot find module '"+a+"'")}}(),require.alias=function(a,b){var c=require.modules.path(),d=null;try{d=require.resolve(a+"/package.json","/")}catch(e){d=require.resolve(a,"/")}var f=c.dirname(d),g=(Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b})(require.modules);for(var h=0;h0){var c=a.shift();c()}}},!0),function(c){b?(a.push(c),window.postMessage("browserify-tick","*")):setTimeout(c,0)}}()),process.title||(process.title="browser"),process.binding||(process.binding=function(a){if(a==="evals")return require("vm");throw new Error("No such module")}),process.cwd||(process.cwd=function(){return"."}),require.define("path",function(a,b,c,d,e){function f(a,b){var c=[];for(var d=0;d=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var h=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var a="",b=!1;for(var c=arguments.length;c>=-1&&!b;c--){var d=c>=0?arguments[c]:process.cwd();if(typeof d!="string"||!d)continue;a=d+"/"+a,b=d.charAt(0)==="/"}return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=a.charAt(0)==="/",c=a.slice(-1)==="/";return a=g(f(a.split("/"),function(a){return!!a}),!b).join("/"),!a&&!b&&(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(f(a,function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var b=h.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=h.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return h.exec(a)[3]||""}}),require.define("/tests/test_utils.js",function(a,b,c,d,e){c.setup=function(){var b=a("../index");return b.Logger.setLevel("ALL"),{"Callback#callback to object success":function(a){var b=function(a){a(null,"one","two")};b(function(b,c,d){a.strictEqual(c,"one"),a.strictEqual(d,"two"),a.done()})},"Callback#callback to object error - single argument":function(a){var b=function(a){a("one")};b(function(b,c,d){a.strictEqual(b,"one"),a.ok(!c),a.ok(!d),a.done()})},"Callback#callback to object error - multi argument":function(a){var b=function(a){a(["one","two"])};b(function(b,c,d){a.strictEqual(b[0],"one"),a.strictEqual(b[1],"two"),a.ok(!c),a.ok(!d),a.done()})},"keyOf works":function(a){a.ok(b.Utils.keyOf(3,{a:3,b:5})),a.ok(!b.Utils.keyOf(3,{a:12,b:6})),a.done()},bind:function(a){var c;(function(){c=function(a){this.a=a}})();var d={},e=b.Utils.bind(d,c);e(12),a.strictEqual(d.a,12),a.done()},trim:function(a){a.strictEqual(b.Utils.trim(" test of something \n\r \t"),"test of something");var c=String.prototype.trim;String.prototype.trim=null,a.strictEqual(b.Utils.trim(" test of something \n\r \t"),"test of something"),String.prototype.trim=c,a.done()},indexOf:function(a){a.strictEqual(b.Utils.indexOf([1,2,3,4,5],3),2),a.strictEqual(b.Utils.indexOf([1,2,3,4,3],3),2),a.strictEqual(b.Utils.indexOf([1,2,3,4,5],12),-1),a.done()},contains:function(a){a.ok(b.Utils.contains([1,2,3,4,5],3)),a.ok(b.Utils.contains([1,2,3,4,3],3)),a.ok(!b.Utils.contains([1,2,3,4,5],12)),a.done()},startsWith:function(a){a.ok(b.Utils.startsWith("abcdefg","abc")),a.ok(!b.Utils.startsWith("bcdefg","abc")),a.done()},endsWith:function(a){a.ok(b.Utils.endsWith("abcdef","def")),a.ok(!b.Utils.endsWith("abcdef","bcd")),a.done()},toArray:function(a){(function(){var c=b.Utils.toArray(arguments),d=[1,2,3,4,5];for(var e=0;e=e.ALL&&g.apply(null,arguments)},error:function(){process.env.LOG_LEVEL>=e.ERROR&&i.apply(null,arguments)},warn:function(){process.env.LOG_LEVEL>=e.WARN&&h.apply(null,arguments)},info:function(){process.env.LOG_LEVEL>=e.INFO&&j.apply(null,arguments)},printMessages:function(a){a=a||[];for(var b=0;b=0},e.startsWith=function(a,b){var c=a.match("^"+b);return c&&c.length>0&&c[0]===b},e.endsWith=function(a,b){var c=a.match(b+"$");return c&&c.length>0&&c[0]===b};var f=Object.prototype.toString;e.toArray=function(a){return Array.prototype.slice.call(a)},e.isArray=Array.isArray||function(a){return f.call(a)==="[object Array]"},e.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},e.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)},e.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},e.isObject=function(a){return a===Object(a)},e.isEmpty=function(a){if(e.isArray(a)||e.isString(a))return a.length===0;for(var b in a)if(this.hasOwnProperty.call(a,b))return!1;return!0},e.forEach=function(a,b,c){if(a===null)return;if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;dh)return 1}return 0}}),h.Sharing={USER:"user",APP:"app",GLOBAL:"global",SYSTEM:"system"}})()}),require.define("/lib/paths.js",function(a,b,c,d,e){(function(){"use strict";var a=c||this;a.Paths={apps:"/services/apps/local",capabilities:"authorization/capabilities",configurations:"configs",dataModels:"datamodel/model",deploymentClient:"deployment/client",deploymentServers:"deployment/server",deploymentServerClasses:"deployment/serverclass",deploymentTenants:"deployment/tenants",eventTypes:"saved/eventtypes",firedAlerts:"alerts/fired_alerts",indexes:"data/indexes",info:"/services/server/info",inputs:null,jobs:"search/jobs",licenseGroups:"licenser/groups",licenseMessages:"licenser/messages",licensePools:"licenser/pools",licenseSlaves:"licenser/slaves",licenseStacks:"licenser/stacks",licenses:"licenser/licenses",loggers:"server/logger",login:"/services/auth/login",messages:"messages",passwords:"admin/passwords",parser:"search/parser",pivot:"datamodel/pivot",properties:"properties",roles:"authorization/roles",savedSearches:"saved/searches",settings:"server/settings",storagePasswords:"storage/passwords",users:"/services/authentication/users",typeahead:"search/typeahead",views:"data/ui/views",currentUser:"/services/authentication/current-context",submitEvent:"/services/receivers/simple"}})()}),require.define("/lib/jquery.class.js",function(a,b,c,d,e){(function(){var a=c||this,b=!1,d=/xyz/.test(function(){return xyz})?/\b_super\b/:/.*/;a.Class=function(){},a.Class.extend=function(a){function g(){!b&&this.init&&this.init.apply(this,arguments)}var c=this.prototype;b=!0;var e=new this;b=!1;for(var f in a)e[f]=typeof a[f]=="function"&&typeof c[f]=="function"&&d.test(a[f])?function(a,b){return function(){var d=this._super;this._super=c[a];var e=b.apply(this,arguments);return this._super=d,e}}(f,a[f]):a[f];return g.prototype=e,g.constructor=g,g.extend=arguments.callee,g}})()}),require.define("/lib/http.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./jquery.class").Class,e=a("./log").Logger,f=a("./utils"),g=a("cookie"),h=c||this,i=null,j={5:function(a){var b=a.query||{},c=a.post||{},d=b.output_mode||c.output_mode||"json";return f.startsWith(d,"json")||(d="json"),b.output_mode=d,b},4:function(a){return a.query||{}},"default":function(a){return j[5](a)},none:function(a){return a.query||{}}};b.exports=h=i=d.extend({init:function(){this.get=f.bind(this,this.get),this.del=f.bind(this,this.del),this.post=f.bind(this,this.post),this.request=f.bind(this,this.request),this._buildResponse=f.bind(this,this._buildResponse),this._setSplunkVersion("none"),this._cookieStore={}},_setSplunkVersion:function(a){this.version=a},_getCookieString:function(){var a="";return f.forEach(this._cookieStore,function(b,c){a+=c,a+="=",a+=b,a+="; "}),a},_parseCookieHeader:function(a){var b=g.parse(a),c={};return f.forEach(b,function(a,b){if(c.key)return;c.key=b,c.value=a}),c},get:function(a,b,c,d,e){var f={method:"GET",headers:b,timeout:d,query:c};return this.request(a,f,e)},post:function(a,b,c,d,e){b["Content-Type"]="application/x-www-form-urlencoded";var f={method:"POST",headers:b,timeout:d,post:c};return this.request(a,f,e)},del:function(a,b,c,d,e){var f={method:"DELETE",headers:b,timeout:d,query:c};return this.request(a,f,e)},request:function(a,b,c){var d=this,e=function(a){c=c||function(){};var b=a.response.headers["set-cookie"];b&&f.forEach(b,function(a){var b=d._parseCookieHeader(a);d._cookieStore[b.key]=b.value}),a.status<400&&a.status!=="abort"?c(null,a):c(a)},g=f.getWithVersion(this.version,j)(b),h=b.post||{},k=a+"?"+i.encode(g),l=b.body?b.body:i.encode(h),m=d._getCookieString();m.length!==0&&(b.headers.Cookie=m,delete b.headers.Authorization);var n={method:b.method,headers:b.headers,timeout:b.timeout,body:l};return this.makeRequest(k,n,e)},makeRequest:function(a,b,c){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},parseJson:function(a){throw new Error("UNDEFINED FUNCTION - OVERRIDE REQUIRED")},_buildResponse:function(a,b,c){var d,g={},h=null;b&&b.headers&&(h=f.trim(b.headers["content-type"]||b.headers["Content-Type"]||b.headers["Content-type"]||b.headers.contentType));if(f.startsWith(h,"application/json")&&c)try{g=this.parseJson(c)||{}}catch(i){e.error("Error in parsing JSON:",c,i),g=c}else g=c;return g&&e.printMessages(g.messages),d={response:b,status:b?b.statusCode:0,data:g,error:a},d}}),i.encode=function(a){var b="";for(var c in a)if(a.hasOwnProperty(c)){b&&b[b.length-1]!=="&"&&(b+="&");var d=a[c];if(d instanceof Array)for(var e=0;e1&&!b)throw new Error("Ambiguous match for name '"+a+"'");for(var e=0;e","<=",">=","is","isNull","isNotNull"],ipv4:["is","isNull","isNotNull","contains","doesNotContain","startsWith"]},_binning:["auto","year","month","day","hour","minute","second"],_sortDirection:["ASCENDING","DESCENDING","DEFAULT"],_statsFunctions:["list","values","first","last","count","dc","sum","average","max","min","stdev","duration","earliest","latest"],init:function(a){this.dataModelObject=a,this.columns=[],this.rows=[],this.filters=[],this.cells=[],this.accelerationNamespace=a.dataModel.isAccelerated()?a.dataModel.name:null,this.run=i.bind(this,this.run),this.pivot=i.bind(this,this.pivot)},setAccelerationJob:function(a){a&&a instanceof k.Job&&(a=a.sid);if(!a)throw new Error("Sid to use for acceleration must not be null.");return this.accelerationNamespace="sid="+a,this},addFilter:function(a,b,c,d){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add filter on a nonexistent field.");if(b!==this.dataModelObject.fieldByName(a).type)throw new Error("Cannot add "+b+" filter on "+a+" because it is of type "+this.dataModelObject.fieldByName(a).type);if(!i.contains(this._comparisons[b],c))throw new Error("Cannot add "+b+" filter because "+c+" is not a valid comparison operator");var e={fieldName:a,owner:this.dataModelObject.fieldByName(a).lineage.join("."),type:b};return i.contains(["boolean","string","ipv4","number"],e.type)&&(e.rule={comparator:c,compareTo:d}),this.filters.push(e),this},addLimitFilter:function(a,b,c,d,e){if(!this.dataModelObject.hasField(a))throw new Error("Cannot add limit filter on a nonexistent field.");var f=this.dataModelObject.fieldByName(a);if(!i.contains(["string","number","objectCount"],f.type))throw new Error("Cannot add limit filter on "+a+" because it is of type "+f.type);if("string"===f.type&&!i.contains(["count","dc"],e))throw new Error("Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found "+e);if("number"===f.type&&!i.contains(["count","dc","average","sum"],e))throw new Error("Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found "+e);if("objectCount"===f.type&&!i.contains(["count"],e))throw new Error("Stats function for fields of type object count must be COUNT; found "+e);var g={fieldName:a,owner:f.lineage.join("."),type:f.type,attributeName:b,attributeOwner:this.dataModelObject.fieldByName(b).lineage.join("."),sortDirection:c,limitAmount:d,statsFn:e};return g.limitType="ASCENDING"===c?"lowest":"highest",this.filters.push(g),this},addRowSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],c.type))throw new Error("Field was of type "+c.type+", expected number or string.");var d={fieldName:a,owner:c.owner,type:c.type,label:b};return"number"===c.type&&(d.display="all"),this.rows.push(d),this},addRangeRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("number"!==d.type)throw new Error("Field was of type "+d.type+", expected number.");var e={};return!i.isUndefined(c.start)&&c.start!==null&&(e.start=c.start),!i.isUndefined(c.end)&&c.end!==null&&(e.end=c.end),!i.isUndefined(c.step)&&c.step!==null&&(e.size=c.step),!i.isUndefined(c.limit)&&c.limit!==null&&(e.maxNumberOf=c.limit),this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,display:"ranges",ranges:e}),this},addBooleanRowSplit:function(a,b,c,d){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var e=this.dataModelObject.fieldByName(a);if("boolean"!==e.type)throw new Error("Field was of type "+e.type+", expected boolean.");return this.rows.push({fieldName:a,owner:e.owner,type:e.type,label:b,trueLabel:c,falseLabel:d}),this},addTimestampRowSplit:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("timestamp"!==d.type)throw new Error("Field was of type "+d.type+", expected timestamp.");if(!i.contains(this._binning,c))throw new Error("Invalid binning "+c+" found. Valid values are: "+this._binning.join(", "));return this.rows.push({fieldName:a,owner:d.owner,type:d.type,label:b,period:c}),this},addColumnSplit:function(a){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var b=this.dataModelObject.fieldByName(a);if(!i.contains(["number","string"],b.type))throw new Error("Field was of type "+b.type+", expected number or string.");var c={fieldName:a,owner:b.owner,type:b.type};return"number"===b.type&&(c.display="all"),this.columns.push(c),this},addRangeColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("number"!==c.type)throw new Error("Field was of type "+c.type+", expected number.");var d={};return!i.isUndefined(b.start)&&b.start!==null&&(d.start=b.start),!i.isUndefined(b.end)&&b.end!==null&&(d.end=b.end),!i.isUndefined(b.step)&&b.step!==null&&(d.size=b.step),!i.isUndefined(b.limit)&&b.limit!==null&&(d.maxNumberOf=b.limit),this.columns.push({fieldName:a,owner:c.owner,type:c.type,display:"ranges",ranges:d}),this},addBooleanColumnSplit:function(a,b,c){if(!this.dataModelObject.fieldByName(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if("boolean"!==d.type)throw new Error("Field was of type "+d.type+", expected boolean.");return this.columns.push({fieldName:a,owner:d.owner,type:d.type,trueLabel:b,falseLabel:c}),this},addTimestampColumnSplit:function(a,b){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var c=this.dataModelObject.fieldByName(a);if("timestamp"!==c.type)throw new Error("Field was of type "+c.type+", expected timestamp.");if(!i.contains(this._binning,b))throw new Error("Invalid binning "+b+" found. Valid values are: "+this._binning.join(", "));return this.columns.push({fieldName:a,owner:c.owner,type:c.type,period:b}),this},addCellValue:function(a,b,c){if(!this.dataModelObject.hasField(a))throw new Error("Did not find field "+a);var d=this.dataModelObject.fieldByName(a);if(i.contains(["string","ipv4"],d.type)&&!i.contains(["list","values","first","last","count","dc"],c))throw new Error("Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found "+c);if("number"===d.type&&!i.contains(["sum","count","average","min","max","stdev","list","values"],c))throw new Error("Stats function on number field must be must be one of: sum, count, average, max, min, stdev, list, or distinct_values; found "+c);if("timestamp"===d.type&&!i.contains(["duration","earliest","latest","list","values"],c))throw new Error("Stats function on timestamp field must be one of: duration, earliest, latest, list, or distinct values; found "+c);if(i.contains(["objectCount","childCount"],d.type)&&"count"!==c)throw new Error("Stats function on childcount and objectcount fields must be count; found "+c);if("boolean"===d.type)throw new Error("Cannot use boolean valued fields as cell values.");return this.cells.push({fieldName:a,owner:d.lineage.join("."),type:d.type,label:b,sparkline:!1,value:c}),this},toJsonObject:function(){return{dataModel:this.dataModelObject.dataModel.name,baseClass:this.dataModelObject.name,rows:this.rows,columns:this.columns,cells:this.cells,filters:this.filters}},pivot:function(a){var b=this.dataModelObject.dataModel.service,c={pivot_json:JSON.stringify(this.toJsonObject())};return i.isUndefined(this.accelerationNamespace)||(c.namespace=this.accelerationNamespace),b.get(g.pivot+"/"+encodeURIComponent(this.dataModelObject.dataModel.name),c,function(c,d){if(c){a(new Error(c.data.messages[0].text),d);return}d.data.entry&&d.data.entry[0]?a(null,new j.Pivot(b,d.data.entry[0].content)):a(new Error("Didn't get a Pivot report back from Splunk"),d)})},run:function(a,b){b||(b=a,a={}),a=a||{},this.pivot(function(c,d){c?b(c,null,null):d.run(a,f.augment(b,d))})}}),j.DataModelObject=h.extend({init:function(a,b){a=a||{},a.owner=a.owner||"",this.dataModel=b,this.name=a.objectName,this.displayName=a.displayName,this.parentName=a.parentName,this.lineage=a.lineage.split("."),a.hasOwnProperty("groupByFields")&&(this.groupByFields=a.groupByFields),a.hasOwnProperty("objectsToGroup")&&(this.objectsToGroup=a.objectsToGroup),a.hasOwnProperty("transactionMaxTimeSpan")&&(this.maxSpan=a.transactionMaxTimeSpan),a.hasOwnProperty("transactionMaxPause")&&(this.maxPause=a.transactionMaxPause),a.hasOwnProperty("baseSearch")&&(this.baseSearch=a.baseSearch),this.fields={};for(var c=0;c0)}})}})})()}),require.define("/lib/async.js",function(a,b,c,d,e){(function(){"use strict";var b=a("./utils"),d=c||this;d.whilst=function(a,b,c){a=a||function(){return!1},b=b||function(a){a()},c=c||function(){};var e=function(e){e?c(e):d.whilst(a,b,c)};a()?b(e):c(null)},d.parallel=function(a,c){if(arguments.length>1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){},a.length===0&&c();var e=a.length,f=[],g=function(a){return function(d){if(d)c&&c(d),c=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),f[a]=g,--e===0&&(f.unshift(null),c&&c.apply(null,f))}}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};var e=function(a,c,d,f){if(!a){d.unshift(null),f.apply(null,d);return}a(function(a){if(a)f&&f(a),f=null;else{var g=b.toArray(arguments);g.shift(),g.length===1&&(g=g[0]),d.push(g),e(c[0],c.slice(1),d,f)}})};e(a[0],a.slice(1),[],c)},d.parallelMap=function(a,c,e){a=a||[],e=e||function(){};var f=[],g=function(a,b){return function(d){c(a,b,d)}};for(var h=0;h1&&b.isFunction(arguments[0])){var d=b.toArray(arguments);a=d.slice(0,d.length-1),c=d[d.length-1]}a=a||[],c=c||function(){};if(!a.length)c();else{var e=function(a,d,f){var g=function(a){if(a)c(a),c=function(){};else{var f=b.toArray(arguments);f.shift(),e(d[0],d.slice(1),f)}},h=f;d.length?h.push(g):h.push(c),a.apply(null,h)};e(a[0],a.slice(1),[])}},d.sleep=function(a,b){setTimeout(function(){b()},a)},d.augment=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){var c=Array.prototype.slice.call(arguments);for(var d=0;d tag unexpected.")}},f.parseXMLData=function(a,b){var c={},d=a.getchildren();for(var e=0;e/g,">"),d||(a=a.replace(/\n/g," "),a=a.replace(/\r/g," ")),c&&(a=a.replace(/"/g,"""))),a}function w(a,b){return v(a,b,!0)}function x(a,b){return v(a,b,!1)}function y(a,b){return v(a,b,!1,!0)}function z(a,b,c){function g(a){return a}function h(a){if(a[0]==="{"){var b=a.substring(1).split("}",2),g=b[0],h=b[1],i=e[g];i===undefined&&(i=t[g],i===undefined&&(i="ns"+Object.keys(e).length),i!=="xml"&&(e[g]=i)),i?d[a]=f("%s:%s",i,h):d[a]=h}else{if(c)throw new Error("cannot use non-qualified names with default_namespace option");d[a]=a}}var d={},e={};return c&&(e[c]=""),a.iter(null,function(a){var b,c=a.tag,e=a.text,f=a.items();if(c instanceof r&&d[c.text]===undefined)h(c.text);else if(typeof c=="string")h(c);else if(c!==null&&c!==o&&c!==p&&c!==q)throw new Error("Invalid tag type for serialization: "+c);e instanceof r&&d[e.text]===undefined&&h(e.text),f.forEach(function(a){var b=a[0],c=a[1];b instanceof r&&(b=b.text),d[b]===undefined&&h(b),c instanceof r&&d[c.text]===undefined&&h(c.text)})}),[d,e]}function A(a,b,c,d,e,h,i){var j=b.tag,k=b.text,l,m,n=h||h===0;a(Array(h+1).join(i));if(j===o)a(f("",x(k,c)));else if(j===q)a(f("",x(k,c)));else if(j===p)k=k||"",a(f("",k));else{j=d[j];if(j===undefined)k&&a(y(k,c)),b.iter(function(b){A(a,b,c,d,null,n?h+1:!1,i)});else{a("<"+j),l=b.items();if(l||e)l.sort(),l.forEach(function(b){var e=b[0],g=b[1];e instanceof r&&(e=e.text),g instanceof r?g=d[g.text]:g=w(g,c),a(f(' %s="%s"',d[e],g))}),e&&(l=g.items(e),l.sort(function(a,b){return a[1]"),!k&&n&&a("\n"),k&&a(y(k,c)),b._children.forEach(function(b){A(a,b,c,d,null,n?h+1:!1,i)}),!k&&h&&a(Array(h+1).join(i)),a("")):a(" />")}}n&&a("\n")}function B(a,b){var c=new s;return c.parse(a,b),c}function C(a,b){return(new s(a)).write(b)}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./elementpath"),i=a("./treebuilder").TreeBuilder,j=a("./parser").get_parser,k=a("./constants"),l=0;m.prototype.toString=function(){return f("",this.tag,this._id)},m.prototype.makeelement=function(a,b){return new m(a,b)},m.prototype.len=function(){return this._children.length},m.prototype.getItem=function(a){return this._children[a]},m.prototype.setItem=function(a,b){this._children[a]=b},m.prototype.delItem=function(a){this._children.splice(a,1)},m.prototype.getSlice=function(a,b){return this._children.slice(a,b)},m.prototype.setSlice=function(a,b,c){var d,e=0;for(d=a;d\n");if(a.method==="text")_serialize_text(b,self._root,encoding);else{var c,d,e,f,h=z(this._root,a.encoding,a.default_namespace);c=h[0],d=h[1],a.hasOwnProperty("indent")?(e=0,f=(new Array(a.indent+1)).join(" ")):e=!1;if(a.method==="xml")A(function(a){b.push(a)},this._root,a.encoding,c,d,e,f);else throw new Error("unknown serialization method "+a.method)}return b.join("")};var t={"http://www.w3.org/XML/1998/namespace":"xml","http://www.w3.org/1999/xhtml":"html","http://www.w3.org/1999/02/22-rdf-syntax-ns#":"rdf","http://schemas.xmlsoap.org/wsdl/":"wsdl","http://www.w3.org/2001/XMLSchema":"xs","http://www.w3.org/2001/XMLSchema-instance":"xsi","http://purl.org/dc/elements/1.1/":"dc"};c.PI=q,c.Comment=o,c.CData=p,c.ProcessingInstruction=q,c.SubElement=n,c.QName=r,c.ElementTree=s,c.ElementPath=h,c.Element=function(a,b){return new m(a,b)},c.XML=function(a){var b=new s;return b.parse(a)},c.parse=B,c.register_namespace=u,c.tostring=C}),require.define("/node_modules/elementtree/lib/sprintf.js",function(a,b,c,d,e){function h(a){var b,c,d=a,e=0,h=1,i="return '";for(b=0;b100&&(i={});if(b.charAt(0)==="/")throw new h(null,"Cannot use absolute path on element");d=k(b),c=[];function o(){return d.shift()}j=o();for(;;){var p=j[1]||"";l=r[p](o,j);if(!l)throw new h(null,f("Invalid path: %s",b));c.push(l),j=o();if(!j)break;j[1]==="/"&&(j=o());if(!j)break}i[b]=c}d=[a],n=new s(a);for(e=0,g=c.length;e0?c[0]:null}function v(a,b,c){var d=t(a,b);return d&&d.length>0?d[0].text:c}var f=a("./sprintf").sprintf,g=a("./utils"),h=a("./errors").SyntaxError,i={},j=new RegExp("('[^']*'|\"[^\"]*\"|::|//?|\\.\\.|\\(\\)|[/.*:\\[\\]\\(\\)@=])|((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|\\s+","g"),k=g.findall.bind(null,j),r={"":l,"*":m,".":n,"..":p,"//":o,"[":q};c.find=u,c.findall=t,c.findtext=v}),require.define("/node_modules/elementtree/lib/errors.js",function(a,b,c,d,e){function h(a,b){b=b||g("Syntax Error at token %s",a.toString()),this.token=a,this.message=b,Error.call(this,b)}var f=a("util"),g=a("./sprintf").sprintf;f.inherits(h,Error),c.SyntaxError=h}),require.define("util",function(a,b,c,d,e){function g(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&g(a.__proto__)}function h(a){return a instanceof RegExp||typeof a=="object"&&Object.prototype.toString.call(a)==="[object RegExp]"}function i(a){if(a instanceof Date)return!0;if(typeof a!="object")return!1;var b=Date.prototype&&n(Date.prototype),c=a.__proto__&&n(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}function j(a){return a<10?"0"+a.toString(10):a.toString(10)}function l(){var a=new Date,b=[j(a.getHours()),j(a.getMinutes()),j(a.getSeconds())].join(":");return[a.getDate(),k[a.getMonth()],b].join(" ")}var f=a("events");c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,d,e){function k(a,d){if(a&&typeof a.inspect=="function"&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(d);switch(typeof a){case"undefined":return j("undefined","undefined");case"string":var e="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return j(e,"string");case"number":return j(""+a,"number");case"boolean":return j(""+a,"boolean")}if(a===null)return j("null","null");var l=m(a),o=b?n(a):l;if(typeof a=="function"&&o.length===0){if(h(a))return j(""+a,"regexp");var p=a.name?": "+a.name:"";return j("[Function"+p+"]","special")}if(i(a)&&o.length===0)return j(a.toUTCString(),"date");var q,r,s;g(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]);if(typeof a=="function"){var t=a.name?": "+a.name:"";q=h(a)?" "+a:" [Function"+t+"]"}else q="";i(a)&&(q=" "+a.toUTCString());if(o.length===0)return s[0]+q+s[1];if(d<0)return h(a)?j(""+a,"regexp"):j("[Object]","special");f.push(a);var u=o.map(function(b){var c,e;a.__lookupGetter__&&(a.__lookupGetter__(b)?a.__lookupSetter__(b)?e=j("[Getter/Setter]","special"):e=j("[Getter]","special"):a.__lookupSetter__(b)&&(e=j("[Setter]","special"))),l.indexOf(b)<0&&(c="["+b+"]"),e||(f.indexOf(a[b])<0?(d===null?e=k(a[b]):e=k(a[b],d-1),e.indexOf("\n")>-1&&(g(a)?e=e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):e="\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=j("[Circular]","special"));if(typeof c=="undefined"){if(r==="Array"&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=j(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=j(c,"string"))}return c+": "+e});f.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return w>50?u=s[0]+(q===""?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:u=s[0]+q+" "+u.join(", ")+" "+s[1],u}var f=[],j=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return e||(j=function(a,b){return a}),k(a,typeof d=="undefined"?2:d)};var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(a){},c.pump=null;var m=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},n=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},o=Object.create||function(a,b){var c;if(a===null)c={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return typeof b!="undefined"&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=o(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}}),require.define("events",function(a,b,c,d,e){process.EventEmitter||(process.EventEmitter=function(){});var f=c.EventEmitter=process.EventEmitter,g=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.toString.call(a)==="[object Array]"},h=10;f.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},f.prototype.emit=function(a){if(a==="error")if(!this._events||!this._events.error||g(this._events.error)&&!this._events.error.length)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if(typeof b=="function"){switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0}if(g(b)){var c=Array.prototype.slice.call(arguments,1),d=b.slice();for(var e=0,f=d.length;e0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var d=c.indexOf(b);if(d<0)return this;c.splice(d,1),c.length==0&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),require.define("/node_modules/elementtree/lib/treebuilder.js",function(a,b,c,d,e){function f(b){this._data=[],this._elem=[],this._last=null,this._tail=null,b||(b=a("./elementtree").Element),this._factory=b}f.prototype.close=function(){return this._last},f.prototype._flush=function(){if(this._data){if(this._last!==null){var a=this._data.join("");this._tail?this._last.tail=a:this._last.text=a}this._data=[]}},f.prototype.data=function(a){this._data.push(a)},f.prototype.start=function(a,b){this._flush();var c=this._factory(a,b);this._last=c,this._elem.length&&this._elem[this._elem.length-1].append(c),this._elem.push(c),this._tail=null},f.prototype.end=function(a){this._flush(),this._last=this._elem.pop();if(this._last.tag!==a)throw new Error("end tag mismatch");return this._tail=1,this._last},c.TreeBuilder=f}),require.define("/node_modules/elementtree/lib/parser.js",function(a,b,c,d,e){function h(a){if(a==="sax")return g.sax;throw new Error("Invalid parser: "+a)}var f=a("util"),g=a("./parsers/index");c.get_parser=h}),require.define("/node_modules/elementtree/lib/parsers/index.js",function(a,b,c,d,e){c.sax=a("./sax")}),require.define("/node_modules/elementtree/lib/parsers/sax.js",function(a,b,c,d,e){function i(a){this.parser=g.parser(!0),this.target=a?a:new h,this.parser.onopentag=this._handleOpenTag.bind(this),this.parser.ontext=this._handleText.bind(this),this.parser.oncdata=this._handleCdata.bind(this),this.parser.ondoctype=this._handleDoctype.bind(this),this.parser.oncomment=this._handleComment.bind(this),this.parser.onclosetag=this._handleCloseTag.bind(this),this.parser.onerror=this._handleError.bind(this)}var f=a("util"),g=a("sax"),h=a("./../treebuilder").TreeBuilder;i.prototype._handleOpenTag=function(a){this.target.start(a.name,a.attributes)},i.prototype._handleText=function(a){this.target.data(a)},i.prototype._handleCdata=function(a){this.target.data(a)},i.prototype._handleDoctype=function(a){},i.prototype._handleComment=function(a){},i.prototype._handleCloseTag=function(a){this.target.end(a)},i.prototype._handleError=function(a){throw a},i.prototype.feed=function(a){this.parser.write(a)},i.prototype.close=function(){return this.parser.close(),this.target.close()},c.XMLParser=i}),require.define("/node_modules/sax/package.json",function(a,b,c,d,e){b.exports={main:"lib/sax.js"}}),require.define("/node_modules/sax/lib/sax.js",function(a,b,c,d,e){(function(b){function d(a,c){if(!(this instanceof d))return new d(a,c);var e=this;f(e),e.q=e.c="",e.bufferCheckPosition=b.MAX_BUFFER_LENGTH,e.opt=c||{},e.tagCase=e.opt.lowercasetags?"toLowerCase":"toUpperCase",e.tags=[],e.closed=e.closedRoot=e.sawRoot=!1,e.tag=e.error=null,e.strict=!!a,e.noscript=!!a||!!e.opt.noscript,e.state=B.BEGIN,e.ENTITIES=Object.create(b.ENTITIES),e.attribList=[],e.opt.xmlns&&(e.ns=Object.create(x)),e.position=e.line=e.column=0,C(e,"onready")}function e(a){var d=Math.max(b.MAX_BUFFER_LENGTH,10),e=0;for(var f=0,g=c.length;fd)switch(c[f]){case"textNode":E(a);break;case"cdata":D(a,"oncdata",a.cdata),a.cdata="";break;case"script":D(a,"onscript",a.script),a.script="";break;default:G(a,"Max buffer length exceeded: "+c[f])}e=Math.max(e,h)}a.bufferCheckPosition=b.MAX_BUFFER_LENGTH-e+a.position}function f(a){for(var b=0,d=c.length;b",a.state=B.TEXT;return}a.tagName=c;var f=a.tags.length;while(f-->b){var g=a.tag=a.tags.pop();a.tagName=a.tag.name,D(a,"onclosetag",a.tagName);var h={};for(var i in g.ns)h[i]=g.ns[i];var j=a.tags[a.tags.length-1]||a;a.opt.xmlns&&g.ns!==j.ns&&Object.keys(g.ns).forEach(function(b){var c=g.ns[b];D(a,"onclosenamespace",{prefix:b,uri:c})})}b===0&&(a.closedRoot=!0),a.tagName=a.attribValue=a.attribName="",a.attribList.length=0,a.state=B.TEXT}function O(a){var b=a.entity.toLowerCase(),c,d="";return a.ENTITIES[b]?a.ENTITIES[b]:(b.charAt(0)==="#"&&(b.charAt(1)==="x"?(b=b.slice(2),c=parseInt(b,16),d=c.toString(16)):(b=b.slice(1),c=parseInt(b,10),d=c.toString(10))),b=b.replace(/^0+/,""),d.toLowerCase()!==b?(I(a,"Invalid character entity"),"&"+a.entity+";"):String.fromCharCode(c))}function P(a){var b=this;if(this.error)throw this.error;if(b.closed)return G(b,"Cannot write after close. Assign an onready handler.");if(a===null)return H(b);var c=0,d="";while(b.c=d=a.charAt(c++)){b.position++,d==="\n"?(b.line++,b.column=0):b.column++;switch(b.state){case B.BEGIN:d==="<"?b.state=B.OPEN_WAKA:A(l,d)&&(I(b,"Non-whitespace before first tag."),b.textNode=d,b.state=B.TEXT);continue;case B.TEXT:if(b.sawRoot&&!b.closedRoot){var f=c-1;while(d&&d!=="<"&&d!=="&")d=a.charAt(c++),d&&(b.position++,d==="\n"?(b.line++,b.column=0):b.column++);b.textNode+=a.substring(f,c-1)}d==="<"?b.state=B.OPEN_WAKA:(A(l,d)&&(!b.sawRoot||b.closedRoot)&&I("Text data outside of root node."),d==="&"?b.state=B.TEXT_ENTITY:b.textNode+=d);continue;case B.SCRIPT:d==="<"?b.state=B.SCRIPT_ENDING:b.script+=d;continue;case B.SCRIPT_ENDING:d==="/"?(D(b,"onscript",b.script),b.state=B.CLOSE_TAG,b.script="",b.tagName=""):(b.script+="<"+d,b.state=B.SCRIPT);continue;case B.OPEN_WAKA:d==="!"?(b.state=B.SGML_DECL,b.sgmlDecl=""):z(l,d)||(z(o,d)?(b.startTagPosition=b.position-1,b.state=B.OPEN_TAG,b.tagName=d):d==="/"?(b.startTagPosition=b.position-1,b.state=B.CLOSE_TAG,b.tagName=""):d==="?"?(b.state=B.PROC_INST,b.procInstName=b.procInstBody=""):(I(b,"Unencoded <"),b.textNode+="<"+d,b.state=B.TEXT));continue;case B.SGML_DECL:(b.sgmlDecl+d).toUpperCase()===t?(D(b,"onopencdata"),b.state=B.CDATA,b.sgmlDecl="",b.cdata=""):b.sgmlDecl+d==="--"?(b.state=B.COMMENT,b.comment="",b.sgmlDecl=""):(b.sgmlDecl+d).toUpperCase()===u?(b.state=B.DOCTYPE,(b.doctype||b.sawRoot)&&I(b,"Inappropriately located doctype declaration"),b.doctype="",b.sgmlDecl=""):d===">"?(D(b,"onsgmldeclaration",b.sgmlDecl),b.sgmlDecl="",b.state=B.TEXT):z(q,d)?(b.state=B.SGML_DECL_QUOTED,b.sgmlDecl+=d):b.sgmlDecl+=d;continue;case B.SGML_DECL_QUOTED:d===b.q&&(b.state=B.SGML_DECL,b.q=""),b.sgmlDecl+=d;continue;case B.DOCTYPE:d===">"?(b.state=B.TEXT,D(b,"ondoctype",b.doctype),b.doctype=!0):(b.doctype+=d,d==="["?b.state=B.DOCTYPE_DTD:z(q,d)&&(b.state=B.DOCTYPE_QUOTED,b.q=d));continue;case B.DOCTYPE_QUOTED:b.doctype+=d,d===b.q&&(b.q="",b.state=B.DOCTYPE);continue;case B.DOCTYPE_DTD:b.doctype+=d,d==="]"?b.state=B.DOCTYPE:z(q,d)&&(b.state=B.DOCTYPE_DTD_QUOTED,b.q=d);continue;case B.DOCTYPE_DTD_QUOTED:b.doctype+=d,d===b.q&&(b.state=B.DOCTYPE_DTD,b.q="");continue;case B.COMMENT:d==="-"?b.state=B.COMMENT_ENDING:b.comment+=d;continue;case B.COMMENT_ENDING:d==="-"?(b.state=B.COMMENT_ENDED,b.comment=F(b.opt,b.comment),b.comment&&D(b,"oncomment",b.comment),b.comment=""):(b.comment+="-"+d,b.state=B.COMMENT);continue;case B.COMMENT_ENDED:d!==">"?(I(b,"Malformed comment"),b.comment+="--"+d,b.state=B.COMMENT):b.state=B.TEXT;continue;case B.CDATA:d==="]"?b.state=B.CDATA_ENDING:b.cdata+=d;continue;case B.CDATA_ENDING:d==="]"?b.state=B.CDATA_ENDING_2:(b.cdata+="]"+d,b.state=B.CDATA);continue;case B.CDATA_ENDING_2:d===">"?(b.cdata&&D(b,"oncdata",b.cdata),D(b,"onclosecdata"),b.cdata="",b.state=B.TEXT):d==="]"?b.cdata+="]":(b.cdata+="]]"+d,b.state=B.CDATA);continue;case B.PROC_INST:d==="?"?b.state=B.PROC_INST_ENDING:z(l,d)?b.state=B.PROC_INST_BODY:b.procInstName+=d;continue;case B.PROC_INST_BODY:if(!b.procInstBody&&z(l,d))continue;d==="?"?b.state=B.PROC_INST_ENDING:z(q,d)?(b.state=B.PROC_INST_QUOTED,b.q=d,b.procInstBody+=d):b.procInstBody+=d;continue;case B.PROC_INST_ENDING:d===">"?(D(b,"onprocessinginstruction",{name:b.procInstName,body:b.procInstBody}),b.procInstName=b.procInstBody="",b.state=B.TEXT):(b.procInstBody+="?"+d,b.state=B.PROC_INST_BODY);continue;case B.PROC_INST_QUOTED:b.procInstBody+=d,d===b.q&&(b.state=B.PROC_INST_BODY,b.q="");continue;case B.OPEN_TAG:z(p,d)?b.tagName+=d:(J(b),d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:(A(l,d)&&I(b,"Invalid character in tag name"),b.state=B.ATTRIB));continue;case B.OPEN_TAG_SLASH:d===">"?(M(b,!0),N(b)):(I(b,"Forward-slash in opening tag not followed by >"),b.state=B.ATTRIB);continue;case B.ATTRIB:if(z(l,d))continue;d===">"?M(b):d==="/"?b.state=B.OPEN_TAG_SLASH:z(o,d)?(b.attribName=d,b.attribValue="",b.state=B.ATTRIB_NAME):I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME:d==="="?b.state=B.ATTRIB_VALUE:z(l,d)?b.state=B.ATTRIB_NAME_SAW_WHITE:z(p,d)?b.attribName+=d:I(b,"Invalid attribute name");continue;case B.ATTRIB_NAME_SAW_WHITE:if(d==="=")b.state=B.ATTRIB_VALUE;else{if(z(l,d))continue;I(b,"Attribute without value"),b.tag.attributes[b.attribName]="",b.attribValue="",D(b,"onattribute",{name:b.attribName,value:""}),b.attribName="",d===">"?M(b):z(o,d)?(b.attribName=d,b.state=B.ATTRIB_NAME):(I(b,"Invalid attribute name"),b.state=B.ATTRIB)}continue;case B.ATTRIB_VALUE:if(z(l,d))continue;z(q,d)?(b.q=d,b.state=B.ATTRIB_VALUE_QUOTED):(I(b,"Unquoted attribute value"),b.state=B.ATTRIB_VALUE_UNQUOTED,b.attribValue=d);continue;case B.ATTRIB_VALUE_QUOTED:if(d!==b.q){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_Q:b.attribValue+=d;continue}L(b),b.q="",b.state=B.ATTRIB;continue;case B.ATTRIB_VALUE_UNQUOTED:if(A(s,d)){d==="&"?b.state=B.ATTRIB_VALUE_ENTITY_U:b.attribValue+=d;continue}L(b),d===">"?M(b):b.state=B.ATTRIB;continue;case B.CLOSE_TAG:if(!b.tagName){if(z(l,d))continue;A(o,d)?I(b,"Invalid tagname in closing tag."):b.tagName=d}else d===">"?N(b):z(p,d)?b.tagName+=d:(A(l,d)&&I(b,"Invalid tagname in closing tag"),b.state=B.CLOSE_TAG_SAW_WHITE);continue;case B.CLOSE_TAG_SAW_WHITE:if(z(l,d))continue;d===">"?N(b):I("Invalid characters in closing tag");continue;case B.TEXT_ENTITY:case B.ATTRIB_VALUE_ENTITY_Q:case B.ATTRIB_VALUE_ENTITY_U:switch(b.state){case B.TEXT_ENTITY:var g=B.TEXT,h="textNode";break;case B.ATTRIB_VALUE_ENTITY_Q:var g=B.ATTRIB_VALUE_QUOTED,h="attribValue";break;case B.ATTRIB_VALUE_ENTITY_U:var g=B.ATTRIB_VALUE_UNQUOTED,h="attribValue"}d===";"?(b[h]+=O(b),b.entity="",b.state=g):z(r,d)?b.entity+=d:(I("Invalid character entity"),b[h]+="&"+b.entity+d,b.entity="",b.state=g);continue;default:throw new Error(b,"Unknown state: "+b.state)}}return b.position>=b.bufferCheckPosition&&e(b),b}b.parser=function(a,b){return new d(a,b)},b.SAXParser=d,b.SAXStream=k,b.createStream=j,b.MAX_BUFFER_LENGTH=65536;var c=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];b.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(a){function b(){this.__proto__=a}return b.prototype=a,new b}),Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.__proto__}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),d.prototype={end:function(){H(this)},write:P,resume:function(){return this.error=null,this},close:function(){return this.write(null)},end:function(){return this.write(null)}};try{var g=a("stream").Stream}catch(h){var g=function(){}}var i=b.EVENTS.filter(function(a){return a!=="error"&&a!=="end"});k.prototype=Object.create(g.prototype,{constructor:{value:k}}),k.prototype.write=function(a){return this._parser.write(a.toString()),this.emit("data",a),!0},k.prototype.end=function(a){return a&&a.length&&this._parser.write(a.toString()),this._parser.end(),!0},k.prototype.on=function(a,b){var c=this;return!c._parser["on"+a]&&i.indexOf(a)!==-1&&(c._parser["on"+a]=function(){var b=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);b.splice(0,0,a),c.emit.apply(c,b)}),g.prototype.on.call(c,a,b)};var l="\r\n\t ",m="0124356789",n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",o=n+"_:",p=o+m+"-.",q="'\"",r=m+n+"#",s=l+">",t="[CDATA[",u="DOCTYPE",v="http://www.w3.org/XML/1998/namespace",w="http://www.w3.org/2000/xmlns/",x={xml:v,xmlns:w};l=y(l),m=y(m),n=y(n),o=y(o),p=y(p),q=y(q),r=y(r),s=y(s);var B=0;b.STATE={BEGIN:B++,TEXT:B++,TEXT_ENTITY:B++,OPEN_WAKA:B++,SGML_DECL:B++,SGML_DECL_QUOTED:B++,DOCTYPE:B++,DOCTYPE_QUOTED:B++,DOCTYPE_DTD:B++,DOCTYPE_DTD_QUOTED:B++,COMMENT_STARTING:B++,COMMENT:B++,COMMENT_ENDING:B++,COMMENT_ENDED:B++,CDATA:B++,CDATA_ENDING:B++,CDATA_ENDING_2:B++,PROC_INST:B++,PROC_INST_BODY:B++,PROC_INST_QUOTED:B++,PROC_INST_ENDING:B++,OPEN_TAG:B++,OPEN_TAG_SLASH:B++,ATTRIB:B++,ATTRIB_NAME:B++,ATTRIB_NAME_SAW_WHITE:B++,ATTRIB_VALUE:B++,ATTRIB_VALUE_QUOTED:B++,ATTRIB_VALUE_UNQUOTED:B++,ATTRIB_VALUE_ENTITY_Q:B++,ATTRIB_VALUE_ENTITY_U:B++,CLOSE_TAG:B++,CLOSE_TAG_SAW_WHITE:B++,SCRIPT:B++,SCRIPT_ENDING:B++},b.ENTITIES={apos:"'",quot:'"',amp:"&",gt:">",lt:"<"};for(var B in b.STATE)b.STATE[b.STATE[B]]=B;B=b.STATE})(typeof c=="undefined"?sax={}:c)}),require.define("stream",function(a,b,c,d,e){function h(){f.EventEmitter.call(this)}var f=a("events"),g=a("util");g.inherits(h,f.EventEmitter),b.exports=h,h.Stream=h,h.prototype.pipe=function(a,b){function d(b){a.writable&&!1===a.write(b)&&c.pause&&c.pause()}function e(){c.readable&&c.resume&&c.resume()}function g(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.end()}function h(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.destroy()}function i(a){j();if(this.listeners("error").length===0)throw a}function j(){c.removeListener("data",d),a.removeListener("drain",e),c.removeListener("end",g),c.removeListener("close",h),c.removeListener("error",i),a.removeListener("error",i),c.removeListener("end",j),c.removeListener("close",j),a.removeListener("end",j),a.removeListener("close",j)}var c=this;c.on("data",d),a.on("drain",e),!a._isStdio&&(!b||b.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,c.on("end",g),c.on("close",h));var f=!1;return c.on("error",i),a.on("error",i),c.on("end",j),c.on("close",j),a.on("end",j),a.on("close",j),a.emit("pipe",c),a}}),require.define("/node_modules/elementtree/lib/constants.js",function(a,b,c,d,e){var f="sax";c.DEFAULT_PARSER=f}),require.define("/lib/modularinputs/inputdefinition.js",function(a,b,c,d,e){(function(){function e(){this.metadata={},this.inputs={}}var c=a("elementtree"),d=a("./utils");e.parse=function(a){var b=new e,f=c.parse(a).getroot().getchildren();for(var g=0;g=10?b=parseFloat(a.toString().substring(0,14)).toFixed(3):a.toString().length<=13||a.toString().indexOf(".")<10?b=parseFloat(a).toFixed(3):b=(parseFloat(a.toString().substring(0,14))/1e3).toFixed(3)):a.toString().length===13?b=(parseFloat(a)/1e3).toFixed(3):a.toString().length<=12?b=parseFloat(a).toFixed(3):b=parseFloat(a.toString().substring(0,13)/1e3).toFixed(3),b)},e.prototype._writeTo=function(a){if(!this.data)throw new Error("Events must have at least the data field set to be written to XML.");var b=c.Element("event");this.stanza&&b.set("stanza",this.stanza),b.set("unbroken",(+this.unbroken).toString()),!d.isUndefined(this.time)&&this.time!==null&&(c.SubElement(b,"time").text=e.formatTime(this.time).toString()),typeof this.data=="object"&&(this.data=JSON.stringify(this.data));var f=[{tag:"source",text:this.source},{tag:"sourcetype",text:this.sourcetype},{tag:"index",text:this.index},{tag:"host",text:this.host},{tag:"data",text:this.data}];for(var g=0;g"),this._headerWritten=!0);try{a._writeTo(this._out)}catch(b){throw b.message==="Events must have at least the data field set to be written to XML."?(e.warn("",b.message,this._err),b):(e.error("",b.message,this._err),b)}},h.prototype.writeXMLDocument=function(a){var b=c.tostring(a,{xml_declaration:!1});this._out.write(b)},h.prototype.close=function(){this._out.write("")},b.exports=h})()}),require.define("/lib/modularinputs/logger.js",function(a,b,c,d,e){(function(){"use strict";var d=a("./utils"),e=c||this;e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL",e._log=function(a,b,c,d){d=d||process.stderr,b&&b.length>0&&(b+=" ");var e=a+" Modular input "+b+c+"\n";d.write(e)},e.debug=function(a,b,c){try{e._log(e.DEBUG,a,b,c)}catch(d){throw d}},e.info=function(a,b,c){try{e._log(e.INFO,a,b,c)}catch(d){throw d}},e.warn=function(a,b,c){try{e._log(e.WARN,a,b,c)}catch(d){throw d}},e.error=function(a,b,c){try{e._log(e.ERROR,a,b,c)}catch(d){throw d}},e.fatal=function(a,b,c){try{e._log(e.FATAL,a,b,c)}catch(d){throw d}},b.exports=e})()}),require.define("/lib/modularinputs/argument.js",function(a,b,c,d,e){(function(){function e(a){a||(a={}),this.name=d.isUndefined(a.name)?"":a.name,this.description=d.isUndefined(a.description)?null:a.description,this.validation=d.isUndefined(a.validation)?null:a.validation,this.dataType=d.isUndefined(a.dataType)?e.dataTypeString:a.dataType,this.requiredOnEdit=d.isUndefined(a.requiredOnEdit)?!1:a.requiredOnEdit,this.requiredOnCreate=d.isUndefined(a.requiredOnCreate)?!1:a.requiredOnCreate}var c=a("elementtree"),d=a("./utils");e.dataTypeBoolean="BOOLEAN",e.dataTypeNumber="NUMBER",e.dataTypeString="STRING",e.prototype.addToDocument=function(a){var b=c.SubElement(a,"arg");b.set("name",this.name),this.description&&(c.SubElement(b,"description").text=this.description),this.validation&&(c.SubElement(b,"validation").text=this.validation);var d=[{tag:"data_type",value:this.dataType},{tag:"required_on_edit",value:this.requiredOnEdit},{tag:"required_on_create",value:this.requiredOnCreate}];for(var e=0;e")){clearTimeout(o);var g=h.parse(c);a._inputDefinition=g,k._inputDefinition=g,f.chain([function(b){f.parallelEach(Object.keys(a._inputDefinition.inputs),function(b,c,e){var g=a._inputDefinition.inputs[b];f.chain([function(c){a.start(b,g,c)},function(c){a.streamEvents(b,g,d,c)},function(c){a.end(b,g,c)}],function(a){e(a,a?1:0)})},function(a){b(a,a?1:0)})}],function(a){d._headerWritten&&d.close(),j(a,a?1:0)})}})}else if(b.length>=2&&b[1].toString().toLowerCase()==="--scheme"){var p=a.getScheme();if(!p)l.fatal("","script returned a null scheme.",d._err),j(null,1);else try{d.writeXMLDocument(p.toXML()),j(null,0)}catch(q){l.fatal("","script could not return the scheme, error: "+q,d._err),j(q,1)}}else if(b.length>=2&&b[1].toString().toLowerCase()==="--validate-arguments"){var r=setTimeout(function(){j(new Error("Receiving validation definition prior to validating timed out."),1)},30500);i.on("data",function(b){n=Buffer.concat([n,b]);var h=n.toString("utf8",0,n.length).trim();e.endsWith(h,"")&&(clearTimeout(r),f.chain([function(b){try{if(e.isUndefined(a.validateInput))b();else{var c=g.parse(n.toString("utf8",0,n.length));a.validateInput(c,b)}}catch(d){b(d)}}],function(a){if(a){l.error("",a.message),l.error("","Stack trace for a modular input error: "+a.stack);try{var b=c.Element("error");c.SubElement(b,"message").text=a.message,d.writeXMLDocument(b),j(a,1)}catch(e){j(e,1)}}else j(null,0)}))})}else{var s="Invalid arguments to modular input script: "+b.join()+"\n";l.error("",s,d._err),j(s,1)}},m.service=function(){if(this._service)return this._service;if(!this._inputDefinition)return null;var a=this._inputDefinition.metadata.server_uri,b=this._inputDefinition.metadata.session_key,c=d.parse(a),e=c.protocol.replace(":",""),f=c.hostname,g=c.port;return this._service=new k({scheme:e,host:f,port:g,token:b}),this._service},m.prototype.setup=function(a){a()},m.prototype.start=function(a,b,c){c()},m.prototype.end=function(a,b,c){c()},m.prototype.teardown=function(a){a()},b.exports=m})()}),require.define("url",function(a,b,c,d,e){function v(a,b,c){if(a&&typeof a=="object"&&a.href)return a;if(typeof a!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d={},e=a;for(var h=0,j=e.length;hn)d.hostname="";else{var G=d.hostname.split(/\./);for(var h=0,j=G.length;h127?I+="x":I+=H[J];if(!I.match(o)){var L=G.slice(0,h),M=G.slice(h+1),N=H.match(p);N&&(L.push(N[1]),M.unshift(N[2])),M.length&&(e="/"+M.join(".")+e),d.hostname=L.join(".");break}}}}d.hostname=d.hostname.toLowerCase();var O=d.hostname.split("."),P=[];for(var h=0;h0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}a.search=b.search,a.query=b.query;if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.href=w(a),a}if(!h.length)return delete a.pathname,a.search?delete a.path:a.path="/"+a.search,a.href=w(a),a;var k=h.slice(-1)[0],l=(a.host||b.host)&&(k==="."||k==="..")||k==="",m=0;for(var n=h.length;n>=0;n--)k=h[n],k=="."?h.splice(n,1):k===".."?(h.splice(n,1),m++):m&&(h.splice(n,1),m--);if(!f&&!g)for(;m--;m)h.unshift("..");f&&h[0]!==""&&(!h[0]||h[0].charAt(0)!=="/")&&h.unshift(""),l&&h.join("/").substr(-1)!=="/"&&h.push("");var o=h[0]===""||h[0]&&h[0].charAt(0)==="/";if(i){a.hostname=a.host=o?"":h.length?h.shift():"";var j=a.host&&a.host.indexOf("@")>0?a.host.split("@"):!1;j&&(a.auth=j.shift(),a.host=a.hostname=j.shift())}f=f||a.host&&h.length,f&&!o&&h.unshift(""),a.pathname=h.join("/");if(a.pathname!==undefined||a.search!==undefined)a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"");return a.auth=b.auth||a.auth,a.slashes=a.slashes||b.slashes,a.href=w(a),a}function z(a){var b={},c=h.exec(a);return c&&(c=c[0],b.port=c.substr(1),a=a.substr(0,a.length-c.length)),a&&(b.hostname=a),b}var f={encode:function(a){return a}};c.parse=v,c.resolve=x,c.resolveObject=y,c.format=w;var g=/^([a-z0-9.+-]+:)/i,h=/:[0-9]+$/,i=["<",">",'"',"`"," ","\r","\n","\t"],j=["{","}","|","\\","^","~","[","]","`"].concat(i),k=["'"],l=["%","/","?",";","#"].concat(j).concat(k),m=["/","@","?","#"].concat(i),n=255,o=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,p=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,q={javascript:!0,"javascript:":!0},r={javascript:!0,"javascript:":!0},s={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},t={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},u=a("querystring")}),require.define("querystring",function(a,b,c,d,e){function j(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function k(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d","Username to login with",undefined,!0).option("--password ","Username to login with",undefined,!1).option("--scheme ","Scheme to use","https",!1).option("--host ","Hostname to use","localhost",!1).option("--port ","Port to use",8089,!1).option("--version ","Which version to use","4",!1),a.parse=function(c){c=(c||[]).slice(2);var d=j();for(var e in d)if(d.hasOwnProperty(e)&&c.indexOf("--"+e)<0){var f=d[e];c.unshift(f),c.unshift("--"+e.trim())}c.unshift(""),c.unshift("");var g=b.call(a,c);return g},a.add=function(b,c,d,e,f,h){var i={};e=e||[];var j=a.command(b+(d?" "+d:"")).description(c||"");for(var k=0;k=0,m="<"+e[k]+">";j.option("--"+e[k]+" "+m,"",undefined,l)}j.action(function(){var a=g.toArray(arguments);a.unshift(b),h.apply(null,a)})},a}})()}),require.define("/tests/test_service.js",function(a,b,c,d,e){c.setup=function(b,c){var d=a("../index"),f=d.Utils,g=d.Async,h=a("./utils"),i=a("path");d.Logger.setLevel("ALL");var j=0,k=function(){return"id"+j++ +"_"+(new Date).valueOf()},l={"Namespace Tests":{setUp:function(a){this.service=b;var c=this,d="jssdk_testapp_"+k(),e="jssdk_testapp_"+k(),f="jssdk_testuser_"+k(),h="jssdk_testuser_"+k(),i=this.service.apps(),j=this.service.users();this.namespace11={owner:f,app:d},this.namespace12={owner:f,app:e},this.namespace21={owner:h,app:d},this.namespace22={owner:h,app:e},g.chain([function(a){i.create({name:d},a)},function(a,b){c.app1=a,c.appName1=d,i.create({name:e},b)},function(a,b){c.app2=a,c.appName2=e,j.create({name:f,password:"abc",roles:["user"]},b)},function(a,b){c.user1=a,c.userName1=f,j.create({name:h,password:"abc",roles:["user"]},b)},function(a,b){c.user2=a,c.userName2=h,b()}],function(b){a()})},"Callback#Namespace protection":function(a){var b="jssdk_search_"+k(),c="search *",d=this.service,e=d.savedSearches(this.namespace11),f=d.savedSearches(this.namespace21),h=this;g.chain([function(a){e.create({name:b,search:c},a)},function(a,b){e.fetch(b)},function(a,b){f.fetch(b)},function(d,g){var h=e.item(b),i=f.item(b);a.ok(h),a.strictEqual(h.name,b),a.strictEqual(h.properties().search,c),a.ok(!i),g()}],function(b){a.ok(!b),a.done()})},"Callback#Namespace item":function(a){var b="jssdk_search_"+k(),c="search *",d=this.service,e={owner:"-",app:this.appName1},f={owner:"nobody",app:this.appName1},h=d.savedSearches(this.namespace11),i=d.savedSearches(this.namespace21),j=d.savedSearches(e),l=d.savedSearches(f),m=this;g.chain([function(a){h.create({name:b,search:c},a)},function(a,d){i.create({name:b,search:c},d)},function(a,b){j.fetch(b)},function(a,b){h.fetch(b)},function(a,b){i.fetch(b)},function(d,e){var f=h.item(b,m.namespace11),g=i.item(b,m.namespace21);a.ok(f),a.strictEqual(f.name,b),a.strictEqual(f.properties().search,c),a.strictEqual(f.namespace.owner,m.namespace11.owner),a.strictEqual(f.namespace.app,m.namespace11.app),a.ok(g),a.strictEqual(g.name,b),a.strictEqual(g.properties().search,c),a.strictEqual(g.namespace.owner,m.namespace21.owner),a.strictEqual(g.namespace.app,m.namespace21.app),e()},function(a){l.create({name:b,search:c},a)},function(a,b){h.fetch(b)},function(a,b){i.fetch(b)},function(d,e){try{j.item(b),a.ok(!1)}catch(f){a.ok(f)}try{j.item(b,{owner:"-"}),a.ok(!1)}catch(f){a.ok(f)}try{j.item(b,{app:"-"}),a.ok(!1)}catch(f){a.ok(f)}try{j.item(b,{app:"-",owner:"-"}),a.ok(!1)}catch(f){a.ok(f)}var g=j.item(b,m.namespace11),h=j.item(b,m.namespace21);a.ok(g),a.strictEqual(g.name,b),a.strictEqual(g.properties().search,c),a.strictEqual(g.namespace.owner,m.namespace11.owner),a.strictEqual(g.namespace.app,m.namespace11.app),a.ok(h),a.strictEqual(h.name,b),a.strictEqual(h.properties().search,c),a.strictEqual(h.namespace.owner,m.namespace21.owner),a.strictEqual(h.namespace.app,m.namespace21.app),e()}],function(b){a.ok(!b),a.done()})},"Callback#delete test applications":function(a){var b=this.service.apps();b.fetch(function(b,c){a.ok(!b),a.ok(c);var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})},"Callback#delete test users":function(a){var b=this.service.users();b.fetch(function(b,c){var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})}},"Job Tests":{setUp:function(a){this.service=b,a()},"Callback#Create+abort job":function(a){var b=this.service;g.chain([function(a){var c=i.join(process.env.SPLUNK_HOME,"/etc/apps/sdk-app-collection/build/sleep_command.tar");c=c.replace("%20"," "),b.post("apps/appinstall",{update:1,name:c},a)},function(c){var d=k(),e={id:d},f=b.jobs({app:"sdk-app-collection"}),h=f.oneshotSearch("search index=_internal | head 1 | sleep 10",e,function(b,c){a.ok(b),a.ok(!c),a.strictEqual(b.error,"abort"),a.done()});g.sleep(1e3,function(){h.abort()})}],function(b){a.ok(!b),a.done()})},"Callback#Create+cancel job":function(a){var b=k();this.service.jobs().search("search index=_internal | head 1",{id:b},function(c,d){a.ok(d),a.strictEqual(d.sid,b),d.cancel(function(){a.done()})})},"Callback#Create job error":function(a){var b=k();this.service.jobs().search({search:"index=_internal | head 1",id:b},function(b){a.ok(!!b),a.done()})},"Callback#List jobs":function(a){this.service.jobs().fetch(function(b,c){a.ok(!b),a.ok(c);var d=c.list();a.ok(d.length>0);for(var e=0;ec),a.ok(e<=c*2),b.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Set priority":function(a){var b=k(),c=0,d=this,e=this.service.specialize("nobody","sdk-app-collection");g.chain([function(a){e.jobs().search("search index=_internal | head 1 | sleep 5",{id:b},a)},function(a,b){a.track({},{ready:function(a){b(null,a)}})},function(b,c){var d=b.properties().priority;a.ok(d,5),b.setPriority(d+1,c)},function(a,b){a.fetch(b)},function(a,b){a.cancel(b)}],function(b){a.ok(!b),a.done()})},"Callback#Search log":function(a){var b=k(),c=this;g.chain([function(a){c.service.jobs().search("search index=_internal | head 1",{id:b,exec_mode:"blocking"},a)},function(a,b){a.searchlog(b)},function(b,c,d){a.ok(c),a.ok(b),a.ok(b.length>0),a.ok(b.split("\r\n").length>0),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Search summary":function(a){var b=k(),c=this;g.chain([function(a){c.service.jobs().search('search index=_internal | head 1 | eval foo="bar" | fields foo',{id:b,status_buckets:300,rf:["foo"]},a)},function(a,b){g.sleep(2e3,function(){a.summary({},b)})},function(b,c,d){a.ok(c),a.ok(b),a.strictEqual(b.event_count,1),a.strictEqual(b.fields.foo.count,1),a.strictEqual(b.fields.foo.distinct_count,1),a.ok(b.fields.foo.is_exact,1),a.strictEqual(b.fields.foo.modes.length,1),a.strictEqual(b.fields.foo.modes[0].count,1),a.strictEqual(b.fields.foo.modes[0].value,"bar"),a.ok(b.fields.foo.modes[0].is_exact),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Search timeline":function(a){var b=k(),c=this;g.chain([function(a){c.service.jobs().search('search index=_internal | head 1 | eval foo="bar" | fields foo',{id:b,status_buckets:300,rf:["foo"],exec_mode:"blocking"},a)},function(a,b){a.timeline({},b)},function(b,c,d){a.ok(c),a.ok(b),a.strictEqual(b.buckets.length,1),a.strictEqual(b.event_count,1),a.strictEqual(b.buckets[0].available_count,1),a.strictEqual(b.buckets[0].duration,.001),a.strictEqual(b.buckets[0].earliest_time_offset,b.buckets[0].latest_time_offset),a.strictEqual(b.buckets[0].total_count,1),a.ok(b.buckets[0].is_finalized),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Touch":function(a){var b=k(),c=this,d="";g.chain([function(a){c.service.jobs().search("search index=_internal | head 1",{id:b},a)},function(a,b){a.fetch(b)},function(b,c){a.ok(b),d=b.properties().updated,g.sleep(1200,function(){b.touch(c)})},function(a,b){a.fetch(b)},function(b,c){a.ok(d!==b.updated()),b.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#Create failure":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",d=this.service.jobs();a.throws(function(){d.create({search:c,name:b,exec_mode:"oneshot"},function(){})}),a.done()},"Callback#Create fails with no search string":function(a){var b=this.service.jobs();b.create("",{},function(b){a.ok(b),a.done()})},"Callback#Oneshot search":function(a){var b=k(),c=this,d="";g.chain([function(a){c.service.jobs().oneshotSearch("search index=_internal | head 1 | stats count",{id:b},a)},function(b,c){a.ok(b),a.ok(b.fields),a.strictEqual(b.fields.length,1),a.strictEqual(b.fields[0],"count"),a.ok(b.rows),a.strictEqual(b.rows.length,1),a.strictEqual(b.rows[0].length,1),a.strictEqual(b.rows[0][0],"1"),c()}],function(b){a.ok(!b),a.done()})},"Callback#Oneshot search with no results":function(a){var b=k(),c=this,d="";g.chain([function(a){var d="search index=history MUST_NOT_EXISTABCDEF";c.service.jobs().oneshotSearch(d,{id:b},a)},function(b,c){a.ok(b),a.strictEqual(b.fields.length,0),a.strictEqual(b.rows.length,0),a.ok(!b.preview),c()}],function(b){a.ok(!b),a.done()})},"Callback#Service oneshot search":function(a){var b=k(),c=this,d={owner:"admin",app:"search"},e=6.1,f="DEBUG";g.chain([function(b){g.chain([function(a){c.service.serverInfo(a)},function(a,c){e=parseFloat(a.properties().version),e<6.2?b():c()},function(a){c.service.configurations({owner:"admin",app:"search"}).fetch(a)},function(a,b){try{a.item("limits").fetch(b)}catch(c){b(c)}},function(a,b){var c=a.item("search_info");f=c.properties().infocsv_log_level,c.update({infocsv_log_level:"DEBUG"},b)},function(b,c){a.strictEqual("DEBUG",b.properties().infocsv_log_level),c()}],function(c){a.ok(!c),b()})},function(a){c.service.oneshotSearch("search index=_internal | head 1 | stats count",{id:b},d,a)},function(b,c){a.ok(b),a.ok(b.fields),a.strictEqual(b.fields.length,1),a.strictEqual(b.fields[0],"count"),a.ok(b.rows),a.strictEqual(b.rows.length,1),a.strictEqual(b.rows[0].length,1),a.strictEqual(b.rows[0][0],"1"),a.ok(b.messages[1].text.indexOf('owner="admin"')),a.ok(b.messages[1].text.indexOf('app="search"')),c()},function(b){g.chain([function(a){e<6.2?b():a()},function(a){c.service.configurations({owner:"admin",app:"search"}).fetch(a)},function(a,b){try{a.item("limits").fetch(b)}catch(c){b(c)}},function(a,b){var c=a.item("search_info");c.update({infocsv_log_level:f},b)},function(b,c){a.strictEqual(f,b.properties().infocsv_log_level),c()}],function(c){a.ok(!c),b()})}],function(b){a.ok(!b),a.done()})},"Callback#Service search":function(a){var b=k(),c=this.service,d=this,e={owner:"admin",app:"search"};g.chain([function(a){d.service.search("search index=_internal | head 1 | stats count",{id:b},e,a)},function(c,d){a.strictEqual(c.sid,b),a.strictEqual(c.namespace,e),h.pollUntil(c,function(a){return c.properties().isDone},10,d)},function(a,b){a.results({},b)},function(b,c,d){a.strictEqual(b.rows.length,1),a.strictEqual(b.fields.length,1),a.strictEqual(b.fields[0],"count"),a.strictEqual(b.rows[0][0],"1"),c.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Wait until job done":function(a){this.service.search("search index=_internal | head 1000",{},function(b,c){a.ok(!b);var d=0,e=0;c.track({period:200},{ready:function(b){a.ok(b),d++},progress:function(b){a.ok(b),e++},done:function(b){a.ok(b),a.ok(d===1),a.ok(e>=1),a.done()},failed:function(b){a.ok(b),a.ok(!1,"Job failed unexpectedly."),a.done()},error:function(b){a.ok(b),a.ok(!1,"Error while tracking job."),a.done()}})})},"Callback#Wait until job failed":function(a){this.service.search("search index=_internal | head bogusarg",{},function(b,c){if(b){a.ok(!b),a.done();return}var d=0,e=0;c.track({period:200},{ready:function(b){a.ok(b),d++},progress:function(b){a.ok(b),e++},done:function(b){a.ok(b),a.ok(!1,"Job became done unexpectedly."),a.done()},failed:function(b){a.ok(b),a.ok(d===1),a.ok(e>=1),a.done()},error:function(b){a.ok(b),a.ok(!1,"Error while tracking job."),a.done()}})})},"Callback#track() with default params and one function":function(a){this.service.search("search index=_internal | head 1",{},function(b,c){if(b){a.ok(!b),a.done();return}c.track({},function(b){a.ok(b),a.done()})})},"Callback#track() should stop polling if only the ready callback is specified":function(a){this.service.search("search index=_internal | head 1",{},function(b,c){if(b){a.ok(!b),a.done();return}c.track({},{ready:function(b){a.ok(b)},_stoppedAfterReady:function(b){a.done()}})})},"Callback#track() a job that is not immediately ready":function(a){var b=20,c=b,e=!1;for(var f=0;f.*) To: (?.*) ",i.expression);var j=d.pbe9bd0rp4;a.ok(j),a.strictEqual("event1",j.owner),a.same(["event1"],j.lineage),a.strictEqual("GeoIP",j.type),a.ok(j.isGeoIP()),a.ok(!j.isLookup()),a.ok(!j.isEval()),a.ok(!j.isRex()),a.strictEqual("·Ä©·öô‡Øµ comment of pbe9bd0rp4",j.comment),a.strictEqual(5,j.outputFieldNames().length),a.strictEqual("output_from_reverse_hostname",j.inputField),c()}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - run queries":function(a){if(this.skip){a.done();return}var b,c=this;g.chain([function(a){c.dataModels.fetch(a)},function(a,c){var d=a.item("internal_audit_logs");b=d.objectByName("searches"),b.startSearch({},"",c)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,c){a.strictEqual("| datamodel internal_audit_logs searches search",b.properties().request.search),b.cancel(c)},function(a,c){b.startSearch({status_buckets:5,enable_lookups:!1},"| head 3",c)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,c){a.strictEqual("| datamodel internal_audit_logs searches search | head 3",b.properties().request.search),b.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - baseSearch is parsed correctly":function(a){if(this.skip){a.done();return}var b;try{b=JSON.parse(f.readFile(e,"../data/model_with_multiple_types.json"))}catch(c){a.ok(!c),a.done()}var h="delete-me-"+k(),i,j=this;g.chain([function(a){j.dataModels.create(h,b,a)},function(b,c){i=b.objectByName("search1"),a.ok(i),a.ok(i instanceof d.Service.DataModelObject),a.strictEqual("BaseSearch",i.parentName),a.ok(i.isBaseSearch()),a.ok(!i.isBaseTransaction()),a.strictEqual("search index=_internal | head 10",i.baseSearch),c()}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - baseTransaction is parsed correctly":function(a){if(this.skip){a.done();return}var b;try{b=JSON.parse(f.readFile(e,"../data/model_with_multiple_types.json"))}catch(c){a.ok(!c),a.done()}var h="delete-me-"+k(),i,j=this;g.chain([function(a){j.dataModels.create(h,b,a)},function(b,c){i=b.objectByName("transaction1"),a.ok(i),a.ok(i instanceof d.Service.DataModelObject),a.strictEqual("BaseTransaction",i.parentName),a.ok(i.isBaseTransaction()),a.ok(!i.isBaseSearch()),a.same(["event1"],i.objectsToGroup),a.same(["host","from"],i.groupByFields),a.strictEqual("25s",i.maxPause),a.strictEqual("100m",i.maxSpan),c()}],function(b){a.ok(!b),a.done()})}},"Pivot tests":{setUp:function(a){this.service=b,this.dataModels=b.dataModels({owner:"nobody",app:"search"}),this.skip=!1;var c=this;this.service.serverInfo(function(b,e){parseInt(e.properties().version.split(".")[0],10)<6&&(c.skip=!0,d.Logger.log("Skipping pivot tests...")),a(b)})},"Callback#Pivot - test constructor args":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){a.ok(b.objectByName("test_data")),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test acceleration, then pivot":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){b.objectByName("test_data"),a.ok(b),b.acceleration.enabled=!0,b.acceleration.earliestTime="-2mon",b.acceleration.cronSchedule="0 */12 * * *",b.update(c)},function(b,c){var d=b.properties();a.strictEqual(!0,b.isAccelerated()),a.strictEqual(!0,!!b.acceleration.enabled),a.strictEqual("-2mon",b.acceleration.earliest_time),a.strictEqual("0 */12 * * *",b.acceleration.cron_schedule);var e=b.objectByName("test_data"),f=e.createPivotSpecification();a.strictEqual(e.dataModel.name,f.accelerationNamespace);var g="delete-me-"+k();f.setAccelerationJob(g),a.strictEqual("sid="+g,f.accelerationNamespace);var h="delete-me-"+k();f.accelerationNamespace=h,a.strictEqual(h,f.accelerationNamespace),f.addCellValue("test_data","Source Value","count").run(c)},function(b,c,d){a.ok(b),a.ok(c),a.notStrictEqual("FAILED",b.properties().dispatchState),b.track({},function(b){a.ok(c.tstatsSearch),a.strictEqual(0,b.properties().request.search.indexOf("| tstats")),a.strictEqual("| tstats",b.properties().request.search.match("^\\| tstats")[0]),a.strictEqual(1,b.properties().request.search.match("^\\| tstats").length),a.strictEqual(c.tstatsSearch,b.properties().request.search),d(null,b)})},function(b,c){a.ok(b),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test illegal filtering (all types)":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter(k(),"boolean","=",!0),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addFilter("_time","boolean","=",!0),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add boolean filter on _time because it is of type timestamp")}try{e.addFilter("has_boris","string","contains","abc"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add string filter on has_boris because it is of type boolean")}try{e.addFilter(k(),"string","contains","abc"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addFilter("has_boris","ipv4","startsWith","192.168"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add ipv4 filter on has_boris because it is of type boolean")}try{e.addFilter(k(),"ipv4","startsWith","192.168"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addFilter("has_boris","number","atLeast",2.3),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add number filter on has_boris because it is of type boolean")}try{e.addFilter(k(),"number","atLeast",2.3),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add filter on a nonexistent field.")}try{e.addLimitFilter("has_boris","host","DEFAULT",50,"count"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add limit filter on has_boris because it is of type boolean")}try{e.addLimitFilter(k(),"host","DEFAULT",50,"count"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot add limit filter on a nonexistent field.")}try{e.addLimitFilter("source","host","DEFAULT",50,"sum"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function for fields of type string must be COUNT or DISTINCT_COUNT; found sum")}try{e.addLimitFilter("epsilon","host","DEFAULT",50,"duration"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function for fields of type number must be one of COUNT, DISTINCT_COUNT, SUM, or AVERAGE; found duration")}try{e.addLimitFilter("test_data","host","DEFAULT",50,"list"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function for fields of type object count must be COUNT; found list")}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test boolean filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("has_boris","boolean","=",!0),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("has_boris",f.fieldName),a.strictEqual("boolean",f.type),a.strictEqual("=",f.rule.comparator),a.strictEqual(!0,f.rule.compareTo),a.strictEqual("test_data",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test string filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("host","string","contains","abc"),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("host",f.fieldName),a.strictEqual("string",f.type),a.strictEqual("contains",f.rule.comparator),a.strictEqual("abc",f.rule.compareTo),a.strictEqual("BaseEvent",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test IPv4 filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("hostip","ipv4","startsWith","192.168"),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("hostip",f.fieldName),a.strictEqual("ipv4",f.type),a.strictEqual("startsWith",f.rule.comparator),a.strictEqual("192.168",f.rule.compareTo),a.strictEqual("test_data",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test number filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addFilter("epsilon","number",">=",2.3),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("rule")),a.ok(f.hasOwnProperty("owner")),a.strictEqual("epsilon",f.fieldName),a.strictEqual("number",f.type),a.strictEqual(">=",f.rule.comparator),a.strictEqual(2.3,f.rule.compareTo),a.strictEqual("test_data",f.owner)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test limit filtering":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addLimitFilter("epsilon","host","ASCENDING",500,"average"),a.strictEqual(1,e.filters.length);var f=e.filters[0];a.ok(f.hasOwnProperty("fieldName")),a.ok(f.hasOwnProperty("type")),a.ok(f.hasOwnProperty("owner")),a.ok(f.hasOwnProperty("attributeName")),a.ok(f.hasOwnProperty("attributeOwner")),a.ok(f.hasOwnProperty("limitType")),a.ok(f.hasOwnProperty("limitAmount")),a.ok(f.hasOwnProperty("statsFn")),a.strictEqual("epsilon",f.fieldName),a.strictEqual("number",f.type),a.strictEqual("test_data",f.owner),a.strictEqual("host",f.attributeName),a.strictEqual("BaseEvent",f.attributeOwner),a.strictEqual("lowest",f.limitType),a.strictEqual(500,f.limitAmount),a.strictEqual("average",f.statsFn)}catch(g){a.ok(!1)}c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test row split":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addRowSplit("has_boris","Wrong type here"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number or string.")}var g=k();try{e.addRowSplit(g,"Break Me!"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addRowSplit("epsilon","My Label"),a.strictEqual(1,e.rows.length);var h=e.rows[0];a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("display")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("My Label",h.label),a.strictEqual("all",h.display),a.same({fieldName:"epsilon",owner:"test_data",type:"number",label:"My Label",display:"all"},h),e.addRowSplit("host","My Label"),a.strictEqual(2,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(!h.hasOwnProperty("display")),a.strictEqual("host",h.fieldName),a.strictEqual("BaseEvent",h.owner),a.strictEqual("string",h.type),a.strictEqual("My Label",h.label),a.same({fieldName:"host",owner:"BaseEvent",type:"string",label:"My Label"},h);try{e.addRangeRowSplit("has_boris","Wrong type here",{start:0,end:100,step:20,limit:5})}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number.")}try{e.addRangeRowSplit(g,"Break Me!",{start:0,end:100,step:20,limit:5}),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addRangeRowSplit("epsilon","My Label",{start:0,end:100,step:20,limit:5}),a.strictEqual(3,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("display")),a.ok(h.hasOwnProperty("ranges")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("My Label",h.label),a.strictEqual("ranges",h.display);var i={start:0,end:100,size:20,maxNumberOf:5};a.same(i,h.ranges),a.same({fieldName:"epsilon",owner:"test_data",type:"number",label:"My Label",display:"ranges",ranges:i},h);try{e.addBooleanRowSplit("epsilon","Wrong type here","t","f")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected boolean.")}try{e.addBooleanRowSplit(g,"Break Me!","t","f"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addBooleanRowSplit("has_boris","My Label","is_true","is_false"),a.strictEqual(4,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("trueLabel")),a.ok(h.hasOwnProperty("falseLabel")),a.strictEqual("has_boris",h.fieldName),a.strictEqual("My Label",h.label),a.strictEqual("test_data",h.owner),a.strictEqual("boolean",h.type),a.strictEqual("is_true",h.trueLabel),a.strictEqual("is_false",h.falseLabel),a.same({fieldName:"has_boris",label:"My Label",owner:"test_data",type:"boolean",trueLabel:"is_true",falseLabel:"is_false"},h);try{e.addTimestampRowSplit("epsilon","Wrong type here","some binning")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected timestamp.")}try{e.addTimestampRowSplit(g,"Break Me!","some binning"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}try{e.addTimestampRowSplit("_time","some label","Bogus binning value"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Invalid binning Bogus binning value found. Valid values are: "+e._binning.join(", "))}e.addTimestampRowSplit("_time","My Label","day"),a.strictEqual(5,e.rows.length),h=e.rows[e.rows.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("period")),a.strictEqual("_time",h.fieldName),a.strictEqual("My Label",h.label),a.strictEqual("BaseEvent",h.owner),a.strictEqual("timestamp",h.type),a.strictEqual("day",h.period),a.same({fieldName:"_time",label:"My Label",owner:"BaseEvent",type:"timestamp",period:"day"},h),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test column split":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addColumnSplit("has_boris","Wrong type here"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number or string.")}var g=k();try{e.addColumnSplit(g,"Break Me!"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addColumnSplit("epsilon"),a.strictEqual(1,e.columns.length);var h=e.columns[e.columns.length-1];a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("display")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("all",h.display),a.same({fieldName:"epsilon",owner:"test_data",type:"number",display:"all"},h),e.addColumnSplit("host"),a.strictEqual(2,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(!h.hasOwnProperty("display")),a.strictEqual("host",h.fieldName),a.strictEqual("BaseEvent",h.owner),a.strictEqual("string",h.type),a.same({fieldName:"host",owner:"BaseEvent",type:"string"},h),c();try{e.addRangeColumnSplit("has_boris","Wrong type here",{start:0,end:100,step:20,limit:5})}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("has_boris").type+", expected number.")}try{e.addRangeColumnSplit(g,{start:0,end:100,step:20,limit:5}),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addRangeColumnSplit("epsilon",{start:0,end:100,step:20,limit:5}),a.strictEqual(3,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(h.hasOwnProperty("display")),a.ok(h.hasOwnProperty("ranges")),a.strictEqual("epsilon",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("number",h.type),a.strictEqual("ranges",h.display);var i={start:"0",end:"100",size:"20",maxNumberOf:"5"};a.same(i,h.ranges),a.same({fieldName:"epsilon",owner:"test_data",type:"number",display:"ranges",ranges:i},h);try{e.addBooleanColumnSplit("epsilon","t","f")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected boolean.")}try{e.addBooleanColumnSplit(g,"t","f"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}e.addBooleanColumnSplit("has_boris","is_true","is_false"),a.strictEqual(4,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(!h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("trueLabel")),a.ok(h.hasOwnProperty("falseLabel")),a.strictEqual("has_boris",h.fieldName),a.strictEqual("test_data",h.owner),a.strictEqual("boolean",h.type),a.strictEqual("is_true",h.trueLabel),a.strictEqual("is_false",h.falseLabel),a.same({fieldName:"has_boris",owner:"test_data",type:"boolean",trueLabel:"is_true",falseLabel:"is_false"},h);try{e.addTimestampColumnSplit("epsilon","Wrong type here")}catch(f){a.ok(f),a.strictEqual(f.message,"Field was of type "+d.fieldByName("epsilon").type+", expected timestamp.")}try{e.addTimestampColumnSplit(g,"Break Me!"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field "+g)}try{e.addTimestampColumnSplit("_time","Bogus binning value"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Invalid binning Bogus binning value found. Valid values are: "+e._binning.join(", "))}e.addTimestampColumnSplit("_time","day"),a.strictEqual(5,e.columns.length),h=e.columns[e.columns.length-1],a.ok(h.hasOwnProperty("fieldName")),a.ok(h.hasOwnProperty("owner")),a.ok(h.hasOwnProperty("type")),a.ok(!h.hasOwnProperty("label")),a.ok(h.hasOwnProperty("period")),a.strictEqual("_time",h.fieldName),a.strictEqual("BaseEvent",h.owner),a.strictEqual("timestamp",h.type),a.strictEqual("day",h.period),a.same({fieldName:"_time",owner:"BaseEvent",type:"timestamp",period:"day"},h)}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test cell value":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d);var e=d.createPivotSpecification();try{e.addCellValue("iDontExist","Break Me!","explosion"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Did not find field iDontExist")}try{e.addCellValue("source","Wrong Stats Function","stdev"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found stdev")}e.addCellValue("source","Source Value","dc"),a.strictEqual(1,e.cells.length);var g=e.cells[e.cells.length-1];a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("source",g.fieldName),a.strictEqual("BaseEvent",g.owner),a.strictEqual("string",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("dc",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"source",owner:"BaseEvent",type:"string",label:"Source Value",value:"dc",sparkline:!1},g);try{e.addCellValue("hostip","Wrong Stats Function","stdev"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on string and IPv4 fields must be one of: list, distinct_values, first, last, count, or distinct_count; found stdev")}e.addCellValue("hostip","Source Value","dc"),a.strictEqual(2,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("hostip",g.fieldName),a.strictEqual("test_data",g.owner),a.strictEqual("ipv4",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("dc",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"hostip",owner:"test_data",type:"ipv4",label:"Source Value",value:"dc",sparkline:!1},g);try{e.addCellValue("has_boris","Booleans not allowed","sum"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Cannot use boolean valued fields as cell values.")}try{e.addCellValue("epsilon","Wrong Stats Function","latest"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on number field must be must be one of: sum, count, average, max, min, stdev, list, or distinct_values; found latest")}e.addCellValue("epsilon","Source Value","average"),a.strictEqual(3,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("epsilon",g.fieldName),a.strictEqual("test_data",g.owner),a.strictEqual("number",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("average",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"epsilon",owner:"test_data",type:"number",label:"Source Value",value:"average",sparkline:!1},g);try{e.addCellValue("_time","Wrong Stats Function","max"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on timestamp field must be one of: duration, earliest, latest, list, or distinct values; found max")}e.addCellValue("_time","Source Value","earliest"),a.strictEqual(4,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("_time",g.fieldName),a.strictEqual("BaseEvent",g.owner),a.strictEqual("timestamp",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("earliest",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"_time",owner:"BaseEvent",type:"timestamp",label:"Source Value",value:"earliest",sparkline:!1},g);try{e.addCellValue("test_data","Wrong Stats Function","min"),a.ok(!1)}catch(f){a.ok(f),a.strictEqual(f.message,"Stats function on childcount and objectcount fields must be count; found min")}e.addCellValue("test_data","Source Value","count"),a.strictEqual(5,e.cells.length),g=e.cells[e.cells.length-1],a.ok(g.hasOwnProperty("fieldName")),a.ok(g.hasOwnProperty("owner")),a.ok(g.hasOwnProperty("type")),a.ok(g.hasOwnProperty("label")),a.ok(g.hasOwnProperty("value")),a.ok(g.hasOwnProperty("sparkline")),a.strictEqual("test_data",g.fieldName),a.strictEqual("test_data",g.owner),a.strictEqual("objectCount",g.type),a.strictEqual("Source Value",g.label),a.strictEqual("count",g.value),a.strictEqual(!1,g.sparkline),a.same({fieldName:"test_data",owner:"test_data",type:"objectCount",label:"Source Value",value:"count",sparkline:!1},g),c()}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test pivot throws HTTP exception":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var h=this;g.chain([function(a){h.dataModels.create(b,c,a)},function(b,c){var d=b.objectByName("test_data");a.ok(d),d.createPivotSpecification().pivot(c)},function(b,c){a.ok(!1)}],function(b){a.ok(b);var c="In handler 'datamodelpivot': Error in 'PivotReport': Must have non-empty cells or non-empty rows.";a.ok(f.endsWith(b.message,c)),a.done()})},"Callback#Pivot - test pivot with simple namespace":function(a){if(this.skip){a.done();return}var b="delete-me-"+k(),c;try{c=JSON.parse(f.readFile(e,"../data/data_model_for_pivot.json"))}catch(d){a.ok(!d),a.done()}var i=this,j,l,m;g.chain([function(a){i.dataModels.create(b,c,a)},function(b,c){j=b.objectByName("test_data"),a.ok(j),j.createLocalAccelerationJob(null,c)},function(b,c){m=b,a.ok(b),l=j.createPivotSpecification(),l.addBooleanRowSplit("has_boris","Has Boris","meep","hilda"),l.addCellValue("hostip","Distinct IPs","count"),l.setAccelerationJob(b),a.strictEqual("string",typeof l.accelerationNamespace),a.strictEqual("sid="+b.sid,l.accelerationNamespace),l.setAccelerationJob(b.sid),a.strictEqual("string",typeof l.accelerationNamespace),a.strictEqual("sid="+b.sid,l.accelerationNamespace),l.pivot(c)},function(b,c){a.ok(b.tstatsSearch),a.ok(b.tstatsSearch.length>0),a.strictEqual(0,b.tstatsSearch.indexOf("| tstats")),a.strictEqual("| tstats",b.tstatsSearch.match("^\\| tstats")[0]),a.strictEqual(1,b.tstatsSearch.match("^\\| tstats").length),b.run(c)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,c){a.ok("FAILED"!==b.properties().dispatchState),a.strictEqual(0,b.properties().request.search.indexOf("| tstats")),a.strictEqual("| tstats",b.properties().request.search.match("^\\| tstats")[0]),a.strictEqual(1,b.properties().request.search.match("^\\| tstats").length),m.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test pivot column range split":function(a){if(this.skip){a.done();return}var b=this,c;g.chain([function(a){b.dataModels.fetch(a)},function(a,b){var c=a.item("internal_audit_logs"),d=c.objectByName("searches"),e=d.createPivotSpecification();e.addRowSplit("user","Executing user"),e.addRangeColumnSplit("exec_time",{start:0,end:12,step:5,limit:4}),e.addCellValue("search","Search Query","values"),e.pivot(b)},function(a,b){c=a.tstatsSearch||a.pivotSearch,a.run(b)},function(a,b){h.pollUntil(a,function(b){return a.properties().isDone},10,b)},function(b,d){a.notStrictEqual("FAILED",b.properties().dispatchState),a.strictEqual(c,b.properties().request.search),b.cancel(d)}],function(b){a.ok(!b),a.done()})},"Callback#Pivot - test pivot with PivotSpecification.run and Job.track":function(a){if(this.skip){a.done();return}var b=this;g.chain([function(a){b.dataModels.fetch(a)},function(a,b){var c=a.item("internal_audit_logs"),d=c.objectByName("searches"),e=d.createPivotSpecification();e.addRowSplit("user","Executing user"),e.addRangeColumnSplit("exec_time",{start:0,end:12,step:5,limit:4}),e.addCellValue("search","Search Query","values"),e.run({},b)},function(b,c,d){b.track({},function(b){a.strictEqual(c.tstatsSearch||c.pivotSearch,b.properties().request.search),d(null,b)})},function(b,c){a.notStrictEqual("FAILED",b.properties().dispatchState),b.cancel(c)}],function(b){a.ok(!b),a.done()})},"Callback#DataModels - delete any remaining data models created by the SDK tests":function(a){if(this.skip){a.done();return}b.dataModels().fetch(function(b,c){b&&a.ok(!b);var d=c.list();g.seriesEach(d,function(a,b,c){f.startsWith(a.name,"delete-me")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})}},"App Tests":{setUp:function(a){this.service=b,a()},"Callback#list applications":function(a){var b=this.service.apps();b.fetch(function(b,c){var d=c.list();a.ok(d.length>0),a.done()})},"Callback#contains applications":function(a){var b=this.service.apps();b.fetch(function(b,c){var d=c.item("search");a.ok(d),a.done()})},"Callback#create + contains app":function(a){var b="jssdk_testapp_"+k(),c=this.service.apps();c.create({name:b},function(b,d){var e=d.name;c.fetch(function(b,c){var f=c.item(e);a.ok(f),d.remove(function(){a.done()})})})},"Callback#create + modify app":function(a){var b="TEST DESCRIPTION",c="1.1.0",d="jssdk_testapp_"+k(),e=this.service.apps();g.chain([function(a){e.create({name:d},a)},function(e,f){a.ok(e),a.strictEqual(e.name,d);var g=e.properties().version==="1.0"||e.properties().version=="1.0.0";a.ok(g),e.update({description:b,version:c},f)},function(d,e){a.ok(d);var f=d.properties();a.strictEqual(f.description,b),a.strictEqual(f.version,c),d.remove(e)}],function(b){a.ok(!b),a.done()})},"Callback#delete test applications":function(a){var b=this.service.apps();b.fetch(function(b,c){var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})},"list applications with cookies as authentication":function(a){this.service.serverInfo(function(c,e){var h=parseInt(e.properties().version.split(".")[0],10),i=parseInt(e.properties().version.split(".")[1],10);if(h<6||h===6&&i<2){d.Logger.log("Skipping cookie test..."),a.done();return}var j=new d.Service({scheme:b.scheme,host:b.host,port:b.port,username:b.username,password:b.password,version:b.version}),k=new d.Service({scheme:b.scheme,host:b.host,port:b.port,version:b.version});g.chain([function(a){j.login(a)},function(b,c){var d=j.http._cookieStore;a.ok(!f.isEmpty(d)),k.http._cookieStore=d;var e=k.apps();e.fetch(c)},function(b,c){var d=b.list();a.ok(d.length>0),a.ok(!f.isEmpty(k.http._cookieStore)),c()}],function(b){a.ok(!b),a.done()})})}},"Saved Search Tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Callback#list":function(a){var b=this.service.savedSearches();b.fetch(function(b,c){var d=c.list();a.ok(d.length>0);for(var e=0;e0);for(var e=0;e1),a.ok(f.indexOf(b.fields().optional,"disabled")>-1),b.remove(c)}],function(b){a.ok(!b),a.done()})},"Callback#dispatch error":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",e=new d.Service.SavedSearch(this.loggedOutService,b,{owner:"nobody",app:"search"});e.dispatch(function(b){a.ok(b),a.done()})},"Callback#dispatch omitting optional arguments":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",d=this.service.savedSearches({owner:this.service.username,app:"sdk-app-collection"});g.chain([function(a){d.create({search:c,name:b},a)},function(d,e){a.ok(d),a.strictEqual(d.name,b),a.strictEqual(d.properties().search,c),a.ok(!d.properties().description),d.dispatch(e)},function(b,c,d){a.ok(b),a.ok(c),a.done()}])},"Callback#history error":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",e=new d.Service.SavedSearch(this.loggedOutService,b,{owner:"nobody",app:"search",sharing:"system"});e.history(function(b){a.ok(b),a.done()})},"Callback#Update error":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",e=new d.Service.SavedSearch(this.loggedOutService,b,{owner:"nobody",app:"search",sharing:"system"});e.update({},function(b){a.ok(b),a.done()})},"Callback#oneshot requires search string":function(a){a.throws(function(){this.service.oneshotSearch({name:"jssdk_oneshot_"+k()},function(a){})}),a.done()},"Callback#Create + dispatch + history":function(a){var b="jssdk_savedsearch_"+k(),c="search index=_internal | head 1",d=this.service.savedSearches({owner:this.service.username,app:"sdk-app-collection"});g.chain(function(a){d.create({search:c,name:b},a)},function(d,e){a.ok(d),a.strictEqual(d.name,b),a.strictEqual(d.properties().search,c),a.ok(!d.properties().description),d.dispatch({force_dispatch:!1,"dispatch.buckets":295},e)},function(b,c,d){a.ok(b),a.ok(c),h.pollUntil(b,function(a){return b.properties().isDone},10,g.augment(d,c))},function(b,c,d){a.strictEqual(b.properties().statusBuckets,295),c.history(g.augment(d,b))},function(b,c,d,e){a.ok(b),a.ok(b.length>0),a.ok(c),a.ok(d);var f=function(a){return function(b){a.cancel(b)}},h=!1,i=[];for(var j=0;j0),c()}],function(b){a.ok(!b),a.done()})},"Callback#item":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web"),c()}],function(b){a.ok(!b),a.done()})},"Callback#contains stanza":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web");var d=b.item("settings");a.ok(d),d.fetch(c)},function(b,c){a.ok(b.properties().hasOwnProperty("httpport")),c()}],function(b){a.ok(!b),a.done()})},"Callback#create file + create stanza + update stanza":function(a){var c=this,e="jssdk_file_"+k(),f="barfoo_"+k(),h={owner:"admin",app:"search"};g.chain([function(a){var b=c.service.configurations(h);b.fetch(a)},function(a,b){a.create(e,b)},function(a,b){a.create("stanza",b)},function(a,b){a.update({jssdk_foobar:f},b)},function(b,c){a.strictEqual(b.properties().jssdk_foobar,f),c()},function(a){var c=new d.Service.ConfigurationFile(b,e);c.fetch(a)},function(b,c){var d=b.item("stanza");a.ok(d),d.remove(c)}],function(b){a.ok(!b),a.done()})}},"Configuration Tests":{setUp:function(a){this.service=b,a()},"Callback#list":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.list();a.ok(d.length>0),c()}],function(b){a.ok(!b),a.done()})},"Callback#contains":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web"),c()}],function(b){a.ok(!b),a.done()})},"Callback#contains stanza":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,c){var d=b.item("web");a.ok(d),d.fetch(c)},function(b,c){a.strictEqual(b.name,"web");var d=b.item("settings");a.ok(d),d.fetch(c)},function(b,c){a.ok(b.properties().hasOwnProperty("httpport")),c()}],function(b){a.ok(!b),a.done()})},"Callback#configurations init":function(a){a.throws(function(){var a=new d.Service.Configurations(this.service,{owner:"-",app:"-",sharing:"system"})}),a.done()},"Callback#create file + create stanza + update stanza":function(a){var c=this,e={owner:"nobody",app:"system"},f="jssdk_file_"+k(),h="barfoo_"+k();g.chain([function(a){var c=b.configurations(e);c.fetch(a)},function(a,b){a.create({__conf:f},b)},function(a,b){a.item("stanza")&&a.item("stanza").remove(),a.create("stanza",b)},function(a,b){a.update({jssdk_foobar:h},b)},function(b,c){a.strictEqual(b.properties().jssdk_foobar,h),c()},function(a){var c=new d.Service.ConfigurationFile(b,f);c.fetch(a)},function(b,c){var d=b.item("stanza");a.ok(d),d.remove(c)}],function(b){a.ok(!b),a.done()})},"Callback#can get default stanza":function(a){var b=this,c={owner:"admin",app:"search"};g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,d){var e=b.item("savedsearches");a.strictEqual(c,e.namespace),a.ok(e),e.fetch(d)},function(b,d){a.strictEqual(c,b.namespace),b.getDefaultStanza().fetch(d)},function(b,d){a.strictEqual(b.name,"default"),a.strictEqual(c,b.namespace),d()}],function(b){a.ok(!b),a.done()})},"Callback#updating default stanza is noop":function(a){var b=this,c={owner:"admin",app:"search"},d=null,e="this won't work";g.chain([function(a){b.service.configurations(c).fetch(a)},function(b,d){var e=b.item("savedsearches");a.strictEqual(c,e.namespace),a.ok(e),e.fetch(d)},function(b,d){a.strictEqual(c,b.namespace),b.getDefaultStanza().fetch(d)},function(b,f){a.ok(b._properties.hasOwnProperty("max_concurrent")),a.strictEqual(c,b.namespace),d=b._properties.max_concurrent,b.update({max_concurrent:e},f)},function(b,c){a.ok(b.properties().hasOwnProperty("max_concurrent")),a.strictEqual(b.properties().max_concurrent,d),a.notStrictEqual(b.properties().max_concurrent,e),b.fetch(c)},function(b,c){a.ok(b.properties().hasOwnProperty("max_concurrent")),a.strictEqual(b.properties().max_concurrent,d),a.notStrictEqual(b.properties().max_concurrent,e),c()}],function(b){a.ok(!b),a.done()})}},"Storage Passwords Tests":{setUp:function(a){this.service=b,a()},"Callback#Create":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual(d+":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create with backslashes":function(a){var b=-1,c="\\delete-me-"+k(),d="\\delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual("\\"+d+":\\"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create with slashes":function(a){var b=-1,c="/delete-me-"+k(),d="/delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual(d+":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create without realm":function(a){var b=-1,c="delete-me-"+k(),d=this;g.chain([function(a){d.service.storagePasswords().fetch(a)},function(a,d){b=a.list().length,a.create({name:c,password:"changeme"},d)},function(b,e){a.strictEqual(c,b.properties().username),a.strictEqual(":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual("",b.properties().realm),d.service.storagePasswords().fetch(g.augment(e,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){d.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create should fail without user, or realm":function(a){var b=this;g.chain([function(a){b.service.storagePasswords().fetch(a)},function(a,b){a.create({name:null,password:"changeme"},b)}],function(b){a.ok(b),a.done()})},"Callback#Create should fail without password":function(a){var b=this;g.chain([function(a){b.service.storagePasswords().fetch(a)},function(a,b){a.create({name:"something",password:null},b)}],function(b){a.ok(b),a.done()})},"Callback#Create should fail without user, realm, or password":function(a){var b=this;g.chain([function(a){b.service.storagePasswords().fetch(a)},function(a,b){a.create({name:null,password:null},b)}],function(b){a.ok(b),a.done()})},"Callback#Create with colons":function(a){var b=-1,c=":delete-me-"+k(),d=":delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual("\\"+d+":\\"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create crazy":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c+":end!@#$%^&*()_+{}:|<>?",realm:":start::!@#$%^&*()_+{}:|<>?"+d,password:"changeme"},e)},function(b,f){a.strictEqual(c+":end!@#$%^&*()_+{}:|<>?",b.properties().username),a.strictEqual("\\:start\\:\\:!@#$%^&*()_+{}\\:|<>?"+d+":"+c+"\\:end!@#$%^&*()_+{}\\:|<>?:",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(":start::!@#$%^&*()_+{}:|<>?"+d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Create with unicode chars":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c+":end!@#$%^&*()_+{}:|<>?쎼 and 쎶 and <&> für",realm:":start::!@#$%^&*()_+{}:|<>?"+encodeURIComponent("쎼 and 쎶 and <&> für")+d,password:decodeURIComponent(encodeURIComponent("쎼 and 쎶 and <&> für"))},e)},function(b,f){a.strictEqual(c+":end!@#$%^&*()_+{}:|<>?쎼 and 쎶 and <&> für",b.properties().username),a.strictEqual("\\:start\\:\\:!@#$%^&*()_+{}\\:|<>?"+encodeURIComponent("쎼 and 쎶 and <&> für")+d+":"+c+"\\:end!@#$%^&*()_+{}\\:|<>?쎼 and 쎶 and <&> für:",b.name),a.strictEqual(decodeURIComponent(encodeURIComponent("쎼 and 쎶 and <&> für")),b.properties().clear_password),a.strictEqual(":start::!@#$%^&*()_+{}:|<>?"+encodeURIComponent("쎼 and 쎶 and <&> für")+d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(c,d,e){a.strictEqual(b+1,c.list().length),d.remove(e)},function(a){e.service.storagePasswords().fetch(a)},function(c,d){a.strictEqual(b,c.list().length),d()}],function(b){a.ok(!b),a.done()})},"Callback#Read":function(a){var b=-1,c="delete-me-"+k(),d="delete-me-"+k(),e=this;g.chain([function(a){e.service.storagePasswords().fetch(a)},function(a,e){b=a.list().length,a.create({name:c,realm:d,password:"changeme"},e)},function(b,f){a.strictEqual(c,b.properties().username),a.strictEqual(d+":"+c+":",b.name),a.strictEqual("changeme",b.properties().clear_password),a.strictEqual(d,b.properties().realm),e.service.storagePasswords().fetch(g.augment(f,b))},function(e,f,g){try{a.ok(!!e.item(d+":"+c+":"))}catch(h){a.ok(!1)}var i=e.list(),j=!1;a.strictEqual(b+1,i.length);for(var k=0;k0},function(a){g.sleep(d,function(){b.fetch(a)})},function(b){b?a(b):a(c<=0?"Timed out":null)})}],function(b){a.ok(!b),a.done()})},"Callback#list indexes":function(a){var b=this.service.indexes();b.fetch(function(b,c){var d=c.list();a.ok(d.length>0),a.done()})},"Callback#contains index":function(a){var b=this.service.indexes(),c=this.indexName;b.fetch(function(b,d){var e=d.item(c);a.ok(e),a.done()})},"Callback#modify index":function(a){var b=this.indexName,c=this.service.indexes(),d=!1;g.chain([function(a){c.fetch(a)},function(c,e){var f=c.item(b);a.ok(f),d=f.properties().syncMeta,f.update({syncMeta:!d},e)},function(b,c){a.ok(b);var e=b.properties();a.strictEqual(!d,e.syncMeta),b.update({syncMeta:!e.syncMeta},c)},function(b,c){a.ok(b);var e=b.properties();a.strictEqual(d,e.syncMeta),c()}],function(b){a.ok(!b),a.done()})},"Callback#Enable+disable index":function(a){var b=this.indexName,c=this.service.indexes();g.chain([function(a){c.fetch(a)},function(c,d){var e=c.item(b);a.ok(e),e.disable(d)},function(b,c){a.ok(b),b.fetch(c)},function(b,c){a.ok(b),a.ok(b.properties().disabled),b.enable(c)},function(b,c){a.ok(b),b.fetch(c)},function(b,c){a.ok(b),a.ok(!b.properties().disabled),c()}],function(b){a.ok(!b),a.done()})},"Callback#Service submit event":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.service,e=this.indexName;g.chain(function(a){d.log(b,{sourcetype:c,index:e},a)},function(d,f){a.ok(d),a.strictEqual(d.sourcetype,c),a.strictEqual(d.bytes,b.length),a.strictEqual(d.index,e),f()},function(b){a.ok(!b),a.done()})},"Callback#Service submit event, omitting optional arguments":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.service,e=this.indexName;g.chain(function(a){d.log(b,a)},function(c,d){a.ok(c),a.strictEqual(c.bytes,b.length),d()},function(b){a.ok(!b),a.done()})},"Callback#Service submit events with multi-byte chars":function(a){var b=this.service,c=["Ummelner Straße 6","Ümmelner Straße 6","Iԉtérԉátíòлåɭìƶåtiòл","Intérnâtì߀лàɭíƶɑtïòл","ãϻét dòner turƙëy ѵ߀lù","ptãte ìԉ rëρrèhënԁérit ","ϻ߀lɭit fìɭèt ϻìǥnoԉ ɭäb߀ríѕ"," êӽ cɦùck cüpïᏧåtåt Ꮷèѕëruлt. ","D߀ɭor ѵélít ìrurè, sèᏧ ѕhòr","t riƅѕ c߀ɰ ɭãnԁյàéɢêr drúmst","ícƙ. Minïm ƃàɭl tip ѕհòrt rìƃѕ,"," ïԁ aɭïqúìρ ѕɦànƙ ρ߀rcɦéttɑ. Pìǥ"," hãm ɦòck ìлcídíԁùԉt séԁ cüpïϻ ","ƙèviл láborê. Et taiɭ ѕtriρ"," steák út üllãϻc߀ rump d߀ɭore.","٩(͡๏̯͡๏)۶ ٩(-̮̮̃•̃).","Lɑƅòré ƃrësãòlá d߀лèr ѕâlámí ","cíllûm ìn ѕɯìлe ϻêàtɭ߀àf dûìs ","ρãncettä ƅrìsƙét ԁèsêrûлt áútè"," յòɰɭ. Lɑbòrìѕ ƙìêɭ","básá ԁòlòré fatƃɑck ƅêéf. Pɑѕtr","ämì piɢ ѕհàлƙ ùɭɭamcò ѕaû","ѕäǥë sɦànƙlë."," Cúpím ɭäƃorum drumstïcƙ jerkϒ veli"," pïcåԉɦɑ ƙíéɭƅãsa. Alïqû","iρ írürë cûpíϻ, äɭìɋuâ ǥròûлd ","roúлᏧ toԉgüè ρàrìãtùr ","briѕkèt ԉostruᏧ cûɭpɑ"," ìd còлѕèqûât làƅ߀rìs."],d=0;g.seriesMap(c,function(a,c,e){d++,b.log(a,e)},function(b,e){a.ok(!b),a.strictEqual(d,c.length);for(var f in c){a.notStrictEqual(c[f].length,e[f].bytes);try{a.strictEqual(Buffer.byteLength(c[f]),e[f].bytes)}catch(b){a.strictEqual(decodeURI(encodeURIComponent(c[f])).length,e[f].bytes)}}a.done()})},"Callback#Service submit event, failure":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.loggedOutService,e=this.indexName;g.chain(function(c){a.ok(d),d.log(b,c)},function(b){a.ok(b),a.done()})},"Callback#remove throws an error":function(a){var b=this.service.indexes().item("_internal");a.throws(function(){b.remove()}),a.done()},"Callback#create an index with alternate argument format":function(a){var b=this.service.indexes();b.create({name:"_internal"},function(b,c){a.ok(b.data.messages[0].text.match("name=_internal already exists")),a.done()})},"Callback#Index submit event with omitted optional arguments":function(a){var b="Hello world -- "+k(),c=this.indexName,d=this.service.indexes();g.chain([function(a){d.fetch(a)},function(d,e){var f=d.item(c);a.ok(f),a.strictEqual(f.name,c),f.submitEvent(b,e)},function(d,e,f){a.ok(d),a.strictEqual(d.bytes,b.length),a.strictEqual(d.index,c),f()}],function(b){a.ok(!b),a.done()})},"Callback#Index submit event":function(a){var b="Hello World -- "+k(),c="sdk-tests",d=this.indexName,e=this.service.indexes();g.chain([function(a){e.fetch(a)},function(e,f){var g=e.item(d);a.ok(g),a.strictEqual(g.name,d),g.submitEvent(b,{sourcetype:c},f)},function(e,f,g){a.ok(e),a.strictEqual(e.sourcetype,c),a.strictEqual(e.bytes,b.length),a.strictEqual(e.index,d),g()}],function(b){a.ok(!b),a.done()})}},"User Tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},tearDown:function(a){this.service.logout(a)},"Callback#Current user":function(a){var b=this.service;b.currentUser(function(c,d){a.ok(!c),a.ok(d),a.strictEqual(d.name,b.username),a.done()})},"Callback#Current user fails":function(a){var b=this.loggedOutService;b.currentUser(function(b,c){a.ok(b),a.done()})},"Callback#List users":function(a){var b=this.service;b.users().fetch(function(b,c){var d=c.list();a.ok(!b),a.ok(c),a.ok(d),a.ok(d.length>0),a.done()})},"Callback#create user failure":function(a){this.loggedOutService.users().create({name:"jssdk_testuser",password:"abc",roles:"user"},function(b,c){a.ok(b),a.done()})},"Callback#Create + update + delete user":function(a){var b=this.service,c="jssdk_testuser";g.chain([function(a){b.users().create({name:"jssdk_testuser",password:"abc",roles:"user"},a)},function(b,d){a.ok(b),a.strictEqual(b.name,c),a.strictEqual(b.properties().roles.length,1),a.strictEqual(b.properties().roles[0],"user"),b.update({realname:"JS SDK",roles:["admin","user"]},d)},function(b,c){a.ok(b),a.strictEqual(b.properties().realname,"JS SDK"),a.strictEqual(b.properties().roles.length,2),a.strictEqual(b.properties().roles[0],"admin"),a.strictEqual(b.properties().roles[1],"user"),b.remove(c)}],function(b){a.ok(!b),a.done()})},"Callback#Roles":function(a){var b=this.service,c="jssdk_testuser_"+k();g.chain([function(a){b.users().create({name:c,password:"abc",roles:"user"},a)},function(b,d){a.ok(b),a.strictEqual(b.name,c),a.strictEqual(b.properties().roles.length,1),a.strictEqual(b.properties().roles[0],"user"),b.update({roles:["admin","user"]},d)},function(b,c){a.ok(b),a.strictEqual(b.properties().roles.length,2),a.strictEqual(b.properties().roles[0],"admin"),a.strictEqual(b.properties().roles[1],"user"),b.update({roles:"user"},c)},function(b,c){a.ok(b),a.strictEqual(b.properties().roles.length,1),a.strictEqual(b.properties().roles[0],"user"),b.update({roles:"__unknown__"},c)}],function(b){a.ok(b),a.strictEqual(b.status,400),a.done()})},"Callback#Passwords":function(a){var b=this.service,c=null,e="jssdk_testuser_"+k();g.chain([function(a){b.users().create({name:e,password:"abc",roles:"user"},a)},function(f,h){a.ok(f),a.strictEqual(f.name,e),a.strictEqual(f.properties().roles.length,1),a.strictEqual(f.properties().roles[0],"user"),c=new d.Service(b.http,{username:e,password:"abc",host:b.host,port:b.port,scheme:b.scheme,version:b.version}),c.login(g.augment(h,f))},function(b,c,d){a.ok(b),a.ok(c),c.update({password:"abc2"},d)},function(b,d){c.login(function(c,e){a.ok(c),a.ok(!e),b.update({password:"abc"},d)})},function(b,d){a.ok(b),c.login(d)}],function(b){a.ok(!b),a.done()})},"Callback#delete test users":function(a){var b=this.service.users();b.fetch(function(b,c){var d=c.list();g.parallelEach(d,function(a,b,c){f.startsWith(a.name,"jssdk_")?a.remove(c):c()},function(b){a.ok(!b),a.done()})})}},"Server Info Tests":{setUp:function(a){this.service=b,a()},"Callback#Basic":function(a){var b=this.service;b.serverInfo(function(b,c){a.ok(!b),a.ok(c),a.strictEqual(c.name,"server-info"),a.ok(c.properties().hasOwnProperty("version")),a.ok(c.properties().hasOwnProperty("serverName")),a.ok(c.properties().hasOwnProperty("os_version")),a.done()})}},"View Tests":{setUp:function(a){this.service=b,a()},"Callback#List views":function(a){var b=this.service;b.views({owner:"admin",app:"search"}).fetch(function(b,c){a.ok(!b),a.ok(c);var d=c.list();a.ok(d),a.ok(d.length>0);for(var e=0;e",e="";g.chain([function(a){b.views({owner:"admin",app:"sdk-app-collection"}).create({name:c,"eai:data":d},a)},function(b,f){a.ok(b),a.strictEqual(b.name,c),a.strictEqual(b.properties()["eai:data"],d),b.update({"eai:data":e},f)},function(b,c){a.ok(b),a.strictEqual(b.properties()["eai:data"],e),b.remove(c)}],function(b){a.ok(!b),a.done()})}},"Parser Tests":{setUp:function(a){this.service=b,a()},"Callback#Basic parse":function(a){var b=this.service;b.parse("search index=_internal | head 1",function(b,c){a.ok(!b),a.ok(c),a.ok(c.commands.length>0),a.done()})},"Callback#Parse error":function(a){var b=this.service;b.parse("ABCXYZ",function(b,c){a.ok(b),a.strictEqual(b.status,400),a.done()})}},"Typeahead Tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Callback#Typeahead failure":function(a){var b=this.loggedOutService;b.typeahead("index=",1,function(b,c){a.ok(b),a.done()})},"Callback#Basic typeahead":function(a){var b=this.service;b.typeahead("index=",1,function(b,c){a.ok(!b),a.ok(c),a.strictEqual(c.length,1),a.ok(c[0]),a.done()})},"Typeahead with omitted optional arguments":function(a){var b=this.service;b.typeahead("index=",function(b,c){a.ok(!b),a.ok(c),a.done()})}},"Endpoint Tests":{setUp:function(a){this.service=b,a()},"Throws on null arguments to init":function(a){var b=this.service;a.throws(function(){var a=new d.Service.Endpoint(null,"a/b")}),a.throws(function(){var a=new d.Service.Endpoint(b,null)}),a.done()},"Endpoint delete on a relative path":function(a){var b=this.service,c=new d.Service.Endpoint(b,"/search/jobs/12345");c.del("search/jobs/12345",{},function(){a.done()})},"Methods of Resource to be overridden":function(a){var b=this.service,c=new d.Service.Resource(b,"/search/jobs/12345");a.throws(function(){c.path()}),a.throws(function(){c.fetch()}),a.ok(d.Utils.isEmpty(c.state())),a.done()}},"Entity tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Accessors function properly":function(a){var b=new d.Service.Entity(this.service,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b._load({acl:{owner:"boris",app:"factory",sharing:"app"},links:{link1:35},published:"meep",author:"Hilda"}),a.ok(b.acl().owner==="boris"),a.ok(b.acl().app==="factory"),a.ok(b.acl().sharing==="app"),a.ok(b.links().link1===35),a.strictEqual(b.author(),"Hilda"),a.strictEqual(b.published(),"meep"),a.done()},"Refresh throws error correctly":function(a){var b=new d.Service.Entity(this.loggedOutService,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b.fetch({},function(b){a.ok(b),a.done()})},"Cannot update name of entity":function(a){var b=new d.Service.Entity(this.service,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});a.throws(function(){b.update({name:"asdf"})}),a.done()},"Disable throws error correctly":function(a){var b=new d.Service.Entity(this.loggedOutService,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b.disable(function(b){a.ok(b),a.done()})},"Enable throws error correctly":function(a){var b=new d.Service.Entity(this.loggedOutService,"/search/jobs/12345",{owner:"boris",app:"factory",sharing:"app"});b.enable(function(b){a.ok(b),a.done()})},"Does reload work?":function(a){var b=new d.Service.Index(this.service,"data/indexes/sdk-test",{owner:"admin",app:"search",sharing:"app"}),c="jssdk_testapp_"+k(),e=this.service.apps(),f=this;g.chain(function(a){e.create({name:c},a)},function(b,c){b.reload(function(d){a.ok(!d),c(null,b)})},function(b,c){var e=new d.Service.Application(f.loggedOutService,b.name);e.reload(function(d){a.ok(d),c(null,b)})},function(a,b){a.remove(b)},function(b){a.ok(!b),a.done()})}},"Collection tests":{setUp:function(a){this.service=b,this.loggedOutService=c,a()},"Methods to be overridden throw":function(a){var b=new d.Service.Collection(this.service,"/data/indexes",{owner:"admin",app:"search",sharing:"app"});a.throws(function(){b.instantiateEntity({})}),a.done()},"Accessors work":function(a){var b=new d.Service.Collection(this.service,"/data/indexes",{owner:"admin",app:"search",sharing:"app"});b._load({links:"Hilda",updated:!0}),a.strictEqual(b.links(),"Hilda"),a.ok(b.updated()),a.done()},"Contains throws without a good id":function(a){var b=new d.Service.Collection(this.service,"/data/indexes",{owner:"admin",app:"search",sharing:"app"});a.throws(function(){b.item(null)}),a.done()}}};return l};if(b===a.main){var f=a("../index"),g=a("../examples/node/cmdline"),h=a("../contrib/nodeunit/test_reporter"),i=g.create(),j=i.parse(process.argv);if(!j)throw new Error("Error in parsing command line parameters");if(!process.env.SPLUNK_HOME)throw new Error("$PATH variable SPLUNK_HOME is not set. Please export SPLUNK_HOME to the splunk instance.");var k=new f.Service({scheme:j.opts.scheme,host:j.opts.host,port:j.opts.port,username:j.opts.username,password:j.opts.password,version:j.opts.version}),l=new f.Service({scheme:j.opts.scheme,host:j.opts.host,port:j.opts.port,username:j.opts.username,password:j.opts.password+"wrong",version:j.opts.version}),m=c.setup(k,l);k.login(function(a,b){if(a||!b)throw new Error("Login failed - not running tests",a||"");h.run([{Tests:m}])})}}),require.define("/tests/test_examples.js",function(a,b,c,d,e){c.setup=function(b,c){var d=a("../index"),e=d.Async;d.Logger.setLevel("ALL");var f=0,g=function(){return"id"+f++ +"_"+(new Date).valueOf()},h=["program","script"];return{"Hello World Tests":{Apps:function(b){var d=a("../examples/node/helloworld/apps").main;d(c,b.done)},"Apps#Async":function(b){var d=a("../examples/node/helloworld/apps_async").main;d(c,b.done)},"Pivot#Async":function(b){var d=a("../examples/node/helloworld/pivot_async").main;d(c,b.done)},"Fired Alerts":function(b){var d=a("../examples/node/helloworld/firedalerts").main;d(c,b.done)},"Fired Alerts#Async":function(b){var d=a("../examples/node/helloworld/firedalerts_async").main;d(c,b.done)},"Fired Alerts#Create":function(b){var d=a("../examples/node/helloworld/firedalerts_create").main;d(c,b.done)},"Fired Alerts#Delete":function(b){var d=a("../examples/node/helloworld/firedalerts_delete").main;d(c,b.done)},"Get Job by sid":function(b){var d=a("../examples/node/helloworld/get_job").main;d(c,b.done)},"Endpoint Instantiation":function(b){var d=a("../examples/node/helloworld/endpoint_instantiation").main;d(c,b.done)},"Saved Searches":function(b){var d=a("../examples/node/helloworld/savedsearches").main;d(c,b.done)},"Saved Searches#Async":function(b){var d=a("../examples/node/helloworld/savedsearches_async").main;d(c,b.done)},"Saved Searches#Delete":function(b){var d=a("../examples/node/helloworld/savedsearches_delete").main;d(c,b.done)},"Saved Searches#Create":function(b){var d=a("../examples/node/helloworld/savedsearches_create").main;d(c,b.done)},"Saved Searches#Delete Again":function(b){var d=a("../examples/node/helloworld/savedsearches_delete").main;d(c,b.done)},"Search#normal":function(b){var d=a("../examples/node/helloworld/search_normal").main;d(c,b.done)},"Search#blocking":function(b){var d=a("../examples/node/helloworld/search_blocking").main;d(c,b.done)},"Search#oneshot":function(b){var d=a("../examples/node/helloworld/search_oneshot").main;d(c,b.done)},"Search#realtime":function(b){var d=a("../examples/node/helloworld/search_realtime").main;d(c,b.done)},Logging:function(b){var d=a("../examples/node/helloworld/log").main;d(c,b.done)}},"Jobs Example Tests":{setUp:function(b){var c=this;this.main=a("../examples/node/jobs").main,this.run=function(a,b,d,e){var f=h.slice();a&&f.push(a);if(b)for(var g=0;g ")),console.log("\t Internal name: "+l.name),l.startSearch({},"| head 5",b)},function(a,b){a.track({},function(a){a.results({},b)})},function(a,b,c){console.log("Results:");for(var d=0;dd},function(b){g.sleep(1e3,function(){a.preview({},function(a,c){if(a){b(a);return}if(c&&c.rows){d++,console.log("========== Iteration "+d+" ==========");var e=c.fields.indexOf("sourcetype"),f=c.fields.indexOf("count");for(var g=0;g",k,[],e),c.add("preview","Fetch preview results for the specified search jobs","",k,[],e),c.add("events","Fetch events for the specified search jobs","",j,[],e),c.add("cancel","Cancel the specify search jobs","",[],[],e),c.add("list","List all search jobs or properties for those specified","[sids...]",[],[],e),c.parse(a);if(!c.executedCommand){console.log(c.helpInformation()),b("You must specify a command to run.");return}},b===a.main&&c.main(process.argv)})()}),require.define("/examples/node/search.js",function(a,b,c,d,e){(function(){var d=a("../../index"),e=d.Class,f=d.Utils,g=d.Async,h=a("./cmdline"),i=a("util").print,j=["search","earliest_time","latest_time","now","time_format","exec_mode","search_mode","rt_blocking","rt_queue_size","rt_maxblocksecs","rt_indexfilter","id","status_buckets","max_count","max_time","timeout","auto_finalize_ec","enable_lookups","reload_macros","reduce_freq","spawn_process","required_field_list","rf","auto_cancel","auto_pause"],k=function(a){return new d.Service({scheme:a.scheme,host:a.host,port:a.port,username:a.username,password:a.password,version:a.version})},l=function(a,b,c){var d=b.search,e=b.verbose,f=b.count||0,h=b.mode||"row";delete b.search,delete b.verbose,delete b.count,delete b.mode,g.chain([function(c){a.search(d,b,c)},function(a,b){g.whilst(function(){return!a.properties().isDone},function(b){a.fetch(function(a,d){if(a)c(a);else{var f=d.properties();if(e){var h=f.doneProgress*100+"%",j=f.scanCount,k=f.eventCount,l=f.resultCount,m="-- "+h+" done | "+j+" scanned | "+k+" matched | "+l+" results";i("\r"+m+" ")}g.sleep(1e3,b)}})},function(c){e&&i("\r"),b(c,a)})},function(a,b){a.results({count:f,json_mode:h},b)},function(a,b,c){process.stdout.write(JSON.stringify(a)),b.cancel(c)}],function(a){c(a)})},m=function(a,b,c){var d=b.search;delete b.search,a.oneshotSearch(d,b,function(a,b){a?c(a):(console.log(JSON.stringify(b)),c())})};c.main=function(a,b){d.Logger.setLevel("NONE"),b=b||function(a){a&&console.log(a)};var c=h.create();c.name="search",c.description("Create a search and print the results to stdout"),c.option("--verbose","Output job progress as we wait for completion"),c.option("--count ","How many results to fetch"),c.option("--mode ","Row or column mode [row|column]");var e=j,f=["search"];for(var g=0;g=0,n="<"+e[g]+">";c.option("--"+e[g]+" "+n,"",undefined,i)}c.on("--help",function(){console.log(" Examples:"),console.log(" "),console.log(" Create a regular search:"),console.log(" > node search.js --search 'search index=_internal | head 10'"),console.log(" "),console.log(" Create a oneshot search:"),console.log(" > node search.js --search 'search index=_internal | head 10' --exec_mode oneshot"),console.log(" "),console.log(" Create a regular search and only return 10 results:"),console.log(" > node search.js --search 'search index=_internal | head 20' --count 10"),console.log(" "),console.log(" Create a regular search and output the progress while the search is running"),console.log(" > node search.js --search 'search index=_internal | head 20' --verbose"),console.log(" ")}),c.parse(a);var o=k(c.opts);o.login(function(a,d){if(a||!d){b("Error logging in");return}delete c.username,delete c.password,delete c.scheme,delete c.host,delete c.port,delete c.namespace,delete c.version,c.opts.exec_mode==="oneshot"?m(o,c.opts,b):l(o,c.opts,b)})},b===a.main&&c.main(process.argv)})()}),require.define("/browser.test.entry.js",function(a,b,c,d,e){window.SplunkTest={Utils:a("../../tests/test_utils"),Async:a("../../tests/test_async"),Http:a("../../tests/test_http"),Context:a("../../tests/test_context"),Service:a("../../tests/test_service"),Examples:a("../../tests/test_examples")}}),require("/browser.test.entry.js") })(); \ No newline at end of file diff --git a/tests/test_log.js b/tests/test_log.js index 4dc7fc6bf..8856839d8 100644 --- a/tests/test_log.js +++ b/tests/test_log.js @@ -16,7 +16,7 @@ exports.setup = function() { var unload = function(name) { for (var k in require.cache) { - if (require.cache.hasOwnProperty(k) && k.match(name + "$")) { + if (require.cache[k] && k.match(name + "$")) { delete require.cache[k]; } } diff --git a/tests/test_service.js b/tests/test_service.js index 439b64a00..a3d4f05c2 100644 --- a/tests/test_service.js +++ b/tests/test_service.js @@ -251,29 +251,29 @@ exports.setup = function(svc, loggedOutSvc) { ); }, - "Callback#delete test applications": function(test) { - var apps = this.service.apps(); - apps.fetch(function(err, apps) { - test.ok(!err); - test.ok(apps); - var appList = apps.list(); - - Async.parallelEach( - appList, - function(app, idx, callback) { - if (utils.startsWith(app.name, "jssdk_")) { - app.remove(callback); - } - else { - callback(); - } - }, function(err) { - test.ok(!err); - test.done(); - } - ); - }); - }, + // "Callback#delete test applications": function(test) { + // var apps = this.service.apps(); + // apps.fetch(function(err, apps) { + // test.ok(!err); + // test.ok(apps); + // var appList = apps.list(); + + // Async.parallelEach( + // appList, + // function(app, idx, callback) { + // if (utils.startsWith(app.name, "jssdk_")) { + // app.remove(callback); + // } + // else { + // callback(); + // } + // }, function(err) { + // test.ok(!err); + // test.done(); + // } + // ); + // }); + // }, "Callback#delete test users": function(test) { var users = this.service.users(); @@ -3907,7 +3907,7 @@ exports.setup = function(svc, loggedOutSvc) { "Callback#create + modify app": function(test) { var DESCRIPTION = "TEST DESCRIPTION"; - var VERSION = "1.1"; + var VERSION = "1.1.0"; var name = "jssdk_testapp_" + getNextId(); var apps = this.service.apps(); @@ -3919,7 +3919,9 @@ exports.setup = function(svc, loggedOutSvc) { function(app, callback) { test.ok(app); test.strictEqual(app.name, name); - test.strictEqual(app.properties().version, "1.0"); + var versionMatches = app.properties().version === "1.0" || + app.properties().version == "1.0.0"; + test.ok(versionMatches); app.update({ description: DESCRIPTION, @@ -3941,27 +3943,27 @@ exports.setup = function(svc, loggedOutSvc) { }); }, - "Callback#delete test applications": function(test) { - var apps = this.service.apps(); - apps.fetch(function(err, apps) { - var appList = apps.list(); - - Async.parallelEach( - appList, - function(app, idx, callback) { - if (utils.startsWith(app.name, "jssdk_")) { - app.remove(callback); - } - else { - callback(); - } - }, function(err) { - test.ok(!err); - test.done(); - } - ); - }); - }, + // "Callback#delete test applications": function(test) { + // var apps = this.service.apps(); + // apps.fetch(function(err, apps) { + // var appList = apps.list(); + + // Async.parallelEach( + // appList, + // function(app, idx, callback) { + // if (utils.startsWith(app.name, "jssdk_")) { + // app.remove(callback); + // } + // else { + // callback(); + // } + // }, function(err) { + // test.ok(!err); + // test.done(); + // } + // ); + // }); + // }, "list applications with cookies as authentication": function(test) { this.service.serverInfo(function (err, info) {