From f4f1d3e34bec8d3c443a51138a74b90938dff350 Mon Sep 17 00:00:00 2001 From: David Valin Date: Mon, 3 Apr 2023 22:59:32 +0200 Subject: [PATCH] commit submit dist/coverage. Link to html report always --- .gitignore | 3 +- README.md | 2 +- dist/coverage/badges.svg | 20 + dist/coverage/coverage-summary.json | 4 + dist/coverage/lcov-report/base.css | 224 ++ dist/coverage/lcov-report/block-navigation.js | 87 + dist/coverage/lcov-report/favicon.png | Bin 0 -> 445 bytes .../lcov-report/howerest.sdkzer.ts.html | 1858 +++++++++++++++++ dist/coverage/lcov-report/index.html | 131 ++ dist/coverage/lcov-report/prettify.css | 1 + dist/coverage/lcov-report/prettify.js | 2 + .../lcov-report/sort-arrow-sprite.png | Bin 0 -> 138 bytes dist/coverage/lcov-report/sorter.js | 196 ++ .../lcov-report/validation_rule.ts.html | 271 +++ dist/coverage/lcov.info | 355 ++++ test-report.html | 232 -- 16 files changed, 3151 insertions(+), 235 deletions(-) create mode 100644 dist/coverage/badges.svg create mode 100644 dist/coverage/coverage-summary.json create mode 100644 dist/coverage/lcov-report/base.css create mode 100644 dist/coverage/lcov-report/block-navigation.js create mode 100644 dist/coverage/lcov-report/favicon.png create mode 100644 dist/coverage/lcov-report/howerest.sdkzer.ts.html create mode 100644 dist/coverage/lcov-report/index.html create mode 100644 dist/coverage/lcov-report/prettify.css create mode 100644 dist/coverage/lcov-report/prettify.js create mode 100644 dist/coverage/lcov-report/sort-arrow-sprite.png create mode 100644 dist/coverage/lcov-report/sorter.js create mode 100644 dist/coverage/lcov-report/validation_rule.ts.html create mode 100644 dist/coverage/lcov.info delete mode 100644 test-report.html diff --git a/.gitignore b/.gitignore index e37e371..68d5051 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -js/ node_modules/ -coverage/ +./coverage/ .DS_Store .baseDir.ts npm-debug.log diff --git a/README.md b/README.md index 67ced68..7559c6b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## sdkzer ## -[Continuous Integration](https://htmlpreview.github.io/?https://github.com/howerest/sdkzer/blob/master/dist/tests_report.html) ![Coverage](./dist/coverage/badges.svg) +[Continuous Integration](https://htmlpreview.github.io/?https://github.com/howerest/sdkzer/blob/master/dist/tests_report.html) [Continuous Integration](https://htmlpreview.github.io/?https://github.com/howerest/sdkzer/blob/master/dist/tests_report.html) [http://howerest.com/labs/sdkzer](http://howerest.com/labs/sdkzer) diff --git a/dist/coverage/badges.svg b/dist/coverage/badges.svg new file mode 100644 index 0000000..4354a36 --- /dev/null +++ b/dist/coverage/badges.svg @@ -0,0 +1,20 @@ + + coverage: 100% + + + + + + + + + + + + + \ No newline at end of file diff --git a/dist/coverage/coverage-summary.json b/dist/coverage/coverage-summary.json new file mode 100644 index 0000000..4c603d7 --- /dev/null +++ b/dist/coverage/coverage-summary.json @@ -0,0 +1,4 @@ +{"total": {"lines":{"total":171,"covered":171,"skipped":0,"pct":100},"statements":{"total":179,"covered":179,"skipped":0,"pct":100},"functions":{"total":41,"covered":34,"skipped":0,"pct":82.92},"branches":{"total":84,"covered":70,"skipped":0,"pct":83.33},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} +,"/home/me/shared_MAIN/sdkzer/src/howerest.sdkzer.ts": {"lines":{"total":157,"covered":157,"skipped":0,"pct":100},"functions":{"total":37,"covered":30,"skipped":0,"pct":81.08},"statements":{"total":164,"covered":164,"skipped":0,"pct":100},"branches":{"total":83,"covered":69,"skipped":0,"pct":83.13}} +,"/home/me/shared_MAIN/sdkzer/src/validation_rule.ts": {"lines":{"total":14,"covered":14,"skipped":0,"pct":100},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":15,"covered":15,"skipped":0,"pct":100},"branches":{"total":1,"covered":1,"skipped":0,"pct":100}} +} diff --git a/dist/coverage/lcov-report/base.css b/dist/coverage/lcov-report/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/dist/coverage/lcov-report/base.css @@ -0,0 +1,224 @@ +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; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* 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) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.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; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.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/dist/coverage/lcov-report/block-navigation.js b/dist/coverage/lcov-report/block-navigation.js new file mode 100644 index 0000000..cc12130 --- /dev/null +++ b/dist/coverage/lcov-report/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/dist/coverage/lcov-report/favicon.png b/dist/coverage/lcov-report/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c1525b811a167671e9de1fa78aab9f5c0b61cef7 GIT binary patch literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*> + + + + Code coverage report for howerest.sdkzer.ts + + + + + + + + + +
+
+

All files howerest.sdkzer.ts

