From f66a9fa7f132f41b2e40029f0fb535521c3fb716 Mon Sep 17 00:00:00 2001 From: jw255 Date: Sat, 24 Feb 2018 17:13:43 +0000 Subject: restructuring of tests + yarn install script --- coverage/base.css | 212 +++ coverage/index.html | 158 ++ coverage/prettify.css | 1 + coverage/prettify.js | 1 + coverage/project-code/coverage/index.html | 106 ++ coverage/project-code/coverage/prettify.js.html | 68 + coverage/project-code/coverage/sorter.js.html | 539 ++++++ coverage/project-code/index.html | 93 + coverage/project-code/karma.conf.js.html | 101 ++ coverage/project-code/src/FileRouter.ts.html | 1769 ++++++++++++++++++++ coverage/project-code/src/app.ts.html | 197 +++ coverage/project-code/src/db/index.html | 106 ++ .../project-code/src/db/initPostgresDB.ts.html | 110 ++ .../src/db/model/ContributorGroup.ts.html | 227 +++ coverage/project-code/src/db/model/File.ts.html | 206 +++ coverage/project-code/src/db/model/Project.ts.html | 290 ++++ coverage/project-code/src/db/model/User.ts.html | 299 ++++ .../project-code/src/db/model/UserGroup.ts.html | 221 +++ .../src/db/model/UserJoinsProject.ts.html | 146 ++ coverage/project-code/src/db/model/index.html | 158 ++ coverage/project-code/src/db/orm.ts.html | 101 ++ coverage/project-code/src/index.html | 93 + coverage/project-code/src/index.ts.html | 227 +++ coverage/project-code/src/matcher/index.html | 106 ++ coverage/project-code/src/matcher/options.ts.html | 362 ++++ .../src/matcher/options.unit.test.ts.html | 554 ++++++ coverage/project-code/src/matcher/types.ts.html | 302 ++++ .../src/matcher/types.unit.test.ts.html | 599 +++++++ coverage/project-code/src/serverConfig.ts.html | 473 ++++++ coverage/project-code/test/hm.test.ts.html | 113 ++ coverage/project-code/test/index.html | 93 + .../project-code/test/protocol.node.test.ts.html | 746 +++++++++ coverage/sort-arrow-sprite.png | Bin 0 -> 209 bytes coverage/sorter.js | 158 ++ getmeyarn.sh | 30 + package.json | 6 +- src/matcher/options.unit.test.ts | 163 -- src/matcher/types.unit.test.ts | 178 -- test/hm.test.ts | 16 - test/integration/auth.routes.test.ts | 42 + test/integration/index.routes.test.ts | 42 + test/integration/protocol.routes.test.ts | 204 +++ test/mocha.opts | 4 + test/protocol.node.test.ts | 227 --- test/unit/options.unit.test.ts | 163 ++ test/unit/types.unit.test.ts | 178 ++ yarn.lock | 259 ++- 47 files changed, 9730 insertions(+), 717 deletions(-) create mode 100644 coverage/base.css create mode 100644 coverage/index.html create mode 100644 coverage/prettify.css create mode 100644 coverage/prettify.js create mode 100644 coverage/project-code/coverage/index.html create mode 100644 coverage/project-code/coverage/prettify.js.html create mode 100644 coverage/project-code/coverage/sorter.js.html create mode 100644 coverage/project-code/index.html create mode 100644 coverage/project-code/karma.conf.js.html create mode 100644 coverage/project-code/src/FileRouter.ts.html create mode 100644 coverage/project-code/src/app.ts.html create mode 100644 coverage/project-code/src/db/index.html create mode 100644 coverage/project-code/src/db/initPostgresDB.ts.html create mode 100644 coverage/project-code/src/db/model/ContributorGroup.ts.html create mode 100644 coverage/project-code/src/db/model/File.ts.html create mode 100644 coverage/project-code/src/db/model/Project.ts.html create mode 100644 coverage/project-code/src/db/model/User.ts.html create mode 100644 coverage/project-code/src/db/model/UserGroup.ts.html create mode 100644 coverage/project-code/src/db/model/UserJoinsProject.ts.html create mode 100644 coverage/project-code/src/db/model/index.html create mode 100644 coverage/project-code/src/db/orm.ts.html create mode 100644 coverage/project-code/src/index.html create mode 100644 coverage/project-code/src/index.ts.html create mode 100644 coverage/project-code/src/matcher/index.html create mode 100644 coverage/project-code/src/matcher/options.ts.html create mode 100644 coverage/project-code/src/matcher/options.unit.test.ts.html create mode 100644 coverage/project-code/src/matcher/types.ts.html create mode 100644 coverage/project-code/src/matcher/types.unit.test.ts.html create mode 100644 coverage/project-code/src/serverConfig.ts.html create mode 100644 coverage/project-code/test/hm.test.ts.html create mode 100644 coverage/project-code/test/index.html create mode 100644 coverage/project-code/test/protocol.node.test.ts.html create mode 100644 coverage/sort-arrow-sprite.png create mode 100644 coverage/sorter.js create mode 100755 getmeyarn.sh delete mode 100644 src/matcher/options.unit.test.ts delete mode 100644 src/matcher/types.unit.test.ts delete mode 100644 test/hm.test.ts create mode 100644 test/integration/auth.routes.test.ts create mode 100644 test/integration/index.routes.test.ts create mode 100644 test/integration/protocol.routes.test.ts create mode 100644 test/mocha.opts delete mode 100644 test/protocol.node.test.ts create mode 100644 test/unit/options.unit.test.ts create mode 100644 test/unit/types.unit.test.ts diff --git a/coverage/base.css b/coverage/base.css new file mode 100644 index 0000000..417c7ad --- /dev/null +++ b/coverage/base.css @@ -0,0 +1,212 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } + + +.medium .chart { border:1px solid #666; } +.medium .cover-fill { background: #666; } + +.cbranch-no { background: yellow !important; color: #111; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } +.medium { background: #eaeaea; } + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/coverage/index.html b/coverage/index.html new file mode 100644 index 0000000..10b3d1c --- /dev/null +++ b/coverage/index.html @@ -0,0 +1,158 @@ + + + + Code coverage report for All files + + + + + + + +
+
+

+ All files +

+
+
+ 0% + Statements + 0/772 +
+
+ 0% + Branches + 0/310 +
+
+ 0% + Functions + 0/132 +
+
+ 0% + Lines + 0/271 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
project-code
0%0/2100%0/00%0/10%0/2
project-code/coverage
0%0/5790%0/3060%0/460%0/78
project-code/src
0%0/160%0/40%0/20%0/16
project-code/src/db
0%0/3100%0/00%0/20%0/3
project-code/src/matcher
0%0/169100%0/00%0/790%0/169
project-code/test
0%0/3100%0/00%0/20%0/3
+
+
+ + + + + + + diff --git a/coverage/prettify.css b/coverage/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/prettify.js b/coverage/prettify.js new file mode 100644 index 0000000..ef51e03 --- /dev/null +++ b/coverage/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/project-code/coverage/index.html b/coverage/project-code/coverage/index.html new file mode 100644 index 0000000..1586bd5 --- /dev/null +++ b/coverage/project-code/coverage/index.html @@ -0,0 +1,106 @@ + + + + Code coverage report for project-code/coverage + + + + + + + +
+
+

+ All files project-code/coverage +

+
+
+ 0% + Statements + 0/579 +
+
+ 0% + Branches + 0/306 +
+
+ 0% + Functions + 0/46 +
+
+ 0% + Lines + 0/78 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
prettify.js
0%0/5020%0/2840%0/290%0/1
sorter.js
0%0/770%0/220%0/170%0/77
+
+
+ + + + + + + diff --git a/coverage/project-code/coverage/prettify.js.html b/coverage/project-code/coverage/prettify.js.html new file mode 100644 index 0000000..117ab03 --- /dev/null +++ b/coverage/project-code/coverage/prettify.js.html @@ -0,0 +1,68 @@ + + + + Code coverage report for project-code/coverage/prettify.js + + + + + + + +
+
+

+ All files / project-code/coverage prettify.js +

+
+
+ 0% + Statements + 0/502 +
+
+ 0% + Branches + 0/284 +
+
+ 0% + Functions + 0/29 +
+
+ 0% + Lines + 0/1 +
+
+
+
+

+
+
1 +2  + 
window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.ignoreCase){ac=true}else{if(/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){S=true;ac=false;break}}}var Y={b:8,t:9,n:10,v:11,f:12,r:13};function ab(ah){var ag=ah.charCodeAt(0);if(ag!==92){return ag}var af=ah.charAt(1);ag=Y[af];if(ag){return ag}else{if("0"<=af&&af<="7"){return parseInt(ah.substring(1),8)}else{if(af==="u"||af==="x"){return parseInt(ah.substring(2),16)}else{return ah.charCodeAt(1)}}}}function T(af){if(af<32){return(af<16?"\\x0":"\\x")+af.toString(16)}var ag=String.fromCharCode(af);if(ag==="\\"||ag==="-"||ag==="["||ag==="]"){ag="\\"+ag}return ag}function X(am){var aq=am.substring(1,am.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));var ak=[];var af=[];var ao=aq[0]==="^";for(var ar=ao?1:0,aj=aq.length;ar<aj;++ar){var ah=aq[ar];if(/\\[bdsw]/i.test(ah)){ak.push(ah)}else{var ag=ab(ah);var al;if(ar+2<aj&&"-"===aq[ar+1]){al=ab(aq[ar+2]);ar+=2}else{al=ag}af.push([ag,al]);if(!(al<65||ag>122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;ar<af.length;++ar){var at=af[ar];if(at[0]<=ap[1]+1){ap[1]=Math.max(ap[1],at[1])}else{ai.push(ap=at)}}var an=["["];if(ao){an.push("^")}an.push.apply(an,ak);for(var ar=0;ar<ai.length;++ar){var at=ai[ar];an.push(T(at[0]));if(at[1]>at[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){an[af]=-1}}}}for(var ak=1;ak<an.length;++ak){if(-1===an[ak]){an[ak]=++ad}}for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am;if(an[am]===undefined){aj[ak]="(?:"}}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){aj[ak]="\\"+an[am]}}}}for(var ak=0,am=0;ak<ah;++ak){if("^"===aj[ak]&&"^"!==aj[ak+1]){aj[ak]=""}}if(al.ignoreCase&&S){for(var ak=0;ak<ah;++ak){var ag=aj[ak];var ai=ag.charAt(0);if(ag.length>=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.global||ae.multiline){throw new Error(""+ae)}aa.push("(?:"+W(ae)+")")}return new RegExp(aa.join("|"),ac?"gi":"g")}function a(V){var U=/(?:^|\s)nocode(?:\s|$)/;var X=[];var T=0;var Z=[];var W=0;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=document.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Y=S&&"pre"===S.substring(0,3);function aa(ab){switch(ab.nodeType){case 1:if(U.test(ab.className)){return}for(var ae=ab.firstChild;ae;ae=ae.nextSibling){aa(ae)}var ad=ab.nodeName;if("BR"===ad||"LI"===ad){X[W]="\n";Z[W<<1]=T++;Z[(W++<<1)|1]=ab}break;case 3:case 4:var ac=ab.nodeValue;if(ac.length){if(!Y){ac=ac.replace(/[ \t\r\n]+/g," ")}else{ac=ac.replace(/\r\n?/g,"\n")}X[W]=ac;Z[W<<1]=T;T+=ac.length;Z[(W++<<1)|1]=ab}break}}aa(V);return{sourceCode:X.join("").replace(/\n$/,""),spans:Z}}function B(S,U,W,T){if(!U){return}var V={sourceCode:U,basePos:S};W(V);T.push.apply(T,V.decorations)}var v=/\S/;function o(S){var V=undefined;for(var U=S.firstChild;U;U=U.nextSibling){var T=U.nodeType;V=(T===1)?(V?S:U):(T===3)?(v.test(U.nodeValue)?S:V):V}return V===S?undefined:V}function g(U,T){var S={};var V;(function(){var ad=U.concat(T);var ah=[];var ag={};for(var ab=0,Z=ad.length;ab<Z;++ab){var Y=ad[ab];var ac=Y[3];if(ac){for(var ae=ac.length;--ae>=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae<aq;++ae){var ag=an[ae];var ap=aj[ag];var ai=void 0;var am;if(typeof ap==="string"){am=false}else{var aa=S[ag.charAt(0)];if(aa){ai=ag.match(aa[1]);ap=aa[0]}else{for(var ao=0;ao<X;++ao){aa=T[ao];ai=ag.match(aa[1]);if(ai){ap=aa[0];break}}if(!ai){ap=F}}am=ap.length>=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y<W.length;++Y){ae(W[Y])}if(ag===(ag|0)){W[0].setAttribute("value",ag)}var aa=ac.createElement("OL");aa.className="linenums";var X=Math.max(0,((ag-1))|0)||0;for(var Y=0,T=W.length;Y<T;++Y){af=W[Y];af.className="L"+((Y+X)%10);if(!af.firstChild){af.appendChild(ac.createTextNode("\xA0"))}aa.appendChild(af)}V.appendChild(aa)}function D(ac){var aj=/\bMSIE\b/.test(navigator.userAgent);var am=/\n/g;var al=ac.sourceCode;var an=al.length;var V=0;var aa=ac.spans;var T=aa.length;var ah=0;var X=ac.decorations;var Y=X.length;var Z=0;X[Y]=an;var ar,aq;for(aq=ar=0;aq<Y;){if(X[aq]!==X[aq+2]){X[ar++]=X[aq++];X[ar++]=X[aq++]}else{aq+=2}}Y=ar;for(aq=ar=0;aq<Y;){var at=X[aq];var ab=X[aq+1];var W=aq+2;while(W+2<=Y&&X[W+1]===ab){W+=2}X[ar++]=at;X[ar++]=ab;aq=W}Y=X.length=ar;var ae=null;while(ah<T){var af=aa[ah];var S=aa[ah+2]||an;var ag=X[Z];var ap=X[Z+2]||an;var W=Math.min(S,ap);var ak=aa[ah+1];var U;if(ak.nodeType!==1&&(U=al.substring(V,W))){if(aj){U=U.replace(am,"\r")}ak.nodeValue=U;var ai=ak.ownerDocument;var ao=ai.createElement("SPAN");ao.className=X[Z+1];var ad=ak.parentNode;ad.replaceChild(ao,ak);ao.appendChild(ak);if(V<S){aa[ah+1]=ak=ai.createTextNode(al.substring(W,S));ad.insertBefore(ak,ao.nextSibling)}}V=W;if(V>=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*</.test(S)?"default-markup":"default-code"}return t[T]}c(K,["default-code"]);c(g([],[[F,/^[^<?]+/],[E,/^<!\w[^>]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa<ac.length;++aa){for(var Z=0,V=ac[aa].length;Z<V;++Z){T.push(ac[aa][Z])}}ac=null;var W=Date;if(!W.now){W={now:function(){return +(new Date)}}}var X=0;var S;var ab=/\blang(?:uage)?-([\w.]+)(?!\S)/;var ae=/\bprettyprint\b/;function U(){var ag=(window.PR_SHOULD_USE_CONTINUATION?W.now()+250:Infinity);for(;X<T.length&&W.now()<ag;X++){var aj=T[X];var ai=aj.className;if(ai.indexOf("prettyprint")>=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X<T.length){setTimeout(U,250)}else{if(ad){ad()}}}U()}window.prettyPrintOne=y;window.prettyPrint=b;window.PR={createSimpleLexer:g,registerLangHandler:c,sourceDecorator:i,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:n,PR_COMMENT:j,PR_DECLARATION:E,PR_KEYWORD:z,PR_LITERAL:G,PR_NOCODE:N,PR_PLAIN:F,PR_PUNCTUATION:L,PR_SOURCE:J,PR_STRING:C,PR_TAG:m,PR_TYPE:O}})();PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_DECLARATION,/^<!\w[^>]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^<script\b[^>]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:<!--|-->)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]);
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/coverage/sorter.js.html b/coverage/project-code/coverage/sorter.js.html new file mode 100644 index 0000000..3048e30 --- /dev/null +++ b/coverage/project-code/coverage/sorter.js.html @@ -0,0 +1,539 @@ + + + + Code coverage report for project-code/coverage/sorter.js + + + + + + + +
+
+

+ All files / project-code/coverage sorter.js +

+
+
+ 0% + Statements + 0/77 +
+
+ 0% + Branches + 0/22 +
+
+ 0% + Functions + 0/17 +
+
+ 0% + Lines + 0/77 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
var addSorting = (function () {
+    "use strict";
+    var cols,
+        currentSort = {
+            index: 0,
+            desc: false
+        };
+ 
+    // returns the summary table element
+    function getTable() { return document.querySelector('.coverage-summary'); }
+    // returns the thead element of the summary table
+    function getTableHeader() { return getTable().querySelector('thead tr'); }
+    // returns the tbody element of the summary table
+    function getTableBody() { return getTable().querySelector('tbody'); }
+    // returns the th element for nth column
+    function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
+ 
+    // loads all columns
+    function loadColumns() {
+        var colNodes = getTableHeader().querySelectorAll('th'),
+            colNode,
+            cols = [],
+            col,
+            i;
+ 
+        for (i = 0; i < colNodes.length; i += 1) {
+            colNode = colNodes[i];
+            col = {
+                key: colNode.getAttribute('data-col'),
+                sortable: !colNode.getAttribute('data-nosort'),
+                type: colNode.getAttribute('data-type') || 'string'
+            };
+            cols.push(col);
+            if (col.sortable) {
+                col.defaultDescSort = col.type === 'number';
+                colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
+            }
+        }
+        return cols;
+    }
+    // attaches a data attribute to every tr element with an object
+    // of data values keyed by column name
+    function loadRowData(tableRow) {
+        var tableCols = tableRow.querySelectorAll('td'),
+            colNode,
+            col,
+            data = {},
+            i,
+            val;
+        for (i = 0; i < tableCols.length; i += 1) {
+            colNode = tableCols[i];
+            col = cols[i];
+            val = colNode.getAttribute('data-value');
+            if (col.type === 'number') {
+                val = Number(val);
+            }
+            data[col.key] = val;
+        }
+        return data;
+    }
+    // loads all row data
+    function loadData() {
+        var rows = getTableBody().querySelectorAll('tr'),
+            i;
+ 
+        for (i = 0; i < rows.length; i += 1) {
+            rows[i].data = loadRowData(rows[i]);
+        }
+    }
+    // sorts the table using the data for the ith column
+    function sortByIndex(index, desc) {
+        var key = cols[index].key,
+            sorter = function (a, b) {
+                a = a.data[key];
+                b = b.data[key];
+                return a < b ? -1 : a > b ? 1 : 0;
+            },
+            finalSorter = sorter,
+            tableBody = document.querySelector('.coverage-summary tbody'),
+            rowNodes = tableBody.querySelectorAll('tr'),
+            rows = [],
+            i;
+ 
+        if (desc) {
+            finalSorter = function (a, b) {
+                return -1 * sorter(a, b);
+            };
+        }
+ 
+        for (i = 0; i < rowNodes.length; i += 1) {
+            rows.push(rowNodes[i]);
+            tableBody.removeChild(rowNodes[i]);
+        }
+ 
+        rows.sort(finalSorter);
+ 
+        for (i = 0; i < rows.length; i += 1) {
+            tableBody.appendChild(rows[i]);
+        }
+    }
+    // removes sort indicators for current column being sorted
+    function removeSortIndicators() {
+        var col = getNthColumn(currentSort.index),
+            cls = col.className;
+ 
+        cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
+        col.className = cls;
+    }
+    // adds sort indicators for current column being sorted
+    function addSortIndicators() {
+        getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
+    }
+    // adds event listeners for all sorter widgets
+    function enableUI() {
+        var i,
+            el,
+            ithSorter = function ithSorter(i) {
+                var col = cols[i];
+ 
+                return function () {
+                    var desc = col.defaultDescSort;
+ 
+                    if (currentSort.index === i) {
+                        desc = !currentSort.desc;
+                    }
+                    sortByIndex(i, desc);
+                    removeSortIndicators();
+                    currentSort.index = i;
+                    currentSort.desc = desc;
+                    addSortIndicators();
+                };
+            };
+        for (i =0 ; i < cols.length; i += 1) {
+            if (cols[i].sortable) {
+                // add the click event handler on the th so users
+                // dont have to click on those tiny arrows
+                el = getNthColumn(i).querySelector('.sorter').parentElement;
+                if (el.addEventListener) {
+                    el.addEventListener('click', ithSorter(i));
+                } else {
+                    el.attachEvent('onclick', ithSorter(i));
+                }
+            }
+        }
+    }
+    // adds sorting functionality to the UI
+    return function () {
+        if (!getTable()) {
+            return;
+        }
+        cols = loadColumns();
+        loadData(cols);
+        addSortIndicators();
+        enableUI();
+    };
+})();
+ 
+window.addEventListener('load', addSorting);
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/index.html b/coverage/project-code/index.html new file mode 100644 index 0000000..2ed40f2 --- /dev/null +++ b/coverage/project-code/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for project-code + + + + + + + +
+
+

+ All files project-code +

+
+
+ 0% + Statements + 0/2 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/1 +
+
+ 0% + Lines + 0/2 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
karma.conf.js
0%0/2100%0/00%0/10%0/2
+
+
+ + + + + + + diff --git a/coverage/project-code/karma.conf.js.html b/coverage/project-code/karma.conf.js.html new file mode 100644 index 0000000..f897e73 --- /dev/null +++ b/coverage/project-code/karma.conf.js.html @@ -0,0 +1,101 @@ + + + + Code coverage report for project-code/karma.conf.js + + + + + + + +
+
+

+ All files / project-code karma.conf.js +

+
+
+ 0% + Statements + 0/2 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/1 +
+
+ 0% + Lines + 0/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13  +  +  +  +  +  +  +  +  +  +  +  + 
module.exports = function(config) {
+    config.set({
+        frameworks: ["jasmine", "karma-typescript"],
+        files: [
+            "src/**/*.ts" // *.tsx for React Jsx
+        ],
+        preprocessors: {
+            "**/*.ts": "karma-typescript" // *.tsx for React Jsx
+        },
+        reporters: ["progress", "karma-typescript"],
+        browsers: ["Chrome"]
+    });
+};
+
+
+ + + + + + + diff --git a/coverage/project-code/src/FileRouter.ts.html b/coverage/project-code/src/FileRouter.ts.html new file mode 100644 index 0000000..e1704c6 --- /dev/null +++ b/coverage/project-code/src/FileRouter.ts.html @@ -0,0 +1,1769 @@ + + + + Code coverage report for project-code/src/FileRouter.ts + + + + + + + +
+
+

+ All files / project-code/src FileRouter.ts +

+
+
+ 44.53% + Statements + 57/128 +
+
+ 0% + Branches + 0/22 +
+
+ 5.41% + Functions + 2/37 +
+
+ 47.9% + Lines + 57/119 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +5691x +  +1x +1x +1x +1x +  +1x +1x +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +1x +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +2x +2x +2x +2x +2x +  +2x +2x +2x +2x +2x +2x +2x +  +2x +2x +2x +2x +2x +  +2x +2x +2x +  +  +  +  +1x +1x +  +1x +1x + 
import { ContributorGroupFullInfo, default as ContributorGroup
+	} from './db/model/ContributorGroup';
+import { default as File } from './db/model/File';
+import { ProjectFullInfo, default as Project } from './db/model/Project';
+import { UserFullInfo, default as User } from './db/model/User';
+import { default as UserGroup } from './db/model/UserGroup';
+ 
+import { NextFunction, Request, Response, Router } from 'express';
+import { default as serverConfig } from './serverConfig';
+ 
+// TODO: figure this out
+const BASE_FILE_STORAGE: string = 'TODO: figure this out';
+ 
+/**
+ * The type of an Express middleware callback.
+ */
+type Middleware =
+	(req: Request, res: Response, next: NextFunction) => void;
+ 
+/**
+ * Returns the supported Protocols
+ *
+ * The server's unwrapped response MUST match:
+ *
+ * exactly({
+ *     "supported": array(string),
+ *     "required": array(string)
+ * })
+ */
+const getProtocols: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	const returnValue: {
+		supported: string[];
+		required: string[];
+	} = {
+	supported: [],
+	required: [
+		'BE01'
+	]
+	};
+	res.send(JSON.stringify(returnValue));
+};
+ 
+/**
+ * Logging Endpoint for all components:
+ *
+ * with a request matching
+ *
+ * array({
+ *     "component": string,
+ *     "level": alternative([
+ *         "info",
+ *         "security",
+ *         "warning",
+ *         "error",
+ *         "critical"
+ *     ]),
+ *     "value": anything
+ * })
+ */
+const postLog: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.status(501)
+		.send({error : 'logging_not_enabled'});
+};
+ 
+/**
+ * Clients authorised as a user with the admin privilege can access
+ *
+ * http://backend.endpoint/log?before=<datetime>&after=<datetime>&level=<level>
+ *
+ * the server response should match
+ *
+ * array({
+ *     "component": string,
+ *     "level": alternative([
+ *         "info",
+ *         "security",
+ *         "warning",
+ *         "error",
+ *         "critical"
+ *     ]),
+ *     "value": anything,
+ *     "username": string,
+ *     "timestamp": string
+ * })
+ */
+const getLog: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.status(501)
+		.send({error : 'logging_not_enabled'});
+};
+ 
+/**
+ * Any authenticated client can access
+ *
+ * http://backend.endpoint/properties
+ *
+ * the server SHOULD respond with a list of properties,
+ * with the unwrapped response matching
+ *
+ * array({
+ *     "id": string,
+ *     "display": optional({
+ *         "category": string,
+ *         "group": string,
+ *         "display_name": string,
+ *         "description": string
+ *     }),
+ *     "read_only": boolean,
+ *     "type": alternative(["string", "integer", "boolean"]),
+ *     "value": alternative([string, integer, boolean])
+ * })
+ */
+const getProperties: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.status(200)
+		.send(serverConfig);
+};
+ 
+/**
+ * To update properties the client POSTs to
+ *
+ * http://backend.endpoint/properties?action=update
+ *
+ * with body
+ *
+ * array({
+ *     "id": string,
+ *     "value": alternative([string, integer, boolean])
+ * })
+ */
+const postProperties: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	let success: boolean = true;
+ 
+	// For each property to update
+	for (const prop of req.body) {
+ 
+		// Check that the property has and id and a value
+		if (!prop.hasOwnProperty('id') || !prop.hasOwnProperty('value')) {
+			res.status(400)
+				.send({
+					error: 'invalid_request',
+					error_description: 'A supplied property is missing an id or value'
+				});
+			success = false;
+			break;
+		}
+ 
+		// Find out if the property exists in the config and if so, at which index
+		const index: number = serverConfig.indexOf(prop.id);
+ 
+		// Check some of the properties values to ensure that it can be updated
+		if (index === -1 || serverConfig[index].readOnly) {
+			/* TODO Implement an or, using Tom's type checker
+			 * to ensure the value is "valid" based on the type of the property */
+			const description: string = index === -1
+				? 'Property not found'
+				: 'Property is Read_Only';
+			res.status(400)
+				.send({
+				error: 'invalid_property',
+				error_data: prop.id,
+				error_description: description
+			});
+			success = false;
+			break;
+		}
+ 
+		// Make the update to the property
+		serverConfig[index].value = prop.value;
+	}
+ 
+	// Tell the client that everything was okay;
+	if (success) {
+		res.status(200)
+			.send();
+	}
+};
+ 
+/**
+ * Listing available privileges
+ *
+ * And the server's response, unwrapped, must match
+ *
+ * array({
+ *     "privilege": string,
+ *     "description": string,
+ *     "internal": boolean
+ * })
+ */
+const getUserPriveleges: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const usergroups: UserGroup[] = await UserGroup.findAll();
+	res.json(usergroups.map(
+		(ug: UserGroup) => ug.getPrivelege()
+	));
+};
+ 
+/**
+ * Listing users
+ *
+ * If the client is authorised as a user with the admin privilege
+ * the server MUST respond with a list of users,
+ * with the unwrapped response matching
+ *
+ * array({
+ *     "username": string,
+ *     "privileges": array(string),
+ *     "projects": array({
+ *         "project_name": string,
+ *         "access_level": string
+ *     }),
+ *     "public_user_metadata": metadata,
+ *     "private_user_metadata": metadata,
+ *     "public_admin_metadata": metadata,
+ *     "private_admin_metadata": metadata
+ * })
+ */
+const getUsers: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const users: User[] = await User.findAll({
+		include: [
+			UserGroup,
+			Project
+		]
+	});
+	res.json(users.map<UserFullInfo>(
+		(u: User) => u.getUserFullInfo()
+	));
+};
+ 
+/**
+ * Expose additional configuration options for individual users
+ */
+const getUserProperties: Middleware =
+	(req: Request, res: Response, next: NextFunction, user?: string): void => {
+	res.status(500)
+	.send({
+		error: 'unsupported',
+		error_description:
+			'Users on this server dont have additional configuration options.'
+	});
+};
+ 
+const userInfoFromName: (name: string) => Promise<UserFullInfo> =
+	async(name: string): Promise<UserFullInfo> =>  {
+	const user: User | null = await User.findOne({
+		where: {
+			username: name
+		},
+		include: [
+			UserGroup,
+			Project
+		]
+	});
+ 
+	if (user === null) {
+		throw new Error(`No user of name ${name} in database.`);
+	} else {
+		return user.getUserFullInfo();
+	}
+};
+ 
+/**
+ * Listing a particular User
+ *
+ * If the client is authorised as a user with the admin privilege
+ * the server MUST respond with details of the particular user if they exist
+ * (unwrapped response):
+ *
+ * {
+ *     "username": string,
+ *     "privileges": array(string),
+ *     "projects": array({
+ *         "project_name": string,
+ *         "access_level": string
+ *     }),
+ *     "public_user_metadata": metadata,
+ *     "private_user_metadata": metadata,
+ *     "public_admin_metadata": metadata,
+ *     "private_admin_metadata": metadata
+ * }
+ */
+const getUsername: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const info: UserFullInfo = await userInfoFromName(req.params.username);
+	res.json(info);
+};
+ 
+const getCurUser: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.json({
+		todo: 'need to findo out where authenticated user info goes'
+	});
+};
+ 
+/**
+ * Updating the current user
+ *
+ * http://backend.endpoint/current_user?action=update
+ *
+ * with body matching
+ *
+ * {
+ *     "password": optional({
+ *         "old": string,
+ *         "new": string
+ *     }),
+ *     "public_user_metadata": optional(metadata),
+ *     "private_user_metadata": optional(metadata),
+ *     "public_admin_metadata": not_present,
+ *     "private_admin_metadata": not_present
+ * }
+ */
+const postCurUser: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.json({todo: 'need to implement meeeee'});
+};
+ 
+/**
+ * Creating a User/updating a user
+ *
+ * http://backend.endpoint/users/<username>?action=create
+ *
+ * with body matching
+ *
+ * {
+ *     "privileges": array(string),
+ *     "password": string,
+ *     "public_user_metadata": optional(metadata),
+ *     "private_user_metadata": optional(metadata),
+ *     "public_admin_metadata": optional(metadata),
+ *     "private_admin_metadata": optional(metadata)
+ * }
+ */
+const postUsername: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.json({todo: 'need to implement meeeee'});
+};
+ 
+/**
+ * Listing available Roles
+ *
+ * The servers response, unwrapped, must match
+ *
+ * array({
+ *     "role": string,
+ *     "description": string,
+ *     "internal": boolean
+ * })
+ */
+const getProjectRoles: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const roles: ContributorGroup[] = await ContributorGroup.findAll();
+	res.json(roles.map<ContributorGroupFullInfo>(
+		(cg: ContributorGroup) => cg.getContributorGroupFullInfo()
+	));
+};
+ 
+/**
+ * Listing Projects
+ *
+ * The server MUST respond with a list of projects,
+ * with the unwrapped response matching
+ *
+ * array({
+ *     "project_name": string,
+ *     "users": array({
+ *         "username": string,
+ *         "access_level": string
+ *     }),
+ *     "public_metadata": metadata,
+ *     "private_metadata": optional(metadata),
+ *     "admin_metadata": optional(metadata)
+ * })
+ */
+const getProjects: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const projects: Project[] = await Project.findAll({
+		include: [
+			User
+		]
+	});
+	res.json(projects.map<ProjectFullInfo>(
+		(p: Project) => p.getProjectFullInfo()
+	));
+};
+ 
+/**
+ * Listing a specific Project
+ *
+ * The server MUST respond with details of the particular project
+ * if it exists (unwrapped response):
+ *
+ * {
+ *     "project_name": string,
+ *     "users": array({
+ *         "username": string,
+ *         "access_level": string
+ *     }),
+ *     "public_metadata": metadata,
+ *     "private_metadata": metadata,
+ *     "admin_metadata": optional(metadata)
+ * }
+ */
+const getProjectName: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const project: Project | null = await Project.findOne({
+		where: {
+			name: req.params.project_name
+		}
+	});
+	if (project === null) {
+		throw new Error(`Project ${req.params.project_name} does not exist`);
+	} else {
+		res.json(project);
+	}
+};
+ 
+/**
+ * Creating a Project / updating a project / deleting / Project grants
+ *
+ * http://backend.endpoint/projects/<project_name>?action=create
+ *
+ * with body matching
+ *
+ * {
+ *     "public_metadata": optional(metadata),
+ *     "private_metadata": optional(metadata),
+ *     "admin_metadata": optional(metadata)
+ * }
+ */
+const postProjectName: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.json({todo: 'need to implement meeeee'});
+};
+ 
+/*
+ * additional configuration options for individual projects
+ */
+const getProjectProperties: Middleware =
+	(req: Request, res: Response, next: NextFunction): void => {
+	res.status(500)
+	.send({
+		error: 'unsupported',
+		error_description:
+			'Projects on this server dont have additional configuration options.'
+	});
+};
+ 
+const getChildFile: (names: string[], parentUuid: string) => Promise<File> =
+	async(names: string[], parentUuid: string): Promise<File> => {
+	// TODO: Check that this works lol :3
+	const child: File | null = await File.findOne({
+		where: {
+			parentFolderId: parentUuid,
+			name: names[0]
+		}
+	});
+ 
+	if (child === null) {
+		throw new Error(`File of name ${names[0]} does not exist`);
+	} else {
+		if (names.length === 1) {
+			return child;
+		} else {
+			names.splice(0, 1);
+			return getChildFile(names, child.uuid);
+		}
+	}
+};
+ 
+/**
+ * GET a File.
+ */
+const getFilePath: Middleware =
+	async(req: Request, res: Response, next: NextFunction): Promise<void> => {
+	const project: Project | null = await Project.findOne({
+		where: {
+			name: req.params.project_name
+		}
+	});
+ 
+	if (project === null) {
+		throw new Error(
+			`Project of name ${req.params.project_name} does not exist`
+		);
+	} else {
+		const file: File = await getChildFile(
+			req.params.project_name, project.rootFolderId
+		);
+ 
+		res.sendFile(
+			`${BASE_FILE_STORAGE}/${req.params.project_name}/${file.uuid}`
+		);
+	}
+};
+ 
+/**
+ * GET a File.
+ */
+const getFileId: Middleware =
+	(req: Request, res: Response, next: NextFunction): void =>  {
+	// TODO: implement correctness of project folder checking.
+	res.sendFile(
+		`${BASE_FILE_STORAGE}/${req.params.project_name}/${req.params.id}`
+	);
+};
+ 
+/**
+ * Post a File. / delete / move / etc
+ */
+const postFilePath: Middleware =
+	(req: Request, res: Response, next: NextFunction): void =>  {
+	res.json({todo: 'need to implement meeeee'});
+};
+ 
+export class FileRouter {
+	public router: Router;
+ 
+	/**
+	 * Initialize the FileRouter
+	 */
+	public constructor() {
+	this.router = Router();
+	this.init();
+	}
+ 
+	/**
+	 * Take each handler, and attach to one of the Express.Router's
+	 * endpoints.
+	 */
+	public init(): void {
+		// General
+		this.router.get ('/_supported_protocols_',	                   getProtocols);
+		this.router.get ('/log',						                     getLog);
+		this.router.post('/log',	       									postLog);
+		this.router.get ('/properties',						          getProperties);
+		this.router.post('/properties',						         postProperties);
+		// Users
+		this.router.get ('/user_privileges',				      getUserPriveleges);
+		this.router.get ('/users',									       getUsers);
+		this.router.get ('/users/:username',				            getUsername);
+		this.router.post('/users/:username',				           postUsername);
+		this.router.get ('/users/:username/properties',           getUserProperties);
+		this.router.get ('/current_user',					             getCurUser);
+		this.router.post('/current_user',					            postCurUser);
+		// Projects
+		this.router.get ('/project_roles',					        getProjectRoles);
+		this.router.get ('/projects',							        getProjects);
+		this.router.get ('/projects/:project_name',                  getProjectName);
+		this.router.post('/projects/:project_name',                 postProjectName);
+		this.router.get ('/projects/:project_name/properties', getProjectProperties);
+		// File access
+		this.router.get ('/projects/:project_name/files/:path',         getFilePath);
+		this.router.post('/projects/:project_name/files/:id',          postFilePath);
+		this.router.get ('/projects/:project_name/files_by_id/:id',       getFileId);
+	}
+}
+ 
+// Create the FileRouter, and export its configured Express.Router
+const fileRoutes: FileRouter = new FileRouter();
+fileRoutes.init();
+ 
+const ex: Router = fileRoutes.router;
+export default ex;
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/app.ts.html b/coverage/project-code/src/app.ts.html new file mode 100644 index 0000000..60f3e87 --- /dev/null +++ b/coverage/project-code/src/app.ts.html @@ -0,0 +1,197 @@ + + + + Code coverage report for project-code/src/app.ts + + + + + + + +
+
+

