diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77d706f..fda96fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ image: hosttoday/ht-docker-node:npmci cache: paths: - - .yarn/ + - .npmci_cache/ key: "$CI_BUILD_STAGE" stages: @@ -26,8 +26,8 @@ mirror: snyk: stage: security script: - - npmci command yarn global add snyk - - npmci command yarn install --ignore-scripts + - npmci command npm install -g snyk + - npmci command npm install --ignore-scripts - npmci command snyk test tags: - docker @@ -117,7 +117,7 @@ pages: image: hosttoday/ht-docker-node:npmci stage: metadata script: - - npmci command yarn global add npmpage + - npmci command npm install -g npmpage - npmci command npmpage tags: - docker diff --git a/package-lock.json b/package-lock.json index 6b9029e..8c0052d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,30 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@pushrocks/smartcli": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@pushrocks/smartcli/-/smartcli-3.0.1.tgz", - "integrity": "sha512-NeLzHOAf2nCdgZq5QUNmiDE4xVo/HQktqxXmNGAf4kt6FnXlHe3pHVMjAB6mU7DmuoN0uY4qnkQAQYgFJ0MZ4A==", - "requires": { - "@types/yargs": "^11.0.0", - "beautylog": "^6.1.10", - "lik": "^2.0.5", - "rxjs": "^6.0.0", - "smartparam": "1.0.2", - "smartq": "^1.1.8", - "yargs": "^11.0.0" - }, - "dependencies": { - "rxjs": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.2.0.tgz", - "integrity": "sha512-qBzf5uu6eOKiCZuAE0SgZ0/Qp+l54oeVxFfC2t+mJ2SFI6IB8gmMdJHs5DUMu5kqifqcCtsKS2XHjhZu6RKvAw==", - "requires": { - "tslib": "^1.9.0" - } - } - } - }, "@types/body-parser": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz", @@ -227,11 +203,6 @@ } } }, - "@types/yargs": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-11.0.0.tgz", - "integrity": "sha512-vFql3tOxs6clgh+WVoLW3nOkNGCdeKsMU6mQZkOerJpV/CR9Xc1c1lZ+kYU+hNSobrQIOcNovWfPFDJIhcG5Pw==" - }, "accepts": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", @@ -251,11 +222,6 @@ "resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz", "integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo=" }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" - }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -404,11 +370,6 @@ "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, "camelize": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz", @@ -472,16 +433,6 @@ "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-1.3.1.tgz", "integrity": "sha512-1QL4544moEsDVH9T/l6Cemov/37iv1RtoKf7NJ04A60+4MREXNfx/QvavbH6QoGdsD4N4Mwy49cmaINR/o2mdg==" }, - "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", - "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" - } - }, "clone": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", @@ -507,11 +458,6 @@ "readable-stream": "^2.3.5" } }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", @@ -584,16 +530,6 @@ "vary": "^1" } }, - "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, "dasherize": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dasherize/-/dasherize-2.0.0.tgz", @@ -607,11 +543,6 @@ "ms": "2.0.0" } }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" - }, "deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -788,20 +719,6 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, - "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, "expect-ct": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/expect-ct/-/expect-ct-0.1.1.tgz", @@ -951,14 +868,6 @@ } } }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "requires": { - "locate-path": "^2.0.0" - } - }, "first-chunk-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz", @@ -1007,22 +916,12 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, - "get-caller-file": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", - "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=" - }, "get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -1171,11 +1070,6 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" - }, "ipaddr.js": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", @@ -1191,16 +1085,6 @@ "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" - }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" - }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -1209,11 +1093,6 @@ "has": "^1.0.1" } }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, "is-symbol": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", @@ -1229,11 +1108,6 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" - }, "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", @@ -1251,14 +1125,6 @@ "graceful-fs": "^4.1.6" } }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "requires": { - "invert-kv": "^1.0.0" - } - }, "leakage": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/leakage/-/leakage-0.3.0.tgz", @@ -1291,15 +1157,6 @@ "symbol-tree": "^3.2.2" } }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, "lodash": { "version": "4.17.10", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", @@ -1392,15 +1249,6 @@ "chalk": "^2.0.1" } }, - "lru-cache": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", - "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, "make-error": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", @@ -1412,14 +1260,6 @@ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" }, - "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", - "requires": { - "mimic-fn": "^1.0.0" - } - }, "memwatch-next": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz", @@ -1532,19 +1372,6 @@ "typings-global": "^1.0.6" } }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "requires": { - "path-key": "^2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -1609,42 +1436,6 @@ "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", - "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" - } - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" - }, - "p-limit": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", - "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" - }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -1666,21 +1457,11 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" - }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" - }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -1722,11 +1503,6 @@ "ipaddr.js": "1.6.0" } }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" - }, "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", @@ -1782,16 +1558,6 @@ "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=" }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" - }, "require-reload": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/require-reload/-/require-reload-0.2.2.tgz", @@ -1862,29 +1628,11 @@ "send": "0.16.2" } }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, "setprototypeof": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" - }, "shortid": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.8.tgz", @@ -1970,18 +1718,6 @@ "vinyl-file": "^3.0.0" } }, - "smartparam": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/smartparam/-/smartparam-1.0.2.tgz", - "integrity": "sha512-Q09m98X6+WG9q0Wpj6LXXSqGdYUItLAsj5ypJ8pRkGtry2V4zZzhimv4xviViLIfrgIBn5uTfbjNU0is7+WRTA==", - "requires": { - "beautylog": "6.1.10", - "is-promise": "^2.1.0", - "minimatch": "^3.0.4", - "smartq": "^1.1.6", - "typings-global": "^1.0.20" - } - }, "smartpath": { "version": "3.2.8", "resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz", @@ -2157,15 +1893,6 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -2174,14 +1901,6 @@ "safe-buffer": "~5.1.0" } }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "requires": { - "ansi-regex": "^3.0.0" - } - }, "strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", @@ -2207,11 +1926,6 @@ "strip-bom": "^2.0.0" } }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" - }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -2258,9 +1972,9 @@ "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" }, "ts-node": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.0.3.tgz", - "integrity": "sha512-ARaOMNFEPKg2ZuC1qJddFvHxHNFVckR0g9xLxMIoMqSSIkDc8iS4/LoV53EdDWWNq2FGwqcEf0bVVGJIWpsznw==", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.0.5.tgz", + "integrity": "sha512-iNhWu2hli9/1p9PGLJ/4OZS+NR0IVEVk63KCrH3qa7jJZxXa+oPheBj5JyM8tuQM9RkBpw1PrNUEUPJR9wTGDw==", "dev": true, "requires": { "arrify": "^1.0.0", @@ -2273,11 +1987,6 @@ "yn": "^2.0.0" } }, - "tslib": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.1.tgz", - "integrity": "sha512-avfPS28HmGLLc2o4elcc2EIq2FcH++Yo5YxpBZi9Yw93BCTGFthI4HPE4Rpep6vSYQaK8e69PelM44tPj+RaQg==" - }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -2368,61 +2077,6 @@ "vinyl": "^2.0.1" } }, - "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -2453,43 +2107,6 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, - "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" - }, - "yargs": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.0.0.tgz", - "integrity": "sha512-Rjp+lMYQOWtgqojx1dEWorjCofi1YN7AoFvYV7b1gx/7dAAeuI4kN5SZiEvr0ZmsZTOpDRcCqrpI10L31tFkBw==", - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - } - }, - "yargs-parser": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz", - "integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=", - "requires": { - "camelcase": "^4.1.0" - } - }, "yeast": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", diff --git a/package.json b/package.json index 04a2ab1..24e1321 100644 --- a/package.json +++ b/package.json @@ -13,16 +13,17 @@ "format": "(gitzone format)" }, "devDependencies": { - "@types/node": "^9.6.0", + "@types/node": "^9.6.18", "tapbundle": "^2.0.0", - "ts-node": "^6.0.3", + "ts-node": "^6.0.5", "typescript": "^2.8.3" }, + "peerDependencies": { + "rxjs": "*" + }, "dependencies": { - "@pushrocks/smartcli": "^3.0.1", "lik": "^2.0.5", "nodehash": "^1.0.4", - "rxjs": "^5.5.8", "smartdelay": "^1.0.4", "smartexpress": "^1.0.21", "smartfile": "^4.2.28", @@ -32,4 +33,4 @@ "smartsocket": "^1.1.19", "smarttime": "^2.0.0" } -} +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index ea07548..955f110 100644 --- a/test/test.ts +++ b/test/test.ts @@ -5,8 +5,8 @@ import * as smartuniverse from '../ts/index'; import { Observable } from 'rxjs'; let testUniverse: smartuniverse.Universe; -let testUniverseClient: smartuniverse.UniverseClient; -let testMessageObservable: Observable; +let testUniverseClient: smartuniverse.ClientUniverse; +let testClientChannel: smartuniverse.ClientUniverseChannel; tap.test('first test', async () => { testUniverse = new smartuniverse.Universe({ @@ -20,10 +20,19 @@ tap.test('add a message to the SmartUniverse', async () => { // testing message handling tap.test('create smartuniverse client', async () => { - testUniverseClient = new smartuniverse.UniverseClient({ + testUniverseClient = new smartuniverse.ClientUniverse({ serverAddress: 'http://localhost:8765' }); - expect(testUniverseClient).to.be.instanceof(smartuniverse.UniverseClient); + expect(testUniverseClient).to.be.instanceof(smartuniverse.ClientUniverse); +}); + +tap.test('should add a channel to the universe', async () => { + await testUniverse.addChannel('testChannel', 'testPassword'); +}); + +tap.test('should get a observable correctly', async () => { + testClientChannel = await testUniverseClient.getChannel('testChannel'); + expect(testClientChannel).to.be.instanceof(smartuniverse.ClientUniverseChannel); }); tap.test('should send a message correctly', async () => { @@ -32,10 +41,6 @@ tap.test('should send a message correctly', async () => { }); }); -tap.test('should get a observable correctly', async () => { - testMessageObservable = testUniverseClient.getMessageObservable(); -}); - tap.test('should receive a message correctly', async () => {}); tap.test('should disconnect the client correctly', async () => { diff --git a/ts/index.ts b/ts/index.ts index 57e1105..e934b6d 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,3 +1,10 @@ +// Client classes +export * from './smartuniverse.classes.clientuniverse'; +export * from './smartuniverse.classes.clientuniversechannel'; + +// Server classes export * from './smartuniverse.classes.universe'; -export * from './smartuniverse.classes.universeclient'; +export * from './smartuniverse.classes.universecache'; +export * from './smartuniverse.classes.universechannel'; export * from './smartuniverse.classes.universemessage'; +export * from './smartuniverse.interfaces'; diff --git a/ts/smartuniverse.classes.universeclient.ts b/ts/smartuniverse.classes.clientuniverse.ts similarity index 64% rename from ts/smartuniverse.classes.universeclient.ts rename to ts/smartuniverse.classes.clientuniverse.ts index fa1f407..17c9538 100644 --- a/ts/smartuniverse.classes.universeclient.ts +++ b/ts/smartuniverse.classes.clientuniverse.ts @@ -1,14 +1,16 @@ import * as plugins from './smartuniverse.plugins'; +import { Objectmap } from 'lik'; import { Observable } from 'rxjs'; import { Smartsocket, SmartsocketClient } from 'smartsocket'; import * as url from 'url'; import { + ClientUniverseChannel, IServerGetMessagesRequestBody, - IServerPutMessageRequestBody -} from './smartuniverse.classes.universe'; -import { UniverseMessage } from './smartuniverse.classes.universemessage'; + IServerPutMessageRequestBody, + UniverseMessage +} from './'; export interface IClientOptions { serverAddress: string; @@ -18,10 +20,12 @@ export interface IClientOptions { * this class is for client side only!!! * allows connecting to a universe server */ -export class UniverseClient { +export class ClientUniverse { public options; - private socketClient: plugins.smartsocket.SmartsocketClient; - private observableIntake: plugins.smartrx.ObservableIntake; + public socketClient: plugins.smartsocket.SmartsocketClient; + public observableIntake: plugins.smartrx.ObservableIntake; + + public channelCache = new Objectmap(); constructor(optionsArg: IClientOptions) { this.options = optionsArg; @@ -38,7 +42,21 @@ export class UniverseClient { }); } - public getMessageObservable() { + public async getChannel(channelName: string): Promise { + await this.checkConnection(); + const clientUniverseChannel = await ClientUniverseChannel.createClientUniverseChannel( + this, + channelName + ); + this.channelCache.add(clientUniverseChannel); + return clientUniverseChannel; + } + + public close() { + this.socketClient.disconnect(); + } + + private async checkConnection() { if (!this.socketClient && !this.observableIntake) { const parsedURL = url.parse(this.options.serverAddress); this.socketClient = new SmartsocketClient({ @@ -51,10 +69,5 @@ export class UniverseClient { this.observableIntake = new plugins.smartrx.ObservableIntake(); this.socketClient.connect(); } - return this.observableIntake.observable; - } - - public close() { - this.socketClient.disconnect(); } } diff --git a/ts/smartuniverse.classes.clientuniversechannel.ts b/ts/smartuniverse.classes.clientuniversechannel.ts new file mode 100644 index 0000000..402a5ef --- /dev/null +++ b/ts/smartuniverse.classes.clientuniversechannel.ts @@ -0,0 +1,34 @@ +import * as plugins from './smartuniverse.plugins'; + +import { ClientUniverse, IUniverseChannel } from './'; + +export class ClientUniverseChannel implements IUniverseChannel { + // ====== + // STATIC + // ====== + public static async createClientUniverseChannel( + clientUniverseArg: ClientUniverse, + channelName: string + ): Promise { + const clientChannel = new ClientUniverseChannel(clientUniverseArg); + await clientChannel.transmitSubscription(); + return clientChannel; + } + + // ======== + // INSTANCE + // ======== + + public clientUniverse: ClientUniverse; + + constructor(clientUniverseArg: ClientUniverse) { + this.clientUniverse = clientUniverseArg; + } + + /** + * tells the universe about this instances interest into a channel + */ + public async transmitSubscription() { + this.clientUniverse.socketClient; + } +} diff --git a/ts/smartuniverse.classes.clientuniversemessage.ts b/ts/smartuniverse.classes.clientuniversemessage.ts new file mode 100644 index 0000000..f87e26c --- /dev/null +++ b/ts/smartuniverse.classes.clientuniversemessage.ts @@ -0,0 +1,15 @@ +import * as plugins from './smartuniverse.plugins'; + +import { IUniverseMessage } from './'; + +export class ClientUniverseMessage implements IUniverseMessage { + // ====== + // STATIC + // ====== + createMessage(messageArg: string, payloadArg: any) {} + + // ======== + // INSTANCE + // ======== + constructor(messageArg, payloadArg) {} +} diff --git a/ts/smartuniverse.classes.universe.ts b/ts/smartuniverse.classes.universe.ts index c5a7850..29961d1 100644 --- a/ts/smartuniverse.classes.universe.ts +++ b/ts/smartuniverse.classes.universe.ts @@ -1,9 +1,7 @@ import * as plugins from './smartuniverse.plugins'; import { Handler, Route, Server } from 'smartexpress'; -import { UniverseChannel } from './smartuniverse.classes.universechannel'; -import { UniverseMessage } from './smartuniverse.classes.universemessage'; -import { UniverseCache } from './smartuniverse.classes.universecache'; +import { UniverseCache, UniverseChannel, UniverseMessage } from './'; import * as paths from './smartuniverse.paths'; @@ -57,6 +55,14 @@ export class Universe { this.universeCache = new UniverseCache(this.options.messageExpiryInMilliseconds); } + /** + * adds a channel to the Universe + */ + public async addChannel(nameArg: string, passphraseArg: string) { + const newChannel = new UniverseChannel(this.universeCache, nameArg, passphraseArg); + this.universeCache.channelMap.add(newChannel); + } + /** * initiates a server */ @@ -68,46 +74,13 @@ export class Universe { port: portArg }); - // message handling - // adds messages - const addMessageHandler = new Handler('PUT', async request => { - const requestBody: IServerPutMessageRequestBody = request.body; - const message = new UniverseMessage( - requestBody.message, - requestBody.channel, - requestBody.passphrase, - requestBody.payload - ); - this.universeCache.addMessage(message); - console.log(requestBody); - return true; - }); - - // gets messages - const readMessageHandler = new Handler('GET', request => { - const done = plugins.smartq.defer(); - const requestBody = request.body; - const messageObservable = this.universeCache.readMessagesYoungerThan(requestBody.since); - messageObservable.toArray().subscribe(universeMessageArrayArg => { - done.resolve(universeMessageArrayArg); - }); - return done.promise; - }); - - // create new Route for messages - const messageRoute = new Route(this.smartexpressServer, 'message'); - messageRoute.addHandler(addMessageHandler); - messageRoute.addHandler(readMessageHandler); - - const leaderElectionRoute = new Route(this.smartexpressServer, 'leadelection'); - // TODO: implement Handlers for leader election - // add websocket upgrade this.smartsocket = new plugins.smartsocket.Smartsocket({ port: 12345 // fix this within smartsocket }); - this.smartsocket.setExternalServer('express', this.smartexpressServer as any); // should work with express as well + this.smartsocket.setExternalServer('express', this.smartexpressServer as any); + // should work with express as well this.smartsocket.start(); await this.smartexpressServer.start(); diff --git a/ts/smartuniverse.classes.universecache.ts b/ts/smartuniverse.classes.universecache.ts index 97fb9d6..cc45908 100644 --- a/ts/smartuniverse.classes.universecache.ts +++ b/ts/smartuniverse.classes.universecache.ts @@ -12,26 +12,27 @@ import { rxjs } from 'smartrx'; * universe store handles the creation, storage and retrieval of messages. */ export class UniverseCache { + // ======== + // INSTANCE + // ======== public standardMessageExpiry: number; public destructionTime: number = 60000; /** * stores messages for this instance */ - public messageCache = new Objectmap(); + public messageMap = new Objectmap(); /** * stores the channels that are available within the universe */ - public channelCache = new Objectmap(); + public channelMap = new Objectmap(); /** * allows messages to be processed in a blacklist mode for further analysis */ public blackListChannel = new UniverseChannel(this, 'blacklist', 'nada'); - private lastId: number = 0; // stores the last id - constructor(standardMessageExpiryArg: number) { this.standardMessageExpiry = standardMessageExpiryArg; } @@ -44,14 +45,14 @@ export class UniverseCache { public async addMessage(messageArg: UniverseMessage) { messageArg.setUniverseCache(this); UniverseChannel.authorizeAMessageForAChannel(this, messageArg); - this.messageCache.add(messageArg); + this.messageMap.add(messageArg); } /** * Read a message from the UniverseStore */ public readMessagesYoungerThan(unixTimeArg?: number): Observable { - const messageObservable = rxjs.Observable.from(this.messageCache.getArray()).filter( + const messageObservable = rxjs.Observable.from(this.messageMap.getArray()).filter( messageArg => { return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime); } diff --git a/ts/smartuniverse.classes.universechannel.ts b/ts/smartuniverse.classes.universechannel.ts index ac63ce3..78b46b8 100644 --- a/ts/smartuniverse.classes.universechannel.ts +++ b/ts/smartuniverse.classes.universechannel.ts @@ -30,7 +30,7 @@ export class UniverseChannel { * returns boolean wether certain channel exists */ public static async doesChannelExists(universeCacheArg: UniverseCache, channelNameArg: string) { - const channel = universeCacheArg.channelCache.find(channelArg => { + const channel = universeCacheArg.channelMap.find(channelArg => { return channelArg.name === channelNameArg; }); if (channel) { @@ -44,7 +44,7 @@ export class UniverseChannel { universeCacheArg: UniverseCache, universeMessageArg: UniverseMessage ) { - const foundChannel = universeCacheArg.channelCache.find(universeChannel => { + const foundChannel = universeCacheArg.channelMap.find(universeChannel => { const result = universeChannel.authenticate(universeMessageArg); return result; }); @@ -86,4 +86,6 @@ export class UniverseChannel { this.passphrase === universeMessageArg.requestedChannelPassphrase ); } + + public pushToClients(messageArg: UniverseMessage) {} } diff --git a/ts/smartuniverse.classes.universemessage.ts b/ts/smartuniverse.classes.universemessage.ts index 80d30c6..131a42c 100644 --- a/ts/smartuniverse.classes.universemessage.ts +++ b/ts/smartuniverse.classes.universemessage.ts @@ -2,7 +2,6 @@ import * as plugins from './smartuniverse.plugins'; import { Objectmap } from 'lik'; - import { Timer, TimeStamp } from 'smarttime'; import { Universe } from './smartuniverse.classes.universe'; import { UniverseChannel } from './smartuniverse.classes.universechannel'; @@ -89,7 +88,7 @@ export class UniverseMessage { // set up self destruction by removing this from the parent messageCache this.destructionTimer.completed.then(async () => { - this.universeCache.messageCache.remove(this); + this.universeCache.messageMap.remove(this); }); } else { this.fallBackDestruction(); diff --git a/ts/smartuniverse.cli.ts b/ts/smartuniverse.cli.ts deleted file mode 100644 index c4ede08..0000000 --- a/ts/smartuniverse.cli.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as plugins from './smartuniverse.plugins'; - -import { Universe } from './index'; - -process.env.CLI = 'true'; - -const universeCli = new plugins.smartcli.Smartcli(); - -universeCli.standardTask().subscribe(async argvArg => { - const standardUniverse = new Universe({ - messageExpiryInMilliseconds: 60000 - }); - await standardUniverse.initServer(8765); -}); diff --git a/ts/smartuniverse.interfaces.ts b/ts/smartuniverse.interfaces.ts new file mode 100644 index 0000000..ff6060e --- /dev/null +++ b/ts/smartuniverse.interfaces.ts @@ -0,0 +1,3 @@ +export interface IUniverseChannel {} + +export interface IUniverseMessage {} diff --git a/ts/smartuniverse.plugins.ts b/ts/smartuniverse.plugins.ts index 7844a31..1442e90 100644 --- a/ts/smartuniverse.plugins.ts +++ b/ts/smartuniverse.plugins.ts @@ -1,4 +1,3 @@ -import * as smartcli from '@pushrocks/smartcli'; import * as lik from 'lik'; import * as nodehash from 'nodehash'; import * as path from 'path'; @@ -15,7 +14,6 @@ export { lik, nodehash, path, - smartcli, smartdelay, smartexpress, smartfile,