+
+ +
+ 100% + Statements + 164/164 +
+ + +
+ 83.13% + Branches + 69/83 +
+ + +
+ 81.08% + Functions + 30/37 +
+ + +
+ 100% + Lines + 157/157 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
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 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +67x +67x +67x +  +  +2x +2x +  +  +  +  +  +  +  +  +67x +67x +  +67x +  +67x +  +53x +53x +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +68x +68x +68x +94x +  +  +  +  +  +  +  +  +  +  +51x +  +  +  +  +  +  +  +  +2x +2x +3x +1x +  +  +1x +  +  +  +  +  +  +  +  +4x +  +4x +  +  +4x +6x +  +4x +1x +1x +  +  +1x +  +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +10x +  +3x +3x +3x +7x +  +6x +6x +6x +2x +  +6x +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +2x +  +2x +2x +1x +  +  +  +1x +  +  +  +  +  +  +  +6x +6x +6x +  +  +6x +16x +39x +4x +4x +  +  +  +  +6x +  +  +  +  +  +  +  +3x +3x +7x +6x +  +  +  +3x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +9x +  +  +9x +8x +  +8x +  +  +  +  +  +  +  +8x +1x +  +  +  +  +  +8x +8x +  +  +  +  +  +6x +  +6x +6x +  +  +  +6x +  +6x +6x +  +  +2x +2x +  +  +  +  +  +  +  +  +  +  +19x +  +  +  +  +  +  +  +  +3x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +  +  +  +3x +  +2x +2x +  +1x +1x +  +  +3x +  +  +  +  +  +  +  +4x +  +  +4x +  +  +4x +2x +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +  +4x +4x +  +  +  +  +3x +  +2x +  +3x +3x +  +1x +  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +2x +2x +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +4x +  +  +4x +4x +  +  +  +  +  +  +4x +1x +  +  +  +  +  +4x +4x +  +  +  +3x +3x +9x +9x +9x +  +3x +  +1x +  +  +  +4x +  +  +  +  +  +  +  +  +  +4x +  +  +  +  +4x +4x +  +  +  +  +  +  +4x +1x +  +  +  +  +  +4x +4x +  +  +  +3x +3x +3x +  +1x +  +  +4x +  +  +  +  +9x +  +9x +1x +1x +1x +1x +2x +2x +2x +  +  +9x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +2x +2x +2x +  +  +2x +2x +  +  +2x +2x +  +  +2x +2x +2x +  +  + 
/* =========================================================================
+ 
+    howerest 2023 - <hola@davidvalin.com> | www.howerest.com
+    ___________________
+    Apache 2.0 Licensed
+ 
+    Implements a standarized & friendly API to deal with RESTful http
+    resources that implement endpoints to perform the CRUD operations.
+ 
+      1. Define a resource by extending Sdkzer class
+      2. Define a "baseEndpoint()" function for your class
+      3. Start consuming your resource
+ 
+=========================================================================== */
+ 
+export interface SdkzerParams {
+  id: any
+}
+ 
+export class Sdkzer<T extends SdkzerParams> {
+ 
+  public attrs:T;
+  public pAttrs:T;
+  protected validationRules:object;
+  public invalidMessages:object = {};
+  public syncing:boolean = false;
+  public lastResponse:Response|null = null;
+ 
+  // Configuration
+  private static DEFAULT_HTTP_HEADERS:THttpHeaders = {};
+  private static PARENTS_FETCH_STRATEGY:string = 'none';
+ 
+  /**
+   * Creates an instance of a model entity with an API to communicate with
+   * a resource (http RESTful resource)
+   * @param  {object}   attrs   The initial attributes for the resource.
+   *                            Those attributes are in force to defaults()
+   */
+  public constructor(attrs:T = {} as T) {
+    this.attrs = { id: null } as T;
+    this.pAttrs = { id: null } as T;
+ 
+    this.setDefaults();
+ 
+    for (let attrKey in attrs) {
+      // Object initialization parameters are in force to default parameters
+      this.attrs[attrKey] = attrs[attrKey];
+      this.pAttrs[attrKey] = attrs[attrKey];
+    }
+  }
+ 
+ 
+  /**
+   * Configures Sdkzer constants that determine the behaviour of Sdkzer in all
+   * classes that extend from Sdkzer in the current scope.
+   * @param {ISdkzerConfigOptions} options The configuration options
+   */
+   public static configure(options:ISdkzerConfigOptions) : void {
+    Sdkzer.DEFAULT_HTTP_HEADERS = options.defaultHttpHeaders || {};
+   }
+ 
+ 
+  /**
+   * Sets the defaults() values in the instance attributes
+   */
+  public setDefaults() : void {
+    if (this.defaults()) {
+      let defaults = this.defaults();
+      for (let attrKey in defaults) {
+        this.attrs[attrKey] = defaults[attrKey];
+      }
+    }
+  }
+ 
+ 
+  /**
+   * Retrieves the defaults for the entity. Override it using your default
+   * attributes if you need any
+   */
+  public defaults() : object {
+    return {};
+  }
+ 
+ 
+  /**
+   * Checks wether an entity is a valid entity.
+   * It doesn't perform validation (check validate())
+   */
+  public isValid() : boolean {
+    const attrs = Object.keys(this.invalidMessages);
+    for(const attrName of attrs) {
+      if (this.invalidMessages[attrName] && this.invalidMessages[attrName].length > 0) {
+        return false;
+      }
+    }
+    return true;
+  }
+ 
+ 
+  /**
+   * Checks wether an entity is a valid entity
+   */
+  public validate() : void {
+    // Reset previous invalid messages from previous validations
+    this.invalidMessages = {};
+    let toValidateAttr, validationRule;
+    const toValidateAttrs = Object.keys(this.validationRules || {});
+ 
+    // Validate attribute's ValidationRules
+    for(toValidateAttr of toValidateAttrs) {
+      for(validationRule of this.validationRules[toValidateAttr]) {
+        // When the ValidationRule is invalid...
+        if (!validationRule.isValid(this.pAttrs[toValidateAttr], this.attrs[toValidateAttr])) {
+          if (!this.invalidMessages[toValidateAttr]) {
+            this.invalidMessages[toValidateAttr] = [];
+          }
+          // Collect the invalid message from the ValidationRules for that field
+          this.invalidMessages[toValidateAttr].push(validationRule.invalidMessage);
+        } else {
+          this.invalidMessages[toValidateAttr] = [];
+        }
+      }
+    }
+  }
+ 
+ 
+  /**
+   * This method can do 3 different things:
+   *
+   * - 1) Reads all attributes. When called as instance.attr()
+   * - 2) Read one attribute. When called as instance.attr('name')
+   * - 3) Set one attribute. When called as instance.attr('name', 'Bruce Lee')
+   *
+   * It's recommended to use this method instead of accessing to attr attribute
+   * directly. This allows you to execute logic before and after setting or
+   * reading attributes. Also, instead of creating 100 setters and getters,
+   * we use a single attr() method
+   *
+   * @param attrName  The attribute name that we want to read or set
+   * @param value     The attribute value that we want to set for "attrName"
+   */
+   public attr(attrName?: string, value?: any) : string | number | boolean | object {
+     // Setting an attribute?
+     if (attrName !== undefined && value !== undefined) {
+       // TODO: Add before&after-callback
+       let attrKeys = attrName.split('.');
+       let attrKeyName = '';
+       eval("this.attrs['"+attrKeys.join("']['")+"'] = " + (typeof(value) === 'string' ? "'"+value+"'" : value));
+     } else if (attrName !== undefined && value === undefined) {
+       // Reading an attribute?
+       let attrKeys = attrName.split('.');
+       let attrValue = this.attrs[attrName.split('.')[0]];
+       for (let i = 1; i < attrKeys.length; i++) {
+         attrValue = attrValue[attrKeys[i]];
+       }
+       return attrValue;
+     } else {
+       // Reading all attributes?
+       // TODO: Add before&after-callbacks
+       return this.attrs || {};
+     }
+   }
+ 
+ 
+  /**
+   * Retrieves the base resource url. Override it using your base endpoint
+   * for your resource.
+   *
+   * NOTE: You need to define a baseEndpoint method in your entities
+   *  in order to be able to sync with a backend endpoint
+   *  A base endpoint for a RESTful endpoint look like:
+   *    return "https://www.an-api.com/v1/users"
+   */
+  public baseEndpoint() : string {
+    return null;
+  }
+ 
+ 
+  /**
+   * Retrieves the resource url
+   * NOTE: This method will become the interface to connect using different
+   * http patterns
+   */
+  public resourceEndpoint() : string {
+    return '';
+  }
+ 
+ 
+  /**
+   * Checks if the record is not saved in the origin. An record will be
+   * consiered new when it has an "id" attribute set to null and it lacks of
+   * a "lastResponse" attribute value
+   */
+  public isNew() : boolean {
+    return ((this.attrs.id !== null) ? false : true);
+  }
+ 
+ 
+  /**
+   * Checks if the record has changed since the last save
+   */
+  public hasChanged() : boolean {
+    return (this.changedAttrs().length > 0 ? true : false);
+  }
+ 
+ 
+  /**
+   * Checks if an attribute has changed from the origin
+   */
+  public hasAttrChanged(attrName:string) : boolean {
+    let i, changedAttrs = this.changedAttrs();
+ 
+    for (i = 0; i < changedAttrs.length; i++) {
+      if (changedAttrs[i] === attrName) {
+        return true;
+      }
+    }
+ 
+    return false;
+  }
+ 
+ 
+  /**
+   * Retrieves the name of the changed attributes since the last save
+   */
+  public changedAttrs() : Array<string> {
+    let changedAttrs = [],
+        currAttrs = Object.keys(this.attrs),
+        prevAttrs = Object.keys(this.pAttrs),
+        i, i2;
+ 
+    for (i=0; i <= currAttrs.length; i++) {
+      for (i2=0; i2 <= prevAttrs.length; i2++) {
+        if (currAttrs[i] !== null && currAttrs[i] === prevAttrs[i2] && this.attrs[currAttrs[i]] !== this.pAttrs[prevAttrs[i2]]) {
+          changedAttrs.push(currAttrs[i]);
+          break;
+        }
+      }
+    }
+ 
+    return changedAttrs;
+  }
+ 
+ 
+  /**
+   * Retrieves the previous attributes
+   */
+  public prevAttrs() : T {
+    let previousAttrs = {} as T;
+    for (let attrKey in this.attrs) {
+      if (this.pAttrs[attrKey] !== this.attrs[attrKey]) {
+        previousAttrs[attrKey] = (this.pAttrs[attrKey] ? this.pAttrs[attrKey] : null);
+      }
+    }
+ 
+    return previousAttrs;
+  }
+ 
+ 
+  /**
+   * Retrieves the previous value prior to last save for a specific attribute
+   */
+  public prevValue(attrName:string) : any {
+    return this.prevAttrs()[attrName];
+  }
+ 
+ 
+  /**
+   * Fetches the newest attributes from the origin.
+   */
+  public async fetch(httpQuery?:IQuery, camelize: boolean = true) : Promise<Response> {
+    let _this = this,
+        promise;
+ 
+    if (this.attrs.id) {
+      this.syncing = true;
+ 
+      let query:IQuery = {
+        url:        `${this.baseEndpoint()}/${this.attrs.id}`,
+        method:     'GET',
+        headers:    Sdkzer.DEFAULT_HTTP_HEADERS || {},
+        qsParams:   {},
+        data:       {}
+      }
+ 
+      if (typeof(httpQuery) !== 'undefined') {
+        query = {
+          ...query,
+          ...httpQuery
+        };
+      }
+      
+      try {
+        let response = await fetch(`${query.url}${query.qsParams ? qsToString(query.qsParams): ''}`, {
+          method: query.method,
+          headers: query.headers,
+          body: query.data.toString()
+        });
+        // Success
+        _this.syncing = false;
+        // TODO: Keep lastResponse
+        let parsedData = _this.parseRecord(JSON.parse(await response.json()));
+        if (camelize) {
+          // parsedData = util.Camel.camelize(parsedData);
+        }
+        // Keep track of previous attributes
+        _this.pAttrs = parsedData;
+        // Assign the parsed attributes
+        _this.attrs = parsedData;
+        return response;
+      } catch(e) {
+        // Fail
+        _this.syncing = false;
+        return Promise.reject(false);
+      }
+    }
+  }
+ 
+ 
+  /**
+   * Parses a single resource record from an incoming HttpResponse data
+   * NOTE: The idea is to return the parsed record data only
+   */
+  public parseRecord(data:object, prefix?:string) : T {
+    return prefix ? data[prefix] : data;
+  }
+ 
+ 
+  /**
+   * Parses a collection of resource records from an incoming HttpResponse data
+   * NOTE: The idea is to return the parsed collection of records data only
+   */
+  public static parseCollection(data:Array<object>, prefix?:string) : Array<object> {
+    return prefix ? data[prefix] : data;
+  }
+ 
+ 
+  /**
+   * Transforms the local attributes to be processed by the origin in JSON format
+   */
+  public toOriginJSON() : object {
+    return this.attrs;
+  }
+ 
+ 
+  /**
+   * Transforms the local attributes to be processed by the origin in XML format
+   */
+  public toOriginXML() : string {
+    return '';
+  }
+ 
+ 
+  /**
+   * Transforms the local attributes to be processed by the origin in a specific format
+   * @param format The format to transform into
+   */
+  public toOrigin(format:string = 'json') : object|string {
+    let snapshot;
+ 
+    switch(format) {
+      case 'json':
+        snapshot = this.toOriginJSON();
+        break;
+      case 'xml':
+        snapshot = this.toOriginXML();
+        break;
+    }
+ 
+    return snapshot;
+  }
+ 
+ 
+  /**
+   * Persists the local state into the origin
+   */
+  public async save(httpHeaders:THttpHeaders = {}) : Promise<Response> {
+    let _this =  this,
+        query:IQuery,
+        request,
+        httpMethod:THttpMethod = (this.attr('id') == null ? 'POST' : 'PUT');
+ 
+    // New record in the origin?
+    if (httpMethod === 'POST') {
+      query = {
+        method:     httpMethod,
+        url:        this.baseEndpoint(),
+        headers:    Sdkzer.DEFAULT_HTTP_HEADERS || {},
+        qsParams:   {},
+        data:       this.toOriginJSON()
+      };
+ 
+    // Existing record in the origin?
+    } else {
+      query = {
+        method:     httpMethod,
+        url:        `${this.baseEndpoint()}/${this.attrs.id}${query && query.qsParams ? qsToString(query.qsParams): ''}`,
+        headers:    Sdkzer.DEFAULT_HTTP_HEADERS || {},
+        qsParams:   {},
+        data:       this.toOriginJSON()
+      };
+    }
+ 
+    try {
+      const response = await fetch(query.url, {
+        method: query.method,
+        headers: query.headers,
+        body: query.data.toString()
+      });
+      if (httpMethod === 'POST') {
+        // Append id to attributes
+        _this.attrs.id = (await response.json())['id'];
+      }
+      _this.lastResponse = response;
+      return response;
+    } catch(e) {
+      return Promise.reject(false);
+    }
+  }
+ 
+ 
+  /**
+   * Destroys the current record in the origin
+   */
+  public async destroy() : Promise<Response> {
+    let query:IQuery;
+ 
+    query = {
+      method:     'DELETE',
+      url:        `${this.baseEndpoint()}/${this.attrs.id}`,
+      headers:    Sdkzer.DEFAULT_HTTP_HEADERS || {},
+      qsParams:   {},
+      data:       {}
+    };
+ 
+    try {
+      return await fetch(query.url, {
+        method: query.method,
+        headers: query.headers,
+        body: query.data.toString()
+      })
+    } catch(e) {
+      return Promise.reject(false);
+    }
+  }
+ 
+ 
+  /**
+   * Retrieves a collection of records from the origin
+   * @param httpQuery An optional query to be merged with the default one 
+   */
+  public static async fetchIndex(httpQuery?:IQuery) : Promise<Array<any>> {
+    let query:IQuery,
+        request,
+        instancesPromise,
+        instances = [],
+        instance;
+ 
+    instancesPromise = new Promise(async (resolve, reject) => {
+      query = {
+        method:     'GET',
+        url:        `${new this().baseEndpoint()}${httpQuery && httpQuery.qsParams ? qsToString(httpQuery.qsParams): ''}`,
+        headers:    Sdkzer.DEFAULT_HTTP_HEADERS || {},
+        qsParams:   {}
+      };
+ 
+      if (typeof(httpQuery) !== 'undefined') {
+        query = {
+          ...query,
+          ...httpQuery
+        };
+      }
+ 
+      try {
+        const response = await fetch(query.url, {
+          method: query.method,
+          headers: query.headers
+        });
+        const collectionList = this.parseCollection(JSON.parse(await response.json()));
+        for (let i in collectionList) {
+          instance = new this();
+          instance.attrs = instance.pAttrs = instance.parseRecord(collectionList[i]);
+          instances.push(instance);
+        }
+        resolve(instances);
+      } catch(e) {
+        reject(e);
+      }
+    });
+ 
+    return instancesPromise;
+  }
+ 
+ 
+  /**
+   * Retrieves a single record from the origin
+   * @param id          The record id that we want to fetch by
+   * @param httpQuery   Use a HttpQuery instance to override the default query
+   */
+  public static fetchOne(id: number|string, httpQuery?:IQuery) : Promise<any>  {
+    let model = new this(),
+        query:IQuery,
+        instancePromise,
+        instance;
+ 
+    instancePromise = new Promise(async (resolve, reject) => {
+      query = {
+        method:     'GET',
+        url:        `${model.baseEndpoint()}/${id}${httpQuery && httpQuery.qsParams ? qsToString(httpQuery.qsParams) : ''}`,
+        headers:    Sdkzer.DEFAULT_HTTP_HEADERS || {},
+        qsParams:   {}
+      };
+ 
+      if (typeof(httpQuery) !== 'undefined') {
+        query = {
+          ...query,
+          ...httpQuery
+        }
+      }
+ 
+      try {
+        const response = await fetch(query.url, {
+          method: query.method,
+          headers: query.headers
+        })
+        instance = new this();
+        instance.attrs = instance.pAttrs = instance.parseRecord(JSON.parse(await response.json()));
+        resolve(instance);
+      } catch(e) {
+        reject(e);
+      }
+    });
+    return instancePromise;
+  }
+}
+ 
+function qsToString(qs:IQueryString) {
+  let qsPart = '';
+  // Add query string to url
+  if (Object.keys(qs).length > 0) {
+    qsPart += '?';
+    let i=0;
+    let keys = Object.keys(qs);
+    for(let key of keys) {
+      if (i > 0) { qsPart += '&'; }
+      qsPart += `${key}=${qs[key]}`;
+      i++;
+    }
+  }
+  return qsPart;
+}
+ 
+export type THttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
+export type THttpHeaders = {
+  [key:string] : string
+}
+export interface IQueryString {
+  [key:string] : string | number
+}
+ 
+export interface IQuery {
+  url?:        string,
+  method?:     THttpMethod,
+  headers?:    THttpHeaders,
+  qsParams?:   IQueryString,
+  data?:       {}
+}
+ 
+export interface ISdkzerConfigOptions {
+  defaultHttpHeaders: THttpHeaders
+}
+ 
+export { ValidationRule, IValidationRule } from "./validation_rule";
+export { RequiredValidator } from "./validation_rules/required_validator"
+export {
+  RegExpValidator,
+  IParams as IRegExpValidatorParams
+} from "./validation_rules/reg_exp_validator"
+export {
+  NumberValidator,
+  IParams as INumberValidatorParams
+} from "./validation_rules/number_validator"
+export {
+  LengthValidator,
+  IParams as ILengthValidatorParams
+} from "./validation_rules/length_validator"
+export { EmailValidator } from "./validation_rules/email_validator"
+export {
+  AllowedValueSwitchValidator,
+  IParams as IAllowedValueSwitchValidatorParams
+} from "./validation_rules/allowed_value_switch_validator"
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/dist/coverage/lcov-report/index.html b/dist/coverage/lcov-report/index.html new file mode 100644 index 0000000..683dd51 --- /dev/null +++ b/dist/coverage/lcov-report/index.html @@ -0,0 +1,131 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 100% + Statements + 179/179 +
+ + +
+ 83.33% + Branches + 70/84 +
+ + +
+ 82.92% + Functions + 34/41 +
+ + +
+ 100% + Lines + 171/171 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
howerest.sdkzer.ts +
+
100%164/16483.13%69/8381.08%30/37100%157/157
validation_rule.ts +
+
100%15/15100%1/1100%4/4100%14/14
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/dist/coverage/lcov-report/prettify.css b/dist/coverage/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/dist/coverage/lcov-report/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/dist/coverage/lcov-report/prettify.js b/dist/coverage/lcov-report/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/dist/coverage/lcov-report/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +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/dist/coverage/lcov-report/sort-arrow-sprite.png b/dist/coverage/lcov-report/sort-arrow-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..6ed68316eb3f65dec9063332d2f69bf3093bbfab GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc literal 0 HcmV?d00001 diff --git a/dist/coverage/lcov-report/sorter.js b/dist/coverage/lcov-report/sorter.js new file mode 100644 index 0000000..2bb296a --- /dev/null +++ b/dist/coverage/lcov-report/sorter.js @@ -0,0 +1,196 @@ +/* eslint-disable */ +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]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + if ( + row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()) + ) { + row.style.display = ''; + } else { + row.style.display = 'none'; + } + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // 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(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/dist/coverage/lcov-report/validation_rule.ts.html b/dist/coverage/lcov-report/validation_rule.ts.html new file mode 100644 index 0000000..707a6bf --- /dev/null +++ b/dist/coverage/lcov-report/validation_rule.ts.html @@ -0,0 +1,271 @@ + + + + + + Code coverage report for validation_rule.ts + + + + + + + + + +
+
+