+ All files / project-code/src app.ts +

+
+
+ 90.48% + Statements + 19/21 +
+
+ 50% + Branches + 1/2 +
+
+ 100% + Functions + 5/5 +
+
+ 90.48% + Lines + 19/21 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +451x +1x +1x +1x +  +  +  +  +  +  +2x +2x +2x +2x +  +  +  +  +2x +  +  +  +2x +2x +  +  +  +  +2x +2x +3x +  +  +  +  +2x +2x +  +  +  +1x +1x +1x +  + 
import * as bodyParser from 'body-parser';
+import * as ex from 'express';
+import FileRouter from './FileRouter';
+import * as logger from 'morgan';
+ 
+class App {
+	public express: ex.Express;
+	private logEnabled: boolean;
+ 
+	public constructor(enableLog: boolean) {
+		this.express = ex();
+		this.middleware();
+		this.mountRoutes();
+		this.logEnabled = enableLog;
+	}
+ 
+	// Configure Express middleware.
+	private middleware(): void {
+		Iif (this.logEnabled) {
+			console.log("log enabled")
+			this.express.use(logger('combined'));
+		}
+		this.express.use(bodyParser.json());
+		this.express.use(bodyParser.urlencoded({ extended: false }));
+	}
+ 
+	// Configure API endpoints.
+	private mountRoutes(): void {
+		const defRouter: ex.Router = ex.Router();
+		defRouter.get('/', (req: ex.Request, res: ex.Response): void => {
+			res.json({
+				message: 'Welcome to the CS3099 BE4 server!',
+				important : 'Endpoints start from /cs3099group-be-4/'
+			});
+		});
+		this.express.use('/', defRouter);
+		this.express.use('/cs3099group-be-4', FileRouter);
+	}
+}
+ 
+export default new App(true).express;
+export function TestApp(){
+	return new App(false).express;
+} 
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/index.html b/coverage/project-code/src/db/index.html new file mode 100644 index 0000000..a7d063a --- /dev/null +++ b/coverage/project-code/src/db/index.html @@ -0,0 +1,106 @@ + + + + Code coverage report for project-code/src/db + + + + + + + +
+
+

