From 8448004445a4aed4cf2be083b7aec9ce2e514827 Mon Sep 17 00:00:00 2001 From: xialei_li Date: Thu, 16 Sep 2021 19:56:47 +0800 Subject: [PATCH] fix test without assert, try to add CI --- Jenkinsfile | 9 + src/connector/node-rest/examples/demo.js | 18 - src/connector/node-rest/package-lock.json | 361 ++++++++++++++++++- src/connector/node-rest/package.json | 8 +- src/connector/node-rest/src/restCursor.js | 14 +- src/connector/node-rest/src/restResult.js | 10 +- src/connector/node-rest/test/testRestConn.js | 30 +- 7 files changed, 405 insertions(+), 45 deletions(-) delete mode 100644 src/connector/node-rest/examples/demo.js diff --git a/Jenkinsfile b/Jenkinsfile index 4a584fbb35..25e5bc62ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -240,6 +240,15 @@ pipeline { node nanosecondTest.js ''' + + sh ''' + cd ${WKC}/src/connector/node-rest/ + npm run build > /dev/null 2>&1 + npm run build:test > /dev/null 2>&1 + npm run test + + ''' + sh ''' cd ${WKC}/tests/examples/C#/taosdemo mcs -out:taosdemo *.cs > /dev/null 2>&1 diff --git a/src/connector/node-rest/examples/demo.js b/src/connector/node-rest/examples/demo.js deleted file mode 100644 index e913e705e3..0000000000 --- a/src/connector/node-rest/examples/demo.js +++ /dev/null @@ -1,18 +0,0 @@ -import taos from "../src" -// import taos from "taos-rest" - -let option = { - host:'u195', - port:'6041', - pass:'taosdata', - user:'root' -} -let conn = taos.connect(option); -console.log("url showDataBases:" + conn._apiUrl()) ; - -(async () => { - data = await conn.query("show databases").catch(err => { - console.log(err); - }); - console.log(data); -})() \ No newline at end of file diff --git a/src/connector/node-rest/package-lock.json b/src/connector/node-rest/package-lock.json index d48e169522..17a253eb0e 100644 --- a/src/connector/node-rest/package-lock.json +++ b/src/connector/node-rest/package-lock.json @@ -1,5 +1,5 @@ { - "name": "taos-rest", + "name": "td-rest-connector", "version": "1.0.0", "lockfileVersion": 1, "requires": true, @@ -137,12 +137,28 @@ "sprintf-js": "~1.0.2" } }, + "assert": { + "version": "2.0.0", + "resolved": "https://registry.npm.taobao.org/assert/download/assert-2.0.0.tgz", + "integrity": "sha1-lfwcYW1IcTUQaA8ury0Q3SLgLTI=", + "requires": { + "es6-object-assign": "^1.1.0", + "is-nan": "^1.2.1", + "object-is": "^1.0.1", + "util": "^0.12.0" + } + }, "astral-regex": { "version": "2.0.0", "resolved": "https://registry.npm.taobao.org/astral-regex/download/astral-regex-2.0.0.tgz", "integrity": "sha1-SDFDxWeu7UeFdZwIZXhtx319LjE=", "dev": true }, + "available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.nlark.com/available-typed-arrays/download/available-typed-arrays-1.0.5.tgz", + "integrity": "sha1-kvlWFlAQadB9EO2y/DfT4cZRI7c=" + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.nlark.com/balanced-match/download/balanced-match-1.0.2.tgz", @@ -159,6 +175,15 @@ "concat-map": "0.0.1" } }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.nlark.com/call-bind/download/call-bind-1.0.2.tgz", + "integrity": "sha1-sdTonmiBGcPJqQOtMKuy9qkZvjw=", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.nlark.com/callsites/download/callsites-3.1.0.tgz", @@ -263,6 +288,14 @@ "integrity": "sha1-pvLc5hL63S7x9Rm3NVHxfoUZmDE=", "dev": true }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.nlark.com/define-properties/download/define-properties-1.1.3.tgz", + "integrity": "sha1-z4jabL7ib+bbcJT2HYcMvYTO6fE=", + "requires": { + "object-keys": "^1.0.12" + } + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npm.taobao.org/doctrine/download/doctrine-3.0.0.tgz", @@ -287,6 +320,46 @@ "ansi-colors": "^4.1.1" } }, + "es-abstract": { + "version": "1.18.6", + "resolved": "https://registry.nlark.com/es-abstract/download/es-abstract-1.18.6.tgz?cache=0&sync_timestamp=1631076806734&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fes-abstract%2Fdownload%2Fes-abstract-1.18.6.tgz", + "integrity": "sha1-LETj6npiVQORZNJlWXd6bZeMtFY=", + "requires": { + "call-bind": "^1.0.2", + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", + "get-symbol-description": "^1.0.0", + "has": "^1.0.3", + "has-symbols": "^1.0.2", + "internal-slot": "^1.0.3", + "is-callable": "^1.2.4", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.4", + "is-string": "^1.0.7", + "object-inspect": "^1.11.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.nlark.com/es-to-primitive/download/es-to-primitive-1.2.1.tgz", + "integrity": "sha1-5VzUyc3BiLzvsDs2bHNjI/xciYo=", + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "es6-object-assign": { + "version": "1.1.0", + "resolved": "https://registry.npm.taobao.org/es6-object-assign/download/es6-object-assign-1.1.0.tgz", + "integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=" + }, "esbuild": { "version": "0.12.25", "resolved": "https://registry.nlark.com/esbuild/download/esbuild-0.12.25.tgz", @@ -494,18 +567,47 @@ "integrity": "sha1-ZL/tXLaP48p4s+shStl7Y77c5WE=", "dev": true }, + "foreach": { + "version": "2.0.5", + "resolved": "https://registry.npm.taobao.org/foreach/download/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.nlark.com/fs.realpath/download/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npm.taobao.org/function-bind/download/function-bind-1.1.1.tgz", + "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=" + }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.nlark.com/functional-red-black-tree/download/functional-red-black-tree-1.0.1.tgz?cache=0&sync_timestamp=1618847182644&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ffunctional-red-black-tree%2Fdownload%2Ffunctional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.nlark.com/get-intrinsic/download/get-intrinsic-1.1.1.tgz", + "integrity": "sha1-FfWfN2+FXERpY5SPDSTNNje0q8Y=", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, + "get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.nlark.com/get-symbol-description/download/get-symbol-description-1.0.0.tgz", + "integrity": "sha1-f9uByQAQH71WTdXxowr1qtweWNY=", + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + } + }, "glob": { "version": "7.1.7", "resolved": "https://registry.nlark.com/glob/download/glob-7.1.7.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fglob%2Fdownload%2Fglob-7.1.7.tgz", @@ -538,12 +640,38 @@ "type-fest": "^0.20.2" } }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npm.taobao.org/has/download/has-1.0.3.tgz", + "integrity": "sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-bigints": { + "version": "1.0.1", + "resolved": "https://registry.npm.taobao.org/has-bigints/download/has-bigints-1.0.1.tgz", + "integrity": "sha1-ZP5qywIGc+O3jbA1pa9pqp0HsRM=" + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.nlark.com/has-flag/download/has-flag-3.0.0.tgz?cache=0&sync_timestamp=1626716143790&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhas-flag%2Fdownload%2Fhas-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npm.taobao.org/has-symbols/download/has-symbols-1.0.2.tgz?cache=0&sync_timestamp=1614443577352&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhas-symbols%2Fdownload%2Fhas-symbols-1.0.2.tgz", + "integrity": "sha1-Fl0wcMADCXUqEjakeTMeOsVvFCM=" + }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.nlark.com/has-tostringtag/download/has-tostringtag-1.0.0.tgz?cache=0&sync_timestamp=1628197490246&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhas-tostringtag%2Fdownload%2Fhas-tostringtag-1.0.0.tgz", + "integrity": "sha1-fhM4GKfTlHNPlB5zw9P5KR5liyU=", + "requires": { + "has-symbols": "^1.0.2" + } + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.nlark.com/ignore/download/ignore-4.0.6.tgz", @@ -579,8 +707,56 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz", - "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=", - "dev": true + "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=" + }, + "internal-slot": { + "version": "1.0.3", + "resolved": "https://registry.nlark.com/internal-slot/download/internal-slot-1.0.3.tgz", + "integrity": "sha1-c0fjB97uovqsKsYgXUvH00ln9Zw=", + "requires": { + "get-intrinsic": "^1.1.0", + "has": "^1.0.3", + "side-channel": "^1.0.4" + } + }, + "is-arguments": { + "version": "1.1.1", + "resolved": "https://registry.nlark.com/is-arguments/download/is-arguments-1.1.1.tgz?cache=0&sync_timestamp=1628202102318&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-arguments%2Fdownload%2Fis-arguments-1.1.1.tgz", + "integrity": "sha1-FbP4j9oB8ql/7ITKdhpWDxI++ps=", + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.nlark.com/is-bigint/download/is-bigint-1.0.4.tgz?cache=0&sync_timestamp=1628747504782&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-bigint%2Fdownload%2Fis-bigint-1.0.4.tgz", + "integrity": "sha1-CBR6GHW8KzIAXUHM2Ckd/8ZpHfM=", + "requires": { + "has-bigints": "^1.0.1" + } + }, + "is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.nlark.com/is-boolean-object/download/is-boolean-object-1.1.2.tgz?cache=0&sync_timestamp=1628207133571&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-boolean-object%2Fdownload%2Fis-boolean-object-1.1.2.tgz", + "integrity": "sha1-XG3CACRt2TIa5LiFoRS7H3X2Nxk=", + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-callable": { + "version": "1.2.4", + "resolved": "https://registry.nlark.com/is-callable/download/is-callable-1.2.4.tgz?cache=0&sync_timestamp=1628259683451&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-callable%2Fdownload%2Fis-callable-1.2.4.tgz", + "integrity": "sha1-RzAdWN0CWUB4ZVR4U99tYf5HGUU=" + }, + "is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.nlark.com/is-date-object/download/is-date-object-1.0.5.tgz", + "integrity": "sha1-CEHVU25yTCVZe/bqYuG9OCmN8x8=", + "requires": { + "has-tostringtag": "^1.0.0" + } }, "is-extglob": { "version": "2.1.1", @@ -594,6 +770,14 @@ "integrity": "sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=", "dev": true }, + "is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.nlark.com/is-generator-function/download/is-generator-function-1.0.10.tgz?cache=0&sync_timestamp=1628227835267&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-generator-function%2Fdownload%2Fis-generator-function-1.0.10.tgz", + "integrity": "sha1-8VWLrxrBfg3up8BBXEODUf8rPHI=", + "requires": { + "has-tostringtag": "^1.0.0" + } + }, "is-glob": { "version": "4.0.1", "resolved": "https://registry.nlark.com/is-glob/download/is-glob-4.0.1.tgz", @@ -603,6 +787,65 @@ "is-extglob": "^2.1.1" } }, + "is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npm.taobao.org/is-nan/download/is-nan-1.3.2.tgz", + "integrity": "sha1-BDpUreoxdItVts1OCara+mm9nh0=", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + } + }, + "is-negative-zero": { + "version": "2.0.1", + "resolved": "https://registry.npm.taobao.org/is-negative-zero/download/is-negative-zero-2.0.1.tgz?cache=0&sync_timestamp=1607123314998&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-negative-zero%2Fdownload%2Fis-negative-zero-2.0.1.tgz", + "integrity": "sha1-PedGwY3aIxkkGlNnWQjY92bxHCQ=" + }, + "is-number-object": { + "version": "1.0.6", + "resolved": "https://registry.nlark.com/is-number-object/download/is-number-object-1.0.6.tgz", + "integrity": "sha1-anqvg4x/BoalC0VT9+VKlklOifA=", + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-regex": { + "version": "1.1.4", + "resolved": "https://registry.nlark.com/is-regex/download/is-regex-1.1.4.tgz", + "integrity": "sha1-7vVmPNWfpMCuM5UFMj32hUuxWVg=", + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-string": { + "version": "1.0.7", + "resolved": "https://registry.nlark.com/is-string/download/is-string-1.0.7.tgz", + "integrity": "sha1-DdEr8gBvJVu1j2lREO/3SR7rwP0=", + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.nlark.com/is-symbol/download/is-symbol-1.0.4.tgz?cache=0&sync_timestamp=1620501308896&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-symbol%2Fdownload%2Fis-symbol-1.0.4.tgz", + "integrity": "sha1-ptrJO2NbBjymhyI23oiRClevE5w=", + "requires": { + "has-symbols": "^1.0.2" + } + }, + "is-typed-array": { + "version": "1.1.8", + "resolved": "https://registry.nlark.com/is-typed-array/download/is-typed-array-1.1.8.tgz", + "integrity": "sha1-y6plhdx9tDMYvFuJUj6jhKb2Xnk=", + "requires": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "es-abstract": "^1.18.5", + "foreach": "^2.0.5", + "has-tostringtag": "^1.0.0" + } + }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npm.taobao.org/isexe/download/isexe-2.0.0.tgz", @@ -700,6 +943,36 @@ "resolved": "https://registry.nlark.com/node-fetch/download/node-fetch-2.6.2.tgz?cache=0&sync_timestamp=1630935314150&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fnode-fetch%2Fdownload%2Fnode-fetch-2.6.2.tgz", "integrity": "sha1-mGmWgYtzeF5HsZZcw06wk6HUZNA=" }, + "object-inspect": { + "version": "1.11.0", + "resolved": "https://registry.nlark.com/object-inspect/download/object-inspect-1.11.0.tgz", + "integrity": "sha1-nc6xRs7dQUig2eUauI00z1CZIrE=" + }, + "object-is": { + "version": "1.1.5", + "resolved": "https://registry.npm.taobao.org/object-is/download/object-is-1.1.5.tgz?cache=0&sync_timestamp=1613858420069&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fobject-is%2Fdownload%2Fobject-is-1.1.5.tgz", + "integrity": "sha1-ud7qpfx/GEag+uzc7sE45XePU6w=", + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + } + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npm.taobao.org/object-keys/download/object-keys-1.1.1.tgz", + "integrity": "sha1-HEfyct8nfzsdrwYWd9nILiMixg4=" + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npm.taobao.org/object.assign/download/object.assign-4.1.2.tgz?cache=0&sync_timestamp=1604115183005&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fobject.assign%2Fdownload%2Fobject.assign-4.1.2.tgz", + "integrity": "sha1-DtVKNC7Os3s4/3brgxoOeIy2OUA=", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.nlark.com/once/download/once-1.4.0.tgz", @@ -789,6 +1062,11 @@ "glob": "^7.1.3" } }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz", + "integrity": "sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY=" + }, "semver": { "version": "7.3.5", "resolved": "https://registry.nlark.com/semver/download/semver-7.3.5.tgz", @@ -813,6 +1091,16 @@ "integrity": "sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=", "dev": true }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npm.taobao.org/side-channel/download/side-channel-1.0.4.tgz", + "integrity": "sha1-785cj9wQTudRslxY1CkAEfpeos8=", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, "slice-ansi": { "version": "4.0.0", "resolved": "https://registry.nlark.com/slice-ansi/download/slice-ansi-4.0.0.tgz", @@ -867,6 +1155,24 @@ "strip-ansi": "^6.0.0" } }, + "string.prototype.trimend": { + "version": "1.0.4", + "resolved": "https://registry.npm.taobao.org/string.prototype.trimend/download/string.prototype.trimend-1.0.4.tgz", + "integrity": "sha1-51rpDClCxjUEaGwYsoe0oLGkX4A=", + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + } + }, + "string.prototype.trimstart": { + "version": "1.0.4", + "resolved": "https://registry.npm.taobao.org/string.prototype.trimstart/download/string.prototype.trimstart-1.0.4.tgz?cache=0&sync_timestamp=1614127318238&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstring.prototype.trimstart%2Fdownload%2Fstring.prototype.trimstart-1.0.4.tgz", + "integrity": "sha1-s2OZr0qymZtMnGSL16P7K7Jv7u0=", + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + } + }, "strip-ansi": { "version": "6.0.0", "resolved": "https://registry.nlark.com/strip-ansi/download/strip-ansi-6.0.0.tgz", @@ -946,6 +1252,17 @@ "integrity": "sha1-G/IH9LKPkVg2ZstfvTJ4hzAc1fQ=", "dev": true }, + "unbox-primitive": { + "version": "1.0.1", + "resolved": "https://registry.nlark.com/unbox-primitive/download/unbox-primitive-1.0.1.tgz", + "integrity": "sha1-CF4hViXsMWJXTciFmr7nilmxRHE=", + "requires": { + "function-bind": "^1.1.1", + "has-bigints": "^1.0.1", + "has-symbols": "^1.0.2", + "which-boxed-primitive": "^1.0.2" + } + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npm.taobao.org/uri-js/download/uri-js-4.4.1.tgz?cache=0&sync_timestamp=1610240086113&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Furi-js%2Fdownload%2Furi-js-4.4.1.tgz", @@ -955,6 +1272,19 @@ "punycode": "^2.1.0" } }, + "util": { + "version": "0.12.4", + "resolved": "https://registry.nlark.com/util/download/util-0.12.4.tgz?cache=0&sync_timestamp=1622213272480&other_urls=https%3A%2F%2Fregistry.nlark.com%2Futil%2Fdownload%2Futil-0.12.4.tgz", + "integrity": "sha1-ZhIaMUIN+PAcoMRkvhXfodGFAlM=", + "requires": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "safe-buffer": "^5.1.2", + "which-typed-array": "^1.1.2" + } + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npm.taobao.org/v8-compile-cache/download/v8-compile-cache-2.3.0.tgz", @@ -970,6 +1300,31 @@ "isexe": "^2.0.0" } }, + "which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npm.taobao.org/which-boxed-primitive/download/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha1-E3V7yJsgmwSf5dhkMOIc9AqJqOY=", + "requires": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + } + }, + "which-typed-array": { + "version": "1.1.7", + "resolved": "https://registry.nlark.com/which-typed-array/download/which-typed-array-1.1.7.tgz?cache=0&sync_timestamp=1630377722719&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fwhich-typed-array%2Fdownload%2Fwhich-typed-array-1.1.7.tgz", + "integrity": "sha1-J2F5m5oi1LhmCzwbQKuqdzlpF5M=", + "requires": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "es-abstract": "^1.18.5", + "foreach": "^2.0.5", + "has-tostringtag": "^1.0.0", + "is-typed-array": "^1.1.7" + } + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.nlark.com/word-wrap/download/word-wrap-1.2.3.tgz", diff --git a/src/connector/node-rest/package.json b/src/connector/node-rest/package.json index 1db7236efb..a190421634 100644 --- a/src/connector/node-rest/package.json +++ b/src/connector/node-rest/package.json @@ -7,15 +7,17 @@ "license": "MIT", "scripts": { "prepare": "npm run build", - "build": "esbuild --bundle --platform=node --outfile=lib/TDengineRest.js ./TDengineRest.js", - "build:dev": "esbuild --bundle --platform=node --outfile=dist/examples/show-database.js examples/show-database.js --watch", - "build:test": "esbuild test/testRestConn.js --bundle --platform=node --outfile=dist/tests/testRestConn.js --watch" + "build": "esbuild --bundle --platform=node --outfile=lib/TDengineRest.js ./TDengineRest.js" , + "build:dev": "esbuild --bundle --platform=node --outfile=dist/examples/show-database.js examples/show-database.js ", + "build:test": "esbuild test/testRestConn.js --bundle --platform=node --outfile=dist/tests/testRestConn.js ", + "test": "node dist/tests/testRestConn.js" }, "devDependencies": { "esbuild": "^0.12.25", "eslint": "^7.32.0" }, "dependencies": { + "assert": "^2.0.0", "node-fetch": "^2.x" } } diff --git a/src/connector/node-rest/src/restCursor.js b/src/connector/node-rest/src/restCursor.js index 204919dabf..beb712f177 100644 --- a/src/connector/node-rest/src/restCursor.js +++ b/src/connector/node-rest/src/restCursor.js @@ -52,15 +52,15 @@ export class TDengineRestCursor { body: sql, headers: {'Authorization': this._token()} }) - if (response.status >= 200 && response.status < 300) { - - return new TDengineRestResultSet(await response.json()) - } else { - throw new Error(response.statusText) - } + // if (response.status == 'succ') { + return await new TDengineRestResultSet(await response.json()) + // } else { + // throw new Error(response.desc) + // } } catch (e) { console.log("Request Failed " + e) } + } +} -} \ No newline at end of file diff --git a/src/connector/node-rest/src/restResult.js b/src/connector/node-rest/src/restResult.js index 8767394228..ba469eb4ec 100644 --- a/src/connector/node-rest/src/restResult.js +++ b/src/connector/node-rest/src/restResult.js @@ -77,9 +77,13 @@ export class TDengineRestResultSet { toString() { - let fields = this.column_type - let rows = this.data - this._prettyStr(fields, rows) + if(this.status === 'succ'){ + let fields = this.column_type + let rows = this.data + this._prettyStr(fields, rows) + }else{ + console.log(this.status+":"+this.desc) + } } _prettyStr(fields, data) { diff --git a/src/connector/node-rest/test/testRestConn.js b/src/connector/node-rest/test/testRestConn.js index 6abad75ab3..80558f4621 100644 --- a/src/connector/node-rest/test/testRestConn.js +++ b/src/connector/node-rest/test/testRestConn.js @@ -1,16 +1,13 @@ import {TDRestConnection} from "../TDengineRest"; +import assert from "assert" -let conn = new TDRestConnection({host: 'u195', user: 'root', pass: 'taosdata', port: 6041}); +let conn = new TDRestConnection({host: 'u195:q' + + ':', user: 'root', pass: 'taosdata', port: 6041}); let cursor = conn.cursor(); -// (async () => { -// result = await cursor.query("drop database if exists node_rest").catch(e=>console.log(e)) -// result.toString() -// })() - -const createDB = "create database if not exists node_rest"; +const createDB = "create database if not exists node_rest"; const dropDB = "drop database if exists node_rest"; -const createTBL = "CREATE STABLE if not exists node_rest.meters3 (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)"; +const createTBL = "CREATE STABLE if not exists node_rest.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)"; const dropTBL = "drop table if exists node_rest.meters "; const insert = "INSERT INTO node_rest.d1001 USING node_rest.meters TAGS (\"Beijng.Chaoyang\", 2) VALUES (now, 10.2, 219, 0.32) "; const select = "select * from node_rest.d1001 "; @@ -18,9 +15,15 @@ const selectStbl = "select * from node_rest.meters"; async function execute(sql) { console.log("SQL:" + sql); - result = await cursor.query(sql); - result.toString() -}; + let result = await cursor.query(sql); + try { + assert.strictEqual(result.getStatus(), 'succ', new Error("response error")) + result.toString() + } catch (e) { + console.log(e) + } + +} (async () => { await execute(createDB); @@ -30,3 +33,8 @@ async function execute(sql) { await execute(selectStbl); await execute(dropDB); })() + +// (async () => { +// result = await cursor.query("drop database if exists node_rest").catch(e=>console.log(e)) +// result.toString() +// })() -- GitLab