All files validation_rule.ts

+
+ +
+ 100% + Statements + 15/15 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 100% + Functions + 4/4 +
+ + +
+ 100% + Lines + 14/14 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
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  +  +  +  +  +  +  +  +  +  +  +8x +24x +  +  +  +24x +  +  +24x +24x +  +  +  +  +  +  +1x +  +  +  +  +  +  +30x +30x +  +  +30x +  +30x +35x +19x +  +  +11x +  +  +  +  +  +  +20x +  +  +  +  +  +  +  +  +  + 
/* --------------------------------------------------------------------------
+ 
+    howerest 2018 - <hola@davidvalin.com> | www.howerest.com
+ 
+    Apache 2.0 Licensed
+    -------------------
+ 
+    ValidationRule: represents a validation rule
+ 
+--------------------------------------------------------------------------- */
+ 
+export class ValidationRule<IParams = {}> implements IValidationRule {
+  protected conditions: Array<Function|any> = [];
+  public fromValue:any;
+  public toValue:any
+  public params: IParams
+  private _invalidMessage = "Invalid";
+ 
+  constructor(params?:any) {
+    this.params = params;
+    this._invalidMessage = "";
+  }
+ 
+  /**
+   * Retrieves the invalid message for the ValidationRule
+   */
+  get invalidMessage(): string {
+    return this._invalidMessage;
+  }
+ 
+  /**
+   * Checks if the ValidationRule is valid
+   */
+  public isValid(fromValue:any, toValue:any): boolean {
+    this.fromValue = fromValue;
+    this.toValue = toValue;
+ 
+    // Reset the invalid message
+    this._invalidMessage = '';
+ 
+    for(let i=0; i < this.conditions.length; i++) {
+      if (this.conditions[i]() === false) {
+        return false;
+      }
+    }
+    return true;
+  }
+ 
+  /**
+   * Adds an invalid message to the ValidationRule
+   */
+  public addInvalidMessage(message:string) {
+    this._invalidMessage += message;
+  }
+}
+ 
+export interface IValidationRule {
+  params: any;
+  invalidMessage: string;
+ 
+  isValid(fromValue:any, toValue:any);
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/dist/coverage/lcov.info b/dist/coverage/lcov.info new file mode 100644 index 0000000..cd449d5 --- /dev/null +++ b/dist/coverage/lcov.info @@ -0,0 +1,355 @@ +TN: +SF:src/howerest.sdkzer.ts +FN:39,(anonymous_7) +FN:58,(anonymous_8) +FN:66,(anonymous_9) +FN:80,(anonymous_10) +FN:89,(anonymous_11) +FN:103,(anonymous_12) +FN:142,(anonymous_13) +FN:174,(anonymous_14) +FN:184,(anonymous_15) +FN:194,(anonymous_16) +FN:202,(anonymous_17) +FN:210,(anonymous_18) +FN:226,(anonymous_19) +FN:248,(anonymous_20) +FN:263,(anonymous_21) +FN:271,(anonymous_22) +FN:324,(anonymous_24) +FN:333,(anonymous_25) +FN:341,(anonymous_26) +FN:349,(anonymous_27) +FN:358,(anonymous_28) +FN:377,(anonymous_29) +FN:425,(anonymous_31) +FN:452,(anonymous_33) +FN:459,(anonymous_35) +FN:459,(anonymous_36) +FN:500,(anonymous_37) +FN:506,(anonymous_38) +FN:506,(anonymous_39) +FN:537,qsToString +FN:573,(anonymous_41) +FN:574,(anonymous_42) +FN:576,(anonymous_43) +FN:580,(anonymous_44) +FN:584,(anonymous_45) +FN:587,(anonymous_46) +FN:589,(anonymous_47) +FNF:37 +FNH:30 +FNDA:67,(anonymous_7) +FNDA:1,(anonymous_8) +FNDA:68,(anonymous_9) +FNDA:51,(anonymous_10) +FNDA:2,(anonymous_11) +FNDA:4,(anonymous_12) +FNDA:10,(anonymous_13) +FNDA:1,(anonymous_14) +FNDA:1,(anonymous_15) +FNDA:2,(anonymous_16) +FNDA:2,(anonymous_17) +FNDA:2,(anonymous_18) +FNDA:6,(anonymous_19) +FNDA:3,(anonymous_20) +FNDA:1,(anonymous_21) +FNDA:9,(anonymous_22) +FNDA:19,(anonymous_24) +FNDA:3,(anonymous_25) +FNDA:1,(anonymous_26) +FNDA:2,(anonymous_27) +FNDA:3,(anonymous_28) +FNDA:4,(anonymous_29) +FNDA:2,(anonymous_31) +FNDA:4,(anonymous_33) +FNDA:4,(anonymous_35) +FNDA:4,(anonymous_36) +FNDA:4,(anonymous_37) +FNDA:4,(anonymous_38) +FNDA:4,(anonymous_39) +FNDA:9,qsToString +FNDA:0,(anonymous_41) +FNDA:0,(anonymous_42) +FNDA:0,(anonymous_43) +FNDA:0,(anonymous_44) +FNDA:0,(anonymous_45) +FNDA:0,(anonymous_46) +FNDA:0,(anonymous_47) +DA:20,2 +DA:25,67 +DA:26,67 +DA:27,67 +DA:30,2 +DA:31,2 +DA:40,67 +DA:41,67 +DA:43,67 +DA:45,67 +DA:47,53 +DA:48,53 +DA:59,1 +DA:67,68 +DA:68,68 +DA:69,68 +DA:70,94 +DA:81,51 +DA:90,2 +DA:91,2 +DA:92,3 +DA:93,1 +DA:96,1 +DA:105,4 +DA:107,4 +DA:110,4 +DA:111,6 +DA:113,4 +DA:114,1 +DA:115,1 +DA:118,1 +DA:120,3 +DA:144,10 +DA:146,3 +DA:147,3 +DA:148,3 +DA:149,7 +DA:151,6 +DA:152,6 +DA:153,6 +DA:154,2 +DA:156,6 +DA:160,1 +DA:175,1 +DA:185,1 +DA:195,2 +DA:203,2 +DA:211,2 +DA:213,2 +DA:214,2 +DA:215,1 +DA:219,1 +DA:227,6 +DA:228,6 +DA:229,6 +DA:232,6 +DA:233,16 +DA:234,39 +DA:235,4 +DA:236,4 +DA:241,6 +DA:249,3 +DA:250,3 +DA:251,7 +DA:252,6 +DA:256,3 +DA:264,1 +DA:272,9 +DA:275,9 +DA:276,8 +DA:278,8 +DA:286,8 +DA:287,1 +DA:293,8 +DA:294,8 +DA:300,6 +DA:302,6 +DA:303,6 +DA:307,6 +DA:309,6 +DA:310,6 +DA:313,2 +DA:314,2 +DA:325,19 +DA:334,3 +DA:342,1 +DA:350,2 +DA:361,3 +DA:363,2 +DA:364,2 +DA:366,1 +DA:367,1 +DA:370,3 +DA:378,4 +DA:381,4 +DA:384,4 +DA:385,2 +DA:395,2 +DA:404,4 +DA:405,4 +DA:410,3 +DA:412,2 +DA:414,3 +DA:415,3 +DA:417,1 +DA:428,2 +DA:436,2 +DA:437,2 +DA:443,1 +DA:456,4 +DA:459,4 +DA:460,4 +DA:467,4 +DA:468,1 +DA:474,4 +DA:475,4 +DA:479,3 +DA:480,3 +DA:481,9 +DA:482,9 +DA:483,9 +DA:485,3 +DA:487,1 +DA:491,4 +DA:501,4 +DA:506,4 +DA:507,4 +DA:514,4 +DA:515,1 +DA:521,4 +DA:522,4 +DA:526,3 +DA:527,3 +DA:528,3 +DA:530,1 +DA:533,4 +DA:538,9 +DA:540,9 +DA:541,1 +DA:542,1 +DA:543,1 +DA:544,1 +DA:545,2 +DA:546,2 +DA:547,2 +DA:550,9 +DA:573,2 +DA:574,2 +DA:575,2 +DA:576,2 +DA:579,2 +DA:580,2 +DA:583,2 +DA:584,2 +DA:587,2 +DA:588,2 +DA:589,2 +LF:157 +LH:157 +BRDA:39,0,0,34 +BRDA:59,1,0,1 +BRDA:59,1,1,0 +BRDA:67,2,0,68 +BRDA:92,3,0,1 +BRDA:92,4,0,3 +BRDA:92,4,1,3 +BRDA:107,5,0,4 +BRDA:107,5,1,0 +BRDA:113,6,0,1 +BRDA:113,6,1,3 +BRDA:114,7,0,1 +BRDA:144,8,0,3 +BRDA:144,8,1,7 +BRDA:144,9,0,10 +BRDA:144,9,1,9 +BRDA:148,10,0,2 +BRDA:148,10,1,1 +BRDA:149,11,0,6 +BRDA:149,11,1,1 +BRDA:149,12,0,7 +BRDA:149,12,1,6 +BRDA:160,13,0,1 +BRDA:160,13,1,0 +BRDA:195,14,0,1 +BRDA:195,14,1,1 +BRDA:203,15,0,1 +BRDA:203,15,1,1 +BRDA:214,16,0,1 +BRDA:234,17,0,4 +BRDA:234,18,0,39 +BRDA:234,18,1,39 +BRDA:234,18,2,16 +BRDA:251,19,0,6 +BRDA:252,20,0,3 +BRDA:252,20,1,3 +BRDA:271,21,0,9 +BRDA:275,22,0,8 +BRDA:281,23,0,8 +BRDA:281,23,1,0 +BRDA:286,24,0,1 +BRDA:294,25,0,8 +BRDA:294,25,1,0 +BRDA:303,26,0,6 +BRDA:325,27,0,1 +BRDA:325,27,1,18 +BRDA:334,28,0,0 +BRDA:334,28,1,3 +BRDA:358,29,0,1 +BRDA:361,30,0,2 +BRDA:361,30,1,1 +BRDA:377,31,0,4 +BRDA:381,32,0,2 +BRDA:381,32,1,2 +BRDA:384,33,0,2 +BRDA:384,33,1,2 +BRDA:388,34,0,2 +BRDA:388,34,1,0 +BRDA:397,35,0,0 +BRDA:397,35,1,2 +BRDA:397,36,0,2 +BRDA:397,36,1,0 +BRDA:398,37,0,2 +BRDA:398,37,1,0 +BRDA:410,38,0,2 +BRDA:431,39,0,2 +BRDA:431,39,1,0 +BRDA:462,40,0,1 +BRDA:462,40,1,3 +BRDA:462,41,0,4 +BRDA:462,41,1,1 +BRDA:463,42,0,4 +BRDA:463,42,1,0 +BRDA:467,43,0,1 +BRDA:509,44,0,0 +BRDA:509,44,1,4 +BRDA:509,45,0,4 +BRDA:509,45,1,1 +BRDA:510,46,0,4 +BRDA:510,46,1,0 +BRDA:514,47,0,1 +BRDA:540,48,0,1 +BRDA:545,49,0,1 +BRF:83 +BRH:69 +end_of_record +TN: +SF:src/validation_rule.ts +FN:19,(anonymous_0) +FN:27,(anonymous_1) +FN:34,(anonymous_2) +FN:52,(anonymous_3) +FNF:4 +FNH:4 +FNDA:24,(anonymous_0) +FNDA:1,(anonymous_1) +FNDA:30,(anonymous_2) +FNDA:20,(anonymous_3) +DA:12,8 +DA:13,24 +DA:17,24 +DA:20,24 +DA:21,24 +DA:28,1 +DA:35,30 +DA:36,30 +DA:39,30 +DA:41,30 +DA:42,35 +DA:43,19 +DA:46,11 +DA:53,20 +LF:14 +LH:14 +BRDA:42,0,0,19 +BRF:1 +BRH:1 +end_of_record diff --git a/test-report.html b/test-report.html deleted file mode 100644 index 162ed3c..0000000 --- a/test-report.html +++ /dev/null @@ -1,232 +0,0 @@ -Test Report

Test Report

Started: 2023-04-03 22:44:45
Suites (8)
8 passed
0 failed
0 pending
Tests (82)
82 passed
0 failed
0 pending
/home/me/shared_MAIN/sdkzer/__test__/sdkzer_spec.ts
15.284s
Sdkzer > .constructor > without providing initial attributes
should not initialize with a defined id or other attributes
passed
0.038s
Sdkzer > .constructor > providing initial attributes
should set the attributes (attr) and previous attributes (pAttrs) using the initial attributes
passed
0.003s
Sdkzer > .constructor > when default attributes are setted > without providing initial attributes
should set the default attributes
passed
0.011s
Sdkzer > .constructor > when default attributes are setted > providing initial attributes
should override the initial attributes with the default attributes
passed
0.01s
Sdkzer > .configure
should configure the default http headers
passed
0.004s
Sdkzer > .setDefaults
should update the attributes with the default attributes
passed
0.001s
Sdkzer > .defaults
should have a defaults() function defined that returns an empty object (no default attributes)
passed
0.009s
Sdkzer > .validate()
it should clean all invalid messages from previous validations
passed
0.037s
Sdkzer > .validate() > without any ValidationRule
should not generate invalid errors
passed
0.001s
Sdkzer > .validate() > with ValidationRules > when one ValidationRule doesn't pass
should generate invalid error messages for the invalid attribute
passed
0.001s
Sdkzer > .validate() > with ValidationRules > when all ValidationRules pass > when the record was previously invalid
should not contain invalid error messages even when the entity was previously invalid
passed
0s
Sdkzer > .isValid
it should be valid when there are no validation error messages
passed
0s
Sdkzer > .isValid
it should be invalid when there are no validation error messages
passed
0.001s
Sdkzer > .attr > when a value is not specified
should read the attribute value based on its key
passed
0.001s
Sdkzer > .attr > when a value is not specified > when the attribute key value uses dots notation
should read the attribute by accessing to the json keys nested between each dot
passed
0.013s
Sdkzer > .attr > when a value as second parameter is specified
should set the value for the attribute name specified in the first parameter
passed
0.001s
Sdkzer > .attr > when a value as second parameter is specified > when the attribute key value uses dots notation
should set the right attribute by accessing to the json keys between each dot
passed
0s
Sdkzer > .attr > when calling it without parameters
should return all attributes of the instance
passed
0.001s
Sdkzer > .baseEndpoint
shouldnt have an empty default base endpoint defined (function should exist)
passed
0.001s
Sdkzer > .resourceEndpoint
should have a default resourceEndpoint defined (function should exist)
passed
0s
Sdkzer > .isNew
should return true when there is no id in the record
passed
0s
Sdkzer > .isNew
should return false when there is an id in the record
passed
0.001s
Sdkzer > .hasChanged
should return false when no attributes have changed since last sync
passed
0s
Sdkzer > .hasChanged
should return true when attributes have changed since last sync
passed
0.001s
Sdkzer > .hasAttrChanged
should return true when the attribute has changed since last sync
passed
0.001s
Sdkzer > .hasAttrChanged
should return false when the attribute has not been changed since last sync
passed
0s
Sdkzer > .changedAttrs
should retrieve a list of attributes different from the origin
passed
0.001s
Sdkzer > .prevAttrs
should retrieve a list of the previous values for the attributes changed from the origin
passed
0.001s
Sdkzer > .prevValue
should retrieve the previous attribute value before last sync from origin
passed
0s
Sdkzer > .fetch > when the record has an id setted > in a successful request
should fetch data from the origin and resolve it in a Promise
passed
0.004s
Sdkzer > .fetch > when the record has an id setted > in a successful request
should set a property called 'syncing' during syncing with the right state
passed
0.001s
Sdkzer > .fetch > when the record has an id setted > in a successful request
should update the attributes parsed from the origin
passed
0.001s
Sdkzer > .fetch > when the record has an id setted > in a successful request
should take the parsed attributes from the origin and store them as previous attributes
passed
0.001s
Sdkzer > .fetch > when the record has an id setted > in a successful request > when not using custom HttpQuery
should make an http request to the right endpoint
passed
0.001s
Sdkzer > .fetch > when the record has an id setted > in a successful request > when passing a custom HttpQuery
should merge the HttpQuery with the default HttpQuery
passed
0.001s
Sdkzer > .fetch > when the record has an id setted > in a failed request
should set a property called 'syncing' during syncing with the right state
passed
0.001s
Sdkzer > .fetch > when the record has an id setted > in a failed request
it should resolve into an error
passed
0.001s
Sdkzer > .fetch > when the record hasn't an id setted
shouldn't make any request
passed
0.001s
Sdkzer > .parseRecord
should parse the data as it comes
passed
0s
Sdkzer > .parseRecord
should parse the data that is on a specific key when a prefix attribute is specified
passed
0.001s
Sdkzer > .toOriginJSON > with the default parser
should return the record attributes as they are for the origin
passed
0s
Sdkzer > .toOriginJSON > with a custom parser
should parse the record attributes correctly for the origin
passed
0.001s
Sdkzer > .toOrigin
should retrieve the attributes in JSON format by default
passed
0.001s
Sdkzer > .toOrigin
should retrieve the attributes in JSON format when 'json' format is specified
passed
0s
Sdkzer > .toOrigin
should retrieve the attributes in xml format when 'xml' format is specified
passed
0.001s
Sdkzer > .save > in a successful request > when the record has an id setted (considered an existing record in the origin)
should update the attributes in the origin using the local attributes and using PUT method
passed
0.002s
Sdkzer > .save > in a successful request > when the record does't have an id setted (considered a new record in the origin)
should create the record in the origin using the local attributes and using POST method
passed
0.001s
Sdkzer > .save > in a successful request > when the record does't have an id setted (considered a new record in the origin)
should set the id attribute retrieved from the origin
passed
0.001s
Sdkzer > .save > in a failed request
it should resolve into an error
passed
0s
Sdkzer > .destroy
should try to destroy the record in the origin
passed
0.002s
Sdkzer > .destroy > in a failed request
it should resolve into an error
passed
0.002s
Sdkzer > #fetchIndex > in a successful request > when not using custom HttpQuery
should make an http request to the right endpoint
passed
0.001s
Sdkzer > #fetchIndex > in a successful request > when passing a custom HttpQuery
should merge the HttpQuery with the default HttpQuery
passed
0.001s
Sdkzer > #fetchIndex > in a successful request
should fetch a collection of records from the origin and return a Promise resolves into an array of instances of Item
passed
0.001s
Sdkzer > #fetchIndex > in a failed request
it should resolve into an error
passed
0.001s
Sdkzer > #fetchOne > in a successful request > when not using custom HttpQuery
should make an http request to the right endpoint
passed
0.001s
Sdkzer > #fetchOne > in a successful request > when passing a custom HttpQuery
should merge the HttpQuery with the default HttpQuery
passed
0.001s
Sdkzer > #fetchOne > in a successful request
should fetch a record from the origin and return a Promise resolves an instance of Item
passed
0.001s
Sdkzer > #fetchOne > in a failed request
it should resolve into an error
passed
0s
/home/me/shared_MAIN/sdkzer/__test__/validation_rules/email_validator_spec.ts
0.976s
EmailValidator
it should be INVALID with 'undefined'
passed
0.02s
EmailValidator
it should be INVALID with ''
passed
0.001s
EmailValidator
it should be INVALID with 'invalidemail'
passed
0s
EmailValidator
it should be INVALID with 'in@valid'
passed
0s
EmailValidator
it should be INVALID with 'in@valid..email'
passed
0.001s
EmailValidator
it should be VALID with 'valid@email.com'
passed
0.001s
/home/me/shared_MAIN/sdkzer/__test__/validation_rule_spec.ts
0.955s
ValidationRule > .constructor()
should assign the value and validator params within the instance
passed
0.006s
ValidationRule > .constructor()
should initialize the _invalidMessage as empty
passed
0.001s
ValidationRule > .isValid()
should assign the original and final values within the instance
passed
0.003s
ValidationRule > .isValid()
should return true when all the ValidationRule conditions return true
passed
0.001s
ValidationRule > .isValid()
should return false when at least one of the ValidationRule conditions return false
passed
0.002s
ValidationRule > .addInvalidMessage()
should add a message to the invalid messages
passed
0.001s
/home/me/shared_MAIN/sdkzer/__test__/validation_rules/allowed_value_switch_validator_spec.ts
0.782s
AllowedValueSwitchValidator
it should be INVALID when transitioning to invalid values
passed
0.003s
AllowedValueSwitchValidator
it should be VALID when transitioning to an allowed value
passed
0.001s
/home/me/shared_MAIN/sdkzer/__test__/validation_rules/reg_exp_validator_spec.ts
0.922s
RegExpValidator
it should be INVALID when not matching the regexp
passed
0.003s
RegExpValidator
it should be VALID when matching the regexp
passed
0s
/home/me/shared_MAIN/sdkzer/__test__/validation_rules/length_validator_spec.ts
0.938s
LengthValidator
it should be INVALID with a smaller array items than the minimum required
passed
0.005s
LengthValidator
it should be INVALID with a higher array items than the maximum required
passed
0.001s
LengthValidator
it should be VALID with the right amount of items required
passed
0.001s
/home/me/shared_MAIN/sdkzer/__test__/validation_rules/number_validator_spec.ts
0.779s
NumberValidator
it should be INVALID with a smaller number than the minimum required
passed
0.005s
NumberValidator
it should be INVALID with a higher number than the maximum required
passed
0s
/home/me/shared_MAIN/sdkzer/__test__/validation_rules/required_validator_spec.ts
0.906s
RequiredValidator
it should be INVALID when the value is undefined
passed
0.008s
RequiredValidator
it should be VALID when a value is defined
passed
0.028s
\ No newline at end of file