+ All files project-code/src/db +

+
+
+ 0% + Statements + 0/3 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/2 +
+
+ 0% + Lines + 0/3 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
initPostgresDB.ts
0%0/2100%0/00%0/20%0/2
orm.ts
0%0/1100%0/0100%0/00%0/1
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/initPostgresDB.ts.html b/coverage/project-code/src/db/initPostgresDB.ts.html new file mode 100644 index 0000000..35036ff --- /dev/null +++ b/coverage/project-code/src/db/initPostgresDB.ts.html @@ -0,0 +1,110 @@ + + + + Code coverage report for project-code/src/db/initPostgresDB.ts + + + + + + + +
+
+

+ All files / project-code/src/db initPostgresDB.ts +

+
+
+ 0% + Statements + 0/2 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/2 +
+
+ 0% + Lines + 0/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import * as Sequelize from 'sequelize';
+const gres: Sequelize.Sequelize = new Sequelize(
+	'postgres://admin:eprprJacR0hBpmWvs5IDJZTnjRAY2gM3tSm0b1af@localhost:5432/be4',
+	{
+		operatorsAliases : false
+	}
+);
+ 
+gres.authenticate()
+	.then(() => {
+		// Connection has been established successfully.
+	})
+	.catch((err: Error) => {
+		// Unable to connect to the database.
+	});
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/ContributorGroup.ts.html b/coverage/project-code/src/db/model/ContributorGroup.ts.html new file mode 100644 index 0000000..e8e3ce2 --- /dev/null +++ b/coverage/project-code/src/db/model/ContributorGroup.ts.html @@ -0,0 +1,227 @@ + + + + Code coverage report for project-code/src/db/model/ContributorGroup.ts + + + + + + + +
+
+

+ All files / project-code/src/db/model ContributorGroup.ts +

+
+
+ 53.85% + Statements + 14/26 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/3 +
+
+ 86.67% + Lines + 13/15 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +551x +  +1x +  +  +1x +  +  +1x +  +  +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +  +1x +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import { AllowNull, Column, DataType, HasMany, Model, Table
+	} from 'sequelize-typescript';
+import { default as UserJoinsProject } from './UserJoinsProject';
+ 
+@Table
+export default class ContributorGroup extends Model<ContributorGroup> {
+	@AllowNull
+	@Column(DataType.TEXT)
+	public name: string | null = null;
+ 
+	/* "Error: Foreign key for "ContributorGroup"
+	 * is missing on "UserJoinsProject"." */
+	@HasMany(() => UserJoinsProject, 'contributorGroupId')
+	public uses: UserJoinsProject[] = [];
+ 
+	@Column
+	public canCreateFiles: boolean = false;
+ 
+	@Column
+	public canDeleteFiles: boolean = false;
+ 
+	@Column
+	public canViewFiles: boolean = false;
+ 
+	@Column
+	public canAddUsers: boolean = false;
+ 
+	@Column
+	public canRemoveUsers: boolean = false;
+ 
+	@Column
+	public canEditUserPermissions: boolean = false;
+ 
+	@AllowNull
+	@Column(DataType.TEXT)
+	public description: string | null = null;
+ 
+	@Column
+	public isInternal: boolean = true;
+ 
+	public getContributorGroupFullInfo(): ContributorGroupFullInfo {
+		return {
+			role: `${this.name}`,
+			description: `${this.description}`,
+			internal: this.isInternal
+		};
+	}
+}
+ 
+export interface ContributorGroupFullInfo {
+	role: string;
+	description: string;
+	internal: boolean;
+}
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/File.ts.html b/coverage/project-code/src/db/model/File.ts.html new file mode 100644 index 0000000..f552af3 --- /dev/null +++ b/coverage/project-code/src/db/model/File.ts.html @@ -0,0 +1,206 @@ + + + + Code coverage report for project-code/src/db/model/File.ts + + + + + + + +
+
+

+ All files / project-code/src/db/model File.ts +

+
+
+ 48.48% + Statements + 16/33 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/7 +
+
+ 71.43% + Lines + 15/21 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +481x +1x +  +1x +  +  +1x +  +1x +  +  +  +1x +  +  +1x +  +  +  +  +1x +  +  +1x +  +  +1x +  +  +  +  +1x +  +  +1x +  +  +1x +  +  +  +1x +  +  +  +1x +  + 
import { default as Project } from './Project';
+import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany,
+		HasOne, Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript';
+import { default as User } from './User';
+ 
+@Table
+export default class File extends Model<File> {
+	@Column
+	public name: string = '';
+ 
+	@PrimaryKey
+	@Column
+	public uuid: string = '';
+ 
+	@Column
+	public mimetype: string = '';
+ 
+	@ForeignKey(() => File)
+	@AllowNull
+	@Column(DataType.TEXT)
+	public parentFolderId: string | null = null;
+ 
+	@BelongsTo(() => File)
+	public parentFolder: File = new File();
+ 
+	@HasMany(() => File)
+	public containedFiles: File[] = [];
+ 
+	@ForeignKey(() => User)
+	@AllowNull
+	@Column(DataType.TEXT)
+	public creatorName: string | null = null;
+ 
+	@BelongsTo(() => User)
+	public creator: User = new User();
+ 
+	@HasOne(() => Project)
+	public rootFolderOf: Project = new Project();
+ 
+	@CreatedAt
+	@Column
+	public uploadDate: Date = new Date();
+ 
+	@UpdatedAt
+	@Column
+	public modifyDate: Date = new Date();
+}
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/Project.ts.html b/coverage/project-code/src/db/model/Project.ts.html new file mode 100644 index 0000000..b6270dc --- /dev/null +++ b/coverage/project-code/src/db/model/Project.ts.html @@ -0,0 +1,290 @@ + + + + Code coverage report for project-code/src/db/model/Project.ts + + + + + + + +
+
+

+ All files / project-code/src/db/model Project.ts +

+
+
+ 46.15% + Statements + 12/26 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/9 +
+
+ 61.11% + Lines + 11/18 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76  +1x +1x +  +1x +1x +  +  +1x +  +  +  +1x +  +  +1x +  +  +  +1x +  +  +1x +  +  +  +1x +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import { default as ContributorGroup } from './ContributorGroup';
+import { default as File } from './File';
+import { BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey,
+		Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript';
+import { default as User } from './User';
+import { default as UserJoinsProject } from './UserJoinsProject';
+ 
+@Table
+export default class Project extends Model<Project> {
+ 
+	@PrimaryKey
+	@Column
+	public name: string = '';
+ 
+	@BelongsToMany(() => User, () => UserJoinsProject)
+	public contributors: User[] = [];
+ 
+	@ForeignKey(() => File)
+	@Column
+	public rootFolderId: string = '';
+ 
+	@BelongsTo(() => File)
+	public rootFolder: File = new File();
+ 
+	@CreatedAt
+	@Column
+	public creationDate: Date = new Date();
+ 
+	@UpdatedAt
+	@Column
+	public lastActivity: Date = new Date();
+ 
+	public getAccessLevel(user: User): ContributorGroup {
+		throw new Error(`unimplemented, ${this}`);
+	}
+ 
+	public getUserInfo(user: User): UserInfo {
+		return {
+			username: user.username,
+			access_level: this.getAccessLevel(user)
+				.toString()
+		};
+	}
+ 
+	public getProjectFullInfo(): ProjectFullInfo {
+		return {
+			project_name: this.name,
+			users: this.contributors
+			.map<UserInfo>(
+				(u: User) => this.getUserInfo(u)
+			),
+			public_metadata: {
+				creation_date: this.creationDate
+			},
+			// TODO: Check if we have anything to use these for yet?
+			private_metadata: {},
+			admin_metadata: {}
+		};
+	}
+}
+ 
+interface Metadata {}
+ 
+interface UserInfo {
+	username: string;
+	access_level: string;
+}
+ 
+export interface ProjectFullInfo {
+	project_name: string;
+	users: UserInfo[];
+	public_metadata: Metadata;
+	private_metadata?: Metadata;
+	admin_metadata?: Metadata;
+}
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/User.ts.html b/coverage/project-code/src/db/model/User.ts.html new file mode 100644 index 0000000..ffec619 --- /dev/null +++ b/coverage/project-code/src/db/model/User.ts.html @@ -0,0 +1,299 @@ + + + + Code coverage report for project-code/src/db/model/User.ts + + + + + + + +
+
+

+ All files / project-code/src/db/model User.ts +

+
+
+ 46.67% + Statements + 14/30 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/10 +
+
+ 61.9% + Lines + 13/21 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +791x +1x +1x +  +1x +1x +  +  +1x +  +  +1x +  +  +1x +  +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import { default as File } from './File';
+import { default as Project } from './Project';
+import { BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey, HasMany,
+		Model, PrimaryKey, Table } from 'sequelize-typescript';
+import { default as UserGroup } from './UserGroup';
+import { default as UserJoinsProject } from './UserJoinsProject';
+ 
+@Table
+export default class User extends Model<User> {
+	@PrimaryKey
+	@Column
+	public username: string = '';
+ 
+	@Column
+	public password: string = '';
+ 
+	@ForeignKey(() => UserGroup)
+	@Column
+	public userGroupId: number = 0;
+ 
+	@BelongsTo(() => UserGroup)
+	public userGroup: UserGroup = new UserGroup();
+ 
+	@BelongsToMany(() => Project, () => UserJoinsProject)
+	public projects: Project[] = [];
+ 
+	@HasMany(() => File)
+	public createdFiles: File[] = [];
+ 
+	@CreatedAt
+	@Column
+	public creationDate: Date = new Date();
+ 
+	// TODO implement
+	public getAccessLevel(project: Project): string {
+		throw new Error(`unimplemented, ${this}`);
+	}
+ 
+	public getProjectInfo(project: Project): ProjectInfo {
+		return {
+			project_name: project.name,
+			access_level: this.getAccessLevel(project)
+		};
+	}
+ 
+	public getUserFullInfo(): UserFullInfo {
+		return {
+			username : this.username,
+			privileges: [`${this.userGroup.name}`],
+			projects : this.projects.map<ProjectInfo>(
+				(p: Project) => this.getProjectInfo(p)
+			),
+			// TODO: Check if we have anything to use these for yet?
+			public_user_metadata: {},
+			private_user_metadata: {},
+			public_admin_metadata: {},
+			private_admin_metadata: {}
+		};
+	}
+}
+ 
+// TODO MAKE PRETTY below
+interface Metadata {}
+ 
+interface ProjectInfo {
+	project_name: string;
+	access_level: string;
+}
+ 
+export interface UserFullInfo {
+	username: string;
+	privileges: string[];
+	projects: ProjectInfo[];
+	public_user_metadata: Metadata;
+	private_user_metadata: Metadata;
+	public_admin_metadata: Metadata;
+	private_admin_metadata: Metadata;
+}
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/UserGroup.ts.html b/coverage/project-code/src/db/model/UserGroup.ts.html new file mode 100644 index 0000000..75f5fbf --- /dev/null +++ b/coverage/project-code/src/db/model/UserGroup.ts.html @@ -0,0 +1,221 @@ + + + + Code coverage report for project-code/src/db/model/UserGroup.ts + + + + + + + +
+
+

+ All files / project-code/src/db/model UserGroup.ts +

+
+
+ 53.85% + Statements + 14/26 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/3 +
+
+ 86.67% + Lines + 13/15 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +531x +  +1x +  +  +  +  +  +  +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +  +1x +  +  +  +  +  +  +  +  +  + 
import { AllowNull, Column, DataType, HasMany, Model, Table
+	} from 'sequelize-typescript';
+import { default as User } from './User';
+ 
+interface UserPrivilege {
+	privilege: string;
+	description: string;
+	internal: boolean;
+}
+ 
+@Table
+export default class UserGroup extends Model<UserGroup> {
+	@AllowNull
+	@Column(DataType.TEXT)
+	public name: string | null = null;
+ 
+	@HasMany(() => User)
+	public users: User[] = [];
+ 
+	@Column
+	public canCreateUsers: boolean = false;
+ 
+	@Column
+	public canDeleteUsers: boolean = false;
+ 
+	@Column
+	public canEditUsers: boolean = false;
+ 
+	@Column
+	public canCreateProjects: boolean = false;
+ 
+	@Column
+	public canDeleteProjects: boolean = false;
+ 
+	@Column
+	public canEditProjects: boolean = false;
+ 
+	@Column
+	public isInternal: boolean = true;
+ 
+	@AllowNull
+	@Column(DataType.TEXT)
+	public description: string | null = null;
+ 
+	public getPrivelege(): UserPrivilege {
+		return {
+			privilege : `${this.name}`,
+			description : `${this.description}`,
+			internal : this.isInternal
+		};
+	}
+}
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/UserJoinsProject.ts.html b/coverage/project-code/src/db/model/UserJoinsProject.ts.html new file mode 100644 index 0000000..0783bbd --- /dev/null +++ b/coverage/project-code/src/db/model/UserJoinsProject.ts.html @@ -0,0 +1,146 @@ + + + + Code coverage report for project-code/src/db/model/UserJoinsProject.ts + + + + + + + +
+
+

+ All files / project-code/src/db/model UserJoinsProject.ts +

+
+
+ 55% + Statements + 11/20 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/5 +
+
+ 71.43% + Lines + 10/14 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +281x +1x +  +1x +1x +  +  +1x +  +  +1x +  +  +  +1x +  +  +  +1x +  +  +  +1x +  +  +1x +  + 
import { default as Project } from './Project';
+import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table
+	} from 'sequelize-typescript';
+import { default as User } from './User';
+import { default as ContributorGroup } from './UserGroup';
+ 
+@Table
+export default class UserJoinsProject extends Model<UserJoinsProject> {
+	@ForeignKey(() => User)
+	@Column
+	public username: string = '';
+ 
+	@ForeignKey(() => Project)
+	@Column
+	public projectName: string = '';
+ 
+	@CreatedAt
+	@Column
+	public joinDate: Date = new Date();
+ 
+	@ForeignKey(() => ContributorGroup)
+	@Column
+	public contributorGroupId: number = 0;
+ 
+	@BelongsTo(() => ContributorGroup)
+	public contributorGroup: ContributorGroup = new ContributorGroup();
+}
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/model/index.html b/coverage/project-code/src/db/model/index.html new file mode 100644 index 0000000..0a79060 --- /dev/null +++ b/coverage/project-code/src/db/model/index.html @@ -0,0 +1,158 @@ + + + + Code coverage report for project-code/src/db/model + + + + + + + +
+
+

+ All files project-code/src/db/model +

+
+
+ 50.31% + Statements + 81/161 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/37 +
+
+ 72.12% + Lines + 75/104 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
ContributorGroup.ts
53.85%14/26100%0/00%0/386.67%13/15
File.ts
48.48%16/33100%0/00%0/771.43%15/21
Project.ts
46.15%12/26100%0/00%0/961.11%11/18
User.ts
46.67%14/30100%0/00%0/1061.9%13/21
UserGroup.ts
53.85%14/26100%0/00%0/386.67%13/15
UserJoinsProject.ts
55%11/20100%0/00%0/571.43%10/14
+
+
+ + + + + + + diff --git a/coverage/project-code/src/db/orm.ts.html b/coverage/project-code/src/db/orm.ts.html new file mode 100644 index 0000000..e8b90ab --- /dev/null +++ b/coverage/project-code/src/db/orm.ts.html @@ -0,0 +1,101 @@ + + + + Code coverage report for project-code/src/db/orm.ts + + + + + + + +
+
+

+ All files / project-code/src/db orm.ts +

+
+
+ 0% + Statements + 0/1 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 0% + Lines + 0/1 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13  +  +  +  +  +  +  +  +  +  +  +  + 
import { Sequelize } from 'sequelize-typescript';
+ 
+const seq: Sequelize = new Sequelize({
+  database: 'be4',
+  dialect: 'postgres',
+  username: 'admin',
+  password: '',
+  operatorsAliases: false,
+  modelPaths: [`${__dirname}/model`]
+});
+ 
+export default seq;
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/index.html b/coverage/project-code/src/index.html new file mode 100644 index 0000000..4307500 --- /dev/null +++ b/coverage/project-code/src/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for project-code/src + + + + + + + +
+
+

+ All files project-code/src +

+
+
+ 0% + Statements + 0/16 +
+
+ 0% + Branches + 0/4 +
+
+ 0% + Functions + 0/2 +
+
+ 0% + Lines + 0/16 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.ts
0%0/160%0/40%0/20%0/16
+
+
+ + + + + + + diff --git a/coverage/project-code/src/index.ts.html b/coverage/project-code/src/index.ts.html new file mode 100644 index 0000000..d4515b2 --- /dev/null +++ b/coverage/project-code/src/index.ts.html @@ -0,0 +1,227 @@ + + + + Code coverage report for project-code/src/index.ts + + + + + + + +
+
+

+ All files / project-code/src index.ts +

+
+
+ 0% + Statements + 0/16 +
+
+ 0% + Branches + 0/4 +
+
+ 0% + Functions + 0/2 +
+
+ 0% + Lines + 0/16 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
/* tslint:disable:no-console
+ * This only goes here until we have a logging system */
+ 
+console.log('begin import');
+import { default as app } from './app';
+import { default as seq } from './db/orm';
+console.log('end import');
+ 
+import { default as UserGroup } from './db/model/UserGroup';
+ 
+const DEFAULT_PORT: number = 3000;
+ 
+// Use default port 3000 or port supplied by OS
+const port: number = process.env.PORT
+	? process.env.PORT
+	: DEFAULT_PORT;
+ 
+// tslint:disable:no-floating-promises
+(async(): Promise<void> => {
+	console.log('Booting PSQL database');
+ 
+	await seq.authenticate();
+ 
+	console.log('Resetting Database');
+ 
+	await seq.sync({
+		force: true
+	});
+ 
+	const admin: UserGroup = new UserGroup({
+		name: 'admin',
+		canCreateUsers: true,
+		canDeleteUsers: true,
+		canEditUsers: true,
+		canCreateProjects: true,
+		canDeleteProjects: true,
+		canEditProjects: true,
+		isInternal: false,
+		description: 'Systems admin'
+	});
+ 
+	// tslint:disable:no-floating-promises
+	admin.save();
+ 
+	console.log('Booting ExpressJS server');
+ 
+	app.listen(port, (err: Error) => {
+		if (err) {
+			return console.log(err);
+		} else {
+			return console.log(`server is listening on port ${port}`);
+		}
+	});
+})();
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/matcher/index.html b/coverage/project-code/src/matcher/index.html new file mode 100644 index 0000000..502c1a9 --- /dev/null +++ b/coverage/project-code/src/matcher/index.html @@ -0,0 +1,106 @@ + + + + Code coverage report for project-code/src/matcher + + + + + + + +
+
+

+ All files project-code/src/matcher +

+
+
+ 0% + Statements + 0/169 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/79 +
+
+ 0% + Lines + 0/169 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
options.unit.test.ts
0%0/69100%0/00%0/290%0/69
types.unit.test.ts
0%0/100100%0/00%0/500%0/100
+
+
+ + + + + + + diff --git a/coverage/project-code/src/matcher/options.ts.html b/coverage/project-code/src/matcher/options.ts.html new file mode 100644 index 0000000..79d0f7e --- /dev/null +++ b/coverage/project-code/src/matcher/options.ts.html @@ -0,0 +1,362 @@ + + + + Code coverage report for project-code/src/matcher/options.ts + + + + + + + +
+
+

+ All files / project-code/src/matcher options.ts +

+
+
+ 63.04% + Statements + 29/46 +
+
+ 46.67% + Branches + 14/30 +
+
+ 77.78% + Functions + 7/9 +
+
+ 65.91% + Lines + 29/44 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +1001x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +35x +12x +23x +13x +10x +  +10x +10x +  +14x +14x +  +  +  +  +  +  +  +1x +22x +1x +  +21x +  +  +  +1x +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +11x +11x +  +  +  +  +  +1x +3x +3x +  +  +  +  +  +  +  +  +  +1x +14x +14x +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +1x + 
import { Atom, default as types } from './types';
+ 
+type Checker = ((value: Value | undefined) => boolean);
+ 
+export type TemplateValue =
+	Atom | Template | Checker;
+ 
+export interface Template {
+	[key: string]: TemplateValue | undefined;
+}
+ 
+export type Value =
+	{ [key: string]: Value | undefined } | Atom;
+ 
+const matchNoCurry:
+	(template: TemplateValue, value: Value | undefined) => boolean =
+	(template: TemplateValue, value: Value | undefined): boolean => {
+	if (types.atom(template)) {
+		return template === value;
+	} else if (types.function(template)) {
+		return template(value);
+	} else Iif (types.atom(value) || value === undefined) {
+		return false;
+	} else Eif (types.object(template)) {
+		return Object.keys(template)
+			.every((key: string): boolean => {
+				const v: Value | undefined = value[key];
+				return matchNoCurry(template[key] as TemplateValue, v);
+			});
+	} else {
+		throw new Error(`Unknown template value: ${template}`);
+	}
+};
+ 
+// tslint:disable-next-line:typedef
+export const match = (template: TemplateValue, value?: Value) => {
+	if (value === undefined) {
+		return matchNoCurry.bind(null, template);
+	}
+	return matchNoCurry(template, value);
+};
+ 
+// tslint:disable-next-line:typedef
+export const exact = (template: Template, value?: Value) => {
+	Eif (value === undefined) {
+		return exact.bind(null, template);
+	}
+	if (!match(template, value)) {
+		return false;
+	}
+	if (!types.atom(value)) {
+		const k1: string[] = Object.keys(template);
+		const k2: string[] = Object.keys(value);
+		return k2.every((x: string) => k1.indexOf(x) < 0);
+	} else {
+		return true;
+	}
+};
+ 
+// tslint:disable-next-line:typedef
+export const optional = (template: TemplateValue, value?: Value) => {
+	Eif (value === undefined) {
+		return optional.bind(null, template);
+	}
+	return types.undefined(value) || match(template, value);
+};
+ 
+// tslint:disable-next-line:typedef
+export const alternative = (templates: TemplateValue[], value?: Value) => {
+	Eif (value === undefined) {
+		return alternative.bind(null, templates);
+	}
+	if (templates.length === 0) {
+		return false;
+	} else {
+		return templates.some((t: TemplateValue): boolean => match(t, value));
+	}
+};
+ 
+// tslint:disable-next-line:typedef
+export const array = (template: TemplateValue, values?: Value[]) => {
+	Eif (values === undefined) {
+		return array.bind(null, template);
+	}
+	const m: Checker = types.function(template)
+		? template
+		: match.bind(null, template);
+	return values.every(m);
+};
+ 
+// tslint:disable-next-line:typedef
+const options = {
+	match,
+	exact,
+	optional,
+	alternative,
+	array
+};
+export default options;
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/matcher/options.unit.test.ts.html b/coverage/project-code/src/matcher/options.unit.test.ts.html new file mode 100644 index 0000000..f629ef7 --- /dev/null +++ b/coverage/project-code/src/matcher/options.unit.test.ts.html @@ -0,0 +1,554 @@ + + + + Code coverage report for project-code/src/matcher/options.unit.test.ts + + + + + + + +
+
+

+ All files / project-code/src/matcher options.unit.test.ts +

+
+
+ 0% + Statements + 0/69 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/29 +
+
+ 0% + Lines + 0/69 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
/* tslint:disable:typedef */
+// Disabled to allow quick template creation.
+ 
+/* tslint:disable:newline-per-chained-call */
+// Disabled to allow Chai- and Mocha-style test formatting.
+ 
+/* tslint:disable:no-unused-expression */
+// Disabled to allow `...to.be.true`.
+ 
+import * as chai from 'chai';
+chai.should();
+ 
+import * as options from './options';
+import { default as types } from './types';
+ 
+// tslint:disable-next-line:no-require-imports
+ 
+describe('Matching:', () => {
+	describe('Rough Matching', () => {
+		context('for literals', () => {
+			context('accepts matching', () => {
+				it('strings', () => {
+					options.match('a', 'a').should.be.true;
+				});
+				it('numbers', () => {
+					options.match(3, 3).should.be.true;
+				});
+				it('boolean values', () => {
+					options.match(true, true).should.be.true;
+				});
+				it('null to null', () => {
+					options.match(null, null).should.be.true;
+				});
+			});
+			context('rejects', () => {
+				it('different strings', () => {
+					options.match('x', 'y').should.be.false;
+				});
+				it('different numbers', () => {
+					options.match(20, 42).should.be.false;
+				});
+				it('different boolean values', () => {
+					options.match(true, false).should.be.false;
+				});
+				it('different types', () => {
+					options.match('55', 55).should.be.false;
+				});
+				it('null matched with non-null values', () => {
+					options.match(null, false).should.be.false;
+				});
+				it('non-null values matched with null', () => {
+					options.match(0, null).should.be.false;
+				});
+			});
+		});
+		context('for checker functions', () => {
+			context('accepts', () => {
+				it('values that succeed the checker function', () => {
+					options.match(types.number, 9).should.be.true;
+				});
+			});
+			context('rejects', () => {
+				it('values that do not succeed the checker function', () => {
+					options.match(types.boolean, 'true').should.be.false;
+				});
+			});
+		});
+		it('accepts basic things', () => {
+			const template = {
+				a: types.string
+			};
+			const matchee = {
+				a: 'yes'
+			};
+			options.match(template, matchee).should.be.true;
+		});
+		it('accepts objects with superfluous properties', () => {
+			const template = {
+				a: types.number
+			};
+			const matchee = {
+				a: 40,
+				b: 20
+			};
+			options.match(template, matchee).should.be.true;
+		});
+		it('rejects objects missing some properties', () => {
+			const template = {
+				a: types.boolean,
+				b: types.number,
+				c: types.number
+			};
+			const matchee = {
+				b: 5
+			};
+			options.match(template, matchee).should.be.false;
+		});
+		it('accepts objects that omit not_present properties', () => {
+			const template = {
+				a: types.number,
+				b: types.not_present,
+				c: types.not_present
+			};
+			const matchee = {
+				a: 4
+			};
+			options.match(template, matchee).should.be.true;
+		});
+		it('rejects empty objects for non-empty templates', () => {
+			const template = {
+				a: types.boolean
+			};
+			const matchee = {
+			};
+			options.match(template, matchee).should.be.false;
+		});
+		it('accepts empty objects for empty templates', () => {
+			const template = {
+			};
+			const matchee = {
+			};
+			options.match(template, matchee).should.be.true;
+		});
+		it('accepts nested objects that match', () => {
+			const template = {
+				a: types.number,
+				b: {
+					ba: types.string,
+					bb: types.string
+				},
+				c: types.boolean
+			};
+			const matchee = {
+				a: 432,
+				b: {
+					ba: 'baracus',
+					bb: 'ATEAM'
+				},
+				c: true,
+				x: false
+			};
+			options.match(template, matchee).should.be.true;
+		});
+		it('accepts literal matches', () => {
+			const template = {
+				a: 'literal'
+			};
+			const matchee = {
+				a: 'literal'
+			};
+			options.match(template, matchee).should.be.true;
+		});
+		it('rejects incorrect literal matches', () => {
+			const template = {
+				g: 99
+			};
+			const matchee = {
+				g: 80
+			};
+			options.match(template, matchee).should.be.false;
+		});
+	});
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/matcher/types.ts.html b/coverage/project-code/src/matcher/types.ts.html new file mode 100644 index 0000000..cbe10a0 --- /dev/null +++ b/coverage/project-code/src/matcher/types.ts.html @@ -0,0 +1,302 @@ + + + + Code coverage report for project-code/src/matcher/types.ts + + + + + + + +
+
+

+ All files / project-code/src/matcher types.ts +

+
+
+ 100% + Statements + 22/22 +
+
+ 100% + Branches + 8/8 +
+
+ 100% + Functions + 7/7 +
+
+ 100% + Lines + 22/22 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80  +  +  +  +  +  +  +1x +6x +213x +6x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +  +  +1x +45x +  +1x +9x +  +1x +6x +  +1x +5x +  +1x +  +45x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x + 
/* tslint:disable:no-any */
+ 
+type Checker<T = any> = (v: any) => v is T;
+ 
+export type Atom = Number | String | Boolean | null;
+ 
+const typeCheckerGenerator: <T>(test: T) => Checker<T> =
+	<T>(test: T): Checker<T> => {
+	const f: Checker<T> = (value: any): value is T =>
+		value != null && value.constructor === test.constructor;
+	return f;
+};
+ 
+export const isObject: Checker<Object> =
+	typeCheckerGenerator<Object>({});
+ 
+export const isNumber: Checker<Number> =
+	typeCheckerGenerator<Number>(0);
+ 
+export const isString: Checker<String> =
+	typeCheckerGenerator<String>('');
+ 
+export const isBoolean: Checker<Boolean> =
+	typeCheckerGenerator<Boolean>(true);
+ 
+export const isArray: Checker<any[]> =
+	typeCheckerGenerator<any[]>([]);
+ 
+export const isFunction: Checker<Function> =
+	typeCheckerGenerator<Function>(new Function());
+ 
+export const isNull: Checker<null> =
+	(v: any): v is null => v === null;
+ 
+export const isUndefined: Checker<undefined> =
+	(v: any): v is undefined => v === undefined;
+ 
+export const isPresent: (v: any) => boolean =
+	(v: any): boolean => !isUndefined(v);
+ 
+export const isInteger: Checker<Number> =
+	(v: any): v is Number => isNumber(v) && Number.isInteger(v as number);
+ 
+export const isAtom: Checker<Atom> =
+	(v: any): v is Atom =>
+		isNull(v) || isNumber(v) || isString(v) || isBoolean(v);
+ 
+const types: {
+	object: Checker<Object>;
+	number: Checker<Number>;
+	string: Checker<String>;
+	boolean: Checker<Boolean>;
+	array: Checker<any[]>;
+	function: Checker<Function>;
+	integer: Checker<Number>;
+	null: Checker<null>;
+	present: (v: any) => boolean;
+	is_present: (v: any) => boolean;
+	not_present: Checker<undefined>;
+	undefined: Checker<undefined>;
+	anything: (v: any) => boolean;
+	atom: Checker<Atom>;
+} = {
+	object:      isObject,
+	number:      isNumber,
+	string:      isString,
+	boolean:     isBoolean,
+	array:       isArray,
+	function:    isFunction,
+	integer:     isInteger,
+	null:        isNull,
+	present:     isPresent,
+	is_present:  isPresent,
+	not_present: isUndefined,
+	undefined:   isUndefined,
+	anything:    isPresent,
+	atom:        isAtom
+};
+export default types;
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/matcher/types.unit.test.ts.html b/coverage/project-code/src/matcher/types.unit.test.ts.html new file mode 100644 index 0000000..4c4ac53 --- /dev/null +++ b/coverage/project-code/src/matcher/types.unit.test.ts.html @@ -0,0 +1,599 @@ + + + + Code coverage report for project-code/src/matcher/types.unit.test.ts + + + + + + + +
+
+

+ All files / project-code/src/matcher types.unit.test.ts +

+
+
+ 0% + Statements + 0/100 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/50 +
+
+ 0% + Lines + 0/100 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
/* tslint:disable:no-unused-expression */
+// Disabled to allow `...to.be.true`.
+ 
+import * as chai from 'chai';
+chai.should();
+ 
+import { default as types } from './types';
+ 
+describe('Type Checking:', () => {
+  for (const x of [
+	{ name: 'Object',  func: types.object  },
+	{ name: 'Number',  func: types.number  },
+	{ name: 'Integer', func: types.integer },
+	{ name: 'String',  func: types.string  },
+	{ name: 'Boolean', func: types.boolean },
+	{ name: 'Array',   func: types.array   }
+  ]) {
+	describe(`${x.name} Checking`, () => {
+  	it('rejects null', () => {
+		x.func(null).should.be.false;
+		});
+		 it('rejects undefined', () => {
+		x.func(undefined).should.be.false;
+		});
+	});
+  }
+ 
+  describe('Presence Checking', () => {
+	it('accepts non-undefined values', () => {
+		types.anything(1).should.be.true;
+		types.anything('string').should.be.true;
+		types.anything(false).should.be.true;
+	});
+	it('accepts null', () => {
+		types.anything(null).should.be.true;
+	});
+	it('rejects undefined', () => {
+		types.anything(undefined).should.be.false;
+	});
+	it('rejects objects without the named property', () => {
+		const x: { [key: string]: number } = {};
+		/* There's no way to pick a key that definitely won't be
+		/* on the object */
+		types.anything(x["hopefully this isn't a property"])
+		.should.be.false;
+	});
+  });
+ 
+  describe('Absence Checking', () => {
+	it('accepts undefined', () => {
+		types.not_present(undefined).should.be.true;
+	});
+  });
+ 
+  describe('Number Checking', () => {
+	it('accepts positive integers', () => {
+		types.number(4).should.be.true;
+	});
+	it('accepts negative integers', () => {
+		types.number(-10).should.be.true;
+	});
+	it('accepts floats', () => {
+		types.number(3.14).should.be.true;
+	});
+	it('accepts zero', () => {
+		types.number(0).should.be.true;
+	});
+	it('accepts boxed numbers', () => {
+		// tslint:disable-next-line:no-construct
+		types.number(new Number(20)).should.be.true;
+	});
+	it('rejects strings', () => {
+		types.number('haha').should.be.false;
+	});
+	it('rejects objects', () => {
+		types.number(new Object()).should.be.false;
+	});
+	it('rejects arrays', () => {
+		types.number([1, 2, 3]).should.be.false;
+	});
+	it('rejects things that look like numbers', () => {
+		types.number('1234').should.be.false;
+		types.number('-3.14').should.be.false;
+	});
+	it('accepts NaN', () => {
+		types.number(NaN).should.be.true;
+	});
+	it('accepts Infinity', () => {
+		types.number(Infinity).should.be.true;
+	});
+  });
+ 
+  describe('Integer Checking', () => {
+	it('rejects non-integer numbers', () => {
+		types.integer(3.14).should.be.false;
+	});
+	it('rejects NaN', () => {
+		types.integer(NaN).should.be.false;
+	});
+	it('rejects Infinity', () => {
+		types.integer(Infinity).should.be.false;
+	});
+  });
+ 
+  describe('String Checking', () => {
+	it('accepts basic primitive strings', () => {
+		types.string('string!').should.be.true;
+	});
+	it('accepts strings of numbers', () => {
+		types.string('1234').should.be.true;
+	});
+	it('accepts the empty string', () => {
+		types.string('').should.be.true;
+	});
+	it('accepts non-primitive string objects', () => {
+		// tslint:disable-next-line:no-construct
+		types.string(new String('String!')).should.be.true;
+	});
+	it('rejects numbers', () => {
+		types.string(5).should.be.false;
+		// tslint:disable-next-line:no-construct
+		types.string(new Number(28)).should.be.false;
+	});
+	it('rejects objects', () => {
+		types.string(new Object()).should.be.false;
+	});
+	it('rejects arrays', () => {
+		types.string(['ah', 'ha']).should.be.false;
+	});
+  });
+ 
+  describe('Boolean Checking', () => {
+	it('accepts true and false', () => {
+		types.boolean(true).should.be.true;
+		types.boolean(false).should.be.true;
+	});
+	it('rejects numbers', () => {
+		types.boolean(2).should.be.false;
+	});
+	it('rejects strings', () => {
+		types.boolean('not boolean').should.be.false;
+	});
+	it('rejects strings of boolean values', () => {
+		types.boolean('true').should.be.false;
+	});
+	it('rejects objects', () => {
+		types.boolean(new Object()).should.be.false;
+	});
+	it('rejects arrays', () => {
+		types.boolean([true, true, false]).should.be.false;
+	});
+	it('rejects falsy values', () => {
+		types.boolean(0).should.be.false;
+	});
+  });
+ 
+  describe('Array Checking', () => {
+	it('accepts arrays', () => {
+		types.array([1, 'two', false]).should.be.true;
+	});
+	it('accepts empty arrays', () => {
+		types.array([]).should.be.true;
+		types.array(new Array()).should.be.true;
+	});
+	it('rejects strings', () => {
+		types.array('not an array').should.be.false;
+	});
+	it('rejects strings that look like arrays', () => {
+		types.array('[1, 2, false]').should.be.false;
+	});
+	it('rejects numbers', () => {
+		types.array(8).should.be.false;
+	});
+	it('rejects objects', () => {
+		types.array(new Object()).should.be.false;
+	});
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/src/serverConfig.ts.html b/coverage/project-code/src/serverConfig.ts.html new file mode 100644 index 0000000..16b59f6 --- /dev/null +++ b/coverage/project-code/src/serverConfig.ts.html @@ -0,0 +1,473 @@ + + + + Code coverage report for project-code/src/serverConfig.ts + + + + + + + +
+
+

+ All files / project-code/src serverConfig.ts +

+
+
+ 66.67% + Statements + 12/18 +
+
+ 0% + Branches + 0/2 +
+
+ 50% + Functions + 1/2 +
+
+ 66.67% + Lines + 12/18 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +1371x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +2x +2x +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +1x + 
const serverConfig: Property[] = [];
+ 
+/**
+ * A way to display user-configurable properties.
+ */
+class PropertyDisplay {
+	/**
+	 * The category the property belongs to.
+	 */
+	public category: string;
+ 
+	/**
+	 * The group the property belongs to.
+	 */
+	public group: string;
+ 
+	/**
+	 * The name for the property to display to a user.
+	 */
+	public displayName: string;
+ 
+	/**
+	 * The description of the property.
+	 */
+	public description: string;
+ 
+	/**
+	 * Constructs a [[PropertyDisplay]] using its properties.
+	 *
+	 * @param cat	The property's category.
+	 * @param grp	The property's group.
+	 * @param dn	 The property's displayable name.
+	 * @param desc A description of the property.
+	 */
+	public constructor(cat: string, grp: string, dn: string, desc: string) {
+		this.category = cat;
+		this.group = grp;
+		this.displayName = dn;
+		this.description = desc;
+	}
+}
+ 
+/**
+ * A server property that infuences the running of the server.
+ * Loaded from configs at launch, and possibly editable during run-time.
+ */
+export interface Property {
+	/**
+	 * The property's unique ID.
+	 */
+	id: string;
+ 
+	/**
+	 * How to display the property to the user.
+	 */
+	display?: PropertyDisplay;
+ 
+	/**
+	 * Is the property read-only, or can it be edited at run-time?
+	 */
+	readOnly: boolean;
+ 
+	/**
+	 * The variable type of the property.
+	 *
+	 * These strings represent Javascript types directly,
+	 * except `"integer"`, which is a `number` in logic.
+	 */
+	type: 'string' | 'number' | 'integer' | 'boolean';
+ 
+	/**
+	 * The value of the property.
+	 */
+	value: string | number | boolean;
+}
+ 
+// Logging
+let propertyDisplay: PropertyDisplay = new PropertyDisplay(
+	'Logging',
+	'BE4',
+	'Is logging enabled?',
+	'This property defines if logging is currently enabled on this backend server.'
+);
+ 
+serverConfig.push({
+	id: 'Server_Log',
+	display: propertyDisplay,
+	readOnly: false,
+	type: 'boolean',
+	value: false
+});
+ 
+// Caching Settings (global)
+serverConfig.push({
+	id: 'Global_Cache_Limit',
+	readOnly: true,
+	type: 'integer',
+	value: 1
+});
+ 
+// Caching Settings (project level)
+propertyDisplay = new PropertyDisplay(
+	'Caching',
+	'BE4',
+	'Caching Type',
+	'This property defines the current caching style for this project.'
+);
+ 
+serverConfig.push({
+	id: 'project_example',
+	display: propertyDisplay,
+	readOnly: false,
+	type: 'integer',
+	value: 1
+});
+ 
+/**
+ * Checks if a property exists in the server's property list.
+ *
+ * @param propKey The property unique ID to search for.
+ * @returns The index of the property in the server's property list,
+ * or `-1` if the property is not present.
+ */
+export const propertyExists: (propKey: string) => number =
+	(propKey: string): number => {
+	let found: number = -1;
+	for (const prop in serverConfig) {
+		if (serverConfig[prop].id === propKey) {
+			found = parseInt(prop, 10);
+			break;
+		}
+	}
+	return found;
+};
+ 
+export default serverConfig;
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/test/hm.test.ts.html b/coverage/project-code/test/hm.test.ts.html new file mode 100644 index 0000000..a04b028 --- /dev/null +++ b/coverage/project-code/test/hm.test.ts.html @@ -0,0 +1,113 @@ + + + + Code coverage report for project-code/test/hm.test.ts + + + + + + + +
+
+

+ All files / project-code/test hm.test.ts +

+
+
+ 0% + Statements + 0/3 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/2 +
+
+ 0% + Lines + 0/3 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
/* tslint:disable:newline-per-chained-call */
+/* Chai assertions look silly when formatted multiline. */
+/* tslint:disable:no-unused-expression */
+/* Chai assertions do not require assignation. */
+ 
+import { expect } from 'chai';
+ 
+// Mocha has to be imported as a side-effect library.
+// tslint:disable-next-line:no-import-side-effect
+import 'mocha';
+ 
+describe('placeholder test', () => {
+	it('should pass', () => {
+		expect(true).to.be.true;
+	});
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/project-code/test/index.html b/coverage/project-code/test/index.html new file mode 100644 index 0000000..71ab3dc --- /dev/null +++ b/coverage/project-code/test/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for project-code/test + + + + + + + +
+
+

+ All files project-code/test +

+
+
+ 0% + Statements + 0/3 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/2 +
+
+ 0% + Lines + 0/3 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
hm.test.ts
0%0/3100%0/00%0/20%0/3
+
+
+ + + + + + + diff --git a/coverage/project-code/test/protocol.node.test.ts.html b/coverage/project-code/test/protocol.node.test.ts.html new file mode 100644 index 0000000..7b110c9 --- /dev/null +++ b/coverage/project-code/test/protocol.node.test.ts.html @@ -0,0 +1,746 @@ + + + + Code coverage report for project-code/test/protocol.node.test.ts + + + + + + + +
+
+

+ All files / project-code/test protocol.node.test.ts +

+
+
+ 89.74% + Statements + 35/39 +
+
+ 90% + Branches + 9/10 +
+
+ 76.47% + Functions + 13/17 +
+
+ 89.74% + Lines + 35/39 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228  +  +  +  +  +1x +1x +  +  +  +1x +  +  +  +1x +  +  +  +1x +  +1x +  +1x +  +1x +1x +  +  +1x +  +  +  +  +  +  +  +  +1x +1x +1x +  +1x +  +  +  +1x +1x +  +1x +  +  +1x +1x +  +1x +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +  +  +20x +  +  +20x +  +  +  +1x +  +  +20x +  +  +20x +  +  +  +1x +  +  +20x +  +  +20x +  +  +  +1x +  +  +1x +1x +  +  +  +  +  +  +  + 
/* tslint:disable:newline-per-chained-call */
+/* Chai assertions look silly when formatted multiline. */
+/* tslint:disable:no-unused-expression */
+/* Chai assertions do not require assignation. */
+ 
+import * as chai from 'chai';
+const expect: Chai.ExpectStatic = chai.expect;
+ 
+// Chai-http must be imported this way:
+// tslint:disable-next-line:no-var-requires no-require-imports
+chai.use(require('chai-http'));
+ 
+// Mocha must be imported as a side-effect library:
+// tslint:disable-next-line:no-import-side-effect
+import 'mocha';
+ 
+// Mocha-each must be imported using a require call:
+// tslint:disable-next-line:no-require-imports
+import forEach = require('mocha-each');
+ 
+import { Template, alternative, array, exact, match, optional
+	} from '../src/matcher/options';
+import { default as types } from '../src/matcher/types';
+ 
+import * as App from '../src/app';
+let app = App.TestApp();
+ 
+ 
+const responseTemplate: Template = {
+	status: types.string,
+	data: optional(types.anything),
+	error: optional(types.string),
+	error_description: optional(types.string),
+	user_message: optional(types.string),
+	error_data: optional(types.anything)
+};
+ 
+describe('baseRoute', () => {
+	it('should be json', () => {
+		return chai.request(app).get('/')
+		.then((res: ChaiHttp.Response) => {
+			expect(res.type).to.eql('application/json');
+		});
+	});
+ 
+	it('should have a message prop', () => {
+		return chai.request(app).get('/')
+		.then((res: ChaiHttp.Response) => {
+			expect(res.body.message).to.eql('Welcome to the CS3099 BE4 server!');
+		});
+	});
+	it('should have an important prop', () => {
+		return chai.request(app).get('/')
+		.then((res: ChaiHttp.Response) => {
+			expect(res.body.important).to.eql('Endpoints start from /cs3099group-be-4/');
+		});
+	});
+ 
+});
+ 
+type MochaForEachInput = [ string, string, Template ];
+ 
+describe('General protocol', () => {
+	const completeProtocol: MochaForEachInput[] = [
+		['get', '/_supported_protocols_', exact({
+				supported: array(types.string),
+				required: array(types.string)
+		})],
+		['get', '/log', types.array({
+			component: types.string,
+			level: alternative([
+				'info',
+				'security',
+				'warning',
+				'error',
+				'critical'
+			]),
+			value: types.anything,
+			username: types.string,
+			timestamp: types.string
+		})],
+		['post', '/log', null],
+		['get', '/properties', types.array({
+			id: types.string,
+			display: optional(match({
+				category: types.string,
+				group: types.string,
+				display_name: types.string,
+				description: types.string
+			})),
+			read_only: types.boolean,
+			type: alternative([
+				'string',
+				'integer',
+				'boolean'
+			]),
+			value: alternative([
+				types.string,
+				types.integer,
+				types.boolean
+			])
+		})],
+		['post', '/properties', null],
+		['get', '/user_privileges', array({
+			privilege: types.string,
+			description: types.string,
+			internal: types.boolean
+		})],
+		['get', '/users', array({
+			username: types.string,
+			privileges: array(types.string),
+			projects: array({
+				project_name: types.string,
+				access_level: types.string
+			}),
+			public_user_metadata: types.anything,
+			private_user_metadata: types.anything,
+			public_admin_metadata: types.anything,
+			private_admin_metadata: types.anything
+		})],
+		// TODO types.metadata
+		['get', '/users/:username', {
+			username: types.string,
+			privileges: array(types.string),
+			projects: array({
+				project_name: types.string,
+				access_level: types.string
+			}),
+			public_user_metadata: types.anything,
+			private_user_metadata: types.anything,
+			public_admin_metadata: types.anything,
+			private_admin_metadata: types.anything
+		}],
+		['post', '/users/:username', null],
+		['get', '/users/:username/properties', {
+			data: optional(types.anything)
+		}],
+		['get', '/current_user', {
+			username: types.string,
+			privileges: array(types.string),
+			projects: array({
+				project_name: types.string,
+				access_level: types.string
+			}),
+			public_user_metadata: types.anything,
+			private_user_metadata: types.anything,
+			public_admin_metadata: types.anything,
+			private_admin_metadata: types.anything
+		}],
+		['post', '/current_user', null],
+		['get', '/project_roles', array({
+			role: types.string,
+			description: types.string,
+			internal: types.boolean
+		})],
+		['get', '/projects', array({
+			project_name: types.string,
+			users: array({
+				username: types.string,
+				access_level: types.string
+			}),
+			public_metadata: types.anything,
+			private_metadata: optional(types.anything),
+			admin_metadata: optional(types.anything)
+		})],
+		['get', '/projects/:project_name', {
+			project_name: types.string,
+			users: array({
+				username: types.string,
+				access_level: types.string
+			}),
+			public_metadata: types.anything,
+			private_metadata: types.anything,
+			admin_metadata: optional(types.anything)
+		}],
+		['post', '/projects/:project_name', null],
+		['get', '/projects/:project_name/properties', {
+			data: optional(types.anything)
+		}],
+		['get', '/projects/:project_name/files/:path', null],
+		['post', '/projects/:project_name/files/:id', null],
+		['get', '/projects/:project_name/files_by_id/:id', null]
+	];
+ 
+	describe('Checking complete Protocol', () => {
+		forEach(completeProtocol).it(
+			'%s %s should be json',
+			(method: string, path: string, temp: Template) => {
+			const request: ChaiHttp.Request = method === 'get'
+				? chai.request(app).get(path)
+				: chai.request(app).post(path);
+			request.then((res: ChaiHttp.Response) => {
+				expect(res.type).to.equal('application/json');
+			});
+		});
+		forEach(completeProtocol).it(
+			'%s %s should have a status 200',
+			(method: string, path: string, temp: Template) => {
+			const request: ChaiHttp.Request = method === 'get'
+				? chai.request(app).get(path)
+				: chai.request(app).post(path);
+			request.then((res: ChaiHttp.Response) => {
+				expect(res).to.have.status(200);
+			});
+		});
+		forEach(completeProtocol).it(
+			'%s %s should conform to standard protocol',
+			(method: string, path: string, temp: Template) => {
+			const request: ChaiHttp.Request = method === 'get'
+				? chai.request(app).get(path)
+				: chai.request(app).post(path);
+			request.then((res: ChaiHttp.Response) => {
+				match(responseTemplate, JSON.parse(res.body)).shoul.be.true;
+			});
+		});
+		forEach(completeProtocol).it(
+			'the response for %s %s should comply with its own protocol',
+			(method: string, path: string, temp: Template) => {
+			Eif (method === 'get' && temp != null) {
+				return chai.request(app).get(path)
+				.then((res: ChaiHttp.Response) => {
+					match(temp)(JSON.parse(res.body)).should.be.true;
+				});
+			}
+		});
+	});
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/sort-arrow-sprite.png b/coverage/sort-arrow-sprite.png new file mode 100644 index 0000000..03f704a Binary files /dev/null and b/coverage/sort-arrow-sprite.png differ diff --git a/coverage/sorter.js b/coverage/sorter.js new file mode 100644 index 0000000..6c5034e --- /dev/null +++ b/coverage/sorter.js @@ -0,0 +1,158 @@ +var addSorting = (function () { + "use strict"; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { return document.querySelector('.coverage-summary'); } + // returns the thead element of the summary table + function getTableHeader() { return getTable().querySelector('thead tr'); } + // returns the tbody element of the summary table + function getTableBody() { return getTable().querySelector('tbody'); } + // returns the th element for nth column + function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function (a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function (a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i =0 ; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(cols); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/getmeyarn.sh b/getmeyarn.sh new file mode 100755 index 0000000..6f8e5c0 --- /dev/null +++ b/getmeyarn.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +### +### Source: https://hackernoon.com/how-to-use-yarn-in-a-project-without-installing-yarn-f946815ddb4e +### + +# Choose which version of yarn you want to use +EXPECTED_YARN_VERSION="0.16.1" + +function install_yarn { + mkdir -p ~/.yarn + DOWNLOAD_URL="https://github.com/yarnpkg/yarn/releases/download/v$EXPECTED_YARN_VERSION/yarn-v$EXPECTED_YARN_VERSION.tar.gz" + echo "Downloading from $DOWNLOAD_URL" + curl -fL $DOWNLOAD_URL > ~/.yarn/yarn.tar.gz + tar zxf ~/.yarn/yarn.tar.gz --strip-components=1 -C ~/.yarn +} + +if [ -f ~/.yarn/bin/yarn ]; then + YARN_VERSION=$(node -e 'const fs = require("fs"); console.log(JSON.parse(fs.readFileSync(".yarn/package.json")).version);') + if [ "$YARN_VERSION" != "$EXPECTED_YARN_VERSION" ]; then + echo "The yarn version is $YARN_VERSION, expected $EXPECTED_YARN_VERSION. Re-downloading" + rm -rf ~/.yarn + install_yarn + fi +else + echo "The file .yarn/bin/yarn does not exist, installing yarn". + install_yarn +fi + +alias yarn="~/.yarn/bin/yarn" diff --git a/package.json b/package.json index 15615c0..ccdf7ad 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "main": "index.ts", "license": "UNLICENSED", "scripts": { - "test": "mocha --reporter spec -r ts-node/register './**/*.test.ts'", - "test_unit": "mocha --reporter spec -r ts-node/register './**/*.unit.test.ts'", - "test_node": "mocha --reporter spec -r ts-node/register './**/*.node.test.ts'", + "test": "mocha --reporter spec -r ts-node/register './test/**/*.test.ts'", + "test_routes": "mocha --reporter spec -r ts-node/register './test/**/*.routes.test.ts'", + "test_unit": "mocha --reporter spec -r ts-node/register './test/**/*.unit.test.ts'", "docs": "typedoc --out 'docs' --readme 'README.md' --name 'St Andrews Junior Honours 2017/18 - Team BE4' --module commonjs --target ES5 --exclude '*.test.ts' --includeDeclarations --excludeExternals 'src'", "start": "ts-node src/index.ts", "lint": "tslint --fix --force -p './tsconfig.json'", diff --git a/src/matcher/options.unit.test.ts b/src/matcher/options.unit.test.ts deleted file mode 100644 index ff5763e..0000000 --- a/src/matcher/options.unit.test.ts +++ /dev/null @@ -1,163 +0,0 @@ -/* tslint:disable:typedef */ -// Disabled to allow quick template creation. - -/* tslint:disable:newline-per-chained-call */ -// Disabled to allow Chai- and Mocha-style test formatting. - -/* tslint:disable:no-unused-expression */ -// Disabled to allow `...to.be.true`. - -import * as chai from 'chai'; -chai.should(); - -import * as options from './options'; -import { default as types } from './types'; - -// tslint:disable-next-line:no-require-imports - -describe('Matching:', () => { - describe('Rough Matching', () => { - context('for literals', () => { - context('accepts matching', () => { - it('strings', () => { - options.match('a', 'a').should.be.true; - }); - it('numbers', () => { - options.match(3, 3).should.be.true; - }); - it('boolean values', () => { - options.match(true, true).should.be.true; - }); - it('null to null', () => { - options.match(null, null).should.be.true; - }); - }); - context('rejects', () => { - it('different strings', () => { - options.match('x', 'y').should.be.false; - }); - it('different numbers', () => { - options.match(20, 42).should.be.false; - }); - it('different boolean values', () => { - options.match(true, false).should.be.false; - }); - it('different types', () => { - options.match('55', 55).should.be.false; - }); - it('null matched with non-null values', () => { - options.match(null, false).should.be.false; - }); - it('non-null values matched with null', () => { - options.match(0, null).should.be.false; - }); - }); - }); - context('for checker functions', () => { - context('accepts', () => { - it('values that succeed the checker function', () => { - options.match(types.number, 9).should.be.true; - }); - }); - context('rejects', () => { - it('values that do not succeed the checker function', () => { - options.match(types.boolean, 'true').should.be.false; - }); - }); - }); - it('accepts basic things', () => { - const template = { - a: types.string - }; - const matchee = { - a: 'yes' - }; - options.match(template, matchee).should.be.true; - }); - it('accepts objects with superfluous properties', () => { - const template = { - a: types.number - }; - const matchee = { - a: 40, - b: 20 - }; - options.match(template, matchee).should.be.true; - }); - it('rejects objects missing some properties', () => { - const template = { - a: types.boolean, - b: types.number, - c: types.number - }; - const matchee = { - b: 5 - }; - options.match(template, matchee).should.be.false; - }); - it('accepts objects that omit not_present properties', () => { - const template = { - a: types.number, - b: types.not_present, - c: types.not_present - }; - const matchee = { - a: 4 - }; - options.match(template, matchee).should.be.true; - }); - it('rejects empty objects for non-empty templates', () => { - const template = { - a: types.boolean - }; - const matchee = { - }; - options.match(template, matchee).should.be.false; - }); - it('accepts empty objects for empty templates', () => { - const template = { - }; - const matchee = { - }; - options.match(template, matchee).should.be.true; - }); - it('accepts nested objects that match', () => { - const template = { - a: types.number, - b: { - ba: types.string, - bb: types.string - }, - c: types.boolean - }; - const matchee = { - a: 432, - b: { - ba: 'baracus', - bb: 'ATEAM' - }, - c: true, - x: false - }; - options.match(template, matchee).should.be.true; - }); - it('accepts literal matches', () => { - const template = { - a: 'literal' - }; - const matchee = { - a: 'literal' - }; - options.match(template, matchee).should.be.true; - }); - it('rejects incorrect literal matches', () => { - const template = { - g: 99 - }; - const matchee = { - g: 80 - }; - options.match(template, matchee).should.be.false; - }); - }); -}); diff --git a/src/matcher/types.unit.test.ts b/src/matcher/types.unit.test.ts deleted file mode 100644 index 398064c..0000000 --- a/src/matcher/types.unit.test.ts +++ /dev/null @@ -1,178 +0,0 @@ -/* tslint:disable:no-unused-expression */ -// Disabled to allow `...to.be.true`. - -import * as chai from 'chai'; -chai.should(); - -import { default as types } from './types'; - -describe('Type Checking:', () => { - for (const x of [ - { name: 'Object', func: types.object }, - { name: 'Number', func: types.number }, - { name: 'Integer', func: types.integer }, - { name: 'String', func: types.string }, - { name: 'Boolean', func: types.boolean }, - { name: 'Array', func: types.array } - ]) { - describe(`${x.name} Checking`, () => { - it('rejects null', () => { - x.func(null).should.be.false; - }); - it('rejects undefined', () => { - x.func(undefined).should.be.false; - }); - }); - } - - describe('Presence Checking', () => { - it('accepts non-undefined values', () => { - types.anything(1).should.be.true; - types.anything('string').should.be.true; - types.anything(false).should.be.true; - }); - it('accepts null', () => { - types.anything(null).should.be.true; - }); - it('rejects undefined', () => { - types.anything(undefined).should.be.false; - }); - it('rejects objects without the named property', () => { - const x: { [key: string]: number } = {}; - /* There's no way to pick a key that definitely won't be - /* on the object */ - types.anything(x["hopefully this isn't a property"]) - .should.be.false; - }); - }); - - describe('Absence Checking', () => { - it('accepts undefined', () => { - types.not_present(undefined).should.be.true; - }); - }); - - describe('Number Checking', () => { - it('accepts positive integers', () => { - types.number(4).should.be.true; - }); - it('accepts negative integers', () => { - types.number(-10).should.be.true; - }); - it('accepts floats', () => { - types.number(3.14).should.be.true; - }); - it('accepts zero', () => { - types.number(0).should.be.true; - }); - it('accepts boxed numbers', () => { - // tslint:disable-next-line:no-construct - types.number(new Number(20)).should.be.true; - }); - it('rejects strings', () => { - types.number('haha').should.be.false; - }); - it('rejects objects', () => { - types.number(new Object()).should.be.false; - }); - it('rejects arrays', () => { - types.number([1, 2, 3]).should.be.false; - }); - it('rejects things that look like numbers', () => { - types.number('1234').should.be.false; - types.number('-3.14').should.be.false; - }); - it('accepts NaN', () => { - types.number(NaN).should.be.true; - }); - it('accepts Infinity', () => { - types.number(Infinity).should.be.true; - }); - }); - - describe('Integer Checking', () => { - it('rejects non-integer numbers', () => { - types.integer(3.14).should.be.false; - }); - it('rejects NaN', () => { - types.integer(NaN).should.be.false; - }); - it('rejects Infinity', () => { - types.integer(Infinity).should.be.false; - }); - }); - - describe('String Checking', () => { - it('accepts basic primitive strings', () => { - types.string('string!').should.be.true; - }); - it('accepts strings of numbers', () => { - types.string('1234').should.be.true; - }); - it('accepts the empty string', () => { - types.string('').should.be.true; - }); - it('accepts non-primitive string objects', () => { - // tslint:disable-next-line:no-construct - types.string(new String('String!')).should.be.true; - }); - it('rejects numbers', () => { - types.string(5).should.be.false; - // tslint:disable-next-line:no-construct - types.string(new Number(28)).should.be.false; - }); - it('rejects objects', () => { - types.string(new Object()).should.be.false; - }); - it('rejects arrays', () => { - types.string(['ah', 'ha']).should.be.false; - }); - }); - - describe('Boolean Checking', () => { - it('accepts true and false', () => { - types.boolean(true).should.be.true; - types.boolean(false).should.be.true; - }); - it('rejects numbers', () => { - types.boolean(2).should.be.false; - }); - it('rejects strings', () => { - types.boolean('not boolean').should.be.false; - }); - it('rejects strings of boolean values', () => { - types.boolean('true').should.be.false; - }); - it('rejects objects', () => { - types.boolean(new Object()).should.be.false; - }); - it('rejects arrays', () => { - types.boolean([true, true, false]).should.be.false; - }); - it('rejects falsy values', () => { - types.boolean(0).should.be.false; - }); - }); - - describe('Array Checking', () => { - it('accepts arrays', () => { - types.array([1, 'two', false]).should.be.true; - }); - it('accepts empty arrays', () => { - types.array([]).should.be.true; - types.array(new Array()).should.be.true; - }); - it('rejects strings', () => { - types.array('not an array').should.be.false; - }); - it('rejects strings that look like arrays', () => { - types.array('[1, 2, false]').should.be.false; - }); - it('rejects numbers', () => { - types.array(8).should.be.false; - }); - it('rejects objects', () => { - types.array(new Object()).should.be.false; - }); - }); -}); diff --git a/test/hm.test.ts b/test/hm.test.ts deleted file mode 100644 index a6cd384..0000000 --- a/test/hm.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* tslint:disable:newline-per-chained-call */ -/* Chai assertions look silly when formatted multiline. */ -/* tslint:disable:no-unused-expression */ -/* Chai assertions do not require assignation. */ - -import { expect } from 'chai'; - -// Mocha has to be imported as a side-effect library. -// tslint:disable-next-line:no-import-side-effect -import 'mocha'; - -describe('placeholder test', () => { - it('should pass', () => { - expect(true).to.be.true; - }); -}); diff --git a/test/integration/auth.routes.test.ts b/test/integration/auth.routes.test.ts new file mode 100644 index 0000000..edfbd0a --- /dev/null +++ b/test/integration/auth.routes.test.ts @@ -0,0 +1,42 @@ +/* tslint:disable:newline-per-chained-call */ +/* Chai assertions look silly when formatted multiline. */ +/* tslint:disable:no-unused-expression */ +/* Chai assertions do not require assignation. */ + +import * as chai from 'chai'; +const expect: Chai.ExpectStatic = chai.expect; + +// Chai-http must be imported this way: +// tslint:disable-next-line:no-var-requires no-require-imports +chai.use(require('chai-http')); + +// Mocha must be imported as a side-effect library: +// tslint:disable-next-line:no-import-side-effect +import 'mocha'; + +import * as App from '../../src/app'; +let app = App.TestApp(); + +describe('baseRoute', () => { + it('should be json', () => { + return chai.request(app).get('/') + .then((res: ChaiHttp.Response) => { + expect(res.type).to.eql('application/json'); + }); + }); + + it('should have a message prop', () => { + return chai.request(app).get('/') + .then((res: ChaiHttp.Response) => { + expect(res.body.message).to.eql('Welcome to the CS3099 BE4 server!'); + }); + }); + + it('should have an important prop', () => { + return chai.request(app).get('/') + .then((res: ChaiHttp.Response) => { + expect(res.body.important).to.eql('Endpoints start from /cs3099group-be-4/'); + }); + }); + +}); \ No newline at end of file diff --git a/test/integration/index.routes.test.ts b/test/integration/index.routes.test.ts new file mode 100644 index 0000000..edfbd0a --- /dev/null +++ b/test/integration/index.routes.test.ts @@ -0,0 +1,42 @@ +/* tslint:disable:newline-per-chained-call */ +/* Chai assertions look silly when formatted multiline. */ +/* tslint:disable:no-unused-expression */ +/* Chai assertions do not require assignation. */ + +import * as chai from 'chai'; +const expect: Chai.ExpectStatic = chai.expect; + +// Chai-http must be imported this way: +// tslint:disable-next-line:no-var-requires no-require-imports +chai.use(require('chai-http')); + +// Mocha must be imported as a side-effect library: +// tslint:disable-next-line:no-import-side-effect +import 'mocha'; + +import * as App from '../../src/app'; +let app = App.TestApp(); + +describe('baseRoute', () => { + it('should be json', () => { + return chai.request(app).get('/') + .then((res: ChaiHttp.Response) => { + expect(res.type).to.eql('application/json'); + }); + }); + + it('should have a message prop', () => { + return chai.request(app).get('/') + .then((res: ChaiHttp.Response) => { + expect(res.body.message).to.eql('Welcome to the CS3099 BE4 server!'); + }); + }); + + it('should have an important prop', () => { + return chai.request(app).get('/') + .then((res: ChaiHttp.Response) => { + expect(res.body.important).to.eql('Endpoints start from /cs3099group-be-4/'); + }); + }); + +}); \ No newline at end of file diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts new file mode 100644 index 0000000..7123beb --- /dev/null +++ b/test/integration/protocol.routes.test.ts @@ -0,0 +1,204 @@ +/* tslint:disable:newline-per-chained-call */ +/* Chai assertions look silly when formatted multiline. */ +/* tslint:disable:no-unused-expression */ +/* Chai assertions do not require assignation. */ + +import * as chai from 'chai'; +const expect: Chai.ExpectStatic = chai.expect; + +// Chai-http must be imported this way: +// tslint:disable-next-line:no-var-requires no-require-imports +chai.use(require('chai-http')); + +// Mocha must be imported as a side-effect library: +// tslint:disable-next-line:no-import-side-effect +import 'mocha'; + +// Mocha-each must be imported using a require call: +// tslint:disable-next-line:no-require-imports +import forEach = require('mocha-each'); + +import { Template, alternative, array, exact, match, optional + } from '../src/matcher/options'; +import { default as types } from '../src/matcher/types'; + +import * as App from '../src/app'; +let app = App.TestApp(); + + +const responseTemplate: Template = { + status: types.string, + data: optional(types.anything), + error: optional(types.string), + error_description: optional(types.string), + user_message: optional(types.string), + error_data: optional(types.anything) +}; + +type MochaForEachInput = [ string, string, Template ]; + +describe('Protocol', () => { + const completeProtocol: MochaForEachInput[] = [ + ['get', '/_supported_protocols_', exact({ + supported: array(types.string), + required: array(types.string) + })], + ['get', '/log', types.array({ + component: types.string, + level: alternative([ + 'info', + 'security', + 'warning', + 'error', + 'critical' + ]), + value: types.anything, + username: types.string, + timestamp: types.string + })], + ['post', '/log', null], + ['get', '/properties', types.array({ + id: types.string, + display: optional(match({ + category: types.string, + group: types.string, + display_name: types.string, + description: types.string + })), + read_only: types.boolean, + type: alternative([ + 'string', + 'integer', + 'boolean' + ]), + value: alternative([ + types.string, + types.integer, + types.boolean + ]) + })], + ['post', '/properties', null], + ['get', '/user_privileges', array({ + privilege: types.string, + description: types.string, + internal: types.boolean + })], + ['get', '/users', array({ + username: types.string, + privileges: array(types.string), + projects: array({ + project_name: types.string, + access_level: types.string + }), + public_user_metadata: types.anything, + private_user_metadata: types.anything, + public_admin_metadata: types.anything, + private_admin_metadata: types.anything + })], + // TODO types.metadata + ['get', '/users/:username', { + username: types.string, + privileges: array(types.string), + projects: array({ + project_name: types.string, + access_level: types.string + }), + public_user_metadata: types.anything, + private_user_metadata: types.anything, + public_admin_metadata: types.anything, + private_admin_metadata: types.anything + }], + ['post', '/users/:username', null], + ['get', '/users/:username/properties', { + data: optional(types.anything) + }], + ['get', '/current_user', { + username: types.string, + privileges: array(types.string), + projects: array({ + project_name: types.string, + access_level: types.string + }), + public_user_metadata: types.anything, + private_user_metadata: types.anything, + public_admin_metadata: types.anything, + private_admin_metadata: types.anything + }], + ['post', '/current_user', null], + ['get', '/project_roles', array({ + role: types.string, + description: types.string, + internal: types.boolean + })], + ['get', '/projects', array({ + project_name: types.string, + users: array({ + username: types.string, + access_level: types.string + }), + public_metadata: types.anything, + private_metadata: optional(types.anything), + admin_metadata: optional(types.anything) + })], + ['get', '/projects/:project_name', { + project_name: types.string, + users: array({ + username: types.string, + access_level: types.string + }), + public_metadata: types.anything, + private_metadata: types.anything, + admin_metadata: optional(types.anything) + }], + ['post', '/projects/:project_name', null], + ['get', '/projects/:project_name/properties', { + data: optional(types.anything) + }], + ['get', '/projects/:project_name/files/:path', null], + ['post', '/projects/:project_name/files/:id', null], + ['get', '/projects/:project_name/files_by_id/:id', null] + ]; + + describe('Response specification', () => { + forEach(completeProtocol).it( + '%s %s should be json', + (method: string, path: string, temp: Template) => { + const request: ChaiHttp.Request = method === 'get' + ? chai.request(app).get(path) + : chai.request(app).post(path); + request.then((res: ChaiHttp.Response) => { + expect(res.type).to.equal('application/json'); + }); + }); + forEach(completeProtocol).it( + '%s %s should have a status 200', + (method: string, path: string, temp: Template) => { + const request: ChaiHttp.Request = method === 'get' + ? chai.request(app).get(path) + : chai.request(app).post(path); + request.then((res: ChaiHttp.Response) => { + expect(res).to.have.status(200); + }); + }); + forEach(completeProtocol).it( + '%s %s should conform to the standard response protocol', + (method: string, path: string, temp: Template) => { + const request: ChaiHttp.Request = method === 'get' + ? chai.request(app).get(path) + : chai.request(app).post(path); + request.then((res: ChaiHttp.Response) => { + match(responseTemplate, JSON.parse(res.body)).shoul.be.true; + }); + }); + forEach(completeProtocol).it( + 'the response for %s %s should conform to its specific response protocol', + (method: string, path: string, temp: Template) => { + if (method === 'get' && temp != null) { + return chai.request(app).get(path) + .then((res: ChaiHttp.Response) => { + match(temp)(JSON.parse(res.body)).should.be.true; + }); + } + }); + }); +}); diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..1782c28 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,4 @@ +--compilers ts-node/register +--require source-map-support/register +--full-trace +src/**/*.test.ts \ No newline at end of file diff --git a/test/protocol.node.test.ts b/test/protocol.node.test.ts deleted file mode 100644 index 1c89b9e..0000000 --- a/test/protocol.node.test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* tslint:disable:newline-per-chained-call */ -/* Chai assertions look silly when formatted multiline. */ -/* tslint:disable:no-unused-expression */ -/* Chai assertions do not require assignation. */ - -import * as chai from 'chai'; -const expect: Chai.ExpectStatic = chai.expect; - -// Chai-http must be imported this way: -// tslint:disable-next-line:no-var-requires no-require-imports -chai.use(require('chai-http')); - -// Mocha must be imported as a side-effect library: -// tslint:disable-next-line:no-import-side-effect -import 'mocha'; - -// Mocha-each must be imported using a require call: -// tslint:disable-next-line:no-require-imports -import forEach = require('mocha-each'); - -import { Template, alternative, array, exact, match, optional - } from '../src/matcher/options'; -import { default as types } from '../src/matcher/types'; - -import * as App from '../src/app'; -let app = App.TestApp(); - - -const responseTemplate: Template = { - status: types.string, - data: optional(types.anything), - error: optional(types.string), - error_description: optional(types.string), - user_message: optional(types.string), - error_data: optional(types.anything) -}; - -describe('baseRoute', () => { - it('should be json', () => { - return chai.request(app).get('/') - .then((res: ChaiHttp.Response) => { - expect(res.type).to.eql('application/json'); - }); - }); - - it('should have a message prop', () => { - return chai.request(app).get('/') - .then((res: ChaiHttp.Response) => { - expect(res.body.message).to.eql('Welcome to the CS3099 BE4 server!'); - }); - }); - it('should have an important prop', () => { - return chai.request(app).get('/') - .then((res: ChaiHttp.Response) => { - expect(res.body.important).to.eql('Endpoints start from /cs3099group-be-4/'); - }); - }); - -}); - -type MochaForEachInput = [ string, string, Template ]; - -describe('General protocol', () => { - const completeProtocol: MochaForEachInput[] = [ - ['get', '/_supported_protocols_', exact({ - supported: array(types.string), - required: array(types.string) - })], - ['get', '/log', types.array({ - component: types.string, - level: alternative([ - 'info', - 'security', - 'warning', - 'error', - 'critical' - ]), - value: types.anything, - username: types.string, - timestamp: types.string - })], - ['post', '/log', null], - ['get', '/properties', types.array({ - id: types.string, - display: optional(match({ - category: types.string, - group: types.string, - display_name: types.string, - description: types.string - })), - read_only: types.boolean, - type: alternative([ - 'string', - 'integer', - 'boolean' - ]), - value: alternative([ - types.string, - types.integer, - types.boolean - ]) - })], - ['post', '/properties', null], - ['get', '/user_privileges', array({ - privilege: types.string, - description: types.string, - internal: types.boolean - })], - ['get', '/users', array({ - username: types.string, - privileges: array(types.string), - projects: array({ - project_name: types.string, - access_level: types.string - }), - public_user_metadata: types.anything, - private_user_metadata: types.anything, - public_admin_metadata: types.anything, - private_admin_metadata: types.anything - })], - // TODO types.metadata - ['get', '/users/:username', { - username: types.string, - privileges: array(types.string), - projects: array({ - project_name: types.string, - access_level: types.string - }), - public_user_metadata: types.anything, - private_user_metadata: types.anything, - public_admin_metadata: types.anything, - private_admin_metadata: types.anything - }], - ['post', '/users/:username', null], - ['get', '/users/:username/properties', { - data: optional(types.anything) - }], - ['get', '/current_user', { - username: types.string, - privileges: array(types.string), - projects: array({ - project_name: types.string, - access_level: types.string - }), - public_user_metadata: types.anything, - private_user_metadata: types.anything, - public_admin_metadata: types.anything, - private_admin_metadata: types.anything - }], - ['post', '/current_user', null], - ['get', '/project_roles', array({ - role: types.string, - description: types.string, - internal: types.boolean - })], - ['get', '/projects', array({ - project_name: types.string, - users: array({ - username: types.string, - access_level: types.string - }), - public_metadata: types.anything, - private_metadata: optional(types.anything), - admin_metadata: optional(types.anything) - })], - ['get', '/projects/:project_name', { - project_name: types.string, - users: array({ - username: types.string, - access_level: types.string - }), - public_metadata: types.anything, - private_metadata: types.anything, - admin_metadata: optional(types.anything) - }], - ['post', '/projects/:project_name', null], - ['get', '/projects/:project_name/properties', { - data: optional(types.anything) - }], - ['get', '/projects/:project_name/files/:path', null], - ['post', '/projects/:project_name/files/:id', null], - ['get', '/projects/:project_name/files_by_id/:id', null] - ]; - - describe('Checking complete Protocol', () => { - forEach(completeProtocol).it( - '%s %s should be json', - (method: string, path: string, temp: Template) => { - const request: ChaiHttp.Request = method === 'get' - ? chai.request(app).get(path) - : chai.request(app).post(path); - request.then((res: ChaiHttp.Response) => { - expect(res.type).to.equal('application/json'); - }); - }); - forEach(completeProtocol).it( - '%s %s should have a status 200', - (method: string, path: string, temp: Template) => { - const request: ChaiHttp.Request = method === 'get' - ? chai.request(app).get(path) - : chai.request(app).post(path); - request.then((res: ChaiHttp.Response) => { - expect(res).to.have.status(200); - }); - }); - forEach(completeProtocol).it( - '%s %s should conform to standard protocol', - (method: string, path: string, temp: Template) => { - const request: ChaiHttp.Request = method === 'get' - ? chai.request(app).get(path) - : chai.request(app).post(path); - request.then((res: ChaiHttp.Response) => { - match(responseTemplate, JSON.parse(res.body)).shoul.be.true; - }); - }); - forEach(completeProtocol).it( - 'the response for %s %s should comply with its own protocol', - (method: string, path: string, temp: Template) => { - if (method === 'get' && temp != null) { - return chai.request(app).get(path) - .then((res: ChaiHttp.Response) => { - match(temp)(JSON.parse(res.body)).should.be.true; - }); - } - }); - }); -}); diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts new file mode 100644 index 0000000..1925835 --- /dev/null +++ b/test/unit/options.unit.test.ts @@ -0,0 +1,163 @@ +/* tslint:disable:typedef */ +// Disabled to allow quick template creation. + +/* tslint:disable:newline-per-chained-call */ +// Disabled to allow Chai- and Mocha-style test formatting. + +/* tslint:disable:no-unused-expression */ +// Disabled to allow `...to.be.true`. + +import * as chai from 'chai'; +chai.should(); + +import * as options from '../../src/matcher/options'; +import { default as types } from '../../src/matcher/types'; + +// tslint:disable-next-line:no-require-imports + +describe('Matching:', () => { + describe('Rough Matching', () => { + context('for literals', () => { + context('accepts matching', () => { + it('strings', () => { + options.match('a', 'a').should.be.true; + }); + it('numbers', () => { + options.match(3, 3).should.be.true; + }); + it('boolean values', () => { + options.match(true, true).should.be.true; + }); + it('null to null', () => { + options.match(null, null).should.be.true; + }); + }); + context('rejects', () => { + it('different strings', () => { + options.match('x', 'y').should.be.false; + }); + it('different numbers', () => { + options.match(20, 42).should.be.false; + }); + it('different boolean values', () => { + options.match(true, false).should.be.false; + }); + it('different types', () => { + options.match('55', 55).should.be.false; + }); + it('null matched with non-null values', () => { + options.match(null, false).should.be.false; + }); + it('non-null values matched with null', () => { + options.match(0, null).should.be.false; + }); + }); + }); + context('for checker functions', () => { + context('accepts', () => { + it('values that succeed the checker function', () => { + options.match(types.number, 9).should.be.true; + }); + }); + context('rejects', () => { + it('values that do not succeed the checker function', () => { + options.match(types.boolean, 'true').should.be.false; + }); + }); + }); + it('accepts basic things', () => { + const template = { + a: types.string + }; + const matchee = { + a: 'yes' + }; + options.match(template, matchee).should.be.true; + }); + it('accepts objects with superfluous properties', () => { + const template = { + a: types.number + }; + const matchee = { + a: 40, + b: 20 + }; + options.match(template, matchee).should.be.true; + }); + it('rejects objects missing some properties', () => { + const template = { + a: types.boolean, + b: types.number, + c: types.number + }; + const matchee = { + b: 5 + }; + options.match(template, matchee).should.be.false; + }); + it('accepts objects that omit not_present properties', () => { + const template = { + a: types.number, + b: types.not_present, + c: types.not_present + }; + const matchee = { + a: 4 + }; + options.match(template, matchee).should.be.true; + }); + it('rejects empty objects for non-empty templates', () => { + const template = { + a: types.boolean + }; + const matchee = { + }; + options.match(template, matchee).should.be.false; + }); + it('accepts empty objects for empty templates', () => { + const template = { + }; + const matchee = { + }; + options.match(template, matchee).should.be.true; + }); + it('accepts nested objects that match', () => { + const template = { + a: types.number, + b: { + ba: types.string, + bb: types.string + }, + c: types.boolean + }; + const matchee = { + a: 432, + b: { + ba: 'baracus', + bb: 'ATEAM' + }, + c: true, + x: false + }; + options.match(template, matchee).should.be.true; + }); + it('accepts literal matches', () => { + const template = { + a: 'literal' + }; + const matchee = { + a: 'literal' + }; + options.match(template, matchee).should.be.true; + }); + it('rejects incorrect literal matches', () => { + const template = { + g: 99 + }; + const matchee = { + g: 80 + }; + options.match(template, matchee).should.be.false; + }); + }); +}); diff --git a/test/unit/types.unit.test.ts b/test/unit/types.unit.test.ts new file mode 100644 index 0000000..ad0f99c --- /dev/null +++ b/test/unit/types.unit.test.ts @@ -0,0 +1,178 @@ +/* tslint:disable:no-unused-expression */ +// Disabled to allow `...to.be.true`. + +import * as chai from 'chai'; +chai.should(); + +import { default as types } from '../../src/matcher/types'; + +describe('Type Checking:', () => { + for (const x of [ + { name: 'Object', func: types.object }, + { name: 'Number', func: types.number }, + { name: 'Integer', func: types.integer }, + { name: 'String', func: types.string }, + { name: 'Boolean', func: types.boolean }, + { name: 'Array', func: types.array } + ]) { + describe(`${x.name} Checking`, () => { + it('rejects null', () => { + x.func(null).should.be.false; + }); + it('rejects undefined', () => { + x.func(undefined).should.be.false; + }); + }); + } + + describe('Presence Checking', () => { + it('accepts non-undefined values', () => { + types.anything(1).should.be.true; + types.anything('string').should.be.true; + types.anything(false).should.be.true; + }); + it('accepts null', () => { + types.anything(null).should.be.true; + }); + it('rejects undefined', () => { + types.anything(undefined).should.be.false; + }); + it('rejects objects without the named property', () => { + const x: { [key: string]: number } = {}; + /* There's no way to pick a key that definitely won't be + /* on the object */ + types.anything(x["hopefully this isn't a property"]) + .should.be.false; + }); + }); + + describe('Absence Checking', () => { + it('accepts undefined', () => { + types.not_present(undefined).should.be.true; + }); + }); + + describe('Number Checking', () => { + it('accepts positive integers', () => { + types.number(4).should.be.true; + }); + it('accepts negative integers', () => { + types.number(-10).should.be.true; + }); + it('accepts floats', () => { + types.number(3.14).should.be.true; + }); + it('accepts zero', () => { + types.number(0).should.be.true; + }); + it('accepts boxed numbers', () => { + // tslint:disable-next-line:no-construct + types.number(new Number(20)).should.be.true; + }); + it('rejects strings', () => { + types.number('haha').should.be.false; + }); + it('rejects objects', () => { + types.number(new Object()).should.be.false; + }); + it('rejects arrays', () => { + types.number([1, 2, 3]).should.be.false; + }); + it('rejects things that look like numbers', () => { + types.number('1234').should.be.false; + types.number('-3.14').should.be.false; + }); + it('accepts NaN', () => { + types.number(NaN).should.be.true; + }); + it('accepts Infinity', () => { + types.number(Infinity).should.be.true; + }); + }); + + describe('Integer Checking', () => { + it('rejects non-integer numbers', () => { + types.integer(3.14).should.be.false; + }); + it('rejects NaN', () => { + types.integer(NaN).should.be.false; + }); + it('rejects Infinity', () => { + types.integer(Infinity).should.be.false; + }); + }); + + describe('String Checking', () => { + it('accepts basic primitive strings', () => { + types.string('string!').should.be.true; + }); + it('accepts strings of numbers', () => { + types.string('1234').should.be.true; + }); + it('accepts the empty string', () => { + types.string('').should.be.true; + }); + it('accepts non-primitive string objects', () => { + // tslint:disable-next-line:no-construct + types.string(new String('String!')).should.be.true; + }); + it('rejects numbers', () => { + types.string(5).should.be.false; + // tslint:disable-next-line:no-construct + types.string(new Number(28)).should.be.false; + }); + it('rejects objects', () => { + types.string(new Object()).should.be.false; + }); + it('rejects arrays', () => { + types.string(['ah', 'ha']).should.be.false; + }); + }); + + describe('Boolean Checking', () => { + it('accepts true and false', () => { + types.boolean(true).should.be.true; + types.boolean(false).should.be.true; + }); + it('rejects numbers', () => { + types.boolean(2).should.be.false; + }); + it('rejects strings', () => { + types.boolean('not boolean').should.be.false; + }); + it('rejects strings of boolean values', () => { + types.boolean('true').should.be.false; + }); + it('rejects objects', () => { + types.boolean(new Object()).should.be.false; + }); + it('rejects arrays', () => { + types.boolean([true, true, false]).should.be.false; + }); + it('rejects falsy values', () => { + types.boolean(0).should.be.false; + }); + }); + + describe('Array Checking', () => { + it('accepts arrays', () => { + types.array([1, 'two', false]).should.be.true; + }); + it('accepts empty arrays', () => { + types.array([]).should.be.true; + types.array(new Array()).should.be.true; + }); + it('rejects strings', () => { + types.array('not an array').should.be.false; + }); + it('rejects strings that look like arrays', () => { + types.array('[1, 2, false]').should.be.false; + }); + it('rejects numbers', () => { + types.array(8).should.be.false; + }); + it('rejects objects', () => { + types.array(new Object()).should.be.false; + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index bcd1c9e..0230074 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1,7 +1,5 @@ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. # yarn lockfile v1 - - "@types/bluebird@*": version "3.5.20" resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.20.tgz#f6363172add6f4eabb8cada53ca9af2781e8d6a1" @@ -152,14 +150,14 @@ version "9.4.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.5.tgz#d2a90c634208173d1b1a0a6ba9f1df3de62edcf5" -"@types/node@6.0.41": - version "6.0.41" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.41.tgz#578cf53aaec65887bcaf16792f8722932e8ff8ea" - "@types/node@^6.0.46": version "6.0.100" resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.100.tgz#26e5599c65f96efa0f100915144eb92cddaa95df" +"@types/node@6.0.41": + version "6.0.41" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.41.tgz#578cf53aaec65887bcaf16792f8722932e8ff8ea" + "@types/passport-local@^1.0.32": version "1.0.32" resolved "https://registry.yarnpkg.com/@types/passport-local/-/passport-local-1.0.32.tgz#0856e3772c46ab8ac89aacf5535fa001a2ce5a13" @@ -185,18 +183,18 @@ version "0.0.4" resolved "https://registry.yarnpkg.com/@types/reflect-metadata/-/reflect-metadata-0.0.4.tgz#b6477ca9a97e5265f2ac67f9ea704eae5e0eaf4d" -"@types/sequelize@4.0.79": - version "4.0.79" - resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.0.79.tgz#74c366407a978e493e70d7cea3d80c681aed15c0" +"@types/sequelize@^4.27.5": + version "4.27.5" + resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.27.5.tgz#3bd4019be8af888413fa95e02c98b69d019fa52f" dependencies: "@types/bluebird" "*" "@types/continuation-local-storage" "*" "@types/lodash" "*" "@types/validator" "*" -"@types/sequelize@^4.27.5": - version "4.27.5" - resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.27.5.tgz#3bd4019be8af888413fa95e02c98b69d019fa52f" +"@types/sequelize@4.0.79": + version "4.0.79" + resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.0.79.tgz#74c366407a978e493e70d7cea3d80c681aed15c0" dependencies: "@types/bluebird" "*" "@types/continuation-local-storage" "*" @@ -334,14 +332,14 @@ asn1@~0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - assert-plus@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" +assert-plus@^1.0.0, assert-plus@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + assertion-error@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" @@ -386,10 +384,6 @@ balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" -base64url@2.0.0, base64url@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/base64url/-/base64url-2.0.0.tgz#eac16e03ea1438eff9423d69baa36262ed1f70bb" - base@^0.11.1: version "0.11.2" resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" @@ -402,6 +396,10 @@ base@^0.11.1: mixin-deep "^1.2.0" pascalcase "^0.1.1" +base64url@^2.0.0, base64url@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64url/-/base64url-2.0.0.tgz#eac16e03ea1438eff9423d69baa36262ed1f70bb" + basic-auth@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.0.tgz#015db3f353e02e56377755f962742e8981e7bbba" @@ -428,7 +426,7 @@ bluebird@^3.4.6, bluebird@^3.5.0: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" -body-parser@1.18.2, body-parser@^1.18.2: +body-parser@^1.18.2, body-parser@1.18.2: version "1.18.2" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" dependencies: @@ -669,12 +667,6 @@ combined-stream@^1.0.5, combined-stream@~1.0.5: dependencies: delayed-stream "~1.0.0" -commander@2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" - commander@^2.12.1: version "2.14.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" @@ -687,6 +679,12 @@ commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + component-emitter@^1.2.0, component-emitter@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -726,19 +724,19 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -cookiejar@2.0.x: - version "2.0.6" - resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.0.6.tgz#0abf356ad00d1c5a219d88d44518046dd026acfe" - cookiejar@^2.0.6: version "2.1.1" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.1.tgz#41ad57b1b555951ec171412a81942b1e8200d34a" +cookiejar@2.0.x: + version "2.0.6" + resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.0.6.tgz#0abf356ad00d1c5a219d88d44518046dd026acfe" + copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" -core-util-is@1.0.2, core-util-is@~1.0.0: +core-util-is@~1.0.0, core-util-is@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -779,13 +777,7 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -debug@2.6.8: - version "2.6.8" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" - dependencies: - ms "2.0.0" - -debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: +debug@^2.2.0, debug@^2.3.3, debug@^2.6.9, debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -797,6 +789,12 @@ debug@^3.1.0: dependencies: ms "2.0.0" +debug@2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + decamelize@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -835,14 +833,14 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" -depd@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" - depd@^1.1.0, depd@~1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" +depd@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + destroy@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" @@ -851,14 +849,14 @@ detect-libc@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" -diff@3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" - diff@^3.1.0, diff@^3.2.0: version "3.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c" +diff@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + dot-prop@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" @@ -869,14 +867,14 @@ dottie@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/dottie/-/dottie-2.0.0.tgz#da191981c8b8d713ca0115d5898cf397c2f0ddd0" -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -906,7 +904,7 @@ escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -1040,14 +1038,14 @@ extglob@^2.0.2: snapdragon "^0.8.1" to-regex "^3.0.1" -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - extsprintf@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -1077,14 +1075,6 @@ forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" -form-data@1.0.0-rc4: - version "1.0.0-rc4" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.0-rc4.tgz#05ac6bc22227b43e4461f488161554699d4f8b5e" - dependencies: - async "^1.5.2" - combined-stream "^1.0.5" - mime-types "^2.1.10" - form-data@~2.1.1: version "2.1.4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" @@ -1093,6 +1083,14 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" +form-data@1.0.0-rc4: + version "1.0.0-rc4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.0-rc4.tgz#05ac6bc22227b43e4461f488161554699d4f8b5e" + dependencies: + async "^1.5.2" + combined-stream "^1.0.5" + mime-types "^2.1.10" + formidable@^1.0.17: version "1.1.1" resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.1.1.tgz#96b8886f7c3c3508b932d6bd70c4d3a88f35f1a9" @@ -1195,25 +1193,25 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob@7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" +glob@^7.0.0, glob@^7.0.5, glob@^7.1.1, glob@7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.2" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.1.2, glob@^7.0.0, glob@^7.0.5, glob@^7.1.1: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" +glob@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^3.0.2" once "^1.3.0" path-is-absolute "^1.0.0" @@ -1317,7 +1315,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -hawk@3.1.3, hawk@~3.1.3: +hawk@~3.1.3, hawk@3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" dependencies: @@ -1344,7 +1342,7 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" -http-errors@1.6.2, http-errors@~1.6.2: +http-errors@~1.6.2, http-errors@1.6.2: version "1.6.2" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" dependencies: @@ -1388,7 +1386,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.3: +inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.3, inherits@2, inherits@2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -1559,7 +1557,7 @@ is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" -isarray@1.0.0, isarray@~1.0.0: +isarray@~1.0.0, isarray@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -1807,14 +1805,14 @@ lodash.set@^4.0.0: version "4.3.2" resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" -lodash@3.x: - version "3.10.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" - lodash@^4.13.1, lodash@^4.17.1: version "4.17.5" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" +lodash@3.x: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -1898,24 +1896,20 @@ mime-types@^2.1.10, mime-types@^2.1.12, mime-types@~2.1.15, mime-types@~2.1.16, dependencies: mime-db "~1.30.0" -mime@1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" - mime@^1.3.4: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" +mime@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" + minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: brace-expansion "^1.1.7" -minimist@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -1924,6 +1918,10 @@ minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + mixin-deep@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" @@ -1931,7 +1929,7 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.1: +mkdirp@^0.5.1, "mkdirp@>=0.5 0", mkdirp@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -1966,7 +1964,7 @@ moment-timezone@^0.5.14: dependencies: moment ">= 2.9.0" -moment@2.x.x, "moment@>= 2.9.0", moment@^2.20.0: +moment@^2.20.0, "moment@>= 2.9.0", moment@2.x.x: version "2.20.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" @@ -1980,14 +1978,14 @@ morgan@^1.9.0: on-finished "~2.3.0" on-headers "~1.0.1" -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - ms@^2.0.0, ms@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + nan@^2.3.0: version "2.8.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" @@ -2341,7 +2339,7 @@ punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -qs@6.5.1, qs@^6.1.0, qs@^6.2.0: +qs@^6.1.0, qs@^6.2.0, qs@6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" @@ -2483,13 +2481,13 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: +rimraf@^2.5.1, rimraf@^2.6.1, rimraf@2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: glob "^7.0.5" -safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1, safe-buffer@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" @@ -2499,14 +2497,14 @@ semver-diff@^2.0.0: dependencies: semver "^5.0.3" -semver@4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.2.tgz#c7a07158a80bedd052355b770d82d6640f803be7" - semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" +semver@4.3.2: + version "4.3.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.2.tgz#c7a07158a80bedd052355b770d82d6640f803be7" + send@0.16.1: version "0.16.1" resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" @@ -2702,18 +2700,18 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" -split@0.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" - dependencies: - through "2" - split@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" dependencies: through "2" +split@0.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + dependencies: + through "2" + sprintf-js@^1.0.3: version "1.1.1" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c" @@ -2763,6 +2761,12 @@ stream-combiner@~0.0.4: dependencies: duplexer "~0.1.1" +string_decoder@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -2778,12 +2782,6 @@ string-width@^2.0.0, string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string_decoder@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" - dependencies: - safe-buffer "~5.1.0" - stringstream@~0.0.4: version "0.0.5" resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" @@ -2827,12 +2825,6 @@ superagent@^2.0.0: qs "^6.1.0" readable-stream "^2.0.5" -supports-color@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" - dependencies: - has-flag "^1.0.0" - supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" @@ -2843,6 +2835,12 @@ supports-color@^5.2.0: dependencies: has-flag "^3.0.0" +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + tar-pack@^3.4.0: version "3.4.1" resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" @@ -2882,7 +2880,7 @@ terraformer@~1.0.5: dependencies: "@types/geojson" "^1.0.0" -through@2, through@~2.3, through@~2.3.1: +through@~2.3, through@~2.3.1, through@2: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" @@ -2992,14 +2990,14 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -type-detect@0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" - type-detect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" +type-detect@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" + type-is@~1.6.15: version "1.6.15" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" @@ -3033,7 +3031,7 @@ typedoc@^0.10.0: typedoc-default-themes "^0.5.0" typescript "2.7.1" -typescript@2.7.1, typescript@^2.7.1: +typescript@^2.7.1, typescript@2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359" @@ -3087,7 +3085,7 @@ universalify@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" -unpipe@1.0.0, unpipe@~1.0.0: +unpipe@~1.0.0, unpipe@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -3207,14 +3205,14 @@ wkx@^0.4.1: dependencies: "@types/node" "*" -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" - wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -3263,3 +3261,4 @@ yargs@~3.10.0: yn@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + -- cgit v1.2.1